yeet
This commit is contained in:
86
node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/adb.js
generated
vendored
Normal file
86
node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/adb.js
generated
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _child_process() {
|
||||
const data = require("child_process");
|
||||
|
||||
_child_process = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Parses the output of the 'adb devices' command
|
||||
*/
|
||||
function parseDevicesResult(result) {
|
||||
if (!result) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const devices = [];
|
||||
const lines = result.trim().split(/\r?\n/);
|
||||
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const words = lines[i].split(/[ ,\t]+/).filter(w => w !== '');
|
||||
|
||||
if (words[1] === 'device') {
|
||||
devices.push(words[0]);
|
||||
}
|
||||
}
|
||||
|
||||
return devices;
|
||||
}
|
||||
/**
|
||||
* Executes the commands needed to get a list of devices from ADB
|
||||
*/
|
||||
|
||||
|
||||
function getDevices(adbPath) {
|
||||
try {
|
||||
const devicesResult = (0, _child_process().execSync)(`${adbPath} devices`);
|
||||
return parseDevicesResult(devicesResult.toString());
|
||||
} catch (e) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Gets available CPUs of devices from ADB
|
||||
*/
|
||||
|
||||
|
||||
function getAvailableCPUs(adbPath, device) {
|
||||
try {
|
||||
const baseArgs = ['-s', device, 'shell', 'getprop'];
|
||||
let cpus = (0, _child_process().execFileSync)(adbPath, baseArgs.concat(['ro.product.cpu.abilist'])).toString(); // pre-Lollipop
|
||||
|
||||
if (!cpus || cpus.trim().length === 0) {
|
||||
cpus = (0, _child_process().execFileSync)(adbPath, baseArgs.concat(['ro.product.cpu.abi'])).toString();
|
||||
}
|
||||
|
||||
return (cpus || '').trim().split(',');
|
||||
} catch (e) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
var _default = {
|
||||
getDevices,
|
||||
getAvailableCPUs
|
||||
};
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=adb.js.map
|
22
node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/getAdbPath.js
generated
vendored
Normal file
22
node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/getAdbPath.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
function getAdbPath() {
|
||||
return process.env.ANDROID_HOME ? `${process.env.ANDROID_HOME}/platform-tools/adb` : 'adb';
|
||||
}
|
||||
|
||||
var _default = getAdbPath;
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=getAdbPath.js.map
|
367
node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js
generated
vendored
Normal file
367
node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js
generated
vendored
Normal file
@ -0,0 +1,367 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require("path"));
|
||||
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _execa() {
|
||||
const data = _interopRequireDefault(require("execa"));
|
||||
|
||||
_execa = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require("chalk"));
|
||||
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _fs() {
|
||||
const data = _interopRequireDefault(require("fs"));
|
||||
|
||||
_fs = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _adb = _interopRequireDefault(require("./adb"));
|
||||
|
||||
var _runOnAllDevices = _interopRequireDefault(require("./runOnAllDevices"));
|
||||
|
||||
var _tryRunAdbReverse = _interopRequireDefault(require("./tryRunAdbReverse"));
|
||||
|
||||
var _tryLaunchAppOnDevice = _interopRequireDefault(require("./tryLaunchAppOnDevice"));
|
||||
|
||||
var _getAdbPath = _interopRequireDefault(require("./getAdbPath"));
|
||||
|
||||
function _cliTools() {
|
||||
const data = require("@react-native-community/cli-tools");
|
||||
|
||||
_cliTools = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _warnAboutManuallyLinkedLibs = _interopRequireDefault(require("../../link/warnAboutManuallyLinkedLibs"));
|
||||
|
||||
var _getAndroidProject = require("../../utils/getAndroidProject");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
function displayWarnings(config, args) {
|
||||
(0, _warnAboutManuallyLinkedLibs.default)(config);
|
||||
|
||||
if (args.appFolder) {
|
||||
_cliTools().logger.warn('Using deprecated "--appFolder" flag. Use "project.android.appName" in react-native.config.js instead.');
|
||||
}
|
||||
|
||||
if (args.root) {
|
||||
_cliTools().logger.warn('Using deprecated "--root" flag. App root is discovered automatically. Alternatively, set "project.android.sourceDir" in react-native.config.js.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the app on a connected Android emulator or device.
|
||||
*/
|
||||
async function runAndroid(_argv, config, args) {
|
||||
displayWarnings(config, args);
|
||||
const androidProject = (0, _getAndroidProject.getAndroidProject)(config);
|
||||
|
||||
if (args.jetifier) {
|
||||
_cliTools().logger.info(`Running ${_chalk().default.bold('jetifier')} to migrate libraries to AndroidX. ${_chalk().default.dim('You can disable it using "--no-jetifier" flag.')}`);
|
||||
|
||||
try {
|
||||
await (0, _execa().default)(require.resolve('jetifier/bin/jetify'), {
|
||||
stdio: 'inherit'
|
||||
});
|
||||
} catch (error) {
|
||||
throw new (_cliTools().CLIError)('Failed to run jetifier.', error);
|
||||
}
|
||||
}
|
||||
|
||||
if (!args.packager) {
|
||||
return buildAndRun(args, androidProject);
|
||||
}
|
||||
|
||||
return (0, _cliTools().isPackagerRunning)(args.port).then(result => {
|
||||
if (result === 'running') {
|
||||
_cliTools().logger.info('JS server already running.');
|
||||
} else if (result === 'unrecognized') {
|
||||
_cliTools().logger.warn('JS server not recognized, continuing with build...');
|
||||
} else {
|
||||
// result == 'not_running'
|
||||
_cliTools().logger.info('Starting JS server...');
|
||||
|
||||
try {
|
||||
startServerInNewWindow(args.port, args.terminal, config.reactNativePath);
|
||||
} catch (error) {
|
||||
_cliTools().logger.warn(`Failed to automatically start the packager server. Please run "react-native start" manually. Error details: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
return buildAndRun(args, androidProject);
|
||||
});
|
||||
} // Builds the app and runs it on a connected emulator / device.
|
||||
|
||||
|
||||
function buildAndRun(args, androidProject) {
|
||||
process.chdir(androidProject.sourceDir);
|
||||
const cmd = process.platform.startsWith('win') ? 'gradlew.bat' : './gradlew';
|
||||
const {
|
||||
appFolder
|
||||
} = args;
|
||||
const packageName = (0, _getAndroidProject.getPackageName)(androidProject, appFolder);
|
||||
const adbPath = (0, _getAdbPath.default)();
|
||||
|
||||
if (args.deviceId) {
|
||||
return runOnSpecificDevice(args, cmd, packageName, adbPath, androidProject);
|
||||
} else {
|
||||
return (0, _runOnAllDevices.default)(args, cmd, packageName, adbPath, androidProject);
|
||||
}
|
||||
}
|
||||
|
||||
function runOnSpecificDevice(args, gradlew, packageName, adbPath, androidProject) {
|
||||
const devices = _adb.default.getDevices(adbPath);
|
||||
|
||||
const {
|
||||
deviceId
|
||||
} = args;
|
||||
|
||||
if (devices.length > 0 && deviceId) {
|
||||
if (devices.indexOf(deviceId) !== -1) {
|
||||
buildApk(gradlew, androidProject.sourceDir);
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
_cliTools().logger.error('No Android device or emulator connected.');
|
||||
}
|
||||
}
|
||||
|
||||
function buildApk(gradlew, sourceDir) {
|
||||
try {
|
||||
// using '-x lint' in order to ignore linting errors while building the apk
|
||||
const gradleArgs = ['build', '-x', 'lint'];
|
||||
|
||||
_cliTools().logger.info('Building the app...');
|
||||
|
||||
_cliTools().logger.debug(`Running command "${gradlew} ${gradleArgs.join(' ')}"`);
|
||||
|
||||
_execa().default.sync(gradlew, gradleArgs, {
|
||||
stdio: 'inherit',
|
||||
cwd: sourceDir
|
||||
});
|
||||
} catch (error) {
|
||||
throw new (_cliTools().CLIError)('Failed to build the app.', error);
|
||||
}
|
||||
}
|
||||
|
||||
function tryInstallAppOnDevice(args, adbPath, device, androidProject) {
|
||||
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 pathToApk = `${buildDirectory}/${apkFile}`;
|
||||
const adbArgs = ['-s', device, 'install', '-r', '-d', pathToApk];
|
||||
|
||||
_cliTools().logger.info(`Installing the app on the device "${device}"...`);
|
||||
|
||||
_cliTools().logger.debug(`Running command "cd android && adb -s ${device} install -r -d ${pathToApk}"`);
|
||||
|
||||
_execa().default.sync(adbPath, adbArgs, {
|
||||
stdio: 'inherit'
|
||||
});
|
||||
} catch (error) {
|
||||
throw new (_cliTools().CLIError)('Failed to install the app on the device.', error);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
(0, _tryLaunchAppOnDevice.default)(selectedDevice, packageName, adbPath, args);
|
||||
}
|
||||
|
||||
function startServerInNewWindow(port, terminal, reactNativePath) {
|
||||
/**
|
||||
* Set up OS-specific filenames and commands
|
||||
*/
|
||||
const isWindows = /^win/.test(process.platform);
|
||||
const scriptFile = isWindows ? 'launchPackager.bat' : 'launchPackager.command';
|
||||
const packagerEnvFilename = isWindows ? '.packager.bat' : '.packager.env';
|
||||
const portExportContent = isWindows ? `set RCT_METRO_PORT=${port}` : `export RCT_METRO_PORT=${port}`;
|
||||
/**
|
||||
* Set up the `.packager.(env|bat)` file to ensure the packager starts on the right port.
|
||||
*/
|
||||
|
||||
const launchPackagerScript = _path().default.join(reactNativePath, `scripts/${scriptFile}`);
|
||||
/**
|
||||
* Set up the `launchpackager.(command|bat)` file.
|
||||
* It lives next to `.packager.(bat|env)`
|
||||
*/
|
||||
|
||||
|
||||
const scriptsDir = _path().default.dirname(launchPackagerScript);
|
||||
|
||||
const packagerEnvFile = _path().default.join(scriptsDir, packagerEnvFilename);
|
||||
|
||||
const procConfig = {
|
||||
cwd: scriptsDir
|
||||
};
|
||||
/**
|
||||
* Ensure we overwrite file by passing the `w` flag
|
||||
*/
|
||||
|
||||
_fs().default.writeFileSync(packagerEnvFile, portExportContent, {
|
||||
encoding: 'utf8',
|
||||
flag: 'w'
|
||||
});
|
||||
|
||||
if (process.platform === 'darwin') {
|
||||
try {
|
||||
return _execa().default.sync('open', ['-a', terminal, launchPackagerScript], procConfig);
|
||||
} catch (error) {
|
||||
return _execa().default.sync('open', [launchPackagerScript], procConfig);
|
||||
}
|
||||
}
|
||||
|
||||
if (process.platform === 'linux') {
|
||||
try {
|
||||
return _execa().default.sync(terminal, ['-e', `sh ${launchPackagerScript}`], { ...procConfig,
|
||||
detached: true
|
||||
});
|
||||
} catch (error) {
|
||||
// By default, the child shell process will be attached to the parent
|
||||
return _execa().default.sync('sh', [launchPackagerScript], procConfig);
|
||||
}
|
||||
}
|
||||
|
||||
if (/^win/.test(process.platform)) {
|
||||
// Awaiting this causes the CLI to hang indefinitely, so this must execute without await.
|
||||
return (0, _execa().default)('cmd.exe', ['/C', launchPackagerScript], { ...procConfig,
|
||||
detached: true,
|
||||
stdio: 'ignore'
|
||||
});
|
||||
}
|
||||
|
||||
_cliTools().logger.error(`Cannot start the packager. Unknown platform ${process.platform}`);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var _default = {
|
||||
name: 'run-android',
|
||||
description: 'builds your app and starts it on a connected Android emulator or device',
|
||||
func: runAndroid,
|
||||
options: [{
|
||||
name: '--root [string]',
|
||||
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",
|
||||
default: 'debug'
|
||||
}, {
|
||||
name: '--appFolder [string]',
|
||||
description: '[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"'
|
||||
}, {
|
||||
name: '--appId [string]',
|
||||
description: 'Specify an applicationId to launch after build. If not specified, `package` from AndroidManifest.xml will be used.',
|
||||
default: ''
|
||||
}, {
|
||||
name: '--appIdSuffix [string]',
|
||||
description: 'Specify an applicationIdSuffix to launch after build.',
|
||||
default: ''
|
||||
}, {
|
||||
name: '--main-activity [string]',
|
||||
description: 'Name of the activity to start',
|
||||
default: 'MainActivity'
|
||||
}, {
|
||||
name: '--deviceId [string]',
|
||||
description: 'builds your app and starts it on a specific device/simulator with the ' + 'given device id (listed by running "adb devices" on the command line).'
|
||||
}, {
|
||||
name: '--no-packager',
|
||||
description: 'Do not launch packager while building'
|
||||
}, {
|
||||
name: '--port [number]',
|
||||
default: process.env.RCT_METRO_PORT || 8081,
|
||||
parse: val => Number(val)
|
||||
}, {
|
||||
name: '--terminal [string]',
|
||||
description: 'Launches the Metro Bundler in a new window using the specified terminal path.',
|
||||
default: (0, _cliTools().getDefaultUserTerminal)()
|
||||
}, {
|
||||
name: '--tasks [list]',
|
||||
description: 'Run custom Gradle tasks. By default it\'s "installDebug"',
|
||||
parse: val => val.split(',')
|
||||
}, {
|
||||
name: '--no-jetifier',
|
||||
description: '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.',
|
||||
default: false
|
||||
}]
|
||||
};
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
129
node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js
generated
vendored
Normal file
129
node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js
generated
vendored
Normal file
@ -0,0 +1,129 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require("chalk"));
|
||||
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _execa() {
|
||||
const data = _interopRequireDefault(require("execa"));
|
||||
|
||||
_execa = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _cliTools() {
|
||||
const data = require("@react-native-community/cli-tools");
|
||||
|
||||
_cliTools = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _adb = _interopRequireDefault(require("./adb"));
|
||||
|
||||
var _tryRunAdbReverse = _interopRequireDefault(require("./tryRunAdbReverse"));
|
||||
|
||||
var _tryLaunchAppOnDevice = _interopRequireDefault(require("./tryLaunchAppOnDevice"));
|
||||
|
||||
var _tryLaunchEmulator = _interopRequireDefault(require("./tryLaunchEmulator"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
function getTaskNames(appName, commands) {
|
||||
return appName ? commands.map(command => `${appName}:${command}`) : commands;
|
||||
}
|
||||
|
||||
function toPascalCase(value) {
|
||||
return value !== '' ? value[0].toUpperCase() + value.slice(1) : value;
|
||||
}
|
||||
|
||||
async function runOnAllDevices(args, cmd, packageName, adbPath, androidProject) {
|
||||
let devices = _adb.default.getDevices(adbPath);
|
||||
|
||||
if (devices.length === 0) {
|
||||
_cliTools().logger.info('Launching emulator...');
|
||||
|
||||
const result = await (0, _tryLaunchEmulator.default)(adbPath);
|
||||
|
||||
if (result.success) {
|
||||
_cliTools().logger.info('Successfully launched emulator.');
|
||||
|
||||
devices = _adb.default.getDevices(adbPath);
|
||||
} else {
|
||||
_cliTools().logger.error(`Failed to launch emulator. Reason: ${_chalk().default.dim(result.error || '')}.`);
|
||||
|
||||
_cliTools().logger.warn('Please launch an emulator manually or connect a device. Otherwise app may fail to launch.');
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const tasks = args.tasks || ['install' + toPascalCase(args.variant)];
|
||||
const gradleArgs = getTaskNames(args.appFolder || androidProject.appName, tasks);
|
||||
|
||||
if (args.port != null) {
|
||||
gradleArgs.push('-PreactNativeDevServerPort=' + args.port);
|
||||
}
|
||||
|
||||
_cliTools().logger.info('Installing the app...');
|
||||
|
||||
_cliTools().logger.debug(`Running command "cd android && ${cmd} ${gradleArgs.join(' ')}"`);
|
||||
|
||||
await (0, _execa().default)(cmd, gradleArgs, {
|
||||
stdio: ['inherit', 'inherit', 'pipe'],
|
||||
cwd: androidProject.sourceDir
|
||||
});
|
||||
} catch (error) {
|
||||
throw createInstallError(error);
|
||||
}
|
||||
|
||||
(devices.length > 0 ? devices : [undefined]).forEach(device => {
|
||||
(0, _tryRunAdbReverse.default)(args.port, device);
|
||||
(0, _tryLaunchAppOnDevice.default)(device, packageName, adbPath, args);
|
||||
});
|
||||
}
|
||||
|
||||
function createInstallError(error) {
|
||||
const stderr = (error.stderr || '').toString();
|
||||
const docs = 'https://reactnative.dev/docs/environment-setup';
|
||||
let message = `Make sure you have the Android development environment set up: ${_chalk().default.underline.dim(docs)}`; // Pass the error message from the command to stdout because we pipe it to
|
||||
// parent process so it's not visible
|
||||
|
||||
_cliTools().logger.log(stderr); // Handle some common failures and make the errors more helpful
|
||||
|
||||
|
||||
if (stderr.includes('No connected devices')) {
|
||||
message = 'Make sure you have an Android emulator running or a device connected';
|
||||
} else if (stderr.includes('licences have not been accepted') || stderr.includes('accept the SDK license')) {
|
||||
message = `Please accept all necessary Android SDK licenses using Android SDK Manager: "${_chalk().default.bold('$ANDROID_HOME/tools/bin/sdkmanager --licenses')}"`;
|
||||
}
|
||||
|
||||
return new (_cliTools().CLIError)(`Failed to install the app. ${message}.`, error);
|
||||
}
|
||||
|
||||
var _default = runOnAllDevices;
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=runOnAllDevices.js.map
|
69
node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/tryLaunchAppOnDevice.js
generated
vendored
Normal file
69
node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/tryLaunchAppOnDevice.js
generated
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _execa() {
|
||||
const data = _interopRequireDefault(require("execa"));
|
||||
|
||||
_execa = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _cliTools() {
|
||||
const data = require("@react-native-community/cli-tools");
|
||||
|
||||
_cliTools = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
function tryLaunchAppOnDevice(device, packageName, adbPath, args) {
|
||||
const {
|
||||
appId,
|
||||
appIdSuffix
|
||||
} = args;
|
||||
const packageNameWithSuffix = [appId || packageName, appIdSuffix].filter(Boolean).join('.');
|
||||
const activityToLaunch = args.mainActivity.includes('.') ? args.mainActivity : [packageName, args.mainActivity].filter(Boolean).join('.');
|
||||
|
||||
try {
|
||||
const adbArgs = ['shell', 'am', 'start', '-n', `${packageNameWithSuffix}/${activityToLaunch}`];
|
||||
|
||||
if (device) {
|
||||
adbArgs.unshift('-s', device);
|
||||
|
||||
_cliTools().logger.info(`Starting the app on "${device}"...`);
|
||||
} else {
|
||||
_cliTools().logger.info('Starting the app...');
|
||||
}
|
||||
|
||||
_cliTools().logger.debug(`Running command "${adbPath} ${adbArgs.join(' ')}"`);
|
||||
|
||||
_execa().default.sync(adbPath, adbArgs, {
|
||||
stdio: 'inherit'
|
||||
});
|
||||
} catch (error) {
|
||||
throw new (_cliTools().CLIError)('Failed to start the app.', error);
|
||||
}
|
||||
}
|
||||
|
||||
var _default = tryLaunchAppOnDevice;
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=tryLaunchAppOnDevice.js.map
|
103
node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/tryLaunchEmulator.js
generated
vendored
Normal file
103
node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/tryLaunchEmulator.js
generated
vendored
Normal file
@ -0,0 +1,103 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = tryLaunchEmulator;
|
||||
|
||||
function _os() {
|
||||
const data = _interopRequireDefault(require("os"));
|
||||
|
||||
_os = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _execa() {
|
||||
const data = _interopRequireDefault(require("execa"));
|
||||
|
||||
_execa = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _adb = _interopRequireDefault(require("./adb"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
const emulatorCommand = process.env.ANDROID_HOME ? `${process.env.ANDROID_HOME}/emulator/emulator` : 'emulator';
|
||||
|
||||
const getEmulators = () => {
|
||||
try {
|
||||
const emulatorsOutput = _execa().default.sync(emulatorCommand, ['-list-avds']).stdout;
|
||||
|
||||
return emulatorsOutput.split(_os().default.EOL).filter(name => name !== '');
|
||||
} catch (_unused) {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
const launchEmulator = async (emulatorName, adbPath) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const cp = (0, _execa().default)(emulatorCommand, [`@${emulatorName}`], {
|
||||
detached: true,
|
||||
stdio: 'ignore'
|
||||
});
|
||||
cp.unref();
|
||||
const timeout = 30; // Reject command after timeout
|
||||
|
||||
const rejectTimeout = setTimeout(() => {
|
||||
cleanup();
|
||||
reject(`Could not start emulator within ${timeout} seconds.`);
|
||||
}, timeout * 1000);
|
||||
const bootCheckInterval = setInterval(() => {
|
||||
if (_adb.default.getDevices(adbPath).length > 0) {
|
||||
cleanup();
|
||||
resolve();
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
const cleanup = () => {
|
||||
clearTimeout(rejectTimeout);
|
||||
clearInterval(bootCheckInterval);
|
||||
};
|
||||
|
||||
cp.on('exit', () => {
|
||||
cleanup();
|
||||
reject('Emulator exited before boot.');
|
||||
});
|
||||
cp.on('error', error => {
|
||||
cleanup();
|
||||
reject(error.message);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
async function tryLaunchEmulator(adbPath) {
|
||||
const emulators = getEmulators();
|
||||
|
||||
if (emulators.length > 0) {
|
||||
try {
|
||||
await launchEmulator(emulators[0], adbPath);
|
||||
return {
|
||||
success: true
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
success: false,
|
||||
error
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
success: false,
|
||||
error: 'No emulators found as an output of `emulator -list-avds`'
|
||||
};
|
||||
}
|
||||
|
||||
//# sourceMappingURL=tryLaunchEmulator.js.map
|
64
node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/tryRunAdbReverse.js
generated
vendored
Normal file
64
node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/tryRunAdbReverse.js
generated
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _child_process() {
|
||||
const data = require("child_process");
|
||||
|
||||
_child_process = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _cliTools() {
|
||||
const data = require("@react-native-community/cli-tools");
|
||||
|
||||
_cliTools = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _getAdbPath = _interopRequireDefault(require("./getAdbPath"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
// Runs ADB reverse tcp:8081 tcp:8081 to allow loading the jsbundle from the packager
|
||||
function tryRunAdbReverse(packagerPort, device) {
|
||||
try {
|
||||
const adbPath = (0, _getAdbPath.default)();
|
||||
const adbArgs = ['reverse', `tcp:${packagerPort}`, `tcp:${packagerPort}`]; // If a device is specified then tell adb to use it
|
||||
|
||||
if (device) {
|
||||
adbArgs.unshift('-s', device);
|
||||
}
|
||||
|
||||
_cliTools().logger.info('Connecting to the development server...');
|
||||
|
||||
_cliTools().logger.debug(`Running command "${adbPath} ${adbArgs.join(' ')}"`);
|
||||
|
||||
(0, _child_process().execFileSync)(adbPath, adbArgs, {
|
||||
stdio: 'inherit'
|
||||
});
|
||||
} catch (e) {
|
||||
_cliTools().logger.warn(`Failed to connect to development server using "adb reverse": ${e.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
var _default = tryRunAdbReverse;
|
||||
exports.default = _default;
|
||||
|
||||
//# sourceMappingURL=tryRunAdbReverse.js.map
|
Reference in New Issue
Block a user