Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save stigi/19427e116e049e5043854a3db33db483 to your computer and use it in GitHub Desktop.
Save stigi/19427e116e049e5043854a3db33db483 to your computer and use it in GitHub Desktop.
Patch file causing problems with `patch-package` on windows
diff --git a/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.d.ts b/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.d.ts
index 54ed145..02dbbf4 100644
--- a/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.d.ts
+++ b/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.d.ts
@@ -2,7 +2,8 @@ import { Config } from '@react-native-community/cli-types';
export interface Flags {
tasks?: Array<string>;
root: string;
- variant: string;
+ flavor: string;
+ type: string;
appFolder: string;
appId: string;
appIdSuffix: string;
diff --git a/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.d.ts.map b/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.d.ts.map
index 5af694d..c5f4d8f 100644
--- a/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.d.ts.map
+++ b/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.d.ts.map
@@ -1 +1 @@
-{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/runAndroid/index.ts"],"names":[],"mappings":"AAWA,OAAO,EAAC,MAAM,EAAC,MAAM,mCAAmC,CAAC;AA6BzD,MAAM,WAAW,KAAK;IACpB,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAID;;GAEG;AACH,iBAAe,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,iBA8C1E;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+MD,wBAsEE"}
\ No newline at end of file
+{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/runAndroid/index.ts"],"names":[],"mappings":"AAWA,OAAO,EAAC,MAAM,EAAC,MAAM,mCAAmC,CAAC;AA6BzD,MAAM,WAAW,KAAK;IACpB,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAID;;GAEG;AACH,iBAAe,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,iBA8C1E;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoND,wBA0EE"}
\ No newline at end of file
diff --git a/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js b/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js
index 30aa14f..5091b40 100644
--- a/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js
+++ b/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js
@@ -159,7 +159,7 @@ function runOnSpecificDevice(args, gradlew, packageName, adbPath, androidProject
if (devices.length > 0 && deviceId) {
if (devices.indexOf(deviceId) !== -1) {
- buildApk(gradlew, androidProject.sourceDir);
+ buildApk(gradlew, androidProject.sourceDir, args, androidProject);
installAndLaunchOnDevice(args, deviceId, packageName, adbPath, androidProject);
} else {
_cliTools().logger.error(`Could not find device with the id: "${deviceId}". Please choose one of the following:`, ...devices);
@@ -169,10 +169,30 @@ function runOnSpecificDevice(args, gradlew, packageName, adbPath, androidProject
}
}
-function buildApk(gradlew, sourceDir) {
+function getTaskNames(appName, commands) {
+ return appName ? commands.map(command => `${appName}:${command}`) : commands;
+}
+
+function toPascalCase(value) {
+ return value !== '' ? value[0].toUpperCase() + value.slice(1) : value;
+}
+
+function buildApk(gradlew, sourceDir, args, androidProject) {
try {
- // using '-x lint' in order to ignore linting errors while building the apk
- const gradleArgs = ['build', '-x', 'lint'];
+ let installTask = 'install';
+ const buildType = toPascalCase(args.type) || 'Debug';
+
+ if (args.flavor) {
+ installTask += toPascalCase(args.flavor);
+ }
+
+ installTask += buildType;
+ const tasks = args.tasks || [installTask];
+ const gradleArgs = getTaskNames(args.appFolder || androidProject.appName, tasks);
+
+ if (args.port != null) {
+ gradleArgs.push('-PreactNativeDevServerPort=' + args.port);
+ }
_cliTools().logger.info('Building the app...');
@@ -194,14 +214,22 @@ function tryInstallAppOnDevice(args, adbPath, device, androidProject) {
appName,
sourceDir
} = androidProject;
- const {
- appFolder
- } = args;
- const variant = args.variant.toLowerCase();
- const buildDirectory = `${sourceDir}/${appName}/build/outputs/apk/${variant}`;
- const apkFile = getInstallApkName(appFolder || appName, // TODO: remove appFolder
- adbPath, variant, device, buildDirectory);
- const pathToApk = `${buildDirectory}/${apkFile}`;
+ const buildType = args.type || 'debug';
+ let buildDirectory = `${sourceDir}/${appName}/build/outputs/apk`;
+
+ if (args.flavor) {
+ buildDirectory += `/${args.flavor}`;
+ }
+
+ buildDirectory += `/${buildType}`;
+ let apkFileName = 'app';
+
+ if (args.flavor) {
+ apkFileName += `-${args.flavor}`;
+ }
+
+ apkFileName += `-${buildType}.apk`;
+ const pathToApk = `${buildDirectory}/${apkFileName}`;
const adbArgs = ['-s', device, 'install', '-r', '-d', pathToApk];
_cliTools().logger.info(`Installing the app on the device "${device}"...`);
@@ -216,28 +244,6 @@ function tryInstallAppOnDevice(args, adbPath, device, androidProject) {
}
}
-function getInstallApkName(appName, adbPath, variant, device, buildDirectory) {
- const availableCPUs = _adb.default.getAvailableCPUs(adbPath, device); // check if there is an apk file like app-armeabi-v7a-debug.apk
-
-
- for (const availableCPU of availableCPUs.concat('universal')) {
- const apkName = `${appName}-${availableCPU}-${variant}.apk`;
-
- if (_fs().default.existsSync(`${buildDirectory}/${apkName}`)) {
- return apkName;
- }
- } // check if there is a default file like app-debug.apk
-
-
- const apkName = `${appName}-${variant}.apk`;
-
- if (_fs().default.existsSync(`${buildDirectory}/${apkName}`)) {
- return apkName;
- }
-
- throw new (_cliTools().CLIError)('Could not find the correct install APK file.');
-}
-
function installAndLaunchOnDevice(args, selectedDevice, packageName, adbPath, androidProject) {
(0, _tryRunAdbReverse.default)(args.port, selectedDevice);
tryInstallAppOnDevice(args, adbPath, selectedDevice, androidProject);
@@ -320,8 +326,11 @@ var _default = {
description: '[DEPRECATED - root is discovered automatically] Override the root directory for the android build (which contains the android directory)',
default: ''
}, {
- name: '--variant <string>',
- description: "Specify your app's build variant",
+ name: '--flavor <string>',
+ description: "Specify your app's build flavor"
+ }, {
+ name: '--type <string>',
+ description: "Specify your app's build type",
default: 'debug'
}, {
name: '--appFolder <string>',
diff --git a/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js.map b/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js.map
index 5fc16f8..5a68ccc 100644
--- a/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js.map
+++ b/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js.map
@@ -1 +1 @@
-{"version":3,"sources":["../../../src/commands/runAndroid/index.ts"],"names":["displayWarnings","config","args","appFolder","logger","warn","root","runAndroid","_argv","androidProject","jetifier","info","chalk","bold","dim","require","resolve","stdio","error","CLIError","packager","buildAndRun","port","then","result","startServerInNewWindow","terminal","reactNativePath","message","process","chdir","sourceDir","cmd","platform","startsWith","packageName","adbPath","deviceId","runOnSpecificDevice","gradlew","devices","adb","getDevices","length","indexOf","buildApk","installAndLaunchOnDevice","gradleArgs","debug","join","execa","sync","cwd","tryInstallAppOnDevice","device","appName","variant","toLowerCase","buildDirectory","apkFile","getInstallApkName","pathToApk","adbArgs","availableCPUs","getAvailableCPUs","availableCPU","concat","apkName","fs","existsSync","selectedDevice","isWindows","test","scriptFile","packagerEnvFilename","portExportContent","launchPackagerScript","path","scriptsDir","dirname","packagerEnvFile","procConfig","writeFileSync","encoding","flag","detached","name","description","func","options","default","env","RCT_METRO_PORT","parse","Number","val","split"],"mappings":";;;;;;;AAOA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAMA;;AACA;;;;AAxBA;;;;;;;AA0BA,SAASA,eAAT,CAAyBC,MAAzB,EAAyCC,IAAzC,EAAsD;AACpD,4CAA4BD,MAA5B;;AACA,MAAIC,IAAI,CAACC,SAAT,EAAoB;AAClBC,uBAAOC,IAAP,CACE,uGADF;AAGD;;AACD,MAAIH,IAAI,CAACI,IAAT,EAAe;AACbF,uBAAOC,IAAP,CACE,iJADF;AAGD;AACF;;AAmBD;;;AAGA,eAAeE,UAAf,CAA0BC,KAA1B,EAAgDP,MAAhD,EAAgEC,IAAhE,EAA6E;AAC3EF,EAA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HAHJ;AAIEG,IAAAA,OAAO,EAAE;AAJX,GAjBO,EAuBP;AACEJ,IAAAA,IAAI,EAAE,wBADR;AAEEC,IAAAA,WAAW,EAAE,uDAFf;AAGEG,IAAAA,OAAO,EAAE;AAHX,GAvBO,EA4BP;AACEJ,IAAAA,IAAI,EAAE,0BADR;AAEEC,IAAAA,WAAW,EAAE,+BAFf;AAGEG,IAAAA,OAAO,EAAE;AAHX,GA5BO,EAiCP;AACEJ,IAAAA,IAAI,EAAE,qBADR;AAEEC,IAAAA,WAAW,EACT,2EACA;AAJJ,GAjCO,EAuCP;AACED,IAAAA,IAAI,EAAE,eADR;AAEEC,IAAAA,WAAW,EAAE;AAFf,GAvCO,EA2CP;AACED,IAAAA,IAAI,EAAE,iBADR;AAEEI,IAAAA,OAAO,EAAE7D,OAAO,CAAC8D,GAAR,CAAYC,cAAZ,IAA8B,IAFzC;AAGEC,IAAAA,KAAK,EAAEC;AAHT,GA3CO,EAgDP;AACER,IAAAA,IAAI,EAAE,qBADR;AAEEC,IAAAA,WAAW,EACT,+EAHJ;AAIEG,IAAAA,OAAO,EAAE;AAJX,GAhDO,EAsDP;AACEJ,IAAAA,IAAI,EAAE,gBADR;AAEEC,IAAAA,WAAW,EAAE,0DAFf;AAGEM,IAAAA,KAAK,EAAGE,GAAD,IAAiBA,GAAG,CAACC,KAAJ,CAAU,GAAV;AAH1B,GAtDO,EA2DP;AACEV,IAAAA,IAAI,EAAE,eADR;AAEEC,IAAAA,WAAW,EACT;AAHJ,GA3DO;AALI,C","sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nimport path from 'path';\nimport execa from 'execa';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport {Config} from '@react-native-community/cli-types';\nimport adb from './adb';\nimport runOnAllDevices from './runOnAllDevices';\nimport tryRunAdbReverse from './tryRunAdbReverse';\nimport tryLaunchAppOnDevice from './tryLaunchAppOnDevice';\nimport getAdbPath from './getAdbPath';\nimport {\n isPackagerRunning,\n logger,\n getDefaultUserTerminal,\n CLIError,\n} from '@react-native-community/cli-tools';\nimport warnAboutManuallyLinkedLibs from '../../link/warnAboutManuallyLinkedLibs';\nimport {getAndroidProject, getPackageName} from '../../utils/getAndroidProject';\n\nfunction displayWarnings(config: Config, args: Flags) {\n warnAboutManuallyLinkedLibs(config);\n if (args.appFolder) {\n logger.warn(\n 'Using deprecated \"--appFolder\" flag. Use \"project.android.appName\" in react-native.config.js instead.',\n );\n }\n if (args.root) {\n logger.warn(\n 'Using deprecated \"--root\" flag. App root is discovered automatically. Alternatively, set \"project.android.sourceDir\" in react-native.config.js.',\n );\n }\n}\n\nexport interface Flags {\n tasks?: Array<string>;\n root: string;\n variant: string;\n appFolder: string;\n appId: string;\n appIdSuffix: string;\n mainActivity: string;\n deviceId?: string;\n packager: boolean;\n port: number;\n terminal: string;\n jetifier: boolean;\n}\n\ntype AndroidProject = NonNullable<Config['project']['android']>;\n\n/**\n * Starts the app on a connected Android emulator or device.\n */\nasync function runAndroid(_argv: Array<string>, config: Config, args: Flags) {\n displayWarnings(config, args);\n const androidProject = getAndroidProject(config);\n\n if (args.jetifier) {\n logger.info(\n `Running ${chalk.bold(\n 'jetifier',\n )} to migrate libraries to AndroidX. ${chalk.dim(\n 'You can disable it using \"--no-jetifier\" flag.',\n )}`,\n );\n\n try {\n await execa(require.resolve('jetifier/bin/jetify'), {stdio: 'inherit'});\n } catch (error) {\n throw new CLIError('Failed to run jetifier.', error);\n }\n }\n\n if (!args.packager) {\n return buildAndRun(args, androidProject);\n }\n\n return isPackagerRunning(args.port).then((result: string) => {\n if (result === 'running') {\n logger.info('JS server already running.');\n } else if (result === 'unrecognized') {\n logger.warn('JS server not recognized, continuing with build...');\n } else {\n // result == 'not_running'\n logger.info('Starting JS server...');\n try {\n startServerInNewWindow(\n args.port,\n args.terminal,\n config.reactNativePath,\n );\n } catch (error) {\n logger.warn(\n `Failed to automatically start the packager server. Please run \"react-native start\" manually. Error details: ${error.message}`,\n );\n }\n }\n return buildAndRun(args, androidProject);\n });\n}\n\n// Builds the app and runs it on a connected emulator / device.\nfunction buildAndRun(args: Flags, androidProject: AndroidProject) {\n process.chdir(androidProject.sourceDir);\n const cmd = process.platform.startsWith('win') ? 'gradlew.bat' : './gradlew';\n\n const {appFolder} = args;\n const packageName = getPackageName(androidProject, appFolder);\n\n const adbPath = getAdbPath();\n if (args.deviceId) {\n return runOnSpecificDevice(args, cmd, packageName, adbPath, androidProject);\n } else {\n return runOnAllDevices(args, cmd, packageName, adbPath, androidProject);\n }\n}\n\nfunction runOnSpecificDevice(\n args: Flags,\n gradlew: 'gradlew.bat' | './gradlew',\n packageName: string,\n adbPath: string,\n androidProject: AndroidProject,\n) {\n const devices = adb.getDevices(adbPath);\n const {deviceId} = args;\n if (devices.length > 0 && deviceId) {\n if (devices.indexOf(deviceId) !== -1) {\n buildApk(gradlew, androidProject.sourceDir);\n installAndLaunchOnDevice(\n args,\n deviceId,\n packageName,\n adbPath,\n androidProject,\n );\n } else {\n logger.error(\n `Could not find device with the id: \"${deviceId}\". Please choose one of the following:`,\n ...devices,\n );\n }\n } else {\n logger.error('No Android device or emulator connected.');\n }\n}\n\nfunction buildApk(gradlew: string, sourceDir: string) {\n try {\n // using '-x lint' in order to ignore linting errors while building the apk\n const gradleArgs = ['build', '-x', 'lint'];\n logger.info('Building the app...');\n logger.debug(`Running command \"${gradlew} ${gradleArgs.join(' ')}\"`);\n execa.sync(gradlew, gradleArgs, {stdio: 'inherit', cwd: sourceDir});\n } catch (error) {\n throw new CLIError('Failed to build the app.', error);\n }\n}\n\nfunction tryInstallAppOnDevice(\n args: Flags,\n adbPath: string,\n device: string,\n androidProject: AndroidProject,\n) {\n try {\n // \"app\" is usually the default value for Android apps with only 1 app\n const {appName, sourceDir} = androidProject;\n const {appFolder} = args;\n const variant = args.variant.toLowerCase();\n const buildDirectory = `${sourceDir}/${appName}/build/outputs/apk/${variant}`;\n const apkFile = getInstallApkName(\n appFolder || appName, // TODO: remove appFolder\n adbPath,\n variant,\n device,\n buildDirectory,\n );\n\n const pathToApk = `${buildDirectory}/${apkFile}`;\n const adbArgs = ['-s', device, 'install', '-r', '-d', pathToApk];\n logger.info(`Installing the app on the device \"${device}\"...`);\n logger.debug(\n `Running command \"cd android && adb -s ${device} install -r -d ${pathToApk}\"`,\n );\n execa.sync(adbPath, adbArgs, {stdio: 'inherit'});\n } catch (error) {\n throw new CLIError('Failed to install the app on the device.', error);\n }\n}\n\nfunction getInstallApkName(\n appName: string,\n adbPath: string,\n variant: string,\n device: string,\n buildDirectory: string,\n) {\n const availableCPUs = adb.getAvailableCPUs(adbPath, device);\n\n // check if there is an apk file like app-armeabi-v7a-debug.apk\n for (const availableCPU of availableCPUs.concat('universal')) {\n const apkName = `${appName}-${availableCPU}-${variant}.apk`;\n if (fs.existsSync(`${buildDirectory}/${apkName}`)) {\n return apkName;\n }\n }\n\n // check if there is a default file like app-debug.apk\n const apkName = `${appName}-${variant}.apk`;\n if (fs.existsSync(`${buildDirectory}/${apkName}`)) {\n return apkName;\n }\n\n throw new CLIError('Could not find the correct install APK file.');\n}\n\nfunction installAndLaunchOnDevice(\n args: Flags,\n selectedDevice: string,\n packageName: string,\n adbPath: string,\n androidProject: AndroidProject,\n) {\n tryRunAdbReverse(args.port, selectedDevice);\n tryInstallAppOnDevice(args, adbPath, selectedDevice, androidProject);\n tryLaunchAppOnDevice(selectedDevice, packageName, adbPath, args);\n}\n\nfunction startServerInNewWindow(\n port: number,\n terminal: string,\n reactNativePath: string,\n) {\n /**\n * Set up OS-specific filenames and commands\n */\n const isWindows = /^win/.test(process.platform);\n const scriptFile = isWindows\n ? 'launchPackager.bat'\n : 'launchPackager.command';\n const packagerEnvFilename = isWindows ? '.packager.bat' : '.packager.env';\n const portExportContent = isWindows\n ? `set RCT_METRO_PORT=${port}`\n : `export RCT_METRO_PORT=${port}`;\n\n /**\n * Set up the `.packager.(env|bat)` file to ensure the packager starts on the right port.\n */\n const launchPackagerScript = path.join(\n reactNativePath,\n `scripts/${scriptFile}`,\n );\n\n /**\n * Set up the `launchpackager.(command|bat)` file.\n * It lives next to `.packager.(bat|env)`\n */\n const scriptsDir = path.dirname(launchPackagerScript);\n const packagerEnvFile = path.join(scriptsDir, packagerEnvFilename);\n const procConfig: execa.SyncOptions = {cwd: scriptsDir};\n\n /**\n * Ensure we overwrite file by passing the `w` flag\n */\n fs.writeFileSync(packagerEnvFile, portExportContent, {\n encoding: 'utf8',\n flag: 'w',\n });\n\n if (process.platform === 'darwin') {\n try {\n return execa.sync(\n 'open',\n ['-a', terminal, launchPackagerScript],\n procConfig,\n );\n } catch (error) {\n return execa.sync('open', [launchPackagerScript], procConfig);\n }\n }\n if (process.platform === 'linux') {\n try {\n return execa.sync(terminal, ['-e', `sh ${launchPackagerScript}`], {\n ...procConfig,\n detached: true,\n });\n } catch (error) {\n // By default, the child shell process will be attached to the parent\n return execa.sync('sh', [launchPackagerScript], procConfig);\n }\n }\n if (/^win/.test(process.platform)) {\n // Awaiting this causes the CLI to hang indefinitely, so this must execute without await.\n return execa('cmd.exe', ['/C', launchPackagerScript], {\n ...procConfig,\n detached: true,\n stdio: 'ignore',\n });\n }\n logger.error(\n `Cannot start the packager. Unknown platform ${process.platform}`,\n );\n return;\n}\n\nexport default {\n name: 'run-android',\n description:\n 'builds your app and starts it on a connected Android emulator or device',\n func: runAndroid,\n options: [\n {\n name: '--root <string>',\n description:\n '[DEPRECATED - root is discovered automatically] Override the root directory for the android build (which contains the android directory)',\n default: '',\n },\n {\n name: '--variant <string>',\n description: \"Specify your app's build variant\",\n default: 'debug',\n },\n {\n name: '--appFolder <string>',\n description:\n '[DEPRECATED – use \"project.android.appName\" in react-native.config.js] Specify a different application folder name for the android source. If not, we assume is \"app\"',\n },\n {\n name: '--appId <string>',\n description:\n 'Specify an applicationId to launch after build. If not specified, `package` from AndroidManifest.xml will be used.',\n default: '',\n },\n {\n name: '--appIdSuffix <string>',\n description: 'Specify an applicationIdSuffix to launch after build.',\n default: '',\n },\n {\n name: '--main-activity <string>',\n description: 'Name of the activity to start',\n default: 'MainActivity',\n },\n {\n name: '--deviceId <string>',\n description:\n 'builds your app and starts it on a specific device/simulator with the ' +\n 'given device id (listed by running \"adb devices\" on the command line).',\n },\n {\n name: '--no-packager',\n description: 'Do not launch packager while building',\n },\n {\n name: '--port <number>',\n default: process.env.RCT_METRO_PORT || 8081,\n parse: Number,\n },\n {\n name: '--terminal <string>',\n description:\n 'Launches the Metro Bundler in a new window using the specified terminal path.',\n default: getDefaultUserTerminal(),\n },\n {\n name: '--tasks <list>',\n description: 'Run custom Gradle tasks. By default it\\'s \"installDebug\"',\n parse: (val: string) => val.split(','),\n },\n {\n name: '--no-jetifier',\n description:\n 'Do not run \"jetifier\" – the AndroidX transition tool. By default it runs before Gradle to ease working with libraries that don\\'t support AndroidX yet. See more at: https://www.npmjs.com/package/jetifier.',\n },\n ],\n};\n"]}
\ No newline at end of file
+{"version":3,"sources":["../../../src/commands/runAndroid/index.ts"],"names":["displayWarnings","config","args","appFolder","logger","warn","root","runAndroid","_argv","androidProject","jetifier","info","chalk","bold","dim","require","resolve","stdio","error","CLIError","packager","buildAndRun","port","then","result","startServerInNewWindow","terminal","reactNativePath","message","process","chdir","sourceDir","cmd","platform","startsWith","packageName","adbPath","deviceId","runOnSpecificDevice","gradlew","devices","adb","getDevices","length","indexOf","buildApk","installAndLaunchOnDevice","getTaskNames","appName","commands","map","command","toPascalCase","value","toUpperCase","slice","installTask","buildType","type","flavor","tasks","gradleArgs","push","debug","join","execa","sync","cwd","tryInstallAppOnDevice","device","buildDirectory","apkFileName","pathToApk","adbArgs","selectedDevice","isWindows","test","scriptFile","packagerEnvFilename","portExportContent","launchPackagerScript","path","scriptsDir","dirname","packagerEnvFile","procConfig","fs","writeFileSync","encoding","flag","detached","name","description","func","options","default","env","RCT_METRO_PORT","parse","Number","val","split"],"mappings":";;;;;;;AAOA;AAAA;;AAAA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A,WAAW,EAAE,+BAFf;AAGEG,IAAAA,OAAO,EAAE;AAHX,GAhCO,EAqCP;AACEJ,IAAAA,IAAI,EAAE,qBADR;AAEEC,IAAAA,WAAW,EACT,2EACA;AAJJ,GArCO,EA2CP;AACED,IAAAA,IAAI,EAAE,eADR;AAEEC,IAAAA,WAAW,EAAE;AAFf,GA3CO,EA+CP;AACED,IAAAA,IAAI,EAAE,iBADR;AAEEI,IAAAA,OAAO,EAAElE,OAAO,CAACmE,GAAR,CAAYC,cAAZ,IAA8B,IAFzC;AAGEC,IAAAA,KAAK,EAAEC;AAHT,GA/CO,EAoDP;AACER,IAAAA,IAAI,EAAE,qBADR;AAEEC,IAAAA,WAAW,EACT,+EAHJ;AAIEG,IAAAA,OAAO,EAAE;AAJX,GApDO,EA0DP;AACEJ,IAAAA,IAAI,EAAE,gBADR;AAEEC,IAAAA,WAAW,EAAE,0DAFf;AAGEM,IAAAA,KAAK,EAAGE,GAAD,IAAiBA,GAAG,CAACC,KAAJ,CAAU,GAAV;AAH1B,GA1DO,EA+DP;AACEV,IAAAA,IAAI,EAAE,eADR;AAEEC,IAAAA,WAAW,EACT;AAHJ,GA/DO;AALI,C","sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nimport path from 'path';\nimport execa from 'execa';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport {Config} from '@react-native-community/cli-types';\nimport adb from './adb';\nimport runOnAllDevices from './runOnAllDevices';\nimport tryRunAdbReverse from './tryRunAdbReverse';\nimport tryLaunchAppOnDevice from './tryLaunchAppOnDevice';\nimport getAdbPath from './getAdbPath';\nimport {\n isPackagerRunning,\n logger,\n getDefaultUserTerminal,\n CLIError,\n} from '@react-native-community/cli-tools';\nimport warnAboutManuallyLinkedLibs from '../../link/warnAboutManuallyLinkedLibs';\nimport {getAndroidProject, getPackageName} from '../../utils/getAndroidProject';\n\nfunction displayWarnings(config: Config, args: Flags) {\n warnAboutManuallyLinkedLibs(config);\n if (args.appFolder) {\n logger.warn(\n 'Using deprecated \"--appFolder\" flag. Use \"project.android.appName\" in react-native.config.js instead.',\n );\n }\n if (args.root) {\n logger.warn(\n 'Using deprecated \"--root\" flag. App root is discovered automatically. Alternatively, set \"project.android.sourceDir\" in react-native.config.js.',\n );\n }\n}\n\nexport interface Flags {\n tasks?: Array<string>;\n root: string;\n flavor: string;\n type: string;\n appFolder: string;\n appId: string;\n appIdSuffix: string;\n mainActivity: string;\n deviceId?: string;\n packager: boolean;\n port: number;\n terminal: string;\n jetifier: boolean;\n}\n\ntype AndroidProject = NonNullable<Config['project']['android']>;\n\n/**\n * Starts the app on a connected Android emulator or device.\n */\nasync function runAndroid(_argv: Array<string>, config: Config, args: Flags) {\n displayWarnings(config, args);\n const androidProject = getAndroidProject(config);\n\n if (args.jetifier) {\n logger.info(\n `Running ${chalk.bold(\n 'jetifier',\n )} to migrate libraries to AndroidX. ${chalk.dim(\n 'You can disable it using \"--no-jetifier\" flag.',\n )}`,\n );\n\n try {\n await execa(require.resolve('jetifier/bin/jetify'), {stdio: 'inherit'});\n } catch (error) {\n throw new CLIError('Failed to run jetifier.', error);\n }\n }\n\n if (!args.packager) {\n return buildAndRun(args, androidProject);\n }\n\n return isPackagerRunning(args.port).then((result: string) => {\n if (result === 'running') {\n logger.info('JS server already running.');\n } else if (result === 'unrecognized') {\n logger.warn('JS server not recognized, continuing with build...');\n } else {\n // result == 'not_running'\n logger.info('Starting JS server...');\n try {\n startServerInNewWindow(\n args.port,\n args.terminal,\n config.reactNativePath,\n );\n } catch (error) {\n logger.warn(\n `Failed to automatically start the packager server. Please run \"react-native start\" manually. Error details: ${error.message}`,\n );\n }\n }\n return buildAndRun(args, androidProject);\n });\n}\n\n// Builds the app and runs it on a connected emulator / device.\nfunction buildAndRun(args: Flags, androidProject: AndroidProject) {\n process.chdir(androidProject.sourceDir);\n const cmd = process.platform.startsWith('win') ? 'gradlew.bat' : './gradlew';\n\n const {appFolder} = args;\n const packageName = getPackageName(androidProject, appFolder);\n\n const adbPath = getAdbPath();\n if (args.deviceId) {\n return runOnSpecificDevice(args, cmd, packageName, adbPath, androidProject);\n } else {\n return runOnAllDevices(args, cmd, packageName, adbPath, androidProject);\n }\n}\n\nfunction runOnSpecificDevice(\n args: Flags,\n gradlew: 'gradlew.bat' | './gradlew',\n packageName: string,\n adbPath: string,\n androidProject: AndroidProject,\n) {\n const devices = adb.getDevices(adbPath);\n const {deviceId} = args;\n if (devices.length > 0 && deviceId) {\n if (devices.indexOf(deviceId) !== -1) {\n buildApk(gradlew, androidProject.sourceDir, args, androidProject);\n installAndLaunchOnDevice(\n args,\n deviceId,\n packageName,\n adbPath,\n androidProject,\n );\n } else {\n logger.error(\n `Could not find device with the id: \"${deviceId}\". Please choose one of the following:`,\n ...devices,\n );\n }\n } else {\n logger.error('No Android device or emulator connected.');\n }\n}\n\nfunction getTaskNames(appName: string, commands: string[]) {\n return appName\n ? commands.map((command) => `${appName}:${command}`)\n : commands;\n}\n\nfunction toPascalCase(value: string) {\n return value !== '' ? value[0].toUpperCase() + value.slice(1) : value;\n}\n\nfunction buildApk(\n gradlew: string,\n sourceDir: string,\n args: Flags,\n androidProject: AndroidProject,\n) {\n try {\n let installTask = 'install';\n const buildType = toPascalCase(args.type) || 'Debug';\n\n if (args.flavor) {\n installTask += toPascalCase(args.flavor);\n }\n installTask += buildType;\n\n const tasks = args.tasks || [installTask];\n const gradleArgs = getTaskNames(\n args.appFolder || androidProject.appName,\n tasks,\n );\n\n if (args.port != null) {\n gradleArgs.push('-PreactNativeDevServerPort=' + args.port);\n }\n logger.info('Building the app...');\n logger.debug(`Running command \"${gradlew} ${gradleArgs.join(' ')}\"`);\n execa.sync(gradlew, gradleArgs, {stdio: 'inherit', cwd: sourceDir});\n } catch (error) {\n throw new CLIError('Failed to build the app.', error);\n }\n}\n\nfunction tryInstallAppOnDevice(\n args: Flags,\n adbPath: string,\n device: string,\n androidProject: AndroidProject,\n) {\n try {\n // \"app\" is usually the default value for Android apps with only 1 app\n const {appName, sourceDir} = androidProject;\n const buildType = args.type || 'debug';\n let buildDirectory = `${sourceDir}/${appName}/build/outputs/apk`;\n if (args.flavor) {\n buildDirectory += `/${args.flavor}`;\n }\n buildDirectory += `/${buildType}`;\n let apkFileName = 'app';\n if (args.flavor) {\n apkFileName += `-${args.flavor}`;\n }\n apkFileName += `-${buildType}.apk`;\n const pathToApk = `${buildDirectory}/${apkFileName}`;\n\n const adbArgs = ['-s', device, 'install', '-r', '-d', pathToApk];\n logger.info(`Installing the app on the device \"${device}\"...`);\n logger.debug(\n `Running command \"cd android && adb -s ${device} install -r -d ${pathToApk}\"`,\n );\n execa.sync(adbPath, adbArgs, {stdio: 'inherit'});\n } catch (error) {\n throw new CLIError('Failed to install the app on the device.', error);\n }\n}\n\nfunction installAndLaunchOnDevice(\n args: Flags,\n selectedDevice: string,\n packageName: string,\n adbPath: string,\n androidProject: AndroidProject,\n) {\n tryRunAdbReverse(args.port, selectedDevice);\n tryInstallAppOnDevice(args, adbPath, selectedDevice, androidProject);\n tryLaunchAppOnDevice(selectedDevice, packageName, adbPath, args);\n}\n\nfunction startServerInNewWindow(\n port: number,\n terminal: string,\n reactNativePath: string,\n) {\n /**\n * Set up OS-specific filenames and commands\n */\n const isWindows = /^win/.test(process.platform);\n const scriptFile = isWindows\n ? 'launchPackager.bat'\n : 'launchPackager.command';\n const packagerEnvFilename = isWindows ? '.packager.bat' : '.packager.env';\n const portExportContent = isWindows\n ? `set RCT_METRO_PORT=${port}`\n : `export RCT_METRO_PORT=${port}`;\n\n /**\n * Set up the `.packager.(env|bat)` file to ensure the packager starts on the right port.\n */\n const launchPackagerScript = path.join(\n reactNativePath,\n `scripts/${scriptFile}`,\n );\n\n /**\n * Set up the `launchpackager.(command|bat)` file.\n * It lives next to `.packager.(bat|env)`\n */\n const scriptsDir = path.dirname(launchPackagerScript);\n const packagerEnvFile = path.join(scriptsDir, packagerEnvFilename);\n const procConfig: execa.SyncOptions = {cwd: scriptsDir};\n\n /**\n * Ensure we overwrite file by passing the `w` flag\n */\n fs.writeFileSync(packagerEnvFile, portExportContent, {\n encoding: 'utf8',\n flag: 'w',\n });\n\n if (process.platform === 'darwin') {\n try {\n return execa.sync(\n 'open',\n ['-a', terminal, launchPackagerScript],\n procConfig,\n );\n } catch (error) {\n return execa.sync('open', [launchPackagerScript], procConfig);\n }\n }\n if (process.platform === 'linux') {\n try {\n return execa.sync(terminal, ['-e', `sh ${launchPackagerScript}`], {\n ...procConfig,\n detached: true,\n });\n } catch (error) {\n // By default, the child shell process will be attached to the parent\n return execa.sync('sh', [launchPackagerScript], procConfig);\n }\n }\n if (/^win/.test(process.platform)) {\n // Awaiting this causes the CLI to hang indefinitely, so this must execute without await.\n return execa('cmd.exe', ['/C', launchPackagerScript], {\n ...procConfig,\n detached: true,\n stdio: 'ignore',\n });\n }\n logger.error(\n `Cannot start the packager. Unknown platform ${process.platform}`,\n );\n return;\n}\n\nexport default {\n name: 'run-android',\n description:\n 'builds your app and starts it on a connected Android emulator or device',\n func: runAndroid,\n options: [\n {\n name: '--root <string>',\n description:\n '[DEPRECATED - root is discovered automatically] Override the root directory for the android build (which contains the android directory)',\n default: '',\n },\n {\n name: '--flavor <string>',\n description: \"Specify your app's build flavor\",\n },\n {\n name: '--type <string>',\n description: \"Specify your app's build type\",\n default: 'debug',\n },\n {\n name: '--appFolder <string>',\n description:\n '[DEPRECATED – use \"project.android.appName\" in react-native.config.js] Specify a different application folder name for the android source. If not, we assume is \"app\"',\n },\n {\n name: '--appId <string>',\n description:\n 'Specify an applicationId to launch after build. If not specified, `package` from AndroidManifest.xml will be used.',\n default: '',\n },\n {\n name: '--appIdSuffix <string>',\n description: 'Specify an applicationIdSuffix to launch after build.',\n default: '',\n },\n {\n name: '--main-activity <string>',\n description: 'Name of the activity to start',\n default: 'MainActivity',\n },\n {\n name: '--deviceId <string>',\n description:\n 'builds your app and starts it on a specific device/simulator with the ' +\n 'given device id (listed by running \"adb devices\" on the command line).',\n },\n {\n name: '--no-packager',\n description: 'Do not launch packager while building',\n },\n {\n name: '--port <number>',\n default: process.env.RCT_METRO_PORT || 8081,\n parse: Number,\n },\n {\n name: '--terminal <string>',\n description:\n 'Launches the Metro Bundler in a new window using the specified terminal path.',\n default: getDefaultUserTerminal(),\n },\n {\n name: '--tasks <list>',\n description: 'Run custom Gradle tasks. By default it\\'s \"installDebug\"',\n parse: (val: string) => val.split(','),\n },\n {\n name: '--no-jetifier',\n description:\n 'Do not run \"jetifier\" – the AndroidX transition tool. By default it runs before Gradle to ease working with libraries that don\\'t support AndroidX yet. See more at: https://www.npmjs.com/package/jetifier.',\n },\n ],\n};\n"]}
\ No newline at end of file
diff --git a/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.d.ts.map b/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.d.ts.map
index e94380c..812dad7 100644
--- a/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.d.ts.map
+++ b/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.d.ts.map
@@ -1 +1 @@
-{"version":3,"file":"runOnAllDevices.d.ts","sourceRoot":"","sources":["../../../src/commands/runAndroid/runOnAllDevices.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAC,MAAM,EAAC,MAAM,mCAAmC,CAAC;AAMzD,OAAO,EAAC,KAAK,EAAC,MAAM,GAAG,CAAC;AAYxB,aAAK,cAAc,GAAG,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;AAEhE,iBAAe,eAAe,CAC5B,IAAI,EAAE,KAAK,EACX,GAAG,EAAE,MAAM,EACX,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,cAAc,iBAiD/B;AA6BD,eAAe,eAAe,CAAC"}
\ No newline at end of file
+{"version":3,"file":"runOnAllDevices.d.ts","sourceRoot":"","sources":["../../../src/commands/runAndroid/runOnAllDevices.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAC,MAAM,EAAC,MAAM,mCAAmC,CAAC;AAMzD,OAAO,EAAC,KAAK,EAAC,MAAM,GAAG,CAAC;AAYxB,aAAK,cAAc,GAAG,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;AAEhE,iBAAe,eAAe,CAC5B,IAAI,EAAE,KAAK,EACX,GAAG,EAAE,MAAM,EACX,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,cAAc,iBAyD/B;AA6BD,eAAe,eAAe,CAAC"}
\ No newline at end of file
diff --git a/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js b/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js
index c12c4bb..12feed5 100644
--- a/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js
+++ b/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js
@@ -80,7 +80,15 @@ async function runOnAllDevices(args, cmd, packageName, adbPath, androidProject)
}
try {
- const tasks = args.tasks || ['install' + toPascalCase(args.variant)];
+ let installTask = 'install';
+ const buildType = toPascalCase(args.type) || 'Debug';
+
+ if (args.flavor) {
+ installTask += toPascalCase(args.flavor);
+ }
+
+ installTask += buildType;
+ const tasks = args.tasks || [installTask];
const gradleArgs = getTaskNames(args.appFolder || androidProject.appName, tasks);
if (args.port != null) {
diff --git a/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js.map b/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js.map
index 35c7d50..c67eded 100644
--- a/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js.map
+++ b/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js.map
@@ -1 +1 @@
-{"version":3,"sources":["../../../src/commands/runAndroid/runOnAllDevices.ts"],"names":["getTaskNames","appName","commands","map","command","toPascalCase","value","toUpperCase","slice","runOnAllDevices","args","cmd","packageName","adbPath","androidProject","devices","adb","getDevices","length","logger","info","result","success","error","chalk","dim","warn","tasks","variant","gradleArgs","appFolder","port","push","debug","join","stdio","cwd","sourceDir","createInstallError","undefined","forEach","device","stderr","toString","docs","message","underline","log","includes","bold","CLIError"],"mappings":";;;;;;;AAQA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;;AACA;;AACA;;AACA;;;;AAfA;;;;;;;AAkBA,SAASA,YAAT,CAAsBC,OAAtB,EAAuCC,QAAvC,EAA+E;AAC7E,SAAOD,OAAO,GACVC,QAAQ,CAACC,GAAT,CAAcC,OAAD,IAAc,GAAEH,OAAQ,IAAGG,OAAQ,EAAhD,CADU,GAEVF,QAFJ;AAGD;;AAED,SAASG,YAAT,CAAsBC,KAAtB,EAAqC;AACnC,SAAOA,KAAK,KAAK,EAAV,GAAeA,KAAK,CAAC,CAAD,CAAL,CAASC,WAAT,KAAyBD,KAAK,CAACE,KAAN,CAAY,CAAZ,CAAxC,GAAyDF,KAAhE;AACD;;AAID,eAAeG,eAAf,CACEC,IADF,EAEEC,GAFF,EAGEC,WAHF,EAIEC,OAJF,EAKEC,cALF,EAME;AACA,MAAIC,OAAO,GAAGC,aAAIC,UAAJ,CAAeJ,OAAf,CAAd;;AACA,MAAIE,OAAO,CAACG,MAAR,KAAmB,CAAvB,EAA0B;AACxBC,uBAAOC,IAAP,CAAY,uBAAZ;;AACA,UAAMC,MAAM,GAAG,MAAM,gCAAkBR,OAAlB,CAArB;;AACA,QAAIQ,MAAM,CAACC,OAAX,EAAoB;AAClBH,yBAAOC,IAAP,CAAY,iCAAZ;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H,IAAnD;AACD,GAJH;AAMD;;AAED,SAAS4B,kBAAT,CAA4Bf,KAA5B,EAA6D;AAC3D,QAAMmB,MAAM,GAAG,CAACnB,KAAK,CAACmB,MAAN,IAAgB,EAAjB,EAAqBC,QAArB,EAAf;AACA,QAAMC,IAAI,GAAG,gDAAb;AACA,MAAIC,OAAO,GAAI,kEAAiErB,iBAAMsB,SAAN,CAAgBrB,GAAhB,CAC9EmB,IAD8E,CAE9E,EAFF,CAH2D,CAO3D;AACA;;AACAzB,qBAAO4B,GAAP,CAAWL,MAAX,EAT2D,CAW3D;;;AACA,MAAIA,MAAM,CAACM,QAAP,CAAgB,sBAAhB,CAAJ,EAA6C;AAC3CH,IAAAA,OAAO,GACL,sEADF;AAED,GAHD,MAGO,IACLH,MAAM,CAACM,QAAP,CAAgB,iCAAhB,KACAN,MAAM,CAACM,QAAP,CAAgB,wBAAhB,CAFK,EAGL;AACAH,IAAAA,OAAO,GAAI,gFAA+ErB,iBAAMyB,IAAN,CACxF,+CADwF,CAExF,GAFF;AAGD;;AAED,SAAO,KAAIC,oBAAJ,EAAc,8BAA6BL,OAAQ,GAAnD,EAAuDtB,KAAvD,CAAP;AACD;;eAEcd,e","sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport chalk from 'chalk';\nimport execa from 'execa';\nimport {Config} from '@react-native-community/cli-types';\nimport {logger, CLIError} from '@react-native-community/cli-tools';\nimport adb from './adb';\nimport tryRunAdbReverse from './tryRunAdbReverse';\nimport tryLaunchAppOnDevice from './tryLaunchAppOnDevice';\nimport tryLaunchEmulator from './tryLaunchEmulator';\nimport {Flags} from '.';\n\nfunction getTaskNames(appName: string, commands: Array<string>): Array<string> {\n return appName\n ? commands.map((command) => `${appName}:${command}`)\n : commands;\n}\n\nfunction toPascalCase(value: string) {\n return value !== '' ? value[0].toUpperCase() + value.slice(1) : value;\n}\n\ntype AndroidProject = NonNullable<Config['project']['android']>;\n\nasync function runOnAllDevices(\n args: Flags,\n cmd: string,\n packageName: string,\n adbPath: string,\n androidProject: AndroidProject,\n) {\n let devices = adb.getDevices(adbPath);\n if (devices.length === 0) {\n logger.info('Launching emulator...');\n const result = await tryLaunchEmulator(adbPath);\n if (result.success) {\n logger.info('Successfully launched emulator.');\n devices = adb.getDevices(adbPath);\n } else {\n logger.error(\n `Failed to launch emulator. Reason: ${chalk.dim(result.error || '')}.`,\n );\n logger.warn(\n 'Please launch an emulator manually or connect a device. Otherwise app may fail to launch.',\n );\n }\n }\n\n try {\n const tasks = args.tasks || ['install' + toPascalCase(args.variant)];\n const gradleArgs = getTaskNames(\n args.appFolder || androidProject.appName,\n tasks,\n );\n\n if (args.port != null) {\n gradleArgs.push('-PreactNativeDevServerPort=' + args.port);\n }\n\n logger.info('Installing the app...');\n logger.debug(\n `Running command \"cd android && ${cmd} ${gradleArgs.join(' ')}\"`,\n );\n\n await execa(cmd, gradleArgs, {\n stdio: ['inherit', 'inherit', 'pipe'],\n cwd: androidProject.sourceDir,\n });\n } catch (error) {\n throw createInstallError(error);\n }\n\n (devices.length > 0 ? devices : [undefined]).forEach(\n (device: string | void) => {\n tryRunAdbReverse(args.port, device);\n tryLaunchAppOnDevice(device, packageName, adbPath, args);\n },\n );\n}\n\nfunction createInstallError(error: Error & {stderr: string}) {\n const stderr = (error.stderr || '').toString();\n const docs = 'https://reactnative.dev/docs/environment-setup';\n let message = `Make sure you have the Android development environment set up: ${chalk.underline.dim(\n docs,\n )}`;\n\n // Pass the error message from the command to stdout because we pipe it to\n // parent process so it's not visible\n logger.log(stderr);\n\n // Handle some common failures and make the errors more helpful\n if (stderr.includes('No connected devices')) {\n message =\n 'Make sure you have an Android emulator running or a device connected';\n } else if (\n stderr.includes('licences have not been accepted') ||\n stderr.includes('accept the SDK license')\n ) {\n message = `Please accept all necessary Android SDK licenses using Android SDK Manager: \"${chalk.bold(\n '$ANDROID_HOME/tools/bin/sdkmanager --licenses',\n )}\"`;\n }\n\n return new CLIError(`Failed to install the app. ${message}.`, error);\n}\n\nexport default runOnAllDevices;\n"]}
\ No newline at end of file
+{"version":3,"sources":["../../../src/commands/runAndroid/runOnAllDevices.ts"],"names":["getTaskNames","appName","commands","map","command","toPascalCase","value","toUpperCase","slice","runOnAllDevices","args","cmd","packageName","adbPath","androidProject","devices","adb","getDevices","length","logger","info","result","success","error","chalk","dim","warn","installTask","buildType","type","flavor","tasks","gradleArgs","appFolder","port","push","debug","join","stdio","cwd","sourceDir","createInstallError","undefined","forEach","device","stderr","toString","docs","message","underline","log","includes","bold","CLIError"],"mappings":";;;;;;;AAQA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;;AACA;;AACA;;AACA;;;;AAfA;;;;;;;AAkBA,SAASA,YAAT,CAAsBC,OAAtB,EAAuCC,QAAvC,EAA+E;AAC7E,SAAOD,OAAO,GACVC,QAAQ,CAACC,GAAT,CAAcC,OAAD,IAAc,GAAEH,OAAQ,IAAGG,OAAQ,EAAhD,CADU,GAEVF,QAFJ;AAGD;;AAED,SAASG,YAAT,CAAsBC,KAAtB,EAAqC;AACnC,SAAOA,KAAK,KAAK,EAAV,GAAeA,KAAK,CAAC,CAAD,CAAL,CAASC,WAAT,KAAyBD,KAAK,CAACE,KAAN,CAAY,CAAZ,CAAxC,GAAyDF,KAAhE;AACD;;AAID,eAAeG,eAAf,CACEC,IADF,EAEEC,GAFF,EAGEC,WAHF,EAIEC,OAJF,EAKEC,cALF,EAME;AACA,MAAIC,OAAO,GAAGC,aAAIC,UAAJ,CAAeJ,OAAf,CAAd;;AACA,MAAIE,OAAO,CAACG,MAAR,KAAmB,CAAvB,EAA0B;AACxBC,uBAAOC,IAAP,CAAY,uBAAZ;;AACA,UAAMC,MAAM,GAAG,MAAM,gCAAkBR,OAAlB,CAAr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OAAOjB,KAAP,EAAc;AACd,UAAMkB,kBAAkB,CAAClB,KAAD,CAAxB;AACD;;AAED,GAACR,OAAO,CAACG,MAAR,GAAiB,CAAjB,GAAqBH,OAArB,GAA+B,CAAC2B,SAAD,CAAhC,EAA6CC,OAA7C,CACGC,MAAD,IAA2B;AACzB,mCAAiBlC,IAAI,CAACwB,IAAtB,EAA4BU,MAA5B;AACA,uCAAqBA,MAArB,EAA6BhC,WAA7B,EAA0CC,OAA1C,EAAmDH,IAAnD;AACD,GAJH;AAMD;;AAED,SAAS+B,kBAAT,CAA4BlB,KAA5B,EAA6D;AAC3D,QAAMsB,MAAM,GAAG,CAACtB,KAAK,CAACsB,MAAN,IAAgB,EAAjB,EAAqBC,QAArB,EAAf;AACA,QAAMC,IAAI,GAAG,gDAAb;AACA,MAAIC,OAAO,GAAI,kEAAiExB,iBAAMyB,SAAN,CAAgBxB,GAAhB,CAC9EsB,IAD8E,CAE9E,EAFF,CAH2D,CAO3D;AACA;;AACA5B,qBAAO+B,GAAP,CAAWL,MAAX,EAT2D,CAW3D;;;AACA,MAAIA,MAAM,CAACM,QAAP,CAAgB,sBAAhB,CAAJ,EAA6C;AAC3CH,IAAAA,OAAO,GACL,sEADF;AAED,GAHD,MAGO,IACLH,MAAM,CAACM,QAAP,CAAgB,iCAAhB,KACAN,MAAM,CAACM,QAAP,CAAgB,wBAAhB,CAFK,EAGL;AACAH,IAAAA,OAAO,GAAI,gFAA+ExB,iBAAM4B,IAAN,CACxF,+CADwF,CAExF,GAFF;AAGD;;AAED,SAAO,KAAIC,oBAAJ,EAAc,8BAA6BL,OAAQ,GAAnD,EAAuDzB,KAAvD,CAAP;AACD;;eAEcd,e","sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport chalk from 'chalk';\nimport execa from 'execa';\nimport {Config} from '@react-native-community/cli-types';\nimport {logger, CLIError} from '@react-native-community/cli-tools';\nimport adb from './adb';\nimport tryRunAdbReverse from './tryRunAdbReverse';\nimport tryLaunchAppOnDevice from './tryLaunchAppOnDevice';\nimport tryLaunchEmulator from './tryLaunchEmulator';\nimport {Flags} from '.';\n\nfunction getTaskNames(appName: string, commands: Array<string>): Array<string> {\n return appName\n ? commands.map((command) => `${appName}:${command}`)\n : commands;\n}\n\nfunction toPascalCase(value: string) {\n return value !== '' ? value[0].toUpperCase() + value.slice(1) : value;\n}\n\ntype AndroidProject = NonNullable<Config['project']['android']>;\n\nasync function runOnAllDevices(\n args: Flags,\n cmd: string,\n packageName: string,\n adbPath: string,\n androidProject: AndroidProject,\n) {\n let devices = adb.getDevices(adbPath);\n if (devices.length === 0) {\n logger.info('Launching emulator...');\n const result = await tryLaunchEmulator(adbPath);\n if (result.success) {\n logger.info('Successfully launched emulator.');\n devices = adb.getDevices(adbPath);\n } else {\n logger.error(\n `Failed to launch emulator. Reason: ${chalk.dim(result.error || '')}.`,\n );\n logger.warn(\n 'Please launch an emulator manually or connect a device. Otherwise app may fail to launch.',\n );\n }\n }\n\n try {\n let installTask = 'install';\n const buildType = toPascalCase(args.type) || 'Debug';\n\n if (args.flavor) {\n installTask += toPascalCase(args.flavor);\n }\n installTask += buildType;\n\n const tasks = args.tasks || [installTask];\n const gradleArgs = getTaskNames(\n args.appFolder || androidProject.appName,\n tasks,\n );\n\n if (args.port != null) {\n gradleArgs.push('-PreactNativeDevServerPort=' + args.port);\n }\n\n logger.info('Installing the app...');\n logger.debug(\n `Running command \"cd android && ${cmd} ${gradleArgs.join(' ')}\"`,\n );\n\n await execa(cmd, gradleArgs, {\n stdio: ['inherit', 'inherit', 'pipe'],\n cwd: androidProject.sourceDir,\n });\n } catch (error) {\n throw createInstallError(error);\n }\n\n (devices.length > 0 ? devices : [undefined]).forEach(\n (device: string | void) => {\n tryRunAdbReverse(args.port, device);\n tryLaunchAppOnDevice(device, packageName, adbPath, args);\n },\n );\n}\n\nfunction createInstallError(error: Error & {stderr: string}) {\n const stderr = (error.stderr || '').toString();\n const docs = 'https://reactnative.dev/docs/environment-setup';\n let message = `Make sure you have the Android development environment set up: ${chalk.underline.dim(\n docs,\n )}`;\n\n // Pass the error message from the command to stdout because we pipe it to\n // parent process so it's not visible\n logger.log(stderr);\n\n // Handle some common failures and make the errors more helpful\n if (stderr.includes('No connected devices')) {\n message =\n 'Make sure you have an Android emulator running or a device connected';\n } else if (\n stderr.includes('licences have not been accepted') ||\n stderr.includes('accept the SDK license')\n ) {\n message = `Please accept all necessary Android SDK licenses using Android SDK Manager: \"${chalk.bold(\n '$ANDROID_HOME/tools/bin/sdkmanager --licenses',\n )}\"`;\n }\n\n return new CLIError(`Failed to install the app. ${message}.`, error);\n}\n\nexport default runOnAllDevices;\n"]}
\ No newline at end of file
diff --git a/node_modules/@react-native-community/cli-platform-android/src/commands/runAndroid/index.ts b/node_modules/@react-native-community/cli-platform-android/src/commands/runAndroid/index.ts
index 29f351d..ec6ad4a 100644
--- a/node_modules/@react-native-community/cli-platform-android/src/commands/runAndroid/index.ts
+++ b/node_modules/@react-native-community/cli-platform-android/src/commands/runAndroid/index.ts
@@ -41,7 +41,8 @@ function displayWarnings(config: Config, args: Flags) {
export interface Flags {
tasks?: Array<string>;
root: string;
- variant: string;
+ flavor: string;
+ type: string;
appFolder: string;
appId: string;
appIdSuffix: string;
@@ -133,7 +134,7 @@ function runOnSpecificDevice(
const {deviceId} = args;
if (devices.length > 0 && deviceId) {
if (devices.indexOf(deviceId) !== -1) {
- buildApk(gradlew, androidProject.sourceDir);
+ buildApk(gradlew, androidProject.sourceDir, args, androidProject);
installAndLaunchOnDevice(
args,
deviceId,
@@ -152,10 +153,40 @@ function runOnSpecificDevice(
}
}
-function buildApk(gradlew: string, sourceDir: string) {
+function getTaskNames(appName: string, commands: string[]) {
+ return appName
+ ? commands.map((command) => `${appName}:${command}`)
+ : commands;
+}
+
+function toPascalCase(value: string) {
+ return value !== '' ? value[0].toUpperCase() + value.slice(1) : value;
+}
+
+function buildApk(
+ gradlew: string,
+ sourceDir: string,
+ args: Flags,
+ androidProject: AndroidProject,
+) {
try {
- // using '-x lint' in order to ignore linting errors while building the apk
- const gradleArgs = ['build', '-x', 'lint'];
+ let installTask = 'install';
+ const buildType = toPascalCase(args.type) || 'Debug';
+
+ if (args.flavor) {
+ installTask += toPascalCase(args.flavor);
+ }
+ installTask += buildType;
+
+ const tasks = args.tasks || [installTask];
+ const gradleArgs = getTaskNames(
+ args.appFolder || androidProject.appName,
+ tasks,
+ );
+
+ if (args.port != null) {
+ gradleArgs.push('-PreactNativeDevServerPort=' + args.port);
+ }
logger.info('Building the app...');
logger.debug(`Running command "${gradlew} ${gradleArgs.join(' ')}"`);
execa.sync(gradlew, gradleArgs, {stdio: 'inherit', cwd: sourceDir});
@@ -173,18 +204,19 @@ function tryInstallAppOnDevice(
try {
// "app" is usually the default value for Android apps with only 1 app
const {appName, sourceDir} = androidProject;
- const {appFolder} = args;
- const variant = args.variant.toLowerCase();
- const buildDirectory = `${sourceDir}/${appName}/build/outputs/apk/${variant}`;
- const apkFile = getInstallApkName(
- appFolder || appName, // TODO: remove appFolder
- adbPath,
- variant,
- device,
- buildDirectory,
- );
+ const buildType = args.type || 'debug';
+ let buildDirectory = `${sourceDir}/${appName}/build/outputs/apk`;
+ if (args.flavor) {
+ buildDirectory += `/${args.flavor}`;
+ }
+ buildDirectory += `/${buildType}`;
+ let apkFileName = 'app';
+ if (args.flavor) {
+ apkFileName += `-${args.flavor}`;
+ }
+ apkFileName += `-${buildType}.apk`;
+ const pathToApk = `${buildDirectory}/${apkFileName}`;
- const pathToApk = `${buildDirectory}/${apkFile}`;
const adbArgs = ['-s', device, 'install', '-r', '-d', pathToApk];
logger.info(`Installing the app on the device "${device}"...`);
logger.debug(
@@ -196,32 +228,6 @@ function tryInstallAppOnDevice(
}
}
-function getInstallApkName(
- appName: string,
- adbPath: string,
- variant: string,
- device: string,
- buildDirectory: string,
-) {
- const availableCPUs = adb.getAvailableCPUs(adbPath, device);
-
- // check if there is an apk file like app-armeabi-v7a-debug.apk
- for (const availableCPU of availableCPUs.concat('universal')) {
- const apkName = `${appName}-${availableCPU}-${variant}.apk`;
- if (fs.existsSync(`${buildDirectory}/${apkName}`)) {
- return apkName;
- }
- }
-
- // check if there is a default file like app-debug.apk
- const apkName = `${appName}-${variant}.apk`;
- if (fs.existsSync(`${buildDirectory}/${apkName}`)) {
- return apkName;
- }
-
- throw new CLIError('Could not find the correct install APK file.');
-}
-
function installAndLaunchOnDevice(
args: Flags,
selectedDevice: string,
@@ -324,8 +330,12 @@ export default {
default: '',
},
{
- name: '--variant <string>',
- description: "Specify your app's build variant",
+ name: '--flavor <string>',
+ description: "Specify your app's build flavor",
+ },
+ {
+ name: '--type <string>',
+ description: "Specify your app's build type",
default: 'debug',
},
{
diff --git a/node_modules/@react-native-community/cli-platform-android/src/commands/runAndroid/runOnAllDevices.ts b/node_modules/@react-native-community/cli-platform-android/src/commands/runAndroid/runOnAllDevices.ts
index 2a968fc..55deea1 100644
--- a/node_modules/@react-native-community/cli-platform-android/src/commands/runAndroid/runOnAllDevices.ts
+++ b/node_modules/@react-native-community/cli-platform-android/src/commands/runAndroid/runOnAllDevices.ts
@@ -53,7 +53,15 @@ async function runOnAllDevices(
}
try {
- const tasks = args.tasks || ['install' + toPascalCase(args.variant)];
+ let installTask = 'install';
+ const buildType = toPascalCase(args.type) || 'Debug';
+
+ if (args.flavor) {
+ installTask += toPascalCase(args.flavor);
+ }
+ installTask += buildType;
+
+ const tasks = args.tasks || [installTask];
const gradleArgs = getTaskNames(
args.appFolder || androidProject.appName,
tasks,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment