repopo 0.9.0 → 0.10.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 +21 -0
- package/esm/commands/check.d.ts +1 -0
- package/esm/commands/check.d.ts.map +1 -1
- package/esm/commands/check.js +48 -11
- package/esm/commands/check.js.map +1 -1
- package/esm/config.d.ts +19 -4
- package/esm/config.d.ts.map +1 -1
- package/esm/config.js +2 -3
- package/esm/config.js.map +1 -1
- package/esm/index.d.ts +2 -2
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +6 -1
- package/esm/index.js.map +1 -1
- package/esm/makePolicy.d.ts +50 -8
- package/esm/makePolicy.d.ts.map +1 -1
- package/esm/makePolicy.js +64 -4
- package/esm/makePolicy.js.map +1 -1
- package/esm/policies/ConditionalScripts.d.ts +94 -0
- package/esm/policies/ConditionalScripts.d.ts.map +1 -0
- package/esm/policies/ConditionalScripts.js +144 -0
- package/esm/policies/ConditionalScripts.js.map +1 -0
- package/esm/policies/ExactScripts.d.ts +51 -0
- package/esm/policies/ExactScripts.d.ts.map +1 -0
- package/esm/policies/ExactScripts.js +107 -0
- package/esm/policies/ExactScripts.js.map +1 -0
- package/esm/policies/HtmlFileHeaders.d.ts +1 -1
- package/esm/policies/HtmlFileHeaders.d.ts.map +1 -1
- package/esm/policies/JsTsFileHeaders.d.ts +1 -1
- package/esm/policies/JsTsFileHeaders.d.ts.map +1 -1
- package/esm/policies/MutuallyExclusiveScripts.d.ts +46 -0
- package/esm/policies/MutuallyExclusiveScripts.d.ts.map +1 -0
- package/esm/policies/MutuallyExclusiveScripts.js +52 -0
- package/esm/policies/MutuallyExclusiveScripts.js.map +1 -0
- package/esm/policies/NoPrivateWorkspaceDependencies.d.ts +1 -1
- package/esm/policies/NoPrivateWorkspaceDependencies.d.ts.map +1 -1
- package/esm/policies/PackageAllowedScopes.d.ts +1 -1
- package/esm/policies/PackageAllowedScopes.d.ts.map +1 -1
- package/esm/policies/PackageEsmType.d.ts +1 -1
- package/esm/policies/PackageEsmType.d.ts.map +1 -1
- package/esm/policies/PackageFolderName.d.ts +1 -1
- package/esm/policies/PackageFolderName.d.ts.map +1 -1
- package/esm/policies/PackageJsonProperties.d.ts +1 -1
- package/esm/policies/PackageJsonProperties.d.ts.map +1 -1
- package/esm/policies/PackageJsonRepoDirectoryProperty.d.ts +1 -1
- package/esm/policies/PackageJsonRepoDirectoryProperty.d.ts.map +1 -1
- package/esm/policies/PackageJsonSorted.d.ts +1 -1
- package/esm/policies/PackageJsonSorted.d.ts.map +1 -1
- package/esm/policies/PackageLicense.d.ts +1 -1
- package/esm/policies/PackageLicense.d.ts.map +1 -1
- package/esm/policies/PackagePrivateField.d.ts +1 -1
- package/esm/policies/PackagePrivateField.d.ts.map +1 -1
- package/esm/policies/PackageReadme.d.ts +1 -1
- package/esm/policies/PackageReadme.d.ts.map +1 -1
- package/esm/policies/PackageScripts.d.ts +1 -1
- package/esm/policies/PackageScripts.d.ts.map +1 -1
- package/esm/policies/PackageTestScripts.d.ts +1 -1
- package/esm/policies/PackageTestScripts.d.ts.map +1 -1
- package/esm/policies/RequiredScripts.d.ts +71 -0
- package/esm/policies/RequiredScripts.d.ts.map +1 -0
- package/esm/policies/RequiredScripts.js +120 -0
- package/esm/policies/RequiredScripts.js.map +1 -0
- package/esm/policies/ScriptContains.d.ts +64 -0
- package/esm/policies/ScriptContains.d.ts.map +1 -0
- package/esm/policies/ScriptContains.js +62 -0
- package/esm/policies/ScriptContains.js.map +1 -0
- package/esm/policies.d.ts +6 -1
- package/esm/policies.d.ts.map +1 -1
- package/esm/policies.js +18 -0
- package/esm/policies.js.map +1 -1
- package/esm/policy.d.ts +180 -86
- package/esm/policy.d.ts.map +1 -1
- package/esm/policy.js +103 -21
- package/esm/policy.js.map +1 -1
- package/esm/policyDefiners/defineFileHeaderPolicy.d.ts +7 -2
- package/esm/policyDefiners/defineFileHeaderPolicy.d.ts.map +1 -1
- package/esm/policyDefiners/defineFileHeaderPolicy.js +5 -0
- package/esm/policyDefiners/defineFileHeaderPolicy.js.map +1 -1
- package/esm/policyDefiners/definePackagePolicy.d.ts +18 -5
- package/esm/policyDefiners/definePackagePolicy.d.ts.map +1 -1
- package/esm/policyDefiners/definePackagePolicy.js +14 -4
- package/esm/policyDefiners/definePackagePolicy.js.map +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
|
@@ -15,5 +15,5 @@ export interface PackageJsonPropertiesSettings {
|
|
|
15
15
|
*
|
|
16
16
|
* @alpha
|
|
17
17
|
*/
|
|
18
|
-
export declare const PackageJsonProperties: import("../policy.js").
|
|
18
|
+
export declare const PackageJsonProperties: import("../policy.js").PolicyShape<PackageJsonPropertiesSettings | undefined>;
|
|
19
19
|
//# sourceMappingURL=PackageJsonProperties.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PackageJsonProperties.d.ts","sourceRoot":"","sources":["../../src/policies/PackageJsonProperties.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAM7C;;;;GAIG;AACH,MAAM,WAAW,6BAA6B;IAC7C;;OAEG;IACH,QAAQ,EAAE,WAAW,CAAC;CACtB;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"PackageJsonProperties.d.ts","sourceRoot":"","sources":["../../src/policies/PackageJsonProperties.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAM7C;;;;GAIG;AACH,MAAM,WAAW,6BAA6B;IAC7C;;OAEG;IACH,QAAQ,EAAE,WAAW,CAAC;CACtB;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,+EAkDhC,CAAC"}
|
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @alpha
|
|
6
6
|
*/
|
|
7
|
-
export declare const PackageJsonRepoDirectoryProperty: import("../policy.js").
|
|
7
|
+
export declare const PackageJsonRepoDirectoryProperty: import("../policy.js").PolicyShape<undefined>;
|
|
8
8
|
//# sourceMappingURL=PackageJsonRepoDirectoryProperty.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PackageJsonRepoDirectoryProperty.d.ts","sourceRoot":"","sources":["../../src/policies/PackageJsonRepoDirectoryProperty.ts"],"names":[],"mappings":"AAOA;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,
|
|
1
|
+
{"version":3,"file":"PackageJsonRepoDirectoryProperty.d.ts","sourceRoot":"","sources":["../../src/policies/PackageJsonRepoDirectoryProperty.ts"],"names":[],"mappings":"AAOA;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,+CAuD3C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PackageJsonSorted.d.ts","sourceRoot":"","sources":["../../src/policies/PackageJsonSorted.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"PackageJsonSorted.d.ts","sourceRoot":"","sources":["../../src/policies/PackageJsonSorted.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,+CAiD5B,CAAC"}
|
|
@@ -57,5 +57,5 @@ export interface PackageLicenseSettings {
|
|
|
57
57
|
*
|
|
58
58
|
* @alpha
|
|
59
59
|
*/
|
|
60
|
-
export declare const PackageLicense: import("../policy.js").
|
|
60
|
+
export declare const PackageLicense: import("../policy.js").PolicyShape<PackageLicenseSettings | undefined>;
|
|
61
61
|
//# sourceMappingURL=PackageLicense.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PackageLicense.d.ts","sourceRoot":"","sources":["../../src/policies/PackageLicense.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACtC;;;;;;;;;;OAUG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CACzB;AA8CD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"PackageLicense.d.ts","sourceRoot":"","sources":["../../src/policies/PackageLicense.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACtC;;;;;;;;;;OAUG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CACzB;AA8CD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,cAAc,wEA0FzB,CAAC"}
|
|
@@ -120,5 +120,5 @@ export interface PackagePrivateFieldConfig {
|
|
|
120
120
|
*
|
|
121
121
|
* @alpha
|
|
122
122
|
*/
|
|
123
|
-
export declare const PackagePrivateField: import("../policy.js").
|
|
123
|
+
export declare const PackagePrivateField: import("../policy.js").PolicyShape<PackagePrivateFieldConfig | undefined>;
|
|
124
124
|
//# sourceMappingURL=PackagePrivateField.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PackagePrivateField.d.ts","sourceRoot":"","sources":["../../src/policies/PackagePrivateField.ts"],"names":[],"mappings":"AAsBA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,WAAW,yBAAyB;IACzC;;;;;;;;;;;;;;;OAeG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IAEvB;;;;;;;;;;;;;;OAcG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IAEzB;;;;;;;;;;;;;;;OAeG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IAEtB;;;;;;;;OAQG;IACH,iBAAiB,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;CACpD;AA+DD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"PackagePrivateField.d.ts","sourceRoot":"","sources":["../../src/policies/PackagePrivateField.ts"],"names":[],"mappings":"AAsBA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,WAAW,yBAAyB;IACzC;;;;;;;;;;;;;;;OAeG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IAEvB;;;;;;;;;;;;;;OAcG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IAEzB;;;;;;;;;;;;;;;OAeG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IAEtB;;;;;;;;OAQG;IACH,iBAAiB,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;CACpD;AA+DD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,mBAAmB,2EA+E9B,CAAC"}
|
|
@@ -73,5 +73,5 @@ export interface PackageReadmeSettings {
|
|
|
73
73
|
*
|
|
74
74
|
* @alpha
|
|
75
75
|
*/
|
|
76
|
-
export declare const PackageReadme: import("../policy.js").
|
|
76
|
+
export declare const PackageReadme: import("../policy.js").PolicyShape<PackageReadmeSettings | undefined>;
|
|
77
77
|
//# sourceMappingURL=PackageReadme.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PackageReadme.d.ts","sourceRoot":"","sources":["../../src/policies/PackageReadme.ts"],"names":[],"mappings":"AAWA;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACrC;;;;;;;;;OASG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;;;;;;;OASG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAE/B;;;;;;;;;;;;OAYG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CACzB;AAkMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"PackageReadme.d.ts","sourceRoot":"","sources":["../../src/policies/PackageReadme.ts"],"names":[],"mappings":"AAWA;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACrC;;;;;;;;;OASG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;;;;;;;OASG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAE/B;;;;;;;;;;;;OAYG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CACzB;AAkMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,aAAa,uEA4CxB,CAAC"}
|
|
@@ -204,5 +204,5 @@ export interface PackageScriptsSettings {
|
|
|
204
204
|
*
|
|
205
205
|
* @alpha
|
|
206
206
|
*/
|
|
207
|
-
export declare const PackageScripts: import("../policy.js").
|
|
207
|
+
export declare const PackageScripts: import("../policy.js").PolicyShape<PackageScriptsSettings | undefined>;
|
|
208
208
|
//# sourceMappingURL=PackageScripts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PackageScripts.d.ts","sourceRoot":"","sources":["../../src/policies/PackageScripts.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACrC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,WAAW,EAAE,MAAM,EAAE,CAAC;CACtB;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACrC;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;;;;;;;;;;;;OAcG;IACH,QAAQ,EAAE,mBAAmB,EAAE,CAAC;CAChC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAElE;;;;GAIG;AACH,MAAM,WAAW,sBAAsB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;;;;;;;;OAYG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC;IAE/B;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,mBAAmB,CAAC,EAAE,qBAAqB,EAAE,CAAC;IAE9C;;;;;;;;;;;;;;;;;;OAkBG;IACH,iBAAiB,CAAC,EAAE,qBAAqB,EAAE,CAAC;CAC5C;AAseD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,eAAO,MAAM,cAAc,wEAgEzB,CAAC"}
|
|
@@ -96,5 +96,5 @@ export interface PackageTestScriptsConfig {
|
|
|
96
96
|
*
|
|
97
97
|
* @alpha
|
|
98
98
|
*/
|
|
99
|
-
export declare const PackageTestScripts: import("../policy.js").
|
|
99
|
+
export declare const PackageTestScripts: import("../policy.js").PolicyShape<PackageTestScriptsConfig | undefined>;
|
|
100
100
|
//# sourceMappingURL=PackageTestScripts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PackageTestScripts.d.ts","sourceRoot":"","sources":["../../src/policies/PackageTestScripts.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,WAAW,wBAAwB;IACxC;;;;;;;;;;;;OAYG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAE3B;;;;;;;;;;;;OAYG;IACH,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAE5B;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAE3B;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AA0GD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,kBAAkB
|
|
1
|
+
{"version":3,"file":"PackageTestScripts.d.ts","sourceRoot":"","sources":["../../src/policies/PackageTestScripts.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,WAAW,wBAAwB;IACxC;;;;;;;;;;;;OAYG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAE3B;;;;;;;;;;;;OAYG;IACH,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAE5B;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAE3B;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AA0GD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,kBAAkB,0EA4D7B,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A required script entry. Can be either:
|
|
3
|
+
* - A string (script name only, no default value)
|
|
4
|
+
* - An object with a single key-value pair (script name → default value for auto-fix)
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* // Script must exist, no auto-fix available
|
|
9
|
+
* "test"
|
|
10
|
+
*
|
|
11
|
+
* // Script must exist, auto-fix will add this value if missing
|
|
12
|
+
* { lint: "biome lint ." }
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @alpha
|
|
16
|
+
*/
|
|
17
|
+
export type RequiredScriptEntry = string | Record<string, string>;
|
|
18
|
+
/**
|
|
19
|
+
* Configuration for the RequiredScripts policy.
|
|
20
|
+
*
|
|
21
|
+
* @alpha
|
|
22
|
+
*/
|
|
23
|
+
export interface RequiredScriptsConfig {
|
|
24
|
+
/**
|
|
25
|
+
* Scripts that must be present in package.json.
|
|
26
|
+
*
|
|
27
|
+
* @remarks
|
|
28
|
+
* Each entry can be:
|
|
29
|
+
* - A string: Script must exist, no auto-fix available, content not validated
|
|
30
|
+
* - An object `{ scriptName: "default value" }`: Script must exist, auto-fix adds the
|
|
31
|
+
* default value if missing, but existing scripts with different content still pass
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* scripts: [
|
|
36
|
+
* "test", // Must exist, no auto-fix
|
|
37
|
+
* { lint: "biome lint ." }, // Must exist, auto-fix available
|
|
38
|
+
* { clean: "rimraf dist esm" }, // Must exist, auto-fix available
|
|
39
|
+
* ]
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
scripts: RequiredScriptEntry[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* A policy that validates required scripts exist in package.json.
|
|
46
|
+
*
|
|
47
|
+
* @remarks
|
|
48
|
+
* Use this policy when you want to ensure specific scripts are present.
|
|
49
|
+
* Scripts can be specified with optional default values that enable auto-fix.
|
|
50
|
+
*
|
|
51
|
+
* Note: This policy only checks for script presence. It does NOT validate
|
|
52
|
+
* the script's content. Use ExactScripts for content validation.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* import { policy } from "repopo";
|
|
57
|
+
* import { RequiredScripts } from "repopo/policies";
|
|
58
|
+
*
|
|
59
|
+
* policy(RequiredScripts, {
|
|
60
|
+
* scripts: [
|
|
61
|
+
* "test", // Must exist, no auto-fix
|
|
62
|
+
* { lint: "biome lint ." }, // Must exist, auto-fix adds default if missing
|
|
63
|
+
* { clean: "rimraf dist esm" }, // Must exist, auto-fix adds default if missing
|
|
64
|
+
* ],
|
|
65
|
+
* })
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* @alpha
|
|
69
|
+
*/
|
|
70
|
+
export declare const RequiredScripts: import("../policy.js").PolicyShape<RequiredScriptsConfig | undefined>;
|
|
71
|
+
//# sourceMappingURL=RequiredScripts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RequiredScripts.d.ts","sourceRoot":"","sources":["../../src/policies/RequiredScripts.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAElE;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACrC;;;;;;;;;;;;;;;;;OAiBG;IACH,OAAO,EAAE,mBAAmB,EAAE,CAAC;CAC/B;AAoFD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,eAAe,uEA2D1B,CAAC"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import jsonfile from "jsonfile";
|
|
2
|
+
import { definePackagePolicy } from "../policyDefiners/definePackagePolicy.js";
|
|
3
|
+
const POLICY_NAME = "RequiredScripts";
|
|
4
|
+
/**
|
|
5
|
+
* Extracts script name and optional default value from a RequiredScriptEntry.
|
|
6
|
+
*/
|
|
7
|
+
function parseRequiredEntry(entry) {
|
|
8
|
+
if (typeof entry === "string") {
|
|
9
|
+
return { name: entry };
|
|
10
|
+
}
|
|
11
|
+
const keys = Object.keys(entry);
|
|
12
|
+
if (keys.length !== 1) {
|
|
13
|
+
throw new Error(`Invalid required script entry: expected single key-value pair, got ${keys.length} keys`);
|
|
14
|
+
}
|
|
15
|
+
// biome-ignore lint/style/noNonNullAssertion: we verified length is 1
|
|
16
|
+
const name = keys[0];
|
|
17
|
+
const defaultValue = entry[name];
|
|
18
|
+
return defaultValue !== undefined ? { name, defaultValue } : { name };
|
|
19
|
+
}
|
|
20
|
+
function validateRequiredScripts(scripts, requiredEntries) {
|
|
21
|
+
const missingScripts = [];
|
|
22
|
+
const missingWithDefaults = [];
|
|
23
|
+
for (const entry of requiredEntries) {
|
|
24
|
+
const { name, defaultValue } = parseRequiredEntry(entry);
|
|
25
|
+
if (!Object.hasOwn(scripts, name)) {
|
|
26
|
+
missingScripts.push(name);
|
|
27
|
+
if (defaultValue !== undefined) {
|
|
28
|
+
missingWithDefaults.push({ name, defaultValue });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return { missingScripts, missingWithDefaults };
|
|
33
|
+
}
|
|
34
|
+
async function fixMissingScripts(json, file, missingWithDefaults, existingScripts) {
|
|
35
|
+
const updatedScripts = {};
|
|
36
|
+
// Copy existing scripts
|
|
37
|
+
for (const [key, value] of Object.entries(existingScripts)) {
|
|
38
|
+
if (value !== undefined) {
|
|
39
|
+
updatedScripts[key] = value;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
// Add missing scripts with defaults
|
|
43
|
+
const fixedScripts = [];
|
|
44
|
+
for (const { name, defaultValue } of missingWithDefaults) {
|
|
45
|
+
updatedScripts[name] = defaultValue;
|
|
46
|
+
fixedScripts.push(name);
|
|
47
|
+
}
|
|
48
|
+
await jsonfile.writeFile(file, { ...json, scripts: updatedScripts }, { spaces: 2 });
|
|
49
|
+
return fixedScripts;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* A policy that validates required scripts exist in package.json.
|
|
53
|
+
*
|
|
54
|
+
* @remarks
|
|
55
|
+
* Use this policy when you want to ensure specific scripts are present.
|
|
56
|
+
* Scripts can be specified with optional default values that enable auto-fix.
|
|
57
|
+
*
|
|
58
|
+
* Note: This policy only checks for script presence. It does NOT validate
|
|
59
|
+
* the script's content. Use ExactScripts for content validation.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* import { policy } from "repopo";
|
|
64
|
+
* import { RequiredScripts } from "repopo/policies";
|
|
65
|
+
*
|
|
66
|
+
* policy(RequiredScripts, {
|
|
67
|
+
* scripts: [
|
|
68
|
+
* "test", // Must exist, no auto-fix
|
|
69
|
+
* { lint: "biome lint ." }, // Must exist, auto-fix adds default if missing
|
|
70
|
+
* { clean: "rimraf dist esm" }, // Must exist, auto-fix adds default if missing
|
|
71
|
+
* ],
|
|
72
|
+
* })
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* @alpha
|
|
76
|
+
*/
|
|
77
|
+
export const RequiredScripts = definePackagePolicy({
|
|
78
|
+
name: POLICY_NAME,
|
|
79
|
+
description: "Validates that required scripts exist in package.json.",
|
|
80
|
+
handler: async (json, { file, resolve, config }) => {
|
|
81
|
+
if (config === undefined || config.scripts.length === 0) {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
const scripts = json.scripts ?? {};
|
|
85
|
+
const validation = validateRequiredScripts(scripts, config.scripts);
|
|
86
|
+
if (validation.missingScripts.length === 0) {
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
const hasAutoFixableErrors = validation.missingWithDefaults.length > 0;
|
|
90
|
+
if (resolve && hasAutoFixableErrors) {
|
|
91
|
+
try {
|
|
92
|
+
const fixedScripts = await fixMissingScripts(json, file, validation.missingWithDefaults, scripts);
|
|
93
|
+
// Check if there are still missing scripts (those without defaults)
|
|
94
|
+
const stillMissing = validation.missingScripts.filter((name) => !fixedScripts.includes(name));
|
|
95
|
+
return {
|
|
96
|
+
name: POLICY_NAME,
|
|
97
|
+
file,
|
|
98
|
+
resolved: stillMissing.length === 0,
|
|
99
|
+
errorMessages: stillMissing.length > 0
|
|
100
|
+
? [
|
|
101
|
+
`Fixed scripts: ${fixedScripts.join(", ")}. Still missing: ${stillMissing.join(", ")}`,
|
|
102
|
+
]
|
|
103
|
+
: [`Fixed scripts: ${fixedScripts.join(", ")}`],
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
// Fall through to return regular failure
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
name: POLICY_NAME,
|
|
112
|
+
file,
|
|
113
|
+
autoFixable: hasAutoFixableErrors,
|
|
114
|
+
errorMessages: [
|
|
115
|
+
`Missing required scripts:\n\t${validation.missingScripts.join("\n\t")}`,
|
|
116
|
+
],
|
|
117
|
+
};
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
//# sourceMappingURL=RequiredScripts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RequiredScripts.js","sourceRoot":"","sources":["../../src/policies/RequiredScripts.ts"],"names":[],"mapp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AAC,IAAI,CAAC,MAAM,CAAC,EAAE;aACxE;SACD,CAAC;IACH,CAAC;CACD,CAAC,CAAC","sourcesContent":["import jsonfile from \"jsonfile\";\nimport type { PackageJson } from \"type-fest\";\nimport { definePackagePolicy } from \"../policyDefiners/definePackagePolicy.js\";\n\n/**\n * A required script entry. Can be either:\n * - A string (script name only, no default value)\n * - An object with a single key-value pair (script name → default value for auto-fix)\n *\n * @example\n * ```typescript\n * // Script must exist, no auto-fix available\n * \"test\"\n *\n * // Script must exist, auto-fix will add this value if missing\n * { lint: \"biome lint .\" }\n * ```\n *\n * @alpha\n */\nexport type RequiredScriptEntry = string | Record<string, string>;\n\n/**\n * Configuration for the RequiredScripts policy.\n *\n * @alpha\n */\nexport interface RequiredScriptsConfig {\n\t/**\n\t * Scripts that must be present in package.json.\n\t *\n\t * @remarks\n\t * Each entry can be:\n\t * - A string: Script must exist, no auto-fix available, content not validated\n\t * - An object `{ scriptName: \"default value\" }`: Script must exist, auto-fix adds the\n\t * default value if missing, but existing scripts with different content still pass\n\t *\n\t * @example\n\t * ```typescript\n\t * scripts: [\n\t * \"test\", // Must exist, no auto-fix\n\t * { lint: \"biome lint .\" }, // Must exist, auto-fix available\n\t * { clean: \"rimraf dist esm\" }, // Must exist, auto-fix available\n\t * ]\n\t * ```\n\t */\n\tscripts: RequiredScriptEntry[];\n}\n\nconst POLICY_NAME = \"RequiredScripts\";\n\ninterface ParsedEntry {\n\tname: string;\n\tdefaultValue?: string;\n}\n\n/**\n * Extracts script name and optional default value from a RequiredScriptEntry.\n */\nfunction parseRequiredEntry(entry: RequiredScriptEntry): ParsedEntry {\n\tif (typeof entry === \"string\") {\n\t\treturn { name: entry };\n\t}\n\tconst keys = Object.keys(entry);\n\tif (keys.length !== 1) {\n\t\tthrow new Error(\n\t\t\t`Invalid required script entry: expected single key-value pair, got ${keys.length} keys`,\n\t\t);\n\t}\n\t// biome-ignore lint/style/noNonNullAssertion: we verified length is 1\n\tconst name = keys[0]!;\n\tconst defaultValue = entry[name];\n\treturn defaultValue !== undefined ? { name, defaultValue } : { name };\n}\n\ninterface ValidationResult {\n\tmissingScripts: string[];\n\tmissingWithDefaults: Array<{ name: string; defaultValue: string }>;\n}\n\nfunction validateRequiredScripts(\n\tscripts: Record<string, string | undefined>,\n\trequiredEntries: RequiredScriptEntry[],\n): ValidationResult {\n\tconst missingScripts: string[] = [];\n\tconst missingWithDefaults: Array<{ name: string; defaultValue: string }> = [];\n\n\tfor (const entry of requiredEntries) {\n\t\tconst { name, defaultValue } = parseRequiredEntry(entry);\n\t\tif (!Object.hasOwn(scripts, name)) {\n\t\t\tmissingScripts.push(name);\n\t\t\tif (defaultValue !== undefined) {\n\t\t\t\tmissingWithDefaults.push({ name, defaultValue });\n\t\t\t}\n\t\t}\n\t}\n\n\treturn { missingScripts, missingWithDefaults };\n}\n\nasync function fixMissingScripts(\n\tjson: PackageJson,\n\tfile: string,\n\tmissingWithDefaults: Array<{ name: string; defaultValue: string }>,\n\texistingScripts: Record<string, string | undefined>,\n): Promise<string[]> {\n\tconst updatedScripts: Record<string, string> = {};\n\n\t// Copy existing scripts\n\tfor (const [key, value] of Object.entries(existingScripts)) {\n\t\tif (value !== undefined) {\n\t\t\tupdatedScripts[key] = value;\n\t\t}\n\t}\n\n\t// Add missing scripts with defaults\n\tconst fixedScripts: string[] = [];\n\tfor (const { name, defaultValue } of missingWithDefaults) {\n\t\tupdatedScripts[name] = defaultValue;\n\t\tfixedScripts.push(name);\n\t}\n\n\tawait jsonfile.writeFile(\n\t\tfile,\n\t\t{ ...json, scripts: updatedScripts },\n\t\t{ spaces: 2 },\n\t);\n\n\treturn fixedScripts;\n}\n\n/**\n * A policy that validates required scripts exist in package.json.\n *\n * @remarks\n * Use this policy when you want to ensure specific scripts are present.\n * Scripts can be specified with optional default values that enable auto-fix.\n *\n * Note: This policy only checks for script presence. It does NOT validate\n * the script's content. Use ExactScripts for content validation.\n *\n * @example\n * ```typescript\n * import { policy } from \"repopo\";\n * import { RequiredScripts } from \"repopo/policies\";\n *\n * policy(RequiredScripts, {\n * scripts: [\n * \"test\", // Must exist, no auto-fix\n * { lint: \"biome lint .\" }, // Must exist, auto-fix adds default if missing\n * { clean: \"rimraf dist esm\" }, // Must exist, auto-fix adds default if missing\n * ],\n * })\n * ```\n *\n * @alpha\n */\nexport const RequiredScripts = definePackagePolicy<\n\tPackageJson,\n\tRequiredScriptsConfig | undefined\n>({\n\tname: POLICY_NAME,\n\tdescription: \"Validates that required scripts exist in package.json.\",\n\thandler: async (json, { file, resolve, config }) => {\n\t\tif (config === undefined || config.scripts.length === 0) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst scripts = json.scripts ?? {};\n\t\tconst validation = validateRequiredScripts(scripts, config.scripts);\n\n\t\tif (validation.missingScripts.length === 0) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst hasAutoFixableErrors = validation.missingWithDefaults.length > 0;\n\n\t\tif (resolve && hasAutoFixableErrors) {\n\t\t\ttry {\n\t\t\t\tconst fixedScripts = await fixMissingScripts(\n\t\t\t\t\tjson,\n\t\t\t\t\tfile,\n\t\t\t\t\tvalidation.missingWithDefaults,\n\t\t\t\t\tscripts,\n\t\t\t\t);\n\n\t\t\t\t// Check if there are still missing scripts (those without defaults)\n\t\t\t\tconst stillMissing = validation.missingScripts.filter(\n\t\t\t\t\t(name) => !fixedScripts.includes(name),\n\t\t\t\t);\n\n\t\t\t\treturn {\n\t\t\t\t\tname: POLICY_NAME,\n\t\t\t\t\tfile,\n\t\t\t\t\tresolved: stillMissing.length === 0,\n\t\t\t\t\terrorMessages:\n\t\t\t\t\t\tstillMissing.length > 0\n\t\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t\t`Fixed scripts: ${fixedScripts.join(\", \")}. Still missing: ${stillMissing.join(\", \")}`,\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t: [`Fixed scripts: ${fixedScripts.join(\", \")}`],\n\t\t\t\t};\n\t\t\t} catch {\n\t\t\t\t// Fall through to return regular failure\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tname: POLICY_NAME,\n\t\t\tfile,\n\t\t\tautoFixable: hasAutoFixableErrors,\n\t\t\terrorMessages: [\n\t\t\t\t`Missing required scripts:\\n\\t${validation.missingScripts.join(\"\\n\\t\")}`,\n\t\t\t],\n\t\t};\n\t},\n});\n"]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration for validating that a script's body contains required substrings.
|
|
3
|
+
*
|
|
4
|
+
* @alpha
|
|
5
|
+
*/
|
|
6
|
+
export interface ScriptContainsRule {
|
|
7
|
+
/**
|
|
8
|
+
* The name of the script to validate.
|
|
9
|
+
*/
|
|
10
|
+
script: string;
|
|
11
|
+
/**
|
|
12
|
+
* Substrings that must appear in the script body.
|
|
13
|
+
* All substrings must be present for the script to pass validation.
|
|
14
|
+
*/
|
|
15
|
+
mustContain: string[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Configuration for the ScriptContains policy.
|
|
19
|
+
*
|
|
20
|
+
* @alpha
|
|
21
|
+
*/
|
|
22
|
+
export interface ScriptContainsConfig {
|
|
23
|
+
/**
|
|
24
|
+
* Rules for validating script body content.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* rules: [
|
|
29
|
+
* { script: "clean", mustContain: ["rimraf"] },
|
|
30
|
+
* { script: "build", mustContain: ["tsc"] },
|
|
31
|
+
* ]
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
rules: ScriptContainsRule[];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* A policy that validates script bodies contain required substrings.
|
|
38
|
+
*
|
|
39
|
+
* @remarks
|
|
40
|
+
* Use this policy to ensure specific scripts contain required commands or patterns
|
|
41
|
+
* without requiring an exact match. For example, requiring that the "clean" script
|
|
42
|
+
* uses "rimraf" or that "build" includes "tsc".
|
|
43
|
+
*
|
|
44
|
+
* The policy only validates scripts that exist. If a script doesn't exist,
|
|
45
|
+
* it's not an error (use RequiredScripts for that).
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* import { policy } from "repopo";
|
|
50
|
+
* import { ScriptContains } from "repopo/policies";
|
|
51
|
+
*
|
|
52
|
+
* policy(ScriptContains, {
|
|
53
|
+
* rules: [
|
|
54
|
+
* { script: "clean", mustContain: ["rimraf"] },
|
|
55
|
+
* { script: "build", mustContain: ["tsc"] },
|
|
56
|
+
* { script: "test", mustContain: ["vitest", "run"] },
|
|
57
|
+
* ],
|
|
58
|
+
* })
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* @alpha
|
|
62
|
+
*/
|
|
63
|
+
export declare const ScriptContains: import("../policy.js").PolicyShape<ScriptContainsConfig | undefined>;
|
|
64
|
+
//# sourceMappingURL=ScriptContains.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScriptContains.d.ts","sourceRoot":"","sources":["../../src/policies/ScriptContains.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAClC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,WAAW,EAAE,MAAM,EAAE,CAAC;CACtB;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACpC;;;;;;;;;;OAUG;IACH,KAAK,EAAE,kBAAkB,EAAE,CAAC;CAC5B;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,cAAc,sEA2CzB,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { definePackagePolicy } from "../policyDefiners/definePackagePolicy.js";
|
|
2
|
+
const POLICY_NAME = "ScriptContains";
|
|
3
|
+
/**
|
|
4
|
+
* A policy that validates script bodies contain required substrings.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Use this policy to ensure specific scripts contain required commands or patterns
|
|
8
|
+
* without requiring an exact match. For example, requiring that the "clean" script
|
|
9
|
+
* uses "rimraf" or that "build" includes "tsc".
|
|
10
|
+
*
|
|
11
|
+
* The policy only validates scripts that exist. If a script doesn't exist,
|
|
12
|
+
* it's not an error (use RequiredScripts for that).
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { policy } from "repopo";
|
|
17
|
+
* import { ScriptContains } from "repopo/policies";
|
|
18
|
+
*
|
|
19
|
+
* policy(ScriptContains, {
|
|
20
|
+
* rules: [
|
|
21
|
+
* { script: "clean", mustContain: ["rimraf"] },
|
|
22
|
+
* { script: "build", mustContain: ["tsc"] },
|
|
23
|
+
* { script: "test", mustContain: ["vitest", "run"] },
|
|
24
|
+
* ],
|
|
25
|
+
* })
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @alpha
|
|
29
|
+
*/
|
|
30
|
+
export const ScriptContains = definePackagePolicy({
|
|
31
|
+
name: POLICY_NAME,
|
|
32
|
+
description: "Validates that script bodies contain required substrings.",
|
|
33
|
+
handler: async (json, { file, config }) => {
|
|
34
|
+
if (config === undefined || config.rules.length === 0) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
const scripts = json.scripts ?? {};
|
|
38
|
+
const errors = [];
|
|
39
|
+
for (const rule of config.rules) {
|
|
40
|
+
// Only validate if the script exists
|
|
41
|
+
if (Object.hasOwn(scripts, rule.script)) {
|
|
42
|
+
const scriptBody = scripts[rule.script];
|
|
43
|
+
if (typeof scriptBody === "string") {
|
|
44
|
+
const missingSubstrings = rule.mustContain.filter((substring) => !scriptBody.includes(substring));
|
|
45
|
+
if (missingSubstrings.length > 0) {
|
|
46
|
+
errors.push(`Script "${rule.script}" must contain: ${missingSubstrings.join(", ")}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (errors.length === 0) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
name: POLICY_NAME,
|
|
56
|
+
file,
|
|
57
|
+
autoFixable: false,
|
|
58
|
+
errorMessages: errors,
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
//# sourceMappingURL=ScriptContains.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScriptContains.js","sourceRoot":"","sources":["../../src/policies/ScriptContains.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAwC/E,MAAM,WAAW,GAAG,gBAAgB,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,mBAAmB,CAG/C;IACD,IAAI,EAAE,WAAW;IACjB,WAAW,EAAE,2DAA2D;IACxE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE;QACzC,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvD,OAAO,IAAI,CAAC;QACb,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC;QACnC,MAAM,MAAM,GAAa,EAAE,CAAC;QAE5B,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;YACjC,qCAAqC;YACrC,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;gBACzC,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACxC,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE,CAAC;oBACpC,MAAM,iBAAiB,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAChD,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,CAC9C,CAAC;oBAEF,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;wBAClC,MAAM,CAAC,IAAI,CACV,WAAW,IAAI,CAAC,MAAM,mBAAmB,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACvE,CAAC;oBACH,CAAC;gBACF,CAAC;YACF,CAAC;QACF,CAAC;QAED,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,IAAI,CAAC;QACb,CAAC;QAED,OAAO;YACN,IAAI,EAAE,WAAW;YACjB,IAAI;YACJ,WAAW,EAAE,KAAK;YAClB,aAAa,EAAE,MAAM;SACrB,CAAC;IACH,CAAC;CACD,CAAC,CAAC","sourcesContent":["import type { PackageJson } from \"type-fest\";\nimport { definePackagePolicy } from \"../policyDefiners/definePackagePolicy.js\";\n\n/**\n * Configuration for validating that a script's body contains required substrings.\n *\n * @alpha\n */\nexport interface ScriptContainsRule {\n\t/**\n\t * The name of the script to validate.\n\t */\n\tscript: string;\n\n\t/**\n\t * Substrings that must appear in the script body.\n\t * All substrings must be present for the script to pass validation.\n\t */\n\tmustContain: string[];\n}\n\n/**\n * Configuration for the ScriptContains policy.\n *\n * @alpha\n */\nexport interface ScriptContainsConfig {\n\t/**\n\t * Rules for validating script body content.\n\t *\n\t * @example\n\t * ```typescript\n\t * rules: [\n\t * { script: \"clean\", mustContain: [\"rimraf\"] },\n\t * { script: \"build\", mustContain: [\"tsc\"] },\n\t * ]\n\t * ```\n\t */\n\trules: ScriptContainsRule[];\n}\n\nconst POLICY_NAME = \"ScriptContains\";\n\n/**\n * A policy that validates script bodies contain required substrings.\n *\n * @remarks\n * Use this policy to ensure specific scripts contain required commands or patterns\n * without requiring an exact match. For example, requiring that the \"clean\" script\n * uses \"rimraf\" or that \"build\" includes \"tsc\".\n *\n * The policy only validates scripts that exist. If a script doesn't exist,\n * it's not an error (use RequiredScripts for that).\n *\n * @example\n * ```typescript\n * import { policy } from \"repopo\";\n * import { ScriptContains } from \"repopo/policies\";\n *\n * policy(ScriptContains, {\n * rules: [\n * { script: \"clean\", mustContain: [\"rimraf\"] },\n * { script: \"build\", mustContain: [\"tsc\"] },\n * { script: \"test\", mustContain: [\"vitest\", \"run\"] },\n * ],\n * })\n * ```\n *\n * @alpha\n */\nexport const ScriptContains = definePackagePolicy<\n\tPackageJson,\n\tScriptContainsConfig | undefined\n>({\n\tname: POLICY_NAME,\n\tdescription: \"Validates that script bodies contain required substrings.\",\n\thandler: async (json, { file, config }) => {\n\t\tif (config === undefined || config.rules.length === 0) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst scripts = json.scripts ?? {};\n\t\tconst errors: string[] = [];\n\n\t\tfor (const rule of config.rules) {\n\t\t\t// Only validate if the script exists\n\t\t\tif (Object.hasOwn(scripts, rule.script)) {\n\t\t\t\tconst scriptBody = scripts[rule.script];\n\t\t\t\tif (typeof scriptBody === \"string\") {\n\t\t\t\t\tconst missingSubstrings = rule.mustContain.filter(\n\t\t\t\t\t\t(substring) => !scriptBody.includes(substring),\n\t\t\t\t\t);\n\n\t\t\t\t\tif (missingSubstrings.length > 0) {\n\t\t\t\t\t\terrors.push(\n\t\t\t\t\t\t\t`Script \"${rule.script}\" must contain: ${missingSubstrings.join(\", \")}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (errors.length === 0) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn {\n\t\t\tname: POLICY_NAME,\n\t\t\tfile,\n\t\t\tautoFixable: false,\n\t\t\terrorMessages: errors,\n\t\t};\n\t},\n});\n"]}
|
package/esm/policies.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
export { type ConditionalScriptEntry, type ConditionalScriptRule, ConditionalScripts, type ConditionalScriptsConfig, } from "./policies/ConditionalScripts.js";
|
|
2
|
+
export { ExactScripts, type ExactScriptsConfig, } from "./policies/ExactScripts.js";
|
|
1
3
|
export { HtmlFileHeaders } from "./policies/HtmlFileHeaders.js";
|
|
2
4
|
export { JsTsFileHeaders } from "./policies/JsTsFileHeaders.js";
|
|
3
5
|
export { LicenseFileExists } from "./policies/LicenseFileExists.js";
|
|
6
|
+
export { MutuallyExclusiveScripts, type MutuallyExclusiveScriptsConfig, } from "./policies/MutuallyExclusiveScripts.js";
|
|
4
7
|
export { NoJsFileExtensions } from "./policies/NoJsFileExtensions.js";
|
|
5
8
|
export { NoLargeBinaryFiles } from "./policies/NoLargeBinaryFiles.js";
|
|
6
9
|
export { NoPrivateWorkspaceDependencies } from "./policies/NoPrivateWorkspaceDependencies.js";
|
|
@@ -13,8 +16,10 @@ export { PackageJsonSorted } from "./policies/PackageJsonSorted.js";
|
|
|
13
16
|
export { PackageLicense, type PackageLicenseSettings, } from "./policies/PackageLicense.js";
|
|
14
17
|
export { PackagePrivateField, type PackagePrivateFieldConfig, } from "./policies/PackagePrivateField.js";
|
|
15
18
|
export { PackageReadme, type PackageReadmeSettings, } from "./policies/PackageReadme.js";
|
|
16
|
-
export { type ConditionalScriptRule, PackageScripts, type PackageScriptsSettings, type RequiredScriptEntry, type ScriptMustContainRule, } from "./policies/PackageScripts.js";
|
|
19
|
+
export { type ConditionalScriptRule as LegacyConditionalScriptRule, PackageScripts, type PackageScriptsSettings, type RequiredScriptEntry as LegacyRequiredScriptEntry, type ScriptMustContainRule, } from "./policies/PackageScripts.js";
|
|
17
20
|
export { PackageTestScripts, type PackageTestScriptsConfig, } from "./policies/PackageTestScripts.js";
|
|
18
21
|
export { RequiredGitignorePatterns } from "./policies/RequiredGitignorePatterns.js";
|
|
22
|
+
export { type RequiredScriptEntry, RequiredScripts, type RequiredScriptsConfig, } from "./policies/RequiredScripts.js";
|
|
23
|
+
export { ScriptContains, type ScriptContainsConfig, type ScriptContainsRule, } from "./policies/ScriptContains.js";
|
|
19
24
|
export { DefaultPolicies } from "./policy.js";
|
|
20
25
|
//# sourceMappingURL=policies.d.ts.map
|
package/esm/policies.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policies.d.ts","sourceRoot":"","sources":["../src/policies.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"policies.d.ts","sourceRoot":"","sources":["../src/policies.ts"],"names":[],"mappings":"AAEA,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,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EACN,wBAAwB,EACxB,KAAK,8BAA8B,GACnC,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAEtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAEtE,OAAO,EAAE,8BAA8B,EAAE,MAAM,8CAA8C,CAAC;AAE9F,OAAO,EACN,oBAAoB,EACpB,KAAK,0BAA0B,GAC/B,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EACN,cAAc,EACd,KAAK,oBAAoB,GACzB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACN,iBAAiB,EACjB,KAAK,uBAAuB,GAC5B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,gCAAgC,EAAE,MAAM,gDAAgD,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EACN,cAAc,EACd,KAAK,sBAAsB,GAC3B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACN,mBAAmB,EACnB,KAAK,yBAAyB,GAC9B,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EACN,aAAa,EACb,KAAK,qBAAqB,GAC1B,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACN,KAAK,qBAAqB,IAAI,2BAA2B,EACzD,cAAc,EACd,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,IAAI,yBAAyB,EACrD,KAAK,qBAAqB,GAC1B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACN,kBAAkB,EAClB,KAAK,wBAAwB,GAC7B,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AACpF,OAAO,EACN,KAAK,mBAAmB,EACxB,eAAe,EACf,KAAK,qBAAqB,GAC1B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACN,cAAc,EACd,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,GACvB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC"}
|
package/esm/policies.js
CHANGED
|
@@ -1,21 +1,39 @@
|
|
|
1
|
+
// New focused script policies (replacements for PackageScripts)
|
|
1
2
|
// biome-ignore lint/performance/noBarrelFile: intentional public API entry point for policies
|
|
3
|
+
export { ConditionalScripts, } from "./policies/ConditionalScripts.js";
|
|
4
|
+
export { ExactScripts, } from "./policies/ExactScripts.js";
|
|
5
|
+
// File header policies
|
|
2
6
|
export { HtmlFileHeaders } from "./policies/HtmlFileHeaders.js";
|
|
3
7
|
export { JsTsFileHeaders } from "./policies/JsTsFileHeaders.js";
|
|
8
|
+
// License policies
|
|
4
9
|
export { LicenseFileExists } from "./policies/LicenseFileExists.js";
|
|
10
|
+
export { MutuallyExclusiveScripts, } from "./policies/MutuallyExclusiveScripts.js";
|
|
11
|
+
// File extension policies
|
|
5
12
|
export { NoJsFileExtensions } from "./policies/NoJsFileExtensions.js";
|
|
13
|
+
// File size policies
|
|
6
14
|
export { NoLargeBinaryFiles } from "./policies/NoLargeBinaryFiles.js";
|
|
15
|
+
// Dependency policies
|
|
7
16
|
export { NoPrivateWorkspaceDependencies } from "./policies/NoPrivateWorkspaceDependencies.js";
|
|
17
|
+
// Package naming policies
|
|
8
18
|
export { PackageAllowedScopes, } from "./policies/PackageAllowedScopes.js";
|
|
19
|
+
// Package type policies
|
|
9
20
|
export { PackageEsmType, } from "./policies/PackageEsmType.js";
|
|
10
21
|
export { PackageFolderName, } from "./policies/PackageFolderName.js";
|
|
22
|
+
// Package.json field policies
|
|
11
23
|
export { PackageJsonProperties } from "./policies/PackageJsonProperties.js";
|
|
12
24
|
export { PackageJsonRepoDirectoryProperty } from "./policies/PackageJsonRepoDirectoryProperty.js";
|
|
13
25
|
export { PackageJsonSorted } from "./policies/PackageJsonSorted.js";
|
|
14
26
|
export { PackageLicense, } from "./policies/PackageLicense.js";
|
|
15
27
|
export { PackagePrivateField, } from "./policies/PackagePrivateField.js";
|
|
28
|
+
// Package readme policies
|
|
16
29
|
export { PackageReadme, } from "./policies/PackageReadme.js";
|
|
30
|
+
// Package script policies (legacy - prefer focused policies above)
|
|
17
31
|
export { PackageScripts, } from "./policies/PackageScripts.js";
|
|
18
32
|
export { PackageTestScripts, } from "./policies/PackageTestScripts.js";
|
|
33
|
+
// Gitignore policies
|
|
19
34
|
export { RequiredGitignorePatterns } from "./policies/RequiredGitignorePatterns.js";
|
|
35
|
+
export { RequiredScripts, } from "./policies/RequiredScripts.js";
|
|
36
|
+
export { ScriptContains, } from "./policies/ScriptContains.js";
|
|
37
|
+
// Default policies
|
|
20
38
|
export { DefaultPolicies } from "./policy.js";
|
|
21
39
|
//# sourceMappingURL=policies.js.map
|
package/esm/policies.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policies.js","sourceRoot":"","sources":["../src/policies.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,8BAA8B,EAAE,MAAM,8CAA8C,CAAC;AAC9F,OAAO,EACN,oBAAoB,GAEpB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACN,cAAc,GAEd,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACN,iBAAiB,GAEjB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,gCAAgC,EAAE,MAAM,gDAAgD,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EACN,cAAc,GAEd,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACN,mBAAmB,GAEnB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACN,aAAa,GAEb,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEN,cAAc,GAId,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACN,kBAAkB,GAElB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AACpF,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC","sourcesContent":["// biome-ignore lint/performance/noBarrelFile: intentional public API entry point for policies\nexport { HtmlFileHeaders } from \"./policies/HtmlFileHeaders.js\";\nexport { JsTsFileHeaders } from \"./policies/JsTsFileHeaders.js\";\nexport { LicenseFileExists } from \"./policies/LicenseFileExists.js\";\nexport { NoJsFileExtensions } from \"./policies/NoJsFileExtensions.js\";\nexport { NoLargeBinaryFiles } from \"./policies/NoLargeBinaryFiles.js\";\nexport { NoPrivateWorkspaceDependencies } from \"./policies/NoPrivateWorkspaceDependencies.js\";\nexport {\n\tPackageAllowedScopes,\n\ttype PackageAllowedScopesConfig,\n} from \"./policies/PackageAllowedScopes.js\";\nexport {\n\tPackageEsmType,\n\ttype PackageEsmTypeConfig,\n} from \"./policies/PackageEsmType.js\";\nexport {\n\tPackageFolderName,\n\ttype PackageFolderNameConfig,\n} from \"./policies/PackageFolderName.js\";\nexport { PackageJsonProperties } 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\";\nexport {\n\tPackageReadme,\n\ttype PackageReadmeSettings,\n} from \"./policies/PackageReadme.js\";\nexport {\n\ttype ConditionalScriptRule,\n\tPackageScripts,\n\ttype PackageScriptsSettings,\n\ttype RequiredScriptEntry,\n\ttype ScriptMustContainRule,\n} from \"./policies/PackageScripts.js\";\nexport {\n\tPackageTestScripts,\n\ttype PackageTestScriptsConfig,\n} from \"./policies/PackageTestScripts.js\";\nexport { RequiredGitignorePatterns } from \"./policies/RequiredGitignorePatterns.js\";\nexport { DefaultPolicies } from \"./policy.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"policies.js","sourceRoot":"","sources":["../src/policies.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,8FAA8F;AAC9F,OAAO,EAGN,kBAAkB,GAElB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACN,YAAY,GAEZ,MAAM,4BAA4B,CAAC;AACpC,uBAAuB;AACvB,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,mBAA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ignore lint/performance/noBarrelFile: intentional public API entry point for policies\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// File header policies\nexport { HtmlFileHeaders } from \"./policies/HtmlFileHeaders.js\";\nexport { JsTsFileHeaders } from \"./policies/JsTsFileHeaders.js\";\n// License policies\nexport { LicenseFileExists } from \"./policies/LicenseFileExists.js\";\nexport {\n\tMutuallyExclusiveScripts,\n\ttype MutuallyExclusiveScriptsConfig,\n} from \"./policies/MutuallyExclusiveScripts.js\";\n// File extension policies\nexport { NoJsFileExtensions } from \"./policies/NoJsFileExtensions.js\";\n// File size policies\nexport { NoLargeBinaryFiles } from \"./policies/NoLargeBinaryFiles.js\";\n// Dependency policies\nexport { NoPrivateWorkspaceDependencies } from \"./policies/NoPrivateWorkspaceDependencies.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 { PackageJsonProperties } 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// Gitignore policies\nexport { RequiredGitignorePatterns } from \"./policies/RequiredGitignorePatterns.js\";\nexport {\n\ttype RequiredScriptEntry,\n\tRequiredScripts,\n\ttype RequiredScriptsConfig,\n} from \"./policies/RequiredScripts.js\";\nexport {\n\tScriptContains,\n\ttype ScriptContainsConfig,\n\ttype ScriptContainsRule,\n} from \"./policies/ScriptContains.js\";\n\n// Default policies\nexport { DefaultPolicies } from \"./policy.js\";\n"]}
|