feat(smart-app): implement complete mobile app MVP

- App.tsx: full navigation (Auth stack + Main tabs with 5 screens)
- Auth: LoginScreen, RegisterScreen, ForgotPasswordScreen
- HomeScreen: dashboard with IoT metrics, weather widget, alerts, quick actions, sensors
- MapScreen: interactive map with layer toggles (6 layers)
- MarketplaceScreen: categories (6), products (5), search
- ChatScreen: AI chat with quick prompts (4), bot responses
- ProfileScreen: user info, stats, menu (9 items), logout
- AlertsScreen: alert list with severity, acknowledge
- SensorsScreen: sensor list with type filters (6 types), search
- ZonesScreen: zone cards with stats
- SettingsScreen: language picker (FR/EN/ES/DE), privacy, about
- Stores: iotStore (sensors, zones, alerts), notificationStore, uiStore + i18n
- Hooks: useSensors, useAlerts, useNotifications, useLocation
- Components: Card, Button, LoadingSpinner, ErrorBoundary, Header
- Services: iotService, notificationService (with axios API client)
- Utils: formatters (temp, AQI, noise, dates), validators (email, password, IBAN)
- Theme: colors.ts with full design system (Blue Ocean palette)
- Ditto: fixed MongoDB connection, new JWT secrets, official gateway image
This commit is contained in:
Eric FELIXINE
2026-06-01 18:00:35 -04:00
parent 08ca495bde
commit e30ae8ed09
35578 changed files with 3703534 additions and 43 deletions

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 react-native-community
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,126 @@
# @react-native-community/cli-platform-android
This package is part of the [React Native CLI](../../README.md). It contains commands for managing the Android part of React Native app.
## Installation
```sh
yarn add @react-native-community/cli-platform-android
```
## Commands
### `run-android`
Usage:
```sh
npx react-native run-android [options]
```
Builds your app and starts it on a connected Android emulator or device.
#### Options
#### `--appId <string>`
Specify an `applicationId` to launch after build. If not specified, `package` from AndroidManifest.xml will be used.
#### `--appIdSuffix <string>`
Specify an `applicationIdSuffix` to launch after build.
#### `--main-activity <string>`
> default: 'MainActivity'
Name of the activity to start.
#### `--deviceId <string>`
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).
#### `--no-packager`
Do not launch packager while building.
#### `--port <number>`
> default: process.env.RCT_METRO_PORT || 8081
#### `--terminal <string>`
> default: process.env.REACT_TERMINAL || process.env.TERM_PROGRAM
Launches the Metro Bundler in a new window using the specified terminal path.
#### `--tasks <list>`
> default: 'installDebug'
Run custom gradle tasks. If this argument is provided, then `--mode` option is ignored.
Example: `yarn react-native run-android --tasks clean,installDebug`.
#### `--active-arch-only`
> default: false
Build native libraries only for the current device architecture for debug builds.
#### `--list-devices`
> default: false
List all available Android devices and simulators and let you choose one to run the app.
#### `--interactive`
Manually select a task and device/simulator you want to run your app on.
> [!WARNING]
> This flag is running `./gradlew tasks` under the hood, which might take some time for more complex apps. If that affects your project, consider using `--mode` and `--deviceId` flags instead.
### `build-android`
Usage:
```sh
npx react-native build-android [options]
```
Builds Android app.
#### Options
#### `--mode <string>`
> default: debug
Mode to build the app. Either 'debug' (default) or 'release'.
#### `--extra-params <string>`
Custom params that will be passed to gradle build command.
Example:
```sh
npx react-native build-android --extra-params "-x lint -x test"
```
#### `--binary-path <path>`
Installs passed binary instead of building a fresh one. This command is not compatible with `--tasks`.
#### `--user` <number | string>
Id of the User Profile you want to install the app on.
### `log-android`
Usage:
```sh
npx react-native log-android
```
Starts [`logkitty`](https://github.com/zamotany/logkitty) displaying pretty Android logs.

View File

@@ -0,0 +1,49 @@
import { Config } from '@react-native-community/cli-types';
export interface BuildFlags {
mode?: string;
activeArchOnly?: boolean;
tasks?: Array<string>;
extraParams?: Array<string>;
interactive?: boolean;
}
declare function buildAndroid(_argv: Array<string>, config: Config, args: BuildFlags): Promise<void>;
export declare function build(gradleArgs: string[], sourceDir: string): void;
export declare const options: ({
name: string;
description: string;
parse?: undefined;
default?: undefined;
} | {
name: string;
description: string;
parse: (val: string) => string[];
default?: undefined;
} | {
name: string;
description: string;
default: boolean;
parse?: undefined;
})[];
declare const _default: {
name: string;
description: string;
func: typeof buildAndroid;
options: ({
name: string;
description: string;
parse?: undefined;
default?: undefined;
} | {
name: string;
description: string;
parse: (val: string) => string[];
default?: undefined;
} | {
name: string;
description: string;
default: boolean;
parse?: undefined;
})[];
};
export default _default;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/buildAndroid/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,MAAM,EAAC,MAAM,mCAAmC,CAAC;AAQzD,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACtB,WAAW,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,iBAAe,YAAY,CACzB,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,EACpB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,UAAU,iBAuDjB;AAED,wBAAgB,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,QAc5D;AAED,eAAO,MAAM,OAAO;;;;;;;;iBASH,MAAM;;;;;;;IAkBtB,CAAC;;;;;;;;;;;;;;;;;;;;;;AAEF,wBAKE"}

View File

@@ -0,0 +1,105 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.build = build;
exports.options = exports.default = void 0;
function _cliTools() {
const data = require("@react-native-community/cli-tools");
_cliTools = function () {
return data;
};
return data;
}
function _execa() {
const data = _interopRequireDefault(require("execa"));
_execa = function () {
return data;
};
return data;
}
var _getAndroidProject = require("../../config/getAndroidProject");
var _adb = _interopRequireDefault(require("../runAndroid/adb"));
var _getAdbPath = _interopRequireDefault(require("../runAndroid/getAdbPath"));
var _getTaskNames = require("../runAndroid/getTaskNames");
var _listAndroidTasks = require("../runAndroid/listAndroidTasks");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
async function buildAndroid(_argv, config, args) {
const androidProject = (0, _getAndroidProject.getAndroidProject)(config);
if (args.tasks && args.mode) {
_cliTools().logger.warn('Both "tasks" and "mode" parameters were passed to "build" command. Using "tasks" for building the app.');
}
let {
tasks
} = args;
if (args.interactive) {
const selectedTask = await (0, _listAndroidTasks.promptForTaskSelection)('build', androidProject.sourceDir);
if (selectedTask) {
tasks = [selectedTask];
}
}
let gradleArgs = (0, _getTaskNames.getTaskNames)(androidProject.appName, args.mode, tasks, 'bundle');
if (args.extraParams) {
gradleArgs.push(...args.extraParams);
}
if (args.activeArchOnly) {
const adbPath = (0, _getAdbPath.default)();
const devices = _adb.default.getDevices(adbPath);
const architectures = devices.map(device => {
return _adb.default.getCPU(adbPath, device);
}).filter((arch, index, array) => arch != null && array.indexOf(arch) === index);
if (architectures.length > 0) {
_cliTools().logger.info(`Detected architectures ${architectures.join(', ')}`);
// `reactNativeDebugArchitectures` was renamed to `reactNativeArchitectures` in 0.68.
// Can be removed when 0.67 no longer needs to be supported.
gradleArgs.push('-PreactNativeDebugArchitectures=' + architectures.join(','));
gradleArgs.push('-PreactNativeArchitectures=' + architectures.join(','));
}
}
return build(gradleArgs, androidProject.sourceDir);
}
function build(gradleArgs, sourceDir) {
process.chdir(sourceDir);
const cmd = process.platform.startsWith('win') ? 'gradlew.bat' : './gradlew';
_cliTools().logger.info('Building the app...');
_cliTools().logger.debug(`Running command "${cmd} ${gradleArgs.join(' ')}"`);
try {
_execa().default.sync(cmd, gradleArgs, {
stdio: 'inherit',
cwd: sourceDir
});
} catch (error) {
(0, _cliTools().printRunDoctorTip)();
throw new (_cliTools().CLIError)('Failed to build the app.', error);
}
}
const options = [{
name: '--mode <string>',
description: "Specify your app's build variant"
}, {
name: '--tasks <list>',
description: 'Run custom Gradle tasks. By default it\'s "assembleDebug". Will override passed mode and variant arguments.',
parse: val => val.split(',')
}, {
name: '--active-arch-only',
description: 'Build native libraries only for the current device architecture for debug builds.',
default: false
}, {
name: '--extra-params <string>',
description: 'Custom params passed to gradle build command',
parse: val => val.split(' ')
}, {
name: '--interactive',
description: 'Explicitly select build type and flavour to use before running a build'
}];
exports.options = options;
var _default = {
name: 'build-android',
description: 'builds your app',
func: buildAndroid,
options
};
exports.default = _default;
//# sourceMappingURL=index.ts.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,42 @@
declare const _default: ({
name: string;
description: string;
func: () => Promise<void>;
} | {
name: string;
description: string;
func: (_argv: string[], config: import("@react-native-community/cli-types").Config, args: import("./runAndroid").Flags) => Promise<void>;
options: ({
name: string;
description: string;
parse?: undefined;
default?: undefined;
} | {
name: string;
description: string;
parse: (val: string) => string[];
default?: undefined;
} | {
name: string;
description: string;
default: boolean;
parse?: undefined;
} | {
name: string;
default: string | number;
parse: NumberConstructor;
description?: undefined;
} | {
name: string;
description: string;
default: string | undefined;
parse?: undefined;
} | {
name: string;
description: string;
parse: NumberConstructor;
default?: undefined;
})[];
})[];
export default _default;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,wBAAsD"}

View File

@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _buildAndroid = _interopRequireDefault(require("./buildAndroid"));
var _logAndroid = _interopRequireDefault(require("./logAndroid"));
var _runAndroid = _interopRequireDefault(require("./runAndroid"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = [_logAndroid.default, _runAndroid.default, _buildAndroid.default];
exports.default = _default;
//# sourceMappingURL=index.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["logAndroid","runAndroid","buildAndroid"],"sources":["../../src/commands/index.ts"],"sourcesContent":["import buildAndroid from './buildAndroid';\nimport logAndroid from './logAndroid';\nimport runAndroid from './runAndroid';\n\nexport default [logAndroid, runAndroid, buildAndroid];\n"],"mappings":";;;;;;AAAA;AACA;AACA;AAAsC;AAAA,eAEvB,CAACA,mBAAU,EAAEC,mBAAU,EAAEC,qBAAY,CAAC;AAAA"}

View File

@@ -0,0 +1,14 @@
/**
* 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.
*/
declare function logAndroid(): Promise<void>;
declare const _default: {
name: string;
description: string;
func: typeof logAndroid;
};
export default _default;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/logAndroid/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAWH,iBAAe,UAAU,kBAgBxB;;;;;;AAED,wBAIE"}

View File

@@ -0,0 +1,49 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
function _logkitty() {
const data = require("logkitty");
_logkitty = function () {
return data;
};
return data;
}
function _cliTools() {
const data = require("@react-native-community/cli-tools");
_cliTools = 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.
*/
async function logAndroid() {
_cliTools().logger.info('Starting logkitty');
const emitter = (0, _logkitty().logkitty)({
platform: 'android',
priority: _logkitty().AndroidPriority.VERBOSE,
filter: (0, _logkitty().makeTagsFilter)('ReactNative', 'ReactNativeJS')
});
emitter.on('entry', entry => {
_cliTools().logger.log((0, _logkitty().formatEntry)(entry));
});
emitter.on('error', error => {
_cliTools().logger.log((0, _logkitty().formatError)(error));
});
}
var _default = {
name: 'log-android',
description: 'starts logkitty',
func: logAndroid
};
exports.default = _default;
//# sourceMappingURL=index.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["logAndroid","logger","info","emitter","logkitty","platform","priority","AndroidPriority","VERBOSE","filter","makeTagsFilter","on","entry","log","formatEntry","error","formatError","name","description","func"],"sources":["../../../src/commands/logAndroid/index.ts"],"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 {\n logkitty,\n makeTagsFilter,\n formatEntry,\n formatError,\n AndroidPriority,\n} from 'logkitty';\nimport {logger} from '@react-native-community/cli-tools';\n\nasync function logAndroid() {\n logger.info('Starting logkitty');\n\n const emitter = logkitty({\n platform: 'android',\n priority: AndroidPriority.VERBOSE,\n filter: makeTagsFilter('ReactNative', 'ReactNativeJS'),\n });\n\n emitter.on('entry', (entry) => {\n logger.log(formatEntry(entry));\n });\n\n emitter.on('error', (error) => {\n logger.log(formatError(error));\n });\n}\n\nexport default {\n name: 'log-android',\n description: 'starts logkitty',\n func: logAndroid,\n};\n"],"mappings":";;;;;;AAOA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAOA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAdA;AACA;AACA;AACA;AACA;AACA;;AAWA,eAAeA,UAAU,GAAG;EAC1BC,kBAAM,CAACC,IAAI,CAAC,mBAAmB,CAAC;EAEhC,MAAMC,OAAO,GAAG,IAAAC,oBAAQ,EAAC;IACvBC,QAAQ,EAAE,SAAS;IACnBC,QAAQ,EAAEC,2BAAe,CAACC,OAAO;IACjCC,MAAM,EAAE,IAAAC,0BAAc,EAAC,aAAa,EAAE,eAAe;EACvD,CAAC,CAAC;EAEFP,OAAO,CAACQ,EAAE,CAAC,OAAO,EAAGC,KAAK,IAAK;IAC7BX,kBAAM,CAACY,GAAG,CAAC,IAAAC,uBAAW,EAACF,KAAK,CAAC,CAAC;EAChC,CAAC,CAAC;EAEFT,OAAO,CAACQ,EAAE,CAAC,OAAO,EAAGI,KAAK,IAAK;IAC7Bd,kBAAM,CAACY,GAAG,CAAC,IAAAG,uBAAW,EAACD,KAAK,CAAC,CAAC;EAChC,CAAC,CAAC;AACJ;AAAC,eAEc;EACbE,IAAI,EAAE,aAAa;EACnBC,WAAW,EAAE,iBAAiB;EAC9BC,IAAI,EAAEnB;AACR,CAAC;AAAA"}

View File

@@ -0,0 +1,3 @@
declare const _default: () => Promise<boolean>;
export default _default;
//# sourceMappingURL=tryLaunchEmulator.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"tryLaunchEmulator.d.ts","sourceRoot":"","sources":["../../../../src/commands/runAndroid/__mocks__/tryLaunchEmulator.ts"],"names":[],"mappings":";AAAA,wBAAgC"}

View File

@@ -0,0 +1,26 @@
/**
* 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.
*
*/
/**
* Executes the commands needed to get a list of devices from ADB
*/
declare function getDevices(adbPath: string): Array<string>;
/**
* Gets available CPUs of devices from ADB
*/
declare function getAvailableCPUs(adbPath: string, device: string): Array<string>;
/**
* Gets the CPU architecture of a device from ADB
*/
declare function getCPU(adbPath: string, device: string): string | null;
declare const _default: {
getDevices: typeof getDevices;
getAvailableCPUs: typeof getAvailableCPUs;
getCPU: typeof getCPU;
};
export default _default;
//# sourceMappingURL=adb.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"adb.d.ts","sourceRoot":"","sources":["../../../src/commands/runAndroid/adb.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAyBH;;GAEG;AACH,iBAAS,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAOlD;AAED;;GAEG;AACH,iBAAS,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAqBxE;AAED;;GAEG;AACH,iBAAS,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAgB9D;;;;;;AAED,wBAIE"}

View File

@@ -0,0 +1,88 @@
"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 [];
}
}
/**
* Gets the CPU architecture of a device from ADB
*/
function getCPU(adbPath, device) {
try {
const cpus = (0, _child_process().execFileSync)(adbPath, ['-s', device, 'shell', 'getprop', 'ro.product.cpu.abi']).toString().trim();
return cpus.length > 0 ? cpus : null;
} catch (e) {
return null;
}
}
var _default = {
getDevices,
getAvailableCPUs,
getCPU
};
exports.default = _default;
//# sourceMappingURL=adb.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["parseDevicesResult","result","devices","lines","trim","split","i","length","words","filter","w","push","getDevices","adbPath","devicesResult","execSync","toString","e","getAvailableCPUs","device","baseArgs","cpus","execFileSync","concat","getCPU"],"sources":["../../../src/commands/runAndroid/adb.ts"],"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 {execSync, execFileSync} from 'child_process';\n\n/**\n * Parses the output of the 'adb devices' command\n */\nfunction parseDevicesResult(result: string): Array<string> {\n if (!result) {\n return [];\n }\n\n const devices = [];\n const lines = result.trim().split(/\\r?\\n/);\n\n for (let i = 0; i < lines.length; i++) {\n const words = lines[i].split(/[ ,\\t]+/).filter((w) => w !== '');\n\n if (words[1] === 'device') {\n devices.push(words[0]);\n }\n }\n return devices;\n}\n\n/**\n * Executes the commands needed to get a list of devices from ADB\n */\nfunction getDevices(adbPath: string): Array<string> {\n try {\n const devicesResult = execSync(`\"${adbPath}\" devices`);\n return parseDevicesResult(devicesResult.toString());\n } catch (e) {\n return [];\n }\n}\n\n/**\n * Gets available CPUs of devices from ADB\n */\nfunction getAvailableCPUs(adbPath: string, device: string): Array<string> {\n try {\n const baseArgs = ['-s', device, 'shell', 'getprop'];\n\n let cpus = execFileSync(\n adbPath,\n baseArgs.concat(['ro.product.cpu.abilist']),\n ).toString();\n\n // pre-Lollipop\n if (!cpus || cpus.trim().length === 0) {\n cpus = execFileSync(\n adbPath,\n baseArgs.concat(['ro.product.cpu.abi']),\n ).toString();\n }\n\n return (cpus || '').trim().split(',');\n } catch (e) {\n return [];\n }\n}\n\n/**\n * Gets the CPU architecture of a device from ADB\n */\nfunction getCPU(adbPath: string, device: string): string | null {\n try {\n const cpus = execFileSync(adbPath, [\n '-s',\n device,\n 'shell',\n 'getprop',\n 'ro.product.cpu.abi',\n ])\n .toString()\n .trim();\n\n return cpus.length > 0 ? cpus : null;\n } catch (e) {\n return null;\n }\n}\n\nexport default {\n getDevices,\n getAvailableCPUs,\n getCPU,\n};\n"],"mappings":";;;;;;AAQA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AARA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACA,SAASA,kBAAkB,CAACC,MAAc,EAAiB;EACzD,IAAI,CAACA,MAAM,EAAE;IACX,OAAO,EAAE;EACX;EAEA,MAAMC,OAAO,GAAG,EAAE;EAClB,MAAMC,KAAK,GAAGF,MAAM,CAACG,IAAI,EAAE,CAACC,KAAK,CAAC,OAAO,CAAC;EAE1C,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGH,KAAK,CAACI,MAAM,EAAED,CAAC,EAAE,EAAE;IACrC,MAAME,KAAK,GAAGL,KAAK,CAACG,CAAC,CAAC,CAACD,KAAK,CAAC,SAAS,CAAC,CAACI,MAAM,CAAEC,CAAC,IAAKA,CAAC,KAAK,EAAE,CAAC;IAE/D,IAAIF,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;MACzBN,OAAO,CAACS,IAAI,CAACH,KAAK,CAAC,CAAC,CAAC,CAAC;IACxB;EACF;EACA,OAAON,OAAO;AAChB;;AAEA;AACA;AACA;AACA,SAASU,UAAU,CAACC,OAAe,EAAiB;EAClD,IAAI;IACF,MAAMC,aAAa,GAAG,IAAAC,yBAAQ,EAAE,IAAGF,OAAQ,WAAU,CAAC;IACtD,OAAOb,kBAAkB,CAACc,aAAa,CAACE,QAAQ,EAAE,CAAC;EACrD,CAAC,CAAC,OAAOC,CAAC,EAAE;IACV,OAAO,EAAE;EACX;AACF;;AAEA;AACA;AACA;AACA,SAASC,gBAAgB,CAACL,OAAe,EAAEM,MAAc,EAAiB;EACxE,IAAI;IACF,MAAMC,QAAQ,GAAG,CAAC,IAAI,EAAED,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC;IAEnD,IAAIE,IAAI,GAAG,IAAAC,6BAAY,EACrBT,OAAO,EACPO,QAAQ,CAACG,MAAM,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAC5C,CAACP,QAAQ,EAAE;;IAEZ;IACA,IAAI,CAACK,IAAI,IAAIA,IAAI,CAACjB,IAAI,EAAE,CAACG,MAAM,KAAK,CAAC,EAAE;MACrCc,IAAI,GAAG,IAAAC,6BAAY,EACjBT,OAAO,EACPO,QAAQ,CAACG,MAAM,CAAC,CAAC,oBAAoB,CAAC,CAAC,CACxC,CAACP,QAAQ,EAAE;IACd;IAEA,OAAO,CAACK,IAAI,IAAI,EAAE,EAAEjB,IAAI,EAAE,CAACC,KAAK,CAAC,GAAG,CAAC;EACvC,CAAC,CAAC,OAAOY,CAAC,EAAE;IACV,OAAO,EAAE;EACX;AACF;;AAEA;AACA;AACA;AACA,SAASO,MAAM,CAACX,OAAe,EAAEM,MAAc,EAAiB;EAC9D,IAAI;IACF,MAAME,IAAI,GAAG,IAAAC,6BAAY,EAACT,OAAO,EAAE,CACjC,IAAI,EACJM,MAAM,EACN,OAAO,EACP,SAAS,EACT,oBAAoB,CACrB,CAAC,CACCH,QAAQ,EAAE,CACVZ,IAAI,EAAE;IAET,OAAOiB,IAAI,CAACd,MAAM,GAAG,CAAC,GAAGc,IAAI,GAAG,IAAI;EACtC,CAAC,CAAC,OAAOJ,CAAC,EAAE;IACV,OAAO,IAAI;EACb;AACF;AAAC,eAEc;EACbL,UAAU;EACVM,gBAAgB;EAChBM;AACF,CAAC;AAAA"}

View File

@@ -0,0 +1,3 @@
declare function getAdbPath(): string;
export default getAdbPath;
//# sourceMappingURL=getAdbPath.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getAdbPath.d.ts","sourceRoot":"","sources":["../../../src/commands/runAndroid/getAdbPath.ts"],"names":[],"mappings":"AASA,iBAAS,UAAU,WAIlB;AAED,eAAe,UAAU,CAAC"}

View File

@@ -0,0 +1,29 @@
"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 _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 getAdbPath() {
return process.env.ANDROID_HOME ? _path().default.join(process.env.ANDROID_HOME, 'platform-tools', 'adb') : 'adb';
}
var _default = getAdbPath;
exports.default = _default;
//# sourceMappingURL=getAdbPath.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["getAdbPath","process","env","ANDROID_HOME","path","join"],"sources":["../../../src/commands/runAndroid/getAdbPath.ts"],"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';\n\nfunction getAdbPath() {\n return process.env.ANDROID_HOME\n ? path.join(process.env.ANDROID_HOME, 'platform-tools', 'adb')\n : 'adb';\n}\n\nexport default getAdbPath;\n"],"mappings":";;;;;;AAOA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAwB;AAPxB;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,UAAU,GAAG;EACpB,OAAOC,OAAO,CAACC,GAAG,CAACC,YAAY,GAC3BC,eAAI,CAACC,IAAI,CAACJ,OAAO,CAACC,GAAG,CAACC,YAAY,EAAE,gBAAgB,EAAE,KAAK,CAAC,GAC5D,KAAK;AACX;AAAC,eAEcH,UAAU;AAAA"}

View File

@@ -0,0 +1,3 @@
import type { BuildFlags } from '../buildAndroid';
export declare function getTaskNames(appName: string, mode: string | undefined, tasks: BuildFlags['tasks'], taskPrefix: 'assemble' | 'install' | 'bundle'): Array<string>;
//# sourceMappingURL=getTaskNames.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getTaskNames.d.ts","sourceRoot":"","sources":["../../../src/commands/runAndroid/getTaskNames.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAEhD,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,IAAI,oBAA8B,EAClC,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,EAC1B,UAAU,EAAE,UAAU,GAAG,SAAS,GAAG,QAAQ,GAC5C,KAAK,CAAC,MAAM,CAAC,CAOf"}

View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getTaskNames = getTaskNames;
var _toPascalCase = require("./toPascalCase");
function getTaskNames(appName, mode = 'debug', tasks, taskPrefix) {
const appTasks = tasks && tasks.length ? tasks : [taskPrefix + (0, _toPascalCase.toPascalCase)(mode)];
return appName ? appTasks.map(command => `${appName}:${command}`) : appTasks;
}
//# sourceMappingURL=getTaskNames.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["getTaskNames","appName","mode","tasks","taskPrefix","appTasks","length","toPascalCase","map","command"],"sources":["../../../src/commands/runAndroid/getTaskNames.ts"],"sourcesContent":["import {toPascalCase} from './toPascalCase';\nimport type {BuildFlags} from '../buildAndroid';\n\nexport function getTaskNames(\n appName: string,\n mode: BuildFlags['mode'] = 'debug',\n tasks: BuildFlags['tasks'],\n taskPrefix: 'assemble' | 'install' | 'bundle',\n): Array<string> {\n const appTasks =\n tasks && tasks.length ? tasks : [taskPrefix + toPascalCase(mode)];\n\n return appName\n ? appTasks.map((command) => `${appName}:${command}`)\n : appTasks;\n}\n"],"mappings":";;;;;;AAAA;AAGO,SAASA,YAAY,CAC1BC,OAAe,EACfC,IAAwB,GAAG,OAAO,EAClCC,KAA0B,EAC1BC,UAA6C,EAC9B;EACf,MAAMC,QAAQ,GACZF,KAAK,IAAIA,KAAK,CAACG,MAAM,GAAGH,KAAK,GAAG,CAACC,UAAU,GAAG,IAAAG,0BAAY,EAACL,IAAI,CAAC,CAAC;EAEnE,OAAOD,OAAO,GACVI,QAAQ,CAACG,GAAG,CAAEC,OAAO,IAAM,GAAER,OAAQ,IAAGQ,OAAQ,EAAC,CAAC,GAClDJ,QAAQ;AACd"}

View File

@@ -0,0 +1,62 @@
import { Config } from '@react-native-community/cli-types';
import adb from './adb';
import tryRunAdbReverse from './tryRunAdbReverse';
import getAdbPath from './getAdbPath';
import listAndroidDevices from './listAndroidDevices';
import { BuildFlags } from '../buildAndroid';
export interface Flags extends BuildFlags {
appId: string;
appIdSuffix: string;
mainActivity?: string;
port: number;
terminal?: string;
packager?: boolean;
deviceId?: string;
listDevices?: boolean;
binaryPath?: string;
user?: number | string;
}
export type AndroidProject = NonNullable<Config['project']['android']>;
/**
* Starts the app on a connected Android emulator or device.
*/
declare function runAndroid(_argv: Array<string>, config: Config, args: Flags): Promise<void>;
declare const _default: {
name: string;
description: string;
func: typeof runAndroid;
options: ({
name: string;
description: string;
parse?: undefined;
default?: undefined;
} | {
name: string;
description: string;
parse: (val: string) => string[];
default?: undefined;
} | {
name: string;
description: string;
default: boolean;
parse?: undefined;
} | {
name: string;
default: string | number;
parse: NumberConstructor;
description?: undefined;
} | {
name: string;
description: string;
default: string | undefined;
parse?: undefined;
} | {
name: string;
description: string;
parse: NumberConstructor;
default?: undefined;
})[];
};
export default _default;
export { adb, getAdbPath, listAndroidDevices, tryRunAdbReverse };
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/runAndroid/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAC,MAAM,EAAC,MAAM,mCAAmC,CAAC;AACzD,OAAO,GAAG,MAAM,OAAO,CAAC;AAExB,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAGlD,OAAO,UAAU,MAAM,cAAc,CAAC;AAUtC,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AAItD,OAAO,EAAQ,UAAU,EAAU,MAAM,iBAAiB,CAAC;AAK3D,MAAM,WAAW,KAAM,SAAQ,UAAU;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB;AAED,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;AAEvE;;GAEG;AACH,iBAAe,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,iBAmD1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6LD,wBA4DE;AAEF,OAAO,EAAC,GAAG,EAAE,UAAU,EAAE,kBAAkB,EAAE,gBAAgB,EAAC,CAAC"}

View File

@@ -0,0 +1,280 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "adb", {
enumerable: true,
get: function () {
return _adb.default;
}
});
exports.default = void 0;
Object.defineProperty(exports, "getAdbPath", {
enumerable: true,
get: function () {
return _getAdbPath.default;
}
});
Object.defineProperty(exports, "listAndroidDevices", {
enumerable: true,
get: function () {
return _listAndroidDevices.default;
}
});
Object.defineProperty(exports, "tryRunAdbReverse", {
enumerable: true,
get: function () {
return _tryRunAdbReverse.default;
}
});
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 _tryInstallAppOnDevice = _interopRequireDefault(require("./tryInstallAppOnDevice"));
var _getAdbPath = _interopRequireDefault(require("./getAdbPath"));
function _cliTools() {
const data = require("@react-native-community/cli-tools");
_cliTools = function () {
return data;
};
return data;
}
var _getAndroidProject = require("../../config/getAndroidProject");
var _listAndroidDevices = _interopRequireDefault(require("./listAndroidDevices"));
var _tryLaunchEmulator = _interopRequireDefault(require("./tryLaunchEmulator"));
function _chalk() {
const data = _interopRequireDefault(require("chalk"));
_chalk = function () {
return data;
};
return data;
}
function _path() {
const data = _interopRequireDefault(require("path"));
_path = function () {
return data;
};
return data;
}
var _buildAndroid = require("../buildAndroid");
var _listAndroidTasks = require("./listAndroidTasks");
var _getTaskNames = require("./getTaskNames");
var _listAndroidUsers = require("./listAndroidUsers");
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.
*
*/
/**
* Starts the app on a connected Android emulator or device.
*/
async function runAndroid(_argv, config, args) {
_cliTools().link.setPlatform('android');
let {
packager,
port
} = args;
if (packager) {
const {
port: newPort,
startPackager
} = await (0, _cliTools().findDevServerPort)(port, config.root);
if (startPackager) {
// Awaiting this causes the CLI to hang indefinitely, so this must execute without await.
(0, _cliTools().startServerInNewWindow)(newPort, config.root, config.reactNativePath, args.terminal);
}
}
if (config.reactNativeVersion !== 'unknown') {
_cliTools().link.setVersion(config.reactNativeVersion);
}
if (args.binaryPath) {
if (args.tasks) {
throw new (_cliTools().CLIError)('binary-path and tasks were specified, but they are not compatible. Specify only one');
}
args.binaryPath = _path().default.isAbsolute(args.binaryPath) ? args.binaryPath : _path().default.join(config.root, args.binaryPath);
if (args.binaryPath && !_fs().default.existsSync(args.binaryPath)) {
throw new (_cliTools().CLIError)('binary-path was specified, but the file was not found.');
}
}
let androidProject = (0, _getAndroidProject.getAndroidProject)(config);
if (args.mainActivity) {
androidProject.mainActivity = args.mainActivity;
}
return buildAndRun(args, androidProject);
}
const defaultPort = 5552;
async function getAvailableDevicePort(port = defaultPort) {
/**
* The default value is 5554 for the first virtual device instance running on your machine. A virtual device normally occupies a pair of adjacent ports: a console port and an adb port. The console of the first virtual device running on a particular machine uses console port 5554 and adb port 5555. Subsequent instances use port numbers increasing by two. For example, 5556/5557, 5558/5559, and so on. The range is 5554 to 5682, allowing for 64 concurrent virtual devices.
*/
const adbPath = (0, _getAdbPath.default)();
const devices = _adb.default.getDevices(adbPath);
if (port > 5682) {
throw new (_cliTools().CLIError)('Failed to launch emulator...');
}
if (devices.some(d => d.includes(port.toString()))) {
return await getAvailableDevicePort(port + 2);
}
return port;
}
// Builds the app and runs it on a connected emulator / device.
async function buildAndRun(args, androidProject) {
process.chdir(androidProject.sourceDir);
const cmd = process.platform.startsWith('win') ? 'gradlew.bat' : './gradlew';
const adbPath = (0, _getAdbPath.default)();
let selectedTask;
if (args.interactive) {
const task = await (0, _listAndroidTasks.promptForTaskSelection)('install', androidProject.sourceDir);
if (task) {
selectedTask = task;
}
}
if (args.listDevices || args.interactive) {
if (args.deviceId) {
_cliTools().logger.warn('Both "deviceId" and "list-devices" parameters were passed to "run" command. We will list available devices and let you choose from one');
}
const device = await (0, _listAndroidDevices.default)();
if (!device) {
throw new (_cliTools().CLIError)(`Failed to select device, please try to run app without ${args.listDevices ? 'list-devices' : 'interactive'} command.`);
}
if (args.interactive) {
const users = (0, _listAndroidUsers.checkUsers)(device.deviceId, adbPath);
if (users && users.length > 1) {
const user = await (0, _listAndroidUsers.promptForUser)(users);
if (user) {
args.user = user.id;
}
}
}
if (device.connected) {
return runOnSpecificDevice({
...args,
deviceId: device.deviceId
}, adbPath, androidProject, selectedTask);
}
const port = await getAvailableDevicePort();
const emulator = `emulator-${port}`;
_cliTools().logger.info('Launching emulator...');
const result = await (0, _tryLaunchEmulator.default)(adbPath, device.readableName, port);
if (result.success) {
_cliTools().logger.info('Successfully launched emulator.');
return runOnSpecificDevice({
...args,
deviceId: emulator
}, adbPath, androidProject, selectedTask);
}
throw new (_cliTools().CLIError)(`Failed to launch emulator. Reason: ${_chalk().default.dim(result.error || '')}`);
}
if (args.deviceId) {
return runOnSpecificDevice(args, adbPath, androidProject, selectedTask);
} else {
return (0, _runOnAllDevices.default)(args, cmd, adbPath, androidProject);
}
}
function runOnSpecificDevice(args, adbPath, androidProject, selectedTask) {
const devices = _adb.default.getDevices(adbPath);
const {
deviceId
} = args;
// if coming from run-android command and we have selected task
// from interactive mode we need to create appropriate build task
// eg 'installRelease' -> 'assembleRelease'
const buildTask = selectedTask ? [selectedTask.replace('install', 'assemble')] : [];
if (devices.length > 0 && deviceId) {
if (devices.indexOf(deviceId) !== -1) {
let gradleArgs = (0, _getTaskNames.getTaskNames)(androidProject.appName, args.mode, args.tasks ?? buildTask, 'install');
// using '-x lint' in order to ignore linting errors while building the apk
gradleArgs.push('-x', 'lint');
if (args.extraParams) {
gradleArgs.push(...args.extraParams);
}
if (args.port) {
gradleArgs.push(`-PreactNativeDevServerPort=${args.port}`);
}
if (args.activeArchOnly) {
const architecture = _adb.default.getCPU(adbPath, deviceId);
if (architecture !== null) {
_cliTools().logger.info(`Detected architecture ${architecture}`);
// `reactNativeDebugArchitectures` was renamed to `reactNativeArchitectures` in 0.68.
// Can be removed when 0.67 no longer needs to be supported.
gradleArgs.push(`-PreactNativeDebugArchitectures=${architecture}`);
gradleArgs.push(`-PreactNativeArchitectures=${architecture}`);
}
}
if (!args.binaryPath) {
(0, _buildAndroid.build)(gradleArgs, androidProject.sourceDir);
}
installAndLaunchOnDevice(args, deviceId, adbPath, androidProject, selectedTask);
} 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 installAndLaunchOnDevice(args, selectedDevice, adbPath, androidProject, selectedTask) {
(0, _tryRunAdbReverse.default)(args.port, selectedDevice);
(0, _tryInstallAppOnDevice.default)(args, adbPath, selectedDevice, androidProject, selectedTask);
(0, _tryLaunchAppOnDevice.default)(selectedDevice, androidProject, adbPath, args);
}
var _default = {
name: 'run-android',
description: 'builds your app and starts it on a connected Android emulator or device',
func: runAndroid,
options: [..._buildAndroid.options, {
name: '--no-packager',
description: 'Do not launch packager while running the app'
}, {
name: '--port <number>',
default: process.env.RCT_METRO_PORT || 8081,
parse: Number
}, {
name: '--terminal <string>',
description: 'Launches the Metro Bundler in a new window using the specified terminal path.',
default: (0, _cliTools().getDefaultUserTerminal)()
}, {
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'
}, {
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: '--list-devices',
description: 'Lists all available Android devices and simulators and let you choose one to run the app',
default: false
}, {
name: '--binary-path <string>',
description: 'Path relative to project root where pre-built .apk binary lives.'
}, {
name: '--user <number>',
description: 'Id of the User Profile you want to install the app on.',
parse: Number
}]
};
exports.default = _default;
//# sourceMappingURL=index.ts.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,9 @@
type DeviceData = {
deviceId: string | undefined;
readableName: string;
connected: boolean;
type: 'emulator' | 'phone';
};
declare function listAndroidDevices(): Promise<DeviceData | undefined>;
export default listAndroidDevices;
//# sourceMappingURL=listAndroidDevices.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"listAndroidDevices.d.ts","sourceRoot":"","sources":["../../../src/commands/runAndroid/listAndroidDevices.ts"],"names":[],"mappings":"AASA,KAAK,UAAU,GAAG;IAChB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC;CAC5B,CAAC;AA2DF,iBAAe,kBAAkB,oCA6ChC;AAED,eAAe,kBAAkB,CAAC"}

View File

@@ -0,0 +1,126 @@
"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;
}
var _adb = _interopRequireDefault(require("./adb"));
var _getAdbPath = _interopRequireDefault(require("./getAdbPath"));
var _tryLaunchEmulator = require("./tryLaunchEmulator");
var _toPascalCase = require("./toPascalCase");
function _os() {
const data = _interopRequireDefault(require("os"));
_os = function () {
return data;
};
return data;
}
function _chalk() {
const data = _interopRequireDefault(require("chalk"));
_chalk = 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 }; }
/**
*
* @param deviceId string
* @returns name of Android emulator
*/
function getEmulatorName(deviceId) {
const adbPath = (0, _getAdbPath.default)();
const buffer = (0, _child_process().execSync)(`${adbPath} -s ${deviceId} emu avd name`);
// 1st line should get us emu name
return buffer.toString().split(_os().default.EOL)[0].replace(/(\r\n|\n|\r)/gm, '').trim();
}
/**
*
* @param deviceId string
* @returns Android device name in readable format
*/
function getPhoneName(deviceId) {
const adbPath = (0, _getAdbPath.default)();
const buffer = (0, _child_process().execSync)(`${adbPath} -s ${deviceId} shell getprop | grep ro.product.model`);
return buffer.toString().replace(/\[ro\.product\.model\]:\s*\[(.*)\]/, '$1').trim();
}
async function promptForDeviceSelection(allDevices) {
if (!allDevices.length) {
throw new (_cliTools().CLIError)('No devices and/or emulators connected. Please create emulator with Android Studio or connect Android device.');
}
const {
device
} = await (0, _cliTools().prompt)({
type: 'select',
name: 'device',
message: 'Select the device / emulator you want to use',
choices: allDevices.map(d => ({
title: `${_chalk().default.bold(`${(0, _toPascalCase.toPascalCase)(d.type)}`)} ${_chalk().default.green(`${d.readableName}`)} (${d.connected ? 'connected' : 'disconnected'})`,
value: d
})),
min: 1
});
return device;
}
async function listAndroidDevices() {
const adbPath = (0, _getAdbPath.default)();
const devices = _adb.default.getDevices(adbPath);
let allDevices = [];
devices.forEach(deviceId => {
if (deviceId.includes('emulator')) {
const emulatorData = {
deviceId,
readableName: getEmulatorName(deviceId),
connected: true,
type: 'emulator'
};
allDevices = [...allDevices, emulatorData];
} else {
const phoneData = {
deviceId,
readableName: getPhoneName(deviceId),
type: 'phone',
connected: true
};
allDevices = [...allDevices, phoneData];
}
});
const emulators = (0, _tryLaunchEmulator.getEmulators)();
// Find not booted ones:
emulators.forEach(emulatorName => {
// skip those already booted
if (allDevices.some(device => device.readableName === emulatorName)) {
return;
}
const emulatorData = {
deviceId: undefined,
readableName: emulatorName,
type: 'emulator',
connected: false
};
allDevices = [...allDevices, emulatorData];
});
const selectedDevice = await promptForDeviceSelection(allDevices);
return selectedDevice;
}
var _default = listAndroidDevices;
exports.default = _default;
//# sourceMappingURL=listAndroidDevices.ts.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,9 @@
type GradleTask = {
task: string;
description: string;
};
export declare const parseTasksFromGradleFile: (taskType: 'install' | 'build', text: string) => Array<GradleTask>;
export declare const getGradleTasks: (taskType: 'install' | 'build', sourceDir: string) => GradleTask[];
export declare const promptForTaskSelection: (taskType: 'install' | 'build', sourceDir: string) => Promise<string | undefined>;
export {};
//# sourceMappingURL=listAndroidTasks.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"listAndroidTasks.d.ts","sourceRoot":"","sources":["../../../src/commands/runAndroid/listAndroidTasks.ts"],"names":[],"mappings":"AAIA,KAAK,UAAU,GAAG;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,wBAAwB,aACzB,SAAS,GAAG,OAAO,QACvB,MAAM,KACX,MAAM,UAAU,CAelB,CAAC;AAEF,eAAO,MAAM,cAAc,aACf,SAAS,GAAG,OAAO,aAClB,MAAM,iBAelB,CAAC;AAEF,eAAO,MAAM,sBAAsB,aACvB,SAAS,GAAG,OAAO,aAClB,MAAM,KAChB,QAAQ,MAAM,GAAG,SAAS,CAgB5B,CAAC"}

