@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/cli.mjs
CHANGED
|
@@ -463,8 +463,11 @@ var init_SqlMigrationBuilder = __esm({
|
|
|
463
463
|
// framework/MigrationManifest.ts
|
|
464
464
|
import fs from "fs";
|
|
465
465
|
import path from "path";
|
|
466
|
+
function isMigrationFile(fileName) {
|
|
467
|
+
return MIGRATION_FILE_REGEX.test(fileName);
|
|
468
|
+
}
|
|
466
469
|
function canonicalMigrationKey(value) {
|
|
467
|
-
return value.replace(
|
|
470
|
+
return value.replace(MIGRATION_FILE_REGEX, "").toLowerCase();
|
|
468
471
|
}
|
|
469
472
|
function resolveMigrationFile(directory, baseName, direction, dialect) {
|
|
470
473
|
const dialectExt = dialect === "sql" ? "mysql" : dialect;
|
|
@@ -477,7 +480,7 @@ function resolveMigrationFile(directory, baseName, direction, dialect) {
|
|
|
477
480
|
function loadMigrationManifest(directory, dialect) {
|
|
478
481
|
const manifest = /* @__PURE__ */ new Map();
|
|
479
482
|
if (!fs.existsSync(directory)) return manifest;
|
|
480
|
-
const files = fs.readdirSync(directory, { withFileTypes: true }).filter((f) => f.isFile()).map((f) => f.name);
|
|
483
|
+
const files = fs.readdirSync(directory, { withFileTypes: true }).filter((f) => f.isFile()).map((f) => f.name).filter(isMigrationFile);
|
|
481
484
|
const uniqueKeys = /* @__PURE__ */ new Set();
|
|
482
485
|
files.forEach((file) => uniqueKeys.add(canonicalMigrationKey(file)));
|
|
483
486
|
uniqueKeys.forEach((key) => {
|
|
@@ -489,8 +492,10 @@ function loadMigrationManifest(directory, dialect) {
|
|
|
489
492
|
});
|
|
490
493
|
return manifest;
|
|
491
494
|
}
|
|
495
|
+
var MIGRATION_FILE_REGEX;
|
|
492
496
|
var init_MigrationManifest = __esm({
|
|
493
497
|
"framework/MigrationManifest.ts"() {
|
|
498
|
+
MIGRATION_FILE_REGEX = /(?:\.(mysql|sqlite|pg))?\.(up|down)\.(sql|js)$/i;
|
|
494
499
|
}
|
|
495
500
|
});
|
|
496
501
|
|
|
@@ -524,7 +529,7 @@ var init_MigrationDirectoryReader = __esm({
|
|
|
524
529
|
}
|
|
525
530
|
loadMigrations(table, connection) {
|
|
526
531
|
fs2.existsSync(this.directory) || fs2.mkdirSync(this.directory);
|
|
527
|
-
const dir_content = fs2.readdirSync(this.directory, { withFileTypes: true }).filter((file) => file.isFile()).map((file) => file.name);
|
|
532
|
+
const dir_content = fs2.readdirSync(this.directory, { withFileTypes: true }).filter((file) => file.isFile()).map((file) => file.name).filter(isMigrationFile);
|
|
528
533
|
const uniqueKeys = /* @__PURE__ */ new Set();
|
|
529
534
|
dir_content.forEach((file) => {
|
|
530
535
|
const key = canonicalMigrationKey(file);
|