@maverickcer/env-cap 0.6.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ADOPTION.md +144 -0
- package/AGENTS.md +146 -0
- package/CHANGELOG.md +449 -0
- package/CODE_OF_CONDUCT.md +124 -0
- package/CODE_REVIEW.md +200 -0
- package/CONTRIBUTING.md +131 -0
- package/GUIDE.md +1214 -0
- package/PROMPT.md +89 -0
- package/README.md +92 -200
- package/RELEASING.md +160 -0
- package/SECURITY.md +270 -0
- package/SUPPORT.md +76 -0
- package/VERSIONING.md +118 -0
- package/benchmarks/READING-BENCHMARKS.md +197 -0
- package/benchmarks/README.md +126 -0
- package/benchmarks/WRITING-BENCHMARKS.md +252 -0
- package/benchmarks/performance-buildtime/BENCHMARKS.md +889 -0
- package/benchmarks/performance-runtime/BENCHMARKS.md +1988 -0
- package/dist/.dts/_ipc/build-fs.d.ts +53 -0
- package/dist/.dts/_ipc/build-fs.d.ts.map +1 -0
- package/dist/.dts/_ipc/compiler-api.d.ts +17 -0
- package/dist/.dts/_ipc/compiler-api.d.ts.map +1 -0
- package/dist/.dts/_ipc/display-path.d.ts +27 -0
- package/dist/.dts/_ipc/display-path.d.ts.map +1 -0
- package/dist/.dts/_ipc/generated-banner.d.ts +58 -0
- package/dist/.dts/_ipc/generated-banner.d.ts.map +1 -0
- package/dist/.dts/_ipc/glob.d.ts +22 -0
- package/dist/.dts/_ipc/glob.d.ts.map +1 -0
- package/dist/.dts/_ipc/no-node-fs.d.ts +35 -0
- package/dist/.dts/_ipc/no-node-fs.d.ts.map +1 -0
- package/dist/.dts/_ipc/resolve-tsconfig-paths.d.ts +134 -0
- package/dist/.dts/_ipc/resolve-tsconfig-paths.d.ts.map +1 -0
- package/dist/.dts/_ipc/typescript.d.ts +20 -0
- package/dist/.dts/_ipc/typescript.d.ts.map +1 -0
- package/dist/.dts/build/compatibility.d.ts.map +1 -1
- package/dist/.dts/build/compiler-api.d.ts +3 -6
- package/dist/.dts/build/compiler-api.d.ts.map +1 -1
- package/dist/.dts/build/display-path.d.ts +3 -21
- package/dist/.dts/build/display-path.d.ts.map +1 -1
- package/dist/.dts/build/generated-banner.d.ts +21 -42
- package/dist/.dts/build/generated-banner.d.ts.map +1 -1
- package/dist/.dts/build/glob.d.ts +3 -15
- package/dist/.dts/build/glob.d.ts.map +1 -1
- package/dist/.dts/build/index.d.ts +3 -3
- package/dist/.dts/build/link.d.ts.map +1 -1
- package/dist/.dts/build/merge-documentation.d.ts +35 -0
- package/dist/.dts/build/merge-documentation.d.ts.map +1 -0
- package/dist/.dts/build/resolution/resolve-tsconfig-paths.d.ts +11 -112
- package/dist/.dts/build/resolution/resolve-tsconfig-paths.d.ts.map +1 -1
- package/dist/.dts/build/types.d.ts +4 -53
- package/dist/.dts/build/types.d.ts.map +1 -1
- package/dist/.dts/build/typescript.d.ts +3 -17
- package/dist/.dts/build/typescript.d.ts.map +1 -1
- package/dist/.dts/eslint-plugin/glob.d.ts +4 -15
- package/dist/.dts/eslint-plugin/glob.d.ts.map +1 -1
- package/dist/.dts/eslint-plugin/index.d.ts +1 -1
- package/dist/.dts/eslint-plugin/no-node-fs.d.ts +8 -18
- 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/{build-H4KFV44Z.js → build-F3RQS7VE.js} +218 -63
- package/dist/build-F3RQS7VE.js.map +1 -0
- package/dist/build.cjs +257 -102
- package/dist/build.cjs.map +1 -1
- package/dist/build.js +256 -101
- package/dist/build.js.map +1 -1
- package/dist/{chunk-7GVPOHDU.js → chunk-QKIQ3LZP.js} +2 -2
- package/dist/cli/index.js +36 -29
- package/dist/cli/index.js.map +1 -1
- package/dist/eslint-plugin/index.cjs +95 -54
- package/dist/eslint-plugin/index.cjs.map +1 -1
- package/dist/eslint-plugin/index.js +94 -53
- package/dist/eslint-plugin/index.js.map +1 -1
- package/examples/README.md +95 -0
- package/package.json +53 -19
- package/skills/env-cap/SKILL.md +91 -0
- package/skills/env-cap/references/api.md +220 -0
- package/specs/architecture.md +634 -0
- package/specs/decisions/0001-runtime-documentation-separation.md +197 -0
- package/specs/decisions/0002-static-analysis-never-execution.md +233 -0
- package/specs/decisions/0003-no-global-env-object.md +172 -0
- package/specs/decisions/0004-no-client-server-package-split.md +116 -0
- package/specs/decisions/0005-warn-not-throw-by-default.md +93 -0
- package/specs/decisions/0006-self-redacting-contracts.md +124 -0
- package/specs/decisions/0007-processor-not-transformer.md +109 -0
- package/specs/decisions/0008-gzip-size-budget.md +173 -0
- package/specs/decisions/0009-exclusive-groups-are-always-errors.md +139 -0
- package/specs/decisions/0010-dependency-ownership-engine-scope-boundary.md +100 -0
- package/specs/decisions/0011-shared-discovery-compute-atomic-write-non-atomic.md +104 -0
- package/specs/decisions/0012-live-expiration-overrides-not-ast-functions.md +145 -0
- package/specs/decisions/0013-json-output-is-a-versioned-mirror.md +136 -0
- package/specs/decisions/0014-cross-package-schema-discovery.md +206 -0
- package/specs/decisions/0015-security-backport-window.md +60 -0
- package/specs/decisions/0016-check-mode-compute-before-compare-never-partial-write.md +113 -0
- package/specs/decisions/0017-eslint-plugin-entry-point.md +113 -0
- package/specs/decisions/0018-rotation-alert-issue-on-non-pr-runs.md +104 -0
- package/specs/decisions/0019-published-json-schema-generated-from-types.md +100 -0
- package/specs/decisions/0020-declaration-maps-via-separate-tsc-pass.md +101 -0
- package/specs/decisions/0021-manifest-change-report-persisted-snapshot.md +177 -0
- package/specs/decisions/0022-validation-contexts.md +267 -0
- package/specs/decisions/0023-tsconfig-path-alias-resolution.md +182 -0
- package/specs/decisions/0024-fact-model-architecture.md +144 -0
- package/specs/decisions/0025-contract-model-json-projection.md +105 -0
- package/specs/decisions/0026-finding-model-unifies-four-families.md +109 -0
- package/specs/decisions/0027-dependency-model-fact-shape-not-engine-access.md +98 -0
- package/specs/decisions/0028-ownership-model-shared-effective-owner.md +85 -0
- package/specs/decisions/0029-lifecycle-model-deprecation-rename-fields.md +98 -0
- package/specs/decisions/0030-change-model-wraps-manifest-change-report.md +97 -0
- package/specs/decisions/0031-evidence-entry-point.md +85 -0
- package/specs/decisions/0032-evidence-projection-provenance-mechanism.md +120 -0
- package/specs/decisions/0033-reference-projections-live-in-examples.md +81 -0
- package/specs/decisions/0034-three-tier-examples-restructuring.md +85 -0
- package/specs/decisions/0035-documentenv-metadata-generalization-and-compliance-fields.md +85 -0
- package/specs/decisions/0036-exact-source-position-evidence.md +122 -0
- package/specs/decisions/0037-developer-declared-dynamic-access-citations.md +114 -0
- package/specs/decisions/0038-always-computed-evidence-model-backs-generate-check-docs.md +244 -0
- package/specs/decisions/0039-scanner-local-dataflow-boundary.md +160 -0
- package/specs/decisions/0040-library-surfaces-do-not-acquire-node-fs.md +156 -0
- package/specs/decisions/0041-dual-package-hazard-checked-documented.md +75 -0
- package/specs/decisions/0042-init-cli-subcommand-scaffolds-only.md +95 -0
- package/specs/decisions/0043-env-cap-resolver-relocated-and-duplicated.md +71 -0
- package/specs/decisions/0044-strict-escalates-every-warning-family.md +88 -0
- package/specs/decisions/0045-promote-experimental-surfaces-to-stable.md +103 -0
- package/specs/decisions/0046-cli-restricted-to-runtime-and-evidence-output.md +177 -0
- package/specs/decisions/0047-supported-toolchain-node-22-and-typescript-5-6.md +30 -0
- package/specs/decisions/0048-eslint-plugin-does-not-vendor-typescript-eslint.md +25 -0
- package/specs/decisions/0049-typescript-7-scanner-uses-a-bundled-typescript-6.md +87 -0
- package/specs/decisions/0050-a-variable-declared-twice-is-documented-once.md +55 -0
- package/specs/generated-artifacts.md +104 -0
- package/specs/migrations/README.md +30 -0
- package/specs/migrations/from-centralized-schema.md +503 -0
- package/specs/migrations/from-dotenv.md +352 -0
- package/specs/migrations/from-envalid.md +482 -0
- package/specs/migrations/from-process-env.md +398 -0
- package/specs/migrations/from-t3-env.md +416 -0
- package/specs/migrations/from-zod.md +303 -0
- package/dist/build-H4KFV44Z.js.map +0 -1
- /package/dist/{chunk-7GVPOHDU.js.map → chunk-QKIQ3LZP.js.map} +0 -0
package/dist/build.cjs
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var path = require('path');
|
|
4
4
|
var crypto = require('crypto');
|
|
5
5
|
var module$1 = require('module');
|
|
6
6
|
|
|
7
7
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
10
10
|
var crypto__default = /*#__PURE__*/_interopDefault(crypto);
|
|
11
11
|
|
|
12
12
|
// node_modules/tsup/assets/cjs_shims.js
|
|
13
13
|
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
|
|
14
14
|
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
15
|
-
function displayPath(root,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
function displayPath(root, filePath) {
|
|
16
|
+
if (!path__default.default.isAbsolute(filePath)) return filePath.split(path__default.default.sep).join("/");
|
|
17
|
+
const relative = path__default.default.relative(root, filePath);
|
|
18
|
+
if (relative === ".." || relative.startsWith(`..${path__default.default.sep}`) || path__default.default.isAbsolute(relative))
|
|
19
|
+
return filePath;
|
|
20
|
+
return relative.split(path__default.default.sep).join("/");
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
// src/build/source-position.ts
|
|
@@ -75,7 +77,7 @@ async function buildCitationSnapshots(activeContracts, previous, root, readFile)
|
|
|
75
77
|
let acknowledgment;
|
|
76
78
|
let contentHash;
|
|
77
79
|
try {
|
|
78
|
-
const content = await readFile(
|
|
80
|
+
const content = await readFile(path__default.default.resolve(root, position.file));
|
|
79
81
|
contentHash = hashContent(content);
|
|
80
82
|
const baseline = previousBaselines.get(
|
|
81
83
|
`${identity}#${position.file}:${position.line}:${position.column}`
|
|
@@ -269,7 +271,7 @@ async function readEvidenceSnapshot(snapshotPath, fs) {
|
|
|
269
271
|
return { status: "ok", snapshot: parsed };
|
|
270
272
|
}
|
|
271
273
|
async function writeEvidenceSnapshot(snapshotPath, snapshot, fs) {
|
|
272
|
-
await fs.mkdir(
|
|
274
|
+
await fs.mkdir(path__default.default.dirname(snapshotPath), { recursive: true });
|
|
273
275
|
await fs.writeFile(snapshotPath, `${JSON.stringify(snapshot, null, 2)}
|
|
274
276
|
`, "utf8");
|
|
275
277
|
}
|
|
@@ -340,7 +342,7 @@ async function computeEvidenceChanges(root, snapshotPath, activeContracts, curre
|
|
|
340
342
|
};
|
|
341
343
|
}
|
|
342
344
|
|
|
343
|
-
// src/
|
|
345
|
+
// src/_ipc/glob.ts
|
|
344
346
|
function globToRegExp(pattern) {
|
|
345
347
|
let out = "";
|
|
346
348
|
let resume = 0;
|
|
@@ -385,13 +387,13 @@ async function discoverSchemaFiles(options) {
|
|
|
385
387
|
`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.`
|
|
386
388
|
);
|
|
387
389
|
}
|
|
388
|
-
return included.map((file) =>
|
|
390
|
+
return included.map((file) => path__default.default.normalize(file)).sort();
|
|
389
391
|
}
|
|
390
392
|
async function walkDirectory(directory, root, exclude, fs) {
|
|
391
393
|
const entries = await fs.readdir(directory, { withFileTypes: true });
|
|
392
394
|
const results = [];
|
|
393
395
|
for (const entry of entries) {
|
|
394
|
-
const fullPath =
|
|
396
|
+
const fullPath = path__default.default.join(directory, entry.name);
|
|
395
397
|
if (entry.isDirectory()) {
|
|
396
398
|
if (isAlwaysSkippedDirName(entry.name)) continue;
|
|
397
399
|
const relativeDir = `${toPosixRelative(root, fullPath)}/`;
|
|
@@ -406,7 +408,7 @@ async function walkDirectory(directory, root, exclude, fs) {
|
|
|
406
408
|
return results;
|
|
407
409
|
}
|
|
408
410
|
function toPosixRelative(root, target) {
|
|
409
|
-
return
|
|
411
|
+
return path__default.default.relative(root, target).split(path__default.default.sep).join("/");
|
|
410
412
|
}
|
|
411
413
|
function matchesAnyPattern(filePath, patterns) {
|
|
412
414
|
return patterns.some((pattern) => globToRegExp(pattern).test(filePath));
|
|
@@ -436,14 +438,19 @@ function pickCompiler(load) {
|
|
|
436
438
|
}
|
|
437
439
|
var ts = pickCompiler(module$1.createRequire(importMetaUrl));
|
|
438
440
|
|
|
439
|
-
// src/
|
|
440
|
-
function assertCompilerApi(compiler) {
|
|
441
|
+
// src/_ipc/compiler-api.ts
|
|
442
|
+
function assertCompilerApi(product, compiler) {
|
|
441
443
|
if (typeof compiler.createSourceFile === "function") return;
|
|
442
444
|
throw new Error(
|
|
443
|
-
|
|
445
|
+
`${product}'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 ${product} 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'.`
|
|
444
446
|
);
|
|
445
447
|
}
|
|
446
448
|
|
|
449
|
+
// src/build/compiler-api.ts
|
|
450
|
+
function assertCompilerApi2(compiler) {
|
|
451
|
+
assertCompilerApi("env-cap", compiler);
|
|
452
|
+
}
|
|
453
|
+
|
|
447
454
|
// src/build/literal-eval.ts
|
|
448
455
|
function evaluateLiteral(node) {
|
|
449
456
|
if (ts.isStringLiteralLike(node)) return { ok: true, value: node.text };
|
|
@@ -488,7 +495,7 @@ function getStaticPropertyName(name) {
|
|
|
488
495
|
|
|
489
496
|
// src/build/parse.ts
|
|
490
497
|
function parseSchemaFile(filePath, sourceText) {
|
|
491
|
-
|
|
498
|
+
assertCompilerApi2(ts);
|
|
492
499
|
const sourceFile = ts.createSourceFile(
|
|
493
500
|
filePath,
|
|
494
501
|
sourceText,
|
|
@@ -1014,12 +1021,99 @@ function mustGet(map, key) {
|
|
|
1014
1021
|
throw new Error(`Internal error: expected key "${String(key)}" to be present in map.`);
|
|
1015
1022
|
return value;
|
|
1016
1023
|
}
|
|
1024
|
+
|
|
1025
|
+
// src/build/merge-documentation.ts
|
|
1026
|
+
var VALUE_FIELDS = [
|
|
1027
|
+
"description",
|
|
1028
|
+
"owner",
|
|
1029
|
+
"sensitivity",
|
|
1030
|
+
"expiresAt",
|
|
1031
|
+
"refreshInstructions",
|
|
1032
|
+
"authenticatorType",
|
|
1033
|
+
"rotationPeriod",
|
|
1034
|
+
"lastRotatedAt",
|
|
1035
|
+
"rotationTriggerEvents",
|
|
1036
|
+
"setupInstructions",
|
|
1037
|
+
"required",
|
|
1038
|
+
"deprecated",
|
|
1039
|
+
"deprecatedReason",
|
|
1040
|
+
"removeBy",
|
|
1041
|
+
"renamedFrom",
|
|
1042
|
+
"purpose",
|
|
1043
|
+
"legalBasis",
|
|
1044
|
+
"retention",
|
|
1045
|
+
"dataResidency",
|
|
1046
|
+
"auditRequired"
|
|
1047
|
+
];
|
|
1048
|
+
function mergeSharedDocumentation(contracts) {
|
|
1049
|
+
const declarationsByKey = /* @__PURE__ */ new Map();
|
|
1050
|
+
for (const contract of contracts) {
|
|
1051
|
+
for (const variable of contract.variables) {
|
|
1052
|
+
const declarations = declarationsByKey.get(variable.key);
|
|
1053
|
+
if (declarations === void 0) declarationsByKey.set(variable.key, [{ contract, variable }]);
|
|
1054
|
+
else declarations.push({ contract, variable });
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
return contracts.map((contract) => ({
|
|
1058
|
+
...contract,
|
|
1059
|
+
variables: contract.variables.map((variable) => {
|
|
1060
|
+
const fromPackages = [];
|
|
1061
|
+
const fromApplication = [];
|
|
1062
|
+
for (const declaration of mustGet(declarationsByKey, variable.key)) {
|
|
1063
|
+
if (declaration.variable === variable) continue;
|
|
1064
|
+
const fromPackage = declaration.contract.packageOrigin !== void 0;
|
|
1065
|
+
if (!fromPackage && contract.packageOrigin === void 0) continue;
|
|
1066
|
+
(fromPackage ? fromPackages : fromApplication).push(declaration);
|
|
1067
|
+
}
|
|
1068
|
+
return fromPackages.length + fromApplication.length === 0 ? variable : filled(variable, fromPackages, fromApplication);
|
|
1069
|
+
})
|
|
1070
|
+
}));
|
|
1071
|
+
}
|
|
1072
|
+
function donated(read, fromPackages, fromApplication) {
|
|
1073
|
+
const fromPackage = fromPackages.find(({ variable }) => read(variable) !== void 0);
|
|
1074
|
+
if (fromPackage !== void 0) return read(fromPackage.variable);
|
|
1075
|
+
const values = fromApplication.map(({ variable }) => read(variable)).filter((v) => v !== void 0);
|
|
1076
|
+
return values.every((value) => deepEqual(value, values[0])) ? values[0] : void 0;
|
|
1077
|
+
}
|
|
1078
|
+
function filled(variable, fromPackages, fromApplication) {
|
|
1079
|
+
const donors = [...fromPackages, ...fromApplication];
|
|
1080
|
+
const merged = { ...variable };
|
|
1081
|
+
for (const field of VALUE_FIELDS) {
|
|
1082
|
+
if (variable[field] !== void 0) continue;
|
|
1083
|
+
merged[field] = donated((other) => other[field], fromPackages, fromApplication);
|
|
1084
|
+
}
|
|
1085
|
+
const metadata = {};
|
|
1086
|
+
for (const key of new Set(
|
|
1087
|
+
donors.flatMap(({ variable: other }) => Object.keys(other.metadata ?? {}))
|
|
1088
|
+
)) {
|
|
1089
|
+
const value = donated((other) => other.metadata?.[key], fromPackages, fromApplication);
|
|
1090
|
+
if (value !== void 0) metadata[key] = value;
|
|
1091
|
+
}
|
|
1092
|
+
Object.assign(metadata, variable.metadata);
|
|
1093
|
+
const result = {
|
|
1094
|
+
...merged,
|
|
1095
|
+
metadata: Object.keys(metadata).length === 0 ? variable.metadata : metadata,
|
|
1096
|
+
documented: variable.documented || donors.some(({ variable: other }) => other.documented)
|
|
1097
|
+
};
|
|
1098
|
+
DONATED.set(
|
|
1099
|
+
result,
|
|
1100
|
+
/* @__PURE__ */ new Set([
|
|
1101
|
+
...VALUE_FIELDS.filter((field) => result[field] !== variable[field]),
|
|
1102
|
+
...Object.keys(metadata).filter((key) => metadata[key] !== variable.metadata?.[key]).map((key) => `metadata.${key}`)
|
|
1103
|
+
])
|
|
1104
|
+
);
|
|
1105
|
+
return result;
|
|
1106
|
+
}
|
|
1107
|
+
var DONATED = /* @__PURE__ */ new WeakMap();
|
|
1108
|
+
function donatedTo(variable) {
|
|
1109
|
+
return DONATED.get(variable) ?? /* @__PURE__ */ new Set();
|
|
1110
|
+
}
|
|
1017
1111
|
function isWithinDirectory(baseDir, targetPath) {
|
|
1018
|
-
const relative =
|
|
1019
|
-
return relative !== ".." && !relative.startsWith(`..${
|
|
1112
|
+
const relative = path__default.default.relative(baseDir, targetPath);
|
|
1113
|
+
return relative !== ".." && !relative.startsWith(`..${path__default.default.sep}`) && !path__default.default.isAbsolute(relative);
|
|
1020
1114
|
}
|
|
1021
1115
|
function resolveWithinRoot(root, location, optionName, functionName) {
|
|
1022
|
-
const resolved =
|
|
1116
|
+
const resolved = path__default.default.resolve(root, location);
|
|
1023
1117
|
if (!isWithinDirectory(root, resolved)) {
|
|
1024
1118
|
return {
|
|
1025
1119
|
ok: false,
|
|
@@ -1042,10 +1136,10 @@ function isRecord2(value) {
|
|
|
1042
1136
|
return typeof value === "object" && value !== null;
|
|
1043
1137
|
}
|
|
1044
1138
|
async function locatePackageManifest(packageName, root, fs) {
|
|
1045
|
-
const req = module$1.createRequire(
|
|
1139
|
+
const req = module$1.createRequire(path__default.default.join(root, "package.json"));
|
|
1046
1140
|
try {
|
|
1047
1141
|
const packageJsonPath = req.resolve(`${packageName}/package.json`);
|
|
1048
|
-
return { packageJsonPath, packageDir:
|
|
1142
|
+
return { packageJsonPath, packageDir: path__default.default.dirname(packageJsonPath) };
|
|
1049
1143
|
} catch {
|
|
1050
1144
|
}
|
|
1051
1145
|
let mainFile;
|
|
@@ -1054,9 +1148,9 @@ async function locatePackageManifest(packageName, root, fs) {
|
|
|
1054
1148
|
} catch {
|
|
1055
1149
|
return void 0;
|
|
1056
1150
|
}
|
|
1057
|
-
let dir =
|
|
1151
|
+
let dir = path__default.default.dirname(mainFile);
|
|
1058
1152
|
for (let i = 0; i < PACKAGE_JSON_ANCESTOR_SEARCH_LIMIT; i++) {
|
|
1059
|
-
const candidate =
|
|
1153
|
+
const candidate = path__default.default.join(dir, "package.json");
|
|
1060
1154
|
try {
|
|
1061
1155
|
const parsed = JSON.parse(await fs.readFile(candidate, "utf8"));
|
|
1062
1156
|
if (isRecord2(parsed) && parsed["name"] === packageName) {
|
|
@@ -1064,7 +1158,7 @@ async function locatePackageManifest(packageName, root, fs) {
|
|
|
1064
1158
|
}
|
|
1065
1159
|
} catch {
|
|
1066
1160
|
}
|
|
1067
|
-
const parent =
|
|
1161
|
+
const parent = path__default.default.dirname(dir);
|
|
1068
1162
|
if (parent === dir) break;
|
|
1069
1163
|
dir = parent;
|
|
1070
1164
|
}
|
|
@@ -1106,7 +1200,7 @@ async function resolveUncached(packageName, root, fs) {
|
|
|
1106
1200
|
reason: `"${packageName}"'s package.json has no "envCap.schema" field (or it is not a string).`
|
|
1107
1201
|
};
|
|
1108
1202
|
}
|
|
1109
|
-
const lexicallyResolved =
|
|
1203
|
+
const lexicallyResolved = path__default.default.resolve(packageDir, declaredField);
|
|
1110
1204
|
if (!isWithinDirectory(packageDir, lexicallyResolved)) {
|
|
1111
1205
|
return {
|
|
1112
1206
|
ok: false,
|
|
@@ -1243,10 +1337,13 @@ async function fileExists(filePath, fs) {
|
|
|
1243
1337
|
}
|
|
1244
1338
|
return false;
|
|
1245
1339
|
}
|
|
1246
|
-
|
|
1340
|
+
function typescriptPath(file, separator) {
|
|
1341
|
+
return file.split(separator).join("/");
|
|
1342
|
+
}
|
|
1343
|
+
async function loadTsconfigPaths(product, root, tsconfigOption, fs) {
|
|
1247
1344
|
if (tsconfigOption === false) return { resolution: void 0, warning: void 0 };
|
|
1248
1345
|
const isExplicit = tsconfigOption !== void 0;
|
|
1249
|
-
const configFile =
|
|
1346
|
+
const configFile = path__default.default.resolve(root, tsconfigOption ?? "tsconfig.json");
|
|
1250
1347
|
if (!await fileExists(configFile, fs)) {
|
|
1251
1348
|
if (!isExplicit) return { resolution: void 0, warning: void 0 };
|
|
1252
1349
|
return {
|
|
@@ -1257,8 +1354,20 @@ async function loadTsconfigPaths(root, tsconfigOption, fs) {
|
|
|
1257
1354
|
}
|
|
1258
1355
|
};
|
|
1259
1356
|
}
|
|
1260
|
-
assertCompilerApi(ts);
|
|
1261
|
-
|
|
1357
|
+
assertCompilerApi(product, ts);
|
|
1358
|
+
let text;
|
|
1359
|
+
try {
|
|
1360
|
+
text = await fs.readFile(configFile, "utf8");
|
|
1361
|
+
} catch (error) {
|
|
1362
|
+
return {
|
|
1363
|
+
resolution: void 0,
|
|
1364
|
+
warning: {
|
|
1365
|
+
file: configFile,
|
|
1366
|
+
message: `Could not read "${configFile}": ${error.message}`
|
|
1367
|
+
}
|
|
1368
|
+
};
|
|
1369
|
+
}
|
|
1370
|
+
const readResult = ts.parseConfigFileTextToJson(typescriptPath(configFile, path__default.default.sep), text);
|
|
1262
1371
|
if (readResult.error) {
|
|
1263
1372
|
const detail = ts.flattenDiagnosticMessageText(readResult.error.messageText, ts.sys.newLine);
|
|
1264
1373
|
return {
|
|
@@ -1269,13 +1378,20 @@ async function loadTsconfigPaths(root, tsconfigOption, fs) {
|
|
|
1269
1378
|
}
|
|
1270
1379
|
};
|
|
1271
1380
|
}
|
|
1272
|
-
const parsed = ts.parseJsonConfigFileContent(readResult.config, ts.sys,
|
|
1381
|
+
const parsed = ts.parseJsonConfigFileContent(readResult.config, ts.sys, path__default.default.dirname(configFile));
|
|
1382
|
+
const problems = parsed.errors.filter((diagnostic) => diagnostic.code !== 18003);
|
|
1383
|
+
const warning = problems.length === 0 ? void 0 : {
|
|
1384
|
+
file: configFile,
|
|
1385
|
+
message: `"${configFile}" has problems the compiler reported: ${problems.map(
|
|
1386
|
+
(diagnostic) => ts.flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine)
|
|
1387
|
+
).join("; ")}`
|
|
1388
|
+
};
|
|
1273
1389
|
const { paths, baseUrl } = pathMappingOptions(parsed.options);
|
|
1274
1390
|
const hasPaths = paths !== void 0 && Object.keys(paths).length > 0;
|
|
1275
1391
|
if (!hasPaths && baseUrl === void 0) {
|
|
1276
|
-
return { resolution: void 0, warning
|
|
1392
|
+
return { resolution: void 0, warning };
|
|
1277
1393
|
}
|
|
1278
|
-
return { resolution: { compilerOptions: parsed.options, configFile }, warning
|
|
1394
|
+
return { resolution: { compilerOptions: parsed.options, configFile }, warning };
|
|
1279
1395
|
}
|
|
1280
1396
|
function resolveAliasImport(specifier, importingFile, resolution, cache) {
|
|
1281
1397
|
const cacheKey = `${importingFile}\0${specifier}`;
|
|
@@ -1284,8 +1400,8 @@ function resolveAliasImport(specifier, importingFile, resolution, cache) {
|
|
|
1284
1400
|
const resolvedFileName = result.resolvedModule?.resolvedFileName;
|
|
1285
1401
|
let resolved;
|
|
1286
1402
|
if (resolvedFileName) {
|
|
1287
|
-
const normalized =
|
|
1288
|
-
const isInNodeModules = normalized.split(
|
|
1403
|
+
const normalized = path__default.default.normalize(resolvedFileName);
|
|
1404
|
+
const isInNodeModules = normalized.split(path__default.default.sep).includes("node_modules");
|
|
1289
1405
|
const isTsSource = /\.tsx?$/.test(normalized);
|
|
1290
1406
|
if (!isInNodeModules && isTsSource) resolved = normalized;
|
|
1291
1407
|
}
|
|
@@ -1293,16 +1409,21 @@ function resolveAliasImport(specifier, importingFile, resolution, cache) {
|
|
|
1293
1409
|
return resolved;
|
|
1294
1410
|
}
|
|
1295
1411
|
|
|
1412
|
+
// src/build/resolution/resolve-tsconfig-paths.ts
|
|
1413
|
+
function loadTsconfigPaths2(root, tsconfigOption, fs) {
|
|
1414
|
+
return loadTsconfigPaths("env-cap", root, tsconfigOption, fs);
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1296
1417
|
// src/build/resolution/resolve-import.ts
|
|
1297
1418
|
async function resolveRelativeImport(importingFile, specifier, fs) {
|
|
1298
1419
|
if (!specifier.startsWith("./") && !specifier.startsWith("../")) return void 0;
|
|
1299
1420
|
const withoutExt = specifier.replace(/\.(js|jsx|ts|tsx)$/, "");
|
|
1300
|
-
const base =
|
|
1421
|
+
const base = path__default.default.resolve(path__default.default.dirname(importingFile), withoutExt);
|
|
1301
1422
|
for (const candidate of [
|
|
1302
1423
|
`${base}.ts`,
|
|
1303
1424
|
`${base}.tsx`,
|
|
1304
|
-
|
|
1305
|
-
|
|
1425
|
+
path__default.default.join(base, "index.ts"),
|
|
1426
|
+
path__default.default.join(base, "index.tsx")
|
|
1306
1427
|
]) {
|
|
1307
1428
|
if (await fileExists2(candidate, fs)) return candidate;
|
|
1308
1429
|
}
|
|
@@ -1451,7 +1572,6 @@ async function linkFiles(discoveredFiles, readFile, context, packageOrigins = /*
|
|
|
1451
1572
|
}
|
|
1452
1573
|
const contracts = [];
|
|
1453
1574
|
const undocumentedContracts = [];
|
|
1454
|
-
const undocumentedVariables = [];
|
|
1455
1575
|
const staleDocEntries = [];
|
|
1456
1576
|
for (const entry of createEnvEntries) {
|
|
1457
1577
|
const linked = documentEnvByIdentity.get(entry.identity);
|
|
@@ -1461,10 +1581,6 @@ async function linkFiles(discoveredFiles, readFile, context, packageOrigins = /*
|
|
|
1461
1581
|
}
|
|
1462
1582
|
const schemaKeys = new Set(entry.variables.map((v) => v.key));
|
|
1463
1583
|
const docsVariables = docs?.variables ?? /* @__PURE__ */ new Map();
|
|
1464
|
-
for (const key of schemaKeys) {
|
|
1465
|
-
if (!docsVariables.has(key))
|
|
1466
|
-
undocumentedVariables.push({ file: entry.file, exportName: entry.exportName, key });
|
|
1467
|
-
}
|
|
1468
1584
|
for (const key of docsVariables.keys()) {
|
|
1469
1585
|
if (!schemaKeys.has(key))
|
|
1470
1586
|
staleDocEntries.push({ file: entry.file, exportName: entry.exportName, key });
|
|
@@ -1526,18 +1642,23 @@ async function linkFiles(discoveredFiles, readFile, context, packageOrigins = /*
|
|
|
1526
1642
|
for (const analysis of analysisCache.values()) {
|
|
1527
1643
|
warnings.push(...analysis.warnings);
|
|
1528
1644
|
}
|
|
1645
|
+
const merged = mergeSharedDocumentation(contracts);
|
|
1529
1646
|
return {
|
|
1530
|
-
contracts,
|
|
1647
|
+
contracts: merged,
|
|
1531
1648
|
warnings,
|
|
1532
1649
|
unresolvedLinks,
|
|
1650
|
+
// Judged after the merge: a variable a package's contract documents is documented for the application that
|
|
1651
|
+
// declares it again.
|
|
1652
|
+
undocumentedVariables: merged.flatMap(
|
|
1653
|
+
({ file, exportName, variables }) => variables.filter(({ documented }) => !documented).map(({ key }) => ({ file, exportName, key }))
|
|
1654
|
+
),
|
|
1533
1655
|
undocumentedContracts,
|
|
1534
|
-
undocumentedVariables,
|
|
1535
1656
|
staleDocEntries
|
|
1536
1657
|
};
|
|
1537
1658
|
}
|
|
1538
1659
|
function summarizeContract(contract, root) {
|
|
1539
1660
|
return {
|
|
1540
|
-
file:
|
|
1661
|
+
file: path__default.default.relative(root, contract.file),
|
|
1541
1662
|
exportName: contract.exportName,
|
|
1542
1663
|
contractName: contract.contractName,
|
|
1543
1664
|
variableCount: contract.variables.length,
|
|
@@ -1591,7 +1712,7 @@ async function assembleProject(options) {
|
|
|
1591
1712
|
packageFiles.map((f) => f.file),
|
|
1592
1713
|
fs
|
|
1593
1714
|
);
|
|
1594
|
-
const { resolution: tsconfigPaths, warning: tsconfigWarning } = await
|
|
1715
|
+
const { resolution: tsconfigPaths, warning: tsconfigWarning } = await loadTsconfigPaths2(
|
|
1595
1716
|
root,
|
|
1596
1717
|
tsconfig,
|
|
1597
1718
|
fs
|
|
@@ -1656,24 +1777,20 @@ function buildChangeModel(manifest, currentContracts, root) {
|
|
|
1656
1777
|
}
|
|
1657
1778
|
|
|
1658
1779
|
// src/build/compatibility.ts
|
|
1659
|
-
var DOCUMENTATION_COMPARISON_FIELDS = [
|
|
1660
|
-
"description",
|
|
1661
|
-
"owner",
|
|
1662
|
-
"sensitivity",
|
|
1663
|
-
"expiresAt",
|
|
1664
|
-
"refreshInstructions",
|
|
1665
|
-
"setupInstructions",
|
|
1666
|
-
"required"
|
|
1667
|
-
];
|
|
1668
1780
|
function documentationDivergences(a, b) {
|
|
1669
1781
|
const divergences = [];
|
|
1670
|
-
|
|
1671
|
-
|
|
1782
|
+
const given = /* @__PURE__ */ new Set([...donatedTo(a), ...donatedTo(b)]);
|
|
1783
|
+
for (const field of VALUE_FIELDS) {
|
|
1784
|
+
if (!given.has(field) && a[field] !== void 0 && b[field] !== void 0 && !deepEqual(a[field], b[field])) {
|
|
1785
|
+
divergences.push(field);
|
|
1786
|
+
}
|
|
1672
1787
|
}
|
|
1673
1788
|
const aMetadata = a.metadata ?? {};
|
|
1674
1789
|
const bMetadata = b.metadata ?? {};
|
|
1675
|
-
for (const key of
|
|
1676
|
-
if (!deepEqual(aMetadata[key], bMetadata[key]))
|
|
1790
|
+
for (const key of Object.keys(aMetadata)) {
|
|
1791
|
+
if (!given.has(`metadata.${key}`) && key in bMetadata && !deepEqual(aMetadata[key], bMetadata[key])) {
|
|
1792
|
+
divergences.push(`metadata.${key}`);
|
|
1793
|
+
}
|
|
1677
1794
|
}
|
|
1678
1795
|
return divergences;
|
|
1679
1796
|
}
|
|
@@ -1720,17 +1837,15 @@ function detectCompatibilityIssues(contracts) {
|
|
|
1720
1837
|
reason: `"${a.contractName}" and "${b.contractName}" both declare a validator for this variable with different implementations. Validator logic cannot be statically compared -- confirm they enforce compatible rules.`
|
|
1721
1838
|
});
|
|
1722
1839
|
}
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
});
|
|
1733
|
-
}
|
|
1840
|
+
const divergences = documentationDivergences(a.variable, b.variable);
|
|
1841
|
+
if (divergences.length > 0) {
|
|
1842
|
+
issues.push({
|
|
1843
|
+
severity: "warning",
|
|
1844
|
+
variable: key,
|
|
1845
|
+
files: [a.file, b.file],
|
|
1846
|
+
code: "DUPLICATE_VARIABLE_DOCUMENTATION",
|
|
1847
|
+
reason: `"${a.contractName}" and "${b.contractName}" both document this variable, but disagree on: ${divergences.join(", ")}. Confirm they're still meant to be the same variable and align the documentation, or document them separately if they're not.`
|
|
1848
|
+
});
|
|
1734
1849
|
}
|
|
1735
1850
|
}
|
|
1736
1851
|
}
|
|
@@ -1998,7 +2113,7 @@ function bindingElementKey(element) {
|
|
|
1998
2113
|
return element.propertyName;
|
|
1999
2114
|
}
|
|
2000
2115
|
function scanFileForDependencies(filePath, sourceText) {
|
|
2001
|
-
|
|
2116
|
+
assertCompilerApi2(ts);
|
|
2002
2117
|
const scriptKind = filePath.endsWith(".tsx") ? ts.ScriptKind.TSX : ts.ScriptKind.TS;
|
|
2003
2118
|
const sourceFile = ts.createSourceFile(
|
|
2004
2119
|
filePath,
|
|
@@ -2109,27 +2224,67 @@ function scanFileForDependencies(filePath, sourceText) {
|
|
|
2109
2224
|
return { file: filePath, imports, accessesByLocalName: accesses, hasWildcardReExport };
|
|
2110
2225
|
}
|
|
2111
2226
|
|
|
2227
|
+
// src/_ipc/generated-banner.ts
|
|
2228
|
+
function marker() {
|
|
2229
|
+
return "GENERATED FILE -- do not edit by hand";
|
|
2230
|
+
}
|
|
2231
|
+
function createGeneratedBanner(describe) {
|
|
2232
|
+
return {
|
|
2233
|
+
reportRegenerateHint: () => describe().reportRegenerateHint,
|
|
2234
|
+
generatedBanner: (format = "ts", regenerate = `Run \`${describe().cliCommand}\` to regenerate.`) => {
|
|
2235
|
+
const text = `${marker()}. ${regenerate}`;
|
|
2236
|
+
return { ts: `// ${text}`, markdown: `<!-- ${text} -->` }[format];
|
|
2237
|
+
},
|
|
2238
|
+
// Not a bare `startsWith`: a shebang, a `"use strict"` pragma or a license header pushes a real marker
|
|
2239
|
+
// off line one, and a stricter check would read a genuinely generated file as hand-written, which a
|
|
2240
|
+
// dependency scan would take as "a real consumer imports this" and so permanently mask an abandoned
|
|
2241
|
+
// contract. The first 20 non-empty lines clear every realistic preamble without scanning a whole file.
|
|
2242
|
+
// A line counts only when the marker opens a comment, as `generatedBanner` writes it, so code or prose that
|
|
2243
|
+
// merely quotes the marker is not mistaken for a generated file.
|
|
2244
|
+
isGeneratedFile: (content) => {
|
|
2245
|
+
let seen = 0;
|
|
2246
|
+
for (const [line] of content.matchAll(/[^\n]*/g)) {
|
|
2247
|
+
const text = line.trimStart();
|
|
2248
|
+
if (text === "") continue;
|
|
2249
|
+
if (text.startsWith(`// ${marker()}`) || text.startsWith(`<!-- ${marker()}`)) return true;
|
|
2250
|
+
seen += 1;
|
|
2251
|
+
if (seen === 20) break;
|
|
2252
|
+
}
|
|
2253
|
+
return false;
|
|
2254
|
+
},
|
|
2255
|
+
evidenceDisclaimer: () => "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.",
|
|
2256
|
+
evidenceProjectionNote: (evidencePath) => {
|
|
2257
|
+
const { product, guideUrl } = describe();
|
|
2258
|
+
const concept = `Projected from ${product}'s Evidence Model (${guideUrl}), the same source every other generated artifact draws from.`;
|
|
2259
|
+
return evidencePath === void 0 ? concept : `${concept} This run also wrote it to \`${evidencePath}\`.`;
|
|
2260
|
+
}
|
|
2261
|
+
};
|
|
2262
|
+
}
|
|
2263
|
+
|
|
2112
2264
|
// src/build/generated-banner.ts
|
|
2113
|
-
function
|
|
2114
|
-
return
|
|
2265
|
+
function envCap() {
|
|
2266
|
+
return {
|
|
2267
|
+
product: "env-cap",
|
|
2268
|
+
guideUrl: "https://github.com/MaverickCER/env-cap/blob/main/GUIDE.md",
|
|
2269
|
+
cliCommand: "npx env-cap",
|
|
2270
|
+
reportRegenerateHint: "Regenerate it by re-running the script that calls `generateDocumentation()` / `generateUsageReport()` from `@maverickcer/env-cap/build`."
|
|
2271
|
+
};
|
|
2115
2272
|
}
|
|
2273
|
+
var banner = createGeneratedBanner(envCap);
|
|
2116
2274
|
function reportRegenerateHint() {
|
|
2117
|
-
return
|
|
2275
|
+
return banner.reportRegenerateHint();
|
|
2118
2276
|
}
|
|
2119
|
-
function generatedBanner(format
|
|
2120
|
-
|
|
2121
|
-
return { ts: `// ${text}`, markdown: `<!-- ${text} -->` }[format];
|
|
2277
|
+
function generatedBanner(format, regenerate) {
|
|
2278
|
+
return banner.generatedBanner(format, regenerate);
|
|
2122
2279
|
}
|
|
2123
2280
|
function isGeneratedFile(content) {
|
|
2124
|
-
|
|
2125
|
-
return nonEmptyLines.slice(0, 20).some((line) => line.includes(generatedFileMarker()));
|
|
2281
|
+
return banner.isGeneratedFile(content);
|
|
2126
2282
|
}
|
|
2127
2283
|
function evidenceDisclaimer() {
|
|
2128
|
-
return
|
|
2284
|
+
return banner.evidenceDisclaimer();
|
|
2129
2285
|
}
|
|
2130
2286
|
function evidenceProjectionNote(evidencePath) {
|
|
2131
|
-
|
|
2132
|
-
return evidencePath === void 0 ? concept : `${concept} This run also wrote it to \`${evidencePath}\`.`;
|
|
2287
|
+
return banner.evidenceProjectionNote(evidencePath);
|
|
2133
2288
|
}
|
|
2134
2289
|
|
|
2135
2290
|
// src/build/dependency-graph.ts
|
|
@@ -2501,7 +2656,7 @@ function discoverValidationContexts(contracts) {
|
|
|
2501
2656
|
}
|
|
2502
2657
|
function renderManifest(contracts, outputFile) {
|
|
2503
2658
|
const sorted = [...contracts].sort((a, b) => a.file.localeCompare(b.file));
|
|
2504
|
-
const outputDir =
|
|
2659
|
+
const outputDir = path__default.default.dirname(outputFile);
|
|
2505
2660
|
const usedNames = /* @__PURE__ */ new Set();
|
|
2506
2661
|
const importLines = [];
|
|
2507
2662
|
const referenceNames = [];
|
|
@@ -2521,7 +2676,7 @@ function renderManifest(contracts, outputFile) {
|
|
|
2521
2676
|
specifier = contract.packageOrigin.packageName;
|
|
2522
2677
|
} else {
|
|
2523
2678
|
const withoutExt = contract.file.replace(/\.tsx?$/, "");
|
|
2524
|
-
specifier =
|
|
2679
|
+
specifier = path__default.default.relative(outputDir, withoutExt).split(path__default.default.sep).join("/");
|
|
2525
2680
|
if (!specifier.startsWith(".")) specifier = `./${specifier}`;
|
|
2526
2681
|
}
|
|
2527
2682
|
const binding = localName === contract.exportName ? contract.exportName : `${contract.exportName} as ${localName}`;
|
|
@@ -2585,11 +2740,11 @@ function computeManifest(root, linkResult, onIncompatibility) {
|
|
|
2585
2740
|
}
|
|
2586
2741
|
async function writeManifest(outputPath, activeContracts, fs) {
|
|
2587
2742
|
const manifestSource = renderManifest(activeContracts, outputPath);
|
|
2588
|
-
await fs.mkdir(
|
|
2743
|
+
await fs.mkdir(path__default.default.dirname(outputPath), { recursive: true });
|
|
2589
2744
|
await fs.writeFile(outputPath, manifestSource, "utf8");
|
|
2590
2745
|
}
|
|
2591
2746
|
async function generateEnvManifest(options) {
|
|
2592
|
-
const root =
|
|
2747
|
+
const root = path__default.default.resolve(options.root ?? process.cwd());
|
|
2593
2748
|
const include = options.include ?? defaultInclude();
|
|
2594
2749
|
const exclude = options.exclude ?? defaultExclude();
|
|
2595
2750
|
const locationResult = resolveWithinRoot(
|
|
@@ -2820,20 +2975,20 @@ async function computeUsage(root, contracts, scanFiles, readFile, context, scann
|
|
|
2820
2975
|
};
|
|
2821
2976
|
const dependencyOwnership = graph.contracts.map((c) => ({
|
|
2822
2977
|
contractName: c.contractName,
|
|
2823
|
-
file:
|
|
2978
|
+
file: path__default.default.relative(root, c.file),
|
|
2824
2979
|
owner: ownerFor(c.file, c.exportName),
|
|
2825
2980
|
variableCount: c.variables.size,
|
|
2826
|
-
consumers: c.consumingFiles.map((f) =>
|
|
2981
|
+
consumers: c.consumingFiles.map((f) => path__default.default.relative(root, f))
|
|
2827
2982
|
}));
|
|
2828
2983
|
const abandonedContracts = findings.abandoned.map((f) => ({
|
|
2829
2984
|
contractName: f.contractName,
|
|
2830
|
-
file:
|
|
2985
|
+
file: path__default.default.relative(root, f.file),
|
|
2831
2986
|
owner: ownerFor(f.file, f.exportName)
|
|
2832
2987
|
}));
|
|
2833
2988
|
const unresolvedConsumers = findings.unresolvedConsumers.map(
|
|
2834
2989
|
(f) => ({
|
|
2835
2990
|
contractName: f.contractName,
|
|
2836
|
-
file:
|
|
2991
|
+
file: path__default.default.relative(root, f.file),
|
|
2837
2992
|
reason: f.reason
|
|
2838
2993
|
})
|
|
2839
2994
|
);
|
|
@@ -2900,11 +3055,11 @@ async function computeUsage(root, contracts, scanFiles, readFile, context, scann
|
|
|
2900
3055
|
}
|
|
2901
3056
|
async function writeUsageReport(reportPath, computed, fs) {
|
|
2902
3057
|
const source = renderUsageReport(computed);
|
|
2903
|
-
await fs.mkdir(
|
|
3058
|
+
await fs.mkdir(path__default.default.dirname(reportPath), { recursive: true });
|
|
2904
3059
|
await fs.writeFile(reportPath, source, "utf8");
|
|
2905
3060
|
}
|
|
2906
3061
|
async function generateUsageReport(options) {
|
|
2907
|
-
const root =
|
|
3062
|
+
const root = path__default.default.resolve(options.root ?? process.cwd());
|
|
2908
3063
|
const include = options.include ?? defaultInclude();
|
|
2909
3064
|
const exclude = options.exclude ?? defaultExclude();
|
|
2910
3065
|
let reportPath;
|
|
@@ -4005,7 +4160,7 @@ async function writeEnvExample(contracts, location, fs, options = {}) {
|
|
|
4005
4160
|
}
|
|
4006
4161
|
if (existingContent === void 0) {
|
|
4007
4162
|
const content2 = renderEnvExample(contracts, []);
|
|
4008
|
-
await fs.mkdir(
|
|
4163
|
+
await fs.mkdir(path__default.default.dirname(location), { recursive: true });
|
|
4009
4164
|
await fs.writeFile(location, content2, "utf8");
|
|
4010
4165
|
return {
|
|
4011
4166
|
writtenPath: location,
|
|
@@ -4030,7 +4185,7 @@ async function writeEnvExample(contracts, location, fs, options = {}) {
|
|
|
4030
4185
|
const content = renderEnvExample(contracts, headerLines);
|
|
4031
4186
|
const writtenPath = onExisting === "overwrite" ? location : `${location}.${Date.now()}`;
|
|
4032
4187
|
const skippedExistingPath = onExisting === "overwrite" ? void 0 : location;
|
|
4033
|
-
await fs.mkdir(
|
|
4188
|
+
await fs.mkdir(path__default.default.dirname(writtenPath), { recursive: true });
|
|
4034
4189
|
await fs.writeFile(writtenPath, content, "utf8");
|
|
4035
4190
|
return { writtenPath, skippedExistingPath, staleVariables, variablesToComment, variablesToAdd };
|
|
4036
4191
|
}
|
|
@@ -4128,7 +4283,7 @@ async function writeDocumentation(docsPath, envExamplePath, root, contracts, con
|
|
|
4128
4283
|
generatedAt,
|
|
4129
4284
|
previousContent
|
|
4130
4285
|
});
|
|
4131
|
-
await fs.mkdir(
|
|
4286
|
+
await fs.mkdir(path__default.default.dirname(docsPath), { recursive: true });
|
|
4132
4287
|
await fs.writeFile(docsPath, docsSource, "utf8");
|
|
4133
4288
|
const envExample = envExamplePath ? (
|
|
4134
4289
|
// `exactOptionalPropertyTypes` rejects an explicit `undefined`, so the key is omitted when unset.
|
|
@@ -4142,7 +4297,7 @@ async function writeDocumentation(docsPath, envExamplePath, root, contracts, con
|
|
|
4142
4297
|
return { envExample };
|
|
4143
4298
|
}
|
|
4144
4299
|
async function generateDocumentation(options) {
|
|
4145
|
-
const root =
|
|
4300
|
+
const root = path__default.default.resolve(options.root ?? process.cwd());
|
|
4146
4301
|
const include = options.include ?? defaultInclude();
|
|
4147
4302
|
const exclude = options.exclude ?? defaultExclude();
|
|
4148
4303
|
const expiringWithinDays = options.expiringWithinDays ?? DEFAULT_EXPIRING_WITHIN_DAYS;
|
|
@@ -4346,12 +4501,12 @@ function buildOwnershipModel(contracts, root) {
|
|
|
4346
4501
|
|
|
4347
4502
|
// src/build/tool-version.ts
|
|
4348
4503
|
function readToolVersion() {
|
|
4349
|
-
return "0.
|
|
4504
|
+
return "0.7.1";
|
|
4350
4505
|
}
|
|
4351
4506
|
|
|
4352
4507
|
// src/build/generate-evidence.ts
|
|
4353
4508
|
async function generateEvidenceModel(options) {
|
|
4354
|
-
const root =
|
|
4509
|
+
const root = path__default.default.resolve(options.root ?? process.cwd());
|
|
4355
4510
|
const include = options.include ?? defaultInclude();
|
|
4356
4511
|
const exclude = options.exclude ?? defaultExclude();
|
|
4357
4512
|
const expiringWithinDays = options.expiringWithinDays ?? DEFAULT_EXPIRING_WITHIN_DAYS;
|
|
@@ -4493,10 +4648,10 @@ async function writeEvidenceFingerprint(evidencePath, fingerprint, fs) {
|
|
|
4493
4648
|
`, "utf8");
|
|
4494
4649
|
}
|
|
4495
4650
|
async function getEvidenceModel(options) {
|
|
4496
|
-
const root =
|
|
4651
|
+
const root = path__default.default.resolve(options.root ?? process.cwd());
|
|
4497
4652
|
const include = options.include ?? defaultInclude();
|
|
4498
4653
|
const exclude = options.exclude ?? defaultExclude();
|
|
4499
|
-
const evidencePath =
|
|
4654
|
+
const evidencePath = path__default.default.resolve(root, options.location);
|
|
4500
4655
|
const fingerprintPath = fingerprintPathFor(evidencePath);
|
|
4501
4656
|
const recompute = async (missReason) => ({
|
|
4502
4657
|
evidence: await generateEvidenceModel(options),
|
|
@@ -4562,7 +4717,7 @@ function requestedPass(option) {
|
|
|
4562
4717
|
return option === false ? void 0 : option;
|
|
4563
4718
|
}
|
|
4564
4719
|
async function computeArtifacts(options) {
|
|
4565
|
-
const root =
|
|
4720
|
+
const root = path__default.default.resolve(options.root ?? process.cwd());
|
|
4566
4721
|
const include = options.include ?? defaultInclude();
|
|
4567
4722
|
const exclude = options.exclude ?? defaultExclude();
|
|
4568
4723
|
const manifestOptions = requestedPass(options.manifest);
|
|
@@ -4915,7 +5070,7 @@ function sarifLocations(finding) {
|
|
|
4915
5070
|
function buildSarifLog(findingModel) {
|
|
4916
5071
|
const ruleIds = [...new Set(findingModel.findings.map((f) => f.code))].sort();
|
|
4917
5072
|
return {
|
|
4918
|
-
$schema: "https://
|
|
5073
|
+
$schema: "https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json",
|
|
4919
5074
|
version: "2.1.0",
|
|
4920
5075
|
runs: [
|
|
4921
5076
|
{
|