View File

@@ -0,0 +1,81 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.promptForTaskSelection = exports.parseTasksFromGradleFile = exports.getGradleTasks = void 0;
function _cliTools() {
const data = require("@react-native-community/cli-tools");
_cliTools = function () {
return data;
};
return data;
}
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 _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const parseTasksFromGradleFile = (taskType, text) => {
const instalTasks = [];
const taskRegex = new RegExp(taskType === 'build' ? '^assemble|^bundle' : '^install');
text.split('\n').forEach(line => {
if (taskRegex.test(line.trim()) && /(?!.*?Test)^.*$/.test(line.trim())) {
const metadata = line.split(' - ');
instalTasks.push({
task: metadata[0],
description: metadata[1]
});
}
});
return instalTasks;
};
exports.parseTasksFromGradleFile = parseTasksFromGradleFile;
const getGradleTasks = (taskType, sourceDir) => {
const loader = (0, _cliTools().getLoader)();
loader.start('Searching for available Gradle tasks...');
const cmd = process.platform.startsWith('win') ? 'gradlew.bat' : './gradlew';
try {
const out = _execa().default.sync(cmd, ['tasks', '--group', taskType], {
cwd: sourceDir
}).stdout;
loader.succeed();
return parseTasksFromGradleFile(taskType, out);
} catch {
loader.fail();
return [];
}
};
exports.getGradleTasks = getGradleTasks;
const promptForTaskSelection = async (taskType, sourceDir) => {
const tasks = getGradleTasks(taskType, sourceDir);
if (!tasks.length) {
throw new (_cliTools().CLIError)(`No actionable ${taskType} tasks were found...`);
}
const {
task
} = await (0, _cliTools().prompt)({
type: 'select',
name: 'task',
message: `Select ${taskType} task you want to perform`,
choices: tasks.map(t => ({
title: `${_chalk().default.bold(t.task)} - ${t.description}`,
value: t.task
})),
min: 1
});
return task;
};
exports.promptForTaskSelection = promptForTaskSelection;
//# sourceMappingURL=listAndroidTasks.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["parseTasksFromGradleFile","taskType","text","instalTasks","taskRegex","RegExp","split","forEach","line","test","trim","metadata","push","task","description","getGradleTasks","sourceDir","loader","getLoader","start","cmd","process","platform","startsWith","out","execa","sync","cwd","stdout","succeed","fail","promptForTaskSelection","tasks","length","CLIError","prompt","type","name","message","choices","map","t","title","chalk","bold","value","min"],"sources":["../../../src/commands/runAndroid/listAndroidTasks.ts"],"sourcesContent":["import {CLIError, getLoader, prompt} from '@react-native-community/cli-tools';\nimport chalk from 'chalk';\nimport execa from 'execa';\n\ntype GradleTask = {\n task: string;\n description: string;\n};\n\nexport const parseTasksFromGradleFile = (\n taskType: 'install' | 'build',\n text: string,\n): Array<GradleTask> => {\n const instalTasks: Array<GradleTask> = [];\n const taskRegex = new RegExp(\n taskType === 'build' ? '^assemble|^bundle' : '^install',\n );\n text.split('\\n').forEach((line) => {\n if (taskRegex.test(line.trim()) && /(?!.*?Test)^.*$/.test(line.trim())) {\n const metadata = line.split(' - ');\n instalTasks.push({\n task: metadata[0],\n description: metadata[1],\n });\n }\n });\n return instalTasks;\n};\n\nexport const getGradleTasks = (\n taskType: 'install' | 'build',\n sourceDir: string,\n) => {\n const loader = getLoader();\n loader.start('Searching for available Gradle tasks...');\n const cmd = process.platform.startsWith('win') ? 'gradlew.bat' : './gradlew';\n try {\n const out = execa.sync(cmd, ['tasks', '--group', taskType], {\n cwd: sourceDir,\n }).stdout;\n loader.succeed();\n return parseTasksFromGradleFile(taskType, out);\n } catch {\n loader.fail();\n return [];\n }\n};\n\nexport const promptForTaskSelection = async (\n taskType: 'install' | 'build',\n sourceDir: string,\n): Promise<string | undefined> => {\n const tasks = getGradleTasks(taskType, sourceDir);\n if (!tasks.length) {\n throw new CLIError(`No actionable ${taskType} tasks were found...`);\n }\n const {task}: {task: string} = await prompt({\n type: 'select',\n name: 'task',\n message: `Select ${taskType} task you want to perform`,\n choices: tasks.map((t: GradleTask) => ({\n title: `${chalk.bold(t.task)} - ${t.description}`,\n value: t.task,\n })),\n min: 1,\n });\n return task;\n};\n"],"mappings":";;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAA0B;AAOnB,MAAMA,wBAAwB,GAAG,CACtCC,QAA6B,EAC7BC,IAAY,KACU;EACtB,MAAMC,WAA8B,GAAG,EAAE;EACzC,MAAMC,SAAS,GAAG,IAAIC,MAAM,CAC1BJ,QAAQ,KAAK,OAAO,GAAG,mBAAmB,GAAG,UAAU,CACxD;EACDC,IAAI,CAACI,KAAK,CAAC,IAAI,CAAC,CAACC,OAAO,CAAEC,IAAI,IAAK;IACjC,IAAIJ,SAAS,CAACK,IAAI,CAACD,IAAI,CAACE,IAAI,EAAE,CAAC,IAAI,iBAAiB,CAACD,IAAI,CAACD,IAAI,CAACE,IAAI,EAAE,CAAC,EAAE;MACtE,MAAMC,QAAQ,GAAGH,IAAI,CAACF,KAAK,CAAC,KAAK,CAAC;MAClCH,WAAW,CAACS,IAAI,CAAC;QACfC,IAAI,EAAEF,QAAQ,CAAC,CAAC,CAAC;QACjBG,WAAW,EAAEH,QAAQ,CAAC,CAAC;MACzB,CAAC,CAAC;IACJ;EACF,CAAC,CAAC;EACF,OAAOR,WAAW;AACpB,CAAC;AAAC;AAEK,MAAMY,cAAc,GAAG,CAC5Bd,QAA6B,EAC7Be,SAAiB,KACd;EACH,MAAMC,MAAM,GAAG,IAAAC,qBAAS,GAAE;EAC1BD,MAAM,CAACE,KAAK,CAAC,yCAAyC,CAAC;EACvD,MAAMC,GAAG,GAAGC,OAAO,CAACC,QAAQ,CAACC,UAAU,CAAC,KAAK,CAAC,GAAG,aAAa,GAAG,WAAW;EAC5E,IAAI;IACF,MAAMC,GAAG,GAAGC,gBAAK,CAACC,IAAI,CAACN,GAAG,EAAE,CAAC,OAAO,EAAE,SAAS,EAAEnB,QAAQ,CAAC,EAAE;MAC1D0B,GAAG,EAAEX;IACP,CAAC,CAAC,CAACY,MAAM;IACTX,MAAM,CAACY,OAAO,EAAE;IAChB,OAAO7B,wBAAwB,CAACC,QAAQ,EAAEuB,GAAG,CAAC;EAChD,CAAC,CAAC,MAAM;IACNP,MAAM,CAACa,IAAI,EAAE;IACb,OAAO,EAAE;EACX;AACF,CAAC;AAAC;AAEK,MAAMC,sBAAsB,GAAG,OACpC9B,QAA6B,EAC7Be,SAAiB,KACe;EAChC,MAAMgB,KAAK,GAAGjB,cAAc,CAACd,QAAQ,EAAEe,SAAS,CAAC;EACjD,IAAI,CAACgB,KAAK,CAACC,MAAM,EAAE;IACjB,MAAM,KAAIC,oBAAQ,EAAE,iBAAgBjC,QAAS,sBAAqB,CAAC;EACrE;EACA,MAAM;IAACY;EAAoB,CAAC,GAAG,MAAM,IAAAsB,kBAAM,EAAC;IAC1CC,IAAI,EAAE,QAAQ;IACdC,IAAI,EAAE,MAAM;IACZC,OAAO,EAAG,UAASrC,QAAS,2BAA0B;IACtDsC,OAAO,EAAEP,KAAK,CAACQ,GAAG,CAAEC,CAAa,KAAM;MACrCC,KAAK,EAAG,GAAEC,gBAAK,CAACC,IAAI,CAACH,CAAC,CAAC5B,IAAI,CAAE,MAAK4B,CAAC,CAAC3B,WAAY,EAAC;MACjD+B,KAAK,EAAEJ,CAAC,CAAC5B;IACX,CAAC,CAAC,CAAC;IACHiC,GAAG,EAAE;EACP,CAAC,CAAC;EACF,OAAOjC,IAAI;AACb,CAAC;AAAC"}

