@nifrajs/cli 5.0.0 → 5.2.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 +3211 -0
- package/README.md +10 -2
- 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 +5 -2
- package/dist/assure-hydration.js.map +1 -1
- package/dist/assure.d.ts +12 -2
- package/dist/assure.d.ts.map +1 -1
- package/dist/assure.js +73 -9
- package/dist/assure.js.map +1 -1
- package/dist/capabilities-tool.d.ts.map +1 -1
- package/dist/capabilities-tool.js +152 -49
- package/dist/capabilities-tool.js.map +1 -1
- package/dist/check-diagnostics.d.ts +7 -0
- package/dist/check-diagnostics.d.ts.map +1 -1
- package/dist/check-diagnostics.js +3 -0
- package/dist/check-diagnostics.js.map +1 -1
- package/dist/check-scan.d.ts +8 -2
- package/dist/check-scan.d.ts.map +1 -1
- package/dist/check-scan.js +49 -13
- package/dist/check-scan.js.map +1 -1
- package/dist/check.d.ts.map +1 -1
- package/dist/check.js +91 -45
- package/dist/check.js.map +1 -1
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +128 -59
- package/dist/cli.js.map +1 -1
- package/dist/client-module.d.ts +5 -3
- package/dist/client-module.d.ts.map +1 -1
- package/dist/client-module.js +34 -10
- package/dist/client-module.js.map +1 -1
- package/dist/command-catalog.d.ts +9 -1
- package/dist/command-catalog.d.ts.map +1 -1
- package/dist/command-catalog.js +75 -26
- package/dist/command-catalog.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 +19 -1
- package/dist/dev-feed-tool.d.ts.map +1 -1
- package/dist/dev-feed-tool.js +114 -0
- 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/fix-recipes.d.ts +2 -0
- package/dist/fix-recipes.d.ts.map +1 -1
- package/dist/fix-recipes.js +93 -12
- package/dist/fix-recipes.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 +60 -4
- package/dist/init-agents.d.ts.map +1 -1
- package/dist/init-agents.js +196 -33
- package/dist/init-agents.js.map +1 -1
- package/dist/internal/config-paths.d.ts +16 -0
- package/dist/internal/config-paths.d.ts.map +1 -0
- package/dist/internal/config-paths.js +124 -0
- package/dist/internal/config-paths.js.map +1 -0
- package/dist/internal/installed-package.d.ts +4 -0
- package/dist/internal/installed-package.d.ts.map +1 -0
- package/dist/internal/installed-package.js +17 -0
- package/dist/internal/installed-package.js.map +1 -0
- package/dist/internal/project-specifiers.d.ts +14 -1
- package/dist/internal/project-specifiers.d.ts.map +1 -1
- package/dist/internal/project-specifiers.js +63 -16
- package/dist/internal/project-specifiers.js.map +1 -1
- package/dist/internal/source-facts.d.ts +12 -1
- package/dist/internal/source-facts.d.ts.map +1 -1
- package/dist/internal/source-facts.js +117 -5
- package/dist/internal/source-facts.js.map +1 -1
- package/dist/internal/typescript-import.d.ts.map +1 -1
- package/dist/internal/typescript-import.js +5 -3
- package/dist/internal/typescript-import.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/introspect.d.ts +9 -0
- package/dist/introspect.d.ts.map +1 -1
- package/dist/introspect.js +32 -1
- package/dist/introspect.js.map +1 -1
- package/dist/levels-tool.d.ts.map +1 -1
- package/dist/levels-tool.js +5 -8
- package/dist/levels-tool.js.map +1 -1
- package/dist/load.d.ts +9 -4
- package/dist/load.d.ts.map +1 -1
- package/dist/load.js +32 -3
- 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-context.d.ts.map +1 -1
- package/dist/mcp-context.js +6 -21
- package/dist/mcp-context.js.map +1 -1
- package/dist/mcp-delegate.d.ts +2 -2
- package/dist/mcp-delegate.d.ts.map +1 -1
- package/dist/mcp-delegate.js +19 -7
- package/dist/mcp-delegate.js.map +1 -1
- package/dist/mcp-exec.d.ts +1 -0
- package/dist/mcp-exec.d.ts.map +1 -1
- package/dist/mcp-exec.js +13 -5
- package/dist/mcp-exec.js.map +1 -1
- package/dist/mcp-http.js +1 -1
- package/dist/mcp-io.d.ts +13 -0
- package/dist/mcp-io.d.ts.map +1 -1
- package/dist/mcp-io.js +23 -0
- package/dist/mcp-io.js.map +1 -1
- package/dist/mcp-path.d.ts +2 -1
- package/dist/mcp-path.d.ts.map +1 -1
- package/dist/mcp-path.js +9 -24
- package/dist/mcp-path.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/mcp.d.ts.map +1 -1
- package/dist/mcp.js +40 -17
- package/dist/mcp.js.map +1 -1
- package/dist/migrate-layout.d.ts +41 -1
- package/dist/migrate-layout.d.ts.map +1 -1
- package/dist/migrate-layout.js +1729 -236
- package/dist/migrate-layout.js.map +1 -1
- package/dist/output-schemas.d.ts +34 -0
- package/dist/output-schemas.d.ts.map +1 -1
- package/dist/output-schemas.js +132 -21
- package/dist/output-schemas.js.map +1 -1
- package/dist/project-path.d.ts +6 -0
- package/dist/project-path.d.ts.map +1 -1
- package/dist/project-path.js +48 -14
- package/dist/project-path.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/index.d.ts +3 -0
- package/dist/recipes/index.d.ts.map +1 -1
- package/dist/recipes/index.js +7 -0
- package/dist/recipes/index.js.map +1 -1
- package/dist/release-verification.d.ts +5 -0
- package/dist/release-verification.d.ts.map +1 -1
- package/dist/release-verification.js +14 -0
- package/dist/release-verification.js.map +1 -1
- package/dist/review.d.ts.map +1 -1
- package/dist/review.js +7 -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 +5 -1
- package/dist/rules/codes.d.ts.map +1 -1
- package/dist/rules/codes.js +5 -1
- 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/data-guard.d.ts +6 -0
- package/dist/rules/data-guard.d.ts.map +1 -1
- package/dist/rules/data-guard.js +37 -0
- package/dist/rules/data-guard.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 +316 -0
- package/dist/rules/explanations.js.map +1 -0
- package/dist/rules/legacy.d.ts.map +1 -1
- package/dist/rules/legacy.js +44 -2
- 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 +56 -3
- package/dist/rules/pages.d.ts.map +1 -1
- package/dist/rules/pages.js +412 -23
- package/dist/rules/pages.js.map +1 -1
- 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/security.d.ts +3 -2
- package/dist/rules/security.d.ts.map +1 -1
- package/dist/rules/security.js +42 -11
- package/dist/rules/security.js.map +1 -1
- package/dist/rules/zones.d.ts.map +1 -1
- package/dist/rules/zones.js +34 -11
- package/dist/rules/zones.js.map +1 -1
- package/dist/stylex-migrate.d.ts.map +1 -1
- package/dist/stylex-migrate.js +127 -17
- package/dist/stylex-migrate.js.map +1 -1
- package/dist/test-tool.d.ts.map +1 -1
- package/dist/test-tool.js +3 -9
- package/dist/test-tool.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 +57 -6
- package/dist/upgrade.d.ts.map +1 -1
- package/dist/upgrade.js +247 -19
- package/dist/upgrade.js.map +1 -1
- package/dist/verification-plan.d.ts.map +1 -1
- package/dist/verification-plan.js +7 -2
- package/dist/verification-plan.js.map +1 -1
- package/dist/version-drift.d.ts.map +1 -1
- package/dist/version-drift.js +66 -3
- 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 +21 -3
- package/docs/llms-full.txt +1083 -168
- package/docs/types.json +535 -112
- package/package.json +13 -12
- package/src/agent-files.ts +27 -17
- package/src/assure-hydration.ts +5 -1
- package/src/assure.ts +99 -11
- package/src/capabilities-tool.ts +188 -53
- package/src/check-diagnostics.ts +10 -0
- package/src/check-scan.ts +65 -12
- package/src/check.ts +122 -51
- package/src/cli.ts +127 -45
- package/src/client-module.ts +45 -9
- package/src/command-catalog.ts +92 -28
- package/src/dev-bun-config.ts +13 -9
- package/src/dev-feed-tool.ts +146 -1
- package/src/doctor.ts +102 -66
- package/src/fix-recipes.ts +101 -10
- package/src/i18n-check.ts +254 -18
- package/src/init-agents.ts +225 -44
- package/src/internal/config-paths.ts +154 -0
- package/src/internal/installed-package.ts +15 -0
- package/src/internal/project-specifiers.ts +78 -17
- package/src/internal/source-facts.ts +147 -5
- package/src/internal/typescript-import.ts +5 -3
- package/src/internal/workspace-packages.ts +218 -0
- package/src/introspect.ts +39 -1
- package/src/levels-tool.ts +7 -9
- package/src/load.ts +46 -4
- package/src/lock-links.ts +173 -0
- package/src/mcp-context.ts +5 -18
- package/src/mcp-delegate.ts +22 -10
- package/src/mcp-exec.ts +14 -4
- package/src/mcp-http.ts +1 -1
- package/src/mcp-io.ts +33 -0
- package/src/mcp-path.ts +8 -22
- package/src/mcp-root.ts +14 -8
- package/src/mcp.ts +48 -19
- package/src/migrate-layout.ts +1968 -245
- package/src/output-schemas.ts +179 -23
- package/src/project-path.ts +44 -13
- 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/index.ts +7 -0
- package/src/release-verification.ts +20 -0
- package/src/review.ts +7 -0
- package/src/rule-explain.ts +75 -0
- package/src/rules/codes.ts +5 -1
- package/src/rules/contract-visibility.ts +118 -20
- package/src/rules/data-guard.ts +40 -0
- package/src/rules/explanations.ts +329 -0
- package/src/rules/legacy.ts +46 -2
- package/src/rules/merge-auth.ts +55 -0
- package/src/rules/pages.ts +486 -25
- package/src/rules/routes.ts +4 -3
- package/src/rules/security.ts +49 -11
- package/src/rules/zones.ts +33 -9
- package/src/stylex-migrate.ts +117 -17
- package/src/test-tool.ts +3 -9
- package/src/typecheck-coverage.ts +51 -6
- package/src/upgrade.ts +312 -19
- package/src/verification-plan.ts +15 -2
- package/src/version-drift.ts +68 -2
- package/src/web-app-options.ts +9 -1
package/src/command-catalog.ts
CHANGED
|
@@ -17,7 +17,7 @@ import { cdnCheckSpec } from "./cdn-check.ts"
|
|
|
17
17
|
import { type CheckResult, renderCheckReport } from "./check.ts"
|
|
18
18
|
import type { ContractsLock } from "./contracts.ts"
|
|
19
19
|
import { dbAuditSpec, dbQuerySpec, dbRoleSpec, dbSchemaSpec } from "./db-tool.ts"
|
|
20
|
-
import { errorsSpec, logsSpec } from "./dev-feed-tool.ts"
|
|
20
|
+
import { errorsSpec, explainSpec, logsSpec } from "./dev-feed-tool.ts"
|
|
21
21
|
import { type Diagnostic, diagnostic, normalizeSeverity, toSarifLog } from "./diagnostics.ts"
|
|
22
22
|
import type { DoctorResult } from "./doctor.ts"
|
|
23
23
|
import { type I18nCheckOutput, i18nCheckPassed, renderI18nCheck } from "./i18n-check.ts"
|
|
@@ -367,6 +367,8 @@ interface MigrateInput {
|
|
|
367
367
|
readonly from?: "tailwind" | undefined
|
|
368
368
|
readonly to?: "stylex" | undefined
|
|
369
369
|
readonly write?: boolean | undefined
|
|
370
|
+
/** `migrate layout`: list the folders modules would leave in package.json zones instead. */
|
|
371
|
+
readonly zones?: boolean | undefined
|
|
370
372
|
readonly json?: boolean | undefined
|
|
371
373
|
readonly dir?: string | undefined
|
|
372
374
|
}
|
|
@@ -395,6 +397,7 @@ interface TypesInput {
|
|
|
395
397
|
|
|
396
398
|
interface SchemasInput {
|
|
397
399
|
readonly write?: boolean | undefined
|
|
400
|
+
readonly check?: boolean | undefined
|
|
398
401
|
readonly json?: boolean | undefined
|
|
399
402
|
readonly dir?: string | undefined
|
|
400
403
|
}
|
|
@@ -486,6 +489,8 @@ interface FixCommandOutput {
|
|
|
486
489
|
/** Recipes that refused, with the reason. A recipe that cannot act says so here instead of
|
|
487
490
|
* aborting the run or - worse - reporting nothing at all. */
|
|
488
491
|
readonly failed: readonly { readonly code: string; readonly reason: string }[]
|
|
492
|
+
/** Findings whose recipe runs only when its code is named, because its change needs review. */
|
|
493
|
+
readonly skipped: readonly { readonly code: string; readonly reason: string }[]
|
|
489
494
|
readonly diagnostics: readonly unknown[]
|
|
490
495
|
}
|
|
491
496
|
type MigrateCommandOutput =
|
|
@@ -751,13 +756,14 @@ const MIGRATE_SCHEMA = input<MigrateInput>(
|
|
|
751
756
|
from: { type: "string", enum: ["tailwind"] },
|
|
752
757
|
to: { type: "string", enum: ["stylex"] },
|
|
753
758
|
write: { type: "boolean" },
|
|
759
|
+
zones: { type: "boolean" },
|
|
754
760
|
json: { type: "boolean" },
|
|
755
761
|
dir: { type: "string" },
|
|
756
762
|
}),
|
|
757
763
|
(value) => {
|
|
758
764
|
const raw = withDir(record(value))
|
|
759
765
|
const flags = {
|
|
760
|
-
...parseBooleanFlags(raw, ["write", "json"]),
|
|
766
|
+
...parseBooleanFlags(raw, ["write", "zones", "json"]),
|
|
761
767
|
...(raw.dir === undefined ? {} : { dir: raw.dir }),
|
|
762
768
|
}
|
|
763
769
|
const kind = optionalString(raw.kind, "kind")
|
|
@@ -766,6 +772,7 @@ const MIGRATE_SCHEMA = input<MigrateInput>(
|
|
|
766
772
|
throw new TypeError("the migration must be `layout` (or --from tailwind --to stylex)")
|
|
767
773
|
return { kind, ...flags }
|
|
768
774
|
}
|
|
775
|
+
if (raw.zones === true) throw new TypeError("--zones applies to `migrate layout` only")
|
|
769
776
|
const from = optionalString(raw.from, "from")
|
|
770
777
|
const to = optionalString(raw.to, "to")
|
|
771
778
|
if (from !== "tailwind") throw new TypeError("from must be tailwind")
|
|
@@ -799,11 +806,16 @@ const TYPES_SCHEMA = input<TypesInput>(
|
|
|
799
806
|
)
|
|
800
807
|
|
|
801
808
|
const SCHEMAS_SCHEMA = input<SchemasInput>(
|
|
802
|
-
objectSchema({
|
|
809
|
+
objectSchema({
|
|
810
|
+
write: { type: "boolean" },
|
|
811
|
+
check: { type: "boolean" },
|
|
812
|
+
json: { type: "boolean" },
|
|
813
|
+
dir: { type: "string" },
|
|
814
|
+
}),
|
|
803
815
|
(value) => {
|
|
804
816
|
const raw = withDir(record(value))
|
|
805
817
|
return {
|
|
806
|
-
...parseBooleanFlags(raw, ["write", "json"]),
|
|
818
|
+
...parseBooleanFlags(raw, ["write", "check", "json"]),
|
|
807
819
|
...(raw.dir === undefined ? {} : { dir: raw.dir }),
|
|
808
820
|
}
|
|
809
821
|
},
|
|
@@ -1370,6 +1382,9 @@ const openApiSpec: CommandSpec<OpenApiInput, OpenApiCommandOutput> = {
|
|
|
1370
1382
|
json: (out) => (out.format === "json" ? JSON.parse(out.text) : out.text),
|
|
1371
1383
|
}
|
|
1372
1384
|
|
|
1385
|
+
// `render` cannot load doctor.ts, so each run's report is built beside its result.
|
|
1386
|
+
const doctorReports = new WeakMap<DoctorResult, readonly string[]>()
|
|
1387
|
+
|
|
1373
1388
|
const doctorSpec: CommandSpec<DoctorInput, DoctorResult> = {
|
|
1374
1389
|
name: "doctor",
|
|
1375
1390
|
summary: "Find undeclared imports, duplicate identity installs, and pipeline readiness drift.",
|
|
@@ -1397,14 +1412,18 @@ const doctorSpec: CommandSpec<DoctorInput, DoctorResult> = {
|
|
|
1397
1412
|
...(value.strict === undefined ? {} : { strict: value.strict }),
|
|
1398
1413
|
...(ctx.cliVersion === undefined ? {} : { cliVersion: ctx.cliVersion }),
|
|
1399
1414
|
}
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1415
|
+
const result =
|
|
1416
|
+
value.autoFix === true
|
|
1417
|
+
? await mod.applyDoctorAutoFix(ctx.cwd, options)
|
|
1418
|
+
: await mod.collectDoctorResult(ctx.cwd, options)
|
|
1419
|
+
doctorReports.set(result, mod.doctorReport(result, ctx.cliVersion))
|
|
1420
|
+
return result
|
|
1403
1421
|
},
|
|
1404
|
-
render: (out) =>
|
|
1405
|
-
out
|
|
1406
|
-
|
|
1407
|
-
|
|
1422
|
+
render: (out) =>
|
|
1423
|
+
doctorReports.get(out) ?? [
|
|
1424
|
+
out.ok ? "✓ doctor passed" : "✖ doctor found issues",
|
|
1425
|
+
...out.findings.map((f) => ` ${f.file}:${f.line} ${f.package}`),
|
|
1426
|
+
],
|
|
1408
1427
|
success: (out) => out.ok,
|
|
1409
1428
|
}
|
|
1410
1429
|
|
|
@@ -1418,6 +1437,7 @@ const fixSpec: CommandSpec<FixInput, FixCommandOutput> = {
|
|
|
1418
1437
|
ok: { type: "boolean" },
|
|
1419
1438
|
changed: { type: "array" },
|
|
1420
1439
|
failed: { type: "array" },
|
|
1440
|
+
skipped: { type: "array" },
|
|
1421
1441
|
diagnostics: { type: "array" },
|
|
1422
1442
|
},
|
|
1423
1443
|
required: ["ok", "diagnostics"],
|
|
@@ -1432,25 +1452,37 @@ const fixSpec: CommandSpec<FixInput, FixCommandOutput> = {
|
|
|
1432
1452
|
},
|
|
1433
1453
|
async run(value, ctx) {
|
|
1434
1454
|
const { collectCheckResult } = await import("./check.ts")
|
|
1435
|
-
const { applyDiagnosticRecipe } = await import("./fix-recipes.ts")
|
|
1455
|
+
const { applyDiagnosticRecipe, getFixRecipe } = await import("./fix-recipes.ts")
|
|
1436
1456
|
const result = await collectCheckResult(ctx.cwd, {
|
|
1437
1457
|
lintsOnly: true,
|
|
1438
1458
|
...(ctx.signal === undefined ? {} : { signal: ctx.signal }),
|
|
1439
1459
|
})
|
|
1440
1460
|
const changed: string[] = []
|
|
1441
1461
|
const failed: { code: string; reason: string }[] = []
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1462
|
+
const skipped: { code: string; reason: string }[] = []
|
|
1463
|
+
for (const diagnostic of result.structuredDiagnostics ?? []) {
|
|
1464
|
+
if (value.code !== undefined && diagnostic.code !== value.code) continue
|
|
1465
|
+
const recipe =
|
|
1466
|
+
diagnostic.fix?.recipe === undefined ? undefined : getFixRecipe(diagnostic.fix.recipe)
|
|
1467
|
+
if (value.code === undefined && recipe?.onlyWhenNamed === true) {
|
|
1468
|
+
if (!skipped.some((entry) => entry.code === diagnostic.code))
|
|
1469
|
+
skipped.push({
|
|
1450
1470
|
code: diagnostic.code,
|
|
1451
|
-
reason:
|
|
1471
|
+
reason: `${recipe.description} Review the finding, then run \`nifra fix --code ${diagnostic.code}\`.`,
|
|
1452
1472
|
})
|
|
1453
|
-
|
|
1473
|
+
continue
|
|
1474
|
+
}
|
|
1475
|
+
// One recipe that cannot act must not cancel the others, and must not pass silently either:
|
|
1476
|
+
// record why and keep going, so a run over many diagnostics still reports every outcome.
|
|
1477
|
+
try {
|
|
1478
|
+
changed.push(...(await applyDiagnosticRecipe(ctx.cwd, diagnostic)))
|
|
1479
|
+
} catch (error) {
|
|
1480
|
+
failed.push({
|
|
1481
|
+
code: diagnostic.code,
|
|
1482
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
1483
|
+
})
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1454
1486
|
const final = await collectCheckResult(ctx.cwd, {
|
|
1455
1487
|
lintsOnly: true,
|
|
1456
1488
|
...(ctx.signal === undefined ? {} : { signal: ctx.signal }),
|
|
@@ -1459,6 +1491,7 @@ const fixSpec: CommandSpec<FixInput, FixCommandOutput> = {
|
|
|
1459
1491
|
ok: final.ok,
|
|
1460
1492
|
changed,
|
|
1461
1493
|
failed,
|
|
1494
|
+
skipped,
|
|
1462
1495
|
diagnostics: final.structuredDiagnostics ?? final.diagnostics,
|
|
1463
1496
|
}
|
|
1464
1497
|
},
|
|
@@ -1466,6 +1499,7 @@ const fixSpec: CommandSpec<FixInput, FixCommandOutput> = {
|
|
|
1466
1499
|
out.ok ? "✓ fixes applied" : "✖ unresolved diagnostics remain",
|
|
1467
1500
|
...out.changed.map((file) => ` changed ${file}`),
|
|
1468
1501
|
...out.failed.map((f) => ` could not fix ${f.code}: ${f.reason}`),
|
|
1502
|
+
...out.skipped.map((s) => ` needs review ${s.code}: ${s.reason}`),
|
|
1469
1503
|
...out.diagnostics.map((d) => ` ${String((d as { code?: unknown }).code ?? "diagnostic")}`),
|
|
1470
1504
|
],
|
|
1471
1505
|
success: (out) => out.ok,
|
|
@@ -1493,6 +1527,7 @@ const migrateSpec: CommandSpec<MigrateInput, MigrateCommandOutput> = {
|
|
|
1493
1527
|
moves: { type: "array" },
|
|
1494
1528
|
rewritten: { type: "array" },
|
|
1495
1529
|
tooling: { type: "array" },
|
|
1530
|
+
followUps: { type: "array" },
|
|
1496
1531
|
mode: { type: "string" },
|
|
1497
1532
|
},
|
|
1498
1533
|
required: ["ok", "write", "issues"],
|
|
@@ -1505,6 +1540,7 @@ const migrateSpec: CommandSpec<MigrateInput, MigrateCommandOutput> = {
|
|
|
1505
1540
|
{ name: "from", field: "from", type: "string" },
|
|
1506
1541
|
{ name: "to", field: "to", type: "string" },
|
|
1507
1542
|
{ name: "write", field: "write", type: "boolean" },
|
|
1543
|
+
{ name: "zones", field: "zones", type: "boolean" },
|
|
1508
1544
|
{ name: "json", field: "json", type: "boolean" },
|
|
1509
1545
|
{ name: "dir", field: "dir", type: "string" },
|
|
1510
1546
|
],
|
|
@@ -1514,7 +1550,8 @@ const migrateSpec: CommandSpec<MigrateInput, MigrateCommandOutput> = {
|
|
|
1514
1550
|
const write = value.write === undefined ? {} : { write: value.write }
|
|
1515
1551
|
if (value.kind === "layout") {
|
|
1516
1552
|
const { migrateLayout } = await import("./migrate-layout.ts")
|
|
1517
|
-
|
|
1553
|
+
const options = { ...write, zones: value.zones === true }
|
|
1554
|
+
return { kind: "layout" as const, ...(await migrateLayout(dir, options)) }
|
|
1518
1555
|
}
|
|
1519
1556
|
const { migrateTailwindToStylex } = await import("./stylex-migrate.ts")
|
|
1520
1557
|
return migrateTailwindToStylex(dir, write)
|
|
@@ -1526,12 +1563,23 @@ const migrateSpec: CommandSpec<MigrateInput, MigrateCommandOutput> = {
|
|
|
1526
1563
|
? `✓ ${out.mode === "api" ? "API-only app" : `${out.splits.length} route file${out.splits.length === 1 ? "" : "s"} split`}, ${out.moves.length} file${out.moves.length === 1 ? "" : "s"} moved`
|
|
1527
1564
|
: `⚠ ${out.issues.length} issue${out.issues.length === 1 ? "" : "s"} need a decision; everything else is planned`,
|
|
1528
1565
|
...out.splits.map(
|
|
1529
|
-
(split) =>
|
|
1566
|
+
(split) =>
|
|
1567
|
+
` split ${split.file} → ${split.backend} (${split.moved.join(", ")})${split.shared === undefined ? "" : `, shared data → ${split.shared}`}`,
|
|
1530
1568
|
),
|
|
1531
1569
|
...out.moves.map((move) => ` move ${move.from} → ${move.to}`),
|
|
1532
1570
|
...out.rewritten.map((file) => ` edit ${file} (imports)`),
|
|
1533
1571
|
...out.tooling.map((edit) => ` edit ${edit.file} (${edit.change})`),
|
|
1572
|
+
...out.schemas
|
|
1573
|
+
.filter((entry) => entry.reason === undefined)
|
|
1574
|
+
.map(
|
|
1575
|
+
(entry) =>
|
|
1576
|
+
` draft ${entry.file} ${entry.schema} - review what it lets the browser see${entry.omitted === undefined ? "" : `; leaves out ${entry.omitted.join(", ")}`}${entry.open === undefined ? "" : `; admits any value at ${entry.open.join(", ")}, typed any or unknown`}`,
|
|
1577
|
+
),
|
|
1534
1578
|
...out.issues.map((issue) => ` ⚠ ${issue.file}: ${issue.reason}`),
|
|
1579
|
+
...out.followUps.map(
|
|
1580
|
+
(step) =>
|
|
1581
|
+
` next ${step.file}: ${step.reason}${step.command === undefined ? "" : ` - \`${step.command}\``}`,
|
|
1582
|
+
),
|
|
1535
1583
|
...(out.write ? [] : [" dry run: pass --write to apply"]),
|
|
1536
1584
|
]
|
|
1537
1585
|
}
|
|
@@ -1683,18 +1731,22 @@ const schemasSpec: CommandSpec<SchemasInput, OutputSchemasReport> = {
|
|
|
1683
1731
|
argv: {
|
|
1684
1732
|
flags: [
|
|
1685
1733
|
{ name: "write", field: "write", type: "boolean" },
|
|
1734
|
+
{ name: "check", field: "check", type: "boolean" },
|
|
1686
1735
|
{ name: "json", field: "json", type: "boolean" },
|
|
1687
1736
|
{ name: "dir", field: "dir", type: "string" },
|
|
1688
1737
|
],
|
|
1689
1738
|
},
|
|
1690
1739
|
async run(value, ctx) {
|
|
1691
1740
|
const { outputSchemas } = await import("./output-schemas.ts")
|
|
1692
|
-
return outputSchemas(resolve(ctx.cwd, value.dir ?? "."), {
|
|
1741
|
+
return outputSchemas(resolve(ctx.cwd, value.dir ?? "."), {
|
|
1742
|
+
write: value.write === true,
|
|
1743
|
+
check: value.check === true,
|
|
1744
|
+
})
|
|
1693
1745
|
},
|
|
1694
1746
|
render: (out) => {
|
|
1695
1747
|
const shown = out.entries.filter(
|
|
1696
1748
|
(entry) =>
|
|
1697
|
-
entry.status !== "current" &&
|
|
1749
|
+
(entry.status !== "current" || entry.open !== undefined) &&
|
|
1698
1750
|
entry.status !== "no-data" &&
|
|
1699
1751
|
(entry.status !== "declared" || entry.dropped.length > 0),
|
|
1700
1752
|
)
|
|
@@ -1709,8 +1761,19 @@ const schemasSpec: CommandSpec<SchemasInput, OutputSchemasReport> = {
|
|
|
1709
1761
|
? "edited by hand under its nifra:generated line"
|
|
1710
1762
|
: entry.dropped.length > 0
|
|
1711
1763
|
? `drops ${entry.dropped.join(", ")}`
|
|
1712
|
-
: undefined
|
|
1713
|
-
|
|
1764
|
+
: entry.omitted !== undefined
|
|
1765
|
+
? `leaves out ${entry.omitted.join(", ")}`
|
|
1766
|
+
: undefined)
|
|
1767
|
+
const open =
|
|
1768
|
+
entry.open === undefined
|
|
1769
|
+
? []
|
|
1770
|
+
: [
|
|
1771
|
+
` admits any value at ${entry.open.join(", ")}: the type there is any or unknown, so the output guard drops nothing below it`,
|
|
1772
|
+
]
|
|
1773
|
+
return [
|
|
1774
|
+
` ${SCHEMA_STATUS_LINE[entry.status]} ${entry.file}:${entry.line} ${entry.schema}${detail === undefined ? "" : ` - ${detail}`}`,
|
|
1775
|
+
...open,
|
|
1776
|
+
].join("\n")
|
|
1714
1777
|
}),
|
|
1715
1778
|
...(out.write || !out.entries.some((e) => e.status === "missing" || e.status === "stale")
|
|
1716
1779
|
? []
|
|
@@ -2020,6 +2083,7 @@ export const commandSpecs = Object.freeze([
|
|
|
2020
2083
|
portSpec,
|
|
2021
2084
|
i18nSpec,
|
|
2022
2085
|
errorsSpec,
|
|
2086
|
+
explainSpec,
|
|
2023
2087
|
logsSpec,
|
|
2024
2088
|
cdnCheckSpec,
|
|
2025
2089
|
dbSchemaSpec,
|
package/src/dev-bun-config.ts
CHANGED
|
@@ -221,12 +221,16 @@ function relativeSpecifier(fromDir: string, target: string): string {
|
|
|
221
221
|
* `singleCopy` is whether `package.json` declares `"nifra": { "singleCopy": [...] }`. The declared
|
|
222
222
|
* resolver then runs where `buildClient` runs it, after the zone guard; an app that also lists
|
|
223
223
|
* `singleCopyPlugin()` in `clientPlugins` gets its own instance in that place, once.
|
|
224
|
+
*
|
|
225
|
+
* `publicEnvPrefix` is the value `loadApp` resolved across both configs, written in as a literal:
|
|
226
|
+
* importing it from `configPath` would miss one set only in `backend/framework.ts`.
|
|
224
227
|
*/
|
|
225
228
|
export function renderBoundaryPluginModule(
|
|
226
229
|
configPath?: string,
|
|
227
230
|
pluginDir?: string,
|
|
228
231
|
servePlugins: readonly string[] = [],
|
|
229
232
|
singleCopy = false,
|
|
233
|
+
publicEnvPrefix?: string,
|
|
230
234
|
): string {
|
|
231
235
|
const appImport =
|
|
232
236
|
configPath !== undefined && pluginDir !== undefined
|
|
@@ -264,22 +268,18 @@ export function renderBoundaryPluginModule(
|
|
|
264
268
|
}
|
|
265
269
|
`
|
|
266
270
|
return `// Generated by \`nifra dev\` (Bun pipeline) - do not edit. Regenerated on every dev start.
|
|
267
|
-
import { serverFnStubPlugin, zoneGuardPlugin } from "@nifrajs/web/build"
|
|
271
|
+
import { importGlobPlugin, serverFnStubPlugin, zoneGuardPlugin } from "@nifrajs/web/build"
|
|
268
272
|
import { reserveDevSpecifiers } from "@nifrajs/web/internal/dev-reserved"
|
|
269
273
|
import { cssModulesBunPlugin } from "@nifrajs/web/plugins/css-modules"
|
|
270
274
|
${singleCopy ? 'import { singleCopyPlugin } from "@nifrajs/core/single-copy"\n' : ""}${appImport}
|
|
271
275
|
// This module lives at <app>/.nifra/dev-bun/, so the app root is two directories up.
|
|
272
276
|
const appRoot = Bun.fileURLToPath(new URL("../../", import.meta.url))
|
|
273
277
|
const zones = zoneGuardPlugin({
|
|
274
|
-
appRoot,${
|
|
275
|
-
appImport === ""
|
|
276
|
-
? ""
|
|
277
|
-
: `
|
|
278
|
-
...(typeof appConfig.publicEnvPrefix === "string" ? { publicEnvPrefix: appConfig.publicEnvPrefix } : {}),`
|
|
279
|
-
}
|
|
278
|
+
appRoot,${publicEnvPrefix === undefined ? "" : `\n publicEnvPrefix: ${JSON.stringify(publicEnvPrefix)},`}
|
|
280
279
|
})
|
|
281
280
|
const fn = serverFnStubPlugin()
|
|
282
281
|
const cssModules = cssModulesBunPlugin("dom")
|
|
282
|
+
const globs = importGlobPlugin({ root: appRoot })
|
|
283
283
|
|
|
284
284
|
export default {
|
|
285
285
|
name: "nifra-dev-boundary",
|
|
@@ -292,7 +292,9 @@ ${singleCopy ? appPluginsSetup : ""} // Boundary first: an app plugin must ne
|
|
|
292
292
|
zones.setup(guarded)
|
|
293
293
|
${singleCopySetup} fn.setup(guarded)
|
|
294
294
|
cssModules.setup(guarded)
|
|
295
|
-
${appSetup}${serveSetup}
|
|
295
|
+
${appSetup}${serveSetup} // Last, as in buildClient: a module another plugin loads is that plugin's.
|
|
296
|
+
globs.setup(guarded)
|
|
297
|
+
},
|
|
296
298
|
}
|
|
297
299
|
`
|
|
298
300
|
}
|
|
@@ -308,11 +310,12 @@ const TOKEN_FILE = "launch-token"
|
|
|
308
310
|
/** Write the generated config for an app; returns the bunfig path to re-exec with and the fresh
|
|
309
311
|
* launch token to pass in the child's environment. `configPath` (the app's `nifra.config.ts` /
|
|
310
312
|
* `backend/framework.ts`) is what lets the app's own `clientPlugins` reach Bun's dev-server
|
|
311
|
-
* bundler; `define`
|
|
313
|
+
* bundler; `define` and `publicEnvPrefix` are the loaded config's own. */
|
|
312
314
|
export async function writeBunDevConfig(
|
|
313
315
|
appRoot: string,
|
|
314
316
|
configPath?: string,
|
|
315
317
|
define?: Readonly<Record<string, string>>,
|
|
318
|
+
publicEnvPrefix?: string,
|
|
316
319
|
): Promise<BunDevConfig> {
|
|
317
320
|
const dir = resolve(appRoot, ".nifra", "dev-bun")
|
|
318
321
|
mkdirSync(dir, { recursive: true })
|
|
@@ -328,6 +331,7 @@ export async function writeBunDevConfig(
|
|
|
328
331
|
dir,
|
|
329
332
|
userServePlugins(user, appRoot),
|
|
330
333
|
readSingleCopyDeclaration(appRoot) !== undefined,
|
|
334
|
+
publicEnvPrefix,
|
|
331
335
|
),
|
|
332
336
|
)
|
|
333
337
|
const bunfigPath = resolve(dir, "bunfig.toml")
|
package/src/dev-feed-tool.ts
CHANGED
|
@@ -18,6 +18,13 @@ import type {
|
|
|
18
18
|
import type { Diagnostic } from "@nifrajs/web/diagnostic"
|
|
19
19
|
import type { CommandCtx, CommandSpec } from "./command-catalog.ts"
|
|
20
20
|
import type { DevServerLookup, LiveDevServer } from "./dev-server-client.ts"
|
|
21
|
+
import {
|
|
22
|
+
isRuleExplanation,
|
|
23
|
+
RULE_CODE_SHAPE,
|
|
24
|
+
type RuleExplainOutput,
|
|
25
|
+
renderRuleExplanation,
|
|
26
|
+
type UnknownRuleOutput,
|
|
27
|
+
} from "./rule-explain.ts"
|
|
21
28
|
|
|
22
29
|
const CATEGORIES: readonly DevErrorCategory[] = [
|
|
23
30
|
"ssr",
|
|
@@ -793,6 +800,144 @@ export const logsSpec: CommandSpec<LogsInput, LogsOutput> = {
|
|
|
793
800
|
json: (out) => out,
|
|
794
801
|
}
|
|
795
802
|
|
|
803
|
+
export interface ExplainInput {
|
|
804
|
+
readonly error?: string | undefined
|
|
805
|
+
readonly stack?: string | undefined
|
|
806
|
+
readonly name?: string | undefined
|
|
807
|
+
readonly port?: number | undefined
|
|
808
|
+
readonly dir?: string | undefined
|
|
809
|
+
readonly json?: boolean | undefined
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
/** A diagnostic, a rule code's catalog entry, or why there was nothing to explain. */
|
|
813
|
+
export type ExplainOutput =
|
|
814
|
+
| (Diagnostic & { readonly entry?: object; readonly note?: string })
|
|
815
|
+
| RuleExplainOutput
|
|
816
|
+
| UnknownRuleOutput
|
|
817
|
+
| { code: "NIFRA_NONE"; message: string }
|
|
818
|
+
|
|
819
|
+
const isRuleOutput = (out: ExplainOutput): out is RuleExplainOutput =>
|
|
820
|
+
"kind" in out && out.kind === "rule"
|
|
821
|
+
const explained = (out: ExplainOutput): out is Diagnostic =>
|
|
822
|
+
out.code !== "NIFRA_NONE" && out.code !== "NIFRA_UNKNOWN_RULE" && !isRuleOutput(out)
|
|
823
|
+
|
|
824
|
+
export const explainSpec: CommandSpec<ExplainInput, ExplainOutput> = {
|
|
825
|
+
name: "explain",
|
|
826
|
+
summary:
|
|
827
|
+
"Turn an error into a structured diagnostic: its code, the frame in your source with a codeframe, and the cause and fix when nifra recognises it. With no message, the running dev server's latest error. A rule code such as NF-C007 explains that rule.",
|
|
828
|
+
input: {
|
|
829
|
+
jsonSchema: {
|
|
830
|
+
type: "object",
|
|
831
|
+
properties: {
|
|
832
|
+
error: {
|
|
833
|
+
type: "string",
|
|
834
|
+
description: "The error message to explain, or a rule code such as NF-C007.",
|
|
835
|
+
},
|
|
836
|
+
stack: {
|
|
837
|
+
type: "string",
|
|
838
|
+
description: "Its stack trace, for the codeframe and source frame.",
|
|
839
|
+
},
|
|
840
|
+
name: { type: "string", description: "Its class name, such as TypeError." },
|
|
841
|
+
port: SHARED_PROPERTIES.port,
|
|
842
|
+
dir: { type: "string", description: "The app directory." },
|
|
843
|
+
json: { type: "boolean" },
|
|
844
|
+
},
|
|
845
|
+
additionalProperties: false,
|
|
846
|
+
},
|
|
847
|
+
parse: (value) => {
|
|
848
|
+
const raw = fields(value)
|
|
849
|
+
return {
|
|
850
|
+
error: text(raw, "error"),
|
|
851
|
+
stack: text(raw, "stack"),
|
|
852
|
+
name: text(raw, "name"),
|
|
853
|
+
port: count(raw, "port"),
|
|
854
|
+
dir: text(raw, "dir"),
|
|
855
|
+
json: flag(raw, "json"),
|
|
856
|
+
}
|
|
857
|
+
},
|
|
858
|
+
},
|
|
859
|
+
output: {
|
|
860
|
+
version: 1,
|
|
861
|
+
jsonSchema: {
|
|
862
|
+
type: "object",
|
|
863
|
+
properties: { code: { type: "string" }, message: { type: "string" } },
|
|
864
|
+
required: ["code", "message"],
|
|
865
|
+
},
|
|
866
|
+
parse: (value) => {
|
|
867
|
+
if (isRuleExplanation(value)) return value
|
|
868
|
+
if (isDiagnostic(value)) return value
|
|
869
|
+
if (
|
|
870
|
+
typeof value === "object" &&
|
|
871
|
+
value !== null &&
|
|
872
|
+
"code" in value &&
|
|
873
|
+
value.code === "NIFRA_UNKNOWN_RULE" &&
|
|
874
|
+
"message" in value &&
|
|
875
|
+
typeof value.message === "string"
|
|
876
|
+
)
|
|
877
|
+
return { code: "NIFRA_UNKNOWN_RULE", message: value.message }
|
|
878
|
+
if (
|
|
879
|
+
typeof value === "object" &&
|
|
880
|
+
value !== null &&
|
|
881
|
+
"code" in value &&
|
|
882
|
+
value.code === "NIFRA_NONE" &&
|
|
883
|
+
"message" in value &&
|
|
884
|
+
typeof value.message === "string"
|
|
885
|
+
)
|
|
886
|
+
return { code: "NIFRA_NONE", message: value.message }
|
|
887
|
+
throw new TypeError(
|
|
888
|
+
"explain output must be a diagnostic, a rule explanation, NIFRA_UNKNOWN_RULE or NIFRA_NONE",
|
|
889
|
+
)
|
|
890
|
+
},
|
|
891
|
+
},
|
|
892
|
+
transports: ["cli"],
|
|
893
|
+
stability: "experimental",
|
|
894
|
+
argv: {
|
|
895
|
+
positionals: ["error"],
|
|
896
|
+
flags: [
|
|
897
|
+
{ name: "stack", field: "stack", type: "string" },
|
|
898
|
+
{ name: "name", field: "name", type: "string" },
|
|
899
|
+
{ name: "port", field: "port", type: "number" },
|
|
900
|
+
{ name: "dir", field: "dir", type: "string" },
|
|
901
|
+
{ name: "json", field: "json", type: "boolean" },
|
|
902
|
+
],
|
|
903
|
+
},
|
|
904
|
+
async run(input, ctx) {
|
|
905
|
+
const code = input.error?.trim()
|
|
906
|
+
if (input.stack === undefined && code !== undefined && RULE_CODE_SHAPE.test(code)) {
|
|
907
|
+
const { explainRule } = await import("./rule-explain.ts")
|
|
908
|
+
return explainRule(code)
|
|
909
|
+
}
|
|
910
|
+
const root = resolve(ctx.cwd, input.dir ?? ".")
|
|
911
|
+
if (input.error === undefined && input.stack === undefined) {
|
|
912
|
+
return explainLatest(root, input.port, ctx.signal)
|
|
913
|
+
}
|
|
914
|
+
const { buildDiagnostic } = await import("@nifrajs/web/diagnostic")
|
|
915
|
+
const { explainSourceGate } = await import("./mcp-exec.ts")
|
|
916
|
+
const error = new Error(input.error ?? "")
|
|
917
|
+
if (input.name !== undefined) error.name = input.name
|
|
918
|
+
// Without --stack the frames would be this command's own, not the app's.
|
|
919
|
+
error.stack = input.stack ?? `${error.name}: ${error.message}`
|
|
920
|
+
return buildDiagnostic(error, { root, showSource: explainSourceGate(root) })
|
|
921
|
+
},
|
|
922
|
+
render: (out) => {
|
|
923
|
+
if (isRuleOutput(out)) return renderRuleExplanation(out)
|
|
924
|
+
if (!explained(out)) return [out.message]
|
|
925
|
+
const at = topFrame(out)
|
|
926
|
+
return [
|
|
927
|
+
`${out.code} ${headline(out)}`,
|
|
928
|
+
...(at === undefined ? [] : [` at ${at}`]),
|
|
929
|
+
...(out.codeframe?.lines ?? []).map(
|
|
930
|
+
(line) => ` ${line.caret ? ">" : " "} ${String(line.number).padStart(4)} | ${line.text}`,
|
|
931
|
+
),
|
|
932
|
+
...(out.cause === undefined ? [] : [` cause: ${out.cause}`]),
|
|
933
|
+
...(out.fix === undefined ? [] : [` fix: ${out.fix}`]),
|
|
934
|
+
]
|
|
935
|
+
},
|
|
936
|
+
exitCode: (out) =>
|
|
937
|
+
explained(out) || isRuleOutput(out) ? 0 : out.code === "NIFRA_UNKNOWN_RULE" ? 1 : 2,
|
|
938
|
+
json: (out) => out,
|
|
939
|
+
}
|
|
940
|
+
|
|
796
941
|
// ---------------------------------------------------------------------------------------------------
|
|
797
942
|
// nifra_explain / nifra_inspect reads
|
|
798
943
|
// ---------------------------------------------------------------------------------------------------
|
|
@@ -802,7 +947,7 @@ export async function explainLatest(
|
|
|
802
947
|
cwd: string,
|
|
803
948
|
port: number | undefined,
|
|
804
949
|
signal?: AbortSignal,
|
|
805
|
-
): Promise<
|
|
950
|
+
): Promise<ExplainOutput> {
|
|
806
951
|
const { findDevServer, describeLookup, readDevFeed } = await import("./dev-server-client.ts")
|
|
807
952
|
const lookup = await findDevServer(cwd, { port }, signal)
|
|
808
953
|
if (lookup.status === "live") {
|