From 4ce456da140f14ae537cf9d02c63a2c33dfef16d Mon Sep 17 00:00:00 2001 From: Losses Don <1384036+Losses@users.noreply.github.com> Date: Tue, 19 Jul 2022 20:38:47 +0800 Subject: [PATCH 1/4] Supports Yarn v2 and Yarn v3 This pull request enables user to use yarn berry (aka yarn v2 and yarn v3) as their package manager, and fixed #4483 --- packages/@ionic/cli/src/lib/utils/npm.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/@ionic/cli/src/lib/utils/npm.ts b/packages/@ionic/cli/src/lib/utils/npm.ts index c717b1924d..0df52a4554 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 } } + const 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]; } /** From 18e9e0cd1547bfdd777924f234b8383b928c1f5e Mon Sep 17 00:00:00 2001 From: Mike Summerfeldt <20338451+IT-MikeS@users.noreply.github.com> Date: Tue, 4 Apr 2023 12:38:58 -0400 Subject: [PATCH 2/4] chore: don't use const for installerExec --- packages/@ionic/cli/src/lib/utils/npm.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@ionic/cli/src/lib/utils/npm.ts b/packages/@ionic/cli/src/lib/utils/npm.ts index 0df52a4554..0b1a55b888 100644 --- a/packages/@ionic/cli/src/lib/utils/npm.ts +++ b/packages/@ionic/cli/src/lib/utils/npm.ts @@ -76,7 +76,7 @@ export async function pkgManagerArgs(npmClient: NpmClient, options: PkgManagerOp } } - const installerExec: string = ''; + let installerExec: string = ''; const installerArgs: string[] = []; switch (npmClient) { From f403455bca99f59bbcae8c555e61802183a182e5 Mon Sep 17 00:00:00 2001 From: Losses Don <1384036+Losses@users.noreply.github.com> Date: Wed, 5 Apr 2023 11:39:07 +0800 Subject: [PATCH 3/4] fix: Incorrect NPM client typing --- packages/@ionic/cli/src/definitions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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'; From a6f5498ef8568b2dc12466f86260632c78575f7b Mon Sep 17 00:00:00 2001 From: Losses Don <1384036+Losses@users.noreply.github.com> Date: Wed, 5 Apr 2023 14:14:37 +0800 Subject: [PATCH 4/4] feat: Add new manager type to builds --- packages/@ionic/cli/src/lib/build.ts | 1 + 1 file changed, 1 insertion(+) 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');