View File

@@ -0,0 +1,8 @@
type User = {
id: string;
name: string;
};
export declare function checkUsers(device: string, adbPath: string): User[];
export declare function promptForUser(users: User[]): Promise<User>;
export {};
//# sourceMappingURL=listAndroidUsers.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"listAndroidUsers.d.ts","sourceRoot":"","sources":["../../../src/commands/runAndroid/listAndroidUsers.ts"],"names":[],"mappings":"AAGA,KAAK,IAAI,GAAG;IACV,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,UAgCzD;AAED,wBAAsB,aAAa,CAAC,KAAK,EAAE,IAAI,EAAE,iBAahD"}

View File

@@ -0,0 +1,69 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.checkUsers = checkUsers;
exports.promptForUser = promptForUser;
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 }; }
function checkUsers(device, adbPath) {
try {
const adbArgs = ['-s', device, 'shell', 'pm', 'list', 'users'];
_cliTools().logger.debug(`Checking users on "${device}"...`);
const {
stdout
} = _execa().default.sync(adbPath, adbArgs, {
encoding: 'utf-8'
});
const regex = new RegExp(/^\s*UserInfo\{(?<userId>\d+):(?<userName>.*):(?<userFlags>[0-9a-f]*)}/);
const users = [];
const lines = stdout.split('\n');
for (const line of lines) {
const res = regex.exec(line);
if (res === null || res === void 0 ? void 0 : res.groups) {
users.push({
id: res.groups.userId,
name: res.groups.userName
});
}
}
if (users.length > 1) {
_cliTools().logger.debug(`Available users are:\n${users.map(user => `${user.name} - ${user.id}`).join('\n')}`);
}
return users;
} catch (error) {
_cliTools().logger.error('Failed to check users of device.', error);
return [];
}
}
async function promptForUser(users) {
const {
selectedUser
} = await (0, _cliTools().prompt)({
type: 'select',
name: 'selectedUser',
message: 'Which profile would you like to launch your app into?',
choices: users.map(user => ({
title: user.name,
value: user
})),
min: 1
});
return selectedUser;
}
//# sourceMappingURL=listAndroidUsers.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["checkUsers","device","adbPath","adbArgs","logger","debug","stdout","execa","sync","encoding","regex","RegExp","users","lines","split","line","res","exec","groups","push","id","userId","name","userName","length","map","user","join","error","promptForUser","selectedUser","prompt","type","message","choices","title","value","min"],"sources":["../../../src/commands/runAndroid/listAndroidUsers.ts"],"sourcesContent":["import execa from 'execa';\nimport {logger, prompt} from '@react-native-community/cli-tools';\n\ntype User = {\n id: string;\n name: string;\n};\n\nexport function checkUsers(device: string, adbPath: string) {\n try {\n const adbArgs = ['-s', device, 'shell', 'pm', 'list', 'users'];\n\n logger.debug(`Checking users on \"${device}\"...`);\n const {stdout} = execa.sync(adbPath, adbArgs, {encoding: 'utf-8'});\n const regex = new RegExp(\n /^\\s*UserInfo\\{(?<userId>\\d+):(?<userName>.*):(?<userFlags>[0-9a-f]*)}/,\n );\n const users: User[] = [];\n\n const lines = stdout.split('\\n');\n for (const line of lines) {\n const res = regex.exec(line);\n if (res?.groups) {\n users.push({id: res.groups.userId, name: res.groups.userName});\n }\n }\n\n if (users.length > 1) {\n logger.debug(\n `Available users are:\\n${users\n .map((user) => `${user.name} - ${user.id}`)\n .join('\\n')}`,\n );\n }\n\n return users;\n } catch (error) {\n logger.error('Failed to check users of device.', error as any);\n return [];\n }\n}\n\nexport async function promptForUser(users: User[]) {\n const {selectedUser}: {selectedUser: User} = await prompt({\n type: 'select',\n name: 'selectedUser',\n message: 'Which profile would you like to launch your app into?',\n choices: users.map((user: User) => ({\n title: user.name,\n value: user,\n })),\n min: 1,\n });\n\n return selectedUser;\n}\n"],"mappings":";;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAiE;AAO1D,SAASA,UAAU,CAACC,MAAc,EAAEC,OAAe,EAAE;EAC1D,IAAI;IACF,MAAMC,OAAO,GAAG,CAAC,IAAI,EAAEF,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC;IAE9DG,kBAAM,CAACC,KAAK,CAAE,sBAAqBJ,MAAO,MAAK,CAAC;IAChD,MAAM;MAACK;IAAM,CAAC,GAAGC,gBAAK,CAACC,IAAI,CAACN,OAAO,EAAEC,OAAO,EAAE;MAACM,QAAQ,EAAE;IAAO,CAAC,CAAC;IAClE,MAAMC,KAAK,GAAG,IAAIC,MAAM,CACtB,uEAAuE,CACxE;IACD,MAAMC,KAAa,GAAG,EAAE;IAExB,MAAMC,KAAK,GAAGP,MAAM,CAACQ,KAAK,CAAC,IAAI,CAAC;IAChC,KAAK,MAAMC,IAAI,IAAIF,KAAK,EAAE;MACxB,MAAMG,GAAG,GAAGN,KAAK,CAACO,IAAI,CAACF,IAAI,CAAC;MAC5B,IAAIC,GAAG,aAAHA,GAAG,uBAAHA,GAAG,CAAEE,MAAM,EAAE;QACfN,KAAK,CAACO,IAAI,CAAC;UAACC,EAAE,EAAEJ,GAAG,CAACE,MAAM,CAACG,MAAM;UAAEC,IAAI,EAAEN,GAAG,CAACE,MAAM,CAACK;QAAQ,CAAC,CAAC;MAChE;IACF;IAEA,IAAIX,KAAK,CAACY,MAAM,GAAG,CAAC,EAAE;MACpBpB,kBAAM,CAACC,KAAK,CACT,yBAAwBO,KAAK,CAC3Ba,GAAG,CAAEC,IAAI,IAAM,GAAEA,IAAI,CAACJ,IAAK,MAAKI,IAAI,CAACN,EAAG,EAAC,CAAC,CAC1CO,IAAI,CAAC,IAAI,CAAE,EAAC,CAChB;IACH;IAEA,OAAOf,KAAK;EACd,CAAC,CAAC,OAAOgB,KAAK,EAAE;IACdxB,kBAAM,CAACwB,KAAK,CAAC,kCAAkC,EAAEA,KAAK,CAAQ;IAC9D,OAAO,EAAE;EACX;AACF;AAEO,eAAeC,aAAa,CAACjB,KAAa,EAAE;EACjD,MAAM;IAACkB;EAAkC,CAAC,GAAG,MAAM,IAAAC,kBAAM,EAAC;IACxDC,IAAI,EAAE,QAAQ;IACdV,IAAI,EAAE,cAAc;IACpBW,OAAO,EAAE,uDAAuD;IAChEC,OAAO,EAAEtB,KAAK,CAACa,GAAG,CAAEC,IAAU,KAAM;MAClCS,KAAK,EAAET,IAAI,CAACJ,IAAI;MAChBc,KAAK,EAAEV;IACT,CAAC,CAAC,CAAC;IACHW,GAAG,EAAE;EACP,CAAC,CAAC;EAEF,OAAOP,YAAY;AACrB"}

