@getstrata/cli 3.1.0 → 3.1.4

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,23 @@
1
1
  # @getstrata/cli changelog
2
2
 
3
+ ## 3.1.4
4
+
5
+ - Synchronize package versions and dependency pins at 3.1.4 for the corrected starter release validation. No additional runtime changes in this package.
6
+
7
+ ## 3.1.3
8
+
9
+ - Generate class-based model listeners instead of missing repository imports; reject missing models before writing files.
10
+ - Avoid duplicate Job suffixes, emit the required static override, and point model registration guidance at the generated app registry.
11
+ - Reject automatic CRUD modules that would ignore selected tenancy or require disabled views before writing files.
12
+
13
+ ## 3.1.2
14
+
15
+ - Describe application servers, scaffolding, migrations, workers and scheduling in npm metadata. Align peer dependencies with 3.1.2.
16
+
17
+ ## 3.1.1
18
+
19
+ - Align core/bootstrap peer ranges with 3.1.1 so generated applications use the coordinated package set.
20
+
3
21
  ## 3.1.0
4
22
 
5
23
  - Generate concise model classes and infer factory/record types without table, interface or repository companion files.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@getstrata/cli",
3
- "version": "3.1.0",
4
- "description": "Strata CLI: framework commands for Bun apps (dev, start, migrate, run)",
3
+ "version": "3.1.4",
4
+ "description": "Strata development tools: application servers, scaffolding, migrations, workers, and scheduling.",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -54,8 +54,8 @@
54
54
  ],
55
55
  "scripts": {},
56
56
  "peerDependencies": {
57
- "@getstrata/bootstrap": "^3.1.0",
58
- "@getstrata/core": "^3.1.0"
57
+ "@getstrata/bootstrap": "^3.1.4",
58
+ "@getstrata/core": "^3.1.4"
59
59
  },
