rbxts-transformer-commit-migrations 1.0.2 → 1.1.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.
- package/bin/init.js +1 -1
- package/out/cli/resolveMacros.js +10 -2
- package/out/test.js +7 -0
- package/package.json +1 -1
package/bin/init.js
CHANGED
|
@@ -15,7 +15,7 @@ if (!existsSync(huskyDir)) {
|
|
|
15
15
|
process.exit(1);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
const setupResolve = `npx resolve-commit-migrations\n`;
|
|
18
|
+
const setupResolve = `npx resolve-commit-migrations | xargs git add\n`;
|
|
19
19
|
|
|
20
20
|
if (existsSync(hookFile)) {
|
|
21
21
|
const existing = readFileSync(hookFile, "utf-8");
|
package/out/cli/resolveMacros.js
CHANGED
|
@@ -24,6 +24,7 @@ const files = glob.sync("src/**/*.ts");
|
|
|
24
24
|
const migrations = [];
|
|
25
25
|
const migrationData = {};
|
|
26
26
|
const usedOrders = new Set();
|
|
27
|
+
const changed = [];
|
|
27
28
|
function walk(node, ctx) {
|
|
28
29
|
if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && MACRO_REGEX.test(node.expression.text)) {
|
|
29
30
|
const entry = findEntryName(node);
|
|
@@ -56,6 +57,7 @@ for (const file of files) {
|
|
|
56
57
|
const ctx = { changed: false };
|
|
57
58
|
walk(sourceFile, ctx);
|
|
58
59
|
if (ctx.changed) {
|
|
60
|
+
changed.push(file);
|
|
59
61
|
writeFileSync(file, src.replaceAll(MACRO_CALL_REGEX, `${MACRO}("__resolved")`));
|
|
60
62
|
}
|
|
61
63
|
}
|
|
@@ -66,8 +68,10 @@ if (removedMigrations.length > 0) {
|
|
|
66
68
|
process.exit(1);
|
|
67
69
|
}
|
|
68
70
|
const newMigrations = migrations.filter((v) => !previousMigrations.includes(v));
|
|
69
|
-
if (newMigrations.length === 0)
|
|
71
|
+
if (newMigrations.length === 0) {
|
|
72
|
+
console.error("No new migrations to resolve.");
|
|
70
73
|
process.exit(0);
|
|
74
|
+
}
|
|
71
75
|
const newLines = newMigrations
|
|
72
76
|
.map((e) => `\t${e}: { timestamp: ${migrationData[e].timestamp}, order: ${migrationData[e].order} },`)
|
|
73
77
|
.join("\n");
|
|
@@ -84,4 +88,8 @@ else {
|
|
|
84
88
|
const updated = lines.join("\n").replace(/\};\s*$/, `${newLines}\n};`);
|
|
85
89
|
writeFileSync(CONFIG, updated);
|
|
86
90
|
}
|
|
87
|
-
|
|
91
|
+
changed.push(CONFIG);
|
|
92
|
+
console.error(`Successfuly resolved ${newMigrations.length} new migrations. [${newMigrations}]`);
|
|
93
|
+
for (const path of changed) {
|
|
94
|
+
console.log(path.replace(/\\/g, "/"));
|
|
95
|
+
}
|
package/out/test.js
ADDED