create-substrat 0.13.23 → 0.13.25

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/index.js CHANGED
@@ -16,34 +16,12 @@ import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync
16
16
  import { basename, dirname, join, resolve } from 'node:path';
17
17
  import { fileURLToPath } from 'node:url';
18
18
 
19
- import { DEV_SERVERS } from './dev-servers.js';
20
- import { TEST_RUNNER, TSCONFIG, VITEST_CONFIG } from './project-files.js';
19
+ import { TSCONFIG, VITEST_CONFIG, packageJson } from './project-files.js';
21
20
  import { offerLongPaths } from './windows.js';
22
21
 
23
22
  const HERE = dirname(fileURLToPath(import.meta.url));
24
23
  const TEMPLATE = join(HERE, 'template');
25
24
 
26
- // Substrat is 0.x, so these are caret ranges on the current minor — a caret on 0.x
27
- // locks the minor, which is what makes a stale pin here a scaffold four minors behind
28
- // rather than a scaffold that quietly upgrades.
29
- //
30
- // EMITTED, NOT EDITED. `pnpm lint:pins` writes this block from each package's own
31
- // version and `--check` fails CI on drift; `version-packages` runs the write, so a
32
- // bump and its pins land in the same PR. Hand-maintained, they went stale twice: once
33
- // resolving nothing (`^0.3.37` after workorder moved to 0.4.x), and once resolving
34
- // fine but freezing the template against packages nobody ships, which is worse — the
35
- // scaffold's own tests stayed green while the surface moved underneath them.
36
- //
37
- // The runtime packages release together off one version line (the changesets `fixed`
38
- // group), so one constant is right for all of them. Engines do NOT share a line —
39
- // each versions on its own, so one pin per engine, deliberately.
40
- const SUBSTRAT = '^0.184.0';
41
- const ENGINE_WORKORDER = '^0.13.9';
42
- const ENGINE_INVOICING = '^0.11.68';
43
- const BOUNDARY_LINT = '^0.8.2';
44
- const DEV_ISSUER = '^0.3.4';
45
- const ATTACHMENT_EXTRACTORS = '^0.2.45';
46
-
47
25
  const DOCS = 'https://substrat.net';
48
26
 