60
60
  "publishConfig": {
61
61
  "access": "public"
@@ -11,9 +11,11 @@ async function makeJobCommand(...args: string[]): Promise<void> {
11
11
  throw new Error("make:job requires a job name.");
12
12
  }
13
13
 
14
- const jobSlug = toKebabCase(name);
15
- const jobClass = `${toPascalCase(name)}Job`;
16
- const payloadType = `${toPascalCase(name)}Payload`;
14
+ const baseName = toPascalCase(name).replace(/Job$/, "");
15
+ if (!baseName) throw new Error("make:job requires a specific job name, such as SendInvoiceJob.");
16
+ const jobSlug = toKebabCase(baseName);
17
+ const jobClass = `${baseName}Job`;
18
+ const payloadType = `${baseName}Payload`;
17
19
  const directory = join(process.cwd(), "src", "jobs");
18
20
  const jobPath = join(directory, `${jobSlug}Job.ts`);
19
21
 
@@ -32,7 +34,7 @@ interface ${payloadType} {
32
34
  }
33
35
 
34
36
  class ${jobClass} extends Job<${payloadType}> {
35
- static readonly jobName = "${jobSlug}";
37
+ static override readonly jobName = "${jobSlug}";
36
38
 
37
39
  override async handle(payload: ${payloadType}): Promise<void> {
38
40
  void payload;
@@ -49,7 +51,7 @@ export type { ${payloadType} };
49
51
  console.log(
50
52
  `Dispatch it via queue.dispatch(new ${jobClass}(), payload) from your controller or listener.`,
51
53
  );
52
- console.log(`Workers discover it from src/jobs/ as "${jobSlug}".`);
54
+ console.log(`Application startup discovers it from src/jobs/ as "${jobSlug}".`);
53
55
  }
54
56
 
55
57
  export { makeJobCommand };
@@ -1,7 +1,7 @@
1
1
  import { access } from "node:fs/promises";
2
2
  import { join, relative, sep } from "node:path";
3
3
  import { scaffoldArguments, writeScaffoldFile } from "./scaffoldFile";
4
- import { toCamelCase, toKebabCase, toPascalCase } from "./utils";
4
+ import { moduleDirectory, toCamelCase, toKebabCase, toPascalCase } from "./utils";
5
5
 
6
6
  async function makeListenerCommand(...args: string[]): Promise<void> {
7
7
  const parsed = scaffoldArguments("make:listener", args);
@@ -30,11 +30,31 @@ async function makeListenerCommand(...args: string[]): Promise<void> {
30
30
  extra.length === 0 &&
31
31
  ["created", "updated", "deleted", "restored", "force-deleted"].includes(action ?? "");
32
32
  const modelName = toPascalCase((table ?? name).replace(/s$/, ""));
33
+ let modelImport = `../models/${modelName}.ts`;
34
+ if (modelEvent) {
35
+ const candidates = [
36
+ join(process.cwd(), "src", "models", `${modelName}.ts`),
37
+ join(await moduleDirectory(toKebabCase(modelName)), "models", `${modelName}.ts`),
38
+ ];
39
+ let modelPath: string | undefined;
40
+ for (const candidate of candidates) {
41
+ if (await Bun.file(candidate).exists()) {
42
+ modelPath = candidate;
43
+ break;
44
+ }
45
+ }
46
+ if (!modelPath)
47
+ throw new Error(
48
+ `Model ${modelName} was not found. Create it with make:model or make:module before make:listener.`,
49
+ );
50
+ modelImport = relative(directory, modelPath).split(sep).join("/");
51
+ if (!modelImport.startsWith(".")) modelImport = `./${modelImport}`;
52
+ }
33
53
  const content = modelEvent
34
54
  ? `import { defineModelListener } from "@getstrata/bootstrap/discoverListeners";
35
- import { ${modelName}Repository } from "../models/${modelName}.ts";
55
+ import { ${modelName} } from "${modelImport}";
36
56
 
37
- export default defineModelListener(${modelName}Repository, ${JSON.stringify(action)}, async row => {
57
+ export default defineModelListener(${modelName}, ${JSON.stringify(action)}, async row => {
38
58
  void row;
39
59
  });
40
60
  `
@@ -65,7 +65,9 @@ export { ${className} };
65
65
  "Model",
66
66
  );
67
67
  console.log(`Created model: ${path}`);
68
- console.log("Register the exported class in createDatabaseBindings({ models: [...] }).");
68
+ console.log(
69
+ "Add the exported class to src/models/register.ts modelDefinitions (passed to defineApp({ models })).",
70
+ );
69
71
  console.log(
70
72
  `Next: strata make:migration create_${table}; define schema explicitly before strata migrate.`,
71
73
  );
@@ -1,5 +1,6 @@
1
1
  import { access } from "node:fs/promises";
2
2
  import { join, relative, sep } from "node:path";
3
+ import { pathToFileURL } from "node:url";
3
4
  import { renderModuleScaffold } from "./renderModule";
4
5
  import { scaffoldArguments, writeScaffoldFile } from "./scaffoldFile";
5
6
  import {
@@ -28,6 +29,22 @@ async function makeModuleCommand(...args: string[]): Promise<void> {
28
29
  throw new Error("make:module requires a valid module name.");
29
30
  }
30
31
 
32
+ // Inspect the generated app's inert choices without importing its bootstrap graph.
33
+ const choicesPath = join(process.cwd(), "src", "config", "app.ts");
34
+ if (await Bun.file(choicesPath).exists()) {
35
+ const { default: choices } = (await import(pathToFileURL(choicesPath).href)) as {
36
+ default?: { views?: boolean; tenancy?: string };
37
+ };
38
+ if (withWeb && choices?.views === false)
39
+ throw new Error(
40
+ "make:module --with-web requires a configured server view renderer. This app disabled views; use make:module without --with-web or configure views first.",
41
+ );
42
+ if (choices?.tenancy === "column" || choices?.tenancy === "rls")
43
+ throw new Error(
44
+ `make:module CRUD does not implement ${choices.tenancy} tenancy. Use make:model, make:controller and make:request to implement trusted tenant scoping and schema explicitly.`,
45
+ );
46
+ }
47
+
31
48
  const directory = await moduleDirectory(moduleSlug);
32
49
 
33
50
  try {
@@ -89,7 +106,9 @@ async function makeModuleCommand(...args: string[]): Promise<void> {
89
106
  console.log(`Module will be auto-discovered from the app modules directory (${moduleSlug}/)`);
90
107
  console.log(`Next: strata make:migration create_${moduleSlug} && strata migrate`);
91
108
 
92
- console.log("Register the generated model class in createDatabaseBindings({ models: [...] }).");
109
+ console.log(
110
+ "Add the generated model class to src/models/register.ts modelDefinitions (passed to defineApp({ models })).",
111
+ );
93
112
  }
94
113
 
95
114
  export { makeModuleCommand };