@nifrajs/cli 2.10.0 → 2.12.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/README.md +7 -1
- package/dist/assure-hydration.d.ts +14 -0
- package/dist/assure-hydration.d.ts.map +1 -0
- package/dist/assure-hydration.js +483 -0
- package/dist/assure-hydration.js.map +1 -0
- package/dist/assure.d.ts +35 -0
- package/dist/assure.d.ts.map +1 -1
- package/dist/assure.js +222 -1
- package/dist/assure.js.map +1 -1
- package/dist/capabilities-tool.d.ts +13 -0
- package/dist/capabilities-tool.d.ts.map +1 -1
- package/dist/capabilities-tool.js +64 -1
- package/dist/capabilities-tool.js.map +1 -1
- package/dist/check.d.ts +133 -10
- package/dist/check.d.ts.map +1 -1
- package/dist/check.js +741 -148
- package/dist/check.js.map +1 -1
- package/dist/cli.d.ts +21 -14
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +288 -73
- package/dist/cli.js.map +1 -1
- package/dist/contract-proof.d.ts +49 -0
- package/dist/contract-proof.d.ts.map +1 -0
- package/dist/contract-proof.js +128 -0
- package/dist/contract-proof.js.map +1 -0
- package/dist/contracts.d.ts +22 -0
- package/dist/contracts.d.ts.map +1 -0
- package/dist/contracts.js +134 -0
- package/dist/contracts.js.map +1 -0
- package/dist/dev-bun-config.d.ts +17 -6
- package/dist/dev-bun-config.d.ts.map +1 -1
- package/dist/dev-bun-config.js +51 -14
- package/dist/dev-bun-config.js.map +1 -1
- package/dist/diagnostics.d.ts +23 -0
- package/dist/diagnostics.d.ts.map +1 -0
- package/dist/diagnostics.js +9 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/diff-tool.d.ts +2 -0
- package/dist/diff-tool.d.ts.map +1 -1
- package/dist/diff-tool.js +1 -1
- package/dist/diff-tool.js.map +1 -1
- package/dist/docs-search.d.ts +8 -3
- package/dist/docs-search.d.ts.map +1 -1
- package/dist/docs-search.js +36 -15
- package/dist/docs-search.js.map +1 -1
- package/dist/doctor.d.ts +38 -2
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +189 -7
- package/dist/doctor.js.map +1 -1
- package/dist/examples.d.ts +1 -2
- package/dist/examples.d.ts.map +1 -1
- package/dist/examples.js +37 -16
- package/dist/examples.js.map +1 -1
- package/dist/fix-recipes.d.ts +12 -0
- package/dist/fix-recipes.d.ts.map +1 -0
- package/dist/fix-recipes.js +106 -0
- package/dist/fix-recipes.js.map +1 -0
- package/dist/init-agents.d.ts.map +1 -1
- package/dist/init-agents.js +60 -4
- package/dist/init-agents.js.map +1 -1
- package/dist/internal/source-facts.d.ts +15 -0
- package/dist/internal/source-facts.d.ts.map +1 -0
- package/dist/internal/source-facts.js +82 -0
- package/dist/internal/source-facts.js.map +1 -0
- package/dist/internal/typescript-import.d.ts +9 -0
- package/dist/internal/typescript-import.d.ts.map +1 -1
- package/dist/internal/typescript-import.js +38 -0
- package/dist/internal/typescript-import.js.map +1 -1
- package/dist/introspect.d.ts +6 -2
- package/dist/introspect.d.ts.map +1 -1
- package/dist/introspect.js +60 -5
- package/dist/introspect.js.map +1 -1
- package/dist/load.d.ts +10 -0
- package/dist/load.d.ts.map +1 -1
- package/dist/load.js +1 -0
- package/dist/load.js.map +1 -1
- package/dist/manifest-tool.d.ts.map +1 -1
- package/dist/manifest-tool.js +14 -9
- package/dist/manifest-tool.js.map +1 -1
- package/dist/mcp-docs-tools.d.ts.map +1 -1
- package/dist/mcp-docs-tools.js +3 -0
- package/dist/mcp-docs-tools.js.map +1 -1
- package/dist/mcp-http.js +1 -1
- package/dist/mcp-root.d.ts +83 -0
- package/dist/mcp-root.d.ts.map +1 -0
- package/dist/mcp-root.js +221 -0
- package/dist/mcp-root.js.map +1 -0
- package/dist/mcp-run.d.ts.map +1 -1
- package/dist/mcp-run.js +18 -4
- package/dist/mcp-run.js.map +1 -1
- package/dist/mcp.d.ts +27 -4
- package/dist/mcp.d.ts.map +1 -1
- package/dist/mcp.js +360 -27
- package/dist/mcp.js.map +1 -1
- package/dist/pipeline-guard.d.ts +25 -10
- package/dist/pipeline-guard.d.ts.map +1 -1
- package/dist/pipeline-guard.js +35 -15
- package/dist/pipeline-guard.js.map +1 -1
- package/dist/pipeline-report.d.ts +34 -0
- package/dist/pipeline-report.d.ts.map +1 -0
- package/dist/pipeline-report.js +282 -0
- package/dist/pipeline-report.js.map +1 -0
- package/dist/project-path.d.ts +3 -0
- package/dist/project-path.d.ts.map +1 -0
- package/dist/project-path.js +36 -0
- package/dist/project-path.js.map +1 -0
- package/dist/replay.d.ts +12 -0
- package/dist/replay.d.ts.map +1 -0
- package/dist/replay.js +36 -0
- package/dist/replay.js.map +1 -0
- package/dist/rules/codes.d.ts +42 -0
- package/dist/rules/codes.d.ts.map +1 -0
- package/dist/rules/codes.js +52 -0
- package/dist/rules/codes.js.map +1 -0
- package/dist/rules/comment-markers.d.ts +10 -0
- package/dist/rules/comment-markers.d.ts.map +1 -0
- package/dist/rules/comment-markers.js +24 -0
- package/dist/rules/comment-markers.js.map +1 -0
- package/dist/rules/index.d.ts +31 -0
- package/dist/rules/index.d.ts.map +1 -0
- package/dist/rules/index.js +133 -0
- package/dist/rules/index.js.map +1 -0
- package/dist/rules/legacy.d.ts +7 -0
- package/dist/rules/legacy.d.ts.map +1 -0
- package/dist/rules/legacy.js +85 -0
- package/dist/rules/legacy.js.map +1 -0
- package/dist/rules/routes.d.ts +12 -0
- package/dist/rules/routes.d.ts.map +1 -0
- package/dist/rules/routes.js +142 -0
- package/dist/rules/routes.js.map +1 -0
- package/dist/rules/security.d.ts +10 -0
- package/dist/rules/security.d.ts.map +1 -0
- package/dist/rules/security.js +471 -0
- package/dist/rules/security.js.map +1 -0
- package/dist/search-terms.d.ts +2 -0
- package/dist/search-terms.d.ts.map +1 -1
- package/dist/search-terms.js +5 -1
- package/dist/search-terms.js.map +1 -1
- package/dist/types-search.d.ts +1 -2
- package/dist/types-search.d.ts.map +1 -1
- package/dist/types-search.js +33 -16
- package/dist/types-search.js.map +1 -1
- package/dist/verification.d.ts +9 -0
- package/dist/verification.d.ts.map +1 -1
- package/dist/verification.js +17 -1
- package/dist/verification.js.map +1 -1
- package/dist/work-graph.d.ts +123 -0
- package/dist/work-graph.d.ts.map +1 -0
- package/dist/work-graph.js +465 -0
- package/dist/work-graph.js.map +1 -0
- package/docs/examples.json +32 -2
- package/docs/llms-full.txt +1105 -27
- package/docs/types.json +1772 -137
- package/package.json +34 -9
- package/src/assure-hydration.ts +606 -0
- package/src/assure.ts +316 -2
- package/src/capabilities-tool.ts +80 -1
- package/src/check.ts +923 -169
- package/src/cli.ts +297 -76
- package/src/contract-proof.ts +194 -0
- package/src/contracts.ts +157 -0
- package/src/dev-bun-config.ts +57 -14
- package/src/diagnostics.ts +32 -0
- package/src/diff-tool.ts +1 -1
- package/src/docs-search.ts +45 -15
- package/src/doctor.ts +286 -8
- package/src/examples.ts +43 -15
- package/src/fix-recipes.ts +126 -0
- package/src/init-agents.ts +61 -4
- package/src/internal/source-facts.ts +133 -0
- package/src/internal/typescript-import.ts +29 -0
- package/src/introspect.ts +81 -6
- package/src/load.ts +11 -0
- package/src/manifest-tool.ts +16 -10
- package/src/mcp-docs-tools.ts +3 -0
- package/src/mcp-http.ts +1 -1
- package/src/mcp-root.ts +271 -0
- package/src/mcp-run.ts +19 -4
- package/src/mcp.ts +440 -34
- package/src/pipeline-guard.ts +44 -14
- package/src/pipeline-report.ts +341 -0
- package/src/project-path.ts +36 -0
- package/src/replay.ts +44 -0
- package/src/rules/codes.ts +57 -0
- package/src/rules/comment-markers.ts +26 -0
- package/src/rules/index.ts +175 -0
- package/src/rules/legacy.ts +93 -0
- package/src/rules/routes.ts +157 -0
- package/src/rules/security.ts +505 -0
- package/src/search-terms.ts +9 -4
- package/src/types-search.ts +39 -15
- package/src/verification.ts +18 -1
- package/src/work-graph.ts +613 -0
package/src/pipeline-guard.ts
CHANGED
|
@@ -116,6 +116,13 @@ export type BuildPipeline = "bun" | "vite"
|
|
|
116
116
|
|
|
117
117
|
export interface PipelineDecision {
|
|
118
118
|
readonly pipeline: BuildPipeline
|
|
119
|
+
/**
|
|
120
|
+
* How the pipeline was arrived at. Always set, because "which bundler am I on" is a question every
|
|
121
|
+
* `dev`/`build` run should answer without the user reading this source: `default` is the plain Bun
|
|
122
|
+
* default, `auto` means the config forced nifra's hand (see {@link reason}), `forced` is `--vite` /
|
|
123
|
+
* `--bun`.
|
|
124
|
+
*/
|
|
125
|
+
readonly why: "default" | "auto" | "forced"
|
|
119
126
|
/**
|
|
120
127
|
* Why this pipeline, for the `nifra build` log line - so an auto-selected Vite build never looks
|
|
121
128
|
* like the user got the default. `undefined` when the choice was the plain default or was forced.
|
|
@@ -139,16 +146,14 @@ const pluginNames = (plugins: readonly unknown[]): string =>
|
|
|
139
146
|
.join(", ")
|
|
140
147
|
|
|
141
148
|
/**
|
|
142
|
-
* Pick the bundler for `nifra build`, per app rather than per global default.
|
|
149
|
+
* Pick the bundler for `nifra build` and `nifra dev`, per app rather than per global default.
|
|
143
150
|
*
|
|
144
|
-
* The phase defaults are
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
* the same failure {@link checkPipelineSeparation} exists to prevent, reached by crossing PHASES instead
|
|
151
|
-
* of slots, and the slot check cannot see it because the plugins are correctly placed.
|
|
151
|
+
* The phase defaults are Bun (faster and Bun-native). For an app with no transforms that is direct and
|
|
152
|
+
* predictable. For an app whose ONLY transforms are Vite plugins it is not: those plugins are required in
|
|
153
|
+
* both dev and production, while the Bun build reads `clientPlugins`/`serverPlugins`, never `vitePlugins`.
|
|
154
|
+
* Selecting Bun would make the build succeed with the transform omitted. That is the same failure
|
|
155
|
+
* {@link checkPipelineSeparation} exists to prevent, reached by crossing PHASES instead of slots, and the
|
|
156
|
+
* slot check cannot see it because the plugins are correctly placed.
|
|
152
157
|
*
|
|
153
158
|
* So the default follows the app: Vite plugins with no Bun counterpart means the app has exactly one
|
|
154
159
|
* pipeline that can build it, and that is the one used. An app declaring BOTH has supplied the Bun
|
|
@@ -161,26 +166,51 @@ const pluginNames = (plugins: readonly unknown[]): string =>
|
|
|
161
166
|
export function chooseBuildPipeline(
|
|
162
167
|
slots: PipelineSlots,
|
|
163
168
|
forced?: BuildPipeline,
|
|
169
|
+
command: "build" | "dev" = "build",
|
|
164
170
|
): PipelineDecision {
|
|
165
171
|
const vitePlugins = slots.vitePlugins ?? []
|
|
166
172
|
const bunPlugins = [...(slots.clientPlugins ?? []), ...(slots.serverPlugins ?? [])]
|
|
167
173
|
const viteOnly = vitePlugins.length > 0 && bunPlugins.length === 0
|
|
168
174
|
|
|
169
175
|
if (forced === "bun" && viteOnly) {
|
|
176
|
+
// Named for the command the user actually typed - a `nifra dev --bun` failure that talks about
|
|
177
|
+
// `nifra build` sends them looking at the wrong command.
|
|
178
|
+
const phase = command === "dev" ? "dev server" : "build"
|
|
170
179
|
throw new Error(
|
|
171
|
-
|
|
172
|
-
|
|
180
|
+
`[nifra] \`nifra ${command} --bun\` would silently drop this app's only transforms. \`vitePlugins\` are ` +
|
|
181
|
+
`read by the Vite ${phase}; the Bun ${phase} reads \`clientPlugins\`/\`serverPlugins\`, so these would ` +
|
|
173
182
|
"never run and the output would look plausible without them.\n" +
|
|
174
183
|
` Would be dropped: ${pluginNames(vitePlugins)}\n` +
|
|
175
|
-
|
|
184
|
+
` Drop the flag to use Vite, or add the Bun equivalents to \`clientPlugins\`/\`serverPlugins\`.`,
|
|
176
185
|
)
|
|
177
186
|
}
|
|
178
|
-
if (forced !== undefined) return { pipeline: forced }
|
|
187
|
+
if (forced !== undefined) return { pipeline: forced, why: "forced" }
|
|
179
188
|
if (viteOnly) {
|
|
180
189
|
return {
|
|
181
190
|
pipeline: "vite",
|
|
191
|
+
why: "auto",
|
|
182
192
|
reason: `auto: this app's only transforms are \`vitePlugins\` (${pluginNames(vitePlugins)}), which the Bun build cannot run`,
|
|
183
193
|
}
|
|
184
194
|
}
|
|
185
|
-
return { pipeline: "bun" }
|
|
195
|
+
return { pipeline: "bun", why: "default" }
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* The one-line "which bundler, and why" note `nifra dev` and `nifra build` print under their banner.
|
|
200
|
+
*
|
|
201
|
+
* Printed on EVERY run, not only the surprising ones. A pipeline that announces itself only when it
|
|
202
|
+
* deviates teaches nobody which pipeline they are normally on, and every gotcha in the dev docs -
|
|
203
|
+
* plugin slots, resolve conditions, which compiler owns a `.svelte` file - is answerable only once you
|
|
204
|
+
* know that. The line also names the flag that switches, so the answer to "can I try the other one"
|
|
205
|
+
* is on screen rather than in the docs.
|
|
206
|
+
*/
|
|
207
|
+
export function describePipeline(decision: PipelineDecision): string {
|
|
208
|
+
const other = decision.pipeline === "bun" ? "--vite" : "--bun"
|
|
209
|
+
const detail =
|
|
210
|
+
decision.why === "forced"
|
|
211
|
+
? `forced by --${decision.pipeline}`
|
|
212
|
+
: decision.why === "auto"
|
|
213
|
+
? (decision.reason ?? "auto")
|
|
214
|
+
: `default; ${other} to switch`
|
|
215
|
+
return `bundler: ${decision.pipeline} (${detail})`
|
|
186
216
|
}
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The two-pipeline rule, reported STATICALLY - which bundler this app runs on, and the config hazards
|
|
3
|
+
* that only exist because nifra supports two.
|
|
4
|
+
*
|
|
5
|
+
* `loadApp` already refuses a plugin in the wrong slot ({@link ./load.ts}), and `nifra dev`/`nifra build`
|
|
6
|
+
* print the chosen bundler. Both of those need the app's config to be IMPORTED, which is code execution -
|
|
7
|
+
* something `nifra check` deliberately never does, and something an agent inspecting a repo it has not
|
|
8
|
+
* installed cannot do at all. So this reads the config as text instead.
|
|
9
|
+
*
|
|
10
|
+
* Text, not types, so the rules are chosen for the ones that survive being read rather than run:
|
|
11
|
+
*
|
|
12
|
+
* - Which pipeline the app is on. `chooseBuildPipeline` decides from whether the plugin slots are
|
|
13
|
+
* empty, and "does this file declare a non-empty `vitePlugins`" is a question the source answers.
|
|
14
|
+
* - The adapter-entry hazard. `nifra build` imports the adapter from `framework.ts`, or from
|
|
15
|
+
* `nifra.config.ts` when there is no `framework.ts`, and bundles everything that file imports into
|
|
16
|
+
* the production server. A Vite plugin or an SFC compiler reached that way builds cleanly and then
|
|
17
|
+
* dies at startup on a missing native binding. Nothing runtime-side catches it: by then the build
|
|
18
|
+
* has already succeeded.
|
|
19
|
+
* - A plugin in the wrong slot, for the subset whose import specifier names its pipeline. The load
|
|
20
|
+
* guard classifies by hook shape and is authoritative; this catches the same thing earlier, before
|
|
21
|
+
* anything is installed or started.
|
|
22
|
+
* - `conditions` on the Bun pipeline, which reach SSR and cannot reach the dev client bundle.
|
|
23
|
+
*
|
|
24
|
+
* Everything here degrades to silence rather than guessing. A config that computes its plugins, or
|
|
25
|
+
* re-exports them from elsewhere, yields `certain: false` and no findings - a static reader that
|
|
26
|
+
* invents a pipeline is worse than one that says it could not tell.
|
|
27
|
+
*/
|
|
28
|
+
import { existsSync } from "node:fs"
|
|
29
|
+
import { join } from "node:path"
|
|
30
|
+
import { codePositionMask, stripComments } from "./check.ts"
|
|
31
|
+
import type { BuildPipeline } from "./pipeline-guard.ts"
|
|
32
|
+
|
|
33
|
+
/** A plugin slot, and the pipeline it feeds. */
|
|
34
|
+
const SLOT_PIPELINE = {
|
|
35
|
+
vitePlugins: "vite",
|
|
36
|
+
clientPlugins: "bun",
|
|
37
|
+
serverPlugins: "bun",
|
|
38
|
+
} as const satisfies Readonly<Record<string, BuildPipeline>>
|
|
39
|
+
|
|
40
|
+
type Slot = keyof typeof SLOT_PIPELINE
|
|
41
|
+
|
|
42
|
+
const SLOTS = Object.keys(SLOT_PIPELINE) as readonly Slot[]
|
|
43
|
+
|
|
44
|
+
export interface PipelineFinding {
|
|
45
|
+
readonly rule: "adapter-entry" | "plugin-slot" | "bun-client-conditions"
|
|
46
|
+
readonly severity: "error" | "warning"
|
|
47
|
+
/** Project-relative file the finding is in. */
|
|
48
|
+
readonly file: string
|
|
49
|
+
readonly line?: number
|
|
50
|
+
readonly message: string
|
|
51
|
+
readonly fix: string
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface PipelineReport {
|
|
55
|
+
/** `false` when the directory holds no `nifra.config.ts` or `framework.ts` - nothing to report on. */
|
|
56
|
+
readonly ran: boolean
|
|
57
|
+
/** The bundler `nifra dev` and `nifra build` will use, or `unknown` when the source can't say. */
|
|
58
|
+
readonly pipeline: BuildPipeline | "unknown"
|
|
59
|
+
/** Plain-language "why this bundler", in the same words the CLI prints. */
|
|
60
|
+
readonly reason: string
|
|
61
|
+
/**
|
|
62
|
+
* Whether the config states its plugin slots outright. `false` when a slot is a thunk, an identifier,
|
|
63
|
+
* or a re-export - the pipeline shown is then nifra's best reading, and `nifra dev` prints the real one.
|
|
64
|
+
*/
|
|
65
|
+
readonly certain: boolean
|
|
66
|
+
/** The config file read, project-relative. */
|
|
67
|
+
readonly configFile?: string
|
|
68
|
+
/** The file `nifra build` imports the adapter from - `framework.ts`, else the config. */
|
|
69
|
+
readonly adapterEntry?: string
|
|
70
|
+
readonly findings: readonly PipelineFinding[]
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Specifiers that carry a dev toolchain: Vite itself, a Vite/Rollup plugin, or a framework's SFC
|
|
75
|
+
* compiler plugin (`@nifrajs/web-vue/plugin` and friends, which import the compiler). A relative
|
|
76
|
+
* `./plugin` is NOT matched - a local file of that name is as likely to be the app's own tiny plugin as
|
|
77
|
+
* a compiler, and this rule fails a gate.
|
|
78
|
+
*/
|
|
79
|
+
const DEV_TOOLCHAIN =
|
|
80
|
+
/^vite$|^vite\/|^@vitejs\/|vite-plugin|^rollup$|^@rollup\/|^esbuild$|^(?:@[^/]+\/)?[^./][^/]*\/(?:.*\/)?plugin(?:\.ts)?$/
|
|
81
|
+
|
|
82
|
+
/** Specifiers that name the Vite pipeline outright. */
|
|
83
|
+
const VITE_SPECIFIER = /^vite$|^vite\/|^@vitejs\/|vite-plugin/
|
|
84
|
+
/** Specifiers whose package subpath is nifra's Bun-plugin convention (`@nifrajs/web-vue/plugin`). */
|
|
85
|
+
const BUN_SPECIFIER = /^(?:@[^/]+\/)?[^./][^/]*\/(?:.*\/)?plugin(?:\.ts)?$/
|
|
86
|
+
|
|
87
|
+
const lineAt = (src: string, index: number): number => {
|
|
88
|
+
let line = 1
|
|
89
|
+
for (let i = 0; i < index && i < src.length; i++) if (src[i] === "\n") line++
|
|
90
|
+
return line
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Local binding names introduced by one import clause (`a`, `{ b as c }`, `* as ns`). */
|
|
94
|
+
function localNames(clause: string): string[] {
|
|
95
|
+
const names: string[] = []
|
|
96
|
+
const braced = /\{([^}]*)\}/.exec(clause)
|
|
97
|
+
if (braced !== null) {
|
|
98
|
+
for (const part of (braced[1] ?? "").split(",")) {
|
|
99
|
+
const named = /([A-Za-z_$][\w$]*)\s*$/.exec(part.trim())
|
|
100
|
+
if (named?.[1] !== undefined) names.push(named[1])
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
const head = clause.replace(/\{[^}]*\}/, " ").replace(/,/g, " ")
|
|
104
|
+
const star = /\*\s*as\s+([A-Za-z_$][\w$]*)/.exec(head)
|
|
105
|
+
if (star?.[1] !== undefined) names.push(star[1])
|
|
106
|
+
else {
|
|
107
|
+
const def = /^\s*([A-Za-z_$][\w$]*)\s*$/.exec(head)
|
|
108
|
+
if (def?.[1] !== undefined) names.push(def[1])
|
|
109
|
+
}
|
|
110
|
+
return names
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
interface ImportedBinding {
|
|
114
|
+
readonly specifier: string
|
|
115
|
+
readonly index: number
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Every value-importing binding in a module, mapped to the specifier it came from. `import type` is
|
|
120
|
+
* skipped: a type has no runtime cost, so it is neither a bundled toolchain nor a plugin in a slot.
|
|
121
|
+
*/
|
|
122
|
+
function importedBindings(stripped: string): Map<string, ImportedBinding> {
|
|
123
|
+
const out = new Map<string, ImportedBinding>()
|
|
124
|
+
const re = /(?<![.\w$])import\s+(?!type[\s{])([^'";]+?)\s+from\s*['"]([^'"]+)['"]/g
|
|
125
|
+
for (let m = re.exec(stripped); m !== null; m = re.exec(stripped)) {
|
|
126
|
+
const specifier = m[2]
|
|
127
|
+
if (specifier === undefined) continue
|
|
128
|
+
for (const name of localNames(m[1] ?? "")) out.set(name, { specifier, index: m.index })
|
|
129
|
+
}
|
|
130
|
+
return out
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Every specifier a module imports for its side effects or bindings, with the position to report. */
|
|
134
|
+
function importedSpecifiers(stripped: string): Array<{ specifier: string; index: number }> {
|
|
135
|
+
const out: Array<{ specifier: string; index: number }> = []
|
|
136
|
+
const re = /(?<![.\w$])import\s+(?:(?!type[\s{])[^'";]*?\s+from\s*)?['"]([^'"]+)['"]/g
|
|
137
|
+
for (let m = re.exec(stripped); m !== null; m = re.exec(stripped)) {
|
|
138
|
+
if (m[1] !== undefined) out.push({ specifier: m[1], index: m.index })
|
|
139
|
+
}
|
|
140
|
+
return out
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** Index just past the `]` matching the `[` at `open`, or `undefined` when it never closes. */
|
|
144
|
+
function closeBracket(masked: string, open: number): number | undefined {
|
|
145
|
+
let depth = 0
|
|
146
|
+
for (let i = open; i < masked.length; i++) {
|
|
147
|
+
const c = masked[i]
|
|
148
|
+
if (c === "[") depth++
|
|
149
|
+
else if (c === "]") {
|
|
150
|
+
depth--
|
|
151
|
+
if (depth === 0) return i
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return undefined
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
interface SlotState {
|
|
158
|
+
/** Whether the slot holds at least one plugin (an empty array literal reads as absent, as at runtime). */
|
|
159
|
+
readonly present: boolean
|
|
160
|
+
/** Whether the source states that outright, rather than deferring to a thunk or a re-export. */
|
|
161
|
+
readonly certain: boolean
|
|
162
|
+
readonly index?: number
|
|
163
|
+
/** Identifiers inside the array literal, when there is one. */
|
|
164
|
+
readonly items?: readonly string[]
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const ABSENT: SlotState = { present: false, certain: true }
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Read one exported binding as a plugin slot.
|
|
171
|
+
*
|
|
172
|
+
* Only an array LITERAL is read precisely; a thunk (`() => import(…)`), a bare identifier or a
|
|
173
|
+
* re-export is recorded as present-but-uncertain. That asymmetry is deliberate: `[]` and `[vue()]`
|
|
174
|
+
* decide the pipeline, and anything else is a promise the source cannot keep.
|
|
175
|
+
*/
|
|
176
|
+
function readSlot(masked: string, stripped: string, name: string): SlotState {
|
|
177
|
+
const declaration = new RegExp(
|
|
178
|
+
`(?<![.\\w$])export\\s+(?:const|let|var)\\s+${name}\\b[^=\\n]*=\\s*`,
|
|
179
|
+
)
|
|
180
|
+
const m = declaration.exec(masked)
|
|
181
|
+
if (m !== null) {
|
|
182
|
+
const start = m.index + m[0].length
|
|
183
|
+
if (masked[start] === "[") {
|
|
184
|
+
const end = closeBracket(masked, start)
|
|
185
|
+
if (end !== undefined) {
|
|
186
|
+
// Both views are offset-preserving, and each answers a different question: the mask has string
|
|
187
|
+
// CONTENTS blanked, so identifiers found in it are real code; the stripped source keeps them, so
|
|
188
|
+
// it is the one that can tell `["solid"]` from `[]`.
|
|
189
|
+
const code = masked.slice(start + 1, end)
|
|
190
|
+
const text = stripped.slice(start + 1, end)
|
|
191
|
+
const items = [...code.matchAll(/(?<![.\w$])([A-Za-z_$][\w$]*)/g)].map((i) => i[1] ?? "")
|
|
192
|
+
return { present: text.trim() !== "", certain: true, index: m.index, items }
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return { present: true, certain: false, index: m.index }
|
|
196
|
+
}
|
|
197
|
+
// `export { vitePlugins } from "./plugins.ts"` - present, but its contents live in another file.
|
|
198
|
+
const reexport = new RegExp(`(?<![.\\w$])export\\s*\\{[^}]*\\b${name}\\b[^}]*\\}`)
|
|
199
|
+
const r = reexport.exec(stripped)
|
|
200
|
+
if (r !== null) return { present: true, certain: false, index: r.index }
|
|
201
|
+
// `export * from …` could carry the slot; say so rather than reporting an absence that isn't one.
|
|
202
|
+
if (/(?<![.\w$])export\s*\*\s*from/.test(stripped)) return { present: false, certain: false }
|
|
203
|
+
return ABSENT
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** Which pipeline a plugin reference belongs to, or `undefined` when its name and origin say nothing. */
|
|
207
|
+
function classifyRef(name: string, specifier: string | undefined): BuildPipeline | undefined {
|
|
208
|
+
// nifra's own Bun plugins are named for what they are, and the name survives an alias-free import.
|
|
209
|
+
if (/BunPlugin$/.test(name)) return "bun"
|
|
210
|
+
if (specifier === undefined) return undefined
|
|
211
|
+
if (VITE_SPECIFIER.test(specifier)) return "vite"
|
|
212
|
+
if (BUN_SPECIFIER.test(specifier)) return "bun"
|
|
213
|
+
return undefined
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** Read one file as text, or `undefined` when it is missing or unreadable. */
|
|
217
|
+
async function readSource(path: string): Promise<string | undefined> {
|
|
218
|
+
try {
|
|
219
|
+
return await Bun.file(path).text()
|
|
220
|
+
} catch {
|
|
221
|
+
return undefined
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Report the pipeline and its config hazards for the app at `cwd`, without executing anything.
|
|
227
|
+
* Total: a missing or unreadable config yields `ran: false`, never a throw.
|
|
228
|
+
*/
|
|
229
|
+
export async function collectPipelineReport(cwd: string): Promise<PipelineReport> {
|
|
230
|
+
const configFile = existsSync(join(cwd, "nifra.config.ts")) ? "nifra.config.ts" : "framework.ts"
|
|
231
|
+
const source = await readSource(join(cwd, configFile))
|
|
232
|
+
if (source === undefined) {
|
|
233
|
+
return {
|
|
234
|
+
ran: false,
|
|
235
|
+
pipeline: "unknown",
|
|
236
|
+
reason: "no nifra.config.ts or framework.ts here",
|
|
237
|
+
certain: false,
|
|
238
|
+
findings: [],
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
const masked = codePositionMask(source)
|
|
242
|
+
const stripped = stripComments(source)
|
|
243
|
+
const bindings = importedBindings(stripped)
|
|
244
|
+
const slots = Object.fromEntries(
|
|
245
|
+
SLOTS.map((slot) => [slot, readSlot(masked, stripped, slot)]),
|
|
246
|
+
) as Record<Slot, SlotState>
|
|
247
|
+
|
|
248
|
+
const findings: PipelineFinding[] = []
|
|
249
|
+
|
|
250
|
+
// A plugin whose specifier names the other pipeline. The load-time guard classifies by hook shape and
|
|
251
|
+
// remains the authority; this is the half of it that can run on a repo nobody has installed yet.
|
|
252
|
+
for (const slot of SLOTS) {
|
|
253
|
+
const state = slots[slot]
|
|
254
|
+
const expected = SLOT_PIPELINE[slot]
|
|
255
|
+
for (const item of state.items ?? []) {
|
|
256
|
+
const binding = bindings.get(item)
|
|
257
|
+
const actual = classifyRef(item, binding?.specifier)
|
|
258
|
+
if (actual === undefined || actual === expected) continue
|
|
259
|
+
const from = binding !== undefined ? ` (imported from "${binding.specifier}")` : ""
|
|
260
|
+
findings.push({
|
|
261
|
+
rule: "plugin-slot",
|
|
262
|
+
severity: "error",
|
|
263
|
+
file: configFile,
|
|
264
|
+
line: lineAt(source, state.index ?? 0),
|
|
265
|
+
message:
|
|
266
|
+
`\`${item}\`${from} is a ${actual === "vite" ? "Vite" : "Bun"} plugin but sits in \`${slot}\`, which feeds ` +
|
|
267
|
+
`${expected === "vite" ? "Vite" : "Bun.build"}. The wrong bundler never calls its hooks, so the transform silently does not run and the build still succeeds.`,
|
|
268
|
+
fix:
|
|
269
|
+
actual === "vite"
|
|
270
|
+
? `move \`${item}\` to \`vitePlugins\``
|
|
271
|
+
: `move \`${item}\` to \`clientPlugins\` (client bundle) or \`serverPlugins\` (SSR)`,
|
|
272
|
+
})
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// Which bundler this app gets, by the same rule `chooseBuildPipeline` applies to the loaded config.
|
|
277
|
+
const viteOnly =
|
|
278
|
+
slots.vitePlugins.present && !slots.clientPlugins.present && !slots.serverPlugins.present
|
|
279
|
+
const certain = SLOTS.every((slot) => slots[slot].certain)
|
|
280
|
+
const pipeline: BuildPipeline = viteOnly ? "vite" : "bun"
|
|
281
|
+
const reason = viteOnly
|
|
282
|
+
? "auto: this app's only transforms are `vitePlugins`, which the Bun build cannot run"
|
|
283
|
+
: slots.clientPlugins.present || slots.serverPlugins.present
|
|
284
|
+
? "default: this app declares Bun plugins, so both phases stay on Bun"
|
|
285
|
+
: "default: no transforms to place, so both phases stay on Bun"
|
|
286
|
+
|
|
287
|
+
// The adapter entry is bundled into every `nifra build` server entry. Whatever it imports goes with it.
|
|
288
|
+
const adapterEntry = existsSync(join(cwd, "framework.ts")) ? "framework.ts" : configFile
|
|
289
|
+
const entrySource =
|
|
290
|
+
adapterEntry === configFile ? source : await readSource(join(cwd, adapterEntry))
|
|
291
|
+
if (entrySource !== undefined) {
|
|
292
|
+
const seen = new Set<string>()
|
|
293
|
+
for (const { specifier, index } of importedSpecifiers(stripComments(entrySource))) {
|
|
294
|
+
if (!DEV_TOOLCHAIN.test(specifier) || seen.has(specifier)) continue
|
|
295
|
+
seen.add(specifier)
|
|
296
|
+
findings.push({
|
|
297
|
+
rule: "adapter-entry",
|
|
298
|
+
severity: "error",
|
|
299
|
+
file: adapterEntry,
|
|
300
|
+
line: lineAt(entrySource, index),
|
|
301
|
+
message:
|
|
302
|
+
`${adapterEntry} imports "${specifier}", and \`nifra build\` imports the adapter from ${adapterEntry} - ` +
|
|
303
|
+
"so the dev toolchain is bundled into the production server entry. The build succeeds and the server then fails at startup on a dependency of the bundler (a missing native binding, typically), which reads like a broken install rather than a config split.",
|
|
304
|
+
fix:
|
|
305
|
+
adapterEntry === "framework.ts"
|
|
306
|
+
? 'move "' +
|
|
307
|
+
specifier +
|
|
308
|
+
'" to `nifra.config.ts`, which only the CLI imports, and keep `framework.ts` to the adapter'
|
|
309
|
+
: 'add a `framework.ts` exporting just the adapter, re-export it from `nifra.config.ts` (`export { adapter } from "./framework"`), and leave the toolchain imports in the config',
|
|
310
|
+
})
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// `conditions` reach SSR on the Bun pipeline and cannot reach the client bundle Bun's dev server
|
|
315
|
+
// serves - it takes no resolve conditions from bunfig or anywhere else. `nifra dev` says so at
|
|
316
|
+
// startup; a project whose CI only runs `nifra check` would otherwise never hear it.
|
|
317
|
+
const conditions = readSlot(masked, stripped, "conditions")
|
|
318
|
+
if (conditions.present && pipeline === "bun") {
|
|
319
|
+
findings.push({
|
|
320
|
+
rule: "bun-client-conditions",
|
|
321
|
+
severity: "warning",
|
|
322
|
+
file: configFile,
|
|
323
|
+
line: lineAt(source, conditions.index ?? 0),
|
|
324
|
+
message:
|
|
325
|
+
"`conditions` are honoured by SSR and by `nifra build`, but Bun's dev-server bundler accepts no resolve conditions - so under `nifra dev` a package with an `exports` map can resolve to one file in the browser and another everywhere else.",
|
|
326
|
+
fix: "run `nifra dev --vite` when the client bundle must resolve exactly as production does",
|
|
327
|
+
})
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
return {
|
|
331
|
+
ran: true,
|
|
332
|
+
pipeline: certain ? pipeline : "unknown",
|
|
333
|
+
reason: certain
|
|
334
|
+
? reason
|
|
335
|
+
: "the config states its plugins indirectly (a thunk, an identifier or a re-export), so the bundler can only be read by loading it - `nifra dev` and `nifra build` print the real one",
|
|
336
|
+
certain,
|
|
337
|
+
configFile,
|
|
338
|
+
adapterEntry,
|
|
339
|
+
findings,
|
|
340
|
+
}
|
|
341
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { realpath } from "node:fs/promises"
|
|
2
|
+
import { basename, dirname, isAbsolute, relative, resolve, sep } from "node:path"
|
|
3
|
+
|
|
4
|
+
function escapesRoot(root: string, candidate: string): boolean {
|
|
5
|
+
const rel = relative(root, candidate)
|
|
6
|
+
return rel === "" || rel === ".." || rel.startsWith(`..${sep}`) || isAbsolute(rel)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** Resolve a diagnostic path only when both its lexical and filesystem paths stay in the project. */
|
|
10
|
+
export async function resolveInsideProject(
|
|
11
|
+
root: string,
|
|
12
|
+
candidate: string,
|
|
13
|
+
): Promise<string | undefined> {
|
|
14
|
+
try {
|
|
15
|
+
if (isAbsolute(candidate)) return undefined
|
|
16
|
+
const resolvedRoot = resolve(root)
|
|
17
|
+
const resolved = resolve(resolvedRoot, candidate)
|
|
18
|
+
if (escapesRoot(resolvedRoot, resolved)) return undefined
|
|
19
|
+
|
|
20
|
+
const realRoot = await realpath(resolvedRoot)
|
|
21
|
+
let realCandidate: string
|
|
22
|
+
try {
|
|
23
|
+
realCandidate = await realpath(resolved)
|
|
24
|
+
} catch (error) {
|
|
25
|
+
if (!(error && typeof error === "object" && (error as { code?: string }).code === "ENOENT")) {
|
|
26
|
+
return undefined
|
|
27
|
+
}
|
|
28
|
+
const realParent = await realpath(dirname(resolved))
|
|
29
|
+
realCandidate = resolve(realParent, basename(resolved))
|
|
30
|
+
}
|
|
31
|
+
if (escapesRoot(realRoot, realCandidate)) return undefined
|
|
32
|
+
return resolved
|
|
33
|
+
} catch {
|
|
34
|
+
return undefined
|
|
35
|
+
}
|
|
36
|
+
}
|
package/src/replay.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { resolve, sep } from "node:path"
|
|
2
|
+
import { type CompatibleReplayFile, parseCompatibleReplayFile } from "@nifrajs/core/replay"
|
|
3
|
+
import { runHydrationAssurance } from "./assure-hydration.ts"
|
|
4
|
+
import { checkContractsLock } from "./contracts.ts"
|
|
5
|
+
|
|
6
|
+
export interface ReplayResult {
|
|
7
|
+
readonly ok: boolean
|
|
8
|
+
readonly replay: CompatibleReplayFile
|
|
9
|
+
readonly compatible?: boolean
|
|
10
|
+
readonly error?: string
|
|
11
|
+
readonly diagnostics?: readonly unknown[]
|
|
12
|
+
readonly replays?: readonly string[]
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Validate and dispatch one token-only replay while keeping the file inside the project root. */
|
|
16
|
+
export async function runReplay(cwd: string, file: string): Promise<ReplayResult> {
|
|
17
|
+
const path = resolve(cwd, file)
|
|
18
|
+
if (path !== cwd && !path.startsWith(cwd + sep)) {
|
|
19
|
+
throw new Error("replay file must stay inside the project root")
|
|
20
|
+
}
|
|
21
|
+
const replay = parseCompatibleReplayFile(JSON.parse(await Bun.file(path).text()))
|
|
22
|
+
if ("gate" in replay && replay.gate === "hydration") {
|
|
23
|
+
const hydration = await runHydrationAssurance(cwd, {
|
|
24
|
+
seed: replay.seed,
|
|
25
|
+
...(replay.case.startsWith("/") ? { routes: [replay.case] } : {}),
|
|
26
|
+
})
|
|
27
|
+
return {
|
|
28
|
+
ok: hydration.diagnostics.length === 0,
|
|
29
|
+
replay,
|
|
30
|
+
diagnostics: hydration.diagnostics,
|
|
31
|
+
...(hydration.replays === undefined ? {} : { replays: hydration.replays }),
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if ("gate" in replay && replay.gate === "contracts") {
|
|
35
|
+
const contracts = await checkContractsLock(cwd)
|
|
36
|
+
return {
|
|
37
|
+
ok: contracts.present && contracts.diagnostics.length === 0,
|
|
38
|
+
replay,
|
|
39
|
+
diagnostics: contracts.diagnostics,
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (!("gate" in replay)) return { ok: true, replay, compatible: true }
|
|
43
|
+
return { ok: false, replay, error: `no replay dispatcher for gate ${replay.gate}` }
|
|
44
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/** Built-in diagnostic code registry. Codes are append-only and reserved by the NF- prefix. */
|
|
2
|
+
|
|
3
|
+
export const RULE_CODES = Object.freeze({
|
|
4
|
+
"NF-C001": "TypeScript contract check",
|
|
5
|
+
"NF-C002": "Typed client check",
|
|
6
|
+
"NF-C003": "Untyped client check",
|
|
7
|
+
"NF-C004": "Server-only import check",
|
|
8
|
+
"NF-C005": "Removed import check",
|
|
9
|
+
"NF-C006": "Interpolated SQL check",
|
|
10
|
+
"NF-C007": "Raw response route advisory",
|
|
11
|
+
"NF-C008": "Undeclared dependency check",
|
|
12
|
+
"NF-C009": "Duplicate install check",
|
|
13
|
+
"NF-C010": "Stale workspace build check",
|
|
14
|
+
"NF-C011": "Build pipeline check",
|
|
15
|
+
"NF-C012": "Server manifest drift check",
|
|
16
|
+
"NF-C013": "Trust manifest drift check",
|
|
17
|
+
"NF-C014": "Capability assurance check",
|
|
18
|
+
"NF-C015": "Assurance configuration check",
|
|
19
|
+
"NF-C016": "Check configuration check",
|
|
20
|
+
"NF-C017": "Rule pack validation",
|
|
21
|
+
"NF-C018": "Reserved client segment check",
|
|
22
|
+
"NF-C019": "Duplicate route registration check",
|
|
23
|
+
"NF-D001": "Doctor check",
|
|
24
|
+
"NF-A001": "Assurance bundle check",
|
|
25
|
+
"NF-H001": "Hydration mismatch",
|
|
26
|
+
"NF-H002": "Duplicate framework runtime",
|
|
27
|
+
"NF-H003": "Stale client build",
|
|
28
|
+
"NF-H004": "Hydration interaction",
|
|
29
|
+
"NF-K001": "Contract snapshot drift",
|
|
30
|
+
"NF-S001": "Fail-open gate",
|
|
31
|
+
"NF-S002": "Non-constant-time secret comparison",
|
|
32
|
+
"NF-S003": "Sensitive value in log call",
|
|
33
|
+
"NF-S004": "CORS origin predicate ignores the origin",
|
|
34
|
+
"NF-S005": "External redirect opt-out",
|
|
35
|
+
"NF-S006": "Security escape hatch enabled",
|
|
36
|
+
"NF-S007": "Secure cookie without a __Host-/__Secure- prefix",
|
|
37
|
+
} as const)
|
|
38
|
+
|
|
39
|
+
/** Codes that no longer fire but remain reserved forever. */
|
|
40
|
+
export const RETIRED_CODES: ReadonlySet<string> = new Set()
|
|
41
|
+
|
|
42
|
+
export type BuiltInCode = keyof typeof RULE_CODES
|
|
43
|
+
|
|
44
|
+
export function isBuiltInCode(code: string): code is BuiltInCode {
|
|
45
|
+
return code in RULE_CODES || RETIRED_CODES.has(code)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function assertUniqueRuleCodes(): void {
|
|
49
|
+
const codes = Object.keys(RULE_CODES)
|
|
50
|
+
if (new Set(codes).size !== codes.length)
|
|
51
|
+
throw new Error("diagnostic code registry contains duplicates")
|
|
52
|
+
for (const code of codes) {
|
|
53
|
+
if (!/^NF-[A-Z]\d{3}$/.test(code)) throw new Error(`invalid built-in diagnostic code: ${code}`)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
assertUniqueRuleCodes()
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Marker recognition for in-source escape hatches (`@nifra-gate-reviewed`, `nifra-expect …`).
|
|
3
|
+
*
|
|
4
|
+
* A marker counts when it appears on the flagged line itself (trailing comment) or ANYWHERE in the
|
|
5
|
+
* contiguous comment block directly above it - which is where a human naturally writes the
|
|
6
|
+
* multi-line justification the hatch asks for. A blank line or a code line ends the block, so a
|
|
7
|
+
* marker in an unrelated comment further up never leaks onto a finding below it.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
// Lines that continue a comment block when walking upward: line comments, block-comment
|
|
11
|
+
// open/body/close lines, and the JSX comment form.
|
|
12
|
+
const COMMENT_LINE = /^\s*(?:\/\/|\/\*|\*\/|\*|\{\/\*)/
|
|
13
|
+
|
|
14
|
+
export function commentBlockHasMarker(
|
|
15
|
+
lines: readonly string[],
|
|
16
|
+
line: number,
|
|
17
|
+
marker: string,
|
|
18
|
+
): boolean {
|
|
19
|
+
if ((lines[line - 1] ?? "").includes(marker)) return true
|
|
20
|
+
for (let i = line - 2; i >= 0; i--) {
|
|
21
|
+
const text = lines[i] ?? ""
|
|
22
|
+
if (!COMMENT_LINE.test(text)) return false
|
|
23
|
+
if (text.includes(marker)) return true
|
|
24
|
+
}
|
|
25
|
+
return false
|
|
26
|
+
}
|