49
27
  function fail(message) {
@@ -76,92 +54,6 @@ function toPackageName(dir) {
76
54
  return name || 'substrat-vertical';
77
55
  }
78
56
 
79
- function packageJson(name) {
80
- return `${JSON.stringify(
81
- {
82
- name,
83
- version: '0.0.0',
84
- private: true,
85
- type: 'module',
86
- // What `substrat push` reads: the permission surface (the registry the
87
- // promotion checkpoint diffs) and the runtime needs the deploy config is
88
- // derived from — you never author wrangler config (src/worker.ts is the
89
- // entry; ScopeDO is the store it exports). Also the client-neutral home of
90
- // the dev topology `.claude/launch.json` is emitted from — see
91
- // dev-servers.js for why the port is read from the code and never declared.
92
- substrat: {
93
- permissions: 'src/provision.ts',
94
- runtimeNeeds: {
95
- entry: 'src/worker.ts',
96
- stores: [
97
- { binding: 'SCOPE', class: 'ScopeDO' },
98
- // The scope-local sweep singleton — the deployment's own timer (#461).
99
- { binding: 'SWEEPER', class: 'SweeperDO' },
100
- // Per-instance config delivered by the platform (/internal/configure) —
101
- // one DO per tenant, rows per scope. Without it the app cannot receive
102
- // the settings the dashboard offers its users.
103
- { binding: 'CONFIG', class: 'ConfigDO' },
104
- ],
105
- },
106
- // No envSpec copy here (#1206): the declared per-instance settings live in
107
- // src/manifest.ts (`SHOP_ENV`), re-exported as `envSpec` from the permissions
108
- // entry — `substrat push` reads them off that same import. The dashboard
109
- // renders its Settings form from what the push uploads.
110
- devServers: DEV_SERVERS,
111
- },
112
- scripts: {
113
- // Two processes: the local OIDC issuer you sign in at, and the API.
114
- dev: 'concurrently -n issuer,api -c magenta,blue "pnpm run issuer" "tsx watch src/server.ts"',
115
- issuer: 'substrat-dev-issuer --personas src/personas.ts',
116
- server: 'tsx src/server.ts',
117
- test: 'vitest run',
118
- // The live test dashboard: the `tests` entry of .claude/launch.json, opened at the
119
- // tokenised URL vitest prints. `--watch` is explicit, since vitest runs once and exits without a TTY.
120
- 'test:ui': 'vitest --watch --ui --open=false -c vitest.ui.config.ts',
121
- typecheck: 'tsc --noEmit && tsc -p tsconfig.worker.json --noEmit',
122
- 'lint:boundaries': 'substrat-boundary-lint',
123
- },
124
- dependencies: {
125
- '@substrat-run/kernel': SUBSTRAT,
126
- '@substrat-run/contracts': SUBSTRAT,
127
- '@substrat-run/adapter-sqlite': SUBSTRAT,
128
- '@substrat-run/adapter-cloudflare': SUBSTRAT,
129
- '@substrat-run/vertical-host': SUBSTRAT,
130
- '@substrat-run/attachment-extractors': ATTACHMENT_EXTRACTORS,
131
- '@substrat-run/engine-workorder': ENGINE_WORKORDER,
132
- '@substrat-run/engine-invoicing': ENGINE_INVOICING,
133
- hono: '^4.6.0',
134
- '@hono/node-server': '^1.13.0',
135
- 'better-sqlite3': '^13.0.3',
136
- },
137
- devDependencies: {
138
- '@substrat-run/boundary-lint': BOUNDARY_LINT,
139
- // The local OIDC issuer `pnpm dev` signs you in at. A devDependency on
140
- // purpose: it is never imported by anything the worker bundles.
141
- '@substrat-run/dev-issuer': DEV_ISSUER,
142
- // What `substrat push` builds the Worker with. The CLI runs the project's own
143
- // wrangler and never downloads one, so a push builds with the version pinned here.
144
- wrangler: '^4.151.0',
145
- // Major 5, because wrangler 4.151+ peers on it: with 4 here, `npm install` of a new
146
- // project stops on ERESOLVE. The template compiles against 5 (checked by installing a
147
- // scaffold from npm); the workspace catalog, which template-check reads, is still on 4.
148
- '@cloudflare/workers-types': '^5.20261023.1',
149
- '@types/better-sqlite3': '^9.6.0',
150
- '@types/node': '^22.0.0',
151
- concurrently: '^9.0.0',
152
- tsx: '^4.19.0',
153
- typescript: '^5.6.0',
154
- ...TEST_RUNNER,
155
- },
156
- // Do NOT add `zod` here — import `z` from `@substrat-run/contracts` (AGENTS.md, rule 10).
157
- // better-sqlite3 >=13 ships prebuilt binaries for every supported platform and
158
- // declares no install script, so it needs no build allowlist entry.
159
- },
160
- null,
161
- 2,
162
- )}\n`;
163
- }
164
-
165
57
  const GITIGNORE = `node_modules/
166
58
  dist/
167
59
  *.sqlite
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-substrat",
3
- "version": "0.13.23",
3
+ "version": "0.13.25",
4
4
  "description": "Scaffold a Substrat vertical — `npm create substrat <dir>`.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -26,6 +26,7 @@
26
26
  "index.js",
27
27
  "dev-servers.js",
28
28
  "project-files.js",
29
+ "project-files.d.ts",
29
30
  "windows.js",
30
31
  "template"
31
32
  ],
@@ -0,0 +1,4 @@
1
+ export const TSCONFIG: string;
2
+ export const VITEST_CONFIG: string;
3
+ export const TEST_RUNNER: Readonly<Record<string, string>>;
4
+ export function packageJson(name: string): string;
package/project-files.js CHANGED
@@ -8,14 +8,35 @@
8
8
  * drift class this repo has been bitten by repeatedly, so there is one copy and
9
9
  * both readers import it.
10
10
  *
11
- * `packageJson()` deliberately stays in `index.js`: it interpolates the emitted
12
- * pin block, and `tools/pins-emit.mts` writes that block into `index.js` by path.
13
- * The workspace check does not want those pins anyway — resolving `@substrat-run/*`
14
- * from npm is exactly what it is NOT doing.
11
+ * The studio is the third reader: it serves these as part of its `template` reference, so a
12
+ * generated project starts from the files a scaffold gets instead of writing its own.
15
13
  *
16
- * Dependency-free, like everything else in this package.
14
+ * Dependency-free, like everything else in this package: the studio's worker bundles it.
17
15
  */
18
16
 
17
+ import { DEV_SERVERS } from './dev-servers.js';
18
+
19
+ // Substrat is 0.x, so these are caret ranges on the current minor — a caret on 0.x
20
+ // locks the minor, which is what makes a stale pin here a scaffold four minors behind
21
+ // rather than a scaffold that quietly upgrades.
22
+ //
23
+ // EMITTED, NOT EDITED. `pnpm lint:pins` writes this block from each package's own
24
+ // version and `--check` fails CI on drift; `version-packages` runs the write, so a
25
+ // bump and its pins land in the same PR. Hand-maintained, they went stale twice: once
26
+ // resolving nothing (`^0.3.37` after workorder moved to 0.4.x), and once resolving
27
+ // fine but freezing the template against packages nobody ships, which is worse — the
28
+ // scaffold's own tests stayed green while the surface moved underneath them.
29
+ //
30
+ // The runtime packages release together off one version line (the changesets `fixed`
31
+ // group), so one constant is right for all of them. Engines do NOT share a line —
32
+ // each versions on its own, so one pin per engine, deliberately.
33
+ const SUBSTRAT = '^0.186.0';
34
+ const ENGINE_WORKORDER = '^0.13.11';
35
+ const ENGINE_INVOICING = '^0.11.70';
36
+ const BOUNDARY_LINT = '^0.8.2';
37
+ const DEV_ISSUER = '^0.3.6';
38
+ const ATTACHMENT_EXTRACTORS = '^0.2.47';
39
+
19
40
  export const TSCONFIG = `${JSON.stringify(
20
41
  {
21
42
  compilerOptions: {
@@ -60,3 +81,90 @@ export default defineConfig({
60
81
  * on a different major is a project nothing on a PR has ever run.
61
82
  */
62
83
  export const TEST_RUNNER = { vitest: '^5.0.0', '@vitest/ui': '^5.0.0' };
84
+
85
+ /** The package.json of a new project. */
86
+ export function packageJson(name) {
87
+ return `${JSON.stringify(
88
+ {
89
+ name,
90
+ version: '0.0.0',
91
+ private: true,
92
+ type: 'module',
93
+ // What `substrat push` reads: the permission surface (the registry the
94
+ // promotion checkpoint diffs) and the runtime needs the deploy config is
95
+ // derived from — you never author wrangler config (src/worker.ts is the
96
+ // entry; ScopeDO is the store it exports). Also the client-neutral home of
97
+ // the dev topology `.claude/launch.json` is emitted from — see
98
+ // dev-servers.js for why the port is read from the code and never declared.
99
+ substrat: {
100
+ permissions: 'src/provision.ts',
101
+ runtimeNeeds: {
102
+ entry: 'src/worker.ts',
103
+ stores: [
104
+ { binding: 'SCOPE', class: 'ScopeDO' },
105
+ // The scope-local sweep singleton — the deployment's own timer (#461).
106
+ { binding: 'SWEEPER', class: 'SweeperDO' },
107
+ // Per-instance config delivered by the platform (/internal/configure) —
108
+ // one DO per tenant, rows per scope. Without it the app cannot receive
109
+ // the settings the dashboard offers its users.
110
+ { binding: 'CONFIG', class: 'ConfigDO' },
111
+ ],
112
+ },
113
+ // No envSpec copy here (#1206): the declared per-instance settings live in
114
+ // src/manifest.ts (`SHOP_ENV`), re-exported as `envSpec` from the permissions
115
+ // entry — `substrat push` reads them off that same import. The dashboard
116
+ // renders its Settings form from what the push uploads.
117
+ devServers: DEV_SERVERS,
118
+ },
119
+ scripts: {
120
+ // Two processes: the local OIDC issuer you sign in at, and the API.
121
+ dev: 'concurrently -n issuer,api -c magenta,blue "pnpm run issuer" "tsx watch src/server.ts"',
122
+ issuer: 'substrat-dev-issuer --personas src/personas.ts',
123
+ server: 'tsx src/server.ts',
124
+ test: 'vitest run',
125
+ // The live test dashboard: the `tests` entry of .claude/launch.json, opened at the
126
+ // tokenised URL vitest prints. `--watch` is explicit, since vitest runs once and exits without a TTY.
127
+ 'test:ui': 'vitest --watch --ui --open=false -c vitest.ui.config.ts',
128
+ typecheck: 'tsc --noEmit && tsc -p tsconfig.worker.json --noEmit',
129
+ 'lint:boundaries': 'substrat-boundary-lint',
130
+ },
131
+ dependencies: {
132
+ '@substrat-run/kernel': SUBSTRAT,
133
+ '@substrat-run/contracts': SUBSTRAT,
134
+ '@substrat-run/adapter-sqlite': SUBSTRAT,
135
+ '@substrat-run/adapter-cloudflare': SUBSTRAT,
136
+ '@substrat-run/vertical-host': SUBSTRAT,
137
+ '@substrat-run/attachment-extractors': ATTACHMENT_EXTRACTORS,
138
+ '@substrat-run/engine-workorder': ENGINE_WORKORDER,
139
+ '@substrat-run/engine-invoicing': ENGINE_INVOICING,
140
+ hono: '^4.6.0',
141
+ '@hono/node-server': '^1.13.0',
142
+ 'better-sqlite3': '^13.0.3',
143
+ },
144
+ devDependencies: {
145
+ '@substrat-run/boundary-lint': BOUNDARY_LINT,
146
+ // The local OIDC issuer `pnpm dev` signs you in at. A devDependency on
147
+ // purpose: it is never imported by anything the worker bundles.
148
+ '@substrat-run/dev-issuer': DEV_ISSUER,
149
+ // What `substrat push` builds the Worker with. The CLI runs the project's own
150
+ // wrangler and never downloads one, so a push builds with the version pinned here.
151
+ wrangler: '^4.151.0',
152
+ // Major 5, because wrangler 4.151+ peers on it: with 4 here, `npm install` of a new
153
+ // project stops on ERESOLVE. The template compiles against 5 (checked by installing a
154
+ // scaffold from npm); the workspace catalog, which template-check reads, is still on 4.
155
+ '@cloudflare/workers-types': '^5.20261023.1',
156
+ '@types/better-sqlite3': '^9.6.0',
157
+ '@types/node': '^22.0.0',
158
+ concurrently: '^9.0.0',
159
+ tsx: '^4.19.0',
160
+ typescript: '^5.6.0',
161
+ ...TEST_RUNNER,
162
+ },
163
+ // Do NOT add `zod` here — import `z` from `@substrat-run/contracts` (AGENTS.md, rule 10).
164
+ // better-sqlite3 >=13 ships prebuilt binaries for every supported platform and
165
+ // declares no install script, so it needs no build allowlist entry.
166
+ },
167
+ null,
168
+ 2,
169
+ )}\n`;
170
+ }