@oliasoft-open-source/node-json-migrator 5.6.0-beta-1 → 5.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.mjs +13 -10
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -4176,6 +4176,17 @@ const throwIfFilesNotFound = (migrationEntries) => {
4176
4176
  throw new Error("Migration files from plan.json are missing from filesystem");
4177
4177
  }
4178
4178
  };
4179
+ /** Throws if active migration files are missing from plan.json. */
4180
+ const throwIfFilesNotInPlan = (filePaths, migrationEntries) => {
4181
+ const missingFileNames = filePaths.map((filePath) => {
4182
+ return path.basename(filePath);
4183
+ }).filter((fileName) => {
4184
+ return !migrationEntries.some((entry) => {
4185
+ return entry.fileName === fileName;
4186
+ });
4187
+ });
4188
+ if (missingFileNames.length) throw new Error(`Migration files are missing from plan.json: ${missingFileNames.join(", ")}. Add them to plan.json and re-run the migrator.`);
4189
+ };
4179
4190
  //#endregion
4180
4191
  //#region src/database/database.ts
4181
4192
  const migrationTablesExist = (db, entity) => {
@@ -4438,21 +4449,12 @@ const getPlannedMigrations = async ({ config }) => {
4438
4449
  if (!await migrationTablesExist(database, entity)) await createMigrationsTables(database, entity);
4439
4450
  }
4440
4451
  const rawPlan = await readPlan(directory);
4441
- const parsedPlan = parsePlan$1(rawPlan);
4442
- const plannedMigrations = parsedPlan.map((m) => ({
4452
+ const plannedMigrations = parsePlan$1(rawPlan).map((m) => ({
4443
4453
  fileHashFromPlan: m.fileHash,
4444
4454
  fileName: m.fileName,
4445
4455
  sequence: m.sequence
4446
4456
  }));
4447
4457
  const filePaths = await getMigrationFilePaths(directory);
4448
- const missingFileNames = filePaths.map((filePath) => {
4449
- return path.basename(filePath);
4450
- }).filter((fileName) => {
4451
- return !parsedPlan.some((entry) => {
4452
- return entry.fileName === fileName;
4453
- });
4454
- });
4455
- if (missingFileNames.length) throw new Error(`Migration files are missing from plan.json: ${missingFileNames.join(", ")}. Add them to plan.json and re-run the migrator.`);
4456
4458
  const skippedFilePaths = await getSkippedFilePaths(directory);
4457
4459
  const plannedMigrationsWithFileEntries = await Promise.all(plannedMigrations.map(async (m) => {
4458
4460
  const { fileName } = m;
@@ -4488,6 +4490,7 @@ const getPlannedMigrations = async ({ config }) => {
4488
4490
  sequenceFromHistory: historicalMigration?.sequence || null
4489
4491
  };
4490
4492
  });
4493
+ throwIfFilesNotInPlan(filePaths, plannedMigrationsWithHistory);
4491
4494
  throwIfFilesNotFound(plannedMigrationsWithHistory);
4492
4495
  throwIfFileNamesInvalid(plannedMigrationsWithHistory);
4493
4496
  throwIfFileNamesNotUnique(plannedMigrationsWithHistory);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oliasoft-open-source/node-json-migrator",
3
- "version": "5.6.0-beta-1",
3
+ "version": "5.6.0",
4
4
  "description": "A library for JSON migrations",
5
5
  "homepage": "https://oliasoft-open-source.gitlab.io/node-json-migrator",
6
6
  "bugs": {