feat(react-native): debug option for build-android (#8702)

* feat(react-native): debug option for build-android

* docs(react-native): debug option
This commit is contained in:
William Sedlacek 2022-02-07 18:39:31 -08:00 committed by GitHub
parent 0182df4b9f
commit e942a85b1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 1 deletions

View File

@ -16,3 +16,9 @@ Options can be configured in `workspace.json` when defining the executor, or whe
Type: `boolean`
Generate apk file(s) rather than a bundle (.aab).
### debug
Type: `boolean`
Generate a debug build instead of a release build

View File

@ -35,9 +35,11 @@ function runCliBuild(
options: ReactNativeBuildOptions
) {
return new Promise((resolve, reject) => {
const gradleCommand = getGradleCommand(options);
childProcess = spawn(
process.platform === 'win32' ? 'gradlew.bat' : './gradlew',
[options.apk ? 'assembleRelease' : 'bundleRelease'],
[gradleCommand],
{
cwd: join(workspaceRoot, projectRoot, 'android'),
stdio: [0, 1, 2],
@ -60,3 +62,19 @@ function runCliBuild(
});
});
}
function getGradleCommand(options: ReactNativeBuildOptions) {
if (options.apk && options.debug) {
return 'assembleDebug';
}
if (options.apk) {
return 'assembleRelease';
}
if (options.debug) {
return 'bundleDebug';
}
return 'bundleRelease';
}

View File

@ -1,3 +1,4 @@
export interface ReactNativeBuildOptions {
apk?: boolean;
debug?: boolean;
}

View File

@ -9,6 +9,10 @@
"apk": {
"type": "boolean",
"description": "Generate apk file(s) rather than a bundle (.aab)."
},
"debug": {
"type": "boolean",
"description": "Generate a debug build instead of a release build"
}
},
"required": []