@ultimat3/cli 31.46.0 → 31.47.1
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 +1 -1
- package/README.md +1 -1
- package/package.json +29 -29
- package/src/affected.ts +3 -2
- package/src/app-config-load.ts +8 -5
- package/src/app-mcp.ts +2 -5
- package/src/app-runtime.ts +4 -4
- package/src/cmd-cache.ts +8 -4
- package/src/cmd-deploy-compose.ts +11 -12
- package/src/cmd-deploy-helm.ts +5 -8
- package/src/cmd-exercise-spec.ts +2 -2
- package/src/cmd-exercise.ts +7 -19
- package/src/cmd-new.ts +4 -3
- package/src/cmd-planned.ts +11 -76
- package/src/cmd-shot-matrix.ts +3 -2
- package/src/cmd-token.ts +11 -3
- package/src/cmd-upgrade.ts +5 -7
- package/src/codemods/ci-weekly-schedule.ts +61 -0
- package/src/codemods/e2e-suite-floor.ts +42 -0
- package/src/codemods/e2e-suite.ts +71 -0
- package/src/codemods/index.ts +4 -0
- package/src/codemods/pending.ts +2 -2
- package/src/codemods/test-ports.ts +40 -33
- package/src/codemods/test-suites.ts +11 -22
- package/src/codemods/vendored-guards.ts +3 -5
- package/src/codemods/verify-floor-skips.ts +22 -12
- package/src/codemods/verify-floor-steps.ts +4 -3
- package/src/db-seed.ts +3 -2
- package/src/dispatch.ts +2 -11
- package/src/duplicate-packages.ts +4 -4
- package/src/exercise-findings.ts +4 -3
- package/src/exercise-floor.ts +1 -1
- package/src/exercise-seed.ts +34 -0
- package/src/fix-command.ts +2 -3
- package/src/flag-reads.ts +6 -3
- package/src/generate-files.ts +10 -6
- package/src/gitignore.ts +4 -3
- package/src/guards-built-in.ts +3 -6
- package/src/guards.ts +5 -8
- package/src/island-bundle.ts +3 -2
- package/src/island-sources.ts +4 -3
- package/src/island-states-load.ts +4 -3
- package/src/island-store.ts +3 -2
- package/src/json-merge.ts +8 -6
- package/src/lint-findings.ts +4 -7
- package/src/mcp-errors.ts +2 -2
- package/src/messages.ts +1 -0
- package/src/prerender-out.ts +4 -3
- package/src/publish-closure.ts +4 -6
- package/src/pwa-manifest-locales.ts +5 -8
- package/src/registry.ts +0 -7
- package/src/root-env.ts +3 -2
- package/src/runtime-admin.ts +2 -4
- package/src/runtime-keys.ts +5 -2
- package/src/static-report.ts +5 -8
- package/src/templates/github/ci-schedule.ts +86 -0
- package/src/templates/github/ci.yml.ts +6 -8
- package/src/templates/github/dependabot.yml.ts +6 -1
- package/src/templates/guard-released-forms.ts +30 -8
- package/src/templates/scaffold-docs.ts +1 -0
- package/src/templates/scaffold-suites.ts +22 -0
- package/src/templates/shapes/overlay.ts +4 -7
- package/src/upgrade-gate-codemods.ts +1 -18
- package/src/upgrade-guards-baseline.ts +3 -5
- package/src/verify-merge-skips.ts +2 -4
- package/src/verify-merge.ts +13 -8
- package/src/verify-part-step.ts +5 -7
- package/src/worker-bundle.ts +4 -2
- package/wiki/Actions.md +69 -5
- package/wiki/Agents.md +13 -0
- package/wiki/Auth.md +4 -0
- package/wiki/Batching-And-Preloading.md +77 -3
- package/wiki/CLI-Reference.md +19 -6
- package/wiki/Caching-And-Invalidation.md +76 -23
- package/wiki/Client-Navigation.md +2 -0
- package/wiki/Compared.md +13 -11
- package/wiki/Configuration.md +17 -4
- package/wiki/Entities-And-Migrations.md +168 -6
- package/wiki/FAQ.md +1 -1
- package/wiki/Feature-Flags.md +3 -0
- package/wiki/Getting-Started.md +27 -1
- package/wiki/Jobs-And-Workflows.md +70 -13
- package/wiki/Known-Gaps.md +58 -49
- package/wiki/MCP-And-AI.md +43 -3
- package/wiki/Mail.md +6 -0
- package/wiki/Migrations-And-Backfills.md +13 -0
- package/wiki/Money.md +20 -1
- package/wiki/N-Plus-One-Detection.md +31 -1
- package/wiki/Notify.md +13 -2
- package/wiki/PWA-And-Offline.md +34 -4
- package/wiki/Policies-And-Authz.md +27 -5
- package/wiki/Queries-And-Live-Queries.md +41 -4
- package/wiki/Realtime.md +22 -0
- package/wiki/Resource-Management.md +6 -1
- package/wiki/Routes-And-Render-Modes.md +54 -6
- package/wiki/SEO.md +24 -2
- package/wiki/Scheduled-Tasks.md +29 -11
- package/wiki/Scraping.md +33 -2
- package/wiki/Stability.md +1 -1
- package/wiki/Static-Assets.md +1 -0
- package/wiki/Storage-And-Uploads.md +8 -1
- package/wiki/Testing.md +120 -13
- package/wiki/The-Eight-Primitives.md +125 -6
- package/wiki/Timezones-And-Dates.md +13 -5
- package/wiki/Troubleshooting.md +1 -1
- package/wiki/Tutorial-02-First-Feature.md +6 -0
- package/wiki/Tutorial-03-Auth-And-Admin.md +8 -0
- package/wiki/Tutorial-04-Jobs-And-Realtime.md +40 -2
- package/wiki/Tutorial-06-Growing-Up.md +1 -2
- package/wiki/UI-Components.md +14 -5
- package/wiki/Upgrading.md +43 -5
package/src/cmd-token.ts
CHANGED
|
@@ -7,11 +7,15 @@ import type { ApiKeyStore, ApiKeySummary } from '@ultimat3/auth';
|
|
|
7
7
|
import { describeApiKey, issueApiKey, postgresAuthAdapter, revokeApiKey } from '@ultimat3/auth';
|
|
8
8
|
import { type Clock, systemClock, tryResolveEnvironment } from '@ultimat3/core';
|
|
9
9
|
import { requireAppRoot } from './app-root';
|
|
10
|
-
import { plannedSubcommand } from './cmd-planned';
|
|
11
10
|
import { TOKEN_MAX_DAYS, TOKEN_SUBCOMMANDS, tokenSpec } from './cmd-token-spec';
|
|
12
11
|
import type { CliCommand, CommandContext } from './command';
|
|
13
12
|
import { ok } from './command';
|
|
14
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
BadFlagError,
|
|
15
|
+
MissingPositionalError,
|
|
16
|
+
MissingSubcommandError,
|
|
17
|
+
UnknownCommandError,
|
|
18
|
+
} from './errors';
|
|
15
19
|
import { parseIntFlag } from './flag-number';
|
|
16
20
|
import { readsAsProduction } from './mcp-db-target';
|
|
17
21
|
import { msg } from './messages';
|
|
@@ -170,7 +174,11 @@ export const tokenCommandOver = (open: OpenToken, clock: Clock = systemClock): C
|
|
|
170
174
|
// a `ParsedArgs` built by hand.
|
|
171
175
|
if (sub === undefined)
|
|
172
176
|
throw new MissingSubcommandError({ command: 'token', known: TOKEN_SUBCOMMANDS });
|
|
173
|
-
throw
|
|
177
|
+
throw new UnknownCommandError({
|
|
178
|
+
path: `token ${sub}`,
|
|
179
|
+
known: TOKEN_SUBCOMMANDS,
|
|
180
|
+
suggestion: 'help token',
|
|
181
|
+
});
|
|
174
182
|
},
|
|
175
183
|
});
|
|
176
184
|
|
package/src/cmd-upgrade.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { runUpgradeCodemods } from './cmd-upgrade-codemods';
|
|
|
11
11
|
import { upgradeSpec } from './cmd-upgrade-spec';
|
|
12
12
|
import type { CliCommand, CommandContext } from './command';
|
|
13
13
|
import { failed, ok } from './command';
|
|
14
|
+
import { supersededFindings } from './doctor-superseded';
|
|
14
15
|
import { BadFlagError, BunVersionError } from './errors';
|
|
15
16
|
import type { Runner } from './exec';
|
|
16
17
|
import { execOutput } from './exec';
|
|
@@ -24,7 +25,7 @@ import type { BunEdit, BunManual } from './upgrade-bun-floor';
|
|
|
24
25
|
import { editBunSites, floorOf, isBunSite } from './upgrade-bun-floor';
|
|
25
26
|
import { requireCleanTree } from './upgrade-clean-tree';
|
|
26
27
|
import { repoScripts, runHopGate, runRepoScripts } from './upgrade-gate';
|
|
27
|
-
import {
|
|
28
|
+
import { EVERY_RELEASE, previewCodemods } from './upgrade-gate-codemods';
|
|
28
29
|
import { acquireUpgradeLock } from './upgrade-lock';
|
|
29
30
|
import { readManifests, readPins, rewritePins } from './upgrade-pins';
|
|
30
31
|
import type { UpgradeHop } from './upgrade-plan';
|
|
@@ -32,7 +33,6 @@ import { planHop, releaseOf } from './upgrade-plan';
|
|
|
32
33
|
import { publishedVersions, releaseBunRange } from './upgrade-registry';
|
|
33
34
|
import type { PlannedWrites } from './upgrade-report';
|
|
34
35
|
import { humanLines, NO_WRITES, report, thenLine } from './upgrade-report';
|
|
35
|
-
import { codemodLines } from './upgrade-report-codemods';
|
|
36
36
|
import { findUpgradeRoot } from './upgrade-root';
|
|
37
37
|
import { stopChildrenOnSignal, tagRunner, upgradeTag } from './upgrade-signals';
|
|
38
38
|
import type { UnfinishedHop } from './upgrade-unfinished';
|
|
@@ -177,9 +177,8 @@ export const createUpgradeCommand = (
|
|
|
177
177
|
// A record for some other target is a hop since undone (`git stash`): nothing left to finish.
|
|
178
178
|
if (unfinished !== undefined && !dryRun) await clearUnfinished(root);
|
|
179
179
|
const then = thenLine({ hop, dryRun, app, gate: undefined, scripts: [] });
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
: undefined;
|
|
180
|
+
// No version moved, so no codemod is owed: a hand run is `x upgrade codemods --from <version>`.
|
|
181
|
+
const superseded = app ? await supersededFindings(root) : [];
|
|
183
182
|
const summary =
|
|
184
183
|
hop.next === null
|
|
185
184
|
? msg('cli.upgrade.atLatest', { version: hop.to })
|
|
@@ -198,11 +197,10 @@ export const createUpgradeCommand = (
|
|
|
198
197
|
scripts: [],
|
|
199
198
|
then,
|
|
200
199
|
typescript,
|
|
201
|
-
|
|
200
|
+
superseded,
|
|
202
201
|
}),
|
|
203
202
|
lines: [
|
|
204
203
|
...typescript.map((lag) => msg('cli.upgrade.typescript', { ...lag })),
|
|
205
|
-
...codemodLines(carried?.codemods ?? null),
|
|
206
204
|
msg('cli.upgrade.then', { then }),
|
|
207
205
|
],
|
|
208
206
|
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// 31.47.0: `x new`'s ci.yml gates the default branch weekly and keeps one issue while that run is
|
|
2
|
+
// red, and its dependabot.yml leaves the Bun image to the repo's Bun pins. A workflow that already
|
|
3
|
+
// has a schedule made these decisions itself and is left alone; one that no longer holds the
|
|
4
|
+
// template's lines is reported with the diff, all or nothing.
|
|
5
|
+
|
|
6
|
+
import { CI_WORKFLOW_PATH } from '../templates/github/ci.yml';
|
|
7
|
+
import {
|
|
8
|
+
ALARM_JOB,
|
|
9
|
+
CONCURRENCY_GROUP,
|
|
10
|
+
PLAN_CONDITION,
|
|
11
|
+
scheduleTrigger,
|
|
12
|
+
} from '../templates/github/ci-schedule';
|
|
13
|
+
import { BUN_IMAGE_IGNORE, DEPENDABOT_PATH } from '../templates/github/dependabot.yml';
|
|
14
|
+
import type { Codemod, CodemodApp, CodemodResult } from './codemod';
|
|
15
|
+
import { editSnippets, mergeResults, readText } from './engine-edits';
|
|
16
|
+
|
|
17
|
+
const NOTHING: CodemodResult = { changed: [], skipped: [] };
|
|
18
|
+
|
|
19
|
+
const OLD_TRIGGERS = 'on:\n push:\n pull_request:\n';
|
|
20
|
+
const OLD_GROUP = `concurrency:
|
|
21
|
+
group: ci-\${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && github.sha || github.ref }}
|
|
22
|
+
`;
|
|
23
|
+
const OLD_CONDITION = ` if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
|
|
24
|
+
`;
|
|
25
|
+
const VERDICT_STEP = ' - run: bun run verify merge "$RUNNER_TEMP"/parts/*.json\n';
|
|
26
|
+
const POSTGRES_IGNORE = ` # A Postgres MAJOR is a planned migration (a new data directory), never a weekly bump.
|
|
27
|
+
- dependency-name: postgres
|
|
28
|
+
update-types: ['version-update:semver-major']
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
/** A `schedule:` key inside the `on:` block, never a job of that name further down. */
|
|
32
|
+
const HAS_SCHEDULE = /^["']?on["']?:[^\n]*\n(?:(?:[ \t#][^\n]*)?\n)*?[ \t]+schedule:/m;
|
|
33
|
+
/** The name `x new` wrote into the workflow's header: the cron's seed, as it was for a new app. */
|
|
34
|
+
const APP_NAME = /^# The gate for ([^\s:]+):/m;
|
|
35
|
+
|
|
36
|
+
async function carryWorkflow(app: CodemodApp): Promise<CodemodResult> {
|
|
37
|
+
const file = await readText(app, CI_WORKFLOW_PATH);
|
|
38
|
+
if (file === undefined || HAS_SCHEDULE.test(file.text)) return NOTHING;
|
|
39
|
+
const name = APP_NAME.exec(file.text)?.[1] ?? app.root;
|
|
40
|
+
return editSnippets(app, CI_WORKFLOW_PATH, [
|
|
41
|
+
{ from: OLD_TRIGGERS, to: `${OLD_TRIGGERS}${scheduleTrigger(name)}` },
|
|
42
|
+
{ from: OLD_GROUP, to: CONCURRENCY_GROUP },
|
|
43
|
+
{ from: OLD_CONDITION, to: PLAN_CONDITION },
|
|
44
|
+
{ from: VERDICT_STEP, to: `${VERDICT_STEP}${ALARM_JOB}` },
|
|
45
|
+
]);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function carryDependabot(app: CodemodApp): Promise<CodemodResult> {
|
|
49
|
+
const file = await readText(app, DEPENDABOT_PATH);
|
|
50
|
+
if (file === undefined || file.text.includes('dependency-name: oven/bun')) return NOTHING;
|
|
51
|
+
return editSnippets(app, DEPENDABOT_PATH, [
|
|
52
|
+
{ from: POSTGRES_IGNORE, to: `${POSTGRES_IGNORE}${BUN_IMAGE_IGNORE}` },
|
|
53
|
+
]);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export const codemod: Codemod = {
|
|
57
|
+
id: 'ci-weekly-schedule',
|
|
58
|
+
since: '31.47.0',
|
|
59
|
+
summary: `${CI_WORKFLOW_PATH}: a weekly gate of the default branch, with one issue kept while it is red; ${DEPENDABOT_PATH}: the Bun image moves with the repo's Bun pins`,
|
|
60
|
+
run: async (app) => mergeResults([await carryWorkflow(app), await carryDependabot(app)]),
|
|
61
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// 31.47.1: 31.28.0's floor required `e2e` of any app with a page, while only `apps/web/site/page.tsx`
|
|
2
|
+
// got a suite, so an app without that page answered `X_VERIFY_SUITE_VANISHED`. A floor in that state
|
|
3
|
+
// gains the suite, or, with no page a suite could visit, excuses the step and says why.
|
|
4
|
+
|
|
5
|
+
import { isJsonObject } from '@ultimat3/core';
|
|
6
|
+
import { VERIFY_FLOOR_FILE } from '../verify-floor';
|
|
7
|
+
import type { Codemod, CodemodResult } from './codemod';
|
|
8
|
+
import { e2eSuitePlan, writeE2eSuite } from './e2e-suite';
|
|
9
|
+
import { e2eExcuse, renderFloor, withSkip } from './verify-floor-skips';
|
|
10
|
+
|
|
11
|
+
const NOTHING: CodemodResult = { changed: [], skipped: [] };
|
|
12
|
+
|
|
13
|
+
function parsed(source: string): Record<string, unknown> | undefined {
|
|
14
|
+
try {
|
|
15
|
+
const floor: unknown = JSON.parse(source);
|
|
16
|
+
return isJsonObject(floor) ? floor : undefined;
|
|
17
|
+
} catch {
|
|
18
|
+
// `verify-floor-skips` reports a floor it cannot read.
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const codemod: Codemod = {
|
|
24
|
+
id: 'e2e-suite-floor',
|
|
25
|
+
since: '31.47.1',
|
|
26
|
+
summary: `an ${VERIFY_FLOOR_FILE} requiring e2e gains a suite for a page the app serves, or excuses the step where no page can be visited`,
|
|
27
|
+
async run(app) {
|
|
28
|
+
const source = await app.read(VERIFY_FLOOR_FILE);
|
|
29
|
+
const floor = source === undefined ? undefined : parsed(source);
|
|
30
|
+
const steps = floor?.['steps'];
|
|
31
|
+
if (floor === undefined || !Array.isArray(steps) || !steps.includes('e2e')) return NOTHING;
|
|
32
|
+
if (isJsonObject(floor['skip']) && 'e2e' in floor['skip']) return NOTHING;
|
|
33
|
+
const plan = await e2eSuitePlan(app);
|
|
34
|
+
if (plan.kind !== 'none') return writeE2eSuite(app, plan);
|
|
35
|
+
const next = withSkip(
|
|
36
|
+
{ ...floor, steps: steps.filter((step) => step !== 'e2e') },
|
|
37
|
+
{ e2e: e2eExcuse(plan) },
|
|
38
|
+
);
|
|
39
|
+
await app.write(VERIFY_FLOOR_FILE, renderFloor(next));
|
|
40
|
+
return { changed: [VERIFY_FLOOR_FILE], skipped: [] };
|
|
41
|
+
},
|
|
42
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// Whether this app's `e2e` step has a suite to run, and if not which one a codemod can write: the
|
|
2
|
+
// one answer the suite codemods and the floor codemods share, so the floor never requires a suite
|
|
3
|
+
// nothing created (`X_VERIFY_SUITE_VANISHED`). Only `apps/web` is here: the page the step boots.
|
|
4
|
+
|
|
5
|
+
import { isJsonObject } from '@ultimat3/core';
|
|
6
|
+
import { routePathFromFile } from '@ultimat3/render';
|
|
7
|
+
import { E2E_SUITE_PATH, e2eSuiteFiles, pageE2eSuite } from '../templates/scaffold-suites';
|
|
8
|
+
import { VERIFY_FLOOR_FILE } from '../verify-floor';
|
|
9
|
+
import { ownerOf } from '../verify-test-command';
|
|
10
|
+
import type { CodemodApp, CodemodResult } from './codemod';
|
|
11
|
+
import { writeIfAbsent } from './engine-edits';
|
|
12
|
+
|
|
13
|
+
export type E2eSuitePlan =
|
|
14
|
+
/** The app already holds an e2e test: the step has something to run. */
|
|
15
|
+
| { readonly kind: 'held' }
|
|
16
|
+
| { readonly kind: 'write'; readonly path: string; readonly contents: string }
|
|
17
|
+
/** Nothing to run and nothing to write; `pages` says whether the app serves any page at all. */
|
|
18
|
+
| { readonly kind: 'none'; readonly pages: boolean };
|
|
19
|
+
|
|
20
|
+
const LANDING_PAGE = 'apps/web/site/page.tsx';
|
|
21
|
+
|
|
22
|
+
/** Why `e2e` is excused for an app whose every page needs a value in its URL. */
|
|
23
|
+
export const NO_STATIC_PAGE_WHY =
|
|
24
|
+
'every page here needs a URL parameter, so no suite could be written for one: add a *.e2e.test.ts that visits a real URL, and then e2e moves from "skip" to "steps"';
|
|
25
|
+
|
|
26
|
+
/** A URL that names itself and is safe inside the suite's quotes: no `:param`, no `*rest`. */
|
|
27
|
+
const STATIC_URL = /^\/[\w./~-]*$/;
|
|
28
|
+
|
|
29
|
+
const holdsE2eTest = async (app: CodemodApp): Promise<boolean> =>
|
|
30
|
+
(await app.glob('{apps,packages,e2e}/**/*.test.{ts,tsx}')).some(
|
|
31
|
+
(path) => !path.includes('/node_modules/') && ownerOf(path) === 'e2e',
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
/** Whether the floor already excuses `e2e`: the app's decision, which no suite overrides. */
|
|
35
|
+
async function floorExcusesE2e(app: CodemodApp): Promise<boolean> {
|
|
36
|
+
try {
|
|
37
|
+
const floor: unknown = JSON.parse((await app.read(VERIFY_FLOOR_FILE)) ?? 'null');
|
|
38
|
+
return isJsonObject(floor) && isJsonObject(floor['skip']) && 'e2e' in floor['skip'];
|
|
39
|
+
} catch {
|
|
40
|
+
// Unreadable is `verify-floor-skips`' to report, and it excuses nothing.
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** The landing page's suite, else one for the shortest URL `apps/web` serves with no parameter. */
|
|
46
|
+
export async function e2eSuitePlan(app: CodemodApp): Promise<E2eSuitePlan> {
|
|
47
|
+
if (await app.exists(LANDING_PAGE)) {
|
|
48
|
+
const contents = e2eSuiteFiles()[0]?.contents;
|
|
49
|
+
if (typeof contents === 'string') return { kind: 'write', path: E2E_SUITE_PATH, contents };
|
|
50
|
+
}
|
|
51
|
+
if (await holdsE2eTest(app)) return { kind: 'held' };
|
|
52
|
+
const pages = await app.glob('apps/web/{site,app}/**/page.tsx');
|
|
53
|
+
const served = (await app.glob('apps/*/{site,app}/**/page.tsx')).length > 0;
|
|
54
|
+
if (await floorExcusesE2e(app)) return { kind: 'none', pages: served };
|
|
55
|
+
const [first] = pages
|
|
56
|
+
.map((file) => ({ file, url: routePathFromFile(file).path }))
|
|
57
|
+
.filter(({ url }) => STATIC_URL.test(url))
|
|
58
|
+
.sort((a, b) => a.url.length - b.url.length || (a.file < b.file ? -1 : 1));
|
|
59
|
+
if (first === undefined) return { kind: 'none', pages: served };
|
|
60
|
+
return {
|
|
61
|
+
kind: 'write',
|
|
62
|
+
path: first.file.replace(/page\.tsx$/, 'page.e2e.test.ts'),
|
|
63
|
+
contents: pageE2eSuite(first.url),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** The plan's file, unless the app already holds that path. */
|
|
68
|
+
export const writeE2eSuite = async (app: CodemodApp, plan: E2eSuitePlan): Promise<CodemodResult> =>
|
|
69
|
+
plan.kind === 'write'
|
|
70
|
+
? writeIfAbsent(app, plan.path, plan.contents)
|
|
71
|
+
: { changed: [], skipped: [] };
|
package/src/codemods/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { codemod as ciArtifactRetention } from './ci-artifact-retention';
|
|
|
11
11
|
import { codemod as ciE2eBrowser } from './ci-e2e-browser';
|
|
12
12
|
import { codemod as ciPinnedActions } from './ci-pinned-actions';
|
|
13
13
|
import { codemod as ciServicesEnv } from './ci-services-env';
|
|
14
|
+
import { codemod as ciWeeklySchedule } from './ci-weekly-schedule';
|
|
14
15
|
import type { Codemod } from './codemod';
|
|
15
16
|
import { codemod as defineErrorLeaf } from './define-error-leaf';
|
|
16
17
|
import { codemod as docsCiParts } from './docs-ci-parts';
|
|
@@ -19,6 +20,7 @@ import { codemod as docsGateProse } from './docs-gate-prose';
|
|
|
19
20
|
import { codemod as docsIslandRows } from './docs-island-rows';
|
|
20
21
|
import { codemod as docsShippedGuards } from './docs-shipped-guards';
|
|
21
22
|
import { codemod as docsTestServices } from './docs-test-services';
|
|
23
|
+
import { codemod as e2eSuiteFloor } from './e2e-suite-floor';
|
|
22
24
|
import { codemod as formatEditedHook } from './format-edited-hook';
|
|
23
25
|
import { codemod as helmAlertsDeploy } from './helm-alerts-deploy';
|
|
24
26
|
import { codemod as helmAlertsObjective } from './helm-alerts-objective';
|
|
@@ -67,4 +69,6 @@ export const CODEMODS: readonly Codemod[] = [
|
|
|
67
69
|
testServices,
|
|
68
70
|
ciPinnedActions,
|
|
69
71
|
ciArtifactRetention,
|
|
72
|
+
ciWeeklySchedule,
|
|
73
|
+
e2eSuiteFloor,
|
|
70
74
|
];
|
package/src/codemods/pending.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// The codemods an app still owes, for `x doctor`: an `x upgrade` driven by a CLI older than the
|
|
2
2
|
// engine applied none, and the installed CLI's gate cannot write. A dry run of every codemod up to
|
|
3
|
-
// this CLI's release names them; `x upgrade --
|
|
3
|
+
// this CLI's release names them; `x upgrade codemods --from 0.0.0` applies them (idempotent).
|
|
4
4
|
|
|
5
5
|
import type { Finding } from '../output';
|
|
6
6
|
import type { Codemod } from './codemod';
|
|
@@ -29,7 +29,7 @@ export async function pendingCodemodFindings(
|
|
|
29
29
|
{
|
|
30
30
|
code: CODEMODS_PENDING,
|
|
31
31
|
cause: `${String(files.length)} file(s) still as an older scaffold wrote them, owed by ${owed.map((one) => `${one.id} (${one.since})`).join(', ')}: the x upgrade that installed ${to} ran under a CLI with no codemods — ${files.slice(0, 8).join(', ')}`,
|
|
32
|
-
fix: 'x upgrade --json #
|
|
32
|
+
fix: 'x upgrade codemods --from 0.0.0 --json # applies every codemod still owed, up to this release',
|
|
33
33
|
at: files[0] ?? '.',
|
|
34
34
|
},
|
|
35
35
|
];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// 31.27.0: the test stack's host ports are the app's own (its name picks an offset into each band),
|
|
2
|
-
// so two apps on one machine stop dialling each other's Postgres.
|
|
3
|
-
//
|
|
2
|
+
// so two apps on one machine stop dialling each other's Postgres. The compose file publishes what
|
|
3
|
+
// the env file names, so they move together, only while both are the old scaffold's byte for byte;
|
|
4
|
+
// otherwise neither moves and each is reported with its diff.
|
|
4
5
|
|
|
5
6
|
import type { NameSet } from '../templates/naming';
|
|
6
7
|
import { names } from '../templates/naming';
|
|
@@ -11,9 +12,10 @@ import {
|
|
|
11
12
|
testPorts,
|
|
12
13
|
testServicesFiles,
|
|
13
14
|
} from '../templates/scaffold-test-services';
|
|
14
|
-
import type { Codemod,
|
|
15
|
+
import type { Codemod, CodemodResult } from './codemod';
|
|
15
16
|
import { unifiedDiff } from './engine-diff';
|
|
16
|
-
import {
|
|
17
|
+
import type { FileText } from './engine-edits';
|
|
18
|
+
import { readText } from './engine-edits';
|
|
17
19
|
|
|
18
20
|
const NOTHING: CodemodResult = { changed: [], skipped: [] };
|
|
19
21
|
|
|
@@ -42,30 +44,27 @@ function before(today: string, app: NameSet): string {
|
|
|
42
44
|
return text;
|
|
43
45
|
}
|
|
44
46
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
},
|
|
67
|
-
],
|
|
68
|
-
};
|
|
47
|
+
interface PortFile {
|
|
48
|
+
readonly path: string;
|
|
49
|
+
readonly today: string;
|
|
50
|
+
readonly old: string;
|
|
51
|
+
readonly file: FileText | undefined;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const isMovable = ({ file, today, old }: PortFile): boolean =>
|
|
55
|
+
file !== undefined && (file.text === today || file.text === old);
|
|
56
|
+
|
|
57
|
+
/** Every file still short of today's, each with why it stays and the change to make by hand. */
|
|
58
|
+
function heldBack(files: readonly PortFile[]): CodemodResult {
|
|
59
|
+
const blockers = files.filter((one) => !isMovable(one)).map((one) => one.path);
|
|
60
|
+
const skipped = files.flatMap(({ path, today, old, file }) => {
|
|
61
|
+
if (file === undefined || file.text === today) return [];
|
|
62
|
+
const reason = blockers.includes(path)
|
|
63
|
+
? "it is no longer the old scaffold's file byte for byte, so the test ports stay in both files: the diff is the scaffold's change, to make by hand in both if two apps share this machine"
|
|
64
|
+
: `${blockers.join(' and ')} cannot move with it, and the two must name the same ports, so this file stays too: the diff is the scaffold's change, to make by hand in both if two apps share this machine`;
|
|
65
|
+
return [{ path, reason, diff: unifiedDiff(path, old, today) }];
|
|
66
|
+
});
|
|
67
|
+
return { changed: [], skipped };
|
|
69
68
|
}
|
|
70
69
|
|
|
71
70
|
export const codemod: Codemod = {
|
|
@@ -76,11 +75,19 @@ export const codemod: Codemod = {
|
|
|
76
75
|
const kebab = appName((await readText(app, TEST_ENV_PATH))?.text ?? '');
|
|
77
76
|
if (kebab === undefined) return NOTHING;
|
|
78
77
|
const name = names(kebab);
|
|
79
|
-
const
|
|
80
|
-
for (const
|
|
81
|
-
if (typeof
|
|
82
|
-
|
|
78
|
+
const files: PortFile[] = [];
|
|
79
|
+
for (const { path, contents } of testServicesFiles(name)) {
|
|
80
|
+
if (typeof contents !== 'string') continue;
|
|
81
|
+
const old = before(contents, name);
|
|
82
|
+
files.push({ path, today: contents, old, file: await readText(app, path) });
|
|
83
|
+
}
|
|
84
|
+
if (!files.every(isMovable)) return heldBack(files);
|
|
85
|
+
const changed: string[] = [];
|
|
86
|
+
for (const { path, today, file } of files) {
|
|
87
|
+
if (file === undefined || file.text === today) continue;
|
|
88
|
+
await app.write(path, file.restore(today));
|
|
89
|
+
changed.push(path);
|
|
83
90
|
}
|
|
84
|
-
return
|
|
91
|
+
return { changed, skipped: [] };
|
|
85
92
|
},
|
|
86
93
|
};
|
|
@@ -1,37 +1,26 @@
|
|
|
1
1
|
// 31.27.0: every scaffold ships a `live` suite (the production driver against a real Postgres) and,
|
|
2
|
-
// where it serves a page, an `e2e` suite (the landing page in a real browser
|
|
3
|
-
//
|
|
2
|
+
// where it serves a page, an `e2e` suite (the landing page in a real browser; `e2e-suite.ts` picks
|
|
3
|
+
// the page for an app with none). An app that predates them gains each; one it holds is its own.
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
E2E_SUITE_PATH,
|
|
7
|
-
e2eSuiteFiles,
|
|
8
|
-
LIVE_SUITE_PATH,
|
|
9
|
-
liveSuiteFiles,
|
|
10
|
-
} from '../templates/scaffold-suites';
|
|
5
|
+
import { LIVE_SUITE_PATH, liveSuiteFiles } from '../templates/scaffold-suites';
|
|
11
6
|
import type { Codemod, CodemodApp, CodemodResult } from './codemod';
|
|
7
|
+
import { e2eSuitePlan, writeE2eSuite } from './e2e-suite';
|
|
12
8
|
import { mergeResults, writeIfAbsent } from './engine-edits';
|
|
13
9
|
|
|
14
10
|
const NOTHING: CodemodResult = { changed: [], skipped: [] };
|
|
15
11
|
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
[
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
async function suite(app: CodemodApp, path: string, host: string): Promise<CodemodResult> {
|
|
23
|
-
if (!(await app.exists(host))) return NOTHING;
|
|
24
|
-
const file = [...liveSuiteFiles(), ...e2eSuiteFiles()].find((one) => one.path === path);
|
|
25
|
-
return typeof file?.contents === 'string' ? writeIfAbsent(app, path, file.contents) : NOTHING;
|
|
12
|
+
/** No db package, no live suite: it lands beside the handle it vouches for. */
|
|
13
|
+
async function liveSuite(app: CodemodApp): Promise<CodemodResult> {
|
|
14
|
+
if (!(await app.exists('packages/db/src/index.ts'))) return NOTHING;
|
|
15
|
+
const contents = liveSuiteFiles()[0]?.contents;
|
|
16
|
+
return typeof contents === 'string' ? writeIfAbsent(app, LIVE_SUITE_PATH, contents) : NOTHING;
|
|
26
17
|
}
|
|
27
18
|
|
|
28
19
|
export const codemod: Codemod = {
|
|
29
20
|
id: 'test-suites',
|
|
30
21
|
since: '31.27.0',
|
|
31
|
-
summary: `the live and e2e suites every scaffold ships: ${LIVE_SUITE_PATH} and
|
|
22
|
+
summary: `the live and e2e suites every scaffold ships: ${LIVE_SUITE_PATH} and a page's *.e2e.test.ts`,
|
|
32
23
|
async run(app) {
|
|
33
|
-
|
|
34
|
-
for (const [path, host] of HOSTS) results.push(await suite(app, path, host));
|
|
35
|
-
return mergeResults(results);
|
|
24
|
+
return mergeResults([await liveSuite(app), await writeE2eSuite(app, await e2eSuitePlan(app))]);
|
|
36
25
|
},
|
|
37
26
|
};
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// differs only in severity becomes a `guards/shipped.json` row; any other edit is kept as the app's
|
|
4
4
|
// own guard under a new name, the shipped one off, with the reason and the diff — never lost.
|
|
5
5
|
|
|
6
|
+
import { isJsonObject } from '@ultimat3/core';
|
|
6
7
|
import {
|
|
7
8
|
parseShippedConfig,
|
|
8
9
|
SHIPPED_GUARD_CONFIG,
|
|
@@ -28,9 +29,6 @@ const REPORT_ONLY = /^\s*severity:\s*'warning',\s*$/m;
|
|
|
28
29
|
const withoutSeverity = (text: string): string =>
|
|
29
30
|
text.replaceAll('\r\n', '\n').replaceAll(SEVERITY_LINE, '');
|
|
30
31
|
|
|
31
|
-
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
32
|
-
typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
33
|
-
|
|
34
32
|
/** What one copy becomes: deleted at a severity, or kept as the app's own guard. */
|
|
35
33
|
type Verdict =
|
|
36
34
|
| { readonly kind: 'delete'; readonly severity: 'error' | 'warning' }
|
|
@@ -78,8 +76,8 @@ const moveBaselines = async (
|
|
|
78
76
|
} catch {
|
|
79
77
|
return false;
|
|
80
78
|
}
|
|
81
|
-
const baseline =
|
|
82
|
-
if (!
|
|
79
|
+
const baseline = isJsonObject(floor) ? floor[GUARD_BASELINE_FIELD] : undefined;
|
|
80
|
+
if (!isJsonObject(floor) || !isJsonObject(baseline)) return false;
|
|
83
81
|
const moved = Object.fromEntries(
|
|
84
82
|
Object.entries(baseline).map(([key, value]) => [renamed.get(key) ?? key, value]),
|
|
85
83
|
);
|
|
@@ -1,36 +1,46 @@
|
|
|
1
1
|
// 31.27.0: a scaffold's x.verify.json names every gate step — required in `steps`, or excused in
|
|
2
2
|
// `skip` with its why — and sets `strict`. An older app gains the `skip` rows that hold for it
|
|
3
|
-
// (roadmap; job with no job suite; e2e with no
|
|
3
|
+
// (roadmap; job with no job suite; e2e with no suite to run). `strict` is 31.28.0's
|
|
4
|
+
// (`verify-floor-steps`).
|
|
4
5
|
|
|
6
|
+
import { isJsonObject } from '@ultimat3/core';
|
|
5
7
|
import { floorSteps } from '../templates/scaffold-verify-floor';
|
|
6
8
|
import { VERIFY_FLOOR_FILE } from '../verify-floor';
|
|
7
9
|
import type { Codemod, CodemodApp } from './codemod';
|
|
10
|
+
import type { E2eSuitePlan } from './e2e-suite';
|
|
11
|
+
import { e2eSuitePlan, NO_STATIC_PAGE_WHY } from './e2e-suite';
|
|
8
12
|
|
|
9
13
|
export type Floor = Record<string, unknown>;
|
|
10
14
|
|
|
11
|
-
export const isObject = (value: unknown): value is Floor =>
|
|
12
|
-
typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
13
|
-
|
|
14
15
|
const any = async (app: CodemodApp, pattern: string): Promise<boolean> =>
|
|
15
16
|
(await app.glob(pattern)).length > 0;
|
|
16
17
|
|
|
17
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* What the app ships suites for, as `floorSteps` asks it: a job suite, and an e2e suite it holds or
|
|
20
|
+
* `test-suites` writes. Never "has a page": that required a suite no codemod had created.
|
|
21
|
+
*/
|
|
18
22
|
export async function floorSuites(
|
|
19
23
|
app: CodemodApp,
|
|
20
24
|
): Promise<{ readonly jobs: boolean; readonly pages: boolean }> {
|
|
21
25
|
return {
|
|
22
26
|
jobs: await any(app, '{apps,packages}/**/*.job.test.ts'),
|
|
23
|
-
pages: await
|
|
27
|
+
pages: (await e2eSuitePlan(app)).kind !== 'none',
|
|
24
28
|
};
|
|
25
29
|
}
|
|
26
30
|
|
|
27
|
-
/**
|
|
31
|
+
/** Why `e2e` cannot run: no page at all is the scaffold's own row, pages with no URL are not. */
|
|
32
|
+
export const e2eExcuse = (plan: E2eSuitePlan): string =>
|
|
33
|
+
plan.kind === 'none' && plan.pages
|
|
34
|
+
? NO_STATIC_PAGE_WHY
|
|
35
|
+
: String(floorSteps({ jobs: false, pages: false }).skip.e2e);
|
|
36
|
+
|
|
37
|
+
/** The steps that cannot run in this app, each with its why. */
|
|
28
38
|
async function excused(app: CodemodApp): Promise<Readonly<Record<string, string>>> {
|
|
29
39
|
const { jobs, pages } = await floorSuites(app);
|
|
30
40
|
const why = floorSteps({ jobs: false, pages: false }).skip;
|
|
31
41
|
const out: Record<string, string> = {};
|
|
32
42
|
if (!jobs && why.job !== undefined) out['job'] = why.job;
|
|
33
|
-
if (!pages
|
|
43
|
+
if (!pages) out['e2e'] = e2eExcuse(await e2eSuitePlan(app));
|
|
34
44
|
if (!(await app.exists('docs/idea/14-roadmap.md')) && why.roadmap !== undefined) {
|
|
35
45
|
out['roadmap'] = why.roadmap;
|
|
36
46
|
}
|
|
@@ -38,8 +48,8 @@ async function excused(app: CodemodApp): Promise<Readonly<Record<string, string>
|
|
|
38
48
|
}
|
|
39
49
|
|
|
40
50
|
/** `floor` with `skip` merged in, placed right after `steps` as the scaffold writes it. */
|
|
41
|
-
function withSkip(floor: Floor, skip: Readonly<Record<string, string>>): Floor {
|
|
42
|
-
const merged = { ...(
|
|
51
|
+
export function withSkip(floor: Floor, skip: Readonly<Record<string, string>>): Floor {
|
|
52
|
+
const merged = { ...(isJsonObject(floor['skip']) ? floor['skip'] : {}), ...skip };
|
|
43
53
|
const out: Floor = {};
|
|
44
54
|
for (const [key, value] of Object.entries(floor)) {
|
|
45
55
|
if (key === 'skip') continue;
|
|
@@ -65,7 +75,7 @@ export const codemod: Codemod = {
|
|
|
65
75
|
} catch {
|
|
66
76
|
floor = undefined;
|
|
67
77
|
}
|
|
68
|
-
if (!
|
|
78
|
+
if (!isJsonObject(floor)) {
|
|
69
79
|
return {
|
|
70
80
|
changed: [],
|
|
71
81
|
skipped: [
|
|
@@ -74,7 +84,7 @@ export const codemod: Codemod = {
|
|
|
74
84
|
};
|
|
75
85
|
}
|
|
76
86
|
const steps = Array.isArray(floor['steps']) ? floor['steps'] : [];
|
|
77
|
-
const held =
|
|
87
|
+
const held = isJsonObject(floor['skip']) ? floor['skip'] : {};
|
|
78
88
|
const add = Object.fromEntries(
|
|
79
89
|
Object.entries(await excused(app)).filter(
|
|
80
90
|
([step]) => !steps.includes(step) && !(step in held),
|
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
// names every gate step — required or excused — `strict` goes on. Short of that, `strict: false`
|
|
4
4
|
// is written once with a note: a decision recorded, not a question asked on every upgrade.
|
|
5
5
|
|
|
6
|
+
import { isJsonObject } from '@ultimat3/core';
|
|
6
7
|
import { floorSteps } from '../templates/scaffold-verify-floor';
|
|
7
8
|
import { VERIFY_FLOOR_FILE } from '../verify-floor';
|
|
8
9
|
import { VERIFY_STEP_NAMES } from '../verify-step';
|
|
9
10
|
import type { Codemod, CodemodResult } from './codemod';
|
|
10
11
|
import { unifiedDiff } from './engine-diff';
|
|
11
12
|
import type { Floor } from './verify-floor-skips';
|
|
12
|
-
import { floorSuites,
|
|
13
|
+
import { floorSuites, renderFloor } from './verify-floor-skips';
|
|
13
14
|
|
|
14
15
|
const NOTHING: CodemodResult = { changed: [], skipped: [] };
|
|
15
16
|
|
|
@@ -50,9 +51,9 @@ export const codemod: Codemod = {
|
|
|
50
51
|
return NOTHING;
|
|
51
52
|
}
|
|
52
53
|
// `verify-floor-skips` already reports a floor that is not a JSON object.
|
|
53
|
-
if (!
|
|
54
|
+
if (!isJsonObject(floor) || !Array.isArray(floor['steps'])) return NOTHING;
|
|
54
55
|
const held: unknown[] = floor['steps'];
|
|
55
|
-
const skip =
|
|
56
|
+
const skip = isJsonObject(floor['skip']) ? floor['skip'] : {};
|
|
56
57
|
const wanted = floorSteps(await floorSuites(app)).steps;
|
|
57
58
|
const added = wanted.filter((step) => !held.includes(step) && !(step in skip));
|
|
58
59
|
// `steps` replaced where it stands: the app's key order kept.
|
package/src/db-seed.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
// why: `node:path` for the joiner and the app-root-relative spelling every finding is keyed by; Bun
|
|
9
9
|
// exposes neither.
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
import type { Environment } from '@ultimat3/core';
|
|
12
12
|
import { UltimateError } from '@ultimat3/core';
|
|
13
13
|
import type { Driver, Seed, SeedTier } from '@ultimat3/entity';
|
|
@@ -16,6 +16,7 @@ import { BadFlagError } from './errors';
|
|
|
16
16
|
import type { Finding, JsonValue } from './output';
|
|
17
17
|
import { findingFrom } from './output';
|
|
18
18
|
import { hasPathSegment } from './path-segments';
|
|
19
|
+
import { posixRelative } from './posix-path';
|
|
19
20
|
import { quoteArg } from './shell-quote';
|
|
20
21
|
import { isTest } from './source-files';
|
|
21
22
|
import { renderTable } from './table';
|
|
@@ -104,7 +105,7 @@ export async function discoverSeeds(root: string): Promise<SeedDiscovery> {
|
|
|
104
105
|
const seen = new Set<string>();
|
|
105
106
|
for (const pattern of SEED_GLOBS) {
|
|
106
107
|
for await (const absolute of new Bun.Glob(pattern).scan({ cwd: root, absolute: true })) {
|
|
107
|
-
const file =
|
|
108
|
+
const file = posixRelative(root, absolute);
|
|
108
109
|
// Root-relative, as `loadApp` tests it: an absolute path under `my.test.app/` is no test.
|
|
109
110
|
if (hasPathSegment(absolute, 'node_modules') || isTest(file)) continue;
|
|
110
111
|
if (seen.has(absolute)) continue;
|