@ultimat3/cli 31.5.0 → 31.6.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 +15 -8
- package/package.json +29 -29
- package/src/admin-catalog-keys.ts +17 -1
- package/src/app-transport.ts +7 -3
- package/src/browser-barrel-cut.ts +109 -0
- package/src/browser-import-chain.ts +119 -0
- package/src/browser-transport.ts +85 -13
- package/src/cmd-dev.ts +15 -2
- package/src/cmd-fix.ts +14 -4
- package/src/cmd-i18n.ts +52 -10
- package/src/dev-boot.ts +6 -4
- package/src/dev-log.ts +95 -0
- package/src/dev-rebuild-remount.ts +152 -0
- package/src/dev-rebuild-schema.ts +30 -0
- package/src/dev-rebuild.ts +51 -14
- package/src/dev-supervisor.ts +5 -4
- package/src/error-codes.ts +2 -0
- package/src/error-contract.ts +29 -2
- package/src/fix-sequence.ts +97 -0
- package/src/generate-grant-findings.ts +2 -2
- package/src/generate-grants.ts +50 -1
- package/src/generate-write.ts +16 -0
- package/src/i18n-registration.ts +8 -5
- package/src/island-bundle.ts +9 -9
- package/src/island-group-cache.ts +2 -1
- package/src/island-identity.ts +22 -51
- package/src/island-link.ts +32 -65
- package/src/island-outputs.ts +2 -6
- package/src/island-realtime.ts +1 -3
- package/src/island-runtime.ts +11 -8
- package/src/load-findings.ts +29 -22
- package/src/mcp-errors.ts +11 -3
- package/src/mcp-host-shell.ts +128 -0
- package/src/mcp-host.ts +19 -54
- package/src/mcp-test-output.ts +5 -2
- package/src/messages-gate.ts +12 -0
- package/src/messages.ts +16 -0
- package/src/page-sync.ts +1 -1
- package/src/policy-append.ts +88 -0
- package/src/sw-artifacts.ts +1 -1
- package/src/templates/entity.ts +18 -3
- package/src/templates/policy.ts +5 -1
- package/src/templates/query.ts +4 -2
- package/src/templates/resource-service.ts +5 -2
- package/src/templates/scaffold-repo.ts +8 -2
- package/src/ts-scan.ts +86 -1
- package/src/verify-checks.ts +23 -51
- package/src/verify-contract-diff.ts +143 -0
- package/src/verify-seeds.ts +132 -0
- package/src/verify-tests.ts +12 -6
- package/src/worker-bundle.ts +8 -9
- package/wiki/CLI-Reference.md +2 -2
- package/wiki/Upgrading.md +4 -0
package/CLAUDE.md
CHANGED
|
@@ -51,14 +51,17 @@ Commands: `bun test ./packages/cli/` (repo root: the preload),
|
|
|
51
51
|
| `verify-floor.ts` | `x.verify.json`: a floor step that ran zero tests is `X_VERIFY_SUITE_VANISHED` |
|
|
52
52
|
| `coverage-{floor,lcov,source}.ts` / `verify-coverage-run.ts` | an app's `unit` coverage floor; `coverage-lcov.ts` is the ONE lcov reader † |
|
|
53
53
|
| `verify-deadline.ts` / `verify-stalled.ts` / `verify-progress.ts` | a step past its deadline is `X_VERIFY_STEP_TIMEOUT`; its children are killed by tag † |
|
|
54
|
-
| `load-findings.ts` | module-load
|
|
54
|
+
| `load-findings.ts` | a module-load failure is reported once, by `manifest`; while red, each step that loads the app is wrapped in `blockedByLoad`: `skipped: load failed (see manifest)`. Under `--only` without `manifest` it carries the findings itself |
|
|
55
|
+
| `verify-contract-diff.ts` | `contract-diff`: baseline is `x.manifest.json` at HEAD; in CI, at the merge base with `origin/$GITHUB_BASE_REF`, or that ref itself when a shallow checkout reaches no merge base; HEAD plus a fetch notice when the ref is not fetched; outside git, the file on disk with a notice |
|
|
55
56
|
| `verify-factories.ts` | `unit` lints `<app>/packages/db/factories.ts` (`X_TEST_FACTORY_INVALID`) |
|
|
57
|
+
| `verify-seeds.ts` | `unit` runs the seeds on one memory driver; a refused row keeps the entity's code and fix, an uncoded throw is `X_SEED_FAILED` |
|
|
56
58
|
| `boundary-findings.ts` / `app-boundaries.ts` / `boundary-cuts.ts` / `package-boundaries.ts` | surface + layer rules, `X_BOUNDARY_PACKAGE_TO_APP`; a `fix:` is the concrete cut † |
|
|
57
59
|
| `app-boundaries.ts` (workspaces) | `@<scope>/<app>/<rest>` resolves onto `apps/<app>/<rest>` when that is an app source, so the surface rules hold across app workspaces |
|
|
58
|
-
| `app-transport.ts` / `browser-transport.ts` / `transport-calls.ts` / `transport-values.ts` / `binding-names.ts` / `import-closure.ts` / `server-barrels.ts` | `boundaries`, built in: one browser transport; never a `guards/` file † |
|
|
60
|
+
| `app-transport.ts` / `browser-transport.ts` / `transport-calls.ts` / `transport-values.ts` / `binding-names.ts` / `import-closure.ts` / `server-barrels.ts` / `browser-import-chain.ts` / `browser-barrel-cut.ts` | `boundaries`, built in: one browser transport; a server barrel below an island is cut at its first hop unless the browser entry exports every name taken (`meta.chain`; `x fix boundary` lists it, rule `browser-server-barrel`); never a `guards/` file † |
|
|
59
61
|
| `guards.ts` / `guard-sources.ts` | an app's `guards/*.ts`, run on `boundaries`; ONE shared walk (`GuardSources`) † |
|
|
60
62
|
| `templates/scaffold-guards.ts` | `SHIPPED`, the one list of shipped guards (`x new`, `x g guard`, `doctor-guards.ts`) † |
|
|
61
|
-
| `error-contract.ts` / `ts-scan.ts` / `fix-scan.ts` / `fix-imports.ts` / `fix-command.ts` / `fix-path.ts` | the `errors` step: every `fix:` names a runnable command, call or existing file |
|
|
63
|
+
| `error-contract.ts` / `ts-scan.ts` / `fix-scan.ts` / `fix-imports.ts` / `fix-command.ts` / `fix-path.ts` | the `errors` step: every `fix:` names a runnable command, call or existing file; `*FIXES` tables are throw sites |
|
|
64
|
+
| `fix-sequence.ts` | `errors`: a `fix:` that defers its edit (`# after …`/`# once …`), only says re-run, or runs `x g … --force` is `X_ERROR_FIX_INVALID`; ratcheted per file (`FIX_SEQUENCE_BASELINE`) |
|
|
62
65
|
| `workspace-checks.ts` / `test-only-shipped.ts` / `workspace-graph.ts` / `tsconfig-references.ts` / `publish-closure.ts` | `package-shape`, `filesize` ‡ |
|
|
63
66
|
| `workspace-external-deps.ts` · `tsconfig-aliases.ts` · `error-codes-package.ts` | `package-shape`: a registry import neither the workspace nor the root declares (`X_WORKSPACE_EXTERNAL_DEP_UNDECLARED`); fix `bun add <pkg> --cwd <workspace>`. The step family's codes and titles, split out of `error-codes.ts` |
|
|
64
67
|
| `app-permissions*.ts` / `permission-grants.ts` | `policy`: `X_PERMISSION_UNGRANTED`, `X_PERMISSION_BORROWED` † |
|
|
@@ -79,13 +82,13 @@ Commands: `bun test ./packages/cli/` (repo root: the preload),
|
|
|
79
82
|
| `job-budget.ts` | `X_JOB_OUTLASTS_DRAIN` (`manifest`): `timeout` vs `workerBudgetMs(drain)`, from the registry † |
|
|
80
83
|
| `output-findings.ts` | render layer only: `runnableFix` (`bunx x`, decided by `dispatch.ts`'s `readerFor`) and `collapseFindings`. Throw sites keep `x …` |
|
|
81
84
|
| `app-load-unresolved.ts` | `X_APP_IMPORT_UNRESOLVED`, read by the scan, `findingFrom` and `x doctor`'s `snapshots` probe |
|
|
82
|
-
| `fix-truth.test.ts` / `fix-truth-fixture.ts` / `db-fix-truth.job.test.ts` | a printed fix, executed: each row breaks a scaffold, asserts the code
|
|
85
|
+
| `fix-truth.test.ts` / `fix-truth-fixture.ts` / `db-fix-truth.job.test.ts` | a printed fix, executed: each row breaks a scaffold, asserts the code, runs the line; `typeErrors()` asserts the app still typechecks |
|
|
83
86
|
|
|
84
87
|
### Generators (`x g`, `x new`)
|
|
85
88
|
|
|
86
89
|
| File | Job |
|
|
87
90
|
|---|---|
|
|
88
|
-
| `cmd-generate.ts` / `generate-files.ts` / `generate-kinds.ts` / `generate-write.ts` | argv → pure file list → writes (conflict-checked, `merge: 'json'` / `'if-absent'`) |
|
|
91
|
+
| `cmd-generate.ts` / `generate-files.ts` / `generate-kinds.ts` / `generate-write.ts` | argv → pure file list → writes (conflict-checked, `merge: 'json'` / `'if-absent'`, `policy.ts` appended) |
|
|
89
92
|
| `templates/workspace.ts` | `x g app` / `x g package`: a workspace the root globs and the one tsconfig alias (`@<app>/*` → `packages/*/src`, then `apps/*`) already reach |
|
|
90
93
|
| `write-generated.ts` | `x new`'s writer: a `link` file is a relative symlink, a copy only on a refusing win32 |
|
|
91
94
|
| `generate-feature.ts` | a `--feature` naming no slice is `X_FEATURE_UNKNOWN`; nothing invents an entity |
|
|
@@ -93,7 +96,9 @@ Commands: `bun test ./packages/cli/` (repo root: the preload),
|
|
|
93
96
|
| `generate-plural.ts` | a planned `entity.ts` in an already-plural slice (`posts` → `postses`) is `X_CLI_BAD_FLAG`; the fix names the singular |
|
|
94
97
|
| `generate-catalog-locales.ts` | `--locales` never starts a catalog; missing locale is `X_CLI_BAD_FLAG` † |
|
|
95
98
|
| `app-name.ts` | `x new`'s slug is asked of core's `defineConfig`, never a copied pattern; refused with a suggested name (`9lives` → `app-9lives`, `a` → `a-app`, cut at 64) |
|
|
96
|
-
| `generate-grants.ts` | a written `policy.ts`
|
|
99
|
+
| `generate-grants.ts` | a written `policy.ts` grants the set the run wrote — its LAST `definePermissions([...])` (`:read` → member, else admin), never a permission already in the file; the slice path only when nothing reads; in `apps/web/shared/roles.ts` ‡ |
|
|
100
|
+
| `policy-append.ts` | a second `x g policy` appends its set; the same set again is the conflict, fix another set |
|
|
101
|
+
| `scaffold-growth.contract.test.ts` | an entity gaining a defaulted and a nullable column breaks no generated insert (`Insertable`) |
|
|
97
102
|
| `api-registration.ts` | a written job or task is listed in `apps/web/api/index.ts` |
|
|
98
103
|
| `generate-exercise.ts` | a contract test's entry in `apps/web/exercise.ts` (`exercise-entry-edit.ts`) |
|
|
99
104
|
| `handle-registration.ts` / `workspace-dep-edit.ts` / `templates/scaffold-db-client.ts` | a written entity joins `entities` (`X_DB_HANDLE_UNREGISTERED`) † |
|
|
@@ -116,6 +121,8 @@ Commands: `bun test ./packages/cli/` (repo root: the preload),
|
|
|
116
121
|
| `generate-refresh.ts` | `x g` refreshes the manifest only when a written file needs it |
|
|
117
122
|
| `role-load.ts` / `document-graph.ts` / `serve-web.ts` | a role imports what it runs: `ROLE_LOADS` (`X_ROLE_LOAD_INCOMPLETE`) † |
|
|
118
123
|
| `module-imports.ts` | a module's imports, resolved once for both graphs: `referenced` (reload), `evaluated` (document) |
|
|
124
|
+
| `dev-rebuild-remount.ts` / `dev-rebuild-schema.ts` | a save that changes what `x dev` mounted or its load findings is a restart, naming what moved; entities ahead of migrations are `X_DB_DRIFT` (`x db gen "…" && x db migrate`), skipped after a failed load |
|
|
125
|
+
| `dev-log.ts` | every logger line to `<stateDir>/dev.log` (`logs.tail`); `dev.log.1` at 16 MiB |
|
|
119
126
|
| `cmd-dev.ts` / `dev-boot.ts` / `dev-rebuild.ts` / `dev-route-table.ts` | `x dev`: every role in one process, `/_x`, the watcher; one save = one generation, and the boot is the first: `buildGeneration` builds the manifest and the islands at once † |
|
|
120
127
|
| `runtime-bindings.ts` | which service each binding points at (embedded or external); events follow `NATS_URL` |
|
|
121
128
|
| `runtime-queue.ts` / `runtime-services.ts` / `runtime-bus.ts` | db + queue; every other accessor; the bus |
|
|
@@ -142,7 +149,7 @@ Commands: `bun test ./packages/cli/` (repo root: the preload),
|
|
|
142
149
|
| `page-navigation.ts` | the client router for `navigation.client` surfaces — built, routed and named ONCE for `x dev`, the container and the static export; none opted in builds nothing |
|
|
143
150
|
| `page-speculation.ts` | Speculation Rules for documents WITHOUT the router (`navigation.speculation`): an allow-list of pure-read pages ‡ |
|
|
144
151
|
| `static-document.ts` | a served `static` page: `304` on `If-None-Match`; container keeps the document (never `x dev`) † |
|
|
145
|
-
| `island-{bundle,groups,outputs,build-pool,group-cache,cache-inputs,store,sources,runtime}.ts` / `island-realtime*.ts` / `solid-loader.ts` | islands,
|
|
152
|
+
| `island-{bundle,groups,outputs,build-pool,group-cache,cache-inputs,store,sources,runtime}.ts` / `island-realtime*.ts` / `solid-loader.ts` | islands, named by their final bytes (#1075): one `Bun.build` per route group — islands on exactly the same routes split together, every other alone; groups read from `page.tsx` sources, the one input every caller has before rendering (`islands.sharedChunks` = one group). A group's output is reused from `.x/cache/islands/` while every file it read (Sass partials included), every directory listing it resolved in and the lockfile/tsconfig/`package.json` environment hash the same (`reuse: false` for a determinism test) † |
|
|
146
153
|
| `local-cli.ts` / `local-cli-handoff.ts` | a global `x` hands over to the app's own CLI (`local-cli.ts` decides whether; `x upgrade` alone stays when the app's is strictly older — `upgrade-handover.test.ts`) |
|
|
147
154
|
| `serve-prebuilt.ts` / `serve-prebuilt-paths.ts` | the image's prebuilt store; a boot that built anything logs `X_IMAGE_NOT_PREBUILT` † |
|
|
148
155
|
| `dev-*.ts` | `x dev` only: dashboard sources, traces, the N+1 ledger, watcher, reload, lock, port |
|
|
@@ -167,7 +174,7 @@ Commands: `bun test ./packages/cli/` (repo root: the preload),
|
|
|
167
174
|
|---|---|
|
|
168
175
|
| `cmd-registries.ts` / `cmd-jobs.ts` / `cmd-tasks.ts` / `cmd-policy.ts` / `cmd-i18n.ts` | project a framework registry; each pairs CLI wiring with a facts module |
|
|
169
176
|
| `cmd-auth.ts` / `cmd-auth-spec.ts` / `doctor-auth.ts` | `x auth seal-mfa`: seals plaintext `x_users.mfa_secret` through auth's `sealMfaSecrets` |
|
|
170
|
-
| `cmd-mcp.ts` / `mcp-host.ts` / `mcp-errors.ts` / `mcp-db-target.ts` | `x mcp serve`: 19 tools, two transports † |
|
|
177
|
+
| `cmd-mcp.ts` / `mcp-host.ts` / `mcp-errors.ts` / `mcp-db-target.ts` / `mcp-host-shell.ts` / `mcp-test-{output,run}.ts` | `x mcp serve`: 19 tools, two transports; `tests.run`/`verify.run` ARE `x test`/`x verify`, `ULTIMATE_ENV` unset in children (`mcp-host.parity.test.ts`) † |
|
|
171
178
|
| `cmd-shot*.ts` / `cdp-shot-*.ts` / `browser-launcher*.ts` / `island-*` | `x shot` over raw CDP; `verdict.json` names its own blind spots. Not a gate step |
|
|
172
179
|
| `shot-route.ts` / `shot-run.ts` / `shot-gpu.ts` | `x shot`'s route argument (`readRoute`, `shotSlug`); one capture (`runShot`); the page's `navigator.gpu` adapter (`verdict.gpu`, never gating). `cmd-shot.ts` re-exports the first two |
|
|
173
180
|
| `cmd-pr.ts` / `cmd-ci.ts` / `ci-runs.ts` / `ci-tested.ts` | GitHub through `gh`, schema-parsed; not gate steps † |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimat3/cli",
|
|
3
|
-
"version": "31.
|
|
3
|
+
"version": "31.6.1",
|
|
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.9",
|
|
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.6.1",
|
|
57
|
+
"@ultimat3/admin": "31.6.1",
|
|
58
|
+
"@ultimat3/ai": "31.6.1",
|
|
59
|
+
"@ultimat3/auth": "31.6.1",
|
|
60
|
+
"@ultimat3/cache": "31.6.1",
|
|
61
|
+
"@ultimat3/core": "31.6.1",
|
|
62
|
+
"@ultimat3/db": "31.6.1",
|
|
63
|
+
"@ultimat3/entity": "31.6.1",
|
|
64
|
+
"@ultimat3/flags": "31.6.1",
|
|
65
|
+
"@ultimat3/http": "31.6.1",
|
|
66
|
+
"@ultimat3/i18n": "31.6.1",
|
|
67
|
+
"@ultimat3/jobs": "31.6.1",
|
|
68
|
+
"@ultimat3/mail": "31.6.1",
|
|
69
|
+
"@ultimat3/manifest": "31.6.1",
|
|
70
|
+
"@ultimat3/mcp": "31.6.1",
|
|
71
|
+
"@ultimat3/money": "31.6.1",
|
|
72
|
+
"@ultimat3/notify": "31.6.1",
|
|
73
|
+
"@ultimat3/policy": "31.6.1",
|
|
74
|
+
"@ultimat3/pwa": "31.6.1",
|
|
75
|
+
"@ultimat3/query": "31.6.1",
|
|
76
|
+
"@ultimat3/realtime": "31.6.1",
|
|
77
|
+
"@ultimat3/render": "31.6.1",
|
|
78
|
+
"@ultimat3/schema": "31.6.1",
|
|
79
|
+
"@ultimat3/scraping": "31.6.1",
|
|
80
|
+
"@ultimat3/seo": "31.6.1",
|
|
81
|
+
"@ultimat3/storage": "31.6.1",
|
|
82
|
+
"@ultimat3/testing": "31.6.1",
|
|
83
|
+
"@ultimat3/time": "31.6.1",
|
|
84
84
|
"babel-preset-solid": "^1.9.16"
|
|
85
85
|
}
|
|
86
86
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
// The catalog keys a MOUNTED admin renders: asked of each `AdminApp` (`catalogKeys()`), never
|
|
2
2
|
// walked here — the admin owns the one derivation, so a key `defineAdmin` would draw and the
|
|
3
|
-
// `i18n` step audits can never be two spellings of one rule.
|
|
3
|
+
// `i18n` step audits can never be two spellings of one rule. Also the label `x i18n sync` writes
|
|
4
|
+
// for one, by the rule `x g resource --admin` already labels its own keys with.
|
|
4
5
|
|
|
5
6
|
import { describePages } from '@ultimat3/render';
|
|
7
|
+
import { columnLabel } from './templates/admin-catalog';
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* The keys of every admin this process declared. Asked of the route table first: an app with no
|
|
@@ -14,3 +16,17 @@ export async function mountedAdminKeys(): Promise<readonly string[]> {
|
|
|
14
16
|
const { adminMounts } = await import('@ultimat3/admin');
|
|
15
17
|
return [...new Set(adminMounts().flatMap((app) => app.catalogKeys()))].sort();
|
|
16
18
|
}
|
|
19
|
+
|
|
20
|
+
/** Segments that name the slot a string fills, not the thing it labels: `admin.posts.title`. */
|
|
21
|
+
const SLOT_SEGMENTS = new Set(['title', 'label']);
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* `admin.posts.field.createdAt` → `Created at`, `admin.posts.title` → `Posts`: the label the
|
|
25
|
+
* generator writes for a key it derives (`adminCatalogEntries`), read back off the key itself so a
|
|
26
|
+
* key the generator never wrote — a section, a scope, an action — gets the same treatment.
|
|
27
|
+
*/
|
|
28
|
+
export function adminKeyLabel(key: string): string {
|
|
29
|
+
const segments = key.split('.');
|
|
30
|
+
while (segments.length > 1 && SLOT_SEGMENTS.has(segments.at(-1) ?? '')) segments.pop();
|
|
31
|
+
return columnLabel(segments.at(-1) ?? key);
|
|
32
|
+
}
|
package/src/app-transport.ts
CHANGED
|
@@ -17,6 +17,7 @@ import { readFileSync } from 'node:fs';
|
|
|
17
17
|
import { join } from 'node:path';
|
|
18
18
|
import { isJsonObject } from '@ultimat3/core';
|
|
19
19
|
import type { SourceFile } from './app-boundaries';
|
|
20
|
+
import { mergeBarrelFindings, publishedEntries } from './browser-barrel-cut';
|
|
20
21
|
import type { FindingContext } from './browser-transport';
|
|
21
22
|
import {
|
|
22
23
|
barrelFinding,
|
|
@@ -200,13 +201,16 @@ export async function appTransportFindings(
|
|
|
200
201
|
workspaces(root),
|
|
201
202
|
installedSpecifiers(root),
|
|
202
203
|
]);
|
|
203
|
-
const
|
|
204
|
+
const specifiers = [...installed, ...own.patterns.filter((p) => !p.wild).map((p) => p.head)];
|
|
205
|
+
const barrelMap = serverBarrels(specifiers);
|
|
204
206
|
const { bypasses, barrels } = checkBrowserTransport({
|
|
205
207
|
entries,
|
|
206
208
|
// The tsconfig first: it is what the app's own typecheck resolves through.
|
|
207
209
|
host: hostOf(root, sources, [...paths, ...own.patterns]),
|
|
208
210
|
seams: new Map(),
|
|
209
|
-
barrels:
|
|
211
|
+
barrels: barrelMap,
|
|
212
|
+
// What each browser entry exports: a swap is printed only where it compiles.
|
|
213
|
+
published: await publishedEntries(root, barrelMap.values()),
|
|
210
214
|
ownsBarrel: (file, barrel) => {
|
|
211
215
|
const dir = own.dirs.get(barrel);
|
|
212
216
|
return dir !== undefined && file.startsWith(`${dir}/`);
|
|
@@ -214,6 +218,6 @@ export async function appTransportFindings(
|
|
|
214
218
|
});
|
|
215
219
|
return [
|
|
216
220
|
...bypasses.map((bypass) => bypassFinding(bypass, CONTEXT)),
|
|
217
|
-
...barrels.map((barrel) => barrelFinding(barrel, CONTEXT)),
|
|
221
|
+
...mergeBarrelFindings(barrels.map((barrel) => barrelFinding(barrel, CONTEXT))),
|
|
218
222
|
];
|
|
219
223
|
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// The browser graph's cuts over an app on disk: what each browser entry really exports (read from
|
|
2
|
+
// the installed manifest, so a promised swap compiles), one `X_BROWSER_SERVER_BARREL` per edge to
|
|
3
|
+
// delete, and the cut as `x fix boundary` prints it. The `boundaries` step (`app-transport.ts`) and
|
|
4
|
+
// `x fix boundary` both read from here, so the gate and the command cannot disagree.
|
|
5
|
+
|
|
6
|
+
// why: Bun ships no path joiner; the manifest and the entry are read at a joined path.
|
|
7
|
+
import { join } from 'node:path';
|
|
8
|
+
import { isJsonObject } from '@ultimat3/core';
|
|
9
|
+
import { exportedNames } from './browser-import-chain';
|
|
10
|
+
import type { Finding, JsonValue } from './output';
|
|
11
|
+
|
|
12
|
+
const CODE = 'X_BROWSER_SERVER_BARREL';
|
|
13
|
+
|
|
14
|
+
/** What `@scope/pkg/sub` exports, read through the app's `node_modules`; `undefined` = unknown. */
|
|
15
|
+
export async function publishedNames(
|
|
16
|
+
root: string,
|
|
17
|
+
spec: string,
|
|
18
|
+
): Promise<ReadonlySet<string> | undefined> {
|
|
19
|
+
const match = /^(@[\w.-]+\/[\w.-]+)\/([\w.-]+)$/.exec(spec);
|
|
20
|
+
if (match === null) return undefined;
|
|
21
|
+
const dir = join(root, 'node_modules', match[1] ?? '');
|
|
22
|
+
try {
|
|
23
|
+
const manifest: unknown = await Bun.file(join(dir, 'package.json')).json();
|
|
24
|
+
const exports = isJsonObject(manifest) ? manifest['exports'] : undefined;
|
|
25
|
+
const row = isJsonObject(exports) ? exports[`./${match[2]}`] : undefined;
|
|
26
|
+
const target = isJsonObject(row) ? (row['import'] ?? row['default']) : row;
|
|
27
|
+
if (typeof target !== 'string') return undefined;
|
|
28
|
+
return exportedNames(await Bun.file(join(dir, target)).text());
|
|
29
|
+
} catch {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const strings = (value: JsonValue | undefined): readonly string[] | undefined =>
|
|
35
|
+
Array.isArray(value) && value.every((one) => typeof one === 'string')
|
|
36
|
+
? (value as readonly string[])
|
|
37
|
+
: undefined;
|
|
38
|
+
|
|
39
|
+
/** One finding per edit: every site one cut clears is listed on it, never printed again. */
|
|
40
|
+
export function mergeBarrelFindings(findings: readonly Finding[]): readonly Finding[] {
|
|
41
|
+
const byEdit = new Map<string, Finding>();
|
|
42
|
+
const out: Finding[] = [];
|
|
43
|
+
for (const finding of findings) {
|
|
44
|
+
const key = `${finding.at ?? ''}\u0000${finding.fix}`;
|
|
45
|
+
const held = byEdit.get(key);
|
|
46
|
+
if (finding.code !== CODE || held === undefined) {
|
|
47
|
+
if (finding.code === CODE) byEdit.set(key, finding);
|
|
48
|
+
out.push(finding);
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const sites = [...(strings(held.meta?.['sites']) ?? [])];
|
|
52
|
+
for (const one of strings(finding.meta?.['sites']) ?? [])
|
|
53
|
+
if (!sites.includes(one)) sites.push(one);
|
|
54
|
+
const grown: Finding = { ...held, meta: { ...held.meta, sites } };
|
|
55
|
+
byEdit.set(key, grown);
|
|
56
|
+
out[out.indexOf(held)] = grown;
|
|
57
|
+
}
|
|
58
|
+
return out.map((finding) => {
|
|
59
|
+
const sites = strings(finding.meta?.['sites']) ?? [];
|
|
60
|
+
return finding.code === CODE && sites.length > 1
|
|
61
|
+
? {
|
|
62
|
+
...finding,
|
|
63
|
+
cause: `${finding.cause}; the same edge also reaches ${sites.slice(1).join(', ')}`,
|
|
64
|
+
}
|
|
65
|
+
: finding;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Every browser entry's export names that could be read; an entry left out is unknown. */
|
|
70
|
+
export async function publishedEntries(
|
|
71
|
+
root: string,
|
|
72
|
+
entries: Iterable<string>,
|
|
73
|
+
): Promise<ReadonlyMap<string, ReadonlySet<string>>> {
|
|
74
|
+
const read = await Promise.all(
|
|
75
|
+
[...new Set(entries)].map(async (entry) => [entry, await publishedNames(root, entry)] as const),
|
|
76
|
+
);
|
|
77
|
+
return new Map(read.flatMap(([entry, names]) => (names === undefined ? [] : [[entry, names]])));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** The browser-graph findings `x fix boundary <target>` owns: its island, or any file on the chain. */
|
|
81
|
+
export const involvesTarget = (finding: Finding, target: string): boolean =>
|
|
82
|
+
finding.code === CODE &&
|
|
83
|
+
(finding.at?.split(':')[0] === target ||
|
|
84
|
+
(strings(finding.meta?.['chain']) ?? []).includes(target));
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* A browser-graph cut as `x fix boundary`'s `data.cuts` carries a surface one: the edge is the
|
|
88
|
+
* entry's first hop for a cut, the barrel import itself for a swap.
|
|
89
|
+
*/
|
|
90
|
+
export function browserCutJson(finding: Finding): JsonValue {
|
|
91
|
+
const meta = finding.meta ?? {};
|
|
92
|
+
const chain = strings(meta['chain']) ?? [];
|
|
93
|
+
const [site = ''] = strings(meta['sites']) ?? [];
|
|
94
|
+
const entry = chain[0] ?? '';
|
|
95
|
+
const edge =
|
|
96
|
+
meta['cut'] === 'entry'
|
|
97
|
+
? { from: entry, to: chain[1] ?? '' }
|
|
98
|
+
: { from: site.replace(/:\d+$/, ''), to: String(meta['barrel'] ?? '') };
|
|
99
|
+
return {
|
|
100
|
+
code: finding.code,
|
|
101
|
+
rule: 'browser-server-barrel',
|
|
102
|
+
entry,
|
|
103
|
+
at: finding.at ?? '',
|
|
104
|
+
edge,
|
|
105
|
+
chain: [...chain],
|
|
106
|
+
edit: finding.fix,
|
|
107
|
+
split: null,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// The browser-graph half of `x fix boundary`, pure: HOW an entry (an island) reaches a module, and
|
|
2
|
+
// WHAT a module takes from a barrel. A server barrel found three hops below an island is the
|
|
3
|
+
// island's mistake when the module importing it is server code — the edge to cut is the entry's
|
|
4
|
+
// first hop, and only the chain says which one that is.
|
|
5
|
+
|
|
6
|
+
import { stripComments } from '@ultimat3/core';
|
|
7
|
+
import type { ClosureHost } from './import-closure';
|
|
8
|
+
import { parseModule, resolveSpec } from './import-closure';
|
|
9
|
+
import { lineIndex } from './ts-scan';
|
|
10
|
+
|
|
11
|
+
/** The path an entry takes to a module, and the import in the entry that starts it. */
|
|
12
|
+
export interface ImportChain {
|
|
13
|
+
/** Entry first, the module last; `[module]` when the module is the entry. */
|
|
14
|
+
readonly chain: readonly string[];
|
|
15
|
+
/** The entry's specifier for `chain[1]` and the line it is written on; absent for `[module]`. */
|
|
16
|
+
readonly hop?: { readonly spec: string; readonly line: number };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Every specifier a module's text can load: value imports, side effects, re-exports, stars. */
|
|
20
|
+
const specifiersOf = (source: string): readonly string[] => {
|
|
21
|
+
const shape = parseModule(source);
|
|
22
|
+
return [
|
|
23
|
+
...shape.imports.map((one) => one.spec),
|
|
24
|
+
...shape.effects,
|
|
25
|
+
...shape.reexports.map((one) => one.spec),
|
|
26
|
+
...shape.stars,
|
|
27
|
+
];
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/** The 1-based line of the first import or re-export in `source` that names `spec`. */
|
|
31
|
+
export function specLine(source: string, spec: string): number {
|
|
32
|
+
const code = stripComments(source);
|
|
33
|
+
const quoted = [`'${spec}'`, `"${spec}"`].map((one) => code.indexOf(one)).filter((at) => at >= 0);
|
|
34
|
+
return quoted.length === 0 ? 1 : lineIndex(code)(Math.min(...quoted));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Breadth first, so the chain printed is the shortest — the one a reader can follow by eye. */
|
|
38
|
+
export function importChain(
|
|
39
|
+
host: ClosureHost,
|
|
40
|
+
entry: string,
|
|
41
|
+
target: string,
|
|
42
|
+
): ImportChain | undefined {
|
|
43
|
+
if (entry === target) return { chain: [target] };
|
|
44
|
+
const parent = new Map<string, { readonly from: string; readonly spec: string }>();
|
|
45
|
+
const queue = [entry];
|
|
46
|
+
const seen = new Set(queue);
|
|
47
|
+
for (let at = queue.shift(); at !== undefined; at = queue.shift()) {
|
|
48
|
+
for (const spec of specifiersOf(host.read(at) ?? '')) {
|
|
49
|
+
const next = resolveSpec(host, at, spec);
|
|
50
|
+
if (next === undefined || seen.has(next)) continue;
|
|
51
|
+
seen.add(next);
|
|
52
|
+
parent.set(next, { from: at, spec });
|
|
53
|
+
if (next === target) return chainTo(host, parent, entry, target);
|
|
54
|
+
queue.push(next);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function chainTo(
|
|
61
|
+
host: ClosureHost,
|
|
62
|
+
parent: ReadonlyMap<string, { readonly from: string; readonly spec: string }>,
|
|
63
|
+
entry: string,
|
|
64
|
+
target: string,
|
|
65
|
+
): ImportChain {
|
|
66
|
+
const chain = [target];
|
|
67
|
+
let spec = '';
|
|
68
|
+
for (let step = parent.get(target); step !== undefined; step = parent.get(step.from)) {
|
|
69
|
+
chain.unshift(step.from);
|
|
70
|
+
spec = step.spec;
|
|
71
|
+
}
|
|
72
|
+
return { chain, hop: { spec, line: specLine(host.read(entry) ?? '', spec) } };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The value names `source` takes from `spec`, or `'*'` when it takes the whole module (a namespace,
|
|
77
|
+
* a side-effect import, a dynamic `import()`, an `export *`) — which no browser entry can promise.
|
|
78
|
+
*/
|
|
79
|
+
export function namesFrom(source: string, spec: string): readonly string[] | '*' {
|
|
80
|
+
const shape = parseModule(source);
|
|
81
|
+
if (shape.effects.includes(spec) || shape.stars.includes(spec)) return '*';
|
|
82
|
+
const names = new Set<string>();
|
|
83
|
+
for (const one of shape.imports) {
|
|
84
|
+
if (one.spec !== spec) continue;
|
|
85
|
+
if (one.names === '*') return '*';
|
|
86
|
+
for (const name of one.names) names.add(name);
|
|
87
|
+
}
|
|
88
|
+
for (const one of shape.reexports) {
|
|
89
|
+
if (one.spec === spec) for (const name of one.map.values()) names.add(name);
|
|
90
|
+
}
|
|
91
|
+
return [...names].sort();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const DECLARED =
|
|
95
|
+
/\bexport\s+(?:declare\s+)?(?:async\s+)?(?:function\*?|const|let|var|class|abstract\s+class|enum|type|interface|namespace)\s+([\w$]+)/g;
|
|
96
|
+
const LISTED = /\bexport\s+(?:type\s+)?\{([^}]*)\}/g;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Every name a module exports, types included, or `undefined` when an `export *` makes the list
|
|
100
|
+
* unknowable from its own text — the caller then cannot promise a swap is safe.
|
|
101
|
+
*/
|
|
102
|
+
export function exportedNames(source: string): ReadonlySet<string> | undefined {
|
|
103
|
+
const code = stripComments(source);
|
|
104
|
+
if (/\bexport\s+\*/.test(code)) return undefined;
|
|
105
|
+
const names = new Set<string>();
|
|
106
|
+
for (const found of code.matchAll(DECLARED)) names.add(found[1] ?? '');
|
|
107
|
+
for (const found of code.matchAll(LISTED)) {
|
|
108
|
+
for (const part of (found[1] ?? '').split(',')) {
|
|
109
|
+
const name = part
|
|
110
|
+
.trim()
|
|
111
|
+
.replace(/^type\s+/, '')
|
|
112
|
+
.split(/\s+as\s+/)
|
|
113
|
+
.at(-1)
|
|
114
|
+
?.trim();
|
|
115
|
+
if (name !== undefined && name !== '') names.add(name);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return names;
|
|
119
|
+
}
|
package/src/browser-transport.ts
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
// one module later (`transport-values.ts`), reported with a fix that removes the hand-off.
|
|
19
19
|
|
|
20
20
|
import { ERROR_DOCS_URL, maskLiterals } from '@ultimat3/core';
|
|
21
|
+
import { importChain, namesFrom } from './browser-import-chain';
|
|
21
22
|
import { commentSafe } from './comment-safe';
|
|
22
23
|
import type { ClosureHost } from './import-closure';
|
|
23
24
|
import { importClosure } from './import-closure';
|
|
@@ -37,6 +38,17 @@ export interface Bypass extends TransportCall {
|
|
|
37
38
|
|
|
38
39
|
export interface ServerBarrel extends BarrelImport {
|
|
39
40
|
readonly file: string;
|
|
41
|
+
/** The browser entry that reaches `file`, first, and `file` last: `[file]` when it IS the entry. */
|
|
42
|
+
readonly chain: readonly string[];
|
|
43
|
+
/** The import in `chain[0]` that starts the chain — the edge a cut deletes. */
|
|
44
|
+
readonly hop?: { readonly spec: string; readonly line: number };
|
|
45
|
+
/** What `file` takes from the barrel; `'*'` is the whole module. */
|
|
46
|
+
readonly names: readonly string[] | '*';
|
|
47
|
+
/**
|
|
48
|
+
* The edit is the swap to the browser entry, at `file` — else the cut of the entry's first hop.
|
|
49
|
+
* A swap only when the entry publishes every name taken; unread, only when `file` IS the entry.
|
|
50
|
+
*/
|
|
51
|
+
readonly swaps: boolean;
|
|
40
52
|
}
|
|
41
53
|
|
|
42
54
|
export const isIsland = (path: string): boolean => path.endsWith('.island.tsx');
|
|
@@ -78,6 +90,11 @@ export interface TransportInput {
|
|
|
78
90
|
readonly barrels: ReadonlyMap<string, string>;
|
|
79
91
|
/** A package's own modules may import its own barrel; only a FOREIGN import pays for it. */
|
|
80
92
|
readonly ownsBarrel?: (file: string, barrel: string) => boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Browser entry → every name it exports, where the caller could read it. A swap promised without
|
|
95
|
+
* it compiles only by luck: `entity()` is in the barrel and not in `@ultimat3/entity/record`.
|
|
96
|
+
*/
|
|
97
|
+
readonly published?: ReadonlyMap<string, ReadonlySet<string>>;
|
|
81
98
|
}
|
|
82
99
|
|
|
83
100
|
/** The whole rule over a tree, pure. */
|
|
@@ -88,7 +105,6 @@ export function checkBrowserTransport(input: TransportInput): {
|
|
|
88
105
|
} {
|
|
89
106
|
const reachable = importClosure(input.host, input.entries);
|
|
90
107
|
const bypasses: Bypass[] = [];
|
|
91
|
-
const barrels: ServerBarrel[] = [];
|
|
92
108
|
for (const file of reachable) {
|
|
93
109
|
if (input.exempt?.has(file) === true) continue;
|
|
94
110
|
const source = input.host.read(file) ?? '';
|
|
@@ -100,12 +116,34 @@ export function checkBrowserTransport(input: TransportInput): {
|
|
|
100
116
|
if (input.seams.get(value.shape) === file) continue;
|
|
101
117
|
bypasses.push({ ...value, file, passed: true });
|
|
102
118
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
119
|
+
}
|
|
120
|
+
return { reachable, bypasses, barrels: serverBarrelSites(input) };
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Per ENTRY, never per tree: a barrel three hops below two islands is two mistakes, one in each
|
|
125
|
+
* island, and a finding that names only the module it landed in blames a file nobody edited.
|
|
126
|
+
*/
|
|
127
|
+
function serverBarrelSites(input: TransportInput): readonly ServerBarrel[] {
|
|
128
|
+
const barrels: ServerBarrel[] = [];
|
|
129
|
+
for (const entry of input.entries) {
|
|
130
|
+
for (const file of importClosure(input.host, [entry])) {
|
|
131
|
+
if (input.exempt?.has(file) === true) continue;
|
|
132
|
+
const source = input.host.read(file) ?? '';
|
|
133
|
+
for (const found of barrelImports(source, input.barrels)) {
|
|
134
|
+
if (input.ownsBarrel?.(file, found.barrel) === true) continue;
|
|
135
|
+
const path = importChain(input.host, entry, file) ?? { chain: [entry, file] };
|
|
136
|
+
const names = namesFrom(source, found.barrel);
|
|
137
|
+
const published = input.published?.get(found.entry);
|
|
138
|
+
const swaps =
|
|
139
|
+
published === undefined
|
|
140
|
+
? entry === file
|
|
141
|
+
: names !== '*' && names.every((name) => published.has(name));
|
|
142
|
+
barrels.push({ ...found, file, ...path, names, swaps });
|
|
143
|
+
}
|
|
106
144
|
}
|
|
107
145
|
}
|
|
108
|
-
return
|
|
146
|
+
return barrels;
|
|
109
147
|
}
|
|
110
148
|
|
|
111
149
|
/**
|
|
@@ -143,8 +181,8 @@ const siteOf = (site: { readonly file: string; readonly line: number }): string
|
|
|
143
181
|
`${commentSafe(site.file)}:${site.line}`;
|
|
144
182
|
|
|
145
183
|
/**
|
|
146
|
-
*
|
|
147
|
-
*
|
|
184
|
+
* The edit first, the re-read after: a line pasted before it is read must not re-run the failure
|
|
185
|
+
* unchanged (`fix-sequence.ts`). Only the finding knows the line, so it names it.
|
|
148
186
|
*/
|
|
149
187
|
export function bypassFinding(bypass: Bypass, context: FindingContext): Finding {
|
|
150
188
|
if (bypass.passed === true) return passedFinding(bypass, context);
|
|
@@ -154,7 +192,7 @@ export function bypassFinding(bypass: Bypass, context: FindingContext): Finding
|
|
|
154
192
|
code: 'X_BROWSER_TRANSPORT_BYPASS',
|
|
155
193
|
at: `${bypass.file}:${bypass.line}`,
|
|
156
194
|
cause: `${site} calls ${bypass.spelled} in browser-reachable code; ${holder === undefined ? 'no module may' : `only ${holder} may`}, so this request skips the page's record store, idempotency header and principal fence`,
|
|
157
|
-
fix:
|
|
195
|
+
fix: `edit ${commentSafe(bypass.file)}:${bypass.line} — replace ${bypass.spelled} with ${REPLACEMENT.get(bypass.shape) ?? ''}; then ${context.rerun}`,
|
|
158
196
|
docs: ERROR_DOCS_URL,
|
|
159
197
|
};
|
|
160
198
|
}
|
|
@@ -171,18 +209,52 @@ function passedFinding(bypass: Bypass, context: FindingContext): Finding {
|
|
|
171
209
|
code: 'X_BROWSER_TRANSPORT_BYPASS',
|
|
172
210
|
at: `${bypass.file}:${bypass.line}`,
|
|
173
211
|
cause: `${site} passes the global ${bypass.spelled} as a value in browser-reachable code; whatever receives it calls it directly, and ${holder === undefined ? 'no module may' : `only ${holder} may`}, so those requests skip the page's record store, idempotency header and principal fence`,
|
|
174
|
-
fix:
|
|
212
|
+
fix: `edit ${commentSafe(bypass.file)}:${bypass.line} — delete ${bypass.spelled} (rpc() and queryClient() send through clientTransport when given none), and make the module that took it use ${REPLACEMENT.get(bypass.shape) ?? ''}; then ${context.rerun}`,
|
|
175
213
|
docs: ERROR_DOCS_URL,
|
|
176
214
|
};
|
|
177
215
|
}
|
|
178
216
|
|
|
179
|
-
|
|
217
|
+
/**
|
|
218
|
+
* Where the barrel is cut (`ServerBarrel.swaps`). A site that needs the server half is server code,
|
|
219
|
+
* so the mistake is the browser entry's first hop: that edge is the one to delete. `meta` carries
|
|
220
|
+
* the chain for a `--json` reader and for `x fix boundary`, which lists the cut for any file on it.
|
|
221
|
+
*/
|
|
222
|
+
export function barrelFinding(site: ServerBarrel, _context: FindingContext): Finding {
|
|
223
|
+
const entry = site.chain[0] ?? site.file;
|
|
180
224
|
const at = siteOf(site);
|
|
225
|
+
const meta = {
|
|
226
|
+
entry,
|
|
227
|
+
chain: [...site.chain],
|
|
228
|
+
sites: [`${site.file}:${site.line}`],
|
|
229
|
+
barrel: site.barrel,
|
|
230
|
+
browserEntry: site.entry,
|
|
231
|
+
names: site.names === '*' ? '*' : [...site.names],
|
|
232
|
+
cut: site.swaps ? 'swap' : 'entry',
|
|
233
|
+
...(site.hop === undefined ? {} : { hop: { spec: site.hop.spec, line: site.hop.line } }),
|
|
234
|
+
};
|
|
235
|
+
const through = site.chain.length > 1 ? ` (${site.chain.map(commentSafe).join(' → ')})` : '';
|
|
236
|
+
if (site.swaps) {
|
|
237
|
+
return {
|
|
238
|
+
code: 'X_BROWSER_SERVER_BARREL',
|
|
239
|
+
at: `${site.file}:${site.line}`,
|
|
240
|
+
cause: `${at} imports ${site.barrel} in browser-reachable code${through}; that barrel is the package's server half, and ${site.entry} is the entry it publishes for a browser`,
|
|
241
|
+
fix: `edit ${commentSafe(site.file)}:${site.line} — change the import from '${site.barrel}' to '${site.entry}'`,
|
|
242
|
+
docs: ERROR_DOCS_URL,
|
|
243
|
+
meta,
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
const taken = site.names === '*' ? 'the whole module' : site.names.join(', ');
|
|
247
|
+
const cut =
|
|
248
|
+
site.hop === undefined
|
|
249
|
+
? { line: site.line, spec: site.barrel }
|
|
250
|
+
: { line: site.hop.line, spec: site.hop.spec };
|
|
251
|
+
const where = siteOf({ file: entry, line: cut.line });
|
|
181
252
|
return {
|
|
182
253
|
code: 'X_BROWSER_SERVER_BARREL',
|
|
183
|
-
at: `${
|
|
184
|
-
cause: `${
|
|
185
|
-
fix:
|
|
254
|
+
at: `${entry}:${cut.line}`,
|
|
255
|
+
cause: `${where} pulls server code into a browser bundle: ${at} takes ${taken} from ${site.barrel}, its server half, not ${site.entry}${through}`,
|
|
256
|
+
fix: `edit ${commentSafe(entry)}:${cut.line} — delete the import of '${cut.spec}' and every use of what it binds; in a browser, read rows through a query (useQuery(<QUERY_REF>, input) from '@ultimat3/realtime') and write through an action (await browserClient.<action>(input))`,
|
|
186
257
|
docs: ERROR_DOCS_URL,
|
|
258
|
+
meta,
|
|
187
259
|
};
|
|
188
260
|
}
|