diff --git a/packages/@ionic/cli/src/definitions.ts b/packages/@ionic/cli/src/definitions.ts index 88debe3b50..486d595f86 100644 --- a/packages/@ionic/cli/src/definitions.ts +++ b/packages/@ionic/cli/src/definitions.ts @@ -481,7 +481,7 @@ export interface ITelemetry { sendCommand(command: string, args: string[]): Promise; } -export type NpmClient = 'yarn' | 'npm' | 'pnpm'; +export type NpmClient = 'yarn' | 'yarn-berry' | 'npm' | 'pnpm'; export type FeatureId = 'ssl-commands'; diff --git a/packages/@ionic/cli/src/lib/build.ts b/packages/@ionic/cli/src/lib/build.ts index 6889c8caf7..57647ca004 100644 --- a/packages/@ionic/cli/src/lib/build.ts +++ b/packages/@ionic/cli/src/lib/build.ts @@ -48,6 +48,7 @@ export abstract class BuildRunner> implements Runner npm: NpmBuildCLI, pnpm: PnpmBuildCLI, yarn: YarnBuildCLI, + 'yarn-berry': YarnBuildCLI, }; const client = this.e.config.get('npmClient'); diff --git a/packages/@ionic/cli/src/lib/utils/npm.ts b/packages/@ionic/cli/src/lib/utils/npm.ts index c717b1924d..0b1a55b888 100644 --- a/packages/@ionic/cli/src/lib/utils/npm.ts +++ b/packages/@ionic/cli/src/lib/utils/npm.ts @@ -76,19 +76,30 @@ export async function pkgManagerArgs(npmClient: NpmClient, options: PkgManagerOp } } + let installerExec: string = ''; const installerArgs: string[] = []; switch (npmClient) { case 'npm': + installerExec = 'npm'; vocab = { run: 'run', install: 'i', bareInstall: 'i', uninstall: 'uninstall', dedupe: 'dedupe', rebuild: 'rebuild', global: '-g', save: '--save', saveDev: '-D', saveExact: '-E', nonInteractive: '', lockFileOnly: '--package-lock-only' }; break; case 'yarn': + installerExec = 'yarn'; vocab = { run: 'run', install: 'add', bareInstall: 'install', uninstall: 'remove', dedupe: '', rebuild: 'install', global: '', save: '', saveDev: '--dev', saveExact: '--exact', nonInteractive: '--non-interactive', lockFileOnly: '' }; if (options.global) { // yarn installs packages globally under the 'global' prefix, instead of having a flag installerArgs.push('global'); } break; + case 'yarn-berry': + installerExec = 'yarn'; + vocab = { run: 'run', install: 'add', bareInstall: 'install', uninstall: 'remove', dedupe: '', rebuild: 'install', global: '', save: '', saveDev: '--dev', saveExact: '--exact', nonInteractive: '', lockFileOnly: '' }; + if (options.global) { // yarn installs packages globally under the 'global' prefix, instead of having a flag + installerArgs.push('global'); + } + break; case 'pnpm': + installerExec = 'pnpm'; vocab = { run: 'run', install: 'add', bareInstall: 'install', uninstall: 'remove', dedupe: '', rebuild: 'rebuild', global: '--global', save: '', saveDev: '--save-dev', saveExact: '--save-exact', nonInteractive: '', lockFileOnly: '--lockfile-only' }; break; default: @@ -171,7 +182,7 @@ export async function pkgManagerArgs(npmClient: NpmClient, options: PkgManagerOp installerArgs.push('--json'); } - return [npmClient, ...installerArgs]; + return [installerExec, ...installerArgs]; } /**