View File

@@ -0,0 +1,13 @@
/**
* 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.
*
*/
import { Config } from '@react-native-community/cli-types';
import type { Flags } from '.';
type AndroidProject = NonNullable<Config['project']['android']>;
declare function runOnAllDevices(args: Flags, cmd: string, adbPath: string, androidProject: AndroidProject): Promise<void>;
export default runOnAllDevices;
//# sourceMappingURL=runOnAllDevices.d.ts.map

View File

@@ -0,0 +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;AAazD,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,GAAG,CAAC;AAE7B,KAAK,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,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,cAAc,iBAmF/B;AAqCD,eAAe,eAAe,CAAC"}

View File

@@ -0,0 +1,121 @@
"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"));
var _tryInstallAppOnDevice = _interopRequireDefault(require("./tryInstallAppOnDevice"));
var _getTaskNames = require("./getTaskNames");
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.
*
*/
async function runOnAllDevices(args, cmd, 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 {
if (!args.binaryPath) {
let gradleArgs = (0, _getTaskNames.getTaskNames)(androidProject.appName, args.mode, args.tasks, 'install');
if (args.extraParams) {
gradleArgs.push(...args.extraParams);
}
if (args.port != null) {
gradleArgs.push('-PreactNativeDevServerPort=' + args.port);
}
if (args.activeArchOnly) {
const architectures = devices.map(device => {
return _adb.default.getCPU(adbPath, device);
}).filter((arch, index, array) => arch != null && array.indexOf(arch) === index);
if (architectures.length > 0) {
_cliTools().logger.info(`Detected architectures ${architectures.join(', ')}`);
// `reactNativeDebugArchitectures` was renamed to `reactNativeArchitectures` in 0.68.
// Can be removed when 0.67 no longer needs to be supported.
gradleArgs.push('-PreactNativeDebugArchitectures=' + architectures.join(','));
gradleArgs.push('-PreactNativeArchitectures=' + architectures.join(','));
}
}
_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) {
(0, _cliTools().printRunDoctorTip)();
throw createInstallError(error);
}
(devices.length > 0 ? devices : [undefined]).forEach(device => {
(0, _tryRunAdbReverse.default)(args.port, device);
if (args.binaryPath && device) {
(0, _tryInstallAppOnDevice.default)(args, adbPath, device, androidProject);
}
(0, _tryLaunchAppOnDevice.default)(device, androidProject, adbPath, args);
});
}
function createInstallError(error) {
const stderr = (error.stderr || '').toString();
let message = '';
// 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')}."`;
} else if (stderr.includes('requires Java')) {
message = `Looks like your Android environment is not properly set. Please go to ${_chalk().default.dim.underline(_cliTools().link.docs('environment-setup', 'android', {
hash: 'jdk-studio',
guide: 'native'
}))} and follow the React Native CLI QuickStart guide to install the compatible version of JDK.`;
} else {
message = error.message;
}
return new (_cliTools().CLIError)(`Failed to install the app.${message ? ' ' + message : ''}`, error.message.length > 0 ? undefined : error);
}
var _default = runOnAllDevices;
exports.default = _default;
//# sourceMappingURL=runOnAllDevices.ts.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
export declare function toPascalCase(value: string): string;
//# sourceMappingURL=toPascalCase.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"toPascalCase.d.ts","sourceRoot":"","sources":["../../../src/commands/runAndroid/toPascalCase.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,UAEzC"}

