@ultimat3/cli 31.31.0 → 31.32.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/package.json +29 -29
- package/src/app-boundaries.ts +11 -7
- package/src/cdp-shot-driver.ts +21 -5
- package/src/ci-runs.ts +7 -3
- package/src/cmd-build.ts +11 -7
- package/src/cmd-ci.ts +1 -1
- package/src/cmd-db-backfill.ts +8 -5
- package/src/cmd-deploy.ts +1 -1
- package/src/cmd-i18n.ts +3 -2
- package/src/cmd-planned.ts +2 -1
- package/src/cmd-repro.ts +8 -2
- package/src/cmd-shot-island.ts +4 -2
- package/src/cmd-test.ts +5 -2
- package/src/db-seed.ts +2 -1
- package/src/dev-lock.ts +2 -2
- package/src/duplicate-packages.ts +5 -1
- package/src/errors.ts +11 -10
- package/src/flag-number.ts +2 -1
- package/src/generate-files.ts +1 -1
- package/src/generate-kinds.ts +2 -2
- package/src/gh-target.ts +3 -2
- package/src/guards.ts +2 -1
- package/src/i18n-registration.ts +2 -1
- package/src/island-capture.ts +5 -4
- package/src/island-shot-errors.ts +2 -1
- package/src/mcp-errors.ts +3 -1
- package/src/parse.ts +3 -3
- package/src/pr-threads.ts +2 -1
- package/src/role-start.ts +3 -2
- package/src/role-sync.ts +2 -1
- package/src/schema-drift.ts +11 -14
- package/src/shell-quote.ts +8 -1
- package/src/shot-locale.ts +2 -1
- package/src/shot-route.ts +2 -1
- package/src/static-report.ts +18 -15
- package/src/test-select.ts +1 -1
- package/src/verify-floor.ts +2 -1
- package/src/verify-services.ts +2 -1
- package/src/workspace-checks.ts +4 -3
- package/src/workspace-external-deps.ts +4 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimat3/cli",
|
|
3
|
-
"version": "31.
|
|
3
|
+
"version": "31.32.0",
|
|
4
4
|
"description": "The `x` binary: new, dev, build, verify, generate, db, mcp, doctor, deploy",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ultimate",
|
|
@@ -53,34 +53,34 @@
|
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@babel/core": "^8.0.10",
|
|
56
|
-
"@ultimat3/action": "31.
|
|
57
|
-
"@ultimat3/admin": "31.
|
|
58
|
-
"@ultimat3/ai": "31.
|
|
59
|
-
"@ultimat3/auth": "31.
|
|
60
|
-
"@ultimat3/cache": "31.
|
|
61
|
-
"@ultimat3/core": "31.
|
|
62
|
-
"@ultimat3/db": "31.
|
|
63
|
-
"@ultimat3/entity": "31.
|
|
64
|
-
"@ultimat3/flags": "31.
|
|
65
|
-
"@ultimat3/http": "31.
|
|
66
|
-
"@ultimat3/i18n": "31.
|
|
67
|
-
"@ultimat3/jobs": "31.
|
|
68
|
-
"@ultimat3/mail": "31.
|
|
69
|
-
"@ultimat3/manifest": "31.
|
|
70
|
-
"@ultimat3/mcp": "31.
|
|
71
|
-
"@ultimat3/money": "31.
|
|
72
|
-
"@ultimat3/notify": "31.
|
|
73
|
-
"@ultimat3/policy": "31.
|
|
74
|
-
"@ultimat3/pwa": "31.
|
|
75
|
-
"@ultimat3/query": "31.
|
|
76
|
-
"@ultimat3/realtime": "31.
|
|
77
|
-
"@ultimat3/render": "31.
|
|
78
|
-
"@ultimat3/schema": "31.
|
|
79
|
-
"@ultimat3/scraping": "31.
|
|
80
|
-
"@ultimat3/seo": "31.
|
|
81
|
-
"@ultimat3/storage": "31.
|
|
82
|
-
"@ultimat3/testing": "31.
|
|
83
|
-
"@ultimat3/time": "31.
|
|
56
|
+
"@ultimat3/action": "31.32.0",
|
|
57
|
+
"@ultimat3/admin": "31.32.0",
|
|
58
|
+
"@ultimat3/ai": "31.32.0",
|
|
59
|
+
"@ultimat3/auth": "31.32.0",
|
|
60
|
+
"@ultimat3/cache": "31.32.0",
|
|
61
|
+
"@ultimat3/core": "31.32.0",
|
|
62
|
+
"@ultimat3/db": "31.32.0",
|
|
63
|
+
"@ultimat3/entity": "31.32.0",
|
|
64
|
+
"@ultimat3/flags": "31.32.0",
|
|
65
|
+
"@ultimat3/http": "31.32.0",
|
|
66
|
+
"@ultimat3/i18n": "31.32.0",
|
|
67
|
+
"@ultimat3/jobs": "31.32.0",
|
|
68
|
+
"@ultimat3/mail": "31.32.0",
|
|
69
|
+
"@ultimat3/manifest": "31.32.0",
|
|
70
|
+
"@ultimat3/mcp": "31.32.0",
|
|
71
|
+
"@ultimat3/money": "31.32.0",
|
|
72
|
+
"@ultimat3/notify": "31.32.0",
|
|
73
|
+
"@ultimat3/policy": "31.32.0",
|
|
74
|
+
"@ultimat3/pwa": "31.32.0",
|
|
75
|
+
"@ultimat3/query": "31.32.0",
|
|
76
|
+
"@ultimat3/realtime": "31.32.0",
|
|
77
|
+
"@ultimat3/render": "31.32.0",
|
|
78
|
+
"@ultimat3/schema": "31.32.0",
|
|
79
|
+
"@ultimat3/scraping": "31.32.0",
|
|
80
|
+
"@ultimat3/seo": "31.32.0",
|
|
81
|
+
"@ultimat3/storage": "31.32.0",
|
|
82
|
+
"@ultimat3/testing": "31.32.0",
|
|
83
|
+
"@ultimat3/time": "31.32.0",
|
|
84
84
|
"babel-preset-solid": "^1.9.16"
|
|
85
85
|
}
|
|
86
86
|
}
|
package/src/app-boundaries.ts
CHANGED
|
@@ -50,13 +50,17 @@ export interface SourceFile {
|
|
|
50
50
|
readonly source: string;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
53
|
+
// Null-prototype: a rule that is not one of these reads `undefined`, never an `Object` member.
|
|
54
|
+
const CODE_OF: Readonly<Record<BoundaryRule, BoundaryCode>> = Object.assign(
|
|
55
|
+
Object.create(null) as object,
|
|
56
|
+
{
|
|
57
|
+
'site-imports-app': 'X_BOUNDARY_SITE_TO_APP',
|
|
58
|
+
'shared-is-a-leaf': 'X_BOUNDARY_SHARED_LEAF',
|
|
59
|
+
'app-imports-api-at-runtime': 'X_BOUNDARY_APP_TO_API',
|
|
60
|
+
// Every other crossing `SURFACE_SPECS` does not allow: the table is the rule (`@ultimat3/render`).
|
|
61
|
+
'surface-imports-surface': 'X_BOUNDARY_SURFACE_IMPORT',
|
|
62
|
+
} satisfies Record<BoundaryRule, BoundaryCode>,
|
|
63
|
+
);
|
|
60
64
|
|
|
61
65
|
/**
|
|
62
66
|
* The one rule → diagnostic-code mapping. `x verify` reports a surface violation as a finding and
|
package/src/cdp-shot-driver.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// else runs over `--cdp-url`. One `open()` is one browser and one page, so a picture's console and
|
|
4
4
|
// network are its own. The page is `cdp-shot-page.ts`; this file is the session around it.
|
|
5
5
|
|
|
6
|
+
import { renderThrowable } from '@ultimat3/core';
|
|
6
7
|
import type { CdpConnection, LaunchedBrowser } from '@ultimat3/scraping/cdp';
|
|
7
8
|
import {
|
|
8
9
|
CdpBrowserMissingError,
|
|
@@ -31,7 +32,7 @@ export interface CdpShotDriverOptions {
|
|
|
31
32
|
| ((executable: string, timeoutMs: number) => Promise<LaunchedBrowser>)
|
|
32
33
|
| undefined;
|
|
33
34
|
readonly connect?: ((endpoint: string, timeoutMs: number) => Promise<CdpConnection>) | undefined;
|
|
34
|
-
readonly fetchJson?: ((url: string) => Promise<unknown>) | undefined;
|
|
35
|
+
readonly fetchJson?: ((url: string, timeoutMs: number) => Promise<unknown>) | undefined;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
const field = (value: unknown, key: string): string | undefined => {
|
|
@@ -46,11 +47,12 @@ const field = (value: unknown, key: string): string | undefined => {
|
|
|
46
47
|
*/
|
|
47
48
|
async function socketUrl(
|
|
48
49
|
cdpUrl: string,
|
|
49
|
-
|
|
50
|
+
timeoutMs: number,
|
|
51
|
+
fetchJson: (url: string, timeoutMs: number) => Promise<unknown>,
|
|
50
52
|
): Promise<string> {
|
|
51
53
|
if (cdpUrl.startsWith('ws://') || cdpUrl.startsWith('wss://')) return cdpUrl;
|
|
52
54
|
const version = new URL('/json/version', cdpUrl).toString();
|
|
53
|
-
const socket = field(await fetchJson(version), 'webSocketDebuggerUrl');
|
|
55
|
+
const socket = field(await fetchJson(version, timeoutMs), 'webSocketDebuggerUrl');
|
|
54
56
|
if (socket === undefined) {
|
|
55
57
|
throw new CdpCallFailedError({
|
|
56
58
|
method: `GET ${version}`,
|
|
@@ -60,7 +62,17 @@ async function socketUrl(
|
|
|
60
62
|
return socket;
|
|
61
63
|
}
|
|
62
64
|
|
|
63
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Under the session's own deadline: a sidecar that accepts the socket and never answers held
|
|
67
|
+
* `x shot` for as long as it liked, because nothing else bounds this one request.
|
|
68
|
+
*/
|
|
69
|
+
const defaultFetchJson = async (url: string, timeoutMs: number): Promise<unknown> => {
|
|
70
|
+
try {
|
|
71
|
+
return await (await fetch(url, { signal: AbortSignal.timeout(timeoutMs) })).json();
|
|
72
|
+
} catch (error) {
|
|
73
|
+
throw new CdpCallFailedError({ method: `GET ${url}`, detail: renderThrowable(error) });
|
|
74
|
+
}
|
|
75
|
+
};
|
|
64
76
|
|
|
65
77
|
export function cdpShotDriver(options: CdpShotDriverOptions): ShotDriver {
|
|
66
78
|
const viewport = options.viewport ?? DEFAULT_SHOT_VIEWPORT;
|
|
@@ -76,7 +88,11 @@ export function cdpShotDriver(options: CdpShotDriverOptions): ShotDriver {
|
|
|
76
88
|
timeoutMs: number,
|
|
77
89
|
): Promise<{ connection: CdpConnection; end: () => Promise<void> }> => {
|
|
78
90
|
if (options.cdpUrl !== undefined) {
|
|
79
|
-
const endpoint = await socketUrl(
|
|
91
|
+
const endpoint = await socketUrl(
|
|
92
|
+
options.cdpUrl,
|
|
93
|
+
timeoutMs,
|
|
94
|
+
options.fetchJson ?? defaultFetchJson,
|
|
95
|
+
);
|
|
80
96
|
const connection = await connect(endpoint, timeoutMs);
|
|
81
97
|
return {
|
|
82
98
|
connection,
|
package/src/ci-runs.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { t } from '@ultimat3/schema';
|
|
|
6
6
|
import type { GhHost } from './gh';
|
|
7
7
|
import { ghJson, runGh } from './gh';
|
|
8
8
|
import type { GhRepo } from './gh-target';
|
|
9
|
+
import { quoteArg } from './shell-quote';
|
|
9
10
|
|
|
10
11
|
/** The fields both `gh run list` and `gh run view` accept, named once so the two agree. */
|
|
11
12
|
export const RUN_FIELDS =
|
|
@@ -162,7 +163,7 @@ export async function listRuns(
|
|
|
162
163
|
RUN_LIST,
|
|
163
164
|
{
|
|
164
165
|
label: `gh run list --branch ${branch}`,
|
|
165
|
-
fix: `x ci --branch ${branch} --repo ${repo.slug} --json`,
|
|
166
|
+
fix: `x ci --branch ${quoteArg(branch)} --repo ${quoteArg(repo.slug)} --json`,
|
|
166
167
|
},
|
|
167
168
|
);
|
|
168
169
|
return rows.map(runOf);
|
|
@@ -178,7 +179,10 @@ export async function viewRun(
|
|
|
178
179
|
host,
|
|
179
180
|
['run', 'view', String(id), '--repo', repo.slug, '--json', `${RUN_FIELDS},jobs`],
|
|
180
181
|
RUN_VIEW,
|
|
181
|
-
{
|
|
182
|
+
{
|
|
183
|
+
label: `gh run view ${id}`,
|
|
184
|
+
fix: `x ci --run ${quoteArg(String(id))} --repo ${quoteArg(repo.slug)} --json`,
|
|
185
|
+
},
|
|
182
186
|
);
|
|
183
187
|
const jobs = viewed.jobs.map((job) => ({
|
|
184
188
|
...job,
|
|
@@ -199,7 +203,7 @@ export async function failedLog(host: GhHost, repo: GhRepo, id: number): Promise
|
|
|
199
203
|
['run', 'view', String(id), '--repo', repo.slug, '--log-failed'],
|
|
200
204
|
{
|
|
201
205
|
label: `gh run view ${id} --log-failed`,
|
|
202
|
-
fix: `gh run view ${id} --repo ${repo.slug} --log # the whole log, when the failed steps carry none`,
|
|
206
|
+
fix: `gh run view ${quoteArg(String(id))} --repo ${quoteArg(repo.slug)} --log # the whole log, when the failed steps carry none`,
|
|
203
207
|
},
|
|
204
208
|
);
|
|
205
209
|
return result.stdout;
|
package/src/cmd-build.ts
CHANGED
|
@@ -69,13 +69,17 @@ export function readTarget(raw: string | undefined): BuildTarget {
|
|
|
69
69
|
* has to refuse a missing entry by name before it spawns anything, and the spawned command has to
|
|
70
70
|
* name the same file — a second copy is how `binary` came to compile a path `x new` never wrote.
|
|
71
71
|
*/
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
72
|
+
// Null-prototype: a target that is not one of these reads `undefined`, never an `Object` member.
|
|
73
|
+
export const BUILD_ENTRY: Readonly<Record<BuildTarget, string>> = Object.assign(
|
|
74
|
+
Object.create(null) as object,
|
|
75
|
+
{
|
|
76
|
+
docker: 'docker/Dockerfile',
|
|
77
|
+
binary: 'apps/web/server.ts',
|
|
78
|
+
static: 'apps/web/prerender.ts',
|
|
79
|
+
// What boots from the store: an image with no server entry has nothing to prebuild for.
|
|
80
|
+
prebuilt: 'apps/web/server.ts',
|
|
81
|
+
} satisfies Record<BuildTarget, string>,
|
|
82
|
+
);
|
|
79
83
|
|
|
80
84
|
/** Absolute path of the target's entry, or the error that names the file and what writes it. */
|
|
81
85
|
export function requireEntry(root: string, target: BuildTarget): string {
|
package/src/cmd-ci.ts
CHANGED
|
@@ -75,7 +75,7 @@ export class CiRunNotFoundError extends UltimateError {
|
|
|
75
75
|
super({
|
|
76
76
|
code: 'X_CI_RUN_NOT_FOUND',
|
|
77
77
|
cause: `no workflow run on ${input.repo} for branch "${input.branch}"${matching}`,
|
|
78
|
-
fix: `x ci --branch main --repo ${input.repo} --json`,
|
|
78
|
+
fix: `x ci --branch main --repo ${quoteArg(input.repo)} --json`,
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
}
|
package/src/cmd-db-backfill.ts
CHANGED
|
@@ -47,11 +47,14 @@ const SHAPE_OF_FLAG = Object.freeze<Record<string, BackfillShape>>({
|
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
/** One runnable line per shape, so a refusal hands back the invocation the caller meant. */
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
// Null-prototype: a shape that is not one of these reads `undefined`, never an `Object` member.
|
|
51
|
+
const FIX_OF_SHAPE: Readonly<Record<BackfillShape, string>> = Object.freeze(
|
|
52
|
+
Object.assign(Object.create(null) as object, {
|
|
53
|
+
list: 'x db backfill --list --json',
|
|
54
|
+
pending: 'x db backfill --pending --json',
|
|
55
|
+
pass: 'x db backfill --all --write --json',
|
|
56
|
+
} satisfies Record<BackfillShape, string>),
|
|
57
|
+
);
|
|
55
58
|
|
|
56
59
|
const refuseShape = (flag: string, reason: string, fix: string): never => {
|
|
57
60
|
throw new BadFlagError({ flag, command: 'db', reason, fix });
|
package/src/cmd-deploy.ts
CHANGED
|
@@ -209,7 +209,7 @@ export function planDeploy(
|
|
|
209
209
|
flag: 'image',
|
|
210
210
|
command: 'deploy',
|
|
211
211
|
reason: `"${image}" pins a digest, and docker/helm renders repository:tag with no digest branch`,
|
|
212
|
-
fix: `x deploy --method helm --image ${image.slice(0, image.lastIndexOf('@'))}:<tag> --json`,
|
|
212
|
+
fix: `x deploy --method helm --image ${quoteArg(image.slice(0, image.lastIndexOf('@')))}:<tag> --json`,
|
|
213
213
|
});
|
|
214
214
|
}
|
|
215
215
|
// Helm splits a `--set-string` argument on `,` and reads `=` as key/value: an image built from
|
package/src/cmd-i18n.ts
CHANGED
|
@@ -38,6 +38,7 @@ import {
|
|
|
38
38
|
} from './i18n-registration';
|
|
39
39
|
import { msg } from './messages';
|
|
40
40
|
import type { CommandResult, Finding, JsonValue } from './output';
|
|
41
|
+
import { quoteArg } from './shell-quote';
|
|
41
42
|
import { renderTable } from './table';
|
|
42
43
|
import { catalogPath, resolveLocales } from './templates/locales';
|
|
43
44
|
|
|
@@ -104,7 +105,7 @@ function requireLocalePositional(ctx: CommandContext, sub: string): string {
|
|
|
104
105
|
function resolveOneLocale(ctx: CommandContext, sub: string): string {
|
|
105
106
|
const raw = requireLocalePositional(ctx, sub);
|
|
106
107
|
const resolved = resolveLocales([raw], {
|
|
107
|
-
fix: `x i18n ${sub} es`,
|
|
108
|
+
fix: `x i18n ${quoteArg(sub)} es`,
|
|
108
109
|
command: 'i18n',
|
|
109
110
|
flag: 'locale',
|
|
110
111
|
});
|
|
@@ -315,7 +316,7 @@ async function runSync(root: string, ctx: CommandContext): Promise<CommandResult
|
|
|
315
316
|
flag: 'locale',
|
|
316
317
|
command: 'i18n',
|
|
317
318
|
reason: `no catalog for "${locale}" at ${catalogPath(locale)}`,
|
|
318
|
-
fix: `x i18n add ${locale}`,
|
|
319
|
+
fix: `x i18n add ${quoteArg(locale)}`,
|
|
319
320
|
});
|
|
320
321
|
}
|
|
321
322
|
|
package/src/cmd-planned.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { NotImplementedError } from '@ultimat3/core';
|
|
|
7
7
|
import type { CliCommand } from './command';
|
|
8
8
|
import type { CommandResult } from './output';
|
|
9
9
|
import type { CommandSpec } from './parse';
|
|
10
|
+
import { quoteArg } from './shell-quote';
|
|
10
11
|
|
|
11
12
|
export interface PlannedCommand {
|
|
12
13
|
readonly name: string;
|
|
@@ -97,7 +98,7 @@ export function plannedSubcommand(command: string, subcommand: string): NotImple
|
|
|
97
98
|
cause: `x ${command} ${subcommand} is not implemented in this build`,
|
|
98
99
|
// `x help <command>`, not `x <command> --help`: for a command that declares subcommands and no
|
|
99
100
|
// default, the latter is refused by the parser before help is ever rendered.
|
|
100
|
-
fix: planned?.fix ?? `x help ${command}`,
|
|
101
|
+
fix: planned?.fix ?? `x help ${quoteArg(command.split(' '))}`,
|
|
101
102
|
});
|
|
102
103
|
}
|
|
103
104
|
|
package/src/cmd-repro.ts
CHANGED
|
@@ -172,7 +172,10 @@ export const reproCommand: CliCommand = {
|
|
|
172
172
|
flag: 'include-rows',
|
|
173
173
|
command: 'repro',
|
|
174
174
|
reason: 'it chooses what a bundle carries, and no --bundle was asked for',
|
|
175
|
-
fix:
|
|
175
|
+
fix:
|
|
176
|
+
id === undefined
|
|
177
|
+
? 'x repro --from <file> --bundle --include-rows'
|
|
178
|
+
: `x repro ${renderFixShellArg(id, '<id>')} --bundle --include-rows`,
|
|
176
179
|
});
|
|
177
180
|
}
|
|
178
181
|
if (bundle && (flagBool(ctx.args, 'write') || flagBool(ctx.args, 'verify'))) {
|
|
@@ -180,7 +183,10 @@ export const reproCommand: CliCommand = {
|
|
|
180
183
|
flag: 'bundle',
|
|
181
184
|
command: 'repro',
|
|
182
185
|
reason: 'a bundle is written for an issue, and --write/--verify run the test in this app',
|
|
183
|
-
fix:
|
|
186
|
+
fix:
|
|
187
|
+
id === undefined
|
|
188
|
+
? 'x repro --from <file> --bundle'
|
|
189
|
+
: `x repro ${renderFixShellArg(id, '<id>')} --bundle`,
|
|
184
190
|
});
|
|
185
191
|
}
|
|
186
192
|
// The app's declarations are what mask a job's input and what a written test replays against.
|
package/src/cmd-shot-island.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
// why: no Bun native joins or resolves a path; `--out` is resolved against the app root.
|
|
11
11
|
import { join, resolve } from 'node:path';
|
|
12
|
+
import { renderFixShellArg } from '@ultimat3/core';
|
|
12
13
|
import type { IslandStatesManifest, IslandViewport } from '@ultimat3/testing';
|
|
13
14
|
import { findIslandStates } from '@ultimat3/testing';
|
|
14
15
|
import { appBrowser } from './browser-launcher';
|
|
@@ -26,6 +27,7 @@ import {
|
|
|
26
27
|
islandVerdictJson,
|
|
27
28
|
} from './island-verdict';
|
|
28
29
|
import type { CommandResult } from './output';
|
|
30
|
+
import { quoteArg } from './shell-quote';
|
|
29
31
|
import type { ShotCookiePair } from './shot-cookie';
|
|
30
32
|
import type { ShotServer } from './shot-server';
|
|
31
33
|
import { SHOT_DIR } from './shot-server';
|
|
@@ -71,7 +73,7 @@ export function readStateFlag(
|
|
|
71
73
|
flag: 'state',
|
|
72
74
|
command: 'shot',
|
|
73
75
|
reason: `${manifest.island} declares no state "${wanted}" — it declares ${known.join(', ')}`,
|
|
74
|
-
fix: `x shot --island ${manifest.name} --state ${known[0]
|
|
76
|
+
fix: `x shot --island ${quoteArg(manifest.name)} --state ${renderFixShellArg(known[0], '<id>')} --json`,
|
|
75
77
|
});
|
|
76
78
|
}
|
|
77
79
|
|
|
@@ -85,7 +87,7 @@ export function refuseRouteWithIsland(route: string | undefined, island: string)
|
|
|
85
87
|
flag: 'island',
|
|
86
88
|
command: 'shot',
|
|
87
89
|
reason: `--island ${island} photographs a component and "${route ?? ''}" is a route; x shot takes one subject`,
|
|
88
|
-
fix: `x shot --island ${island} --json`,
|
|
90
|
+
fix: `x shot --island ${quoteArg(island)} --json`,
|
|
89
91
|
});
|
|
90
92
|
}
|
|
91
93
|
|
package/src/cmd-test.ts
CHANGED
|
@@ -98,7 +98,7 @@ function readOnlyType(positionals: readonly string[]): TestType | undefined {
|
|
|
98
98
|
flag: 'type',
|
|
99
99
|
command: 'test',
|
|
100
100
|
reason: `takes at most one test type, got ${positionals.length}: ${positionals.join(' ')}`,
|
|
101
|
-
fix: `x test ${type} --filter ${quoteArg(second)}`,
|
|
101
|
+
fix: `x test ${quoteArg(type)} --filter ${quoteArg(second)}`,
|
|
102
102
|
});
|
|
103
103
|
}
|
|
104
104
|
|
|
@@ -119,7 +119,10 @@ async function readAffectedScope(ctx: CommandContext): Promise<AffectedScope | u
|
|
|
119
119
|
flag: idle,
|
|
120
120
|
command: 'test',
|
|
121
121
|
reason: 'only narrows a run together with --affected, and on its own it changes nothing',
|
|
122
|
-
fix:
|
|
122
|
+
fix:
|
|
123
|
+
idle === 'base'
|
|
124
|
+
? `x test --affected --base ${quoteArg(DEFAULT_BASE)}`
|
|
125
|
+
: 'x test --affected --dirty',
|
|
123
126
|
});
|
|
124
127
|
}
|
|
125
128
|
return undefined;
|
package/src/db-seed.ts
CHANGED
|
@@ -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 { quoteArg } from './shell-quote';
|
|
19
20
|
import { isTest } from './source-files';
|
|
20
21
|
import { renderTable } from './table';
|
|
21
22
|
|
|
@@ -74,7 +75,7 @@ export class SeedEnvironmentError extends UltimateError {
|
|
|
74
75
|
super({
|
|
75
76
|
code: 'X_SEED_ENVIRONMENT',
|
|
76
77
|
cause: `seed "${input.seed}" is tier ${input.tier} and ULTIMATE_ENV resolved ${input.environment}, where x db seed runs ${input.tiers.join(', ')} — ULTIMATE_SEED_TIER=${input.tier} says this deploy takes it anyway`,
|
|
77
|
-
fix: `x db seed ${input.seed} --tier ${input.tier} --json`,
|
|
78
|
+
fix: `x db seed ${quoteArg(input.seed)} --tier ${quoteArg(input.tier)} --json`,
|
|
78
79
|
});
|
|
79
80
|
}
|
|
80
81
|
}
|
package/src/dev-lock.ts
CHANGED
|
@@ -200,8 +200,8 @@ export class DevPortInUseError extends UltimateError {
|
|
|
200
200
|
cause: `:${input.port} is already bound by ${named}, so the web role cannot listen — on a machine running several projects this is usually another one's dev server, not a stale copy of this one`,
|
|
201
201
|
fix:
|
|
202
202
|
holder.pid === undefined
|
|
203
|
-
? `x dev --port ${input.suggestion}`
|
|
204
|
-
: `x dev --port ${input.suggestion} # or free it, if that pid is yours: kill ${holder.pid}`,
|
|
203
|
+
? `x dev --port ${quoteArg(String(input.suggestion))}`
|
|
204
|
+
: `x dev --port ${quoteArg(String(input.suggestion))} # or free it, if that pid is yours: kill ${holder.pid}`,
|
|
205
205
|
meta: { port: input.port, ...holder },
|
|
206
206
|
});
|
|
207
207
|
}
|
|
@@ -225,7 +225,11 @@ const manifestOf = (from: string): string | undefined =>
|
|
|
225
225
|
* app-relative one an agent can open.
|
|
226
226
|
*/
|
|
227
227
|
export function duplicateCause(root: string, duplicate: DuplicateInstall): string {
|
|
228
|
-
|
|
228
|
+
// The package name is data: `constructor` is a published package, and the bare read answered
|
|
229
|
+
// `Object`'s own function into the cause.
|
|
230
|
+
const registry = Object.hasOwn(REGISTRY_PACKAGES, duplicate.pkg)
|
|
231
|
+
? REGISTRY_PACKAGES[duplicate.pkg]
|
|
232
|
+
: 'registry';
|
|
229
233
|
const copies = duplicate.copies.map((copy) => renderCopy(root, copy)).join(' and ');
|
|
230
234
|
return (
|
|
231
235
|
`${duplicate.copies.length} copies of ${duplicate.pkg} are installed: ${copies} — each is ` +
|
package/src/errors.ts
CHANGED
|
@@ -17,7 +17,7 @@ export class UnknownCommandError extends UltimateError {
|
|
|
17
17
|
super({
|
|
18
18
|
code: 'X_CLI_UNKNOWN_COMMAND',
|
|
19
19
|
cause: `"x ${input.path}" is not a command (known: ${input.known.join(', ')})${input.why === undefined ? '' : ` — ${input.why}`}`,
|
|
20
|
-
fix: input.suggestion === undefined ? 'x help' : `x ${input.suggestion}`,
|
|
20
|
+
fix: input.suggestion === undefined ? 'x help' : `x ${quoteArg(input.suggestion.split(' '))}`,
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -32,7 +32,7 @@ export class BadFlagError extends UltimateError {
|
|
|
32
32
|
super({
|
|
33
33
|
code: 'X_CLI_BAD_FLAG',
|
|
34
34
|
cause: `--${input.flag} on "x ${input.command}": ${input.reason}`,
|
|
35
|
-
fix: input.fix ?? `x ${input.command} --help`,
|
|
35
|
+
fix: input.fix ?? `x ${quoteArg(input.command.split(' '))} --help`,
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -111,7 +111,7 @@ export class MissingSubcommandError extends UltimateError {
|
|
|
111
111
|
super({
|
|
112
112
|
code: 'X_CLI_BAD_FLAG',
|
|
113
113
|
cause: `"x ${input.command}" takes a subcommand and got none (one of: ${input.known.join(', ')})`,
|
|
114
|
-
fix: `x help ${input.command}`,
|
|
114
|
+
fix: `x help ${quoteArg(input.command.split(' '))}`,
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
117
|
}
|
|
@@ -245,7 +245,7 @@ export class CatalogExistsError extends UltimateError {
|
|
|
245
245
|
super({
|
|
246
246
|
code: 'X_GENERATE_CONFLICT',
|
|
247
247
|
cause: `${input.path} already exists`,
|
|
248
|
-
fix: `x i18n sync ${input.locale}`,
|
|
248
|
+
fix: `x i18n sync ${quoteArg(input.locale)}`,
|
|
249
249
|
});
|
|
250
250
|
}
|
|
251
251
|
}
|
|
@@ -277,7 +277,7 @@ export class ErrorCodeUnknownError extends UltimateError {
|
|
|
277
277
|
fix:
|
|
278
278
|
input.suggestion === undefined
|
|
279
279
|
? 'x errors list --json'
|
|
280
|
-
: `x errors explain ${input.suggestion}`,
|
|
280
|
+
: `x errors explain ${quoteArg(input.suggestion)}`,
|
|
281
281
|
});
|
|
282
282
|
}
|
|
283
283
|
}
|
|
@@ -302,8 +302,8 @@ export class DeclarationUnknownError extends UltimateError {
|
|
|
302
302
|
cause: `no ${input.singular} named "${input.name}" is registered (${input.known.length} known)`,
|
|
303
303
|
fix:
|
|
304
304
|
input.suggestion === undefined
|
|
305
|
-
? `x ${input.kind} list --json`
|
|
306
|
-
: `x ${input.kind} ${input.verb ?? 'show'} ${input.suggestion}`,
|
|
305
|
+
? `x ${quoteArg(input.kind)} list --json`
|
|
306
|
+
: `x ${quoteArg(input.kind)} ${quoteArg(input.verb ?? 'show')} ${quoteArg(input.suggestion)}`,
|
|
307
307
|
});
|
|
308
308
|
}
|
|
309
309
|
}
|
|
@@ -332,7 +332,7 @@ export class FixTargetUnknownError extends UltimateError {
|
|
|
332
332
|
fix:
|
|
333
333
|
input.suggestion === undefined
|
|
334
334
|
? 'x routes --json # every registered route file, app-root-relative'
|
|
335
|
-
: `x fix boundary ${input.suggestion}`,
|
|
335
|
+
: `x fix boundary ${quoteArg(input.suggestion)}`,
|
|
336
336
|
});
|
|
337
337
|
}
|
|
338
338
|
}
|
|
@@ -347,7 +347,7 @@ export class IslandBuildFailedError extends UltimateError {
|
|
|
347
347
|
super({
|
|
348
348
|
code: 'X_BUILD_FAILED',
|
|
349
349
|
cause: `${input.file} is an island entry point and would not bundle: ${input.logs}`,
|
|
350
|
-
fix: `bun build --target browser ${input.file}`,
|
|
350
|
+
fix: `bun build --target browser ${quoteArg(input.file)}`,
|
|
351
351
|
});
|
|
352
352
|
}
|
|
353
353
|
}
|
|
@@ -450,10 +450,11 @@ export class PortInvalidError extends UltimateError {
|
|
|
450
450
|
/** `name` so the scrape port reports itself; the code stays one, because the fault is one. */
|
|
451
451
|
constructor(input: { value: string; name?: string }) {
|
|
452
452
|
const name = input.name ?? 'PORT';
|
|
453
|
+
const example = quoteArg(`${name}=${name === 'PORT' ? 3000 : 9090}`);
|
|
453
454
|
super({
|
|
454
455
|
code: 'X_PORT_INVALID',
|
|
455
456
|
cause: `${name}="${input.value}" is not a TCP port number between 0 and 65535`,
|
|
456
|
-
fix: `docker run -e ${
|
|
457
|
+
fix: `docker run -e ${example} my-app:latest`,
|
|
457
458
|
});
|
|
458
459
|
}
|
|
459
460
|
}
|
package/src/flag-number.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { UltimateError } from '@ultimat3/core';
|
|
|
7
7
|
import { BadFlagError } from './errors';
|
|
8
8
|
import type { ParsedArgs } from './parse';
|
|
9
9
|
import { flagString } from './parse';
|
|
10
|
+
import { quoteArg } from './shell-quote';
|
|
10
11
|
|
|
11
12
|
export interface IntFlag {
|
|
12
13
|
readonly name: string;
|
|
@@ -93,7 +94,7 @@ class SyncPortUnavailableError extends UltimateError {
|
|
|
93
94
|
super({
|
|
94
95
|
code: 'X_PORT_INVALID',
|
|
95
96
|
cause: `the sync role binds PORT + 1, and PORT=${input.port} is the top of the range — it would ask for ${input.port + 1}, which is not a TCP port`,
|
|
96
|
-
fix: `x dev --port ${neighbouringPort(input.port)} # leaves ${PORT_RANGE.max} free for the sync node`,
|
|
97
|
+
fix: `x dev --port ${quoteArg(String(neighbouringPort(input.port)))} # leaves ${PORT_RANGE.max} free for the sync node`,
|
|
97
98
|
meta: { port: input.port },
|
|
98
99
|
});
|
|
99
100
|
}
|
package/src/generate-files.ts
CHANGED
|
@@ -335,7 +335,7 @@ export function generate(options: GenerateOptions): readonly GeneratedFile[] {
|
|
|
335
335
|
default:
|
|
336
336
|
throw new NotImplementedError({
|
|
337
337
|
cause: `generator "${String(options.kind)}" is not implemented in this build`,
|
|
338
|
-
fix: `x g ${GENERATORS.join('
|
|
338
|
+
fix: `x help g # one of: ${GENERATORS.join(', ')}`,
|
|
339
339
|
});
|
|
340
340
|
}
|
|
341
341
|
}
|
package/src/generate-kinds.ts
CHANGED
|
@@ -61,7 +61,7 @@ export function assertSurfaceSupported(kind: Generator, surface: Surface, name:
|
|
|
61
61
|
reason: 'a resource slice is app-surface — site/ ships 0kb JS and may not import app/',
|
|
62
62
|
// The caller's own name, not `<name>`: a `fix:` is copied and run verbatim, and `x g resource
|
|
63
63
|
// <name>` is a shell redirect (`bash: name: No such file or directory`), not a command.
|
|
64
|
-
fix: `x g resource ${name} && x g route ${name} --surface site`,
|
|
64
|
+
fix: `x g resource ${quoteArg(name)} && x g route ${quoteArg(name)} --surface site`,
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
67
|
|
|
@@ -134,7 +134,7 @@ export function readSurface(raw: string | undefined, kind: Generator, name: stri
|
|
|
134
134
|
flag: 'surface',
|
|
135
135
|
command: 'g',
|
|
136
136
|
reason: `"${raw}" is not a surface (site, app)`,
|
|
137
|
-
fix: `x g ${kind} ${name} --surface app`,
|
|
137
|
+
fix: `x g ${quoteArg(kind)} ${quoteArg(name)} --surface app`,
|
|
138
138
|
});
|
|
139
139
|
}
|
|
140
140
|
|
package/src/gh-target.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { t } from '@ultimat3/schema';
|
|
|
7
7
|
import { BadFlagError } from './errors';
|
|
8
8
|
import type { GhHost } from './gh';
|
|
9
9
|
import { GhFailedError, ghJson } from './gh';
|
|
10
|
+
import { quoteArg } from './shell-quote';
|
|
10
11
|
|
|
11
12
|
/** `owner/name`, split once so a caller never re-splits it and never re-joins it wrong. */
|
|
12
13
|
export interface GhRepo {
|
|
@@ -53,14 +54,14 @@ export async function resolveRepo(
|
|
|
53
54
|
flag: 'repo',
|
|
54
55
|
command,
|
|
55
56
|
reason: `"${flag}" is not an owner/name repository reference`,
|
|
56
|
-
fix: `x ${command} --repo developerz-ai/ultimate --json`,
|
|
57
|
+
fix: `x ${quoteArg(command.split(' '))} --repo developerz-ai/ultimate --json`,
|
|
57
58
|
});
|
|
58
59
|
}
|
|
59
60
|
return repoOf(flag);
|
|
60
61
|
}
|
|
61
62
|
const viewed = await ghJson(host, ['repo', 'view', '--json', 'nameWithOwner'], REPO_VIEW, {
|
|
62
63
|
label: 'gh repo view',
|
|
63
|
-
fix: `x ${command} --repo developerz-ai/ultimate --json`,
|
|
64
|
+
fix: `x ${quoteArg(command.split(' '))} --repo developerz-ai/ultimate --json`,
|
|
64
65
|
});
|
|
65
66
|
return repoOf(viewed.nameWithOwner);
|
|
66
67
|
}
|
package/src/guards.ts
CHANGED
|
@@ -25,6 +25,7 @@ export { GUARD_DIR, guardPaths } from './guards-paths';
|
|
|
25
25
|
|
|
26
26
|
import { vendoredCopy, vendoredFinding } from './guards-vendored';
|
|
27
27
|
import type { Finding } from './output';
|
|
28
|
+
import { quoteArg } from './shell-quote';
|
|
28
29
|
import { readVerifyFloor } from './verify-floor';
|
|
29
30
|
import type { GuardBaseline } from './verify-guard-baseline';
|
|
30
31
|
import { guardNameOf, judgeGuardBaseline, orphanedBaselineFindings } from './verify-guard-baseline';
|
|
@@ -151,7 +152,7 @@ const notAGuard = (path: string, exported: unknown): Finding => {
|
|
|
151
152
|
const notADirectory: Finding = {
|
|
152
153
|
code: 'X_GUARD_INVALID',
|
|
153
154
|
cause: `${GUARD_DIR} is not a directory, so none of this app's own guards can run beside the shipped ones`,
|
|
154
|
-
fix: `mv ${GUARD_DIR} ${GUARD_DIR}.txt && mkdir ${GUARD_DIR} && x verify --only boundaries --json # ${GUARD_DIR}/ is the directory the gate discovers; a rule of yours goes in it as ${GUARD_DIR}/<name>.ts`,
|
|
155
|
+
fix: `mv ${quoteArg(GUARD_DIR)} ${quoteArg(GUARD_DIR)}.txt && mkdir ${quoteArg(GUARD_DIR)} && x verify --only boundaries --json # ${GUARD_DIR}/ is the directory the gate discovers; a rule of yours goes in it as ${GUARD_DIR}/<name>.ts`,
|
|
155
156
|
docs: ERROR_DOCS_URL,
|
|
156
157
|
at: GUARD_DIR,
|
|
157
158
|
};
|
package/src/i18n-registration.ts
CHANGED
|
@@ -30,6 +30,7 @@ import { localeParityFindings } from './i18n-locale-parity';
|
|
|
30
30
|
import { mailPreviewFindings } from './mail-preview-findings';
|
|
31
31
|
import type { Finding } from './output';
|
|
32
32
|
import { findingFrom } from './output';
|
|
33
|
+
import { quoteArg } from './shell-quote';
|
|
33
34
|
import { CATALOG_ROOT, catalogPath } from './templates/locales';
|
|
34
35
|
|
|
35
36
|
/** The one package this check probes for a duplicate: its registry is the one it reads. */
|
|
@@ -212,7 +213,7 @@ export function unregisteredFix(
|
|
|
212
213
|
// report a registered locale as unregistered, which is the direction that costs trust.
|
|
213
214
|
if (index.includes(`${CATALOG_ROOT.split('/').pop() ?? 'catalogs'}/${locale}.json`)) return {};
|
|
214
215
|
return {
|
|
215
|
-
fix: `x i18n sync ${locale} # re-derives ${APP_CATALOGS_PATH} from the catalogs on disk`,
|
|
216
|
+
fix: `x i18n sync ${quoteArg(locale)} # re-derives ${APP_CATALOGS_PATH} from the catalogs on disk`,
|
|
216
217
|
};
|
|
217
218
|
}
|
|
218
219
|
|
package/src/island-capture.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { readinessProbe } from './island-harness-script';
|
|
|
14
14
|
import { IslandRequestUnstubbedError, IslandUnphotographableError } from './island-shot-errors';
|
|
15
15
|
import type { IslandReadiness, IslandStateShot } from './island-verdict';
|
|
16
16
|
import { parseReadiness } from './island-verdict';
|
|
17
|
+
import { quoteArg } from './shell-quote';
|
|
17
18
|
import { type ShotCookiePair, shotCookies } from './shot-cookie';
|
|
18
19
|
import type { ShotServer } from './shot-server';
|
|
19
20
|
import { allowHostsFrom } from './shot-server';
|
|
@@ -71,11 +72,11 @@ export function photographFault(
|
|
|
71
72
|
target: IslandShotTarget,
|
|
72
73
|
seen: IslandReadiness | null,
|
|
73
74
|
): Refusal | undefined {
|
|
74
|
-
const settle = `x shot --island ${target.name} --settle 8000 --json`;
|
|
75
|
+
const settle = `x shot --island ${quoteArg(target.name)} --settle 8000 --json`;
|
|
75
76
|
if (seen === null) {
|
|
76
77
|
return {
|
|
77
78
|
reason: 'answered no readiness probe at all, so nothing about the page can be asserted',
|
|
78
|
-
fix: `x shot --island ${target.name} --state ${target.state} --timeout 60000 --json`,
|
|
79
|
+
fix: `x shot --island ${quoteArg(target.name)} --state ${quoteArg(target.state)} --timeout 60000 --json`,
|
|
79
80
|
};
|
|
80
81
|
}
|
|
81
82
|
if (!seen.harness) {
|
|
@@ -91,7 +92,7 @@ export function photographFault(
|
|
|
91
92
|
if (seen.failed !== null) {
|
|
92
93
|
return {
|
|
93
94
|
reason: `mounted and its mount() REJECTED: ${seen.failed}`,
|
|
94
|
-
fix: `x shot --island ${target.name} --state ${target.state} --json # the verdict carries the throw and its frame`,
|
|
95
|
+
fix: `x shot --island ${quoteArg(target.name)} --state ${quoteArg(target.state)} --json # the verdict carries the throw and its frame`,
|
|
95
96
|
};
|
|
96
97
|
}
|
|
97
98
|
if (!seen.mounted) {
|
|
@@ -265,7 +266,7 @@ export async function captureIslandState(
|
|
|
265
266
|
state: target.state,
|
|
266
267
|
theme: target.theme,
|
|
267
268
|
reason: `produced ${bytes.byteLength} bytes, under the ${floor}-byte floor — that is not an image`,
|
|
268
|
-
fix: `x shot --island ${target.name} --browser /usr/bin/chromium --json # macOS: --browser "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"; Windows: --browser "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"`,
|
|
269
|
+
fix: `x shot --island ${quoteArg(target.name)} --browser /usr/bin/chromium --json # macOS: --browser "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"; Windows: --browser "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"`,
|
|
269
270
|
});
|
|
270
271
|
}
|
|
271
272
|
await Bun.write(join(options.outDir, target.file), bytes);
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// call stay in `error-codes.ts`: one owner, one registration, one place a duplicate can surface.
|
|
4
4
|
|
|
5
5
|
import { renderCauseValue, renderFixLiteral, UltimateError } from '@ultimat3/core';
|
|
6
|
+
import { quoteArg } from './shell-quote';
|
|
6
7
|
|
|
7
8
|
// No `docs:` on the subclasses below. `UltimateError` fills it from `describeErrorCode(code).docs`.
|
|
8
9
|
|
|
@@ -87,7 +88,7 @@ export class IslandShotsMissingError extends UltimateError {
|
|
|
87
88
|
super({
|
|
88
89
|
code: 'X_SHOT_ISLAND_MISSING',
|
|
89
90
|
cause: `${input.missing.length} of ${input.expected} declared picture(s) are not on disk under ${renderCauseValue(input.dir)}: ${input.missing.join(', ')}`,
|
|
90
|
-
fix: `x shot --island ${input.island} --json # the run above names why each one was refused`,
|
|
91
|
+
fix: `x shot --island ${quoteArg(input.island)} --json # the run above names why each one was refused`,
|
|
91
92
|
meta: { island: input.island, missing: [...input.missing] },
|
|
92
93
|
});
|
|
93
94
|
}
|
package/src/mcp-errors.ts
CHANGED
|
@@ -475,7 +475,9 @@ export function explainErrorCode(code: string): ErrorExplanation | undefined {
|
|
|
475
475
|
return {
|
|
476
476
|
code,
|
|
477
477
|
cause: described.title,
|
|
478
|
-
|
|
478
|
+
// `Object.hasOwn`, not `isCliCode` alone: the code is an MCP caller's, and the guard above is a
|
|
479
|
+
// list the table could drift from — `constructor` must never answer `Object`'s function here.
|
|
480
|
+
fix: cli && Object.hasOwn(CLI_FIXES, code) ? CLI_FIXES[code] : projectedFix(code),
|
|
479
481
|
docs: described.docs,
|
|
480
482
|
};
|
|
481
483
|
}
|
package/src/parse.ts
CHANGED
|
@@ -176,7 +176,7 @@ export function parseArgs(argv: readonly string[], specs: readonly CommandSpec[]
|
|
|
176
176
|
flag: '',
|
|
177
177
|
command: spec.name,
|
|
178
178
|
reason: `hands nothing to another tool, so ${passthrough.join(' ')} would be dropped in silence`,
|
|
179
|
-
fix: `x ${spec.name} --help`,
|
|
179
|
+
fix: `x ${quoteArg(spec.name)} --help`,
|
|
180
180
|
});
|
|
181
181
|
}
|
|
182
182
|
const flags = defaults(spec);
|
|
@@ -288,12 +288,12 @@ function assertFlagsApply(
|
|
|
288
288
|
const only = flag.subcommands;
|
|
289
289
|
if (only === undefined || only.includes(subcommand) || !given.has(flag.name)) continue;
|
|
290
290
|
const value = flags.get(flag.name);
|
|
291
|
-
const
|
|
291
|
+
const invocation = `x ${quoteArg(spec.name)} ${quoteArg(only[0] ?? subcommand)} --${quoteArg(flag.name)}`;
|
|
292
292
|
throw new BadFlagError({
|
|
293
293
|
flag: flag.name,
|
|
294
294
|
command: `${spec.name} ${subcommand}`,
|
|
295
295
|
reason: `read by ${only.map((word) => `x ${spec.name} ${word}`).join(' / ')} only — "${subcommand}" would ignore it`,
|
|
296
|
-
fix:
|
|
296
|
+
fix: typeof value === 'string' ? `${invocation} ${quoteArg(value)}` : invocation,
|
|
297
297
|
});
|
|
298
298
|
}
|
|
299
299
|
}
|
package/src/pr-threads.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { GhResponseInvalidError, ghGraphql } from './gh';
|
|
|
9
9
|
import type { GhRepo } from './gh-target';
|
|
10
10
|
import type { PrActivity } from './pr-activity';
|
|
11
11
|
import { ACTIVITY_FIELDS, ACTIVITY_SCHEMA, activityOf } from './pr-activity';
|
|
12
|
+
import { quoteArg } from './shell-quote';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* How many threads one page holds. The query is built from it, so the report and the request can
|
|
@@ -184,7 +185,7 @@ export async function fetchReviewReport(
|
|
|
184
185
|
REVIEW_RESPONSE,
|
|
185
186
|
{
|
|
186
187
|
label: `gh api graphql (review threads on ${repo.slug}#${number})`,
|
|
187
|
-
fix: `gh pr view ${number} --repo ${repo.slug} --json number # confirm the pull request is visible to this token`,
|
|
188
|
+
fix: `gh pr view ${quoteArg(String(number))} --repo ${quoteArg(repo.slug)} --json number # confirm the pull request is visible to this token`,
|
|
188
189
|
},
|
|
189
190
|
);
|
|
190
191
|
const pull = response.data.repository?.pullRequest;
|
package/src/role-start.ts
CHANGED
|
@@ -54,6 +54,7 @@ import { startLiveFeed } from './runtime-live-feed';
|
|
|
54
54
|
import { type RunningServices, releaseOrThrow } from './runtime-services';
|
|
55
55
|
import { inlineScriptSources } from './script-csp';
|
|
56
56
|
import { bootWarningConcernsAny } from './serve-boot-warnings';
|
|
57
|
+
import { quoteArg } from './shell-quote';
|
|
57
58
|
import { inlineStyleSources } from './style-csp';
|
|
58
59
|
import { syncConnectSources } from './sync-url';
|
|
59
60
|
import { trustedHopsFromEnv } from './trusted-hops';
|
|
@@ -93,7 +94,7 @@ export function selectRoles(flag: string | undefined): readonly Role[] {
|
|
|
93
94
|
flag: 'role',
|
|
94
95
|
command: 'dev',
|
|
95
96
|
reason: `"${name}" is not a role (known: ${ROLES.join(', ')})`,
|
|
96
|
-
fix: `x dev --role ${DEV_ROLES.join(',')}`,
|
|
97
|
+
fix: `x dev --role ${quoteArg(DEV_ROLES.join(','))}`,
|
|
97
98
|
});
|
|
98
99
|
}
|
|
99
100
|
if (!SELECTABLE_ROLES.includes(name)) {
|
|
@@ -101,7 +102,7 @@ export function selectRoles(flag: string | undefined): readonly Role[] {
|
|
|
101
102
|
flag: 'role',
|
|
102
103
|
command: 'dev',
|
|
103
104
|
reason: `"${name}" does not run under x dev (it runs once, as \`x db migrate\`)`,
|
|
104
|
-
fix: `x dev --role ${DEV_ROLES.join(',')}`,
|
|
105
|
+
fix: `x dev --role ${quoteArg(DEV_ROLES.join(','))}`,
|
|
105
106
|
});
|
|
106
107
|
}
|
|
107
108
|
if (!selected.includes(name)) selected.push(name);
|
package/src/role-sync.ts
CHANGED
|
@@ -28,6 +28,7 @@ import { portFree } from './port-probe';
|
|
|
28
28
|
import type { StartRolesOptions } from './role-start';
|
|
29
29
|
import { startOrWaitForBus } from './role-sync-bus-wait';
|
|
30
30
|
import type { Env } from './runtime-bindings';
|
|
31
|
+
import { quoteArg } from './shell-quote';
|
|
31
32
|
import { syncAuthenticator } from './sync-authenticator';
|
|
32
33
|
import { syncOriginsFrom } from './sync-url';
|
|
33
34
|
// A value edge back into `role-start.ts`, read only inside a call: the one parser of
|
|
@@ -55,7 +56,7 @@ class SyncPortInUseError extends UltimateError {
|
|
|
55
56
|
// web port IS the sync port this refusal is about — the fix said `x dev --port 4000` for a
|
|
56
57
|
// run that had just died on 4000, and a test named "its fix is a command that ends the
|
|
57
58
|
// failure" pinned it.
|
|
58
|
-
fix: `x dev --port ${portPairAfter(input.webPort)} # or free port ${input.port}: lsof -nP -iTCP:${input.port} -sTCP:LISTEN`,
|
|
59
|
+
fix: `x dev --port ${quoteArg(String(portPairAfter(input.webPort)))} # or free port ${input.port}: lsof -nP -iTCP:${input.port} -sTCP:LISTEN`,
|
|
59
60
|
meta: { port: input.port, webPort: input.webPort },
|
|
60
61
|
});
|
|
61
62
|
}
|
package/src/schema-drift.ts
CHANGED
|
@@ -15,13 +15,7 @@ import { existsSync } from 'node:fs';
|
|
|
15
15
|
import { join } from 'node:path';
|
|
16
16
|
import { ERROR_DOCS_URL } from '@ultimat3/core';
|
|
17
17
|
import type { EntityDescriptionLike, UnrenderedDeclaration } from '@ultimat3/db';
|
|
18
|
-
import {
|
|
19
|
-
declaredSchema,
|
|
20
|
-
recordRetired,
|
|
21
|
-
shellInertIdentifier,
|
|
22
|
-
snapshotOf,
|
|
23
|
-
unrenderedOf,
|
|
24
|
-
} from '@ultimat3/db';
|
|
18
|
+
import { declaredSchema, recordRetired, snapshotOf, unrenderedOf } from '@ultimat3/db';
|
|
25
19
|
import { registeredEntities } from '@ultimat3/entity';
|
|
26
20
|
import { loadApp } from './app-load';
|
|
27
21
|
import { checkSourceDrift, DB_PACKAGE } from './drift';
|
|
@@ -35,6 +29,7 @@ import type { Finding } from './output';
|
|
|
35
29
|
import { settledDescriptions } from './redundant-indexes';
|
|
36
30
|
import { appRowSecurity, type RowSecurityWanted, rowSecurityFindings } from './row-security-wanted';
|
|
37
31
|
import { diffDeclaredSchema, type SchemaDifference } from './schema-diff';
|
|
32
|
+
import { quoteArg } from './shell-quote';
|
|
38
33
|
|
|
39
34
|
/**
|
|
40
35
|
* What the app declares, or `undefined` when the app would not load. Injected so this module's
|
|
@@ -104,14 +99,16 @@ function repairFix(
|
|
|
104
99
|
// the DROP, and the other branch — the declaration may have been LOST rather than removed, which
|
|
105
100
|
// is the whole reason this direction is its own finding — rides in the cause: a `fix:` is one
|
|
106
101
|
// command, and a `# or …` after it was a shell comment nobody's paste would run.
|
|
107
|
-
|
|
108
|
-
//
|
|
109
|
-
//
|
|
110
|
-
|
|
102
|
+
// The name can be read off a sidecar on disk, so the description is SINGLE-quoted: inside
|
|
103
|
+
// double quotes `$(…)` and a backtick still run, inside single quotes nothing does, and the line
|
|
104
|
+
// stays the one runnable command naming the real object.
|
|
105
|
+
if (difference.direction === 'unmigrated') {
|
|
106
|
+
const recorded = quoteArg(`record ${difference.name}`);
|
|
107
|
+
return { fix: `x db gen ${recorded}` };
|
|
108
|
+
}
|
|
109
|
+
const dropped = quoteArg(`drop ${difference.name}`);
|
|
111
110
|
return {
|
|
112
|
-
fix:
|
|
113
|
-
? `x db gen "drop ${difference.name}"`
|
|
114
|
-
: 'x db gen "drop what the entities no longer declare"',
|
|
111
|
+
fix: `x db gen ${dropped}`,
|
|
115
112
|
why: `if ${difference.name} was lost rather than removed, re-declare it on the entity instead — this command drops it`,
|
|
116
113
|
};
|
|
117
114
|
}
|
package/src/shell-quote.ts
CHANGED
|
@@ -11,5 +11,12 @@ const SHELL_SAFE = /^[\w@%+=:,./-]+$/;
|
|
|
11
11
|
* `'\''` is the only escape a single-quoted string has. A shell-safe value is left alone, so the
|
|
12
12
|
* common case stays readable.
|
|
13
13
|
*/
|
|
14
|
-
|
|
14
|
+
const quoteOne = (value: string): string =>
|
|
15
15
|
SHELL_SAFE.test(value) ? value : `'${value.split("'").join("'\\''")}'`;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A word list is an INVOCATION (`['g', 'route', name]`): each word quoted on its own and joined,
|
|
19
|
+
* because quoting it whole made `x 'g route posts'`, one word no command answers to.
|
|
20
|
+
*/
|
|
21
|
+
export const quoteArg = (value: string | readonly string[]): string =>
|
|
22
|
+
typeof value === 'string' ? quoteOne(value) : value.map(quoteOne).join(' ');
|
package/src/shot-locale.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import type { AppLocaleSet } from '@ultimat3/i18n/app-catalogs';
|
|
7
7
|
import { BadFlagError } from './errors';
|
|
8
|
+
import { quoteArg } from './shell-quote';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* `@ultimat3/i18n/app-catalogs`'s `appLocaleSet(root)` — the one reader, and its one answer for an
|
|
@@ -20,7 +21,7 @@ export function readLocaleFlag(value: string | undefined, app: ShotLocales): str
|
|
|
20
21
|
flag: 'locale',
|
|
21
22
|
command: 'shot',
|
|
22
23
|
reason: `"${value}" is not one of the app's locales (${app.locales.join(', ')})`,
|
|
23
|
-
fix: `x shot / --locale ${app.defaultLocale} --json`,
|
|
24
|
+
fix: `x shot / --locale ${quoteArg(app.defaultLocale)} --json`,
|
|
24
25
|
});
|
|
25
26
|
}
|
|
26
27
|
|
package/src/shot-route.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// `allowHosts` exists to refuse is refused here, at the argument, where the reader can see why.
|
|
4
4
|
|
|
5
5
|
import { BadFlagError, MissingPositionalError } from './errors';
|
|
6
|
+
import { quoteArg } from './shell-quote';
|
|
6
7
|
|
|
7
8
|
/** A directory name a route can never escape: everything that is not a letter or digit is a dash. */
|
|
8
9
|
export function shotSlug(route: string): string {
|
|
@@ -75,7 +76,7 @@ export function readRoute(raw: string | undefined): string {
|
|
|
75
76
|
reason: `"${route}" is an absolute URL; x shot photographs a route of the app under test`,
|
|
76
77
|
// The path out of the URL when it parses — the refusal's own fix line has to be runnable,
|
|
77
78
|
// and `new URL('http://')` throws, so the fallback is the route every app has.
|
|
78
|
-
fix: `x shot ${pathOf(route)} --json`,
|
|
79
|
+
fix: `x shot ${quoteArg(pathOf(route))} --json`,
|
|
79
80
|
});
|
|
80
81
|
}
|
|
81
82
|
const path = route.startsWith('/') ? route : `/${route}`;
|
package/src/static-report.ts
CHANGED
|
@@ -145,21 +145,24 @@ export function skipReasonFor(route: RouteFacts): SkipReason | null {
|
|
|
145
145
|
* English rather than `t()`, for the reason every `cause:`/`fix:` in this repo is English: this is
|
|
146
146
|
* a diagnostic an agent pastes into a report, and `wiki/Error-Codes.md` is the same surface.
|
|
147
147
|
*/
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
'
|
|
162
|
-
})
|
|
148
|
+
// Null-prototype: a reason that is not one of these reads `undefined`, never an `Object` member.
|
|
149
|
+
const WHY: Readonly<Record<SkipReason, (route: RouteFacts) => string>> = Object.freeze(
|
|
150
|
+
Object.assign(Object.create(null) as object, {
|
|
151
|
+
'surface-forbids-static': (route) =>
|
|
152
|
+
`${route.surface}/ surface — server-rendered, not prerendered; ` +
|
|
153
|
+
`${route.surface}/ allows ${SURFACE_SPECS[route.surface].allowedModes.join(' | ') || 'no render mode'}, ` +
|
|
154
|
+
'so no route on it can ever reach the artifact',
|
|
155
|
+
'mode-revalidates': (route) =>
|
|
156
|
+
`render: '${route.render}' regenerates on a tag or ttl and a published file cannot, ` +
|
|
157
|
+
"so it is served by the app — change it to render: 'static' to emit it",
|
|
158
|
+
'mode-per-request': (route) =>
|
|
159
|
+
`render: '${route.render}' is rendered per request, so it is served by the app — ` +
|
|
160
|
+
"change it to render: 'static' to emit it",
|
|
161
|
+
'no-prerender-paths': (route) =>
|
|
162
|
+
`render: '${route.render}' with dynamic params and no prerender() paths, so the build ` +
|
|
163
|
+
'enumerated nothing to write — add prerender() to the route',
|
|
164
|
+
} satisfies Record<SkipReason, (route: RouteFacts) => string>),
|
|
165
|
+
);
|
|
163
166
|
|
|
164
167
|
/** The reason as a row: the code a machine keys off, and the sentence a human reads. */
|
|
165
168
|
export function skippedRoute(
|
package/src/test-select.ts
CHANGED
|
@@ -108,7 +108,7 @@ export function readType(raw: string | undefined): TestType | undefined {
|
|
|
108
108
|
flag: 'type',
|
|
109
109
|
command: 'test',
|
|
110
110
|
reason: `"${raw}" is not a test type (known: ${TEST_TYPES.join(', ')})`,
|
|
111
|
-
fix:
|
|
111
|
+
fix: `x test ${renderFixShellArg(suggestion ?? TEST_TYPES[0], '<type>')}`,
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
114
|
|
package/src/verify-floor.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { COVERAGE_FIELD, readCoverageFloor } from './coverage-floor';
|
|
|
14
14
|
import type { ExerciseFloor } from './exercise-floor';
|
|
15
15
|
import { EXERCISE_FIELD, readExerciseFloor } from './exercise-floor';
|
|
16
16
|
import type { Finding } from './output';
|
|
17
|
+
import { quoteArg } from './shell-quote';
|
|
17
18
|
import type { StepTimeouts } from './verify-deadline';
|
|
18
19
|
import { readStepTimeouts, STEP_TIMEOUT_FIELD } from './verify-deadline';
|
|
19
20
|
import type { GuardBaseline } from './verify-guard-baseline';
|
|
@@ -320,7 +321,7 @@ export const vanishedSuiteFinding = (step: string, command: string = GATE_COMMAN
|
|
|
320
321
|
export const skippedSuiteFinding = (step: string, skipped: number): Finding => ({
|
|
321
322
|
code: 'X_VERIFY_SUITE_VANISHED',
|
|
322
323
|
cause: `${VERIFY_FLOOR_FILE} requires the ${step} step and all ${skipped} test(s) it found skipped themselves, so nothing ran`,
|
|
323
|
-
fix: `x test ${step} --json # then set what the suite skips without, or drop "${step}" from ${VERIFY_FLOOR_FILE} in the commit that says why`,
|
|
324
|
+
fix: `x test ${quoteArg(step)} --json # then set what the suite skips without, or drop "${step}" from ${VERIFY_FLOOR_FILE} in the commit that says why`,
|
|
324
325
|
docs: ERROR_DOCS_URL,
|
|
325
326
|
at: VERIFY_FLOOR_FILE,
|
|
326
327
|
});
|
package/src/verify-services.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { renderThrowable } from '@ultimat3/core';
|
|
|
10
10
|
import type { Runner } from './exec';
|
|
11
11
|
import { execOutput } from './exec';
|
|
12
12
|
import type { Finding } from './output';
|
|
13
|
+
import { quoteArg } from './shell-quote';
|
|
13
14
|
import { TEST_COMPOSE_PATH, TEST_ENV_PATH } from './templates/scaffold-test-services';
|
|
14
15
|
import { parseDotenvValues } from './test-dotenv';
|
|
15
16
|
|
|
@@ -140,7 +141,7 @@ const hostOf = (url: string): string => {
|
|
|
140
141
|
const foreignFinding = (url: string): Finding => ({
|
|
141
142
|
code: 'X_TEST_SERVICES_UNAVAILABLE',
|
|
142
143
|
cause: `a Postgres answers at ${hostOf(url)} (${TEST_ENV_PATH}'s ${TEST_DATABASE_KEY}) and refuses this app's credentials — another app's test stack holds the port, so the live suites are not run against it`,
|
|
143
|
-
fix: `docker ps --filter publish=${portOf(url)} # stop that stack (docker compose -p <project> down), or give this app another port in ${TEST_COMPOSE_PATH} and ${TEST_ENV_PATH}`,
|
|
144
|
+
fix: `docker ps --filter publish=${quoteArg(portOf(url))} # stop that stack (docker compose -p <project> down), or give this app another port in ${TEST_COMPOSE_PATH} and ${TEST_ENV_PATH}`,
|
|
144
145
|
at: TEST_ENV_PATH,
|
|
145
146
|
});
|
|
146
147
|
|
package/src/workspace-checks.ts
CHANGED
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
mayReachFixture,
|
|
25
25
|
} from './publish-closure';
|
|
26
26
|
import { isReExportManifest } from './reexport-manifest';
|
|
27
|
+
import { quoteArg } from './shell-quote';
|
|
27
28
|
import { eachSourceFile, isGenerated } from './source-files';
|
|
28
29
|
import type { ShippedPackage } from './test-only-shipped';
|
|
29
30
|
import { checkTestOnlyShipped, entryPatternsOf } from './test-only-shipped';
|
|
@@ -98,7 +99,7 @@ export const missingFileFinding = (dir: string, file: string, scaffolder: boolea
|
|
|
98
99
|
code: 'X_PACKAGE_SHAPE',
|
|
99
100
|
cause: `packages/${dir} has no ${file}`,
|
|
100
101
|
fix: scaffolder
|
|
101
|
-
? `bun run scripts/new-package.ts ${dir} --only ${file}`
|
|
102
|
+
? `bun run scripts/new-package.ts ${quoteArg(dir)} --only ${quoteArg(file)}`
|
|
102
103
|
: `add packages/${dir}/${file}, shaped like the one in a sibling package`,
|
|
103
104
|
docs: ERROR_DOCS_URL,
|
|
104
105
|
at: `packages/${dir}/${file}`,
|
|
@@ -153,7 +154,7 @@ export const PUBLISHED_DEP_FIELDS = [
|
|
|
153
154
|
export const versionSkewFinding = (dir: string, found: string, expected: string): Finding => ({
|
|
154
155
|
code: 'X_RELEASE_VERSION_SKEW',
|
|
155
156
|
cause: `packages/${dir} is at ${found}, not the lockstep version ${expected}`,
|
|
156
|
-
fix: `bun run scripts/release.ts --version ${expected}`,
|
|
157
|
+
fix: `bun run scripts/release.ts --version ${quoteArg(expected)}`,
|
|
157
158
|
docs: ERROR_DOCS_URL,
|
|
158
159
|
at: `packages/${dir}/package.json`,
|
|
159
160
|
});
|
|
@@ -166,7 +167,7 @@ export const pinSkewFinding = (
|
|
|
166
167
|
): Finding => ({
|
|
167
168
|
code: 'X_RELEASE_VERSION_SKEW',
|
|
168
169
|
cause: `packages/${dir} pins ${dep} at ${range}, not the lockstep version ${expected}`,
|
|
169
|
-
fix: `bun run scripts/release.ts --version ${expected}`,
|
|
170
|
+
fix: `bun run scripts/release.ts --version ${quoteArg(expected)}`,
|
|
170
171
|
docs: ERROR_DOCS_URL,
|
|
171
172
|
at: `packages/${dir}/package.json`,
|
|
172
173
|
});
|
|
@@ -97,11 +97,13 @@ export const undeclaredExternalDepFinding = (
|
|
|
97
97
|
// package across the app, rather than whatever the registry calls latest today.
|
|
98
98
|
const pinned = range === undefined ? dependency : `${dependency}@${range}`;
|
|
99
99
|
const spec = renderFixShellArg(pinned, '') === '' ? dependency : pinned;
|
|
100
|
-
const dev = at.endsWith(FIXTURE_SUFFIX)
|
|
100
|
+
const dev = at.endsWith(FIXTURE_SUFFIX);
|
|
101
|
+
const added = renderFixShellArg(spec, '<the package>');
|
|
102
|
+
const cwd = renderFixShellArg(owner.dir, '<the workspace directory>');
|
|
101
103
|
return {
|
|
102
104
|
code: 'X_WORKSPACE_EXTERNAL_DEP_UNDECLARED',
|
|
103
105
|
cause: `${at} imports ${dependency}, which neither ${owner.dir}/package.json nor the root package.json declares — it resolves only while another workspace's copy is hoisted`,
|
|
104
|
-
fix: `bun add ${
|
|
106
|
+
fix: dev ? `bun add ${added} --dev --cwd ${cwd}` : `bun add ${added} --cwd ${cwd}`,
|
|
105
107
|
docs: ERROR_DOCS_URL,
|
|
106
108
|
at: `${owner.dir}/package.json`,
|
|
107
109
|
};
|