repopo 0.10.0 → 0.12.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 (229) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/README.md +41 -2
  3. package/THIRD-PARTY-LICENSES.txt +71 -11
  4. package/bin/dev.js +5 -1
  5. package/esm/baseCommand.d.ts +1 -1
  6. package/esm/baseCommand.d.ts.map +1 -1
  7. package/esm/baseCommand.js +6 -9
  8. package/esm/baseCommand.js.map +1 -1
  9. package/esm/commands/check-native.d.ts +25 -0
  10. package/esm/commands/check-native.d.ts.map +1 -0
  11. package/esm/commands/check-native.js +137 -0
  12. package/esm/commands/check-native.js.map +1 -0
  13. package/esm/commands/check.d.ts +8 -20
  14. package/esm/commands/check.d.ts.map +1 -1
  15. package/esm/commands/check.js +77 -186
  16. package/esm/commands/check.js.map +1 -1
  17. package/esm/commands/list.d.ts.map +1 -1
  18. package/esm/commands/list.js +5 -6
  19. package/esm/commands/list.js.map +1 -1
  20. package/esm/context.d.ts +13 -3
  21. package/esm/context.d.ts.map +1 -1
  22. package/esm/context.js +11 -1
  23. package/esm/context.js.map +1 -1
  24. package/esm/index.d.ts +6 -1
  25. package/esm/index.d.ts.map +1 -1
  26. package/esm/index.js +3 -0
  27. package/esm/index.js.map +1 -1
  28. package/esm/makePolicy.d.ts +29 -2
  29. package/esm/makePolicy.d.ts.map +1 -1
  30. package/esm/makePolicy.js +46 -2
  31. package/esm/makePolicy.js.map +1 -1
  32. package/esm/perf.d.ts +7 -2
  33. package/esm/perf.d.ts.map +1 -1
  34. package/esm/perf.js.map +1 -1
  35. package/esm/policies/CargoLicenceValidated.d.ts +41 -0
  36. package/esm/policies/CargoLicenceValidated.d.ts.map +1 -0
  37. package/esm/policies/CargoLicenceValidated.js +45 -0
  38. package/esm/policies/CargoLicenceValidated.js.map +1 -0
  39. package/esm/policies/CargoLintsConfigured.d.ts +30 -0
  40. package/esm/policies/CargoLintsConfigured.d.ts.map +1 -0
  41. package/esm/policies/CargoLintsConfigured.js +61 -0
  42. package/esm/policies/CargoLintsConfigured.js.map +1 -0
  43. package/esm/policies/CargoLockPolicy.d.ts +34 -0
  44. package/esm/policies/CargoLockPolicy.d.ts.map +1 -0
  45. package/esm/policies/CargoLockPolicy.js +57 -0
  46. package/esm/policies/CargoLockPolicy.js.map +1 -0
  47. package/esm/policies/CargoTomlRequired.d.ts +34 -0
  48. package/esm/policies/CargoTomlRequired.d.ts.map +1 -0
  49. package/esm/policies/CargoTomlRequired.js +77 -0
  50. package/esm/policies/CargoTomlRequired.js.map +1 -0
  51. package/esm/policies/CargoTomlSorted.d.ts +20 -0
  52. package/esm/policies/CargoTomlSorted.d.ts.map +1 -0
  53. package/esm/policies/CargoTomlSorted.js +164 -0
  54. package/esm/policies/CargoTomlSorted.js.map +1 -0
  55. package/esm/policies/ConditionalScripts.d.ts.map +1 -1
  56. package/esm/policies/ConditionalScripts.js +3 -2
  57. package/esm/policies/ConditionalScripts.js.map +1 -1
  58. package/esm/policies/ExactScripts.d.ts.map +1 -1
  59. package/esm/policies/ExactScripts.js +3 -2
  60. package/esm/policies/ExactScripts.js.map +1 -1
  61. package/esm/policies/GleamDepVersions.d.ts +25 -0
  62. package/esm/policies/GleamDepVersions.d.ts.map +1 -0
  63. package/esm/policies/GleamDepVersions.js +67 -0
  64. package/esm/policies/GleamDepVersions.js.map +1 -0
  65. package/esm/policies/GleamDocExists.d.ts +24 -0
  66. package/esm/policies/GleamDocExists.d.ts.map +1 -0
  67. package/esm/policies/GleamDocExists.js +39 -0
  68. package/esm/policies/GleamDocExists.js.map +1 -0
  69. package/esm/policies/GleamInternalModulesConfigured.d.ts +21 -0
  70. package/esm/policies/GleamInternalModulesConfigured.d.ts.map +1 -0
  71. package/esm/policies/GleamInternalModulesConfigured.js +30 -0
  72. package/esm/policies/GleamInternalModulesConfigured.js.map +1 -0
  73. package/esm/policies/GleamLicenceConfigured.d.ts +29 -0
  74. package/esm/policies/GleamLicenceConfigured.d.ts.map +1 -0
  75. package/esm/policies/GleamLicenceConfigured.js +34 -0
  76. package/esm/policies/GleamLicenceConfigured.js.map +1 -0
  77. package/esm/policies/GleamManifestCommitted.d.ts +9 -0
  78. package/esm/policies/GleamManifestCommitted.d.ts.map +1 -0
  79. package/esm/policies/GleamManifestCommitted.js +26 -0
  80. package/esm/policies/GleamManifestCommitted.js.map +1 -0
  81. package/esm/policies/GleamMonorepoConsistency.d.ts +30 -0
  82. package/esm/policies/GleamMonorepoConsistency.d.ts.map +1 -0
  83. package/esm/policies/GleamMonorepoConsistency.js +74 -0
  84. package/esm/policies/GleamMonorepoConsistency.js.map +1 -0
  85. package/esm/policies/GleamNameRestrictions.d.ts +25 -0
  86. package/esm/policies/GleamNameRestrictions.d.ts.map +1 -0
  87. package/esm/policies/GleamNameRestrictions.js +44 -0
  88. package/esm/policies/GleamNameRestrictions.js.map +1 -0
  89. package/esm/policies/GleamNoPathDepsInPublished.d.ts +22 -0
  90. package/esm/policies/GleamNoPathDepsInPublished.d.ts.map +1 -0
  91. package/esm/policies/GleamNoPathDepsInPublished.js +43 -0
  92. package/esm/policies/GleamNoPathDepsInPublished.js.map +1 -0
  93. package/esm/policies/GleamPathDepsValid.d.ts +9 -0
  94. package/esm/policies/GleamPathDepsValid.d.ts.map +1 -0
  95. package/esm/policies/GleamPathDepsValid.js +59 -0
  96. package/esm/policies/GleamPathDepsValid.js.map +1 -0
  97. package/esm/policies/GleamProjectStructure.d.ts +25 -0
  98. package/esm/policies/GleamProjectStructure.d.ts.map +1 -0
  99. package/esm/policies/GleamProjectStructure.js +33 -0
  100. package/esm/policies/GleamProjectStructure.js.map +1 -0
  101. package/esm/policies/GleamSharedDependencyVersions.d.ts +29 -0
  102. package/esm/policies/GleamSharedDependencyVersions.d.ts.map +1 -0
  103. package/esm/policies/GleamSharedDependencyVersions.js +101 -0
  104. package/esm/policies/GleamSharedDependencyVersions.js.map +1 -0
  105. package/esm/policies/GleamTomlRequired.d.ts +30 -0
  106. package/esm/policies/GleamTomlRequired.d.ts.map +1 -0
  107. package/esm/policies/GleamTomlRequired.js +37 -0
  108. package/esm/policies/GleamTomlRequired.js.map +1 -0
  109. package/esm/policies/GleamTomlSorted.d.ts +20 -0
  110. package/esm/policies/GleamTomlSorted.d.ts.map +1 -0
  111. package/esm/policies/GleamTomlSorted.js +153 -0
  112. package/esm/policies/GleamTomlSorted.js.map +1 -0
  113. package/esm/policies/GleamVersionConstraint.d.ts +20 -0
  114. package/esm/policies/GleamVersionConstraint.d.ts.map +1 -0
  115. package/esm/policies/GleamVersionConstraint.js +64 -0
  116. package/esm/policies/GleamVersionConstraint.js.map +1 -0
  117. package/esm/policies/HtmlFileHeaders.js +1 -1
  118. package/esm/policies/HtmlFileHeaders.js.map +1 -1
  119. package/esm/policies/NoBuildDirectory.d.ts +9 -0
  120. package/esm/policies/NoBuildDirectory.d.ts.map +1 -0
  121. package/esm/policies/NoBuildDirectory.js +29 -0
  122. package/esm/policies/NoBuildDirectory.js.map +1 -0
  123. package/esm/policies/NoTargetArtifacts.d.ts +8 -0
  124. package/esm/policies/NoTargetArtifacts.d.ts.map +1 -0
  125. package/esm/policies/NoTargetArtifacts.js +42 -0
  126. package/esm/policies/NoTargetArtifacts.js.map +1 -0
  127. package/esm/policies/NoUnsafeWithoutJustification.d.ts +24 -0
  128. package/esm/policies/NoUnsafeWithoutJustification.d.ts.map +1 -0
  129. package/esm/policies/NoUnsafeWithoutJustification.js +80 -0
  130. package/esm/policies/NoUnsafeWithoutJustification.js.map +1 -0
  131. package/esm/policies/NoWildcardDependencies.d.ts +30 -0
  132. package/esm/policies/NoWildcardDependencies.d.ts.map +1 -0
  133. package/esm/policies/NoWildcardDependencies.js +83 -0
  134. package/esm/policies/NoWildcardDependencies.js.map +1 -0
  135. package/esm/policies/PackageEsmType.d.ts.map +1 -1
  136. package/esm/policies/PackageEsmType.js +7 -5
  137. package/esm/policies/PackageEsmType.js.map +1 -1
  138. package/esm/policies/PackageJsonProperties.d.ts.map +1 -1
  139. package/esm/policies/PackageJsonProperties.js +12 -4
  140. package/esm/policies/PackageJsonProperties.js.map +1 -1
  141. package/esm/policies/PackageJsonRepoDirectoryProperty.d.ts.map +1 -1
  142. package/esm/policies/PackageJsonRepoDirectoryProperty.js +3 -2
  143. package/esm/policies/PackageJsonRepoDirectoryProperty.js.map +1 -1
  144. package/esm/policies/PackageJsonSorted.d.ts.map +1 -1
  145. package/esm/policies/PackageJsonSorted.js +42 -7
  146. package/esm/policies/PackageJsonSorted.js.map +1 -1
  147. package/esm/policies/PackageLicense.d.ts.map +1 -1
  148. package/esm/policies/PackageLicense.js +1 -2
  149. package/esm/policies/PackageLicense.js.map +1 -1
  150. package/esm/policies/PackagePrivateField.d.ts.map +1 -1
  151. package/esm/policies/PackagePrivateField.js +3 -2
  152. package/esm/policies/PackagePrivateField.js.map +1 -1
  153. package/esm/policies/PackageReadme.js +2 -2
  154. package/esm/policies/PackageReadme.js.map +1 -1
  155. package/esm/policies/PackageScripts.d.ts.map +1 -1
  156. package/esm/policies/PackageScripts.js +3 -2
  157. package/esm/policies/PackageScripts.js.map +1 -1
  158. package/esm/policies/PackageTestScripts.js +3 -3
  159. package/esm/policies/PackageTestScripts.js.map +1 -1
  160. package/esm/policies/PublicApiDocumented.d.ts +21 -0
  161. package/esm/policies/PublicApiDocumented.d.ts.map +1 -0
  162. package/esm/policies/PublicApiDocumented.js +36 -0
  163. package/esm/policies/PublicApiDocumented.js.map +1 -0
  164. package/esm/policies/RequiredScripts.d.ts.map +1 -1
  165. package/esm/policies/RequiredScripts.js +3 -2
  166. package/esm/policies/RequiredScripts.js.map +1 -1
  167. package/esm/policies/RustDocExists.d.ts +24 -0
  168. package/esm/policies/RustDocExists.d.ts.map +1 -0
  169. package/esm/policies/RustDocExists.js +49 -0
  170. package/esm/policies/RustDocExists.js.map +1 -0
  171. package/esm/policies/RustToolchainExists.d.ts +20 -0
  172. package/esm/policies/RustToolchainExists.d.ts.map +1 -0
  173. package/esm/policies/RustToolchainExists.js +27 -0
  174. package/esm/policies/RustToolchainExists.js.map +1 -0
  175. package/esm/policies/RustfmtConfigExists.d.ts +20 -0
  176. package/esm/policies/RustfmtConfigExists.d.ts.map +1 -0
  177. package/esm/policies/RustfmtConfigExists.js +27 -0
  178. package/esm/policies/RustfmtConfigExists.js.map +1 -0
  179. package/esm/policies/SharedDependencyVersions.d.ts +24 -0
  180. package/esm/policies/SharedDependencyVersions.d.ts.map +1 -0
  181. package/esm/policies/SharedDependencyVersions.js +135 -0
  182. package/esm/policies/SharedDependencyVersions.js.map +1 -0
  183. package/esm/policies/WorkspaceInheritance.d.ts +24 -0
  184. package/esm/policies/WorkspaceInheritance.d.ts.map +1 -0
  185. package/esm/policies/WorkspaceInheritance.js +94 -0
  186. package/esm/policies/WorkspaceInheritance.js.map +1 -0
  187. package/esm/policies/WorkspaceMembersValid.d.ts +20 -0
  188. package/esm/policies/WorkspaceMembersValid.d.ts.map +1 -0
  189. package/esm/policies/WorkspaceMembersValid.js +88 -0
  190. package/esm/policies/WorkspaceMembersValid.js.map +1 -0
  191. package/esm/policies/constants.d.ts +8 -0
  192. package/esm/policies/constants.d.ts.map +1 -1
  193. package/esm/policies/constants.js +8 -0
  194. package/esm/policies/constants.js.map +1 -1
  195. package/esm/policies.d.ts +30 -0
  196. package/esm/policies.d.ts.map +1 -1
  197. package/esm/policies.js +51 -1
  198. package/esm/policies.js.map +1 -1
  199. package/esm/policy.d.ts +24 -0
  200. package/esm/policy.d.ts.map +1 -1
  201. package/esm/policy.js.map +1 -1
  202. package/esm/policyDefiners/defineCargoPolicy.d.ts +66 -0
  203. package/esm/policyDefiners/defineCargoPolicy.d.ts.map +1 -0
  204. package/esm/policyDefiners/defineCargoPolicy.js +60 -0
  205. package/esm/policyDefiners/defineCargoPolicy.js.map +1 -0
  206. package/esm/policyDefiners/defineFileHeaderPolicy.d.ts.map +1 -1
  207. package/esm/policyDefiners/defineFileHeaderPolicy.js +6 -7
  208. package/esm/policyDefiners/defineFileHeaderPolicy.js.map +1 -1
  209. package/esm/policyDefiners/defineGleamPolicy.d.ts +65 -0
  210. package/esm/policyDefiners/defineGleamPolicy.d.ts.map +1 -0
  211. package/esm/policyDefiners/defineGleamPolicy.js +59 -0
  212. package/esm/policyDefiners/defineGleamPolicy.js.map +1 -0
  213. package/esm/policyDefiners/spdxValidator.d.ts +74 -0
  214. package/esm/policyDefiners/spdxValidator.d.ts.map +1 -0
  215. package/esm/policyDefiners/spdxValidator.js +127 -0
  216. package/esm/policyDefiners/spdxValidator.js.map +1 -0
  217. package/esm/policyDefiners/tomlParser.d.ts +8 -0
  218. package/esm/policyDefiners/tomlParser.d.ts.map +1 -0
  219. package/esm/policyDefiners/tomlParser.js +17 -0
  220. package/esm/policyDefiners/tomlParser.js.map +1 -0
  221. package/esm/runner.d.ts +60 -0
  222. package/esm/runner.d.ts.map +1 -0
  223. package/esm/runner.js +174 -0
  224. package/esm/runner.js.map +1 -0
  225. package/esm/tsdoc-metadata.json +1 -1
  226. package/oclif.manifest.json +100 -3
  227. package/package.json +46 -31
  228. package/scripts/postinstall.mjs +154 -0
  229. package/sidecar/sidecar.mjs +468 -0
