@noego/proper 0.2.0 → 0.2.1
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.
- package/bin/cli.js +7 -3
- package/bin/cli.js.map +1 -1
- package/bin/cli.mjs +8 -3
- package/bin/cli.mjs.map +1 -1
- package/bin/index.js +7 -3
- package/bin/index.js.map +1 -1
- package/bin/index.mjs +7 -3
- package/bin/index.mjs.map +1 -1
- package/package.json +1 -1
- package/readme.md +5 -0
package/bin/index.mjs
CHANGED
|
@@ -370,8 +370,12 @@ var SqlMigrationBuilder = class {
|
|
|
370
370
|
// framework/MigrationManifest.ts
|
|
371
371
|
import fs from "fs";
|
|
372
372
|
import path from "path";
|
|
373
|
+
var MIGRATION_FILE_REGEX = /(?:\.(mysql|sqlite|pg))?\.(up|down)\.(sql|js)$/i;
|
|
374
|
+
function isMigrationFile(fileName) {
|
|
375
|
+
return MIGRATION_FILE_REGEX.test(fileName);
|
|
376
|
+
}
|
|
373
377
|
function canonicalMigrationKey(value) {
|
|
374
|
-
return value.replace(
|
|
378
|
+
return value.replace(MIGRATION_FILE_REGEX, "").toLowerCase();
|
|
375
379
|
}
|
|
376
380
|
function resolveMigrationFile(directory, baseName, direction, dialect) {
|
|
377
381
|
const dialectExt = dialect === "sql" ? "mysql" : dialect;
|
|
@@ -384,7 +388,7 @@ function resolveMigrationFile(directory, baseName, direction, dialect) {
|
|
|
384
388
|
function loadMigrationManifest(directory, dialect) {
|
|
385
389
|
const manifest = /* @__PURE__ */ new Map();
|
|
386
390
|
if (!fs.existsSync(directory)) return manifest;
|
|
387
|
-
const files = fs.readdirSync(directory, { withFileTypes: true }).filter((f) => f.isFile()).map((f) => f.name);
|
|
391
|
+
const files = fs.readdirSync(directory, { withFileTypes: true }).filter((f) => f.isFile()).map((f) => f.name).filter(isMigrationFile);
|
|
388
392
|
const uniqueKeys = /* @__PURE__ */ new Set();
|
|
389
393
|
files.forEach((file) => uniqueKeys.add(canonicalMigrationKey(file)));
|
|
390
394
|
uniqueKeys.forEach((key) => {
|
|
@@ -421,7 +425,7 @@ var MigrationDirectoryReader = class {
|
|
|
421
425
|
}
|
|
422
426
|
loadMigrations(table, connection) {
|
|
423
427
|
fs2.existsSync(this.directory) || fs2.mkdirSync(this.directory);
|
|
424
|
-
const dir_content = fs2.readdirSync(this.directory, { withFileTypes: true }).filter((file) => file.isFile()).map((file) => file.name);
|
|
428
|
+
const dir_content = fs2.readdirSync(this.directory, { withFileTypes: true }).filter((file) => file.isFile()).map((file) => file.name).filter(isMigrationFile);
|
|
425
429
|
const uniqueKeys = /* @__PURE__ */ new Set();
|
|
426
430
|
dir_content.forEach((file) => {
|
|
427
431
|
const key = canonicalMigrationKey(file);
|