@nifrajs/cli 5.1.0 → 5.3.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 +3313 -0
- package/README.md +3 -0
- package/dist/agent-files.d.ts +19 -11
- package/dist/agent-files.d.ts.map +1 -1
- package/dist/agent-files.js +26 -18
- package/dist/agent-files.js.map +1 -1
- package/dist/assure-hydration.d.ts.map +1 -1
- package/dist/assure-hydration.js +7 -2
- package/dist/assure-hydration.js.map +1 -1
- package/dist/assure.d.ts.map +1 -1
- package/dist/assure.js +14 -1
- package/dist/assure.js.map +1 -1
- package/dist/capabilities-tool.d.ts.map +1 -1
- package/dist/capabilities-tool.js +131 -45
- package/dist/capabilities-tool.js.map +1 -1
- package/dist/check-diagnostics.d.ts +5 -0
- package/dist/check-diagnostics.d.ts.map +1 -1
- package/dist/check-diagnostics.js +5 -0
- package/dist/check-diagnostics.js.map +1 -1
- package/dist/check-scan.d.ts +9 -3
- package/dist/check-scan.d.ts.map +1 -1
- package/dist/check-scan.js +61 -21
- package/dist/check-scan.js.map +1 -1
- package/dist/check.d.ts.map +1 -1
- package/dist/check.js +55 -15
- package/dist/check.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +37 -18
- package/dist/cli.js.map +1 -1
- package/dist/command-catalog.d.ts.map +1 -1
- package/dist/command-catalog.js +9 -5
- package/dist/command-catalog.js.map +1 -1
- package/dist/db-tool.d.ts.map +1 -1
- package/dist/db-tool.js +2 -1
- package/dist/db-tool.js.map +1 -1
- package/dist/dev-bun-config.d.ts +6 -3
- package/dist/dev-bun-config.d.ts.map +1 -1
- package/dist/dev-bun-config.js +13 -10
- package/dist/dev-bun-config.js.map +1 -1
- package/dist/dev-feed-tool.d.ts +3 -2
- package/dist/dev-feed-tool.d.ts.map +1 -1
- package/dist/dev-feed-tool.js +26 -5
- package/dist/dev-feed-tool.js.map +1 -1
- package/dist/doctor.d.ts +15 -1
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +79 -61
- package/dist/doctor.js.map +1 -1
- package/dist/env-file.d.ts.map +1 -1
- package/dist/env-file.js +41 -8
- package/dist/env-file.js.map +1 -1
- package/dist/i18n-check.d.ts +11 -1
- package/dist/i18n-check.d.ts.map +1 -1
- package/dist/i18n-check.js +170 -17
- package/dist/i18n-check.js.map +1 -1
- package/dist/init-agents.d.ts +46 -6
- package/dist/init-agents.d.ts.map +1 -1
- package/dist/init-agents.js +193 -31
- package/dist/init-agents.js.map +1 -1
- package/dist/internal/project-specifiers.d.ts.map +1 -1
- package/dist/internal/project-specifiers.js +9 -1
- package/dist/internal/project-specifiers.js.map +1 -1
- package/dist/internal/source-facts.d.ts +22 -0
- package/dist/internal/source-facts.d.ts.map +1 -1
- package/dist/internal/source-facts.js +322 -0
- package/dist/internal/source-facts.js.map +1 -1
- package/dist/internal/workspace-packages.d.ts +22 -0
- package/dist/internal/workspace-packages.d.ts.map +1 -0
- package/dist/internal/workspace-packages.js +215 -0
- package/dist/internal/workspace-packages.js.map +1 -0
- package/dist/load.d.ts +7 -2
- package/dist/load.d.ts.map +1 -1
- package/dist/load.js +11 -2
- package/dist/load.js.map +1 -1
- package/dist/lock-links.d.ts +42 -0
- package/dist/lock-links.d.ts.map +1 -0
- package/dist/lock-links.js +144 -0
- package/dist/lock-links.js.map +1 -0
- package/dist/mcp-exec.d.ts +1 -0
- package/dist/mcp-exec.d.ts.map +1 -1
- package/dist/mcp-exec.js +16 -5
- package/dist/mcp-exec.js.map +1 -1
- package/dist/mcp-http.js +1 -1
- package/dist/mcp-io.d.ts +23 -3
- package/dist/mcp-io.d.ts.map +1 -1
- package/dist/mcp-io.js +59 -12
- 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-root.d.ts +6 -4
- package/dist/mcp-root.d.ts.map +1 -1
- package/dist/mcp-root.js +12 -8
- package/dist/mcp-root.js.map +1 -1
- package/dist/migrate-layout.d.ts +2 -1
- package/dist/migrate-layout.d.ts.map +1 -1
- package/dist/migrate-layout.js +435 -29
- package/dist/migrate-layout.js.map +1 -1
- package/dist/project-site.d.ts +7 -0
- package/dist/project-site.d.ts.map +1 -0
- package/dist/project-site.js +19 -0
- package/dist/project-site.js.map +1 -0
- package/dist/recipes/4.0.0.d.ts.map +1 -1
- package/dist/recipes/4.0.0.js +2 -0
- package/dist/recipes/4.0.0.js.map +1 -1
- package/dist/recipes/5.1.0.d.ts +9 -0
- package/dist/recipes/5.1.0.d.ts.map +1 -0
- package/dist/recipes/5.1.0.js +22 -0
- package/dist/recipes/5.1.0.js.map +1 -0
- package/dist/recipes/5.2.0.d.ts +10 -0
- package/dist/recipes/5.2.0.d.ts.map +1 -0
- package/dist/recipes/5.2.0.js +32 -0
- package/dist/recipes/5.2.0.js.map +1 -0
- package/dist/recipes/5.3.0.d.ts +11 -0
- package/dist/recipes/5.3.0.d.ts.map +1 -0
- package/dist/recipes/5.3.0.js +35 -0
- package/dist/recipes/5.3.0.js.map +1 -0
- package/dist/recipes/index.d.ts +3 -0
- package/dist/recipes/index.d.ts.map +1 -1
- package/dist/recipes/index.js +9 -0
- package/dist/recipes/index.js.map +1 -1
- package/dist/review.d.ts.map +1 -1
- package/dist/review.js +4 -0
- package/dist/review.js.map +1 -1
- package/dist/rule-explain.d.ts +26 -0
- package/dist/rule-explain.d.ts.map +1 -0
- package/dist/rule-explain.js +49 -0
- package/dist/rule-explain.js.map +1 -0
- package/dist/rules/codes.d.ts +4 -0
- package/dist/rules/codes.d.ts.map +1 -1
- package/dist/rules/codes.js +4 -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 +93 -21
- package/dist/rules/contract-visibility.js.map +1 -1
- package/dist/rules/explanations.d.ts +14 -0
- package/dist/rules/explanations.d.ts.map +1 -0
- package/dist/rules/explanations.js +326 -0
- package/dist/rules/explanations.js.map +1 -0
- package/dist/rules/legacy.d.ts.map +1 -1
- package/dist/rules/legacy.js +24 -1
- package/dist/rules/legacy.js.map +1 -1
- package/dist/rules/merge-auth.d.ts +12 -0
- package/dist/rules/merge-auth.d.ts.map +1 -0
- package/dist/rules/merge-auth.js +52 -0
- package/dist/rules/merge-auth.js.map +1 -0
- package/dist/rules/pages.d.ts +51 -0
- package/dist/rules/pages.d.ts.map +1 -1
- package/dist/rules/pages.js +293 -2
- package/dist/rules/pages.js.map +1 -1
- package/dist/rules/route-statement.d.ts +10 -0
- package/dist/rules/route-statement.d.ts.map +1 -0
- package/dist/rules/route-statement.js +150 -0
- package/dist/rules/route-statement.js.map +1 -0
- package/dist/rules/routes.d.ts +3 -2
- package/dist/rules/routes.d.ts.map +1 -1
- package/dist/rules/routes.js +4 -3
- package/dist/rules/routes.js.map +1 -1
- package/dist/rules/zones.d.ts.map +1 -1
- package/dist/rules/zones.js +3 -2
- package/dist/rules/zones.js.map +1 -1
- package/dist/typecheck-coverage.d.ts +11 -0
- package/dist/typecheck-coverage.d.ts.map +1 -1
- package/dist/typecheck-coverage.js +50 -7
- package/dist/typecheck-coverage.js.map +1 -1
- package/dist/upgrade.d.ts +80 -11
- package/dist/upgrade.d.ts.map +1 -1
- package/dist/upgrade.js +332 -65
- package/dist/upgrade.js.map +1 -1
- package/dist/verification-plan.d.ts.map +1 -1
- package/dist/verification-plan.js +2 -0
- package/dist/verification-plan.js.map +1 -1
- package/dist/version-drift.d.ts.map +1 -1
- package/dist/version-drift.js +12 -1
- package/dist/version-drift.js.map +1 -1
- package/dist/web-app-options.d.ts +1 -1
- package/dist/web-app-options.d.ts.map +1 -1
- package/dist/web-app-options.js.map +1 -1
- package/docs/examples.json +19 -1
- package/docs/llms-full.txt +716 -138
- package/docs/types.json +516 -74
- package/package.json +13 -12
- package/src/agent-files.ts +27 -17
- package/src/assure-hydration.ts +8 -1
- package/src/assure.ts +11 -1
- package/src/capabilities-tool.ts +159 -50
- package/src/check-diagnostics.ts +10 -0
- package/src/check-scan.ts +64 -19
- package/src/check.ts +75 -15
- package/src/cli.ts +38 -17
- package/src/command-catalog.ts +16 -8
- package/src/db-tool.ts +2 -0
- package/src/dev-bun-config.ts +13 -9
- package/src/dev-feed-tool.ts +40 -6
- package/src/doctor.ts +102 -66
- package/src/env-file.ts +42 -7
- package/src/i18n-check.ts +254 -18
- package/src/init-agents.ts +221 -41
- package/src/internal/project-specifiers.ts +9 -1
- package/src/internal/source-facts.ts +397 -0
- package/src/internal/workspace-packages.ts +218 -0
- package/src/load.ts +19 -3
- package/src/lock-links.ts +173 -0
- package/src/mcp-exec.ts +18 -4
- package/src/mcp-http.ts +1 -1
- package/src/mcp-io.ts +72 -12
- package/src/mcp-isolate.ts +2 -0
- package/src/mcp-root.ts +14 -8
- package/src/migrate-layout.ts +496 -31
- package/src/project-site.ts +18 -0
- package/src/recipes/4.0.0.ts +2 -0
- package/src/recipes/5.1.0.ts +23 -0
- package/src/recipes/5.2.0.ts +33 -0
- package/src/recipes/5.3.0.ts +36 -0
- package/src/recipes/index.ts +9 -0
- package/src/review.ts +4 -0
- package/src/rule-explain.ts +75 -0
- package/src/rules/codes.ts +4 -0
- package/src/rules/contract-visibility.ts +118 -20
- package/src/rules/explanations.ts +339 -0
- package/src/rules/legacy.ts +24 -1
- package/src/rules/merge-auth.ts +55 -0
- package/src/rules/pages.ts +381 -2
- package/src/rules/route-statement.ts +170 -0
- package/src/rules/routes.ts +4 -3
- package/src/rules/zones.ts +3 -2
- package/src/typecheck-coverage.ts +51 -6
- package/src/upgrade.ts +430 -70
- package/src/verification-plan.ts +6 -0
- package/src/version-drift.ts +15 -0
- package/src/web-app-options.ts +9 -1
package/dist/check-scan.js
CHANGED
|
@@ -294,7 +294,9 @@ export function parseSimpleFetchCall(snippet) {
|
|
|
294
294
|
return undefined;
|
|
295
295
|
return { path, method, start: match.index, end: close + 1 };
|
|
296
296
|
}
|
|
297
|
-
|
|
297
|
+
// `createWebApp(...)` returns the same `Server`, so a route chained onto it is a backend route.
|
|
298
|
+
const NIFRA_SERVER_CONSTRUCTION = /(?<![.\w])(?:server|createWebApp)\s*\(/;
|
|
299
|
+
const SERVER_CONSTRUCTION = /(?<![.\w])(?:server|createWebApp)\s*\(|new\s+Hono(?:<[^>]+>)?\s*\(/;
|
|
298
300
|
function isPotentialBackendSource(code, file, project) {
|
|
299
301
|
return (code.includes("@nifrajs/core") ||
|
|
300
302
|
SERVER_CONSTRUCTION.test(code) ||
|
|
@@ -2860,36 +2862,74 @@ function serverOnlyChains(graph, file, content, browserRoot) {
|
|
|
2860
2862
|
// silently vanishes for that route. Advisory, not a failure: a raw Response is sometimes intended
|
|
2861
2863
|
// (redirects, files, streams). Fix is to return a plain object, or declare `{ response: t.… }` to type it.
|
|
2862
2864
|
const RESPONSE_RETURN = /(?:=>\s*|return\s+)(?:new\s+Response|Response\s*\.\s*json)\s*\(/g;
|
|
2863
|
-
/**
|
|
2864
|
-
*
|
|
2865
|
-
|
|
2865
|
+
/**
|
|
2866
|
+
* Scan a backend module (one that calls `server(` or `createWebApp(`) for handlers returning a raw
|
|
2867
|
+
* `Response`, which collapses the typed client's `data` to `never`. Pure + line-accurate; returns `[]`
|
|
2868
|
+
* for any other file. With an AST it also follows what the lexical pattern cannot see: a local holding
|
|
2869
|
+
* the Response, the context's `json()`/`text()`, and - given `project` - a helper imported from a
|
|
2870
|
+
* relative module whose export returns one, reported at each route's return. It skips a handler the
|
|
2871
|
+
* client still types: one that also returns a plain value, or whose route declares `response`.
|
|
2872
|
+
*/
|
|
2873
|
+
export function scanResponseRoutes(file, content, facts, project) {
|
|
2866
2874
|
// Strip comments + template literals first: a commented-out or doc-example `return new Response(`
|
|
2867
2875
|
// must not raise a spurious advisory. Lengths are preserved, so lineAt + the raw-line snippet align.
|
|
2868
2876
|
const code = stripComments(content);
|
|
2869
|
-
if (
|
|
2877
|
+
if (!NIFRA_SERVER_CONSTRUCTION.test(code))
|
|
2870
2878
|
return [];
|
|
2871
2879
|
const out = [];
|
|
2872
2880
|
const lines = content.split("\n");
|
|
2881
|
+
// A `// nifra-expect NF-C007` comment (or the `raw-response` slug) marks an intentional raw Response
|
|
2882
|
+
// (a file/redirect that can't be a typed route), silencing this advisory with or without a reason.
|
|
2883
|
+
// It counts on the return line or in the comment block directly above, so a TRAILING comment on one
|
|
2884
|
+
// route's return line can't leak down onto the next route. `stripComments` blanks it in `code` (so it
|
|
2885
|
+
// never affects the match); the raw `lines` still carry it.
|
|
2886
|
+
const report = (line) => {
|
|
2887
|
+
if (commentBlockExpectation(lines, line, RAW_RESPONSE_EXPECTATION) !== undefined)
|
|
2888
|
+
return;
|
|
2889
|
+
out.push({ file, line, snippet: (lines[line - 1] ?? "").trim() });
|
|
2890
|
+
};
|
|
2891
|
+
const source = facts?.parse(file, content);
|
|
2892
|
+
const exportsByImport = new Map();
|
|
2893
|
+
const importReturnsResponse = facts === undefined || project === undefined
|
|
2894
|
+
? undefined
|
|
2895
|
+
: (specifier, name) => {
|
|
2896
|
+
const key = `${specifier}\0${name}`;
|
|
2897
|
+
let answer = exportsByImport.get(key);
|
|
2898
|
+
if (answer === undefined) {
|
|
2899
|
+
const target = projectModule(project, file, specifier);
|
|
2900
|
+
const text = target === undefined ? undefined : project.get(target);
|
|
2901
|
+
const module = target === undefined || text === undefined ? undefined : facts.parse(target, text);
|
|
2902
|
+
answer = module !== undefined && facts.exportReturnsResponse(module, name);
|
|
2903
|
+
exportsByImport.set(key, answer);
|
|
2904
|
+
}
|
|
2905
|
+
return answer;
|
|
2906
|
+
};
|
|
2907
|
+
const routes = facts === undefined || source === undefined
|
|
2908
|
+
? undefined
|
|
2909
|
+
: facts.untypedResponseRoutes(source, importReturnsResponse);
|
|
2873
2910
|
RESPONSE_RETURN.lastIndex = 0;
|
|
2874
2911
|
for (let m = RESPONSE_RETURN.exec(code); m !== null; m = RESPONSE_RETURN.exec(code)) {
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
const line = lineAt(content, m.index);
|
|
2883
|
-
// A `// nifra-expect NF-C007` comment (or the `raw-response` slug) marks an intentional raw Response
|
|
2884
|
-
// (a file/redirect that can't be a typed route), silencing this advisory with or without a reason.
|
|
2885
|
-
// It counts on the return line or in the comment block directly above, so a TRAILING comment on one
|
|
2886
|
-
// route's return line can't leak down onto the next route. `stripComments` blanks it in `code` (so it
|
|
2887
|
-
// never affects the match); the raw `lines` still carry it.
|
|
2888
|
-
if (commentBlockExpectation(lines, line, RAW_RESPONSE_EXPECTATION) !== undefined)
|
|
2912
|
+
// A parseable AST rejects `return new Response(` text that only lives in a normal string, one
|
|
2913
|
+
// outside a route handler (an auth stage's `rejected` helper, say), and one in a handler the client
|
|
2914
|
+
// still types: it returns a plain value too, or its route declares `response`. On malformed
|
|
2915
|
+
// source we keep the lexical candidate; the typecheck gate will report the syntax error.
|
|
2916
|
+
if (facts !== undefined &&
|
|
2917
|
+
source !== undefined &&
|
|
2918
|
+
(facts.isResponseSyntaxAt(source, m.index) !== true || routes?.isUntypedAt(m.index) !== true))
|
|
2889
2919
|
continue;
|
|
2890
|
-
|
|
2920
|
+
report(lineAt(content, m.index));
|
|
2891
2921
|
}
|
|
2892
|
-
|
|
2922
|
+
if (routes === undefined)
|
|
2923
|
+
return out;
|
|
2924
|
+
const reported = new Set(out.map((finding) => finding.line));
|
|
2925
|
+
for (const position of routes.indirectReturns) {
|
|
2926
|
+
const line = lineAt(content, position);
|
|
2927
|
+
if (reported.has(line))
|
|
2928
|
+
continue;
|
|
2929
|
+
reported.add(line);
|
|
2930
|
+
report(line);
|
|
2931
|
+
}
|
|
2932
|
+
return out.sort((a, b) => a.line - b.line);
|
|
2893
2933
|
}
|
|
2894
2934
|
/** What suppresses the {@link scanResponseRoutes} advisory for an intentional raw Response. */
|
|
2895
2935
|
const RAW_RESPONSE_EXPECTATION = ["NF-C007", "raw-response"];
|