@@ -2,20 +2,12 @@ import { EOL as newline } from "node:os";
2
2
  import process from "node:process";
3
3
  import { Flags } from "@oclif/core";
4
4
  import { StringBuilder } from "@rushstack/node-core-library";
5
- import { all, call, run } from "effection";
5
+ import { call, run } from "effection";
6
6
  import chalk from "picocolors";
7
- /**
8
- * Type guard to check if a value is an Effection Operation (generator).
9
- */
10
- function isOperation(value) {
11
- return (typeof value === "object" &&
12
- value !== null &&
13
- "next" in value &&
14
- typeof value.next === "function");
15
- }
16
7
  import { BaseRepopoCommand } from "../baseCommand.js";
17
- import { logStats, runWithPerf } from "../perf.js";
8
+ import { logStats } from "../perf.js";
18
9
  import { isPolicyError, isPolicyFixResult, } from "../policy.js";
10
+ import { PolicyRunner } from "../runner.js";
19
11
  async function readStdin() {
20
12
  return new Promise((resolve) => {
21
13
  const stdin = process.stdin;
@@ -60,184 +52,102 @@ export class CheckPolicy extends BaseRepopoCommand {
60
52
  if (this.flags.fix) {
61
53
  this.info("Resolving errors if possible.");
62
54
  }
63
- const config = this.commandConfig;
64
- const policies = config?.policies ?? [];
65
- this.verbose(`${policies.length} policies loaded.`);
66
- for (const h of policies) {
67
- this.verbose(h.name);
55
+ const filePathsToCheck = await this.collectFilePaths();
56
+ const context = await this.getContext();
57
+ this.verbose(`${context.policies.length} policies loaded.`);
58
+ for (const configuredPolicy of context.policies) {
59
+ this.verbose(configuredPolicy.instanceId);
60
+ }
61
+ const runner = new PolicyRunner({
62
+ policies: context.policies,
63
+ excludeFromAll: context.excludeFromAll,
64
+ excludePoliciesForFiles: context.excludePoliciesForFiles,
65
+ gitRoot: context.gitRoot,
66
+ resolve: this.flags.fix,
67
+ logger: this.logger,
68
+ });
69
+ const runResults = await run(() => runner.run(filePathsToCheck));
70
+ // Format and log results
71
+ for (const result of runResults.results) {
72
+ this.formatResult(result);
73
+ }
74
+ if (!this.flags.quiet) {
75
+ logStats(runResults.perfStats, this.logger);
68
76
  }
69
- const filePathsToCheck = [];
77
+ }
78
+ /**
79
+ * Collects file paths to check from either stdin or git ls-files.
80
+ */
81
+ async collectFilePaths() {
70
82
  if (this.flags.stdin) {
71
83
  const stdInput = await run(function* () {
72
84
  return yield* call(() => readStdin());
73
85
  });
74
86
  if (stdInput !== undefined && stdInput !== null) {
75
- filePathsToCheck.push(...stdInput
87
+ return stdInput
76
88
  .replace(
77
89
  // normalize slashes in case they're windows paths
78
90
  /\\/g, "/")
79
- .split("\n"));
91
+ .split("\n");
80
92
  }
81
- }
82
- else {
83
- const gitFiles = (await this.git.raw("ls-files",
84
- // include staged files and untracked files
85
- "-co",
86
- // exclude gitignored files and other standard ignore rules
87
- "--exclude-standard",
88
- // Outputs paths relative to the root of the repository, regardless of the current working directory.
89
- "--full-name")) ?? "";
90
- filePathsToCheck.push(...gitFiles
91
- .replace(
92
- // normalize slashes in case they're windows paths
93
- /\\/g, "/")
94
- .split("\n"));
95
- }
96
- const context = await this.getContext();
97
- await run(() => this.checkAllFiles(filePathsToCheck, context));
93
+ return [];
94
+ }
95
+ const gitFiles = (await this.git.raw("ls-files",
96
+ // include staged files and untracked files
97
+ "-co",
98
+ // NUL-delimited paths are not quoted or escaped by Git.
99
+ "-z",
100
+ // exclude gitignored files and other standard ignore rules
101
+ "--exclude-standard",
102
+ // Outputs paths relative to the root of the repository, regardless of the current working directory.
103
+ "--full-name")) ?? "";
104
+ return gitFiles.split("\0").filter((file) => file.length > 0);
98
105
  }
99
106
  /**
100
- * Executes all policies against the provided paths.
101
- *
102
- * @param pathsToCheck - All paths that should be checked. Paths should be relative to the repository root.
103
- * @param context - The context.
107
+ * Formats a single policy file result, logging messages and setting exit codes.
104
108
  */
105
- *checkAllFiles(pathsToCheck, context) {
106
- try {
107
- for (const pathToCheck of pathsToCheck) {
108
- yield* this.checkOrExcludeFile(pathToCheck, context);
109
- }
110
- }
111
- finally {
112
- if (!this.flags.quiet) {
113
- logStats(context.perfStats, this.logger);
114
- }
115
- }
116
- }
117
- /**
118
- * Given a string that represents a path to a file in the repo, determines if the file should be checked, and if so,
119
- * routes the file to the appropriate handlers.
120
- *
121
- * @param relPath - A git repo-relative path to a file.
122
- */
123
- *checkOrExcludeFile(relPath, context) {
124
- const { perfStats } = context;
125
- perfStats.count++;
126
- try {
127
- yield* this.routeToPolicies(relPath, context);
128
- }
129
- catch (error) {
130
- throw new Error(`Error routing ${relPath} to handler: ${error}\nStack:\n${error.stack}`);
131
- }
132
- }
133
- *routeToPolicies(relPath, context) {
134
- const { policies, excludeFromAll } = context;
135
- // Check exclusions
136
- if (excludeFromAll.some((regex) => regex.test(relPath))) {
137
- this.verbose(`Excluded all handlers: ${relPath}`);
109
+ formatResult(result) {
110
+ const { outcome, resolution } = result;
111
+ // Handle fix results (legacy format with resolved property)
112
+ if (isPolicyFixResult(outcome)) {
113
+ this.formatFixResult(outcome.resolved, outcome.file, result.policyId);
138
114
  return;
139
115
  }
140
- // Run all matching policies
141
- const matchingPolicies = policies.filter((policy) => policy.match.test(relPath));
142
- yield* all(matchingPolicies.map((policy) => {
143
- return this.runPolicyOnFile(relPath, policy, context);
144
- }));
145
- }
146
- *runPolicyOnFile(relPath, policy, context) {
147
- const { excludePoliciesForFiles, perfStats, gitRoot } = context;
148
- // Check if the policy is excluded for the file
149
- if (this.isPolicyExcluded(relPath, policy, excludePoliciesForFiles)) {
150
- this.verbose(`Excluded from '${policy.name}' policy: ${relPath}`);
151
- return;
152
- }
153
- try {
154
- // Execute the policy handler
155
- const result = yield* this.executePolicyHandler(relPath, policy, perfStats, gitRoot);
156
- // Handle the result of the policy execution
157
- yield* this.handlePolicyResult(result, relPath, policy, perfStats, gitRoot);
158
- }
159
- catch (error) {
160
- // Log and rethrow the error for higher-level handling
161
- this.exit(`Error executing policy '${policy.name}' for file '${relPath}': ${error}`);
162
- }
163
- }
164
- isPolicyExcluded(relPath, policy, excludePoliciesForFiles) {
165
- return (excludePoliciesForFiles
166
- .get(policy.name)
167
- ?.some((regex) => regex.test(relPath)) ?? false);
168
- }
169
- *executePolicyHandler(relPath, policy, perfStats, gitRoot) {
170
- const resolve = this.flags.fix;
171
- try {
172
- const result = yield* runWithPerf(policy.name, "handle", perfStats, function* () {
173
- const args = {
174
- file: relPath,
175
- root: gitRoot,
176
- resolve,
177
- config: policy.config,
178
- };
179
- // Use normalized _internalHandler if available (from policy() function)
180
- // This avoids per-invocation type checking
181
- if (policy._internalHandler) {
182
- return yield* policy._internalHandler(args);
183
- }
184
- // Fallback for policies not created with policy() function
185
- const handlerResult = policy.handler(args);
186
- // Handle both Operation (generator) and Promise return types
187
- if (handlerResult instanceof Promise) {
188
- return yield* call(() => handlerResult);
189
- }
190
- // Check if it's an Effection Operation (generator)
191
- if (isOperation(handlerResult)) {
192
- return yield* handlerResult;
193
- }
194
- // This should never happen with proper handler typing
195
- throw new Error(`Unexpected handler result type: ${typeof handlerResult}`);
196
- });
197
- if (result === undefined) {
198
- throw new Error("Policy result was undefined.");
199
- }
200
- return result;
201
- }
202
- catch (error) {
203
- this.exit(`Error in policy handler '${policy.name}' for file '${relPath}': ${error}`);
204
- }
205
- }
206
- *handlePolicyResult(result, relPath, policy, perfStats, gitRoot) {
207
- if (result === true) {
116
+ // Handle new PolicyError with fixed property (fix was attempted inline)
117
+ if (isPolicyError(outcome) && outcome.fixed !== undefined) {
118
+ this.formatPolicyErrorFixResult(outcome, result.file, result.policyId);
208
119
  return;
209
120
  }
210
- // Handle fix results (both legacy and new formats)
211
- if (isPolicyFixResult(result)) {
212
- this.handleFixResult(result, policy);
121
+ // Handle failure with standalone resolver result
122
+ if (resolution !== undefined) {
123
+ this.formatResolutionResult(resolution, result.file, result.policyId);
213
124
  return;
214
125
  }
215
- // Handle new PolicyError with fixed property (fix was attempted)
216
- if (isPolicyError(result) && result.fixed !== undefined) {
217
- this.handlePolicyErrorFixResult(result, relPath, policy);
126
+ // Handle plain failure (no fix attempted)
127
+ // The runner only collects non-true results, but TypeScript needs explicit narrowing
128
+ if (outcome === true) {
218
129
  return;
219
130
  }
220
- // Handle failure results (PolicyFailure or PolicyError without fix)
221
- yield* this.handleFailureResult(result, relPath, policy, perfStats, gitRoot);
131
+ this.formatPolicyFailure(outcome, result.file, result.policyId);
222
132
  }
223
- handleFixResult(result, policy) {
133
+ formatFixResult(resolved, file, policyName) {
224
134
  const messages = new StringBuilder();
225
- if (result.resolved) {
226
- messages.append(`Resolved ${policy.name} policy failure for file: ${result.file}`);
135
+ if (resolved) {
136
+ messages.append(`Resolved ${policyName} policy failure for file: ${file}`);
227
137
  }
228
138
  else {
229
- messages.append(`Error fixing ${policy.name} policy failure in ${result.file}`);
139
+ messages.append(`Error fixing ${policyName} policy failure in ${file}`);
230
140
  process.exitCode = 1;
231
141
  }
232
142
  this.logMessages(messages);
233
143
  }
234
- handlePolicyErrorFixResult(result, file, policy) {
144
+ formatPolicyErrorFixResult(result, file, policyName) {
235
145
  const messages = new StringBuilder();
236
146
  if (result.fixed) {
237
- messages.append(`Resolved ${policy.name} policy failure for file: ${file}`);
147
+ messages.append(`Resolved ${policyName} policy failure for file: ${file}`);
238
148
  }
239
149
  else {
240
- messages.append(`Error fixing ${policy.name} policy failure in ${file}`);
150
+ messages.append(`Error fixing ${policyName} policy failure in ${file}`);
241
151
  if (result.error) {
242
152
  messages.append(`${newline}\t${result.error}`);
243
153
  }
@@ -245,55 +155,36 @@ export class CheckPolicy extends BaseRepopoCommand {
245
155
  }
246
156
  this.logMessages(messages);
247
157
  }
248
- *handleFailureResult(result, relPath, policy, perfStats, gitRoot) {
158
+ formatResolutionResult(resolution, file, policyName) {
249
159
  const messages = new StringBuilder();
250
- if (this.flags.fix && policy.resolver) {
251
- yield* this.attemptResolution(relPath, policy, policy.resolver, perfStats, gitRoot, messages);
252
- }
253
- else {
254
- this.logPolicyFailure(result, relPath, policy, messages);
255
- }
256
- this.logMessages(messages);
257
- }
258
- *attemptResolution(relPath, policy, resolver, perfStats, gitRoot, messages) {
259
- messages.append(`${newline}Attempting to resolve: ${relPath}`);
260
- const resolveResult = yield* runWithPerf(policy.name, "resolve", perfStats, function* () {
261
- const result = resolver({ file: relPath, root: gitRoot });
262
- // Handle both Operation (generator) and Promise return types
263
- if (result instanceof Promise) {
264
- return yield* call(() => result);
265
- }
266
- // Check if it's an Effection Operation (generator)
267
- if (isOperation(result)) {
268
- return yield* result;
269
- }
270
- // This should never happen with proper resolver typing
271
- throw new Error(`Unexpected resolver result type: ${typeof result}`);
272
- });
273
- if (!resolveResult.resolved) {
160
+ messages.append(`${newline}Attempting to resolve '${policyName}' policy failure for file: ${file}`);
161
+ if (!resolution.resolved) {
274
162
  process.exitCode = 1;
275
163
  }
276
- if (resolveResult.errorMessages?.length > 0) {
277
- messages.append(newline + resolveResult.errorMessages.join(newline));
164
+ if (resolution.errorMessages && resolution.errorMessages.length > 0) {
165
+ messages.append(newline + resolution.errorMessages.join(newline));
278
166
  }
167
+ this.logMessages(messages);
279
168
  }
280
- logPolicyFailure(result, file, policy, messages) {
169
+ formatPolicyFailure(result, file, policyName) {
170
+ const messages = new StringBuilder();
281
171
  // Handle both legacy PolicyFailure and new PolicyError formats
282
172
  if (isPolicyError(result)) {
283
173
  const autoFixable = result.fixable ? chalk.green(" (autofixable)") : "";
284
- messages.append(`'${chalk.bold(policy.name)}' policy failure${autoFixable}: ${file}`);
174
+ messages.append(`'${chalk.bold(policyName)}' policy failure${autoFixable}: ${file}`);
285
175
  messages.append(`${newline}\t${result.error}`);
286
176
  }
287
177
  else {
288
178
  const autoFixable = result.autoFixable
289
179
  ? chalk.green(" (autofixable)")
290
180
  : "";
291
- messages.append(`'${chalk.bold(policy.name)}' policy failure${autoFixable}: ${result.file}`);
181
+ messages.append(`'${chalk.bold(policyName)}' policy failure${autoFixable}: ${result.file}`);
292
182
  if (result.errorMessages?.length > 0) {
293
183
  messages.append(`${newline}\t${result.errorMessages.join(`${newline}\t`)}`);
294
184
  }
295
185
  }
296
186
  process.exitCode = 1;
187
+ this.logMessages(messages);
297
188
  }
298
189
  logMessages(messages) {
299
190
  if ((process.exitCode ?? 0) === 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"check.js","sourceRoot":"","sources":["../../src/commands/check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,GAAG,EAAE,IAAI,EAAkB,GAAG,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,KAAK,MAAM,YAAY,CAAC;AAE/B;;GAEG;AACH,SAAS,WAAW,CAAI,KAAc;IACrC,OAAO,CACN,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,MAAM,IAAI,KAAK;QACf,OAAQ,KAA2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,EAAE,CAAC,CAAC;QAChC,CAAC;aAAM,CAAC;YACP,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;QACnC,CAAC;IACF,CAAC","sourcesContent":["import { EOL as newline } from \"node:os\";\nimport process from \"node:process\";\nimport { Flags } from \"@oclif/core\";\nimport { StringBuilder } from \"@rushstack/node-core-library\";\nimport { all, call, type Operation, run } from \"effection\";\nimport chalk from \"picocolors\";\n\n/**\n * Type guard to check if a value is an Effection Operation (generator).\n */\nfunction isOperation<T>(value: unknown): value is Operation<T> {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\t\"next\" in value &&\n\t\ttypeof (value as { next: unknown }).next === \"function\"\n\t);\n}\n\nimport { BaseRepopoCommand } from \"../baseCommand.js\";\nimport type { RepopoCommandContext } from \"../context.js\";\nimport { logStats, type PolicyHandlerPerfStats, runWithPerf } from \"../perf.js\";\nimport {\n\tisPolicyError,\n\tisPolicyFixResult,\n\ttype PolicyError,\n\ttype PolicyFailure,\n\ttype PolicyFixResult,\n\ttype PolicyHandlerResult,\n\ttype PolicyInstance,\n\ttype PolicyStandaloneResolver,\n} from \"../policy.js\";\n\nasync function readStdin(): Promise<string> {\n\treturn new Promise((resolve) => {\n\t\tconst stdin = process.stdin;\n\t\tstdin.setEncoding(\"utf8\");\n\n\t\tlet data = \"\";\n\t\tstdin.on(\"data\", (chunk) => {\n\t\t\tdata += chunk;\n\t\t});\n\n\t\tstdin.on(\"end\", () => {\n\t\t\tresolve(data);\n\t\t});\n\n\t\tif (stdin.isTTY) {\n\t\t\tresolve(\"\");\n\t\t}\n\t});\n}\n\n/**\n * This tool enforces policies across the code base via a series of handler functions. The handler functions are\n * associated with a regular expression, and all files matching that expression are passed to the handler function.\n *\n * By default, the list of files to check comes from `git ls-files. You can also pipe in file names from stdin. For\n * example:\n *\n * `git ls-files -co --exclude-standard --full-name | repopo check --stdin --verbose`\n */\nexport class CheckPolicy<\n\tT extends typeof BaseRepopoCommand & {\n\t\targs: typeof CheckPolicy.args;\n\t\tflags: typeof CheckPolicy.flags;\n\t},\n> extends BaseRepopoCommand<T> {\n\tpublic static override readonly summary =\n\t\t\"Checks and applies policies to the files in the repository.\";\n\n\tpublic static override readonly flags = {\n\t\tfix: Flags.boolean({\n\t\t\taliases: [\"resolve\"],\n\t\t\tdescription: \"Fix errors if possible.\",\n\t\t\trequired: false,\n\t\t\tchar: \"f\",\n\t\t}),\n\t\tstdin: Flags.boolean({\n\t\t\tdescription: \"Read list of files from stdin.\",\n\t\t\trequired: false,\n\t\t}),\n\t\t...BaseRepopoCommand.flags,\n\t} as const;\n\n\tpublic override async run(): Promise<void> {\n\t\tif (this.flags.fix) {\n\t\t\tthis.info(\"Resolving errors if possible.\");\n\t\t}\n\n\t\tconst config = this.commandConfig;\n\t\tconst policies = config?.policies ?? [];\n\t\tthis.verbose(`${policies.length} policies loaded.`);\n\t\tfor (const h of policies) {\n\t\t\tthis.verbose(h.name);\n\t\t}\n\n\t\tconst filePathsToCheck: string[] = [];\n\n\t\tif (this.flags.stdin) {\n\t\t\tconst stdInput = await run(function* () {\n\t\t\t\treturn yield* call(() => readStdin());\n\t\t\t});\n\n\t\t\tif (stdInput !== undefined && stdInput !== null) {\n\t\t\t\tfilePathsToCheck.push(\n\t\t\t\t\t...stdInput\n\t\t\t\t\t\t.replace(\n\t\t\t\t\t\t\t// normalize slashes in case they're windows paths\n\t\t\t\t\t\t\t/\\\\/g,\n\t\t\t\t\t\t\t\"/\",\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.split(\"\\n\"),\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tconst gitFiles =\n\t\t\t\t(await this.git.raw(\n\t\t\t\t\t\"ls-files\",\n\t\t\t\t\t// include staged files and untracked files\n\t\t\t\t\t\"-co\",\n\t\t\t\t\t// exclude gitignored files and other standard ignore rules\n\t\t\t\t\t\"--exclude-standard\",\n\t\t\t\t\t// Outputs paths relative to the root of the repository, regardless of the current working directory.\n\t\t\t\t\t\"--full-name\",\n\t\t\t\t)) ?? \"\";\n\n\t\t\tfilePathsToCheck.push(\n\t\t\t\t...gitFiles\n\t\t\t\t\t.replace(\n\t\t\t\t\t\t// normalize slashes in case they're windows paths\n\t\t\t\t\t\t/\\\\/g,\n\t\t\t\t\t\t\"/\",\n\t\t\t\t\t)\n\t\t\t\t\t.split(\"\\n\"),\n\t\t\t);\n\t\t}\n\n\t\tconst context: RepopoCommandContext = await this.getContext();\n\n\t\tawait run(() => this.checkAllFiles(filePathsToCheck, context));\n\t}\n\n\t/**\n\t * Executes all policies against the provided paths.\n\t *\n\t * @param pathsToCheck - All paths that should be checked. Paths should be relative to the repository root.\n\t * @param context - The context.\n\t */\n\tprivate *checkAllFiles(\n\t\tpathsToCheck: string[],\n\t\tcontext: RepopoCommandContext,\n\t): Operation<void> {\n\t\ttry {\n\t\t\tfor (const pathToCheck of pathsToCheck) {\n\t\t\t\tyield* this.checkOrExcludeFile(pathToCheck, context);\n\t\t\t}\n\t\t} finally {\n\t\t\tif (!this.flags.quiet) {\n\t\t\t\tlogStats(context.perfStats, this.logger);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Given a string that represents a path to a file in the repo, determines if the file should be checked, and if so,\n\t * routes the file to the appropriate handlers.\n\t *\n\t * @param relPath - A git repo-relative path to a file.\n\t */\n\tprivate *checkOrExcludeFile(\n\t\trelPath: string,\n\t\tcontext: RepopoCommandContext,\n\t): Operation<void> {\n\t\tconst { perfStats } = context;\n\t\tperfStats.count++;\n\n\t\ttry {\n\t\t\tyield* this.routeToPolicies(relPath, context);\n\t\t} catch (error: unknown) {\n\t\t\tthrow new Error(\n\t\t\t\t`Error routing ${relPath} to handler: ${error}\\nStack:\\n${(error as Error).stack}`,\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate *routeToPolicies(\n\t\trelPath: string,\n\t\tcontext: RepopoCommandContext,\n\t): Operation<void> {\n\t\tconst { policies, excludeFromAll } = context;\n\n\t\t// Check exclusions\n\t\tif (excludeFromAll.some((regex) => regex.test(relPath))) {\n\t\t\tthis.verbose(`Excluded all handlers: ${relPath}`);\n\t\t\treturn;\n\t\t}\n\n\t\t// Run all matching policies\n\t\tconst matchingPolicies = policies.filter((policy) =>\n\t\t\tpolicy.match.test(relPath),\n\t\t);\n\n\t\tyield* all(\n\t\t\tmatchingPolicies.map((policy) => {\n\t\t\t\treturn this.runPolicyOnFile(relPath, policy, context);\n\t\t\t}),\n\t\t);\n\t}\n\n\tprivate *runPolicyOnFile(\n\t\trelPath: string,\n\t\tpolicy: PolicyInstance,\n\t\tcontext: RepopoCommandContext,\n\t): Operation<void> {\n\t\tconst { excludePoliciesForFiles, perfStats, gitRoot } = context;\n\n\t\t// Check if the policy is excluded for the file\n\t\tif (this.isPolicyExcluded(relPath, policy, excludePoliciesForFiles)) {\n\t\t\tthis.verbose(`Excluded from '${policy.name}' policy: ${relPath}`);\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\t// Execute the policy handler\n\t\t\tconst result = yield* this.executePolicyHandler(\n\t\t\t\trelPath,\n\t\t\t\tpolicy,\n\t\t\t\tperfStats,\n\t\t\t\tgitRoot,\n\t\t\t);\n\n\t\t\t// Handle the result of the policy execution\n\t\t\tyield* this.handlePolicyResult(\n\t\t\t\tresult,\n\t\t\t\trelPath,\n\t\t\t\tpolicy,\n\t\t\t\tperfStats,\n\t\t\t\tgitRoot,\n\t\t\t);\n\t\t} catch (error: unknown) {\n\t\t\t// Log and rethrow the error for higher-level handling\n\t\t\tthis.exit(\n\t\t\t\t`Error executing policy '${policy.name}' for file '${relPath}': ${error}`,\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate isPolicyExcluded(\n\t\trelPath: string,\n\t\tpolicy: PolicyInstance,\n\t\texcludePoliciesForFiles: Map<string, RegExp[]>,\n\t): boolean {\n\t\treturn (\n\t\t\texcludePoliciesForFiles\n\t\t\t\t.get(policy.name)\n\t\t\t\t?.some((regex) => regex.test(relPath)) ?? false\n\t\t);\n\t}\n\n\tprivate *executePolicyHandler(\n\t\trelPath: string,\n\t\tpolicy: PolicyInstance,\n\t\tperfStats: PolicyHandlerPerfStats,\n\t\tgitRoot: string,\n\t): Operation<PolicyHandlerResult> {\n\t\tconst resolve = this.flags.fix;\n\t\ttry {\n\t\t\tconst result = yield* runWithPerf(\n\t\t\t\tpolicy.name,\n\t\t\t\t\"handle\",\n\t\t\t\tperfStats,\n\t\t\t\tfunction* () {\n\t\t\t\t\tconst args = {\n\t\t\t\t\t\tfile: relPath,\n\t\t\t\t\t\troot: gitRoot,\n\t\t\t\t\t\tresolve,\n\t\t\t\t\t\tconfig: policy.config,\n\t\t\t\t\t};\n\n\t\t\t\t\t// Use normalized _internalHandler if available (from policy() function)\n\t\t\t\t\t// This avoids per-invocation type checking\n\t\t\t\t\tif (policy._internalHandler) {\n\t\t\t\t\t\treturn yield* policy._internalHandler(args);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Fallback for policies not created with policy() function\n\t\t\t\t\tconst handlerResult = policy.handler(args);\n\n\t\t\t\t\t// Handle both Operation (generator) and Promise return types\n\t\t\t\t\tif (handlerResult instanceof Promise) {\n\t\t\t\t\t\treturn yield* call(() => handlerResult);\n\t\t\t\t\t}\n\t\t\t\t\t// Check if it's an Effection Operation (generator)\n\t\t\t\t\tif (isOperation<PolicyHandlerResult>(handlerResult)) {\n\t\t\t\t\t\treturn yield* handlerResult;\n\t\t\t\t\t}\n\t\t\t\t\t// This should never happen with proper handler typing\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Unexpected handler result type: ${typeof handlerResult}`,\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t);\n\t\t\tif (result === undefined) {\n\t\t\t\tthrow new Error(\"Policy result was undefined.\");\n\t\t\t}\n\t\t\treturn result;\n\t\t} catch (error: unknown) {\n\t\t\tthis.exit(\n\t\t\t\t`Error in policy handler '${policy.name}' for file '${relPath}': ${error}`,\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate *handlePolicyResult(\n\t\tresult: PolicyHandlerResult,\n\t\trelPath: string,\n\t\tpolicy: PolicyInstance,\n\t\tperfStats: PolicyHandlerPerfStats,\n\t\tgitRoot: string,\n\t): Operation<void> {\n\t\tif (result === true) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Handle fix results (both legacy and new formats)\n\t\tif (isPolicyFixResult(result)) {\n\t\t\tthis.handleFixResult(result, policy);\n\t\t\treturn;\n\t\t}\n\n\t\t// Handle new PolicyError with fixed property (fix was attempted)\n\t\tif (isPolicyError(result) && result.fixed !== undefined) {\n\t\t\tthis.handlePolicyErrorFixResult(result, relPath, policy);\n\t\t\treturn;\n\t\t}\n\n\t\t// Handle failure results (PolicyFailure or PolicyError without fix)\n\t\tyield* this.handleFailureResult(\n\t\t\tresult,\n\t\t\trelPath,\n\t\t\tpolicy,\n\t\t\tperfStats,\n\t\t\tgitRoot,\n\t\t);\n\t}\n\n\tprivate handleFixResult(\n\t\tresult: PolicyFixResult,\n\t\tpolicy: PolicyInstance,\n\t): void {\n\t\tconst messages = new StringBuilder();\n\n\t\tif (result.resolved) {\n\t\t\tmessages.append(\n\t\t\t\t`Resolved ${policy.name} policy failure for file: ${result.file}`,\n\t\t\t);\n\t\t} else {\n\t\t\tmessages.append(\n\t\t\t\t`Error fixing ${policy.name} policy failure in ${result.file}`,\n\t\t\t);\n\t\t\tprocess.exitCode = 1;\n\t\t}\n\n\t\tthis.logMessages(messages);\n\t}\n\n\tprivate handlePolicyErrorFixResult(\n\t\tresult: PolicyError,\n\t\tfile: string,\n\t\tpolicy: PolicyInstance,\n\t): void {\n\t\tconst messages = new StringBuilder();\n\n\t\tif (result.fixed) {\n\t\t\tmessages.append(\n\t\t\t\t`Resolved ${policy.name} policy failure for file: ${file}`,\n\t\t\t);\n\t\t} else {\n\t\t\tmessages.append(`Error fixing ${policy.name} policy failure in ${file}`);\n\t\t\tif (result.error) {\n\t\t\t\tmessages.append(`${newline}\\t${result.error}`);\n\t\t\t}\n\t\t\tprocess.exitCode = 1;\n\t\t}\n\n\t\tthis.logMessages(messages);\n\t}\n\n\tprivate *handleFailureResult(\n\t\tresult: PolicyFailure | PolicyError,\n\t\trelPath: string,\n\t\tpolicy: PolicyInstance,\n\t\tperfStats: PolicyHandlerPerfStats,\n\t\tgitRoot: string,\n\t): Operation<void> {\n\t\tconst messages = new StringBuilder();\n\n\t\tif (this.flags.fix && policy.resolver) {\n\t\t\tyield* this.attemptResolution(\n\t\t\t\trelPath,\n\t\t\t\tpolicy,\n\t\t\t\tpolicy.resolver,\n\t\t\t\tperfStats,\n\t\t\t\tgitRoot,\n\t\t\t\tmessages,\n\t\t\t);\n\t\t} else {\n\t\t\tthis.logPolicyFailure(result, relPath, policy, messages);\n\t\t}\n\n\t\tthis.logMessages(messages);\n\t}\n\n\tprivate *attemptResolution(\n\t\trelPath: string,\n\t\tpolicy: PolicyInstance,\n\t\tresolver: PolicyStandaloneResolver,\n\t\tperfStats: PolicyHandlerPerfStats,\n\t\tgitRoot: string,\n\t\tmessages: StringBuilder,\n\t): Operation<void> {\n\t\tmessages.append(`${newline}Attempting to resolve: ${relPath}`);\n\t\tconst resolveResult = yield* runWithPerf(\n\t\t\tpolicy.name,\n\t\t\t\"resolve\",\n\t\t\tperfStats,\n\t\t\tfunction* () {\n\t\t\t\tconst result = resolver({ file: relPath, root: gitRoot });\n\n\t\t\t\t// Handle both Operation (generator) and Promise return types\n\t\t\t\tif (result instanceof Promise) {\n\t\t\t\t\treturn yield* call(() => result);\n\t\t\t\t}\n\t\t\t\t// Check if it's an Effection Operation (generator)\n\t\t\t\tif (isOperation<PolicyFixResult>(result)) {\n\t\t\t\t\treturn yield* result;\n\t\t\t\t}\n\t\t\t\t// This should never happen with proper resolver typing\n\t\t\t\tthrow new Error(`Unexpected resolver result type: ${typeof result}`);\n\t\t\t},\n\t\t);\n\n\t\tif (!resolveResult.resolved) {\n\t\t\tprocess.exitCode = 1;\n\t\t}\n\n\t\tif (resolveResult.errorMessages?.length > 0) {\n\t\t\tmessages.append(newline + resolveResult.errorMessages.join(newline));\n\t\t}\n\t}\n\n\tprivate logPolicyFailure(\n\t\tresult: PolicyFailure | PolicyError,\n\t\tfile: string,\n\t\tpolicy: PolicyInstance,\n\t\tmessages: StringBuilder,\n\t): void {\n\t\t// Handle both legacy PolicyFailure and new PolicyError formats\n\t\tif (isPolicyError(result)) {\n\t\t\tconst autoFixable = result.fixable ? chalk.green(\" (autofixable)\") : \"\";\n\t\t\tmessages.append(\n\t\t\t\t`'${chalk.bold(policy.name)}' policy failure${autoFixable}: ${file}`,\n\t\t\t);\n\t\t\tmessages.append(`${newline}\\t${result.error}`);\n\t\t} else {\n\t\t\tconst autoFixable = result.autoFixable\n\t\t\t\t? chalk.green(\" (autofixable)\")\n\t\t\t\t: \"\";\n\t\t\tmessages.append(\n\t\t\t\t`'${chalk.bold(policy.name)}' policy failure${autoFixable}: ${result.file}`,\n\t\t\t);\n\t\t\tif (result.errorMessages?.length > 0) {\n\t\t\t\tmessages.append(\n\t\t\t\t\t`${newline}\\t${result.errorMessages.join(`${newline}\\t`)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tprocess.exitCode = 1;\n\t}\n\tprivate logMessages(messages: StringBuilder): void {\n\t\tif ((process.exitCode ?? 0) === 0) {\n\t\t\tthis.info(messages.toString());\n\t\t} else {\n\t\t\tthis.warning(messages.toString());\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"check.js","sourceRoot":"","sources":["../../src/commands/check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,KA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AAI,EAAE,CACnE,CAAC;YACF,QAAQ,CAAC,MAAM,CAAC,GAAG,OAAO,KAAK,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;QAChD,CAAC;aAAM,CAAC;YACP,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW;gBACrC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAAC;gBAC/B,CAAC,CAAC,EAAE,CAAC;YACN,QAAQ,CAAC,MAAM,CACd,IAAI,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,mBAAmB,WAAW,KAAK,MAAM,CAAC,IAAI,EAAE,CAC1E,CAAC;YACF,IAAI,MAAM,CAAC,aAAa,EAAE,MAAM,GAAG,CAAC,EAAE,CAAC;gBACtC,QAAQ,CAAC,MAAM,CACd,GAAG,OAAO,KAAK,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,OAAO,IAAI,CAAC,EAAE,CAC1D,CAAC;YACH,CAAC;QACF,CAAC;QACD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QAErB,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC5B,CAAC;IAEO,WAAW,CAAC,QAAuB;QAC1C,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;YACnC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;QAChC,CAAC;aAAM,CAAC;YACP,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;QACnC,CAAC;IACF,CAAC","sourcesContent":["import { EOL as newline } from \"node:os\";\nimport process from \"node:process\";\nimport { Flags } from \"@oclif/core\";\nimport { StringBuilder } from \"@rushstack/node-core-library\";\nimport { call, run } from \"effection\";\nimport chalk from \"picocolors\";\n\nimport { BaseRepopoCommand } from \"../baseCommand.js\";\nimport type { RepopoCommandContext } from \"../context.js\";\nimport { logStats } from \"../perf.js\";\nimport {\n\tisPolicyError,\n\tisPolicyFixResult,\n\ttype PolicyError,\n\ttype PolicyFailure,\n} from \"../policy.js\";\nimport { type PolicyFileResult, PolicyRunner } from \"../runner.js\";\n\nasync function readStdin(): Promise<string> {\n\treturn new Promise((resolve) => {\n\t\tconst stdin = process.stdin;\n\t\tstdin.setEncoding(\"utf8\");\n\n\t\tlet data = \"\";\n\t\tstdin.on(\"data\", (chunk) => {\n\t\t\tdata += chunk;\n\t\t});\n\n\t\tstdin.on(\"end\", () => {\n\t\t\tresolve(data);\n\t\t});\n\n\t\tif (stdin.isTTY) {\n\t\t\tresolve(\"\");\n\t\t}\n\t});\n}\n\n/**\n * This tool enforces policies across the code base via a series of handler functions. The handler functions are\n * associated with a regular expression, and all files matching that expression are passed to the handler function.\n *\n * By default, the list of files to check comes from `git ls-files. You can also pipe in file names from stdin. For\n * example:\n *\n * `git ls-files -co --exclude-standard --full-name | repopo check --stdin --verbose`\n */\nexport class CheckPolicy<\n\tT extends typeof BaseRepopoCommand & {\n\t\targs: typeof CheckPolicy.args;\n\t\tflags: typeof CheckPolicy.flags;\n\t},\n> extends BaseRepopoCommand<T> {\n\tpublic static override readonly summary =\n\t\t\"Checks and applies policies to the files in the repository.\";\n\n\tpublic static override readonly flags = {\n\t\tfix: Flags.boolean({\n\t\t\taliases: [\"resolve\"],\n\t\t\tdescription: \"Fix errors if possible.\",\n\t\t\trequired: false,\n\t\t\tchar: \"f\",\n\t\t}),\n\t\tstdin: Flags.boolean({\n\t\t\tdescription: \"Read list of files from stdin.\",\n\t\t\trequired: false,\n\t\t}),\n\t\t...BaseRepopoCommand.flags,\n\t} as const;\n\n\tpublic override async run(): Promise<void> {\n\t\tif (this.flags.fix) {\n\t\t\tthis.info(\"Resolving errors if possible.\");\n\t\t}\n\n\t\tconst filePathsToCheck = await this.collectFilePaths();\n\t\tconst context: RepopoCommandContext = await this.getContext();\n\t\tthis.verbose(`${context.policies.length} policies loaded.`);\n\t\tfor (const configuredPolicy of context.policies) {\n\t\t\tthis.verbose(configuredPolicy.instanceId);\n\t\t}\n\n\t\tconst runner = new PolicyRunner({\n\t\t\tpolicies: context.policies,\n\t\t\texcludeFromAll: context.excludeFromAll,\n\t\t\texcludePoliciesForFiles: context.excludePoliciesForFiles,\n\t\t\tgitRoot: context.gitRoot,\n\t\t\tresolve: this.flags.fix,\n\t\t\tlogger: this.logger,\n\t\t});\n\n\t\tconst runResults = await run(() => runner.run(filePathsToCheck));\n\n\t\t// Format and log results\n\t\tfor (const result of runResults.results) {\n\t\t\tthis.formatResult(result);\n\t\t}\n\n\t\tif (!this.flags.quiet) {\n\t\t\tlogStats(runResults.perfStats, this.logger);\n\t\t}\n\t}\n\n\t/**\n\t * Collects file paths to check from either stdin or git ls-files.\n\t */\n\tprivate async collectFilePaths(): Promise<string[]> {\n\t\tif (this.flags.stdin) {\n\t\t\tconst stdInput = await run(function* () {\n\t\t\t\treturn yield* call(() => readStdin());\n\t\t\t});\n\n\t\t\tif (stdInput !== undefined && stdInput !== null) {\n\t\t\t\treturn stdInput\n\t\t\t\t\t.replace(\n\t\t\t\t\t\t// normalize slashes in case they're windows paths\n\t\t\t\t\t\t/\\\\/g,\n\t\t\t\t\t\t\"/\",\n\t\t\t\t\t)\n\t\t\t\t\t.split(\"\\n\");\n\t\t\t}\n\n\t\t\treturn [];\n\t\t}\n\n\t\tconst gitFiles =\n\t\t\t(await this.git.raw(\n\t\t\t\t\"ls-files\",\n\t\t\t\t// include staged files and untracked files\n\t\t\t\t\"-co\",\n\t\t\t\t// NUL-delimited paths are not quoted or escaped by Git.\n\t\t\t\t\"-z\",\n\t\t\t\t// exclude gitignored files and other standard ignore rules\n\t\t\t\t\"--exclude-standard\",\n\t\t\t\t// Outputs paths relative to the root of the repository, regardless of the current working directory.\n\t\t\t\t\"--full-name\",\n\t\t\t)) ?? \"\";\n\n\t\treturn gitFiles.split(\"\\0\").filter((file) => file.length > 0);\n\t}\n\n\t/**\n\t * Formats a single policy file result, logging messages and setting exit codes.\n\t */\n\tprivate formatResult(result: PolicyFileResult): void {\n\t\tconst { outcome, resolution } = result;\n\n\t\t// Handle fix results (legacy format with resolved property)\n\t\tif (isPolicyFixResult(outcome)) {\n\t\t\tthis.formatFixResult(outcome.resolved, outcome.file, result.policyId);\n\t\t\treturn;\n\t\t}\n\n\t\t// Handle new PolicyError with fixed property (fix was attempted inline)\n\t\tif (isPolicyError(outcome) && outcome.fixed !== undefined) {\n\t\t\tthis.formatPolicyErrorFixResult(outcome, result.file, result.policyId);\n\t\t\treturn;\n\t\t}\n\n\t\t// Handle failure with standalone resolver result\n\t\tif (resolution !== undefined) {\n\t\t\tthis.formatResolutionResult(resolution, result.file, result.policyId);\n\t\t\treturn;\n\t\t}\n\n\t\t// Handle plain failure (no fix attempted)\n\t\t// The runner only collects non-true results, but TypeScript needs explicit narrowing\n\t\tif (outcome === true) {\n\t\t\treturn;\n\t\t}\n\t\tthis.formatPolicyFailure(outcome, result.file, result.policyId);\n\t}\n\n\tprivate formatFixResult(\n\t\tresolved: boolean,\n\t\tfile: string,\n\t\tpolicyName: string,\n\t): void {\n\t\tconst messages = new StringBuilder();\n\n\t\tif (resolved) {\n\t\t\tmessages.append(\n\t\t\t\t`Resolved ${policyName} policy failure for file: ${file}`,\n\t\t\t);\n\t\t} else {\n\t\t\tmessages.append(`Error fixing ${policyName} policy failure in ${file}`);\n\t\t\tprocess.exitCode = 1;\n\t\t}\n\n\t\tthis.logMessages(messages);\n\t}\n\n\tprivate formatPolicyErrorFixResult(\n\t\tresult: PolicyError,\n\t\tfile: string,\n\t\tpolicyName: string,\n\t): void {\n\t\tconst messages = new StringBuilder();\n\n\t\tif (result.fixed) {\n\t\t\tmessages.append(\n\t\t\t\t`Resolved ${policyName} policy failure for file: ${file}`,\n\t\t\t);\n\t\t} else {\n\t\t\tmessages.append(`Error fixing ${policyName} policy failure in ${file}`);\n\t\t\tif (result.error) {\n\t\t\t\tmessages.append(`${newline}\\t${result.error}`);\n\t\t\t}\n\t\t\tprocess.exitCode = 1;\n\t\t}\n\n\t\tthis.logMessages(messages);\n\t}\n\n\tprivate formatResolutionResult(\n\t\tresolution: { resolved: boolean; errorMessages?: string[] },\n\t\tfile: string,\n\t\tpolicyName: string,\n\t): void {\n\t\tconst messages = new StringBuilder();\n\t\tmessages.append(\n\t\t\t`${newline}Attempting to resolve '${policyName}' policy failure for file: ${file}`,\n\t\t);\n\n\t\tif (!resolution.resolved) {\n\t\t\tprocess.exitCode = 1;\n\t\t}\n\n\t\tif (resolution.errorMessages && resolution.errorMessages.length > 0) {\n\t\t\tmessages.append(newline + resolution.errorMessages.join(newline));\n\t\t}\n\n\t\tthis.logMessages(messages);\n\t}\n\n\tprivate formatPolicyFailure(\n\t\tresult: PolicyFailure | PolicyError,\n\t\tfile: string,\n\t\tpolicyName: string,\n\t): void {\n\t\tconst messages = new StringBuilder();\n\n\t\t// Handle both legacy PolicyFailure and new PolicyError formats\n\t\tif (isPolicyError(result)) {\n\t\t\tconst autoFixable = result.fixable ? chalk.green(\" (autofixable)\") : \"\";\n\t\t\tmessages.append(\n\t\t\t\t`'${chalk.bold(policyName)}' policy failure${autoFixable}: ${file}`,\n\t\t\t);\n\t\t\tmessages.append(`${newline}\\t${result.error}`);\n\t\t} else {\n\t\t\tconst autoFixable = result.autoFixable\n\t\t\t\t? chalk.green(\" (autofixable)\")\n\t\t\t\t: \"\";\n\t\t\tmessages.append(\n\t\t\t\t`'${chalk.bold(policyName)}' policy failure${autoFixable}: ${result.file}`,\n\t\t\t);\n\t\t\tif (result.errorMessages?.length > 0) {\n\t\t\t\tmessages.append(\n\t\t\t\t\t`${newline}\\t${result.errorMessages.join(`${newline}\\t`)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tprocess.exitCode = 1;\n\n\t\tthis.logMessages(messages);\n\t}\n\n\tprivate logMessages(messages: StringBuilder): void {\n\t\tif ((process.exitCode ?? 0) === 0) {\n\t\t\tthis.info(messages.toString());\n\t\t} else {\n\t\t\tthis.warning(messages.toString());\n\t\t}\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGtD;;GAEG;AACH,qBAAa,WAAW,CACvB,CAAC,SAAS,OAAO,iBAAiB,GAAG;IACpC,IAAI,EAAE,OAAO,WAAW,CAAC,IAAI,CAAC;IAC9B,KAAK,EAAE,OAAO,WAAW,CAAC,KAAK,CAAC;CAChC,CACA,SAAQ,iBAAiB,CAAC,CAAC,CAAC;IAC7B,gBAAgC,OAAO,2CACE;IAEnB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAU1C"}
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;GAEG;AACH,qBAAa,WAAW,CACvB,CAAC,SAAS,OAAO,iBAAiB,GAAG;IACpC,IAAI,EAAE,OAAO,WAAW,CAAC,IAAI,CAAC;IAC9B,KAAK,EAAE,OAAO,WAAW,CAAC,KAAK,CAAC;CAChC,CACA,SAAQ,iBAAiB,CAAC,CAAC,CAAC;IAC7B,gBAAgC,OAAO,2CACE;IAEnB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAU1C"}
@@ -1,17 +1,16 @@
1
1
  import { BaseRepopoCommand } from "../baseCommand.js";
2
- import { DefaultPolicies } from "../policy.js";
3
2
  /**
4
3
  * This command lists all the policies configured to run.
5
4
  */
6
5
  export class ListCommand extends BaseRepopoCommand {
7
6
  static summary = "Lists the policies configured to run.";
8
7
  async run() {
9
- const policies = this.commandConfig?.policies ?? DefaultPolicies;
8
+ const { policies } = await this.getContext();
10
9
  // list the handlers then exit
11
- for (const h of policies) {
12
- this.log(`${h.name}`);
13
- this.log(` ${h.description}`);
14
- this.log(` resolver: ${h.resolver !== undefined}\n`);
10
+ for (const configuredPolicy of policies) {
11
+ this.log(configuredPolicy.instanceId);
12
+ this.log(` ${configuredPolicy.description}`);
13
+ this.log(` resolver: ${configuredPolicy.resolver !== undefined}\n`);
15
14
  }
16
15
  this.log(`${policies.length} TOTAL POLICY HANDLERS`);
17
16
  }
@@ -1 +1 @@
1
- {"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C;;GAEG;AACH,MAAM,OAAO,WAKX,SAAQ,iBAAoB;IACtB,MAAM,CAAmB,OAAO,GACtC,uCAAuC,CAAC;IAEzB,KAAK,CAAC,GAAG;QACxB,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,EAAE,QAAQ,IAAI,eAAe,CAAC;QACjE,8BAA8B;QAC9B,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;YAC1B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;YACtB,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;YAC/B,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,QAAQ,KAAK,SAAS,IAAI,CAAC,CAAC;QACvD,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,MAAM,wBAAwB,CAAC,CAAC;IACtD,CAAC","sourcesContent":["import { BaseRepopoCommand } from \"../baseCommand.js\";\nimport { DefaultPolicies } from \"../policy.js\";\n\n/**\n * This command lists all the policies configured to run.\n */\nexport class ListCommand<\n\tT extends typeof BaseRepopoCommand & {\n\t\targs: typeof ListCommand.args;\n\t\tflags: typeof ListCommand.flags;\n\t},\n> extends BaseRepopoCommand<T> {\n\tpublic static override readonly summary =\n\t\t\"Lists the policies configured to run.\";\n\n\tpublic override async run(): Promise<void> {\n\t\tconst policies = this.commandConfig?.policies ?? DefaultPolicies;\n\t\t// list the handlers then exit\n\t\tfor (const h of policies) {\n\t\t\tthis.log(`${h.name}`);\n\t\t\tthis.log(` ${h.description}`);\n\t\t\tthis.log(` resolver: ${h.resolver !== undefined}\\n`);\n\t\t}\n\t\tthis.log(`${policies.length} TOTAL POLICY HANDLERS`);\n\t}\n}\n"]}
1
+ {"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;GAEG;AACH,MAAM,OAAO,WAKX,SAAQ,iBAAoB;IACtB,MAAM,CAAmB,OAAO,GACtC,uCAAuC,CAAC;IAEzB,KAAK,CAAC,GAAG;QACxB,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;QAC7C,8BAA8B;QAC9B,KAAK,MAAM,gBAAgB,IAAI,QAAQ,EAAE,CAAC;YACzC,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;YACtC,IAAI,CAAC,GAAG,CAAC,KAAK,gBAAgB,CAAC,WAAW,EAAE,CAAC,CAAC;YAC9C,IAAI,CAAC,GAAG,CAAC,eAAe,gBAAgB,CAAC,QAAQ,KAAK,SAAS,IAAI,CAAC,CAAC;QACtE,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,MAAM,wBAAwB,CAAC,CAAC;IACtD,CAAC","sourcesContent":["import { BaseRepopoCommand } from \"../baseCommand.js\";\n\n/**\n * This command lists all the policies configured to run.\n */\nexport class ListCommand<\n\tT extends typeof BaseRepopoCommand & {\n\t\targs: typeof ListCommand.args;\n\t\tflags: typeof ListCommand.flags;\n\t},\n> extends BaseRepopoCommand<T> {\n\tpublic static override readonly summary =\n\t\t\"Lists the policies configured to run.\";\n\n\tpublic override async run(): Promise<void> {\n\t\tconst { policies } = await this.getContext();\n\t\t// list the handlers then exit\n\t\tfor (const configuredPolicy of policies) {\n\t\t\tthis.log(configuredPolicy.instanceId);\n\t\t\tthis.log(` ${configuredPolicy.description}`);\n\t\t\tthis.log(` resolver: ${configuredPolicy.resolver !== undefined}\\n`);\n\t\t}\n\t\tthis.log(`${policies.length} TOTAL POLICY HANDLERS`);\n\t}\n}\n"]}
package/esm/context.d.ts CHANGED
@@ -1,6 +1,16 @@
1
1
  import type { PolicyHandlerPerfStats } from "./perf.js";
2
- import type { PolicyInstance, PolicyName } from "./policy.js";
3
- export type ExcludedPolicyFileMap = Map<PolicyName, RegExp[]>;
2
+ import type { IdentifiedPolicy, PolicyInstanceId } from "./policy.js";
3
+ /**
4
+ * A map of policy instance IDs to file-path regexes that should be excluded from those policies.
5
+ * @alpha
6
+ */
7
+ export type ExcludedPolicyFileMap = Map<PolicyInstanceId, RegExp[]>;
8
+ /**
9
+ * Creates the per-instance exclusion map used by policy runners.
10
+ *
11
+ * @internal
12
+ */
13
+ export declare function createExcludedPolicyFileMap(policies: IdentifiedPolicy[]): ExcludedPolicyFileMap;
4
14
  /**
5
15
  * Contextual data available to all Repopo commands.
6
16
  */
@@ -12,7 +22,7 @@ export interface RepopoCommandContext {
12
22
  /**
13
23
  * A list of handlers to apply to selected files.
14
24
  */
15
- policies: PolicyInstance[];
25
+ policies: IdentifiedPolicy[];
16
26
  /**
17
27
  * A per-handler list of regular expressions used to exclude files from specific handlers.
18
28
  */
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9D,MAAM,MAAM,qBAAqB,GAAG,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC;;OAEG;IACH,cAAc,EAAE,MAAM,EAAE,CAAC;IAEzB;;OAEG;IACH,QAAQ,EAAE,cAAc,EAAE,CAAC;IAE3B;;OAEG;IACH,uBAAuB,EAAE,qBAAqB,CAAC;IAE/C;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,SAAS,EAAE,sBAAsB,CAAC;CAClC"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEtE;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAAG,GAAG,CAAC,gBAAgB,EAAE,MAAM,EAAE,CAAC,CAAC;AAEpE;;;;GAIG;AACH,wBAAgB,2BAA2B,CAC1C,QAAQ,EAAE,gBAAgB,EAAE,GAC1B,qBAAqB,CASvB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC;;OAEG;IACH,cAAc,EAAE,MAAM,EAAE,CAAC;IAEzB;;OAEG;IACH,QAAQ,EAAE,gBAAgB,EAAE,CAAC;IAE7B;;OAEG;IACH,uBAAuB,EAAE,qBAAqB,CAAC;IAE/C;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,SAAS,EAAE,sBAAsB,CAAC;CAClC"}
package/esm/context.js CHANGED
@@ -1,2 +1,12 @@
1
- export {};
1
+ /**
2
+ * Creates the per-instance exclusion map used by policy runners.
3
+ *
4
+ * @internal
5
+ */
6
+ export function createExcludedPolicyFileMap(policies) {
7
+ return new Map(policies.map((configuredPolicy) => [
8
+ configuredPolicy.instanceId,
9
+ configuredPolicy.excludeFiles?.map((pattern) => new RegExp(pattern, "i")) ?? [],
10
+ ]));
11
+ }
2
12
  //# sourceMappingURL=context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"","sourcesContent":["import type { PolicyHandlerPerfStats } from \"./perf.js\";\nimport type { PolicyInstance, PolicyName } from \"./policy.js\";\n\nexport type ExcludedPolicyFileMap = Map<PolicyName, RegExp[]>;\n\n/**\n * Contextual data available to all Repopo commands.\n */\nexport interface RepopoCommandContext {\n\t/**\n\t * A list of regular expressions used to exclude files from all handlers.\n\t */\n\texcludeFromAll: RegExp[];\n\n\t/**\n\t * A list of handlers to apply to selected files.\n\t */\n\tpolicies: PolicyInstance[];\n\n\t/**\n\t * A per-handler list of regular expressions used to exclude files from specific handlers.\n\t */\n\texcludePoliciesForFiles: ExcludedPolicyFileMap;\n\n\t/**\n\t * Path to the root of the git repo.\n\t */\n\tgitRoot: string;\n\n\t/**\n\t * Stores performance data for each handler. Used to collect and display performance stats.\n\t */\n\tperfStats: PolicyHandlerPerfStats;\n}\n"]}
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AASA;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CAC1C,QAA4B;IAE5B,OAAO,IAAI,GAAG,CACb,QAAQ,CAAC,GAAG,CAAC,CAAC,gBAAgB,EAAE,EAAE,CAAC;QAClC,gBAAgB,CAAC,UAAU;QAC3B,gBAAgB,CAAC,YAAY,EAAE,GAAG,CACjC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,CACrC,IAAI,EAAE;KACP,CAAC,CACF,CAAC;AACH,CAAC","sourcesContent":["import type { PolicyHandlerPerfStats } from \"./perf.js\";\nimport type { IdentifiedPolicy, PolicyInstanceId } from \"./policy.js\";\n\n/**\n * A map of policy instance IDs to file-path regexes that should be excluded from those policies.\n * @alpha\n */\nexport type ExcludedPolicyFileMap = Map<PolicyInstanceId, RegExp[]>;\n\n/**\n * Creates the per-instance exclusion map used by policy runners.\n *\n * @internal\n */\nexport function createExcludedPolicyFileMap(\n\tpolicies: IdentifiedPolicy[],\n): ExcludedPolicyFileMap {\n\treturn new Map(\n\t\tpolicies.map((configuredPolicy) => [\n\t\t\tconfiguredPolicy.instanceId,\n\t\t\tconfiguredPolicy.excludeFiles?.map(\n\t\t\t\t(pattern) => new RegExp(pattern, \"i\"),\n\t\t\t) ?? [],\n\t\t]),\n\t);\n}\n\n/**\n * Contextual data available to all Repopo commands.\n */\nexport interface RepopoCommandContext {\n\t/**\n\t * A list of regular expressions used to exclude files from all handlers.\n\t */\n\texcludeFromAll: RegExp[];\n\n\t/**\n\t * A list of handlers to apply to selected files.\n\t */\n\tpolicies: IdentifiedPolicy[];\n\n\t/**\n\t * A per-handler list of regular expressions used to exclude files from specific handlers.\n\t */\n\texcludePoliciesForFiles: ExcludedPolicyFileMap;\n\n\t/**\n\t * Path to the root of the git repo.\n\t */\n\tgitRoot: string;\n\n\t/**\n\t * Stores performance data for each handler. Used to collect and display performance stats.\n\t */\n\tperfStats: PolicyHandlerPerfStats;\n}\n"]}
package/esm/index.d.ts CHANGED
@@ -11,8 +11,13 @@
11
11
  export { run } from "@oclif/core";
12
12
  export { type FluidAdapterOptions, type FluidHandler, fromFluidHandlers, } from "./adapters/fluidFramework.js";
13
13
  export type { RepopoConfig, } from "./config.js";
14
+ export type { ExcludedPolicyFileMap } from "./context.js";
14
15
  export { makePolicy, makePolicyDefinition, type PolicyDefinitionInput, type PolicyOptions, policy, } from "./makePolicy.js";
15
- export { type ConfiguredPolicy, isPolicyError, isPolicyFailure, isPolicyFixResult, Policy, type PolicyArgs, type PolicyDefinition, type PolicyError, type PolicyFailure, type PolicyFixResult, type PolicyFunctionArguments, type PolicyHandler, type PolicyHandlerResult, type PolicyInstance, type PolicyInstanceSettings, type PolicyName, type PolicyResolver, type PolicyResult, type PolicyShape, type PolicyStandaloneResolver, } from "./policy.js";
16
+ export type { PolicyAction, PolicyHandlerPerfStats } from "./perf.js";
17
+ export { type ConfiguredPolicy, type IdentifiedPolicy, isPolicyError, isPolicyFailure, isPolicyFixResult, Policy, type PolicyArgs, type PolicyDefinition, type PolicyError, type PolicyFailure, type PolicyFixResult, type PolicyFunctionArguments, type PolicyHandler, type PolicyHandlerResult, type PolicyInstance, type PolicyInstanceId, type PolicyInstanceSettings, type PolicyName, type PolicyResolver, type PolicyResult, type PolicyShape, type PolicyStandaloneResolver, } from "./policy.js";
18
+ export { type CargoToml, type CargoTomlHandler, type DefineCargoPolicyArgs, defineCargoPolicy, } from "./policyDefiners/defineCargoPolicy.js";
16
19
  export { type DefineFileHeaderPolicyArgs, defineFileHeaderPolicy, type FileHeaderGeneratorConfig, type FileHeaderPolicyConfig, } from "./policyDefiners/defineFileHeaderPolicy.js";
20
+ export { type DefineGleamPolicyArgs, defineGleamPolicy, type GleamToml, type GleamTomlHandler, } from "./policyDefiners/defineGleamPolicy.js";
17
21
  export { type DefinePackagePolicyArgs, definePackagePolicy as generatePackagePolicy, type PackageJsonHandler, } from "./policyDefiners/definePackagePolicy.js";
22
+ export { type PolicyFileResult, PolicyRunner, type PolicyRunnerOptions, type PolicyRunResults, } from "./runner.js";
18
23
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EACN,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,iBAAiB,GACjB,MAAM,8BAA8B,CAAC;AACtC,YAAY,EAEX,YAAY,GACZ,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,UAAU,EACV,oBAAoB,EACpB,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAClB,MAAM,GACN,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,KAAK,gBAAgB,EAErB,aAAa,EACb,eAAe,EACf,iBAAiB,EAEjB,MAAM,EACN,KAAK,UAAU,EAEf,KAAK,gBAAgB,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AClB,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,wBAAwB,GAC7B,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,iBAAiB,GACjB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACN,KAAK,0BAA0B,EAC/B,sBAAsB,EACtB,KAAK,yBAAyB,EAC9B,KAAK,sBAAsB,GAC3B,MAAM,4CAA4C,CAAC;AACpD,OAAO,EACN,KAAK,qBAAqB,EAC1B,iBAAiB,EACjB,KAAK,SAAS,EACd,KAAK,gBAAgB,GACrB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACN,KAAK,uBAAuB,EAC5B,mBAAmB,IAAI,qBAAqB,EAC5C,KAAK,kBAAkB,GACvB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACN,KAAK,gBAAgB,EACrB,YAAY,EACZ,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,GACrB,MAAM,aAAa,CAAC"}
package/esm/index.js CHANGED
@@ -16,6 +16,9 @@ export {
16
16
  isPolicyError, isPolicyFailure, isPolicyFixResult,
17
17
  // New types
18
18
  Policy, } from "./policy.js";
19
+ export { defineCargoPolicy, } from "./policyDefiners/defineCargoPolicy.js";
19
20
  export { defineFileHeaderPolicy, } from "./policyDefiners/defineFileHeaderPolicy.js";
21
+ export { defineGleamPolicy, } from "./policyDefiners/defineGleamPolicy.js";
20
22
  export { definePackagePolicy as generatePackagePolicy, } from "./policyDefiners/definePackagePolicy.js";
23
+ export { PolicyRunner, } from "./runner.js";
21
24
  //# sourceMappingURL=index.js.map
package/esm/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAGN,iBAAiB,GACjB,MAAM,8BAA8B,CAAC;AAKtC,OAAO,EACN,UAAU,EACV,oBAAoB,EAGpB,MAAM,GACN,MAAM,iBAAiB,CAAC;AACzB,OAAO;AAEN,cAAc;AACd,aAAa,EACb,eAAe,EACf,iBAAiB;AACjB,YAAY;AACZ,MAAM,GAiBN,MAAM,aAAa,CAAC;AACrB,OAAO,EAEN,sBAAsB,GAGtB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAEN,mBAAmB,IAAI,qBAAqB,GAE5C,MAAM,yCAAyC,CAAC","sourcesContent":["/**\n * A tool for enforcing repository policies and standards across codebases.\n *\n * @remarks\n * Repopo provides a framework for defining and enforcing policies across repositories,\n * such as file headers, package.json consistency, and other code standards.\n * It can be used as a CLI tool or integrated into CI/CD pipelines.\n *\n * @packageDocumentation\n */\n\nexport { run } from \"@oclif/core\";\nexport {\n\ttype FluidAdapterOptions,\n\ttype FluidHandler,\n\tfromFluidHandlers,\n} from \"./adapters/fluidFramework.js\";\nexport type {\n\t// PolicyList,\n\tRepopoConfig,\n} from \"./config.js\";\nexport {\n\tmakePolicy,\n\tmakePolicyDefinition,\n\ttype PolicyDefinitionInput,\n\ttype PolicyOptions,\n\tpolicy,\n} from \"./makePolicy.js\";\nexport {\n\ttype ConfiguredPolicy,\n\t// Type guards\n\tisPolicyError,\n\tisPolicyFailure,\n\tisPolicyFixResult,\n\t// New types\n\tPolicy,\n\ttype PolicyArgs,\n\t// Legacy types (for backward compatibility)\n\ttype PolicyDefinition,\n\ttype PolicyError,\n\ttype PolicyFailure,\n\ttype PolicyFixResult,\n\ttype PolicyFunctionArguments,\n\ttype PolicyHandler,\n\ttype PolicyHandlerResult,\n\ttype PolicyInstance,\n\ttype PolicyInstanceSettings,\n\ttype PolicyName,\n\ttype PolicyResolver,\n\ttype PolicyResult,\n\ttype PolicyShape,\n\ttype PolicyStandaloneResolver,\n} from \"./policy.js\";\nexport {\n\ttype DefineFileHeaderPolicyArgs,\n\tdefineFileHeaderPolicy,\n\ttype FileHeaderGeneratorConfig,\n\ttype FileHeaderPolicyConfig,\n} from \"./policyDefiners/defineFileHeaderPolicy.js\";\nexport {\n\ttype DefinePackagePolicyArgs,\n\tdefinePackagePolicy as generatePackagePolicy,\n\ttype PackageJsonHandler,\n} from \"./policyDefiners/definePackagePolicy.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAGN,iBAAiB,GACjB,MAAM,8BAA8B,CAAC;AAMtC,OAAO,EACN,UAAU,EACV,oBAAoB,EAGpB,MAAM,GACN,MAAM,iBAAiB,CAAC;AAEzB,OAAO;AAGN,cAAc;AACd,aAAa,EACb,eAAe,EACf,iBAAiB;AACjB,YAAY;AACZ,MAAM,GAkBN,MAAM,aAAa,CAAC;AACrB,OAAO,EAIN,iBAAiB,GACjB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAEN,sBAAsB,GAGtB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAEN,iBAAiB,GAGjB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAEN,mBAAmB,IAAI,qBAAqB,GAE5C,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAEN,YAAY,GAGZ,MAAM,aAAa,CAAC","sourcesContent":["/**\n * A tool for enforcing repository policies and standards across codebases.\n *\n * @remarks\n * Repopo provides a framework for defining and enforcing policies across repositories,\n * such as file headers, package.json consistency, and other code standards.\n * It can be used as a CLI tool or integrated into CI/CD pipelines.\n *\n * @packageDocumentation\n */\n\nexport { run } from \"@oclif/core\";\nexport {\n\ttype FluidAdapterOptions,\n\ttype FluidHandler,\n\tfromFluidHandlers,\n} from \"./adapters/fluidFramework.js\";\nexport type {\n\t// PolicyList,\n\tRepopoConfig,\n} from \"./config.js\";\nexport type { ExcludedPolicyFileMap } from \"./context.js\";\nexport {\n\tmakePolicy,\n\tmakePolicyDefinition,\n\ttype PolicyDefinitionInput,\n\ttype PolicyOptions,\n\tpolicy,\n} from \"./makePolicy.js\";\nexport type { PolicyAction, PolicyHandlerPerfStats } from \"./perf.js\";\nexport {\n\ttype ConfiguredPolicy,\n\ttype IdentifiedPolicy,\n\t// Type guards\n\tisPolicyError,\n\tisPolicyFailure,\n\tisPolicyFixResult,\n\t// New types\n\tPolicy,\n\ttype PolicyArgs,\n\t// Legacy types (for backward compatibility)\n\ttype PolicyDefinition,\n\ttype PolicyError,\n\ttype PolicyFailure,\n\ttype PolicyFixResult,\n\ttype PolicyFunctionArguments,\n\ttype PolicyHandler,\n\ttype PolicyHandlerResult,\n\ttype PolicyInstance,\n\ttype PolicyInstanceId,\n\ttype PolicyInstanceSettings,\n\ttype PolicyName,\n\ttype PolicyResolver,\n\ttype PolicyResult,\n\ttype PolicyShape,\n\ttype PolicyStandaloneResolver,\n} from \"./policy.js\";\nexport {\n\ttype CargoToml,\n\ttype CargoTomlHandler,\n\ttype DefineCargoPolicyArgs,\n\tdefineCargoPolicy,\n} from \"./policyDefiners/defineCargoPolicy.js\";\nexport {\n\ttype DefineFileHeaderPolicyArgs,\n\tdefineFileHeaderPolicy,\n\ttype FileHeaderGeneratorConfig,\n\ttype FileHeaderPolicyConfig,\n} from \"./policyDefiners/defineFileHeaderPolicy.js\";\nexport {\n\ttype DefineGleamPolicyArgs,\n\tdefineGleamPolicy,\n\ttype GleamToml,\n\ttype GleamTomlHandler,\n} from \"./policyDefiners/defineGleamPolicy.js\";\nexport {\n\ttype DefinePackagePolicyArgs,\n\tdefinePackagePolicy as generatePackagePolicy,\n\ttype PackageJsonHandler,\n} from \"./policyDefiners/definePackagePolicy.js\";\nexport {\n\ttype PolicyFileResult,\n\tPolicyRunner,\n\ttype PolicyRunnerOptions,\n\ttype PolicyRunResults,\n} from \"./runner.js\";\n"]}