@ultimat3/cli 31.26.0 → 31.28.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 +47 -37
- package/README.md +19 -8
- package/package.json +29 -29
- package/src/app-manifest.ts +6 -1
- package/src/app-mcp.ts +17 -3
- package/src/cmd-cache-spec.ts +5 -2
- package/src/cmd-db-spec.ts +2 -3
- package/src/cmd-db.ts +0 -2
- package/src/cmd-deploy-verify-sample.ts +93 -0
- package/src/cmd-deploy-verify.ts +2 -41
- package/src/cmd-dev-spec.ts +15 -1
- package/src/cmd-dev.ts +31 -4
- package/src/cmd-doctor.ts +15 -4
- package/src/cmd-exercise-spec.ts +7 -1
- package/src/cmd-exercise.ts +22 -10
- package/src/cmd-generate.ts +2 -0
- package/src/cmd-jobs-spec.ts +3 -6
- package/src/cmd-jobs.ts +1 -7
- package/src/cmd-logs-spec.ts +2 -1
- package/src/cmd-logs.ts +9 -28
- package/src/cmd-planned.ts +11 -45
- package/src/cmd-profile-frames.ts +99 -0
- package/src/cmd-profile-spec.ts +24 -0
- package/src/cmd-profile.ts +164 -0
- package/src/cmd-repro-spec.ts +13 -1
- package/src/cmd-repro.ts +37 -5
- package/src/cmd-status-sample.ts +57 -0
- package/src/cmd-status-spec.ts +30 -0
- package/src/cmd-status.ts +108 -0
- package/src/cmd-token-spec.ts +5 -2
- package/src/cmd-token.ts +7 -3
- package/src/cmd-upgrade-codemods.ts +71 -0
- package/src/cmd-upgrade-spec.ts +19 -5
- package/src/cmd-upgrade.ts +91 -34
- package/src/codemods/agents-dev-mcp.ts +50 -0
- package/src/codemods/authenticator-session-refusal.ts +214 -0
- package/src/codemods/biome-no-default-export.ts +58 -0
- package/src/codemods/bunfig-island-coverage.ts +33 -0
- package/src/codemods/chart-dashboard.ts +73 -0
- package/src/codemods/ci-e2e-browser-stock.ts +75 -0
- package/src/codemods/ci-e2e-browser.ts +63 -0
- package/src/codemods/codemod.ts +58 -0
- package/src/codemods/define-error-leaf.ts +73 -0
- package/src/codemods/docs-ci-parts.ts +65 -0
- package/src/codemods/docs-gate-prose.ts +53 -0
- package/src/codemods/docs-island-rows.ts +31 -0
- package/src/codemods/docs-shipped-guards.ts +100 -0
- package/src/codemods/docs-test-services.ts +62 -0
- package/src/codemods/engine-diff.ts +104 -0
- package/src/codemods/engine-edits.ts +111 -0
- package/src/codemods/engine-fs.ts +95 -0
- package/src/codemods/engine.ts +191 -0
- package/src/codemods/format-edited-hook-3122.ts +28 -0
- package/src/codemods/format-edited-hook.ts +152 -0
- package/src/codemods/helm-alerts-objective.ts +105 -0
- package/src/codemods/helm-alerts-stock.ts +108 -0
- package/src/codemods/index.ts +56 -0
- package/src/codemods/metrics-probe-healthz.ts +47 -0
- package/src/codemods/pending.ts +36 -0
- package/src/codemods/repro-gitignore.ts +40 -0
- package/src/codemods/runtime-pin-lines.ts +109 -0
- package/src/codemods/runtime-pin.ts +116 -0
- package/src/codemods/solid-floor.ts +63 -0
- package/src/codemods/test-ports.ts +86 -0
- package/src/codemods/test-suites.ts +37 -0
- package/src/codemods/theme-toggle-mount-over.ts +70 -0
- package/src/codemods/vendored-guards.ts +186 -0
- package/src/codemods/verify-floor-skips.ts +88 -0
- package/src/codemods/verify-floor-steps.ts +90 -0
- package/src/coverage-island.ts +121 -0
- package/src/coverage-lcov.ts +49 -5
- package/src/coverage-remap.ts +146 -0
- package/src/db-replay-engine-prepared.ts +66 -0
- package/src/db-replay-engine-template.ts +156 -0
- package/src/db-replay-engine.ts +4 -0
- package/src/db-replay-scratch-reap.ts +54 -0
- package/src/deploy-verify-flags.ts +9 -2
- package/src/deploy-verify-grade.ts +10 -3
- package/src/dev-boot.ts +14 -1
- package/src/dev-dashboard-guard.ts +57 -10
- package/src/dev-host.ts +46 -0
- package/src/dev-tls-cache.ts +103 -0
- package/src/dev-tls-der.ts +69 -0
- package/src/dev-tls.ts +120 -0
- package/src/doctor-advisory-floors.ts +113 -0
- package/src/doctor-browser.ts +60 -0
- package/src/doctor-guards.ts +39 -86
- package/src/doctor-superseded.ts +67 -0
- package/src/error-codes-doctor.ts +12 -4
- package/src/error-codes-verify.ts +47 -0
- package/src/error-codes.ts +20 -23
- package/src/exercise-database.ts +47 -9
- package/src/exercise-push-device.ts +51 -0
- package/src/exercise-route-api.ts +74 -0
- package/src/exercise-routes.ts +14 -5
- package/src/exercise-services.ts +3 -1
- package/src/exercise-shard-flag.ts +47 -0
- package/src/fix-command.ts +2 -2
- package/src/generate-factories.ts +5 -11
- package/src/generate-feature-required.ts +9 -4
- package/src/generate-files.ts +26 -7
- package/src/generate-kinds.ts +5 -1
- package/src/guards-built-in-codes.ts +36 -0
- package/src/guards-built-in-refusal.ts +25 -0
- package/src/guards-built-in.ts +134 -0
- package/src/guards-materialize.ts +42 -0
- package/src/guards-paths.ts +37 -0
- package/src/guards-shipped-names.ts +38 -0
- package/src/guards-vendored.ts +73 -0
- package/src/guards.ts +105 -34
- package/src/index.ts +10 -0
- package/src/island-bundle-options.ts +48 -0
- package/src/island-bundle.ts +18 -46
- package/src/island-link.ts +5 -0
- package/src/island-outputs.ts +5 -0
- package/src/lint-findings.ts +3 -3
- package/src/mcp-errors-verify.ts +35 -0
- package/src/mcp-errors.ts +21 -20
- package/src/mcp-host-logs.ts +121 -0
- package/src/mcp-host.ts +12 -73
- package/src/measure-scope.ts +23 -3
- package/src/messages-floor.ts +19 -0
- package/src/messages-repro.ts +16 -2
- package/src/messages-status.ts +10 -0
- package/src/messages-upgrade.ts +15 -0
- package/src/messages.ts +22 -1
- package/src/registry.ts +4 -0
- package/src/repro-archive-collect.ts +161 -0
- package/src/repro-archive-write.ts +96 -0
- package/src/repro-archive.ts +161 -0
- package/src/repro-bundle.ts +8 -16
- package/src/repro-errors.ts +14 -2
- package/src/repro-framework.ts +53 -0
- package/src/repro-parse.ts +87 -0
- package/src/repro-redact.ts +218 -0
- package/src/repro-scrub.ts +257 -0
- package/src/role-start-types.ts +7 -0
- package/src/role-start.ts +4 -0
- package/src/serve-boot.ts +7 -1
- package/src/serve-env-tls.ts +57 -0
- package/src/solid-loader.ts +27 -10
- package/src/superseded-match.ts +87 -0
- package/src/superseded.ts +84 -0
- package/src/templates/bun-image.ts +48 -0
- package/src/templates/generate-export-rows.ts +136 -0
- package/src/templates/generate-import-rows.ts +186 -0
- package/src/templates/generate-rows-slice.ts +95 -0
- package/src/templates/github/ci.yml.ts +5 -1
- package/src/templates/guard-released-forms.ts +112 -0
- package/src/templates/guard-runtime-pin-test.ts +54 -0
- package/src/templates/guard-runtime-pin.ts +189 -0
- package/src/templates/scaffold-claude-agents.ts +6 -6
- package/src/templates/scaffold-claude-commands.ts +1 -1
- package/src/templates/scaffold-claude-hook.ts +18 -8
- package/src/templates/scaffold-claude.ts +2 -2
- package/src/templates/scaffold-db-package.ts +3 -0
- package/src/templates/scaffold-docs.ts +34 -30
- package/src/templates/scaffold-guards.ts +73 -39
- package/src/templates/scaffold-repo.ts +4 -8
- package/src/templates/scaffold-site.ts +4 -1
- package/src/templates/scaffold-suites.ts +72 -0
- package/src/templates/scaffold-test-services.ts +35 -10
- package/src/templates/scaffold-verify-floor.ts +53 -31
- package/src/templates/shapes/api.ts +4 -0
- package/src/templates/slice-foundation.ts +3 -3
- package/src/unthrown-codes.ts +3 -1
- package/src/upgrade-bun-floor.ts +4 -0
- package/src/upgrade-clean-tree.ts +54 -0
- package/src/upgrade-gate-codemods-install.ts +40 -0
- package/src/upgrade-gate-codemods.ts +151 -0
- package/src/upgrade-gate.ts +44 -7
- package/src/upgrade-guards-baseline.ts +43 -0
- package/src/upgrade-guards.ts +37 -2
- package/src/upgrade-lock.ts +118 -0
- package/src/upgrade-plan.ts +2 -1
- package/src/upgrade-report-codemods.ts +54 -0
- package/src/upgrade-report.ts +55 -27
- package/src/upgrade-signals.ts +91 -0
- package/src/upgrade-unfinished.ts +61 -0
- package/src/verify-coverage-run.ts +42 -11
- package/src/verify-e2e.ts +115 -4
- package/src/verify-floor.ts +27 -0
- package/src/verify-guard-baseline.ts +109 -0
- package/src/verify-live.ts +72 -0
- package/src/verify-merge-skips.ts +51 -0
- package/src/verify-merge.ts +36 -2
- package/src/verify-run.ts +48 -7
- package/src/verify-services.ts +287 -0
- package/src/verify-skip-reason.ts +53 -0
- package/src/verify-strict.ts +108 -0
- package/src/verify-test-command.ts +129 -0
- package/src/verify-tests.ts +39 -126
- package/types/babel-modules.d.ts +2 -0
- package/wiki/CLI-Reference.md +200 -27
- package/wiki/Caching-And-Invalidation.md +1 -1
- package/wiki/Entities-And-Migrations.md +1 -1
- package/wiki/Interface-Rules.md +17 -8
- package/wiki/Jobs-And-Workflows.md +3 -3
- package/wiki/Known-Gaps.md +5 -1
- package/wiki/MCP-And-AI.md +1 -1
- package/wiki/Observability.md +1 -0
- package/wiki/PWA-And-Offline.md +1 -1
- package/wiki/Project-Layout.md +4 -4
- package/wiki/Troubleshooting.md +3 -3
- package/wiki/Tutorial-05-Deploy-Free.md +2 -2
- package/wiki/Upgrading.md +8 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// The Bun image `x new` builds on, as a value: what the `runtime-pin` guard names in a fix and what
|
|
2
|
+
// the `runtime-pin` codemod moves an older app to. The Dockerfile template states the same image as
|
|
3
|
+
// literal text (scripts/bun-pin.test.ts reads that source), and bun-image.test.ts holds the two equal.
|
|
4
|
+
|
|
5
|
+
import { REQUIRED_BUN } from '../app-root';
|
|
6
|
+
|
|
7
|
+
export interface BunImage {
|
|
8
|
+
/** The exact Bun the digest was read from — `engines.bun`'s floor, the patch CI runs. */
|
|
9
|
+
readonly patch: string;
|
|
10
|
+
/** What the `FROM` tag names: the series, so the reader sees which line it follows. */
|
|
11
|
+
readonly series: string;
|
|
12
|
+
readonly variant: string;
|
|
13
|
+
readonly digest: string;
|
|
14
|
+
/** `oven/bun:<series>-<variant>@<digest>`, the text after `FROM`. */
|
|
15
|
+
readonly ref: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const series = REQUIRED_BUN.split('.').slice(0, 2).join('.');
|
|
19
|
+
const variant = 'alpine';
|
|
20
|
+
// `docker buildx imagetools inspect oven/bun:1.4.4-alpine` — moved together with REQUIRED_BUN.
|
|
21
|
+
const digest = 'sha256:4cf82f5686b196504fe119db3fcd9185b191f82ece82c40680e597228ec6070a';
|
|
22
|
+
|
|
23
|
+
export const SCAFFOLD_BUN_IMAGE: BunImage = {
|
|
24
|
+
patch: REQUIRED_BUN,
|
|
25
|
+
series,
|
|
26
|
+
variant,
|
|
27
|
+
digest,
|
|
28
|
+
ref: `oven/bun:${series}-${variant}@${digest}`,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Every digest a released scaffold's Dockerfile built on, by the exact Bun it was read from. The
|
|
33
|
+
* `FROM` tag names only the series, so this is how the framework reads back the patch of an image
|
|
34
|
+
* it wrote itself; any other digest was chosen or moved by the app. A bump moves the current row
|
|
35
|
+
* here as an earlier one.
|
|
36
|
+
*/
|
|
37
|
+
const DIGEST_PATCHES: Readonly<Record<string, string>> = {
|
|
38
|
+
// 27.10.3
|
|
39
|
+
'sha256:d888c0ae6c86d7866ff10c5aafdd9077b36aee6455b33dd270fb93c0dd5cef6f': '1.4.2',
|
|
40
|
+
// 28.0.0
|
|
41
|
+
'sha256:629e17411f1f129dbec3af78d5af9c9f2a937435c80349437206c6b0b7422373': '1.4.3',
|
|
42
|
+
// 29.0.0 onward
|
|
43
|
+
[digest]: REQUIRED_BUN,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/** The Bun patch a scaffold-written digest holds, or undefined for one no scaffold wrote. */
|
|
47
|
+
export const scaffoldDigestPatch = (sha: string): string | undefined =>
|
|
48
|
+
Object.hasOwn(DIGEST_PATCHES, sha) ? DIGEST_PATCHES[sha] : undefined;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// `x g export-rows` — one org's rows of the slice's table, streamed to storage a page at a time.
|
|
2
|
+
// `exportRows()` is a factory over `job()`, never a ninth primitive: the export is retried,
|
|
3
|
+
// resumed from its cursor, deduped per artifact and in the manifest like any job.
|
|
4
|
+
|
|
5
|
+
import type { RowsOptions } from './generate-rows-slice';
|
|
6
|
+
import { assertScaffoldRow, rowsTestHead } from './generate-rows-slice';
|
|
7
|
+
import { sortedImports } from './imports';
|
|
8
|
+
import type { GeneratedFile, NameSet } from './naming';
|
|
9
|
+
import { names } from './naming';
|
|
10
|
+
import { PLACEHOLDER_DB_MODULE } from './scaffold-db-client';
|
|
11
|
+
import { sliceFoundation } from './slice-foundation';
|
|
12
|
+
|
|
13
|
+
const source = (
|
|
14
|
+
name: NameSet,
|
|
15
|
+
feature: NameSet,
|
|
16
|
+
dbModule: string,
|
|
17
|
+
): string => `// ${name.camel}: one org's ${feature.plural}, as csv parts in storage. \`exportRows()\` is a
|
|
18
|
+
// factory over job(), so the export is retried, resumes from its cursor and is in the manifest.
|
|
19
|
+
// List this module in apps/web/api/index.ts's \`jobs:\` to register it.
|
|
20
|
+
|
|
21
|
+
${sortedImports([
|
|
22
|
+
"import { exportRows, t } from '@ultimat3/jobs';",
|
|
23
|
+
"import { disk } from '@ultimat3/storage';",
|
|
24
|
+
`import { db } from '${dbModule}';`,
|
|
25
|
+
])}
|
|
26
|
+
import type { ${feature.pascal} } from '../entity';
|
|
27
|
+
|
|
28
|
+
/** The columns, in order: the csv header, and the only keys a row may answer. */
|
|
29
|
+
export const ${name.camel}Columns = ['id', 'title', 'priceMinor', 'priceCurrency', 'createdAt'];
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* One row's cells. Money as its integer minor units beside its currency, never a float; a date
|
|
33
|
+
* as a UTC instant, never a zone-less format. Add a column here and in the list above together.
|
|
34
|
+
*/
|
|
35
|
+
export const ${name.camel}Row = (row: ${feature.pascal}) => ({
|
|
36
|
+
id: row.id,
|
|
37
|
+
title: row.title,
|
|
38
|
+
priceMinor: row.price.minor,
|
|
39
|
+
priceCurrency: row.price.currency,
|
|
40
|
+
createdAt: row.createdAt.toISOString(),
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export const ${name.camel} = exportRows({
|
|
44
|
+
// Pinned: the queue row, the step trace and every part's step carry this name.
|
|
45
|
+
name: '${name.kebab}',
|
|
46
|
+
input: t.object({ orgId: t.uuid, exportId: t.string }),
|
|
47
|
+
// The security boundary: an export concentrates one org's rows into one downloadable object,
|
|
48
|
+
// so the run is scoped to the org its input names — and the read below to the same org.
|
|
49
|
+
tenant: ({ orgId }) => orgId,
|
|
50
|
+
prefix: ({ orgId, exportId }) => \`exports/${name.kebab}/\${orgId}/\${exportId}\`,
|
|
51
|
+
source: ({ input }) => db.${feature.plural}.where({ orgId: input.orgId }),
|
|
52
|
+
format: 'csv',
|
|
53
|
+
columns: ${name.camel}Columns,
|
|
54
|
+
row: ${name.camel}Row,
|
|
55
|
+
// A thunk, read per write: the app's disks exist after boot, never at import.
|
|
56
|
+
sink: () => disk(),
|
|
57
|
+
});
|
|
58
|
+
`;
|
|
59
|
+
|
|
60
|
+
const jobSuite = (
|
|
61
|
+
name: NameSet,
|
|
62
|
+
): string => `// ${name.camel}'s durable identity: a job, one live pass per artifact. The pass itself — the rows it
|
|
63
|
+
// writes and the org it keeps to — is the unit suite's, next door.
|
|
64
|
+
|
|
65
|
+
import { memoryJobDriver } from '@ultimat3/jobs';
|
|
66
|
+
import { beforeAll, expect, jobTest, swapAdapter } from '@ultimat3/testing';
|
|
67
|
+
import { ${name.camel} } from './${name.kebab}';
|
|
68
|
+
|
|
69
|
+
// The queue is a process-global adapter port, so it is swapped for this file and put back after.
|
|
70
|
+
beforeAll(() => swapAdapter('jobs', memoryJobDriver()));
|
|
71
|
+
|
|
72
|
+
const input = { orgId: '00000000-0000-4000-8000-000000000002', exportId: 'weekly' };
|
|
73
|
+
|
|
74
|
+
jobTest('is a job scoped to the org its input names', () => {
|
|
75
|
+
expect(${name.camel}.kind).toBe('job');
|
|
76
|
+
expect(${name.camel}.tenantFor(input)).toBe(input.orgId);
|
|
77
|
+
expect(${name.camel}.retry.attempts).toBeGreaterThan(1);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
jobTest('enqueues once per artifact, and dedupes a second while one is live', async () => {
|
|
81
|
+
const first = await ${name.camel}.enqueue(input);
|
|
82
|
+
expect(first.deduped).toBe(false);
|
|
83
|
+
const again = await ${name.camel}.enqueue(input);
|
|
84
|
+
expect(again.deduped).toBe(true);
|
|
85
|
+
});
|
|
86
|
+
`;
|
|
87
|
+
|
|
88
|
+
const unitSuite = (
|
|
89
|
+
name: NameSet,
|
|
90
|
+
feature: NameSet,
|
|
91
|
+
dbModule: string,
|
|
92
|
+
): string => `// ${name.camel}, RUN: one pass by a worker in this process, over rows in the in-memory driver, into
|
|
93
|
+
// a memory disk. What is worth failing on: the header, one org's rows and never another's.
|
|
94
|
+
${rowsTestHead(name, feature, dbModule, [name.camel, `${name.camel}Row`])}
|
|
95
|
+
const partText = async (orgId: string, exportId: string): Promise<string> => {
|
|
96
|
+
const read = await disk.get(\`exports/${name.kebab}/\${orgId}/\${exportId}/part-00000.csv\`);
|
|
97
|
+
return new TextDecoder().decode(read.bytes);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
unitTest('one pass writes the org rows as csv, and no other org', async ({ runJobs }) => {
|
|
101
|
+
await store(orgA, 'ours');
|
|
102
|
+
await store(orgB, 'theirs');
|
|
103
|
+
const trace = await runJobs(${name.camel}, { orgId: orgA, exportId: 'weekly' });
|
|
104
|
+
expect(trace.executions.map((run) => run.outcome)).toEqual(['completed']);
|
|
105
|
+
const text = await partText(orgA, 'weekly');
|
|
106
|
+
expect(text.split('\\n')[0]).toBe('id,title,priceMinor,priceCurrency,createdAt');
|
|
107
|
+
expect(text).toContain('ours,1250,USD');
|
|
108
|
+
expect(text).not.toContain('theirs');
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
unitTest('a row is its cells: integer minor units, its currency, a UTC instant', async () => {
|
|
112
|
+
const stored = await store(orgA, 'one');
|
|
113
|
+
expect(${name.camel}Row(stored)).toEqual({
|
|
114
|
+
id: stored.id,
|
|
115
|
+
title: 'one',
|
|
116
|
+
priceMinor: 1250,
|
|
117
|
+
priceCurrency: 'USD',
|
|
118
|
+
createdAt: stored.createdAt.toISOString(),
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
`;
|
|
122
|
+
|
|
123
|
+
/** The export and its job/unit suites in the feature's `jobs/`, the entity planted when absent. */
|
|
124
|
+
export function exportRowsFiles(rawName: string, target: RowsOptions): readonly GeneratedFile[] {
|
|
125
|
+
const name = names(rawName);
|
|
126
|
+
const feature = names(target.feature);
|
|
127
|
+
assertScaffoldRow('export-rows', name, target);
|
|
128
|
+
const dir = `${target.surfaceDir}/${target.feature}/jobs`;
|
|
129
|
+
const dbModule = target.dbModule ?? PLACEHOLDER_DB_MODULE;
|
|
130
|
+
return [
|
|
131
|
+
...sliceFoundation(target, ['entity'], target.locales),
|
|
132
|
+
{ path: `${dir}/${name.kebab}.ts`, contents: source(name, feature, dbModule) },
|
|
133
|
+
{ path: `${dir}/${name.kebab}.job.test.ts`, contents: jobSuite(name) },
|
|
134
|
+
{ path: `${dir}/${name.kebab}.test.ts`, contents: unitSuite(name, feature, dbModule) },
|
|
135
|
+
];
|
|
136
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
// `x g import-rows` — an uploaded csv read a page at a time, through a schema, into the slice's
|
|
2
|
+
// table. `importRows()` is a factory over `job()`, never a ninth primitive: a killed attempt
|
|
3
|
+
// resumes at its byte offset, and a refused row is reported by line, never by value.
|
|
4
|
+
|
|
5
|
+
import type { ExerciseEntry } from '../exercise-entry-edit';
|
|
6
|
+
import type { RowsOptions } from './generate-rows-slice';
|
|
7
|
+
import { assertScaffoldRow, rowsTestHead } from './generate-rows-slice';
|
|
8
|
+
import { sortedImports } from './imports';
|
|
9
|
+
import type { GeneratedFile, NameSet } from './naming';
|
|
10
|
+
import { names } from './naming';
|
|
11
|
+
import { PLACEHOLDER_DB_MODULE } from './scaffold-db-client';
|
|
12
|
+
import { sliceFoundation } from './slice-foundation';
|
|
13
|
+
|
|
14
|
+
const source = (
|
|
15
|
+
name: NameSet,
|
|
16
|
+
feature: NameSet,
|
|
17
|
+
dbModule: string,
|
|
18
|
+
): string => `// ${name.camel}: an uploaded csv of ${feature.plural}, into one org's rows. \`importRows()\` is a
|
|
19
|
+
// factory over job(), so a killed attempt resumes at its byte offset and the run is in the manifest.
|
|
20
|
+
// List this module in apps/web/api/index.ts's \`jobs:\` to register it.
|
|
21
|
+
|
|
22
|
+
${sortedImports([
|
|
23
|
+
"import { importRows, t } from '@ultimat3/jobs';",
|
|
24
|
+
"import { disk } from '@ultimat3/storage';",
|
|
25
|
+
`import { db } from '${dbModule}';`,
|
|
26
|
+
])}
|
|
27
|
+
|
|
28
|
+
/** Where one org's uploads for this import sit: the only keys an import for that org may read. */
|
|
29
|
+
export const ${name.camel}Prefix = (orgId: string): string => \`imports/${name.kebab}/\${orgId}/\`;
|
|
30
|
+
|
|
31
|
+
export const ${name.camel} = importRows({
|
|
32
|
+
// Pinned: the queue row, the step trace and every page's step carry this name.
|
|
33
|
+
name: '${name.kebab}',
|
|
34
|
+
// A pointer to the upload, never its rows. The key is the CALLER'S, so it is held to the org the
|
|
35
|
+
// run is scoped to: \`tenant\` scopes the writes, and nothing else stops an import reading
|
|
36
|
+
// another org's upload into this one. The run's dedupe key is the upload key, so it is per org.
|
|
37
|
+
input: t.object({ orgId: t.uuid, key: t.string }).refine({
|
|
38
|
+
name: 'key-in-own-org',
|
|
39
|
+
message: 'key must sit under imports/${name.kebab}/<orgId>/ for the orgId this import names',
|
|
40
|
+
check: ({ orgId, key }) => key.startsWith(${name.camel}Prefix(orgId)) && !key.includes('..'),
|
|
41
|
+
path: ['key'],
|
|
42
|
+
}),
|
|
43
|
+
// The org the rows are written under is the input's: a scoped write fails closed without it.
|
|
44
|
+
tenant: ({ orgId }) => orgId,
|
|
45
|
+
// Thunks, read per page: the app's disks exist after boot, never at import.
|
|
46
|
+
source: () => disk(),
|
|
47
|
+
key: ({ key }) => key,
|
|
48
|
+
format: 'csv',
|
|
49
|
+
// The header must name exactly these, in any order.
|
|
50
|
+
columns: ['id', 'title', 'priceMinor', 'priceCurrency'],
|
|
51
|
+
// A row that fails this is reported by line and rule in the errors part, never by its value.
|
|
52
|
+
schema: t.object({
|
|
53
|
+
id: t.uuid,
|
|
54
|
+
title: t.string,
|
|
55
|
+
priceMinor: t.number.int(),
|
|
56
|
+
priceCurrency: t.string,
|
|
57
|
+
}),
|
|
58
|
+
// At least once per page, so the write is idempotent: a replayed row collides on its primary
|
|
59
|
+
// key and \`onMatch: 'nothing'\` writes nothing — never a row of another org.
|
|
60
|
+
handle: async ({ rows, input }) => {
|
|
61
|
+
await db.${feature.plural}.upsertAll(
|
|
62
|
+
rows.map((row) => ({
|
|
63
|
+
id: row.id,
|
|
64
|
+
orgId: input.orgId,
|
|
65
|
+
title: row.title,
|
|
66
|
+
price: { minor: row.priceMinor, currency: row.priceCurrency },
|
|
67
|
+
})),
|
|
68
|
+
{ onConflict: ['id'], onMatch: 'nothing' },
|
|
69
|
+
);
|
|
70
|
+
},
|
|
71
|
+
errors: { sink: () => disk(), prefix: ({ orgId }) => \`imports/${name.kebab}/\${orgId}/errors\` },
|
|
72
|
+
});
|
|
73
|
+
`;
|
|
74
|
+
|
|
75
|
+
const jobSuite = (
|
|
76
|
+
name: NameSet,
|
|
77
|
+
): string => `// ${name.camel}'s durable identity: a job scoped to the org its input names. The pass itself —
|
|
78
|
+
// the rows it writes and the rows it refuses — is the unit suite's, next door.
|
|
79
|
+
|
|
80
|
+
import { memoryJobDriver } from '@ultimat3/jobs';
|
|
81
|
+
import { beforeAll, expect, jobTest, swapAdapter } from '@ultimat3/testing';
|
|
82
|
+
import { ${name.camel} } from './${name.kebab}';
|
|
83
|
+
|
|
84
|
+
// The queue is a process-global adapter port, so it is swapped for this file and put back after.
|
|
85
|
+
beforeAll(() => swapAdapter('jobs', memoryJobDriver()));
|
|
86
|
+
|
|
87
|
+
const orgId = '00000000-0000-4000-8000-000000000002';
|
|
88
|
+
const input = { orgId, key: \`imports/${name.kebab}/\${orgId}/one.csv\` };
|
|
89
|
+
|
|
90
|
+
jobTest('is a job scoped to the org its input names', () => {
|
|
91
|
+
expect(${name.camel}.kind).toBe('job');
|
|
92
|
+
expect(${name.camel}.tenantFor(input)).toBe(input.orgId);
|
|
93
|
+
expect(${name.camel}.retry.attempts).toBeGreaterThan(1);
|
|
94
|
+
});
|
|
95
|
+
`;
|
|
96
|
+
|
|
97
|
+
const unitSuite = (
|
|
98
|
+
name: NameSet,
|
|
99
|
+
feature: NameSet,
|
|
100
|
+
dbModule: string,
|
|
101
|
+
): string => `// ${name.camel}, RUN: one pass by a worker in this process, from a memory disk into the in-memory
|
|
102
|
+
// driver. What is worth failing on: rows land under the input's org, a bad row is refused by line,
|
|
103
|
+
// and a replay writes nothing twice.
|
|
104
|
+
${rowsTestHead(name, feature, dbModule, [name.camel, `${name.camel}Prefix`])}
|
|
105
|
+
const idA = '00000000-0000-4000-8000-0000000000a1';
|
|
106
|
+
const idB = '00000000-0000-4000-8000-0000000000b2';
|
|
107
|
+
|
|
108
|
+
const upload = (key: string, lines: readonly string[]) =>
|
|
109
|
+
disk.put(key, new TextEncoder().encode(\`\${lines.join('\\n')}\\n\`));
|
|
110
|
+
|
|
111
|
+
/** An upload key under \`orgId\`'s own prefix: the only kind an import for that org may read. */
|
|
112
|
+
const keyOf = (orgId: string, file: string): string => \`\${${name.camel}Prefix(orgId)}\${file}\`;
|
|
113
|
+
|
|
114
|
+
const titlesOf = (orgId: string): Promise<readonly string[]> =>
|
|
115
|
+
inOrg(orgId, async () => (await db.${feature.plural}.all()).map((row) => row.title).toSorted());
|
|
116
|
+
|
|
117
|
+
unitTest('writes the valid rows under the input org, refuses the rest', async ({ runJobs }) => {
|
|
118
|
+
await upload(keyOf(orgA, 'one.csv'), [
|
|
119
|
+
'id,title,priceMinor,priceCurrency',
|
|
120
|
+
\`\${idA},first,1250,USD\`,
|
|
121
|
+
'not-a-uuid,second,1,USD',
|
|
122
|
+
\`\${idB},third,0,EUR\`,
|
|
123
|
+
]);
|
|
124
|
+
const trace = await runJobs(${name.camel}, { orgId: orgA, key: keyOf(orgA, 'one.csv') });
|
|
125
|
+
expect(trace.executions.map((run) => run.outcome)).toEqual(['completed']);
|
|
126
|
+
expect(trace.executions[0]?.result).toMatchObject({ rows: 2, rejected: 1 });
|
|
127
|
+
expect(await titlesOf(orgA)).toEqual(['first', 'third']);
|
|
128
|
+
expect(await titlesOf(orgB)).toEqual([]);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
unitTest('a replayed upload writes nothing twice', async ({ runJobs }) => {
|
|
132
|
+
await store(orgA, 'existing');
|
|
133
|
+
const key = keyOf(orgA, 'again.csv');
|
|
134
|
+
await upload(key, ['id,title,priceMinor,priceCurrency', \`\${idA},once,1,USD\`]);
|
|
135
|
+
await runJobs(${name.camel}, { orgId: orgA, key });
|
|
136
|
+
await runJobs(${name.camel}, { orgId: orgA, key });
|
|
137
|
+
expect(await titlesOf(orgA)).toEqual(['existing', 'once']);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
// The key is the caller's: an import for org A naming org B's upload is refused at the input,
|
|
141
|
+
// before a byte is read — so B's rows never land under A, and whether B's object exists is not said.
|
|
142
|
+
unitTest('another org upload is refused at the input, and nothing is read', async ({ runJobs }) => {
|
|
143
|
+
await upload(keyOf(orgB, 'theirs.csv'), ['id,title,priceMinor,priceCurrency', \`\${idB},b,1,USD\`]);
|
|
144
|
+
const theirs = keyOf(orgB, 'theirs.csv');
|
|
145
|
+
for (const key of [theirs, \`\${keyOf(orgA, '..')}/\${orgB}/theirs.csv\`]) {
|
|
146
|
+
const [run] = (await runJobs(${name.camel}, { orgId: orgA, key })).executions;
|
|
147
|
+
// Terminal on its first attempt, with no step run: the object was never opened.
|
|
148
|
+
expect(run?.outcome).toBe('dead-lettered');
|
|
149
|
+
expect(run?.code).toBe('X_VALIDATION_FAILED');
|
|
150
|
+
expect(run?.steps).toEqual([]);
|
|
151
|
+
}
|
|
152
|
+
expect(await titlesOf(orgA)).toEqual([]);
|
|
153
|
+
});
|
|
154
|
+
`;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* The job's entry in `apps/web/exercise.ts`: off, with its why. A draw names an upload key no
|
|
158
|
+
* object sits at, and the pass seeds no storage — so the run is proven in its unit suite instead.
|
|
159
|
+
*/
|
|
160
|
+
const exerciseEntry = (name: NameSet): ExerciseEntry => ({
|
|
161
|
+
name: name.kebab,
|
|
162
|
+
value: [
|
|
163
|
+
'{',
|
|
164
|
+
` off: 'reads an uploaded object, and the exercise pass seeds no storage — the whole pass runs in jobs/${name.kebab}.test.ts against a memory disk',`,
|
|
165
|
+
'}',
|
|
166
|
+
].join('\n'),
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
/** The import and its job/unit suites in the feature's `jobs/`, the entity planted when absent. */
|
|
170
|
+
export function importRowsFiles(rawName: string, target: RowsOptions): readonly GeneratedFile[] {
|
|
171
|
+
const name = names(rawName);
|
|
172
|
+
const feature = names(target.feature);
|
|
173
|
+
assertScaffoldRow('import-rows', name, target);
|
|
174
|
+
const dir = `${target.surfaceDir}/${target.feature}/jobs`;
|
|
175
|
+
const dbModule = target.dbModule ?? PLACEHOLDER_DB_MODULE;
|
|
176
|
+
return [
|
|
177
|
+
...sliceFoundation(target, ['entity'], target.locales),
|
|
178
|
+
{
|
|
179
|
+
path: `${dir}/${name.kebab}.ts`,
|
|
180
|
+
contents: source(name, feature, dbModule),
|
|
181
|
+
exercise: exerciseEntry(name),
|
|
182
|
+
},
|
|
183
|
+
{ path: `${dir}/${name.kebab}.job.test.ts`, contents: jobSuite(name) },
|
|
184
|
+
{ path: `${dir}/${name.kebab}.test.ts`, contents: unitSuite(name, feature, dbModule) },
|
|
185
|
+
];
|
|
186
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// What `x g export-rows` and `x g import-rows` share: both move the slice's OWN scaffolded table
|
|
2
|
+
// (`db.<plural>`, its `title` and `price`) through storage, so a slice whose entity is shaped
|
|
3
|
+
// otherwise is refused before a file is planned, and the test helpers are spelled once.
|
|
4
|
+
|
|
5
|
+
import { stripComments, UltimateError } from '@ultimat3/core';
|
|
6
|
+
import type { FeatureTarget } from './entity';
|
|
7
|
+
import { sortedImports } from './imports';
|
|
8
|
+
import type { NameSet } from './naming';
|
|
9
|
+
import { sliceTakesScaffoldRow } from './slice-foundation';
|
|
10
|
+
import { wrapImport } from './wrap';
|
|
11
|
+
|
|
12
|
+
/** The slice's files as `x g` read them off the disk: absent when the feature has none yet. */
|
|
13
|
+
export interface RowsOptions extends FeatureTarget {
|
|
14
|
+
readonly locales?: readonly string[];
|
|
15
|
+
readonly sliceEntity?: string;
|
|
16
|
+
readonly sliceRepo?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Declared beside its two throwers' shared check: `errors.ts` sits at its ceiling. */
|
|
20
|
+
export class RowsSliceEntityError extends UltimateError {
|
|
21
|
+
constructor(input: {
|
|
22
|
+
readonly kind: string;
|
|
23
|
+
readonly name: string;
|
|
24
|
+
readonly feature: string;
|
|
25
|
+
readonly tables: readonly string[];
|
|
26
|
+
}) {
|
|
27
|
+
const declared = input.tables.length === 0 ? 'no table' : input.tables.join(', ');
|
|
28
|
+
super({
|
|
29
|
+
code: 'X_ROWS_SLICE_ENTITY',
|
|
30
|
+
cause: `x g ${input.kind} moves the ${input.feature} slice's own scaffolded table, and its entity.ts declares ${declared} instead — the generated columns would name fields that table does not have`,
|
|
31
|
+
fix: `x g job ${input.name} --feature ${input.feature} # then declare ${input.kind === 'export-rows' ? 'exportRows' : 'importRows'}({ … }) from @ultimat3/jobs in it over db.<one of: ${declared}>`,
|
|
32
|
+
meta: { feature: input.feature, tables: [...input.tables] },
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Every table an `entity.ts` declares, in source order. */
|
|
38
|
+
const declaredTables = (source: string): readonly string[] =>
|
|
39
|
+
[...stripComments(source).matchAll(/\bentity\(\s*['"]([^'"]+)['"]/g)].map(
|
|
40
|
+
(match) => match[1] ?? '',
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
/** Refuses a slice whose entity is not the scaffolded row; a slice with none gets it planted. */
|
|
44
|
+
export function assertScaffoldRow(kind: string, name: NameSet, target: RowsOptions): void {
|
|
45
|
+
if (target.sliceEntity === undefined) return;
|
|
46
|
+
if (sliceTakesScaffoldRow(target, target.sliceEntity, target.sliceRepo)) return;
|
|
47
|
+
throw new RowsSliceEntityError({
|
|
48
|
+
kind,
|
|
49
|
+
name: name.kebab,
|
|
50
|
+
feature: target.feature,
|
|
51
|
+
tables: declaredTables(target.sliceEntity),
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** The unit suite's head: two orgs, a memory disk installed per test, both torn down after. */
|
|
56
|
+
export const rowsTestHead = (
|
|
57
|
+
name: NameSet,
|
|
58
|
+
feature: NameSet,
|
|
59
|
+
dbModule: string,
|
|
60
|
+
bindings: readonly string[] = [name.camel],
|
|
61
|
+
): string => `${sortedImports([
|
|
62
|
+
"import { ctxOf, runWithContext } from '@ultimat3/core';",
|
|
63
|
+
"import { testActor } from '@ultimat3/policy';",
|
|
64
|
+
"import { defineStorage, memoryStorageDriver, resetStorage } from '@ultimat3/storage';",
|
|
65
|
+
"import { afterEach, beforeEach, expect, unitTest } from '@ultimat3/testing';",
|
|
66
|
+
`import { db, driver } from '${dbModule}';`,
|
|
67
|
+
])}
|
|
68
|
+
import type { ${feature.pascal} } from '../entity';
|
|
69
|
+
${wrapImport(bindings, `./${name.kebab}`)}
|
|
70
|
+
|
|
71
|
+
const orgA = '00000000-0000-4000-8000-000000000002';
|
|
72
|
+
const orgB = '00000000-0000-4000-8000-000000000009';
|
|
73
|
+
|
|
74
|
+
/** What a request is to the handle: an actor, whose org every read and write runs under. */
|
|
75
|
+
const inOrg = <T>(orgId: string, run: () => Promise<T>): Promise<T> =>
|
|
76
|
+
runWithContext(ctxOf({ actor: testActor('member', { orgId }).actor }), run);
|
|
77
|
+
|
|
78
|
+
const store = (orgId: string, title: string): Promise<${feature.pascal}> => {
|
|
79
|
+
const draft = { orgId, title, price: { minor: 1250, currency: 'USD' } };
|
|
80
|
+
return inOrg(orgId, () => db.${feature.plural}.insert(draft));
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
// A memory disk per test, installed as the app's storage: the job resolves \`disk()\` per page.
|
|
84
|
+
let disk = memoryStorageDriver();
|
|
85
|
+
beforeEach(() => {
|
|
86
|
+
disk = memoryStorageDriver();
|
|
87
|
+
defineStorage({ disks: { local: disk } });
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// One store per process: without this, one test's rows and objects are the next test's fixtures.
|
|
91
|
+
afterEach(() => {
|
|
92
|
+
driver.reset?.();
|
|
93
|
+
resetStorage();
|
|
94
|
+
});
|
|
95
|
+
`;
|
|
@@ -23,7 +23,7 @@ const CI_WORKFLOW_NAME = 'ci';
|
|
|
23
23
|
* instead: GitHub owns the runner and the tag together. Same rule the framework's own
|
|
24
24
|
* `.github/actions/setup/action.yml` states, and the same SHA.
|
|
25
25
|
*/
|
|
26
|
-
const SETUP_BUN = 'oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0';
|
|
26
|
+
export const SETUP_BUN = 'oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0';
|
|
27
27
|
|
|
28
28
|
/** The plan job's one command: the app's `verify` script, so the CLI it asks is the one installed. */
|
|
29
29
|
export const PLAN_COMMAND = `bun run verify plan --parts ${String(DEFAULT_PLAN_PARTS)} --json`;
|
|
@@ -125,6 +125,10 @@ ${SETUP_STEPS}
|
|
|
125
125
|
run: |
|
|
126
126
|
docker compose -f ${TEST_COMPOSE_PATH} up -d --wait
|
|
127
127
|
cat ${TEST_ENV_PATH} >> "$GITHUB_ENV"
|
|
128
|
+
# ubuntu-latest ships Chrome, and the \`e2e\` step finds it. Required here, so a runner that
|
|
129
|
+
# has none (a \`CI_RUNNER\` label) is red with the command that locates one — never a skip.
|
|
130
|
+
- if: contains(matrix.only, 'e2e')
|
|
131
|
+
run: echo "E2E_BROWSER_REQUIRED=1" >> "$GITHUB_ENV"
|
|
128
132
|
# Under $RUNNER_TEMP, never in the checkout, where \`lint\` would walk the open file.
|
|
129
133
|
- env:
|
|
130
134
|
PART: \${{ matrix.part }}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// GENERATED by `bun run scripts/lib/guard-refresh-forms.ts --write` — never hand-edited. Every
|
|
2
|
+
// rule-file text each shipped guard was released as (`guardFormHash`), with how it reported, so the
|
|
3
|
+
// `vendored-guards` codemod deletes a stale but unedited copy instead of keeping it as an edit.
|
|
4
|
+
|
|
5
|
+
export const RELEASED_GUARD_FORMS: Readonly<
|
|
6
|
+
Record<string, readonly (readonly [string, 'error' | 'warning'])[]>
|
|
7
|
+
> = {
|
|
8
|
+
'animated-layout-property': [['2hqr04589t23q', 'error']],
|
|
9
|
+
'bare-error': [
|
|
10
|
+
['1m3eimglwzrdq', 'error'],
|
|
11
|
+
['1njzso3r6drnd', 'error'],
|
|
12
|
+
],
|
|
13
|
+
'error-declared': [
|
|
14
|
+
['1rlzex7nalpiw', 'error'],
|
|
15
|
+
['2tfw2hq80msju', 'error'],
|
|
16
|
+
['3kqd7d8pzpcnn', 'error'],
|
|
17
|
+
],
|
|
18
|
+
'focus-visible': [['4c2nf0mpzn0z', 'error']],
|
|
19
|
+
'image-dimensions': [
|
|
20
|
+
['1cfzth883qzt5', 'error'],
|
|
21
|
+
['33uv2ua4a9zcf', 'error'],
|
|
22
|
+
],
|
|
23
|
+
'island-mount-clears': [['1v09h5ptzqvs2', 'error']],
|
|
24
|
+
'island-without-states': [['2os1f5fb6aass', 'error']],
|
|
25
|
+
'native-confirm': [
|
|
26
|
+
['1f7eh34hj085a', 'error'],
|
|
27
|
+
['2b134wpkoaqso', 'error'],
|
|
28
|
+
['2eb7ld3hg0tpb', 'error'],
|
|
29
|
+
],
|
|
30
|
+
'raw-breakpoint': [['wdo3lsqmvsya', 'error']],
|
|
31
|
+
'raw-colour': [['3onnbx54g9zmd', 'error']],
|
|
32
|
+
'raw-fetch': [
|
|
33
|
+
['17xdeprvzx5v2', 'error'],
|
|
34
|
+
['1hgdwthi7j353', 'error'],
|
|
35
|
+
['mazudnz7t6iy', 'error'],
|
|
36
|
+
],
|
|
37
|
+
'raw-interval': [
|
|
38
|
+
['1o6p0fmjhzdhw', 'error'],
|
|
39
|
+
['2xrqszz066coc', 'error'],
|
|
40
|
+
['3qipy7ijjnz7r', 'error'],
|
|
41
|
+
['ll7h7zpr075u', 'error'],
|
|
42
|
+
],
|
|
43
|
+
'raw-length': [['2vfl0ssvkqvua', 'error']],
|
|
44
|
+
'raw-motion': [
|
|
45
|
+
['14c1bs20ysc1u', 'error'],
|
|
46
|
+
['w8aw0q20tfsz', 'error'],
|
|
47
|
+
],
|
|
48
|
+
'raw-shadow': [['1vhy6xulc5cs5', 'error']],
|
|
49
|
+
'raw-z-index': [['2nnuj62o3qvvr', 'error']],
|
|
50
|
+
'repo-await-in-loop': [['3a3v6vvmbf8q2', 'warning']],
|
|
51
|
+
'repo-raw-sql': [
|
|
52
|
+
['12qj02j416sib', 'error'],
|
|
53
|
+
['2kr7gbv7j2m0v', 'error'],
|
|
54
|
+
['3nmlelym16o78', 'error'],
|
|
55
|
+
],
|
|
56
|
+
'repo-unbounded': [
|
|
57
|
+
['2yjuyaj4n8dqq', 'error'],
|
|
58
|
+
['ae4czielms3c', 'warning'],
|
|
59
|
+
],
|
|
60
|
+
'runtime-pin': [['28ffbpwy4q2ji', 'error']],
|
|
61
|
+
'semantic-interactive': [
|
|
62
|
+
['29pfa4ea628cv', 'error'],
|
|
63
|
+
['d4ncwu39wtrk', 'error'],
|
|
64
|
+
],
|
|
65
|
+
'unbounded-fanout': [['xk4dv9vsq8gg', 'error']],
|
|
66
|
+
'undeclared-custom-property': [
|
|
67
|
+
['2xnl4zuy9xv6f', 'error'],
|
|
68
|
+
['3b0u9i8hze00x', 'error'],
|
|
69
|
+
],
|
|
70
|
+
'undefined-style-class': [
|
|
71
|
+
['3food9t4vrzv8', 'error'],
|
|
72
|
+
['w7as1ib1ido8', 'error'],
|
|
73
|
+
],
|
|
74
|
+
'untranslated-string': [
|
|
75
|
+
['2x85ib5eqdxzi', 'error'],
|
|
76
|
+
['h57qtdwn7inz', 'error'],
|
|
77
|
+
],
|
|
78
|
+
'unzoned-date': [
|
|
79
|
+
['8apjndc5ybvm', 'error'],
|
|
80
|
+
['haaxmgzsgjns', 'error'],
|
|
81
|
+
],
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/** Every hash each shipped guard's TEST file was released as: an unedited test goes without a note. */
|
|
85
|
+
export const RELEASED_GUARD_TEST_FORMS: Readonly<Record<string, readonly string[]>> = {
|
|
86
|
+
'animated-layout-property': ['191zjn08f13h4'],
|
|
87
|
+
'bare-error': ['1w7vwbtypxdwe'],
|
|
88
|
+
'error-declared': ['2hj2bs2czhxnw', 'qe8afpq7pzf1'],
|
|
89
|
+
'focus-visible': ['12c0rk3ljkx6q'],
|
|
90
|
+
'image-dimensions': ['3p4hkambgpb4j'],
|
|
91
|
+
'island-mount-clears': ['2jkeu60fnvtdg'],
|
|
92
|
+
'island-without-states': ['vls0ujdd16gw'],
|
|
93
|
+
'native-confirm': ['1c7vps5wn37uv', 'qwyn1mzn9ace'],
|
|
94
|
+
'raw-breakpoint': ['w356i8dreh7j'],
|
|
95
|
+
'raw-colour': ['1tc7cambk8byr'],
|
|
96
|
+
'raw-fetch': ['2lips924uo00f'],
|
|
97
|
+
'raw-interval': ['1z55givy4sst0'],
|
|
98
|
+
'raw-length': ['1hpgz9jowk5qu'],
|
|
99
|
+
'raw-motion': ['6420344uhv97', 'g6cs0de9jmr7'],
|
|
100
|
+
'raw-shadow': ['3kg8ft6y3ia0y'],
|
|
101
|
+
'raw-z-index': ['3fb40f6bwp8kq'],
|
|
102
|
+
'repo-await-in-loop': ['2axgbb82wldt4'],
|
|
103
|
+
'repo-raw-sql': ['c5pfl8w3qj94', 'f19j7irkta44'],
|
|
104
|
+
'repo-unbounded': ['98ncw525gpmo'],
|
|
105
|
+
'runtime-pin': ['dy20fh65qziz'],
|
|
106
|
+
'semantic-interactive': ['2uh0p6xoh996t', '393msxyy1bz36'],
|
|
107
|
+
'unbounded-fanout': ['key86lol3wnh'],
|
|
108
|
+
'undeclared-custom-property': ['30bi2v92swukf', 'svuf8sm14fm8'],
|
|
109
|
+
'undefined-style-class': ['1uy88gpk5k8p8', '2sy8me3i3bmzw'],
|
|
110
|
+
'untranslated-string': ['30q3u45cey2eq'],
|
|
111
|
+
'unzoned-date': ['1siep3fqscks4', '20x6l238r09jk'],
|
|
112
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// The test `x new` writes beside the `runtime-pin` guard: the rule's own cases, run in the app.
|
|
2
|
+
// Split from `guard-runtime-pin.ts` at the file target; the code and the image are handed in.
|
|
3
|
+
|
|
4
|
+
import { SCAFFOLD_BUN_IMAGE } from './bun-image';
|
|
5
|
+
|
|
6
|
+
export const runtimePinTest = (code: string): string => {
|
|
7
|
+
const { patch, ref, series, variant } = SCAFFOLD_BUN_IMAGE;
|
|
8
|
+
return `// The rule, driven directly. Failure case first: a guard whose rule silently stopped matching is
|
|
9
|
+
// a green gate over the convention it was written to enforce.
|
|
10
|
+
|
|
11
|
+
import { expect, unitTest } from '@ultimat3/testing';
|
|
12
|
+
import { runtimePins } from './runtime-pin';
|
|
13
|
+
|
|
14
|
+
/** The image \`x new\` wrote: the digest every FROM builds on. */
|
|
15
|
+
const IMAGE =
|
|
16
|
+
'${ref}';
|
|
17
|
+
|
|
18
|
+
const ENGINES = { path: 'package.json', source: '{ "engines": { "bun": ">=${patch}" } }' };
|
|
19
|
+
const workflow = (pin: string) => ({
|
|
20
|
+
path: '.github/workflows/ci.yml',
|
|
21
|
+
source: ['jobs:', ' a:', ' steps:', \` bun-version: \${pin}\`].join('\\n'),
|
|
22
|
+
});
|
|
23
|
+
const dockerfile = (from: string) => ({
|
|
24
|
+
path: 'docker/Dockerfile',
|
|
25
|
+
source: \`FROM \${from} AS deps\`,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
unitTest('a CI pin off engines.bun is refused at its line, with the line to write', () => {
|
|
29
|
+
const findings = runtimePins([ENGINES, workflow("'1.0.0'")]);
|
|
30
|
+
expect(findings).toHaveLength(1);
|
|
31
|
+
expect(findings[0]?.code).toBe('${code}');
|
|
32
|
+
expect(findings[0]?.at).toBe('.github/workflows/ci.yml:4');
|
|
33
|
+
expect(findings[0]?.fix).toStartWith("edit .github/workflows/ci.yml:4 — bun-version: '${patch}'");
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
unitTest('an image tag with no digest is refused, and the fix pastes one', () => {
|
|
37
|
+
const findings = runtimePins([ENGINES, dockerfile('oven/bun:${series}-${variant}')]);
|
|
38
|
+
expect(findings.map((finding) => finding.at)).toEqual(['docker/Dockerfile:1']);
|
|
39
|
+
expect(findings[0]?.fix).toContain(\`FROM \${IMAGE} AS deps\`);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
unitTest('no engines.bun is refused: nothing else can be checked against it', () => {
|
|
43
|
+
const findings = runtimePins([{ path: 'package.json', source: '{}' }]);
|
|
44
|
+
expect(findings.map((finding) => finding.at)).toEqual(['package.json:1']);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
unitTest('the same patch, its series, an expression and a digest-pinned image are silent', () => {
|
|
48
|
+
expect(runtimePins([ENGINES, workflow("'${patch}'"), dockerfile(IMAGE)])).toEqual([]);
|
|
49
|
+
expect(runtimePins([ENGINES, workflow('${series}.x')])).toEqual([]);
|
|
50
|
+
// biome-ignore lint/suspicious/noTemplateCurlyInString: a GitHub expression, written as text.
|
|
51
|
+
expect(runtimePins([ENGINES, workflow('\${{ matrix.bun }}')])).toEqual([]);
|
|
52
|
+
});
|
|
53
|
+
`;
|
|
54
|
+
};
|