@nifrajs/cli 5.12.1 → 5.14.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/CHANGELOG.md +72 -0
- package/README.md +3 -1
- package/dist/agent-files.js +0 -74
- package/dist/agent-files.js.map +1 -1
- package/dist/app-files.js +0 -19
- package/dist/app-files.js.map +1 -1
- package/dist/assure-hydration.js +0 -23
- package/dist/assure-hydration.js.map +1 -1
- package/dist/assure.js +0 -14
- package/dist/assure.js.map +1 -1
- package/dist/capabilities-tool.js +0 -51
- package/dist/capabilities-tool.js.map +1 -1
- package/dist/cdn-check.js +0 -2
- package/dist/cdn-check.js.map +1 -1
- package/dist/check-diagnostics.js +0 -29
- package/dist/check-diagnostics.js.map +1 -1
- package/dist/check-scan.js +10 -621
- package/dist/check-scan.js.map +1 -1
- package/dist/check.js +0 -86
- package/dist/check.js.map +1 -1
- package/dist/cli.d.ts +9 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +139 -351
- package/dist/cli.js.map +1 -1
- package/dist/client-module.js +0 -13
- package/dist/client-module.js.map +1 -1
- package/dist/command-catalog.d.ts +29 -1
- package/dist/command-catalog.d.ts.map +1 -1
- package/dist/command-catalog.js +100 -23
- package/dist/command-catalog.js.map +1 -1
- package/dist/component-check.js +1 -7
- package/dist/component-check.js.map +1 -1
- package/dist/config-target.js +0 -13
- package/dist/config-target.js.map +1 -1
- package/dist/contract-proof.js +0 -1
- package/dist/contract-proof.js.map +1 -1
- package/dist/contracts.js +0 -36
- package/dist/contracts.js.map +1 -1
- package/dist/db-audit.js +0 -15
- package/dist/db-audit.js.map +1 -1
- package/dist/db-child.js +0 -20
- package/dist/db-child.js.map +1 -1
- package/dist/db-config.js +0 -23
- package/dist/db-config.js.map +1 -1
- package/dist/db-tool.js +0 -24
- package/dist/db-tool.js.map +1 -1
- package/dist/deployment-adapters.d.ts +12 -0
- package/dist/deployment-adapters.d.ts.map +1 -0
- package/dist/deployment-adapters.js +86 -0
- package/dist/deployment-adapters.js.map +1 -0
- package/dist/dev-bun-config.d.ts +4 -3
- package/dist/dev-bun-config.d.ts.map +1 -1
- package/dist/dev-bun-config.js +9 -101
- package/dist/dev-bun-config.js.map +1 -1
- package/dist/dev-feed-tool.js +0 -32
- package/dist/dev-feed-tool.js.map +1 -1
- package/dist/dev-server-client.js +0 -16
- package/dist/dev-server-client.js.map +1 -1
- package/dist/diagnostics.js +0 -10
- package/dist/diagnostics.js.map +1 -1
- package/dist/diff-tool.js +0 -23
- package/dist/diff-tool.js.map +1 -1
- package/dist/docs-search.js +0 -35
- package/dist/docs-search.js.map +1 -1
- package/dist/doctor.js +3 -161
- package/dist/doctor.js.map +1 -1
- package/dist/env-file.js +0 -66
- package/dist/env-file.js.map +1 -1
- package/dist/examples.js +0 -16
- package/dist/examples.js.map +1 -1
- package/dist/fix-recipes.js +0 -20
- package/dist/fix-recipes.js.map +1 -1
- package/dist/frontend-guidance.js +0 -36
- package/dist/frontend-guidance.js.map +1 -1
- package/dist/hand-built-manifest.js +0 -17
- package/dist/hand-built-manifest.js.map +1 -1
- package/dist/hooks-report.js +0 -4
- package/dist/hooks-report.js.map +1 -1
- package/dist/i18n-check.js +0 -30
- package/dist/i18n-check.js.map +1 -1
- package/dist/init-agents.d.ts +5 -0
- package/dist/init-agents.d.ts.map +1 -1
- package/dist/init-agents.js +2 -134
- package/dist/init-agents.js.map +1 -1
- package/dist/internal/code-unit-order.js +0 -2
- package/dist/internal/code-unit-order.js.map +1 -1
- package/dist/internal/config-paths.js +0 -12
- package/dist/internal/config-paths.js.map +1 -1
- package/dist/internal/control-character.js +0 -1
- package/dist/internal/control-character.js.map +1 -1
- package/dist/internal/escape-regexp.d.ts +1 -2
- package/dist/internal/escape-regexp.d.ts.map +1 -1
- package/dist/internal/escape-regexp.js +1 -4
- package/dist/internal/escape-regexp.js.map +1 -1
- package/dist/internal/git-ignored.js +0 -11
- package/dist/internal/git-ignored.js.map +1 -1
- package/dist/internal/installed-package.js +0 -2
- package/dist/internal/installed-package.js.map +1 -1
- package/dist/internal/line-at.js +0 -1
- package/dist/internal/line-at.js.map +1 -1
- package/dist/internal/nifra-project.js +0 -31
- package/dist/internal/nifra-project.js.map +1 -1
- package/dist/internal/posix-path.js +0 -1
- package/dist/internal/posix-path.js.map +1 -1
- package/dist/internal/project-specifiers.js +0 -34
- package/dist/internal/project-specifiers.js.map +1 -1
- package/dist/internal/realpath-or-self.js +0 -1
- package/dist/internal/realpath-or-self.js.map +1 -1
- package/dist/internal/record.d.ts +1 -1
- package/dist/internal/record.d.ts.map +1 -1
- package/dist/internal/record.js +1 -4
- package/dist/internal/record.js.map +1 -1
- package/dist/internal/reserved-segment-codemod.js +0 -44
- package/dist/internal/reserved-segment-codemod.js.map +1 -1
- package/dist/internal/script-kind.js +0 -5
- package/dist/internal/script-kind.js.map +1 -1
- package/dist/internal/source-facts.js +3 -37
- package/dist/internal/source-facts.js.map +1 -1
- package/dist/internal/typescript-import.js +0 -49
- package/dist/internal/typescript-import.js.map +1 -1
- package/dist/internal/workspace-packages.js +0 -24
- package/dist/internal/workspace-packages.js.map +1 -1
- package/dist/introspect.js +1 -89
- package/dist/introspect.js.map +1 -1
- package/dist/learn.js +0 -16
- package/dist/learn.js.map +1 -1
- package/dist/levels-tool.js +0 -34
- package/dist/levels-tool.js.map +1 -1
- package/dist/load.d.ts +12 -3
- package/dist/load.d.ts.map +1 -1
- package/dist/load.js +19 -75
- package/dist/load.js.map +1 -1
- package/dist/local-cli.js +0 -23
- package/dist/local-cli.js.map +1 -1
- package/dist/lock-links.js +0 -20
- package/dist/lock-links.js.map +1 -1
- package/dist/manifest-tool.js +0 -5
- package/dist/manifest-tool.js.map +1 -1
- package/dist/mcp-app-tool.js +0 -9
- package/dist/mcp-app-tool.js.map +1 -1
- package/dist/mcp-context.js +0 -30
- package/dist/mcp-context.js.map +1 -1
- package/dist/mcp-delegate.js +0 -45
- package/dist/mcp-delegate.js.map +1 -1
- package/dist/mcp-docs-tools.js +0 -13
- package/dist/mcp-docs-tools.js.map +1 -1
- package/dist/mcp-exec.js +0 -71
- package/dist/mcp-exec.js.map +1 -1
- package/dist/mcp-http.js +1 -38
- package/dist/mcp-http.js.map +1 -1
- package/dist/mcp-io.d.ts +5 -1
- package/dist/mcp-io.d.ts.map +1 -1
- package/dist/mcp-io.js +3 -68
- package/dist/mcp-io.js.map +1 -1
- package/dist/mcp-isolate.js +0 -28
- package/dist/mcp-isolate.js.map +1 -1
- package/dist/mcp-path.js +0 -8
- package/dist/mcp-path.js.map +1 -1
- package/dist/mcp-project-child.js +0 -19
- package/dist/mcp-project-child.js.map +1 -1
- package/dist/mcp-protocol.js +0 -5
- package/dist/mcp-protocol.js.map +1 -1
- package/dist/mcp-reflect.js +0 -11
- package/dist/mcp-reflect.js.map +1 -1
- package/dist/mcp-relay.d.ts +4 -0
- package/dist/mcp-relay.d.ts.map +1 -1
- package/dist/mcp-relay.js +9 -20
- package/dist/mcp-relay.js.map +1 -1
- package/dist/mcp-render.js +1 -42
- package/dist/mcp-render.js.map +1 -1
- package/dist/mcp-root.d.ts.map +1 -1
- package/dist/mcp-root.js +18 -90
- package/dist/mcp-root.js.map +1 -1
- package/dist/mcp-run.js +1 -38
- package/dist/mcp-run.js.map +1 -1
- package/dist/mcp-tool-meta.js +3 -8
- package/dist/mcp-tool-meta.js.map +1 -1
- package/dist/mcp-ws.js +0 -16
- package/dist/mcp-ws.js.map +1 -1
- package/dist/mcp.js +0 -86
- package/dist/mcp.js.map +1 -1
- package/dist/migrate-layout.js +0 -313
- package/dist/migrate-layout.js.map +1 -1
- package/dist/openapi-tool.js +0 -18
- package/dist/openapi-tool.js.map +1 -1
- package/dist/openapi-types.js +0 -22
- package/dist/openapi-types.js.map +1 -1
- package/dist/output-schemas.js +0 -67
- package/dist/output-schemas.js.map +1 -1
- package/dist/pipeline-guard.js +0 -58
- package/dist/pipeline-guard.js.map +1 -1
- package/dist/pipeline-report.js +0 -71
- package/dist/pipeline-report.js.map +1 -1
- package/dist/port.d.ts +6 -3
- package/dist/port.d.ts.map +1 -1
- package/dist/port.js +16 -92
- package/dist/port.js.map +1 -1
- package/dist/ppr-read-fix.js +0 -29
- package/dist/ppr-read-fix.js.map +1 -1
- package/dist/project-facts.js +0 -5
- package/dist/project-facts.js.map +1 -1
- package/dist/project-path.js +0 -7
- package/dist/project-path.js.map +1 -1
- package/dist/project-site.js +0 -2
- package/dist/project-site.js.map +1 -1
- package/dist/recipes/1.8.0.js +0 -9
- package/dist/recipes/1.8.0.js.map +1 -1
- package/dist/recipes/2.0.0.js +0 -6
- package/dist/recipes/2.0.0.js.map +1 -1
- package/dist/recipes/3.0.0.js +0 -7
- package/dist/recipes/3.0.0.js.map +1 -1
- package/dist/recipes/4.0.0.js +0 -6
- package/dist/recipes/4.0.0.js.map +1 -1
- package/dist/recipes/5.0.0.js +0 -8
- package/dist/recipes/5.0.0.js.map +1 -1
- package/dist/recipes/5.1.0.js +0 -6
- package/dist/recipes/5.1.0.js.map +1 -1
- package/dist/recipes/5.10.0.js +0 -10
- package/dist/recipes/5.10.0.js.map +1 -1
- package/dist/recipes/5.11.0.js +0 -7
- package/dist/recipes/5.11.0.js.map +1 -1
- package/dist/recipes/5.12.0.js +0 -6
- package/dist/recipes/5.12.0.js.map +1 -1
- package/dist/recipes/5.13.0.d.ts +9 -0
- package/dist/recipes/5.13.0.d.ts.map +1 -0
- package/dist/recipes/5.13.0.js +34 -0
- package/dist/recipes/5.13.0.js.map +1 -0
- package/dist/recipes/5.14.0.d.ts +10 -0
- package/dist/recipes/5.14.0.d.ts.map +1 -0
- package/dist/recipes/5.14.0.js +26 -0
- package/dist/recipes/5.14.0.js.map +1 -0
- package/dist/recipes/5.2.0.js +0 -7
- package/dist/recipes/5.2.0.js.map +1 -1
- package/dist/recipes/5.3.0.js +0 -8
- package/dist/recipes/5.3.0.js.map +1 -1
- package/dist/recipes/5.4.0.js +0 -8
- package/dist/recipes/5.4.0.js.map +1 -1
- package/dist/recipes/5.5.0.js +0 -6
- package/dist/recipes/5.5.0.js.map +1 -1
- package/dist/recipes/5.6.0.js +0 -7
- package/dist/recipes/5.6.0.js.map +1 -1
- package/dist/recipes/5.7.0.js +0 -9
- package/dist/recipes/5.7.0.js.map +1 -1
- package/dist/recipes/5.8.0.js +0 -6
- package/dist/recipes/5.8.0.js.map +1 -1
- package/dist/recipes/5.9.0.js +0 -9
- package/dist/recipes/5.9.0.js.map +1 -1
- package/dist/recipes/index.d.ts.map +1 -1
- package/dist/recipes/index.js +4 -9
- package/dist/recipes/index.js.map +1 -1
- package/dist/release-verification.js +0 -14
- package/dist/release-verification.js.map +1 -1
- package/dist/replay.js +0 -3
- package/dist/replay.js.map +1 -1
- package/dist/review.js +0 -21
- package/dist/review.js.map +1 -1
- package/dist/route-types.js +0 -17
- package/dist/route-types.js.map +1 -1
- package/dist/rule-explain.js +0 -5
- package/dist/rule-explain.js.map +1 -1
- package/dist/rules/codes.js +0 -2
- package/dist/rules/codes.js.map +1 -1
- package/dist/rules/comment-markers.js +0 -25
- package/dist/rules/comment-markers.js.map +1 -1
- package/dist/rules/contract-visibility.js +0 -27
- package/dist/rules/contract-visibility.js.map +1 -1
- package/dist/rules/data-guard.js +1 -52
- package/dist/rules/data-guard.js.map +1 -1
- package/dist/rules/internal-links.js +0 -36
- package/dist/rules/internal-links.js.map +1 -1
- package/dist/rules/islands.js +2 -65
- package/dist/rules/islands.js.map +1 -1
- package/dist/rules/layout.js +0 -1
- package/dist/rules/layout.js.map +1 -1
- package/dist/rules/legacy.js +0 -31
- package/dist/rules/legacy.js.map +1 -1
- package/dist/rules/merge-auth.js +0 -9
- package/dist/rules/merge-auth.js.map +1 -1
- package/dist/rules/pages.js +0 -95
- package/dist/rules/pages.js.map +1 -1
- package/dist/rules/ppr.js +0 -8
- package/dist/rules/ppr.js.map +1 -1
- package/dist/rules/route-statement.js +0 -13
- package/dist/rules/route-statement.js.map +1 -1
- package/dist/rules/routes.js +1 -67
- package/dist/rules/routes.js.map +1 -1
- package/dist/rules/secrets.js +0 -15
- package/dist/rules/secrets.js.map +1 -1
- package/dist/rules/security.js +0 -113
- package/dist/rules/security.js.map +1 -1
- package/dist/rules/server-fn-namespace.js +0 -5
- package/dist/rules/server-fn-namespace.js.map +1 -1
- package/dist/rules/source-scan.js +0 -5
- package/dist/rules/source-scan.js.map +1 -1
- package/dist/rules/swap.js +0 -21
- package/dist/rules/swap.js.map +1 -1
- package/dist/rules/text-slot-boolean.js +0 -5
- package/dist/rules/text-slot-boolean.js.map +1 -1
- package/dist/rules/typescript.js +0 -5
- package/dist/rules/typescript.js.map +1 -1
- package/dist/rules/undeclared-response.js +0 -8
- package/dist/rules/undeclared-response.js.map +1 -1
- package/dist/rules/zones.js +0 -45
- package/dist/rules/zones.js.map +1 -1
- package/dist/runtime-differences.js +0 -20
- package/dist/runtime-differences.js.map +1 -1
- package/dist/scaffold-hole.js +1 -45
- package/dist/scaffold-hole.js.map +1 -1
- package/dist/scaffold.js +3 -60
- package/dist/scaffold.js.map +1 -1
- package/dist/sdk.js +1 -13
- package/dist/sdk.js.map +1 -1
- package/dist/search-terms.js +0 -12
- package/dist/search-terms.js.map +1 -1
- package/dist/shell-files.d.ts +44 -0
- package/dist/shell-files.d.ts.map +1 -0
- package/dist/shell-files.js +186 -0
- package/dist/shell-files.js.map +1 -0
- package/dist/shell-init.d.ts +33 -0
- package/dist/shell-init.d.ts.map +1 -0
- package/dist/shell-init.js +84 -0
- package/dist/shell-init.js.map +1 -0
- package/dist/smoke.js +0 -4
- package/dist/smoke.js.map +1 -1
- package/dist/source-rewrites.js +0 -43
- package/dist/source-rewrites.js.map +1 -1
- package/dist/stylex-migrate.js +0 -29
- package/dist/stylex-migrate.js.map +1 -1
- package/dist/symptom-search.js +0 -3
- package/dist/symptom-search.js.map +1 -1
- package/dist/sync-manifest.js +3 -33
- package/dist/sync-manifest.js.map +1 -1
- package/dist/test-tool.js +0 -10
- package/dist/test-tool.js.map +1 -1
- package/dist/typecheck-coverage.js +0 -36
- package/dist/typecheck-coverage.js.map +1 -1
- package/dist/types-search.js +0 -35
- package/dist/types-search.js.map +1 -1
- package/dist/upgrade.js +0 -214
- package/dist/upgrade.js.map +1 -1
- package/dist/verification-plan.js +0 -19
- package/dist/verification-plan.js.map +1 -1
- package/dist/verification.js +0 -23
- package/dist/verification.js.map +1 -1
- package/dist/version-drift.js +0 -8
- package/dist/version-drift.js.map +1 -1
- package/dist/web-app-options.js +0 -16
- package/dist/web-app-options.js.map +1 -1
- package/dist/work-graph.js +0 -21
- package/dist/work-graph.js.map +1 -1
- package/dist/workspace-link.js +0 -31
- package/dist/workspace-link.js.map +1 -1
- package/docs/examples.json +97 -1
- package/docs/llms-full.txt +1347 -59
- package/docs/types.json +756 -37
- package/package.json +12 -11
- package/src/assure-hydration.ts +3 -3
- package/src/cli.ts +189 -39
- package/src/command-catalog.ts +144 -7
- package/src/deployment-adapters.ts +107 -0
- package/src/dev-bun-config.ts +21 -2
- package/src/init-agents.ts +1 -1
- package/src/internal/escape-regexp.ts +1 -4
- package/src/internal/record.ts +1 -3
- package/src/internal/typescript-import.ts +1 -1
- package/src/load.ts +36 -3
- package/src/mcp-http.ts +1 -1
- package/src/mcp-io.ts +8 -5
- package/src/mcp-relay.ts +19 -7
- package/src/mcp-render.ts +1 -1
- package/src/mcp-root.ts +21 -3
- package/src/mcp-tool-meta.ts +3 -3
- package/src/port.ts +25 -8
- package/src/recipes/5.13.0.ts +41 -0
- package/src/recipes/5.14.0.ts +34 -0
- package/src/recipes/index.ts +4 -0
- package/src/rules/routes.ts +2 -2
- package/src/shell-files.ts +225 -0
- package/src/shell-init.ts +139 -0
package/dist/doctor.js
CHANGED
|
@@ -1,21 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `nifra doctor` - catches the Bun-workspace footgun the typed-client lint can't: a package that's
|
|
3
|
-
* IMPORTED in source but NOT declared in `package.json`. Bun resolves it at runtime (via hoisting or a
|
|
4
|
-
* workspace), so tests pass and `bun install` reports "no changes" - false confidence - yet `tsc` fails
|
|
5
|
-
* and a fresh or standalone install can't resolve it. doctor diffs every bare import specifier against
|
|
6
|
-
* the package's declared dependencies and flags the gap, with a stable `--json` shape for agents/CI.
|
|
7
|
-
*
|
|
8
|
-
* Scope is intentionally per-package: it checks the `package.json` at `cwd`, because a dependency must be
|
|
9
|
-
* declared by the package that imports it (for `tsc` and for that package to install on its own) even
|
|
10
|
-
* when a monorepo would hoist it. Relative paths, runtime builtins (node core, `node:`/`bun:`, `bun`),
|
|
11
|
-
* the package's own name, and tsconfig `paths` aliases are excluded - none of them are npm deps.
|
|
12
|
-
*
|
|
13
|
-
* The diff is against DECLARED dependency sets only; what happens to be installed on disk is never
|
|
14
|
-
* consulted. That is the point: a package pulled in transitively by some other dependency resolves fine
|
|
15
|
-
* locally while no manifest declares it, so resolvability is not evidence of declaration. The scan
|
|
16
|
-
* therefore also covers `*.test.ts`/`*.spec.ts`, which `nifra check` skips - `tsc` compiles them, so an
|
|
17
|
-
* undeclared import there fails a clean `bun install --frozen-lockfile` build just the same.
|
|
18
|
-
*/
|
|
19
1
|
import { existsSync } from "node:fs";
|
|
20
2
|
import { readdir, realpath, stat } from "node:fs/promises";
|
|
21
3
|
import { builtinModules } from "node:module";
|
|
@@ -35,19 +17,11 @@ import { resolveTarget } from "./port.js";
|
|
|
35
17
|
import { isFixedGroup, resolvePackageFrom } from "./upgrade.js";
|
|
36
18
|
import { collectVersionDrift, versionDriftMessage } from "./version-drift.js";
|
|
37
19
|
import { buildScriptName } from "./workspace-link.js";
|
|
38
|
-
// Runtime-provided modules that are never an npm dependency: Node core (bare + `node:` form) and Bun's
|
|
39
|
-
// own `bun` module. `node:`/`bun:`-prefixed specifiers are filtered in packageOf by prefix.
|
|
40
20
|
const BUILTINS = new Set([
|
|
41
21
|
...builtinModules,
|
|
42
22
|
...builtinModules.map((m) => `node:${m}`),
|
|
43
23
|
"bun",
|
|
44
24
|
]);
|
|
45
|
-
// The four specifier-bearing forms: static import/re-export with a source, side-effect import, dynamic
|
|
46
|
-
// import, and CJS require. Anchored with `(?<![.\w$])` so `myimport`/`.import`/`foorequire` never match.
|
|
47
|
-
// Comments are stripped before these run (see stripComments) - else a doc-comment usage example would be
|
|
48
|
-
// flagged as a real import.
|
|
49
|
-
// The clause before `from` is spelled out rather than scanned lazily: a lazy scan restarts at every
|
|
50
|
-
// `export const` line and is quadratic on a long module with no string literal.
|
|
51
25
|
const IMPORT_PATTERNS = [
|
|
52
26
|
/(?<![.\w$])(?:import|export)\b\s*(?:type\b\s*)?(?:[\w$]+\s*,?\s*)?(?:\*\s*(?:as\b\s*[\w$]+\s*)?|\{[^{}'"]*\}\s*)?from\s*['"]([^'"]+)['"]/g,
|
|
53
27
|
/(?<![.\w$])import\s+['"]([^'"]+)['"]/g,
|
|
@@ -63,11 +37,6 @@ const DEPENDENCY_FIELDS = [
|
|
|
63
37
|
];
|
|
64
38
|
const isNpmPackageName = (name) => NPM_PACKAGE_NAME.test(name) &&
|
|
65
39
|
name.split("/").every((part) => part !== "" && part !== "." && part !== "..");
|
|
66
|
-
/**
|
|
67
|
-
* Resolve an import specifier to the npm package name it would install as, or `undefined` when it isn't
|
|
68
|
-
* an npm dependency at all (a relative/absolute path, a runtime builtin, or a malformed scope like the
|
|
69
|
-
* `@/…` path-alias convention). `@scope/name/sub` → `@scope/name`; `name/sub` → `name`.
|
|
70
|
-
*/
|
|
71
40
|
export function packageOf(spec) {
|
|
72
41
|
if (spec === "" || spec.startsWith(".") || spec.startsWith("/"))
|
|
73
42
|
return undefined;
|
|
@@ -76,7 +45,7 @@ export function packageOf(spec) {
|
|
|
76
45
|
if (spec.startsWith("@")) {
|
|
77
46
|
const [scope, name] = spec.split("/");
|
|
78
47
|
if (!scope || scope === "@" || !name)
|
|
79
|
-
return undefined;
|
|
48
|
+
return undefined;
|
|
80
49
|
const pkg = `${scope}/${name}`;
|
|
81
50
|
return isNpmPackageName(pkg) ? pkg : undefined;
|
|
82
51
|
}
|
|
@@ -85,28 +54,20 @@ export function packageOf(spec) {
|
|
|
85
54
|
return undefined;
|
|
86
55
|
return BUILTINS.has(name) ? undefined : name;
|
|
87
56
|
}
|
|
88
|
-
/** Build a predicate matching tsconfig `paths` aliases (e.g. `@/*`, `~/utils`), which resolve to local
|
|
89
|
-
* source, not npm packages - so doctor must not flag them. */
|
|
90
57
|
export function aliasMatcher(paths) {
|
|
91
58
|
const prefixes = Object.keys(paths ?? {})
|
|
92
59
|
.map((k) => k.replace(/\/?\*$/, ""))
|
|
93
60
|
.filter((p) => p !== "");
|
|
94
61
|
return (spec) => prefixes.some((p) => spec === p || spec.startsWith(`${p}/`));
|
|
95
62
|
}
|
|
96
|
-
/**
|
|
97
|
-
* Scan one file for bare imports whose resolved package is neither `declared` nor a path `alias`. Pure +
|
|
98
|
-
* line-accurate. Deduped per (package, line): the `snippet` carries the undeclared package name.
|
|
99
|
-
*/
|
|
100
63
|
export function scanUndeclaredImports(file, content, declared, isAlias) {
|
|
101
64
|
const out = [];
|
|
102
65
|
const seen = new Set();
|
|
103
|
-
const code = stripComments(content);
|
|
66
|
+
const code = stripComments(content);
|
|
104
67
|
const positions = codePositionMask(content);
|
|
105
68
|
for (const rx of IMPORT_PATTERNS) {
|
|
106
69
|
rx.lastIndex = 0;
|
|
107
70
|
for (let m = rx.exec(code); m !== null; m = rx.exec(code)) {
|
|
108
|
-
// The specifier regex must run over quoted literals, but its import/require token must begin in
|
|
109
|
-
// executable code. Otherwise documentation and code-generator strings look like real imports.
|
|
110
71
|
if (positions[m.index] === " ")
|
|
111
72
|
continue;
|
|
112
73
|
const spec = m[1] ?? "";
|
|
@@ -125,7 +86,6 @@ export function scanUndeclaredImports(file, content, declared, isAlias) {
|
|
|
125
86
|
}
|
|
126
87
|
return out.sort((a, b) => a.line - b.line || codeUnitOrder(a.snippet, b.snippet));
|
|
127
88
|
}
|
|
128
|
-
/** Read + parse a JSON file, or `undefined` if it's missing/unparseable (doctor degrades, never throws). */
|
|
129
89
|
async function readJson(path) {
|
|
130
90
|
try {
|
|
131
91
|
const text = await Bun.file(path).text();
|
|
@@ -156,9 +116,6 @@ function workspacePatterns(pkg) {
|
|
|
156
116
|
.filter((entry) => typeof entry === "string" && entry.length > 0)
|
|
157
117
|
.sort();
|
|
158
118
|
}
|
|
159
|
-
/** Discover package roots declared by npm/Bun's workspace manifest shapes plus nested package
|
|
160
|
-
* boundaries (scaffold templates and benchmark fixtures are commonly real standalone packages even
|
|
161
|
-
* when they are not workspace members). Bounded so a hostile tree cannot make doctor unbounded. */
|
|
162
119
|
async function workspaceImporters(cwd, rootPackage, includeNestedPackages = false) {
|
|
163
120
|
const manifests = new Set([join(cwd, "package.json")]);
|
|
164
121
|
for (const pattern of workspacePatterns(rootPackage)) {
|
|
@@ -167,8 +124,6 @@ async function workspaceImporters(cwd, rootPackage, includeNestedPackages = fals
|
|
|
167
124
|
if (rel.split(/[\\/]/).includes("node_modules"))
|
|
168
125
|
continue;
|
|
169
126
|
manifests.add(join(cwd, rel));
|
|
170
|
-
// A pathological workspace pattern should not make doctor unbounded. Duplicate detection is
|
|
171
|
-
// skipped, while the existing source/declaration diagnostic still runs normally.
|
|
172
127
|
if (manifests.size > MAX_WORKSPACE_IMPORTERS)
|
|
173
128
|
return [];
|
|
174
129
|
}
|
|
@@ -202,12 +157,9 @@ const declaredPackages = (pkg) => {
|
|
|
202
157
|
}
|
|
203
158
|
return declared;
|
|
204
159
|
};
|
|
205
|
-
/** Build per-package declaration scopes for a workspace. Longest roots are first so nested packages
|
|
206
|
-
* own their source; files outside a workspace package remain owned by the root manifest. */
|
|
207
160
|
async function doctorPackageScopes(cwd, rootPackage) {
|
|
208
161
|
const importers = await workspaceImporters(cwd, rootPackage, true);
|
|
209
162
|
const packages = importers.length > 0 ? importers : [{ root: cwd, package: rootPackage }];
|
|
210
|
-
// The nearest tsconfig, read as TypeScript does: comments, trailing commas and `extends` included.
|
|
211
163
|
const resolver = createSpecifierResolver();
|
|
212
164
|
const scopes = packages.map((entry) => ({
|
|
213
165
|
root: entry.root,
|
|
@@ -219,13 +171,6 @@ async function doctorPackageScopes(cwd, rootPackage) {
|
|
|
219
171
|
}
|
|
220
172
|
const scopeForFile = (scopes, file) => scopes.find((scope) => scope.relativeRoot !== "" &&
|
|
221
173
|
(file === scope.relativeRoot || file.startsWith(`${scope.relativeRoot}/`))) ?? scopes.find((scope) => scope.relativeRoot === "");
|
|
222
|
-
/* Identity-sensitive install resolution is owned by @nifrajs/web/internal/parity. */
|
|
223
|
-
/** Find identity-sensitive dependencies that resolve to multiple physical directories. Two copies at
|
|
224
|
-
* the same version still fail: module identity (React hooks, Nifra symbols/registries) is path-based.
|
|
225
|
-
*
|
|
226
|
-
* `cwd` is where the user ran the check; the scan is anchored at the workspace root above it (see
|
|
227
|
-
* The shared parity seam resolves the governing workspace root, while paths are still REPORTED
|
|
228
|
-
* relative to `cwd` so the findings read the way the user's terminal does. */
|
|
229
174
|
export async function collectDuplicateInstalls(cwd, rootPackage) {
|
|
230
175
|
return (await collectAllDuplicateInstalls(cwd, rootPackage)).duplicates;
|
|
231
176
|
}
|
|
@@ -233,15 +178,6 @@ const asDuplicateInstall = (finding) => ({
|
|
|
233
178
|
...finding,
|
|
234
179
|
copies: finding.copies.map((copy) => ({ ...copy })),
|
|
235
180
|
});
|
|
236
|
-
/**
|
|
237
|
-
* Both halves of the identity scan: what still breaks, and what a declaration already collapses -
|
|
238
|
-
* plus the basis they were decided on.
|
|
239
|
-
*
|
|
240
|
-
* The basis travels with the findings because doctor and the build/dev preflight answer the same
|
|
241
|
-
* question, and a reader who gets two answers needs to see which tree each one looked at. They now
|
|
242
|
-
* scan identically (one shared seam, one workspace resolution), so the line is corroboration rather
|
|
243
|
-
* than an excuse - and it is the only way a TRUNCATED scan can be told apart from a clean one.
|
|
244
|
-
*/
|
|
245
181
|
export async function collectAllDuplicateInstalls(cwd, rootPackage) {
|
|
246
182
|
const result = await collectIdentityParity(cwd, rootPackage);
|
|
247
183
|
return {
|
|
@@ -251,10 +187,6 @@ export async function collectAllDuplicateInstalls(cwd, rootPackage) {
|
|
|
251
187
|
truncated: result.truncated,
|
|
252
188
|
};
|
|
253
189
|
}
|
|
254
|
-
/**
|
|
255
|
-
* Resolve one condition through an export-map entry: a string is terminal; an object takes the first
|
|
256
|
-
* key that is the wanted condition or `default` (insertion order, like the runtime), skipping `types`.
|
|
257
|
-
*/
|
|
258
190
|
function exportTarget(entry, condition) {
|
|
259
191
|
if (typeof entry === "string")
|
|
260
192
|
return entry;
|
|
@@ -268,8 +200,6 @@ function exportTarget(entry, condition) {
|
|
|
268
200
|
}
|
|
269
201
|
return undefined;
|
|
270
202
|
}
|
|
271
|
-
// Bounded recursive walk for the newest file under a package's source tree. The cap is a runaway
|
|
272
|
-
// guard, not a tuning knob - a real `src/` is a few hundred files.
|
|
273
203
|
const MAX_SOURCE_FILES = 4_096;
|
|
274
204
|
async function newestFileUnder(dir) {
|
|
275
205
|
let newest;
|
|
@@ -297,16 +227,6 @@ async function newestFileUnder(dir) {
|
|
|
297
227
|
await walk(dir);
|
|
298
228
|
return newest;
|
|
299
229
|
}
|
|
300
|
-
/**
|
|
301
|
-
* Find workspace-linked dependencies whose `default`-condition artifact (`dist/…`) has fallen behind
|
|
302
|
-
* their `bun`-condition source (`src/…`).
|
|
303
|
-
*
|
|
304
|
-
* The split export map is what makes this a trap: Bun (the build, the tests, the prod binary) reads
|
|
305
|
-
* live source, while Vite's SSR runner and any node consumer read a build artifact nothing in the dev
|
|
306
|
-
* loop regenerates. `dist/` is gitignored, so the drift never shows in a diff - it surfaces as a 500
|
|
307
|
-
* INSIDE framework/shared-package code and reads like an upstream regression. npm-installed copies are
|
|
308
|
-
* immutable and skipped; only symlinked (workspace) installs can drift.
|
|
309
|
-
*/
|
|
310
230
|
export async function collectStaleWorkspaceDists(cwd, rootPackage) {
|
|
311
231
|
const findings = [];
|
|
312
232
|
const seen = new Set();
|
|
@@ -315,19 +235,13 @@ export async function collectStaleWorkspaceDists(cwd, rootPackage) {
|
|
|
315
235
|
if (seen.has(name))
|
|
316
236
|
continue;
|
|
317
237
|
seen.add(name);
|
|
318
|
-
// Boundary "" - never matches a real dir, so the upward walk runs to the filesystem root and
|
|
319
|
-
// finds a hoisted copy wherever the install put it.
|
|
320
238
|
const copy = await resolvedInstalledCopy(cwd, "", name);
|
|
321
|
-
// A real (tarball) install lives under node_modules and cannot drift; only a symlink out of the
|
|
322
|
-
// tree - a workspace/link install whose realpath escapes node_modules - has a live `src`.
|
|
323
239
|
if (copy === undefined || copy.path.includes(`${sep}node_modules${sep}`))
|
|
324
240
|
continue;
|
|
325
241
|
const meta = await readJson(join(copy.path, "package.json"));
|
|
326
242
|
const exportsMap = meta?.exports;
|
|
327
243
|
if (!isRecord(exportsMap))
|
|
328
244
|
continue;
|
|
329
|
-
// Every subpath with a bun→src / default→dist split; the root "." alone would miss the common
|
|
330
|
-
// "deep subpaths only" layout.
|
|
331
245
|
const pairs = [];
|
|
332
246
|
const entries = Object.keys(exportsMap).some((k) => k.startsWith("."))
|
|
333
247
|
? Object.entries(exportsMap)
|
|
@@ -340,7 +254,6 @@ export async function collectStaleWorkspaceDists(cwd, rootPackage) {
|
|
|
340
254
|
}
|
|
341
255
|
if (pairs.length === 0)
|
|
342
256
|
continue;
|
|
343
|
-
// One newest-source probe per package: the bun targets share a source tree (its top directory).
|
|
344
257
|
const sourceDirs = new Set(pairs
|
|
345
258
|
.map((p) => p.bun.replace(/^\.\//, "").split("/")[0])
|
|
346
259
|
.filter((d) => d !== undefined && d.length > 0));
|
|
@@ -354,7 +267,6 @@ export async function collectStaleWorkspaceDists(cwd, rootPackage) {
|
|
|
354
267
|
continue;
|
|
355
268
|
const packageDir = displayPath(cwd, copy.path);
|
|
356
269
|
const buildScript = buildScriptName(meta);
|
|
357
|
-
// Report the package once, anchored on its stalest (or missing) artifact.
|
|
358
270
|
let worst;
|
|
359
271
|
for (const pair of pairs) {
|
|
360
272
|
const distPath = join(copy.path, pair.dist.replace(/^\.\//, ""));
|
|
@@ -413,12 +325,6 @@ function readinessSource(file, source, via) {
|
|
|
413
325
|
const code = codePositionMask(source);
|
|
414
326
|
return via === undefined ? { file, source, code } : { file, source, code, via };
|
|
415
327
|
}
|
|
416
|
-
/**
|
|
417
|
-
* The source of every package the app imports from outside its own tree that is not a registry
|
|
418
|
-
* install (a `file:` or `link:` dependency, a workspace sibling), and of those it imports in turn: a
|
|
419
|
-
* server factory such a package builds is this app's server. nifra's own packages are skipped - they
|
|
420
|
-
* define these settings, they do not apply them.
|
|
421
|
-
*/
|
|
422
328
|
async function linkedReadinessSources(cwd, files) {
|
|
423
329
|
let root;
|
|
424
330
|
try {
|
|
@@ -451,14 +357,12 @@ async function linkedReadinessSources(cwd, files) {
|
|
|
451
357
|
await follow(root, files);
|
|
452
358
|
return linked;
|
|
453
359
|
}
|
|
454
|
-
/** Read only source shapes used to report production readiness. Values and secrets are never loaded. */
|
|
455
360
|
async function collectDoctorReadiness(cwd, opts) {
|
|
456
361
|
const resolved = await resolveTarget(cwd, opts.target);
|
|
457
362
|
const own = [];
|
|
458
363
|
await walkSource(cwd, (file, source) => {
|
|
459
364
|
own.push(readinessSource(file, source));
|
|
460
365
|
});
|
|
461
|
-
// The app's own files first, so a setting it makes itself is the evidence shown.
|
|
462
366
|
const files = [...own, ...(await linkedReadinessSources(cwd, own))];
|
|
463
367
|
const edgeTarget = /^(?:cloudflare|vercel|workers|edge|static)$/.test(resolved?.target ?? "");
|
|
464
368
|
const configured = (id, label, pattern, sourcePattern) => {
|
|
@@ -473,21 +377,9 @@ async function collectDoctorReadiness(cwd, opts) {
|
|
|
473
377
|
};
|
|
474
378
|
const items = [
|
|
475
379
|
configured("request-timeout", "request timeout or budget", /\b(?:requestTimeoutMs|createRequestBudget|admitDeadline)\s*[:(]/),
|
|
476
|
-
// `admission: controller`, the shorthand `{ admission }` (trailing comma or closing brace), or
|
|
477
|
-
// the documented constructor call - shorthand is the idiomatic form when the controller is an
|
|
478
|
-
// import or module const.
|
|
479
380
|
configured("admission", "capacity admission", /\badmission\s*[:,}]|\bcreateAdmissionController\s*\(/),
|
|
480
381
|
configured("request-id-tracing", "request id or tracing middleware", /\b(?:requestId|tracing)\s*\(/),
|
|
481
|
-
configured("health-route", "health route", /\bhealthcheck\s*\(/,
|
|
482
|
-
// Conventional health paths: /health, /healthz (the k8s form healthcheck() is most often
|
|
483
|
-
// configured to serve), /health-check, and the underscore-prefixed variants, each also
|
|
484
|
-
// matching as a prefix (`/health/live`). `/healthy` etc. stay non-matches: the path must end
|
|
485
|
-
// (closing quote) or continue with a segment right after the recognized name.
|
|
486
|
-
/\.(?:get|head)\s*\(\s*["']\/_?health(?:z|-check)?(?:["']|\/)/),
|
|
487
|
-
// Asserts "a redacting logger is INSTALLED", so only the call forms count: the redacting
|
|
488
|
-
// constructors, or @nifrajs/middleware's `logger()` structured request logger (which logs only
|
|
489
|
-
// method/path/status/duration - nothing redactable). A bare `logger:` property proves nothing:
|
|
490
|
-
// `logger: console` matches it and redacts nothing.
|
|
382
|
+
configured("health-route", "health route", /\bhealthcheck\s*\(/, /\.(?:get|head)\s*\(\s*["']\/_?health(?:z|-check)?(?:["']|\/)/),
|
|
491
383
|
configured("log-redaction", "log redaction", /\b(?:jsonLogger|redactLogFields|logger)\s*\(/),
|
|
492
384
|
edgeTarget
|
|
493
385
|
? { id: "graceful-lifecycle", label: "graceful lifecycle", status: "not-applicable" }
|
|
@@ -526,10 +418,6 @@ async function ancestorDependencySpec(cwd, name) {
|
|
|
526
418
|
return undefined;
|
|
527
419
|
}
|
|
528
420
|
}
|
|
529
|
-
/**
|
|
530
|
-
* A path spec (`file:packages/x`, `link:../x`, `./vendor/x.tgz`) resolves against the package.json
|
|
531
|
-
* that declares it, so a spec copied from an ancestor is re-pointed to the same target from `cwd`.
|
|
532
|
-
*/
|
|
533
421
|
function rebaseDependencySpec(spec, declaredIn, cwd) {
|
|
534
422
|
const protocol = /^(?:file|link|portal):/.exec(spec)?.[0] ?? "";
|
|
535
423
|
const path = spec.slice(protocol.length);
|
|
@@ -563,8 +451,6 @@ async function inferDependencyFix(cwd, name) {
|
|
|
563
451
|
? undefined
|
|
564
452
|
: { version: installedSpec, source: "installed-package-json" };
|
|
565
453
|
}
|
|
566
|
-
/** Run doctor against the project at `cwd`: diff source imports vs declared deps. */
|
|
567
|
-
// Packages whose session cookies the identity epoch knows by their default names.
|
|
568
454
|
const KNOWN_AUTH_PACKAGES = [
|
|
569
455
|
"@nifrajs/auth",
|
|
570
456
|
"@nifrajs/authjs",
|
|
@@ -573,23 +459,9 @@ const KNOWN_AUTH_PACKAGES = [
|
|
|
573
459
|
"next-auth",
|
|
574
460
|
];
|
|
575
461
|
const IDENTITY_SIGNAL = /\b(?:identityCookies\s*:|rotateIdentityEpoch\s*\(|identityChanged\s*\()/;
|
|
576
|
-
// A session cookie renamed outright: Better Auth's `advanced.cookies.session_token.name`, Auth.js's
|
|
577
|
-
// `cookies.sessionToken.name`, `@nifrajs/auth`'s `cookieName`. A Better Auth `cookiePrefix` keeps the
|
|
578
|
-
// suffix the identity epoch matches, so it is not one, and neither is a type's `name: string`.
|
|
579
462
|
const RENAMED_SESSION = /\b(?:session_token|sessionToken)\s*:\s*\{[^}]*\bname\s*:\s*["'`]|\bcookieName\s*:\s*["'`]/;
|
|
580
|
-
// Below the app itself, only what a package loads at runtime is followed.
|
|
581
463
|
const AUTH_RUNTIME_FIELDS = ["dependencies", "peerDependencies", "optionalDependencies"];
|
|
582
|
-
// Bounds the walk over a large install; a wrapper sits a step or two from the app.
|
|
583
464
|
const MAX_AUTH_WALK = 2000;
|
|
584
|
-
/**
|
|
585
|
-
* The known auth package nearest the app among the packages it depends on, followed through the
|
|
586
|
-
* installed and linked graph (real paths, so a workspace package and its own install count once),
|
|
587
|
-
* with the dependency chain that reaches it. The app's own dependencies are checked by the caller.
|
|
588
|
-
* A package declared but not installed - an unmet peer or optional dependency - is not reached.
|
|
589
|
-
* `renamedIn` is the first file of a source package on that chain outside the app's tree (a workspace
|
|
590
|
-
* sibling, a `file:` or `link:` package) that renames the session cookie: the app's own scan never
|
|
591
|
-
* reads it.
|
|
592
|
-
*/
|
|
593
465
|
async function reachableAuthPackage(cwd, pkg) {
|
|
594
466
|
let root;
|
|
595
467
|
try {
|
|
@@ -635,7 +507,6 @@ async function reachableAuthPackage(cwd, pkg) {
|
|
|
635
507
|
}
|
|
636
508
|
async function renamedInSources(root, dirs) {
|
|
637
509
|
for (const resolved of dirs) {
|
|
638
|
-
// root is a realpath; a resolved dir can still hold a Windows 8.3 name such as RUNNER~1.
|
|
639
510
|
const dir = await realpath(resolved).catch(() => resolved);
|
|
640
511
|
if (dir.startsWith(root + sep) || dir.split(sep).includes("node_modules"))
|
|
641
512
|
continue;
|
|
@@ -672,10 +543,6 @@ export async function collectDoctorResult(cwd, opts = {}) {
|
|
|
672
543
|
const manifestLists = [];
|
|
673
544
|
let identitySignal = false;
|
|
674
545
|
let renamedIn;
|
|
675
|
-
// A standalone app owns its tests, so they remain in the declaration check. A workspace root owns
|
|
676
|
-
// the published package source while its root devDependencies intentionally own shared tests,
|
|
677
|
-
// benchmarks, and scaffold copy-surfaces. Keep that boundary explicit instead of reporting a
|
|
678
|
-
// monorepo-wide false failure or silently dropping files from the result.
|
|
679
546
|
const workspaceProduction = workspacePatterns(pkg).length > 0;
|
|
680
547
|
const scanScope = Object.freeze({
|
|
681
548
|
kind: workspaceProduction ? "workspace-production" : "standalone",
|
|
@@ -712,9 +579,6 @@ export async function collectDoctorResult(cwd, opts = {}) {
|
|
|
712
579
|
const pipeline = await collectPipelineReport(cwd);
|
|
713
580
|
const pipelineErrors = pipeline.findings.filter((f) => f.severity === "error");
|
|
714
581
|
const readiness = await collectDoctorReadiness(cwd, opts);
|
|
715
|
-
// A stale binary answering about a project it does not match is an environment condition, so like
|
|
716
|
-
// `staleDists` it is reported but never folded into `ok`. Skipped entirely when the caller did not
|
|
717
|
-
// pass its own version (e.g. the MCP server, which already annotates every result with the drift).
|
|
718
582
|
const toolingDrift = opts.cliVersion !== undefined ? await detectToolingDrift(cwd, opts.cliVersion) : undefined;
|
|
719
583
|
const staleMcpPins = await collectStaleMcpPins(cwd).catch(() => undefined);
|
|
720
584
|
const versionDrift = collectVersionDrift(cwd, opts.cliVersion);
|
|
@@ -723,7 +587,6 @@ export async function collectDoctorResult(cwd, opts = {}) {
|
|
|
723
587
|
const handBuilt = handBuiltManifests(cwd, manifestLists);
|
|
724
588
|
const directAuth = KNOWN_AUTH_PACKAGES.some((name) => dependencySpec(pkg, name) !== undefined);
|
|
725
589
|
const keptRoutes = identitySignal || (directAuth && renamedIn === undefined) ? [] : keepAliveRoutes(cwd);
|
|
726
|
-
// A wrapper package the app owns may be what brings the auth library in.
|
|
727
590
|
const reachedAuth = keptRoutes.length === 0 || directAuth ? undefined : await reachableAuthPackage(cwd, pkg);
|
|
728
591
|
renamedIn ??= reachedAuth?.renamedIn;
|
|
729
592
|
const knownAuth = directAuth || reachedAuth !== undefined;
|
|
@@ -735,7 +598,6 @@ export async function collectDoctorResult(cwd, opts = {}) {
|
|
|
735
598
|
const keepAliveIdentityCovered = reachedAuth !== undefined && renamedIn === undefined
|
|
736
599
|
? { routes: keptRoutes, package: reachedAuth.package, via: reachedAuth.via }
|
|
737
600
|
: undefined;
|
|
738
|
-
// `staleDists`, `toolingDrift` and `staleMcpPins` are advisory (see DoctorResult): they never fail `ok`.
|
|
739
601
|
return {
|
|
740
602
|
ok: findings.length === 0 &&
|
|
741
603
|
duplicateInstalls.length === 0 &&
|
|
@@ -767,7 +629,6 @@ export async function collectDoctorResult(cwd, opts = {}) {
|
|
|
767
629
|
...(pipeline.ran ? { pipeline } : {}),
|
|
768
630
|
};
|
|
769
631
|
}
|
|
770
|
-
/** Safely add undeclared imports to package.json when the version can be inferred without network I/O. */
|
|
771
632
|
export async function applyDoctorAutoFix(cwd, opts = {}) {
|
|
772
633
|
const before = await collectDoctorResult(cwd, opts);
|
|
773
634
|
if (!before.ran || before.findings.length === 0)
|
|
@@ -837,7 +698,6 @@ export async function applyDoctorAutoFix(cwd, opts = {}) {
|
|
|
837
698
|
...(skippedFixes.length > 0 ? { skippedFixes } : {}),
|
|
838
699
|
};
|
|
839
700
|
}
|
|
840
|
-
/** Run doctor; print a report (`--json` for machine output) and return whether it passed. */
|
|
841
701
|
export async function runDoctor(cwd, opts = {}) {
|
|
842
702
|
const result = opts.autoFix
|
|
843
703
|
? await applyDoctorAutoFix(cwd, opts)
|
|
@@ -845,7 +705,6 @@ export async function runDoctor(cwd, opts = {}) {
|
|
|
845
705
|
console.log(opts.json ? JSON.stringify(result, null, 2) : doctorReport(result, opts.cliVersion).join("\n"));
|
|
846
706
|
return result.ok;
|
|
847
707
|
}
|
|
848
|
-
/** The human report of a doctor run, one printed line per entry. */
|
|
849
708
|
export function doctorReport(result, cliVersion) {
|
|
850
709
|
const lines = [];
|
|
851
710
|
lines.push("nifra doctor\n");
|
|
@@ -867,8 +726,6 @@ export function doctorReport(result, cliVersion) {
|
|
|
867
726
|
}
|
|
868
727
|
lines.push("");
|
|
869
728
|
}
|
|
870
|
-
// Printed before the findings and regardless of ok: which bundler owns this app is the frame the
|
|
871
|
-
// rest of the report is read in, not a footnote to it.
|
|
872
729
|
if (result.pipeline !== undefined) {
|
|
873
730
|
const p = result.pipeline;
|
|
874
731
|
lines.push(p.pipeline === "unknown"
|
|
@@ -885,8 +742,6 @@ export function doctorReport(result, cliVersion) {
|
|
|
885
742
|
lines.push(` excluded: ${result.scanScope.excluded.join(", ")}`);
|
|
886
743
|
lines.push("");
|
|
887
744
|
}
|
|
888
|
-
// Advisory, printed regardless of ok: a stale linked dist doesn't fail doctor, but silently eating
|
|
889
|
-
// it costs an hour of misdiagnosis when the dev server 500s inside the package.
|
|
890
745
|
if (result.staleDists.length > 0) {
|
|
891
746
|
lines.push(`⚠ ${result.staleDists.length} workspace-linked package(s) with a build artifact older than their source (Bun reads src, Vite SSR/node consumers read dist):\n`);
|
|
892
747
|
for (const f of result.staleDists) {
|
|
@@ -910,8 +765,6 @@ export function doctorReport(result, cliVersion) {
|
|
|
910
765
|
}
|
|
911
766
|
lines.push("");
|
|
912
767
|
}
|
|
913
|
-
// Advisory, printed regardless of ok: the binary answering is a different feature version than the
|
|
914
|
-
// one the project builds with, so its types/checks/docs describe a surface the code does not have.
|
|
915
768
|
if (result.toolingDrift !== undefined) {
|
|
916
769
|
const drift = result.toolingDrift;
|
|
917
770
|
lines.push(`⚠ this CLI is nifra ${drift.cli}, but the project installs ${drift.package} ${drift.project} - ` +
|
|
@@ -939,8 +792,6 @@ export function doctorReport(result, cliVersion) {
|
|
|
939
792
|
const { routes, package: library, via } = result.keepAliveIdentityCovered;
|
|
940
793
|
lines.push(`ℹ ${routes.join(", ")} keep pages alive, and this app reaches ${library} through ${via.join(" > ")}: nifra knows its session cookie by the default name${library === "better-auth" ? " or the <prefix>.session_token suffix" : ""}, so a sign-out drops the kept pages unless that package renames the cookie outright (then name it in keepAlive.identityCookies)\n`);
|
|
941
794
|
}
|
|
942
|
-
// Advisory: the agent's MCP server is launched from these pins, so a stale one answers for an old
|
|
943
|
-
// release even when the CLI running doctor matches the project.
|
|
944
795
|
if (result.staleMcpPins !== undefined) {
|
|
945
796
|
const { target, files } = result.staleMcpPins;
|
|
946
797
|
lines.push(target === null
|
|
@@ -957,14 +808,11 @@ export function doctorReport(result, cliVersion) {
|
|
|
957
808
|
lines.push("✓ every imported package is declared and identity-sensitive installs are deduplicated");
|
|
958
809
|
if (result.identityBasis !== undefined)
|
|
959
810
|
lines.push(` identity scan: ${result.identityBasis}`);
|
|
960
|
-
// A partial scan that prints a bare ✓ is a lie by omission - the packages past the cap were never
|
|
961
|
-
// looked at, and the reader has no way to know that from the tick alone.
|
|
962
811
|
if (result.identityScanTruncated === true) {
|
|
963
812
|
lines.push(" ! the identity scan was truncated, so this is not a clean bill for the whole workspace");
|
|
964
813
|
}
|
|
965
814
|
return lines;
|
|
966
815
|
}
|
|
967
|
-
// Group by package so the fix ("add X to dependencies") is stated once with its import sites.
|
|
968
816
|
const byPkg = new Map();
|
|
969
817
|
for (const f of result.findings) {
|
|
970
818
|
const list = byPkg.get(f.package) ?? [];
|
|
@@ -990,21 +838,15 @@ export function doctorReport(result, cliVersion) {
|
|
|
990
838
|
lines.push(` ${copy.version} at ${copy.path} ← ${copy.importers.join(", ")}`);
|
|
991
839
|
}
|
|
992
840
|
lines.push(` ${finding.explanation}`);
|
|
993
|
-
// A planted symlink is the cause no reinstall here can see, so it is named before the fix.
|
|
994
841
|
if (finding.provenance !== undefined)
|
|
995
842
|
lines.push(` links: ${finding.provenance}`);
|
|
996
|
-
// The shape of the split decides which fix can work, so it is printed above the fix itself.
|
|
997
843
|
if (finding.topology !== undefined)
|
|
998
844
|
lines.push(` topology: ${finding.topology}`);
|
|
999
|
-
// Why a copy this directory never imports still counts. Without it, a workspace-wide answer
|
|
1000
|
-
// read from inside one app looks like the tool checking the wrong project.
|
|
1001
845
|
if (finding.scope !== undefined)
|
|
1002
846
|
lines.push(` scope: ${finding.scope}`);
|
|
1003
847
|
lines.push(` fix: ${finding.remediation}`);
|
|
1004
848
|
}
|
|
1005
849
|
}
|
|
1006
|
-
// Not a failure and not silence: the copies are real, and whoever reads this report needs to know
|
|
1007
|
-
// the graph is held together by a declaration rather than by the install.
|
|
1008
850
|
if (result.deduplicatedInstalls !== undefined && result.deduplicatedInstalls.length > 0) {
|
|
1009
851
|
lines.push("\n• identity-sensitive packages deduplicated by declaration:\n");
|
|
1010
852
|
for (const finding of result.deduplicatedInstalls) {
|