@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.js
CHANGED
|
@@ -419,8 +419,12 @@ var SqlMigrationBuilder = class {
|
|
|
419
419
|
// framework/MigrationManifest.ts
|
|
420
420
|
var import_fs = __toESM(require("fs"));
|
|
421
421
|
var import_path = __toESM(require("path"));
|
|
422
|
+
var MIGRATION_FILE_REGEX = /(?:\.(mysql|sqlite|pg))?\.(up|down)\.(sql|js)$/i;
|
|
423
|
+
function isMigrationFile(fileName) {
|
|
424
|
+
return MIGRATION_FILE_REGEX.test(fileName);
|
|
425
|
+
}
|
|
422
426
|
function canonicalMigrationKey(value) {
|
|
423
|
-
return value.replace(
|
|
427
|
+
return value.replace(MIGRATION_FILE_REGEX, "").toLowerCase();
|
|
424
428
|
}
|
|
425
429
|
function resolveMigrationFile(directory, baseName, direction, dialect) {
|
|
426
430
|
const dialectExt = dialect === "sql" ? "mysql" : dialect;
|
|
@@ -433,7 +437,7 @@ function resolveMigrationFile(directory, baseName, direction, dialect) {
|
|
|
433
437
|
function loadMigrationManifest(directory, dialect) {
|
|
434
438
|
const manifest = /* @__PURE__ */ new Map();
|
|
435
439
|
if (!import_fs.default.existsSync(directory)) return manifest;
|
|
436
|
-
const files = import_fs.default.readdirSync(directory, { withFileTypes: true }).filter((f) => f.isFile()).map((f) => f.name);
|
|
440
|
+
const files = import_fs.default.readdirSync(directory, { withFileTypes: true }).filter((f) => f.isFile()).map((f) => f.name).filter(isMigrationFile);
|
|
437
441
|
const uniqueKeys = /* @__PURE__ */ new Set();
|
|
438
442
|
files.forEach((file) => uniqueKeys.add(canonicalMigrationKey(file)));
|
|
439
443
|
uniqueKeys.forEach((key) => {
|
|
@@ -470,7 +474,7 @@ var MigrationDirectoryReader = class {
|
|
|
470
474
|
}
|
|
471
475
|
loadMigrations(table, connection) {
|
|
472
476
|
import_fs2.default.existsSync(this.directory) || import_fs2.default.mkdirSync(this.directory);
|
|
473
|
-
const dir_content = import_fs2.default.readdirSync(this.directory, { withFileTypes: true }).filter((file) => file.isFile()).map((file) => file.name);
|
|
477
|
+
const dir_content = import_fs2.default.readdirSync(this.directory, { withFileTypes: true }).filter((file) => file.isFile()).map((file) => file.name).filter(isMigrationFile);
|
|
474
478
|
const uniqueKeys = /* @__PURE__ */ new Set();
|
|
475
479
|
dir_content.forEach((file) => {
|
|
476
480
|
const key = canonicalMigrationKey(file);
|