From 62bd5a45e5496a381c414f4aaa9523db96027b0f Mon Sep 17 00:00:00 2001 From: Joakim Carlstein Date: Thu, 16 Nov 2023 10:54:34 +0100 Subject: [PATCH] feat(plugin-tools): add more properties to the MigrationMetadata type --- .changeset/small-snakes-explode.md | 5 +++++ packages/plugin-tools/src/types.ts | 33 +++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 .changeset/small-snakes-explode.md diff --git a/.changeset/small-snakes-explode.md b/.changeset/small-snakes-explode.md new file mode 100644 index 0000000..32a4c56 --- /dev/null +++ b/.changeset/small-snakes-explode.md @@ -0,0 +1,5 @@ +--- +'@emigrate/plugin-tools': minor +--- + +Add more properties to the MigrationMetadata type to ease writing "loader" plugins diff --git a/packages/plugin-tools/src/types.ts b/packages/plugin-tools/src/types.ts index 873fe86..c49b59a 100644 --- a/packages/plugin-tools/src/types.ts +++ b/packages/plugin-tools/src/types.ts @@ -90,8 +90,39 @@ export type GenerateMigrationFunction = GeneratorPlugin['generateMigration']; export type MigrationFunction = () => Promise; export type MigrationMetadata = { + /** + * The name of the migration file + * + * @example 20210901123456000_create_users_table.js + */ name: string; - filename: string; + /** + * The directory where the migration file is located, relative to the current working directory + * + * @example migrations + */ + directory: string; + /** + * The full absolute path to the migration file + * + * @example /home/user/project/migrations/20210901123456000_create_users_table.js + */ + filePath: string; + /** + * The relative path to the migration file, relative to the current working directory + * + * @example migrations/20210901123456000_create_users_table.js + */ + relativeFilePath: string; + /** + * The current working directory (the same as process.cwd()) + */ + cwd: string; + /** + * The extension of the migration file + * + * @example js + */ extension: string; };