View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.toPascalCase = toPascalCase;
function toPascalCase(value) {
return value !== '' ? value[0].toUpperCase() + value.slice(1) : value;
}
//# sourceMappingURL=toPascalCase.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["toPascalCase","value","toUpperCase","slice"],"sources":["../../../src/commands/runAndroid/toPascalCase.ts"],"sourcesContent":["export function toPascalCase(value: string) {\n return value !== '' ? value[0].toUpperCase() + value.slice(1) : value;\n}\n"],"mappings":";;;;;;AAAO,SAASA,YAAY,CAACC,KAAa,EAAE;EAC1C,OAAOA,KAAK,KAAK,EAAE,GAAGA,KAAK,CAAC,CAAC,CAAC,CAACC,WAAW,EAAE,GAAGD,KAAK,CAACE,KAAK,CAAC,CAAC,CAAC,GAAGF,KAAK;AACvE"}

View File

@@ -0,0 +1,4 @@
import type { AndroidProject, Flags } from './';
declare function tryInstallAppOnDevice(args: Flags, adbPath: string, device: string, androidProject: AndroidProject, selectedTask?: string): void;
export default tryInstallAppOnDevice;
//# sourceMappingURL=tryInstallAppOnDevice.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"tryInstallAppOnDevice.d.ts","sourceRoot":"","sources":["../../../src/commands/runAndroid/tryInstallAppOnDevice.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,cAAc,EAAE,KAAK,EAAC,MAAM,IAAI,CAAC;AAE9C,iBAAS,qBAAqB,CAC5B,IAAI,EAAE,KAAK,EACX,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,cAAc,EAC9B,YAAY,CAAC,EAAE,MAAM,QAiDtB;AA4BD,eAAe,qBAAqB,CAAC"}

View File

@@ -0,0 +1,90 @@
"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 _fs() {
const data = _interopRequireDefault(require("fs"));
_fs = 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"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function tryInstallAppOnDevice(args, adbPath, device, androidProject, selectedTask) {
try {
var _variantFromSelectedT, _variantFromSelectedT2;
// "app" is usually the default value for Android apps with only 1 app
const {
appName,
sourceDir
} = androidProject;
const defaultVariant = (args.mode || 'debug').toLowerCase();
// handle if selected task from interactive mode includes build flavour as well, eg. installProductionDebug should create ['production','debug'] array
const variantFromSelectedTask = selectedTask === null || selectedTask === void 0 ? void 0 : selectedTask.replace('install', '').split(/(?=[A-Z])/);
// create path to output file, eg. `production/debug`
const variantPath = (variantFromSelectedTask === null || variantFromSelectedTask === void 0 ? void 0 : (_variantFromSelectedT = variantFromSelectedTask.join('/')) === null || _variantFromSelectedT === void 0 ? void 0 : _variantFromSelectedT.toLowerCase()) ?? defaultVariant;
// create output file name, eg. `production-debug`
const variantAppName = (variantFromSelectedTask === null || variantFromSelectedTask === void 0 ? void 0 : (_variantFromSelectedT2 = variantFromSelectedTask.join('-')) === null || _variantFromSelectedT2 === void 0 ? void 0 : _variantFromSelectedT2.toLowerCase()) ?? defaultVariant;
let pathToApk;
if (!args.binaryPath) {
const buildDirectory = `${sourceDir}/${appName}/build/outputs/apk/${variantPath}`;
const apkFile = getInstallApkName(appName, adbPath, variantAppName, device, buildDirectory);
pathToApk = `${buildDirectory}/${apkFile}`;
} else {
pathToApk = args.binaryPath;
}
const installArgs = ['-s', device, 'install', '-r', '-d'];
if (args.user !== undefined) {
installArgs.push('--user', `${args.user}`);
}
const adbArgs = [...installArgs, pathToApk];
_cliTools().logger.info(`Installing the app on the device "${device}"...`);
_cliTools().logger.debug(`Running command "cd android && adb ${adbArgs.join(' ')}"`);
_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 Error('Could not find the correct install APK file.');
}
var _default = tryInstallAppOnDevice;
exports.default = _default;
//# sourceMappingURL=tryInstallAppOnDevice.ts.map

View File

@@ -0,0 +1,11 @@
/**
* 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.
*
*/
import { AndroidProject, Flags } from '.';
declare function tryLaunchAppOnDevice(device: string | void, androidProject: AndroidProject, adbPath: string, args: Flags): void;
export default tryLaunchAppOnDevice;
//# sourceMappingURL=tryLaunchAppOnDevice.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"tryLaunchAppOnDevice.d.ts","sourceRoot":"","sources":["../../../src/commands/runAndroid/tryLaunchAppOnDevice.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAC,cAAc,EAAE,KAAK,EAAC,MAAM,GAAG,CAAC;AAGxC,iBAAS,oBAAoB,CAC3B,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,KAAK,QAyCZ;AAED,eAAe,oBAAoB,CAAC"}

View File

