@getstrata/cli 1.1.9 → 2.0.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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @getstrata/cli changelog
2
2
 
3
+ ## 2.0.0
4
+
5
+ - Strata 2.0: compose business transactions and tenant scopes
6
+
7
+ ## Unreleased
8
+
9
+ - 2.0: migrations no longer implicitly call an app seed export. Seeding requires --seed; fresh accepts the same explicit flag. Missing seed exports are rejected before applying migrations or resetting data.
10
+
3
11
  ## 1.1.9
4
12
 
5
13
  - Defer model events until the surrounding transaction commits
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getstrata/cli",
3
- "version": "1.1.9",
3
+ "version": "2.0.0",
4
4
  "description": "Strata CLI: framework commands for Bun apps (dev, start, migrate, run)",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -33,11 +33,14 @@ async function migrateCommand(app: StrataAppConfig, args: string[]): Promise<voi
33
33
  if (typeof entry.migrate !== "function") {
34
34
  throw new Error(`${app.migrate} must export a migrate() function.`);
35
35
  }
36
+ if (args.includes("--seed") && typeof entry.seed !== "function") {
37
+ throw new Error("--seed requires a seed() export on the migration entry.");
38
+ }
36
39
 
37
40
  try {
38
41
  await entry.migrate(...args);
39
42
 
40
- if (typeof entry.seed === "function") {
43
+ if (args.includes("--seed") && typeof entry.seed === "function") {
41
44
  await entry.seed(...args);
42
45
  }
43
46
  } finally {
@@ -52,10 +55,24 @@ async function migrateFreshCommand(app: StrataAppConfig, args: string[]): Promis
52
55
  if (typeof entry.fresh !== "function") {
53
56
  throw new Error(`${app.fresh} must export a fresh() function.`);
54
57
  }
58
+ const seedEntry = args.includes("--seed")
59
+ ? typeof entry.seed === "function"
60
+ ? entry
61
+ : app.migrate
62
+ ? await importEntry(app.migrate)
63
+ : undefined
64
+ : undefined;
65
+ if (args.includes("--seed") && typeof seedEntry?.seed !== "function") {
66
+ throw new Error("--seed requires a seed() export on the migration or fresh entry.");
67
+ }
55
68
  try {
56
69
  await entry.fresh(...args);
70
+ if (seedEntry?.seed) {
71
+ await seedEntry.seed(...args);
72
+ }
57
73
  } finally {
58
74
  await closeEntry(entry);
75
+ if (seedEntry && seedEntry !== entry) await closeEntry(seedEntry);
59
76
  }
60
77
  console.log("Database reset and migrated.");
61
78
  return;