@ultimat3/cli 30.9.0 → 31.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/CLAUDE.md +80 -64
- package/README.md +4 -1
- package/package.json +30 -29
- package/src/admin-registration.ts +1 -1
- package/src/affected-base.ts +51 -0
- package/src/affected.ts +34 -11
- package/src/app-boundaries.ts +88 -9
- package/src/app-load-async.ts +133 -0
- package/src/app-load-batch.ts +203 -0
- package/src/app-load-prebuilt.ts +147 -0
- package/src/app-load-register.ts +175 -0
- package/src/app-load.ts +143 -175
- package/src/app-loader-imports.ts +31 -0
- package/src/app-root.ts +13 -0
- package/src/app-runtime.ts +5 -1
- package/src/boundary-findings.ts +12 -0
- package/src/browser-launcher-port.ts +3 -7
- package/src/browser-launcher.ts +1 -1
- package/src/budgets-scan.ts +8 -0
- package/src/budgets.ts +10 -1
- package/src/build-registry-background.ts +59 -0
- package/src/build-registry.ts +207 -0
- package/src/cdp-shot-clock.ts +3 -11
- package/src/cdp-shot-driver.ts +3 -2
- package/src/cdp-shot-element.ts +3 -2
- package/src/cdp-shot-page.ts +2 -2
- package/src/cdp-shot-watch.ts +4 -3
- package/src/ci-log.ts +76 -13
- package/src/cmd-affected-spec.ts +7 -3
- package/src/cmd-affected.ts +91 -77
- package/src/cmd-auth.ts +3 -3
- package/src/cmd-ci.ts +6 -3
- package/src/cmd-db-recount.ts +15 -0
- package/src/cmd-drill.ts +10 -6
- package/src/cmd-exercise.ts +2 -1
- package/src/cmd-generate-spec.ts +6 -0
- package/src/cmd-generate.ts +22 -4
- package/src/cmd-mail.ts +1 -1
- package/src/cmd-pr-spec.ts +1 -1
- package/src/cmd-pr.ts +72 -1
- package/src/cmd-routes.ts +2 -2
- package/src/cmd-secrets-spec.ts +4 -1
- package/src/cmd-shot.ts +14 -262
- package/src/cmd-test-spec.ts +2 -2
- package/src/cmd-verify-spec.ts +21 -1
- package/src/cmd-verify.ts +16 -4
- package/src/coverage-source.ts +4 -1
- package/src/db-diagnostics.ts +8 -1
- package/src/dev-boot.ts +29 -15
- package/src/dev-dashboard-invalidations.ts +43 -0
- package/src/dev-dashboard.ts +13 -16
- package/src/dev-n-plus-one.ts +7 -3
- package/src/dev-rebuild.ts +2 -1
- package/src/dev-route-table.ts +1 -1
- package/src/dev-traces.ts +16 -15
- package/src/document-options.ts +12 -1
- package/src/drift-store.ts +55 -0
- package/src/error-catalog.ts +8 -3
- package/src/error-codes-boundary.ts +32 -0
- package/src/error-codes-package.ts +38 -0
- package/src/error-codes.ts +28 -40
- package/src/errors.ts +17 -7
- package/src/exercise-database.ts +13 -1
- package/src/exercise-findings.ts +36 -18
- package/src/exercise-services.ts +84 -0
- package/src/exercise-subject.ts +38 -13
- package/src/failure-capture-boot.ts +9 -5
- package/src/framework-schema.ts +5 -5
- package/src/generate-exercise.ts +1 -1
- package/src/generate-files.ts +27 -7
- package/src/generate-kinds.ts +5 -0
- package/src/generate-refresh.ts +53 -0
- package/src/generate-workspace.ts +169 -0
- package/src/generate-write.ts +8 -2
- package/src/hold.ts +19 -8
- package/src/image-prepare.ts +6 -2
- package/src/index.ts +5 -20
- package/src/island-bundle.ts +7 -3
- package/src/island-capture.ts +2 -2
- package/src/island-harness.ts +1 -1
- package/src/job-registration.ts +43 -6
- package/src/jobs-driver.ts +4 -5
- package/src/mcp-errors.ts +20 -4
- package/src/mcp-host.ts +5 -1
- package/src/mcp-ui-interact.ts +3 -0
- package/src/messages-gate.ts +10 -0
- package/src/new-shapes-generate.ts +1 -1
- package/src/otlp-export.ts +94 -29
- package/src/output.ts +24 -10
- package/src/page-sync.ts +3 -1
- package/src/pr-activity.ts +150 -0
- package/src/pr-bots.ts +109 -0
- package/src/pr-threads.ts +7 -2
- package/src/role-load.ts +17 -11
- package/src/role-start.ts +5 -4
- package/src/role-sync.ts +7 -8
- package/src/route-islands-preload.ts +46 -0
- package/src/route-islands.ts +6 -2
- package/src/runtime-admin.ts +5 -1
- package/src/runtime-bindings.ts +25 -19
- package/src/runtime-boot-ports.ts +66 -0
- package/src/runtime-bus.ts +29 -5
- package/src/runtime-cache-bus.ts +53 -0
- package/src/runtime-cache.ts +43 -13
- package/src/runtime-isr-outcome.ts +5 -4
- package/src/runtime-jobs.ts +2 -2
- package/src/runtime-keys.ts +37 -0
- package/src/runtime-overrides.ts +148 -42
- package/src/runtime-port-bindings-queue.ts +36 -0
- package/src/runtime-port-bindings.ts +117 -0
- package/src/runtime-ports.ts +164 -0
- package/src/runtime-purge.ts +41 -28
- package/src/runtime-push.ts +7 -3
- package/src/runtime-queue.ts +70 -55
- package/src/runtime-realtime.ts +5 -5
- package/src/runtime-render-document.ts +4 -1
- package/src/runtime-services.ts +110 -158
- package/src/runtime-storage-boot.ts +111 -0
- package/src/runtime-storage-upload.ts +9 -7
- package/src/runtime-storage.ts +7 -1
- package/src/serve-boot.ts +8 -4
- package/src/serve-entry.ts +3 -0
- package/src/serve-env.ts +47 -14
- package/src/serve-prebuilt-paths.ts +3 -0
- package/src/serve-prebuilt.ts +15 -4
- package/src/serve.ts +2 -2
- package/src/shot-gpu.ts +61 -0
- package/src/shot-route.ts +95 -0
- package/src/shot-run.ts +189 -0
- package/src/shot-verdict.ts +5 -0
- package/src/static-cards.ts +3 -2
- package/src/static-report.ts +2 -2
- package/src/style-bundle.ts +1 -1
- package/src/sync-authenticator.ts +17 -18
- package/src/templates/action-tests.ts +4 -4
- package/src/templates/backfill.ts +5 -8
- package/src/templates/entity.ts +3 -0
- package/src/templates/github/ci.yml.ts +3 -1
- package/src/templates/github/dependabot.yml.ts +73 -0
- package/src/templates/job.ts +13 -22
- package/src/templates/naming.ts +20 -1
- package/src/templates/pinned/docker-compose.yml +1 -1
- package/src/templates/query.ts +7 -8
- package/src/templates/route.ts +5 -3
- package/src/templates/scaffold-api.ts +1 -1
- package/src/templates/scaffold-auth.ts +5 -3
- package/src/templates/scaffold-claude-commands.ts +6 -3
- package/src/templates/scaffold-claude.ts +4 -4
- package/src/templates/scaffold-container-compose.ts +2 -4
- package/src/templates/scaffold-domain-package.ts +1 -1
- package/src/templates/scaffold-entries.ts +6 -1
- package/src/templates/scaffold-helm-fences.ts +3 -2
- package/src/templates/scaffold-helm.ts +35 -6
- package/src/templates/scaffold-repo.ts +47 -135
- package/src/templates/scaffold-runtime-ports.ts +62 -0
- package/src/templates/scaffold-verify-floor.ts +97 -0
- package/src/templates/shapes/overlay.ts +1 -1
- package/src/templates/sign-in-oidc.ts +5 -3
- package/src/templates/sign-in-shared.ts +28 -10
- package/src/templates/workspace.ts +75 -0
- package/src/test-ignores.ts +5 -2
- package/src/test-select.ts +4 -1
- package/src/tsconfig-aliases.ts +85 -0
- package/src/upgrade-gate.ts +30 -5
- package/src/upgrade-report.ts +7 -1
- package/src/verify-changed-facts.ts +53 -0
- package/src/verify-changed-scope.ts +162 -0
- package/src/verify-changed.ts +174 -0
- package/src/verify-checks.ts +33 -19
- package/src/verify-drift-owner.ts +30 -0
- package/src/verify-e2e.ts +2 -1
- package/src/verify-factories.ts +86 -0
- package/src/verify-run.ts +13 -11
- package/src/verify-step.ts +13 -0
- package/src/verify-tests.ts +58 -6
- package/src/workspace-external-deps.ts +164 -0
- package/src/write-line.ts +21 -6
- package/wiki/Actions.md +2 -2
- package/wiki/Adapters.md +400 -0
- package/wiki/Admin-Dashboard.md +1 -1
- package/wiki/Agents.md +9 -9
- package/wiki/Auth.md +78 -2
- package/wiki/Building-Your-Own-Base.md +1 -1
- package/wiki/CLI-Reference.md +45 -14
- package/wiki/Caching-And-Invalidation.md +17 -5
- package/wiki/Compared.md +8 -2
- package/wiki/Configuration.md +14 -14
- package/wiki/Deployment.md +28 -1
- package/wiki/Entities-And-Migrations.md +47 -1
- package/wiki/FAQ.md +8 -2
- package/wiki/Feature-Flags.md +1 -1
- package/wiki/Home.md +3 -2
- package/wiki/Jobs-And-Workflows.md +107 -6
- package/wiki/Known-Gaps.md +4 -3
- package/wiki/MCP-And-AI.md +18 -4
- package/wiki/Mail.md +14 -5
- package/wiki/Migrations-And-Backfills.md +29 -4
- package/wiki/Money.md +2 -0
- package/wiki/N-Plus-One-Detection.md +24 -22
- package/wiki/Notify.md +28 -4
- package/wiki/Observability.md +121 -15
- package/wiki/Queries-And-Live-Queries.md +2 -2
- package/wiki/Realtime.md +9 -4
- package/wiki/Routes-And-Render-Modes.md +5 -0
- package/wiki/Scraping.md +57 -11
- package/wiki/Shapes.md +2 -2
- package/wiki/Stability.md +7 -5
- package/wiki/Storage-And-Uploads.md +56 -4
- package/wiki/Testing.md +65 -52
- package/wiki/Troubleshooting.md +1 -1
- package/wiki/Tutorial-01-First-App.md +1 -1
- package/wiki/Tutorial-04-Jobs-And-Realtime.md +1 -1
- package/wiki/Tutorial-05-Deploy-Free.md +1 -1
- package/wiki/Tutorial-06-Growing-Up.md +8 -8
- package/wiki/Upgrading.md +136 -5
|
@@ -6,10 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import { ENV_EXAMPLE_PATH } from '@ultimat3/core';
|
|
8
8
|
import { REQUIRED_BUN } from '../app-root';
|
|
9
|
-
import type { CoverageExclude } from '../coverage-floor';
|
|
10
|
-
import { COVERAGE_BAR } from '../coverage-floor';
|
|
11
9
|
import { VERIFY_FLOOR_FILE } from '../verify-floor';
|
|
12
|
-
import type { VerifyStepName } from '../verify-step';
|
|
13
10
|
import type { GeneratedFile, NameSet } from './naming';
|
|
14
11
|
import { titleCase } from './naming';
|
|
15
12
|
import { BIN_SCRIPTS, binScript } from './scaffold-bin';
|
|
@@ -23,14 +20,15 @@ import { scaffoldGuardFiles } from './scaffold-guards';
|
|
|
23
20
|
import { i18nFiles } from './scaffold-i18n';
|
|
24
21
|
import { mcpPackageFiles } from './scaffold-mcp-package';
|
|
25
22
|
import { uiPackageFiles } from './scaffold-ui-package';
|
|
23
|
+
import { verifyFloor } from './scaffold-verify-floor';
|
|
26
24
|
|
|
27
25
|
/**
|
|
28
26
|
* Spelled once and pinned EXACTLY, because two places named it and a caret let them disagree:
|
|
29
27
|
* `"^2.4.15"` beside a `$schema` of `2.4.15` installed 2.5.8, whose own parser then reported the
|
|
30
|
-
* config as out of date on every `bun run lint`. A formatter is a build input
|
|
28
|
+
* config as out of date on every `bun run lint`. A formatter is a build input: a floating range
|
|
31
29
|
* is a `lint` step whose verdict depends on the day the app was installed.
|
|
32
30
|
*/
|
|
33
|
-
const BIOME_VERSION = '2.
|
|
31
|
+
const BIOME_VERSION = '2.6.3';
|
|
34
32
|
|
|
35
33
|
/**
|
|
36
34
|
* The checker a scaffolded app typechecks with, and it must not lag the one the FRAMEWORK is built
|
|
@@ -58,10 +56,9 @@ const SOLID_VERSION = '1.9.17';
|
|
|
58
56
|
// floor admitting a runtime the app's own first command refuses. Interpolated, the two cannot
|
|
59
57
|
// disagree; `scripts/bun-pin.test.ts` reads the emitted string as one more pin site, and
|
|
60
58
|
// `github/ci.yml.ts` pins the workflow's Bun to the same constant.
|
|
61
|
-
//
|
|
62
|
-
//
|
|
63
|
-
//
|
|
64
|
-
// the `manifest` verify step and every production boot with X_APP_PACKAGE_INVALID.
|
|
59
|
+
// `version` is not decoration: the manifest's app version IS the contract's compatibility gate, and
|
|
60
|
+
// the manifest never fabricates one, so an app scaffolded without it failed `x manifest` and every
|
|
61
|
+
// production boot with X_APP_PACKAGE_INVALID.
|
|
65
62
|
const rootPackage = (app: NameSet, version: string): string => `{
|
|
66
63
|
"name": "${app.kebab}",
|
|
67
64
|
"version": "0.1.0",
|
|
@@ -127,12 +124,17 @@ const rootPackage = (app: NameSet, version: string): string => `{
|
|
|
127
124
|
* `references`). `-b` decides "up to date?" by MTIME, and Bun installs a dependency as hardlinks
|
|
128
125
|
* carrying its cache's old mtimes: upgrading to a version already in the cache left every input
|
|
129
126
|
* older than the buildinfo, so `-b` skipped the program and reported green while a cold CI was
|
|
130
|
-
* red. `-p` with `incremental` compares content hashes
|
|
131
|
-
* `app.config.js` that `noEmit` never writes
|
|
127
|
+
* red. `-p` with `incremental` compares content hashes, and `-b` also wanted an emitted
|
|
128
|
+
* `app.config.js` that `noEmit` never writes — which is why this line was first needed.
|
|
132
129
|
*
|
|
133
|
-
* The note lives HERE and not in the emitted file, for the reason `biome.json` below gives: an
|
|
134
|
-
*
|
|
130
|
+
* The note lives HERE and not in the emitted file, for the reason `biome.json` below gives: an app
|
|
131
|
+
* author has no use for eight lines of framework archaeology in their own tsconfig, and
|
|
135
132
|
* `*.tsbuildinfo` is already in the scaffold's `.gitignore`.
|
|
133
|
+
*
|
|
134
|
+
* ONE alias for every workspace: `@<app>/<pkg>` tries `packages/<pkg>/src` first, then
|
|
135
|
+
* `@<app>/<app-ws>/<module>` falls through to `apps/<app-ws>/<module>` — TypeScript tries each
|
|
136
|
+
* substitution in order. A per-app line (`@<app>/web/*`) meant `x g app <name>` had to edit this
|
|
137
|
+
* file, and an app added by hand without one failed `typecheck` on its first import.
|
|
136
138
|
*/
|
|
137
139
|
const rootTsconfig = (app: NameSet): string => `{
|
|
138
140
|
"compilerOptions": {
|
|
@@ -142,9 +144,7 @@ const rootTsconfig = (app: NameSet): string => `{
|
|
|
142
144
|
"lib": ["ES2023", "DOM", "DOM.Iterable"],
|
|
143
145
|
"types": ["bun"],
|
|
144
146
|
"paths": {
|
|
145
|
-
"@${app.kebab}
|
|
146
|
-
"@${app.kebab}/admin/*": ["./apps/admin/*"],
|
|
147
|
-
"@${app.kebab}/*": ["./packages/*/src"]
|
|
147
|
+
"@${app.kebab}/*": ["./packages/*/src", "./apps/*"]
|
|
148
148
|
},
|
|
149
149
|
"strict": true,
|
|
150
150
|
"noUncheckedIndexedAccess": true,
|
|
@@ -212,9 +212,9 @@ export const config = defineConfig({
|
|
|
212
212
|
// The tiers ARE the cache selection: add 'redis' to build the shared rung, which reads
|
|
213
213
|
// \`REDIS_URL\` and refuses the boot when it is unset.
|
|
214
214
|
cache: { tiers: ['request-memo', 'lru'] },
|
|
215
|
-
jobs: { queues: ['
|
|
216
|
-
//
|
|
217
|
-
realtime: { enabled: true
|
|
215
|
+
jobs: { queues: ['default'], concurrency: 4 },
|
|
216
|
+
// The bus is NATS_URL's: unset, one node's in-process fanout; set it to scale past one node.
|
|
217
|
+
realtime: { enabled: true },
|
|
218
218
|
// \`name\` and \`colors\` are what an install prompt shows and what a browser paints the splash
|
|
219
219
|
// with before any stylesheet has loaded — the four values the framework cannot derive, so
|
|
220
220
|
// \`defineConfig\` refuses \`pwa.enabled: true\` without them. Raw hex is legal here and nowhere
|
|
@@ -252,30 +252,23 @@ defineMeasurementActor(async () => {
|
|
|
252
252
|
`;
|
|
253
253
|
|
|
254
254
|
// `biome.json` is strict JSON — Biome's own parser rejects a `//` comment in it, which made every
|
|
255
|
-
// scaffolded app fail its first `x verify` on the config rather than on the code. The note
|
|
256
|
-
//
|
|
257
|
-
//
|
|
258
|
-
//
|
|
259
|
-
//
|
|
260
|
-
//
|
|
261
|
-
//
|
|
262
|
-
//
|
|
263
|
-
//
|
|
264
|
-
//
|
|
265
|
-
//
|
|
266
|
-
//
|
|
267
|
-
//
|
|
268
|
-
//
|
|
269
|
-
//
|
|
270
|
-
//
|
|
271
|
-
//
|
|
272
|
-
// `--no-example` hid it, because an app with no island has nothing under `.x/static/islands`.
|
|
273
|
-
//
|
|
274
|
-
// `vcs.useIgnoreFile` is the second half and not a duplicate of the first: it makes every future
|
|
275
|
-
// generated directory the app adds to `.gitignore` excluded by the act of ignoring it, rather than
|
|
276
|
-
// by an edit to this file nobody will remember to make. It needs `.gitignore` to EXIST — Biome
|
|
277
|
-
// exits 1 with `couldn't find an ignore file` when it does not — which `x new` writes, and which
|
|
278
|
-
// is why the two are declared together rather than one of them alone.
|
|
255
|
+
// scaffolded app fail its first `x verify` on the config rather than on the code. The note lives
|
|
256
|
+
// here, where whoever would change the line reads it: x.manifest.json and openapi.json are
|
|
257
|
+
// emitted byte-for-byte by `x manifest`, so a formatter rewriting them puts `x manifest` and
|
|
258
|
+
// `x verify` in a loop neither can win; `**/migrations` is the same rule and the same glob this
|
|
259
|
+
// repo's own biome.json carries, because `x db gen` writes the `.sql` and its sidecar. `preset`,
|
|
260
|
+
// not `recommended`: the older key is deprecated from 2.5 on and printed a migration notice.
|
|
261
|
+
// `!**/.x` makes the app's fix chain terminate: `x build` writes MINIFIED island bundles there, and
|
|
262
|
+
// without it `lint` reported ~175 `noCommaOperator`/`noAssignInExpressions` errors in Bun's own
|
|
263
|
+
// output whose `fix:` still exits 1, so `x verify` was red forever once `x build` ran. `--unsafe` was
|
|
264
|
+
// worse — it REWROTE a content-hashed chunk in place, so the name no longer matched the bytes.
|
|
265
|
+
// `vcs.useIgnoreFile` excludes every future generated directory the app adds to `.gitignore`, and
|
|
266
|
+
// needs that file to EXIST else Biome exits 1 — `x new` writes it. `markdown`/`yaml` formatters are
|
|
267
|
+
// OFF and `**/helm/templates` leaves the file list: 2.6 is the first Biome that reads either, and
|
|
268
|
+
// Go-templated manifests are a parse ERROR, not a format miss. `css.quoteStyle` is `single` and SCSS
|
|
269
|
+
// turns `noUnknownUnit` off: 2.6 begins PARSING SCSS too, its default is double, and a token call
|
|
270
|
+
// reads as a dimension (`tokens.text('lg')` → unit `lg`), so both misfire on the framework's own
|
|
271
|
+
// idiom.
|
|
279
272
|
const biome = (): string => `{
|
|
280
273
|
"$schema": "https://biomejs.dev/schemas/${BIOME_VERSION}/schema.json",
|
|
281
274
|
"vcs": { "enabled": true, "clientKind": "git", "useIgnoreFile": true },
|
|
@@ -286,11 +279,13 @@ const biome = (): string => `{
|
|
|
286
279
|
"!**/dist",
|
|
287
280
|
"!**/.output",
|
|
288
281
|
"!**/migrations",
|
|
282
|
+
"!**/helm/templates",
|
|
289
283
|
"!x.manifest.json",
|
|
290
284
|
"!openapi.json"
|
|
291
285
|
]
|
|
292
286
|
},
|
|
293
287
|
"formatter": { "indentStyle": "space", "indentWidth": 2, "lineWidth": 100 },
|
|
288
|
+
"css": { "formatter": { "quoteStyle": "single" } },
|
|
294
289
|
"linter": {
|
|
295
290
|
"rules": {
|
|
296
291
|
"preset": "recommended",
|
|
@@ -301,100 +296,17 @@ const biome = (): string => `{
|
|
|
301
296
|
},
|
|
302
297
|
"javascript": {
|
|
303
298
|
"formatter": { "quoteStyle": "single", "semicolons": "always", "trailingCommas": "all" }
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
`;
|
|
307
|
-
|
|
308
|
-
/**
|
|
309
|
-
* The suite ratchet, committed on day one. Without it `readVerifyFloor` answers "no file is no
|
|
310
|
-
* floor" and a deleted suite turns its step from green into skipped-and-green — so
|
|
311
|
-
* `X_VERIFY_SUITE_VANISHED` was unreachable in every generated app, in the one repo shape that
|
|
312
|
-
* grows suites fastest.
|
|
313
|
-
*
|
|
314
|
-
* Every name here is a step this scaffold has proved it can run: the SIX that declare no `applies`
|
|
315
|
-
* at all — typecheck, lint, boundaries, filesize, errors, manifest — plus `package-shape` (five
|
|
316
|
-
* workspace packages), `unit` (every generator emits a `<file>.test.ts`; like every suite step it
|
|
317
|
-
* applies on its own file list, `verify-tests.ts`), and `eval`, `drift` and `budgets`, which apply
|
|
318
|
-
* to any root with an `app.config.ts`. Typed as `VerifyStepName`, so a name the gate does not run
|
|
319
|
-
* is a compile error rather than a floor that covers nothing.
|
|
320
|
-
*
|
|
321
|
-
* Plus `contract`, which every variant now ships a file for — `apps/web/api/health.contract.test.ts`
|
|
322
|
-
* — and, with the example slice, `live` and `job`: its query is a `liveTest` and its job a
|
|
323
|
-
* `jobTest`, and both were written into plain `<name>.test.ts` files that the `unit` step ran while
|
|
324
|
-
* `x test live` and `x test job` answered X_TEST_NO_FILES. This is the commit that makes the app's
|
|
325
|
-
* own gate run them, which is what the paragraph below always said the condition was.
|
|
326
|
-
*
|
|
327
|
-
* Two remain absent. `e2e` has a scaffolded file and it is an `e2eTest` — `test.skip` until the app
|
|
328
|
-
* registers a browser driver, so the step would run zero tests and fail the ratchet on the
|
|
329
|
-
* scaffold's own placeholder. Its absence is visible rather than silent: a suite that executed
|
|
330
|
-
* nothing reports as a SKIPPED step, not the green check it printed until #434, so the app's own
|
|
331
|
-
* gate line says `- e2e` and names it in the summary until a driver makes it run. `contract-diff` needs a committed `x.manifest.json`, which
|
|
332
|
-
* `x manifest` writes later. Each joins the list in the commit that makes the app's gate run it.
|
|
333
|
-
*/
|
|
334
|
-
const SCAFFOLD_FLOOR: readonly VerifyStepName[] = [
|
|
335
|
-
'typecheck',
|
|
336
|
-
'lint',
|
|
337
|
-
'boundaries',
|
|
338
|
-
'filesize',
|
|
339
|
-
'package-shape',
|
|
340
|
-
'errors',
|
|
341
|
-
'unit',
|
|
342
|
-
'contract',
|
|
343
|
-
// Every app has an `app.config.ts` and primitives to run: `x new` writes `apps/web/exercise.ts`.
|
|
344
|
-
'exercise',
|
|
345
|
-
'eval',
|
|
346
|
-
'drift',
|
|
347
|
-
'budgets',
|
|
348
|
-
// Always applicable to a scaffolded app — it has an `app.config.ts`, roles and two guarded
|
|
349
|
-
// routes — so a run that reports it skipped is a gate that lost the step, not an app with
|
|
350
|
-
// nothing to check. It is the step that would have caught the 500 `x new` used to ship.
|
|
351
|
-
'policy',
|
|
352
|
-
'manifest',
|
|
353
|
-
];
|
|
354
|
-
|
|
355
|
-
/** The two suites only the example slice writes a file for — a floor step with no file is red. */
|
|
356
|
-
const EXAMPLE_FLOOR: readonly VerifyStepName[] = ['live', 'job'];
|
|
357
|
-
|
|
358
|
-
/**
|
|
359
|
-
* What a unit test cannot execute in a scaffolded app, each with its reason — `x doctor` prints
|
|
360
|
-
* them. Two kinds and no more: a file here is a file the floor does not see, so the list is not
|
|
361
|
-
* a place to put code that merely has no test yet.
|
|
362
|
-
*/
|
|
363
|
-
export const SCAFFOLD_COVERAGE_EXCLUDE: readonly CoverageExclude[] = [
|
|
364
|
-
{
|
|
365
|
-
glob: 'apps/**/*.island.tsx',
|
|
366
|
-
why: 'an island runs in a browser: its test mounts a BUILT chunk (mountIsland), and Bun cannot map that chunk back to this source — its states are held by guards/island-without-states.ts and photographed by x shot --island',
|
|
367
|
-
},
|
|
368
|
-
{
|
|
369
|
-
glob: 'apps/*/server.ts',
|
|
370
|
-
why: 'the container entry point: it boots the roles and lives as long as the process — bun run dev and the image exercise it',
|
|
371
299
|
},
|
|
372
|
-
{
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
},
|
|
376
|
-
];
|
|
377
|
-
|
|
378
|
-
/**
|
|
379
|
-
* The coverage floor every scaffolded app starts on: the bar the framework holds its own packages
|
|
380
|
-
* to (`COVERAGE_BAR`), not a softer one for apps. `scaffold-smoke` runs the app's own `x verify`,
|
|
381
|
-
* so the scaffold is green at it on what it generates or the job is red.
|
|
382
|
-
*/
|
|
383
|
-
const verifyFloor = (example: boolean): string =>
|
|
384
|
-
`${JSON.stringify(
|
|
300
|
+
"markdown": { "formatter": { "enabled": false } },
|
|
301
|
+
"yaml": { "formatter": { "enabled": false } },
|
|
302
|
+
"overrides": [
|
|
385
303
|
{
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
// The rolling rail judges from the first migration: a new app has nothing to grandfather.
|
|
393
|
-
rollingSince: '0',
|
|
394
|
-
},
|
|
395
|
-
null,
|
|
396
|
-
2,
|
|
397
|
-
)}\n`;
|
|
304
|
+
"includes": ["**/*.scss"],
|
|
305
|
+
"linter": { "rules": { "correctness": { "noUnknownUnit": "off" } } }
|
|
306
|
+
}
|
|
307
|
+
]
|
|
308
|
+
}
|
|
309
|
+
`;
|
|
398
310
|
|
|
399
311
|
const bunfig = (): string => `[test]
|
|
400
312
|
root = "."
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// The commented port lines `apps/<app>/runtime.ts` is written with: one per `ADAPTER_PORTS` row,
|
|
2
|
+
// derived from the table, so a row core adds reaches the next scaffold with no edit here. Each line
|
|
3
|
+
// is the field to uncomment, the interface to implement, and the default the boot builds instead.
|
|
4
|
+
|
|
5
|
+
import { ADAPTER_PORTS } from '@ultimat3/core';
|
|
6
|
+
import { isWired } from '../runtime-ports';
|
|
7
|
+
import type { GeneratedFile } from './naming';
|
|
8
|
+
|
|
9
|
+
/** Where the generated runtime lives: `apps/<app>/runtime.ts` is what both boots read first. */
|
|
10
|
+
export const RUNTIME_MODULE = 'apps/web/runtime.ts';
|
|
11
|
+
export const RUNTIME_TEST = 'apps/web/runtime.test.ts';
|
|
12
|
+
|
|
13
|
+
/** What the header of every generated `runtime.ts` says, whichever generator wrote it. */
|
|
14
|
+
export const RUNTIME_HEADER = `// What this app hands the framework's boot — \`x dev\` and the container both import it before a
|
|
15
|
+
// port is bound. The ONE place a backend is swapped: uncomment a port, hand it your adapter (the
|
|
16
|
+
// interface is on its package's \`/adapter\` subpath, its conformance suite in @ultimat3/testing).
|
|
17
|
+
// This file runs BEFORE its own ports are installed: import no app module that seals a secret or
|
|
18
|
+
// builds auth at module scope — it would run on the default clock and secret source.`;
|
|
19
|
+
|
|
20
|
+
/** The camel-cased value name a line suggests (`JobDriver` → `myJobDriver`). */
|
|
21
|
+
const valueName = (iface: string): string => `my${iface}`;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Every row as a comment. A wired row is a `RuntimeOverrides` field — uncommented it typechecks
|
|
25
|
+
* against the interface it names. A pending row says so, because uncommenting it is TS2353 until
|
|
26
|
+
* the boot honours it (`runtime-port-bindings.ts`).
|
|
27
|
+
*/
|
|
28
|
+
export function runtimePortLines(indent = ' '): string {
|
|
29
|
+
return ADAPTER_PORTS.map((row) => {
|
|
30
|
+
const port = row.port;
|
|
31
|
+
const where = `${row.interface} from '${row.pkg}/adapter'; default: ${row.envDefault}`;
|
|
32
|
+
return isWired(port)
|
|
33
|
+
? `${indent}// ${port}: ${valueName(row.interface)}, // ${where}`
|
|
34
|
+
: `${indent}// ${port}: not a runtime.ts field yet (${row.interface}, ${row.pkg})`;
|
|
35
|
+
}).join('\n');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** `x new`'s `runtime.ts`: no routes, no guard — every port commented, the object typed. */
|
|
39
|
+
export const baseRuntimeSource = (): string => `${RUNTIME_HEADER}
|
|
40
|
+
import type { RuntimeOverrides } from '@ultimat3/cli/serve';
|
|
41
|
+
|
|
42
|
+
export const runtime = {
|
|
43
|
+
${runtimePortLines()}
|
|
44
|
+
} satisfies RuntimeOverrides;
|
|
45
|
+
`;
|
|
46
|
+
|
|
47
|
+
/** Its test: the module loads, and names no port until the author uncomments one. */
|
|
48
|
+
export const baseRuntimeTest =
|
|
49
|
+
(): string => `// The runtime loads under test, and swaps nothing until a port is uncommented.
|
|
50
|
+
import { expect, unitTest } from '@ultimat3/testing';
|
|
51
|
+
import { runtime } from './runtime';
|
|
52
|
+
|
|
53
|
+
unitTest('the runtime loads', () => {
|
|
54
|
+
expect(runtime).toEqual({});
|
|
55
|
+
});
|
|
56
|
+
`;
|
|
57
|
+
|
|
58
|
+
/** The pair `x new` writes; `x g sign-in` replaces both while they are still these bytes. */
|
|
59
|
+
export const baseRuntimeFiles = (): readonly GeneratedFile[] => [
|
|
60
|
+
{ path: RUNTIME_MODULE, contents: baseRuntimeSource() },
|
|
61
|
+
{ path: RUNTIME_TEST, contents: baseRuntimeTest() },
|
|
62
|
+
];
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// `x new`'s `x.verify.json`: the suite floor and the coverage bar every scaffolded app starts on.
|
|
2
|
+
// Split from `scaffold-repo.ts` (the repo's root files), which had reached the 500-line ceiling.
|
|
3
|
+
|
|
4
|
+
import type { CoverageExclude } from '../coverage-floor';
|
|
5
|
+
import { COVERAGE_BAR } from '../coverage-floor';
|
|
6
|
+
import type { VerifyStepName } from '../verify-step';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The suite ratchet, committed on day one. Without it `readVerifyFloor` answers "no file is no
|
|
10
|
+
* floor" and a deleted suite turns its step from green into skipped-and-green — so
|
|
11
|
+
* `X_VERIFY_SUITE_VANISHED` was unreachable in every generated app, in the one repo shape that
|
|
12
|
+
* grows suites fastest.
|
|
13
|
+
*
|
|
14
|
+
* Every name here is a step this scaffold has proved it can run: the SIX that declare no `applies`
|
|
15
|
+
* at all — typecheck, lint, boundaries, filesize, errors, manifest — plus `package-shape` (five
|
|
16
|
+
* workspace packages), `unit` (every generator emits a `<file>.test.ts`; like every suite step it
|
|
17
|
+
* applies on its own file list, `verify-tests.ts`), and `eval`, `drift` and `budgets`, which apply
|
|
18
|
+
* to any root with an `app.config.ts`. Typed as `VerifyStepName`, so a name the gate does not run
|
|
19
|
+
* is a compile error rather than a floor that covers nothing.
|
|
20
|
+
*
|
|
21
|
+
* Plus `contract`, which every variant now ships a file for — `apps/web/api/health.contract.test.ts`
|
|
22
|
+
* — and, with the example slice, `live` and `job`: its query is a `liveTest` and its job a
|
|
23
|
+
* `jobTest`, and both were written into plain `<name>.test.ts` files that the `unit` step ran while
|
|
24
|
+
* `x test live` and `x test job` answered X_TEST_NO_FILES. This is the commit that makes the app's
|
|
25
|
+
* own gate run them, which is what the paragraph below always said the condition was.
|
|
26
|
+
*
|
|
27
|
+
* Two remain absent. `e2e` has a scaffolded file and it is an `e2eTest` — `test.skip` until the app
|
|
28
|
+
* registers a browser driver, so the step would run zero tests and fail the ratchet on the
|
|
29
|
+
* scaffold's own placeholder. Its absence is visible rather than silent: a suite that executed
|
|
30
|
+
* nothing reports as a SKIPPED step, not the green check it printed until #434, so the app's own
|
|
31
|
+
* gate line says `- e2e` and names it in the summary until a driver makes it run. `contract-diff` needs a committed `x.manifest.json`, which
|
|
32
|
+
* `x manifest` writes later. Each joins the list in the commit that makes the app's gate run it.
|
|
33
|
+
*/
|
|
34
|
+
const SCAFFOLD_FLOOR: readonly VerifyStepName[] = [
|
|
35
|
+
'typecheck',
|
|
36
|
+
'lint',
|
|
37
|
+
'boundaries',
|
|
38
|
+
'filesize',
|
|
39
|
+
'package-shape',
|
|
40
|
+
'errors',
|
|
41
|
+
'unit',
|
|
42
|
+
'contract',
|
|
43
|
+
// Every app has an `app.config.ts` and primitives to run: `x new` writes `apps/web/exercise.ts`.
|
|
44
|
+
'exercise',
|
|
45
|
+
'eval',
|
|
46
|
+
'drift',
|
|
47
|
+
'budgets',
|
|
48
|
+
// Always applicable to a scaffolded app — it has an `app.config.ts`, roles and two guarded
|
|
49
|
+
// routes — so a run that reports it skipped is a gate that lost the step, not an app with
|
|
50
|
+
// nothing to check. It is the step that would have caught the 500 `x new` used to ship.
|
|
51
|
+
'policy',
|
|
52
|
+
'manifest',
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
/** The two suites only the example slice writes a file for — a floor step with no file is red. */
|
|
56
|
+
const EXAMPLE_FLOOR: readonly VerifyStepName[] = ['live', 'job'];
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* What a unit test cannot execute in a scaffolded app, each with its reason — `x doctor` prints
|
|
60
|
+
* them. Two kinds and no more: a file here is a file the floor does not see, so the list is not
|
|
61
|
+
* a place to put code that merely has no test yet.
|
|
62
|
+
*/
|
|
63
|
+
export const SCAFFOLD_COVERAGE_EXCLUDE: readonly CoverageExclude[] = [
|
|
64
|
+
{
|
|
65
|
+
glob: 'apps/**/*.island.tsx',
|
|
66
|
+
why: 'an island runs in a browser: its test mounts a BUILT chunk (mountIsland), and Bun cannot map that chunk back to this source — its states are held by guards/island-without-states.ts and photographed by x shot --island',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
glob: 'apps/*/server.ts',
|
|
70
|
+
why: 'the container entry point: it boots the roles and lives as long as the process — bun run dev and the image exercise it',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
glob: 'apps/*/prerender.ts',
|
|
74
|
+
why: "the static build's entry point: x build --target static runs it, and the budgets step weighs what it writes",
|
|
75
|
+
},
|
|
76
|
+
];
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The coverage floor every scaffolded app starts on: the bar the framework holds its own packages
|
|
80
|
+
* to (`COVERAGE_BAR`), not a softer one for apps. `scaffold-smoke` runs the app's own `x verify`,
|
|
81
|
+
* so the scaffold is green at it on what it generates or the job is red.
|
|
82
|
+
*/
|
|
83
|
+
export const verifyFloor = (example: boolean): string =>
|
|
84
|
+
`${JSON.stringify(
|
|
85
|
+
{
|
|
86
|
+
steps: example ? [...SCAFFOLD_FLOOR, ...EXAMPLE_FLOOR] : SCAFFOLD_FLOOR,
|
|
87
|
+
coverage: {
|
|
88
|
+
lines: COVERAGE_BAR,
|
|
89
|
+
funcs: COVERAGE_BAR,
|
|
90
|
+
exclude: SCAFFOLD_COVERAGE_EXCLUDE,
|
|
91
|
+
},
|
|
92
|
+
// The rolling rail judges from the first migration: a new app has nothing to grandfather.
|
|
93
|
+
rollingSince: '0',
|
|
94
|
+
},
|
|
95
|
+
null,
|
|
96
|
+
2,
|
|
97
|
+
)}\n`;
|
|
@@ -32,7 +32,7 @@ export interface ShapeOverlay {
|
|
|
32
32
|
const CATALOG = 'packages/i18n/catalogs/en.json';
|
|
33
33
|
|
|
34
34
|
/** A stale overlay is the framework's bug, never the app's: the shape tests name which one. */
|
|
35
|
-
const FIX = 'bun test packages/cli/src/templates/shapes';
|
|
35
|
+
const FIX = 'bun test ./packages/cli/src/templates/shapes';
|
|
36
36
|
|
|
37
37
|
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
38
38
|
typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
// the page that links to the first one. PKCE, the sealed handshake, the state check and the account
|
|
4
4
|
// link are the framework's; which IdP group means which role stays the app's (`resolveGrants`).
|
|
5
5
|
|
|
6
|
+
// The literal the generated tests pin comes from auth itself, so the scaffold cannot drift from it.
|
|
7
|
+
import { oauthStartPath } from '@ultimat3/auth';
|
|
6
8
|
import { catalogJson } from './catalog-json';
|
|
7
9
|
import { catalogPath } from './locales';
|
|
8
10
|
import type { GeneratedFile } from './naming';
|
|
@@ -54,7 +56,7 @@ import { AFTER_SIGN_IN } from './sign-in-flow';
|
|
|
54
56
|
|
|
55
57
|
export const OIDC_PROVIDER = '${provider}';
|
|
56
58
|
export const OIDC_ISSUER_ENV = '${oidcEnvPrefix(provider)}_ISSUER';
|
|
57
|
-
/** Where the sign-in page sends a browser: the start leg,
|
|
59
|
+
/** Where the sign-in page sends a browser: the start leg, \`${oauthStartPath(provider)}\`. */
|
|
58
60
|
export const OIDC_START_PATH = oauthStartPath(OIDC_PROVIDER);
|
|
59
61
|
|
|
60
62
|
type Env = Readonly<Record<string, string | undefined>>;
|
|
@@ -94,7 +96,7 @@ import { OIDC_ISSUER_ENV, OIDC_PROVIDER, OIDC_START_PATH, oidcLegs } from './oid
|
|
|
94
96
|
unitTest('the provider, its issuer key and its start path are spelled once', () => {
|
|
95
97
|
expect(OIDC_PROVIDER).toBe('${provider}');
|
|
96
98
|
expect(OIDC_ISSUER_ENV).toBe('${oidcEnvPrefix(provider)}_ISSUER');
|
|
97
|
-
expect(OIDC_START_PATH).toBe('
|
|
99
|
+
expect(OIDC_START_PATH).toBe('${oauthStartPath(provider)}');
|
|
98
100
|
// Importing this module registered nothing: the first sign-in does.
|
|
99
101
|
expect(hasOAuthProvider(OIDC_PROVIDER)).toBe(false);
|
|
100
102
|
});
|
|
@@ -175,7 +177,7 @@ export function oidcSignInFiles(
|
|
|
175
177
|
{ path: `${AUTH_DIR}/sign-in/page.tsx`, contents: signInPageSource(module, OIDC_FORM) },
|
|
176
178
|
{
|
|
177
179
|
path: `${AUTH_DIR}/sign-in/page.test.ts`,
|
|
178
|
-
contents: signInPageTest(module, 'app.auth.signIn', `'href="
|
|
180
|
+
contents: signInPageTest(module, 'app.auth.signIn', `'href="${oauthStartPath(provider)}"'`),
|
|
179
181
|
},
|
|
180
182
|
...options.locales.map((locale) => ({
|
|
181
183
|
path: catalogPath(locale),
|
|
@@ -5,6 +5,14 @@
|
|
|
5
5
|
|
|
6
6
|
import type { GeneratedFile } from './naming';
|
|
7
7
|
import { authModule } from './scaffold-auth';
|
|
8
|
+
import {
|
|
9
|
+
baseRuntimeSource,
|
|
10
|
+
baseRuntimeTest,
|
|
11
|
+
RUNTIME_HEADER,
|
|
12
|
+
RUNTIME_MODULE,
|
|
13
|
+
RUNTIME_TEST,
|
|
14
|
+
runtimePortLines,
|
|
15
|
+
} from './scaffold-runtime-ports';
|
|
8
16
|
import { destroySessionTest } from './sign-in-action-tests';
|
|
9
17
|
|
|
10
18
|
/** Every generated file lives under the scaffold's own auth slice, beside `auth.ts`. */
|
|
@@ -215,8 +223,6 @@ const styleSource =
|
|
|
215
223
|
`;
|
|
216
224
|
|
|
217
225
|
/** The files both shapes write, with the guard over this shape's settings. */
|
|
218
|
-
/** Where the generated runtime lives: `apps/<app>/runtime.ts` is what both boots read first. */
|
|
219
|
-
export const RUNTIME_MODULE = 'apps/web/runtime.ts';
|
|
220
226
|
|
|
221
227
|
/** The plain routes a shape mounts: an import line, and the expression `routes:` takes. */
|
|
222
228
|
export interface RuntimeRoutes {
|
|
@@ -224,16 +230,17 @@ export interface RuntimeRoutes {
|
|
|
224
230
|
readonly expression: string;
|
|
225
231
|
}
|
|
226
232
|
|
|
227
|
-
const runtimeSource = (
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
// role, where the same throw in a module the app scan imports is logged and the boot goes on.
|
|
233
|
+
const runtimeSource = (routes: RuntimeRoutes | undefined): string => `${RUNTIME_HEADER}
|
|
234
|
+
// The sign-in guard runs HERE: a throw in this module stops the role, where the same throw in a
|
|
235
|
+
// module the app scan imports is logged and the boot goes on.
|
|
236
|
+
import type { RuntimeOverrides } from '@ultimat3/cli/serve';
|
|
232
237
|
import { assertSignInConfigured } from './app/auth/sign-in-guard';${routes === undefined ? '' : `\n${routes.importLine}`}
|
|
233
238
|
|
|
234
239
|
assertSignInConfigured(process.env);
|
|
235
240
|
|
|
236
|
-
export const runtime = {
|
|
241
|
+
export const runtime = {
|
|
242
|
+
${routes === undefined ? '' : ` routes: ${routes.expression},\n`}${runtimePortLines()}
|
|
243
|
+
} satisfies RuntimeOverrides;
|
|
237
244
|
`;
|
|
238
245
|
|
|
239
246
|
const runtimeTest = (
|
|
@@ -253,8 +260,19 @@ export function sharedSignInFiles(
|
|
|
253
260
|
routes?: RuntimeRoutes,
|
|
254
261
|
): readonly GeneratedFile[] {
|
|
255
262
|
return [
|
|
256
|
-
|
|
257
|
-
{
|
|
263
|
+
// Over `x new`'s own pair while it is untouched; an author's edited copy is a conflict.
|
|
264
|
+
{
|
|
265
|
+
path: RUNTIME_MODULE,
|
|
266
|
+
contents: runtimeSource(routes),
|
|
267
|
+
merge: 'replaces-pristine',
|
|
268
|
+
pristine: baseRuntimeSource(),
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
path: RUNTIME_TEST,
|
|
272
|
+
contents: runtimeTest(routes),
|
|
273
|
+
merge: 'replaces-pristine',
|
|
274
|
+
pristine: baseRuntimeTest(),
|
|
275
|
+
},
|
|
258
276
|
{ path: `${AUTH_DIR}/sign-in-flow.ts`, contents: flowSource() },
|
|
259
277
|
{ path: `${AUTH_DIR}/sign-in-flow.test.ts`, contents: flowTest() },
|
|
260
278
|
{ path: `${AUTH_DIR}/sign-in-guard.ts`, contents: guardSource(keys, why) },
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// `x g app <name>` and `x g package <name>`: one more workspace in a scaffolded monorepo. Nothing
|
|
2
|
+
// outside the new directory changes: the root `workspaces` globs (`apps/*`, `packages/*`) admit it
|
|
3
|
+
// and the root tsconfig's one alias (`@<app>/*` → `packages/*/src`, then `apps/*`) reaches it.
|
|
4
|
+
|
|
5
|
+
import type { GeneratedFile, NameSet } from './naming';
|
|
6
|
+
import { packageShapeFiles, workspacePackageJson } from './scaffold-package-shape';
|
|
7
|
+
|
|
8
|
+
const appTsconfig = `{
|
|
9
|
+
"extends": "../../tsconfig.json",
|
|
10
|
+
"include": ["**/*.ts", "**/*.tsx", "../../types/scss.d.ts"]
|
|
11
|
+
}
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* No `dependencies`: an app declares a package as it first imports one (`package-shape`'s
|
|
16
|
+
* `X_WORKSPACE_DEP_UNDECLARED`), and a fresh app imports nothing. `exports` is apps/admin's, so a
|
|
17
|
+
* sibling's `import type` of a module here resolves the same way.
|
|
18
|
+
*/
|
|
19
|
+
const appPackageJson = (app: NameSet, name: string): string => `{
|
|
20
|
+
"name": "@${app.kebab}/${name}",
|
|
21
|
+
"version": "0.0.0",
|
|
22
|
+
"private": true,
|
|
23
|
+
"type": "module",
|
|
24
|
+
"exports": {
|
|
25
|
+
"./*": "./*.ts",
|
|
26
|
+
"./*.tsx": "./*.tsx"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"typecheck": "tsc --noEmit -p ../../tsconfig.json"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
`;
|
|
33
|
+
|
|
34
|
+
/** `apps/<name>/`: scanned by the one boot like `apps/web`, served by the same image. */
|
|
35
|
+
export const workspaceAppFiles = (app: NameSet, name: string): readonly GeneratedFile[] => [
|
|
36
|
+
{ path: `apps/${name}/package.json`, contents: appPackageJson(app, name) },
|
|
37
|
+
{ path: `apps/${name}/tsconfig.json`, contents: appTsconfig },
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
const packageIndex = (
|
|
41
|
+
app: NameSet,
|
|
42
|
+
name: string,
|
|
43
|
+
): string => `// @${app.kebab}/${name}: code every app of this repo may share. Named exports only; it imports
|
|
44
|
+
// \`@ultimat3/*\` and sibling packages, never an app (the \`boundaries\` step,
|
|
45
|
+
// X_BOUNDARY_PACKAGE_TO_APP).
|
|
46
|
+
|
|
47
|
+
/** This package's import specifier, for a caller that has to name it in a message. */
|
|
48
|
+
export const PACKAGE_NAME = '@${app.kebab}/${name}';
|
|
49
|
+
`;
|
|
50
|
+
|
|
51
|
+
const packageTest = (
|
|
52
|
+
app: NameSet,
|
|
53
|
+
): string => `// Pins the package's place in the repo: it is installed under the app's own scope, so a
|
|
54
|
+
// sibling imports it as \`@${app.kebab}/<name>\` and never by a relative path.
|
|
55
|
+
|
|
56
|
+
import { expect } from 'bun:test';
|
|
57
|
+
import { unitTest } from '@ultimat3/testing';
|
|
58
|
+
import { PACKAGE_NAME } from './index';
|
|
59
|
+
|
|
60
|
+
unitTest('the package is named into the app scope', () => {
|
|
61
|
+
expect(PACKAGE_NAME.startsWith('@${app.kebab}/')).toBe(true);
|
|
62
|
+
});
|
|
63
|
+
`;
|
|
64
|
+
|
|
65
|
+
/** `packages/<name>/`: the root alias `@<app>/*` → `./packages/*\/src` already reaches it. */
|
|
66
|
+
export const workspacePackageFiles = (
|
|
67
|
+
app: NameSet,
|
|
68
|
+
name: string,
|
|
69
|
+
description = 'Code shared by every app in this repository',
|
|
70
|
+
): readonly GeneratedFile[] => [
|
|
71
|
+
{ path: `packages/${name}/package.json`, contents: workspacePackageJson(app, name, description) },
|
|
72
|
+
...packageShapeFiles(app, name, description),
|
|
73
|
+
{ path: `packages/${name}/src/index.ts`, contents: packageIndex(app, name) },
|
|
74
|
+
{ path: `packages/${name}/src/index.test.ts`, contents: packageTest(app) },
|
|
75
|
+
];
|
package/src/test-ignores.ts
CHANGED
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
// predicate `discoverTests` filters by and the `--path-ignore-patterns` the serial steps pass to
|
|
3
3
|
// `bun test`. A leaf, so `test-select.ts` and `verify-tests.ts` (which import each other) share it.
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Build output, installed packages, git's own tree and an app's `.x/` state: never a test, at ANY
|
|
7
|
+
* depth. The last two because discovery scans dot-directories (`.claude/hooks/*.test.ts` is a test).
|
|
8
|
+
*/
|
|
9
|
+
const IGNORED_ANYWHERE = ['dist', 'node_modules', '.git', '.x'] as const;
|
|
7
10
|
|
|
8
11
|
/**
|
|
9
12
|
* Nested projects with their own gate (`examples/`, `dummy/`, run by
|
package/src/test-select.ts
CHANGED
|
@@ -48,7 +48,10 @@ export async function discoverTests(
|
|
|
48
48
|
): Promise<readonly TestFile[]> {
|
|
49
49
|
const filters = filter === undefined ? undefined : typeof filter === 'string' ? [filter] : filter;
|
|
50
50
|
const files: TestFile[] = [];
|
|
51
|
-
|
|
51
|
+
// `dot: true`: a hook's test under `.claude/hooks/` is a test; `.git` and `.x` are refused by the
|
|
52
|
+
// one ignore policy below (`test-ignores.ts`), never by the glob.
|
|
53
|
+
const glob = new Bun.Glob(TEST_GLOB);
|
|
54
|
+
for await (const found of glob.scan({ cwd: root, absolute: false, dot: true })) {
|
|
52
55
|
const path = found.split('\\').join('/');
|
|
53
56
|
if (isIgnoredTestPath(path)) continue;
|
|
54
57
|
if (filters !== undefined && !filters.some((part) => path.includes(part))) continue;
|