repopo 0.8.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.
Files changed (141) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/THIRD-PARTY-LICENSES.txt +4 -3
  3. package/esm/adapters/fluidFramework.js +8 -3
  4. package/esm/adapters/fluidFramework.js.map +1 -1
  5. package/esm/baseCommand.d.ts.map +1 -1
  6. package/esm/baseCommand.js +2 -1
  7. package/esm/baseCommand.js.map +1 -1
  8. package/esm/commands/check.d.ts +1 -0
  9. package/esm/commands/check.d.ts.map +1 -1
  10. package/esm/commands/check.js +114 -52
  11. package/esm/commands/check.js.map +1 -1
  12. package/esm/commands/list.d.ts.map +1 -1
  13. package/esm/commands/list.js +3 -1
  14. package/esm/commands/list.js.map +1 -1
  15. package/esm/config.d.ts +19 -4
  16. package/esm/config.d.ts.map +1 -1
  17. package/esm/config.js +2 -3
  18. package/esm/config.js.map +1 -1
  19. package/esm/generators.d.ts +30 -2
  20. package/esm/generators.d.ts.map +1 -1
  21. package/esm/generators.js +31 -1
  22. package/esm/generators.js.map +1 -1
  23. package/esm/index.d.ts +14 -4
  24. package/esm/index.d.ts.map +1 -1
  25. package/esm/index.js +17 -2
  26. package/esm/index.js.map +1 -1
  27. package/esm/makePolicy.d.ts +74 -3
  28. package/esm/makePolicy.d.ts.map +1 -1
  29. package/esm/makePolicy.js +87 -13
  30. package/esm/makePolicy.js.map +1 -1
  31. package/esm/perf.d.ts +3 -2
  32. package/esm/perf.d.ts.map +1 -1
  33. package/esm/perf.js +2 -2
  34. package/esm/perf.js.map +1 -1
  35. package/esm/policies/ConditionalScripts.d.ts +94 -0
  36. package/esm/policies/ConditionalScripts.d.ts.map +1 -0
  37. package/esm/policies/ConditionalScripts.js +144 -0
  38. package/esm/policies/ConditionalScripts.js.map +1 -0
  39. package/esm/policies/ExactScripts.d.ts +51 -0
  40. package/esm/policies/ExactScripts.d.ts.map +1 -0
  41. package/esm/policies/ExactScripts.js +107 -0
  42. package/esm/policies/ExactScripts.js.map +1 -0
  43. package/esm/policies/HtmlFileHeaders.d.ts +1 -1
  44. package/esm/policies/HtmlFileHeaders.d.ts.map +1 -1
  45. package/esm/policies/HtmlFileHeaders.js +11 -7
  46. package/esm/policies/HtmlFileHeaders.js.map +1 -1
  47. package/esm/policies/JsTsFileHeaders.d.ts +1 -1
  48. package/esm/policies/JsTsFileHeaders.d.ts.map +1 -1
  49. package/esm/policies/JsTsFileHeaders.js +11 -7
  50. package/esm/policies/JsTsFileHeaders.js.map +1 -1
  51. package/esm/policies/LicenseFileExists.d.ts.map +1 -1
  52. package/esm/policies/LicenseFileExists.js +22 -18
  53. package/esm/policies/LicenseFileExists.js.map +1 -1
  54. package/esm/policies/MutuallyExclusiveScripts.d.ts +46 -0
  55. package/esm/policies/MutuallyExclusiveScripts.d.ts.map +1 -0
  56. package/esm/policies/MutuallyExclusiveScripts.js +52 -0
  57. package/esm/policies/MutuallyExclusiveScripts.js.map +1 -0
  58. package/esm/policies/NoJsFileExtensions.d.ts.map +1 -1
  59. package/esm/policies/NoJsFileExtensions.js +16 -12
  60. package/esm/policies/NoJsFileExtensions.js.map +1 -1
  61. package/esm/policies/NoLargeBinaryFiles.d.ts.map +1 -1
  62. package/esm/policies/NoLargeBinaryFiles.js +35 -31
  63. package/esm/policies/NoLargeBinaryFiles.js.map +1 -1
  64. package/esm/policies/NoPrivateWorkspaceDependencies.d.ts +1 -1
  65. package/esm/policies/NoPrivateWorkspaceDependencies.d.ts.map +1 -1
  66. package/esm/policies/NoPrivateWorkspaceDependencies.js +53 -45
  67. package/esm/policies/NoPrivateWorkspaceDependencies.js.map +1 -1
  68. package/esm/policies/PackageAllowedScopes.d.ts +1 -1
  69. package/esm/policies/PackageAllowedScopes.d.ts.map +1 -1
  70. package/esm/policies/PackageAllowedScopes.js +45 -40
  71. package/esm/policies/PackageAllowedScopes.js.map +1 -1
  72. package/esm/policies/PackageEsmType.d.ts +1 -1
  73. package/esm/policies/PackageEsmType.d.ts.map +1 -1
  74. package/esm/policies/PackageEsmType.js +48 -44
  75. package/esm/policies/PackageEsmType.js.map +1 -1
  76. package/esm/policies/PackageFolderName.d.ts +1 -1
  77. package/esm/policies/PackageFolderName.d.ts.map +1 -1
  78. package/esm/policies/PackageFolderName.js +38 -34
  79. package/esm/policies/PackageFolderName.js.map +1 -1
  80. package/esm/policies/PackageJsonProperties.d.ts +1 -1
  81. package/esm/policies/PackageJsonProperties.d.ts.map +1 -1
  82. package/esm/policies/PackageJsonProperties.js +36 -31
  83. package/esm/policies/PackageJsonProperties.js.map +1 -1
  84. package/esm/policies/PackageJsonRepoDirectoryProperty.d.ts +1 -1
  85. package/esm/policies/PackageJsonRepoDirectoryProperty.d.ts.map +1 -1
  86. package/esm/policies/PackageJsonRepoDirectoryProperty.js +41 -38
  87. package/esm/policies/PackageJsonRepoDirectoryProperty.js.map +1 -1
  88. package/esm/policies/PackageJsonSorted.d.ts +1 -1
  89. package/esm/policies/PackageJsonSorted.d.ts.map +1 -1
  90. package/esm/policies/PackageJsonSorted.js +40 -36
  91. package/esm/policies/PackageJsonSorted.js.map +1 -1
  92. package/esm/policies/PackageLicense.d.ts +1 -1
  93. package/esm/policies/PackageLicense.d.ts.map +1 -1
  94. package/esm/policies/PackageLicense.js +58 -54
  95. package/esm/policies/PackageLicense.js.map +1 -1
  96. package/esm/policies/PackagePrivateField.d.ts +1 -1
  97. package/esm/policies/PackagePrivateField.d.ts.map +1 -1
  98. package/esm/policies/PackagePrivateField.js +58 -54
  99. package/esm/policies/PackagePrivateField.js.map +1 -1
  100. package/esm/policies/PackageReadme.d.ts +1 -1
  101. package/esm/policies/PackageReadme.d.ts.map +1 -1
  102. package/esm/policies/PackageReadme.js +30 -26
  103. package/esm/policies/PackageReadme.js.map +1 -1
  104. package/esm/policies/PackageScripts.d.ts +1 -1
  105. package/esm/policies/PackageScripts.d.ts.map +1 -1
  106. package/esm/policies/PackageScripts.js +39 -35
  107. package/esm/policies/PackageScripts.js.map +1 -1
  108. package/esm/policies/PackageTestScripts.d.ts +1 -1
  109. package/esm/policies/PackageTestScripts.d.ts.map +1 -1
  110. package/esm/policies/PackageTestScripts.js +46 -40
  111. package/esm/policies/PackageTestScripts.js.map +1 -1
  112. package/esm/policies/RequiredGitignorePatterns.d.ts.map +1 -1
  113. package/esm/policies/RequiredGitignorePatterns.js +20 -15
  114. package/esm/policies/RequiredGitignorePatterns.js.map +1 -1
  115. package/esm/policies/RequiredScripts.d.ts +71 -0
  116. package/esm/policies/RequiredScripts.d.ts.map +1 -0
  117. package/esm/policies/RequiredScripts.js +120 -0
  118. package/esm/policies/RequiredScripts.js.map +1 -0
  119. package/esm/policies/ScriptContains.d.ts +64 -0
  120. package/esm/policies/ScriptContains.d.ts.map +1 -0
  121. package/esm/policies/ScriptContains.js +62 -0
  122. package/esm/policies/ScriptContains.js.map +1 -0
  123. package/esm/policies.d.ts +6 -1
  124. package/esm/policies.d.ts.map +1 -1
  125. package/esm/policies.js +18 -0
  126. package/esm/policies.js.map +1 -1
  127. package/esm/policy.d.ts +193 -74
  128. package/esm/policy.d.ts.map +1 -1
  129. package/esm/policy.js +110 -19
  130. package/esm/policy.js.map +1 -1
  131. package/esm/policyDefiners/defineFileHeaderPolicy.d.ts +49 -2
  132. package/esm/policyDefiners/defineFileHeaderPolicy.d.ts.map +1 -1
  133. package/esm/policyDefiners/defineFileHeaderPolicy.js +21 -4
  134. package/esm/policyDefiners/defineFileHeaderPolicy.js.map +1 -1
  135. package/esm/policyDefiners/definePackagePolicy.d.ts +57 -3
  136. package/esm/policyDefiners/definePackagePolicy.d.ts.map +1 -1
  137. package/esm/policyDefiners/definePackagePolicy.js +50 -5
  138. package/esm/policyDefiners/definePackagePolicy.js.map +1 -1
  139. package/esm/tsdoc-metadata.json +1 -1
  140. package/oclif.manifest.json +1 -1
  141. package/package.json +6 -4
