rbxts-transformer-commit-migrations 1.0.1 → 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 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");
@@ -24,16 +24,13 @@ 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);
30
31
  const orderArg = node.arguments[0];
31
32
  const order = orderArg ? ts.isNumericLiteral(orderArg) ? parseInt(orderArg.getText()) : null : 0;
32
- if (order === null) {
33
- console.error("Recieved null order when resolving migration macros.");
34
- process.exit(1);
35
- }
36
- if (usedOrders.has(order)) {
33
+ if (order !== null && usedOrders.has(order)) {
37
34
  console.error("Multiple of the same migration orders found. Every migration has to have a unique order.");
38
35
  process.exit(1);
39
36
  }
@@ -42,8 +39,10 @@ function walk(node, ctx) {
42
39
  process.exit(1);
43
40
  }
44
41
  if (!orderArg?.getText().includes("__resolved")) {
42
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
45
43
  usedOrders.add(order);
46
- migrationData[entry] = { timestamp: Date.now(), order };
44
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
45
+ migrationData[entry] = { timestamp: Date.now(), order: order };
47
46
  ctx.changed = true;
48
47
  }
49
48
  migrations.push(entry);
@@ -58,6 +57,7 @@ for (const file of files) {
58
57
  const ctx = { changed: false };
59
58
  walk(sourceFile, ctx);
60
59
  if (ctx.changed) {
60
+ changed.push(file);
61
61
  writeFileSync(file, src.replaceAll(MACRO_CALL_REGEX, `${MACRO}("__resolved")`));
62
62
  }
63
63
  }
@@ -68,8 +68,10 @@ if (removedMigrations.length > 0) {
68
68
  process.exit(1);
69
69
  }
70
70
  const newMigrations = migrations.filter((v) => !previousMigrations.includes(v));
71
- if (newMigrations.length === 0)
71
+ if (newMigrations.length === 0) {
72
+ console.error("No new migrations to resolve.");
72
73
  process.exit(0);
74
+ }
73
75
  const newLines = newMigrations
74
76
  .map((e) => `\t${e}: { timestamp: ${migrationData[e].timestamp}, order: ${migrationData[e].order} },`)
75
77
  .join("\n");
@@ -86,4 +88,8 @@ else {
86
88
  const updated = lines.join("\n").replace(/\};\s*$/, `${newLines}\n};`);
87
89
  writeFileSync(CONFIG, updated);
88
90
  }
89
- console.log(`Successfuly resolved ${newMigrations.length} new migrations. [${newMigrations}]`);
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
@@ -0,0 +1,7 @@
1
+ import { $migrate } from "../index.js";
2
+ function test(b) {
3
+ return 0;
4
+ }
5
+ export const abc = {
6
+ hello: test($migrate(0))
7
+ };
@@ -30,7 +30,6 @@ export default function (config) {
30
30
  continue;
31
31
  result.push(prop.name.text);
32
32
  object[prop.name.text] = reconstructProperties(prop.initializer.properties);
33
- console.log(reconstructProperties(prop.initializer.properties));
34
33
  }
35
34
  return [result, object];
36
35
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rbxts-transformer-commit-migrations",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "rbxts transformer used in user data migration builder chains",
5
5
  "main": "out/index.js",
6
6
  "type": "module",