From 5307e872426f395703873ee0dfca1856a65a4069 Mon Sep 17 00:00:00 2001 From: Joakim Carlstein Date: Tue, 12 Dec 2023 15:38:24 +0100 Subject: [PATCH] fix(list): don't log info about locked migrations as it doesn't happen in this command --- .changeset/seven-dolls-hug.md | 6 ++++++ packages/cli/src/reporters/default.ts | 7 ++++--- 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 .changeset/seven-dolls-hug.md diff --git a/.changeset/seven-dolls-hug.md b/.changeset/seven-dolls-hug.md new file mode 100644 index 0000000..9af2545 --- /dev/null +++ b/.changeset/seven-dolls-hug.md @@ -0,0 +1,6 @@ +--- +'@emigrate/cli': patch +'@emigrate/reporter-pino': patch +--- + +Only log info about locked migrations in the "up" command, as "list" doesn't do any locking diff --git a/packages/cli/src/reporters/default.ts b/packages/cli/src/reporters/default.ts index b18fb58..db5a931 100644 --- a/packages/cli/src/reporters/default.ts +++ b/packages/cli/src/reporters/default.ts @@ -225,6 +225,7 @@ const getSummary = ( }; const getHeaderMessage = ( + command: ReporterInitParameters['command'], migrations?: Array, lockedMigrations?: Array, ) => { @@ -246,7 +247,7 @@ const getHeaderMessage = ( const failedMigrations = nonLockedMigrations.filter( (migration) => 'status' in migration && migration.status === 'failed', ); - const unlockableCount = nonLockedMigrations.length - failedMigrations.length; + const unlockableCount = command === 'up' ? nonLockedMigrations.length - failedMigrations.length : 0; const parts = [ bold(`${lockedMigrations.length} of ${migrations.length}`), @@ -340,7 +341,7 @@ class DefaultFancyReporter implements Required { #render(flush = false): void { const parts = [ getTitle(this.#parameters), - getHeaderMessage(this.#migrations, this.#lockedMigrations), + getHeaderMessage(this.#parameters.command, this.#migrations, this.#lockedMigrations), this.#migrations?.map((migration) => getMigrationText(migration, this.#activeMigration)).join('\n') ?? '', getSummary(this.#parameters.command, this.#migrations), getError(this.#error), @@ -394,7 +395,7 @@ class DefaultReporter implements Required { onLockedMigrations(migrations: MigrationMetadata[]): void | PromiseLike { this.#lockedMigrations = migrations; - console.log(getHeaderMessage(this.#migrations, this.#lockedMigrations)); + console.log(getHeaderMessage(this.#parameters.command, this.#migrations, this.#lockedMigrations)); console.log(''); }