Skip to content

Commit

Permalink
fix(list): don't log info about locked migrations as it doesn't happe…
Browse files Browse the repository at this point in the history
…n in this command
  • Loading branch information
joakimbeng committed Dec 12, 2023
1 parent bc33e63 commit 5307e87
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changeset/seven-dolls-hug.md
Original file line number Diff line number Diff line change
@@ -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
7 changes: 4 additions & 3 deletions packages/cli/src/reporters/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ const getSummary = (
};

const getHeaderMessage = (
command: ReporterInitParameters['command'],
migrations?: Array<MigrationMetadata | MigrationMetadataFinished>,
lockedMigrations?: Array<MigrationMetadata | MigrationMetadataFinished>,
) => {
Expand All @@ -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}`),
Expand Down Expand Up @@ -340,7 +341,7 @@ class DefaultFancyReporter implements Required<EmigrateReporter> {
#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),
Expand Down Expand Up @@ -394,7 +395,7 @@ class DefaultReporter implements Required<EmigrateReporter> {
onLockedMigrations(migrations: MigrationMetadata[]): void | PromiseLike<void> {
this.#lockedMigrations = migrations;

console.log(getHeaderMessage(this.#migrations, this.#lockedMigrations));
console.log(getHeaderMessage(this.#parameters.command, this.#migrations, this.#lockedMigrations));
console.log('');
}

Expand Down

0 comments on commit 5307e87

Please sign in to comment.