Allow applicationId to be specified on build

Summary:
Added the ability to define a specific applicationId (in case it's different to the package name)

<details>
  Thanks for submitting a PR! Please read these instructions carefully:

  - [x] Explain the **motivation** for making this change.
  - [ ] Provide a **test plan** demonstrating that the code is solid.
  - [x] Match the **code formatting** of the rest of the codebase.
  - [x] Target the `master` branch, NOT a "stable" branch.

  Please read the [Contribution Guidelines](https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md) to learn more about contributing to React Native.
</details>

We have a specific requirement that our package name differs from the applicationId but not in a way that allows us to add it as a suffix to our package name. I wanted to add the option to specify a specific applicationId.

`react-native run-android --appId <Specific Application Id>`
Closes https://github.com/facebook/react-native/pull/14524

Differential Revision: D5910259

Pulled By: shergin

fbshipit-source-id: 768fbc910f6b520dd18936f6bceeee136fca7025
This commit is contained in:
Rajesh Singh 2017-09-26 00:02:58 -07:00 committed by Facebook Github Bot
parent c70ac24966
commit 979629504b
1 changed files with 15 additions and 1 deletions

View File

@ -88,6 +88,16 @@ function tryRunAdbReverse(packagerPort, device) {
}
}
function getPackageNameWithSuffix(appId, appIdSuffix, packageName) {
if (appId) {
return appId;
} else if (appIdSuffix) {
return packageName + '.' + appIdSuffix;
}
return packageName;
}
// Builds the app and runs it on a connected emulator / device.
function buildAndRun(args) {
process.chdir(path.join(args.root, 'android'));
@ -100,7 +110,7 @@ function buildAndRun(args) {
'utf8'
).match(/package="(.+?)"/)[1];
const packageNameWithSuffix = args.appIdSuffix ? packageName + '.' + args.appIdSuffix : packageName;
const packageNameWithSuffix = getPackageNameWithSuffix(args.appId, args.appIdSuffix, packageName);
const adbPath = getAdbPath();
if (args.deviceId) {
@ -302,6 +312,10 @@ module.exports = {
command: '--appFolder [string]',
description: 'Specify a different application folder name for the android source.',
default: 'app',
}, {
command: '--appId [string]',
description: 'Specify an applicationId to launch after build.',
default: '',
}, {
command: '--appIdSuffix [string]',
description: 'Specify an applicationIdSuffix to launch after build.',