@react-native-community/cli-platform-android
Advanced tools
Comparing version 12.0.0-alpha.18 to 12.0.0
@@ -42,3 +42,3 @@ "use strict"; | ||
} | ||
let gradleArgs = (0, _getTaskNames.getTaskNames)(androidProject.appName, args.mode, tasks, 'bundle', androidProject.sourceDir); | ||
let gradleArgs = (0, _getTaskNames.getTaskNames)(androidProject.appName, args.mode, tasks, 'bundle'); | ||
if (args.extraParams) { | ||
@@ -45,0 +45,0 @@ gradleArgs.push(...args.extraParams); |
import type { BuildFlags } from '../buildAndroid'; | ||
export declare function getTaskNames(appName: string, mode: string | undefined, tasks: BuildFlags['tasks'], taskPrefix: 'assemble' | 'install' | 'bundle', sourceDir: string): Array<string>; | ||
export declare function getTaskNames(appName: string, mode: string | undefined, tasks: BuildFlags['tasks'], taskPrefix: 'assemble' | 'install' | 'bundle'): Array<string>; | ||
//# sourceMappingURL=getTaskNames.d.ts.map |
@@ -8,25 +8,4 @@ "use strict"; | ||
var _toPascalCase = require("./toPascalCase"); | ||
var _listAndroidTasks = require("./listAndroidTasks"); | ||
function _cliTools() { | ||
const data = require("@react-native-community/cli-tools"); | ||
_cliTools = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function getTaskNames(appName, mode = 'debug', tasks, taskPrefix, sourceDir) { | ||
let appTasks = tasks && tasks.length ? tasks : [taskPrefix + (0, _toPascalCase.toPascalCase)(mode)]; | ||
// Check against build flavors for "install" task ("assemble" don't care about it so much and will build all) | ||
if (!(tasks === null || tasks === void 0 ? void 0 : tasks.length) && taskPrefix === 'install') { | ||
const actionableInstallTasks = (0, _listAndroidTasks.getGradleTasks)('install', sourceDir); | ||
if (!actionableInstallTasks.find(t => t.task.includes(appTasks[0]))) { | ||
const installTasksForMode = actionableInstallTasks.filter(t => t.task.toLowerCase().includes(mode)); | ||
if (!installTasksForMode.length) { | ||
throw new (_cliTools().CLIError)(`Couldn't find "${appTasks.map(taskName => taskName.replace(taskPrefix, '')).join(', ')}" build variant. Available variants are: ${actionableInstallTasks.map(t => `"${t.task.replace(taskPrefix, '')}"`).join(', ')}.`); | ||
} | ||
_cliTools().logger.warn(`Found multiple tasks for "install" command: ${installTasksForMode.map(t => t.task).join(', ')}.\nSelecting first available: ${installTasksForMode[0].task}.`); | ||
appTasks = [installTasksForMode[0].task]; | ||
} | ||
} | ||
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; | ||
@@ -33,0 +12,0 @@ } |
@@ -90,18 +90,11 @@ "use strict"; | ||
} = args; | ||
const packagerStatus = await (0, _cliTools().isPackagerRunning)(port); | ||
if (typeof packagerStatus === 'object' && packagerStatus.status === 'running') { | ||
if (packagerStatus.root === config.root) { | ||
packager = false; | ||
(0, _cliTools().logAlreadyRunningBundler)(port); | ||
} else { | ||
const result = await (0, _cliTools().handlePortUnavailable)(port, config.root, packager); | ||
[port, packager] = [result.port, result.packager]; | ||
if (packager) { | ||
const { | ||
port: newPort, | ||
startPackager | ||
} = await (0, _cliTools().findDevServerPort)(port, config.root); | ||
if (startPackager) { | ||
await (0, _cliTools().startServerInNewWindow)(newPort, config.root, config.reactNativePath, args.terminal); | ||
} | ||
} else if (packagerStatus === 'unrecognized') { | ||
const result = await (0, _cliTools().handlePortUnavailable)(port, config.root, packager); | ||
[port, packager] = [result.port, result.packager]; | ||
} | ||
if (packager) { | ||
await (0, _cliTools().startServerInNewWindow)(port, config.root, config.reactNativePath, args.terminal); | ||
} | ||
if (config.reactNativeVersion !== 'unknown') { | ||
@@ -207,3 +200,3 @@ _cliTools().link.setVersion(config.reactNativeVersion); | ||
if (devices.indexOf(deviceId) !== -1) { | ||
let gradleArgs = (0, _getTaskNames.getTaskNames)(androidProject.appName, args.mode, args.tasks ?? buildTask, 'install', androidProject.sourceDir); | ||
let gradleArgs = (0, _getTaskNames.getTaskNames)(androidProject.appName, args.mode, args.tasks ?? buildTask, 'install'); | ||
@@ -210,0 +203,0 @@ // using '-x lint' in order to ignore linting errors while building the apk |
@@ -25,9 +25,2 @@ "use strict"; | ||
} | ||
function _prompts() { | ||
const data = _interopRequireDefault(require("prompts")); | ||
_prompts = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _chalk() { | ||
@@ -77,3 +70,3 @@ const data = _interopRequireDefault(require("chalk")); | ||
device | ||
} = await (0, _prompts().default)({ | ||
} = await (0, _cliTools().prompt)({ | ||
type: 'select', | ||
@@ -80,0 +73,0 @@ name: 'device', |
@@ -28,9 +28,2 @@ "use strict"; | ||
} | ||
function _prompts() { | ||
const data = _interopRequireDefault(require("prompts")); | ||
_prompts = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -53,7 +46,15 @@ const parseTasksFromGradleFile = (taskType, text) => { | ||
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'; | ||
const out = _execa().default.sync(cmd, ['tasks', '--group', taskType], { | ||
cwd: sourceDir | ||
}).stdout; | ||
return parseTasksFromGradleFile(taskType, out); | ||
try { | ||
const out = _execa().default.sync(cmd, ['tasks', '--group', taskType], { | ||
cwd: sourceDir | ||
}).stdout; | ||
loader.succeed(); | ||
return parseTasksFromGradleFile(taskType, out); | ||
} catch { | ||
loader.fail(); | ||
return []; | ||
} | ||
}; | ||
@@ -68,3 +69,3 @@ exports.getGradleTasks = getGradleTasks; | ||
task | ||
} = await (0, _prompts().default)({ | ||
} = await (0, _cliTools().prompt)({ | ||
type: 'select', | ||
@@ -71,0 +72,0 @@ name: 'task', |
@@ -8,9 +8,2 @@ "use strict"; | ||
exports.promptForUser = promptForUser; | ||
function _cliTools() { | ||
const data = require("@react-native-community/cli-tools"); | ||
_cliTools = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _execa() { | ||
@@ -23,5 +16,5 @@ const data = _interopRequireDefault(require("execa")); | ||
} | ||
function _prompts() { | ||
const data = _interopRequireDefault(require("prompts")); | ||
_prompts = function () { | ||
function _cliTools() { | ||
const data = require("@react-native-community/cli-tools"); | ||
_cliTools = function () { | ||
return data; | ||
@@ -65,3 +58,3 @@ }; | ||
selectedUser | ||
} = await (0, _prompts().default)({ | ||
} = await (0, _cliTools().prompt)({ | ||
type: 'select', | ||
@@ -68,0 +61,0 @@ name: 'selectedUser', |
@@ -58,3 +58,3 @@ "use strict"; | ||
if (!args.binaryPath) { | ||
let gradleArgs = (0, _getTaskNames.getTaskNames)(androidProject.appName, args.mode, args.tasks, 'install', androidProject.sourceDir); | ||
let gradleArgs = (0, _getTaskNames.getTaskNames)(androidProject.appName, args.mode, args.tasks, 'install'); | ||
if (args.extraParams) { | ||
@@ -114,2 +114,4 @@ gradleArgs.push(...args.extraParams); | ||
}))} and follow the React Native CLI QuickStart guide to install the compatible version of JDK.`; | ||
} else { | ||
message = error.message; | ||
} | ||
@@ -116,0 +118,0 @@ return new (_cliTools().CLIError)(`Failed to install the app.${message ? ' ' + message : ''}`, error.message.length > 0 ? undefined : error); |
{ | ||
"name": "@react-native-community/cli-platform-android", | ||
"version": "12.0.0-alpha.18", | ||
"version": "12.0.0", | ||
"license": "MIT", | ||
@@ -10,3 +10,3 @@ "main": "build/index.js", | ||
"dependencies": { | ||
"@react-native-community/cli-tools": "12.0.0-alpha.18", | ||
"@react-native-community/cli-tools": "12.0.0", | ||
"chalk": "^4.1.2", | ||
@@ -25,3 +25,3 @@ "execa": "^5.0.0", | ||
"devDependencies": { | ||
"@react-native-community/cli-types": "12.0.0-alpha.18", | ||
"@react-native-community/cli-types": "12.0.0", | ||
"@types/fs-extra": "^8.1.0", | ||
@@ -36,3 +36,3 @@ "@types/glob": "^7.1.1" | ||
}, | ||
"gitHead": "174948353be0bf67c5b8beb657608b22b21de5ca" | ||
"gitHead": "3f206fd01f70706ce17e4a33c3528a60e684d41e" | ||
} |
@@ -76,2 +76,10 @@ # @react-native-community/cli-platform-android | ||
#### `--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` | ||
@@ -78,0 +86,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
128
228520
2389
60
+ Added@react-native-community/cli-tools@12.0.0(transitive)
- Removed@react-native-community/cli-tools@12.0.0-alpha.18(transitive)