@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
|
@@ -60,8 +60,8 @@ const input = { id, orgId${isMutator ? ", title: 'a title'" : ''} };
|
|
|
60
60
|
: ''
|
|
61
61
|
}
|
|
62
62
|
// Named here because every projection needs a stable name and this file does not boot the app.
|
|
63
|
-
// At boot \`
|
|
64
|
-
//
|
|
63
|
+
// At boot \`defineApi\` stamps the same name onto the same object, so each projection of it
|
|
64
|
+
// works there with nothing to remember.
|
|
65
65
|
const target = ${name.camel}.named('${name.camel}');
|
|
66
66
|
${
|
|
67
67
|
outsider
|
|
@@ -205,8 +205,8 @@ const id = '${ID}';
|
|
|
205
205
|
${shape.org ? `const orgId = '${ORG}';\n` : ''}const input = { id${shape.org ? ', orgId' : ''}${shape.isMutator ? ", title: 'a title'" : ''} };
|
|
206
206
|
${shape.isMutator ? `\n// The client store's table: the entity's own, so the twin and the server row share one key.\nconst TABLE = '${feature.table}';\n` : ''}
|
|
207
207
|
// Named here because every projection needs a stable name and this file does not boot the app.
|
|
208
|
-
// At boot \`
|
|
209
|
-
//
|
|
208
|
+
// At boot \`defineApi\` stamps the same name onto the same object, so each projection of it
|
|
209
|
+
// works there with nothing to remember.
|
|
210
210
|
const target = ${name.camel}.named('${name.camel}');
|
|
211
211
|
${
|
|
212
212
|
known
|
|
@@ -108,16 +108,13 @@ const backfillTest = (
|
|
|
108
108
|
): string => `// ${name.camel}'s durable identity: one live run per name, retried under the same key. The work
|
|
109
109
|
// itself — the pass over real rows and the projection it applies — is the unit suite's, next door.
|
|
110
110
|
|
|
111
|
-
import { memoryJobDriver
|
|
112
|
-
import {
|
|
111
|
+
import { memoryJobDriver } from '@ultimat3/jobs';
|
|
112
|
+
import { beforeAll, expect, jobTest, swapAdapter } from '@ultimat3/testing';
|
|
113
113
|
import { ${name.camel} } from './${name.kebab}';
|
|
114
114
|
|
|
115
|
-
// The
|
|
116
|
-
// left behind for whichever test happens to run next.
|
|
117
|
-
beforeAll(() =>
|
|
118
|
-
setJobDriver(memoryJobDriver());
|
|
119
|
-
});
|
|
120
|
-
afterAll(resetJobDriver);
|
|
115
|
+
// The queue is a process-global adapter port, so it is swapped for this file and put back when the
|
|
116
|
+
// file ends, never left behind for whichever test happens to run next.
|
|
117
|
+
beforeAll(() => swapAdapter('jobs', memoryJobDriver()));
|
|
121
118
|
|
|
122
119
|
// The durable name this sweep runs under, spelled once — so the assertion below carries the
|
|
123
120
|
// backfill's own name and still fits the formatter width the app's \`lint\` step enforces.
|
package/src/templates/entity.ts
CHANGED
|
@@ -66,6 +66,9 @@ export const ${name.camel} = entity('${table}', {
|
|
|
66
66
|
invariant('${snake}_price_non_negative', c.price.minor.atLeast(0)),
|
|
67
67
|
],
|
|
68
68
|
indexes: [{ on: ['orgId', 'createdAt'] }],
|
|
69
|
+
// PARTITIONED? \`partitionBy: { column: 'createdAt', interval: 'month' }\` needs its maintenance
|
|
70
|
+
// job too, or no partition is created ahead: export \`partitions()\` from '@ultimat3/jobs' in a
|
|
71
|
+
// module listed under \`jobs\` in apps/web/api/index.ts, and its \`.schedule\` under \`tasks\`.
|
|
69
72
|
});
|
|
70
73
|
|
|
71
74
|
export type ${name.pascal} = typeof ${name.camel}.$row;
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
import { REQUIRED_BUN } from '../../app-root';
|
|
13
13
|
import type { GeneratedFile, NameSet } from '../naming';
|
|
14
14
|
import { TEST_COMPOSE_PATH, TEST_ENV_PATH } from '../scaffold-test-services';
|
|
15
|
+
import { DEPENDABOT_PATH, dependabot } from './dependabot.yml';
|
|
15
16
|
import { IMAGE_WORKFLOW_PATH, imageWorkflow } from './image.yml';
|
|
16
17
|
import { RUNS_ON } from './runner';
|
|
17
18
|
|
|
@@ -96,10 +97,11 @@ jobs:
|
|
|
96
97
|
- run: bun run verify
|
|
97
98
|
`;
|
|
98
99
|
|
|
99
|
-
/** The CI a new app is born with, in
|
|
100
|
+
/** The CI a new app is born with, in reading order: the gate, the image, the dependency updates. */
|
|
100
101
|
export function githubFiles(app: NameSet): readonly GeneratedFile[] {
|
|
101
102
|
return [
|
|
102
103
|
{ path: CI_WORKFLOW_PATH, contents: ci(app) },
|
|
103
104
|
{ path: IMAGE_WORKFLOW_PATH, contents: imageWorkflow(CI_WORKFLOW_NAME) },
|
|
105
|
+
{ path: DEPENDABOT_PATH, contents: dependabot() },
|
|
104
106
|
];
|
|
105
107
|
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// The Dependabot config `x new` writes. Every `@ultimat3/*` package is released in lockstep, so a
|
|
2
|
+
// PR that bumps one of them alone is an install no release ever shipped: they move as ONE group,
|
|
3
|
+
// majors included. The base images the scaffold pins under `docker/` are watched beside them.
|
|
4
|
+
|
|
5
|
+
/** Where GitHub reads it. */
|
|
6
|
+
export const DEPENDABOT_PATH = '.github/dependabot.yml';
|
|
7
|
+
|
|
8
|
+
/** The directory `x new` writes its Dockerfile and compose files into. */
|
|
9
|
+
const DOCKER_DIR = '/docker';
|
|
10
|
+
|
|
11
|
+
export const dependabot = (): string => `version: 2
|
|
12
|
+
|
|
13
|
+
# Weekly, grouped, and small — a dependency PR nobody can review in one sitting gets merged unread.
|
|
14
|
+
updates:
|
|
15
|
+
# \`bun\`, never \`npm\`: the tree is locked by \`bun.lock\` alone, which the npm ecosystem refuses.
|
|
16
|
+
- package-ecosystem: bun
|
|
17
|
+
directory: /
|
|
18
|
+
schedule:
|
|
19
|
+
interval: weekly
|
|
20
|
+
# A release sits 14 days before it is proposed: most yanked versions are yanked by then.
|
|
21
|
+
cooldown:
|
|
22
|
+
default-days: 14
|
|
23
|
+
open-pull-requests-limit: 5
|
|
24
|
+
labels: [dependencies]
|
|
25
|
+
groups:
|
|
26
|
+
# Released in lockstep, so upgraded in lockstep: one PR, every update type. A bump of one
|
|
27
|
+
# package alone is a combination no release shipped. A major is \`x upgrade\`'s job — the PR
|
|
28
|
+
# says it is due; run \`bunx x upgrade\` on its branch.
|
|
29
|
+
ultimate:
|
|
30
|
+
patterns: ['@ultimat3/*', 'create-ultimate']
|
|
31
|
+
dependencies:
|
|
32
|
+
patterns: ['*']
|
|
33
|
+
exclude-patterns: ['@ultimat3/*', 'create-ultimate']
|
|
34
|
+
update-types: [minor, patch]
|
|
35
|
+
ignore:
|
|
36
|
+
# Bun is pinned by \`engines\` and the workflow's \`bun-version\`, not by a package bump.
|
|
37
|
+
- dependency-name: bun
|
|
38
|
+
|
|
39
|
+
- package-ecosystem: github-actions
|
|
40
|
+
directory: /
|
|
41
|
+
schedule:
|
|
42
|
+
interval: weekly
|
|
43
|
+
cooldown:
|
|
44
|
+
default-days: 14
|
|
45
|
+
labels: [dependencies, ci]
|
|
46
|
+
groups:
|
|
47
|
+
actions:
|
|
48
|
+
patterns: ['*']
|
|
49
|
+
|
|
50
|
+
# The base images the Dockerfile and the compose files pin.
|
|
51
|
+
- package-ecosystem: docker
|
|
52
|
+
directories: ['${DOCKER_DIR}']
|
|
53
|
+
schedule:
|
|
54
|
+
interval: weekly
|
|
55
|
+
cooldown:
|
|
56
|
+
default-days: 14
|
|
57
|
+
labels: [dependencies, docker]
|
|
58
|
+
ignore:
|
|
59
|
+
# A Postgres MAJOR is a planned migration (a new data directory), never a weekly bump.
|
|
60
|
+
- dependency-name: postgres
|
|
61
|
+
update-types: ['version-update:semver-major']
|
|
62
|
+
|
|
63
|
+
- package-ecosystem: docker-compose
|
|
64
|
+
directories: ['${DOCKER_DIR}']
|
|
65
|
+
schedule:
|
|
66
|
+
interval: weekly
|
|
67
|
+
cooldown:
|
|
68
|
+
default-days: 14
|
|
69
|
+
labels: [dependencies, docker]
|
|
70
|
+
ignore:
|
|
71
|
+
- dependency-name: postgres
|
|
72
|
+
update-types: ['version-update:semver-major']
|
|
73
|
+
`;
|
package/src/templates/job.ts
CHANGED
|
@@ -129,8 +129,8 @@ const jobTest = (
|
|
|
129
129
|
name: NameSet,
|
|
130
130
|
): string => `// ${name.camel} against a real driver: enqueue, drain, assert. Retries and the dead-letter path
|
|
131
131
|
// are the framework's, so what this pins is that THIS job's steps run and are idempotent.
|
|
132
|
-
import { memoryJobDriver
|
|
133
|
-
import {
|
|
132
|
+
import { memoryJobDriver } from '@ultimat3/jobs';
|
|
133
|
+
import { beforeAll, expect, jobTest, swapAdapter } from '@ultimat3/testing';
|
|
134
134
|
import { ${name.camel} } from './${name.kebab}';
|
|
135
135
|
|
|
136
136
|
const id = '00000000-0000-4000-8000-000000000001';
|
|
@@ -140,12 +140,9 @@ const input = { id, orgId };
|
|
|
140
140
|
// the job's own name and still fits the formatter width the app's \`lint\` step enforces.
|
|
141
141
|
const expectedKey = \`${name.kebab}:\${id}\`;
|
|
142
142
|
|
|
143
|
-
// The
|
|
144
|
-
// left behind for whichever test happens to run next.
|
|
145
|
-
beforeAll(() =>
|
|
146
|
-
setJobDriver(memoryJobDriver());
|
|
147
|
-
});
|
|
148
|
-
afterAll(resetJobDriver);
|
|
143
|
+
// The queue is a process-global adapter port, so it is swapped for this file and put back when the
|
|
144
|
+
// file ends, never left behind for whichever test happens to run next.
|
|
145
|
+
beforeAll(() => swapAdapter('jobs', memoryJobDriver()));
|
|
149
146
|
|
|
150
147
|
jobTest('${name.camel} declares a key and a retry policy', () => {
|
|
151
148
|
expect(${name.camel}.kind).toBe('job');
|
|
@@ -186,8 +183,8 @@ const neutralJobTest = (
|
|
|
186
183
|
name: NameSet,
|
|
187
184
|
): string => `// ${name.camel} against a real driver: enqueue, drain, assert. Retries and the dead-letter path
|
|
188
185
|
// are the framework's, so what this pins is that THIS job's steps run and are idempotent.
|
|
189
|
-
import { memoryJobDriver
|
|
190
|
-
import {
|
|
186
|
+
import { memoryJobDriver } from '@ultimat3/jobs';
|
|
187
|
+
import { beforeAll, expect, jobTest, swapAdapter } from '@ultimat3/testing';
|
|
191
188
|
import { ${name.camel} } from './${name.kebab}';
|
|
192
189
|
|
|
193
190
|
const id = '00000000-0000-4000-8000-000000000001';
|
|
@@ -196,12 +193,9 @@ const input = { id };
|
|
|
196
193
|
// the job's own name and still fits the formatter width the app's \`lint\` step enforces.
|
|
197
194
|
const expectedKey = \`${name.kebab}:\${id}\`;
|
|
198
195
|
|
|
199
|
-
// The
|
|
200
|
-
// left behind for whichever test happens to run next.
|
|
201
|
-
beforeAll(() =>
|
|
202
|
-
setJobDriver(memoryJobDriver());
|
|
203
|
-
});
|
|
204
|
-
afterAll(resetJobDriver);
|
|
196
|
+
// The queue is a process-global adapter port, so it is swapped for this file and put back when the
|
|
197
|
+
// file ends, never left behind for whichever test happens to run next.
|
|
198
|
+
beforeAll(() => swapAdapter('jobs', memoryJobDriver()));
|
|
205
199
|
|
|
206
200
|
jobTest('${name.camel} declares a key and a retry policy', () => {
|
|
207
201
|
expect(${name.camel}.kind).toBe('job');
|
|
@@ -243,15 +237,12 @@ const taskTest = (
|
|
|
243
237
|
jobName: NameSet,
|
|
244
238
|
): string => `// ${name.camel}: the schedule it declares, the timezone it declares it in, and the job it
|
|
245
239
|
// enqueues. A cron with no explicit IANA zone fires at a different hour twice a year.
|
|
246
|
-
import { memoryJobDriver
|
|
247
|
-
import {
|
|
240
|
+
import { memoryJobDriver } from '@ultimat3/jobs';
|
|
241
|
+
import { beforeAll, expect, jobTest, swapAdapter } from '@ultimat3/testing';
|
|
248
242
|
import { ${jobName.camel} } from '../jobs/${jobName.kebab}';
|
|
249
243
|
import { ${name.camel} } from './${name.kebab}';
|
|
250
244
|
|
|
251
|
-
beforeAll(() =>
|
|
252
|
-
setJobDriver(memoryJobDriver());
|
|
253
|
-
});
|
|
254
|
-
afterAll(resetJobDriver);
|
|
245
|
+
beforeAll(() => swapAdapter('jobs', memoryJobDriver()));
|
|
255
246
|
|
|
256
247
|
jobTest('${name.camel} declares a cron with an explicit time zone', () => {
|
|
257
248
|
expect(${name.camel}.kind).toBe('task');
|
package/src/templates/naming.ts
CHANGED
|
@@ -55,13 +55,32 @@ export interface GeneratedFoundationFile {
|
|
|
55
55
|
readonly merge: 'if-absent';
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
/**
|
|
59
|
+
* A file the base scaffold writes and a later generator owns a richer version of — `x g sign-in`'s
|
|
60
|
+
* `apps/web/runtime.ts`. Written when absent, REPLACED when the copy on disk is still byte-for-byte
|
|
61
|
+
* `pristine` (the scaffold's own, untouched), and a conflict once the author has edited it: their
|
|
62
|
+
* ports are theirs, and only `--force` overwrites them.
|
|
63
|
+
*/
|
|
64
|
+
export interface GeneratedReplacingFile {
|
|
65
|
+
/** POSIX path relative to the app root. */
|
|
66
|
+
readonly path: string;
|
|
67
|
+
readonly contents: string;
|
|
68
|
+
readonly merge: 'replaces-pristine';
|
|
69
|
+
/** The exact bytes this file may replace without asking. */
|
|
70
|
+
readonly pristine: string;
|
|
71
|
+
}
|
|
72
|
+
|
|
58
73
|
/**
|
|
59
74
|
* Split on `merge` rather than widening one shape's `contents` in place, so the split is
|
|
60
75
|
* load-bearing, not cosmetic: a `merge: 'json'` file's `contents` stays a plain `string` at the
|
|
61
76
|
* type level, which is what stops a byte-carrying file from ever reaching
|
|
62
77
|
* `cmd-generate.ts`'s JSON parser — the compiler refuses the call before the code can run.
|
|
63
78
|
*/
|
|
64
|
-
export type GeneratedFile =
|
|
79
|
+
export type GeneratedFile =
|
|
80
|
+
| GeneratedJsonFile
|
|
81
|
+
| GeneratedSourceFile
|
|
82
|
+
| GeneratedFoundationFile
|
|
83
|
+
| GeneratedReplacingFile;
|
|
65
84
|
|
|
66
85
|
const words = (input: string): readonly string[] =>
|
|
67
86
|
input
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
# It is grouped in .github/dependabot.yml with docker/, so one PR moves every copy together.
|
|
4
4
|
services:
|
|
5
5
|
s3:
|
|
6
|
-
image: versity/versitygw:v1.
|
|
6
|
+
image: versity/versitygw:v1.10.0@sha256:89cad13cc981986ee284cbafea4613f9533ce6fd5f37a2c96c4c4fb8adb3a316
|
package/src/templates/query.ts
CHANGED
|
@@ -75,6 +75,7 @@ const queryTest = (name: NameSet, feature: NameSet, shape: ReadShape): string =>
|
|
|
75
75
|
const subscribes = live && shape.storesRow;
|
|
76
76
|
const imports = subscribes
|
|
77
77
|
? [
|
|
78
|
+
"import { defineApi } from '@ultimat3/action';",
|
|
78
79
|
"import { ctxOf, frozenClock, runWithContext } from '@ultimat3/core';",
|
|
79
80
|
`import { afterEach, expect, ${wrapper} } from '@ultimat3/testing';`,
|
|
80
81
|
`import { driver } from '${shape.dbModule}';`,
|
|
@@ -90,15 +91,12 @@ const queryTest = (name: NameSet, feature: NameSet, shape: ReadShape): string =>
|
|
|
90
91
|
${sortedImports([
|
|
91
92
|
...imports,
|
|
92
93
|
"import { testActor } from '@ultimat3/policy';",
|
|
93
|
-
|
|
94
|
-
? "import { registerQuery, sourceFor } from '@ultimat3/query';"
|
|
95
|
-
: "import { sourceFor } from '@ultimat3/query';",
|
|
94
|
+
"import { sourceFor } from '@ultimat3/query';",
|
|
96
95
|
])}${repo}
|
|
97
96
|
import { ${name.camel} } from './${name.kebab}';
|
|
98
97
|
${live && !shape.storesRow ? '' : ORG_LINE}
|
|
99
98
|
// Named here because every projection needs a stable name and this file does not boot the app.
|
|
100
|
-
// At boot \`
|
|
101
|
-
// onto the same object.
|
|
99
|
+
// At boot \`defineApi\` stamps the same name onto the same object.
|
|
102
100
|
const target = ${name.camel}.named('${name.camel}');
|
|
103
101
|
|
|
104
102
|
// Holds the grant and no org — so a denial here is the predicate deciding, not the grant.
|
|
@@ -174,9 +172,10 @@ ${subscribes ? subscribeTest(name, feature) : ''}`;
|
|
|
174
172
|
* Two orgs, a snapshot and a write: the window a subscriber is served from is its own org's.
|
|
175
173
|
*/
|
|
176
174
|
const subscribeTest = (name: NameSet, feature: NameSet): string => `
|
|
177
|
-
// The module's own export under its own name
|
|
178
|
-
// frame naming it reaches this declaration.
|
|
179
|
-
const
|
|
175
|
+
// The module's own export under its own name, through \`defineApi\` as the boot hands it over, so
|
|
176
|
+
// a subscribe frame naming it reaches this declaration.
|
|
177
|
+
const api = defineApi({ queries: { ${name.camel} } });
|
|
178
|
+
const live = api.queries.${name.camel};
|
|
180
179
|
|
|
181
180
|
type Row = ${feature.pascal};
|
|
182
181
|
|
package/src/templates/route.ts
CHANGED
|
@@ -75,8 +75,8 @@ export const routeParams = (path: string): readonly string[] =>
|
|
|
75
75
|
* only this function knows where `x g resource`'s page went — a second copy of the formula in the
|
|
76
76
|
* resource generator is how the specifier it prints stops matching the file it writes.
|
|
77
77
|
*/
|
|
78
|
-
export const routeDir = (surface: Surface, path: string): string =>
|
|
79
|
-
`apps
|
|
78
|
+
export const routeDir = (surface: Surface, path: string, app = 'web'): string =>
|
|
79
|
+
`apps/${app}/${surface}/${segmentsOf(path).join('/')}`;
|
|
80
80
|
|
|
81
81
|
/**
|
|
82
82
|
* How the generated page reaches a string, and it is the whole reason this generator takes an app
|
|
@@ -260,11 +260,13 @@ export interface RouteOptions {
|
|
|
260
260
|
* generated page fall back to importing `t` from `@ultimat3/i18n`.
|
|
261
261
|
*/
|
|
262
262
|
readonly catalogModule?: string;
|
|
263
|
+
/** The app workspace the page lands in, `apps/<app>/` — `x g route --app`. Default `web`. */
|
|
264
|
+
readonly app?: string;
|
|
263
265
|
}
|
|
264
266
|
|
|
265
267
|
export function routeFiles(rawPath: string, options: RouteOptions): readonly GeneratedFile[] {
|
|
266
268
|
const path = rawPath.replace(/^\/+/, '');
|
|
267
|
-
const dir = routeDir(options.surface, path);
|
|
269
|
+
const dir = routeDir(options.surface, path, options.app);
|
|
268
270
|
const locales = resolveLocales(options.locales);
|
|
269
271
|
return [
|
|
270
272
|
{ path: `${dir}/page.tsx`, contents: pageSource(options.surface, path, options.catalogModule) },
|
|
@@ -33,7 +33,7 @@ import { contractTest, expect } from '@ultimat3/testing';
|
|
|
33
33
|
import { health } from './health';
|
|
34
34
|
|
|
35
35
|
// Named here because every projection needs a stable name and this file does not boot the app.
|
|
36
|
-
// At boot \`
|
|
36
|
+
// At boot \`defineApi\` stamps the same name onto the same object.
|
|
37
37
|
const target = health.named('health');
|
|
38
38
|
|
|
39
39
|
contractTest('health is an action exposed over MCP', () => {
|
|
@@ -209,7 +209,7 @@ const devActorTest =
|
|
|
209
209
|
(): string => `// The development viewer is safe because of what it refuses: a role nobody declared is never the
|
|
210
210
|
// default viewer, and the actor it mints holds what its role holds and nothing else. WHEN it is
|
|
211
211
|
// asked is \`authenticator.ts\`'s, and \`authenticator.test.ts\` holds that half.
|
|
212
|
-
import {
|
|
212
|
+
import { installLogSink } from '@ultimat3/core';
|
|
213
213
|
import { actorHas } from '@ultimat3/policy';
|
|
214
214
|
import { expect, unitTest } from '@ultimat3/testing';
|
|
215
215
|
import { roles } from '../../shared/roles';
|
|
@@ -267,12 +267,14 @@ unitTest('it answers a request from its cookie header, and no other', () => {
|
|
|
267
267
|
|
|
268
268
|
unitTest('an undeclared role is answered as ANONYMOUS, and the log names what it read', () => {
|
|
269
269
|
const lines: Record<string, unknown>[] = [];
|
|
270
|
-
const
|
|
270
|
+
const releaseLogSink = installLogSink((line) =>
|
|
271
|
+
lines.push(JSON.parse(line) as Record<string, unknown>),
|
|
272
|
+
);
|
|
271
273
|
try {
|
|
272
274
|
const cookie = \`\${DEV_ROLE_COOKIE}=auditor\`;
|
|
273
275
|
expect(devAuthenticate({ header: () => cookie })).toBeNull();
|
|
274
276
|
} finally {
|
|
275
|
-
|
|
277
|
+
releaseLogSink();
|
|
276
278
|
}
|
|
277
279
|
expect(lines).toHaveLength(1);
|
|
278
280
|
expect(lines[0]?.level).toBe('warn');
|
|
@@ -87,8 +87,9 @@ bun run verify --json # the same, machine-readable
|
|
|
87
87
|
|
|
88
88
|
Red is instructions, not a verdict: **every finding carries an executable \`fix:\` — run it verbatim
|
|
89
89
|
before improvising**, and \`bunx x errors explain <CODE>\` expands any code it names. Never narrow the gate
|
|
90
|
-
to make it pass:
|
|
91
|
-
|
|
90
|
+
to make it pass: \`--only <step>\` narrows feedback and prints \`NOT A GATE RUN\`, so it is never the
|
|
91
|
+
verdict; there is no \`--skip\`, on purpose; disabling a lint rule or loosening a compiler flag is the
|
|
92
|
+
same move wearing a different hat.
|
|
92
93
|
|
|
93
94
|
While you iterate, narrow the *feedback*, not the gate:
|
|
94
95
|
|
|
@@ -97,6 +98,7 @@ While you iterate, narrow the *feedback*, not the gate:
|
|
|
97
98
|
| one test file | \`bun test <path>/<file>.test.ts\` |
|
|
98
99
|
| one test by name | \`bun test -t '<name>'\` |
|
|
99
100
|
| a whole type | \`bunx x test unit\` · \`bunx x test contract\` · \`bunx x test e2e\` |
|
|
101
|
+
| one gate step | \`bunx x verify --only <step> --json\` — \`NOT A GATE RUN\` |
|
|
100
102
|
| lint the files you touched | \`bunx biome check --write <paths>\` |
|
|
101
103
|
| types, once, when otherwise done | \`bun run typecheck\` |
|
|
102
104
|
| a broken environment | \`bunx x doctor\` |
|
|
@@ -213,7 +215,8 @@ executable \`fix:\` — **run the \`fix:\` verbatim before improvising**, and us
|
|
|
213
215
|
when the cause is not enough. \`bun run verify --json\` gives the same steps machine-readably; \`bunx x doctor\`
|
|
214
216
|
covers the case where the environment, not the code, is what is broken.
|
|
215
217
|
|
|
216
|
-
Do not narrow the gate to make it pass.
|
|
218
|
+
Do not narrow the gate to make it pass. \`bunx x verify --only <step>\` re-runs one step while you fix it,
|
|
219
|
+
and says \`NOT A GATE RUN\`: green is the run with no flag. There is no \`--skip\`; disabling a lint rule,
|
|
217
220
|
loosening a compiler flag, or deleting an assertion is the same evasion. Fix the code.
|
|
218
221
|
|
|
219
222
|
Report one line per fix: the code, the file, what changed.
|
|
@@ -116,10 +116,10 @@ means it rewrites that file in place** — the same safe fixes \`biome check --w
|
|
|
116
116
|
repo-wide, but your working tree does change after every agent edit. Scoped to one file, so it costs
|
|
117
117
|
milliseconds, and it settles formatting arguments before they reach a diff.
|
|
118
118
|
|
|
119
|
-
It is not a typecheck, because a *scoped* one does not exist: \`tsc\` needs the project, and
|
|
120
|
-
|
|
121
|
-
the
|
|
122
|
-
are choosing to pay for it.
|
|
119
|
+
It is not a typecheck, because a *scoped* one does not exist: \`tsc\` needs the project, and even
|
|
120
|
+
\`bunx x verify --only typecheck\` checks the whole tree — and says \`NOT A GATE RUN\`, because green
|
|
121
|
+
means the run with no flag. There is no \`--skip\`. If you want types on every edit, \`bun run typecheck\`
|
|
122
|
+
is the whole project and you are choosing to pay for it.
|
|
123
123
|
|
|
124
124
|
## Where the rules live
|
|
125
125
|
|
|
@@ -151,12 +151,10 @@ services:
|
|
|
151
151
|
migrate: { condition: service_completed_successfully }
|
|
152
152
|
# OFF by default (zero replicas). A sync node on this database hears committed changes only
|
|
153
153
|
# from a replicator it can reach, and this file runs none: booted anyway it is refused
|
|
154
|
-
# (X_REALTIME_TOPOLOGY). To turn live queries and channels on:
|
|
155
|
-
# true, transport: 'nats', urlEnv: 'NATS_URL' } in app.config.ts, add a NATS service and set the
|
|
154
|
+
# (X_REALTIME_TOPOLOGY). To turn live queries and channels on: add a NATS service and set the
|
|
156
155
|
# SAME NATS_URL for web, sync and a replicator service (ROLE=replicator, exactly one), start
|
|
157
156
|
# Postgres with wal_level=logical and a REPLICATION role on a cluster dedicated to this app (the replicator creates its publication at boot), then set replicas: 1.
|
|
158
|
-
#
|
|
159
|
-
# without one.
|
|
157
|
+
# NATS_URL alone selects the bus: unset, each process fans out in-process only.
|
|
160
158
|
deploy: { replicas: 0 } # when on: scales on concurrent websockets — pinned to 1 by the port
|
|
161
159
|
# The sync role binds PORT + 1. PORT is unset here, so it is 3000 and this listens on 3001.
|
|
162
160
|
ports: ['3001:3001']
|
|
@@ -42,7 +42,7 @@ export const ${app.pascal}CurrencyMismatchError = defineError<CurrencyPair>({
|
|
|
42
42
|
cause: (pair) =>
|
|
43
43
|
\`cannot add \${pair.left} to \${pair.right}: Money is only additive inside one currency\`,
|
|
44
44
|
fix: (pair) =>
|
|
45
|
-
\`bun test packages/domain/src/index.test.ts # add() is defined only inside one currency — convert \${pair.right} to \${pair.left} before calling it\`,
|
|
45
|
+
\`bun test ./packages/domain/src/index.test.ts # add() is defined only inside one currency — convert \${pair.right} to \${pair.left} before calling it\`,
|
|
46
46
|
});
|
|
47
47
|
|
|
48
48
|
export const zero = (currency: string): Money => ({ minor: 0, currency });
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// answers, so an upgrade moves them without a codemod in every app that ever shipped.
|
|
6
6
|
|
|
7
7
|
import type { GeneratedFile } from './naming';
|
|
8
|
+
import { baseRuntimeFiles } from './scaffold-runtime-ports';
|
|
8
9
|
|
|
9
10
|
const server =
|
|
10
11
|
(): string => `// The production entry. \`docker/Dockerfile\` starts this, and \`x build --target binary\` compiles it.
|
|
@@ -131,8 +132,12 @@ if (import.meta.main) {
|
|
|
131
132
|
}
|
|
132
133
|
`;
|
|
133
134
|
|
|
134
|
-
/**
|
|
135
|
+
/**
|
|
136
|
+
* The process, its runtime (every adapter port, commented — `scaffold-runtime-ports.ts`), then the
|
|
137
|
+
* artifact, in the order a deploy meets them.
|
|
138
|
+
*/
|
|
135
139
|
export const entryFiles = (): readonly GeneratedFile[] => [
|
|
136
140
|
{ path: 'apps/web/server.ts', contents: server() },
|
|
141
|
+
...baseRuntimeFiles(),
|
|
137
142
|
{ path: 'apps/web/prerender.ts', contents: prerender() },
|
|
138
143
|
];
|
|
@@ -19,8 +19,9 @@ pressure, where with a limit the kubelet evicts that pod alone.
|
|
|
19
19
|
const networkPolicy = (app: NameSet): string => `{{/*
|
|
20
20
|
One NetworkPolicy per enabled role: \`http\` (web, sync) from networkPolicy.httpFrom, \`metrics\`
|
|
21
21
|
(every role) from networkPolicy.metricsFrom, nothing else. A \`from\` that renders empty is omitted,
|
|
22
|
-
which Kubernetes reads as "any source". Egress
|
|
23
|
-
|
|
22
|
+
which Kubernetes reads as "any source". Egress renders networkPolicy.egress verbatim: values.yaml
|
|
23
|
+
defaults it CLOSED (DNS, this namespace, the public internet minus metadata, CGNAT and private
|
|
24
|
+
ranges); \`egress: []\` turns filtering off. Serving roles
|
|
24
25
|
only: the migrate Job is a pre-install hook that runs before this exists, and opens no port.
|
|
25
26
|
*/}}
|
|
26
27
|
{{- if .Values.networkPolicy.enabled }}
|
|
@@ -98,14 +98,45 @@ tmp:
|
|
|
98
98
|
# httpFrom empty = any source; narrow it to your ingress controller's namespace, e.g.
|
|
99
99
|
# [{ namespaceSelector: { matchLabels: { kubernetes.io/metadata.name: ingress-nginx } } }]
|
|
100
100
|
# metricsFrom default: any pod in the cluster and no address outside it
|
|
101
|
-
# egress
|
|
102
|
-
#
|
|
101
|
+
# egress FILTERED by default, and closed only where it is dangerous: DNS, every pod in the
|
|
102
|
+
# cluster, and every routable address — private ranges INCLUDED, so a database on a
|
|
103
|
+
# VPC address (RDS on 10.x) keeps working — but never 169.254.0.0/16 (the cloud
|
|
104
|
+
# metadata endpoint, which hands any pod the node's credentials, and link-local),
|
|
105
|
+
# fe80::/10, AWS's fd00:ec2::254 or its NAT64 spelling 64:ff9b::a9fe:a9fe.
|
|
106
|
+
# A list you set REPLACES it whole; \`egress: []\` turns filtering OFF.
|
|
107
|
+
# Recommended hardening, once you know your backends' addresses: replace the
|
|
108
|
+
# cluster-pods rule with \`- to: [{ podSelector: {} }]\` (this namespace only), add
|
|
109
|
+
# 10.0.0.0/8, 100.64.0.0/10, 172.16.0.0/12, 192.168.0.0/16 to the IPv4 except and
|
|
110
|
+
# fc00::/7, 64:ff9b::/96 to the IPv6 one, then one rule per backend, e.g.
|
|
111
|
+
# - to: [{ ipBlock: { cidr: 10.0.12.0/24 } }]
|
|
112
|
+
# ports: [{ port: 5432, protocol: TCP }]
|
|
113
|
+
# An IPv6 cluster whose pods hold GLOBAL addresses must narrow ::/0 itself: no
|
|
114
|
+
# except list knows another tenant's global prefix.
|
|
103
115
|
networkPolicy:
|
|
104
116
|
enabled: true
|
|
105
117
|
httpFrom: []
|
|
106
118
|
metricsFrom:
|
|
107
119
|
- namespaceSelector: {}
|
|
108
|
-
egress:
|
|
120
|
+
egress:
|
|
121
|
+
# Port 53 to cluster pods (CoreDNS behind kube-dns) and NodeLocal DNSCache's 169.254.20.10.
|
|
122
|
+
- to:
|
|
123
|
+
- namespaceSelector: {}
|
|
124
|
+
- ipBlock: { cidr: 169.254.20.10/32 }
|
|
125
|
+
ports:
|
|
126
|
+
- { port: 53, protocol: UDP }
|
|
127
|
+
- { port: 53, protocol: TCP }
|
|
128
|
+
# Every pod in the cluster, on every port: an in-cluster Postgres, NATS, Redis or collector in
|
|
129
|
+
# any namespace — named by selector, because some CNIs never match a pod by its ipBlock.
|
|
130
|
+
- to:
|
|
131
|
+
- namespaceSelector: {}
|
|
132
|
+
# Every routable address, private ranges included; never metadata or link-local.
|
|
133
|
+
- to:
|
|
134
|
+
- ipBlock:
|
|
135
|
+
cidr: 0.0.0.0/0
|
|
136
|
+
except: [169.254.0.0/16]
|
|
137
|
+
- ipBlock:
|
|
138
|
+
cidr: ::/0
|
|
139
|
+
except: [fe80::/10, fd00:ec2::254/128, 64:ff9b::a9fe:a9fe/128]
|
|
109
140
|
|
|
110
141
|
# The scrape listener every serving role opens, on its own port and never the app's: the ingress
|
|
111
142
|
# routes / to web, so /metrics beside /healthz on 3000 is /metrics on the internet. This is
|
|
@@ -178,9 +209,7 @@ roles:
|
|
|
178
209
|
sync:
|
|
179
210
|
# OFF by default. A sync pod on a real database hears committed changes only from a replicator
|
|
180
211
|
# it can reach, and a fresh deploy has none: booted anyway it is refused (X_REALTIME_TOPOLOGY).
|
|
181
|
-
# To turn live queries and channels on:
|
|
182
|
-
# urlEnv: 'NATS_URL' } in app.config.ts (a NATS_URL under transport 'memory' is refused, and
|
|
183
|
-
# 'nats' without it is too); run NATS and set the SAME NATS_URL for web, sync and the
|
|
212
|
+
# To turn live queries and channels on: run NATS and set the SAME NATS_URL for web, sync and the
|
|
184
213
|
# replicator; enable exactly one replicator (below) against a Postgres started with
|
|
185
214
|
# wal_level=logical (the replicator creates its publication at boot) and a role with REPLICATION on a cluster dedicated to this app; then set this to true.
|
|
186
215
|
enabled: false
|