@@ -0,0 +1,62 @@
"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, androidProject, adbPath, args) {
const {
appId,
appIdSuffix
} = args;
const {
packageName,
mainActivity,
applicationId
} = androidProject;
const applicationIdWithSuffix = [appId || applicationId, appIdSuffix].filter(Boolean).join('.');
const activityToLaunch = mainActivity.startsWith(packageName) ? mainActivity : mainActivity.startsWith('.') ? [packageName, mainActivity].join('') : [packageName, mainActivity].filter(Boolean).join('.');
try {
// Here we're using the same flags as Android Studio to launch the app
const adbArgs = ['shell', 'am', 'start', '-n', `${applicationIdWithSuffix}/${activityToLaunch}`, '-a', 'android.intent.action.MAIN', '-c', 'android.intent.category.LAUNCHER'];
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.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["tryLaunchAppOnDevice","device","androidProject","adbPath","args","appId","appIdSuffix","packageName","mainActivity","applicationId","applicationIdWithSuffix","filter","Boolean","join","activityToLaunch","startsWith","adbArgs","unshift","logger","info","debug","execa","sync","stdio","error","CLIError"],"sources":["../../../src/commands/runAndroid/tryLaunchAppOnDevice.ts"],"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 execa from 'execa';\nimport {AndroidProject, Flags} from '.';\nimport {logger, CLIError} from '@react-native-community/cli-tools';\n\nfunction tryLaunchAppOnDevice(\n device: string | void,\n androidProject: AndroidProject,\n adbPath: string,\n args: Flags,\n) {\n const {appId, appIdSuffix} = args;\n\n const {packageName, mainActivity, applicationId} = androidProject;\n\n const applicationIdWithSuffix = [appId || applicationId, appIdSuffix]\n .filter(Boolean)\n .join('.');\n\n const activityToLaunch = mainActivity.startsWith(packageName)\n ? mainActivity\n : mainActivity.startsWith('.')\n ? [packageName, mainActivity].join('')\n : [packageName, mainActivity].filter(Boolean).join('.');\n\n try {\n // Here we're using the same flags as Android Studio to launch the app\n const adbArgs = [\n 'shell',\n 'am',\n 'start',\n '-n',\n `${applicationIdWithSuffix}/${activityToLaunch}`,\n '-a',\n 'android.intent.action.MAIN',\n '-c',\n 'android.intent.category.LAUNCHER',\n ];\n\n if (device) {\n adbArgs.unshift('-s', device);\n logger.info(`Starting the app on \"${device}\"...`);\n } else {\n logger.info('Starting the app...');\n }\n logger.debug(`Running command \"${adbPath} ${adbArgs.join(' ')}\"`);\n execa.sync(adbPath, adbArgs, {stdio: 'inherit'});\n } catch (error) {\n throw new CLIError('Failed to start the app.', error as any);\n }\n}\n\nexport default tryLaunchAppOnDevice;\n"],"mappings":";;;;;;AAQA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAmE;AAVnE;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA,SAASA,oBAAoB,CAC3BC,MAAqB,EACrBC,cAA8B,EAC9BC,OAAe,EACfC,IAAW,EACX;EACA,MAAM;IAACC,KAAK;IAAEC;EAAW,CAAC,GAAGF,IAAI;EAEjC,MAAM;IAACG,WAAW;IAAEC,YAAY;IAAEC;EAAa,CAAC,GAAGP,cAAc;EAEjE,MAAMQ,uBAAuB,GAAG,CAACL,KAAK,IAAII,aAAa,EAAEH,WAAW,CAAC,CAClEK,MAAM,CAACC,OAAO,CAAC,CACfC,IAAI,CAAC,GAAG,CAAC;EAEZ,MAAMC,gBAAgB,GAAGN,YAAY,CAACO,UAAU,CAACR,WAAW,CAAC,GACzDC,YAAY,GACZA,YAAY,CAACO,UAAU,CAAC,GAAG,CAAC,GAC5B,CAACR,WAAW,EAAEC,YAAY,CAAC,CAACK,IAAI,CAAC,EAAE,CAAC,GACpC,CAACN,WAAW,EAAEC,YAAY,CAAC,CAACG,MAAM,CAACC,OAAO,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC;EAEzD,IAAI;IACF;IACA,MAAMG,OAAO,GAAG,CACd,OAAO,EACP,IAAI,EACJ,OAAO,EACP,IAAI,EACH,GAAEN,uBAAwB,IAAGI,gBAAiB,EAAC,EAChD,IAAI,EACJ,4BAA4B,EAC5B,IAAI,EACJ,kCAAkC,CACnC;IAED,IAAIb,MAAM,EAAE;MACVe,OAAO,CAACC,OAAO,CAAC,IAAI,EAAEhB,MAAM,CAAC;MAC7BiB,kBAAM,CAACC,IAAI,CAAE,wBAAuBlB,MAAO,MAAK,CAAC;IACnD,CAAC,MAAM;MACLiB,kBAAM,CAACC,IAAI,CAAC,qBAAqB,CAAC;IACpC;IACAD,kBAAM,CAACE,KAAK,CAAE,oBAAmBjB,OAAQ,IAAGa,OAAO,CAACH,IAAI,CAAC,GAAG,CAAE,GAAE,CAAC;IACjEQ,gBAAK,CAACC,IAAI,CAACnB,OAAO,EAAEa,OAAO,EAAE;MAACO,KAAK,EAAE;IAAS,CAAC,CAAC;EAClD,CAAC,CAAC,OAAOC,KAAK,EAAE;IACd,MAAM,KAAIC,oBAAQ,EAAC,0BAA0B,EAAED,KAAK,CAAQ;EAC9D;AACF;AAAC,eAEcxB,oBAAoB;AAAA"}

View File

@@ -0,0 +1,6 @@
export declare const getEmulators: () => string[];
export default function tryLaunchEmulator(adbPath: string, emulatorName?: string, port?: number): Promise<{
success: boolean;
error?: string;
}>;
//# sourceMappingURL=tryLaunchEmulator.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"tryLaunchEmulator.d.ts","sourceRoot":"","sources":["../../../src/commands/runAndroid/tryLaunchEmulator.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,YAAY,gBAOxB,CAAC;AA2DF,wBAA8B,iBAAiB,CAC7C,OAAO,EAAE,MAAM,EACf,YAAY,CAAC,EAAE,MAAM,EACrB,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAC,CAAC,CAc7C"}

View File

@@ -0,0 +1,94 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = tryLaunchEmulator;
exports.getEmulators = void 0;
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 {
return [];
}
};
exports.getEmulators = getEmulators;
const launchEmulator = async (emulatorName, adbPath, port) => {
const manualCommand = `${emulatorCommand} @${emulatorName}`;
const cp = (0, _execa().default)(emulatorCommand, port ? [`@${emulatorName}`, '-port', `${port}`] : [`@${emulatorName}`], {
detached: true,
stdio: 'ignore'
});
cp.unref();
const timeout = 30;
return new Promise((resolve, reject) => {
const bootCheckInterval = setInterval(async () => {
const devices = _adb.default.getDevices(adbPath);
const connected = port ? devices.find(d => d.includes(`${port}`)) : devices.length > 0;
if (connected) {
cleanup();
resolve(true);
}
}, 1000);
// Reject command after timeout
const rejectTimeout = setTimeout(() => {
stopWaitingAndReject(`It took too long to start and connect with Android emulator: ${emulatorName}. You can try starting the emulator manually from the terminal with: ${manualCommand}`);
}, timeout * 1000);
const cleanup = () => {
clearTimeout(rejectTimeout);
clearInterval(bootCheckInterval);
};
const stopWaitingAndReject = message => {
cleanup();
reject(new Error(message));
};
cp.on('error', ({
message
}) => stopWaitingAndReject(message));
cp.on('exit', () => {
stopWaitingAndReject(`The emulator (${emulatorName}) quit before it finished opening. You can try starting the emulator manually from the terminal with: ${manualCommand}`);
});
});
};
async function tryLaunchEmulator(adbPath, emulatorName, port) {
const emulators = getEmulators();
if (emulators.length > 0) {
try {
await launchEmulator(emulatorName ?? emulators[0], adbPath, port);
return {
success: true
};
} catch (error) {
var _ref;
return {
success: false,
error: (_ref = error) === null || _ref === void 0 ? void 0 : _ref.message
};
}
}
return {
success: false,
error: 'No emulators found as an output of `emulator -list-avds`'
};
}
//# sourceMappingURL=tryLaunchEmulator.ts.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,10 @@
/**
* 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.
*
*/
declare function tryRunAdbReverse(packagerPort: number | string, device?: string | void): void;
export default tryRunAdbReverse;
//# sourceMappingURL=tryRunAdbReverse.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"tryRunAdbReverse.d.ts","sourceRoot":"","sources":["../../../src/commands/runAndroid/tryRunAdbReverse.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,iBAAS,gBAAgB,CACvB,YAAY,EAAE,MAAM,GAAG,MAAM,EAC7B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,QAsBvB;AAED,eAAe,gBAAgB,CAAC"}

View File

@@ -0,0 +1,53 @@
"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.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["tryRunAdbReverse","packagerPort","device","adbPath","getAdbPath","adbArgs","unshift","logger","info","debug","join","execFileSync","stdio","e","warn","message"],"sources":["../../../src/commands/runAndroid/tryRunAdbReverse.ts"],"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 {execFileSync} from 'child_process';\nimport {logger} from '@react-native-community/cli-tools';\nimport getAdbPath from './getAdbPath';\n\n// Runs ADB reverse tcp:8081 tcp:8081 to allow loading the jsbundle from the packager\nfunction tryRunAdbReverse(\n packagerPort: number | string,\n device?: string | void,\n) {\n try {\n const adbPath = getAdbPath();\n const adbArgs = ['reverse', `tcp:${packagerPort}`, `tcp:${packagerPort}`];\n\n // If a device is specified then tell adb to use it\n if (device) {\n adbArgs.unshift('-s', device);\n }\n\n logger.info('Connecting to the development server...');\n logger.debug(`Running command \"${adbPath} ${adbArgs.join(' ')}\"`);\n\n execFileSync(adbPath, adbArgs, {stdio: 'inherit'});\n } catch (e) {\n logger.warn(\n `Failed to connect to development server using \"adb reverse\": ${\n (e as any).message\n }`,\n );\n }\n}\n\nexport default tryRunAdbReverse;\n"],"mappings":";;;;;;AAQA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;AAAsC;AAVtC;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA,SAASA,gBAAgB,CACvBC,YAA6B,EAC7BC,MAAsB,EACtB;EACA,IAAI;IACF,MAAMC,OAAO,GAAG,IAAAC,mBAAU,GAAE;IAC5B,MAAMC,OAAO,GAAG,CAAC,SAAS,EAAG,OAAMJ,YAAa,EAAC,EAAG,OAAMA,YAAa,EAAC,CAAC;;IAEzE;IACA,IAAIC,MAAM,EAAE;MACVG,OAAO,CAACC,OAAO,CAAC,IAAI,EAAEJ,MAAM,CAAC;IAC/B;IAEAK,kBAAM,CAACC,IAAI,CAAC,yCAAyC,CAAC;IACtDD,kBAAM,CAACE,KAAK,CAAE,oBAAmBN,OAAQ,IAAGE,OAAO,CAACK,IAAI,CAAC,GAAG,CAAE,GAAE,CAAC;IAEjE,IAAAC,6BAAY,EAACR,OAAO,EAAEE,OAAO,EAAE;MAACO,KAAK,EAAE;IAAS,CAAC,CAAC;EACpD,CAAC,CAAC,OAAOC,CAAC,EAAE;IACVN,kBAAM,CAACO,IAAI,CACR,gEACED,CAAC,CAASE,OACZ,EAAC,CACH;EACH;AACF;AAAC,eAEcf,gBAAgB;AAAA"}

View File

@@ -0,0 +1,117 @@
/**
* 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.
*
*/
export declare const valid: {
'build.gradle': any;
src: {
'AndroidManifest.xml': any;
main: {
com: {
some: {
example: {
[x: string]: any;
'Main.java': any;
};
};
};
};
};
};
export declare const validKotlin: {
'build.gradle': any;
src: {
'AndroidManifest.xml': any;
main: {
com: {
some: {
example: {
[x: string]: any;
'Main.java': any;
};
};
};
};
};
};
export declare const validApp: {
'build.gradle': any;
app: {
'build.gradle': any;
};
src: {
'AndroidManifest.xml': any;
};
};
export declare const userConfigManifest: {
src: {
main: {
'AndroidManifest.xml': any;
com: {
some: {
example: {
'Main.java': any;
'ReactPackage.java': any;
};
};
};
};
debug: {
'AndroidManifest.xml': any;
};
};
};
export declare const corrupted: {
src: {
'AndroidManifest.xml': any;
main: {
com: {
some: {
example: {};
};
};
};
};
};
export declare const noPackage: {
src: {
'AndroidManifest.xml': any;
main: {
com: {
some: {
example: {
'Main.java': any;
};
};
};
};
};
};
export declare const findPackagesClassNameKotlinValid: string[];
export declare const findPackagesClassNameKotlinNotValid: string[];
export declare const findPackagesClassNameJavaValid: string[];
export declare const findPackagesClassNameJavaNotValid: string[];
export declare const fewActivities: {
src: {
'AndroidManifest.xml': any;
};
};
export declare const className: {
src: {
'AndroidManifest.xml': any;
};
};
export declare const customFlavor: {
src: {
e2e: {
'AndroidManifest.xml': any;
};
main: {
'AndroidManifest.xml': any;
};
};
};
//# sourceMappingURL=android.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"android.d.ts","sourceRoot":"","sources":["../../../src/config/__fixtures__/android.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAmEH,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;CAAwD,CAAC;AAE3E,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;CAAsD,CAAC;AAE/E,eAAO,MAAM,QAAQ;;;;;;;;CAAqC,CAAC;AAE3D,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;CAqB9B,CAAC;AAEF,eAAO,MAAM,SAAS;;;;;;;;;;;CAWrB,CAAC;AAEF,eAAO,MAAM,SAAS;;;;;;;;;;;;;CAarB,CAAC;AAEF,eAAO,MAAM,gCAAgC,UAsE5C,CAAC;AAEF,eAAO,MAAM,mCAAmC,UAuB/C,CAAC;AAEF,eAAO,MAAM,8BAA8B,UA6C1C,CAAC;AAEF,eAAO,MAAM,iCAAiC,UAqB7C,CAAC;AAEF,eAAO,MAAM,aAAa;;;;CAIzB,CAAC;AAEF,eAAO,MAAM,SAAS;;;;CAIrB,CAAC;AAEF,eAAO,MAAM,YAAY;;;;;;;;;CASxB,CAAC"}

View File

