From b083c991c30965267f5c1a092c1a18606de40a89 Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Thu, 7 Nov 2024 21:55:44 -0800 Subject: [PATCH] fix: allow root level build command flags --- .../nx/src/executors/build/build.schema.json | 29 +++++++++++++ .../nx/src/executors/build/debug.schema.json | 33 +++++++++++++-- .../src/executors/build/prepare.schema.json | 33 +++++++++++++-- .../nx/src/executors/build/run.schema.json | 33 +++++++++++++-- .../nx/src/executors/build/test.schema.json | 33 +++++++++++++-- packages/nx/src/schemas/base.schema.ts | 41 ++++++++++++++++++- packages/nx/src/utils/executors.ts | 32 +++++++++++---- 7 files changed, 207 insertions(+), 27 deletions(-) diff --git a/packages/nx/src/executors/build/build.schema.json b/packages/nx/src/executors/build/build.schema.json index 720ba5073..e15ecdcae 100644 --- a/packages/nx/src/executors/build/build.schema.json +++ b/packages/nx/src/executors/build/build.schema.json @@ -37,6 +37,35 @@ "type": "string", "description": "Used with targets to share build configurations and avoid duplicating configurations across multiple targets." }, + "provision": { + "type": "string", + "description": "(Apple Only) When building, use this provision profile name." + }, + "aab": { + "type": "boolean", + "default": false, + "description": "(Android Only) When building, create an Android App Bundle (.aab file)." + }, + "keyStorePath": { + "type": "string", + "description": "(Android Only) When building, use the keystore file at this location." + }, + "keyStorePassword": { + "type": "string", + "description": "(Android Only) When building, use this keystore password." + }, + "keyStoreAlias": { + "type": "string", + "description": "(Android Only) When building, use this keystore alias." + }, + "keyStoreAliasPassword": { + "type": "string", + "description": "(Android Only) When building, use this keystore alias password." + }, + "copyTo": { + "type": "string", + "description": "When building, copy the package to this location." + }, "android": { "type": "object", "aab": { diff --git a/packages/nx/src/executors/build/debug.schema.json b/packages/nx/src/executors/build/debug.schema.json index dbea83ee6..3a48e0a9e 100644 --- a/packages/nx/src/executors/build/debug.schema.json +++ b/packages/nx/src/executors/build/debug.schema.json @@ -37,6 +37,35 @@ "type": "string", "description": "Used with targets to share build configurations and avoid duplicating configurations across multiple targets." }, + "provision": { + "type": "string", + "description": "(Apple Only) When building, use this provision profile name." + }, + "aab": { + "type": "boolean", + "default": false, + "description": "(Android Only) When building, create an Android App Bundle (.aab file)." + }, + "keyStorePath": { + "type": "string", + "description": "(Android Only) When building, use the keystore file at this location." + }, + "keyStorePassword": { + "type": "string", + "description": "(Android Only) When building, use this keystore password." + }, + "keyStoreAlias": { + "type": "string", + "description": "(Android Only) When building, use this keystore alias." + }, + "keyStoreAliasPassword": { + "type": "string", + "description": "(Android Only) When building, use this keystore alias password." + }, + "copyTo": { + "type": "string", + "description": "When building, copy the package to this location." + }, "android": { "type": "object", "aab": { @@ -163,10 +192,6 @@ "default": -1, "description": "Increase the default 90s timeout to connect to a device/simulator" }, - "copyTo": { - "type": "string", - "description": "When building, copy the package to this location." - }, "prepare": { "type": "boolean", "description": "Starts a Webpack compilation and prepares the app's App_Resources and the plugins platforms directories. The output is generated in a subdirectory for the selected target platform in the platforms directory. This lets you build the project for the selected platform.", diff --git a/packages/nx/src/executors/build/prepare.schema.json b/packages/nx/src/executors/build/prepare.schema.json index 3c0f8b990..b097af84e 100644 --- a/packages/nx/src/executors/build/prepare.schema.json +++ b/packages/nx/src/executors/build/prepare.schema.json @@ -37,6 +37,35 @@ "type": "string", "description": "Used with targets to share build configurations and avoid duplicating configurations across multiple targets." }, + "provision": { + "type": "string", + "description": "(Apple Only) When building, use this provision profile name." + }, + "aab": { + "type": "boolean", + "default": false, + "description": "(Android Only) When building, create an Android App Bundle (.aab file)." + }, + "keyStorePath": { + "type": "string", + "description": "(Android Only) When building, use the keystore file at this location." + }, + "keyStorePassword": { + "type": "string", + "description": "(Android Only) When building, use this keystore password." + }, + "keyStoreAlias": { + "type": "string", + "description": "(Android Only) When building, use this keystore alias." + }, + "keyStoreAliasPassword": { + "type": "string", + "description": "(Android Only) When building, use this keystore alias password." + }, + "copyTo": { + "type": "string", + "description": "When building, copy the package to this location." + }, "android": { "type": "object", "aab": { @@ -162,10 +191,6 @@ "default": -1, "description": "Increase the default 90s timeout to connect to a device/simulator" }, - "copyTo": { - "type": "string", - "description": "When building, copy the package to this location." - }, "prepare": { "type": "boolean", "description": "Starts a Webpack compilation and prepares the app's App_Resources and the plugins platforms directories. The output is generated in a subdirectory for the selected target platform in the platforms directory. This lets you build the project for the selected platform.", diff --git a/packages/nx/src/executors/build/run.schema.json b/packages/nx/src/executors/build/run.schema.json index 88949d3d7..8aa628dcf 100644 --- a/packages/nx/src/executors/build/run.schema.json +++ b/packages/nx/src/executors/build/run.schema.json @@ -37,6 +37,35 @@ "type": "string", "description": "Used with targets to share build configurations and avoid duplicating configurations across multiple targets." }, + "provision": { + "type": "string", + "description": "(Apple Only) When building, use this provision profile name." + }, + "aab": { + "type": "boolean", + "default": false, + "description": "(Android Only) When building, create an Android App Bundle (.aab file)." + }, + "keyStorePath": { + "type": "string", + "description": "(Android Only) When building, use the keystore file at this location." + }, + "keyStorePassword": { + "type": "string", + "description": "(Android Only) When building, use this keystore password." + }, + "keyStoreAlias": { + "type": "string", + "description": "(Android Only) When building, use this keystore alias." + }, + "keyStoreAliasPassword": { + "type": "string", + "description": "(Android Only) When building, use this keystore alias password." + }, + "copyTo": { + "type": "string", + "description": "When building, copy the package to this location." + }, "android": { "type": "object", "aab": { @@ -162,10 +191,6 @@ "default": -1, "description": "Increase the default 90s timeout to connect to a device/simulator" }, - "copyTo": { - "type": "string", - "description": "When building, copy the package to this location." - }, "prepare": { "type": "boolean", "description": "Starts a Webpack compilation and prepares the app's App_Resources and the plugins platforms directories. The output is generated in a subdirectory for the selected target platform in the platforms directory. This lets you build the project for the selected platform.", diff --git a/packages/nx/src/executors/build/test.schema.json b/packages/nx/src/executors/build/test.schema.json index 8883c081f..6fe14988b 100644 --- a/packages/nx/src/executors/build/test.schema.json +++ b/packages/nx/src/executors/build/test.schema.json @@ -37,6 +37,35 @@ "type": "string", "description": "Used with targets to share build configurations and avoid duplicating configurations across multiple targets." }, + "provision": { + "type": "string", + "description": "(Apple Only) When building, use this provision profile name." + }, + "aab": { + "type": "boolean", + "default": false, + "description": "(Android Only) When building, create an Android App Bundle (.aab file)." + }, + "keyStorePath": { + "type": "string", + "description": "(Android Only) When building, use the keystore file at this location." + }, + "keyStorePassword": { + "type": "string", + "description": "(Android Only) When building, use this keystore password." + }, + "keyStoreAlias": { + "type": "string", + "description": "(Android Only) When building, use this keystore alias." + }, + "keyStoreAliasPassword": { + "type": "string", + "description": "(Android Only) When building, use this keystore alias password." + }, + "copyTo": { + "type": "string", + "description": "When building, copy the package to this location." + }, "android": { "type": "object", "aab": { @@ -162,10 +191,6 @@ "default": -1, "description": "Increase the default 90s timeout to connect to a device/simulator" }, - "copyTo": { - "type": "string", - "description": "When building, copy the package to this location." - }, "prepare": { "type": "boolean", "description": "Starts a Webpack compilation and prepares the app's App_Resources and the plugins platforms directories. The output is generated in a subdirectory for the selected target platform in the platforms directory. This lets you build the project for the selected platform.", diff --git a/packages/nx/src/schemas/base.schema.ts b/packages/nx/src/schemas/base.schema.ts index 17b2888f1..95211159d 100644 --- a/packages/nx/src/schemas/base.schema.ts +++ b/packages/nx/src/schemas/base.schema.ts @@ -10,6 +10,13 @@ export interface BaseSchema { platform: Platform; silent: boolean; verbose: boolean; + provision: string; + aab: boolean; + keyStorePath: string; + keyStorePassword: string; + keyStoreAlias: string; + keyStoreAliasPassword: string; + copyTo: string; } export const baseSchema = { @@ -30,7 +37,8 @@ export const baseSchema = { force: { type: 'boolean', default: true, - description: 'If true, skips the application compatibility checks and forces npm i to ensure all dependencies are installed. Otherwise, the command will check the application compatibility with the current CLI version and could fail requiring ns migrate.', + description: + 'If true, skips the application compatibility checks and forces npm i to ensure all dependencies are installed. Otherwise, the command will check the application compatibility with the current CLI version and could fail requiring ns migrate.', }, silent: { type: 'boolean', @@ -51,5 +59,34 @@ export const baseSchema = { type: 'string', description: 'Used with targets to share build configurations and avoid duplicating configurations across multiple targets.', }, + provision: { + type: 'string', + description: '(Apple Only) When building, use this provision profile name.', + }, + aab: { + type: 'boolean', + default: false, + description: '(Android Only) When building, create an Android App Bundle (.aab file).', + }, + keyStorePath: { + type: 'string', + description: '(Android Only) When building, use the keystore file at this location.', + }, + keyStorePassword: { + type: 'string', + description: '(Android Only) When building, use this keystore password.', + }, + keyStoreAlias: { + type: 'string', + description: '(Android Only) When building, use this keystore alias.', + }, + keyStoreAliasPassword: { + type: 'string', + description: '(Android Only) When building, use this keystore alias password.', + }, + copyTo: { + type: 'string', + description: 'When building, copy the package to this location.', + }, }, -}; \ No newline at end of file +}; diff --git a/packages/nx/src/utils/executors.ts b/packages/nx/src/utils/executors.ts index bfdc0bbee..70f5d011a 100644 --- a/packages/nx/src/utils/executors.ts +++ b/packages/nx/src/utils/executors.ts @@ -40,7 +40,7 @@ export function commonExecutor(options: ExecutorSchema, context: ExecutorContext } if (!isClean) { - options.platform = isAndroid ? 'android' : (isIos ? 'ios' : 'visionos'); + options.platform = isAndroid ? 'android' : isIos ? 'ios' : 'visionos'; } const projectConfig = context.projectsConfigurations.projects[context.projectName]; @@ -124,16 +124,30 @@ export function commonExecutor(options: ExecutorSchema, context: ExecutorContext // early exit for `ns clean` if (options.command === COMMANDS.CLEAN) return nsOptions; - if (options.platform === 'android' && options.android) { - options.android.aab && nsOptions.push('--aab'); - options.android.keyStorePath && nsOptions.push(`--key-store-path=${options.android.keyStorePath}`); - options.android.keyStorePassword && nsOptions.push(`--key-store-password=${options.android.keyStorePassword}`); - options.android.keyStoreAlias && nsOptions.push(`--key-store-alias=${options.android.keyStoreAlias}`); - options.android.keyStoreAliasPassword && nsOptions.push(`--key-store-alias-password=${options.android.keyStoreAliasPassword}`); + if (options.platform === 'android') { + if (options.android?.aab || options.aab) { + nsOptions.push('--aab'); + } + if (options.android?.keyStorePath || options.keyStorePath) { + nsOptions.push(`--key-store-path=${options.android?.keyStorePath || options.keyStorePath}`); + } + if (options.android?.keyStorePassword || options.keyStorePassword) { + nsOptions.push(`--key-store-password=${options.android?.keyStorePassword || options.keyStorePassword}`); + } + if (options.android?.keyStoreAlias || options.keyStoreAlias) { + nsOptions.push(`--key-store-alias=${options.android?.keyStoreAlias || options.keyStoreAlias}`); + } + if (options.android?.keyStoreAliasPassword || options.keyStoreAliasPassword) { + nsOptions.push(`--key-store-alias-password=${options.android?.keyStoreAliasPassword || options.keyStoreAliasPassword}`); + } } - if (options.platform === 'ios' && options.ios) { - options.ios.provision && nsOptions.push(`--provision=${options.ios.provision}`); + if (options.platform === 'ios') { + if (options.ios?.provision) { + nsOptions.push(`--provision=${options.ios.provision}`); + } else if (options.provision) { + nsOptions.push(`--provision=${options.provision}`); + } } // Append common options