@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/src/recipes/index.ts
CHANGED
|
@@ -20,6 +20,8 @@ import { recipe as v5_5_0 } from "./5.5.0.ts"
|
|
|
20
20
|
import { recipe as v5_6_0 } from "./5.6.0.ts"
|
|
21
21
|
import { recipe as v5_7_0 } from "./5.7.0.ts"
|
|
22
22
|
import { recipe as v5_8_0 } from "./5.8.0.ts"
|
|
23
|
+
import { recipe as v5_9_0 } from "./5.9.0.ts"
|
|
24
|
+
import { recipe as v5_10_0 } from "./5.10.0.ts"
|
|
23
25
|
|
|
24
26
|
/** A pin rule: every dependency whose name starts with `match` is set to version `to`. */
|
|
25
27
|
export interface PinRule {
|
|
@@ -69,6 +71,11 @@ export interface UpgradeRecipe {
|
|
|
69
71
|
readonly importMoves: readonly ImportMove[]
|
|
70
72
|
readonly dependencyAdds?: readonly DependencyAdd[]
|
|
71
73
|
readonly retiredMarkers?: readonly RetiredMarker[]
|
|
74
|
+
/**
|
|
75
|
+
* Syntax-tree rewrites (`../source-rewrites.ts`) by id, run on every source file after the import
|
|
76
|
+
* moves with the project's own TypeScript. An upgrade that needs one refuses to run without it.
|
|
77
|
+
*/
|
|
78
|
+
readonly sourceRewrites?: readonly string[]
|
|
72
79
|
/** Human notes printed after the plan - e.g. structural changes the runner deliberately can't do. */
|
|
73
80
|
readonly notes?: readonly string[]
|
|
74
81
|
/**
|
|
@@ -94,6 +101,8 @@ const RECIPES: Record<string, UpgradeRecipe> = {
|
|
|
94
101
|
[v5_6_0.version]: v5_6_0,
|
|
95
102
|
[v5_7_0.version]: v5_7_0,
|
|
96
103
|
[v5_8_0.version]: v5_8_0,
|
|
104
|
+
[v5_9_0.version]: v5_9_0,
|
|
105
|
+
[v5_10_0.version]: v5_10_0,
|
|
97
106
|
}
|
|
98
107
|
|
|
99
108
|
export function getRecipe(version: string): UpgradeRecipe | undefined {
|
package/src/review.ts
CHANGED
|
@@ -17,6 +17,8 @@ import type { CheckResult } from "./check.ts"
|
|
|
17
17
|
import type { CommandCtx, CommandSpec } from "./command-catalog.ts"
|
|
18
18
|
import type { Diagnostic } from "./diagnostics.ts"
|
|
19
19
|
import { diagnosticCompatibilityOf, toSarifLog } from "./diagnostics.ts"
|
|
20
|
+
import { codeUnitOrder } from "./internal/code-unit-order.ts"
|
|
21
|
+
import { isRecord } from "./internal/record.ts"
|
|
20
22
|
import { RULE_CODES } from "./rules/codes.ts"
|
|
21
23
|
import { LEGACY_RULE_CODES } from "./rules/legacy.ts"
|
|
22
24
|
|
|
@@ -43,10 +45,6 @@ const REVIEW_INPUT_KEYS = new Set(["strict", "diff", "sarif", "fix", "dryRun", "
|
|
|
43
45
|
const CODE_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/
|
|
44
46
|
const SAFE_GIT_REF = /^[A-Za-z0-9][A-Za-z0-9._/@+-]{0,255}$/
|
|
45
47
|
|
|
46
|
-
function compareText(left: string, right: string): number {
|
|
47
|
-
return left < right ? -1 : left > right ? 1 : 0
|
|
48
|
-
}
|
|
49
|
-
|
|
50
48
|
const CHECK_IDS: readonly ReviewCheckId[] = [
|
|
51
49
|
"typecheck",
|
|
52
50
|
"typed-client",
|
|
@@ -164,6 +162,9 @@ export const CHECK_CODES: Readonly<Record<string, ReviewCheckId>> = {
|
|
|
164
162
|
"NF-C045": "typed-client",
|
|
165
163
|
"NF-C054": "typed-client",
|
|
166
164
|
"NF-C055": "route-boundary",
|
|
165
|
+
"NF-C056": "route-boundary",
|
|
166
|
+
"NF-C057": "typed-client",
|
|
167
|
+
"NF-C058": "typed-client",
|
|
167
168
|
"NF-C046": "dependency",
|
|
168
169
|
"NF-D001": "dependency",
|
|
169
170
|
"NF-D002": "dependency",
|
|
@@ -199,10 +200,6 @@ const REVIEW_INPUT_SCHEMA = {
|
|
|
199
200
|
additionalProperties: false,
|
|
200
201
|
} as const
|
|
201
202
|
|
|
202
|
-
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
203
|
-
return typeof value === "object" && value !== null && !Array.isArray(value)
|
|
204
|
-
}
|
|
205
|
-
|
|
206
203
|
function optionalBoolean(raw: Record<string, unknown>, key: string): boolean | undefined {
|
|
207
204
|
const value = raw[key]
|
|
208
205
|
if (value === undefined) return undefined
|
|
@@ -485,7 +482,7 @@ async function diffScope(cwd: string, ref: string): Promise<ReviewScope> {
|
|
|
485
482
|
const untracked = await runGit(cwd, ["ls-files", "--others", "--exclude-standard", "-z", "--"])
|
|
486
483
|
if (!changed.ok || !untracked.ok) throw new ReviewInputError("invalid git scope")
|
|
487
484
|
const paths = [...new Set([...nulPaths(changed.stdout), ...nulPaths(untracked.stdout)])].sort(
|
|
488
|
-
|
|
485
|
+
codeUnitOrder,
|
|
489
486
|
)
|
|
490
487
|
if (
|
|
491
488
|
paths.some(
|
|
@@ -630,14 +627,17 @@ async function composeCollectedReport(
|
|
|
630
627
|
const leftLocation = normalizedLocation(cwd, left.diagnostic.file, left.diagnostic.line)
|
|
631
628
|
const rightLocation = normalizedLocation(cwd, right.diagnostic.file, right.diagnostic.line)
|
|
632
629
|
return (
|
|
633
|
-
|
|
634
|
-
|
|
630
|
+
codeUnitOrder(
|
|
631
|
+
normalizedCode(left.diagnostic.code),
|
|
632
|
+
normalizedCode(right.diagnostic.code),
|
|
633
|
+
) ||
|
|
634
|
+
codeUnitOrder(
|
|
635
635
|
normalizedSeverity(left.diagnostic.severity),
|
|
636
636
|
normalizedSeverity(right.diagnostic.severity),
|
|
637
637
|
) ||
|
|
638
|
-
|
|
638
|
+
codeUnitOrder(leftLocation?.path ?? "", rightLocation?.path ?? "") ||
|
|
639
639
|
(leftLocation?.line ?? 0) - (rightLocation?.line ?? 0) ||
|
|
640
|
-
|
|
640
|
+
codeUnitOrder(left.diagnostic.fix?.recipe ?? "", right.diagnostic.fix?.recipe ?? "") ||
|
|
641
641
|
left.index - right.index
|
|
642
642
|
)
|
|
643
643
|
})
|
|
@@ -773,7 +773,7 @@ async function composeCollectedReport(
|
|
|
773
773
|
findings.flatMap((finding) => (finding.fix === undefined ? [] : [finding.fix.recipe])),
|
|
774
774
|
),
|
|
775
775
|
]
|
|
776
|
-
.sort(
|
|
776
|
+
.sort(codeUnitOrder)
|
|
777
777
|
.map((recipe): ReviewFixResult => ({ recipe, status: "planned" }))
|
|
778
778
|
: undefined
|
|
779
779
|
const draft: ReviewReportDraft = {
|
|
@@ -825,7 +825,7 @@ async function safeChangedPaths(cwd: string, paths: readonly string[]): Promise<
|
|
|
825
825
|
if (relativePath.length > 0 && relativePath !== ".." && !relativePath.startsWith("../"))
|
|
826
826
|
result.push(relativePath)
|
|
827
827
|
}
|
|
828
|
-
return [...new Set(result)].sort(
|
|
828
|
+
return [...new Set(result)].sort(codeUnitOrder)
|
|
829
829
|
}
|
|
830
830
|
|
|
831
831
|
async function applyRequestedFixes(
|
package/src/rules/codes.ts
CHANGED
|
@@ -54,6 +54,9 @@ export const RULE_CODES = Object.freeze({
|
|
|
54
54
|
"NF-C053": "Partially prerendered page reads the request",
|
|
55
55
|
"NF-C054": "Route without a response schema in a published document",
|
|
56
56
|
"NF-C055": "zod coerce.boolean() reads request text",
|
|
57
|
+
"NF-C056": "serverFunctions namespace differs from its module's filename",
|
|
58
|
+
"NF-C057": "Internal link to a path no page serves",
|
|
59
|
+
"NF-C058": "Internal link written as a path string",
|
|
57
60
|
"NF-D001": "Doctor check",
|
|
58
61
|
"NF-D002": "Mixed nifra versions",
|
|
59
62
|
"NF-D003": "Stale file: dependencies in bun.lock",
|
|
@@ -8,12 +8,13 @@
|
|
|
8
8
|
* A contract imported from a workspace package is read through that package's `exports`.
|
|
9
9
|
* Re-exports on the way to a contract, and `...operations` spreads inside one, are followed.
|
|
10
10
|
*/
|
|
11
|
-
import { existsSync, readFileSync
|
|
11
|
+
import { existsSync, readFileSync } from "node:fs"
|
|
12
12
|
import { join, relative } from "node:path"
|
|
13
13
|
import type * as TSApi from "typescript"
|
|
14
14
|
import { BACKEND_APP_FILE } from "../app-files.ts"
|
|
15
15
|
import { type Diagnostic, diagnostic } from "../diagnostics.ts"
|
|
16
16
|
import { createSpecifierResolver, type SpecifierResolver } from "../internal/project-specifiers.ts"
|
|
17
|
+
import { realpathOrSelf } from "../internal/realpath-or-self.ts"
|
|
17
18
|
import { scriptKindOf } from "../internal/script-kind.ts"
|
|
18
19
|
import { createExportedFileResolver } from "../internal/workspace-packages.ts"
|
|
19
20
|
import type { CheckRule } from "./index.ts"
|
|
@@ -233,13 +234,7 @@ export const contractVisibilityRule: CheckRule = {
|
|
|
233
234
|
return undefined
|
|
234
235
|
}
|
|
235
236
|
// The resolver answers with real paths, so the root is read as one to name files project-relative.
|
|
236
|
-
const realRoot = (
|
|
237
|
-
try {
|
|
238
|
-
return realpathSync(ctx.root)
|
|
239
|
-
} catch {
|
|
240
|
-
return ctx.root
|
|
241
|
-
}
|
|
242
|
-
})()
|
|
237
|
+
const realRoot = realpathOrSelf(ctx.root)
|
|
243
238
|
const parsedCache = new Map<string, Parsed | undefined>()
|
|
244
239
|
/** A project file, by its project-relative name, parsed with its contract bindings. */
|
|
245
240
|
const parse = (file: string, text: string | undefined): Parsed | undefined => {
|
package/src/rules/data-guard.ts
CHANGED
|
@@ -8,18 +8,17 @@
|
|
|
8
8
|
* refuses (an object, array, string, number or boolean) and a warning otherwise, since only running
|
|
9
9
|
* the loader proves what an expression evaluates to.
|
|
10
10
|
*/
|
|
11
|
-
import { realpathSync } from "node:fs"
|
|
12
11
|
import { isAbsolute, join, relative } from "node:path"
|
|
13
12
|
import { isSensitiveFieldName } from "@nifrajs/web/zones"
|
|
14
13
|
import { codePositionMask } from "../check-scan.ts"
|
|
15
14
|
import { type Diagnostic, diagnostic } from "../diagnostics.ts"
|
|
16
15
|
import { codeUnitOrder } from "../internal/code-unit-order.ts"
|
|
16
|
+
import { lineAt } from "../internal/line-at.ts"
|
|
17
17
|
import { createSpecifierResolver } from "../internal/project-specifiers.ts"
|
|
18
|
+
import { realpathOrSelf } from "../internal/realpath-or-self.ts"
|
|
18
19
|
import type { CheckRule } from "./index.ts"
|
|
19
20
|
import { zonedFiles } from "./zones.ts"
|
|
20
21
|
|
|
21
|
-
const lineAt = (text: string, index: number): number => text.slice(0, index).split("\n").length
|
|
22
|
-
|
|
23
22
|
const byPlace = (a: Diagnostic, b: Diagnostic): number =>
|
|
24
23
|
codeUnitOrder(a.file ?? "", b.file ?? "") || (a.line ?? 0) - (b.line ?? 0)
|
|
25
24
|
|
|
@@ -453,13 +452,7 @@ export const sensitiveOutputRule: CheckRule = {
|
|
|
453
452
|
async scan(ctx) {
|
|
454
453
|
const findings: Diagnostic[] = []
|
|
455
454
|
const resolve = createSpecifierResolver()
|
|
456
|
-
const realRoot = (
|
|
457
|
-
try {
|
|
458
|
-
return realpathSync(ctx.root)
|
|
459
|
-
} catch {
|
|
460
|
-
return ctx.root
|
|
461
|
-
}
|
|
462
|
-
})()
|
|
455
|
+
const realRoot = realpathOrSelf(ctx.root)
|
|
463
456
|
const sources = new Map<string, SchemaSource | undefined>()
|
|
464
457
|
const sourceOf = (file: string): SchemaSource | undefined => {
|
|
465
458
|
if (!sources.has(file)) {
|
|
@@ -289,6 +289,21 @@ export const RULE_EXPLANATIONS: Readonly<Record<BuiltInCode, RuleExplanation>> =
|
|
|
289
289
|
fix: "Use `z.stringbool()`, which reads `true`/`1`/`yes`/`on` as true, `false`/`0`/`no`/`off` as false, and refuses other text. A use kept on purpose takes `// nifra-expect NF-C055: <reason>` above the call.",
|
|
290
290
|
docs: "/docs/api",
|
|
291
291
|
},
|
|
292
|
+
"NF-C056": {
|
|
293
|
+
why: "The client build calls the namespace named by a `*.fn.ts` file (`todos.fn.ts` posts under `todos`). A `serverFunctions` mount under another word serves routes the stubs never reach, so every call 404s.",
|
|
294
|
+
fix: 'Pass the filename\'s namespace to `serverFunctions` (`serverFunctions("todos", todos)` for `todos.fn.ts`), or rename the file. A mount kept on purpose takes `// nifra-expect NF-C056: <reason>` above the call.',
|
|
295
|
+
docs: "/docs/server-functions",
|
|
296
|
+
},
|
|
297
|
+
"NF-C057": {
|
|
298
|
+
why: "An `<a href>` names a path that no page of the app, no backend route and no file in `public/` serves, so following it is a 404. Nothing fails at build time: a path string is invisible to the types, and a renamed or removed page leaves every link to it dead.",
|
|
299
|
+
fix: "Build the link with `href({ to, params })` (exported by `@nifrajs/web-<framework>/router`): `to` is a route of the app, so a route that does not exist is a compile error. A path some other server answers takes `rawHref(path)`; a link kept on purpose takes `// nifra-expect NF-C057: <reason>` above the attribute.",
|
|
300
|
+
docs: "/docs/routing",
|
|
301
|
+
},
|
|
302
|
+
"NF-C058": {
|
|
303
|
+
why: "An `<a href>` writes a page's path as a string. It works today, but renaming or removing the page leaves the link dead and nothing fails: `href()` checks a link against the app's routes, a path string is not checked.",
|
|
304
|
+
fix: "Build the link with `href({ to, params, search, hash })`, which `nifra check` and `tsc` hold to the app's routes. A path built elsewhere, such as a CMS link, takes `rawHref(path)`; a link kept on purpose takes `// nifra-expect NF-C058: <reason>` above the attribute. Silence the code for the project with `rules` in `nifra.config`.",
|
|
305
|
+
docs: "/docs/routing",
|
|
306
|
+
},
|
|
292
307
|
"NF-D001": {
|
|
293
308
|
why: "The doctor gate of `nifra assure` found an undeclared import or a package installed more than once.",
|
|
294
309
|
fix: "Run `nifra doctor` for the details and the fix of each finding.",
|