Skip to content

Conversation

@thecodrr
Copy link
Contributor

@thecodrr thecodrr commented Aug 3, 2019

Summary:

This is a work in progress and might take more than a little time.

These checks should add a little more context (and actionable output) when the script fails and reduce the number of false issues. All these handle potential points of failure e.g. invalid arguments, typos in provided file/dir paths or directories that no longer exist.

Adding a list here of all the commands that need to checked.

CLI

  • init [done]
  • bundle - [done]
  • config [no need]
  • info [no need]
  • install [done]
  • link [done]
  • upgrade [done]

Android

  • log-android [no need]
  • run-android [done but not tested]
  • link [no need]
  • config [no need]

Test Plan:

Only way to test is by failing all the checks one by one. 😆 Maybe more jest tests can be added to assure these comply?

Copy link
Member

@thymikee thymikee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice work here, appreciate it! Here's some early feedback

@thecodrr
Copy link
Contributor Author

thecodrr commented Aug 5, 2019

@thymikee Thank you!

A question: I have not been able to test the platform-android code. Is there a simple way I can run it and check the error outputs?

@thymikee
Copy link
Member

thymikee commented Aug 5, 2019

You need to yarn link @react-native-community/cli-platform-android in the test project

@thecodrr
Copy link
Contributor Author

thecodrr commented Aug 6, 2019

@thymikee I am done with this, please review.

@thecodrr thecodrr changed the title WIP: Add proper error checks with human readable outputs Add proper error checks with human readable outputs Aug 6, 2019
Copy link
Member

@grabbou grabbou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the direction this PR is moving. Is it already ready to be reviewed or merged? I left few comments and I am wondering what would be the next step now (it's been a while)

@thecodrr
Copy link
Contributor Author

@grabbou thanks. Yes this is done and ready to be reviewed. I may have left some errors out (intentionally) because they don't make sense or slow down the performance.

@grabbou
Copy link
Member

grabbou commented Oct 1, 2019

Uhm, looks like we have moved on with Typescript and other PRs in the meantime (unintentionally), making conflicts with this PR.

I do really like it and was wondering if you'd be open to rebasing and preparing it for merging once again?

@thecodrr
Copy link
Contributor Author

thecodrr commented Oct 5, 2019

@grabbou Okay I will begin the work ASAP.

@thymikee thymikee force-pushed the properly-handle-template-errors branch from 3cb73bc to 06b9cec Compare October 11, 2019 14:07
@thymikee
Copy link
Member

@thecodrr I took a stab at it and rebased your work. Please review if I didn't mess anything up :)

@thymikee thymikee changed the title Add proper error checks with human readable outputs feat: better error messages with human readable outputs Oct 11, 2019
@thecodrr
Copy link
Contributor Author

@thymikee Everything looks perfect. : )

@thecodrr
Copy link
Contributor Author

@thymikee ping

@thymikee thymikee force-pushed the properly-handle-template-errors branch from 06b9cec to 879f9b8 Compare November 28, 2019 16:00
Copy link
Member

@grabbou grabbou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff! Did you like CLIError? I spent a bit of time working on this abstraction and I am happy that you found it useful here!

@grabbou grabbou merged commit 2e3302e into react-native-community:master Jan 30, 2020
grabbou pushed a commit that referenced this pull request Feb 5, 2020
* refactor: properly handle invalid template package

* refactor: error checks when getting template name

* refactor: remove duplicate exception throw

* refactor: check if assets dest exists

* refactor: add error checks when upgrading

* chore: add comment for using process.exit()

* refactor: improve error outputs in link command

* refactor: use for of loop

* refactor: check package before uninstalling

* refactor: use CLIError instead of direct exit

* refactor: handle potential android pkg name errors

* refactor: fix typos/mistakes in error outputs

* refactor: add adb & android sdk path checks

* refactor: fix imports

* refactor: improve install apk error outputs

* Apply suggestions from code review

Co-Authored-By: Michał Pierzchała <thymikee@gmail.com>

* refactor: add init doc link in error output

* test: make sure all tests pass

* refactor: use try/catch around readFileSync

* refactor: do not read build.gradle twice

* refactor: clean up code in android linking

* fix: packageJson not defined in templateName

* refactor: remove unintentional --verbose flag

* refactor: make flow very happy

* refactor: remove unnecessary variable definition

* pkgjson undefined tweak

* eslint fix

* remove adb/android_home checks because we have doctor

* use mockImplementationOnce

* revert link changes, as it's going to be removed in next version

* inline fns

* revert uninstall changes as we're removing that in next version

* adjust copy

* mock existsSync once

* remove unused code

Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
return Promise.resolve();
}

if (!fs.existsSync(assetsDest)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @thecodrr @thymikee @grabbou,
I have a situation that I need to run bundle and copy assets into new created folder based on assetsDest and I was relying on https://github.com/react-native-community/cli/pull/609/files#diff-e59437386ac414095e6ed43a3da37303R93 to create folder if not exists.
Any specific reason that it needs to check assetsDest first before copying assets?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are calling mkdirp in the copy function, maybe this is no longer needed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, i think it should be safe using mkdirp before copy files

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this check can be safely removed then. What do you think @thymikee?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @thecodrr @thymikee will open the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants