diff --git a/.changeset/tame-apples-lick.md b/.changeset/tame-apples-lick.md new file mode 100644 index 0000000..ef6ad0a --- /dev/null +++ b/.changeset/tame-apples-lick.md @@ -0,0 +1,5 @@ +--- +'@emigrate/reporter-pino': minor +--- + +Adapt to the new Reporter interface, i.e. the removal of the "remove" command related methods diff --git a/packages/reporter-pino/src/index.ts b/packages/reporter-pino/src/index.ts index 942c55d..a6c519c 100644 --- a/packages/reporter-pino/src/index.ts +++ b/packages/reporter-pino/src/index.ts @@ -104,27 +104,14 @@ class PinoReporter implements Required { ); } - onMigrationRemoveStart(migration: MigrationMetadata): Awaitable { - this.#logger.debug({ migration: migration.relativeFilePath }, `Removing migration: ${migration.name}`); - } - - onMigrationRemoveSuccess(migration: MigrationMetadataFinished): Awaitable { - this.#logger.info({ migration: migration.relativeFilePath }, `Successfully removed migration: ${migration.name}`); - } - - onMigrationRemoveError(migration: MigrationMetadataFinished, error: Error): Awaitable { - this.#logger.error( - { migration: migration.relativeFilePath, [this.errorKey]: error }, - `Failed to remove migration: ${migration.name}`, - ); - } - onMigrationStart(migration: MigrationMetadata): Awaitable { - this.#logger.info({ migration: migration.relativeFilePath }, `${migration.name} (running)`); + const status = this.#command === 'up' ? 'running' : 'removing'; + this.#logger.info({ migration: migration.relativeFilePath }, `${migration.name} (${status})`); } onMigrationSuccess(migration: MigrationMetadataFinished): Awaitable { - this.#logger.info({ migration: migration.relativeFilePath }, `${migration.name} (${migration.status})`); + const status = this.#command === 'up' ? 'done' : 'removed'; + this.#logger.info({ migration: migration.relativeFilePath }, `${migration.name} (${status})`); } onMigrationError(migration: MigrationMetadataFinished, error: Error): Awaitable { @@ -174,16 +161,15 @@ class PinoReporter implements Required { } } + const result = + this.#command === 'remove' + ? { removed: done, failed, skipped, pending, total } + : { done, failed, skipped, pending, total }; + if (error) { - this.#logger.error( - { result: { failed, done, skipped, pending, total }, [this.errorKey]: error }, - `Emigrate "${this.#command}" failed`, - ); + this.#logger.error({ result, [this.errorKey]: error }, `Emigrate "${this.#command}" failed`); } else { - this.#logger.info( - { result: { failed, done, skipped, pending, total } }, - `Emigrate "${this.#command}" finished successfully`, - ); + this.#logger.info({ result }, `Emigrate "${this.#command}" finished successfully`); } } }