From 375575cb0098970b11861bb1786a73ef26637246 Mon Sep 17 00:00:00 2001 From: "damian.ionic" Date: Fri, 5 Apr 2024 12:14:46 -0700 Subject: [PATCH 1/3] feat(cli): Support bun when running cap migrate --- cli/src/tasks/migrate.ts | 66 +++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/cli/src/tasks/migrate.ts b/cli/src/tasks/migrate.ts index b9f15d0e82..ab9de9186a 100644 --- a/cli/src/tasks/migrate.ts +++ b/cli/src/tasks/migrate.ts @@ -79,10 +79,10 @@ export async function migrateCommand( const variablesAndClasspaths: | { - 'variables': any; - 'com.android.tools.build:gradle': string; - 'com.google.gms:google-services': string; - } + 'variables': any; + 'com.android.tools.build:gradle': string; + 'com.google.gms:google-services': string; + } | undefined = await getAndroidVariablesAndClasspaths(config); if (!variablesAndClasspaths) { @@ -95,21 +95,21 @@ export async function migrateCommand( }; const monorepoWarning = - 'Please note this tool is not intended for use in a mono-repo enviroment, please check out the Ionic vscode extension for this functionality.'; + 'Please note this tool is not intended for use in a mono-repo environment, please check out the Ionic vscode extension for this functionality.'; logger.info(monorepoWarning); const { migrateconfirm } = noprompt ? { migrateconfirm: 'y' } : await logPrompt( - `Capacitor 6 sets a deployment target of iOS 13 and Android 14 (SDK 34). \n`, - { - type: 'text', - name: 'migrateconfirm', - message: `Are you sure you want to migrate? (Y/n)`, - initial: 'y', - }, - ); + `Capacitor 6 sets a deployment target of iOS 13 and Android 14 (SDK 34). \n`, + { + type: 'text', + name: 'migrateconfirm', + message: `Are you sure you want to migrate? (Y/n)`, + initial: 'y', + }, + ); if ( typeof migrateconfirm === 'string' && @@ -119,14 +119,14 @@ export async function migrateCommand( const { depInstallConfirm } = noprompt ? { depInstallConfirm: 'y' } : await logPrompt( - `Would you like the migrator to run npm, yarn, or pnpm install to install the latest versions of capacitor packages? (Those using other package managers should answer N)`, - { - type: 'text', - name: 'depInstallConfirm', - message: `Run Dependency Install? (Y/n)`, - initial: 'y', - }, - ); + `Would you like the migrator to run npm, yarn, bun, or pnpm install to install the latest versions of capacitor packages? (Those using other package managers should answer N)`, + { + type: 'text', + name: 'depInstallConfirm', + message: `Run Dependency Install? (Y/n)`, + initial: 'y', + }, + ); const runNpmInstall = typeof depInstallConfirm === 'string' && @@ -137,16 +137,17 @@ export async function migrateCommand( const { manager } = packagemanager ? { manager: packagemanager } : await logPrompt('What dependency manager do you use?', { - type: 'select', - name: 'manager', - message: `Dependency Management Tool`, - choices: [ - { title: 'NPM', value: 'npm' }, - { title: 'Yarn', value: 'yarn' }, - { title: 'PNPM', value: 'pnpm' }, - ], - initial: 0, - }); + type: 'select', + name: 'manager', + message: `Dependency Management Tool`, + choices: [ + { title: 'NPM', value: 'npm' }, + { title: 'Yarn', value: 'yarn' }, + { title: 'PNPM', value: 'pnpm' }, + { title: 'Bun', value: 'bun' }, + ], + initial: 0, + }); installerType = manager; } @@ -354,7 +355,8 @@ export async function migrateCommand( if (!installFailed) { // Run Cap Sync await runTask(`Running cap sync.`, () => { - return getCommandOutput('npx', ['cap', 'sync']); + const runCommand = installerType == 'bun' ? 'bunx' : 'npx'; + return getCommandOutput(runCommand, ['cap', 'sync']); }); } else { logger.warn('Skipped Running cap sync.'); From f8fdb4bef266163d2cd3354193cadcae7ed8ca7a Mon Sep 17 00:00:00 2001 From: "damian.ionic" Date: Mon, 8 Apr 2024 07:03:42 -0700 Subject: [PATCH 2/3] chore: fix linting --- cli/src/tasks/migrate.ts | 62 ++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/cli/src/tasks/migrate.ts b/cli/src/tasks/migrate.ts index ab9de9186a..e25d6ae915 100644 --- a/cli/src/tasks/migrate.ts +++ b/cli/src/tasks/migrate.ts @@ -79,10 +79,10 @@ export async function migrateCommand( const variablesAndClasspaths: | { - 'variables': any; - 'com.android.tools.build:gradle': string; - 'com.google.gms:google-services': string; - } + 'variables': any; + 'com.android.tools.build:gradle': string; + 'com.google.gms:google-services': string; + } | undefined = await getAndroidVariablesAndClasspaths(config); if (!variablesAndClasspaths) { @@ -102,14 +102,14 @@ export async function migrateCommand( const { migrateconfirm } = noprompt ? { migrateconfirm: 'y' } : await logPrompt( - `Capacitor 6 sets a deployment target of iOS 13 and Android 14 (SDK 34). \n`, - { - type: 'text', - name: 'migrateconfirm', - message: `Are you sure you want to migrate? (Y/n)`, - initial: 'y', - }, - ); + `Capacitor 6 sets a deployment target of iOS 13 and Android 14 (SDK 34). \n`, + { + type: 'text', + name: 'migrateconfirm', + message: `Are you sure you want to migrate? (Y/n)`, + initial: 'y', + }, + ); if ( typeof migrateconfirm === 'string' && @@ -119,14 +119,14 @@ export async function migrateCommand( const { depInstallConfirm } = noprompt ? { depInstallConfirm: 'y' } : await logPrompt( - `Would you like the migrator to run npm, yarn, bun, or pnpm install to install the latest versions of capacitor packages? (Those using other package managers should answer N)`, - { - type: 'text', - name: 'depInstallConfirm', - message: `Run Dependency Install? (Y/n)`, - initial: 'y', - }, - ); + `Would you like the migrator to run npm, yarn, bun, or pnpm install to install the latest versions of capacitor packages? (Those using other package managers should answer N)`, + { + type: 'text', + name: 'depInstallConfirm', + message: `Run Dependency Install? (Y/n)`, + initial: 'y', + }, + ); const runNpmInstall = typeof depInstallConfirm === 'string' && @@ -137,17 +137,17 @@ export async function migrateCommand( const { manager } = packagemanager ? { manager: packagemanager } : await logPrompt('What dependency manager do you use?', { - type: 'select', - name: 'manager', - message: `Dependency Management Tool`, - choices: [ - { title: 'NPM', value: 'npm' }, - { title: 'Yarn', value: 'yarn' }, - { title: 'PNPM', value: 'pnpm' }, - { title: 'Bun', value: 'bun' }, - ], - initial: 0, - }); + type: 'select', + name: 'manager', + message: `Dependency Management Tool`, + choices: [ + { title: 'NPM', value: 'npm' }, + { title: 'Yarn', value: 'yarn' }, + { title: 'PNPM', value: 'pnpm' }, + { title: 'Bun', value: 'bun' }, + ], + initial: 0, + }); installerType = manager; } From 37edbde157249d8e2e4f37f7118fe5ef1b24eeab Mon Sep 17 00:00:00 2001 From: "damian.ionic" Date: Tue, 9 Apr 2024 09:25:41 -0700 Subject: [PATCH 3/3] chore: address code review comments --- cli/src/tasks/migrate.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cli/src/tasks/migrate.ts b/cli/src/tasks/migrate.ts index e25d6ae915..ff14c7dee2 100644 --- a/cli/src/tasks/migrate.ts +++ b/cli/src/tasks/migrate.ts @@ -119,7 +119,7 @@ export async function migrateCommand( const { depInstallConfirm } = noprompt ? { depInstallConfirm: 'y' } : await logPrompt( - `Would you like the migrator to run npm, yarn, bun, or pnpm install to install the latest versions of capacitor packages? (Those using other package managers should answer N)`, + `Would you like the migrator to run npm, yarn, pnpm, or bun install to install the latest versions of capacitor packages? (Those using other package managers should answer N)`, { type: 'text', name: 'depInstallConfirm', @@ -355,8 +355,7 @@ export async function migrateCommand( if (!installFailed) { // Run Cap Sync await runTask(`Running cap sync.`, () => { - const runCommand = installerType == 'bun' ? 'bunx' : 'npx'; - return getCommandOutput(runCommand, ['cap', 'sync']); + return getCommandOutput('npx', ['cap', 'sync']); }); } else { logger.warn('Skipped Running cap sync.');