repopo 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/README.md +13 -6
- package/esm/api.d.ts +2 -0
- package/esm/api.d.ts.map +1 -1
- package/esm/api.js +1 -0
- package/esm/api.js.map +1 -1
- package/esm/commands/check-native.d.ts +2 -0
- package/esm/commands/check-native.d.ts.map +1 -1
- package/esm/commands/check-native.js +9 -0
- package/esm/commands/check-native.js.map +1 -1
- package/esm/commands/check.d.ts +2 -0
- package/esm/commands/check.d.ts.map +1 -1
- package/esm/commands/check.js +26 -2
- package/esm/commands/check.js.map +1 -1
- package/esm/commands/list.d.ts.map +1 -1
- package/esm/commands/list.js +1 -1
- package/esm/commands/list.js.map +1 -1
- package/esm/config.d.ts +5 -0
- package/esm/config.d.ts.map +1 -1
- package/esm/config.js.map +1 -1
- package/esm/context.d.ts +2 -0
- package/esm/context.d.ts.map +1 -1
- package/esm/context.js +11 -0
- package/esm/context.js.map +1 -1
- package/esm/makePolicy.d.ts.map +1 -1
- package/esm/makePolicy.js +3 -1
- package/esm/makePolicy.js.map +1 -1
- package/esm/policies/MaxChangedFiles.d.ts +17 -0
- package/esm/policies/MaxChangedFiles.d.ts.map +1 -0
- package/esm/policies/MaxChangedFiles.js +22 -0
- package/esm/policies/MaxChangedFiles.js.map +1 -0
- package/esm/policies/RequireCompanionChanges.d.ts +16 -0
- package/esm/policies/RequireCompanionChanges.d.ts.map +1 -0
- package/esm/policies/RequireCompanionChanges.js +42 -0
- package/esm/policies/RequireCompanionChanges.js.map +1 -0
- package/esm/policies.d.ts +2 -0
- package/esm/policies.d.ts.map +1 -1
- package/esm/policies.js +2 -0
- package/esm/policies.js.map +1 -1
- package/esm/policy.d.ts +9 -3
- package/esm/policy.d.ts.map +1 -1
- package/esm/policy.js.map +1 -1
- package/esm/policyExecution.d.ts +4 -3
- package/esm/policyExecution.d.ts.map +1 -1
- package/esm/policyExecution.js +13 -3
- package/esm/policyExecution.js.map +1 -1
- package/esm/repositoryChanges.d.ts +26 -0
- package/esm/repositoryChanges.d.ts.map +1 -0
- package/esm/repositoryChanges.js +172 -0
- package/esm/repositoryChanges.js.map +1 -0
- package/esm/repositoryFiles.d.ts +2 -0
- package/esm/repositoryFiles.d.ts.map +1 -1
- package/esm/repositoryFiles.js +6 -3
- package/esm/repositoryFiles.js.map +1 -1
- package/esm/runner.d.ts +5 -4
- package/esm/runner.d.ts.map +1 -1
- package/esm/runner.js +26 -27
- package/esm/runner.js.map +1 -1
- package/oclif.manifest.json +39 -1
- package/package.json +1 -1
- package/sidecar/sidecar.mjs +48 -8
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Limit the number of files in the selected change set. @public */
|
|
2
|
+
export const MaxChangedFiles = {
|
|
3
|
+
name: "MaxChangedFiles",
|
|
4
|
+
description: "Limits the number of changed files in a change set.",
|
|
5
|
+
scope: "changes",
|
|
6
|
+
requiresConfig: true,
|
|
7
|
+
handler: async ({ entries, config }) => {
|
|
8
|
+
if (!(config && Number.isInteger(config.maxFiles)) || config.maxFiles < 0) {
|
|
9
|
+
throw new TypeError("MaxChangedFiles requires maxFiles to be a nonnegative integer.");
|
|
10
|
+
}
|
|
11
|
+
const count = entries.filter((entry) => entry.status !== "unchanged").length;
|
|
12
|
+
return count > config.maxFiles
|
|
13
|
+
? [
|
|
14
|
+
{
|
|
15
|
+
message: `Change set contains ${count} changed files; maximum allowed is ${config.maxFiles}.`,
|
|
16
|
+
manualFix: "Reduce the number of changed files or split the change into smaller change sets.",
|
|
17
|
+
},
|
|
18
|
+
]
|
|
19
|
+
: [];
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=MaxChangedFiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MaxChangedFiles.js","sourceRoot":"","sources":["../../src/policies/MaxChangedFiles.ts"],"names":[],"mappings":"AAQA,oEAAoE;AACpE,MAAM,CAAC,MAAM,eAAe,GAAG;IAC9B,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,qDAAqD;IAClE,KAAK,EAAE,SAAS;IAChB,cAAc,EAAE,IAAI;IACpB,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE;QACtC,IAAI,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,MAAM,CAAC,QAAQ,GAAG,CAAC,EAAE,CAAC;YAC3E,MAAM,IAAI,SAAS,CAClB,gEAAgE,CAChE,CAAC;QACH,CAAC;QACD,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAC3B,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,KAAK,WAAW,CACvC,CAAC,MAAM,CAAC;QACT,OAAO,KAAK,GAAG,MAAM,CAAC,QAAQ;YAC7B,CAAC,CAAC;gBACA;oBACC,OAAO,EAAE,uBAAuB,KAAK,sCAAsC,MAAM,CAAC,QAAQ,GAAG;oBAC7F,SAAS,EACR,kFAAkF;iBACnF;aACD;YACF,CAAC,CAAC,EAAE,CAAC;IACP,CAAC;CAC2D,CAAC","sourcesContent":["import type { RepositoryPolicyDefinition } from \"../policy.js\";\n\n/** Configuration for the changed-file limit. @public */\nexport interface MaxChangedFilesConfig {\n\t/** Maximum number of eligible changed files; must be a nonnegative integer. */\n\tmaxFiles: number;\n}\n\n/** Limit the number of files in the selected change set. @public */\nexport const MaxChangedFiles = {\n\tname: \"MaxChangedFiles\",\n\tdescription: \"Limits the number of changed files in a change set.\",\n\tscope: \"changes\",\n\trequiresConfig: true,\n\thandler: async ({ entries, config }) => {\n\t\tif (!(config && Number.isInteger(config.maxFiles)) || config.maxFiles < 0) {\n\t\t\tthrow new TypeError(\n\t\t\t\t\"MaxChangedFiles requires maxFiles to be a nonnegative integer.\",\n\t\t\t);\n\t\t}\n\t\tconst count = entries.filter(\n\t\t\t(entry) => entry.status !== \"unchanged\",\n\t\t).length;\n\t\treturn count > config.maxFiles\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\tmessage: `Change set contains ${count} changed files; maximum allowed is ${config.maxFiles}.`,\n\t\t\t\t\t\tmanualFix:\n\t\t\t\t\t\t\t\"Reduce the number of changed files or split the change into smaller change sets.\",\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t: [];\n\t},\n} satisfies RepositoryPolicyDefinition<MaxChangedFilesConfig>;\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Require a related update when trigger paths change. @public */
|
|
2
|
+
export declare const RequireCompanionChanges: {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
scope: "changes";
|
|
6
|
+
requiresConfig: true;
|
|
7
|
+
handler: ({ entries, config }: import("../policy.js").RepositoryPolicyArgs<{
|
|
8
|
+
trigger: string | RegExp;
|
|
9
|
+
companion: string | RegExp;
|
|
10
|
+
}>) => Promise<{
|
|
11
|
+
message: string;
|
|
12
|
+
files: string[];
|
|
13
|
+
manualFix: string;
|
|
14
|
+
}[]>;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=RequireCompanionChanges.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RequireCompanionChanges.d.ts","sourceRoot":"","sources":["../../src/policies/RequireCompanionChanges.ts"],"names":[],"mappings":"AAYA,kEAAkE;AAClE,eAAO,MAAM,uBAAuB;;;;;;iBA4C1B,MAAM,GAAG,MAAM;mBACb,MAAM,GAAG,MAAM;;;;;;CACzB,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { exclusionRegex, matchesPath } from "../context.js";
|
|
2
|
+
function compilePattern(value) {
|
|
3
|
+
if (typeof value !== "string" && !(value instanceof RegExp)) {
|
|
4
|
+
throw new TypeError("Trigger and companion must be regex strings or RegExp values.");
|
|
5
|
+
}
|
|
6
|
+
return exclusionRegex(value);
|
|
7
|
+
}
|
|
8
|
+
/** Require a related update when trigger paths change. @public */
|
|
9
|
+
export const RequireCompanionChanges = {
|
|
10
|
+
name: "RequireCompanionChanges",
|
|
11
|
+
description: "Requires a related file change when trigger paths change.",
|
|
12
|
+
scope: "changes",
|
|
13
|
+
requiresConfig: true,
|
|
14
|
+
handler: async ({ entries, config }) => {
|
|
15
|
+
if (!config) {
|
|
16
|
+
throw new TypeError("RequireCompanionChanges requires config.");
|
|
17
|
+
}
|
|
18
|
+
const trigger = compilePattern(config.trigger);
|
|
19
|
+
const companion = compilePattern(config.companion);
|
|
20
|
+
const triggers = [
|
|
21
|
+
...new Set(entries
|
|
22
|
+
.filter((entry) => entry.status !== "unchanged")
|
|
23
|
+
.flatMap((entry) => (entry.status === "renamed"
|
|
24
|
+
? [entry.previousPath, entry.path]
|
|
25
|
+
: [entry.path]).filter((path) => matchesPath(trigger, path)))),
|
|
26
|
+
];
|
|
27
|
+
if (triggers.length === 0 ||
|
|
28
|
+
entries.some((entry) => entry.status !== "unchanged" &&
|
|
29
|
+
entry.status !== "deleted" &&
|
|
30
|
+
matchesPath(companion, entry.path))) {
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
return [
|
|
34
|
+
{
|
|
35
|
+
message: `Changes matching ${trigger} require a companion change matching ${companion}.`,
|
|
36
|
+
files: triggers,
|
|
37
|
+
manualFix: "Add, update, or rename a file into the companion pattern in the same change set. Deletions do not satisfy this rule.",
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=RequireCompanionChanges.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RequireCompanionChanges.js","sourceRoot":"","sources":["../../src/policies/RequireCompanionChanges.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5D,SAAS,cAAc,CAAC,KAAc;IACrC,IAAI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CAAC,MAAM,KAAK,WAAW;gBAC5B,KAAK,CAAC,MAAM,KAAK,SAAS;gBAC1B,WAAW,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,CACnC,EACA,CAAC;YACF,OAAO,EAAE,CAAC;QACX,CAAC;QACD,OAAO;YACN;gBACC,OAAO,EAAE,oBAAoB,OAAO,wCAAwC,SAAS,GAAG;gBACxF,KAAK,EAAE,QAAQ;gBACf,SAAS,EACR,sHAAsH;aACvH;SACD,CAAC;IACH,CAAC;CAIA,CAAC","sourcesContent":["import { exclusionRegex, matchesPath } from \"../context.js\";\nimport type { RepositoryPolicyDefinition } from \"../policy.js\";\n\nfunction compilePattern(value: unknown): RegExp {\n\tif (typeof value !== \"string\" && !(value instanceof RegExp)) {\n\t\tthrow new TypeError(\n\t\t\t\"Trigger and companion must be regex strings or RegExp values.\",\n\t\t);\n\t}\n\treturn exclusionRegex(value);\n}\n\n/** Require a related update when trigger paths change. @public */\nexport const RequireCompanionChanges = {\n\tname: \"RequireCompanionChanges\",\n\tdescription: \"Requires a related file change when trigger paths change.\",\n\tscope: \"changes\",\n\trequiresConfig: true,\n\thandler: async ({ entries, config }) => {\n\t\tif (!config) {\n\t\t\tthrow new TypeError(\"RequireCompanionChanges requires config.\");\n\t\t}\n\t\tconst trigger = compilePattern(config.trigger);\n\t\tconst companion = compilePattern(config.companion);\n\t\tconst triggers = [\n\t\t\t...new Set(\n\t\t\t\tentries\n\t\t\t\t\t.filter((entry) => entry.status !== \"unchanged\")\n\t\t\t\t\t.flatMap((entry) =>\n\t\t\t\t\t\t(entry.status === \"renamed\"\n\t\t\t\t\t\t\t? [entry.previousPath, entry.path]\n\t\t\t\t\t\t\t: [entry.path]\n\t\t\t\t\t\t).filter((path) => matchesPath(trigger, path)),\n\t\t\t\t\t),\n\t\t\t),\n\t\t];\n\t\tif (\n\t\t\ttriggers.length === 0 ||\n\t\t\tentries.some(\n\t\t\t\t(entry) =>\n\t\t\t\t\tentry.status !== \"unchanged\" &&\n\t\t\t\t\tentry.status !== \"deleted\" &&\n\t\t\t\t\tmatchesPath(companion, entry.path),\n\t\t\t)\n\t\t) {\n\t\t\treturn [];\n\t\t}\n\t\treturn [\n\t\t\t{\n\t\t\t\tmessage: `Changes matching ${trigger} require a companion change matching ${companion}.`,\n\t\t\t\tfiles: triggers,\n\t\t\t\tmanualFix:\n\t\t\t\t\t\"Add, update, or rename a file into the companion pattern in the same change set. Deletions do not satisfy this rule.\",\n\t\t\t},\n\t\t];\n\t},\n} satisfies RepositoryPolicyDefinition<{\n\ttrigger: string | RegExp;\n\tcompanion: string | RegExp;\n}>;\n"]}
|
package/esm/policies.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export { GleamVersionConstraint, type GleamVersionConstraintConfig, } from "./po
|
|
|
29
29
|
export { HtmlFileHeaders } from "./policies/HtmlFileHeaders.js";
|
|
30
30
|
export { JsTsFileHeaders } from "./policies/JsTsFileHeaders.js";
|
|
31
31
|
export { LicenseFileExists, type LicenseFileExistsSettings, } from "./policies/LicenseFileExists.js";
|
|
32
|
+
export { MaxChangedFiles, type MaxChangedFilesConfig, } from "./policies/MaxChangedFiles.js";
|
|
32
33
|
export { MutuallyExclusiveScripts, type MutuallyExclusiveScriptsConfig, } from "./policies/MutuallyExclusiveScripts.js";
|
|
33
34
|
export { NoBuildDirectory } from "./policies/NoBuildDirectory.js";
|
|
34
35
|
export { NoJsFileExtensions } from "./policies/NoJsFileExtensions.js";
|
|
@@ -49,6 +50,7 @@ export { PackageReadme, type PackageReadmeSettings, } from "./policies/PackageRe
|
|
|
49
50
|
export { type ConditionalScriptRule as LegacyConditionalScriptRule, PackageScripts, type PackageScriptsSettings, type RequiredScriptEntry as LegacyRequiredScriptEntry, type ScriptMustContainRule, } from "./policies/PackageScripts.js";
|
|
50
51
|
export { PackageTestScripts, type PackageTestScriptsConfig, } from "./policies/PackageTestScripts.js";
|
|
51
52
|
export { PublicApiDocumented, type PublicApiDocumentedConfig, } from "./policies/PublicApiDocumented.js";
|
|
53
|
+
export { RequireCompanionChanges } from "./policies/RequireCompanionChanges.js";
|
|
52
54
|
export { RequiredGitignorePatterns, type RequiredGitignorePatternsSettings, } from "./policies/RequiredGitignorePatterns.js";
|
|
53
55
|
export { type RequiredScriptEntry, RequiredScripts, type RequiredScriptsConfig, } from "./policies/RequiredScripts.js";
|
|
54
56
|
export { RustDocExists, type RustDocExistsConfig, } from "./policies/RustDocExists.js";
|
package/esm/policies.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policies.d.ts","sourceRoot":"","sources":["../src/policies.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EACN,qBAAqB,EACrB,KAAK,2BAA2B,GAChC,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACN,oBAAoB,EACpB,KAAK,0BAA0B,GAC/B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACN,eAAe,EACf,KAAK,qBAAqB,GAC1B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACN,iBAAiB,EACjB,KAAK,uBAAuB,GAC5B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACN,eAAe,EACf,KAAK,qBAAqB,GAC1B,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EACN,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,kBAAkB,EAClB,KAAK,wBAAwB,GAC7B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACN,YAAY,EACZ,KAAK,kBAAkB,GACvB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACN,gBAAgB,EAChB,KAAK,sBAAsB,GAC3B,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACN,cAAc,EACd,KAAK,oBAAoB,GACzB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EACN,8BAA8B,EAC9B,KAAK,oCAAoC,GACzC,MAAM,8CAA8C,CAAC;AAEtD,OAAO,EACN,sBAAsB,EACtB,KAAK,4BAA4B,GACjC,MAA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AkB,GACvB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EACN,wBAAwB,EACxB,KAAK,8BAA8B,GACnC,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACN,oBAAoB,EACpB,KAAK,0BAA0B,GAC/B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACN,qBAAqB,EACrB,KAAK,2BAA2B,GAChC,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,YAAY,EACX,yBAAyB,EACzB,sBAAsB,GACtB,MAAM,4CAA4C,CAAC"}
|
package/esm/policies.js
CHANGED
|
@@ -45,6 +45,7 @@ export { HtmlFileHeaders } from "./policies/HtmlFileHeaders.js";
|
|
|
45
45
|
export { JsTsFileHeaders } from "./policies/JsTsFileHeaders.js";
|
|
46
46
|
// License policies
|
|
47
47
|
export { LicenseFileExists, } from "./policies/LicenseFileExists.js";
|
|
48
|
+
export { MaxChangedFiles, } from "./policies/MaxChangedFiles.js";
|
|
48
49
|
export { MutuallyExclusiveScripts, } from "./policies/MutuallyExclusiveScripts.js";
|
|
49
50
|
// Build directory policies
|
|
50
51
|
export { NoBuildDirectory } from "./policies/NoBuildDirectory.js";
|
|
@@ -78,6 +79,7 @@ export { PackageScripts, } from "./policies/PackageScripts.js";
|
|
|
78
79
|
export { PackageTestScripts, } from "./policies/PackageTestScripts.js";
|
|
79
80
|
// Rust documentation policies
|
|
80
81
|
export { PublicApiDocumented, } from "./policies/PublicApiDocumented.js";
|
|
82
|
+
export { RequireCompanionChanges } from "./policies/RequireCompanionChanges.js";
|
|
81
83
|
// Gitignore policies
|
|
82
84
|
export { RequiredGitignorePatterns, } from "./policies/RequiredGitignorePatterns.js";
|
|
83
85
|
export { RequiredScripts, } from "./policies/RequiredScripts.js";
|
package/esm/policies.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policies.js","sourceRoot":"","sources":["../src/policies.ts"],"names":[],"mappings":"AAA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,mBAAmB,GAEnB,MAAM,mCAAmC,CAAC;AAC3C,0BAA0B;AAC1B,OAAO,EACN,aAAa,GAEb,MAAM,6BAA6B,CAAC;AACrC,mEAAmE;AACnE,OAAO,EAEN,cAAc,GAId,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACN,kBAAkB,GAElB,MAAM,kCAAkC,CAAC;AAC1C,8BAA8B;AAC9B,OAAO,EACN,mBAAmB,GAEnB,MAAM,mCAAmC,CAAC;AAC3C,qBAAqB;AACrB,OAAO,EACN,yBAAyB,GAEzB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAEN,eAAe,GAEf,MAAM,+BAA+B,CAAC;AACvC,mCAAmC;AACnC,OAAO,EACN,aAAa,GAEb,MAAM,6BAA6B,CAAC;AACrC,kCAAkC;AAClC,OAAO,EACN,mBAAmB,GAEnB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACN,mBAAmB,GAEnB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACN,cAAc,GAGd,MAAM,8BAA8B,CAAC;AACtC,2BAA2B;AAC3B,OAAO,EACN,wBAAwB,GAExB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACN,oBAAoB,GAEpB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACN,qBAAqB,GAErB,MAAM,qCAAqC,CAAC;AAC7C,mBAAmB;AACnB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC","sourcesContent":["/**\n * Built-in file and repository policies and their configuration types.\n *\n * Use `makePolicy()` from `repopo` or `repopo/api` to configure these definitions.\n *\n * @packageDocumentation\n */\n\n// Cargo.toml / Rust policies\n// biome-ignore lint/performance/noBarrelFile: intentional public API entry point for policies\nexport {\n\tCargoLicenceValidated,\n\ttype CargoLicenceValidatedConfig,\n} from \"./policies/CargoLicenceValidated.js\";\nexport {\n\tCargoLintsConfigured,\n\ttype CargoLintsConfiguredConfig,\n} from \"./policies/CargoLintsConfigured.js\";\nexport {\n\tCargoLockPolicy,\n\ttype CargoLockPolicyConfig,\n} from \"./policies/CargoLockPolicy.js\";\nexport {\n\tCargoTomlRequired,\n\ttype CargoTomlRequiredConfig,\n} from \"./policies/CargoTomlRequired.js\";\nexport {\n\tCargoTomlSorted,\n\ttype CargoTomlSortedConfig,\n} from \"./policies/CargoTomlSorted.js\";\n// New focused script policies (replacements for PackageScripts)\nexport {\n\ttype ConditionalScriptEntry,\n\ttype ConditionalScriptRule,\n\tConditionalScripts,\n\ttype ConditionalScriptsConfig,\n} from \"./policies/ConditionalScripts.js\";\nexport {\n\tExactScripts,\n\ttype ExactScriptsConfig,\n} from \"./policies/ExactScripts.js\";\n// Gleam dependency policies\nexport {\n\tGleamDepVersions,\n\ttype GleamDepVersionsConfig,\n} from \"./policies/GleamDepVersions.js\";\n// Gleam documentation policies\nexport {\n\tGleamDocExists,\n\ttype GleamDocExistsConfig,\n} from \"./policies/GleamDocExists.js\";\n// Gleam internal modules policies\nexport {\n\tGleamInternalModulesConfigured,\n\ttype GleamInternalModulesConfiguredConfig,\n} from \"./policies/GleamInternalModulesConfigured.js\";\n// Gleam licence policies\nexport {\n\tGleamLicenceConfigured,\n\ttype GleamLicenceConfiguredConfig,\n} from \"./policies/GleamLicenceConfigured.js\";\n// Gleam project structure policies\nexport { GleamManifestCommitted } from \"./policies/GleamManifestCommitted.js\";\n// Gleam monorepo policies\nexport {\n\tGleamMonorepoConsistency,\n\ttype GleamMonorepoConsistencyConfig,\n} from \"./policies/GleamMonorepoConsistency.js\";\n// Gleam naming policies\nexport {\n\tGleamNameRestrictions,\n\ttype GleamNameRestrictionsConfig,\n} from \"./policies/GleamNameRestrictions.js\";\n// Gleam path dependency policies\nexport {\n\tGleamNoPathDepsInPublished,\n\ttype GleamNoPathDepsInPublishedConfig,\n} from \"./policies/GleamNoPathDepsInPublished.js\";\nexport { GleamPathDepsValid } from \"./policies/GleamPathDepsValid.js\";\nexport {\n\tGleamProjectStructure,\n\ttype GleamProjectStructureConfig,\n} from \"./policies/GleamProjectStructure.js\";\n// Gleam shared dependency version policies\nexport {\n\tGleamSharedDependencyVersions,\n\ttype GleamSharedDependencyVersionsConfig,\n} from \"./policies/GleamSharedDependencyVersions.js\";\n// Gleam toml field policies\nexport {\n\tGleamTomlRequired,\n\ttype GleamTomlRequiredConfig,\n} from \"./policies/GleamTomlRequired.js\";\nexport {\n\tGleamTomlSorted,\n\ttype GleamTomlSortedConfig,\n} from \"./policies/GleamTomlSorted.js\";\n// Gleam version constraint policies\nexport {\n\tGleamVersionConstraint,\n\ttype GleamVersionConstraintConfig,\n} from \"./policies/GleamVersionConstraint.js\";\n// File header policies\nexport { HtmlFileHeaders } from \"./policies/HtmlFileHeaders.js\";\nexport { JsTsFileHeaders } from \"./policies/JsTsFileHeaders.js\";\n// License policies\nexport {\n\tLicenseFileExists,\n\ttype LicenseFileExistsSettings,\n} from \"./policies/LicenseFileExists.js\";\nexport {\n\tMutuallyExclusiveScripts,\n\ttype MutuallyExclusiveScriptsConfig,\n} from \"./policies/MutuallyExclusiveScripts.js\";\n// Build directory policies\nexport { NoBuildDirectory } from \"./policies/NoBuildDirectory.js\";\n// File extension policies\nexport { NoJsFileExtensions } from \"./policies/NoJsFileExtensions.js\";\n// File size policies\nexport {\n\tNoLargeBinaryFiles,\n\ttype NoLargeBinaryFilesSettings,\n} from \"./policies/NoLargeBinaryFiles.js\";\n// Dependency policies\nexport {\n\tNoPrivateWorkspaceDependencies,\n\ttype NoPrivateWorkspaceDependenciesSettings,\n} from \"./policies/NoPrivateWorkspaceDependencies.js\";\n// Rust build artifact policies\nexport { NoTargetArtifacts } from \"./policies/NoTargetArtifacts.js\";\n// Rust unsafe code policies\nexport {\n\tNoUnsafeWithoutJustification,\n\ttype NoUnsafeWithoutJustificationConfig,\n} from \"./policies/NoUnsafeWithoutJustification.js\";\n// Rust dependency policies\nexport {\n\tNoWildcardDependencies,\n\ttype NoWildcardDependenciesConfig,\n} from \"./policies/NoWildcardDependencies.js\";\n// Package naming policies\nexport {\n\tPackageAllowedScopes,\n\ttype PackageAllowedScopesConfig,\n} from \"./policies/PackageAllowedScopes.js\";\n// Package type policies\nexport {\n\tPackageEsmType,\n\ttype PackageEsmTypeConfig,\n} from \"./policies/PackageEsmType.js\";\nexport {\n\tPackageFolderName,\n\ttype PackageFolderNameConfig,\n} from \"./policies/PackageFolderName.js\";\n// Package.json field policies\nexport {\n\tPackageJsonProperties,\n\ttype PackageJsonPropertiesSettings,\n} from \"./policies/PackageJsonProperties.js\";\nexport { PackageJsonRepoDirectoryProperty } from \"./policies/PackageJsonRepoDirectoryProperty.js\";\nexport { PackageJsonSorted } from \"./policies/PackageJsonSorted.js\";\nexport {\n\tPackageLicense,\n\ttype PackageLicenseSettings,\n} from \"./policies/PackageLicense.js\";\nexport {\n\tPackagePrivateField,\n\ttype PackagePrivateFieldConfig,\n} from \"./policies/PackagePrivateField.js\";\n// Package readme policies\nexport {\n\tPackageReadme,\n\ttype PackageReadmeSettings,\n} from \"./policies/PackageReadme.js\";\n// Package script policies (legacy - prefer focused policies above)\nexport {\n\ttype ConditionalScriptRule as LegacyConditionalScriptRule,\n\tPackageScripts,\n\ttype PackageScriptsSettings,\n\ttype RequiredScriptEntry as LegacyRequiredScriptEntry,\n\ttype ScriptMustContainRule,\n} from \"./policies/PackageScripts.js\";\nexport {\n\tPackageTestScripts,\n\ttype PackageTestScriptsConfig,\n} from \"./policies/PackageTestScripts.js\";\n// Rust documentation policies\nexport {\n\tPublicApiDocumented,\n\ttype PublicApiDocumentedConfig,\n} from \"./policies/PublicApiDocumented.js\";\n// Gitignore policies\nexport {\n\tRequiredGitignorePatterns,\n\ttype RequiredGitignorePatternsSettings,\n} from \"./policies/RequiredGitignorePatterns.js\";\nexport {\n\ttype RequiredScriptEntry,\n\tRequiredScripts,\n\ttype RequiredScriptsConfig,\n} from \"./policies/RequiredScripts.js\";\n// Rust documentation file policies\nexport {\n\tRustDocExists,\n\ttype RustDocExistsConfig,\n} from \"./policies/RustDocExists.js\";\n// Rust project structure policies\nexport {\n\tRustfmtConfigExists,\n\ttype RustfmtConfigExistsConfig,\n} from \"./policies/RustfmtConfigExists.js\";\nexport {\n\tRustToolchainExists,\n\ttype RustToolchainExistsConfig,\n} from \"./policies/RustToolchainExists.js\";\nexport {\n\tScriptContains,\n\ttype ScriptContainsConfig,\n\ttype ScriptContainsRule,\n} from \"./policies/ScriptContains.js\";\n// Cargo workspace policies\nexport {\n\tSharedDependencyVersions,\n\ttype SharedDependencyVersionsConfig,\n} from \"./policies/SharedDependencyVersions.js\";\nexport {\n\tWorkspaceInheritance,\n\ttype WorkspaceInheritanceConfig,\n} from \"./policies/WorkspaceInheritance.js\";\nexport {\n\tWorkspaceMembersValid,\n\ttype WorkspaceMembersValidConfig,\n} from \"./policies/WorkspaceMembersValid.js\";\n// Default policies\nexport { DefaultPolicies } from \"./policy.js\";\nexport type {\n\tFileHeaderGeneratorConfig,\n\tFileHeaderPolicyConfig,\n} from \"./policyDefiners/defineFileHeaderPolicy.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"policies.js","sourceRoot":"","sources":["../src/policies.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,6BAA6B;AAC7B,8FAA8F;AAC9F,OAAO,EACN,qBAAqB,GAErB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACN,oBAAoB,GAEpB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACN,eAAe,GAEf,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACN,iBAAiB,GAEjB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACN,eAAe,GAEf,MAAM,+BAA+B,CAAC;AACvC,gEAAgE;AAChE,OAAO,EAGN,kBAAkB,GAElB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACN,YAAY,GAEZ,MAAM,4BAA4B,CAAC;AACpC,4BAA4B;AAC5B,OAAO,EACN,gBAAgB,GAEhB,MAAM,gCAAgC,CAAC;AACxC,+BAA+B;AAC/B,OAAO,EACN,cAAc,GAEd,MAAM,8BAA8B,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b,MAAM,6BAA6B,CAAC;AACrC,kCAAkC;AAClC,OAAO,EACN,mBAAmB,GAEnB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACN,mBAAmB,GAEnB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACN,cAAc,GAGd,MAAM,8BAA8B,CAAC;AACtC,2BAA2B;AAC3B,OAAO,EACN,wBAAwB,GAExB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACN,oBAAoB,GAEpB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACN,qBAAqB,GAErB,MAAM,qCAAqC,CAAC;AAC7C,mBAAmB;AACnB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC","sourcesContent":["/**\n * Built-in file and repository policies and their configuration types.\n *\n * Use `makePolicy()` from `repopo` or `repopo/api` to configure these definitions.\n *\n * @packageDocumentation\n */\n\n// Cargo.toml / Rust policies\n// biome-ignore lint/performance/noBarrelFile: intentional public API entry point for policies\nexport {\n\tCargoLicenceValidated,\n\ttype CargoLicenceValidatedConfig,\n} from \"./policies/CargoLicenceValidated.js\";\nexport {\n\tCargoLintsConfigured,\n\ttype CargoLintsConfiguredConfig,\n} from \"./policies/CargoLintsConfigured.js\";\nexport {\n\tCargoLockPolicy,\n\ttype CargoLockPolicyConfig,\n} from \"./policies/CargoLockPolicy.js\";\nexport {\n\tCargoTomlRequired,\n\ttype CargoTomlRequiredConfig,\n} from \"./policies/CargoTomlRequired.js\";\nexport {\n\tCargoTomlSorted,\n\ttype CargoTomlSortedConfig,\n} from \"./policies/CargoTomlSorted.js\";\n// New focused script policies (replacements for PackageScripts)\nexport {\n\ttype ConditionalScriptEntry,\n\ttype ConditionalScriptRule,\n\tConditionalScripts,\n\ttype ConditionalScriptsConfig,\n} from \"./policies/ConditionalScripts.js\";\nexport {\n\tExactScripts,\n\ttype ExactScriptsConfig,\n} from \"./policies/ExactScripts.js\";\n// Gleam dependency policies\nexport {\n\tGleamDepVersions,\n\ttype GleamDepVersionsConfig,\n} from \"./policies/GleamDepVersions.js\";\n// Gleam documentation policies\nexport {\n\tGleamDocExists,\n\ttype GleamDocExistsConfig,\n} from \"./policies/GleamDocExists.js\";\n// Gleam internal modules policies\nexport {\n\tGleamInternalModulesConfigured,\n\ttype GleamInternalModulesConfiguredConfig,\n} from \"./policies/GleamInternalModulesConfigured.js\";\n// Gleam licence policies\nexport {\n\tGleamLicenceConfigured,\n\ttype GleamLicenceConfiguredConfig,\n} from \"./policies/GleamLicenceConfigured.js\";\n// Gleam project structure policies\nexport { GleamManifestCommitted } from \"./policies/GleamManifestCommitted.js\";\n// Gleam monorepo policies\nexport {\n\tGleamMonorepoConsistency,\n\ttype GleamMonorepoConsistencyConfig,\n} from \"./policies/GleamMonorepoConsistency.js\";\n// Gleam naming policies\nexport {\n\tGleamNameRestrictions,\n\ttype GleamNameRestrictionsConfig,\n} from \"./policies/GleamNameRestrictions.js\";\n// Gleam path dependency policies\nexport {\n\tGleamNoPathDepsInPublished,\n\ttype GleamNoPathDepsInPublishedConfig,\n} from \"./policies/GleamNoPathDepsInPublished.js\";\nexport { GleamPathDepsValid } from \"./policies/GleamPathDepsValid.js\";\nexport {\n\tGleamProjectStructure,\n\ttype GleamProjectStructureConfig,\n} from \"./policies/GleamProjectStructure.js\";\n// Gleam shared dependency version policies\nexport {\n\tGleamSharedDependencyVersions,\n\ttype GleamSharedDependencyVersionsConfig,\n} from \"./policies/GleamSharedDependencyVersions.js\";\n// Gleam toml field policies\nexport {\n\tGleamTomlRequired,\n\ttype GleamTomlRequiredConfig,\n} from \"./policies/GleamTomlRequired.js\";\nexport {\n\tGleamTomlSorted,\n\ttype GleamTomlSortedConfig,\n} from \"./policies/GleamTomlSorted.js\";\n// Gleam version constraint policies\nexport {\n\tGleamVersionConstraint,\n\ttype GleamVersionConstraintConfig,\n} from \"./policies/GleamVersionConstraint.js\";\n// File header policies\nexport { HtmlFileHeaders } from \"./policies/HtmlFileHeaders.js\";\nexport { JsTsFileHeaders } from \"./policies/JsTsFileHeaders.js\";\n// License policies\nexport {\n\tLicenseFileExists,\n\ttype LicenseFileExistsSettings,\n} from \"./policies/LicenseFileExists.js\";\nexport {\n\tMaxChangedFiles,\n\ttype MaxChangedFilesConfig,\n} from \"./policies/MaxChangedFiles.js\";\nexport {\n\tMutuallyExclusiveScripts,\n\ttype MutuallyExclusiveScriptsConfig,\n} from \"./policies/MutuallyExclusiveScripts.js\";\n// Build directory policies\nexport { NoBuildDirectory } from \"./policies/NoBuildDirectory.js\";\n// File extension policies\nexport { NoJsFileExtensions } from \"./policies/NoJsFileExtensions.js\";\n// File size policies\nexport {\n\tNoLargeBinaryFiles,\n\ttype NoLargeBinaryFilesSettings,\n} from \"./policies/NoLargeBinaryFiles.js\";\n// Dependency policies\nexport {\n\tNoPrivateWorkspaceDependencies,\n\ttype NoPrivateWorkspaceDependenciesSettings,\n} from \"./policies/NoPrivateWorkspaceDependencies.js\";\n// Rust build artifact policies\nexport { NoTargetArtifacts } from \"./policies/NoTargetArtifacts.js\";\n// Rust unsafe code policies\nexport {\n\tNoUnsafeWithoutJustification,\n\ttype NoUnsafeWithoutJustificationConfig,\n} from \"./policies/NoUnsafeWithoutJustification.js\";\n// Rust dependency policies\nexport {\n\tNoWildcardDependencies,\n\ttype NoWildcardDependenciesConfig,\n} from \"./policies/NoWildcardDependencies.js\";\n// Package naming policies\nexport {\n\tPackageAllowedScopes,\n\ttype PackageAllowedScopesConfig,\n} from \"./policies/PackageAllowedScopes.js\";\n// Package type policies\nexport {\n\tPackageEsmType,\n\ttype PackageEsmTypeConfig,\n} from \"./policies/PackageEsmType.js\";\nexport {\n\tPackageFolderName,\n\ttype PackageFolderNameConfig,\n} from \"./policies/PackageFolderName.js\";\n// Package.json field policies\nexport {\n\tPackageJsonProperties,\n\ttype PackageJsonPropertiesSettings,\n} from \"./policies/PackageJsonProperties.js\";\nexport { PackageJsonRepoDirectoryProperty } from \"./policies/PackageJsonRepoDirectoryProperty.js\";\nexport { PackageJsonSorted } from \"./policies/PackageJsonSorted.js\";\nexport {\n\tPackageLicense,\n\ttype PackageLicenseSettings,\n} from \"./policies/PackageLicense.js\";\nexport {\n\tPackagePrivateField,\n\ttype PackagePrivateFieldConfig,\n} from \"./policies/PackagePrivateField.js\";\n// Package readme policies\nexport {\n\tPackageReadme,\n\ttype PackageReadmeSettings,\n} from \"./policies/PackageReadme.js\";\n// Package script policies (legacy - prefer focused policies above)\nexport {\n\ttype ConditionalScriptRule as LegacyConditionalScriptRule,\n\tPackageScripts,\n\ttype PackageScriptsSettings,\n\ttype RequiredScriptEntry as LegacyRequiredScriptEntry,\n\ttype ScriptMustContainRule,\n} from \"./policies/PackageScripts.js\";\nexport {\n\tPackageTestScripts,\n\ttype PackageTestScriptsConfig,\n} from \"./policies/PackageTestScripts.js\";\n// Rust documentation policies\nexport {\n\tPublicApiDocumented,\n\ttype PublicApiDocumentedConfig,\n} from \"./policies/PublicApiDocumented.js\";\nexport { RequireCompanionChanges } from \"./policies/RequireCompanionChanges.js\";\n// Gitignore policies\nexport {\n\tRequiredGitignorePatterns,\n\ttype RequiredGitignorePatternsSettings,\n} from \"./policies/RequiredGitignorePatterns.js\";\nexport {\n\ttype RequiredScriptEntry,\n\tRequiredScripts,\n\ttype RequiredScriptsConfig,\n} from \"./policies/RequiredScripts.js\";\n// Rust documentation file policies\nexport {\n\tRustDocExists,\n\ttype RustDocExistsConfig,\n} from \"./policies/RustDocExists.js\";\n// Rust project structure policies\nexport {\n\tRustfmtConfigExists,\n\ttype RustfmtConfigExistsConfig,\n} from \"./policies/RustfmtConfigExists.js\";\nexport {\n\tRustToolchainExists,\n\ttype RustToolchainExistsConfig,\n} from \"./policies/RustToolchainExists.js\";\nexport {\n\tScriptContains,\n\ttype ScriptContainsConfig,\n\ttype ScriptContainsRule,\n} from \"./policies/ScriptContains.js\";\n// Cargo workspace policies\nexport {\n\tSharedDependencyVersions,\n\ttype SharedDependencyVersionsConfig,\n} from \"./policies/SharedDependencyVersions.js\";\nexport {\n\tWorkspaceInheritance,\n\ttype WorkspaceInheritanceConfig,\n} from \"./policies/WorkspaceInheritance.js\";\nexport {\n\tWorkspaceMembersValid,\n\ttype WorkspaceMembersValidConfig,\n} from \"./policies/WorkspaceMembersValid.js\";\n// Default policies\nexport { DefaultPolicies } from \"./policy.js\";\nexport type {\n\tFileHeaderGeneratorConfig,\n\tFileHeaderPolicyConfig,\n} from \"./policyDefiners/defineFileHeaderPolicy.js\";\n"]}
|
package/esm/policy.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Operation } from "effection";
|
|
2
|
+
import type { RepositoryFile } from "./repositoryChanges.js";
|
|
2
3
|
/** Display name of a policy. @public */
|
|
3
4
|
export type PolicyName = string;
|
|
4
5
|
/** Stable configured-instance identity. @public */
|
|
@@ -10,9 +11,11 @@ export interface PolicyArgs<C = void> {
|
|
|
10
11
|
resolve: boolean;
|
|
11
12
|
config?: C | undefined;
|
|
12
13
|
}
|
|
13
|
-
/** Arguments supplied to a repository handler; selection never limits
|
|
14
|
+
/** Arguments supplied to a repository/change handler; stdin selection never limits entries. @public */
|
|
14
15
|
export interface RepositoryPolicyArgs<C = void> extends Omit<PolicyArgs<C>, "file"> {
|
|
15
16
|
files: readonly string[];
|
|
17
|
+
/** Matching eligible inventory, including unchanged files and deleted paths. */
|
|
18
|
+
entries: readonly RepositoryFile[];
|
|
16
19
|
}
|
|
17
20
|
/** A single independently actionable violation or recorded fix. @public */
|
|
18
21
|
export interface PolicyFinding {
|
|
@@ -41,11 +44,14 @@ export interface FilePolicyDefinition<C = void> {
|
|
|
41
44
|
defaultConfig?: C | undefined;
|
|
42
45
|
requiresConfig?: boolean | undefined;
|
|
43
46
|
}
|
|
44
|
-
/** Repository
|
|
47
|
+
/** Repository/change scopes run once over matching inventory; fixers are inline only. @public */
|
|
45
48
|
export interface RepositoryPolicyDefinition<C = void> {
|
|
46
49
|
name: PolicyName;
|
|
47
50
|
description: string;
|
|
48
|
-
scope
|
|
51
|
+
/** Changes scope requests Git status annotation (PR mode by default). */
|
|
52
|
+
scope: "repository" | "changes";
|
|
53
|
+
/** Match repo-relative paths, including either rename endpoint; omitted means all entries. */
|
|
54
|
+
match?: RegExp | undefined;
|
|
49
55
|
handler(args: RepositoryPolicyArgs<C>): Promise<PolicyResult> | Operation<PolicyResult>;
|
|
50
56
|
resolver?: never;
|
|
51
57
|
defaultConfig?: C | undefined;
|
package/esm/policy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../src/policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../src/policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAI3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,wCAAwC;AACxC,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAChC,mDAAmD;AACnD,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAEtC,oDAAoD;AACpD,MAAM,WAAW,UAAU,CAAC,CAAC,GAAG,IAAI;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC;CACvB;AAED,uGAAuG;AACvG,MAAM,WAAW,oBAAoB,CAAC,CAAC,GAAG,IAAI,CAC7C,SAAQ,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC;IACnC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,gFAAgF;IAChF,OAAO,EAAE,SAAS,cAAc,EAAE,CAAC;CACnC;AAED,2EAA2E;AAC3E,MAAM,WAAW,aAAa;IAC7B,OAAO,EAAE,MAA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CAA8C;AAC9C,MAAM,MAAM,0BAA0B,CAAC,CAAC,GAAG,IAAI,IAC9C,0BAA0B,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;AAClD,mEAAmE;AACnE,MAAM,MAAM,gBAAgB,CAAC,CAAC,GAAG,OAAO,IACrC,oBAAoB,CAAC,CAAC,CAAC,GACvB,0BAA0B,CAAC,CAAC,CAAC,CAAC;AACjC,oEAAoE;AACpE,MAAM,MAAM,gBAAgB,CAAC,CAAC,GAAG,OAAO,IAAI,gBAAgB,CAAC,CAAC,CAAC,GAAG;IACjE,UAAU,EAAE,gBAAgB,CAAC;CAC7B,CAAC;AAEF,iFAAiF;AACjF,eAAO,MAAM,eAAe;;;;;0DAIlB,CAAC"}
|
package/esm/policy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../src/policy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,gCAAgC,EAAE,MAAM,gDAAgD,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../src/policy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,gCAAgC,EAAE,MAAM,gDAAgD,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AA2GpE,iFAAiF;AACjF,MAAM,CAAC,MAAM,eAAe,GAAG;IAC9B,kBAAkB;IAClB,gCAAgC;IAChC,iBAAiB;CACR,CAAC","sourcesContent":["import type { Operation } from \"effection\";\nimport { NoJsFileExtensions } from \"./policies/NoJsFileExtensions.js\";\nimport { PackageJsonRepoDirectoryProperty } from \"./policies/PackageJsonRepoDirectoryProperty.js\";\nimport { PackageJsonSorted } from \"./policies/PackageJsonSorted.js\";\nimport type { RepositoryFile } from \"./repositoryChanges.js\";\n\n/** Display name of a policy. @public */\nexport type PolicyName = string;\n/** Stable configured-instance identity. @public */\nexport type PolicyInstanceId = string;\n\n/** Arguments supplied to a file handler. @public */\nexport interface PolicyArgs<C = void> {\n\tfile: string;\n\troot: string;\n\tresolve: boolean;\n\tconfig?: C | undefined;\n}\n\n/** Arguments supplied to a repository/change handler; stdin selection never limits entries. @public */\nexport interface RepositoryPolicyArgs<C = void>\n\textends Omit<PolicyArgs<C>, \"file\"> {\n\tfiles: readonly string[];\n\t/** Matching eligible inventory, including unchanged files and deleted paths. */\n\tentries: readonly RepositoryFile[];\n}\n\n/** A single independently actionable violation or recorded fix. @public */\nexport interface PolicyFinding {\n\tmessage: string;\n\tmanualFix?: string | undefined;\n\tfixStatus?: \"available\" | \"fixed\" | \"failed\" | undefined;\n\t/** Repo-relative affected files. Only repository handlers may supply this. */\n\tfiles?: readonly string[] | undefined;\n}\n\n/** Empty means pass. Fixed findings remain visible. @public */\nexport type PolicyResult = readonly PolicyFinding[];\n\n/** Standalone file fixers receive and return the complete findings list. @public */\nexport type PolicyResolver<C = void> = {\n\tresolve(\n\t\targs: Omit<PolicyArgs<C>, \"resolve\"> & { findings: PolicyResult },\n\t): Promise<PolicyResult> | Operation<PolicyResult>;\n}[\"resolve\"];\n\n/** File scope is the default. @public */\nexport interface FilePolicyDefinition<C = void> {\n\tname: PolicyName;\n\tdescription: string;\n\tscope?: \"file\";\n\tmatch: RegExp;\n\thandler(args: PolicyArgs<C>): Promise<PolicyResult> | Operation<PolicyResult>;\n\tresolver?: PolicyResolver<C> | undefined;\n\tdefaultConfig?: C | undefined;\n\trequiresConfig?: boolean | undefined;\n}\n\n/** Repository/change scopes run once over matching inventory; fixers are inline only. @public */\nexport interface RepositoryPolicyDefinition<C = void> {\n\tname: PolicyName;\n\tdescription: string;\n\t/** Changes scope requests Git status annotation (PR mode by default). */\n\tscope: \"repository\" | \"changes\";\n\t/** Match repo-relative paths, including either rename endpoint; omitted means all entries. */\n\tmatch?: RegExp | undefined;\n\thandler(\n\t\targs: RepositoryPolicyArgs<C>,\n\t): Promise<PolicyResult> | Operation<PolicyResult>;\n\tresolver?: never;\n\tdefaultConfig?: C | undefined;\n\trequiresConfig?: boolean | undefined;\n}\n\n/** A canonical policy definition. @public */\nexport type PolicyDefinition<C = void> =\n\t| FilePolicyDefinition<C>\n\t| RepositoryPolicyDefinition<C>;\n\n/** Async and Effection file handlers are supported. @public */\nexport type PolicyHandler<C = void> = FilePolicyDefinition<C>[\"handler\"];\n/** Async and Effection repository handlers are supported. @public */\nexport type RepositoryPolicyHandler<C = void> =\n\tRepositoryPolicyDefinition<C>[\"handler\"];\n\n/** Exclude undefined (including void) while preserving allowed null values. @internal */\nexport type DefinedConfig<C> = NonNullable<C> | (C & null);\n\n/** Instance configuration and repo-relative regex exclusions. @public */\nexport interface PolicyOptions<C = void> {\n\tconfig?: C | undefined;\n\texclude?: readonly (string | RegExp)[] | undefined;\n\tinstanceId?: PolicyInstanceId | undefined;\n}\n\n/** A configured file policy. @public */\nexport type ConfiguredFilePolicy<C = void> = FilePolicyDefinition<C> &\n\tPolicyOptions<C>;\n/** A configured repository policy. @public */\nexport type ConfiguredRepositoryPolicy<C = void> =\n\tRepositoryPolicyDefinition<C> & PolicyOptions<C>;\n/** A configured policy, retaining scope discrimination. @public */\nexport type ConfiguredPolicy<C = unknown> =\n\t| ConfiguredFilePolicy<C>\n\t| ConfiguredRepositoryPolicy<C>;\n/** A configured policy with a validated stable identity. @public */\nexport type IdentifiedPolicy<C = unknown> = ConfiguredPolicy<C> & {\n\tinstanceId: PolicyInstanceId;\n};\n\n/** The default definitions, configured when no policies are supplied. @public */\nexport const DefaultPolicies = [\n\tNoJsFileExtensions,\n\tPackageJsonRepoDirectoryProperty,\n\tPackageJsonSorted,\n] as const;\n"]}
|
package/esm/policyExecution.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Operation } from "effection";
|
|
2
2
|
import { type ParsedFileCache } from "./fileCache.js";
|
|
3
3
|
import type { IdentifiedPolicy } from "./policy.js";
|
|
4
|
+
import { type RepositoryFile } from "./repositoryChanges.js";
|
|
4
5
|
import type { PolicyRunResults } from "./runner.js";
|
|
5
6
|
/** Describe thrown values without allowing hostile coercion to discard a run. */
|
|
6
7
|
export declare function executionMessage(cause: unknown): string;
|
|
@@ -10,10 +11,10 @@ export declare class PolicyExecutor {
|
|
|
10
11
|
private readonly fix;
|
|
11
12
|
constructor(root: string, fix: boolean);
|
|
12
13
|
repository(policy: Extract<IdentifiedPolicy, {
|
|
13
|
-
scope: "repository";
|
|
14
|
-
}>,
|
|
14
|
+
scope: "repository" | "changes";
|
|
15
|
+
}>, entries: readonly RepositoryFile[], output: PolicyRunResults): Operation<boolean>;
|
|
15
16
|
file(file: string, policy: Exclude<IdentifiedPolicy, {
|
|
16
|
-
scope: "repository";
|
|
17
|
+
scope: "repository" | "changes";
|
|
17
18
|
}>, output: PolicyRunResults, cache: ParsedFileCache | undefined): Operation<boolean>;
|
|
18
19
|
}
|
|
19
20
|
//# sourceMappingURL=policyExecution.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policyExecution.d.ts","sourceRoot":"","sources":["../src/policyExecution.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"policyExecution.d.ts","sourceRoot":"","sources":["../src/policyExecution.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAG3C,OAAO,EAAa,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjE,OAAO,KAAK,EAAE,gBAAgB,EAAgB,MAAM,aAAa,CAAC;AAClE,OAAO,EAAkB,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAsHpD,iFAAiF;AACjF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAgBvD;AAuBD,6EAA6E;AAC7E,qBAAa,cAAc;IAEzB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,GAAG;gBADH,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,OAAO;IAGtB,UAAU,CACjB,MAAM,EAAE,OAAO,CAAC,gBAAgB,EAAE;QAAE,KAAK,EAAE,YAAY,GAAG,SAAS,CAAA;KAAE,CAAC,EACtE,OAAO,EAAE,SAAS,cAAc,EAAE,EAClC,MAAM,EAAE,gBAAgB,GACtB,SAAS,CAAC,OAAO,CAAC;IAoDb,IAAI,CACX,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,OAAO,CAAC,gBAAgB,EAAE;QAAE,KAAK,EAAE,YAAY,GAAG,SAAS,CAAA;KAAE,CAAC,EACtE,MAAM,EAAE,gBAAgB,EACxB,KAAK,EAAE,eAAe,GAAG,SAAS,GAChC,SAAS,CAAC,OAAO,CAAC;CA0ErB"}
|
package/esm/policyExecution.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { types } from "node:util";
|
|
2
|
+
import { matchesPath } from "./context.js";
|
|
2
3
|
import { ExecutionContractError } from "./executionContractError.js";
|
|
3
4
|
import { fileCache } from "./fileCache.js";
|
|
4
5
|
import { runWithPerf } from "./perf.js";
|
|
6
|
+
import { inventoryPaths } from "./repositoryChanges.js";
|
|
5
7
|
import { settlePolicyPromise } from "./settlePolicyPromise.js";
|
|
6
8
|
const windowsAbsolutePath = /^[A-Za-z]:/;
|
|
7
9
|
function* execute(handler) {
|
|
@@ -130,10 +132,18 @@ export class PolicyExecutor {
|
|
|
130
132
|
this.root = root;
|
|
131
133
|
this.fix = fix;
|
|
132
134
|
}
|
|
133
|
-
*repository(policy,
|
|
135
|
+
*repository(policy, entries, output) {
|
|
136
|
+
const { match } = policy;
|
|
137
|
+
const matching = match
|
|
138
|
+
? entries.filter((entry) => matchesPath(match, entry.path) ||
|
|
139
|
+
(entry.status === "renamed" &&
|
|
140
|
+
matchesPath(match, entry.previousPath)))
|
|
141
|
+
: entries;
|
|
142
|
+
const eligible = inventoryPaths(matching);
|
|
134
143
|
try {
|
|
135
144
|
const findings = yield* runWithPerf(policy.instanceId, "handle", output.perfStats, () => execute(() => policy.handler({
|
|
136
145
|
files: eligible,
|
|
146
|
+
entries: matching,
|
|
137
147
|
root: this.root,
|
|
138
148
|
resolve: this.fix,
|
|
139
149
|
config: policy.config,
|
|
@@ -142,7 +152,7 @@ export class PolicyExecutor {
|
|
|
142
152
|
for (const finding of findings) {
|
|
143
153
|
output.findings.push({
|
|
144
154
|
...finding,
|
|
145
|
-
scope:
|
|
155
|
+
scope: policy.scope,
|
|
146
156
|
policy: policy.name,
|
|
147
157
|
policyId: policy.instanceId,
|
|
148
158
|
});
|
|
@@ -150,7 +160,7 @@ export class PolicyExecutor {
|
|
|
150
160
|
}
|
|
151
161
|
catch (cause) {
|
|
152
162
|
output.errors.push({
|
|
153
|
-
scope:
|
|
163
|
+
scope: policy.scope,
|
|
154
164
|
files: eligible,
|
|
155
165
|
policy: policy.name,
|
|
156
166
|
policyId: policy.instanceId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policyExecution.js","sourceRoot":"","sources":["../src/policyExecution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,SAAS,EAAwB,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAGxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,MAAM,mBAAmB,GAAG,YAAY,CAAC;AAEzC,QAAQ,CAAC,CAAC,OAAO,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AI,CAAC,IAAI;oBACf,MAAM,EAAE,IAAI,CAAC,MAAM;oBACnB,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;iBACpD,CAAC,CACF,CACF,CAAC;gBACF,cAAc,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;gBACtC,OAAO,GAAG,aAAa,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;YAC5C,CAAC;QACF,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACzB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;gBAClB,KAAK,EAAE,MAAM;gBACb,IAAI;gBACJ,MAAM,EAAE,MAAM,CAAC,IAAI;gBACnB,QAAQ,EAAE,MAAM,CAAC,UAAU;gBAC3B,KAAK;gBACL,IAAI,EAAE,SAAS,CAAC,KAAK,CAAC;gBACtB,OAAO,EAAE,gBAAgB,CAAC,KAAK,CAAC;gBAChC,KAAK;aACL,CAAC,CAAC;YACH,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC;YACnB,IAAI,KAAK,KAAK,QAAQ,EAAE,CAAC;gBACxB,OAAO,GAAG,EAAE,CAAC;YACd,CAAC;QACF,CAAC;QACD,KAAK,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,IAAI,OAAO,EAAE,CAAC;YACrD,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;gBACpB,GAAG,OAAO;gBACV,KAAK,EAAE,MAAM;gBACb,IAAI;gBACJ,MAAM,EAAE,MAAM,CAAC,IAAI;gBACnB,QAAQ,EAAE,MAAM,CAAC,UAAU;aAC3B,CAAC,CAAC;QACJ,CAAC;QACD,OAAO,OAAO,CAAC;IAChB,CAAC;CACD","sourcesContent":["import { types } from \"node:util\";\nimport type { Operation } from \"effection\";\nimport { ExecutionContractError } from \"./executionContractError.js\";\nimport { fileCache, type ParsedFileCache } from \"./fileCache.js\";\nimport { runWithPerf } from \"./perf.js\";\nimport type { IdentifiedPolicy, PolicyResult } from \"./policy.js\";\nimport type { PolicyRunResults } from \"./runner.js\";\nimport { settlePolicyPromise } from \"./settlePolicyPromise.js\";\n\nconst windowsAbsolutePath = /^[A-Za-z]:/;\n\nfunction* execute<T>(handler: () => Promise<T> | Operation<T>): Operation<T> {\n\tconst execution = handler();\n\tif (execution instanceof Promise) {\n\t\treturn yield* settlePolicyPromise(execution);\n\t}\n\tif (\n\t\ttypeof execution === \"object\" &&\n\t\texecution !== null &&\n\t\tSymbol.iterator in execution &&\n\t\t!Array.isArray(execution)\n\t) {\n\t\treturn yield* execution;\n\t}\n\tthrow new ExecutionContractError(\n\t\t\"Handlers and resolvers must be async functions or Effection generators.\",\n\t);\n}\n\nfunction validPath(path: unknown): path is string {\n\treturn (\n\t\ttypeof path === \"string\" &&\n\t\tpath.length > 0 &&\n\t\t!path.includes(\"\\\\\") &&\n\t\t!path.includes(\"\\0\") &&\n\t\t!path.startsWith(\"/\") &&\n\t\t!windowsAbsolutePath.test(path) &&\n\t\tpath\n\t\t\t.split(\"/\")\n\t\t\t.every((part) => part !== \"\" && part !== \".\" && part !== \"..\")\n\t);\n}\n\nfunction validateResult(\n\tresult: unknown,\n\trepository: boolean,\n\tfix: boolean,\n): asserts result is PolicyResult {\n\tconst invalid = () =>\n\t\tnew ExecutionContractError(\n\t\t\t\"Policy handlers and resolvers must return readonly PolicyFinding[] with message, optional manualFix, fixStatus and repository-only files; legacy results are not supported.\",\n\t\t);\n\tif (!Array.isArray(result)) {\n\t\tthrow invalid();\n\t}\n\tfor (const finding of result) {\n\t\tif (\n\t\t\ttypeof finding !== \"object\" ||\n\t\t\tfinding === null ||\n\t\t\tArray.isArray(finding) ||\n\t\t\tReflect.ownKeys(finding).some(\n\t\t\t\t(key) =>\n\t\t\t\t\ttypeof key !== \"string\" ||\n\t\t\t\t\t![\"message\", \"manualFix\", \"fixStatus\", \"files\"].includes(key),\n\t\t\t) ||\n\t\t\t!(\"message\" in finding) ||\n\t\t\ttypeof finding.message !== \"string\" ||\n\t\t\tfinding.message.length === 0 ||\n\t\t\t(\"manualFix\" in finding &&\n\t\t\t\tfinding.manualFix !== undefined &&\n\t\t\t\ttypeof finding.manualFix !== \"string\") ||\n\t\t\t(\"fixStatus\" in finding &&\n\t\t\t\tfinding.fixStatus !== undefined &&\n\t\t\t\t![\"available\", \"fixed\", \"failed\"].includes(finding.fixStatus)) ||\n\t\t\t(!fix &&\n\t\t\t\t(finding.fixStatus === \"fixed\" || finding.fixStatus === \"failed\")) ||\n\t\t\t(\"files\" in finding &&\n\t\t\t\t!(\n\t\t\t\t\trepository &&\n\t\t\t\t\t(finding.files === undefined ||\n\t\t\t\t\t\t(Array.isArray(finding.files) && finding.files.every(validPath)))\n\t\t\t\t))\n\t\t) {\n\t\t\tthrow invalid();\n\t\t}\n\t}\n}\n\nfunction mergeFindings(\n\tchecked: PolicyResult,\n\tresolved: PolicyResult,\n): PolicyResult {\n\t// Omission is not resolution; messages identify independent findings.\n\tconst merged = [...checked];\n\tconst used = new Set<number>();\n\tfor (const finding of resolved) {\n\t\tconst index = checked.findIndex(\n\t\t\t(previous, candidateIndex) =>\n\t\t\t\t!used.has(candidateIndex) && previous.message === finding.message,\n\t\t);\n\t\tif (index === -1) {\n\t\t\tmerged.push(finding);\n\t\t} else if (merged[index]?.fixStatus !== \"fixed\") {\n\t\t\tmerged[index] = { ...merged[index], ...finding };\n\t\t\tused.add(index);\n\t\t}\n\t}\n\treturn merged;\n}\n\nfunction nativeErrorMessage(cause: object): string | undefined {\n\tlet current: object | null = cause;\n\twhile (current && !types.isProxy(current)) {\n\t\tconst descriptor = Object.getOwnPropertyDescriptor(current, \"message\");\n\t\tif (descriptor) {\n\t\t\treturn \"value\" in descriptor && typeof descriptor.value === \"string\"\n\t\t\t\t? descriptor.value\n\t\t\t\t: undefined;\n\t\t}\n\t\tcurrent = Object.getPrototypeOf(current);\n\t}\n\treturn undefined;\n}\n\n/** Describe thrown values without allowing hostile coercion to discard a run. */\nexport function executionMessage(cause: unknown): string {\n\ttry {\n\t\tif (\n\t\t\tcause === null ||\n\t\t\t(typeof cause !== \"object\" && typeof cause !== \"function\")\n\t\t) {\n\t\t\treturn String(cause);\n\t\t}\n\t\tconst message =\n\t\t\t!types.isProxy(cause) && types.isNativeError(cause)\n\t\t\t\t? nativeErrorMessage(cause)\n\t\t\t\t: undefined;\n\t\treturn message ?? \"Policy threw a non-Error or uninspectable value.\";\n\t} catch {\n\t\treturn \"Policy threw a value that cannot be inspected.\";\n\t}\n}\n\nfunction errorKind(cause: unknown): \"contract\" | \"exception\" {\n\ttry {\n\t\tif (\n\t\t\tcause === null ||\n\t\t\t(typeof cause !== \"object\" && typeof cause !== \"function\")\n\t\t) {\n\t\t\treturn \"exception\";\n\t\t}\n\t\tlet current: object | null = cause;\n\t\twhile (current && !types.isProxy(current)) {\n\t\t\tif (current === ExecutionContractError.prototype) {\n\t\t\t\treturn \"contract\";\n\t\t\t}\n\t\t\tcurrent = Object.getPrototypeOf(current);\n\t\t}\n\t\treturn \"exception\";\n\t} catch {\n\t\treturn \"exception\";\n\t}\n}\n\n/** Internal single-policy execution; engines own matching and scheduling. */\nexport class PolicyExecutor {\n\tpublic constructor(\n\t\tprivate readonly root: string,\n\t\tprivate readonly fix: boolean,\n\t) {}\n\n\tpublic *repository(\n\t\tpolicy: Extract<IdentifiedPolicy, { scope: \"repository\" }>,\n\t\teligible: readonly string[],\n\t\toutput: PolicyRunResults,\n\t): Operation<boolean> {\n\t\ttry {\n\t\t\tconst findings = yield* runWithPerf(\n\t\t\t\tpolicy.instanceId,\n\t\t\t\t\"handle\",\n\t\t\t\toutput.perfStats,\n\t\t\t\t() =>\n\t\t\t\t\texecute(() =>\n\t\t\t\t\t\tpolicy.handler({\n\t\t\t\t\t\t\tfiles: eligible,\n\t\t\t\t\t\t\troot: this.root,\n\t\t\t\t\t\t\tresolve: this.fix,\n\t\t\t\t\t\t\tconfig: policy.config,\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t);\n\t\t\tvalidateResult(findings, true, this.fix);\n\t\t\tfor (const finding of findings) {\n\t\t\t\toutput.findings.push({\n\t\t\t\t\t...finding,\n\t\t\t\t\tscope: \"repository\",\n\t\t\t\t\tpolicy: policy.name,\n\t\t\t\t\tpolicyId: policy.instanceId,\n\t\t\t\t});\n\t\t\t}\n\t\t} catch (cause: unknown) {\n\t\t\toutput.errors.push({\n\t\t\t\tscope: \"repository\",\n\t\t\t\tfiles: eligible,\n\t\t\t\tpolicy: policy.name,\n\t\t\t\tpolicyId: policy.instanceId,\n\t\t\t\tphase: \"handle\",\n\t\t\t\tkind: errorKind(cause),\n\t\t\t\tmessage: executionMessage(cause),\n\t\t\t\tcause,\n\t\t\t});\n\t\t\treturn this.fix;\n\t\t}\n\t\treturn false;\n\t}\n\n\tpublic *file(\n\t\tfile: string,\n\t\tpolicy: Exclude<IdentifiedPolicy, { scope: \"repository\" }>,\n\t\toutput: PolicyRunResults,\n\t\tcache: ParsedFileCache | undefined,\n\t): Operation<boolean> {\n\t\tlet stopped = false;\n\t\tlet phase: \"handle\" | \"resolve\" = \"handle\";\n\t\tlet checked: PolicyResult = [];\n\t\ttry {\n\t\t\tconst args = {\n\t\t\t\tfile,\n\t\t\t\troot: this.root,\n\t\t\t\tresolve: this.fix,\n\t\t\t\tconfig: policy.config,\n\t\t\t\t[fileCache]: cache,\n\t\t\t};\n\t\t\tchecked = yield* runWithPerf(\n\t\t\t\tpolicy.instanceId,\n\t\t\t\t\"handle\",\n\t\t\t\toutput.perfStats,\n\t\t\t\t() => execute(() => policy.handler(args)),\n\t\t\t);\n\t\t\tvalidateResult(checked, false, this.fix);\n\t\t\tif (\n\t\t\t\tthis.fix &&\n\t\t\t\tchecked.length > 0 &&\n\t\t\t\tpolicy.resolver &&\n\t\t\t\t!checked.some(\n\t\t\t\t\t(finding) =>\n\t\t\t\t\t\tfinding.fixStatus === \"fixed\" || finding.fixStatus === \"failed\",\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tphase = \"resolve\";\n\t\t\t\tconst resolver = policy.resolver;\n\t\t\t\tconst resolved = yield* runWithPerf(\n\t\t\t\t\tpolicy.instanceId,\n\t\t\t\t\t\"resolve\",\n\t\t\t\t\toutput.perfStats,\n\t\t\t\t\t() =>\n\t\t\t\t\t\texecute(() =>\n\t\t\t\t\t\t\tresolver({\n\t\t\t\t\t\t\t\tfile,\n\t\t\t\t\t\t\t\troot: args.root,\n\t\t\t\t\t\t\t\tconfig: args.config,\n\t\t\t\t\t\t\t\tfindings: checked.map((finding) => ({ ...finding })),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tvalidateResult(resolved, false, true);\n\t\t\t\tchecked = mergeFindings(checked, resolved);\n\t\t\t}\n\t\t} catch (cause: unknown) {\n\t\t\toutput.errors.push({\n\t\t\t\tscope: \"file\",\n\t\t\t\tfile,\n\t\t\t\tpolicy: policy.name,\n\t\t\t\tpolicyId: policy.instanceId,\n\t\t\t\tphase,\n\t\t\t\tkind: errorKind(cause),\n\t\t\t\tmessage: executionMessage(cause),\n\t\t\t\tcause,\n\t\t\t});\n\t\t\tstopped = this.fix;\n\t\t\tif (phase === \"handle\") {\n\t\t\t\tchecked = [];\n\t\t\t}\n\t\t}\n\t\tfor (const { files: _files, ...finding } of checked) {\n\t\t\toutput.findings.push({\n\t\t\t\t...finding,\n\t\t\t\tscope: \"file\",\n\t\t\t\tfile,\n\t\t\t\tpolicy: policy.name,\n\t\t\t\tpolicyId: policy.instanceId,\n\t\t\t});\n\t\t}\n\t\treturn stopped;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"policyExecution.js","sourceRoot":"","sources":["../src/policyExecution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,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AE,MAAM,CAAC,IAAI;gBACnB,QAAQ,EAAE,MAAM,CAAC,UAAU;gBAC3B,KAAK;gBACL,IAAI,EAAE,SAAS,CAAC,KAAK,CAAC;gBACtB,OAAO,EAAE,gBAAgB,CAAC,KAAK,CAAC;gBAChC,KAAK;aACL,CAAC,CAAC;YACH,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC;YACnB,IAAI,KAAK,KAAK,QAAQ,EAAE,CAAC;gBACxB,OAAO,GAAG,EAAE,CAAC;YACd,CAAC;QACF,CAAC;QACD,KAAK,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,IAAI,OAAO,EAAE,CAAC;YACrD,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;gBACpB,GAAG,OAAO;gBACV,KAAK,EAAE,MAAM;gBACb,IAAI;gBACJ,MAAM,EAAE,MAAM,CAAC,IAAI;gBACnB,QAAQ,EAAE,MAAM,CAAC,UAAU;aAC3B,CAAC,CAAC;QACJ,CAAC;QACD,OAAO,OAAO,CAAC;IAChB,CAAC;CACD","sourcesContent":["import { types } from \"node:util\";\nimport type { Operation } from \"effection\";\nimport { matchesPath } from \"./context.js\";\nimport { ExecutionContractError } from \"./executionContractError.js\";\nimport { fileCache, type ParsedFileCache } from \"./fileCache.js\";\nimport { runWithPerf } from \"./perf.js\";\nimport type { IdentifiedPolicy, PolicyResult } from \"./policy.js\";\nimport { inventoryPaths, type RepositoryFile } from \"./repositoryChanges.js\";\nimport type { PolicyRunResults } from \"./runner.js\";\nimport { settlePolicyPromise } from \"./settlePolicyPromise.js\";\n\nconst windowsAbsolutePath = /^[A-Za-z]:/;\n\nfunction* execute<T>(handler: () => Promise<T> | Operation<T>): Operation<T> {\n\tconst execution = handler();\n\tif (execution instanceof Promise) {\n\t\treturn yield* settlePolicyPromise(execution);\n\t}\n\tif (\n\t\ttypeof execution === \"object\" &&\n\t\texecution !== null &&\n\t\tSymbol.iterator in execution &&\n\t\t!Array.isArray(execution)\n\t) {\n\t\treturn yield* execution;\n\t}\n\tthrow new ExecutionContractError(\n\t\t\"Handlers and resolvers must be async functions or Effection generators.\",\n\t);\n}\n\nfunction validPath(path: unknown): path is string {\n\treturn (\n\t\ttypeof path === \"string\" &&\n\t\tpath.length > 0 &&\n\t\t!path.includes(\"\\\\\") &&\n\t\t!path.includes(\"\\0\") &&\n\t\t!path.startsWith(\"/\") &&\n\t\t!windowsAbsolutePath.test(path) &&\n\t\tpath\n\t\t\t.split(\"/\")\n\t\t\t.every((part) => part !== \"\" && part !== \".\" && part !== \"..\")\n\t);\n}\n\nfunction validateResult(\n\tresult: unknown,\n\trepository: boolean,\n\tfix: boolean,\n): asserts result is PolicyResult {\n\tconst invalid = () =>\n\t\tnew ExecutionContractError(\n\t\t\t\"Policy handlers and resolvers must return readonly PolicyFinding[] with message, optional manualFix, fixStatus and repository-only files; legacy results are not supported.\",\n\t\t);\n\tif (!Array.isArray(result)) {\n\t\tthrow invalid();\n\t}\n\tfor (const finding of result) {\n\t\tif (\n\t\t\ttypeof finding !== \"object\" ||\n\t\t\tfinding === null ||\n\t\t\tArray.isArray(finding) ||\n\t\t\tReflect.ownKeys(finding).some(\n\t\t\t\t(key) =>\n\t\t\t\t\ttypeof key !== \"string\" ||\n\t\t\t\t\t![\"message\", \"manualFix\", \"fixStatus\", \"files\"].includes(key),\n\t\t\t) ||\n\t\t\t!(\"message\" in finding) ||\n\t\t\ttypeof finding.message !== \"string\" ||\n\t\t\tfinding.message.length === 0 ||\n\t\t\t(\"manualFix\" in finding &&\n\t\t\t\tfinding.manualFix !== undefined &&\n\t\t\t\ttypeof finding.manualFix !== \"string\") ||\n\t\t\t(\"fixStatus\" in finding &&\n\t\t\t\tfinding.fixStatus !== undefined &&\n\t\t\t\t![\"available\", \"fixed\", \"failed\"].includes(finding.fixStatus)) ||\n\t\t\t(!fix &&\n\t\t\t\t(finding.fixStatus === \"fixed\" || finding.fixStatus === \"failed\")) ||\n\t\t\t(\"files\" in finding &&\n\t\t\t\t!(\n\t\t\t\t\trepository &&\n\t\t\t\t\t(finding.files === undefined ||\n\t\t\t\t\t\t(Array.isArray(finding.files) && finding.files.every(validPath)))\n\t\t\t\t))\n\t\t) {\n\t\t\tthrow invalid();\n\t\t}\n\t}\n}\n\nfunction mergeFindings(\n\tchecked: PolicyResult,\n\tresolved: PolicyResult,\n): PolicyResult {\n\t// Omission is not resolution; messages identify independent findings.\n\tconst merged = [...checked];\n\tconst used = new Set<number>();\n\tfor (const finding of resolved) {\n\t\tconst index = checked.findIndex(\n\t\t\t(previous, candidateIndex) =>\n\t\t\t\t!used.has(candidateIndex) && previous.message === finding.message,\n\t\t);\n\t\tif (index === -1) {\n\t\t\tmerged.push(finding);\n\t\t} else if (merged[index]?.fixStatus !== \"fixed\") {\n\t\t\tmerged[index] = { ...merged[index], ...finding };\n\t\t\tused.add(index);\n\t\t}\n\t}\n\treturn merged;\n}\n\nfunction nativeErrorMessage(cause: object): string | undefined {\n\tlet current: object | null = cause;\n\twhile (current && !types.isProxy(current)) {\n\t\tconst descriptor = Object.getOwnPropertyDescriptor(current, \"message\");\n\t\tif (descriptor) {\n\t\t\treturn \"value\" in descriptor && typeof descriptor.value === \"string\"\n\t\t\t\t? descriptor.value\n\t\t\t\t: undefined;\n\t\t}\n\t\tcurrent = Object.getPrototypeOf(current);\n\t}\n\treturn undefined;\n}\n\n/** Describe thrown values without allowing hostile coercion to discard a run. */\nexport function executionMessage(cause: unknown): string {\n\ttry {\n\t\tif (\n\t\t\tcause === null ||\n\t\t\t(typeof cause !== \"object\" && typeof cause !== \"function\")\n\t\t) {\n\t\t\treturn String(cause);\n\t\t}\n\t\tconst message =\n\t\t\t!types.isProxy(cause) && types.isNativeError(cause)\n\t\t\t\t? nativeErrorMessage(cause)\n\t\t\t\t: undefined;\n\t\treturn message ?? \"Policy threw a non-Error or uninspectable value.\";\n\t} catch {\n\t\treturn \"Policy threw a value that cannot be inspected.\";\n\t}\n}\n\nfunction errorKind(cause: unknown): \"contract\" | \"exception\" {\n\ttry {\n\t\tif (\n\t\t\tcause === null ||\n\t\t\t(typeof cause !== \"object\" && typeof cause !== \"function\")\n\t\t) {\n\t\t\treturn \"exception\";\n\t\t}\n\t\tlet current: object | null = cause;\n\t\twhile (current && !types.isProxy(current)) {\n\t\t\tif (current === ExecutionContractError.prototype) {\n\t\t\t\treturn \"contract\";\n\t\t\t}\n\t\t\tcurrent = Object.getPrototypeOf(current);\n\t\t}\n\t\treturn \"exception\";\n\t} catch {\n\t\treturn \"exception\";\n\t}\n}\n\n/** Internal single-policy execution; engines own matching and scheduling. */\nexport class PolicyExecutor {\n\tpublic constructor(\n\t\tprivate readonly root: string,\n\t\tprivate readonly fix: boolean,\n\t) {}\n\n\tpublic *repository(\n\t\tpolicy: Extract<IdentifiedPolicy, { scope: \"repository\" | \"changes\" }>,\n\t\tentries: readonly RepositoryFile[],\n\t\toutput: PolicyRunResults,\n\t): Operation<boolean> {\n\t\tconst { match } = policy;\n\t\tconst matching = match\n\t\t\t? entries.filter(\n\t\t\t\t\t(entry) =>\n\t\t\t\t\t\tmatchesPath(match, entry.path) ||\n\t\t\t\t\t\t(entry.status === \"renamed\" &&\n\t\t\t\t\t\t\tmatchesPath(match, entry.previousPath)),\n\t\t\t\t)\n\t\t\t: entries;\n\t\tconst eligible = inventoryPaths(matching);\n\t\ttry {\n\t\t\tconst findings = yield* runWithPerf(\n\t\t\t\tpolicy.instanceId,\n\t\t\t\t\"handle\",\n\t\t\t\toutput.perfStats,\n\t\t\t\t() =>\n\t\t\t\t\texecute(() =>\n\t\t\t\t\t\tpolicy.handler({\n\t\t\t\t\t\t\tfiles: eligible,\n\t\t\t\t\t\t\tentries: matching,\n\t\t\t\t\t\t\troot: this.root,\n\t\t\t\t\t\t\tresolve: this.fix,\n\t\t\t\t\t\t\tconfig: policy.config,\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t);\n\t\t\tvalidateResult(findings, true, this.fix);\n\t\t\tfor (const finding of findings) {\n\t\t\t\toutput.findings.push({\n\t\t\t\t\t...finding,\n\t\t\t\t\tscope: policy.scope,\n\t\t\t\t\tpolicy: policy.name,\n\t\t\t\t\tpolicyId: policy.instanceId,\n\t\t\t\t});\n\t\t\t}\n\t\t} catch (cause: unknown) {\n\t\t\toutput.errors.push({\n\t\t\t\tscope: policy.scope,\n\t\t\t\tfiles: eligible,\n\t\t\t\tpolicy: policy.name,\n\t\t\t\tpolicyId: policy.instanceId,\n\t\t\t\tphase: \"handle\",\n\t\t\t\tkind: errorKind(cause),\n\t\t\t\tmessage: executionMessage(cause),\n\t\t\t\tcause,\n\t\t\t});\n\t\t\treturn this.fix;\n\t\t}\n\t\treturn false;\n\t}\n\n\tpublic *file(\n\t\tfile: string,\n\t\tpolicy: Exclude<IdentifiedPolicy, { scope: \"repository\" | \"changes\" }>,\n\t\toutput: PolicyRunResults,\n\t\tcache: ParsedFileCache | undefined,\n\t): Operation<boolean> {\n\t\tlet stopped = false;\n\t\tlet phase: \"handle\" | \"resolve\" = \"handle\";\n\t\tlet checked: PolicyResult = [];\n\t\ttry {\n\t\t\tconst args = {\n\t\t\t\tfile,\n\t\t\t\troot: this.root,\n\t\t\t\tresolve: this.fix,\n\t\t\t\tconfig: policy.config,\n\t\t\t\t[fileCache]: cache,\n\t\t\t};\n\t\t\tchecked = yield* runWithPerf(\n\t\t\t\tpolicy.instanceId,\n\t\t\t\t\"handle\",\n\t\t\t\toutput.perfStats,\n\t\t\t\t() => execute(() => policy.handler(args)),\n\t\t\t);\n\t\t\tvalidateResult(checked, false, this.fix);\n\t\t\tif (\n\t\t\t\tthis.fix &&\n\t\t\t\tchecked.length > 0 &&\n\t\t\t\tpolicy.resolver &&\n\t\t\t\t!checked.some(\n\t\t\t\t\t(finding) =>\n\t\t\t\t\t\tfinding.fixStatus === \"fixed\" || finding.fixStatus === \"failed\",\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tphase = \"resolve\";\n\t\t\t\tconst resolver = policy.resolver;\n\t\t\t\tconst resolved = yield* runWithPerf(\n\t\t\t\t\tpolicy.instanceId,\n\t\t\t\t\t\"resolve\",\n\t\t\t\t\toutput.perfStats,\n\t\t\t\t\t() =>\n\t\t\t\t\t\texecute(() =>\n\t\t\t\t\t\t\tresolver({\n\t\t\t\t\t\t\t\tfile,\n\t\t\t\t\t\t\t\troot: args.root,\n\t\t\t\t\t\t\t\tconfig: args.config,\n\t\t\t\t\t\t\t\tfindings: checked.map((finding) => ({ ...finding })),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tvalidateResult(resolved, false, true);\n\t\t\t\tchecked = mergeFindings(checked, resolved);\n\t\t\t}\n\t\t} catch (cause: unknown) {\n\t\t\toutput.errors.push({\n\t\t\t\tscope: \"file\",\n\t\t\t\tfile,\n\t\t\t\tpolicy: policy.name,\n\t\t\t\tpolicyId: policy.instanceId,\n\t\t\t\tphase,\n\t\t\t\tkind: errorKind(cause),\n\t\t\t\tmessage: executionMessage(cause),\n\t\t\t\tcause,\n\t\t\t});\n\t\t\tstopped = this.fix;\n\t\t\tif (phase === \"handle\") {\n\t\t\t\tchecked = [];\n\t\t\t}\n\t\t}\n\t\tfor (const { files: _files, ...finding } of checked) {\n\t\t\toutput.findings.push({\n\t\t\t\t...finding,\n\t\t\t\tscope: \"file\",\n\t\t\t\tfile,\n\t\t\t\tpolicy: policy.name,\n\t\t\t\tpolicyId: policy.instanceId,\n\t\t\t});\n\t\t}\n\t\treturn stopped;\n\t}\n}\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { RepopoConfig } from "./config.js";
|
|
2
|
+
type ChangeOptions = NonNullable<RepopoConfig["changes"]>;
|
|
3
|
+
/** Repo-relative Git paths; renames retain both endpoints. @public */
|
|
4
|
+
export type RepositoryFile = ({
|
|
5
|
+
readonly status: "unchanged" | "added" | "modified" | "deleted" | "type-changed";
|
|
6
|
+
readonly path: string;
|
|
7
|
+
} | {
|
|
8
|
+
readonly status: "renamed";
|
|
9
|
+
readonly path: string;
|
|
10
|
+
readonly previousPath: string;
|
|
11
|
+
}) & {
|
|
12
|
+
/** Working-tree presence when it differs from status (for example an unstaged deletion in PR mode). */
|
|
13
|
+
readonly exists?: boolean | undefined;
|
|
14
|
+
};
|
|
15
|
+
/** Validate options independently of whether a policy requests changes. @internal */
|
|
16
|
+
export declare function validateChangeOptions(options: ChangeOptions): void;
|
|
17
|
+
/** Normalize legacy paths and copy records before policies can observe them. @internal */
|
|
18
|
+
export declare function snapshotInventory(files: readonly (string | RepositoryFile)[]): readonly RepositoryFile[];
|
|
19
|
+
/** Derive the legacy working-tree inventory, excluding absent paths. @internal */
|
|
20
|
+
export declare function inventoryPaths(entries: readonly RepositoryFile[]): string[];
|
|
21
|
+
/** Refresh live paths without changing the statuses captured before fixes. @internal */
|
|
22
|
+
export declare function annotateInventory(files: readonly string[], snapshot: readonly RepositoryFile[]): readonly RepositoryFile[];
|
|
23
|
+
/** Collect the full inventory with Git statuses; does not fetch or require an actual pull request. @public */
|
|
24
|
+
export declare function collectRepositoryInventory(root: string, options?: NonNullable<RepopoConfig["changes"]>): Promise<readonly RepositoryFile[]>;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=repositoryChanges.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repositoryChanges.d.ts","sourceRoot":"","sources":["../src/repositoryChanges.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAKhD,KAAK,aAAa,GAAG,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC;AAE1D,sEAAsE;AACtE,MAAM,MAAM,cAAc,GAAG,CAC1B;IACA,QAAQ,CAAC,MAAM,EACZ,WAAW,GACX,OAAO,GACP,UAAU,GACV,SAAS,GACT,cAAc,CAAC;IAClB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACrB,GACD;IACA,QAAQ,CAAC,MAAM,EAA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