@nifrajs/cli 5.8.0 → 5.10.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 +191 -0
- package/dist/agent-files.d.ts +0 -22
- package/dist/agent-files.d.ts.map +1 -1
- package/dist/agent-files.js +3 -1
- package/dist/agent-files.js.map +1 -1
- package/dist/assure-hydration.d.ts.map +1 -1
- package/dist/assure-hydration.js +2 -10
- package/dist/assure-hydration.js.map +1 -1
- package/dist/assure.d.ts.map +1 -1
- package/dist/assure.js +3 -3
- package/dist/assure.js.map +1 -1
- package/dist/check-diagnostics.d.ts +1 -0
- package/dist/check-diagnostics.d.ts.map +1 -1
- package/dist/check-diagnostics.js +4 -0
- package/dist/check-diagnostics.js.map +1 -1
- package/dist/check-scan.d.ts +3 -0
- package/dist/check-scan.d.ts.map +1 -1
- package/dist/check-scan.js +62 -87
- package/dist/check-scan.js.map +1 -1
- package/dist/check.d.ts +3 -0
- package/dist/check.d.ts.map +1 -1
- package/dist/check.js +27 -25
- package/dist/check.js.map +1 -1
- package/dist/cli.d.ts +8 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +53 -20
- package/dist/cli.js.map +1 -1
- package/dist/command-catalog.d.ts +1 -5
- package/dist/command-catalog.d.ts.map +1 -1
- package/dist/command-catalog.js +20 -49
- package/dist/command-catalog.js.map +1 -1
- package/dist/config-target.js +1 -1
- package/dist/config-target.js.map +1 -1
- package/dist/db-child.js +3 -10
- package/dist/db-child.js.map +1 -1
- package/dist/db-config.d.ts +2 -0
- package/dist/db-config.d.ts.map +1 -1
- package/dist/db-config.js +2 -0
- package/dist/db-config.js.map +1 -1
- package/dist/doctor.d.ts +14 -3
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +91 -6
- package/dist/doctor.js.map +1 -1
- package/dist/frontend-guidance.d.ts +19 -0
- package/dist/frontend-guidance.d.ts.map +1 -1
- package/dist/frontend-guidance.js +267 -23
- package/dist/frontend-guidance.js.map +1 -1
- package/dist/hand-built-manifest.d.ts.map +1 -1
- package/dist/hand-built-manifest.js +1 -1
- package/dist/hand-built-manifest.js.map +1 -1
- package/dist/internal/control-character.d.ts +3 -0
- package/dist/internal/control-character.d.ts.map +1 -0
- package/dist/internal/control-character.js +10 -0
- package/dist/internal/control-character.js.map +1 -0
- package/dist/internal/escape-regexp.d.ts +3 -0
- package/dist/internal/escape-regexp.d.ts.map +1 -0
- package/dist/internal/escape-regexp.js +5 -0
- package/dist/internal/escape-regexp.js.map +1 -0
- package/dist/internal/line-at.d.ts +3 -0
- package/dist/internal/line-at.d.ts.map +1 -0
- package/dist/internal/line-at.js +5 -0
- package/dist/internal/line-at.js.map +1 -0
- package/dist/internal/nifra-project.d.ts.map +1 -1
- package/dist/internal/nifra-project.js +35 -41
- package/dist/internal/nifra-project.js.map +1 -1
- package/dist/internal/posix-path.d.ts +3 -0
- package/dist/internal/posix-path.d.ts.map +1 -0
- package/dist/internal/posix-path.js +5 -0
- package/dist/internal/posix-path.js.map +1 -0
- package/dist/internal/project-specifiers.d.ts.map +1 -1
- package/dist/internal/project-specifiers.js +3 -10
- package/dist/internal/project-specifiers.js.map +1 -1
- package/dist/internal/realpath-or-self.d.ts +3 -0
- package/dist/internal/realpath-or-self.d.ts.map +1 -0
- package/dist/internal/realpath-or-self.js +11 -0
- package/dist/internal/realpath-or-self.js.map +1 -0
- package/dist/internal/record.d.ts +3 -0
- package/dist/internal/record.d.ts.map +1 -0
- package/dist/internal/record.js +5 -0
- package/dist/internal/record.js.map +1 -0
- package/dist/internal/source-facts.d.ts +30 -0
- package/dist/internal/source-facts.d.ts.map +1 -1
- package/dist/internal/source-facts.js +155 -25
- package/dist/internal/source-facts.js.map +1 -1
- package/dist/introspect.d.ts +0 -22
- package/dist/introspect.d.ts.map +1 -1
- package/dist/introspect.js +11 -151
- package/dist/introspect.js.map +1 -1
- package/dist/levels-tool.d.ts +2 -0
- package/dist/levels-tool.d.ts.map +1 -1
- package/dist/levels-tool.js +54 -64
- package/dist/levels-tool.js.map +1 -1
- package/dist/load.d.ts +8 -1
- package/dist/load.d.ts.map +1 -1
- package/dist/load.js +5 -0
- package/dist/load.js.map +1 -1
- package/dist/local-cli.d.ts +7 -0
- package/dist/local-cli.d.ts.map +1 -1
- package/dist/local-cli.js +13 -0
- package/dist/local-cli.js.map +1 -1
- package/dist/mcp-docs-tools.d.ts +1 -1
- package/dist/mcp-docs-tools.d.ts.map +1 -1
- package/dist/mcp-docs-tools.js +46 -3
- package/dist/mcp-docs-tools.js.map +1 -1
- package/dist/mcp-http.d.ts +1 -1
- package/dist/mcp-http.js +2 -2
- package/dist/mcp-http.js.map +1 -1
- package/dist/mcp-io.d.ts +16 -0
- package/dist/mcp-io.d.ts.map +1 -1
- package/dist/mcp-io.js +63 -0
- package/dist/mcp-io.js.map +1 -1
- package/dist/mcp-isolate.d.ts.map +1 -1
- package/dist/mcp-isolate.js +2 -1
- package/dist/mcp-isolate.js.map +1 -1
- package/dist/mcp-project-child.d.ts.map +1 -1
- package/dist/mcp-project-child.js +5 -12
- package/dist/mcp-project-child.js.map +1 -1
- package/dist/mcp-render.d.ts.map +1 -1
- package/dist/mcp-render.js +9 -51
- package/dist/mcp-render.js.map +1 -1
- package/dist/mcp-root.js +1 -1
- package/dist/mcp-root.js.map +1 -1
- package/dist/mcp-run.d.ts.map +1 -1
- package/dist/mcp-run.js +3 -46
- package/dist/mcp-run.js.map +1 -1
- package/dist/mcp-tool-meta.d.ts.map +1 -1
- package/dist/mcp-tool-meta.js +0 -1
- package/dist/mcp-tool-meta.js.map +1 -1
- package/dist/mcp-ws.d.ts.map +1 -1
- package/dist/mcp-ws.js +2 -18
- package/dist/mcp-ws.js.map +1 -1
- package/dist/migrate-layout.d.ts.map +1 -1
- package/dist/migrate-layout.js +36 -57
- package/dist/migrate-layout.js.map +1 -1
- package/dist/output-schemas.d.ts.map +1 -1
- package/dist/output-schemas.js +7 -7
- package/dist/output-schemas.js.map +1 -1
- package/dist/port.d.ts.map +1 -1
- package/dist/port.js +1 -2
- package/dist/port.js.map +1 -1
- package/dist/ppr-read-fix.js +2 -2
- package/dist/ppr-read-fix.js.map +1 -1
- package/dist/recipes/5.10.0.d.ts +12 -0
- package/dist/recipes/5.10.0.d.ts.map +1 -0
- package/dist/recipes/5.10.0.js +44 -0
- package/dist/recipes/5.10.0.js.map +1 -0
- package/dist/recipes/5.9.0.d.ts +10 -0
- package/dist/recipes/5.9.0.d.ts.map +1 -0
- package/dist/recipes/5.9.0.js +41 -0
- package/dist/recipes/5.9.0.js.map +1 -0
- package/dist/recipes/index.d.ts +5 -0
- package/dist/recipes/index.d.ts.map +1 -1
- package/dist/recipes/index.js +4 -0
- package/dist/recipes/index.js.map +1 -1
- package/dist/review.d.ts.map +1 -1
- package/dist/review.js +12 -13
- package/dist/review.js.map +1 -1
- package/dist/rules/codes.d.ts +3 -0
- package/dist/rules/codes.d.ts.map +1 -1
- package/dist/rules/codes.js +3 -0
- package/dist/rules/codes.js.map +1 -1
- package/dist/rules/contract-visibility.d.ts.map +1 -1
- package/dist/rules/contract-visibility.js +3 -9
- package/dist/rules/contract-visibility.js.map +1 -1
- package/dist/rules/data-guard.d.ts.map +1 -1
- package/dist/rules/data-guard.js +3 -10
- package/dist/rules/data-guard.js.map +1 -1
- package/dist/rules/explanations.d.ts.map +1 -1
- package/dist/rules/explanations.js +15 -0
- package/dist/rules/explanations.js.map +1 -1
- package/dist/rules/internal-links.d.ts +5 -0
- package/dist/rules/internal-links.d.ts.map +1 -0
- package/dist/rules/internal-links.js +418 -0
- package/dist/rules/internal-links.js.map +1 -0
- package/dist/rules/legacy.d.ts.map +1 -1
- package/dist/rules/legacy.js +20 -0
- package/dist/rules/legacy.js.map +1 -1
- package/dist/rules/pages.d.ts.map +1 -1
- package/dist/rules/pages.js +41 -58
- package/dist/rules/pages.js.map +1 -1
- package/dist/rules/routes.d.ts.map +1 -1
- package/dist/rules/routes.js +20 -27
- package/dist/rules/routes.js.map +1 -1
- package/dist/rules/security.d.ts.map +1 -1
- package/dist/rules/security.js +206 -313
- package/dist/rules/security.js.map +1 -1
- package/dist/rules/server-fn-namespace.d.ts +8 -0
- package/dist/rules/server-fn-namespace.d.ts.map +1 -0
- package/dist/rules/server-fn-namespace.js +43 -0
- package/dist/rules/server-fn-namespace.js.map +1 -0
- package/dist/rules/source-scan.d.ts +29 -0
- package/dist/rules/source-scan.d.ts.map +1 -0
- package/dist/rules/source-scan.js +38 -0
- package/dist/rules/source-scan.js.map +1 -0
- package/dist/rules/text-slot-boolean.d.ts.map +1 -1
- package/dist/rules/text-slot-boolean.js +21 -43
- package/dist/rules/text-slot-boolean.js.map +1 -1
- package/dist/rules/zones.d.ts.map +1 -1
- package/dist/rules/zones.js +3 -10
- package/dist/rules/zones.js.map +1 -1
- package/dist/runtime-differences.d.ts +62 -0
- package/dist/runtime-differences.d.ts.map +1 -0
- package/dist/runtime-differences.js +222 -0
- package/dist/runtime-differences.js.map +1 -0
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +43 -43
- package/dist/sdk.js.map +1 -1
- package/dist/smoke.d.ts.map +1 -1
- package/dist/smoke.js +4 -12
- package/dist/smoke.js.map +1 -1
- package/dist/source-rewrites.d.ts +27 -0
- package/dist/source-rewrites.d.ts.map +1 -0
- package/dist/source-rewrites.js +517 -0
- package/dist/source-rewrites.js.map +1 -0
- package/dist/stylex-migrate.d.ts.map +1 -1
- package/dist/stylex-migrate.js +1 -1
- package/dist/stylex-migrate.js.map +1 -1
- package/dist/symptom-search.d.ts +5 -0
- package/dist/symptom-search.d.ts.map +1 -0
- package/dist/symptom-search.js +21 -0
- package/dist/symptom-search.js.map +1 -0
- package/dist/typecheck-coverage.d.ts +9 -0
- package/dist/typecheck-coverage.d.ts.map +1 -1
- package/dist/typecheck-coverage.js +16 -0
- package/dist/typecheck-coverage.js.map +1 -1
- package/dist/upgrade.d.ts +28 -3
- package/dist/upgrade.d.ts.map +1 -1
- package/dist/upgrade.js +153 -64
- package/dist/upgrade.js.map +1 -1
- package/dist/verification-plan.d.ts.map +1 -1
- package/dist/verification-plan.js +5 -3
- package/dist/verification-plan.js.map +1 -1
- package/docs/examples.json +51 -9
- package/docs/llms-full.txt +1296 -287
- package/docs/types.json +854 -170
- package/package.json +11 -11
- package/src/agent-files.ts +4 -1
- package/src/assure-hydration.ts +2 -9
- package/src/assure.ts +3 -4
- package/src/check-diagnostics.ts +5 -0
- package/src/check-scan.ts +74 -83
- package/src/check.ts +40 -26
- package/src/cli.ts +76 -20
- package/src/command-catalog.ts +22 -56
- package/src/config-target.ts +1 -1
- package/src/db-child.ts +3 -10
- package/src/db-config.ts +4 -0
- package/src/doctor.ts +128 -12
- package/src/frontend-guidance.ts +344 -25
- package/src/hand-built-manifest.ts +1 -2
- package/src/internal/control-character.ts +8 -0
- package/src/internal/escape-regexp.ts +4 -0
- package/src/internal/line-at.ts +4 -0
- package/src/internal/nifra-project.ts +39 -35
- package/src/internal/posix-path.ts +4 -0
- package/src/internal/project-specifiers.ts +3 -10
- package/src/internal/realpath-or-self.ts +10 -0
- package/src/internal/record.ts +4 -0
- package/src/internal/source-facts.ts +194 -29
- package/src/introspect.ts +16 -156
- package/src/levels-tool.ts +71 -78
- package/src/load.ts +15 -1
- package/src/local-cli.ts +12 -0
- package/src/mcp-docs-tools.ts +51 -3
- package/src/mcp-http.ts +2 -2
- package/src/mcp-io.ts +77 -0
- package/src/mcp-isolate.ts +2 -3
- package/src/mcp-project-child.ts +5 -14
- package/src/mcp-render.ts +11 -59
- package/src/mcp-root.ts +1 -1
- package/src/mcp-run.ts +5 -54
- package/src/mcp-tool-meta.ts +0 -1
- package/src/mcp-ws.ts +2 -19
- package/src/migrate-layout.ts +52 -72
- package/src/output-schemas.ts +7 -8
- package/src/port.ts +1 -4
- package/src/ppr-read-fix.ts +2 -2
- package/src/recipes/5.10.0.ts +45 -0
- package/src/recipes/5.9.0.ts +42 -0
- package/src/recipes/index.ts +9 -0
- package/src/review.ts +15 -15
- package/src/rules/codes.ts +3 -0
- package/src/rules/contract-visibility.ts +3 -8
- package/src/rules/data-guard.ts +3 -10
- package/src/rules/explanations.ts +15 -0
- package/src/rules/internal-links.ts +490 -0
- package/src/rules/legacy.ts +21 -0
- package/src/rules/pages.ts +47 -58
- package/src/rules/routes.ts +21 -27
- package/src/rules/security.ts +224 -255
- package/src/rules/server-fn-namespace.ts +47 -0
- package/src/rules/source-scan.ts +66 -0
- package/src/rules/text-slot-boolean.ts +26 -42
- package/src/rules/zones.ts +3 -10
- package/src/runtime-differences.ts +302 -0
- package/src/sdk.ts +55 -58
- package/src/smoke.ts +4 -13
- package/src/source-rewrites.ts +592 -0
- package/src/stylex-migrate.ts +1 -3
- package/src/symptom-search.ts +27 -0
- package/src/typecheck-coverage.ts +23 -0
- package/src/upgrade.ts +194 -74
- package/src/verification-plan.ts +10 -4
- package/dist/sync-routes.d.ts +0 -29
- package/dist/sync-routes.d.ts.map +0 -1
- package/dist/sync-routes.js +0 -56
- package/dist/sync-routes.js.map +0 -1
- package/src/sync-routes.ts +0 -70
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nifrajs/cli",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.10.0",
|
|
4
4
|
"description": "The nifra CLI - zero-config dev/build/start for a nifra app (`nifra dev`, `nifra build`, `nifra start`).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bun",
|
|
@@ -70,16 +70,16 @@
|
|
|
70
70
|
"access": "public"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@nifrajs/client": "5.
|
|
74
|
-
"@nifrajs/core": "5.
|
|
75
|
-
"@nifrajs/agent-review": "5.
|
|
76
|
-
"@nifrajs/i18n": "5.
|
|
77
|
-
"@nifrajs/mcp": "5.
|
|
78
|
-
"@nifrajs/mcp-db": "5.
|
|
79
|
-
"@nifrajs/runner": "5.
|
|
80
|
-
"@nifrajs/schema": "5.
|
|
81
|
-
"@nifrajs/testing": "5.
|
|
82
|
-
"@nifrajs/web": "5.
|
|
73
|
+
"@nifrajs/client": "5.10.0",
|
|
74
|
+
"@nifrajs/core": "5.10.0",
|
|
75
|
+
"@nifrajs/agent-review": "5.10.0",
|
|
76
|
+
"@nifrajs/i18n": "5.10.0",
|
|
77
|
+
"@nifrajs/mcp": "5.10.0",
|
|
78
|
+
"@nifrajs/mcp-db": "5.10.0",
|
|
79
|
+
"@nifrajs/runner": "5.10.0",
|
|
80
|
+
"@nifrajs/schema": "5.10.0",
|
|
81
|
+
"@nifrajs/testing": "5.10.0",
|
|
82
|
+
"@nifrajs/web": "5.10.0"
|
|
83
83
|
},
|
|
84
84
|
"repository": {
|
|
85
85
|
"type": "git",
|
package/src/agent-files.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// Generated by scripts/gen-vendored.ts - edit packages/create-nifra/src/agent-files.ts instead.
|
|
2
|
+
// Copied so `nifra init-agents` writes what a scaffold writes, without depending on create-nifra.
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* The canonical generators for the agent files an app ships. `AGENTS.md` is the single source of agent
|
|
3
6
|
* guidance; every other agent's file is a thin pointer to it, so no two copies can drift:
|
|
@@ -10,7 +13,7 @@
|
|
|
10
13
|
* .mcp.json, .cursor/mcp.json - the nifra MCP server, registered for Claude Code and Cursor
|
|
11
14
|
*
|
|
12
15
|
* `create-nifra` (scaffold time) and `@nifrajs/cli`'s `nifra init-agents` (retrofit an existing app) each
|
|
13
|
-
* ship this file byte-identical - `
|
|
16
|
+
* ship this file byte-identical - the CLI's is generated from this one (`scripts/gen-vendored.ts`) - so
|
|
14
17
|
* the generated files can never drift apart and neither package needs the other at runtime. It stays
|
|
15
18
|
* dependency-free (pure string + object generation) on purpose: `create-nifra` ships with no runtime deps.
|
|
16
19
|
*
|
package/src/assure-hydration.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
forwardTerminalSignals,
|
|
18
18
|
joinHeadTail,
|
|
19
19
|
OWN_PROCESS_GROUP,
|
|
20
|
+
protocolStdout,
|
|
20
21
|
readBoundedStream,
|
|
21
22
|
readHeadTail,
|
|
22
23
|
signalProcessGroup,
|
|
@@ -700,15 +701,7 @@ export async function runHydrationAssurance(
|
|
|
700
701
|
}
|
|
701
702
|
|
|
702
703
|
if (import.meta.main && process.argv.includes("--nifra-hydration-child")) {
|
|
703
|
-
|
|
704
|
-
// never reaches the answer channel.
|
|
705
|
-
const stdout = process.stdout.write.bind(process.stdout)
|
|
706
|
-
const toStderr = (...args: unknown[]): void => {
|
|
707
|
-
process.stderr.write(`${args.map((arg) => String(arg)).join(" ")}\n`)
|
|
708
|
-
}
|
|
709
|
-
console.log = toStderr
|
|
710
|
-
console.info = toStderr
|
|
711
|
-
console.debug = toStderr
|
|
704
|
+
const stdout = protocolStdout()
|
|
712
705
|
const token = (await readBoundedStream(Bun.stdin.stream(), 256)).text.trim()
|
|
713
706
|
const cwd = process.argv[2] ?? process.cwd()
|
|
714
707
|
const rawOptions = process.argv[4]
|
package/src/assure.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { pathToFileURL } from "node:url"
|
|
|
6
6
|
import type { AssuranceConfig, AssuranceReport, AssuredRoute } from "@nifrajs/core/assurance"
|
|
7
7
|
import { CONFIG_FILE, FRAMEWORK_FILE } from "./app-files.ts"
|
|
8
8
|
import type { Diagnostic } from "./diagnostics.ts"
|
|
9
|
+
import { toPosix } from "./internal/posix-path.ts"
|
|
9
10
|
import type { ProjectVerification } from "./verification.ts"
|
|
10
11
|
|
|
11
12
|
export interface AssureSink {
|
|
@@ -60,8 +61,6 @@ export function createMemoryAssureSink(): MemoryAssureSink {
|
|
|
60
61
|
|
|
61
62
|
export const DEFAULT_ASSURANCE_CONFIG = "nifra.assurance.ts"
|
|
62
63
|
|
|
63
|
-
const displayPath = (path: string): string => path.replaceAll("\\", "/")
|
|
64
|
-
|
|
65
64
|
function isConfig(value: unknown): value is AssuranceConfig {
|
|
66
65
|
if (typeof value !== "object" || value === null) return false
|
|
67
66
|
const candidate = value as Partial<AssuranceConfig>
|
|
@@ -79,7 +78,7 @@ export async function loadAssuranceConfig(
|
|
|
79
78
|
const path = resolve(cwd, configPath)
|
|
80
79
|
if (!existsSync(path)) {
|
|
81
80
|
throw new Error(
|
|
82
|
-
`[nifra] route assurance config not found: ${
|
|
81
|
+
`[nifra] route assurance config not found: ${toPosix(path)} - create ${DEFAULT_ASSURANCE_CONFIG} with a default defineAssuranceConfig({ source, policy }) export.`,
|
|
83
82
|
)
|
|
84
83
|
}
|
|
85
84
|
const specifier = pathToFileURL(path)
|
|
@@ -97,7 +96,7 @@ export async function loadAssuranceConfig(
|
|
|
97
96
|
}
|
|
98
97
|
if (!isConfig(loaded.default)) {
|
|
99
98
|
throw new Error(
|
|
100
|
-
`[nifra] ${
|
|
99
|
+
`[nifra] ${toPosix(path)} must default-export defineAssuranceConfig({ source, policy }).`,
|
|
101
100
|
)
|
|
102
101
|
}
|
|
103
102
|
return loaded.default
|
package/src/check-diagnostics.ts
CHANGED
|
@@ -25,6 +25,7 @@ import { freezeProjectFacts, type ProjectFactsSeed } from "./project-facts.ts"
|
|
|
25
25
|
import { contractVisibilityRule } from "./rules/contract-visibility.ts"
|
|
26
26
|
import { dataGuardRules } from "./rules/data-guard.ts"
|
|
27
27
|
import { parseRulePacks, runRuleRegistry } from "./rules/index.ts"
|
|
28
|
+
import { internalLinkRules } from "./rules/internal-links.ts"
|
|
28
29
|
import { islandRules } from "./rules/islands.ts"
|
|
29
30
|
import { retiredLayoutRule } from "./rules/layout.ts"
|
|
30
31
|
import { LEGACY_RULE_CODES, LEGACY_RULE_ORDER, legacyRules } from "./rules/legacy.ts"
|
|
@@ -35,6 +36,7 @@ import { routeStatementRule } from "./rules/route-statement.ts"
|
|
|
35
36
|
import { routeRules } from "./rules/routes.ts"
|
|
36
37
|
import { secretRules } from "./rules/secrets.ts"
|
|
37
38
|
import { securityRules } from "./rules/security.ts"
|
|
39
|
+
import { serverFnNamespaceRule } from "./rules/server-fn-namespace.ts"
|
|
38
40
|
import { swapRules } from "./rules/swap.ts"
|
|
39
41
|
import { textSlotBooleanRule } from "./rules/text-slot-boolean.ts"
|
|
40
42
|
import { undeclaredResponseRule } from "./rules/undeclared-response.ts"
|
|
@@ -381,6 +383,7 @@ export interface CheckTypecheckResult {
|
|
|
381
383
|
/** TypeScript sources found with no tsconfig.json to typecheck them. */
|
|
382
384
|
readonly sourcesWithoutTsconfig?: number
|
|
383
385
|
readonly outsideProgram?: readonly string[]
|
|
386
|
+
readonly routeTableOutsideProgram?: string
|
|
384
387
|
}
|
|
385
388
|
|
|
386
389
|
export interface CheckAnalysisInput {
|
|
@@ -507,6 +510,8 @@ export async function collectCheckDiagnostics(
|
|
|
507
510
|
routeStatementRule,
|
|
508
511
|
undeclaredResponseRule,
|
|
509
512
|
textSlotBooleanRule,
|
|
513
|
+
...internalLinkRules,
|
|
514
|
+
serverFnNamespaceRule,
|
|
510
515
|
...zoneRules,
|
|
511
516
|
...dataGuardRules,
|
|
512
517
|
...secretRules,
|
package/src/check-scan.ts
CHANGED
|
@@ -12,6 +12,9 @@ import { Glob } from "bun"
|
|
|
12
12
|
import type * as TSApi from "typescript"
|
|
13
13
|
import { codeUnitOrder } from "./internal/code-unit-order.ts"
|
|
14
14
|
import { gitIgnored } from "./internal/git-ignored.ts"
|
|
15
|
+
import { lineAt } from "./internal/line-at.ts"
|
|
16
|
+
import { toPosix } from "./internal/posix-path.ts"
|
|
17
|
+
import { realpathOrSelf } from "./internal/realpath-or-self.ts"
|
|
15
18
|
import { scriptKindOf } from "./internal/script-kind.ts"
|
|
16
19
|
import type { SourceFacts } from "./internal/source-facts.ts"
|
|
17
20
|
import {
|
|
@@ -75,11 +78,11 @@ const IGNORED_DIR =
|
|
|
75
78
|
// legitimately drives `fetch`, hand-rolls a client, and calls a route directly. It is NOT excluded from
|
|
76
79
|
// `nifra doctor`: tsc typechecks tests, so an import a test declares nowhere is a real broken build.
|
|
77
80
|
const TEST_FILE = /\.(test|spec)\.[cm]?[jt]sx?$/
|
|
78
|
-
const IGNORED = new RegExp(`${IGNORED_DIR.source}|${TEST_FILE.source}`)
|
|
81
|
+
export const IGNORED = new RegExp(`${IGNORED_DIR.source}|${TEST_FILE.source}`)
|
|
79
82
|
|
|
80
83
|
/** Paths crossing the scanner boundary are project-relative identifiers, not filesystem paths. Keep
|
|
81
84
|
* them stable across runtimes so rules, diagnostics, ignore globs, and import chains have one shape. */
|
|
82
|
-
const normalizeProjectPath =
|
|
85
|
+
const normalizeProjectPath = toPosix
|
|
83
86
|
|
|
84
87
|
// Browser code by path, mirroring `@nifrajs/web/zones`: a suffix decides first, then the folder. A
|
|
85
88
|
// route's backend half (`x.backend.ts`), `backend/` and `*.fn.ts` run on the server only.
|
|
@@ -218,10 +221,6 @@ interface SimpleFetchCall {
|
|
|
218
221
|
readonly end: number
|
|
219
222
|
}
|
|
220
223
|
|
|
221
|
-
/** Line number (1-based) of a match index within `content`. */
|
|
222
|
-
const lineAt = (content: string, index: number): number =>
|
|
223
|
-
content.slice(0, index).split("\n").length
|
|
224
|
-
|
|
225
224
|
function parseQuotedLiteral(raw: string): string | undefined {
|
|
226
225
|
try {
|
|
227
226
|
return JSON.parse(raw) as string
|
|
@@ -253,59 +252,51 @@ function parseQuotedLiteral(raw: string): string | undefined {
|
|
|
253
252
|
}
|
|
254
253
|
}
|
|
255
254
|
|
|
256
|
-
|
|
257
|
-
|
|
255
|
+
/**
|
|
256
|
+
* Calls `visit` with each index from `from` whose character sits outside a string literal, until it
|
|
257
|
+
* returns true. Returns that index, `src.length` when the scan ran out, or -1 when it ran out inside a
|
|
258
|
+
* literal left open.
|
|
259
|
+
*/
|
|
260
|
+
function scanOutsideStrings(src: string, from: number, visit: (index: number) => boolean): number {
|
|
258
261
|
let quote: '"' | "'" | "`" | undefined
|
|
259
|
-
for (let i =
|
|
262
|
+
for (let i = from; i < src.length; i++) {
|
|
260
263
|
const c = src[i]
|
|
261
264
|
if (quote !== undefined) {
|
|
262
|
-
if (c === "\\")
|
|
263
|
-
|
|
264
|
-
continue
|
|
265
|
-
}
|
|
266
|
-
if (c === quote) quote = undefined
|
|
267
|
-
continue
|
|
268
|
-
}
|
|
269
|
-
if (c === '"' || c === "'" || c === "`") {
|
|
270
|
-
quote = c
|
|
265
|
+
if (c === "\\") i++
|
|
266
|
+
else if (c === quote) quote = undefined
|
|
271
267
|
continue
|
|
272
268
|
}
|
|
273
|
-
if (c === "
|
|
274
|
-
else if (
|
|
275
|
-
depth--
|
|
276
|
-
if (depth === 0) return i
|
|
277
|
-
}
|
|
269
|
+
if (c === '"' || c === "'" || c === "`") quote = c
|
|
270
|
+
else if (visit(i)) return i
|
|
278
271
|
}
|
|
279
|
-
return undefined
|
|
272
|
+
return quote === undefined ? src.length : -1
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
function findMatchingParen(src: string, openIndex: number): number | undefined {
|
|
276
|
+
let depth = 0
|
|
277
|
+
const end = scanOutsideStrings(src, openIndex, (i) => {
|
|
278
|
+
if (src[i] === "(") depth++
|
|
279
|
+
else if (src[i] === ")") return --depth === 0
|
|
280
|
+
return false
|
|
281
|
+
})
|
|
282
|
+
return end >= 0 && end < src.length ? end : undefined
|
|
280
283
|
}
|
|
281
284
|
|
|
282
285
|
function splitTopLevelArgs(src: string): string[] | undefined {
|
|
283
286
|
const args: string[] = []
|
|
284
287
|
let start = 0
|
|
285
288
|
let depth = 0
|
|
286
|
-
|
|
287
|
-
for (let i = 0; i < src.length; i++) {
|
|
289
|
+
const end = scanOutsideStrings(src, 0, (i) => {
|
|
288
290
|
const c = src[i]
|
|
289
|
-
if (quote !== undefined) {
|
|
290
|
-
if (c === "\\") {
|
|
291
|
-
i++
|
|
292
|
-
continue
|
|
293
|
-
}
|
|
294
|
-
if (c === quote) quote = undefined
|
|
295
|
-
continue
|
|
296
|
-
}
|
|
297
|
-
if (c === '"' || c === "'" || c === "`") {
|
|
298
|
-
quote = c
|
|
299
|
-
continue
|
|
300
|
-
}
|
|
301
291
|
if (c === "(" || c === "{" || c === "[") depth++
|
|
302
292
|
else if (c === ")" || c === "}" || c === "]") depth--
|
|
303
293
|
else if (c === "," && depth === 0) {
|
|
304
294
|
args.push(src.slice(start, i).trim())
|
|
305
295
|
start = i + 1
|
|
306
296
|
}
|
|
307
|
-
|
|
308
|
-
|
|
297
|
+
return false
|
|
298
|
+
})
|
|
299
|
+
if (end < 0 || depth !== 0) return undefined
|
|
309
300
|
const tail = src.slice(start).trim()
|
|
310
301
|
if (tail !== "") args.push(tail)
|
|
311
302
|
return args
|
|
@@ -643,26 +634,14 @@ function matchesExternalMount(content: string, start: number, mounts: readonly s
|
|
|
643
634
|
|
|
644
635
|
function findTopLevelPropertyColon(src: string): number | undefined {
|
|
645
636
|
let depth = 0
|
|
646
|
-
|
|
647
|
-
for (let i = 0; i < src.length; i++) {
|
|
637
|
+
const end = scanOutsideStrings(src, 0, (i) => {
|
|
648
638
|
const c = src[i]
|
|
649
|
-
if (quote !== undefined) {
|
|
650
|
-
if (c === "\\") {
|
|
651
|
-
i++
|
|
652
|
-
continue
|
|
653
|
-
}
|
|
654
|
-
if (c === quote) quote = undefined
|
|
655
|
-
continue
|
|
656
|
-
}
|
|
657
|
-
if (c === '"' || c === "'" || c === "`") {
|
|
658
|
-
quote = c
|
|
659
|
-
continue
|
|
660
|
-
}
|
|
661
639
|
if (c === "(" || c === "{" || c === "[") depth++
|
|
662
640
|
else if (c === ")" || c === "}" || c === "]") depth--
|
|
663
|
-
else
|
|
664
|
-
|
|
665
|
-
|
|
641
|
+
else return c === ":" && depth === 0
|
|
642
|
+
return false
|
|
643
|
+
})
|
|
644
|
+
return end >= 0 && end < src.length ? end : undefined
|
|
666
645
|
}
|
|
667
646
|
|
|
668
647
|
function parseStaticPropertyName(raw: string): string | undefined {
|
|
@@ -711,18 +690,33 @@ export function scanFetchText(
|
|
|
711
690
|
file: string,
|
|
712
691
|
content: string,
|
|
713
692
|
externalMounts: readonly string[] = [],
|
|
693
|
+
): TypedClientFinding[] {
|
|
694
|
+
return ownPathCalls(file, content, GLOBAL_FETCH_CALL, externalMounts, (m) =>
|
|
695
|
+
hasLiteralNifraDataHeader(content, m.index + m[0].lastIndexOf("(")),
|
|
696
|
+
)
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* A finding for each `pattern` match in code whose first argument is a literal own-API path (`"/…"`,
|
|
701
|
+
* not `"//…"`), unless it falls under one of `externalMounts` or `skip` passes it.
|
|
702
|
+
*/
|
|
703
|
+
function ownPathCalls(
|
|
704
|
+
file: string,
|
|
705
|
+
content: string,
|
|
706
|
+
pattern: RegExp,
|
|
707
|
+
externalMounts: readonly string[],
|
|
708
|
+
skip?: (match: RegExpExecArray) => boolean,
|
|
714
709
|
): TypedClientFinding[] {
|
|
715
710
|
const out: TypedClientFinding[] = []
|
|
716
711
|
const lines = content.split("\n")
|
|
717
712
|
const code = codePositionMask(content)
|
|
718
|
-
|
|
719
|
-
for (let m =
|
|
713
|
+
pattern.lastIndex = 0
|
|
714
|
+
for (let m = pattern.exec(code); m !== null; m = pattern.exec(code)) {
|
|
720
715
|
const argument = firstArgumentIndex(content, m.index + m[0].length)
|
|
721
716
|
const quote = content[argument]
|
|
722
717
|
if (quote !== "'" && quote !== '"' && quote !== "`") continue
|
|
723
718
|
if (content[argument + 1] !== "/" || content[argument + 2] === "/") continue
|
|
724
|
-
|
|
725
|
-
if (hasLiteralNifraDataHeader(content, openParen)) continue
|
|
719
|
+
if (skip?.(m) === true) continue
|
|
726
720
|
if (externalMounts.length > 0 && matchesExternalMount(content, argument + 1, externalMounts))
|
|
727
721
|
continue
|
|
728
722
|
out.push(typedClientFinding(file, lines, lineAt(content, m.index)))
|
|
@@ -749,20 +743,7 @@ export function scanStreamText(
|
|
|
749
743
|
content: string,
|
|
750
744
|
externalMounts: readonly string[] = [],
|
|
751
745
|
): TypedClientFinding[] {
|
|
752
|
-
|
|
753
|
-
const lines = content.split("\n")
|
|
754
|
-
const code = codePositionMask(content)
|
|
755
|
-
STREAM_CONSTRUCT.lastIndex = 0
|
|
756
|
-
for (let m = STREAM_CONSTRUCT.exec(code); m !== null; m = STREAM_CONSTRUCT.exec(code)) {
|
|
757
|
-
const argument = firstArgumentIndex(content, m.index + m[0].length)
|
|
758
|
-
const quote = content[argument]
|
|
759
|
-
if (quote !== "'" && quote !== '"' && quote !== "`") continue
|
|
760
|
-
if (content[argument + 1] !== "/" || content[argument + 2] === "/") continue
|
|
761
|
-
if (externalMounts.length > 0 && matchesExternalMount(content, argument + 1, externalMounts))
|
|
762
|
-
continue
|
|
763
|
-
out.push(typedClientFinding(file, lines, lineAt(content, m.index)))
|
|
764
|
-
}
|
|
765
|
-
return out
|
|
746
|
+
return ownPathCalls(file, content, STREAM_CONSTRUCT, externalMounts)
|
|
766
747
|
}
|
|
767
748
|
|
|
768
749
|
/** Statically collect simple Nifra route registrations from source, without importing app code. */
|
|
@@ -2169,6 +2150,14 @@ function writesTo(ts: TypeScriptApi, root: TSApi.Node, name: string): SqlWrite[]
|
|
|
2169
2150
|
}
|
|
2170
2151
|
|
|
2171
2152
|
function mentionsName(ts: TypeScriptApi, node: TSApi.Node, name: string): boolean {
|
|
2153
|
+
// A member/key named like the variable does not read that variable (`record = client.record()`).
|
|
2154
|
+
if (ts.isPropertyAccessExpression(node)) return mentionsName(ts, node.expression, name)
|
|
2155
|
+
if (ts.isPropertyAssignment(node)) {
|
|
2156
|
+
return (
|
|
2157
|
+
mentionsName(ts, node.initializer, name) ||
|
|
2158
|
+
(ts.isComputedPropertyName(node.name) && mentionsName(ts, node.name.expression, name))
|
|
2159
|
+
)
|
|
2160
|
+
}
|
|
2172
2161
|
if (ts.isIdentifier(node)) return node.text === name
|
|
2173
2162
|
return ts.forEachChild(node, (child) => mentionsName(ts, child, name) || undefined) === true
|
|
2174
2163
|
}
|
|
@@ -2733,13 +2722,7 @@ const SQL_SOURCE_FILE = /\.[cm]?tsx?$/
|
|
|
2733
2722
|
* flagged - the pre-feature answer.
|
|
2734
2723
|
*/
|
|
2735
2724
|
export function createProjectSqlImports(cwd: string): SqlImports {
|
|
2736
|
-
const root = (()
|
|
2737
|
-
try {
|
|
2738
|
-
return realpathSync(resolve(cwd))
|
|
2739
|
-
} catch {
|
|
2740
|
-
return resolve(cwd)
|
|
2741
|
-
}
|
|
2742
|
-
})()
|
|
2725
|
+
const root = realpathOrSelf(resolve(cwd))
|
|
2743
2726
|
return createSqlImports((fromModule, specifier) => {
|
|
2744
2727
|
if (!isRelativeSpecifier(specifier)) return undefined
|
|
2745
2728
|
try {
|
|
@@ -3496,6 +3479,8 @@ export async function walkSource(
|
|
|
3496
3479
|
* files in a zone. A `.svelte`/`.vue` file is visited as {@link componentScripts}.
|
|
3497
3480
|
*/
|
|
3498
3481
|
readonly scripts?: boolean
|
|
3482
|
+
/** With `scripts`, every `.js` file too: in a library package, plain `.js` is its code, not tooling. */
|
|
3483
|
+
readonly library?: boolean
|
|
3499
3484
|
} = {},
|
|
3500
3485
|
): Promise<void> {
|
|
3501
3486
|
const skip = opts.includeTests === true ? IGNORED_DIR : IGNORED
|
|
@@ -3510,7 +3495,13 @@ export async function walkSource(
|
|
|
3510
3495
|
// A backslash is a filename character on POSIX; only Windows separators need normalizing.
|
|
3511
3496
|
const rel = sep === "\\" ? normalizeProjectPath(rawRel) : rawRel
|
|
3512
3497
|
// A `.js` file outside a zone is tooling (a bundler config, a script, a vendored asset), not app code.
|
|
3513
|
-
if (
|
|
3498
|
+
if (
|
|
3499
|
+
opts.library !== true &&
|
|
3500
|
+
PLAIN_SCRIPT_FILE.test(rel) &&
|
|
3501
|
+
!ZONE_DIRECTORY.test(rel) &&
|
|
3502
|
+
!ZONE_SUFFIX.test(rel)
|
|
3503
|
+
)
|
|
3504
|
+
continue
|
|
3514
3505
|
if (!skip.test(rel) && (opts.ignore === undefined || !opts.ignore(rel))) rels.push(rel)
|
|
3515
3506
|
}
|
|
3516
3507
|
const ignored = await gitIgnored(cwd, rels)
|
package/src/check.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* anything fails. Pure scanners (`scanFetchText`, `scanServerOnlyImports`) are unit-tested.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
import { existsSync, mkdtempSync, readFileSync,
|
|
19
|
+
import { existsSync, mkdtempSync, readFileSync, rmdirSync, rmSync } from "node:fs"
|
|
20
20
|
import { tmpdir } from "node:os"
|
|
21
21
|
import { dirname, isAbsolute, join, relative, resolve } from "node:path"
|
|
22
22
|
import { declaredSide, specifierPackage } from "@nifrajs/web/zones"
|
|
@@ -32,10 +32,11 @@ import {
|
|
|
32
32
|
} from "./check-diagnostics.ts"
|
|
33
33
|
import { appDirs, clientModuleRoot } from "./client-module.ts"
|
|
34
34
|
import { checkContractsLock, DEFAULT_CONTRACTS_LOCK } from "./contracts.ts"
|
|
35
|
-
import { type Diagnostic, normalizeSeverity, toSarifLog } from "./diagnostics.ts"
|
|
35
|
+
import { type Diagnostic, diagnostic, normalizeSeverity, toSarifLog } from "./diagnostics.ts"
|
|
36
36
|
import { installedManifest } from "./internal/installed-package.ts"
|
|
37
37
|
import { createApiOnlyProbe, createNifraProjectProbe } from "./internal/nifra-project.ts"
|
|
38
38
|
import { createSpecifierResolver } from "./internal/project-specifiers.ts"
|
|
39
|
+
import { realpathOrSelf } from "./internal/realpath-or-self.ts"
|
|
39
40
|
import { createSourceFacts } from "./internal/source-facts.ts"
|
|
40
41
|
import { loadProjectTypeScript, type TypeScriptApi } from "./internal/typescript-import.ts"
|
|
41
42
|
import {
|
|
@@ -49,7 +50,12 @@ import {
|
|
|
49
50
|
import type { ContractCheckFacts, ProjectFactsSeed } from "./project-facts.ts"
|
|
50
51
|
import { RULE_CODES } from "./rules/codes.ts"
|
|
51
52
|
import { sourceIndex } from "./rules/index.ts"
|
|
52
|
-
import {
|
|
53
|
+
import {
|
|
54
|
+
filesOutsideProgram,
|
|
55
|
+
routeTableOutsideProgram,
|
|
56
|
+
splitListedFiles,
|
|
57
|
+
typecheckProjects,
|
|
58
|
+
} from "./typecheck-coverage.ts"
|
|
53
59
|
|
|
54
60
|
export type {
|
|
55
61
|
CheckAnalysisInput,
|
|
@@ -109,6 +115,8 @@ interface TypecheckResult {
|
|
|
109
115
|
readonly programFiles?: readonly string[]
|
|
110
116
|
/** Zoned TypeScript files outside the program, project-relative: the typecheck never read them. */
|
|
111
117
|
readonly outsideProgram?: readonly string[]
|
|
118
|
+
/** The generated route table, when it exists and the program does not hold it. */
|
|
119
|
+
readonly routeTableOutsideProgram?: string
|
|
112
120
|
}
|
|
113
121
|
|
|
114
122
|
/**
|
|
@@ -262,7 +270,7 @@ async function loadCheckConfig(
|
|
|
262
270
|
const raw = Array.isArray(parsed.externalMounts) ? parsed.externalMounts : []
|
|
263
271
|
const externalMounts = raw
|
|
264
272
|
.filter((m): m is string => typeof m === "string" && m.startsWith("/"))
|
|
265
|
-
.map((m) => m.replace(/\/\*+$/, "").replace(
|
|
273
|
+
.map((m) => m.replace(/\/\*+$/, "").replace(/(?<!\/)\/+$/, "") || "/")
|
|
266
274
|
const warnings: string[] = []
|
|
267
275
|
const rules: Record<string, RuleOverride> = {}
|
|
268
276
|
if (parsed.rules !== undefined) {
|
|
@@ -383,7 +391,7 @@ function withoutTsconfig(
|
|
|
383
391
|
function withProgramCoverage(
|
|
384
392
|
cwd: string,
|
|
385
393
|
result: TypecheckResult,
|
|
386
|
-
sourceFiles: ReadonlyArray<{ readonly file: string }>,
|
|
394
|
+
sourceFiles: ReadonlyArray<{ readonly file: string; readonly content: string }>,
|
|
387
395
|
checkConfig: CheckConfig,
|
|
388
396
|
): TypecheckResult {
|
|
389
397
|
const { programFiles, ...rest } = result
|
|
@@ -394,7 +402,12 @@ function withProgramCoverage(
|
|
|
394
402
|
sourceFiles.map((source) => source.file),
|
|
395
403
|
programFiles,
|
|
396
404
|
).filter((file) => !ignore?.some((pattern) => safeIgnoreGlobMatch(pattern, file)))
|
|
397
|
-
|
|
405
|
+
const table = routeTableOutsideProgram(cwd, programFiles, sourceFiles)
|
|
406
|
+
return {
|
|
407
|
+
...rest,
|
|
408
|
+
...(outside.length === 0 ? {} : { outsideProgram: outside }),
|
|
409
|
+
...(table === undefined ? {} : { routeTableOutsideProgram: table }),
|
|
410
|
+
}
|
|
398
411
|
}
|
|
399
412
|
|
|
400
413
|
/** Build the rule input from one source walk and the other check-wide scans. */
|
|
@@ -462,13 +475,7 @@ async function buildProjectScan(
|
|
|
462
475
|
// Resolved modules stay project-relative, as the scanned files are: the zone of a path is read
|
|
463
476
|
// from its folders, and a checkout under a folder named `backend/` must not make it all backend.
|
|
464
477
|
// The resolver answers with real paths, so the project root is read as one too.
|
|
465
|
-
const realCwd = (
|
|
466
|
-
try {
|
|
467
|
-
return realpathSync(cwd)
|
|
468
|
-
} catch {
|
|
469
|
-
return cwd
|
|
470
|
-
}
|
|
471
|
-
})()
|
|
478
|
+
const realCwd = realpathOrSelf(cwd)
|
|
472
479
|
const resolveSpecifier = createSpecifierResolver()
|
|
473
480
|
const sourceFacts =
|
|
474
481
|
sqlCompiler === undefined
|
|
@@ -792,6 +799,25 @@ function belowError(warnings: number, infos: number): string {
|
|
|
792
799
|
return parts.join(", ")
|
|
793
800
|
}
|
|
794
801
|
|
|
802
|
+
/** The check's findings as structured diagnostics: the collector's own, else each report entry mapped over. */
|
|
803
|
+
export function checkDiagnostics(result: CheckResult): readonly Diagnostic[] {
|
|
804
|
+
return (
|
|
805
|
+
result.structuredDiagnostics ??
|
|
806
|
+
result.diagnostics.map((value) =>
|
|
807
|
+
diagnostic({
|
|
808
|
+
code: value.code ?? value.rule,
|
|
809
|
+
severity: normalizeSeverity(value.severity),
|
|
810
|
+
message: value.message,
|
|
811
|
+
...(value.file === undefined ? {} : { file: value.file }),
|
|
812
|
+
...(value.line === undefined ? {} : { line: value.line }),
|
|
813
|
+
...(value.evidence === undefined ? {} : { evidence: value.evidence }),
|
|
814
|
+
...(value.fix === undefined ? {} : { fix: { recipe: value.fix } }),
|
|
815
|
+
...(value.verify === undefined ? {} : { verify: value.verify }),
|
|
816
|
+
}),
|
|
817
|
+
)
|
|
818
|
+
)
|
|
819
|
+
}
|
|
820
|
+
|
|
795
821
|
/** Run the full check; print a report (`--json` for machine output) and return whether it passed. */
|
|
796
822
|
export async function runCheck(
|
|
797
823
|
cwd: string,
|
|
@@ -807,19 +833,7 @@ export async function runCheck(
|
|
|
807
833
|
const verification = await collectProjectVerification(cwd, { lintsOnly: opts.lintsOnly ?? false })
|
|
808
834
|
const result = await verification.check()
|
|
809
835
|
if (opts.sarif) {
|
|
810
|
-
|
|
811
|
-
result.structuredDiagnostics ??
|
|
812
|
-
result.diagnostics.map((value) => ({
|
|
813
|
-
code: value.code ?? value.rule,
|
|
814
|
-
severity: normalizeSeverity(value.severity),
|
|
815
|
-
message: value.message,
|
|
816
|
-
...(value.file === undefined ? {} : { file: value.file }),
|
|
817
|
-
...(value.line === undefined ? {} : { line: value.line }),
|
|
818
|
-
...(value.evidence === undefined ? {} : { evidence: value.evidence }),
|
|
819
|
-
...(value.fix === undefined ? {} : { fix: { recipe: value.fix } }),
|
|
820
|
-
...(value.verify === undefined ? {} : { verify: value.verify }),
|
|
821
|
-
}))
|
|
822
|
-
console.log(JSON.stringify(toSarifLog(diagnostics), null, 2))
|
|
836
|
+
console.log(JSON.stringify(toSarifLog(checkDiagnostics(result)), null, 2))
|
|
823
837
|
return result.ok
|
|
824
838
|
}
|
|
825
839
|
if (opts.json) {
|