@@ -0,0 +1,75 @@
export declare const flat: {
android: {
'build.gradle': any;
src: {
'AndroidManifest.xml': any;
main: {
com: {
some: {
example: {
[x: string]: any;
'Main.java': any;
};
};
};
};
};
};
};
export declare const nested: {
android: {
app: {
'build.gradle': any;
src: {
'AndroidManifest.xml': any;
main: {
com: {
some: {
example: {
[x: string]: any;
'Main.java': any;
};
};
};
};
};
};
};
};
export declare const withExamples: {
Examples: {
android: {
'build.gradle': any;
src: {
'AndroidManifest.xml': any;
main: {
com: {
some: {
example: {
[x: string]: any;
'Main.java': any;
};
};
};
};
};
};
};
android: {
'build.gradle': any;
src: {
'AndroidManifest.xml': any;
main: {
com: {
some: {
example: {
[x: string]: any;
'Main.java': any;
};
};
};
};
};
};
};
//# sourceMappingURL=projects.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"projects.d.ts","sourceRoot":"","sources":["../../../src/config/__fixtures__/projects.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;CAEhB,CAAC;AAEF,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;CAIlB,CAAC;AAEF,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGxB,CAAC"}

View File

@@ -0,0 +1,2 @@
export declare function extractComponentDescriptors(contents: string): string | null;
//# sourceMappingURL=extractComponentDescriptors.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"extractComponentDescriptors.d.ts","sourceRoot":"","sources":["../../src/config/extractComponentDescriptors.ts"],"names":[],"mappings":"AAKA,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,MAAM,iBAM3D"}

View File