package/esm/policy.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { Operation } from "effection";
1
2
  /**
2
3
  * A type representing a policy name.
3
4
  *
@@ -5,11 +6,11 @@
5
6
  */
6
7
  export type PolicyName = string;
7
8
  /**
8
- * Arguments passed to policy functions.
9
+ * Arguments passed to policy handler functions.
9
10
  *
10
11
  * @alpha
11
12
  */
12
- export interface PolicyFunctionArguments<C> {
13
+ export interface PolicyArgs<C = void> {
13
14
  /**
14
15
  * Path to the file, relative to the repo root.
15
16
  */
@@ -23,148 +24,266 @@ export interface PolicyFunctionArguments<C> {
23
24
  */
24
25
  resolve: boolean;
25
26
  /**
26
- * @remarks
27
- *
28
- * Note that the handler function receives the config as an argument.
27
+ * Optional configuration for the policy.
29
28
  */
30
29
  config?: C | undefined;
31
30
  }
32
31
  /**
33
- * A policy handler is a function that is called to check policy against a file.
32
+ * @deprecated Use {@link PolicyArgs} instead.
33
+ * @alpha
34
+ */
35
+ export type PolicyFunctionArguments<C> = PolicyArgs<C>;
36
+ /**
37
+ * A policy error returned when a file fails a policy check.
34
38
  *
35
39
  * @alpha
36
40
  */
37
- export type PolicyHandler<C = unknown | undefined> = (args: PolicyFunctionArguments<C>) => Promise<PolicyHandlerResult>;
41
+ export interface PolicyError {
42
+ /**
43
+ * The error message describing what failed.
44
+ */
45
+ error: string;
46
+ /**
47
+ * Set to `true` if the policy violation can be fixed automatically.
48
+ */
49
+ fixable?: boolean | undefined;
50
+ /**
51
+ * Set to `true` if the violation was successfully fixed (only set when resolve=true).
52
+ */
53
+ fixed?: boolean | undefined;
54
+ /**
55
+ * An optional string that tells the user how to manually fix the failure.
56
+ */
57
+ manualFix?: string | undefined;
58
+ }
38
59
  /**
39
- * A standalone function that can be called to resolve a policy failure.
60
+ * The result of a policy handler.
61
+ * Returns `true` if the file passes the policy, or a {@link PolicyError} if it fails.
40
62
  *
41
63
  * @alpha
42
64
  */
43
- export type PolicyStandaloneResolver<C = undefined> = (args: Omit<PolicyFunctionArguments<C>, "resolve">) => Promise<PolicyFixResult>;
65
+ export type PolicyResult = true | PolicyError;
44
66
  /**
45
- * A RepoPolicyDefinition checks and applies policies to files in the repository.
67
+ * A policy failure (legacy format).
46
68
  *
47
- * Each policy has a name and a match regex for matching which files it should apply to. Every file in th repo is
48
- * enumerated and if it matches the regex for a policy, that policy is applied.
69
+ * @deprecated Use {@link PolicyError} instead, which has a simpler API.
49
70
  *
50
- * Each policy includes a handler function that checks a file against the policy and can optionally resolve any problems
51
- * (automated resolutions depend on the policy implementation).
71
+ * @alpha
72
+ */
73
+ export interface PolicyFailure {
74
+ /**
75
+ * Name of the policy that failed.
76
+ */
77
+ name: PolicyName;
78
+ /**
79
+ * Path to the file that failed the policy.
80
+ */
81
+ file: string;
82
+ /**
83
+ * Set to `true` if the policy can be fixed automatically.
84
+ */
85
+ autoFixable?: boolean | undefined;
86
+ /**
87
+ * An optional error message accompanying the failure.
88
+ */
89
+ errorMessages: string[];
90
+ /**
91
+ * An optional string that tells the user how to fix the failure(s).
92
+ */
93
+ manualFix?: string | undefined;
94
+ }
95
+ /**
96
+ * The result of an automatic fix for a failing policy (legacy format).
52
97
  *
53
- * @typeParam C - type of configuration object used by the policy
98
+ * @deprecated Use {@link PolicyError} with `fixed: boolean` instead.
54
99
  *
55
100
  * @alpha
56
101
  */
57
- export interface PolicyDefinition<C = undefined> {
102
+ export interface PolicyFixResult extends PolicyFailure {
103
+ /**
104
+ * Set to true if the failure was resolved by the automated fixer.
105
+ */
106
+ resolved: boolean;
107
+ }
108
+ /**
109
+ * Result type that accepts both legacy and new formats.
110
+ *
111
+ * @alpha
112
+ */
113
+ export type PolicyHandlerResult = true | PolicyFailure | PolicyFixResult | PolicyError;
114
+ /**
115
+ * A policy handler function that checks a file against a policy.
116
+ *
117
+ * @remarks
118
+ * Policy handlers can be implemented in two ways:
119
+ * - As an async function returning a Promise
120
+ * - As an Effection generator function returning an Operation
121
+ *
122
+ * Both styles are supported. Async handlers are automatically wrapped for Effection.
123
+ *
124
+ * Handlers can return either the legacy format ({@link PolicyFailure}) or
125
+ * the new format ({@link PolicyError}). The new format is simpler and recommended
126
+ * for new policies.
127
+ *
128
+ * @alpha
129
+ */
130
+ export type PolicyHandler<C = unknown | undefined> = ((args: PolicyArgs<C>) => Promise<PolicyHandlerResult>) | ((args: PolicyArgs<C>) => Operation<PolicyHandlerResult>);
131
+ /**
132
+ * A standalone resolver function that can fix policy violations (legacy format).
133
+ *
134
+ * @deprecated Use {@link PolicyResolver} instead, which uses {@link PolicyError}.
135
+ *
136
+ * @alpha
137
+ */
138
+ export type PolicyStandaloneResolver<C = undefined> = (args: Omit<PolicyArgs<C>, "resolve">) => Promise<PolicyFixResult> | Operation<PolicyFixResult>;
139
+ /**
140
+ * A standalone resolver function using the new format.
141
+ *
142
+ * @alpha
143
+ */
144
+ export type PolicyResolver<C = void> = (args: Omit<PolicyArgs<C>, "resolve">) => Promise<PolicyError> | Operation<PolicyError>;
145
+ /**
146
+ * Interface describing the shape of a policy definition.
147
+ *
148
+ * @typeParam C - Type of configuration object used by the policy
149
+ *
150
+ * @alpha
151
+ */
152
+ export interface PolicyShape<C = void> {
58
153
  /**
59
154
  * The name of the policy; displayed in UI and used in settings.
60
155
  */
61
156
  name: PolicyName;
62
157
  /**
63
- * A more detailed description of the policy and its intended function.
158
+ * A detailed description of the policy and its purpose.
64
159
  */
65
- description?: string | undefined;
160
+ description: string;
66
161
  /**
67
- * A regular expression that is used to match files in the repo.
162
+ * A regular expression that matches files this policy applies to.
68
163
  */
69
164
  match: RegExp;
70
165
  /**
71
- * A handler function that checks if a file is compliant with the policy.
72
- *
73
- * @param file - Repo-relative path to the file to check.
74
- * @param root - Absolute path to the root of the repo.
75
- * @param resolve - If true, automated policy fixes will be applied. Not all policies support automated fixes.
76
- * @returns True if the file passed the policy; otherwise a PolicyFailure object will be returned.
166
+ * The handler function that checks if a file complies with the policy.
77
167
  */
78
168
  handler: PolicyHandler<C>;
79
169
  /**
80
- * A resolver function that can be used to automatically address the policy violation.
81
- *
82
- * @param file - Repo-relative path to the file to check.
83
- * @param root - Absolute path to the root of the repo.
84
- * @returns true if the file passed the policy; otherwise a PolicyFailure object will be returned.
170
+ * An optional resolver function that can automatically fix violations.
85
171
  */
86
172
  resolver?: PolicyStandaloneResolver<C> | undefined;
87
173
  /**
88
- * A default config that will be used if none is provided.
174
+ * A default configuration that will be used if none is provided.
89
175
  */
90
176
  defaultConfig?: C | undefined;
91
177
  }
92
178
  /**
179
+ * Abstract base class for creating policies with object-based construction.
180
+ *
181
+ * @remarks
182
+ * This class accepts a {@link PolicyShape} object in its constructor,
183
+ * making it easier to add new optional properties in the future without breaking changes.
184
+ *
93
185
  * @alpha
94
186
  */
95
- export interface PolicyInstanceSettings<C> {
96
- /**
97
- * An array of strings/regular expressions. File paths that match any of these expressions will be completely excluded
98
- * from policy.
99
- *
100
- * Paths will be matched relative to the root of the repo.
101
- */
102
- excludeFiles?: (string | RegExp)[];
103
- /**
104
- * The config that is applied to the policy instance.
105
- */
106
- config?: C | undefined;
187
+ export declare abstract class Policy<C = void> implements PolicyShape<C> {
188
+ readonly name: string;
189
+ readonly description: string;
190
+ readonly match: RegExp;
191
+ readonly handler: PolicyHandler<C>;
192
+ readonly defaultConfig?: C | undefined;
193
+ readonly resolver?: PolicyStandaloneResolver<C> | undefined;
194
+ constructor(definition: PolicyShape<C>);
107
195
  }
108
196
  /**
197
+ * @deprecated Use {@link PolicyShape} instead.
109
198
  * @alpha
110
199
  */
111
- export type PolicyInstance<C = undefined> = PolicyDefinition<C> & PolicyInstanceSettings<C>;
200
+ export type PolicyDefinition<C = undefined> = PolicyShape<C>;
112
201
  /**
113
- * A policy failure.
202
+ * A policy instance with configuration and exclusion settings applied.
203
+ *
204
+ * @typeParam C - Type of configuration object used by the policy
114
205
  *
115
206
  * @alpha
116
207
  */
117
- export interface PolicyFailure {
208
+ export interface ConfiguredPolicy<C = void> extends PolicyShape<C> {
118
209
  /**
119
- * Name of the policy that failed.
210
+ * The configuration applied to this policy instance.
120
211
  */
121
- name: PolicyName;
212
+ config?: C | undefined;
122
213
  /**
123
- * Path to the file that failed the policy.
214
+ * File paths matching these patterns will be excluded from this policy.
215
+ * @deprecated Use `excludeFiles` instead for backward compatibility.
124
216
  */
125
- file: string;
217
+ exclude?: (string | RegExp)[] | undefined;
126
218
  /**
127
- * Set to `true` if the policy can be fixed automatically.
219
+ * File paths matching these patterns will be excluded from this policy.
128
220
  */
129
- autoFixable?: boolean | undefined;
221
+ excludeFiles?: (string | RegExp)[] | undefined;
130
222
  /**
131
- * An optional error message accompanying the failure.
132
- */
133
- errorMessages: string[];
134
- /**
135
- * An optional string that tells the user how to fix the failure(s).
223
+ * Internal normalized handler (always an Effection Operation).
224
+ * This is set by the policy() function and used by the execution engine.
225
+ * @internal
136
226
  */
137
- manualFix?: string;
227
+ _internalHandler?: (args: PolicyArgs<C>) => Operation<PolicyHandlerResult>;
138
228
  }
139
229
  /**
140
- * The result of an automatic fix for a failing policy.
141
- *
230
+ * Settings for configuring a policy instance.
142
231
  * @alpha
143
232
  */
144
- export interface PolicyFixResult extends PolicyFailure {
233
+ export interface PolicyInstanceSettings<C> {
145
234
  /**
146
- * Set to true if the failure was resolved by the automated fixer.
235
+ * An array of strings/regular expressions. File paths that match any of these expressions will be completely excluded
236
+ * from policy.
237
+ *
238
+ * Paths will be matched relative to the root of the repo.
147
239
  */
148
- resolved: boolean;
240
+ excludeFiles?: (string | RegExp)[];
241
+ /**
242
+ * The config that is applied to the policy instance.
243
+ */
244
+ config?: C | undefined;
149
245
  }
150
246
  /**
247
+ * @deprecated Use {@link ConfiguredPolicy} instead.
248
+ * @alpha
249
+ */
250
+ export type PolicyInstance<C = undefined> = ConfiguredPolicy<C>;
251
+ /**
252
+ * Type guard to check if a result is a {@link PolicyFixResult} (legacy).
253
+ *
254
+ * @deprecated Use {@link isPolicyError} instead when working with the new {@link PolicyError} format.
255
+ *
151
256
  * @alpha
152
257
  */
153
- export type PolicyHandlerResult = true | PolicyFailure | PolicyFixResult;
154
258
  export declare function isPolicyFixResult(toCheck: any): toCheck is PolicyFixResult;
259
+ /**
260
+ * Type guard to check if a result is a PolicyError (new format).
261
+ *
262
+ * @alpha
263
+ */
264
+ export declare function isPolicyError(toCheck: any): toCheck is PolicyError;
265
+ /**
266
+ * Type guard to check if a result is a {@link PolicyFailure} (legacy format).
267
+ *
268
+ * @deprecated Use {@link isPolicyError} instead when working with the new {@link PolicyError} format.
269
+ *
270
+ * @alpha
271
+ */
272
+ export declare function isPolicyFailure(toCheck: any): toCheck is PolicyFailure;
273
+ /**
274
+ * Converts a legacy PolicyFailure/PolicyFixResult to the new PolicyError format.
275
+ * @internal
276
+ */
277
+ export declare function convertLegacyResult(result: PolicyHandlerResult, _file: string): PolicyResult;
278
+ /**
279
+ * Converts a new PolicyError to the legacy PolicyFailure format.
280
+ * @internal
281
+ */
282
+ export declare function convertToLegacyResult(result: PolicyError, policyName: string, file: string): PolicyFailure | PolicyFixResult;
155
283
  /**
156
284
  * Default policies included with repopo.
157
285
  *
158
286
  * @alpha
159
287
  */
160
- export declare const DefaultPolicies: PolicyDefinition<any>[];
161
- export declare abstract class Policy<C> implements PolicyDefinition<C> {
162
- readonly name: string;
163
- readonly match: RegExp;
164
- readonly handler: PolicyHandler<C>;
165
- readonly description?: string | undefined;
166
- readonly defaultConfig?: C | undefined;
167
- readonly resolver?: PolicyStandaloneResolver<C> | undefined;
168
- constructor(name: string, match: RegExp, handler: PolicyHandler<C>, description?: string | undefined, defaultConfig?: C | undefined, resolver?: PolicyStandaloneResolver<C> | undefined);
169
- }
288
+ export declare const DefaultPolicies: Policy<any>[];
170
289
  //# sourceMappingURL=policy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../src/policy.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAEhC;;;;GAIG;AAEH,MAAM,WAAW,uBAAuB,CAAC,CAAC;IACzC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,IAAI,EAA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AI,gBAAgB,CAAC,CAAC,CAAC,CAAC;AAMhE;;;;;;GAMG;AAEH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,IAAI,eAAe,CAK1E;AAED;;;;GAIG;AAEH,wBAAgB,aAAa,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,IAAI,WAAW,CAKlE;AAED;;;;;;GAMG;AAEH,wBAAgB,eAAe,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,IAAI,aAAa,CAKtE;AAMD;;;GAGG;AACH,wBAAgB,mBAAmB,CAClC,MAAM,EAAE,mBAAmB,EAC3B,KAAK,EAAE,MAAM,GACX,YAAY,CAoBd;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACpC,MAAM,EAAE,WAAW,EACnB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,GACV,aAAa,GAAG,eAAe,CAiBjC;AAMD;;;;GAIG;AAEH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,GAAG,CAAC,EAI/B,CAAC"}
package/esm/policy.js CHANGED
@@ -1,14 +1,122 @@
1
1
  import { NoJsFileExtensions } from "./policies/NoJsFileExtensions.js";
2
2
  import { PackageJsonRepoDirectoryProperty } from "./policies/PackageJsonRepoDirectoryProperty.js";
3
3
  import { PackageJsonSorted } from "./policies/PackageJsonSorted.js";
4
- import { PackageScripts } from "./policies/PackageScripts.js";
4
+ /**
5
+ * Abstract base class for creating policies with object-based construction.
6
+ *
7
+ * @remarks
8
+ * This class accepts a {@link PolicyShape} object in its constructor,
9
+ * making it easier to add new optional properties in the future without breaking changes.
10
+ *
11
+ * @alpha
12
+ */
13
+ export class Policy {
14
+ name;
15
+ description;
16
+ match;
17
+ handler;
18
+ defaultConfig;
19
+ resolver;
20
+ constructor(definition) {
21
+ this.name = definition.name;
22
+ this.description = definition.description;
23
+ this.match = definition.match;
24
+ this.handler = definition.handler;
25
+ this.defaultConfig = definition.defaultConfig;
26
+ this.resolver = definition.resolver;
27
+ }
28
+ }
29
+ // ============================================================================
30
+ // Type Guards
31
+ // ============================================================================
32
+ /**
33
+ * Type guard to check if a result is a {@link PolicyFixResult} (legacy).
34
+ *
35
+ * @deprecated Use {@link isPolicyError} instead when working with the new {@link PolicyError} format.
36
+ *
37
+ * @alpha
38
+ */
5
39
  // biome-ignore lint/suspicious/noExplicitAny: type guard
6
40
  export function isPolicyFixResult(toCheck) {
7
- if (typeof toCheck !== "object") {
41
+ if (typeof toCheck !== "object" || toCheck === null) {
8
42
  return false;
9
43
  }
10
44
  return "resolved" in toCheck;
11
45
  }
46
+ /**
47
+ * Type guard to check if a result is a PolicyError (new format).
48
+ *
49
+ * @alpha
50
+ */
51
+ // biome-ignore lint/suspicious/noExplicitAny: type guard
52
+ export function isPolicyError(toCheck) {
53
+ if (typeof toCheck !== "object" || toCheck === null) {
54
+ return false;
55
+ }
56
+ return "error" in toCheck && typeof toCheck.error === "string";
57
+ }
58
+ /**
59
+ * Type guard to check if a result is a {@link PolicyFailure} (legacy format).
60
+ *
61
+ * @deprecated Use {@link isPolicyError} instead when working with the new {@link PolicyError} format.
62
+ *
63
+ * @alpha
64
+ */
65
+ // biome-ignore lint/suspicious/noExplicitAny: type guard
66
+ export function isPolicyFailure(toCheck) {
67
+ if (typeof toCheck !== "object" || toCheck === null) {
68
+ return false;
69
+ }
70
+ return "errorMessages" in toCheck && Array.isArray(toCheck.errorMessages);
71
+ }
72
+ // ============================================================================
73
+ // Conversion Functions
74
+ // ============================================================================
75
+ /**
76
+ * Converts a legacy PolicyFailure/PolicyFixResult to the new PolicyError format.
77
+ * @internal
78
+ */
79
+ export function convertLegacyResult(result, _file) {
80
+ if (result === true) {
81
+ return true;
82
+ }
83
+ // Check if it's already the new format
84
+ if (isPolicyError(result)) {
85
+ return result;
86
+ }
87
+ // It's a legacy PolicyFailure or PolicyFixResult
88
+ const error = result.errorMessages?.join("; ") ?? "Policy violation";
89
+ const isFixResult = isPolicyFixResult(result);
90
+ return {
91
+ error,
92
+ fixable: result.autoFixable ?? false,
93
+ fixed: isFixResult ? result.resolved : undefined,
94
+ manualFix: result.manualFix,
95
+ };
96
+ }
97
+ /**
98
+ * Converts a new PolicyError to the legacy PolicyFailure format.
99
+ * @internal
100
+ */
101
+ export function convertToLegacyResult(result, policyName, file) {
102
+ const base = {
103
+ name: policyName,
104
+ file,
105
+ autoFixable: result.fixable,
106
+ errorMessages: [result.error],
107
+ manualFix: result.manualFix,
108
+ };
109
+ if (result.fixed !== undefined) {
110
+ return {
111
+ ...base,
112
+ resolved: result.fixed,
113
+ };
114
+ }
115
+ return base;
116
+ }
117
+ // ============================================================================
118
+ // Default Policies
119
+ // ============================================================================
12
120
  /**
13
121
  * Default policies included with repopo.
14
122
  *
@@ -19,22 +127,5 @@ export const DefaultPolicies = [
19
127
  NoJsFileExtensions,
20
128
  PackageJsonRepoDirectoryProperty,
21
129
  PackageJsonSorted,
22
- PackageScripts,
23
130
  ];
24
- export class Policy {
25
- name;
26
- match;
27
- handler;
28
- description;
29
- defaultConfig;
30
- resolver;
31
- constructor(name, match, handler, description, defaultConfig, resolver) {
32
- this.name = name;
33
- this.match = match;
34
- this.handler = handler;
35
- this.description = description;
36
- this.defaultConfig = defaultConfig;
37
- this.resolver = resolver;
38
- }
39
- }
40
131
  //# sourceMappingURL=policy.js.map
package/esm/policy.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"policy.js","sourceRoot":"","sources":["../src/policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,gCAAgC,EAAE,MAAM,gDAAgD,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAiM9D,yDAAyD;AACzD,MAAM,UAAU,iBAAiB,CAAC,OAAY;IAC7C,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QACjC,OAAO,KAAK,CAAC;IACd,CAAC;IACD,OAAO,UAAU,IAAI,OAAO,CAAC;AAC9B,CAAC;AAED;;;;GAIG;AAEH,oDAAoD;AACpD,MAAM,CAAC,MAAM,eAAe,GAA4B;IACvD,kBAAkB;IAClB,gCAAgC;IAChC,iBAAiB;IACjB,cAAc;CACL,CAAC;AAEX,MAAM,OAAgB,MAAM;IAEV;IACA;IACA;IACA;IACA;IACA;IANjB,YACiB,IAAY,EACZ,KAAa,EACb,OAAyB,EACzB,WAAoB,EACpB,aAAiB,EACjB,QAAsC;QALtC,SAAI,GAAJ,IAAI,CAAQ;QACZ,UAAK,GAAL,KAAK,CAAQ;QACb,YAAO,GAAP,OAAO,CAAkB;QACzB,gBAAW,GAAX,WAAW,CAAS;QACpB,kBAAa,GAAb,aAAa,CAAI;QACjB,aAAQ,GAAR,QAAQ,CAA8B;IACpD,CAAC;CACJ","sourcesContent":["import { NoJsFileExtensions } from \"./policies/NoJsFileExtensions.js\";\nimport { PackageJsonRepoDirectoryProperty } from \"./policies/PackageJsonRepoDirectoryProperty.js\";\nimport { PackageJsonSorted } from \"./policies/PackageJsonSorted.js\";\nimport { PackageScripts } from \"./policies/PackageScripts.js\";\n\n/**\n * A type representing a policy name.\n *\n * @alpha\n */\nexport type PolicyName = string;\n\n/**\n * Arguments passed to policy functions.\n *\n * @alpha\n */\n\nexport interface PolicyFunctionArguments<C> {\n\t/**\n\t * Path to the file, relative to the repo root.\n\t */\n\tfile: string;\n\n\t/**\n\t * Absolute path to the root of the repo.\n\t */\n\troot: string;\n\n\t/**\n\t * If true, the handler should resolve any violations automatically if possible.\n\t */\n\tresolve: boolean;\n\n\t/**\n\t * @remarks\n\t *\n\t * Note that the handler function receives the config as an argument.\n\t */\n\tconfig?: C | undefined;\n}\n\n/**\n * A policy handler is a function that is called to check policy against a file.\n *\n * @alpha\n */\n\nexport type PolicyHandler<C = unknown | undefined> = (\n\targs: PolicyFunctionArguments<C>,\n) => Promise<PolicyHandlerResult>;\n\n// export type PolicyCheckOnly = (\n// \tfile: string,\n// \troot: string,\n// ) => Promise<PolicyHandlerResult>;\n\n/**\n * A standalone function that can be called to resolve a policy failure.\n *\n * @alpha\n */\nexport type PolicyStandaloneResolver<C = undefined> = (\n\targs: Omit<PolicyFunctionArguments<C>, \"resolve\">,\n) => Promise<PolicyFixResult>;\n\n// function isPolicyHandler(input: PolicyHandler | PolicyCheckOnly): input is PolicyHandler\n\n/**\n * A RepoPolicyDefinition checks and applies policies to files in the repository.\n *\n * Each policy has a name and a match regex for matching which files it should apply to. Every file in th repo is\n * enumerated and if it matches the regex for a policy, that policy is applied.\n *\n * Each policy includes a handler function that checks a file against the policy and can optionally resolve any problems\n * (automated resolutions depend on the policy implementation).\n *\n * @typeParam C - type of configuration object used by the policy\n *\n * @alpha\n */\nexport interface PolicyDefinition<C = undefined> {\n\t/**\n\t * The name of the policy; displayed in UI and used in settings.\n\t */\n\tname: PolicyName;\n\n\t/**\n\t * A more detailed description of the policy and its intended function.\n\t */\n\tdescription?: string | undefined;\n\n\t/**\n\t * A regular expression that is used to match files in the repo.\n\t */\n\tmatch: RegExp;\n\n\t/**\n\t * A handler function that checks if a file is compliant with the policy.\n\t *\n\t * @param file - Repo-relative path to the file to check.\n\t * @param root - Absolute path to the root of the repo.\n\t * @param resolve - If true, automated policy fixes will be applied. Not all policies support automated fixes.\n\t * @returns True if the file passed the policy; otherwise a PolicyFailure object will be returned.\n\t */\n\n\thandler: PolicyHandler<C>;\n\n\t/**\n\t * A resolver function that can be used to automatically address the policy violation.\n\t *\n\t * @param file - Repo-relative path to the file to check.\n\t * @param root - Absolute path to the root of the repo.\n\t * @returns true if the file passed the policy; otherwise a PolicyFailure object will be returned.\n\t */\n\tresolver?: PolicyStandaloneResolver<C> | undefined;\n\n\t/**\n\t * A default config that will be used if none is provided.\n\t */\n\tdefaultConfig?: C | undefined;\n}\n\n/**\n * @alpha\n */\nexport interface PolicyInstanceSettings<C> {\n\t/**\n\t * An array of strings/regular expressions. File paths that match any of these expressions will be completely excluded\n\t * from policy.\n\t *\n\t * Paths will be matched relative to the root of the repo.\n\t */\n\texcludeFiles?: (string | RegExp)[];\n\n\t/**\n\t * The config that is applied to the policy instance.\n\t */\n\tconfig?: C | undefined;\n}\n\n/**\n * @alpha\n */\nexport type PolicyInstance<C = undefined> = PolicyDefinition<C> &\n\tPolicyInstanceSettings<C>;\n\n/**\n * A policy failure.\n *\n * @alpha\n */\nexport interface PolicyFailure {\n\t/**\n\t * Name of the policy that failed.\n\t */\n\tname: PolicyName;\n\n\t/**\n\t * Path to the file that failed the policy.\n\t */\n\tfile: string;\n\n\t/**\n\t * Set to `true` if the policy can be fixed automatically.\n\t */\n\tautoFixable?: boolean | undefined;\n\n\t/**\n\t * An optional error message accompanying the failure.\n\t */\n\terrorMessages: string[];\n\n\t/**\n\t * An optional string that tells the user how to fix the failure(s).\n\t */\n\tmanualFix?: string;\n}\n\n/**\n * The result of an automatic fix for a failing policy.\n *\n * @alpha\n */\nexport interface PolicyFixResult extends PolicyFailure {\n\t/**\n\t * Set to true if the failure was resolved by the automated fixer.\n\t */\n\tresolved: boolean;\n}\n\n/**\n * @alpha\n */\nexport type PolicyHandlerResult = true | PolicyFailure | PolicyFixResult;\n\n// biome-ignore lint/suspicious/noExplicitAny: type guard\nexport function isPolicyFixResult(toCheck: any): toCheck is PolicyFixResult {\n\tif (typeof toCheck !== \"object\") {\n\t\treturn false;\n\t}\n\treturn \"resolved\" in toCheck;\n}\n\n/**\n * Default policies included with repopo.\n *\n * @alpha\n */\n\n// biome-ignore lint/suspicious/noExplicitAny: FIXME\nexport const DefaultPolicies: PolicyDefinition<any>[] = [\n\tNoJsFileExtensions,\n\tPackageJsonRepoDirectoryProperty,\n\tPackageJsonSorted,\n\tPackageScripts,\n] as const;\n\nexport abstract class Policy<C> implements PolicyDefinition<C> {\n\tpublic constructor(\n\t\tpublic readonly name: string,\n\t\tpublic readonly match: RegExp,\n\t\tpublic readonly handler: PolicyHandler<C>,\n\t\tpublic readonly description?: string,\n\t\tpublic readonly defaultConfig?: C,\n\t\tpublic readonly resolver?: PolicyStandaloneResolver<C>,\n\t) {}\n}\n"]}
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;AAuOpE;;;;;;;;GAQG;AACH,MAAM,OAAgB,MAAM;IACX,IAAI,CAAS;IACb,WAAW,CAAS;IACpB,KAAK,CAAS;IACd,OAAO,CAAmB;IAC1B,aAAa,CAAiB;IAC9B,QAAQ,CAA2C;IAEnE,YAAmB,UAA0B;QAC5C,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;QAC5B,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC;QAC1C,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;QAC9B,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC;QAClC,IAAI,CAAC,aAAa,GAAG,UAAU,CAAC,aAAa,CAAC;QAC9C,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC;IACrC,CAAC;CACD;AAiED,+EAA+E;AAC/E,cAAc;AACd,+EAA+E;AAE/E;;;;;;GAMG;AACH,yDAAyD;AACzD,MAAM,UAAU,iBAAiB,CAAC,OAAY;IAC7C,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACrD,OAAO,KAAK,CAAC;IACd,CAAC;IACD,OAAO,UAAU,IAAI,OAAO,CAAC;AAC9B,CAAC;AAED;;;;GAIG;AACH,yDAAyD;AACzD,MAAM,UAAU,aAAa,CAAC,OAAY;IACzC,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAA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,WAAW,EAAE,MAAM,CAAC,OAAO;QAC3B,aAAa,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC;QAC7B,SAAS,EAAE,MAAM,CAAC,SAAS;KAC3B,CAAC;IAEF,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAChC,OAAO;YACN,GAAG,IAAI;YACP,QAAQ,EAAE,MAAM,CAAC,KAAK;SACI,CAAC;IAC7B,CAAC;IAED,OAAO,IAAI,CAAC;AACb,CAAC;AAED,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E;;;;GAIG;AACH,oDAAoD;AACpD,MAAM,CAAC,MAAM,eAAe,GAAkB;IAC7C,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\";\n\n/**\n * A type representing a policy name.\n *\n * @alpha\n */\nexport type PolicyName = string;\n\n/**\n * Arguments passed to policy handler functions.\n *\n * @alpha\n */\nexport interface PolicyArgs<C = void> {\n\t/**\n\t * Path to the file, relative to the repo root.\n\t */\n\tfile: string;\n\n\t/**\n\t * Absolute path to the root of the repo.\n\t */\n\troot: string;\n\n\t/**\n\t * If true, the handler should resolve any violations automatically if possible.\n\t */\n\tresolve: boolean;\n\n\t/**\n\t * Optional configuration for the policy.\n\t */\n\tconfig?: C | undefined;\n}\n\n/**\n * @deprecated Use {@link PolicyArgs} instead.\n * @alpha\n */\nexport type PolicyFunctionArguments<C> = PolicyArgs<C>;\n\n// ============================================================================\n// New Result Types\n// ============================================================================\n\n/**\n * A policy error returned when a file fails a policy check.\n *\n * @alpha\n */\nexport interface PolicyError {\n\t/**\n\t * The error message describing what failed.\n\t */\n\terror: string;\n\n\t/**\n\t * Set to `true` if the policy violation can be fixed automatically.\n\t */\n\tfixable?: boolean | undefined;\n\n\t/**\n\t * Set to `true` if the violation was successfully fixed (only set when resolve=true).\n\t */\n\tfixed?: boolean | undefined;\n\n\t/**\n\t * An optional string that tells the user how to manually fix the failure.\n\t */\n\tmanualFix?: string | undefined;\n}\n\n/**\n * The result of a policy handler.\n * Returns `true` if the file passes the policy, or a {@link PolicyError} if it fails.\n *\n * @alpha\n */\nexport type PolicyResult = true | PolicyError;\n\n// ============================================================================\n// Legacy Result Types (Still supported for backward compatibility)\n// ============================================================================\n\n/**\n * A policy failure (legacy format).\n *\n * @deprecated Use {@link PolicyError} instead, which has a simpler API.\n *\n * @alpha\n */\nexport interface PolicyFailure {\n\t/**\n\t * Name of the policy that failed.\n\t */\n\tname: PolicyName;\n\n\t/**\n\t * Path to the file that failed the policy.\n\t */\n\tfile: string;\n\n\t/**\n\t * Set to `true` if the policy can be fixed automatically.\n\t */\n\tautoFixable?: boolean | undefined;\n\n\t/**\n\t * An optional error message accompanying the failure.\n\t */\n\terrorMessages: string[];\n\n\t/**\n\t * An optional string that tells the user how to fix the failure(s).\n\t */\n\tmanualFix?: string | undefined;\n}\n\n/**\n * The result of an automatic fix for a failing policy (legacy format).\n *\n * @deprecated Use {@link PolicyError} with `fixed: boolean` instead.\n *\n * @alpha\n */\nexport interface PolicyFixResult extends PolicyFailure {\n\t/**\n\t * Set to true if the failure was resolved by the automated fixer.\n\t */\n\tresolved: boolean;\n}\n\n/**\n * Result type that accepts both legacy and new formats.\n *\n * @alpha\n */\nexport type PolicyHandlerResult =\n\t| true\n\t| PolicyFailure\n\t| PolicyFixResult\n\t| PolicyError;\n\n// ============================================================================\n// Handler Types\n// ============================================================================\n\n/**\n * A policy handler function that checks a file against a policy.\n *\n * @remarks\n * Policy handlers can be implemented in two ways:\n * - As an async function returning a Promise\n * - As an Effection generator function returning an Operation\n *\n * Both styles are supported. Async handlers are automatically wrapped for Effection.\n *\n * Handlers can return either the legacy format ({@link PolicyFailure}) or\n * the new format ({@link PolicyError}). The new format is simpler and recommended\n * for new policies.\n *\n * @alpha\n */\nexport type PolicyHandler<C = unknown | undefined> =\n\t| ((args: PolicyArgs<C>) => Promise<PolicyHandlerResult>)\n\t| ((args: PolicyArgs<C>) => Operation<PolicyHandlerResult>);\n\n/**\n * A standalone resolver function that can fix policy violations (legacy format).\n *\n * @deprecated Use {@link PolicyResolver} instead, which uses {@link PolicyError}.\n *\n * @alpha\n */\nexport type PolicyStandaloneResolver<C = undefined> = (\n\targs: Omit<PolicyArgs<C>, \"resolve\">,\n) => Promise<PolicyFixResult> | Operation<PolicyFixResult>;\n\n/**\n * A standalone resolver function using the new format.\n *\n * @alpha\n */\nexport type PolicyResolver<C = void> = (\n\targs: Omit<PolicyArgs<C>, \"resolve\">,\n) => Promise<PolicyError> | Operation<PolicyError>;\n\n// ============================================================================\n// Policy Definition Types\n// ============================================================================\n\n/**\n * Interface describing the shape of a policy definition.\n *\n * @typeParam C - Type of configuration object used by the policy\n *\n * @alpha\n */\nexport interface PolicyShape<C = void> {\n\t/**\n\t * The name of the policy; displayed in UI and used in settings.\n\t */\n\tname: PolicyName;\n\n\t/**\n\t * A detailed description of the policy and its purpose.\n\t */\n\tdescription: string;\n\n\t/**\n\t * A regular expression that matches files this policy applies to.\n\t */\n\tmatch: RegExp;\n\n\t/**\n\t * The handler function that checks if a file complies with the policy.\n\t */\n\thandler: PolicyHandler<C>;\n\n\t/**\n\t * An optional resolver function that can automatically fix violations.\n\t */\n\tresolver?: PolicyStandaloneResolver<C> | undefined;\n\n\t/**\n\t * A default configuration that will be used if none is provided.\n\t */\n\tdefaultConfig?: C | undefined;\n}\n\n/**\n * Abstract base class for creating policies with object-based construction.\n *\n * @remarks\n * This class accepts a {@link PolicyShape} object in its constructor,\n * making it easier to add new optional properties in the future without breaking changes.\n *\n * @alpha\n */\nexport abstract class Policy<C = void> implements PolicyShape<C> {\n\tpublic readonly name: string;\n\tpublic readonly description: string;\n\tpublic readonly match: RegExp;\n\tpublic readonly handler: PolicyHandler<C>;\n\tpublic readonly defaultConfig?: C | undefined;\n\tpublic readonly resolver?: PolicyStandaloneResolver<C> | undefined;\n\n\tpublic constructor(definition: PolicyShape<C>) {\n\t\tthis.name = definition.name;\n\t\tthis.description = definition.description;\n\t\tthis.match = definition.match;\n\t\tthis.handler = definition.handler;\n\t\tthis.defaultConfig = definition.defaultConfig;\n\t\tthis.resolver = definition.resolver;\n\t}\n}\n\n/**\n * @deprecated Use {@link PolicyShape} instead.\n * @alpha\n */\nexport type PolicyDefinition<C = undefined> = PolicyShape<C>;\n\n/**\n * A policy instance with configuration and exclusion settings applied.\n *\n * @typeParam C - Type of configuration object used by the policy\n *\n * @alpha\n */\nexport interface ConfiguredPolicy<C = void> extends PolicyShape<C> {\n\t/**\n\t * The configuration applied to this policy instance.\n\t */\n\tconfig?: C | undefined;\n\n\t/**\n\t * File paths matching these patterns will be excluded from this policy.\n\t * @deprecated Use `excludeFiles` instead for backward compatibility.\n\t */\n\texclude?: (string | RegExp)[] | undefined;\n\n\t/**\n\t * File paths matching these patterns will be excluded from this policy.\n\t */\n\texcludeFiles?: (string | RegExp)[] | undefined;\n\n\t/**\n\t * Internal normalized handler (always an Effection Operation).\n\t * This is set by the policy() function and used by the execution engine.\n\t * @internal\n\t */\n\t_internalHandler?: (args: PolicyArgs<C>) => Operation<PolicyHandlerResult>;\n}\n\n/**\n * Settings for configuring a policy instance.\n * @alpha\n */\nexport interface PolicyInstanceSettings<C> {\n\t/**\n\t * An array of strings/regular expressions. File paths that match any of these expressions will be completely excluded\n\t * from policy.\n\t *\n\t * Paths will be matched relative to the root of the repo.\n\t */\n\texcludeFiles?: (string | RegExp)[];\n\n\t/**\n\t * The config that is applied to the policy instance.\n\t */\n\tconfig?: C | undefined;\n}\n\n/**\n * @deprecated Use {@link ConfiguredPolicy} instead.\n * @alpha\n */\nexport type PolicyInstance<C = undefined> = ConfiguredPolicy<C>;\n\n// ============================================================================\n// Type Guards\n// ============================================================================\n\n/**\n * Type guard to check if a result is a {@link PolicyFixResult} (legacy).\n *\n * @deprecated Use {@link isPolicyError} instead when working with the new {@link PolicyError} format.\n *\n * @alpha\n */\n// biome-ignore lint/suspicious/noExplicitAny: type guard\nexport function isPolicyFixResult(toCheck: any): toCheck is PolicyFixResult {\n\tif (typeof toCheck !== \"object\" || toCheck === null) {\n\t\treturn false;\n\t}\n\treturn \"resolved\" in toCheck;\n}\n\n/**\n * Type guard to check if a result is a PolicyError (new format).\n *\n * @alpha\n */\n// biome-ignore lint/suspicious/noExplicitAny: type guard\nexport function isPolicyError(toCheck: any): toCheck is PolicyError {\n\tif (typeof toCheck !== \"object\" || toCheck === null) {\n\t\treturn false;\n\t}\n\treturn \"error\" in toCheck && typeof toCheck.error === \"string\";\n}\n\n/**\n * Type guard to check if a result is a {@link PolicyFailure} (legacy format).\n *\n * @deprecated Use {@link isPolicyError} instead when working with the new {@link PolicyError} format.\n *\n * @alpha\n */\n// biome-ignore lint/suspicious/noExplicitAny: type guard\nexport function isPolicyFailure(toCheck: any): toCheck is PolicyFailure {\n\tif (typeof toCheck !== \"object\" || toCheck === null) {\n\t\treturn false;\n\t}\n\treturn \"errorMessages\" in toCheck && Array.isArray(toCheck.errorMessages);\n}\n\n// ============================================================================\n// Conversion Functions\n// ============================================================================\n\n/**\n * Converts a legacy PolicyFailure/PolicyFixResult to the new PolicyError format.\n * @internal\n */\nexport function convertLegacyResult(\n\tresult: PolicyHandlerResult,\n\t_file: string,\n): PolicyResult {\n\tif (result === true) {\n\t\treturn true;\n\t}\n\n\t// Check if it's already the new format\n\tif (isPolicyError(result)) {\n\t\treturn result;\n\t}\n\n\t// It's a legacy PolicyFailure or PolicyFixResult\n\tconst error = result.errorMessages?.join(\"; \") ?? \"Policy violation\";\n\tconst isFixResult = isPolicyFixResult(result);\n\n\treturn {\n\t\terror,\n\t\tfixable: result.autoFixable ?? false,\n\t\tfixed: isFixResult ? result.resolved : undefined,\n\t\tmanualFix: result.manualFix,\n\t};\n}\n\n/**\n * Converts a new PolicyError to the legacy PolicyFailure format.\n * @internal\n */\nexport function convertToLegacyResult(\n\tresult: PolicyError,\n\tpolicyName: string,\n\tfile: string,\n): PolicyFailure | PolicyFixResult {\n\tconst base: PolicyFailure = {\n\t\tname: policyName,\n\t\tfile,\n\t\tautoFixable: result.fixable,\n\t\terrorMessages: [result.error],\n\t\tmanualFix: result.manualFix,\n\t};\n\n\tif (result.fixed !== undefined) {\n\t\treturn {\n\t\t\t...base,\n\t\t\tresolved: result.fixed,\n\t\t} satisfies PolicyFixResult;\n\t}\n\n\treturn base;\n}\n\n// ============================================================================\n// Default Policies\n// ============================================================================\n\n/**\n * Default policies included with repopo.\n *\n * @alpha\n */\n// biome-ignore lint/suspicious/noExplicitAny: FIXME\nexport const DefaultPolicies: Policy<any>[] = [\n\tNoJsFileExtensions,\n\tPackageJsonRepoDirectoryProperty,\n\tPackageJsonSorted,\n] as const;\n"]}
@@ -1,4 +1,4 @@
1
- import type { PolicyDefinition } from "../policy.js";
1
+ import type { PolicyShape } from "../policy.js";
2
2
  /**
3
3
  * @alpha
4
4
  */
@@ -13,9 +13,16 @@ export interface FileHeaderPolicyConfig {
13
13
  autoGenText?: string;
14
14
  }
15
15
  /**
16
+ * Configuration for generating file headers with specific formatting rules.
17
+ *
18
+ * @remarks
19
+ * This interface extends FileHeaderPolicyConfig and adds formatting-specific
20
+ * properties to control how headers are inserted into different file types.
21
+ *
16
22
  * @alpha
17
23
  */
18
24
  export interface FileHeaderGeneratorConfig extends Partial<FileHeaderPolicyConfig> {
25
+ /** Regular expression that matches files this header generator applies to */
19
26
  match: RegExp;
20
27
  /**
21
28
  * Regex matching header prefix (e.g. `/*!\r?\n`)
@@ -33,13 +40,53 @@ export interface FileHeaderGeneratorConfig extends Partial<FileHeaderPolicyConfi
33
40
  * Regex matching the header postfix.
34
41
  */
35
42
  headerEnd?: RegExp;
43
+ /**
44
+ * Function that generates the properly formatted header content for insertion into files.
45
+ *
46
+ * @param content - The original file content
47
+ * @param config - The file header policy configuration
48
+ * @returns The formatted header string to insert
49
+ */
36
50
  replacer: (content: string, config: FileHeaderPolicyConfig) => string;
37
51
  }
52
+ /**
53
+ * Input arguments for defining a file header policy.
54
+ *
55
+ * @alpha
56
+ */
57
+ export interface DefineFileHeaderPolicyArgs {
58
+ /**
59
+ * The name of the policy.
60
+ */
61
+ name: string;
62
+ /**
63
+ * A description of the policy's purpose.
64
+ */
65
+ description: string;
66
+ /**
67
+ * Configuration for how headers are detected and inserted.
68
+ */
69
+ config: FileHeaderGeneratorConfig;
70
+ }
38
71
  /**
39
72
  * Given a {@link FileHeaderPolicyConfig}, produces a function that detects correct file headers
40
73
  * and returns an error string if the header is missing or incorrect.
41
74
  *
75
+ * @example
76
+ * ```typescript
77
+ * const MyHeaderPolicy = defineFileHeaderPolicy({
78
+ * name: "MyHeaderPolicy",
79
+ * description: "Ensures files have required headers",
80
+ * config: { match: /\.ts$/, lineStart: /\/\/ /, lineEnd: /\r?\n/, replacer: ... },
81
+ * });
82
+ * ```
83
+ *
84
+ * @alpha
85
+ */
86
+ export declare function defineFileHeaderPolicy(args: DefineFileHeaderPolicyArgs): PolicyShape<FileHeaderPolicyConfig>;
87
+ /**
88
+ * Alias for defineFileHeaderPolicy.
42
89
  * @alpha
43
90
  */
44
- export declare function defineFileHeaderPolicy(name: string, config: FileHeaderGeneratorConfig): PolicyDefinition<FileHeaderPolicyConfig>;
91
+ export declare const fileHeaderPolicy: typeof defineFileHeaderPolicy;
45
92
  //# sourceMappingURL=defineFileHeaderPolicy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"defineFileHeaderPolicy.d.ts","sourceRoot":"","sources":["../../src/policyDefiners/defineFileHeaderPolicy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACX,gBAAgB,EAGhB,MAAM,cAAc,CAAC;AAItB;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,WAAW,CAAC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M,CAAC;CACtE;AAED;;;;GAIG;AACH,MAAM,WAAW,0BAA0B;IAC1C;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,MAAM,EAAE,yBAAyB,CAAC;CAClC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CACrC,IAAI,EAAE,0BAA0B,GAC9B,WAAW,CAAC,sBAAsB,CAAC,CAoErC;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,+BAAyB,CAAC"}