Skip to content

feat(cli): now support bun #5097

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/@ionic/cli/src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ export interface ITelemetry {
sendCommand(command: string, args: string[]): Promise<void>;
}

export type NpmClient = 'yarn' | 'npm' | 'pnpm';
export type NpmClient = 'yarn' | 'npm' | 'pnpm' | 'bun';

export type FeatureId = 'ssl-commands';

Expand Down
7 changes: 7 additions & 0 deletions packages/@ionic/cli/src/lib/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export abstract class BuildRunner<T extends BuildOptions<any>> implements Runner
npm: NpmBuildCLI,
pnpm: PnpmBuildCLI,
yarn: YarnBuildCLI,
bun: BunBuildCLI,
};

const client = this.e.config.get('npmClient');
Expand Down Expand Up @@ -307,6 +308,12 @@ export class YarnBuildCLI extends PkgManagerBuildCLI {
readonly program = 'yarn';
}

export class BunBuildCLI extends PkgManagerBuildCLI {
readonly name = 'Bun';
readonly pkg = 'bun';
readonly program = 'bun';
}

class BuildBeforeHook extends Hook {
readonly name = 'build:before';
}
Expand Down
8 changes: 8 additions & 0 deletions packages/@ionic/cli/src/lib/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export abstract class ServeRunner<T extends ServeOptions> implements Runner<T, S
npm: NpmServeCLI,
pnpm: PnpmServeCLI,
yarn: YarnServeCLI,
bun: BunServeCLI,
};

const client = this.e.config.get('npmClient');
Expand Down Expand Up @@ -626,3 +627,10 @@ export class YarnServeCLI extends PkgManagerServeCLI {
readonly program = 'yarn';
readonly prefix = 'yarn';
}

export class BunServeCLI extends PkgManagerServeCLI {
readonly name = 'Bun';
readonly pkg = 'bun';
readonly program = 'bun';
readonly prefix = 'bun';
}
5 changes: 4 additions & 1 deletion packages/@ionic/cli/src/lib/utils/npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ export async function pkgManagerArgs(npmClient: NpmClient, options: PkgManagerOp
case '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;
case 'bun':
vocab = { run: 'run', install: 'add', bareInstall: 'install', uninstall: 'remove', dedupe: '', rebuild: 'rebuild', global: '--global', save: '', saveDev: '--save-dev', saveExact: '--save-exact', nonInteractive: '', lockFileOnly: '' };
break;
default:
throw new Error(`unknown installer: ${npmClient}`);
}
Expand Down Expand Up @@ -158,7 +161,7 @@ export async function pkgManagerArgs(npmClient: NpmClient, options: PkgManagerOp
}

if (cmd === 'run' && options.script && options.scriptArgs && options.scriptArgs.length > 0) {
if (npmClient === 'npm' || npmClient === 'pnpm') {
if (npmClient === 'npm' || npmClient === 'pnpm' || npmClient === 'bun') {
installerArgs.push('--');
}

Expand Down