* Get and use LaunchPackageName in place of pacakageNameWithSuffix
Build system may alter application id for build and flavor purposes. This commit alters the system to not need a packageNameWithSuffix, but instead pull the launch package name directly from the merged manifest and use that to launch it on the device.
* cleanup getLaunchPackageName into it's own file
* Cleanup style
* Added flowtyping to getLaunchPackageName, added a jest test for it.
Also fixed some faulty RegExps as a result of testing.
* Fix grammar in comment
* Move sample files for test to __fixtures__
* Update paths to be OS-agnostic
* Tests passing, barring Windows pathing issue with snapshot
* build flavor test
* move code to platform-android
* reuse test helpers
* fix typescript
* Convert tests to typescript - part 1
* Update index.ts
Co-authored-by: Michał Pierzchała <[email protected]>
Co-authored-by: Chris Fanti <[email protected]>
* 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 <[email protected]>
* 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 <[email protected]>
* chore: cleanup run-android implementation
* feat: overhaul gradle install errors
* fix copying executables by bringing back chmod
* rename 'installDebug' -> 'task'
* cleanup unused args from refactor
* use inherit and don't show null error
* simplify creating gradle args
* adjust descriptions
* use logger
* Add support for multiple tasks
* Change function name to match current functionality
* Change task to tasks
* fix: typos in Autolinking & use same repo for both examples
* structure new files
* Add documentation for plugins and update naming in one place
* Update index.js
* Fix flow and update docs
* Update
* Prefix
* Updates
* Take advantage of Joi
* Update docs/plugins.md
Co-Authored-By: grabbou <[email protected]>
* Update docs/plugins.md
Co-Authored-By: grabbou <[email protected]>
* Some other tweaks
* Placeholder for dependency
* Updates
* Delete linking.md
* fix tests
* Put `isPackagerRunning` function on `cli-tools` to share between iOS & Android
* Fix `terminal` argument not working when not being provided
* Fallback to the default terminal of the machine when starting the packager on `run-android`
* Delete `isPackagerRunning` as it was moved to `tools`
* Add `terminal` argument to `run-ios`
* Launch Metro from within the `runIOS` command
* Remove code & add `—terminal` argument
* Try using `REACT_TERMINAL` before the default terminal
* Put `isPackagerRunning` function on `cli-tools` to share between iOS & Android
* Fix `terminal` argument not working when not being provided
* Fallback to the default terminal of the machine when starting the packager on `run-android`
* Delete `isPackagerRunning` as it was moved to `tools`
* Add `terminal` argument to `run-ios`
* Launch Metro from within the `runIOS` command
* Remove code & add `—terminal` argument
* Try using `REACT_TERMINAL` before the default terminal
* Add tool function to get the default user terminal
* Fix `terminal` arg type
* Remove spread and specify entry twice instead
* Improve `args` being passed through functions
* Reduce code duplication
* Put `device` and `udid` variable up in the scope
Summary:
---------
If we run `react-native run-android` while it's already installed, it will fail with the following error.
```bash
info Installing the app on the device (cd android && adb -s emulator-5554 install app/build/outputs/apk/debug/app-x86-debug.apk
adb: failed to install app/build/outputs/apk/debug/app-x86-debug.apk: Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install me.mycake without first uninstalling.]
```
In the development phase, I think using adb's install options below is much more efficient.
```
-r : Reinstall an existing app, keeping its data.
-d : Allow version code downgrade.
```
Test Plan:
----------
Not required.
* chore: move shared types to root; moar link styles; bye promiseWaterfall
* fix test
* add alias for global types
* bump Flow to 0.97
* add lint annotation to bin
* enable babel module resolver plugin
* import inquirer prompt type
* wip
* Finish it up
* Clean up packages
* Move files around
* Simplify regex
* Remove unused type
* Move packages around
* Fix type
* Update snapshot
* Make snapshot even smaller
* Throw unlink error
* feat: infer packageName and projectName for upgrade from config
* extract merge to tools and use it in tests
* warn if unsupported platform is being upgraded
Summary:
---------
Historically, Android and iOS platform were hardcoded inside CLI and provided by default. Then, other packages could export additional platforms on top of it.
React Native as a platform was hardcoded in Metro configuration (default platforms, default extensions) and inside link. That means all new features were always developed with these platforms in mind, leaving others behind. We often used private APIs, which made things more complicated for 3rd party platform developers.
From this PR on, there's no longer concept of an out-of-tree platform inside of the CLI. In a follow up PR to React Native, I am going to configure iOS and Android platforms inside React Native, just like React Native Windows exposes Windows platform.
This will open room for improvements and should make it even easier for the CLI to welcome other platforms.