@stsepelin/checktrail 0.1.0-alpha.1
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/CONTRIBUTING.md +42 -0
- package/LICENSE +21 -0
- package/README.md +355 -0
- package/SECURITY.md +46 -0
- package/dist/src/actionlint-evidence.d.ts +2 -0
- package/dist/src/actionlint-evidence.js +166 -0
- package/dist/src/actionlint-inputs.d.ts +5 -0
- package/dist/src/actionlint-inputs.js +123 -0
- package/dist/src/actionlint-runner.d.ts +1 -0
- package/dist/src/actionlint-runner.js +122 -0
- package/dist/src/actionlint.d.ts +19 -0
- package/dist/src/actionlint.js +80 -0
- package/dist/src/adapters.d.ts +49 -0
- package/dist/src/adapters.js +430 -0
- package/dist/src/architecture.d.ts +107 -0
- package/dist/src/architecture.js +230 -0
- package/dist/src/clang-evidence.d.ts +2 -0
- package/dist/src/clang-evidence.js +194 -0
- package/dist/src/clang-protocol.d.ts +3 -0
- package/dist/src/clang-protocol.js +25 -0
- package/dist/src/clang-runner.d.ts +1 -0
- package/dist/src/clang-runner.js +159 -0
- package/dist/src/clang.d.ts +44 -0
- package/dist/src/clang.js +197 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +338 -0
- package/dist/src/config.d.ts +33 -0
- package/dist/src/config.js +140 -0
- package/dist/src/contract-schema.d.ts +85 -0
- package/dist/src/contract-schema.js +56 -0
- package/dist/src/contract-worker.d.ts +1 -0
- package/dist/src/contract-worker.js +123 -0
- package/dist/src/contracts.d.ts +22 -0
- package/dist/src/contracts.js +123 -0
- package/dist/src/django-evidence.d.ts +2 -0
- package/dist/src/django-evidence.js +100 -0
- package/dist/src/django-runner.d.ts +1 -0
- package/dist/src/django-runner.js +80 -0
- package/dist/src/django.d.ts +9 -0
- package/dist/src/django.js +50 -0
- package/dist/src/dotnet-compiler.d.ts +1 -0
- package/dist/src/dotnet-compiler.js +87 -0
- package/dist/src/dotnet-evidence.d.ts +2 -0
- package/dist/src/dotnet-evidence.js +127 -0
- package/dist/src/dotnet-runner.d.ts +1 -0
- package/dist/src/dotnet-runner.js +167 -0
- package/dist/src/dotnet.d.ts +65 -0
- package/dist/src/dotnet.js +120 -0
- package/dist/src/engine.d.ts +19 -0
- package/dist/src/engine.js +239 -0
- package/dist/src/environment.d.ts +6 -0
- package/dist/src/environment.js +36 -0
- package/dist/src/eslint-evidence.d.ts +2 -0
- package/dist/src/eslint-evidence.js +98 -0
- package/dist/src/eslint-runner.d.ts +1 -0
- package/dist/src/eslint-runner.js +61 -0
- package/dist/src/eslint.d.ts +2 -0
- package/dist/src/eslint.js +40 -0
- package/dist/src/evidence.d.ts +2 -0
- package/dist/src/evidence.js +313 -0
- package/dist/src/external-adapter.d.ts +164 -0
- package/dist/src/external-adapter.js +265 -0
- package/dist/src/external-evidence.d.ts +2 -0
- package/dist/src/external-evidence.js +127 -0
- package/dist/src/external-runner.d.ts +1 -0
- package/dist/src/external-runner.js +122 -0
- package/dist/src/fastapi-evidence.d.ts +2 -0
- package/dist/src/fastapi-evidence.js +126 -0
- package/dist/src/fastapi-runner.d.ts +1 -0
- package/dist/src/fastapi-runner.js +84 -0
- package/dist/src/fastapi.d.ts +10 -0
- package/dist/src/fastapi.js +52 -0
- package/dist/src/fetch-pack.d.ts +16 -0
- package/dist/src/fetch-pack.js +154 -0
- package/dist/src/finding-policy-schema.d.ts +146 -0
- package/dist/src/finding-policy-schema.js +70 -0
- package/dist/src/finding-policy.d.ts +62 -0
- package/dist/src/finding-policy.js +206 -0
- package/dist/src/git-selection.d.ts +3 -0
- package/dist/src/git-selection.js +229 -0
- package/dist/src/go-directives.d.ts +1 -0
- package/dist/src/go-directives.js +32 -0
- package/dist/src/go-scope.d.ts +11 -0
- package/dist/src/go-scope.js +122 -0
- package/dist/src/golangci-evidence.d.ts +2 -0
- package/dist/src/golangci-evidence.js +92 -0
- package/dist/src/golangci-runner.d.ts +1 -0
- package/dist/src/golangci-runner.js +124 -0
- package/dist/src/golangci.d.ts +2 -0
- package/dist/src/golangci.js +35 -0
- package/dist/src/guidance.d.ts +98 -0
- package/dist/src/guidance.js +247 -0
- package/dist/src/index.d.ts +31 -0
- package/dist/src/index.js +16 -0
- package/dist/src/inventory.d.ts +4 -0
- package/dist/src/inventory.js +94 -0
- package/dist/src/java-compiler.d.ts +1 -0
- package/dist/src/java-compiler.js +110 -0
- package/dist/src/java-evidence.d.ts +2 -0
- package/dist/src/java-evidence.js +114 -0
- package/dist/src/java-runner.d.ts +1 -0
- package/dist/src/java-runner.js +79 -0
- package/dist/src/java.d.ts +25 -0
- package/dist/src/java.js +102 -0
- package/dist/src/jest-evidence.d.ts +2 -0
- package/dist/src/jest-evidence.js +117 -0
- package/dist/src/jest-runner.d.ts +1 -0
- package/dist/src/jest-runner.js +46 -0
- package/dist/src/jest.d.ts +2 -0
- package/dist/src/jest.js +36 -0
- package/dist/src/junit.d.ts +18 -0
- package/dist/src/junit.js +157 -0
- package/dist/src/laravel-evidence.d.ts +2 -0
- package/dist/src/laravel-evidence.js +175 -0
- package/dist/src/laravel-runner.d.ts +1 -0
- package/dist/src/laravel-runner.js +168 -0
- package/dist/src/laravel.d.ts +8 -0
- package/dist/src/laravel.js +50 -0
- package/dist/src/local-tool.d.ts +1 -0
- package/dist/src/local-tool.js +19 -0
- package/dist/src/mcp.d.ts +14 -0
- package/dist/src/mcp.js +362 -0
- package/dist/src/mutation.d.ts +118 -0
- package/dist/src/mutation.js +370 -0
- package/dist/src/mypy-evidence.d.ts +2 -0
- package/dist/src/mypy-evidence.js +63 -0
- package/dist/src/mypy.d.ts +2 -0
- package/dist/src/mypy.js +59 -0
- package/dist/src/node-reporter.d.ts +1 -0
- package/dist/src/node-reporter.js +28 -0
- package/dist/src/nuxt-evidence.d.ts +2 -0
- package/dist/src/nuxt-evidence.js +160 -0
- package/dist/src/nuxt-protocol.d.ts +52 -0
- package/dist/src/nuxt-protocol.js +29 -0
- package/dist/src/nuxt-runner.d.ts +1 -0
- package/dist/src/nuxt-runner.js +165 -0
- package/dist/src/nuxt.d.ts +24 -0
- package/dist/src/nuxt.js +105 -0
- package/dist/src/output.d.ts +3 -0
- package/dist/src/output.js +48 -0
- package/dist/src/phpstan-evidence.d.ts +2 -0
- package/dist/src/phpstan-evidence.js +81 -0
- package/dist/src/phpstan.d.ts +2 -0
- package/dist/src/phpstan.js +51 -0
- package/dist/src/phpunit-evidence.d.ts +2 -0
- package/dist/src/phpunit-evidence.js +53 -0
- package/dist/src/phpunit.d.ts +2 -0
- package/dist/src/phpunit.js +58 -0
- package/dist/src/pint-evidence.d.ts +2 -0
- package/dist/src/pint-evidence.js +79 -0
- package/dist/src/pint-runner.d.ts +1 -0
- package/dist/src/pint-runner.js +53 -0
- package/dist/src/pint.d.ts +2 -0
- package/dist/src/pint.js +37 -0
- package/dist/src/playwright-evidence.d.ts +2 -0
- package/dist/src/playwright-evidence.js +127 -0
- package/dist/src/playwright-reporter.d.ts +10 -0
- package/dist/src/playwright-reporter.js +37 -0
- package/dist/src/playwright-runner.d.ts +1 -0
- package/dist/src/playwright-runner.js +61 -0
- package/dist/src/playwright.d.ts +2 -0
- package/dist/src/playwright.js +35 -0
- package/dist/src/policy-pack.d.ts +21 -0
- package/dist/src/policy-pack.js +41 -0
- package/dist/src/pytest-evidence.d.ts +2 -0
- package/dist/src/pytest-evidence.js +116 -0
- package/dist/src/pytest-runner.d.ts +1 -0
- package/dist/src/pytest-runner.js +48 -0
- package/dist/src/pytest.d.ts +2 -0
- package/dist/src/pytest.js +25 -0
- package/dist/src/report-validation.d.ts +129 -0
- package/dist/src/report-validation.js +27 -0
- package/dist/src/review.d.ts +270 -0
- package/dist/src/review.js +349 -0
- package/dist/src/ruby.d.ts +2 -0
- package/dist/src/ruby.js +25 -0
- package/dist/src/ruff-evidence.d.ts +2 -0
- package/dist/src/ruff-evidence.js +99 -0
- package/dist/src/ruff.d.ts +2 -0
- package/dist/src/ruff.js +40 -0
- package/dist/src/runner.d.ts +8 -0
- package/dist/src/runner.js +117 -0
- package/dist/src/runtime-inventory.d.ts +112 -0
- package/dist/src/runtime-inventory.js +200 -0
- package/dist/src/rust-dep-info.d.ts +1 -0
- package/dist/src/rust-dep-info.js +46 -0
- package/dist/src/rust-evidence.d.ts +2 -0
- package/dist/src/rust-evidence.js +157 -0
- package/dist/src/rust-runner.d.ts +1 -0
- package/dist/src/rust-runner.js +161 -0
- package/dist/src/rust.d.ts +7 -0
- package/dist/src/rust.js +39 -0
- package/dist/src/sarif.d.ts +86 -0
- package/dist/src/sarif.js +113 -0
- package/dist/src/schemas.d.ts +393 -0
- package/dist/src/schemas.js +222 -0
- package/dist/src/staticcheck-evidence.d.ts +2 -0
- package/dist/src/staticcheck-evidence.js +75 -0
- package/dist/src/swift.d.ts +2 -0
- package/dist/src/swift.js +20 -0
- package/dist/src/task-store.d.ts +37 -0
- package/dist/src/task-store.js +349 -0
- package/dist/src/tool-versions.d.ts +3 -0
- package/dist/src/tool-versions.js +260 -0
- package/dist/src/types.d.ts +157 -0
- package/dist/src/types.js +37 -0
- package/dist/src/typescript-build-evidence.d.ts +2 -0
- package/dist/src/typescript-build-evidence.js +86 -0
- package/dist/src/typescript-build-runner.d.ts +1 -0
- package/dist/src/typescript-build-runner.js +132 -0
- package/dist/src/typescript-build.d.ts +2 -0
- package/dist/src/typescript-build.js +41 -0
- package/dist/src/typescript.d.ts +2 -0
- package/dist/src/typescript.js +54 -0
- package/dist/src/validation-task-worker.d.ts +1 -0
- package/dist/src/validation-task-worker.js +205 -0
- package/dist/src/validation-tasks-protocol.d.ts +69 -0
- package/dist/src/validation-tasks-protocol.js +57 -0
- package/dist/src/validation-tasks.d.ts +11 -0
- package/dist/src/validation-tasks.js +144 -0
- package/dist/src/vitest-evidence.d.ts +2 -0
- package/dist/src/vitest-evidence.js +112 -0
- package/dist/src/vitest-runner.d.ts +1 -0
- package/dist/src/vitest-runner.js +48 -0
- package/dist/src/vitest.d.ts +2 -0
- package/dist/src/vitest.js +36 -0
- package/dist/src/vue-router-capture.d.ts +42 -0
- package/dist/src/vue-router-capture.js +87 -0
- package/dist/src/vue-router-evidence.d.ts +2 -0
- package/dist/src/vue-router-evidence.js +126 -0
- package/dist/src/vue-router-protocol.d.ts +63 -0
- package/dist/src/vue-router-protocol.js +44 -0
- package/dist/src/vue-router-runner.d.ts +1 -0
- package/dist/src/vue-router-runner.js +88 -0
- package/dist/src/vue-router.d.ts +23 -0
- package/dist/src/vue-router.js +108 -0
- package/dist/src/vue-tsc-runner.d.ts +1 -0
- package/dist/src/vue-tsc-runner.js +24 -0
- package/dist/src/workspace.d.ts +7 -0
- package/dist/src/workspace.js +53 -0
- package/docs/ACCEPTANCE.md +56 -0
- package/docs/ACTIONLINT.md +112 -0
- package/docs/ARCHITECTURE-POLICY.md +82 -0
- package/docs/ARCHITECTURE.md +122 -0
- package/docs/CLANG.md +113 -0
- package/docs/CLIENTS.md +109 -0
- package/docs/CONTRACTS.md +73 -0
- package/docs/DEPENDENCIES.md +42 -0
- package/docs/DJANGO.md +70 -0
- package/docs/DOTNET.md +114 -0
- package/docs/ENVIRONMENTS.md +52 -0
- package/docs/ESLINT.md +68 -0
- package/docs/EVALUATION.md +124 -0
- package/docs/EXECUTION.md +250 -0
- package/docs/EXTERNAL-ADAPTERS.md +170 -0
- package/docs/EXTERNAL-EVALUATION.md +155 -0
- package/docs/EXTERNAL-RUFF-EVALUATION.md +85 -0
- package/docs/FASTAPI.md +73 -0
- package/docs/FINDING-POLICY.md +67 -0
- package/docs/GO-RACE.md +19 -0
- package/docs/GO-SCOPE.md +63 -0
- package/docs/GOLANGCI-LINT.md +64 -0
- package/docs/GUIDANCE.md +46 -0
- package/docs/IMPACT-MEASUREMENT.md +97 -0
- package/docs/INSTALLATION.md +102 -0
- package/docs/JAVA.md +79 -0
- package/docs/JEST.md +36 -0
- package/docs/JUNIT.md +31 -0
- package/docs/LANGUAGES.md +113 -0
- package/docs/LARAVEL.md +111 -0
- package/docs/MCP-COMPATIBILITY.md +68 -0
- package/docs/MUTATIONS.md +93 -0
- package/docs/MYPY.md +37 -0
- package/docs/NATIVE-CI.md +96 -0
- package/docs/NUXT.md +123 -0
- package/docs/PACK-DISTRIBUTION.md +98 -0
- package/docs/PERFORMANCE.md +71 -0
- package/docs/PEST.md +36 -0
- package/docs/PHPSTAN.md +48 -0
- package/docs/PHPUNIT.md +32 -0
- package/docs/PINT.md +41 -0
- package/docs/PLAN.md +265 -0
- package/docs/PLAYWRIGHT.md +73 -0
- package/docs/POLICY-PACKS.md +106 -0
- package/docs/PRIOR-WORKFLOW-EVALUATION.md +116 -0
- package/docs/PUBLICATION.md +28 -0
- package/docs/PYTEST.md +51 -0
- package/docs/RELEASE.md +115 -0
- package/docs/RENAMING.md +55 -0
- package/docs/REVIEW-EXCHANGE.md +136 -0
- package/docs/RUBY.md +50 -0
- package/docs/RUFF.md +39 -0
- package/docs/RUNTIME-INVENTORY.md +56 -0
- package/docs/RUST.md +74 -0
- package/docs/SARIF.md +64 -0
- package/docs/STATUS.md +530 -0
- package/docs/SWIFT.md +48 -0
- package/docs/TASK-STORAGE.md +141 -0
- package/docs/TOOL-IDENTITY.md +30 -0
- package/docs/TYPESCRIPT-BUILD.md +55 -0
- package/docs/VALIDATION-TASKS.md +119 -0
- package/docs/VITEST.md +36 -0
- package/docs/VUE-ROUTER.md +130 -0
- package/docs/VUE-TSC.md +26 -0
- package/docs/WORKSPACES.md +81 -0
- package/docs/licenses/nodable-entities-3.0.0.txt +21 -0
- package/docs/measurements/client-claude-before-schema-fix-darwin-arm64-node26.json +60 -0
- package/docs/measurements/client-claude-darwin-arm64-node26.json +55 -0
- package/docs/measurements/client-codex-darwin-arm64-node26.json +175 -0
- package/docs/measurements/evaluation-corpus-repo-verifier.json +332 -0
- package/docs/measurements/evaluation-darwin-arm64-node26.json +1236 -0
- package/docs/measurements/evaluation-linux-arm64-node22.json +1236 -0
- package/docs/measurements/external-eslint-darwin-arm64-node26.json +11866 -0
- package/docs/measurements/external-eslint-linux-arm64-node22.json +11866 -0
- package/docs/measurements/external-eslint-preservation.json +1527 -0
- package/docs/measurements/external-ruff-darwin-arm64-node26.json +1031 -0
- package/docs/measurements/external-ruff-linux-arm64-node22.json +1031 -0
- package/docs/measurements/hosted-ci-52ba415.json +1005 -0
- package/docs/measurements/impact-darwin-arm64-node26.json +6685 -0
- package/docs/measurements/impact-linux-arm64-node22.json +6690 -0
- package/docs/measurements/performance-darwin-arm64-node26.json +845 -0
- package/docs/measurements/performance-linux-arm64-node22.json +845 -0
- package/docs/measurements/required-native-profiles.json +500 -0
- package/package.json +72 -0
- package/packs/actionlint.json +8 -0
- package/packs/cpp.json +8 -0
- package/packs/dotnet.json +8 -0
- package/packs/go.json +7 -0
- package/packs/java.json +8 -0
- package/packs/javascript-node.json +7 -0
- package/packs/nuxt.json +7 -0
- package/packs/php-pest.json +7 -0
- package/packs/php-phpunit.json +7 -0
- package/packs/python-pytest.json +7 -0
- package/packs/ruby.json +7 -0
- package/packs/rust.json +7 -0
- package/packs/swift.json +7 -0
- package/packs/vue-router.json +7 -0
- package/packs/vue.json +11 -0
- package/schemas/actionlint-config.schema.json +19 -0
- package/schemas/architecture-policy.schema.json +51 -0
- package/schemas/architecture-report.schema.json +123 -0
- package/schemas/architecture-summary.schema.json +82 -0
- package/schemas/clang-database.schema.json +23 -0
- package/schemas/config.schema.json +69 -0
- package/schemas/contract-bundle.schema.json +78 -0
- package/schemas/contract-report.schema.json +114 -0
- package/schemas/contract-summary.schema.json +72 -0
- package/schemas/dependency-graph.schema.json +65 -0
- package/schemas/django-config.schema.json +16 -0
- package/schemas/dotnet-config.schema.json +60 -0
- package/schemas/external-manifest.schema.json +97 -0
- package/schemas/external-reference.schema.json +10 -0
- package/schemas/external-request.schema.json +56 -0
- package/schemas/external-result.schema.json +111 -0
- package/schemas/fastapi-config.schema.json +27 -0
- package/schemas/finding-baseline.schema.json +92 -0
- package/schemas/finding-comparison-summary.schema.json +95 -0
- package/schemas/finding-comparison.schema.json +121 -0
- package/schemas/guidance-context.schema.json +34 -0
- package/schemas/guidance-report.schema.json +176 -0
- package/schemas/guidance-summary.schema.json +68 -0
- package/schemas/java-config.schema.json +24 -0
- package/schemas/junit.schema.json +69 -0
- package/schemas/laravel-config.schema.json +11 -0
- package/schemas/mutation-recipe.schema.json +31 -0
- package/schemas/mutation-report.schema.json +238 -0
- package/schemas/mutation-summary.schema.json +98 -0
- package/schemas/nuxt-config.schema.json +51 -0
- package/schemas/plan-summary.schema.json +63 -0
- package/schemas/plan.schema.json +244 -0
- package/schemas/policy-pack.schema.json +41 -0
- package/schemas/report-summary.schema.json +100 -0
- package/schemas/report.schema.json +463 -0
- package/schemas/review-assessment.schema.json +133 -0
- package/schemas/review-context-summary.schema.json +31 -0
- package/schemas/review-context.schema.json +254 -0
- package/schemas/review-receipt-summary.schema.json +104 -0
- package/schemas/review-receipt.schema.json +271 -0
- package/schemas/review-selection.schema.json +30 -0
- package/schemas/runtime-comparison-summary.schema.json +68 -0
- package/schemas/runtime-comparison.schema.json +127 -0
- package/schemas/runtime-inventory.schema.json +99 -0
- package/schemas/vue-router-config.schema.json +67 -0
- package/server.json +47 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { nuxtConfigSchema, nuxtVersions } from "./nuxt.js";
|
|
5
|
+
import { nuxtResultSchema } from "./nuxt-protocol.js";
|
|
6
|
+
import { vueRouteAttributesSchema, vueRouteKey, } from "./vue-router-protocol.js";
|
|
7
|
+
export function nuxtEvidence(check, processes) {
|
|
8
|
+
const incomplete = {
|
|
9
|
+
status: "inconclusive",
|
|
10
|
+
reason: "Nuxt SSR capture, stable assembly or route participation evidence is incomplete.",
|
|
11
|
+
findingsComplete: false,
|
|
12
|
+
};
|
|
13
|
+
if (processes.length !== 1)
|
|
14
|
+
return incomplete;
|
|
15
|
+
const execution = processes[0];
|
|
16
|
+
if (execution.exitCode === 3) {
|
|
17
|
+
try {
|
|
18
|
+
z.strictObject({
|
|
19
|
+
unavailable: z.literal("nuxt-runtime"),
|
|
20
|
+
reason: z.literal("unsupported-version"),
|
|
21
|
+
}).parse(JSON.parse(execution.stdout));
|
|
22
|
+
return {
|
|
23
|
+
status: "unavailable",
|
|
24
|
+
reason: "The verified Nuxt runtime versions are not installed.",
|
|
25
|
+
findingsComplete: false,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return incomplete;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (execution.exitCode !== 0)
|
|
33
|
+
return {
|
|
34
|
+
status: "error",
|
|
35
|
+
reason: "Nuxt build or SSR capture failed.",
|
|
36
|
+
findingsComplete: false,
|
|
37
|
+
};
|
|
38
|
+
try {
|
|
39
|
+
const result = nuxtResultSchema.parse(JSON.parse(execution.stdout));
|
|
40
|
+
const config = nuxtConfigSchema.parse(JSON.parse(check.commands[0].args[3]));
|
|
41
|
+
if (result.sourceFingerprint !== check.commands[0].args[4] ||
|
|
42
|
+
result.probes.length !== config.probes.length ||
|
|
43
|
+
Object.keys(result.versions).length !==
|
|
44
|
+
Object.keys(nuxtVersions).length ||
|
|
45
|
+
Object.entries(nuxtVersions).some(([name, version]) => result.versions[name] !== version))
|
|
46
|
+
return incomplete;
|
|
47
|
+
const collection = result.runtime?.collections[0];
|
|
48
|
+
const entries = collection?.entries ?? [];
|
|
49
|
+
if (result.runtime) {
|
|
50
|
+
if (result.runtime.sourceFingerprint !== result.sourceFingerprint ||
|
|
51
|
+
result.runtime.producer.name !== "checktrail.nuxt" ||
|
|
52
|
+
result.runtime.producer.version !== "1.0.0" ||
|
|
53
|
+
result.runtime.assembly.name !== config.assembly ||
|
|
54
|
+
result.runtime.assembly.environment !== config.environment ||
|
|
55
|
+
result.runtime.collections.length !== 1 ||
|
|
56
|
+
collection?.kind !== "routes" ||
|
|
57
|
+
!collection.ordered ||
|
|
58
|
+
collection.complete !== (entries.length === result.totalRoutes) ||
|
|
59
|
+
result.indices.length !== entries.length ||
|
|
60
|
+
result.indices.some((value, index) => value >= result.totalRoutes ||
|
|
61
|
+
(index > 0 && value <= result.indices[index - 1])))
|
|
62
|
+
return incomplete;
|
|
63
|
+
const signature = createHash("sha256")
|
|
64
|
+
.update(JSON.stringify({
|
|
65
|
+
totalRoutes: result.totalRoutes,
|
|
66
|
+
indices: result.indices,
|
|
67
|
+
entries,
|
|
68
|
+
}))
|
|
69
|
+
.digest("hex");
|
|
70
|
+
if (result.signature !== signature)
|
|
71
|
+
return incomplete;
|
|
72
|
+
}
|
|
73
|
+
else if (result.totalRoutes ||
|
|
74
|
+
result.indices.length ||
|
|
75
|
+
result.signature !== null)
|
|
76
|
+
return incomplete;
|
|
77
|
+
const records = new Map();
|
|
78
|
+
for (const [offset, entry] of entries.entries()) {
|
|
79
|
+
const attributes = vueRouteAttributesSchema.parse(entry.attributes);
|
|
80
|
+
if (entry.key !== vueRouteKey(attributes))
|
|
81
|
+
return incomplete;
|
|
82
|
+
records.set(result.indices[offset], {
|
|
83
|
+
path: attributes.path,
|
|
84
|
+
name: attributes.name,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
const observed = new Set();
|
|
88
|
+
const findings = [];
|
|
89
|
+
let capturesComplete = Boolean(collection?.complete && result.totalRoutes);
|
|
90
|
+
for (const [index, probe] of result.probes.entries()) {
|
|
91
|
+
const expected = config.probes[index];
|
|
92
|
+
if (probe.path !== expected.path)
|
|
93
|
+
return incomplete;
|
|
94
|
+
const file = path.posix.join(check.project, "checktrail.nuxt.json");
|
|
95
|
+
if (probe.status !== 200)
|
|
96
|
+
findings.push({
|
|
97
|
+
ruleId: "nuxt/http-status",
|
|
98
|
+
level: "error",
|
|
99
|
+
file,
|
|
100
|
+
message: `SSR request ${probe.path} returned HTTP ${probe.status}, expected HTTP 200.`,
|
|
101
|
+
});
|
|
102
|
+
if (!probe.capture) {
|
|
103
|
+
capturesComplete = false;
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
const capture = probe.capture;
|
|
107
|
+
if (!result.runtime ||
|
|
108
|
+
capture.signature !== result.signature ||
|
|
109
|
+
capture.totalRoutes !== result.totalRoutes ||
|
|
110
|
+
capture.supportedRoutes !== entries.length)
|
|
111
|
+
capturesComplete = false;
|
|
112
|
+
if (capture.indices.length !== capture.matched.length)
|
|
113
|
+
return incomplete;
|
|
114
|
+
const nonnull = capture.indices.filter((value) => value !== null);
|
|
115
|
+
if (new Set(nonnull).size !== nonnull.length ||
|
|
116
|
+
nonnull.some((value) => value >= capture.totalRoutes))
|
|
117
|
+
return incomplete;
|
|
118
|
+
if (capture.signature === result.signature) {
|
|
119
|
+
for (const [offset, recordIndex] of capture.indices.entries()) {
|
|
120
|
+
if (recordIndex === null)
|
|
121
|
+
continue;
|
|
122
|
+
if (records.has(recordIndex) &&
|
|
123
|
+
JSON.stringify(records.get(recordIndex)) !==
|
|
124
|
+
JSON.stringify(capture.matched[offset]))
|
|
125
|
+
return incomplete;
|
|
126
|
+
observed.add(recordIndex);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (JSON.stringify(capture.matched) !== JSON.stringify(expected.matched))
|
|
130
|
+
findings.push({
|
|
131
|
+
ruleId: "nuxt/probe-mismatch",
|
|
132
|
+
level: "error",
|
|
133
|
+
file,
|
|
134
|
+
message: `SSR request ${probe.path} did not render its declared matched route chain.`,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
const complete = capturesComplete && observed.size === result.totalRoutes;
|
|
138
|
+
const evidence = {
|
|
139
|
+
...(result.runtime ? { runtime: result.runtime } : {}),
|
|
140
|
+
findings,
|
|
141
|
+
findingsComplete: complete,
|
|
142
|
+
};
|
|
143
|
+
if (findings.length)
|
|
144
|
+
return {
|
|
145
|
+
...evidence,
|
|
146
|
+
status: "failed",
|
|
147
|
+
reason: "Nuxt SSR requests differ from the declared route contract.",
|
|
148
|
+
};
|
|
149
|
+
if (!complete)
|
|
150
|
+
return { ...evidence, ...incomplete };
|
|
151
|
+
return {
|
|
152
|
+
...evidence,
|
|
153
|
+
status: "passed",
|
|
154
|
+
reason: "Every native route participated in a successful SSR request and all matched chains agreed with the declared contract.",
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
return incomplete;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const nuxtResultSchema: z.ZodObject<{
|
|
3
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
4
|
+
versions: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
5
|
+
sourceFingerprint: z.ZodString;
|
|
6
|
+
runtime: z.ZodNullable<z.ZodObject<{
|
|
7
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
8
|
+
format: z.ZodLiteral<"runtime-inventory">;
|
|
9
|
+
producer: z.ZodObject<{
|
|
10
|
+
name: z.ZodString;
|
|
11
|
+
version: z.ZodString;
|
|
12
|
+
}, z.core.$strict>;
|
|
13
|
+
assembly: z.ZodObject<{
|
|
14
|
+
name: z.ZodString;
|
|
15
|
+
environment: z.ZodString;
|
|
16
|
+
}, z.core.$strict>;
|
|
17
|
+
sourceFingerprint: z.ZodString;
|
|
18
|
+
capturedAt: z.ZodISODateTime;
|
|
19
|
+
collections: z.ZodArray<z.ZodObject<{
|
|
20
|
+
kind: z.ZodEnum<{
|
|
21
|
+
routes: "routes";
|
|
22
|
+
listeners: "listeners";
|
|
23
|
+
middleware: "middleware";
|
|
24
|
+
schedules: "schedules";
|
|
25
|
+
bindings: "bindings";
|
|
26
|
+
}>;
|
|
27
|
+
complete: z.ZodBoolean;
|
|
28
|
+
ordered: z.ZodBoolean;
|
|
29
|
+
entries: z.ZodArray<z.ZodObject<{
|
|
30
|
+
key: z.ZodString;
|
|
31
|
+
attributes: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodArray<z.ZodString>]>>;
|
|
32
|
+
}, z.core.$strict>>;
|
|
33
|
+
}, z.core.$strict>>;
|
|
34
|
+
}, z.core.$strict>>;
|
|
35
|
+
totalRoutes: z.ZodNumber;
|
|
36
|
+
indices: z.ZodArray<z.ZodNumber>;
|
|
37
|
+
signature: z.ZodNullable<z.ZodString>;
|
|
38
|
+
probes: z.ZodArray<z.ZodObject<{
|
|
39
|
+
path: z.ZodString;
|
|
40
|
+
status: z.ZodNumber;
|
|
41
|
+
capture: z.ZodNullable<z.ZodObject<{
|
|
42
|
+
signature: z.ZodString;
|
|
43
|
+
totalRoutes: z.ZodNumber;
|
|
44
|
+
supportedRoutes: z.ZodNumber;
|
|
45
|
+
matched: z.ZodArray<z.ZodObject<{
|
|
46
|
+
path: z.ZodString;
|
|
47
|
+
name: z.ZodNullable<z.ZodString>;
|
|
48
|
+
}, z.core.$strict>>;
|
|
49
|
+
indices: z.ZodArray<z.ZodNullable<z.ZodNumber>>;
|
|
50
|
+
}, z.core.$strict>>;
|
|
51
|
+
}, z.core.$strict>>;
|
|
52
|
+
}, z.core.$strict>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { runtimeInventorySchema } from "./runtime-inventory.js";
|
|
3
|
+
import { vueRouteIdentitySchema } from "./vue-router.js";
|
|
4
|
+
const count = z.number().int().nonnegative().max(2048);
|
|
5
|
+
const signature = z.string().regex(/^[a-f0-9]{64}$/);
|
|
6
|
+
export const nuxtResultSchema = z.strictObject({
|
|
7
|
+
schemaVersion: z.literal(1),
|
|
8
|
+
versions: z.record(z.string(), z.string()),
|
|
9
|
+
sourceFingerprint: signature,
|
|
10
|
+
runtime: runtimeInventorySchema.nullable(),
|
|
11
|
+
totalRoutes: count,
|
|
12
|
+
indices: z.array(count).max(2048),
|
|
13
|
+
signature: signature.nullable(),
|
|
14
|
+
probes: z
|
|
15
|
+
.array(z.strictObject({
|
|
16
|
+
path: z.string(),
|
|
17
|
+
status: z.number().int().min(100).max(599),
|
|
18
|
+
capture: z
|
|
19
|
+
.strictObject({
|
|
20
|
+
signature,
|
|
21
|
+
totalRoutes: count,
|
|
22
|
+
supportedRoutes: count,
|
|
23
|
+
matched: z.array(vueRouteIdentitySchema).max(32),
|
|
24
|
+
indices: z.array(count.nullable()).max(32),
|
|
25
|
+
})
|
|
26
|
+
.nullable(),
|
|
27
|
+
}))
|
|
28
|
+
.max(16),
|
|
29
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { writeSync } from "node:fs";
|
|
3
|
+
import { readFile, realpath, writeFile } from "node:fs/promises";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { pathToFileURL } from "node:url";
|
|
6
|
+
import { nuxtConfigSchema, nuxtVersions } from "./nuxt.js";
|
|
7
|
+
import { nuxtResultSchema } from "./nuxt-protocol.js";
|
|
8
|
+
import { captureVueRecords, vueRecordIdentity, } from "./vue-router-capture.js";
|
|
9
|
+
const symbol = Symbol.for("checktrail.nuxt.capture");
|
|
10
|
+
const host = globalThis;
|
|
11
|
+
const hash = (value) => createHash("sha256").update(JSON.stringify(value)).digest("hex");
|
|
12
|
+
async function main() {
|
|
13
|
+
const [entry, encodedMetadata, encodedConfig, sourceFingerprint] = process.argv.slice(2);
|
|
14
|
+
const config = nuxtConfigSchema.parse(JSON.parse(encodedConfig));
|
|
15
|
+
const metadata = JSON.parse(encodedMetadata);
|
|
16
|
+
const versions = {};
|
|
17
|
+
for (const [name, expected] of Object.entries(nuxtVersions)) {
|
|
18
|
+
versions[name] = JSON.parse(await readFile(metadata[name], "utf8")).version;
|
|
19
|
+
if (versions[name] !== expected) {
|
|
20
|
+
writeSync(1, JSON.stringify({
|
|
21
|
+
unavailable: "nuxt-runtime",
|
|
22
|
+
reason: "unsupported-version",
|
|
23
|
+
}));
|
|
24
|
+
process.exitCode = 3;
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const temporary = await realpath(process.env.CHECKTRAIL_TEMP);
|
|
29
|
+
const root = await realpath(process.cwd());
|
|
30
|
+
const buildDir = path.join(temporary, "build");
|
|
31
|
+
const serverDir = path.join(temporary, "server");
|
|
32
|
+
const plugin = path.join(temporary, "capture.mjs");
|
|
33
|
+
await writeFile(plugin, `import {defineNuxtPlugin} from '#app';
|
|
34
|
+
export default defineNuxtPlugin({name:'checktrail-capture',dependsOn:['nuxt:router'],enforce:'pre',setup(app){
|
|
35
|
+
const router=app.$router; const records=router.getRoutes.bind(router);
|
|
36
|
+
app.hook('app:rendered',()=>globalThis[Symbol.for('checktrail.nuxt.capture')]?.(()=>({records:records(),matched:router.currentRoute.value.matched,strict:router.options.strict??false,sensitive:router.options.sensitive??false,url:app.ssrContext.url})));
|
|
37
|
+
}});`);
|
|
38
|
+
const { loadNuxt, build } = (await import(pathToFileURL(entry).href));
|
|
39
|
+
let nuxt;
|
|
40
|
+
let runtime;
|
|
41
|
+
try {
|
|
42
|
+
nuxt = await loadNuxt({
|
|
43
|
+
cwd: root,
|
|
44
|
+
dotenv: false,
|
|
45
|
+
overrides: {
|
|
46
|
+
dev: false,
|
|
47
|
+
test: true,
|
|
48
|
+
ssr: true,
|
|
49
|
+
telemetry: false,
|
|
50
|
+
devtools: { enabled: false },
|
|
51
|
+
builder: "@nuxt/vite-builder",
|
|
52
|
+
buildDir,
|
|
53
|
+
plugins: [{ src: plugin, mode: "server" }],
|
|
54
|
+
vite: { cacheDir: path.join(temporary, "vite") },
|
|
55
|
+
nitro: {
|
|
56
|
+
preset: "nitro-prerender",
|
|
57
|
+
output: {
|
|
58
|
+
dir: path.join(temporary, "output"),
|
|
59
|
+
serverDir,
|
|
60
|
+
publicDir: path.join(temporary, "public"),
|
|
61
|
+
},
|
|
62
|
+
prerender: { crawlLinks: false, routes: [] },
|
|
63
|
+
},
|
|
64
|
+
experimental: {
|
|
65
|
+
buildCache: false,
|
|
66
|
+
typescriptPlugin: false,
|
|
67
|
+
chromeDevtoolsProjectSettings: false,
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
if (nuxt.options.dev ||
|
|
72
|
+
!nuxt.options.test ||
|
|
73
|
+
!nuxt.options.ssr ||
|
|
74
|
+
nuxt.options.buildDir !== buildDir ||
|
|
75
|
+
nuxt.options.rootDir !== root)
|
|
76
|
+
throw new Error("Nuxt testing assembly settings changed");
|
|
77
|
+
await build(nuxt);
|
|
78
|
+
runtime = await import(pathToFileURL(path.join(serverDir, "index.mjs")).href);
|
|
79
|
+
const result = {
|
|
80
|
+
schemaVersion: 1,
|
|
81
|
+
versions,
|
|
82
|
+
sourceFingerprint,
|
|
83
|
+
runtime: null,
|
|
84
|
+
totalRoutes: 0,
|
|
85
|
+
indices: [],
|
|
86
|
+
signature: null,
|
|
87
|
+
probes: [],
|
|
88
|
+
};
|
|
89
|
+
for (const probe of config.probes) {
|
|
90
|
+
const captures = [];
|
|
91
|
+
host[symbol] = (capture) => {
|
|
92
|
+
if (captures.length >= 2)
|
|
93
|
+
throw new Error("Repeated runtime capture");
|
|
94
|
+
captures.push(capture);
|
|
95
|
+
};
|
|
96
|
+
const response = await runtime.localFetch(probe.path, {
|
|
97
|
+
headers: { host: "checktrail.invalid" },
|
|
98
|
+
});
|
|
99
|
+
await response.body?.cancel();
|
|
100
|
+
let capture = null;
|
|
101
|
+
const native = captures.length === 1 ? captures[0]() : undefined;
|
|
102
|
+
if (native?.url === probe.path) {
|
|
103
|
+
if (native.records.length > 2048 ||
|
|
104
|
+
typeof native.strict !== "boolean" ||
|
|
105
|
+
typeof native.sensitive !== "boolean")
|
|
106
|
+
throw new Error("Unsupported native router");
|
|
107
|
+
const { entries, indices } = captureVueRecords(native.records, native);
|
|
108
|
+
const signature = hash({
|
|
109
|
+
totalRoutes: native.records.length,
|
|
110
|
+
indices,
|
|
111
|
+
entries,
|
|
112
|
+
});
|
|
113
|
+
if (!result.runtime) {
|
|
114
|
+
result.totalRoutes = native.records.length;
|
|
115
|
+
result.indices = indices;
|
|
116
|
+
result.signature = signature;
|
|
117
|
+
result.runtime = {
|
|
118
|
+
schemaVersion: 1,
|
|
119
|
+
format: "runtime-inventory",
|
|
120
|
+
producer: { name: "checktrail.nuxt", version: "1.0.0" },
|
|
121
|
+
assembly: {
|
|
122
|
+
name: config.assembly,
|
|
123
|
+
environment: config.environment,
|
|
124
|
+
},
|
|
125
|
+
sourceFingerprint,
|
|
126
|
+
capturedAt: new Date().toISOString(),
|
|
127
|
+
collections: [
|
|
128
|
+
{
|
|
129
|
+
kind: "routes",
|
|
130
|
+
ordered: true,
|
|
131
|
+
complete: entries.length === native.records.length,
|
|
132
|
+
entries,
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
capture = {
|
|
138
|
+
signature,
|
|
139
|
+
totalRoutes: native.records.length,
|
|
140
|
+
supportedRoutes: entries.length,
|
|
141
|
+
matched: native.matched.map(vueRecordIdentity),
|
|
142
|
+
indices: native.matched.map((record) => {
|
|
143
|
+
const index = native.records.indexOf(record);
|
|
144
|
+
return index < 0 ? null : index;
|
|
145
|
+
}),
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
result.probes.push({
|
|
149
|
+
path: probe.path,
|
|
150
|
+
status: response.status,
|
|
151
|
+
capture,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
writeSync(1, JSON.stringify(nuxtResultSchema.parse(result)));
|
|
155
|
+
}
|
|
156
|
+
finally {
|
|
157
|
+
delete host[symbol];
|
|
158
|
+
await runtime?.closePrerenderer();
|
|
159
|
+
await nuxt?.close();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
main().catch(() => {
|
|
163
|
+
writeSync(2, "Nuxt build or SSR runtime capture could not complete\n");
|
|
164
|
+
process.exitCode = 2;
|
|
165
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { Check, Inventory, Project } from "./types.js";
|
|
3
|
+
export declare const nuxtVersions: {
|
|
4
|
+
readonly nuxt: "4.5.2";
|
|
5
|
+
readonly "@nuxt/kit": "4.5.2";
|
|
6
|
+
readonly "@nuxt/vite-builder": "4.5.2";
|
|
7
|
+
readonly "@nuxt/nitro-server": "4.5.2";
|
|
8
|
+
readonly nitropack: "2.13.4";
|
|
9
|
+
readonly vue: "3.5.43";
|
|
10
|
+
readonly "vue-router": "5.3.1";
|
|
11
|
+
};
|
|
12
|
+
export declare const nuxtConfigSchema: z.ZodObject<{
|
|
13
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
14
|
+
assembly: z.ZodString;
|
|
15
|
+
environment: z.ZodLiteral<"test">;
|
|
16
|
+
probes: z.ZodArray<z.ZodObject<{
|
|
17
|
+
path: z.ZodString;
|
|
18
|
+
matched: z.ZodArray<z.ZodObject<{
|
|
19
|
+
path: z.ZodString;
|
|
20
|
+
name: z.ZodNullable<z.ZodString>;
|
|
21
|
+
}, z.core.$strict>>;
|
|
22
|
+
}, z.core.$strict>>;
|
|
23
|
+
}, z.core.$strict>;
|
|
24
|
+
export declare function nuxtCheck(source: Inventory, project: Project): Promise<Check>;
|
package/dist/src/nuxt.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { localTool } from "./local-tool.js";
|
|
6
|
+
import { readProjectFile, withinRoot } from "./inventory.js";
|
|
7
|
+
import { vueRouteIdentitySchema } from "./vue-router.js";
|
|
8
|
+
export const nuxtVersions = {
|
|
9
|
+
nuxt: "4.5.2",
|
|
10
|
+
"@nuxt/kit": "4.5.2",
|
|
11
|
+
"@nuxt/vite-builder": "4.5.2",
|
|
12
|
+
"@nuxt/nitro-server": "4.5.2",
|
|
13
|
+
nitropack: "2.13.4",
|
|
14
|
+
vue: "3.5.43",
|
|
15
|
+
"vue-router": "5.3.1",
|
|
16
|
+
};
|
|
17
|
+
export const nuxtConfigSchema = z.strictObject({
|
|
18
|
+
schemaVersion: z.literal(1),
|
|
19
|
+
assembly: z.string().min(1).max(256),
|
|
20
|
+
environment: z.literal("test"),
|
|
21
|
+
probes: z
|
|
22
|
+
.array(z.strictObject({
|
|
23
|
+
path: z
|
|
24
|
+
.string()
|
|
25
|
+
.regex(/^\/(?!\/)[^\r\n#]*$/)
|
|
26
|
+
.max(4096),
|
|
27
|
+
matched: z.array(vueRouteIdentitySchema).min(1).max(32),
|
|
28
|
+
}))
|
|
29
|
+
.min(1)
|
|
30
|
+
.max(16),
|
|
31
|
+
});
|
|
32
|
+
export async function nuxtCheck(source, project) {
|
|
33
|
+
const check = {
|
|
34
|
+
id: "javascript.nuxt-runtime",
|
|
35
|
+
adapter: project.adapter,
|
|
36
|
+
project: project.path,
|
|
37
|
+
kind: "analysis",
|
|
38
|
+
parser: "nuxt-json",
|
|
39
|
+
scope: [],
|
|
40
|
+
commands: [],
|
|
41
|
+
reason: "Build an isolated Nuxt SSR testing assembly and verify declared requests against its native runtime router.",
|
|
42
|
+
};
|
|
43
|
+
if (!project.files.includes("checktrail.nuxt.json")) {
|
|
44
|
+
check.unavailableReason =
|
|
45
|
+
"Nuxt runtime checks require an explicit checktrail.nuxt.json profile.";
|
|
46
|
+
return check;
|
|
47
|
+
}
|
|
48
|
+
const config = nuxtConfigSchema.parse(JSON.parse(await readProjectFile(source.root, path.posix.join(project.path, "checktrail.nuxt.json"))));
|
|
49
|
+
if (new Set(config.probes.map((probe) => probe.path)).size !==
|
|
50
|
+
config.probes.length)
|
|
51
|
+
throw new Error("Nuxt probes require unique request paths");
|
|
52
|
+
const encoded = JSON.stringify(config);
|
|
53
|
+
if (Buffer.byteLength(encoded) > 64 * 1024)
|
|
54
|
+
throw new Error("Nuxt profile exceeds 64 KiB");
|
|
55
|
+
const configs = project.files.filter((file) => /^nuxt\.config\.[cm]?[jt]s$/.test(file));
|
|
56
|
+
if (configs.length !== 1) {
|
|
57
|
+
check.unavailableReason =
|
|
58
|
+
"Nuxt runtime checks require exactly one inventoried root Nuxt configuration.";
|
|
59
|
+
return check;
|
|
60
|
+
}
|
|
61
|
+
check.scope = configs;
|
|
62
|
+
const entry = await localTool(source.root, project.path, "nuxt/dist/index.mjs");
|
|
63
|
+
if (!entry) {
|
|
64
|
+
check.unavailableReason =
|
|
65
|
+
"Nuxt must already be installed inside the configured root.";
|
|
66
|
+
return check;
|
|
67
|
+
}
|
|
68
|
+
const metadata = {};
|
|
69
|
+
try {
|
|
70
|
+
const require = createRequire(entry);
|
|
71
|
+
for (const name of Object.keys(nuxtVersions)) {
|
|
72
|
+
const resolver = name === "nitropack"
|
|
73
|
+
? createRequire(metadata["@nuxt/nitro-server"])
|
|
74
|
+
: require;
|
|
75
|
+
const resolved = resolver.resolve(`${name}/package.json`);
|
|
76
|
+
metadata[name] = await withinRoot(source.root, path.relative(source.root, resolved));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
check.unavailableReason =
|
|
81
|
+
"Nuxt runtime dependencies must resolve inside the configured root.";
|
|
82
|
+
return check;
|
|
83
|
+
}
|
|
84
|
+
check.commands = [
|
|
85
|
+
{
|
|
86
|
+
executable: process.execPath,
|
|
87
|
+
args: [
|
|
88
|
+
fileURLToPath(new URL("./nuxt-runner.js", import.meta.url)),
|
|
89
|
+
entry,
|
|
90
|
+
JSON.stringify(metadata),
|
|
91
|
+
encoded,
|
|
92
|
+
source.fingerprint,
|
|
93
|
+
],
|
|
94
|
+
cwd: project.path,
|
|
95
|
+
env: {
|
|
96
|
+
NODE_ENV: "test",
|
|
97
|
+
NODE_OPTIONS: "",
|
|
98
|
+
NUXT_TELEMETRY_DISABLED: "1",
|
|
99
|
+
CI: "1",
|
|
100
|
+
},
|
|
101
|
+
temporaryDirectory: true,
|
|
102
|
+
},
|
|
103
|
+
];
|
|
104
|
+
return check;
|
|
105
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
function selectionSummary(selection) {
|
|
2
|
+
return selection
|
|
3
|
+
? {
|
|
4
|
+
selection: {
|
|
5
|
+
mode: selection.mode,
|
|
6
|
+
reason: selection.reason,
|
|
7
|
+
projectCount: selection.selectedProjects.length,
|
|
8
|
+
changedFileCount: selection.changedFiles.length,
|
|
9
|
+
},
|
|
10
|
+
}
|
|
11
|
+
: {};
|
|
12
|
+
}
|
|
13
|
+
export function projectPlan(plan, detailed) {
|
|
14
|
+
if (detailed)
|
|
15
|
+
return { ...plan };
|
|
16
|
+
return {
|
|
17
|
+
...selectionSummary(plan.selection),
|
|
18
|
+
schemaVersion: plan.schemaVersion,
|
|
19
|
+
engineVersion: plan.engineVersion,
|
|
20
|
+
projectCount: plan.projects.length,
|
|
21
|
+
adapters: [...new Set(plan.projects.map((project) => project.adapter))],
|
|
22
|
+
excludedCount: plan.excluded.length,
|
|
23
|
+
checks: plan.checks.map((check) => ({
|
|
24
|
+
id: check.id,
|
|
25
|
+
kind: check.kind,
|
|
26
|
+
ready: !check.unavailableReason,
|
|
27
|
+
})),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export function projectReport(report, detailed) {
|
|
31
|
+
if (detailed)
|
|
32
|
+
return { ...report };
|
|
33
|
+
return {
|
|
34
|
+
...selectionSummary(report.selection),
|
|
35
|
+
schemaVersion: report.schemaVersion,
|
|
36
|
+
engineVersion: report.engineVersion,
|
|
37
|
+
runId: report.runId,
|
|
38
|
+
outcome: report.outcome,
|
|
39
|
+
durationMs: report.durationMs,
|
|
40
|
+
sourceChanged: report.sourceChanged,
|
|
41
|
+
sourceError: report.sourceError,
|
|
42
|
+
checks: report.checks.map((check) => ({
|
|
43
|
+
id: check.id,
|
|
44
|
+
status: check.status,
|
|
45
|
+
...(check.tests ? { tests: check.tests } : {}),
|
|
46
|
+
})),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
const count = z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
4
|
+
const schema = z.object({
|
|
5
|
+
totals: z.object({ errors: count, file_errors: count }),
|
|
6
|
+
files: z.record(z.string(), z.object({
|
|
7
|
+
errors: count,
|
|
8
|
+
messages: z.array(z.object({
|
|
9
|
+
message: z.string(),
|
|
10
|
+
line: z.number().int().positive().nullable(),
|
|
11
|
+
ignorable: z.boolean(),
|
|
12
|
+
identifier: z.string().min(1).optional(),
|
|
13
|
+
})),
|
|
14
|
+
})),
|
|
15
|
+
errors: z.array(z.string()),
|
|
16
|
+
});
|
|
17
|
+
export function phpstanEvidence(check, processes, root) {
|
|
18
|
+
const incomplete = {
|
|
19
|
+
status: "inconclusive",
|
|
20
|
+
reason: "PHPStan output does not account for every planned file or consistent diagnostic totals.",
|
|
21
|
+
};
|
|
22
|
+
if (!root || processes.length !== 1 || !check.scope.length)
|
|
23
|
+
return incomplete;
|
|
24
|
+
const process = processes[0];
|
|
25
|
+
const lines = process.stdout.split(/\r?\n/).filter(Boolean);
|
|
26
|
+
let report;
|
|
27
|
+
try {
|
|
28
|
+
report = schema.parse(JSON.parse(lines.pop() ?? ""));
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return process.exitCode === 0
|
|
32
|
+
? incomplete
|
|
33
|
+
: {
|
|
34
|
+
status: "error",
|
|
35
|
+
reason: "PHPStan could not produce native analysis evidence; inspect configuration and runtime errors.",
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
if (process.exitCode !== 0 && process.exitCode !== 1)
|
|
39
|
+
return { status: "error", reason: "PHPStan did not exit normally." };
|
|
40
|
+
const expected = new Set(check.scope.map((file) => path.resolve(root, check.project, file)));
|
|
41
|
+
let errors = 0;
|
|
42
|
+
const findings = [];
|
|
43
|
+
for (const [file, result] of Object.entries(report.files)) {
|
|
44
|
+
if (!expected.has(file) || result.errors !== result.messages.length)
|
|
45
|
+
return incomplete;
|
|
46
|
+
errors += result.errors;
|
|
47
|
+
findings.push(...result.messages.map((message) => ({
|
|
48
|
+
ruleId: message.identifier ?? "diagnostic",
|
|
49
|
+
level: "error",
|
|
50
|
+
message: message.message,
|
|
51
|
+
file: path.relative(root, file).split(path.sep).join("/"),
|
|
52
|
+
...(message.line ? { line: message.line } : {}),
|
|
53
|
+
})));
|
|
54
|
+
}
|
|
55
|
+
if (errors !== report.totals.file_errors ||
|
|
56
|
+
report.errors.length !== report.totals.errors)
|
|
57
|
+
return incomplete;
|
|
58
|
+
const complete = lines.length === expected.size &&
|
|
59
|
+
new Set(lines).size === expected.size &&
|
|
60
|
+
lines.every((file) => expected.has(file)) &&
|
|
61
|
+
!process.stderr.trim();
|
|
62
|
+
if (errors || report.errors.length || process.exitCode === 1)
|
|
63
|
+
return {
|
|
64
|
+
status: "failed",
|
|
65
|
+
reason: "PHPStan reported analysis diagnostics.",
|
|
66
|
+
findings,
|
|
67
|
+
findingsComplete: complete &&
|
|
68
|
+
errors > 0 &&
|
|
69
|
+
!report.errors.length &&
|
|
70
|
+
process.exitCode === 1 &&
|
|
71
|
+
Object.values(report.files).every((file) => file.messages.every((message) => message.ignorable)),
|
|
72
|
+
};
|
|
73
|
+
if (!complete)
|
|
74
|
+
return incomplete;
|
|
75
|
+
return {
|
|
76
|
+
status: "passed",
|
|
77
|
+
findings,
|
|
78
|
+
findingsComplete: true,
|
|
79
|
+
reason: "PHPStan analysed every planned file and reported no diagnostics.",
|
|
80
|
+
};
|
|
81
|
+
}
|