From 62fa792131a702561ead8f12674336d397dd556f Mon Sep 17 00:00:00 2001 From: Benjamin Fischer <61995275+c4spar@users.noreply.github.com> Date: Sat, 28 Sep 2024 14:29:25 +0200 Subject: [PATCH] feat(command): add support for disabling spinner in upgrade command (#749) --- command/upgrade/provider/npm.ts | 2 +- command/upgrade/upgrade_command.ts | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/command/upgrade/provider/npm.ts b/command/upgrade/provider/npm.ts index 8e5a41e9..c9f66c8f 100644 --- a/command/upgrade/provider/npm.ts +++ b/command/upgrade/provider/npm.ts @@ -16,7 +16,7 @@ export class NpmProvider extends Provider { private readonly packageName?: string; private readonly packageScope?: string; - constructor({ main, logger, ...options }: NpmProviderOptions) { + constructor({ main, logger, ...options }: NpmProviderOptions = {}) { super({ main, logger }); if ("package" in options) { if (options.package.startsWith("@")) { diff --git a/command/upgrade/upgrade_command.ts b/command/upgrade/upgrade_command.ts index c670893e..8e542463 100644 --- a/command/upgrade/upgrade_command.ts +++ b/command/upgrade/upgrade_command.ts @@ -17,6 +17,7 @@ export interface UpgradeCommandOptions< > extends RuntimeOptions { provider: TProvider | Array; runtime?: RuntimeOptionsMap; + spinner?: boolean; } /** @@ -58,7 +59,8 @@ export class UpgradeCommand extends Command { private readonly providers: ReadonlyArray; constructor( - { provider, ...options }: UpgradeCommandOptions, + { provider, spinner: withSpinner = true, ...options }: + UpgradeCommandOptions, ) { super(); this.providers = Array.isArray(provider) ? provider : [provider]; @@ -108,7 +110,9 @@ export class UpgradeCommand extends Command { "-v, --verbose", "Log verbose output.", ) - .option("--no-spinner", "Disable spinner.") + .option("--no-spinner", "Disable spinner.", { + hidden: !withSpinner, + }) .complete("version", () => this.getAllVersions()) .action( async ( @@ -123,7 +127,7 @@ export class UpgradeCommand extends Command { const name: string = this.getMainCommand().getName(); const currentVersion: string | undefined = this.getVersion(); - const spinner = spinnerEnabled + const spinner = withSpinner && spinnerEnabled ? new Spinner({ message: brightBlue( `Upgrading ${bold(name)} from version ${