diff --git a/cli/package.json b/cli/package.json index f20151812..8d1c3b75f 100644 --- a/cli/package.json +++ b/cli/package.json @@ -44,38 +44,38 @@ "watch": "npm run assets && tsc -w" }, "dependencies": { - "@ionic/cli-framework-output": "^2.2.5", - "@ionic/utils-subprocess": "2.1.11", - "@ionic/utils-terminal": "^2.3.3", - "commander": "^9.3.0", - "debug": "^4.3.4", + "@ionic/cli-framework-output": "^2.2.8", + "@ionic/utils-subprocess": "^3.0.1", + "@ionic/utils-terminal": "^2.3.5", + "commander": "^12.1.0", + "debug": "^4.4.0", "env-paths": "^2.2.0", "fs-extra": "^11.2.0", - "kleur": "^4.1.4", - "native-run": "^2.0.0", + "kleur": "^4.1.5", + "native-run": "^2.0.1", "open": "^8.4.0", - "plist": "^3.0.5", + "plist": "^3.1.0", "prompts": "^2.4.2", - "rimraf": "^4.4.1", - "semver": "^7.3.7", + "rimraf": "^6.0.1", + "semver": "^7.6.3", "tar": "^6.1.11", - "tslib": "^2.4.0", - "xml2js": "^0.5.0" + "tslib": "^2.8.1", + "xml2js": "^0.6.2" }, "devDependencies": { - "@types/debug": "^4.1.7", + "@types/debug": "^4.1.12", "@types/fs-extra": "^11.0.4", - "@types/jest": "^29.5.0", - "@types/plist": "^3.0.2", - "@types/prompts": "^2.0.14", - "@types/semver": "^7.3.10", + "@types/jest": "^29.5.14", + "@types/plist": "^3.0.5", + "@types/prompts": "^2.4.9", + "@types/semver": "^7.5.8", "@types/tar": "^6.1.1", - "@types/tmp": "^0.2.3", + "@types/tmp": "^0.2.6", "@types/xml2js": "0.4.5", - "jest": "^29.5.0", - "jest-environment-jsdom": "^29.5.0", - "jest-jasmine2": "^29.5.0", - "tmp": "^0.2.1", + "jest": "^29.7.0", + "jest-environment-jsdom": "^29.7.0", + "jest-jasmine2": "^29.7.0", + "tmp": "^0.2.3", "ts-jest": "^29.0.5", "typescript": "~5.0.2" }, diff --git a/cli/src/index.ts b/cli/src/index.ts index 1c014fbd1..7afede477 100644 --- a/cli/src/index.ts +++ b/cli/src/index.ts @@ -187,8 +187,7 @@ export function runProgram(config: Config): void { .option('--scheme ', 'set the scheme of the iOS project') .option('--flavor ', 'set the flavor of the Android project (flavor dimensions not yet supported)') .option('--list', 'list targets, then quit') - // TODO: remove once --json is a hidden option (https://github.com/tj/commander.js/issues/1106) - .allowUnknownOption(true) + .addOption(new Option('--json').hideHelp()) .option('--target ', 'use a specific target') .option('--no-sync', `do not run ${c.input('sync')}`) .option('--forwardPorts ', 'Automatically run "adb reverse" for better live-reloading support') @@ -202,13 +201,14 @@ export function runProgram(config: Config): void { config, async ( platform, - { scheme, flavor, list, target, sync, forwardPorts, liveReload, host, port, configuration }, + { scheme, flavor, list, json, target, sync, forwardPorts, liveReload, host, port, configuration }, ) => { const { runCommand } = await import('./tasks/run'); await runCommand(config, platform, { scheme, flavor, list, + json, target, sync, forwardPorts, diff --git a/cli/src/tasks/run.ts b/cli/src/tasks/run.ts index 2c3afd8a0..7217d6123 100644 --- a/cli/src/tasks/run.ts +++ b/cli/src/tasks/run.ts @@ -24,6 +24,7 @@ export interface RunCommandOptions { scheme?: string; flavor?: string; list?: boolean; + json?: boolean; target?: string; sync?: boolean; forwardPorts?: string; @@ -67,8 +68,7 @@ export async function runCommand( id: t.id ?? '?', })); - // TODO: make hidden commander option (https://github.com/tj/commander.js/issues/1106) - if (process.argv.includes('--json')) { + if (options.json) { process.stdout.write(`${JSON.stringify(outputTargets)}\n`); } else { const rows = outputTargets.map((t) => [t.name, t.api, t.id]); diff --git a/cli/src/util/subprocess.ts b/cli/src/util/subprocess.ts index b6067c4ec..c4743bdec 100644 --- a/cli/src/util/subprocess.ts +++ b/cli/src/util/subprocess.ts @@ -16,7 +16,7 @@ export async function runCommand( } catch (e) { if (e instanceof SubprocessError) { // old behavior of just throwing the stdout/stderr strings - throw e.output ? e.output : e.code ? e.code : e.error ? e.error.message : 'Unknown error'; + throw e.output ? e.output : e.cause ? `${e.message} ${e.cause.toString()}` : e.code ? e.code : 'Unknown error'; } throw e; diff --git a/cli/tsconfig.json b/cli/tsconfig.json index b254c555c..a36770895 100644 --- a/cli/tsconfig.json +++ b/cli/tsconfig.json @@ -3,7 +3,10 @@ "declaration": true, "esModuleInterop": true, "importHelpers": true, - "lib": ["es2019"], + "lib": [ + "ES2021", + "ES2022.Error" + ], "module": "commonjs", "moduleResolution": "node", "noEmitHelpers": true,