@maverickcer/env-cap 0.5.3 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -5
- package/dist/.dts/build/assemble-project.d.ts +1 -1
- package/dist/.dts/build/assemble-project.d.ts.map +1 -1
- package/dist/.dts/build/change-model.d.ts.map +1 -1
- package/dist/.dts/build/check-artifacts.d.ts.map +1 -1
- package/dist/.dts/build/citation-verification.d.ts.map +1 -1
- package/dist/.dts/build/compatibility.d.ts.map +1 -1
- package/dist/.dts/build/compiler-api.d.ts +15 -0
- package/dist/.dts/build/compiler-api.d.ts.map +1 -0
- package/dist/.dts/build/dependency-graph.d.ts +3 -1
- package/dist/.dts/build/dependency-graph.d.ts.map +1 -1
- package/dist/.dts/build/dependency-model.d.ts.map +1 -1
- package/dist/.dts/build/discover.d.ts.map +1 -1
- package/dist/.dts/build/docs.d.ts +1 -1
- package/dist/.dts/build/docs.d.ts.map +1 -1
- package/dist/.dts/build/env-example.d.ts.map +1 -1
- package/dist/.dts/build/evidence-cache.d.ts +1 -1
- package/dist/.dts/build/evidence-cache.d.ts.map +1 -1
- package/dist/.dts/build/evidence-model.d.ts +2 -2
- package/dist/.dts/build/evidence-snapshot.d.ts +25 -0
- package/dist/.dts/build/evidence-snapshot.d.ts.map +1 -1
- package/dist/.dts/build/finding-model.d.ts +1 -1
- package/dist/.dts/build/finding-model.d.ts.map +1 -1
- package/dist/.dts/build/generate-documentation.d.ts.map +1 -1
- package/dist/.dts/build/generate-env-artifacts.d.ts +23 -8
- package/dist/.dts/build/generate-env-artifacts.d.ts.map +1 -1
- package/dist/.dts/build/generate-evidence.d.ts.map +1 -1
- package/dist/.dts/build/generate-manifest.d.ts +1 -1
- package/dist/.dts/build/generate-manifest.d.ts.map +1 -1
- package/dist/.dts/build/generate-usage.d.ts +3 -3
- package/dist/.dts/build/generate-usage.d.ts.map +1 -1
- package/dist/.dts/build/generated-banner.d.ts +15 -3
- package/dist/.dts/build/generated-banner.d.ts.map +1 -1
- package/dist/.dts/build/glob.d.ts.map +1 -1
- package/dist/.dts/build/index.d.ts +2 -2
- package/dist/.dts/build/lifecycle-model.d.ts.map +1 -1
- package/dist/.dts/build/link.d.ts.map +1 -1
- package/dist/.dts/build/literal-eval.d.ts +4 -3
- package/dist/.dts/build/literal-eval.d.ts.map +1 -1
- package/dist/.dts/build/live-expirations.d.ts.map +1 -1
- package/dist/.dts/build/manifest.d.ts.map +1 -1
- package/dist/.dts/build/parse.d.ts +12 -12
- package/dist/.dts/build/parse.d.ts.map +1 -1
- package/dist/.dts/build/reference-projections.d.ts +17 -3
- package/dist/.dts/build/reference-projections.d.ts.map +1 -1
- package/dist/.dts/build/resolution/resolve-import.d.ts +5 -0
- package/dist/.dts/build/resolution/resolve-import.d.ts.map +1 -1
- package/dist/.dts/build/resolution/resolve-package-schema.d.ts +1 -1
- package/dist/.dts/build/resolution/resolve-package-schema.d.ts.map +1 -1
- package/dist/.dts/build/resolution/resolve-tsconfig-paths.d.ts +20 -2
- package/dist/.dts/build/resolution/resolve-tsconfig-paths.d.ts.map +1 -1
- package/dist/.dts/build/sarif.d.ts.map +1 -1
- package/dist/.dts/build/scan-dependencies.d.ts +23 -0
- package/dist/.dts/build/scan-dependencies.d.ts.map +1 -1
- package/dist/.dts/build/types.d.ts +1 -1
- package/dist/.dts/build/typescript.d.ts +20 -0
- package/dist/.dts/build/typescript.d.ts.map +1 -0
- package/dist/.dts/build/usage-report.d.ts.map +1 -1
- package/dist/.dts/cli/filesystem.d.ts +4 -0
- package/dist/.dts/cli/filesystem.d.ts.map +1 -1
- package/dist/.dts/eslint-plugin/glob.d.ts.map +1 -1
- package/dist/.dts/eslint-plugin/index.d.ts +2 -2
- package/dist/.dts/eslint-plugin/no-node-fs.d.ts.map +1 -1
- package/dist/.dts/eslint-plugin/no-raw-process-env.d.ts.map +1 -1
- package/dist/.dts/evidence/index.d.ts +2 -2
- package/dist/.dts/helpers/index.d.ts +2 -2
- package/dist/.dts/helpers/processors.d.ts.map +1 -1
- package/dist/.dts/helpers/validators.d.ts.map +1 -1
- package/dist/.dts/runtime/cache.d.ts +0 -3
- package/dist/.dts/runtime/cache.d.ts.map +1 -1
- package/dist/.dts/runtime/create.d.ts.map +1 -1
- package/dist/.dts/runtime/document.d.ts.map +1 -1
- package/dist/.dts/runtime/index.d.ts +2 -2
- package/dist/.dts/runtime/registry.d.ts.map +1 -1
- package/dist/.dts/runtime/validate.d.ts.map +1 -1
- package/dist/{build-U326PI5A.js → build-H4KFV44Z.js} +501 -599
- package/dist/build-H4KFV44Z.js.map +1 -0
- package/dist/build.cjs +516 -607
- package/dist/build.cjs.map +1 -1
- package/dist/build.js +513 -605
- package/dist/build.js.map +1 -1
- package/dist/{chunk-BSTLSR2R.js → chunk-7GVPOHDU.js} +2 -2
- package/dist/chunk-7GVPOHDU.js.map +1 -0
- package/dist/cli/index.js +35 -41
- package/dist/cli/index.js.map +1 -1
- package/dist/eslint-plugin/index.cjs +15 -576
- package/dist/eslint-plugin/index.cjs.map +1 -1
- package/dist/eslint-plugin/index.js +15 -576
- package/dist/eslint-plugin/index.js.map +1 -1
- package/dist/evidence.cjs.map +1 -1
- package/dist/evidence.js.map +1 -1
- package/dist/helpers.cjs +4 -9
- package/dist/helpers.cjs.map +1 -1
- package/dist/helpers.js +4 -9
- package/dist/helpers.js.map +1 -1
- package/dist/index.cjs +11 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -25
- package/dist/index.js.map +1 -1
- package/dist/node.cjs +10 -8
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +10 -8
- package/dist/node.js.map +1 -1
- package/node_modules/@typescript/old/LICENSE.txt +55 -0
- package/node_modules/@typescript/old/README.md +50 -0
- package/node_modules/@typescript/old/SECURITY.md +39 -0
- package/node_modules/@typescript/old/ThirdPartyNoticeText.txt +193 -0
- package/node_modules/@typescript/old/bin/tsc +2 -0
- package/node_modules/@typescript/old/bin/tsserver +2 -0
- package/node_modules/@typescript/old/lib/_tsc.js +134465 -0
- package/node_modules/@typescript/old/lib/_tsserver.js +659 -0
- package/node_modules/@typescript/old/lib/_typingsInstaller.js +222 -0
- package/node_modules/@typescript/old/lib/cs/diagnosticMessages.generated.json +2129 -0
- package/node_modules/@typescript/old/lib/de/diagnosticMessages.generated.json +2125 -0
- package/node_modules/@typescript/old/lib/es/diagnosticMessages.generated.json +2129 -0
- package/node_modules/@typescript/old/lib/fr/diagnosticMessages.generated.json +2129 -0
- package/node_modules/@typescript/old/lib/it/diagnosticMessages.generated.json +2125 -0
- package/node_modules/@typescript/old/lib/ja/diagnosticMessages.generated.json +2129 -0
- package/node_modules/@typescript/old/lib/ko/diagnosticMessages.generated.json +2129 -0
- package/node_modules/@typescript/old/lib/lib.d.ts +20 -0
- package/node_modules/@typescript/old/lib/lib.decorators.d.ts +382 -0
- package/node_modules/@typescript/old/lib/lib.decorators.legacy.d.ts +20 -0
- package/node_modules/@typescript/old/lib/lib.dom.asynciterable.d.ts +18 -0
- package/node_modules/@typescript/old/lib/lib.dom.d.ts +45125 -0
- package/node_modules/@typescript/old/lib/lib.dom.iterable.d.ts +18 -0
- package/node_modules/@typescript/old/lib/lib.es2015.collection.d.ts +150 -0
- package/node_modules/@typescript/old/lib/lib.es2015.core.d.ts +595 -0
- package/node_modules/@typescript/old/lib/lib.es2015.d.ts +26 -0
- package/node_modules/@typescript/old/lib/lib.es2015.generator.d.ts +75 -0
- package/node_modules/@typescript/old/lib/lib.es2015.iterable.d.ts +603 -0
- package/node_modules/@typescript/old/lib/lib.es2015.promise.d.ts +79 -0
- package/node_modules/@typescript/old/lib/lib.es2015.proxy.d.ts +126 -0
- package/node_modules/@typescript/old/lib/lib.es2015.reflect.d.ts +142 -0
- package/node_modules/@typescript/old/lib/lib.es2015.symbol.d.ts +44 -0
- package/node_modules/@typescript/old/lib/lib.es2015.symbol.wellknown.d.ts +324 -0
- package/node_modules/@typescript/old/lib/lib.es2016.array.include.d.ts +114 -0
- package/node_modules/@typescript/old/lib/lib.es2016.d.ts +19 -0
- package/node_modules/@typescript/old/lib/lib.es2016.full.d.ts +21 -0
- package/node_modules/@typescript/old/lib/lib.es2016.intl.d.ts +29 -0
- package/node_modules/@typescript/old/lib/lib.es2017.arraybuffer.d.ts +19 -0
- package/node_modules/@typescript/old/lib/lib.es2017.d.ts +24 -0
- package/node_modules/@typescript/old/lib/lib.es2017.date.d.ts +29 -0
- package/node_modules/@typescript/old/lib/lib.es2017.full.d.ts +21 -0
- package/node_modules/@typescript/old/lib/lib.es2017.intl.d.ts +42 -0
- package/node_modules/@typescript/old/lib/lib.es2017.object.d.ts +47 -0
- package/node_modules/@typescript/old/lib/lib.es2017.sharedmemory.d.ts +133 -0
- package/node_modules/@typescript/old/lib/lib.es2017.string.d.ts +43 -0
- package/node_modules/@typescript/old/lib/lib.es2017.typedarrays.d.ts +51 -0
- package/node_modules/@typescript/old/lib/lib.es2018.asyncgenerator.d.ts +75 -0
- package/node_modules/@typescript/old/lib/lib.es2018.asynciterable.d.ts +51 -0
- package/node_modules/@typescript/old/lib/lib.es2018.d.ts +22 -0
- package/node_modules/@typescript/old/lib/lib.es2018.full.d.ts +22 -0
- package/node_modules/@typescript/old/lib/lib.es2018.intl.d.ts +81 -0
- package/node_modules/@typescript/old/lib/lib.es2018.promise.d.ts +28 -0
- package/node_modules/@typescript/old/lib/lib.es2018.regexp.d.ts +35 -0
- package/node_modules/@typescript/old/lib/lib.es2019.array.d.ts +77 -0
- package/node_modules/@typescript/old/lib/lib.es2019.d.ts +22 -0
- package/node_modules/@typescript/old/lib/lib.es2019.full.d.ts +22 -0
- package/node_modules/@typescript/old/lib/lib.es2019.intl.d.ts +21 -0
- package/node_modules/@typescript/old/lib/lib.es2019.object.d.ts +31 -0
- package/node_modules/@typescript/old/lib/lib.es2019.string.d.ts +35 -0
- package/node_modules/@typescript/old/lib/lib.es2019.symbol.d.ts +22 -0
- package/node_modules/@typescript/old/lib/lib.es2020.bigint.d.ts +763 -0
- package/node_modules/@typescript/old/lib/lib.es2020.d.ts +25 -0
- package/node_modules/@typescript/old/lib/lib.es2020.date.d.ts +40 -0
- package/node_modules/@typescript/old/lib/lib.es2020.full.d.ts +22 -0
- package/node_modules/@typescript/old/lib/lib.es2020.intl.d.ts +472 -0
- package/node_modules/@typescript/old/lib/lib.es2020.number.d.ts +26 -0
- package/node_modules/@typescript/old/lib/lib.es2020.promise.d.ts +45 -0
- package/node_modules/@typescript/old/lib/lib.es2020.sharedmemory.d.ts +97 -0
- package/node_modules/@typescript/old/lib/lib.es2020.string.d.ts +42 -0
- package/node_modules/@typescript/old/lib/lib.es2020.symbol.wellknown.d.ts +39 -0
- package/node_modules/@typescript/old/lib/lib.es2021.d.ts +21 -0
- package/node_modules/@typescript/old/lib/lib.es2021.full.d.ts +22 -0
- package/node_modules/@typescript/old/lib/lib.es2021.intl.d.ts +164 -0
- package/node_modules/@typescript/old/lib/lib.es2021.promise.d.ts +46 -0
- package/node_modules/@typescript/old/lib/lib.es2021.string.d.ts +31 -0
- package/node_modules/@typescript/old/lib/lib.es2021.weakref.d.ts +76 -0
- package/node_modules/@typescript/old/lib/lib.es2022.array.d.ts +119 -0
- package/node_modules/@typescript/old/lib/lib.es2022.d.ts +23 -0
- package/node_modules/@typescript/old/lib/lib.es2022.error.d.ts +73 -0
- package/node_modules/@typescript/old/lib/lib.es2022.full.d.ts +22 -0
- package/node_modules/@typescript/old/lib/lib.es2022.intl.d.ts +143 -0
- package/node_modules/@typescript/old/lib/lib.es2022.object.d.ts +24 -0
- package/node_modules/@typescript/old/lib/lib.es2022.regexp.d.ts +37 -0
- package/node_modules/@typescript/old/lib/lib.es2022.string.d.ts +23 -0
- package/node_modules/@typescript/old/lib/lib.es2023.array.d.ts +922 -0
- package/node_modules/@typescript/old/lib/lib.es2023.collection.d.ts +19 -0
- package/node_modules/@typescript/old/lib/lib.es2023.d.ts +20 -0
- package/node_modules/@typescript/old/lib/lib.es2023.full.d.ts +22 -0
- package/node_modules/@typescript/old/lib/lib.es2023.intl.d.ts +62 -0
- package/node_modules/@typescript/old/lib/lib.es2024.arraybuffer.d.ts +63 -0
- package/node_modules/@typescript/old/lib/lib.es2024.collection.d.ts +27 -0
- package/node_modules/@typescript/old/lib/lib.es2024.d.ts +24 -0
- package/node_modules/@typescript/old/lib/lib.es2024.full.d.ts +22 -0
- package/node_modules/@typescript/old/lib/lib.es2024.object.d.ts +27 -0
- package/node_modules/@typescript/old/lib/lib.es2024.promise.d.ts +33 -0
- package/node_modules/@typescript/old/lib/lib.es2024.regexp.d.ts +23 -0
- package/node_modules/@typescript/old/lib/lib.es2024.sharedmemory.d.ts +66 -0
- package/node_modules/@typescript/old/lib/lib.es2024.string.d.ts +27 -0
- package/node_modules/@typescript/old/lib/lib.es2025.collection.d.ts +94 -0
- package/node_modules/@typescript/old/lib/lib.es2025.d.ts +23 -0
- package/node_modules/@typescript/old/lib/lib.es2025.float16.d.ts +443 -0
- package/node_modules/@typescript/old/lib/lib.es2025.full.d.ts +22 -0
- package/node_modules/@typescript/old/lib/lib.es2025.intl.d.ts +200 -0
- package/node_modules/@typescript/old/lib/lib.es2025.iterator.d.ts +146 -0
- package/node_modules/@typescript/old/lib/lib.es2025.promise.d.ts +32 -0
- package/node_modules/@typescript/old/lib/lib.es2025.regexp.d.ts +30 -0
- package/node_modules/@typescript/old/lib/lib.es5.d.ts +4599 -0
- package/node_modules/@typescript/old/lib/lib.es6.d.ts +21 -0
- package/node_modules/@typescript/old/lib/lib.esnext.array.d.ts +33 -0
- package/node_modules/@typescript/old/lib/lib.esnext.collection.d.ts +47 -0
- package/node_modules/@typescript/old/lib/lib.esnext.d.ts +27 -0
- package/node_modules/@typescript/old/lib/lib.esnext.date.d.ts +21 -0
- package/node_modules/@typescript/old/lib/lib.esnext.decorators.d.ts +26 -0
- package/node_modules/@typescript/old/lib/lib.esnext.disposable.d.ts +191 -0
- package/node_modules/@typescript/old/lib/lib.esnext.error.d.ts +22 -0
- package/node_modules/@typescript/old/lib/lib.esnext.full.d.ts +22 -0
- package/node_modules/@typescript/old/lib/lib.esnext.intl.d.ts +107 -0
- package/node_modules/@typescript/old/lib/lib.esnext.sharedmemory.d.ts +23 -0
- package/node_modules/@typescript/old/lib/lib.esnext.temporal.d.ts +485 -0
- package/node_modules/@typescript/old/lib/lib.esnext.typedarrays.d.ts +90 -0
- package/node_modules/@typescript/old/lib/lib.scripthost.d.ts +320 -0
- package/node_modules/@typescript/old/lib/lib.webworker.asynciterable.d.ts +18 -0
- package/node_modules/@typescript/old/lib/lib.webworker.d.ts +15606 -0
- package/node_modules/@typescript/old/lib/lib.webworker.importscripts.d.ts +21 -0
- package/node_modules/@typescript/old/lib/lib.webworker.iterable.d.ts +18 -0
- package/node_modules/@typescript/old/lib/pl/diagnosticMessages.generated.json +2129 -0
- package/node_modules/@typescript/old/lib/pt-br/diagnosticMessages.generated.json +2129 -0
- package/node_modules/@typescript/old/lib/ru/diagnosticMessages.generated.json +2125 -0
- package/node_modules/@typescript/old/lib/tr/diagnosticMessages.generated.json +2129 -0
- package/node_modules/@typescript/old/lib/tsc.js +8 -0
- package/node_modules/@typescript/old/lib/tsserver.js +8 -0
- package/node_modules/@typescript/old/lib/tsserverlibrary.d.ts +17 -0
- package/node_modules/@typescript/old/lib/tsserverlibrary.js +21 -0
- package/node_modules/@typescript/old/lib/typesMap.json +497 -0
- package/node_modules/@typescript/old/lib/typescript.d.ts +11448 -0
- package/node_modules/@typescript/old/lib/typescript.js +201039 -0
- package/node_modules/@typescript/old/lib/typingsInstaller.js +8 -0
- package/node_modules/@typescript/old/lib/watchGuard.js +53 -0
- package/node_modules/@typescript/old/lib/zh-cn/diagnosticMessages.generated.json +2129 -0
- package/node_modules/@typescript/old/lib/zh-tw/diagnosticMessages.generated.json +2125 -0
- package/node_modules/@typescript/old/package.json +118 -0
- package/node_modules/@typescript/typescript6/LICENSE.txt +55 -0
- package/node_modules/@typescript/typescript6/README.md +9 -0
- package/node_modules/@typescript/typescript6/bin/tsc6 +2 -0
- package/node_modules/@typescript/typescript6/lib/tsc.js +1 -0
- package/node_modules/@typescript/typescript6/lib/tsserverlibrary.d.ts +2 -0
- package/node_modules/@typescript/typescript6/lib/tsserverlibrary.js +1 -0
- package/node_modules/@typescript/typescript6/lib/typescript.d.ts +2 -0
- package/node_modules/@typescript/typescript6/lib/typescript.js +1 -0
- package/node_modules/@typescript/typescript6/package.json +39 -0
- package/package.json +32 -14
- package/schemas/env-cap-report.schema.json +1 -1
- package/dist/build-U326PI5A.js.map +0 -1
- package/dist/chunk-BSTLSR2R.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
readToolVersion
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-7GVPOHDU.js";
|
|
5
5
|
|
|
6
6
|
// src/build/evidence-snapshot.ts
|
|
7
7
|
import path3 from "path";
|
|
@@ -45,7 +45,6 @@ function previousContentHashes(previous) {
|
|
|
45
45
|
for (const contract of previous?.dependency.contracts ?? []) {
|
|
46
46
|
for (const variable of contract.variables) {
|
|
47
47
|
for (const assertion of variable.dynamicAccessAssertions) {
|
|
48
|
-
if (assertion.contentHash === void 0) continue;
|
|
49
48
|
const identity = dynamicAccessVariableIdentity(
|
|
50
49
|
contract.file,
|
|
51
50
|
contract.exportName,
|
|
@@ -66,8 +65,8 @@ async function buildCitationSnapshots(activeContracts, previous, root, readFile)
|
|
|
66
65
|
for (const contract of activeContracts) {
|
|
67
66
|
const file = displayPath(root, contract.file);
|
|
68
67
|
for (const variable of contract.variables) {
|
|
69
|
-
const citations = variable.evidence?.dynamicAccess
|
|
70
|
-
if (citations
|
|
68
|
+
const citations = variable.evidence?.dynamicAccess;
|
|
69
|
+
if (citations === void 0) continue;
|
|
71
70
|
const identity = dynamicAccessVariableIdentity(file, contract.exportName, variable.key);
|
|
72
71
|
const assertions = [];
|
|
73
72
|
for (const citation of citations) {
|
|
@@ -145,9 +144,7 @@ function toVariableRef(contract, variable) {
|
|
|
145
144
|
return { file: contract.file, exportName: contract.exportName, key: variable.key };
|
|
146
145
|
}
|
|
147
146
|
function toComparable(value) {
|
|
148
|
-
|
|
149
|
-
if (typeof value === "string") return value;
|
|
150
|
-
return JSON.stringify(value);
|
|
147
|
+
return typeof value === "string" ? value : JSON.stringify(value);
|
|
151
148
|
}
|
|
152
149
|
function genericFieldChanges(previous, current, skipKeys) {
|
|
153
150
|
const keys = /* @__PURE__ */ new Set([...Object.keys(previous), ...Object.keys(current)]);
|
|
@@ -190,17 +187,7 @@ function recordFieldChanges(previous, current) {
|
|
|
190
187
|
return changes;
|
|
191
188
|
}
|
|
192
189
|
function byIdentity(a, b) {
|
|
193
|
-
return a.file.localeCompare(b.file) || a.exportName.localeCompare(b.exportName) ||
|
|
194
|
-
// array this function ever sorts: a `ManifestContractRef` never carries
|
|
195
|
-
// a `key` at all, but its own array can never hold two entries sharing
|
|
196
|
-
// both file+exportName (contracts are unique by that pair) so the key
|
|
197
|
-
// term is never reached for them either way; a `ManifestVariableRef`'s
|
|
198
|
-
// `key` is always a real, non-empty string, never `undefined`. Hand-
|
|
199
|
-
// verified: mutating both fallbacks to a distinguishing sentinel and
|
|
200
|
-
// running the real suite (this file plus
|
|
201
|
-
// check-artifacts.test.ts/generate-evidence.test.ts) passes unchanged.
|
|
202
|
-
// Stryker disable next-line StringLiteral
|
|
203
|
-
(a.key ?? "").localeCompare(b.key ?? "");
|
|
190
|
+
return a.file.localeCompare(b.file) || a.exportName.localeCompare(b.exportName) || String(a.key).localeCompare(String(b.key));
|
|
204
191
|
}
|
|
205
192
|
function diffContracts(previous, current) {
|
|
206
193
|
const previousContracts = new Map((previous ?? []).map((c) => [contractIdentity(c), c]));
|
|
@@ -219,25 +206,12 @@ function diffContracts(previous, current) {
|
|
|
219
206
|
const changes = genericFieldChanges(
|
|
220
207
|
previousContract,
|
|
221
208
|
currentContract,
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
// contracts of a matched pair share the same Map key
|
|
225
|
-
// (`contractIdentity()`), itself derived from file+exportName, so
|
|
226
|
-
// they're always structurally equal for two contracts matched
|
|
227
|
-
// into one updatedContracts entry. Hand-verified equivalent via
|
|
228
|
-
// direct mutation + a real suite run.
|
|
229
|
-
// Stryker disable next-line StringLiteral
|
|
230
|
-
"file",
|
|
231
|
-
// Stryker disable next-line StringLiteral
|
|
232
|
-
"exportName",
|
|
233
|
-
// Genuinely skipped AND real-tested -- see "does not report the
|
|
234
|
-
// whole variables array as a changed field" below.
|
|
235
|
-
"variables"
|
|
236
|
-
])
|
|
209
|
+
// `file` and `exportName` cannot differ for a matched pair (they make up its identity).
|
|
210
|
+
/* @__PURE__ */ new Set(["variables"])
|
|
237
211
|
);
|
|
238
212
|
if (changes.length > 0) updatedContracts.push({ ...toContractRef(currentContract), changes });
|
|
239
213
|
}
|
|
240
|
-
const previousVariables = new Map(
|
|
214
|
+
const previousVariables = new Map(previousContract?.variables.map((v) => [v.key, v]));
|
|
241
215
|
const currentVariables = new Map(currentContract.variables.map((v) => [v.key, v]));
|
|
242
216
|
for (const [key, currentVariable] of currentVariables) {
|
|
243
217
|
const previousVariable = previousVariables.get(key);
|
|
@@ -248,16 +222,14 @@ function diffContracts(previous, current) {
|
|
|
248
222
|
const changes = genericFieldChanges(
|
|
249
223
|
previousVariable,
|
|
250
224
|
currentVariable,
|
|
251
|
-
/* @__PURE__ */ new Set(
|
|
225
|
+
/* @__PURE__ */ new Set()
|
|
252
226
|
);
|
|
253
227
|
if (changes.length > 0)
|
|
254
228
|
updatedVariables.push({ ...toVariableRef(currentContract, currentVariable), changes });
|
|
255
229
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
removedVariables.push(toVariableRef(previousContract, previousVariable));
|
|
260
|
-
}
|
|
230
|
+
for (const [key, previousVariable] of previousVariables) {
|
|
231
|
+
if (!currentVariables.has(key))
|
|
232
|
+
removedVariables.push(toVariableRef(currentContract, previousVariable));
|
|
261
233
|
}
|
|
262
234
|
}
|
|
263
235
|
for (const [identity, previousContract] of previousContracts) {
|
|
@@ -301,7 +273,6 @@ async function writeEvidenceSnapshot(snapshotPath, snapshot, fs) {
|
|
|
301
273
|
await fs.writeFile(snapshotPath, `${JSON.stringify(snapshot, null, 2)}
|
|
302
274
|
`, "utf8");
|
|
303
275
|
}
|
|
304
|
-
var EXPIRY_DAY_COUNT = /\b\d+ day\(s\)/g;
|
|
305
276
|
function normalizeEvidenceSnapshotForComparison(snapshot) {
|
|
306
277
|
return {
|
|
307
278
|
...snapshot,
|
|
@@ -325,7 +296,7 @@ function normalizeEvidenceSnapshotForComparison(snapshot) {
|
|
|
325
296
|
finding: {
|
|
326
297
|
...snapshot.finding,
|
|
327
298
|
findings: snapshot.finding.findings.map(
|
|
328
|
-
(f) => f.code === "EXPIRED" || f.code === "EXPIRING_SOON" ? { ...f, message: f.message.replace(
|
|
299
|
+
(f) => f.code === "EXPIRED" || f.code === "EXPIRING_SOON" ? { ...f, message: f.message.replace(/\b\d+ day\(s\)/g, "N day(s)") } : f
|
|
329
300
|
)
|
|
330
301
|
}
|
|
331
302
|
};
|
|
@@ -334,19 +305,22 @@ async function computeEvidenceChanges(root, snapshotPath, activeContracts, curre
|
|
|
334
305
|
const read = await readEvidenceSnapshot(snapshotPath, fs);
|
|
335
306
|
let previous;
|
|
336
307
|
let readWarning;
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
308
|
+
switch (read.status) {
|
|
309
|
+
case "ok":
|
|
310
|
+
previous = read.snapshot;
|
|
311
|
+
break;
|
|
312
|
+
case "invalid-json":
|
|
313
|
+
readWarning = {
|
|
314
|
+
file: snapshotPath,
|
|
315
|
+
message: `Evidence snapshot could not be parsed as JSON (${read.detail}); treating this run as if no previous snapshot existed.`
|
|
316
|
+
};
|
|
317
|
+
break;
|
|
318
|
+
case "unsupported-version":
|
|
319
|
+
readWarning = {
|
|
320
|
+
file: snapshotPath,
|
|
321
|
+
message: `Evidence snapshot has schemaVersion ${JSON.stringify(read.foundVersion)}, which this version of env-cap does not understand (expected ${EVIDENCE_MODEL_SCHEMA_VERSION}); treating this run as if no previous snapshot existed.`
|
|
322
|
+
};
|
|
323
|
+
break;
|
|
350
324
|
}
|
|
351
325
|
const dynamicAccessAcknowledgments = await buildCitationSnapshots(
|
|
352
326
|
activeContracts,
|
|
@@ -375,27 +349,18 @@ import path4 from "path";
|
|
|
375
349
|
// src/build/glob.ts
|
|
376
350
|
function globToRegExp(pattern) {
|
|
377
351
|
let out = "";
|
|
378
|
-
let
|
|
379
|
-
const
|
|
380
|
-
|
|
381
|
-
passes++;
|
|
382
|
-
if (passes > maxPasses) {
|
|
383
|
-
throw new Error(
|
|
384
|
-
// Stryker disable next-line StringLiteral
|
|
385
|
-
`globToRegExp: exceeded ${String(maxPasses)} iterations parsing pattern ${JSON.stringify(pattern)} -- this should never happen for any real pattern and indicates an internal parsing bug.`
|
|
386
|
-
);
|
|
387
|
-
}
|
|
388
|
-
const char = pattern[i];
|
|
389
|
-
if (char === void 0) continue;
|
|
352
|
+
let resume = 0;
|
|
353
|
+
for (const [i, char] of pattern.split("").entries()) {
|
|
354
|
+
if (i < resume) continue;
|
|
390
355
|
if (char === "*" && pattern[i + 1] === "*") {
|
|
391
356
|
const precededBySlashOrStart = i === 0 || pattern[i - 1] === "/";
|
|
392
357
|
const followedBySlash = pattern[i + 2] === "/";
|
|
393
358
|
if (precededBySlashOrStart && followedBySlash) {
|
|
394
359
|
out += "(?:.*/)?";
|
|
395
|
-
i
|
|
360
|
+
resume = i + 3;
|
|
396
361
|
} else {
|
|
397
362
|
out += ".*";
|
|
398
|
-
i
|
|
363
|
+
resume = i + 2;
|
|
399
364
|
}
|
|
400
365
|
} else if (char === "*") {
|
|
401
366
|
out += "[^/]*";
|
|
@@ -426,7 +391,7 @@ async function discoverSchemaFiles(options) {
|
|
|
426
391
|
`discoverSchemaFiles: found ${String(included.length)} files matching "include" under ${options.root} -- more than the ${String(MAX_DISCOVERED_SCHEMA_FILES)}-file sanity limit. This almost always means "root" (or "include"/"exclude") resolved more broadly than intended -- e.g. an omitted "root" falling back to an unexpectedly large process.cwd() -- rather than a real project genuinely declaring this many contracts. Narrow "root"/"include"/"exclude" to the intended project boundary.`
|
|
427
392
|
);
|
|
428
393
|
}
|
|
429
|
-
return included.map((file) => path4.normalize(file)).sort(
|
|
394
|
+
return included.map((file) => path4.normalize(file)).sort();
|
|
430
395
|
}
|
|
431
396
|
async function walkDirectory(directory, root, exclude, fs) {
|
|
432
397
|
const entries = await fs.readdir(directory, { withFileTypes: true });
|
|
@@ -456,11 +421,42 @@ function matchesAnyPattern(filePath, patterns) {
|
|
|
456
421
|
// src/build/link.ts
|
|
457
422
|
import path9 from "path";
|
|
458
423
|
|
|
459
|
-
// src/build/
|
|
460
|
-
import
|
|
424
|
+
// src/build/typescript.ts
|
|
425
|
+
import { createRequire } from "module";
|
|
426
|
+
function hasClassicApi(candidate) {
|
|
427
|
+
return typeof candidate?.createSourceFile === "function";
|
|
428
|
+
}
|
|
429
|
+
function isModuleNotFound(error, id) {
|
|
430
|
+
const { code, message } = error ?? {};
|
|
431
|
+
if (code !== "MODULE_NOT_FOUND" && code !== "ERR_MODULE_NOT_FOUND") return false;
|
|
432
|
+
return typeof message === "string" && (message.startsWith(`Cannot find module '${id}'`) || message.startsWith(`Cannot find package '${id}'`));
|
|
433
|
+
}
|
|
434
|
+
function tryLoad(load, id) {
|
|
435
|
+
try {
|
|
436
|
+
return load(id);
|
|
437
|
+
} catch (error) {
|
|
438
|
+
if (isModuleNotFound(error, id)) return void 0;
|
|
439
|
+
throw error;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
function pickCompiler(load) {
|
|
443
|
+
const consumer = tryLoad(load, "typescript");
|
|
444
|
+
if (hasClassicApi(consumer)) return consumer;
|
|
445
|
+
const bundled = tryLoad(load, "@typescript/typescript6");
|
|
446
|
+
if (hasClassicApi(bundled)) return bundled;
|
|
447
|
+
return consumer ?? {};
|
|
448
|
+
}
|
|
449
|
+
var ts = pickCompiler(createRequire(import.meta.url));
|
|
450
|
+
|
|
451
|
+
// src/build/compiler-api.ts
|
|
452
|
+
function assertCompilerApi(compiler) {
|
|
453
|
+
if (typeof compiler.createSourceFile === "function") return;
|
|
454
|
+
throw new Error(
|
|
455
|
+
`env-cap's build-time scanner needs TypeScript's classic compiler API (typescript ^5 || ^6), but the installed typescript${compiler.version === void 0 ? "" : ` ${compiler.version}`} does not expose it and the bundled @typescript/typescript6 could not be loaded. Reinstall env-cap with its dependencies, or provide a TypeScript 6 compiler: npm install --save-dev typescript@npm:@typescript/typescript6 (this swaps your \`tsc\` for \`tsc6\`; to keep TypeScript 7's \`tsc\`, also add @typescript/native@npm:typescript@^7). See VERSIONING.md, 'Supported toolchain'.`
|
|
456
|
+
);
|
|
457
|
+
}
|
|
461
458
|
|
|
462
459
|
// src/build/literal-eval.ts
|
|
463
|
-
import ts from "typescript";
|
|
464
460
|
function evaluateLiteral(node) {
|
|
465
461
|
if (ts.isStringLiteralLike(node)) return { ok: true, value: node.text };
|
|
466
462
|
if (ts.isNumericLiteral(node)) return { ok: true, value: Number(node.text) };
|
|
@@ -504,12 +500,13 @@ function getStaticPropertyName(name) {
|
|
|
504
500
|
|
|
505
501
|
// src/build/parse.ts
|
|
506
502
|
function parseSchemaFile(filePath, sourceText) {
|
|
507
|
-
|
|
503
|
+
assertCompilerApi(ts);
|
|
504
|
+
const sourceFile = ts.createSourceFile(
|
|
508
505
|
filePath,
|
|
509
506
|
sourceText,
|
|
510
|
-
|
|
507
|
+
ts.ScriptTarget.Latest,
|
|
511
508
|
true,
|
|
512
|
-
|
|
509
|
+
ts.ScriptKind.TS
|
|
513
510
|
);
|
|
514
511
|
const warnings = [];
|
|
515
512
|
const localConsts = /* @__PURE__ */ new Map();
|
|
@@ -518,21 +515,21 @@ function parseSchemaFile(filePath, sourceText) {
|
|
|
518
515
|
const createEnvCalls = [];
|
|
519
516
|
const documentEnvCalls = [];
|
|
520
517
|
for (const statement of sourceFile.statements) {
|
|
521
|
-
if (
|
|
518
|
+
if (ts.isImportDeclaration(statement)) {
|
|
522
519
|
collectImportBindings(statement, imports);
|
|
523
520
|
continue;
|
|
524
521
|
}
|
|
525
|
-
if (!
|
|
526
|
-
const isExported = statement.modifiers?.some((m) => m.kind ===
|
|
522
|
+
if (!ts.isVariableStatement(statement)) continue;
|
|
523
|
+
const isExported = statement.modifiers?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword) ?? false;
|
|
527
524
|
for (const decl of statement.declarationList.declarations) {
|
|
528
|
-
if (!
|
|
525
|
+
if (!ts.isIdentifier(decl.name) || !decl.initializer) continue;
|
|
529
526
|
const bindingName = decl.name.text;
|
|
530
|
-
if (
|
|
527
|
+
if (ts.isObjectLiteralExpression(decl.initializer)) {
|
|
531
528
|
localConsts.set(bindingName, decl.initializer);
|
|
532
529
|
if (isExported) exportedConstNames.add(bindingName);
|
|
533
530
|
continue;
|
|
534
531
|
}
|
|
535
|
-
if (
|
|
532
|
+
if (ts.isCallExpression(decl.initializer)) {
|
|
536
533
|
if (isCallToName(decl.initializer, "createEnv")) {
|
|
537
534
|
if (!isExported) {
|
|
538
535
|
warnings.push({
|
|
@@ -560,9 +557,9 @@ function parseSchemaFile(filePath, sourceText) {
|
|
|
560
557
|
}
|
|
561
558
|
}
|
|
562
559
|
for (const statement of sourceFile.statements) {
|
|
563
|
-
if (!
|
|
560
|
+
if (!ts.isExpressionStatement(statement)) continue;
|
|
564
561
|
const expr = statement.expression;
|
|
565
|
-
if (!
|
|
562
|
+
if (!ts.isCallExpression(expr) || !isCallToName(expr, "documentEnv")) continue;
|
|
566
563
|
const [schemaArg, docsArg] = expr.arguments;
|
|
567
564
|
documentEnvCalls.push({ schemaRef: resolveSchemaRef(schemaArg), docsArg, node: expr });
|
|
568
565
|
}
|
|
@@ -579,15 +576,15 @@ function parseSchemaFile(filePath, sourceText) {
|
|
|
579
576
|
}
|
|
580
577
|
function resolveSchemaRef(node) {
|
|
581
578
|
if (!node) return { kind: "unresolvable" };
|
|
582
|
-
if (
|
|
583
|
-
if (
|
|
579
|
+
if (ts.isObjectLiteralExpression(node)) return { kind: "literal", node };
|
|
580
|
+
if (ts.isIdentifier(node)) return { kind: "identifier", name: node.text };
|
|
584
581
|
return { kind: "unresolvable" };
|
|
585
582
|
}
|
|
586
583
|
function collectImportBindings(statement, imports) {
|
|
587
|
-
if (!
|
|
584
|
+
if (!ts.isStringLiteralLike(statement.moduleSpecifier)) return;
|
|
588
585
|
const specifier = statement.moduleSpecifier.text;
|
|
589
586
|
const namedBindings = statement.importClause?.namedBindings;
|
|
590
|
-
if (!namedBindings || !
|
|
587
|
+
if (!namedBindings || !ts.isNamedImports(namedBindings)) return;
|
|
591
588
|
for (const element of namedBindings.elements) {
|
|
592
589
|
const localName = element.name.text;
|
|
593
590
|
const importedName = element.propertyName?.text ?? localName;
|
|
@@ -596,8 +593,8 @@ function collectImportBindings(statement, imports) {
|
|
|
596
593
|
}
|
|
597
594
|
function isCallToName(call, name) {
|
|
598
595
|
const expr = call.expression;
|
|
599
|
-
if (
|
|
600
|
-
if (
|
|
596
|
+
if (ts.isIdentifier(expr)) return expr.text === name;
|
|
597
|
+
if (ts.isPropertyAccessExpression(expr)) return expr.name.text === name;
|
|
601
598
|
return false;
|
|
602
599
|
}
|
|
603
600
|
function isValidEnvKey(key) {
|
|
@@ -606,7 +603,7 @@ function isValidEnvKey(key) {
|
|
|
606
603
|
function extractSchemaVariables(schemaLiteral, filePath, contextLabel, warnings, sourceFile) {
|
|
607
604
|
const variables = [];
|
|
608
605
|
for (const prop of schemaLiteral.properties) {
|
|
609
|
-
if (!
|
|
606
|
+
if (!ts.isPropertyAssignment(prop)) {
|
|
610
607
|
warnings.push({
|
|
611
608
|
file: filePath,
|
|
612
609
|
message: `Skipped a non-static schema entry in "${contextLabel}" (spread or computed key are not statically analyzable).`
|
|
@@ -622,7 +619,7 @@ function extractSchemaVariables(schemaLiteral, filePath, contextLabel, warnings,
|
|
|
622
619
|
});
|
|
623
620
|
continue;
|
|
624
621
|
}
|
|
625
|
-
if (!
|
|
622
|
+
if (!ts.isObjectLiteralExpression(prop.initializer)) {
|
|
626
623
|
warnings.push({
|
|
627
624
|
file: filePath,
|
|
628
625
|
message: `Definition for "${key}" in "${contextLabel}" is not an inline object literal; skipping static analysis for this variable.`
|
|
@@ -646,7 +643,7 @@ function extractSchemaVariable(key, definition, filePath, contextLabel, warnings
|
|
|
646
643
|
let validatorSource;
|
|
647
644
|
let context;
|
|
648
645
|
for (const prop of definition.properties) {
|
|
649
|
-
if (!
|
|
646
|
+
if (!ts.isPropertyAssignment(prop)) continue;
|
|
650
647
|
const name = getStaticPropertyName(prop.name);
|
|
651
648
|
if (name === "default") {
|
|
652
649
|
hasDefault = true;
|
|
@@ -684,13 +681,13 @@ function extractSchemaVariable(key, definition, filePath, contextLabel, warnings
|
|
|
684
681
|
};
|
|
685
682
|
}
|
|
686
683
|
function extractReturnType(node) {
|
|
687
|
-
if ((
|
|
688
|
-
return node.type.getText().replace(/\s
|
|
684
|
+
if ((ts.isArrowFunction(node) || ts.isFunctionExpression(node)) && node.type) {
|
|
685
|
+
return node.type.getText().replace(/\s/g, "");
|
|
689
686
|
}
|
|
690
687
|
return void 0;
|
|
691
688
|
}
|
|
692
689
|
function normalizeSource(text) {
|
|
693
|
-
return text.replace(/\s+/g, " ")
|
|
690
|
+
return text.replace(/\s+/g, " ");
|
|
694
691
|
}
|
|
695
692
|
function extractContractDocs(docsArg, filePath, contextLabel, warnings) {
|
|
696
693
|
let name;
|
|
@@ -709,7 +706,7 @@ function extractContractDocs(docsArg, filePath, contextLabel, warnings) {
|
|
|
709
706
|
let auditRequired;
|
|
710
707
|
let metadata;
|
|
711
708
|
const variables = /* @__PURE__ */ new Map();
|
|
712
|
-
if (!docsArg || !
|
|
709
|
+
if (!docsArg || !ts.isObjectLiteralExpression(docsArg)) {
|
|
713
710
|
if (docsArg) {
|
|
714
711
|
warnings.push({
|
|
715
712
|
file: filePath,
|
|
@@ -736,7 +733,7 @@ function extractContractDocs(docsArg, filePath, contextLabel, warnings) {
|
|
|
736
733
|
};
|
|
737
734
|
}
|
|
738
735
|
for (const prop of docsArg.properties) {
|
|
739
|
-
if (!
|
|
736
|
+
if (!ts.isPropertyAssignment(prop)) continue;
|
|
740
737
|
const propName = getStaticPropertyName(prop.name);
|
|
741
738
|
if (propName === "name") {
|
|
742
739
|
const evaluated = evaluateLiteral(prop.initializer);
|
|
@@ -840,7 +837,7 @@ function extractContractDocs(docsArg, filePath, contextLabel, warnings) {
|
|
|
840
837
|
});
|
|
841
838
|
}
|
|
842
839
|
} else if (propName === "variables") {
|
|
843
|
-
if (
|
|
840
|
+
if (ts.isObjectLiteralExpression(prop.initializer)) {
|
|
844
841
|
extractVariableDocsMap(prop.initializer, filePath, contextLabel, warnings, variables);
|
|
845
842
|
} else {
|
|
846
843
|
warnings.push({
|
|
@@ -871,10 +868,10 @@ function extractContractDocs(docsArg, filePath, contextLabel, warnings) {
|
|
|
871
868
|
}
|
|
872
869
|
function extractVariableDocsMap(variablesLiteral, filePath, contextLabel, warnings, out) {
|
|
873
870
|
for (const prop of variablesLiteral.properties) {
|
|
874
|
-
if (!
|
|
871
|
+
if (!ts.isPropertyAssignment(prop)) continue;
|
|
875
872
|
const key = getStaticPropertyName(prop.name);
|
|
876
873
|
if (key === void 0) continue;
|
|
877
|
-
if (!
|
|
874
|
+
if (!ts.isObjectLiteralExpression(prop.initializer)) {
|
|
878
875
|
warnings.push({
|
|
879
876
|
file: filePath,
|
|
880
877
|
message: `documentEnv() variable docs for "${key}" in "${contextLabel}" is not an inline object literal; skipped.`
|
|
@@ -904,11 +901,9 @@ function extractVariableDocsMap(variablesLiteral, filePath, contextLabel, warnin
|
|
|
904
901
|
let metadata;
|
|
905
902
|
let evidence;
|
|
906
903
|
for (const field of prop.initializer.properties) {
|
|
907
|
-
if (!
|
|
904
|
+
if (!ts.isPropertyAssignment(field)) continue;
|
|
908
905
|
const fieldName = getStaticPropertyName(field.name);
|
|
909
|
-
if (fieldName === void 0) continue;
|
|
910
906
|
const evaluated = evaluateLiteral(field.initializer);
|
|
911
|
-
if (!evaluated.ok) continue;
|
|
912
907
|
if (fieldName === "description" && typeof evaluated.value === "string")
|
|
913
908
|
description = evaluated.value;
|
|
914
909
|
else if (fieldName === "owner" && typeof evaluated.value === "string") owner = evaluated.value;
|
|
@@ -1004,9 +999,9 @@ function extractDynamicAccessCitations(value, filePath, key, contextLabel, warni
|
|
|
1004
999
|
return citations;
|
|
1005
1000
|
}
|
|
1006
1001
|
function extractCreateEnvOptionsName(optionsArg) {
|
|
1007
|
-
if (!optionsArg || !
|
|
1002
|
+
if (!optionsArg || !ts.isObjectLiteralExpression(optionsArg)) return void 0;
|
|
1008
1003
|
for (const prop of optionsArg.properties) {
|
|
1009
|
-
if (!
|
|
1004
|
+
if (!ts.isPropertyAssignment(prop)) continue;
|
|
1010
1005
|
if (getStaticPropertyName(prop.name) !== "name") continue;
|
|
1011
1006
|
const evaluated = evaluateLiteral(prop.initializer);
|
|
1012
1007
|
if (evaluated.ok && typeof evaluated.value === "string") return evaluated.value;
|
|
@@ -1036,7 +1031,7 @@ function mustGet(map, key) {
|
|
|
1036
1031
|
import path8 from "path";
|
|
1037
1032
|
|
|
1038
1033
|
// src/build/resolution/resolve-package-schema.ts
|
|
1039
|
-
import { createRequire } from "module";
|
|
1034
|
+
import { createRequire as createRequire2 } from "module";
|
|
1040
1035
|
import path6 from "path";
|
|
1041
1036
|
|
|
1042
1037
|
// src/build/resolution/resolve-within-root.ts
|
|
@@ -1069,7 +1064,7 @@ function isRecord2(value) {
|
|
|
1069
1064
|
return typeof value === "object" && value !== null;
|
|
1070
1065
|
}
|
|
1071
1066
|
async function locatePackageManifest(packageName, root, fs) {
|
|
1072
|
-
const req =
|
|
1067
|
+
const req = createRequire2(path6.join(root, "package.json"));
|
|
1073
1068
|
try {
|
|
1074
1069
|
const packageJsonPath = req.resolve(`${packageName}/package.json`);
|
|
1075
1070
|
return { packageJsonPath, packageDir: path6.dirname(packageJsonPath) };
|
|
@@ -1251,7 +1246,6 @@ async function mergeLocalAndPackageFiles(localFiles, packageFiles, fs) {
|
|
|
1251
1246
|
}
|
|
1252
1247
|
async function resolvePackageImport(specifier, allowedPackages, root, cache, fs) {
|
|
1253
1248
|
const matched = allowedPackages.find(
|
|
1254
|
-
// Stryker disable next-line ConditionalExpression
|
|
1255
1249
|
(pkg) => specifier === pkg || specifier.startsWith(`${pkg}/`)
|
|
1256
1250
|
);
|
|
1257
1251
|
if (!matched) return void 0;
|
|
@@ -1261,7 +1255,9 @@ async function resolvePackageImport(specifier, allowedPackages, root, cache, fs)
|
|
|
1261
1255
|
|
|
1262
1256
|
// src/build/resolution/resolve-tsconfig-paths.ts
|
|
1263
1257
|
import path7 from "path";
|
|
1264
|
-
|
|
1258
|
+
function pathMappingOptions(options) {
|
|
1259
|
+
return options;
|
|
1260
|
+
}
|
|
1265
1261
|
function createAliasResolutionCache() {
|
|
1266
1262
|
return { resolutions: /* @__PURE__ */ new Map() };
|
|
1267
1263
|
}
|
|
@@ -1286,9 +1282,10 @@ async function loadTsconfigPaths(root, tsconfigOption, fs) {
|
|
|
1286
1282
|
}
|
|
1287
1283
|
};
|
|
1288
1284
|
}
|
|
1289
|
-
|
|
1285
|
+
assertCompilerApi(ts);
|
|
1286
|
+
const readResult = ts.readConfigFile(configFile, (p) => ts.sys.readFile(p));
|
|
1290
1287
|
if (readResult.error) {
|
|
1291
|
-
const detail =
|
|
1288
|
+
const detail = ts.flattenDiagnosticMessageText(readResult.error.messageText, ts.sys.newLine);
|
|
1292
1289
|
return {
|
|
1293
1290
|
resolution: void 0,
|
|
1294
1291
|
warning: {
|
|
@@ -1297,8 +1294,8 @@ async function loadTsconfigPaths(root, tsconfigOption, fs) {
|
|
|
1297
1294
|
}
|
|
1298
1295
|
};
|
|
1299
1296
|
}
|
|
1300
|
-
const parsed =
|
|
1301
|
-
const { paths, baseUrl } = parsed.options;
|
|
1297
|
+
const parsed = ts.parseJsonConfigFileContent(readResult.config, ts.sys, path7.dirname(configFile));
|
|
1298
|
+
const { paths, baseUrl } = pathMappingOptions(parsed.options);
|
|
1302
1299
|
const hasPaths = paths !== void 0 && Object.keys(paths).length > 0;
|
|
1303
1300
|
if (!hasPaths && baseUrl === void 0) {
|
|
1304
1301
|
return { resolution: void 0, warning: void 0 };
|
|
@@ -1308,7 +1305,7 @@ async function loadTsconfigPaths(root, tsconfigOption, fs) {
|
|
|
1308
1305
|
function resolveAliasImport(specifier, importingFile, resolution, cache) {
|
|
1309
1306
|
const cacheKey = `${importingFile}\0${specifier}`;
|
|
1310
1307
|
if (cache.resolutions.has(cacheKey)) return cache.resolutions.get(cacheKey);
|
|
1311
|
-
const result =
|
|
1308
|
+
const result = ts.resolveModuleName(specifier, importingFile, resolution.compilerOptions, ts.sys);
|
|
1312
1309
|
const resolvedFileName = result.resolvedModule?.resolvedFileName;
|
|
1313
1310
|
let resolved;
|
|
1314
1311
|
if (resolvedFileName) {
|
|
@@ -1336,13 +1333,11 @@ async function resolveRelativeImport(importingFile, specifier, fs) {
|
|
|
1336
1333
|
}
|
|
1337
1334
|
return void 0;
|
|
1338
1335
|
}
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
return false;
|
|
1345
|
-
}
|
|
1336
|
+
function fileExists2(filePath, fs) {
|
|
1337
|
+
return fs.stat(filePath).then(
|
|
1338
|
+
(stat) => stat.isFile(),
|
|
1339
|
+
() => false
|
|
1340
|
+
);
|
|
1346
1341
|
}
|
|
1347
1342
|
async function resolveImportSpecifier(importingFile, specifier, context) {
|
|
1348
1343
|
const relative = await resolveRelativeImport(importingFile, specifier, context.fs);
|
|
@@ -1381,24 +1376,29 @@ async function linkFiles(discoveredFiles, readFile, context, packageOrigins = /*
|
|
|
1381
1376
|
const warnings = [];
|
|
1382
1377
|
const unresolvedLinks = [];
|
|
1383
1378
|
async function resolveSchema(ref, inFile, contextLabel) {
|
|
1384
|
-
if (ref.kind === "unresolvable") return void 0;
|
|
1385
1379
|
const inFileAnalysis = mustGet(analysisCache, inFile);
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1380
|
+
switch (ref.kind) {
|
|
1381
|
+
case "literal":
|
|
1382
|
+
return {
|
|
1383
|
+
identity: `${inFile}#<inline:${ref.node.pos}>`,
|
|
1384
|
+
variables: extractSchemaVariables(
|
|
1385
|
+
ref.node,
|
|
1386
|
+
inFile,
|
|
1387
|
+
contextLabel,
|
|
1388
|
+
warnings,
|
|
1389
|
+
inFileAnalysis.sourceFile
|
|
1390
|
+
)
|
|
1391
|
+
};
|
|
1392
|
+
case "identifier":
|
|
1393
|
+
return resolveNamedSchema(ref.name, inFile, inFileAnalysis, contextLabel);
|
|
1397
1394
|
}
|
|
1398
|
-
|
|
1395
|
+
return void 0;
|
|
1396
|
+
}
|
|
1397
|
+
async function resolveNamedSchema(name, inFile, inFileAnalysis, contextLabel) {
|
|
1398
|
+
const local = inFileAnalysis.localConsts.get(name);
|
|
1399
1399
|
if (local) {
|
|
1400
1400
|
return {
|
|
1401
|
-
identity: `${inFile}#${
|
|
1401
|
+
identity: `${inFile}#${name}`,
|
|
1402
1402
|
variables: extractSchemaVariables(
|
|
1403
1403
|
local,
|
|
1404
1404
|
inFile,
|
|
@@ -1408,7 +1408,7 @@ async function linkFiles(discoveredFiles, readFile, context, packageOrigins = /*
|
|
|
1408
1408
|
)
|
|
1409
1409
|
};
|
|
1410
1410
|
}
|
|
1411
|
-
const imported = inFileAnalysis.imports.get(
|
|
1411
|
+
const imported = inFileAnalysis.imports.get(name);
|
|
1412
1412
|
if (!imported) return void 0;
|
|
1413
1413
|
const targetFile = await resolveImportSpecifier(inFile, imported.specifier, context);
|
|
1414
1414
|
if (!targetFile) return void 0;
|
|
@@ -1594,7 +1594,7 @@ function effectiveAuditRequired(contract, variable) {
|
|
|
1594
1594
|
|
|
1595
1595
|
// src/build/assemble-project.ts
|
|
1596
1596
|
async function assembleProject(options) {
|
|
1597
|
-
const { fs, root, include, exclude, packages, tsconfig } = options;
|
|
1597
|
+
const { fs, root, include, exclude, packages = [], tsconfig } = options;
|
|
1598
1598
|
const fileCache = /* @__PURE__ */ new Map();
|
|
1599
1599
|
const readFileCached = (filePath) => {
|
|
1600
1600
|
let cached = fileCache.get(filePath);
|
|
@@ -1651,7 +1651,6 @@ function buildChangeModel(manifest, currentContracts, root) {
|
|
|
1651
1651
|
const relativeFile = displayPath(root, contract.file);
|
|
1652
1652
|
const cIdentity = contractIdentity2(relativeFile, contract.exportName);
|
|
1653
1653
|
for (const variable of contract.variables) {
|
|
1654
|
-
if (!variable.renamedFrom) continue;
|
|
1655
1654
|
const addedRef = findByContractAndKey(
|
|
1656
1655
|
manifest.addedVariables,
|
|
1657
1656
|
relativeFile,
|
|
@@ -1777,8 +1776,7 @@ function variableShape(variable) {
|
|
|
1777
1776
|
};
|
|
1778
1777
|
}
|
|
1779
1778
|
function shapesMatch(a, b) {
|
|
1780
|
-
|
|
1781
|
-
return a.valueType === b.valueType && a.hasProcessor === b.hasProcessor && a.hasValidator === b.hasValidator;
|
|
1779
|
+
return a.valueType !== "unknown" && a.valueType === b.valueType && a.hasProcessor === b.hasProcessor && a.hasValidator === b.hasValidator;
|
|
1782
1780
|
}
|
|
1783
1781
|
function detectDuplicateVariableShapes(contracts) {
|
|
1784
1782
|
const candidates = contracts.filter((c) => c.active && !c.exclusiveGroup);
|
|
@@ -1919,61 +1917,53 @@ function isPlainObject(value) {
|
|
|
1919
1917
|
}
|
|
1920
1918
|
|
|
1921
1919
|
// src/build/scan-dependencies.ts
|
|
1922
|
-
import ts4 from "typescript";
|
|
1923
1920
|
function unwrapParens(node) {
|
|
1924
1921
|
let current = node;
|
|
1925
|
-
while (
|
|
1922
|
+
while (ts.isParenthesizedExpression(current)) current = current.expression;
|
|
1926
1923
|
return current;
|
|
1927
1924
|
}
|
|
1928
1925
|
function staticElementKey(node) {
|
|
1929
|
-
return
|
|
1926
|
+
return ts.isStringLiteralLike(node) ? node.text : void 0;
|
|
1930
1927
|
}
|
|
1931
1928
|
function forEachBindingName(name, record) {
|
|
1932
|
-
if (
|
|
1929
|
+
if (ts.isIdentifier(name)) {
|
|
1933
1930
|
record(name.text);
|
|
1934
1931
|
return;
|
|
1935
1932
|
}
|
|
1936
1933
|
for (const element of name.elements) {
|
|
1937
|
-
if (
|
|
1934
|
+
if (ts.isOmittedExpression(element)) continue;
|
|
1938
1935
|
forEachBindingName(element.name, record);
|
|
1939
1936
|
}
|
|
1940
1937
|
}
|
|
1941
1938
|
function isAssignmentToken(token) {
|
|
1942
|
-
return token >=
|
|
1939
|
+
return token >= ts.SyntaxKind.FirstAssignment && token <= ts.SyntaxKind.LastAssignment;
|
|
1943
1940
|
}
|
|
1944
1941
|
function recordIfIdentifierTarget(expression, assignedNames) {
|
|
1945
1942
|
const target = unwrapParens(expression);
|
|
1946
|
-
if (
|
|
1943
|
+
if (ts.isIdentifier(target)) assignedNames.add(target.text);
|
|
1947
1944
|
}
|
|
1948
1945
|
function recordAssignmentTargets(node, assignedNames) {
|
|
1949
|
-
if (
|
|
1946
|
+
if (ts.isBinaryExpression(node) && isAssignmentToken(node.operatorToken.kind)) {
|
|
1950
1947
|
recordIfIdentifierTarget(node.left, assignedNames);
|
|
1951
1948
|
return;
|
|
1952
1949
|
}
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
// any other node the two `=== PlusPlus/MinusMinus` checks below both
|
|
1957
|
-
// read `undefined` and fail. Hand-verified: mutating this compound to
|
|
1958
|
-
// `if (true)` and running the real suite passes unchanged.
|
|
1959
|
-
// Stryker disable next-line ConditionalExpression
|
|
1960
|
-
(ts4.isPrefixUnaryExpression(node) || ts4.isPostfixUnaryExpression(node)) && (node.operator === ts4.SyntaxKind.PlusPlusToken || node.operator === ts4.SyntaxKind.MinusMinusToken)
|
|
1961
|
-
) {
|
|
1962
|
-
recordIfIdentifierTarget(node.operand, assignedNames);
|
|
1950
|
+
const { operator, operand } = node;
|
|
1951
|
+
if (operator === ts.SyntaxKind.PlusPlusToken || operator === ts.SyntaxKind.MinusMinusToken) {
|
|
1952
|
+
recordIfIdentifierTarget(operand, assignedNames);
|
|
1963
1953
|
return;
|
|
1964
1954
|
}
|
|
1965
|
-
if ((
|
|
1955
|
+
if ((ts.isForOfStatement(node) || ts.isForInStatement(node)) && !ts.isVariableDeclarationList(node.initializer)) {
|
|
1966
1956
|
recordIfIdentifierTarget(node.initializer, assignedNames);
|
|
1967
1957
|
}
|
|
1968
1958
|
}
|
|
1969
1959
|
function recordDeclarationIntroduction(node, countDeclaration, constAliasCandidates) {
|
|
1970
|
-
if (
|
|
1960
|
+
if (ts.isVariableDeclaration(node) || ts.isParameter(node)) {
|
|
1971
1961
|
forEachBindingName(node.name, countDeclaration);
|
|
1972
|
-
if (!
|
|
1962
|
+
if (!ts.isVariableDeclaration(node) || !ts.isIdentifier(node.name)) return;
|
|
1973
1963
|
if (node.initializer === void 0) return;
|
|
1974
1964
|
const initializer = unwrapParens(node.initializer);
|
|
1975
|
-
const isConst = (
|
|
1976
|
-
if (isConst &&
|
|
1965
|
+
const isConst = (ts.getCombinedNodeFlags(node) & ts.NodeFlags.Const) !== 0;
|
|
1966
|
+
if (isConst && ts.isIdentifier(initializer)) {
|
|
1977
1967
|
constAliasCandidates.push({
|
|
1978
1968
|
aliasName: node.name.text,
|
|
1979
1969
|
baseName: initializer.text,
|
|
@@ -1982,7 +1972,7 @@ function recordDeclarationIntroduction(node, countDeclaration, constAliasCandida
|
|
|
1982
1972
|
}
|
|
1983
1973
|
return;
|
|
1984
1974
|
}
|
|
1985
|
-
if ((
|
|
1975
|
+
if ((ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node)) && node.name) {
|
|
1986
1976
|
countDeclaration(node.name.text);
|
|
1987
1977
|
}
|
|
1988
1978
|
}
|
|
@@ -1996,9 +1986,9 @@ function collectDeclarationFacts(sourceFile) {
|
|
|
1996
1986
|
function walk(node) {
|
|
1997
1987
|
recordDeclarationIntroduction(node, countDeclaration, constAliasCandidates);
|
|
1998
1988
|
recordAssignmentTargets(node, assignedNames);
|
|
1999
|
-
|
|
1989
|
+
ts.forEachChild(node, walk);
|
|
2000
1990
|
}
|
|
2001
|
-
|
|
1991
|
+
ts.forEachChild(sourceFile, walk);
|
|
2002
1992
|
return { declarationCounts, assignedNames, constAliasCandidates };
|
|
2003
1993
|
}
|
|
2004
1994
|
function resolveAliasTargets(candidates, declarationCounts, assignedNames, imports) {
|
|
@@ -2023,21 +2013,22 @@ function bindingElementKey(element) {
|
|
|
2023
2013
|
if (element.propertyName === void 0) {
|
|
2024
2014
|
return element.name.text;
|
|
2025
2015
|
}
|
|
2026
|
-
if (
|
|
2016
|
+
if (ts.isIdentifier(element.propertyName) || ts.isStringLiteral(element.propertyName)) {
|
|
2027
2017
|
return element.propertyName.text;
|
|
2028
2018
|
}
|
|
2029
|
-
if (
|
|
2019
|
+
if (ts.isComputedPropertyName(element.propertyName)) {
|
|
2030
2020
|
const inner = element.propertyName.expression;
|
|
2031
|
-
return
|
|
2021
|
+
return ts.isStringLiteralLike(inner) ? inner.text : inner;
|
|
2032
2022
|
}
|
|
2033
2023
|
return element.propertyName;
|
|
2034
2024
|
}
|
|
2035
2025
|
function scanFileForDependencies(filePath, sourceText) {
|
|
2036
|
-
|
|
2037
|
-
const
|
|
2026
|
+
assertCompilerApi(ts);
|
|
2027
|
+
const scriptKind = filePath.endsWith(".tsx") ? ts.ScriptKind.TSX : ts.ScriptKind.TS;
|
|
2028
|
+
const sourceFile = ts.createSourceFile(
|
|
2038
2029
|
filePath,
|
|
2039
2030
|
sourceText,
|
|
2040
|
-
|
|
2031
|
+
ts.ScriptTarget.Latest,
|
|
2041
2032
|
// Load-bearing, unlike before: `ts.getCombinedNodeFlags()` (used to tell
|
|
2042
2033
|
// a `const` declaration apart from `let`/`var` when resolving alias
|
|
2043
2034
|
// candidates) walks parent pointers internally. Flipping this to `false`
|
|
@@ -2049,9 +2040,9 @@ function scanFileForDependencies(filePath, sourceText) {
|
|
|
2049
2040
|
const imports = /* @__PURE__ */ new Map();
|
|
2050
2041
|
let hasWildcardReExport = false;
|
|
2051
2042
|
for (const statement of sourceFile.statements) {
|
|
2052
|
-
if (
|
|
2043
|
+
if (ts.isImportDeclaration(statement)) {
|
|
2053
2044
|
collectImportBindings(statement, imports);
|
|
2054
|
-
} else if (
|
|
2045
|
+
} else if (ts.isExportDeclaration(statement) && !statement.exportClause && statement.moduleSpecifier) {
|
|
2055
2046
|
hasWildcardReExport = true;
|
|
2056
2047
|
}
|
|
2057
2048
|
}
|
|
@@ -2082,7 +2073,7 @@ function scanFileForDependencies(filePath, sourceText) {
|
|
|
2082
2073
|
for (const element of pattern.elements) {
|
|
2083
2074
|
if (element.dotDotDotToken) {
|
|
2084
2075
|
record(localName, { kind: "escape", via: "rest", ...positionOf(sourceFile, element) });
|
|
2085
|
-
} else if (!
|
|
2076
|
+
} else if (!ts.isIdentifier(element.name)) {
|
|
2086
2077
|
record(localName, {
|
|
2087
2078
|
kind: "escape",
|
|
2088
2079
|
via: "nested-pattern",
|
|
@@ -2098,17 +2089,17 @@ function scanFileForDependencies(filePath, sourceText) {
|
|
|
2098
2089
|
via: "computed-key",
|
|
2099
2090
|
...positionOf(sourceFile, element)
|
|
2100
2091
|
});
|
|
2101
|
-
|
|
2092
|
+
ts.forEachChild(key, visit);
|
|
2102
2093
|
}
|
|
2103
2094
|
}
|
|
2104
|
-
|
|
2095
|
+
ts.forEachChild(element.initializer, visit);
|
|
2105
2096
|
}
|
|
2106
2097
|
}
|
|
2107
2098
|
function tryRecordPropertyOrElementAccess(node) {
|
|
2108
|
-
const isProperty =
|
|
2109
|
-
if (!isProperty && !
|
|
2099
|
+
const isProperty = ts.isPropertyAccessExpression(node);
|
|
2100
|
+
if (!isProperty && !ts.isElementAccessExpression(node)) return false;
|
|
2110
2101
|
const base = unwrapParens(node.expression);
|
|
2111
|
-
if (!
|
|
2102
|
+
if (!ts.isIdentifier(base) || !imports.has(base.text)) return false;
|
|
2112
2103
|
if (isProperty) {
|
|
2113
2104
|
record(base.text, { kind: "member", member: node.name.text, ...positionOf(sourceFile, node) });
|
|
2114
2105
|
return true;
|
|
@@ -2118,28 +2109,28 @@ function scanFileForDependencies(filePath, sourceText) {
|
|
|
2118
2109
|
base.text,
|
|
2119
2110
|
key !== void 0 ? { kind: "member", member: key, ...positionOf(sourceFile, node) } : { kind: "dynamic", ...positionOf(sourceFile, node) }
|
|
2120
2111
|
);
|
|
2121
|
-
|
|
2112
|
+
ts.forEachChild(node.argumentExpression, visit);
|
|
2122
2113
|
return true;
|
|
2123
2114
|
}
|
|
2124
2115
|
function visit(node) {
|
|
2125
|
-
if (
|
|
2116
|
+
if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node) || ts.isVariableDeclaration(node) && handledDeclarations.has(node)) {
|
|
2126
2117
|
return;
|
|
2127
2118
|
}
|
|
2128
|
-
if (
|
|
2119
|
+
if (ts.isVariableDeclaration(node) && ts.isObjectBindingPattern(node.name) && node.initializer) {
|
|
2129
2120
|
const base = unwrapParens(node.initializer);
|
|
2130
|
-
if (
|
|
2121
|
+
if (ts.isIdentifier(base) && imports.has(base.text)) {
|
|
2131
2122
|
recordObjectBindingAccesses(node.name, base.text);
|
|
2132
2123
|
return;
|
|
2133
2124
|
}
|
|
2134
2125
|
}
|
|
2135
2126
|
if (tryRecordPropertyOrElementAccess(node)) return;
|
|
2136
|
-
if (
|
|
2127
|
+
if (ts.isIdentifier(node) && imports.has(node.text)) {
|
|
2137
2128
|
record(node.text, { kind: "reference", ...positionOf(sourceFile, node) });
|
|
2138
2129
|
return;
|
|
2139
2130
|
}
|
|
2140
|
-
|
|
2131
|
+
ts.forEachChild(node, visit);
|
|
2141
2132
|
}
|
|
2142
|
-
|
|
2133
|
+
ts.forEachChild(sourceFile, visit);
|
|
2143
2134
|
return { file: filePath, imports, accessesByLocalName: accesses, hasWildcardReExport };
|
|
2144
2135
|
}
|
|
2145
2136
|
|
|
@@ -2147,8 +2138,11 @@ function scanFileForDependencies(filePath, sourceText) {
|
|
|
2147
2138
|
function generatedFileMarker() {
|
|
2148
2139
|
return "GENERATED FILE";
|
|
2149
2140
|
}
|
|
2150
|
-
function
|
|
2151
|
-
|
|
2141
|
+
function reportRegenerateHint() {
|
|
2142
|
+
return "Regenerate it by re-running the script that calls `generateDocumentation()` / `generateUsageReport()` from `@maverickcer/env-cap/build`.";
|
|
2143
|
+
}
|
|
2144
|
+
function generatedBanner(format = "ts", regenerate = "Run `npx env-cap` to regenerate.") {
|
|
2145
|
+
const text = `${generatedFileMarker()} -- do not edit by hand. ${regenerate}`;
|
|
2152
2146
|
return { ts: `// ${text}`, markdown: `<!-- ${text} -->` }[format];
|
|
2153
2147
|
}
|
|
2154
2148
|
function isGeneratedFile(content) {
|
|
@@ -2159,7 +2153,7 @@ function evidenceDisclaimer() {
|
|
|
2159
2153
|
return "Machine-generated engineering artifact assembled from statically-provable code facts and author-declared documentation. It can support a security, privacy, or compliance review. It does not itself establish compliance with any standard.";
|
|
2160
2154
|
}
|
|
2161
2155
|
function evidenceProjectionNote(evidencePath) {
|
|
2162
|
-
const concept = "Projected from env-cap's Evidence Model (
|
|
2156
|
+
const concept = "Projected from env-cap's Evidence Model (https://github.com/MaverickCER/env-cap/blob/main/GUIDE.md), the same source every other generated artifact draws from.";
|
|
2163
2157
|
return evidencePath === void 0 ? concept : `${concept} This run also wrote it to \`${evidencePath}\`.`;
|
|
2164
2158
|
}
|
|
2165
2159
|
|
|
@@ -2270,8 +2264,7 @@ async function buildDependencyGraph(contracts, scanFiles, readFile, context, sca
|
|
|
2270
2264
|
for (const scan of scanResults) {
|
|
2271
2265
|
for (const [localName, binding] of scan.imports) {
|
|
2272
2266
|
const resolvedFile = await resolveImportSpecifier(scan.file, binding.specifier, context);
|
|
2273
|
-
|
|
2274
|
-
const building = byIdentity2.get(`${resolvedFile}#${binding.importedName}`);
|
|
2267
|
+
const building = byIdentity2.get(`${String(resolvedFile)}#${binding.importedName}`);
|
|
2275
2268
|
if (!building) continue;
|
|
2276
2269
|
building.imported = true;
|
|
2277
2270
|
building.consumingFiles.add(scan.file);
|
|
@@ -2281,8 +2274,7 @@ async function buildDependencyGraph(contracts, scanFiles, readFile, context, sca
|
|
|
2281
2274
|
for (const scan of scanResults) {
|
|
2282
2275
|
for (const [, binding] of scan.imports) {
|
|
2283
2276
|
const resolvedFile = await resolveImportSpecifier(scan.file, binding.specifier, context);
|
|
2284
|
-
|
|
2285
|
-
const targetScan = scanByFile.get(resolvedFile);
|
|
2277
|
+
const targetScan = scanByFile.get(String(resolvedFile));
|
|
2286
2278
|
if (!targetScan?.hasWildcardReExport) continue;
|
|
2287
2279
|
for (const building of byIdentity2.values()) {
|
|
2288
2280
|
if (building.imported) continue;
|
|
@@ -2385,20 +2377,9 @@ async function buildDependencyModel(contracts, scanFiles, readFile, context, roo
|
|
|
2385
2377
|
positions: info.positions.map((p) => relativizePosition2(root, p)),
|
|
2386
2378
|
dynamicAccessAssertions: info.dynamicAccessAssertions
|
|
2387
2379
|
})).sort((a, b) => a.key.localeCompare(b.key)),
|
|
2388
|
-
//
|
|
2389
|
-
//
|
|
2390
|
-
// dependency-graph.ts's own `consumingFiles` is already
|
|
2391
|
-
// `[...building.consumingFiles].sort()` before this projection ever
|
|
2392
|
-
// sees it (see that file's own comment). Hand-verified: dropping this
|
|
2393
|
-
// `.sort()` and running the real suite passes unchanged -- confirmed
|
|
2394
|
-
// again 2026-09-18 against CI's own diagnostic mutation report, which
|
|
2395
|
-
// flagged this exact `MethodExpression` mutant as Survived.
|
|
2396
|
-
// Stryker disable next-line MethodExpression
|
|
2380
|
+
// Sorted after mapping to display paths: a file outside `root` (a package surface) shows as
|
|
2381
|
+
// `../...`, which can order differently from its absolute path.
|
|
2397
2382
|
consumingFiles: [...contract.consumingFiles].map((f) => displayPath(root, f)).sort(),
|
|
2398
|
-
// Same reasoning as `consumingFiles` just above -- the whole
|
|
2399
|
-
// `.map(...).sort()` chain is a coarser-grained `MethodExpression`
|
|
2400
|
-
// mutant target than the next-line one on `.sort()` alone just below.
|
|
2401
|
-
// Stryker disable next-line MethodExpression
|
|
2402
2383
|
ambiguousBarrelFiles: [...contract.ambiguousBarrelFiles].map((f) => displayPath(root, f)).sort(),
|
|
2403
2384
|
dynamicAccessSites: contract.dynamicAccessSites.map((p) => relativizePosition2(root, p))
|
|
2404
2385
|
}));
|
|
@@ -2562,30 +2543,11 @@ function renderManifest(contracts, outputFile) {
|
|
|
2562
2543
|
for (const contract of sorted) {
|
|
2563
2544
|
let localName = contract.exportName;
|
|
2564
2545
|
if (usedNames.has(localName)) {
|
|
2565
|
-
const
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
if (passes > maxSuffix) {
|
|
2571
|
-
throw new Error(
|
|
2572
|
-
// Stryker disable next-line StringLiteral
|
|
2573
|
-
`renderManifest: exceeded ${String(maxSuffix)} attempts choosing a unique local import name for "${contract.exportName}" -- this should never happen and indicates an internal naming bug.`
|
|
2574
|
-
);
|
|
2575
|
-
}
|
|
2576
|
-
const candidate = `${contract.exportName}_${suffix}`;
|
|
2577
|
-
if (!usedNames.has(candidate)) {
|
|
2578
|
-
found = candidate;
|
|
2579
|
-
break;
|
|
2580
|
-
}
|
|
2581
|
-
}
|
|
2582
|
-
if (found === void 0) {
|
|
2583
|
-
throw new Error(
|
|
2584
|
-
// Stryker disable next-line StringLiteral
|
|
2585
|
-
`renderManifest: could not find a unique local import name for "${contract.exportName}" within ${String(maxSuffix)} attempts -- this should never happen and indicates an internal naming bug.`
|
|
2586
|
-
);
|
|
2587
|
-
}
|
|
2588
|
-
localName = found;
|
|
2546
|
+
const candidates = Array.from(
|
|
2547
|
+
{ length: usedNames.size + 1 },
|
|
2548
|
+
(_, index) => `${contract.exportName}_${index + 1}`
|
|
2549
|
+
);
|
|
2550
|
+
localName = String(candidates.find((candidate) => !usedNames.has(candidate)));
|
|
2589
2551
|
}
|
|
2590
2552
|
usedNames.add(localName);
|
|
2591
2553
|
referenceNames.push(localName);
|
|
@@ -2634,10 +2596,8 @@ function defaultExclude() {
|
|
|
2634
2596
|
// inspect `exclude` directly, and as defense if that hardcoding ever
|
|
2635
2597
|
// changes) -- hand-verified: emptying both and running the full
|
|
2636
2598
|
// `vitest run` leaves all 1243 tests passing.
|
|
2637
|
-
// Stryker disable next-line StringLiteral
|
|
2638
2599
|
"**/node_modules/**",
|
|
2639
2600
|
"**/dist/**",
|
|
2640
|
-
// Stryker disable next-line StringLiteral
|
|
2641
2601
|
"**/.git/**"
|
|
2642
2602
|
];
|
|
2643
2603
|
}
|
|
@@ -2667,8 +2627,6 @@ async function generateEnvManifest(options) {
|
|
|
2667
2627
|
const root = path11.resolve(options.root ?? process.cwd());
|
|
2668
2628
|
const include = options.include ?? defaultInclude();
|
|
2669
2629
|
const exclude = options.exclude ?? defaultExclude();
|
|
2670
|
-
const packages = options.packages ?? [];
|
|
2671
|
-
const onIncompatibility = options.onIncompatibility ?? "warn";
|
|
2672
2630
|
const locationResult = resolveWithinRoot(
|
|
2673
2631
|
root,
|
|
2674
2632
|
options.location,
|
|
@@ -2682,10 +2640,10 @@ async function generateEnvManifest(options) {
|
|
|
2682
2640
|
root,
|
|
2683
2641
|
include,
|
|
2684
2642
|
exclude,
|
|
2685
|
-
packages,
|
|
2643
|
+
packages: options.packages,
|
|
2686
2644
|
tsconfig: options.tsconfig
|
|
2687
2645
|
});
|
|
2688
|
-
const computed = computeManifest(root, linkResult, onIncompatibility);
|
|
2646
|
+
const computed = computeManifest(root, linkResult, options.onIncompatibility);
|
|
2689
2647
|
if (computed.blocking.length > 0) throw new EnvManifestGenerationError(computed.blocking);
|
|
2690
2648
|
await writeManifest(outputPath, computed.activeContracts, options.fs);
|
|
2691
2649
|
return {
|
|
@@ -2828,7 +2786,7 @@ function renderParseWarnings(warnings) {
|
|
|
2828
2786
|
}
|
|
2829
2787
|
function renderUsageReport(computed) {
|
|
2830
2788
|
const lines = [
|
|
2831
|
-
generatedBanner("markdown"),
|
|
2789
|
+
generatedBanner("markdown", reportRegenerateHint()),
|
|
2832
2790
|
"",
|
|
2833
2791
|
`> ${evidenceDisclaimer()}`,
|
|
2834
2792
|
"",
|
|
@@ -2836,7 +2794,7 @@ function renderUsageReport(computed) {
|
|
|
2836
2794
|
"",
|
|
2837
2795
|
"# Dependency & Ownership Report",
|
|
2838
2796
|
"",
|
|
2839
|
-
"_Produced by `env-cap
|
|
2797
|
+
"_Produced by `generateUsageReport()` from `@maverickcer/env-cap/build`._",
|
|
2840
2798
|
"",
|
|
2841
2799
|
"Which feature owns each variable, which features consume that contract, and what the blast radius is if it changes.",
|
|
2842
2800
|
"",
|
|
@@ -2848,7 +2806,7 @@ function renderUsageReport(computed) {
|
|
|
2848
2806
|
...renderAsserted(computed.asserted),
|
|
2849
2807
|
...renderParseWarnings(computed.parseWarnings)
|
|
2850
2808
|
];
|
|
2851
|
-
return lines.join("\n")
|
|
2809
|
+
return lines.join("\n");
|
|
2852
2810
|
}
|
|
2853
2811
|
|
|
2854
2812
|
// src/build/generate-usage.ts
|
|
@@ -2879,7 +2837,7 @@ async function computeScanSurface(root, exclude, origins, fs) {
|
|
|
2879
2837
|
}
|
|
2880
2838
|
return { scanFiles, scannedSurfaces };
|
|
2881
2839
|
}
|
|
2882
|
-
async function computeUsage(root, contracts, scanFiles, readFile, context,
|
|
2840
|
+
async function computeUsage(root, contracts, scanFiles, readFile, context, scannedSurfaces, dynamicAccessAcknowledgments) {
|
|
2883
2841
|
const graph = await buildDependencyGraph(
|
|
2884
2842
|
contracts,
|
|
2885
2843
|
scanFiles,
|
|
@@ -2892,13 +2850,9 @@ async function computeUsage(root, contracts, scanFiles, readFile, context, parse
|
|
|
2892
2850
|
const contractByIdentity = /* @__PURE__ */ new Map();
|
|
2893
2851
|
for (const contract of contracts)
|
|
2894
2852
|
contractByIdentity.set(`${contract.file}#${contract.exportName}`, contract);
|
|
2895
|
-
const ownerFor = (file, exportName) => (
|
|
2896
|
-
// Stryker disable next-line OptionalChaining
|
|
2897
|
-
contractByIdentity.get(`${file}#${exportName}`)?.owner
|
|
2898
|
-
);
|
|
2853
|
+
const ownerFor = (file, exportName) => mustGet(contractByIdentity, `${file}#${exportName}`).owner;
|
|
2899
2854
|
const effectiveOwnerFor = (file, exportName, key) => {
|
|
2900
|
-
const contract = contractByIdentity
|
|
2901
|
-
if (!contract) return void 0;
|
|
2855
|
+
const contract = mustGet(contractByIdentity, `${file}#${exportName}`);
|
|
2902
2856
|
const variable = contract.variables.find((v) => v.key === key);
|
|
2903
2857
|
return variable ? effectiveOwner(contract, variable) : contract.owner;
|
|
2904
2858
|
};
|
|
@@ -2924,19 +2878,16 @@ async function computeUsage(root, contracts, scanFiles, readFile, context, parse
|
|
|
2924
2878
|
const staleOrMissingCitationsFor = (contractName, file, exportName, key) => {
|
|
2925
2879
|
const relativeFile = displayPath(root, file);
|
|
2926
2880
|
const identity = dynamicAccessVariableIdentity(relativeFile, exportName, key);
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
if (a.acknowledgment === "fresh") continue;
|
|
2930
|
-
problems.push({
|
|
2881
|
+
return (dynamicAccessAcknowledgments?.get(identity) ?? []).map(
|
|
2882
|
+
(a) => ({
|
|
2931
2883
|
contractName,
|
|
2932
2884
|
file: relativeFile,
|
|
2933
2885
|
exportName,
|
|
2934
2886
|
key,
|
|
2935
2887
|
position: { file: a.file, line: a.line, column: a.column },
|
|
2936
2888
|
acknowledgment: a.acknowledgment
|
|
2937
|
-
})
|
|
2938
|
-
|
|
2939
|
-
return problems;
|
|
2889
|
+
})
|
|
2890
|
+
);
|
|
2940
2891
|
};
|
|
2941
2892
|
const unconsumedOwnedVariables = findings.unconsumedOwned.map(
|
|
2942
2893
|
(f) => ({
|
|
@@ -2981,7 +2932,6 @@ async function computeUsage(root, contracts, scanFiles, readFile, context, parse
|
|
|
2981
2932
|
unconsumedOwnedVariables,
|
|
2982
2933
|
indeterminate,
|
|
2983
2934
|
asserted,
|
|
2984
|
-
parseWarnings,
|
|
2985
2935
|
scannedSurfaces: graph.scannedSurfaces
|
|
2986
2936
|
}
|
|
2987
2937
|
};
|
|
@@ -2995,24 +2945,23 @@ async function generateUsageReport(options) {
|
|
|
2995
2945
|
const root = path12.resolve(options.root ?? process.cwd());
|
|
2996
2946
|
const include = options.include ?? defaultInclude();
|
|
2997
2947
|
const exclude = options.exclude ?? defaultExclude();
|
|
2998
|
-
const packages = options.packages ?? [];
|
|
2999
2948
|
let reportPath;
|
|
3000
2949
|
if (options.report) {
|
|
3001
|
-
const
|
|
2950
|
+
const result2 = resolveWithinRoot(
|
|
3002
2951
|
root,
|
|
3003
2952
|
options.report.location,
|
|
3004
2953
|
"report.location",
|
|
3005
2954
|
"generateUsageReport"
|
|
3006
2955
|
);
|
|
3007
|
-
if (!
|
|
3008
|
-
reportPath =
|
|
2956
|
+
if (!result2.ok) throw new EnvUsageAnalysisError([result2.issue]);
|
|
2957
|
+
reportPath = result2.resolved;
|
|
3009
2958
|
}
|
|
3010
2959
|
const { readFileCached, linkResult, context, origins, packageWarnings, tsconfigWarnings } = await assembleProject({
|
|
3011
2960
|
fs: options.fs,
|
|
3012
2961
|
root,
|
|
3013
2962
|
include,
|
|
3014
2963
|
exclude,
|
|
3015
|
-
packages,
|
|
2964
|
+
packages: options.packages,
|
|
3016
2965
|
tsconfig: options.tsconfig
|
|
3017
2966
|
});
|
|
3018
2967
|
const { scanFiles, scannedSurfaces } = await computeScanSurface(
|
|
@@ -3027,11 +2976,14 @@ async function generateUsageReport(options) {
|
|
|
3027
2976
|
scanFiles,
|
|
3028
2977
|
readFileCached,
|
|
3029
2978
|
context,
|
|
3030
|
-
[...packageWarnings, ...tsconfigWarnings, ...linkResult.warnings],
|
|
3031
2979
|
scannedSurfaces
|
|
3032
2980
|
);
|
|
3033
|
-
|
|
3034
|
-
|
|
2981
|
+
const result = {
|
|
2982
|
+
...computed.result,
|
|
2983
|
+
parseWarnings: [...packageWarnings, ...tsconfigWarnings, ...linkResult.warnings]
|
|
2984
|
+
};
|
|
2985
|
+
if (reportPath) await writeUsageReport(reportPath, result, options.fs);
|
|
2986
|
+
return { reportPath, ...result };
|
|
3035
2987
|
}
|
|
3036
2988
|
|
|
3037
2989
|
// src/build/generate-evidence.ts
|
|
@@ -3351,107 +3303,132 @@ function groupVariablesByOwner(contracts, ownerOf) {
|
|
|
3351
3303
|
}
|
|
3352
3304
|
return byOwner;
|
|
3353
3305
|
}
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3306
|
+
function configurationReference(evidence) {
|
|
3307
|
+
return projectConfigurationReference(evidence).value;
|
|
3308
|
+
}
|
|
3309
|
+
configurationReference.project = projectConfigurationReference;
|
|
3310
|
+
function projectConfigurationReference(evidence) {
|
|
3311
|
+
return defineEvidenceProjection(configurationReferenceSchema()).project(evidence);
|
|
3312
|
+
}
|
|
3313
|
+
function configurationReferenceSchema() {
|
|
3314
|
+
return {
|
|
3315
|
+
disclaimer: evidenceDisclaimer,
|
|
3316
|
+
entries: (evidence) => {
|
|
3317
|
+
const entries = [];
|
|
3318
|
+
for (const contract of evidence.contract.contracts) {
|
|
3319
|
+
for (const variable of contract.variables) {
|
|
3320
|
+
entries.push({
|
|
3321
|
+
file: contract.file,
|
|
3322
|
+
exportName: contract.exportName,
|
|
3323
|
+
contractName: contract.contractName,
|
|
3324
|
+
key: variable.key,
|
|
3325
|
+
description: variable.description,
|
|
3326
|
+
owner: variable.owner ?? contract.owner,
|
|
3327
|
+
sensitivity: variable.sensitivity ?? contract.sensitivity,
|
|
3328
|
+
required: variable.required,
|
|
3329
|
+
hasDefault: variable.hasDefault,
|
|
3330
|
+
hasProcessor: variable.hasProcessor,
|
|
3331
|
+
hasValidator: variable.hasValidator,
|
|
3332
|
+
expiresAt: variable.expiresAt,
|
|
3333
|
+
active: contract.active
|
|
3334
|
+
});
|
|
3335
|
+
}
|
|
3376
3336
|
}
|
|
3337
|
+
return entries.sort(byContractThenKey);
|
|
3377
3338
|
}
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
)
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3339
|
+
};
|
|
3340
|
+
}
|
|
3341
|
+
function ownershipSummary(evidence) {
|
|
3342
|
+
return projectOwnershipSummary(evidence).value;
|
|
3343
|
+
}
|
|
3344
|
+
ownershipSummary.project = projectOwnershipSummary;
|
|
3345
|
+
function projectOwnershipSummary(evidence) {
|
|
3346
|
+
return defineEvidenceProjection(ownershipSummarySchema()).project(evidence);
|
|
3347
|
+
}
|
|
3348
|
+
function ownershipSummarySchema() {
|
|
3349
|
+
return {
|
|
3350
|
+
disclaimer: evidenceDisclaimer,
|
|
3351
|
+
owners: (evidence) => {
|
|
3352
|
+
const contracts = contractIndex(evidence.contract.contracts);
|
|
3353
|
+
const nameOf = (file, exportName) => contracts.get(`${file}#${exportName}`)?.contractName ?? exportName;
|
|
3354
|
+
const variablesByOwner = groupVariablesByOwner(
|
|
3355
|
+
evidence.ownership.contracts,
|
|
3356
|
+
(_contract, variable) => variable.owner
|
|
3357
|
+
);
|
|
3358
|
+
const contractsByOwner = /* @__PURE__ */ new Map();
|
|
3359
|
+
for (const contract of evidence.ownership.contracts) {
|
|
3360
|
+
if (contract.owner === void 0) continue;
|
|
3361
|
+
const list = contractsByOwner.get(contract.owner) ?? [];
|
|
3362
|
+
list.push(nameOf(contract.file, contract.exportName));
|
|
3363
|
+
contractsByOwner.set(contract.owner, list);
|
|
3364
|
+
}
|
|
3365
|
+
const owners = /* @__PURE__ */ new Set([...variablesByOwner.keys(), ...contractsByOwner.keys()]);
|
|
3366
|
+
return [...owners].sort().map((owner) => ({
|
|
3367
|
+
owner,
|
|
3368
|
+
variables: (variablesByOwner.get(owner) ?? []).map(
|
|
3369
|
+
({ contract, variable }) => `${nameOf(contract.file, contract.exportName)}.${variable.key}`
|
|
3370
|
+
).sort(),
|
|
3371
|
+
contracts: (contractsByOwner.get(owner) ?? []).sort()
|
|
3372
|
+
}));
|
|
3373
|
+
},
|
|
3374
|
+
unowned: (evidence) => {
|
|
3375
|
+
const contracts = contractIndex(evidence.contract.contracts);
|
|
3376
|
+
return evidence.ownership.unownedVariables.map((ref) => {
|
|
3377
|
+
const contractName = contracts.get(`${ref.file}#${ref.exportName}`)?.contractName ?? ref.exportName;
|
|
3378
|
+
return `${contractName}.${ref.key}`;
|
|
3379
|
+
}).sort();
|
|
3397
3380
|
}
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
refreshInstructions: variable?.refreshInstructions,
|
|
3439
|
-
owner: entry.key === void 0 ? contract?.owner : ownerByVariable.get(`${entry.file}#${entry.exportName}#${entry.key}`) ?? contract?.owner
|
|
3440
|
-
};
|
|
3441
|
-
});
|
|
3442
|
-
},
|
|
3443
|
-
// Same static covered-mutant false-Survivor as the `disclaimer` arrows
|
|
3444
|
-
// above -- hand-verified killed (mutating this whole arrow to `() =>
|
|
3445
|
-
// undefined` fails the "expiredCount" assertions in every test above).
|
|
3446
|
-
// Stryker disable next-line ArrowFunction
|
|
3447
|
-
expiredCount: (evidence) => evidence.lifecycle.expiring.filter((e) => e.daysRemaining < 0).length
|
|
3448
|
-
});
|
|
3381
|
+
};
|
|
3382
|
+
}
|
|
3383
|
+
function expiringSoonReport(evidence) {
|
|
3384
|
+
return projectExpiringSoonReport(evidence).value;
|
|
3385
|
+
}
|
|
3386
|
+
expiringSoonReport.project = projectExpiringSoonReport;
|
|
3387
|
+
function projectExpiringSoonReport(evidence) {
|
|
3388
|
+
return defineEvidenceProjection(expiringSoonReportSchema()).project(evidence);
|
|
3389
|
+
}
|
|
3390
|
+
function expiringSoonReportSchema() {
|
|
3391
|
+
return {
|
|
3392
|
+
disclaimer: evidenceDisclaimer,
|
|
3393
|
+
entries: (evidence) => {
|
|
3394
|
+
const contracts = contractIndex(evidence.contract.contracts);
|
|
3395
|
+
const ownerByVariable = /* @__PURE__ */ new Map();
|
|
3396
|
+
for (const contract of evidence.ownership.contracts)
|
|
3397
|
+
for (const variable of contract.variables)
|
|
3398
|
+
ownerByVariable.set(
|
|
3399
|
+
`${contract.file}#${contract.exportName}#${variable.key}`,
|
|
3400
|
+
variable.owner
|
|
3401
|
+
);
|
|
3402
|
+
return evidence.lifecycle.expiring.map((entry) => {
|
|
3403
|
+
const contract = contracts.get(`${entry.file}#${entry.exportName}`);
|
|
3404
|
+
const variable = contract?.variables.find((v) => v.key === entry.key);
|
|
3405
|
+
return {
|
|
3406
|
+
file: entry.file,
|
|
3407
|
+
exportName: entry.exportName,
|
|
3408
|
+
contractName: contract?.contractName ?? entry.exportName,
|
|
3409
|
+
key: entry.key,
|
|
3410
|
+
expiresAt: entry.expiresAt,
|
|
3411
|
+
daysRemaining: entry.daysRemaining,
|
|
3412
|
+
expired: entry.daysRemaining < 0,
|
|
3413
|
+
refreshInstructions: variable?.refreshInstructions,
|
|
3414
|
+
owner: entry.key === void 0 ? contract?.owner : ownerByVariable.get(`${entry.file}#${entry.exportName}#${entry.key}`) ?? contract?.owner
|
|
3415
|
+
};
|
|
3416
|
+
});
|
|
3417
|
+
},
|
|
3418
|
+
expiredCount: (evidence) => evidence.lifecycle.expiring.filter((e) => e.daysRemaining < 0).length
|
|
3419
|
+
};
|
|
3420
|
+
}
|
|
3449
3421
|
|
|
3450
3422
|
// src/build/docs.ts
|
|
3451
3423
|
function parseIsoDate(value) {
|
|
3452
3424
|
const date = new Date(value);
|
|
3453
3425
|
return Number.isNaN(date.getTime()) ? void 0 : date;
|
|
3454
3426
|
}
|
|
3427
|
+
function parseExpiry(expiresAt) {
|
|
3428
|
+
const raw = String(expiresAt);
|
|
3429
|
+
const date = parseIsoDate(raw);
|
|
3430
|
+
return date && { raw, date };
|
|
3431
|
+
}
|
|
3455
3432
|
var MS_PER_DAY = 864e5;
|
|
3456
3433
|
function daysRemainingFrom(date, now) {
|
|
3457
3434
|
return Math.ceil((date.getTime() - now.getTime()) / MS_PER_DAY);
|
|
@@ -3459,32 +3436,29 @@ function daysRemainingFrom(date, now) {
|
|
|
3459
3436
|
function computeExpiringEntries(contracts, expiringWithinDays, now) {
|
|
3460
3437
|
const entries = [];
|
|
3461
3438
|
for (const contract of contracts) {
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
});
|
|
3474
|
-
}
|
|
3439
|
+
const contractExpiry = parseExpiry(contract.expiresAt);
|
|
3440
|
+
if (contractExpiry) {
|
|
3441
|
+
const daysRemaining = daysRemainingFrom(contractExpiry.date, now);
|
|
3442
|
+
if (daysRemaining <= expiringWithinDays) {
|
|
3443
|
+
entries.push({
|
|
3444
|
+
file: contract.file,
|
|
3445
|
+
exportName: contract.exportName,
|
|
3446
|
+
key: void 0,
|
|
3447
|
+
expiresAt: contractExpiry.raw,
|
|
3448
|
+
daysRemaining
|
|
3449
|
+
});
|
|
3475
3450
|
}
|
|
3476
3451
|
}
|
|
3477
3452
|
for (const variable of contract.variables) {
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
const daysRemaining = daysRemainingFrom(date, now);
|
|
3453
|
+
const expiry = parseExpiry(variable.expiresAt);
|
|
3454
|
+
if (!expiry) continue;
|
|
3455
|
+
const daysRemaining = daysRemainingFrom(expiry.date, now);
|
|
3482
3456
|
if (daysRemaining <= expiringWithinDays) {
|
|
3483
3457
|
entries.push({
|
|
3484
3458
|
file: contract.file,
|
|
3485
3459
|
exportName: contract.exportName,
|
|
3486
3460
|
key: variable.key,
|
|
3487
|
-
expiresAt:
|
|
3461
|
+
expiresAt: expiry.raw,
|
|
3488
3462
|
daysRemaining
|
|
3489
3463
|
});
|
|
3490
3464
|
}
|
|
@@ -3535,7 +3509,7 @@ function buildCatalog(contracts) {
|
|
|
3535
3509
|
function extractPreviouslyDocumentedKeys(previousContent) {
|
|
3536
3510
|
const keys = /* @__PURE__ */ new Set();
|
|
3537
3511
|
for (const match of previousContent.matchAll(/^### `([A-Za-z_][A-Za-z0-9_]*)`$/gm)) {
|
|
3538
|
-
|
|
3512
|
+
keys.add(String(match[1]));
|
|
3539
3513
|
}
|
|
3540
3514
|
return keys;
|
|
3541
3515
|
}
|
|
@@ -3575,7 +3549,7 @@ function computeChangeSummary(contracts, previousContent) {
|
|
|
3575
3549
|
};
|
|
3576
3550
|
}
|
|
3577
3551
|
function slugify(text) {
|
|
3578
|
-
return text.toLowerCase().replace(/[^a-z0-9_]+/g, "-").replace(
|
|
3552
|
+
return text.toLowerCase().replace(/[^a-z0-9_]+/g, "-").replace(/^-|-$/g, "") || "section";
|
|
3579
3553
|
}
|
|
3580
3554
|
var AnchorRegistry = class {
|
|
3581
3555
|
constructor() {
|
|
@@ -3592,16 +3566,24 @@ var AnchorRegistry = class {
|
|
|
3592
3566
|
this.assigned.set(target, anchor);
|
|
3593
3567
|
return anchor;
|
|
3594
3568
|
}
|
|
3569
|
+
/** The anchor an earlier {@link anchorFor} call assigned to `target`; throws if there was none. */
|
|
3570
|
+
anchorOf(target) {
|
|
3571
|
+
return mustGet(this.assigned, target);
|
|
3572
|
+
}
|
|
3595
3573
|
};
|
|
3596
3574
|
function mdLink(text, anchor) {
|
|
3597
3575
|
return `[${text}](#${anchor})`;
|
|
3598
3576
|
}
|
|
3577
|
+
function sortedByKey(items) {
|
|
3578
|
+
const byKey = new Map(items.map((item) => [item.key, item]));
|
|
3579
|
+
return [...byKey.keys()].sort().map((key) => mustGet(byKey, key));
|
|
3580
|
+
}
|
|
3599
3581
|
function sortedContracts(contracts) {
|
|
3600
3582
|
return [...contracts].sort((a, b) => a.contractName.localeCompare(b.contractName));
|
|
3601
3583
|
}
|
|
3602
3584
|
function renderHeader(contracts, options, anchors, hasOwnership, hasDuplicates, hasLifecycle) {
|
|
3603
3585
|
const lines = [
|
|
3604
|
-
generatedBanner("markdown"),
|
|
3586
|
+
generatedBanner("markdown", reportRegenerateHint()),
|
|
3605
3587
|
"",
|
|
3606
3588
|
`> ${evidenceDisclaimer()}`,
|
|
3607
3589
|
"",
|
|
@@ -3609,7 +3591,7 @@ function renderHeader(contracts, options, anchors, hasOwnership, hasDuplicates,
|
|
|
3609
3591
|
"",
|
|
3610
3592
|
"# Environment Variables",
|
|
3611
3593
|
"",
|
|
3612
|
-
"_Produced by `env-cap
|
|
3594
|
+
"_Produced by `generateDocumentation()` from `@maverickcer/env-cap/build`._",
|
|
3613
3595
|
"",
|
|
3614
3596
|
`_Generated ${options.generatedAt.toISOString()}_`,
|
|
3615
3597
|
""
|
|
@@ -3652,7 +3634,7 @@ function renderCatalog(contracts, anchors, undocumented) {
|
|
|
3652
3634
|
);
|
|
3653
3635
|
}
|
|
3654
3636
|
for (const contract of sortedContracts(contracts)) {
|
|
3655
|
-
lines.push(`<a id="${anchors.
|
|
3637
|
+
lines.push(`<a id="${anchors.anchorOf(contract)}"></a>`);
|
|
3656
3638
|
lines.push(`## ${contract.contractName}`, "", `Source: \`${contract.file}\``);
|
|
3657
3639
|
if (undocumentedByIdentity.has(`${contract.file}#${contract.exportName}`)) {
|
|
3658
3640
|
lines.push("", "> \u26A0\uFE0F **Undocumented.** No `documentEnv()` call is linked to this contract.");
|
|
@@ -3677,10 +3659,8 @@ function renderCatalog(contracts, anchors, undocumented) {
|
|
|
3677
3659
|
}
|
|
3678
3660
|
}
|
|
3679
3661
|
lines.push("");
|
|
3680
|
-
for (const variable of
|
|
3681
|
-
lines.push(
|
|
3682
|
-
`<a id="${anchors.anchorFor(variable, `${contract.contractName}-${variable.key}`)}"></a>`
|
|
3683
|
-
);
|
|
3662
|
+
for (const variable of sortedByKey(contract.variables)) {
|
|
3663
|
+
lines.push(`<a id="${anchors.anchorOf(variable)}"></a>`);
|
|
3684
3664
|
lines.push(`### \`${variable.key}\``, "");
|
|
3685
3665
|
if (variable.description) lines.push(variable.description, "");
|
|
3686
3666
|
if (!variable.documented) lines.push("> \u26A0\uFE0F **Undocumented.**", "");
|
|
@@ -3793,18 +3773,17 @@ function renderLifecycleReport(contracts, anchors, expiringWithinDays, now) {
|
|
|
3793
3773
|
const owner = effectiveOwner(contract, variable);
|
|
3794
3774
|
if (variable.expiresAt === void 0 && owner === void 0 && variable.refreshInstructions === void 0)
|
|
3795
3775
|
continue;
|
|
3796
|
-
const
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
const daysRemaining = daysRemainingFrom(expiry, now);
|
|
3776
|
+
const expiry = parseExpiry(variable.expiresAt);
|
|
3777
|
+
let expiresCell = variable.expiresAt ?? "--";
|
|
3778
|
+
if (expiry) {
|
|
3779
|
+
const daysRemaining = daysRemainingFrom(expiry.date, now);
|
|
3801
3780
|
if (daysRemaining < 0)
|
|
3802
|
-
expiresCell = `${
|
|
3781
|
+
expiresCell = `${expiry.raw} (**expired ${Math.abs(daysRemaining)}d ago**)`;
|
|
3803
3782
|
else if (daysRemaining <= expiringWithinDays)
|
|
3804
|
-
expiresCell = `${
|
|
3783
|
+
expiresCell = `${expiry.raw} (**${daysRemaining}d remaining**)`;
|
|
3805
3784
|
}
|
|
3806
3785
|
rows.push(
|
|
3807
|
-
`| ${mdLink(`\`${variable.key}\``, anchors.
|
|
3786
|
+
`| ${mdLink(`\`${variable.key}\``, anchors.anchorOf(variable))} | ${owner ?? "--"} | ${expiresCell} | ${variable.refreshInstructions ?? "--"} |`
|
|
3808
3787
|
);
|
|
3809
3788
|
}
|
|
3810
3789
|
}
|
|
@@ -3920,7 +3899,14 @@ function renderDocs(contracts, options) {
|
|
|
3920
3899
|
);
|
|
3921
3900
|
const catalog = renderCatalog(sorted, anchors, options.undocumentedContracts);
|
|
3922
3901
|
const security = renderSecurityReview(sorted, options, options.generatedAt);
|
|
3923
|
-
return [
|
|
3902
|
+
return [
|
|
3903
|
+
...header,
|
|
3904
|
+
...catalog,
|
|
3905
|
+
...ownership,
|
|
3906
|
+
...dependencyLines,
|
|
3907
|
+
...lifecycleLines,
|
|
3908
|
+
...security
|
|
3909
|
+
].join("\n");
|
|
3924
3910
|
}
|
|
3925
3911
|
function normalizeDocsForComparison(content) {
|
|
3926
3912
|
return content.replace(/^_Generated .+_$/m, "_Generated <normalized-for-comparison>_").replace(/\(\*\*\d+d remaining\*\*\)/g, "(**Nd remaining**)").replace(/\(\*\*expired \d+d ago\*\*\)/g, "(**expired Nd ago**)").replace(/^(- Already expired:) \d+$/gm, "$1 N").replace(/^(- Expiring within \d+ days:) \d+$/gm, "$1 N");
|
|
@@ -3962,9 +3948,9 @@ function groupByKey(contracts) {
|
|
|
3962
3948
|
const byKey = /* @__PURE__ */ new Map();
|
|
3963
3949
|
for (const contract of contracts) {
|
|
3964
3950
|
for (const variable of contract.variables) {
|
|
3965
|
-
const
|
|
3966
|
-
|
|
3967
|
-
|
|
3951
|
+
const existing = byKey.get(variable.key);
|
|
3952
|
+
if (existing === void 0) byKey.set(variable.key, [{ contract, variable }]);
|
|
3953
|
+
else existing.push({ contract, variable });
|
|
3968
3954
|
}
|
|
3969
3955
|
}
|
|
3970
3956
|
return byKey;
|
|
@@ -3972,7 +3958,6 @@ function groupByKey(contracts) {
|
|
|
3972
3958
|
function renderEnvExample(contracts, reconciliationHeader = []) {
|
|
3973
3959
|
const sorted = [...contracts].sort((a, b) => a.file.localeCompare(b.file));
|
|
3974
3960
|
const active = sorted.filter((c) => c.active);
|
|
3975
|
-
const inactive = sorted.filter((c) => !c.active);
|
|
3976
3961
|
const lines = [
|
|
3977
3962
|
"# AUTO-GENERATED EXAMPLE FILE.",
|
|
3978
3963
|
"# Copy to .env and fill in real values. Do not commit .env."
|
|
@@ -3984,12 +3969,11 @@ function renderEnvExample(contracts, reconciliationHeader = []) {
|
|
|
3984
3969
|
"# still written to this file regardless of its context."
|
|
3985
3970
|
);
|
|
3986
3971
|
}
|
|
3987
|
-
|
|
3972
|
+
lines.push(...reconciliationHeader);
|
|
3988
3973
|
lines.push("");
|
|
3989
3974
|
const activeByKey = groupByKey(active);
|
|
3990
3975
|
for (const key of [...activeByKey.keys()].sort()) {
|
|
3991
3976
|
const [first, ...rest] = mustGet(activeByKey, key);
|
|
3992
|
-
if (first === void 0) continue;
|
|
3993
3977
|
lines.push(...renderVariableLines(first.variable));
|
|
3994
3978
|
for (const dup of rest) {
|
|
3995
3979
|
lines.push(
|
|
@@ -4000,11 +3984,10 @@ function renderEnvExample(contracts, reconciliationHeader = []) {
|
|
|
4000
3984
|
);
|
|
4001
3985
|
}
|
|
4002
3986
|
}
|
|
4003
|
-
const inactiveByKey = groupByKey(
|
|
3987
|
+
const inactiveByKey = groupByKey(sorted);
|
|
4004
3988
|
for (const key of [...inactiveByKey.keys()].sort()) {
|
|
4005
3989
|
if (activeByKey.has(key)) continue;
|
|
4006
3990
|
const [first] = mustGet(inactiveByKey, key);
|
|
4007
|
-
if (first === void 0) continue;
|
|
4008
3991
|
lines.push(
|
|
4009
3992
|
...renderVariableLines(first.variable, {
|
|
4010
3993
|
commented: true,
|
|
@@ -4012,13 +3995,12 @@ function renderEnvExample(contracts, reconciliationHeader = []) {
|
|
|
4012
3995
|
})
|
|
4013
3996
|
);
|
|
4014
3997
|
}
|
|
4015
|
-
return lines.join("\n")
|
|
3998
|
+
return lines.join("\n");
|
|
4016
3999
|
}
|
|
4017
4000
|
function extractDeclaredVariables(source) {
|
|
4018
4001
|
const names = [];
|
|
4019
4002
|
for (const line of source.split("\n")) {
|
|
4020
4003
|
const trimmed = line.trim();
|
|
4021
|
-
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
4022
4004
|
const match = /^([A-Za-z_][A-Za-z0-9_]*)=/.exec(trimmed);
|
|
4023
4005
|
if (match?.[1]) names.push(match[1]);
|
|
4024
4006
|
}
|
|
@@ -4028,9 +4010,7 @@ function extractCommentedVariables(source) {
|
|
|
4028
4010
|
const names = [];
|
|
4029
4011
|
for (const line of source.split("\n")) {
|
|
4030
4012
|
const trimmed = line.trim();
|
|
4031
|
-
|
|
4032
|
-
const withoutHash = trimmed.replace(/^#+\s*/, "");
|
|
4033
|
-
const match = /^([A-Za-z_][A-Za-z0-9_]*)=/.exec(withoutHash);
|
|
4013
|
+
const match = /^#+\s*([A-Za-z_][A-Za-z0-9_]*)=/.exec(trimmed);
|
|
4034
4014
|
if (match?.[1]) names.push(match[1]);
|
|
4035
4015
|
}
|
|
4036
4016
|
return names;
|
|
@@ -4112,7 +4092,7 @@ function collectVariableNames(contracts) {
|
|
|
4112
4092
|
}
|
|
4113
4093
|
function overrideVariable(variable, overrides) {
|
|
4114
4094
|
const override = overrides[variable.key];
|
|
4115
|
-
const date =
|
|
4095
|
+
const date = parseIsoDate(String(override));
|
|
4116
4096
|
return {
|
|
4117
4097
|
...variable,
|
|
4118
4098
|
expiresAt: date ? override : variable.expiresAt,
|
|
@@ -4134,16 +4114,14 @@ async function resolveLiveExpirationDates(contracts, liveExpirationDates) {
|
|
|
4134
4114
|
|
|
4135
4115
|
// src/build/generate-documentation.ts
|
|
4136
4116
|
var DEFAULT_EXPIRING_WITHIN_DAYS = 30;
|
|
4137
|
-
|
|
4138
|
-
"secret",
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
"config"
|
|
4142
|
-
]);
|
|
4117
|
+
function standardSensitivityLevels() {
|
|
4118
|
+
return ["secret", "credential", "pii", "config"];
|
|
4119
|
+
}
|
|
4120
|
+
var STANDARD_SENSITIVITY_LEVELS = new Set(standardSensitivityLevels());
|
|
4143
4121
|
function findNonstandardSensitivityLevels(contracts) {
|
|
4144
4122
|
const entries = [];
|
|
4145
4123
|
for (const contract of contracts) {
|
|
4146
|
-
if (contract.sensitivity !== void 0 && !
|
|
4124
|
+
if (contract.sensitivity !== void 0 && !standardSensitivityLevels().includes(contract.sensitivity))
|
|
4147
4125
|
entries.push({
|
|
4148
4126
|
file: contract.file,
|
|
4149
4127
|
exportName: contract.exportName,
|
|
@@ -4152,7 +4130,7 @@ function findNonstandardSensitivityLevels(contracts) {
|
|
|
4152
4130
|
});
|
|
4153
4131
|
for (const variable of [...contract.variables].sort((a, b) => a.key.localeCompare(b.key))) {
|
|
4154
4132
|
if (variable.sensitivity === void 0) continue;
|
|
4155
|
-
if (
|
|
4133
|
+
if (standardSensitivityLevels().includes(variable.sensitivity)) continue;
|
|
4156
4134
|
entries.push({
|
|
4157
4135
|
file: contract.file,
|
|
4158
4136
|
exportName: contract.exportName,
|
|
@@ -4193,36 +4171,20 @@ async function writeDocumentation(docsPath, envExamplePath, root, contracts, con
|
|
|
4193
4171
|
undocumentedContracts: documentation.undocumentedContracts.map(
|
|
4194
4172
|
(ref) => relativizeRef(root, ref)
|
|
4195
4173
|
),
|
|
4196
|
-
|
|
4197
|
-
// ONLY via `.length` (the security-review counter) -- never by content
|
|
4198
|
-
// or identity, unlike its `undocumentedContracts` sibling above (matched
|
|
4199
|
-
// by identity against the catalog for the "Undocumented." marker).
|
|
4200
|
-
// `.map()` always preserves length regardless of what each element
|
|
4201
|
-
// transforms to, so this specific `relativizeRef()` call's own output is
|
|
4202
|
-
// unobservable through this call site. Hand-verified: mapping every
|
|
4203
|
-
// entry to `undefined` instead and running the full `vitest run` leaves
|
|
4204
|
-
// all tests passing.
|
|
4205
|
-
// Stryker disable next-line ArrowFunction
|
|
4206
|
-
undocumentedVariables: documentation.undocumentedVariables.map(
|
|
4207
|
-
(ref) => relativizeRef(root, ref)
|
|
4208
|
-
),
|
|
4174
|
+
undocumentedVariables: documentation.undocumentedVariables,
|
|
4209
4175
|
generatedAt,
|
|
4210
4176
|
previousContent
|
|
4211
4177
|
});
|
|
4212
4178
|
await fs.mkdir(path14.dirname(docsPath), { recursive: true });
|
|
4213
4179
|
await fs.writeFile(docsPath, docsSource, "utf8");
|
|
4214
4180
|
const envExample = envExamplePath ? (
|
|
4215
|
-
// exactOptionalPropertyTypes
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
await writeEnvExample(contracts, envExamplePath, fs, {
|
|
4223
|
-
// Stryker disable next-line ConditionalExpression
|
|
4224
|
-
...envExampleOnExisting === void 0 ? {} : { onExisting: envExampleOnExisting }
|
|
4225
|
-
})
|
|
4181
|
+
// `exactOptionalPropertyTypes` rejects an explicit `undefined`, so the key is omitted when unset.
|
|
4182
|
+
await writeEnvExample(
|
|
4183
|
+
contracts,
|
|
4184
|
+
envExamplePath,
|
|
4185
|
+
fs,
|
|
4186
|
+
envExampleOnExisting && { onExisting: envExampleOnExisting }
|
|
4187
|
+
)
|
|
4226
4188
|
) : void 0;
|
|
4227
4189
|
return { envExample };
|
|
4228
4190
|
}
|
|
@@ -4230,7 +4192,6 @@ async function generateDocumentation(options) {
|
|
|
4230
4192
|
const root = path14.resolve(options.root ?? process.cwd());
|
|
4231
4193
|
const include = options.include ?? defaultInclude();
|
|
4232
4194
|
const exclude = options.exclude ?? defaultExclude();
|
|
4233
|
-
const packages = options.packages ?? [];
|
|
4234
4195
|
const expiringWithinDays = options.expiringWithinDays ?? DEFAULT_EXPIRING_WITHIN_DAYS;
|
|
4235
4196
|
const docsLocationResult = resolveWithinRoot(
|
|
4236
4197
|
root,
|
|
@@ -4256,7 +4217,7 @@ async function generateDocumentation(options) {
|
|
|
4256
4217
|
root,
|
|
4257
4218
|
include,
|
|
4258
4219
|
exclude,
|
|
4259
|
-
packages,
|
|
4220
|
+
packages: options.packages,
|
|
4260
4221
|
tsconfig: options.tsconfig
|
|
4261
4222
|
});
|
|
4262
4223
|
const docsContracts = await resolveLiveExpirationDates(
|
|
@@ -4310,7 +4271,7 @@ function parseRotationPeriodDays(value) {
|
|
|
4310
4271
|
if (plain) {
|
|
4311
4272
|
const amount = Number(plain[1]);
|
|
4312
4273
|
if (amount > 0) {
|
|
4313
|
-
const unit = (plain[2]
|
|
4274
|
+
const unit = String(plain[2]).toLowerCase();
|
|
4314
4275
|
switch (unit) {
|
|
4315
4276
|
case "day":
|
|
4316
4277
|
case "days":
|
|
@@ -4343,18 +4304,14 @@ function parseRotationPeriodDays(value) {
|
|
|
4343
4304
|
}
|
|
4344
4305
|
function computeRotationStatus(variable, now) {
|
|
4345
4306
|
if (!hasRotationData(variable)) return "undeclared";
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
if (expiry !== void 0 && expiry.getTime() < now.getTime()) return "expired";
|
|
4349
|
-
}
|
|
4307
|
+
const expiry = parseIsoDate(String(variable.expiresAt));
|
|
4308
|
+
if (expiry !== void 0 && expiry.getTime() < now.getTime()) return "expired";
|
|
4350
4309
|
if (variable.rotationPeriod !== void 0) {
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
return dueDate < now.getTime() ? "overdue" : "compliant";
|
|
4357
|
-
}
|
|
4310
|
+
const lastRotated = parseIsoDate(String(variable.lastRotatedAt));
|
|
4311
|
+
const periodDays = parseRotationPeriodDays(variable.rotationPeriod);
|
|
4312
|
+
if (lastRotated !== void 0 && lastRotated.getTime() <= now.getTime() && periodDays !== void 0) {
|
|
4313
|
+
const dueDate = lastRotated.getTime() + periodDays * MS_PER_DAY2;
|
|
4314
|
+
return dueDate < now.getTime() ? "overdue" : "compliant";
|
|
4358
4315
|
}
|
|
4359
4316
|
return "overdue";
|
|
4360
4317
|
}
|
|
@@ -4439,7 +4396,6 @@ async function generateEvidenceModel(options) {
|
|
|
4439
4396
|
const root = path15.resolve(options.root ?? process.cwd());
|
|
4440
4397
|
const include = options.include ?? defaultInclude();
|
|
4441
4398
|
const exclude = options.exclude ?? defaultExclude();
|
|
4442
|
-
const packages = options.packages ?? [];
|
|
4443
4399
|
const expiringWithinDays = options.expiringWithinDays ?? DEFAULT_EXPIRING_WITHIN_DAYS;
|
|
4444
4400
|
let snapshotPath;
|
|
4445
4401
|
if (options.previousSnapshotLocation !== void 0) {
|
|
@@ -4457,10 +4413,10 @@ async function generateEvidenceModel(options) {
|
|
|
4457
4413
|
root,
|
|
4458
4414
|
include,
|
|
4459
4415
|
exclude,
|
|
4460
|
-
packages,
|
|
4416
|
+
packages: options.packages,
|
|
4461
4417
|
tsconfig: options.tsconfig
|
|
4462
4418
|
});
|
|
4463
|
-
const { readFileCached, linkResult, context, origins
|
|
4419
|
+
const { readFileCached, linkResult, context, origins } = assembled;
|
|
4464
4420
|
const generatedAt = /* @__PURE__ */ new Date();
|
|
4465
4421
|
const activeContracts = linkResult.contracts.filter((c) => c.active);
|
|
4466
4422
|
const lifecycleContracts = options.liveExpirationDates ? await resolveLiveExpirationDates(linkResult.contracts, options.liveExpirationDates) : linkResult.contracts;
|
|
@@ -4514,8 +4470,6 @@ async function generateEvidenceModel(options) {
|
|
|
4514
4470
|
scanFiles,
|
|
4515
4471
|
readFileCached,
|
|
4516
4472
|
context,
|
|
4517
|
-
// Stryker disable next-line ArrayDeclaration
|
|
4518
|
-
[...packageWarnings, ...tsconfigWarnings, ...linkResult.warnings],
|
|
4519
4473
|
scannedSurfaces,
|
|
4520
4474
|
evidenceChanges?.dynamicAccessAcknowledgments
|
|
4521
4475
|
);
|
|
@@ -4528,12 +4482,7 @@ async function generateEvidenceModel(options) {
|
|
|
4528
4482
|
unresolvedConsumers: usageComputed.result.unresolvedConsumers,
|
|
4529
4483
|
unconsumedOwnedVariables: usageComputed.result.unconsumedOwnedVariables,
|
|
4530
4484
|
indeterminateOwnership: usageComputed.result.indeterminate,
|
|
4531
|
-
|
|
4532
|
-
// on this exact same field, so even an `undefined` that slipped past
|
|
4533
|
-
// this one (e.g. `??`-vs-`&&` on `evidenceChanges?.…`) is caught there
|
|
4534
|
-
// identically -- belt-and-suspenders, not independently observable.
|
|
4535
|
-
// Stryker disable next-line LogicalOperator
|
|
4536
|
-
dynamicAccessCitationProblems: evidenceChanges?.dynamicAccessCitationProblems ?? []
|
|
4485
|
+
dynamicAccessCitationProblems: evidenceChanges?.dynamicAccessCitationProblems
|
|
4537
4486
|
});
|
|
4538
4487
|
const commit = options.commit ? await options.commit() : void 0;
|
|
4539
4488
|
return deepFreeze({
|
|
@@ -4589,7 +4538,6 @@ async function getEvidenceModel(options) {
|
|
|
4589
4538
|
const root = path16.resolve(options.root ?? process.cwd());
|
|
4590
4539
|
const include = options.include ?? defaultInclude();
|
|
4591
4540
|
const exclude = options.exclude ?? defaultExclude();
|
|
4592
|
-
const packages = options.packages ?? [];
|
|
4593
4541
|
const evidencePath = path16.resolve(root, options.location);
|
|
4594
4542
|
const fingerprintPath = fingerprintPathFor(evidencePath);
|
|
4595
4543
|
const recompute = async (missReason) => ({
|
|
@@ -4604,7 +4552,7 @@ async function getEvidenceModel(options) {
|
|
|
4604
4552
|
root,
|
|
4605
4553
|
include,
|
|
4606
4554
|
exclude,
|
|
4607
|
-
packages
|
|
4555
|
+
packages: options.packages
|
|
4608
4556
|
});
|
|
4609
4557
|
} catch (error) {
|
|
4610
4558
|
return recompute(
|
|
@@ -4652,91 +4600,61 @@ function findingFiles(finding) {
|
|
|
4652
4600
|
if (location.model === "change") return [location.path];
|
|
4653
4601
|
return location.file === void 0 ? [] : [location.file];
|
|
4654
4602
|
}
|
|
4603
|
+
function requestedPass(option) {
|
|
4604
|
+
return option === false ? void 0 : option;
|
|
4605
|
+
}
|
|
4655
4606
|
async function computeArtifacts(options) {
|
|
4656
4607
|
const root = path17.resolve(options.root ?? process.cwd());
|
|
4657
4608
|
const include = options.include ?? defaultInclude();
|
|
4658
4609
|
const exclude = options.exclude ?? defaultExclude();
|
|
4659
|
-
const
|
|
4660
|
-
const
|
|
4661
|
-
const
|
|
4662
|
-
const
|
|
4663
|
-
const evidenceOptions = options.evidence === false ? void 0 : options.evidence;
|
|
4610
|
+
const manifestOptions = requestedPass(options.manifest);
|
|
4611
|
+
const docsOptions = requestedPass(options.docs);
|
|
4612
|
+
const usageOptions = requestedPass(options.usage);
|
|
4613
|
+
const evidenceOptions = requestedPass(options.evidence);
|
|
4664
4614
|
const pathIssues = [];
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
if (result.ok) docsPath = result.resolved;
|
|
4686
|
-
else pathIssues.push(result.issue);
|
|
4687
|
-
if (docsOptions.envExample) {
|
|
4688
|
-
const exampleResult = resolveWithinRoot(
|
|
4689
|
-
root,
|
|
4690
|
-
docsOptions.envExample.location,
|
|
4691
|
-
"docs.envExample.location",
|
|
4692
|
-
"generateEnvArtifacts"
|
|
4693
|
-
);
|
|
4694
|
-
if (exampleResult.ok) envExamplePath = exampleResult.resolved;
|
|
4695
|
-
else pathIssues.push(exampleResult.issue);
|
|
4696
|
-
}
|
|
4697
|
-
}
|
|
4698
|
-
let usageReportPath;
|
|
4699
|
-
if (usageOptions?.report) {
|
|
4700
|
-
const result = resolveWithinRoot(
|
|
4701
|
-
root,
|
|
4702
|
-
usageOptions.report.location,
|
|
4703
|
-
"usage.report.location",
|
|
4704
|
-
"generateEnvArtifacts"
|
|
4705
|
-
);
|
|
4706
|
-
if (result.ok) usageReportPath = result.resolved;
|
|
4707
|
-
else pathIssues.push(result.issue);
|
|
4708
|
-
}
|
|
4709
|
-
let evidencePath;
|
|
4710
|
-
if (evidenceOptions) {
|
|
4711
|
-
const result = resolveWithinRoot(
|
|
4712
|
-
root,
|
|
4713
|
-
evidenceOptions.location,
|
|
4714
|
-
"evidence.location",
|
|
4715
|
-
"generateEnvArtifacts"
|
|
4716
|
-
);
|
|
4717
|
-
if (result.ok) evidencePath = result.resolved;
|
|
4718
|
-
else pathIssues.push(result.issue);
|
|
4719
|
-
}
|
|
4615
|
+
const resolveOutput = (location, label) => {
|
|
4616
|
+
const result = resolveWithinRoot(root, location, label, "generateEnvArtifacts");
|
|
4617
|
+
if (result.ok) return result.resolved;
|
|
4618
|
+
pathIssues.push(result.issue);
|
|
4619
|
+
return location;
|
|
4620
|
+
};
|
|
4621
|
+
const manifestTarget = manifestOptions && {
|
|
4622
|
+
options: manifestOptions,
|
|
4623
|
+
outputPath: resolveOutput(manifestOptions.location, "manifest.location")
|
|
4624
|
+
};
|
|
4625
|
+
const docsTarget = docsOptions && {
|
|
4626
|
+
options: docsOptions,
|
|
4627
|
+
path: resolveOutput(docsOptions.location, "docs.location"),
|
|
4628
|
+
envExamplePath: docsOptions.envExample ? resolveOutput(docsOptions.envExample.location, "docs.envExample.location") : void 0
|
|
4629
|
+
};
|
|
4630
|
+
const usageTarget = usageOptions && {
|
|
4631
|
+
options: usageOptions,
|
|
4632
|
+
reportPath: usageOptions.report ? resolveOutput(usageOptions.report.location, "usage.report.location") : void 0
|
|
4633
|
+
};
|
|
4634
|
+
const evidencePath = evidenceOptions ? resolveOutput(evidenceOptions.location, "evidence.location") : void 0;
|
|
4720
4635
|
if (pathIssues.length > 0) throw new EnvProjectGenerationError(pathIssues);
|
|
4721
4636
|
const { readFileCached, linkResult, context, origins, packageWarnings, tsconfigWarnings } = await assembleProject({
|
|
4722
4637
|
fs: options.fs,
|
|
4723
4638
|
root,
|
|
4724
4639
|
include,
|
|
4725
4640
|
exclude,
|
|
4726
|
-
packages,
|
|
4641
|
+
packages: options.packages,
|
|
4727
4642
|
tsconfig: options.tsconfig
|
|
4728
4643
|
});
|
|
4729
4644
|
const generatedAt = /* @__PURE__ */ new Date();
|
|
4730
4645
|
const activeContracts = linkResult.contracts.filter((c) => c.active);
|
|
4731
4646
|
const liveExpirationContracts = options.liveExpirationDates ? await resolveLiveExpirationDates(linkResult.contracts, options.liveExpirationDates) : linkResult.contracts;
|
|
4732
|
-
const docsContracts =
|
|
4647
|
+
const docsContracts = docsTarget ? liveExpirationContracts : linkResult.contracts;
|
|
4733
4648
|
const blocking = [];
|
|
4734
|
-
const
|
|
4735
|
-
|
|
4649
|
+
const manifest = manifestTarget && {
|
|
4650
|
+
...manifestTarget,
|
|
4651
|
+
computed: computeManifest(root, linkResult, manifestTarget.options.onIncompatibility)
|
|
4652
|
+
};
|
|
4653
|
+
if (manifest) blocking.push(...manifest.computed.blocking);
|
|
4736
4654
|
const docsComputed = computeDocumentation(
|
|
4737
4655
|
root,
|
|
4738
4656
|
{ ...linkResult, contracts: liveExpirationContracts },
|
|
4739
|
-
|
|
4657
|
+
docsTarget?.options.expiringWithinDays ?? DEFAULT_EXPIRING_WITHIN_DAYS,
|
|
4740
4658
|
generatedAt
|
|
4741
4659
|
);
|
|
4742
4660
|
const { scanFiles, scannedSurfaces } = await computeScanSurface(
|
|
@@ -4760,14 +4678,13 @@ async function computeArtifacts(options) {
|
|
|
4760
4678
|
scanFiles,
|
|
4761
4679
|
readFileCached,
|
|
4762
4680
|
context,
|
|
4763
|
-
[...packageWarnings, ...tsconfigWarnings, ...linkResult.warnings],
|
|
4764
4681
|
scannedSurfaces,
|
|
4765
4682
|
evidenceChanges?.dynamicAccessAcknowledgments
|
|
4766
4683
|
);
|
|
4767
4684
|
const ownership = buildOwnershipModel(linkResult.contracts, root);
|
|
4768
4685
|
const lifecycle = buildLifecycleModel(
|
|
4769
4686
|
liveExpirationContracts,
|
|
4770
|
-
|
|
4687
|
+
docsTarget?.options.expiringWithinDays ?? DEFAULT_EXPIRING_WITHIN_DAYS,
|
|
4771
4688
|
generatedAt,
|
|
4772
4689
|
root
|
|
4773
4690
|
);
|
|
@@ -4804,7 +4721,7 @@ async function computeArtifacts(options) {
|
|
|
4804
4721
|
unresolvedConsumers: usageComputed.result.unresolvedConsumers,
|
|
4805
4722
|
unconsumedOwnedVariables: usageComputed.result.unconsumedOwnedVariables,
|
|
4806
4723
|
indeterminateOwnership: usageComputed.result.indeterminate,
|
|
4807
|
-
dynamicAccessCitationProblems: evidenceChanges?.dynamicAccessCitationProblems
|
|
4724
|
+
dynamicAccessCitationProblems: evidenceChanges?.dynamicAccessCitationProblems
|
|
4808
4725
|
});
|
|
4809
4726
|
if (options.onUndocumented === "throw")
|
|
4810
4727
|
blocking.push(...escalatedFindings(finding.findings, "documentation"));
|
|
@@ -4826,16 +4743,11 @@ async function computeArtifacts(options) {
|
|
|
4826
4743
|
});
|
|
4827
4744
|
return {
|
|
4828
4745
|
root,
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
manifestComputed,
|
|
4832
|
-
docsOptions,
|
|
4833
|
-
docsPath,
|
|
4834
|
-
envExamplePath,
|
|
4746
|
+
manifest,
|
|
4747
|
+
docs: docsTarget,
|
|
4835
4748
|
docsComputed,
|
|
4836
4749
|
docsContracts,
|
|
4837
|
-
|
|
4838
|
-
usageReportPath,
|
|
4750
|
+
usage: usageTarget,
|
|
4839
4751
|
usageComputed,
|
|
4840
4752
|
evidencePath,
|
|
4841
4753
|
evidence,
|
|
@@ -4848,16 +4760,11 @@ async function computeArtifacts(options) {
|
|
|
4848
4760
|
async function generateEnvArtifacts(options) {
|
|
4849
4761
|
const computed = await computeArtifacts(options);
|
|
4850
4762
|
const {
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
manifestComputed,
|
|
4854
|
-
docsOptions,
|
|
4855
|
-
docsPath,
|
|
4856
|
-
envExamplePath,
|
|
4763
|
+
manifest,
|
|
4764
|
+
docs,
|
|
4857
4765
|
docsComputed,
|
|
4858
4766
|
docsContracts,
|
|
4859
|
-
|
|
4860
|
-
usageReportPath,
|
|
4767
|
+
usage,
|
|
4861
4768
|
usageComputed,
|
|
4862
4769
|
evidencePath,
|
|
4863
4770
|
evidence,
|
|
@@ -4868,43 +4775,47 @@ async function generateEnvArtifacts(options) {
|
|
|
4868
4775
|
generatedAt
|
|
4869
4776
|
} = computed;
|
|
4870
4777
|
if (blocking.length > 0) throw new EnvProjectGenerationError(blocking);
|
|
4778
|
+
const parseWarnings = [...packageWarnings, ...linkWarnings];
|
|
4871
4779
|
let manifestResult;
|
|
4872
|
-
if (
|
|
4873
|
-
await writeManifest(
|
|
4780
|
+
if (manifest) {
|
|
4781
|
+
await writeManifest(manifest.outputPath, manifest.computed.activeContracts, options.fs);
|
|
4874
4782
|
manifestResult = {
|
|
4875
|
-
outputPath:
|
|
4876
|
-
contracts:
|
|
4877
|
-
warnings:
|
|
4878
|
-
parseWarnings
|
|
4783
|
+
outputPath: manifest.outputPath,
|
|
4784
|
+
contracts: manifest.computed.contractSummaries,
|
|
4785
|
+
warnings: manifest.computed.warnings,
|
|
4786
|
+
parseWarnings
|
|
4879
4787
|
};
|
|
4880
4788
|
}
|
|
4881
4789
|
let docsResult;
|
|
4882
|
-
if (
|
|
4790
|
+
if (docs) {
|
|
4883
4791
|
const { envExample } = await writeDocumentation(
|
|
4884
|
-
|
|
4885
|
-
envExamplePath,
|
|
4792
|
+
docs.path,
|
|
4793
|
+
docs.envExamplePath,
|
|
4886
4794
|
root,
|
|
4887
4795
|
docsContracts,
|
|
4888
4796
|
docsComputed.contractModelContracts,
|
|
4889
4797
|
docsComputed.documentation,
|
|
4890
|
-
|
|
4798
|
+
docs.options.expiringWithinDays ?? DEFAULT_EXPIRING_WITHIN_DAYS,
|
|
4891
4799
|
generatedAt,
|
|
4892
4800
|
options.fs,
|
|
4893
|
-
|
|
4801
|
+
docs.options.envExample?.onExisting
|
|
4894
4802
|
);
|
|
4895
4803
|
docsResult = {
|
|
4896
|
-
docsPath,
|
|
4804
|
+
docsPath: docs.path,
|
|
4897
4805
|
envExample,
|
|
4898
4806
|
contracts: docsComputed.contractSummaries,
|
|
4899
4807
|
catalog: docsComputed.catalog,
|
|
4900
|
-
parseWarnings
|
|
4808
|
+
parseWarnings,
|
|
4901
4809
|
documentation: docsComputed.documentation
|
|
4902
4810
|
};
|
|
4903
4811
|
}
|
|
4904
4812
|
let usageResult;
|
|
4905
|
-
if (
|
|
4906
|
-
|
|
4907
|
-
|
|
4813
|
+
if (usage) {
|
|
4814
|
+
const usageReport = { ...usageComputed.result, parseWarnings };
|
|
4815
|
+
if (usage.reportPath !== void 0) {
|
|
4816
|
+
await writeUsageReport(usage.reportPath, usageReport, options.fs);
|
|
4817
|
+
}
|
|
4818
|
+
usageResult = { reportPath: usage.reportPath, ...usageReport };
|
|
4908
4819
|
}
|
|
4909
4820
|
if (evidencePath) {
|
|
4910
4821
|
await writeEvidenceSnapshot(evidencePath, evidence, options.fs);
|
|
@@ -4913,7 +4824,7 @@ async function generateEnvArtifacts(options) {
|
|
|
4913
4824
|
root,
|
|
4914
4825
|
include: options.include ?? defaultInclude(),
|
|
4915
4826
|
exclude: options.exclude ?? defaultExclude(),
|
|
4916
|
-
packages: options.packages
|
|
4827
|
+
packages: options.packages
|
|
4917
4828
|
});
|
|
4918
4829
|
await writeEvidenceFingerprint(evidencePath, fingerprint, options.fs);
|
|
4919
4830
|
}
|
|
@@ -4921,12 +4832,8 @@ async function generateEnvArtifacts(options) {
|
|
|
4921
4832
|
}
|
|
4922
4833
|
|
|
4923
4834
|
// src/build/check-artifacts.ts
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
return await fs.readFile(filePath, "utf8");
|
|
4927
|
-
} catch {
|
|
4928
|
-
return void 0;
|
|
4929
|
-
}
|
|
4835
|
+
function readIfExists(filePath, fs) {
|
|
4836
|
+
return fs.readFile(filePath, "utf8").catch(() => void 0);
|
|
4930
4837
|
}
|
|
4931
4838
|
function normalizeEvidenceJsonForComparison(text) {
|
|
4932
4839
|
try {
|
|
@@ -4952,46 +4859,38 @@ async function checkEnvArtifacts(options) {
|
|
|
4952
4859
|
const c = await computeArtifacts(options);
|
|
4953
4860
|
if (c.blocking.length > 0) throw new EnvProjectGenerationError(c.blocking);
|
|
4954
4861
|
const findings = [];
|
|
4955
|
-
if (c.
|
|
4956
|
-
const expected = renderManifest(c.
|
|
4957
|
-
findings.push(
|
|
4862
|
+
if (c.manifest) {
|
|
4863
|
+
const expected = renderManifest(c.manifest.computed.activeContracts, c.manifest.outputPath);
|
|
4864
|
+
findings.push(
|
|
4865
|
+
await compareTextArtifact("manifest", c.manifest.outputPath, expected, options.fs)
|
|
4866
|
+
);
|
|
4958
4867
|
}
|
|
4959
|
-
if (c.
|
|
4960
|
-
const previousContent = await readIfExists(c.
|
|
4868
|
+
if (c.docs) {
|
|
4869
|
+
const previousContent = await readIfExists(c.docs.path, options.fs);
|
|
4961
4870
|
const expected = renderDocs(c.docsComputed.contractModelContracts, {
|
|
4962
|
-
expiringWithinDays: c.
|
|
4871
|
+
expiringWithinDays: c.docs.options.expiringWithinDays ?? DEFAULT_EXPIRING_WITHIN_DAYS,
|
|
4963
4872
|
undocumentedContracts: c.docsComputed.documentation.undocumentedContracts.map(
|
|
4964
4873
|
(ref) => relativizeRef(c.root, ref)
|
|
4965
4874
|
),
|
|
4966
|
-
|
|
4967
|
-
// ONLY via `.length` (the security-review counter), never by content
|
|
4968
|
-
// or identity -- same equivalence already established for
|
|
4969
|
-
// `generate-documentation.ts`'s identical call site. Hand-verified:
|
|
4970
|
-
// mapping every entry to `undefined` instead and running the full
|
|
4971
|
-
// `vitest run` leaves every test passing.
|
|
4972
|
-
// Stryker disable ArrowFunction
|
|
4973
|
-
undocumentedVariables: c.docsComputed.documentation.undocumentedVariables.map(
|
|
4974
|
-
(ref) => relativizeRef(c.root, ref)
|
|
4975
|
-
),
|
|
4976
|
-
// Stryker restore ArrowFunction
|
|
4875
|
+
undocumentedVariables: c.docsComputed.documentation.undocumentedVariables,
|
|
4977
4876
|
generatedAt: c.generatedAt,
|
|
4978
4877
|
previousContent
|
|
4979
4878
|
});
|
|
4980
4879
|
findings.push(
|
|
4981
4880
|
await compareTextArtifact(
|
|
4982
4881
|
"docs",
|
|
4983
|
-
c.
|
|
4882
|
+
c.docs.path,
|
|
4984
4883
|
expected,
|
|
4985
4884
|
options.fs,
|
|
4986
4885
|
normalizeDocsForComparison
|
|
4987
4886
|
)
|
|
4988
4887
|
);
|
|
4989
|
-
if (c.
|
|
4990
|
-
const existing = await readIfExists(c.envExamplePath, options.fs);
|
|
4888
|
+
if (c.docs.envExamplePath !== void 0) {
|
|
4889
|
+
const existing = await readIfExists(c.docs.envExamplePath, options.fs);
|
|
4991
4890
|
if (existing === void 0) {
|
|
4992
4891
|
findings.push({
|
|
4993
4892
|
artifact: "envExample",
|
|
4994
|
-
path: c.envExamplePath,
|
|
4893
|
+
path: c.docs.envExamplePath,
|
|
4995
4894
|
status: "missing",
|
|
4996
4895
|
detail: "not yet generated"
|
|
4997
4896
|
});
|
|
@@ -5003,7 +4902,7 @@ async function checkEnvArtifacts(options) {
|
|
|
5003
4902
|
const driftCount = staleVariables.length + variablesToComment.length + variablesToAdd.length;
|
|
5004
4903
|
findings.push({
|
|
5005
4904
|
artifact: "envExample",
|
|
5006
|
-
path: c.envExamplePath,
|
|
4905
|
+
path: c.docs.envExamplePath,
|
|
5007
4906
|
status: driftCount > 0 ? "stale" : "ok",
|
|
5008
4907
|
// exactOptionalPropertyTypes: omit the key entirely rather than
|
|
5009
4908
|
// set it to `undefined` -- `detail` is absent when there's
|
|
@@ -5015,9 +4914,12 @@ async function checkEnvArtifacts(options) {
|
|
|
5015
4914
|
}
|
|
5016
4915
|
}
|
|
5017
4916
|
}
|
|
5018
|
-
if (c.
|
|
5019
|
-
const expected = renderUsageReport(
|
|
5020
|
-
|
|
4917
|
+
if (c.usage?.reportPath !== void 0) {
|
|
4918
|
+
const expected = renderUsageReport({
|
|
4919
|
+
...c.usageComputed.result,
|
|
4920
|
+
parseWarnings: [...c.packageWarnings, ...c.linkWarnings]
|
|
4921
|
+
});
|
|
4922
|
+
findings.push(await compareTextArtifact("usage", c.usage.reportPath, expected, options.fs));
|
|
5021
4923
|
}
|
|
5022
4924
|
if (c.evidencePath) {
|
|
5023
4925
|
const expected = JSON.stringify(c.evidence, null, 2);
|
|
@@ -5042,7 +4944,7 @@ function sarifLocations(finding) {
|
|
|
5042
4944
|
const location = finding.location;
|
|
5043
4945
|
const uri = location.model === "change" ? location.path : location.file;
|
|
5044
4946
|
if (uri === void 0) return void 0;
|
|
5045
|
-
const position = location
|
|
4947
|
+
const { position } = location;
|
|
5046
4948
|
return [
|
|
5047
4949
|
{
|
|
5048
4950
|
physicalLocation: {
|
|
@@ -5145,4 +5047,4 @@ export {
|
|
|
5145
5047
|
resolveRelativeImport,
|
|
5146
5048
|
writeEnvExample
|
|
5147
5049
|
};
|
|
5148
|
-
//# sourceMappingURL=build-
|
|
5050
|
+
//# sourceMappingURL=build-H4KFV44Z.js.map
|