@ploaness/governance 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/a11y-hit-target.d.ts +35 -0
- package/dist/a11y-hit-target.d.ts.map +1 -0
- package/dist/a11y-hit-target.js +82 -0
- package/dist/a11y-hit-target.js.map +1 -0
- package/dist/a11y-incomplete.d.ts +18 -0
- package/dist/a11y-incomplete.d.ts.map +1 -0
- package/dist/a11y-incomplete.js +65 -0
- package/dist/a11y-incomplete.js.map +1 -0
- package/dist/access-boundary.d.ts +62 -6
- package/dist/access-boundary.d.ts.map +1 -1
- package/dist/access-boundary.js +201 -6
- package/dist/access-boundary.js.map +1 -1
- package/dist/admin-view-coverage.d.ts +25 -0
- package/dist/admin-view-coverage.d.ts.map +1 -0
- package/dist/admin-view-coverage.js +74 -0
- package/dist/admin-view-coverage.js.map +1 -0
- package/dist/asset-policy.d.ts.map +1 -1
- package/dist/asset-policy.js +1 -23
- package/dist/asset-policy.js.map +1 -1
- package/dist/axe-coverage.d.ts +40 -0
- package/dist/axe-coverage.d.ts.map +1 -0
- package/dist/axe-coverage.js +62 -0
- package/dist/axe-coverage.js.map +1 -0
- package/dist/banned-typography.d.ts.map +1 -1
- package/dist/banned-typography.js +26 -0
- package/dist/banned-typography.js.map +1 -1
- package/dist/blocklist-entries.d.ts +36 -0
- package/dist/blocklist-entries.d.ts.map +1 -0
- package/dist/blocklist-entries.js +338 -0
- package/dist/blocklist-entries.js.map +1 -0
- package/dist/blocklist.d.ts +91 -0
- package/dist/blocklist.d.ts.map +1 -0
- package/dist/blocklist.js +187 -0
- package/dist/blocklist.js.map +1 -0
- package/dist/build-diagnosis.d.ts +10 -0
- package/dist/build-diagnosis.d.ts.map +1 -0
- package/dist/build-diagnosis.js +38 -0
- package/dist/build-diagnosis.js.map +1 -0
- package/dist/container-failure.d.ts.map +1 -1
- package/dist/container-failure.js +1 -18
- package/dist/container-failure.js.map +1 -1
- package/dist/container-files.d.ts +16 -0
- package/dist/container-files.d.ts.map +1 -1
- package/dist/container-files.js +23 -8
- package/dist/container-files.js.map +1 -1
- package/dist/container-images.d.ts +43 -0
- package/dist/container-images.d.ts.map +1 -0
- package/dist/container-images.js +157 -0
- package/dist/container-images.js.map +1 -0
- package/dist/dependency-freshness.d.ts +8 -0
- package/dist/dependency-freshness.d.ts.map +1 -1
- package/dist/dependency-freshness.js +2 -18
- package/dist/dependency-freshness.js.map +1 -1
- package/dist/doc-blocks.d.ts.map +1 -1
- package/dist/doc-blocks.js +1 -13
- package/dist/doc-blocks.js.map +1 -1
- package/dist/document-references.d.ts.map +1 -1
- package/dist/document-references.js +7 -1
- package/dist/document-references.js.map +1 -1
- package/dist/editorconfig-policy.d.ts +7 -0
- package/dist/editorconfig-policy.d.ts.map +1 -1
- package/dist/editorconfig-policy.js +19 -12
- package/dist/editorconfig-policy.js.map +1 -1
- package/dist/environment-coherence.d.ts +87 -0
- package/dist/environment-coherence.d.ts.map +1 -0
- package/dist/environment-coherence.js +128 -0
- package/dist/environment-coherence.js.map +1 -0
- package/dist/environment-files.d.ts.map +1 -1
- package/dist/environment-files.js +1 -19
- package/dist/environment-files.js.map +1 -1
- package/dist/file-roles.d.ts +7 -2
- package/dist/file-roles.d.ts.map +1 -1
- package/dist/file-roles.js +10 -9
- package/dist/file-roles.js.map +1 -1
- package/dist/freshness-repair.d.ts +82 -0
- package/dist/freshness-repair.d.ts.map +1 -0
- package/dist/freshness-repair.js +91 -0
- package/dist/freshness-repair.js.map +1 -0
- package/dist/generated-denial.d.ts.map +1 -1
- package/dist/generated-denial.js +1 -9
- package/dist/generated-denial.js.map +1 -1
- package/dist/generated-drift.d.ts +18 -0
- package/dist/generated-drift.d.ts.map +1 -0
- package/dist/generated-drift.js +24 -0
- package/dist/generated-drift.js.map +1 -0
- package/dist/harness-package.d.ts +13 -0
- package/dist/harness-package.d.ts.map +1 -0
- package/dist/harness-package.js +20 -0
- package/dist/harness-package.js.map +1 -0
- package/dist/history-policy.d.ts.map +1 -1
- package/dist/history-policy.js +1 -7
- package/dist/history-policy.js.map +1 -1
- package/dist/image-assets.d.ts.map +1 -1
- package/dist/image-assets.js +1 -10
- package/dist/image-assets.js.map +1 -1
- package/dist/index.d.ts +22 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -1
- package/dist/index.js.map +1 -1
- package/dist/install-policy.d.ts +21 -0
- package/dist/install-policy.d.ts.map +1 -1
- package/dist/install-policy.js +53 -1
- package/dist/install-policy.js.map +1 -1
- package/dist/jsx-accessibility-scope.d.ts +17 -0
- package/dist/jsx-accessibility-scope.d.ts.map +1 -0
- package/dist/jsx-accessibility-scope.js +36 -0
- package/dist/jsx-accessibility-scope.js.map +1 -0
- package/dist/jsx-accessibility.d.ts +13 -0
- package/dist/jsx-accessibility.d.ts.map +1 -0
- package/dist/jsx-accessibility.js +188 -0
- package/dist/jsx-accessibility.js.map +1 -0
- package/dist/network-policy.d.ts.map +1 -1
- package/dist/network-policy.js +1 -12
- package/dist/network-policy.js.map +1 -1
- package/dist/oxlint-policy.d.ts +16 -0
- package/dist/oxlint-policy.d.ts.map +1 -0
- package/dist/oxlint-policy.js +28 -0
- package/dist/oxlint-policy.js.map +1 -0
- package/dist/oxlint-report.d.ts +29 -0
- package/dist/oxlint-report.d.ts.map +1 -0
- package/dist/oxlint-report.js +84 -0
- package/dist/oxlint-report.js.map +1 -0
- package/dist/oxlint-scope.d.ts +13 -0
- package/dist/oxlint-scope.d.ts.map +1 -0
- package/dist/oxlint-scope.js +46 -0
- package/dist/oxlint-scope.js.map +1 -0
- package/dist/oxlint-suppressions.d.ts +17 -0
- package/dist/oxlint-suppressions.d.ts.map +1 -0
- package/dist/oxlint-suppressions.js +72 -0
- package/dist/oxlint-suppressions.js.map +1 -0
- package/dist/paired-assets.d.ts.map +1 -1
- package/dist/paired-assets.js.map +1 -1
- package/dist/payload-access.d.ts +6 -0
- package/dist/payload-access.d.ts.map +1 -1
- package/dist/payload-access.js +188 -57
- package/dist/payload-access.js.map +1 -1
- package/dist/payload-configs.d.ts +23 -0
- package/dist/payload-configs.d.ts.map +1 -0
- package/dist/payload-configs.js +96 -0
- package/dist/payload-configs.js.map +1 -0
- package/dist/payload-defaults.d.ts +128 -0
- package/dist/payload-defaults.d.ts.map +1 -0
- package/dist/payload-defaults.js +295 -0
- package/dist/payload-defaults.js.map +1 -0
- package/dist/payload-field-access.d.ts +4 -0
- package/dist/payload-field-access.d.ts.map +1 -0
- package/dist/payload-field-access.js +51 -0
- package/dist/payload-field-access.js.map +1 -0
- package/dist/payload-policy.d.ts +13 -0
- package/dist/payload-policy.d.ts.map +1 -1
- package/dist/payload-policy.js +171 -32
- package/dist/payload-policy.js.map +1 -1
- package/dist/payload-source.js +2 -2
- package/dist/payload-source.js.map +1 -1
- package/dist/relationship-cleanup.d.ts +18 -0
- package/dist/relationship-cleanup.d.ts.map +1 -0
- package/dist/relationship-cleanup.js +96 -0
- package/dist/relationship-cleanup.js.map +1 -0
- package/dist/release-age.d.ts.map +1 -1
- package/dist/release-age.js +1 -16
- package/dist/release-age.js.map +1 -1
- package/dist/request-limits.d.ts.map +1 -1
- package/dist/request-limits.js +1 -11
- package/dist/request-limits.js.map +1 -1
- package/dist/route-coverage.d.ts +27 -0
- package/dist/route-coverage.d.ts.map +1 -0
- package/dist/route-coverage.js +57 -0
- package/dist/route-coverage.js.map +1 -0
- package/dist/route-map.d.ts +65 -0
- package/dist/route-map.d.ts.map +1 -0
- package/dist/route-map.js +168 -0
- package/dist/route-map.js.map +1 -0
- package/dist/run-plan.d.ts.map +1 -1
- package/dist/run-plan.js +1 -19
- package/dist/run-plan.js.map +1 -1
- package/dist/secret-policy.d.ts.map +1 -1
- package/dist/secret-policy.js +5 -15
- package/dist/secret-policy.js.map +1 -1
- package/dist/settings-layering.d.ts +8 -30
- package/dist/settings-layering.d.ts.map +1 -1
- package/dist/settings-layering.js +19 -48
- package/dist/settings-layering.js.map +1 -1
- package/dist/settings.d.ts +19 -2
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +5 -1
- package/dist/settings.js.map +1 -1
- package/dist/source-security.d.ts +4 -0
- package/dist/source-security.d.ts.map +1 -0
- package/dist/source-security.js +56 -0
- package/dist/source-security.js.map +1 -0
- package/dist/source-text.d.ts +16 -0
- package/dist/source-text.d.ts.map +1 -1
- package/dist/source-text.js +46 -16
- package/dist/source-text.js.map +1 -1
- package/dist/toolchain-pins.d.ts.map +1 -1
- package/dist/toolchain-pins.js +2 -19
- package/dist/toolchain-pins.js.map +1 -1
- package/dist/version-policy.d.ts +7 -8
- package/dist/version-policy.d.ts.map +1 -1
- package/dist/version-policy.js +46 -26
- package/dist/version-policy.js.map +1 -1
- package/dist/vulnerability-policy.d.ts.map +1 -1
- package/dist/vulnerability-policy.js +1 -11
- package/dist/vulnerability-policy.js.map +1 -1
- package/dist/wiring-policy.d.ts.map +1 -1
- package/dist/wiring-policy.js +4 -1
- package/dist/wiring-policy.js.map +1 -1
- package/dist/wiring-violation.d.ts.map +1 -1
- package/dist/wiring-violation.js +1 -6
- package/dist/wiring-violation.js.map +1 -1
- package/dist/workspace-policy.d.ts.map +1 -1
- package/dist/workspace-policy.js +3 -9
- package/dist/workspace-policy.js.map +1 -1
- package/dist/yaml-blocks.d.ts +10 -0
- package/dist/yaml-blocks.d.ts.map +1 -1
- package/dist/yaml-blocks.js +20 -0
- package/dist/yaml-blocks.js.map +1 -1
- package/package.json +2 -2
- package/dist/url-safety.d.ts +0 -12
- package/dist/url-safety.d.ts.map +0 -1
- package/dist/url-safety.js +0 -58
- package/dist/url-safety.js.map +0 -1
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
// The `.editorconfig` is a pinned managed file, so every project holds the same one - and until now
|
|
4
|
-
// nothing checked a single file against it. The formatter covers only the globs it owns, which leaves
|
|
5
|
-
// Markdown, YAML, shell scripts, and Dockerfiles free to carry a CRLF, a tab, a trailing space, or a
|
|
6
|
-
// missing final newline.
|
|
7
|
-
//
|
|
8
|
-
// The expectations are read from the `.editorconfig` itself rather than restated here, so editing the
|
|
9
|
-
// pinned file moves the gate with it and the gate cannot contradict the file it checks against. The one
|
|
10
|
-
// value that does NOT come from there is the line cap: `max_line_length` is an editor hint that tells a
|
|
11
|
-
// ruler where to sit, while the standard's 120 characters is a cap that binds as an error. A project's
|
|
12
|
-
// formatter may aim shorter, and frequently does.
|
|
1
|
+
// Judge committed formatting and the authored-code line cap independently of filesystem access.
|
|
2
|
+
import { CODE_EXTENSIONS, hasExtension, matchesGlob } from './file-roles.js';
|
|
13
3
|
/** The standard's line cap. Not configurable: a cap is never raised. */
|
|
14
4
|
export const MAX_LINE_LENGTH = 120;
|
|
15
5
|
const FIRST_LINE = 1;
|
|
@@ -80,6 +70,23 @@ const lineViolations = (content, rules, isLineLengthEnforced) => {
|
|
|
80
70
|
});
|
|
81
71
|
});
|
|
82
72
|
};
|
|
73
|
+
/**
|
|
74
|
+
* Decide whether the standard's line cap binds for one file.
|
|
75
|
+
* @param filePath the repo-relative path.
|
|
76
|
+
* @param generatedArtefacts the globs the project declares generated.
|
|
77
|
+
* @returns true for an authored code file; false for prose and for generated output.
|
|
78
|
+
*/
|
|
79
|
+
// A cap is a rule about how a person writes code, so it reaches code roles only - and only where a
|
|
80
|
+
// person wrote it. A generator emits what it emits: Payload renders each migration statement as one SQL
|
|
81
|
+
// string, and no formatter setting and no edit shortens it, because the file is frozen once applied.
|
|
82
|
+
// Holding a project to a cap it cannot satisfy would teach it to exclude the path from this gate
|
|
83
|
+
// altogether, which would cost the encoding and whitespace rules too - and those a generated file does
|
|
84
|
+
// satisfy, because the project runs its own formatter over the output.
|
|
85
|
+
// Matched as globs, not through `isGovernedCode`: `generatedArtefacts` is declared as globs and reaches
|
|
86
|
+
// ESLint's ignore list as globs, and `src/migrations/**` is not merely a different pattern under regex
|
|
87
|
+
// rules - `new RegExp` rejects it outright, so the gate would have thrown rather than reported.
|
|
88
|
+
export const isLineCapEnforced = (filePath, generatedArtefacts) => hasExtension(filePath, CODE_EXTENSIONS) &&
|
|
89
|
+
!generatedArtefacts.some((pattern) => matchesGlob(pattern, filePath));
|
|
83
90
|
/**
|
|
84
91
|
* Check one file against the committed configuration.
|
|
85
92
|
* @param content the file's decoded content.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editorconfig-policy.js","sourceRoot":"","sources":["../src/editorconfig-policy.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"editorconfig-policy.js","sourceRoot":"","sources":["../src/editorconfig-policy.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAEhG,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAE5E,wEAAwE;AACxE,MAAM,CAAC,MAAM,eAAe,GAAW,GAAG,CAAA;AAgB1C,MAAM,UAAU,GAAW,CAAC,CAAA;AAC5B,qGAAqG;AACrG,sGAAsG;AACtG,0FAA0F;AAC1F,MAAM,eAAe,GAAW,OAAO,CAAA;AACvC,MAAM,GAAG,GAAW,MAAM,CAAC,aAAa,CAAC,eAAe,CAAC,CAAA;AAEzD;;;;GAIG;AACH,qGAAqG;AACrG,sEAAsE;AACtE,MAAM,eAAe,GAAG,CAAC,IAAY,EAAqB,EAAE;IAC1D,MAAM,KAAK,GAAsB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAW,EAAU,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAA;IAC1F,MAAM,KAAK,GAAW,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAC1C,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;QACjB,OAAO,EAAE,CAAA;IACX,CAAC;IACD,MAAM,IAAI,GAAsB,KAAK,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAA;IACtD,MAAM,GAAG,GAAW,IAAI,CAAC,SAAS,CAA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AAE,CAAA;IACR,OAAO;QACL,GAAG,aAAa;QAChB,GAAG,cAAc,CAAC,OAAO,EAAE,KAAK,EAAE,oBAAoB,CAAC;QACvD,GAAG,YAAY;KAChB,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/** Where a variable was declared, for a message that names the two places rather than one. */
|
|
2
|
+
export type EnvironmentOrigin = 'application' | 'compose';
|
|
3
|
+
/** An environment variable declared in one place and absent from another it has to reach. */
|
|
4
|
+
export interface EnvironmentViolation {
|
|
5
|
+
readonly name: string;
|
|
6
|
+
readonly origin: EnvironmentOrigin;
|
|
7
|
+
readonly reason: string;
|
|
8
|
+
}
|
|
9
|
+
/** A workflow, as the rule needs it: what to call it in a finding, and what it says. */
|
|
10
|
+
export interface WorkflowFile {
|
|
11
|
+
readonly file: string;
|
|
12
|
+
readonly content: string;
|
|
13
|
+
}
|
|
14
|
+
/** Inputs for {@link findEnvironmentViolations}, already read so the core stays pure. */
|
|
15
|
+
export interface EnvironmentInputs {
|
|
16
|
+
/** The contents of every validated environment module the repository holds, one per member. */
|
|
17
|
+
readonly applicationSources: readonly string[];
|
|
18
|
+
/** The contents of the example file, or undefined when the repository ships none. */
|
|
19
|
+
readonly example: string | undefined;
|
|
20
|
+
/** The contents of every compose file. */
|
|
21
|
+
readonly composeSources: readonly string[];
|
|
22
|
+
/** Every workflow the repository ships. Only the verifying ones are judged. */
|
|
23
|
+
readonly workflows: readonly WorkflowFile[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The module a Payload project reads `process.env` in, which is the only module ploaness exempts from
|
|
27
|
+
* the ban and therefore the only one this rule can read a variable name out of.
|
|
28
|
+
*/
|
|
29
|
+
export declare const VALIDATED_ENVIRONMENT_MODULE: string;
|
|
30
|
+
/**
|
|
31
|
+
* Every module exempt from the `process.env` ban.
|
|
32
|
+
*
|
|
33
|
+
* `src/proxy.ts` is exempt for a structural reason rather than a convenience one - Next mandates the
|
|
34
|
+
* file and runs it in the edge runtime, where the validated module is not reachable - and what it reads
|
|
35
|
+
* there is `NODE_ENV`, which the framework sets. So it is exempt from the LINT rule and is deliberately
|
|
36
|
+
* not read by this one: it holds no project configuration to document.
|
|
37
|
+
*/
|
|
38
|
+
export declare const ENVIRONMENT_READ_EXEMPTIONS: readonly string[];
|
|
39
|
+
/**
|
|
40
|
+
* The example files a repository may document its environment in, most conventional first.
|
|
41
|
+
*
|
|
42
|
+
* A list rather than one name because the convention is not universal, and a project using
|
|
43
|
+
* `.env.sample` has documented its variables just as well as one using `.env.example`.
|
|
44
|
+
*/
|
|
45
|
+
export declare const ENVIRONMENT_EXAMPLE_FILES: readonly string[];
|
|
46
|
+
/**
|
|
47
|
+
* The variables an application reads out of its validated environment module.
|
|
48
|
+
* @param source the contents of that module.
|
|
49
|
+
* @returns each name once, sorted, so a finding list is deterministic.
|
|
50
|
+
*/
|
|
51
|
+
export declare const readEnvironmentNames: (source: string) => readonly string[];
|
|
52
|
+
/**
|
|
53
|
+
* The variables an example file documents.
|
|
54
|
+
* @param example the contents of the example file.
|
|
55
|
+
* @returns each name once, sorted.
|
|
56
|
+
*/
|
|
57
|
+
export declare const documentedEnvironmentNames: (example: string) => readonly string[];
|
|
58
|
+
/**
|
|
59
|
+
* The variables a compose file interpolates without supplying a default.
|
|
60
|
+
* @param compose the contents of the compose file.
|
|
61
|
+
* @returns each name once, sorted.
|
|
62
|
+
*/
|
|
63
|
+
export declare const interpolatedEnvironmentNames: (compose: string) => readonly string[];
|
|
64
|
+
/**
|
|
65
|
+
* The variables a workflow supplies, by any means and at any nesting depth.
|
|
66
|
+
* @param workflow the contents of the workflow file.
|
|
67
|
+
* @returns each name once, sorted.
|
|
68
|
+
*/
|
|
69
|
+
export declare const workflowSuppliedNames: (workflow: string) => readonly string[];
|
|
70
|
+
/**
|
|
71
|
+
* Whether a workflow runs a ploaness verification, and therefore evaluates the compose files.
|
|
72
|
+
* @param workflow the contents of the workflow file.
|
|
73
|
+
* @returns true when the workflow invokes verification or a single gate.
|
|
74
|
+
*/
|
|
75
|
+
export declare const isVerifyingWorkflow: (workflow: string) => boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Every environment variable declared in one place and absent from another it has to reach.
|
|
78
|
+
*
|
|
79
|
+
* Three containments, each one-directional. What the application reads must be documented. What a
|
|
80
|
+
* compose file interpolates must be documented, because `docker compose config` reads the example file
|
|
81
|
+
* a developer copied. And what a compose file interpolates must be supplied by every workflow that
|
|
82
|
+
* verifies, because a workflow has no copied file to interpolate from.
|
|
83
|
+
* @param inputs the files, already read.
|
|
84
|
+
* @returns the violations, sorted by name within each rule. An empty array means the four places agree.
|
|
85
|
+
*/
|
|
86
|
+
export declare const findEnvironmentViolations: (inputs: EnvironmentInputs) => readonly EnvironmentViolation[];
|
|
87
|
+
//# sourceMappingURL=environment-coherence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment-coherence.d.ts","sourceRoot":"","sources":["../src/environment-coherence.ts"],"names":[],"mappings":"AAEA,8FAA8F;AAC9F,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAAG,SAAS,CAAA;AAEzD,6FAA6F;AAC7F,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAA;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB;AAED,wFAAwF;AACxF,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB;AAED,yFAAyF;AACzF,MAAM,WAAW,iBAAiB;IAChC,+FAA+F;IAC/F,QAAQ,CAAC,kBAAkB,EAAE,SAAS,MAAM,EAAE,CAAA;IAC9C,qFAAqF;IACrF,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IACpC,0CAA0C;IAC1C,QAAQ,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,CAAA;IAC1C,+EAA+E;IAC/E,QAAQ,CAAC,SAAS,EAAE,SAAS,YAAY,EAAE,CAAA;CAC5C;AAED;;;GAGG;AACH,eAAO,MAAM,4BAA4B,EAAE,MAAiC,CAAA;AAE5E;;;;;;;GAOG;AACH,eAAO,MAAM,2BAA2B,EAAE,SAAS,MAAM,EAGxD,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,EAAE,SAAS,MAAM,EAItD,CAAA;AA4CD;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAI,QAAQ,MAAM,KAAG,SAAS,MAAM,EAChB,CAAA;AAErD;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,GAAI,SAAS,MAAM,KAAG,SAAS,MAAM,EAClB,CAAA;AAE1D;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,GAAI,SAAS,MAAM,KAAG,SAAS,MAAM,EACjB,CAAA;AAE7D;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAI,UAAU,MAAM,KAAG,SAAS,MAAM,EAIpE,CAAA;AAEJ;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,UAAU,MAAM,KAAG,OAC4B,CAAA;AA+BnF;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,GACpC,QAAQ,iBAAiB,KACxB,SAAS,oBAAoB,EAkC/B,CAAA"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// Require environment reads, example declarations, compose interpolation, and verifying workflows to agree.
|
|
2
|
+
/**
|
|
3
|
+
* The module a Payload project reads `process.env` in, which is the only module ploaness exempts from
|
|
4
|
+
* the ban and therefore the only one this rule can read a variable name out of.
|
|
5
|
+
*/
|
|
6
|
+
export const VALIDATED_ENVIRONMENT_MODULE = 'src/lib/environment.ts';
|
|
7
|
+
/**
|
|
8
|
+
* Every module exempt from the `process.env` ban.
|
|
9
|
+
*
|
|
10
|
+
* `src/proxy.ts` is exempt for a structural reason rather than a convenience one - Next mandates the
|
|
11
|
+
* file and runs it in the edge runtime, where the validated module is not reachable - and what it reads
|
|
12
|
+
* there is `NODE_ENV`, which the framework sets. So it is exempt from the LINT rule and is deliberately
|
|
13
|
+
* not read by this one: it holds no project configuration to document.
|
|
14
|
+
*/
|
|
15
|
+
export const ENVIRONMENT_READ_EXEMPTIONS = [
|
|
16
|
+
VALIDATED_ENVIRONMENT_MODULE,
|
|
17
|
+
'src/proxy.ts',
|
|
18
|
+
];
|
|
19
|
+
/**
|
|
20
|
+
* The example files a repository may document its environment in, most conventional first.
|
|
21
|
+
*
|
|
22
|
+
* A list rather than one name because the convention is not universal, and a project using
|
|
23
|
+
* `.env.sample` has documented its variables just as well as one using `.env.example`.
|
|
24
|
+
*/
|
|
25
|
+
export const ENVIRONMENT_EXAMPLE_FILES = [
|
|
26
|
+
'.env.example',
|
|
27
|
+
'.env.sample',
|
|
28
|
+
'.env.template',
|
|
29
|
+
];
|
|
30
|
+
// BRACKET ACCESS ONLY, and that is the rule rather than a shortcut. `process.env` is an index
|
|
31
|
+
// signature, so a variable this project invented can only be read with brackets; a variable node or the
|
|
32
|
+
// framework DECLARES - `NODE_ENV` above all - is a known property and is read with a dot. The two forms
|
|
33
|
+
// therefore separate project configuration, which `.env.example` owes a reader, from the ambient
|
|
34
|
+
// variables a runtime sets and no example file should claim to document.
|
|
35
|
+
const BRACKETED_READ = /process\.env\[\s*(?<quote>['"])(?<name>[A-Za-z_]\w*)\k<quote>\s*\]/g;
|
|
36
|
+
// A dotenv assignment: a name at the start of a line, optionally exported, followed by `=`. A comment
|
|
37
|
+
// line cannot match, because `#` is not a name character.
|
|
38
|
+
const EXAMPLE_ASSIGNMENT = /^[ \t]*(?:export[ \t]+)?(?<name>[A-Za-z_]\w*)[ \t]*=/gm;
|
|
39
|
+
// A compose interpolation with NO default. `${NAME}` must be supplied; `${NAME:-5432}` and `${NAME-x}`
|
|
40
|
+
// supply themselves, and `${NAME:?message}` declares its own failure, so none of the three is this
|
|
41
|
+
// gate's business. The braced form alone is read: `$NAME` is legal in compose and rare in practice, and
|
|
42
|
+
// telling it apart from a `$$` escape or a shell fragment inside a `command:` is guesswork.
|
|
43
|
+
const COMPOSE_INTERPOLATION = /\$\{(?<name>[A-Z_]\w*)\}/gi;
|
|
44
|
+
// A name a workflow supplies: a mapping key in SCREAMING_SNAKE, or a reference to a secret, a variable,
|
|
45
|
+
// or the job environment. The key form is matched at any indentation, for the reason the header states.
|
|
46
|
+
const WORKFLOW_KEY = /^[ \t]*(?<name>[A-Z_][A-Z0-9_]*)[ \t]*:/gm;
|
|
47
|
+
const WORKFLOW_CONTEXT_REFERENCE = /\$\{\{[^}]*?\b(?:secrets|vars|env)\.(?<name>[A-Za-z_]\w*)/g;
|
|
48
|
+
// What makes a workflow one whose job environment has to carry the compose variables: it runs a
|
|
49
|
+
// ploaness verification, and verification validates every compose file the repository ships. A workflow
|
|
50
|
+
// that publishes a release or labels an issue evaluates no compose file and is owed nothing.
|
|
51
|
+
const VERIFYING_COMMANDS = ['ploaness verify', 'ploaness gate', 'run verify'];
|
|
52
|
+
// Read through a NAMED group rather than a positional one. The bracketed-read pattern needs a
|
|
53
|
+
// back-reference to match a quote with its own kind, which puts the name in the second group and the
|
|
54
|
+
// quote in the first - a number that says nothing at the call site and that the magic-number rule is
|
|
55
|
+
// right to refuse. Every pattern here therefore captures into `name`.
|
|
56
|
+
const namesMatching = (source, pattern) => [...source.matchAll(pattern)].map((match) => String(match.groups?.['name']));
|
|
57
|
+
const uniqueSorted = (names) => [...new Set(names)].sort((left, right) => left.localeCompare(right));
|
|
58
|
+
/**
|
|
59
|
+
* The variables an application reads out of its validated environment module.
|
|
60
|
+
* @param source the contents of that module.
|
|
61
|
+
* @returns each name once, sorted, so a finding list is deterministic.
|
|
62
|
+
*/
|
|
63
|
+
export const readEnvironmentNames = (source) => uniqueSorted(namesMatching(source, BRACKETED_READ));
|
|
64
|
+
/**
|
|
65
|
+
* The variables an example file documents.
|
|
66
|
+
* @param example the contents of the example file.
|
|
67
|
+
* @returns each name once, sorted.
|
|
68
|
+
*/
|
|
69
|
+
export const documentedEnvironmentNames = (example) => uniqueSorted(namesMatching(example, EXAMPLE_ASSIGNMENT));
|
|
70
|
+
/**
|
|
71
|
+
* The variables a compose file interpolates without supplying a default.
|
|
72
|
+
* @param compose the contents of the compose file.
|
|
73
|
+
* @returns each name once, sorted.
|
|
74
|
+
*/
|
|
75
|
+
export const interpolatedEnvironmentNames = (compose) => uniqueSorted(namesMatching(compose, COMPOSE_INTERPOLATION));
|
|
76
|
+
/**
|
|
77
|
+
* The variables a workflow supplies, by any means and at any nesting depth.
|
|
78
|
+
* @param workflow the contents of the workflow file.
|
|
79
|
+
* @returns each name once, sorted.
|
|
80
|
+
*/
|
|
81
|
+
export const workflowSuppliedNames = (workflow) => uniqueSorted([
|
|
82
|
+
...namesMatching(workflow, WORKFLOW_KEY),
|
|
83
|
+
...namesMatching(workflow, WORKFLOW_CONTEXT_REFERENCE),
|
|
84
|
+
]);
|
|
85
|
+
/**
|
|
86
|
+
* Whether a workflow runs a ploaness verification, and therefore evaluates the compose files.
|
|
87
|
+
* @param workflow the contents of the workflow file.
|
|
88
|
+
* @returns true when the workflow invokes verification or a single gate.
|
|
89
|
+
*/
|
|
90
|
+
export const isVerifyingWorkflow = (workflow) => VERIFYING_COMMANDS.some((command) => workflow.includes(command));
|
|
91
|
+
const undocumented = (names, documented, origin, reason) => names
|
|
92
|
+
.filter((name) => !documented.has(name))
|
|
93
|
+
.map((name) => ({ name, origin, reason }));
|
|
94
|
+
const missingFromWorkflow = (names, workflow) => {
|
|
95
|
+
const supplied = new Set(workflowSuppliedNames(workflow.content));
|
|
96
|
+
return names
|
|
97
|
+
.filter((name) => !supplied.has(name))
|
|
98
|
+
.map((name) => ({
|
|
99
|
+
name,
|
|
100
|
+
origin: 'compose',
|
|
101
|
+
reason: [
|
|
102
|
+
'interpolated by a compose file but not supplied by',
|
|
103
|
+
`${workflow.file}, where verification will evaluate it`,
|
|
104
|
+
].join(' '),
|
|
105
|
+
}));
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Every environment variable declared in one place and absent from another it has to reach.
|
|
109
|
+
*
|
|
110
|
+
* Three containments, each one-directional. What the application reads must be documented. What a
|
|
111
|
+
* compose file interpolates must be documented, because `docker compose config` reads the example file
|
|
112
|
+
* a developer copied. And what a compose file interpolates must be supplied by every workflow that
|
|
113
|
+
* verifies, because a workflow has no copied file to interpolate from.
|
|
114
|
+
* @param inputs the files, already read.
|
|
115
|
+
* @returns the violations, sorted by name within each rule. An empty array means the four places agree.
|
|
116
|
+
*/
|
|
117
|
+
export const findEnvironmentViolations = (inputs) => {
|
|
118
|
+
const documented = new Set(inputs.example === undefined ? [] : documentedEnvironmentNames(inputs.example));
|
|
119
|
+
const read = uniqueSorted(inputs.applicationSources.flatMap((source) => readEnvironmentNames(source)));
|
|
120
|
+
const interpolated = uniqueSorted(inputs.composeSources.flatMap((source) => interpolatedEnvironmentNames(source)));
|
|
121
|
+
const verifying = inputs.workflows.filter((workflow) => isVerifyingWorkflow(workflow.content));
|
|
122
|
+
return [
|
|
123
|
+
...undocumented(read, documented, 'application', 'read by the validated environment module but documented in no example file'),
|
|
124
|
+
...undocumented(interpolated, documented, 'compose', 'interpolated by a compose file but documented in no example file'),
|
|
125
|
+
...verifying.flatMap((workflow) => missingFromWorkflow(interpolated, workflow)),
|
|
126
|
+
];
|
|
127
|
+
};
|
|
128
|
+
//# sourceMappingURL=environment-coherence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment-coherence.js","sourceRoot":"","sources":["../src/environment-coherence.ts"],"names":[],"mappings":"AAAA,4GAA4G;AA8B5G;;;GAGG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAW,wBAAwB,CAAA;AAE5E;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAsB;IAC5D,4BAA4B;IAC5B,cAAc;CACf,CAAA;AAED;;;;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AAsB,EAAmC,EAAE,CAC/E,mBAAmB,CAAC,YAAY,EAAE,QAAQ,CAAC,CAC5C;KACF,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environment-files.d.ts","sourceRoot":"","sources":["../src/environment-files.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"environment-files.d.ts","sourceRoot":"","sources":["../src/environment-files.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAA2B,CAAA;AAE9E;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAC9B,gBAAgB,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,KAChD,SAAS,MAAM,EAC6D,CAAA;AAE/E;;;;;;;;;GASG;AACH,eAAO,MAAM,MAAM,GAAI,WAAW,MAAM,KAAG,MAAM,GAAG,SASnD,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,uBAAuB,GAClC,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,EACrD,aAAa,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,EAAE,KACnE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAe/B,CAAA"}
|
|
@@ -1,22 +1,4 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// A Payload config validates `process.env` at module scope, so anything that boots the project boots
|
|
4
|
-
// its configuration first. Next reads these files itself, which is why the application under test never
|
|
5
|
-
// had a problem - but a test runner does not, and the runner ploaness ships a Playwright config for
|
|
6
|
-
// boots the project in its OWN process: an end-to-end helper that seeds a user through `getPayload`
|
|
7
|
-
// evaluates `payload.config.ts` at spec-collection time, before a browser or a server is involved.
|
|
8
|
-
//
|
|
9
|
-
// The project used to load them from its own `playwright.config.ts`. The wiring gate now requires that
|
|
10
|
-
// file to be a bare re-export, which removes the only seam it had, so the harness that took the seam
|
|
11
|
-
// away owes the load. Vitest is the other half of the same shape and keeps its own answer: a project
|
|
12
|
-
// writes `vitest.setup.ts` and ploaness loads it, which is a seam the project still owns.
|
|
13
|
-
//
|
|
14
|
-
// The order is the part that carries meaning, and it is stated here rather than at the call site so
|
|
15
|
-
// that it is measured: `packages/config` is an analyzer configuration that no coverage floor reads,
|
|
16
|
-
// while everything in this package is unit-tested. Nothing loaded later may replace a value already
|
|
17
|
-
// set, so the file that must win is read first, and a variable the real environment already carries -
|
|
18
|
-
// a CI secret, a `DATABASE_URL` exported by a service container - outranks every file, because it was
|
|
19
|
-
// there before any of them was read.
|
|
1
|
+
// Declare environment file precedence shared by analysis, tests, and application startup.
|
|
20
2
|
/**
|
|
21
3
|
* The environment files a run reads, highest precedence first. `.env.local` leads because it is the
|
|
22
4
|
* personal, untracked override of `.env`; the managed `.gitignore` ignores both, which is what makes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environment-files.js","sourceRoot":"","sources":["../src/environment-files.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"environment-files.js","sourceRoot":"","sources":["../src/environment-files.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAE1F;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAsB,CAAC,YAAY,EAAE,MAAM,CAAC,CAAA;AAE9E;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,cAAiD,EAC9B,EAAE,CACrB,qBAAqB,CAAC,MAAM,CAAC,CAAC,IAAY,EAAW,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAA;AAE/E;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,SAAiB,EAAsB,EAAE;IAC9D,IAAI,CAAC;QACH,MAAM,IAAI,GAAW,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,CAAA;QAC5C,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAA;IAC3C,CAAC;IAAC,MAAM,CAAC;QACP,+FAA+F;QAC/F,kFAAkF;QAClF,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,OAAqD,EACrD,WAAoE,EAClC,EAAE,CACpC,MAAM,CAAC,WAAW,CAChB,WAAW;KACR,OAAO,CACN,CACE,IAAkD,EACT,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CACnE;KACA,MAAM,CACL,CAAC,KAA4C,EAA6B,EAAE,CAC1E,KAAK,CAAC,CAAC,CAAC,KAAK,SAAS,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,SAAS,CAC5D;IACD,kGAAkG;IAClG,mEAAmE;KAClE,UAAU,EAAE,CAChB,CAAA"}
|
package/dist/file-roles.d.ts
CHANGED
|
@@ -15,13 +15,18 @@ export declare const isBinary: (bytes: Uint8Array) => boolean;
|
|
|
15
15
|
* @returns true when the path ends with one of them.
|
|
16
16
|
*/
|
|
17
17
|
export declare const hasExtension: (filePath: string, extensions: readonly string[]) => boolean;
|
|
18
|
+
/** A role regex evaluated either at the repository root or inside its declaring member. */
|
|
19
|
+
export type RolePattern = string | {
|
|
20
|
+
readonly memberPath: string;
|
|
21
|
+
readonly pattern: string;
|
|
22
|
+
};
|
|
18
23
|
/**
|
|
19
24
|
* Decide whether a path is excluded by a declared role pattern.
|
|
20
25
|
* @param filePath the repo-relative path.
|
|
21
26
|
* @param patterns the declared exclusion patterns.
|
|
22
27
|
* @returns true when any pattern matches.
|
|
23
28
|
*/
|
|
24
|
-
export declare const matchesRole: (filePath: string, patterns: readonly
|
|
29
|
+
export declare const matchesRole: (filePath: string, patterns: readonly RolePattern[]) => boolean;
|
|
25
30
|
/**
|
|
26
31
|
* Whether a repo-relative path matches a glob pattern of the kind the coverage settings carry.
|
|
27
32
|
* @param pattern the glob, such as `src/app/**` or `src/**\/*.tsx`.
|
|
@@ -35,5 +40,5 @@ export declare const matchesGlob: (pattern: string, filePath: string) => boolean
|
|
|
35
40
|
* @param excluded the declared generated-role patterns.
|
|
36
41
|
* @returns true when the file is code and no declared role excludes it.
|
|
37
42
|
*/
|
|
38
|
-
export declare const isGovernedCode: (filePath: string, excluded: readonly
|
|
43
|
+
export declare const isGovernedCode: (filePath: string, excluded: readonly RolePattern[]) => boolean;
|
|
39
44
|
//# sourceMappingURL=file-roles.d.ts.map
|
package/dist/file-roles.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-roles.d.ts","sourceRoot":"","sources":["../src/file-roles.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"file-roles.d.ts","sourceRoot":"","sources":["../src/file-roles.ts"],"names":[],"mappings":"AAKA,sGAAsG;AACtG,eAAO,MAAM,eAAe,EAAE,SAAS,MAAM,EAW5C,CAAA;AAED,kGAAkG;AAClG,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAA6B,CAAA;AAE3E;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,UAAU,KAAG,OACM,CAAA;AAEnD;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,UAAU,MAAM,EAAE,YAAY,SAAS,MAAM,EAAE,KAAG,OACA,CAAA;AAE/E,2FAA2F;AAC3F,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAA;AAY5F;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,UAAU,MAAM,EAAE,UAAU,SAAS,WAAW,EAAE,KAAG,OACI,CAAA;AA2BrF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,SAAS,MAAM,EAAE,UAAU,MAAM,KAAG,OAG9C,CAAA;AAElB;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAI,UAAU,MAAM,EAAE,UAAU,SAAS,WAAW,EAAE,KAAG,OACP,CAAA"}
|
package/dist/file-roles.js
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
//
|
|
2
|
-
// exclude it from a check.
|
|
3
|
-
//
|
|
4
|
-
// The typography ban used to carry its own allowlist of ten extensions, which is the wrong shape for a
|
|
5
|
-
// rule that reaches "every tracked file the repository does not exclude by role": a `.css`, a `.adoc`,
|
|
6
|
-
// a shell script, or a Dockerfile went unscanned, and every new text format arrived unscanned until
|
|
7
|
-
// someone remembered to extend the list. A role predicate is default-safe in the opposite direction -
|
|
8
|
-
// a new format is covered by construction, and exclusion is the thing that must be stated.
|
|
1
|
+
// Identify source, generated, binary, and prose roles so exclusions follow file meaning rather than tool defaults.
|
|
9
2
|
/** How much of a file is inspected before deciding it is text. Enough to reach any real header. */
|
|
10
3
|
const BINARY_PROBE_BYTES = 8192;
|
|
11
4
|
/** Extensions the Code Rules apply to, used where a rule is about code rather than about any text. */
|
|
12
5
|
export const CODE_EXTENSIONS = [
|
|
13
6
|
'.ts',
|
|
14
7
|
'.tsx',
|
|
8
|
+
'.jsx',
|
|
15
9
|
'.mts',
|
|
16
10
|
'.cts',
|
|
17
11
|
'.js',
|
|
@@ -35,13 +29,20 @@ export const isBinary = (bytes) => bytes.subarray(0, BINARY_PROBE_BYTES).include
|
|
|
35
29
|
* @returns true when the path ends with one of them.
|
|
36
30
|
*/
|
|
37
31
|
export const hasExtension = (filePath, extensions) => extensions.some((extension) => filePath.endsWith(extension));
|
|
32
|
+
const matchesPattern = (filePath, pattern) => {
|
|
33
|
+
if (typeof pattern === 'string') {
|
|
34
|
+
return new RegExp(pattern).test(filePath);
|
|
35
|
+
}
|
|
36
|
+
const prefix = `${pattern.memberPath}/`;
|
|
37
|
+
return (filePath.startsWith(prefix) && new RegExp(pattern.pattern).test(filePath.slice(prefix.length)));
|
|
38
|
+
};
|
|
38
39
|
/**
|
|
39
40
|
* Decide whether a path is excluded by a declared role pattern.
|
|
40
41
|
* @param filePath the repo-relative path.
|
|
41
42
|
* @param patterns the declared exclusion patterns.
|
|
42
43
|
* @returns true when any pattern matches.
|
|
43
44
|
*/
|
|
44
|
-
export const matchesRole = (filePath, patterns) => patterns.some((pattern) =>
|
|
45
|
+
export const matchesRole = (filePath, patterns) => patterns.some((pattern) => matchesPattern(filePath, pattern));
|
|
45
46
|
// The glob dialect the coverage settings are written in, which is not the regex dialect `matchesRole`
|
|
46
47
|
// reads. `**/` crosses directory boundaries and `*` does not, which is the whole distinction between
|
|
47
48
|
// `src/**/*.tsx` and `src/*.tsx`; collapsing the two would silently widen every pattern that uses one.
|
package/dist/file-roles.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-roles.js","sourceRoot":"","sources":["../src/file-roles.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"file-roles.js","sourceRoot":"","sources":["../src/file-roles.ts"],"names":[],"mappings":"AAAA,mHAAmH;AAEnH,mGAAmG;AACnG,MAAM,kBAAkB,GAAW,IAAI,CAAA;AAEvC,sGAAsG;AACtG,MAAM,CAAC,MAAM,eAAe,GAAsB;IAChD,KAAK;IACL,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,KAAK;IACL,MAAM;IACN,MAAM;IACN,MAAM;IACN,OAAO;CACR,CAAA;AAED,kGAAkG;AAClG,MAAM,CAAC,MAAM,gBAAgB,GAAsB,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;AAE3E;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAiB,EAAW,EAAE,CACrD,KAAK,CAAC,QAAQ,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAC,QAAQ,CAAC,C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T,OAAO,OAAO,CAAA;QAChB,CAAC;QACD,KAAK,GAAG,CAAC,CAAC,CAAC;YACT,OAAO,MAAM,CAAA;QACf,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACR,OAAO,KAAK,KAAK,EAAE,CAAA;QACrB,CAAC;IACH,CAAC;AACH,CAAC,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,OAAe,EAAE,QAAgB,EAAW,EAAE,CACxE,IAAI,MAAM,CACR,IAAI,OAAO,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC,KAAa,EAAU,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,GAAG,CACtF,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;AAElB;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,QAAgB,EAAE,QAAgC,EAAW,EAAE,CAC5F,YAAY,CAAC,QAAQ,EAAE,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { DeclaredCoordinate, FreshnessFinding, ManifestSource } from './dependency-freshness.js';
|
|
2
|
+
/**
|
|
3
|
+
* Who can act on a freshness finding.
|
|
4
|
+
*
|
|
5
|
+
* - `project`: declared by this repository at a version it chooses. Change the declaration.
|
|
6
|
+
* - `pin`: declared by this repository at a version ploaness decides. The wiring gate holds the
|
|
7
|
+
* declaration to the pin, so the repair is a ploaness release that carries the newer one.
|
|
8
|
+
* - `inherited`: declared in a manifest this repository inherits from ploaness. The same repair, with
|
|
9
|
+
* no line in the project to edit at all.
|
|
10
|
+
*/
|
|
11
|
+
export type FreshnessRepair = 'project' | 'pin' | 'inherited';
|
|
12
|
+
/** The order the groups print in: what the reader can act on first. */
|
|
13
|
+
export declare const REPAIR_ORDER: readonly FreshnessRepair[];
|
|
14
|
+
/** What the report needs to know about whose version a name is. */
|
|
15
|
+
export interface FreshnessOwnership {
|
|
16
|
+
/** Every name whose exact version ploaness pins for a project that declares it. */
|
|
17
|
+
readonly pinnedByHarness: ReadonlySet<string>;
|
|
18
|
+
/**
|
|
19
|
+
* True when the repository under judgement is ploaness itself. Its pins are a file it tracks, so a
|
|
20
|
+
* pinned coordinate there is the project's to change like any other.
|
|
21
|
+
*/
|
|
22
|
+
readonly isHarnessItself: boolean;
|
|
23
|
+
}
|
|
24
|
+
/** One group of the report: the findings that share a repair, under the line that states it. */
|
|
25
|
+
export interface FreshnessSection {
|
|
26
|
+
readonly repair: FreshnessRepair;
|
|
27
|
+
/** The action for every finding beneath it, stated once. */
|
|
28
|
+
readonly heading: string;
|
|
29
|
+
readonly findings: readonly FreshnessFinding[];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Whether this repository is ploaness: it tracks the manifest of the package called `ploaness`.
|
|
33
|
+
*
|
|
34
|
+
* Decided from what the tree contains rather than from a flag, for the reason a member's kind is
|
|
35
|
+
* derived from what it declares: nothing can describe itself into a weaker reading. Read from the
|
|
36
|
+
* project's own manifests only, because in a consumer the same name arrives as an INHERITED manifest,
|
|
37
|
+
* and that is exactly the case this must answer `false` for.
|
|
38
|
+
* @param manifests every manifest the gate read, the project's own and the inherited ones.
|
|
39
|
+
* @returns true when a manifest the project tracks is ploaness's own.
|
|
40
|
+
*/
|
|
41
|
+
export declare const isHarnessRepository: (manifests: readonly ManifestSource[]) => boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Whether ploaness decides the version a project declares a name at.
|
|
44
|
+
*
|
|
45
|
+
* Three rules, each one the wiring gate already enforces and each derived from it rather than restated:
|
|
46
|
+
* a pinned name must match the pin, a `@payloadcms/*` package must match the pinned `payload`, and a
|
|
47
|
+
* `@ploaness/*` package must match the declared `ploaness`. `ploaness` itself is the one exception,
|
|
48
|
+
* and it proves the third rule: the release is the single version a project is entitled to choose,
|
|
49
|
+
* and upgrading it is the repair every line in the two harness groups names.
|
|
50
|
+
* @param name the declared name.
|
|
51
|
+
* @param pinnedByHarness every name ploaness pins.
|
|
52
|
+
* @returns true when the project may not change the version on its own.
|
|
53
|
+
*/
|
|
54
|
+
export declare const isVersionDecidedByHarness: (name: string, pinnedByHarness: ReadonlySet<string>) => boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Whose repair one coordinate is.
|
|
57
|
+
* @param coordinate the declared coordinate, with the manifest that declares it.
|
|
58
|
+
* @param ownership whose version each name is.
|
|
59
|
+
* @returns the group the finding belongs in.
|
|
60
|
+
*/
|
|
61
|
+
export declare const repairOf: (coordinate: DeclaredCoordinate, ownership: FreshnessOwnership) => FreshnessRepair;
|
|
62
|
+
/**
|
|
63
|
+
* Whether a finding is the harness release itself, in the project's own manifest.
|
|
64
|
+
*
|
|
65
|
+
* It is the one line in the project group whose repair is every harness line's repair, so the report
|
|
66
|
+
* says so on it.
|
|
67
|
+
* @param finding the finding to classify.
|
|
68
|
+
* @returns true for `ploaness` declared by the project.
|
|
69
|
+
*/
|
|
70
|
+
export declare const isHarnessRelease: (finding: DeclaredCoordinate) => boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Sort the report's findings into the three repair groups, in the order they print.
|
|
73
|
+
*
|
|
74
|
+
* Every group is returned, empty or not, so the caller decides what an empty one prints as; the
|
|
75
|
+
* order within a group is the order the findings arrived in, which is manifest order, so the same tree
|
|
76
|
+
* yields the same report.
|
|
77
|
+
* @param findings every finding the report will print.
|
|
78
|
+
* @param ownership whose version each name is.
|
|
79
|
+
* @returns the three groups, each under its heading.
|
|
80
|
+
*/
|
|
81
|
+
export declare const sectionFreshnessReport: (findings: readonly FreshnessFinding[], ownership: FreshnessOwnership) => readonly FreshnessSection[];
|
|
82
|
+
//# sourceMappingURL=freshness-repair.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"freshness-repair.d.ts","sourceRoot":"","sources":["../src/freshness-repair.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACf,MAAM,2BAA2B,CAAA;AAKlC;;;;;;;;GAQG;AACH,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,KAAK,GAAG,WAAW,CAAA;AAE7D,uEAAuE;AACvE,eAAO,MAAM,YAAY,EAAE,SAAS,eAAe,EAAoC,CAAA;AAEvF,mEAAmE;AACnE,MAAM,WAAW,kBAAkB;IACjC,mFAAmF;IACnF,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;IAC7C;;;OAGG;IACH,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAA;CAClC;AAED,gGAAgG;AAChG,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAA;IAChC,4DAA4D;IAC5D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,QAAQ,EAAE,SAAS,gBAAgB,EAAE,CAAA;CAC/C;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,GAAI,WAAW,SAAS,cAAc,EAAE,KAAG,OAIxE,CAAA;AAEH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,yBAAyB,GACpC,MAAM,MAAM,EACZ,iBAAiB,WAAW,CAAC,MAAM,CAAC,KACnC,OAEoF,CAAA;AAEvF;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GACnB,YAAY,kBAAkB,EAC9B,WAAW,kBAAkB,KAC5B,eAQF,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,GAAI,SAAS,kBAAkB,KAAG,OACL,CAAA;AAwB1D;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB,GACjC,UAAU,SAAS,gBAAgB,EAAE,EACrC,WAAW,kBAAkB,KAC5B,SAAS,gBAAgB,EAa3B,CAAA"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// Assign each update to the project or harness that owns its version, using the wiring policy as authority.
|
|
2
|
+
import { HARNESS_PACKAGE, isHarnessPackage } from './harness-package.js';
|
|
3
|
+
import { asRecord, asText } from './json-shapes.js';
|
|
4
|
+
import { isPayloadFamilyPackage } from './version-policy.js';
|
|
5
|
+
/** The order the groups print in: what the reader can act on first. */
|
|
6
|
+
export const REPAIR_ORDER = ['project', 'pin', 'inherited'];
|
|
7
|
+
/**
|
|
8
|
+
* Whether this repository is ploaness: it tracks the manifest of the package called `ploaness`.
|
|
9
|
+
*
|
|
10
|
+
* Decided from what the tree contains rather than from a flag, for the reason a member's kind is
|
|
11
|
+
* derived from what it declares: nothing can describe itself into a weaker reading. Read from the
|
|
12
|
+
* project's own manifests only, because in a consumer the same name arrives as an INHERITED manifest,
|
|
13
|
+
* and that is exactly the case this must answer `false` for.
|
|
14
|
+
* @param manifests every manifest the gate read, the project's own and the inherited ones.
|
|
15
|
+
* @returns true when a manifest the project tracks is ploaness's own.
|
|
16
|
+
*/
|
|
17
|
+
export const isHarnessRepository = (manifests) => manifests.some((manifest) => !manifest.isInherited && asText(asRecord(manifest.packageJson)['name']) === HARNESS_PACKAGE);
|
|
18
|
+
/**
|
|
19
|
+
* Whether ploaness decides the version a project declares a name at.
|
|
20
|
+
*
|
|
21
|
+
* Three rules, each one the wiring gate already enforces and each derived from it rather than restated:
|
|
22
|
+
* a pinned name must match the pin, a `@payloadcms/*` package must match the pinned `payload`, and a
|
|
23
|
+
* `@ploaness/*` package must match the declared `ploaness`. `ploaness` itself is the one exception,
|
|
24
|
+
* and it proves the third rule: the release is the single version a project is entitled to choose,
|
|
25
|
+
* and upgrading it is the repair every line in the two harness groups names.
|
|
26
|
+
* @param name the declared name.
|
|
27
|
+
* @param pinnedByHarness every name ploaness pins.
|
|
28
|
+
* @returns true when the project may not change the version on its own.
|
|
29
|
+
*/
|
|
30
|
+
export const isVersionDecidedByHarness = (name, pinnedByHarness) => name !== HARNESS_PACKAGE &&
|
|
31
|
+
(pinnedByHarness.has(name) || isPayloadFamilyPackage(name) || isHarnessPackage(name));
|
|
32
|
+
/**
|
|
33
|
+
* Whose repair one coordinate is.
|
|
34
|
+
* @param coordinate the declared coordinate, with the manifest that declares it.
|
|
35
|
+
* @param ownership whose version each name is.
|
|
36
|
+
* @returns the group the finding belongs in.
|
|
37
|
+
*/
|
|
38
|
+
export const repairOf = (coordinate, ownership) => {
|
|
39
|
+
if (coordinate.isInherited) {
|
|
40
|
+
return 'inherited';
|
|
41
|
+
}
|
|
42
|
+
return !ownership.isHarnessItself &&
|
|
43
|
+
isVersionDecidedByHarness(coordinate.name, ownership.pinnedByHarness)
|
|
44
|
+
? 'pin'
|
|
45
|
+
: 'project';
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Whether a finding is the harness release itself, in the project's own manifest.
|
|
49
|
+
*
|
|
50
|
+
* It is the one line in the project group whose repair is every harness line's repair, so the report
|
|
51
|
+
* says so on it.
|
|
52
|
+
* @param finding the finding to classify.
|
|
53
|
+
* @returns true for `ploaness` declared by the project.
|
|
54
|
+
*/
|
|
55
|
+
export const isHarnessRelease = (finding) => !finding.isInherited && finding.name === HARNESS_PACKAGE;
|
|
56
|
+
// The two harness groups name one repair, and which one depends on whether there is a release to take.
|
|
57
|
+
// A heading that said "upgrade ploaness" over a project already on the latest release would send the
|
|
58
|
+
// reader to an upgrade that does not exist; the honest statement then is that the wait is on ploaness.
|
|
59
|
+
const harnessRepair = (hasNewerHarness) => hasNewerHarness
|
|
60
|
+
? `upgrading ${HARNESS_PACKAGE} is the repair`
|
|
61
|
+
: `no newer ${HARNESS_PACKAGE} release is published yet, so the repair is to report a version ` +
|
|
62
|
+
'that matters';
|
|
63
|
+
const headingOf = (repair, hasNewerHarness) => {
|
|
64
|
+
const headings = {
|
|
65
|
+
project: 'yours to change: declared by this project at a version it chooses',
|
|
66
|
+
pin: `pinned by ${HARNESS_PACKAGE}: declared by this project at a version ${HARNESS_PACKAGE} ` +
|
|
67
|
+
`decides, and the wiring gate holds it there; ${harnessRepair(hasNewerHarness)}`,
|
|
68
|
+
inherited: `declared by ${HARNESS_PACKAGE}: in manifests this project inherits, so there is nothing ` +
|
|
69
|
+
`here to edit; ${harnessRepair(hasNewerHarness)}`,
|
|
70
|
+
};
|
|
71
|
+
return headings[repair];
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Sort the report's findings into the three repair groups, in the order they print.
|
|
75
|
+
*
|
|
76
|
+
* Every group is returned, empty or not, so the caller decides what an empty one prints as; the
|
|
77
|
+
* order within a group is the order the findings arrived in, which is manifest order, so the same tree
|
|
78
|
+
* yields the same report.
|
|
79
|
+
* @param findings every finding the report will print.
|
|
80
|
+
* @param ownership whose version each name is.
|
|
81
|
+
* @returns the three groups, each under its heading.
|
|
82
|
+
*/
|
|
83
|
+
export const sectionFreshnessReport = (findings, ownership) => {
|
|
84
|
+
const hasNewerHarness = findings.some((finding) => isHarnessRelease(finding));
|
|
85
|
+
return REPAIR_ORDER.map((repair) => ({
|
|
86
|
+
repair,
|
|
87
|
+
heading: headingOf(repair, hasNewerHarness),
|
|
88
|
+
findings: findings.filter((finding) => repairOf(finding, ownership) === repair),
|
|
89
|
+
}));
|
|
90
|
+
};
|
|
91
|
+
//# sourceMappingURL=freshness-repair.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"freshness-repair.js","sourceRoot":"","sources":["../src/freshness-repair.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAO5G,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAa5D,uEAAuE;AACvE,MAAM,CAAC,MAAM,YAAY,GAA+B,CAAC,SAAS,EAAE,KAAK,EAAE,WAAW,CAAC,CAAA;AAqBvF;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,SAAoC,EAAW,EAAE,CACnF,SAAS,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AO,EAAE,mEAAmE;QAC5E,GAAG,EACD,aAAa,eAAe,2CAA2C,eAAe,GAAG;YACzF,gDAAgD,aAAa,CAAC,eAAe,CAAC,EAAE;QAClF,SAAS,EACP,eAAe,eAAe,4DAA4D;YAC1F,iBAAiB,aAAa,CAAC,eAAe,CAAC,EAAE;KACpD,CAAA;IACD,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAA;AACzB,CAAC,CAAA;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,QAAqC,EACrC,SAA6B,EACA,EAAE;IAC/B,MAAM,eAAe,GAAY,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAyB,EAAW,EAAE,CACpF,gBAAgB,CAAC,OAAO,CAAC,CAC1B,CAAA;IACD,OAAO,YAAY,CAAC,GAAG,CACrB,CAAC,MAAuB,EAAoB,EAAE,CAAC,CAAC;QAC9C,MAAM;QACN,OAAO,EAAE,SAAS,CAAC,MAAM,EAAE,eAAe,CAAC;QAC3C,QAAQ,EAAE,QAAQ,CAAC,MAAM,CACvB,CAAC,OAAyB,EAAW,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC,KAAK,MAAM,CAChF;KACF,CAAC,CACH,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generated-denial.d.ts","sourceRoot":"","sources":["../src/generated-denial.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generated-denial.d.ts","sourceRoot":"","sources":["../src/generated-denial.ts"],"names":[],"mappings":"AAGA,sGAAsG;AACtG,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EAIhD,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,GAAI,WAAW,SAAS,MAAM,EAAE,KAAG,SAAS,MAAM,EAI5E,CAAA;AASJ;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GACzB,UAAU,OAAO,EACjB,WAAW,SAAS,MAAM,EAAE,KAC3B,MAAM,CAAC,MAAM,EAAE,OAAO,CASxB,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAC/B,UAAU,OAAO,EACjB,eAAe,OAAO,EACtB,WAAW,SAAS,MAAM,EAAE,KAC3B,SAAS,MAAM,EAgBjB,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,GACzB,aAAa,SAAS,MAAM,EAAE,EAC9B,WAAW,SAAS,MAAM,EAAE,KAC3B,SAAS,MAAM,EAKf,CAAA"}
|