@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.extractComponentDescriptors = extractComponentDescriptors;
// TODO: avoid the regex and improve reliability by reading this data from codegen schema.json.
// Need to find a way to run "generateNewArchitectureFiles" gradle task after each library's "generateCodegenSchemaFromJavaScript" task.
const CODEGEN_NATIVE_COMPONENT_REGEX = /codegenNativeComponent(<.*>)?\s*\(\s*["'`](\w+)["'`](,?[\s\S]+interfaceOnly:\s*(\w+))?/m;
function extractComponentDescriptors(contents) {
const match = contents.match(CODEGEN_NATIVE_COMPONENT_REGEX);
if (!((match === null || match === void 0 ? void 0 : match[4]) === 'true') && (match === null || match === void 0 ? void 0 : match[2])) {
return `${match[2]}ComponentDescriptor`;
}
return null;
}
//# sourceMappingURL=extractComponentDescriptors.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["CODEGEN_NATIVE_COMPONENT_REGEX","extractComponentDescriptors","contents","match"],"sources":["../../src/config/extractComponentDescriptors.ts"],"sourcesContent":["// TODO: avoid the regex and improve reliability by reading this data from codegen schema.json.\n// Need to find a way to run \"generateNewArchitectureFiles\" gradle task after each library's \"generateCodegenSchemaFromJavaScript\" task.\nconst CODEGEN_NATIVE_COMPONENT_REGEX =\n /codegenNativeComponent(<.*>)?\\s*\\(\\s*[\"'`](\\w+)[\"'`](,?[\\s\\S]+interfaceOnly:\\s*(\\w+))?/m;\n\nexport function extractComponentDescriptors(contents: string) {\n const match = contents.match(CODEGEN_NATIVE_COMPONENT_REGEX);\n if (!(match?.[4] === 'true') && match?.[2]) {\n return `${match[2]}ComponentDescriptor`;\n }\n return null;\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA,MAAMA,8BAA8B,GAClC,yFAAyF;AAEpF,SAASC,2BAA2B,CAACC,QAAgB,EAAE;EAC5D,MAAMC,KAAK,GAAGD,QAAQ,CAACC,KAAK,CAACH,8BAA8B,CAAC;EAC5D,IAAI,EAAE,CAAAG,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAG,CAAC,CAAC,MAAK,MAAM,CAAC,KAAIA,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAG,CAAC,CAAC,GAAE;IAC1C,OAAQ,GAAEA,KAAK,CAAC,CAAC,CAAE,qBAAoB;EACzC;EACA,OAAO,IAAI;AACb"}

View File

@@ -0,0 +1,9 @@
/**
* 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.
*
*/
export default function findAndroidDir(root: string): "android" | null;
//# sourceMappingURL=findAndroidDir.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"findAndroidDir.d.ts","sourceRoot":"","sources":["../../src/config/findAndroidDir.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,IAAI,EAAE,MAAM,oBAMlD"}

View File

@@ -0,0 +1,37 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = findAndroidDir;
function _fs() {
const data = _interopRequireDefault(require("fs"));
_fs = function () {
return data;
};
return data;
}
function _path() {
const data = _interopRequireDefault(require("path"));
_path = 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 findAndroidDir(root) {
if (_fs().default.existsSync(_path().default.join(root, 'android'))) {
return 'android';
}
return null;
}
//# sourceMappingURL=findAndroidDir.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["findAndroidDir","root","fs","existsSync","path","join"],"sources":["../../src/config/findAndroidDir.ts"],"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 fs from 'fs';\nimport path from 'path';\n\nexport default function findAndroidDir(root: string) {\n if (fs.existsSync(path.join(root, 'android'))) {\n return 'android';\n }\n\n return null;\n}\n"],"mappings":";;;;;;AAQA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAwB;AATxB;AACA;AACA;AACA;AACA;AACA;AACA;;AAKe,SAASA,cAAc,CAACC,IAAY,EAAE;EACnD,IAAIC,aAAE,CAACC,UAAU,CAACC,eAAI,CAACC,IAAI,CAACJ,IAAI,EAAE,SAAS,CAAC,CAAC,EAAE;IAC7C,OAAO,SAAS;EAClB;EAEA,OAAO,IAAI;AACb"}

View File

@@ -0,0 +1,2 @@
export declare function findBuildGradle(sourceDir: string, isLibrary: boolean): string | null;
//# sourceMappingURL=findBuildGradle.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"findBuildGradle.d.ts","sourceRoot":"","sources":["../../src/config/findBuildGradle.ts"],"names":[],"mappings":"AAGA,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,iBAiBpE"}

View File

@@ -0,0 +1,34 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.findBuildGradle = findBuildGradle;
function _fs() {
const data = _interopRequireDefault(require("fs"));
_fs = function () {
return data;
};
return data;
}
function _path() {
const data = _interopRequireDefault(require("path"));
_path = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function findBuildGradle(sourceDir, isLibrary) {
const buildGradlePath = _path().default.join(sourceDir, isLibrary ? 'build.gradle' : 'app/build.gradle');
const buildGradleKtsPath = _path().default.join(sourceDir, isLibrary ? 'build.gradle.kts' : 'app/build.gradle.kts');
if (_fs().default.existsSync(buildGradlePath)) {
return buildGradlePath;
} else if (_fs().default.existsSync(buildGradleKtsPath)) {
return buildGradleKtsPath;
} else {
return null;
}
}
//# sourceMappingURL=findBuildGradle.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["findBuildGradle","sourceDir","isLibrary","buildGradlePath","path","join","buildGradleKtsPath","fs","existsSync"],"sources":["../../src/config/findBuildGradle.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nexport function findBuildGradle(sourceDir: string, isLibrary: boolean) {\n const buildGradlePath = path.join(\n sourceDir,\n isLibrary ? 'build.gradle' : 'app/build.gradle',\n );\n const buildGradleKtsPath = path.join(\n sourceDir,\n isLibrary ? 'build.gradle.kts' : 'app/build.gradle.kts',\n );\n\n if (fs.existsSync(buildGradlePath)) {\n return buildGradlePath;\n } else if (fs.existsSync(buildGradleKtsPath)) {\n return buildGradleKtsPath;\n } else {\n return null;\n }\n}\n"],"mappings":";;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAwB;AAEjB,SAASA,eAAe,CAACC,SAAiB,EAAEC,SAAkB,EAAE;EACrE,MAAMC,eAAe,GAAGC,eAAI,CAACC,IAAI,CAC/BJ,SAAS,EACTC,SAAS,GAAG,cAAc,GAAG,kBAAkB,CAChD;EACD,MAAMI,kBAAkB,GAAGF,eAAI,CAACC,IAAI,CAClCJ,SAAS,EACTC,SAAS,GAAG,kBAAkB,GAAG,sBAAsB,CACxD;EAED,IAAIK,aAAE,CAACC,UAAU,CAACL,eAAe,CAAC,EAAE;IAClC,OAAOA,eAAe;EACxB,CAAC,MAAM,IAAII,aAAE,CAACC,UAAU,CAACF,kBAAkB,CAAC,EAAE;IAC5C,OAAOA,kBAAkB;EAC3B,CAAC,MAAM;IACL,OAAO,IAAI;EACb;AACF"}

View File

@@ -0,0 +1,2 @@
export declare function findComponentDescriptors(packageRoot: string): string[];
//# sourceMappingURL=findComponentDescriptors.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"findComponentDescriptors.d.ts","sourceRoot":"","sources":["../../src/config/findComponentDescriptors.ts"],"names":[],"mappings":"AAMA,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,MAAM,YAgB3D"}

View File

@@ -0,0 +1,50 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.findComponentDescriptors = findComponentDescriptors;
function _fs() {
const data = _interopRequireDefault(require("fs"));
_fs = function () {
return data;
};
return data;
}
function _path() {
const data = _interopRequireDefault(require("path"));
_path = function () {
return data;
};
return data;
}
function _fastGlob() {
const data = _interopRequireDefault(require("fast-glob"));
_fastGlob = function () {
return data;
};
return data;
}
var _extractComponentDescriptors = require("./extractComponentDescriptors");
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 }; }
function findComponentDescriptors(packageRoot) {
const files = _fastGlob().default.sync('**/+(*.js|*.jsx|*.ts|*.tsx)', {
cwd: (0, _cliTools().unixifyPaths)(packageRoot),
onlyFiles: true,
ignore: ['**/node_modules/**']
});
const codegenComponent = files.map(filePath => _fs().default.readFileSync(_path().default.join(packageRoot, filePath), 'utf8')).map(_extractComponentDescriptors.extractComponentDescriptors).filter(Boolean);
// Filter out duplicates as it happens that libraries contain multiple outputs due to package publishing.
// TODO: consider using "codegenConfig" to avoid this.
return Array.from(new Set(codegenComponent));
}
//# sourceMappingURL=findComponentDescriptors.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["findComponentDescriptors","packageRoot","files","glob","sync","cwd","unixifyPaths","onlyFiles","ignore","codegenComponent","map","filePath","fs","readFileSync","path","join","extractComponentDescriptors","filter","Boolean","Array","from","Set"],"sources":["../../src/config/findComponentDescriptors.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport glob from 'fast-glob';\nimport {extractComponentDescriptors} from './extractComponentDescriptors';\nimport {unixifyPaths} from '@react-native-community/cli-tools';\n\nexport function findComponentDescriptors(packageRoot: string) {\n const files = glob.sync('**/+(*.js|*.jsx|*.ts|*.tsx)', {\n cwd: unixifyPaths(packageRoot),\n onlyFiles: true,\n ignore: ['**/node_modules/**'],\n });\n const codegenComponent = files\n .map((filePath) =>\n fs.readFileSync(path.join(packageRoot, filePath), 'utf8'),\n )\n .map(extractComponentDescriptors)\n .filter(Boolean);\n\n // Filter out duplicates as it happens that libraries contain multiple outputs due to package publishing.\n // TODO: consider using \"codegenConfig\" to avoid this.\n return Array.from(new Set(codegenComponent as string[]));\n}\n"],"mappings":";;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAA+D;AAExD,SAASA,wBAAwB,CAACC,WAAmB,EAAE;EAC5D,MAAMC,KAAK,GAAGC,mBAAI,CAACC,IAAI,CAAC,6BAA6B,EAAE;IACrDC,GAAG,EAAE,IAAAC,wBAAY,EAACL,WAAW,CAAC;IAC9BM,SAAS,EAAE,IAAI;IACfC,MAAM,EAAE,CAAC,oBAAoB;EAC/B,CAAC,CAAC;EACF,MAAMC,gBAAgB,GAAGP,KAAK,CAC3BQ,GAAG,CAAEC,QAAQ,IACZC,aAAE,CAACC,YAAY,CAACC,eAAI,CAACC,IAAI,CAACd,WAAW,EAAEU,QAAQ,CAAC,EAAE,MAAM,CAAC,CAC1D,CACAD,GAAG,CAACM,wDAA2B,CAAC,CAChCC,MAAM,CAACC,OAAO,CAAC;;EAElB;EACA;EACA,OAAOC,KAAK,CAACC,IAAI,CAAC,IAAIC,GAAG,CAACZ,gBAAgB,CAAa,CAAC;AAC1D"}

View File

@@ -0,0 +1,2 @@
export declare function findLibraryName(root: string, sourceDir: string): any;
//# sourceMappingURL=findLibraryName.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"findLibraryName.d.ts","sourceRoot":"","sources":["../../src/config/findLibraryName.ts"],"names":[],"mappings":"AAGA,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OA8B9D"}

View File

@@ -0,0 +1,53 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.findLibraryName = findLibraryName;
function _fs() {
const data = _interopRequireDefault(require("fs"));
_fs = function () {
return data;
};
return data;
}
function _path() {
const data = _interopRequireDefault(require("path"));
_path = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function findLibraryName(root, sourceDir) {
const packageJsonPath = _path().default.join(root, 'package.json');
const buildGradlePath = _path().default.join(sourceDir, 'build.gradle');
const buildGradleKtsPath = _path().default.join(sourceDir, 'build.gradle.kts');
// We first check if there is a codegenConfig.name inside the package.json file.
if (_fs().default.existsSync(packageJsonPath)) {
var _packageJson$codegenC;
const packageJson = JSON.parse(_fs().default.readFileSync(packageJsonPath, 'utf8'));
if ((_packageJson$codegenC = packageJson.codegenConfig) === null || _packageJson$codegenC === void 0 ? void 0 : _packageJson$codegenC.name) {
return packageJson.codegenConfig.name;
}
}
// If not, we check if the library specified it in the build.gradle file.
let buildGradleContents = '';
if (_fs().default.existsSync(buildGradlePath)) {
buildGradleContents = _fs().default.readFileSync(buildGradlePath, 'utf-8');
} else if (_fs().default.existsSync(buildGradleKtsPath)) {
buildGradleContents = _fs().default.readFileSync(buildGradleKtsPath, 'utf-8');
} else {
return undefined;
}
const match = buildGradleContents.match(/libraryName = ["'](.+)["']/);
if (match) {
return match[1];
} else {
return undefined;
}
}
//# sourceMappingURL=findLibraryName.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["findLibraryName","root","sourceDir","packageJsonPath","path","join","buildGradlePath","buildGradleKtsPath","fs","existsSync","packageJson","JSON","parse","readFileSync","codegenConfig","name","buildGradleContents","undefined","match"],"sources":["../../src/config/findLibraryName.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nexport function findLibraryName(root: string, sourceDir: string) {\n const packageJsonPath = path.join(root, 'package.json');\n const buildGradlePath = path.join(sourceDir, 'build.gradle');\n const buildGradleKtsPath = path.join(sourceDir, 'build.gradle.kts');\n\n // We first check if there is a codegenConfig.name inside the package.json file.\n if (fs.existsSync(packageJsonPath)) {\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));\n if (packageJson.codegenConfig?.name) {\n return packageJson.codegenConfig.name;\n }\n }\n\n // If not, we check if the library specified it in the build.gradle file.\n let buildGradleContents = '';\n if (fs.existsSync(buildGradlePath)) {\n buildGradleContents = fs.readFileSync(buildGradlePath, 'utf-8');\n } else if (fs.existsSync(buildGradleKtsPath)) {\n buildGradleContents = fs.readFileSync(buildGradleKtsPath, 'utf-8');\n } else {\n return undefined;\n }\n\n const match = buildGradleContents.match(/libraryName = [\"'](.+)[\"']/);\n\n if (match) {\n return match[1];\n } else {\n return undefined;\n }\n}\n"],"mappings":";;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAwB;AAEjB,SAASA,eAAe,CAACC,IAAY,EAAEC,SAAiB,EAAE;EAC/D,MAAMC,eAAe,GAAGC,eAAI,CAACC,IAAI,CAACJ,IAAI,EAAE,cAAc,CAAC;EACvD,MAAMK,eAAe,GAAGF,eAAI,CAACC,IAAI,CAACH,SAAS,EAAE,cAAc,CAAC;EAC5D,MAAMK,kBAAkB,GAAGH,eAAI,CAACC,IAAI,CAACH,SAAS,EAAE,kBAAkB,CAAC;;EAEnE;EACA,IAAIM,aAAE,CAACC,UAAU,CAACN,eAAe,CAAC,EAAE;IAAA;IAClC,MAAMO,WAAW,GAAGC,IAAI,CAACC,KAAK,CAACJ,aAAE,CAACK,YAAY,CAACV,eAAe,EAAE,MAAM,CAAC,CAAC;IACxE,6BAAIO,WAAW,CAACI,aAAa,0DAAzB,sBAA2BC,IAAI,EAAE;MACnC,OAAOL,WAAW,CAACI,aAAa,CAACC,IAAI;IACvC;EACF;;EAEA;EACA,IAAIC,mBAAmB,GAAG,EAAE;EAC5B,IAAIR,aAAE,CAACC,UAAU,CAACH,eAAe,CAAC,EAAE;IAClCU,mBAAmB,GAAGR,aAAE,CAACK,YAAY,CAACP,eAAe,EAAE,OAAO,CAAC;EACjE,CAAC,MAAM,IAAIE,aAAE,CAACC,UAAU,CAACF,kBAAkB,CAAC,EAAE;IAC5CS,mBAAmB,GAAGR,aAAE,CAACK,YAAY,CAACN,kBAAkB,EAAE,OAAO,CAAC;EACpE,CAAC,MAAM;IACL,OAAOU,SAAS;EAClB;EAEA,MAAMC,KAAK,GAAGF,mBAAmB,CAACE,KAAK,CAAC,4BAA4B,CAAC;EAErE,IAAIA,KAAK,EAAE;IACT,OAAOA,KAAK,CAAC,CAAC,CAAC;EACjB,CAAC,MAAM;IACL,OAAOD,SAAS;EAClB;AACF"}

View File

@@ -0,0 +1,9 @@
/**
* 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.
*
*/
export default function findManifest(folder: string): string | null;
//# sourceMappingURL=findManifest.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"findManifest.d.ts","sourceRoot":"","sources":["../../src/config/findManifest.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,MAAM,EAAE,MAAM,iBA0BlD"}

View File

@@ -0,0 +1,52 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = findManifest;
function _fastGlob() {
const data = _interopRequireDefault(require("fast-glob"));
_fastGlob = function () {
return data;
};
return data;
}
function _path() {
const data = _interopRequireDefault(require("path"));
_path = 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 findManifest(folder) {
let manifestPaths = _fastGlob().default.sync('**/AndroidManifest.xml', {
cwd: (0, _cliTools().unixifyPaths)(folder),
ignore: ['node_modules/**', '**/build/**', '**/debug/**', 'Examples/**', 'examples/**', '**/Pods/**', '**/sdks/hermes/android/**', '**/src/androidTest/**', '**/src/test/**']
});
if (manifestPaths.length > 1) {
// if we have more than one manifest, pick the one in the main folder if present
const mainManifest = manifestPaths.filter(manifestPath => manifestPath.includes('src/main/'));
if (mainManifest.length === 1) {
manifestPaths = mainManifest;
}
}
return manifestPaths[0] ? _path().default.join(folder, manifestPaths[0]) : null;
}
//# sourceMappingURL=findManifest.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["findManifest","folder","manifestPaths","glob","sync","cwd","unixifyPaths","ignore","length","mainManifest","filter","manifestPath","includes","path","join"],"sources":["../../src/config/findManifest.ts"],"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 glob from 'fast-glob';\nimport path from 'path';\nimport {unixifyPaths} from '@react-native-community/cli-tools';\n\nexport default function findManifest(folder: string) {\n let manifestPaths = glob.sync('**/AndroidManifest.xml', {\n cwd: unixifyPaths(folder),\n ignore: [\n 'node_modules/**',\n '**/build/**',\n '**/debug/**',\n 'Examples/**',\n 'examples/**',\n '**/Pods/**',\n '**/sdks/hermes/android/**',\n '**/src/androidTest/**',\n '**/src/test/**',\n ],\n });\n if (manifestPaths.length > 1) {\n // if we have more than one manifest, pick the one in the main folder if present\n const mainManifest = manifestPaths.filter((manifestPath) =>\n manifestPath.includes('src/main/'),\n );\n if (mainManifest.length === 1) {\n manifestPaths = mainManifest;\n }\n }\n\n return manifestPaths[0] ? path.join(folder, manifestPaths[0]) : null;\n}\n"],"mappings":";;;;;;AAQA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAA+D;AAV/D;AACA;AACA;AACA;AACA;AACA;AACA;;AAMe,SAASA,YAAY,CAACC,MAAc,EAAE;EACnD,IAAIC,aAAa,GAAGC,mBAAI,CAACC,IAAI,CAAC,wBAAwB,EAAE;IACtDC,GAAG,EAAE,IAAAC,wBAAY,EAACL,MAAM,CAAC;IACzBM,MAAM,EAAE,CACN,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,YAAY,EACZ,2BAA2B,EAC3B,uBAAuB,EACvB,gBAAgB;EAEpB,CAAC,CAAC;EACF,IAAIL,aAAa,CAACM,MAAM,GAAG,CAAC,EAAE;IAC5B;IACA,MAAMC,YAAY,GAAGP,aAAa,CAACQ,MAAM,CAAEC,YAAY,IACrDA,YAAY,CAACC,QAAQ,CAAC,WAAW,CAAC,CACnC;IACD,IAAIH,YAAY,CAACD,MAAM,KAAK,CAAC,EAAE;MAC7BN,aAAa,GAAGO,YAAY;IAC9B;EACF;EAEA,OAAOP,aAAa,CAAC,CAAC,CAAC,GAAGW,eAAI,CAACC,IAAI,CAACb,MAAM,EAAEC,aAAa,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;AACtE"}

View File

@@ -0,0 +1,10 @@
/**
* 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.
*
*/
export default function getPackageClassName(folder: string): string | null;
export declare function matchClassName(file: string): RegExpMatchArray | null;
//# sourceMappingURL=findPackageClassName.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"findPackageClassName.d.ts","sourceRoot":"","sources":["../../src/config/findPackageClassName.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,MAAM,EAAE,MAAM,iBAUzD;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,2BAa1C"}

View File

@@ -0,0 +1,65 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = getPackageClassName;
exports.matchClassName = matchClassName;
function _fs() {
const data = _interopRequireDefault(require("fs"));
_fs = function () {
return data;
};
return data;
}
function _fastGlob() {
const data = _interopRequireDefault(require("fast-glob"));
_fastGlob = function () {
return data;
};
return data;
}
function _path() {
const data = _interopRequireDefault(require("path"));
_path = 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 getPackageClassName(folder) {
const files = _fastGlob().default.sync('**/+(*.java|*.kt)', {
cwd: (0, _cliTools().unixifyPaths)(folder)
});
const packages = files.map(filePath => _fs().default.readFileSync(_path().default.join(folder, filePath), 'utf8')).map(matchClassName).filter(match => match);
// @ts-ignore
return packages.length ? packages[0][1] : null;
}
function matchClassName(file) {
const nativeModuleMatch = file.match(/class\s+(\w+[^(\s]*)[\s\w():]*(\s+implements\s+|:)[\s\w():,]*[^{]*ReactPackage/);
// We first check for implementation of ReactPackage to find native
// modules and then for subclasses of TurboReactPackage to find turbo modules.
if (nativeModuleMatch) {
return nativeModuleMatch;
} else {
return file.match(/class\s+(\w+[^(\s]*)[\s\w():]*(\s+extends\s+|:)[\s\w():,]*[^{]*TurboReactPackage/);
}
}
//# sourceMappingURL=findPackageClassName.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["getPackageClassName","folder","files","glob","sync","cwd","unixifyPaths","packages","map","filePath","fs","readFileSync","path","join","matchClassName","filter","match","length","file","nativeModuleMatch"],"sources":["../../src/config/findPackageClassName.ts"],"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 fs from 'fs';\nimport glob from 'fast-glob';\nimport path from 'path';\nimport {unixifyPaths} from '@react-native-community/cli-tools';\n\nexport default function getPackageClassName(folder: string) {\n const files = glob.sync('**/+(*.java|*.kt)', {cwd: unixifyPaths(folder)});\n\n const packages = files\n .map((filePath) => fs.readFileSync(path.join(folder, filePath), 'utf8'))\n .map(matchClassName)\n .filter((match) => match);\n\n // @ts-ignore\n return packages.length ? packages[0][1] : null;\n}\n\nexport function matchClassName(file: string) {\n const nativeModuleMatch = file.match(\n /class\\s+(\\w+[^(\\s]*)[\\s\\w():]*(\\s+implements\\s+|:)[\\s\\w():,]*[^{]*ReactPackage/,\n );\n // We first check for implementation of ReactPackage to find native\n // modules and then for subclasses of TurboReactPackage to find turbo modules.\n if (nativeModuleMatch) {\n return nativeModuleMatch;\n } else {\n return file.match(\n /class\\s+(\\w+[^(\\s]*)[\\s\\w():]*(\\s+extends\\s+|:)[\\s\\w():,]*[^{]*TurboReactPackage/,\n );\n }\n}\n"],"mappings":";;;;;;;AAQA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAA+D;AAX/D;AACA;AACA;AACA;AACA;AACA;AACA;;AAOe,SAASA,mBAAmB,CAACC,MAAc,EAAE;EAC1D,MAAMC,KAAK,GAAGC,mBAAI,CAACC,IAAI,CAAC,mBAAmB,EAAE;IAACC,GAAG,EAAE,IAAAC,wBAAY,EAACL,MAAM;EAAC,CAAC,CAAC;EAEzE,MAAMM,QAAQ,GAAGL,KAAK,CACnBM,GAAG,CAAEC,QAAQ,IAAKC,aAAE,CAACC,YAAY,CAACC,eAAI,CAACC,IAAI,CAACZ,MAAM,EAAEQ,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAC,CACvED,GAAG,CAACM,cAAc,CAAC,CACnBC,MAAM,CAAEC,KAAK,IAAKA,KAAK,CAAC;;EAE3B;EACA,OAAOT,QAAQ,CAACU,MAAM,GAAGV,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;AAChD;AAEO,SAASO,cAAc,CAACI,IAAY,EAAE;EAC3C,MAAMC,iBAAiB,GAAGD,IAAI,CAACF,KAAK,CAClC,gFAAgF,CACjF;EACD;EACA;EACA,IAAIG,iBAAiB,EAAE;IACrB,OAAOA,iBAAiB;EAC1B,CAAC,MAAM;IACL,OAAOD,IAAI,CAACF,KAAK,CACf,kFAAkF,CACnF;EACH;AACF"}

Some files were not shown because too many files have changed in this diff Show More