repopo 0.10.0 → 0.13.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 (340) hide show
  1. package/CHANGELOG.md +113 -0
  2. package/README.md +76 -77
  3. package/THIRD-PARTY-LICENSES.txt +232 -14
  4. package/bin/dev.js +5 -1
  5. package/esm/adapters/fluidFramework.d.ts +13 -9
  6. package/esm/adapters/fluidFramework.d.ts.map +1 -1
  7. package/esm/adapters/fluidFramework.js +20 -43
  8. package/esm/adapters/fluidFramework.js.map +1 -1
  9. package/esm/api.d.ts +64 -1
  10. package/esm/api.d.ts.map +1 -1
  11. package/esm/api.js +17 -1
  12. package/esm/api.js.map +1 -1
  13. package/esm/baseCommand.d.ts +1 -1
  14. package/esm/baseCommand.d.ts.map +1 -1
  15. package/esm/baseCommand.js +7 -10
  16. package/esm/baseCommand.js.map +1 -1
  17. package/esm/commands/check-native.d.ts +25 -0
  18. package/esm/commands/check-native.d.ts.map +1 -0
  19. package/esm/commands/check-native.js +156 -0
  20. package/esm/commands/check-native.js.map +1 -0
  21. package/esm/commands/check.d.ts +7 -34
  22. package/esm/commands/check.d.ts.map +1 -1
  23. package/esm/commands/check.js +76 -265
  24. package/esm/commands/check.js.map +1 -1
  25. package/esm/commands/list.d.ts.map +1 -1
  26. package/esm/commands/list.js +6 -6
  27. package/esm/commands/list.js.map +1 -1
  28. package/esm/concurrency.d.ts +3 -0
  29. package/esm/concurrency.d.ts.map +1 -0
  30. package/esm/concurrency.js +8 -0
  31. package/esm/concurrency.js.map +1 -0
  32. package/esm/config.d.ts +5 -39
  33. package/esm/config.d.ts.map +1 -1
  34. package/esm/config.js +3 -7
  35. package/esm/config.js.map +1 -1
  36. package/esm/context.d.ts +20 -3
  37. package/esm/context.d.ts.map +1 -1
  38. package/esm/context.js +18 -1
  39. package/esm/context.js.map +1 -1
  40. package/esm/executionContractError.d.ts +4 -0
  41. package/esm/executionContractError.d.ts.map +1 -0
  42. package/esm/executionContractError.js +4 -0
  43. package/esm/executionContractError.js.map +1 -0
  44. package/esm/fileCache.d.ts +12 -0
  45. package/esm/fileCache.d.ts.map +1 -0
  46. package/esm/fileCache.js +37 -0
  47. package/esm/fileCache.js.map +1 -0
  48. package/esm/filePaths.d.ts +2 -0
  49. package/esm/filePaths.d.ts.map +1 -0
  50. package/esm/filePaths.js +9 -0
  51. package/esm/filePaths.js.map +1 -0
  52. package/esm/generators.d.ts +0 -20
  53. package/esm/generators.d.ts.map +1 -1
  54. package/esm/generators.js.map +1 -1
  55. package/esm/index.d.ts +3 -11
  56. package/esm/index.d.ts.map +1 -1
  57. package/esm/index.js +3 -14
  58. package/esm/index.js.map +1 -1
  59. package/esm/makePolicy.d.ts +26 -79
  60. package/esm/makePolicy.d.ts.map +1 -1
  61. package/esm/makePolicy.js +51 -95
  62. package/esm/makePolicy.js.map +1 -1
  63. package/esm/perf.d.ts +10 -2
  64. package/esm/perf.d.ts.map +1 -1
  65. package/esm/perf.js +10 -9
  66. package/esm/perf.js.map +1 -1
  67. package/esm/policies/CargoLicenceValidated.d.ts +41 -0
  68. package/esm/policies/CargoLicenceValidated.d.ts.map +1 -0
  69. package/esm/policies/CargoLicenceValidated.js +47 -0
  70. package/esm/policies/CargoLicenceValidated.js.map +1 -0
  71. package/esm/policies/CargoLintsConfigured.d.ts +30 -0
  72. package/esm/policies/CargoLintsConfigured.d.ts.map +1 -0
  73. package/esm/policies/CargoLintsConfigured.js +65 -0
  74. package/esm/policies/CargoLintsConfigured.js.map +1 -0
  75. package/esm/policies/CargoLockPolicy.d.ts +34 -0
  76. package/esm/policies/CargoLockPolicy.d.ts.map +1 -0
  77. package/esm/policies/CargoLockPolicy.js +61 -0
  78. package/esm/policies/CargoLockPolicy.js.map +1 -0
  79. package/esm/policies/CargoTomlRequired.d.ts +34 -0
  80. package/esm/policies/CargoTomlRequired.d.ts.map +1 -0
  81. package/esm/policies/CargoTomlRequired.js +77 -0
  82. package/esm/policies/CargoTomlRequired.js.map +1 -0
  83. package/esm/policies/CargoTomlSorted.d.ts +20 -0
  84. package/esm/policies/CargoTomlSorted.d.ts.map +1 -0
  85. package/esm/policies/CargoTomlSorted.js +168 -0
  86. package/esm/policies/CargoTomlSorted.js.map +1 -0
  87. package/esm/policies/ConditionalScripts.d.ts +10 -8
  88. package/esm/policies/ConditionalScripts.d.ts.map +1 -1
  89. package/esm/policies/ConditionalScripts.js +27 -24
  90. package/esm/policies/ConditionalScripts.js.map +1 -1
  91. package/esm/policies/ExactScripts.d.ts +8 -6
  92. package/esm/policies/ExactScripts.d.ts.map +1 -1
  93. package/esm/policies/ExactScripts.js +18 -20
  94. package/esm/policies/ExactScripts.js.map +1 -1
  95. package/esm/policies/GleamDepVersions.d.ts +25 -0
  96. package/esm/policies/GleamDepVersions.d.ts.map +1 -0
  97. package/esm/policies/GleamDepVersions.js +67 -0
  98. package/esm/policies/GleamDepVersions.js.map +1 -0
  99. package/esm/policies/GleamDocExists.d.ts +24 -0
  100. package/esm/policies/GleamDocExists.d.ts.map +1 -0
  101. package/esm/policies/GleamDocExists.js +39 -0
  102. package/esm/policies/GleamDocExists.js.map +1 -0
  103. package/esm/policies/GleamInternalModulesConfigured.d.ts +21 -0
  104. package/esm/policies/GleamInternalModulesConfigured.d.ts.map +1 -0
  105. package/esm/policies/GleamInternalModulesConfigured.js +32 -0
  106. package/esm/policies/GleamInternalModulesConfigured.js.map +1 -0
  107. package/esm/policies/GleamLicenceConfigured.d.ts +29 -0
  108. package/esm/policies/GleamLicenceConfigured.d.ts.map +1 -0
  109. package/esm/policies/GleamLicenceConfigured.js +36 -0
  110. package/esm/policies/GleamLicenceConfigured.js.map +1 -0
  111. package/esm/policies/GleamManifestCommitted.d.ts +16 -0
  112. package/esm/policies/GleamManifestCommitted.d.ts.map +1 -0
  113. package/esm/policies/GleamManifestCommitted.js +27 -0
  114. package/esm/policies/GleamManifestCommitted.js.map +1 -0
  115. package/esm/policies/GleamMonorepoConsistency.d.ts +38 -0
  116. package/esm/policies/GleamMonorepoConsistency.d.ts.map +1 -0
  117. package/esm/policies/GleamMonorepoConsistency.js +74 -0
  118. package/esm/policies/GleamMonorepoConsistency.js.map +1 -0
  119. package/esm/policies/GleamNameRestrictions.d.ts +25 -0
  120. package/esm/policies/GleamNameRestrictions.d.ts.map +1 -0
  121. package/esm/policies/GleamNameRestrictions.js +44 -0
  122. package/esm/policies/GleamNameRestrictions.js.map +1 -0
  123. package/esm/policies/GleamNoPathDepsInPublished.d.ts +22 -0
  124. package/esm/policies/GleamNoPathDepsInPublished.d.ts.map +1 -0
  125. package/esm/policies/GleamNoPathDepsInPublished.js +43 -0
  126. package/esm/policies/GleamNoPathDepsInPublished.js.map +1 -0
  127. package/esm/policies/GleamPathDepsValid.d.ts +9 -0
  128. package/esm/policies/GleamPathDepsValid.d.ts.map +1 -0
  129. package/esm/policies/GleamPathDepsValid.js +59 -0
  130. package/esm/policies/GleamPathDepsValid.js.map +1 -0
  131. package/esm/policies/GleamProjectStructure.d.ts +32 -0
  132. package/esm/policies/GleamProjectStructure.d.ts.map +1 -0
  133. package/esm/policies/GleamProjectStructure.js +32 -0
  134. package/esm/policies/GleamProjectStructure.js.map +1 -0
  135. package/esm/policies/GleamSharedDependencyVersions.d.ts +37 -0
  136. package/esm/policies/GleamSharedDependencyVersions.d.ts.map +1 -0
  137. package/esm/policies/GleamSharedDependencyVersions.js +101 -0
  138. package/esm/policies/GleamSharedDependencyVersions.js.map +1 -0
  139. package/esm/policies/GleamTomlRequired.d.ts +30 -0
  140. package/esm/policies/GleamTomlRequired.d.ts.map +1 -0
  141. package/esm/policies/GleamTomlRequired.js +37 -0
  142. package/esm/policies/GleamTomlRequired.js.map +1 -0
  143. package/esm/policies/GleamTomlSorted.d.ts +20 -0
  144. package/esm/policies/GleamTomlSorted.d.ts.map +1 -0
  145. package/esm/policies/GleamTomlSorted.js +157 -0
  146. package/esm/policies/GleamTomlSorted.js.map +1 -0
  147. package/esm/policies/GleamVersionConstraint.d.ts +20 -0
  148. package/esm/policies/GleamVersionConstraint.d.ts.map +1 -0
  149. package/esm/policies/GleamVersionConstraint.js +68 -0
  150. package/esm/policies/GleamVersionConstraint.js.map +1 -0
  151. package/esm/policies/HtmlFileHeaders.d.ts +4 -2
  152. package/esm/policies/HtmlFileHeaders.d.ts.map +1 -1
  153. package/esm/policies/HtmlFileHeaders.js +2 -2
  154. package/esm/policies/HtmlFileHeaders.js.map +1 -1
  155. package/esm/policies/JsTsFileHeaders.d.ts +4 -2
  156. package/esm/policies/JsTsFileHeaders.d.ts.map +1 -1
  157. package/esm/policies/JsTsFileHeaders.js +1 -1
  158. package/esm/policies/JsTsFileHeaders.js.map +1 -1
  159. package/esm/policies/LicenseFileExists.d.ts +10 -4
  160. package/esm/policies/LicenseFileExists.d.ts.map +1 -1
  161. package/esm/policies/LicenseFileExists.js +27 -20
  162. package/esm/policies/LicenseFileExists.js.map +1 -1
  163. package/esm/policies/MutuallyExclusiveScripts.d.ts +8 -6
  164. package/esm/policies/MutuallyExclusiveScripts.d.ts.map +1 -1
  165. package/esm/policies/MutuallyExclusiveScripts.js +9 -13
  166. package/esm/policies/MutuallyExclusiveScripts.js.map +1 -1
  167. package/esm/policies/NoBuildDirectory.d.ts +15 -0
  168. package/esm/policies/NoBuildDirectory.d.ts.map +1 -0
  169. package/esm/policies/NoBuildDirectory.js +24 -0
  170. package/esm/policies/NoBuildDirectory.js.map +1 -0
  171. package/esm/policies/NoJsFileExtensions.d.ts +9 -3
  172. package/esm/policies/NoJsFileExtensions.d.ts.map +1 -1
  173. package/esm/policies/NoJsFileExtensions.js +9 -14
  174. package/esm/policies/NoJsFileExtensions.js.map +1 -1
  175. package/esm/policies/NoLargeBinaryFiles.d.ts +9 -4
  176. package/esm/policies/NoLargeBinaryFiles.d.ts.map +1 -1
  177. package/esm/policies/NoLargeBinaryFiles.js +10 -16
  178. package/esm/policies/NoLargeBinaryFiles.js.map +1 -1
  179. package/esm/policies/NoPrivateWorkspaceDependencies.d.ts +10 -6
  180. package/esm/policies/NoPrivateWorkspaceDependencies.d.ts.map +1 -1
  181. package/esm/policies/NoPrivateWorkspaceDependencies.js +12 -14
  182. package/esm/policies/NoPrivateWorkspaceDependencies.js.map +1 -1
  183. package/esm/policies/NoTargetArtifacts.d.ts +14 -0
  184. package/esm/policies/NoTargetArtifacts.d.ts.map +1 -0
  185. package/esm/policies/NoTargetArtifacts.js +37 -0
  186. package/esm/policies/NoTargetArtifacts.js.map +1 -0
  187. package/esm/policies/NoUnsafeWithoutJustification.d.ts +31 -0
  188. package/esm/policies/NoUnsafeWithoutJustification.d.ts.map +1 -0
  189. package/esm/policies/NoUnsafeWithoutJustification.js +79 -0
  190. package/esm/policies/NoUnsafeWithoutJustification.js.map +1 -0
  191. package/esm/policies/NoWildcardDependencies.d.ts +30 -0
  192. package/esm/policies/NoWildcardDependencies.d.ts.map +1 -0
  193. package/esm/policies/NoWildcardDependencies.js +83 -0
  194. package/esm/policies/NoWildcardDependencies.js.map +1 -0
  195. package/esm/policies/PackageAllowedScopes.d.ts +9 -5
  196. package/esm/policies/PackageAllowedScopes.d.ts.map +1 -1
  197. package/esm/policies/PackageAllowedScopes.js +15 -16
  198. package/esm/policies/PackageAllowedScopes.js.map +1 -1
  199. package/esm/policies/PackageEsmType.d.ts +7 -5
  200. package/esm/policies/PackageEsmType.d.ts.map +1 -1
  201. package/esm/policies/PackageEsmType.js +38 -36
  202. package/esm/policies/PackageEsmType.js.map +1 -1
  203. package/esm/policies/PackageFolderName.d.ts +8 -6
  204. package/esm/policies/PackageFolderName.d.ts.map +1 -1
  205. package/esm/policies/PackageFolderName.js +13 -16
  206. package/esm/policies/PackageFolderName.js.map +1 -1
  207. package/esm/policies/PackageJsonProperties.d.ts +5 -3
  208. package/esm/policies/PackageJsonProperties.d.ts.map +1 -1
  209. package/esm/policies/PackageJsonProperties.js +18 -21
  210. package/esm/policies/PackageJsonProperties.js.map +1 -1
  211. package/esm/policies/PackageJsonRepoDirectoryProperty.d.ts +2 -7
  212. package/esm/policies/PackageJsonRepoDirectoryProperty.d.ts.map +1 -1
  213. package/esm/policies/PackageJsonRepoDirectoryProperty.js +29 -42
  214. package/esm/policies/PackageJsonRepoDirectoryProperty.js.map +1 -1
  215. package/esm/policies/PackageJsonSorted.d.ts +2 -2
  216. package/esm/policies/PackageJsonSorted.d.ts.map +1 -1
  217. package/esm/policies/PackageJsonSorted.js +51 -31
  218. package/esm/policies/PackageJsonSorted.js.map +1 -1
  219. package/esm/policies/PackageLicense.d.ts +4 -4
  220. package/esm/policies/PackageLicense.d.ts.map +1 -1
  221. package/esm/policies/PackageLicense.js +32 -54
  222. package/esm/policies/PackageLicense.js.map +1 -1
  223. package/esm/policies/PackagePrivateField.d.ts +12 -8
  224. package/esm/policies/PackagePrivateField.d.ts.map +1 -1
  225. package/esm/policies/PackagePrivateField.js +34 -25
  226. package/esm/policies/PackagePrivateField.js.map +1 -1
  227. package/esm/policies/PackageReadme.d.ts +6 -5
  228. package/esm/policies/PackageReadme.d.ts.map +1 -1
  229. package/esm/policies/PackageReadme.js +24 -61
  230. package/esm/policies/PackageReadme.js.map +1 -1
  231. package/esm/policies/PackageScripts.d.ts +26 -22
  232. package/esm/policies/PackageScripts.d.ts.map +1 -1
  233. package/esm/policies/PackageScripts.js +42 -38
  234. package/esm/policies/PackageScripts.js.map +1 -1
  235. package/esm/policies/PackageTestScripts.d.ts +10 -6
  236. package/esm/policies/PackageTestScripts.d.ts.map +1 -1
  237. package/esm/policies/PackageTestScripts.js +17 -19
  238. package/esm/policies/PackageTestScripts.js.map +1 -1
  239. package/esm/policies/PublicApiDocumented.d.ts +21 -0
  240. package/esm/policies/PublicApiDocumented.d.ts.map +1 -0
  241. package/esm/policies/PublicApiDocumented.js +38 -0
  242. package/esm/policies/PublicApiDocumented.js.map +1 -0
  243. package/esm/policies/RequiredGitignorePatterns.d.ts +11 -4
  244. package/esm/policies/RequiredGitignorePatterns.d.ts.map +1 -1
  245. package/esm/policies/RequiredGitignorePatterns.js +29 -36
  246. package/esm/policies/RequiredGitignorePatterns.js.map +1 -1
  247. package/esm/policies/RequiredScripts.d.ts +9 -7
  248. package/esm/policies/RequiredScripts.d.ts.map +1 -1
  249. package/esm/policies/RequiredScripts.js +27 -26
  250. package/esm/policies/RequiredScripts.js.map +1 -1
  251. package/esm/policies/RustDocExists.d.ts +24 -0
  252. package/esm/policies/RustDocExists.d.ts.map +1 -0
  253. package/esm/policies/RustDocExists.js +49 -0
  254. package/esm/policies/RustDocExists.js.map +1 -0
  255. package/esm/policies/RustToolchainExists.d.ts +27 -0
  256. package/esm/policies/RustToolchainExists.d.ts.map +1 -0
  257. package/esm/policies/RustToolchainExists.js +28 -0
  258. package/esm/policies/RustToolchainExists.js.map +1 -0
  259. package/esm/policies/RustfmtConfigExists.d.ts +27 -0
  260. package/esm/policies/RustfmtConfigExists.d.ts.map +1 -0
  261. package/esm/policies/RustfmtConfigExists.js +28 -0
  262. package/esm/policies/RustfmtConfigExists.js.map +1 -0
  263. package/esm/policies/ScriptContains.d.ts +9 -7
  264. package/esm/policies/ScriptContains.d.ts.map +1 -1
  265. package/esm/policies/ScriptContains.js +9 -13
  266. package/esm/policies/ScriptContains.js.map +1 -1
  267. package/esm/policies/SharedDependencyVersions.d.ts +29 -0
  268. package/esm/policies/SharedDependencyVersions.d.ts.map +1 -0
  269. package/esm/policies/SharedDependencyVersions.js +143 -0
  270. package/esm/policies/SharedDependencyVersions.js.map +1 -0
  271. package/esm/policies/WorkspaceInheritance.d.ts +31 -0
  272. package/esm/policies/WorkspaceInheritance.d.ts.map +1 -0
  273. package/esm/policies/WorkspaceInheritance.js +93 -0
  274. package/esm/policies/WorkspaceInheritance.js.map +1 -0
  275. package/esm/policies/WorkspaceMembersValid.d.ts +27 -0
  276. package/esm/policies/WorkspaceMembersValid.d.ts.map +1 -0
  277. package/esm/policies/WorkspaceMembersValid.js +87 -0
  278. package/esm/policies/WorkspaceMembersValid.js.map +1 -0
  279. package/esm/policies/constants.d.ts +8 -0
  280. package/esm/policies/constants.d.ts.map +1 -1
  281. package/esm/policies/constants.js +9 -1
  282. package/esm/policies/constants.js.map +1 -1
  283. package/esm/policies.d.ts +43 -5
  284. package/esm/policies.d.ts.map +1 -1
  285. package/esm/policies.js +63 -6
  286. package/esm/policies.js.map +1 -1
  287. package/esm/policy.d.ts +65 -269
  288. package/esm/policy.d.ts.map +1 -1
  289. package/esm/policy.js +1 -122
  290. package/esm/policy.js.map +1 -1
  291. package/esm/policyDefiners/defineCargoPolicy.d.ts +82 -0
  292. package/esm/policyDefiners/defineCargoPolicy.d.ts.map +1 -0
  293. package/esm/policyDefiners/defineCargoPolicy.js +42 -0
  294. package/esm/policyDefiners/defineCargoPolicy.js.map +1 -0
  295. package/esm/policyDefiners/defineFileHeaderPolicy.d.ts +27 -14
  296. package/esm/policyDefiners/defineFileHeaderPolicy.d.ts.map +1 -1
  297. package/esm/policyDefiners/defineFileHeaderPolicy.js +19 -39
  298. package/esm/policyDefiners/defineFileHeaderPolicy.js.map +1 -1
  299. package/esm/policyDefiners/defineGleamPolicy.d.ts +81 -0
  300. package/esm/policyDefiners/defineGleamPolicy.d.ts.map +1 -0
  301. package/esm/policyDefiners/defineGleamPolicy.js +42 -0
  302. package/esm/policyDefiners/defineGleamPolicy.js.map +1 -0
  303. package/esm/policyDefiners/definePackagePolicy.d.ts +24 -13
  304. package/esm/policyDefiners/definePackagePolicy.d.ts.map +1 -1
  305. package/esm/policyDefiners/definePackagePolicy.js +9 -32
  306. package/esm/policyDefiners/definePackagePolicy.js.map +1 -1
  307. package/esm/policyDefiners/spdxValidator.d.ts +66 -0
  308. package/esm/policyDefiners/spdxValidator.d.ts.map +1 -0
  309. package/esm/policyDefiners/spdxValidator.js +139 -0
  310. package/esm/policyDefiners/spdxValidator.js.map +1 -0
  311. package/esm/policyDefiners/tomlParser.d.ts +8 -0
  312. package/esm/policyDefiners/tomlParser.d.ts.map +1 -0
  313. package/esm/policyDefiners/tomlParser.js +17 -0
  314. package/esm/policyDefiners/tomlParser.js.map +1 -0
  315. package/esm/policyExecution.d.ts +19 -0
  316. package/esm/policyExecution.d.ts.map +1 -0
  317. package/esm/policyExecution.js +224 -0
  318. package/esm/policyExecution.js.map +1 -0
  319. package/esm/repositoryFiles.d.ts +4 -0
  320. package/esm/repositoryFiles.d.ts.map +1 -0
  321. package/esm/repositoryFiles.js +8 -0
  322. package/esm/repositoryFiles.js.map +1 -0
  323. package/esm/runner.d.ts +85 -0
  324. package/esm/runner.d.ts.map +1 -0
  325. package/esm/runner.js +189 -0
  326. package/esm/runner.js.map +1 -0
  327. package/esm/settlePolicyPromise.d.ts +4 -0
  328. package/esm/settlePolicyPromise.d.ts.map +1 -0
  329. package/esm/settlePolicyPromise.js +10 -0
  330. package/esm/settlePolicyPromise.js.map +1 -0
  331. package/esm/tsdoc-metadata.json +1 -1
  332. package/esm/utils/safePaths.d.ts +9 -0
  333. package/esm/utils/safePaths.d.ts.map +1 -0
  334. package/esm/utils/safePaths.js +40 -0
  335. package/esm/utils/safePaths.js.map +1 -0
  336. package/oclif.manifest.json +117 -3
  337. package/package.json +66 -36
  338. package/scripts/benchmark.mjs +341 -0
  339. package/scripts/postinstall.mjs +154 -0
  340. package/sidecar/sidecar.mjs +399 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-native.js","sourceRoot":"","sources":["../../src/commands/check-native.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7E,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,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EAAE,CAAC;YAC3B,OAAO,SAAS,CAAC;QAClB,CAAC;QAED,MAAM,IAAI,KAAK,CACd,yCAAyC;YACxC,+EAA+E;YAC/E,2EAA2E,CAC5E,CAAC;IACH,CAAC;IAEO,kBAAkB,CAAC,QAAiB;QAC3C,IAAI,QAAQ,EAAE,CAAC;YACd,OAAO,QAAQ,CAAC;QACjB,CAAC;QAED,MAAM,WAAW,GAAG,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QACnD,OAAO,OAAO,CAAC,WAAW,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;IACvD,CAAC","sourcesContent":["import { spawn } from \"node:child_process\";\nimport { existsSync } from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport { Command, Flags } from \"@oclif/core\";\nimport { dirname, resolve } from \"pathe\";\nimport { DEFAULT_CONCURRENCY, validateConcurrency } from \"../concurrency.js\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\n/**\n * Runs the Rust-based repopo-core engine with the Node.js sidecar for\n * per-policy execution. Rust owns matching, ordering, concurrency, exception\n * boundaries, repository scheduling and aggregation.\n */\nexport class CheckNative extends Command {\n\tpublic static override readonly summary =\n\t\t\"Checks and applies policies using the Rust engine.\";\n\n\tpublic static override readonly description =\n\t\t\"Runs the Rust-based repopo-core engine with the Node.js sidecar. \" +\n\t\t\"Rust handles file matching, scheduling and reporting; the sidecar shares per-policy contracts with 'check'. \" +\n\t\t\"Repository policies always run with the full repository inventory, including with --stdin. \" +\n\t\t\"With --fix, repository policies can modify files outside the stdin selection.\";\n\n\tpublic static override readonly flags = {\n\t\tconcurrency: Flags.integer({\n\t\t\tdescription:\n\t\t\t\t\"Maximum concurrent files in read-only checks. Fixes remain sequential.\",\n\t\t\tdefault: DEFAULT_CONCURRENCY,\n\t\t\tparse: async (value) => validateConcurrency(Number(value)),\n\t\t}),\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\tverbose: Flags.boolean({\n\t\t\tdescription: \"Show verbose output including per-policy timing.\",\n\t\t\trequired: false,\n\t\t\tchar: \"v\",\n\t\t}),\n\t\tquiet: Flags.boolean({\n\t\t\tdescription: \"Suppress all output except errors.\",\n\t\t\trequired: false,\n\t\t\tchar: \"q\",\n\t\t}),\n\t\tconfig: Flags.string({\n\t\t\tdescription: \"Path to the config file.\",\n\t\t\trequired: false,\n\t\t\tchar: \"c\",\n\t\t}),\n\t\t\"sidecar-path\": Flags.string({\n\t\t\tdescription: \"Path to the Node.js sidecar script.\",\n\t\t\trequired: false,\n\t\t\tenv: \"REPOPO_SIDECAR_PATH\",\n\t\t}),\n\t\t\"binary-path\": Flags.string({\n\t\t\tdescription: \"Path to the repopo-core Rust binary.\",\n\t\t\trequired: false,\n\t\t\tenv: \"REPOPO_CORE_PATH\",\n\t\t}),\n\t\truntime: Flags.string({\n\t\t\tdescription: \"JS runtime for the sidecar process (auto, node, bun).\",\n\t\t\trequired: false,\n\t\t\tenv: \"REPOPO_RUNTIME\",\n\t\t\toptions: [\"auto\", \"node\", \"bun\"],\n\t\t}),\n\t} as const;\n\n\tpublic override async run(): Promise<void> {\n\t\tconst { flags } = await this.parse(CheckNative);\n\n\t\tconst binaryPath = this.resolveBinaryPath(flags[\"binary-path\"]);\n\t\tconst sidecarPath = this.resolveSidecarPath(flags[\"sidecar-path\"]);\n\n\t\tconst args: string[] = [\"check\", \"--sidecar-path\", sidecarPath];\n\t\targs.push(\"--concurrency\", String(flags.concurrency));\n\n\t\tif (flags.fix) {\n\t\t\targs.push(\"--fix\");\n\t\t}\n\t\tif (flags.stdin) {\n\t\t\targs.push(\"--stdin\");\n\t\t}\n\t\tif (flags.verbose) {\n\t\t\targs.push(\"--verbose\");\n\t\t}\n\t\tif (flags.quiet) {\n\t\t\targs.push(\"--quiet\");\n\t\t}\n\t\tif (flags.config) {\n\t\t\targs.push(\"--config\", flags.config);\n\t\t}\n\t\tif (flags.runtime) {\n\t\t\targs.push(\"--runtime\", flags.runtime);\n\t\t}\n\n\t\treturn new Promise<void>((resolvePromise, reject) => {\n\t\t\tconst child = spawn(binaryPath, args, {\n\t\t\t\tstdio: \"inherit\",\n\t\t\t\t// biome-ignore lint/style/noProcessEnv: Need to pass parent environment to child process\n\t\t\t\tenv: { ...process.env },\n\t\t\t});\n\t\t\tconst interrupt = () => child.kill(\"SIGINT\");\n\t\t\tconst terminate = () => child.kill(\"SIGTERM\");\n\t\t\tconst cleanup = () => {\n\t\t\t\tprocess.removeListener(\"SIGINT\", interrupt);\n\t\t\t\tprocess.removeListener(\"SIGTERM\", terminate);\n\t\t\t};\n\t\t\tprocess.on(\"SIGINT\", interrupt);\n\t\t\tprocess.on(\"SIGTERM\", terminate);\n\n\t\t\tchild.on(\"error\", (err) => {\n\t\t\t\tcleanup();\n\t\t\t\treject(\n\t\t\t\t\tnew Error(\n\t\t\t\t\t\t`Failed to spawn repopo-core: ${err.message}\\n` +\n\t\t\t\t\t\t\t`Binary path: ${binaryPath}\\n` +\n\t\t\t\t\t\t\t\"Make sure the Rust binary has been built: cargo build --manifest-path crates/core/Cargo.toml\",\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t});\n\n\t\t\tchild.on(\"close\", (code, signal) => {\n\t\t\t\tcleanup();\n\t\t\t\tif (code !== 0) {\n\t\t\t\t\tprocess.exitCode =\n\t\t\t\t\t\tcode ??\n\t\t\t\t\t\t(signal === \"SIGINT\" ? 130 : signal === \"SIGTERM\" ? 143 : 1);\n\t\t\t\t}\n\t\t\t\tresolvePromise();\n\t\t\t});\n\t\t});\n\t}\n\n\tprivate resolveBinaryPath(explicit?: string): string {\n\t\tif (explicit) {\n\t\t\treturn explicit;\n\t\t}\n\n\t\tconst packageRoot = resolve(__dirname, \"..\", \"..\");\n\t\tconst binaryName =\n\t\t\tprocess.platform === \"win32\" ? \"repopo-core.exe\" : \"repopo-core\";\n\n\t\t// Check paths in priority order:\n\t\t// 1. Postinstall-downloaded binary (npm install)\n\t\tconst nativePath = resolve(packageRoot, \"native\", binaryName);\n\t\tif (existsSync(nativePath)) {\n\t\t\treturn nativePath;\n\t\t}\n\n\t\t// 2. Local release build (cargo build --release)\n\t\tconst releasePath = resolve(\n\t\t\tpackageRoot,\n\t\t\t\"crates\",\n\t\t\t\"core\",\n\t\t\t\"target\",\n\t\t\t\"release\",\n\t\t\tbinaryName,\n\t\t);\n\t\tif (existsSync(releasePath)) {\n\t\t\treturn releasePath;\n\t\t}\n\n\t\t// 3. Local debug build (cargo build)\n\t\tconst debugPath = resolve(\n\t\t\tpackageRoot,\n\t\t\t\"crates\",\n\t\t\t\"core\",\n\t\t\t\"target\",\n\t\t\t\"debug\",\n\t\t\tbinaryName,\n\t\t);\n\t\tif (existsSync(debugPath)) {\n\t\t\treturn debugPath;\n\t\t}\n\n\t\tthrow new Error(\n\t\t\t\"repopo-core binary not found. Either:\\n\" +\n\t\t\t\t\" - Install the package (npm install repopo) to download pre-built binaries\\n\" +\n\t\t\t\t\" - Build from source: cargo build --manifest-path crates/core/Cargo.toml\",\n\t\t);\n\t}\n\n\tprivate resolveSidecarPath(explicit?: string): string {\n\t\tif (explicit) {\n\t\t\treturn explicit;\n\t\t}\n\n\t\tconst packageRoot = resolve(__dirname, \"..\", \"..\");\n\t\treturn resolve(packageRoot, \"sidecar\", \"sidecar.mjs\");\n\t}\n}\n"]}
@@ -1,48 +1,21 @@
1
1
  import { BaseRepopoCommand } from "../baseCommand.js";
2
- /**
3
- * This tool enforces policies across the code base via a series of handler functions. The handler functions are
4
- * associated with a regular expression, and all files matching that expression are passed to the handler function.
5
- *
6
- * By default, the list of files to check comes from `git ls-files. You can also pipe in file names from stdin. For
7
- * example:
8
- *
9
- * `git ls-files -co --exclude-standard --full-name | repopo check --stdin --verbose`
10
- */
2
+ /** Check selected files and the complete repository inventory. */
11
3
  export declare class CheckPolicy<T extends typeof BaseRepopoCommand & {
12
4
  args: typeof CheckPolicy.args;
13
5
  flags: typeof CheckPolicy.flags;
14
6
  }> extends BaseRepopoCommand<T> {
15
7
  static readonly summary = "Checks and applies policies to the files in the repository.";
8
+ static readonly description: string;
16
9
  static readonly flags: {
17
10
  readonly config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ readonly concurrency: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
18
12
  readonly fix: import("@oclif/core/interfaces").BooleanFlag<boolean>;
19
13
  readonly stdin: import("@oclif/core/interfaces").BooleanFlag<boolean>;
20
14
  };
21
15
  run(): Promise<void>;
22
- /**
23
- * Executes all policies against the provided paths.
24
- *
25
- * @param pathsToCheck - All paths that should be checked. Paths should be relative to the repository root.
26
- * @param context - The context.
27
- */
28
- private checkAllFiles;
29
- /**
30
- * Given a string that represents a path to a file in the repo, determines if the file should be checked, and if so,
31
- * routes the file to the appropriate handlers.
32
- *
33
- * @param relPath - A git repo-relative path to a file.
34
- */
35
- private checkOrExcludeFile;
36
- private routeToPolicies;
37
- private runPolicyOnFile;
38
- private isPolicyExcluded;
39
- private executePolicyHandler;
40
- private handlePolicyResult;
41
- private handleFixResult;
42
- private handlePolicyErrorFixResult;
43
- private handleFailureResult;
44
- private attemptResolution;
45
- private logPolicyFailure;
46
- private logMessages;
16
+ private reportFinding;
17
+ private reportError;
18
+ private collectFilePaths;
19
+ private collectRepositoryFiles;
47
20
  }
48
21
  //# sourceMappingURL=check.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/commands/check.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAkCtD;;;;;;;;GAQG;AACH,qBAAa,WAAW,CACvB,CAAC,SAAS,OAAO,iBAAiB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1,34 @@
1
- import { EOL as newline } from "node:os";
2
1
  import process from "node:process";
3
2
  import { Flags } from "@oclif/core";
4
- import { StringBuilder } from "@rushstack/node-core-library";
5
- import { all, call, run } from "effection";
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
3
  import { BaseRepopoCommand } from "../baseCommand.js";
17
- import { logStats, runWithPerf } from "../perf.js";
18
- import { isPolicyError, isPolicyFixResult, } from "../policy.js";
4
+ import { DEFAULT_CONCURRENCY, validateConcurrency } from "../concurrency.js";
5
+ import { parseFilePaths } from "../filePaths.js";
6
+ import { logStats } from "../perf.js";
7
+ import { readRepositoryFiles } from "../repositoryFiles.js";
8
+ import { runPolicies, } from "../runner.js";
9
+ import { normalizeRepoRelativeFilePath } from "../utils/safePaths.js";
19
10
  async function readStdin() {
20
- return new Promise((resolve) => {
21
- const stdin = process.stdin;
22
- stdin.setEncoding("utf8");
23
- let data = "";
24
- stdin.on("data", (chunk) => {
25
- data += chunk;
26
- });
27
- stdin.on("end", () => {
28
- resolve(data);
29
- });
30
- if (stdin.isTTY) {
31
- resolve("");
32
- }
33
- });
11
+ if (process.stdin.isTTY) {
12
+ return "";
13
+ }
14
+ process.stdin.setEncoding("utf8");
15
+ let data = "";
16
+ for await (const chunk of process.stdin) {
17
+ data += chunk;
18
+ }
19
+ return data;
34
20
  }
35
- /**
36
- * This tool enforces policies across the code base via a series of handler functions. The handler functions are
37
- * associated with a regular expression, and all files matching that expression are passed to the handler function.
38
- *
39
- * By default, the list of files to check comes from `git ls-files. You can also pipe in file names from stdin. For
40
- * example:
41
- *
42
- * `git ls-files -co --exclude-standard --full-name | repopo check --stdin --verbose`
43
- */
21
+ /** Check selected files and the complete repository inventory. */
44
22
  export class CheckPolicy extends BaseRepopoCommand {
45
23
  static summary = "Checks and applies policies to the files in the repository.";
24
+ static description = "File policies check selected files. Repository policies always run with the full repository file inventory, " +
25
+ "including with --stdin. With --fix, repository policies can modify files outside the stdin selection.";
46
26
  static flags = {
27
+ concurrency: Flags.integer({
28
+ description: "Maximum concurrent files in read-only checks. Fixes remain sequential.",
29
+ default: DEFAULT_CONCURRENCY,
30
+ parse: async (value) => validateConcurrency(Number(value)),
31
+ }),
47
32
  fix: Flags.boolean({
48
33
  aliases: ["resolve"],
49
34
  description: "Fix errors if possible.",
@@ -60,248 +45,74 @@ export class CheckPolicy extends BaseRepopoCommand {
60
45
  if (this.flags.fix) {
61
46
  this.info("Resolving errors if possible.");
62
47
  }
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);
68
- }
69
- const filePathsToCheck = [];
70
- if (this.flags.stdin) {
71
- const stdInput = await run(function* () {
72
- return yield* call(() => readStdin());
73
- });
74
- if (stdInput !== undefined && stdInput !== null) {
75
- filePathsToCheck.push(...stdInput
76
- .replace(
77
- // normalize slashes in case they're windows paths
78
- /\\/g, "/")
79
- .split("\n"));
80
- }
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
48
  const context = await this.getContext();
97
- await run(() => this.checkAllFiles(filePathsToCheck, context));
98
- }
99
- /**
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.
104
- */
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}`);
138
- return;
139
- }
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);
49
+ const files = await this.collectFilePaths(context.gitRoot);
50
+ this.verbose(`${context.policies.length} policies loaded.`);
51
+ for (const policy of context.policies) {
52
+ this.verbose(policy.instanceId);
53
+ }
54
+ const results = await runPolicies({
55
+ policies: context.policies,
56
+ root: context.gitRoot,
57
+ files,
58
+ inventory: () => this.collectRepositoryFiles(),
59
+ exclude: context.excludeFromAll,
60
+ fix: this.flags.fix,
61
+ concurrency: this.flags.concurrency,
62
+ });
63
+ for (const finding of results.findings) {
64
+ this.reportFinding(finding);
158
65
  }
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}`);
66
+ for (const error of results.errors) {
67
+ this.reportError(error);
162
68
  }
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;
69
+ for (const skipped of results.skipped) {
70
+ this.verbose(`Skipped ${skipped.policyId}: ${skipped.scope === "file" ? skipped.file : "repository"} (${skipped.reason})`);
201
71
  }
202
- catch (error) {
203
- this.exit(`Error in policy handler '${policy.name}' for file '${relPath}': ${error}`);
72
+ if (!this.flags.quiet) {
73
+ logStats(results.perfStats, this.logger);
204
74
  }
205
75
  }
206
- *handlePolicyResult(result, relPath, policy, perfStats, gitRoot) {
207
- if (result === true) {
208
- return;
209
- }
210
- // Handle fix results (both legacy and new formats)
211
- if (isPolicyFixResult(result)) {
212
- this.handleFixResult(result, policy);
213
- return;
214
- }
215
- // Handle new PolicyError with fixed property (fix was attempted)
216
- if (isPolicyError(result) && result.fixed !== undefined) {
217
- this.handlePolicyErrorFixResult(result, relPath, policy);
76
+ reportFinding(finding) {
77
+ const location = finding.scope === "file"
78
+ ? finding.file
79
+ : finding.files?.join(", ") || "repository";
80
+ const message = `${finding.policyId}: ${location}: ${finding.message}`;
81
+ if (finding.fixStatus === "fixed") {
82
+ this.info(`Resolved ${message}`);
218
83
  return;
219
84
  }
220
- // Handle failure results (PolicyFailure or PolicyError without fix)
221
- yield* this.handleFailureResult(result, relPath, policy, perfStats, gitRoot);
222
- }
223
- handleFixResult(result, policy) {
224
- const messages = new StringBuilder();
225
- if (result.resolved) {
226
- messages.append(`Resolved ${policy.name} policy failure for file: ${result.file}`);
227
- }
228
- else {
229
- messages.append(`Error fixing ${policy.name} policy failure in ${result.file}`);
230
- process.exitCode = 1;
231
- }
232
- this.logMessages(messages);
233
- }
234
- handlePolicyErrorFixResult(result, file, policy) {
235
- const messages = new StringBuilder();
236
- if (result.fixed) {
237
- messages.append(`Resolved ${policy.name} policy failure for file: ${file}`);
238
- }
239
- else {
240
- messages.append(`Error fixing ${policy.name} policy failure in ${file}`);
241
- if (result.error) {
242
- messages.append(`${newline}\t${result.error}`);
243
- }
244
- process.exitCode = 1;
85
+ process.exitCode = 1;
86
+ this.warning(message);
87
+ if (finding.manualFix) {
88
+ this.warning(`Manual fix: ${finding.manualFix}`);
245
89
  }
246
- this.logMessages(messages);
247
90
  }
248
- *handleFailureResult(result, relPath, policy, perfStats, gitRoot) {
249
- 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);
91
+ reportError(error) {
92
+ process.exitCode = 1;
93
+ const location = error.scope === "file"
94
+ ? error.file
95
+ : error.files.join(", ") || "repository";
96
+ this.warning(`Execution error (${error.kind}, ${error.phase}) ${error.policyId}: ${location}: ${error.message}`);
257
97
  }
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);
98
+ async collectFilePaths(gitRoot) {
99
+ const paths = this.flags.stdin
100
+ ? parseFilePaths(await readStdin())
101
+ : await this.collectRepositoryFiles();
102
+ return paths.map((filePath) => {
103
+ try {
104
+ return normalizeRepoRelativeFilePath(gitRoot, filePath);
265
105
  }
266
- // Check if it's an Effection Operation (generator)
267
- if (isOperation(result)) {
268
- return yield* result;
106
+ catch (error) {
107
+ const message = error instanceof Error ? error.message : String(error);
108
+ throw new Error(`Invalid file path '${filePath}': ${message}`, {
109
+ cause: error,
110
+ });
269
111
  }
270
- // This should never happen with proper resolver typing
271
- throw new Error(`Unexpected resolver result type: ${typeof result}`);
272
112
  });
273
- if (!resolveResult.resolved) {
274
- process.exitCode = 1;
275
- }
276
- if (resolveResult.errorMessages?.length > 0) {
277
- messages.append(newline + resolveResult.errorMessages.join(newline));
278
- }
279
113
  }
280
- logPolicyFailure(result, file, policy, messages) {
281
- // Handle both legacy PolicyFailure and new PolicyError formats
282
- if (isPolicyError(result)) {
283
- const autoFixable = result.fixable ? chalk.green(" (autofixable)") : "";
284
- messages.append(`'${chalk.bold(policy.name)}' policy failure${autoFixable}: ${file}`);
285
- messages.append(`${newline}\t${result.error}`);
286
- }
287
- else {
288
- const autoFixable = result.autoFixable
289
- ? chalk.green(" (autofixable)")
290
- : "";
291
- messages.append(`'${chalk.bold(policy.name)}' policy failure${autoFixable}: ${result.file}`);
292
- if (result.errorMessages?.length > 0) {
293
- messages.append(`${newline}\t${result.errorMessages.join(`${newline}\t`)}`);
294
- }
295
- }
296
- process.exitCode = 1;
297
- }
298
- logMessages(messages) {
299
- if ((process.exitCode ?? 0) === 0) {
300
- this.info(messages.toString());
301
- }
302
- else {
303
- this.warning(messages.toString());
304
- }
114
+ async collectRepositoryFiles() {
115
+ return readRepositoryFiles(this.git);
305
116
  }
306
117
  }
307
118
  //# sourceMappingURL=check.js.map
@@ -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,KAA2B,CAAC,IAAI,KAAK,UAAU,CACvD,CAAC;AACH,CAAC;AAED,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAA+B,WAAW,EAAE,MAAM,YAAY,CAAC;AAChF,OAAO,EACN,aAAa,EACb,iBAAiB,GAOjB,MAAM,cAAc,CAAC;AAEtB,KAAK,UAAU,SAAS;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC9B,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC5B,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAE1B,IAAI,IAAI,GAAG,EAAE,CAAC;QACd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,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,MAAM,CAAC,IAAI,CAAC,mBAAmB,WAAW,KAAK,MAAM,CAAC,IAAI,EAAE,CAC3E,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;IACtB,CAAC;IACO,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 { 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,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAGN,WAAW,GACX,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AAEtE,KAAK,UAAU,SAAS;IACvB,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACzB,OAAO,EAAE,CAAC;IACX,CAAC;IACD,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAClC,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,OAAO,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,OAAO,6BAA6B,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;YACzD,CAAC;YAAC,OAAO,KAAc,EAAE,CAAC;gBACzB,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACvE,MAAM,IAAI,KAAK,CAAC,sBAAsB,QAAQ,MAAM,OAAO,EAAE,EAAE;oBAC9D,KAAK,EAAE,KAAK;iBACZ,CAAC,CAAC;YACJ,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,sBAAsB;QACnC,OAAO,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACtC,CAAC","sourcesContent":["import process from \"node:process\";\nimport { Flags } from \"@oclif/core\";\nimport { BaseRepopoCommand } from \"../baseCommand.js\";\nimport { DEFAULT_CONCURRENCY, validateConcurrency } from \"../concurrency.js\";\nimport { parseFilePaths } from \"../filePaths.js\";\nimport { logStats } from \"../perf.js\";\nimport { readRepositoryFiles } from \"../repositoryFiles.js\";\nimport {\n\ttype PolicyExecutionError,\n\ttype PolicyRunFinding,\n\trunPolicies,\n} from \"../runner.js\";\nimport { normalizeRepoRelativeFilePath } from \"../utils/safePaths.js\";\n\nasync function readStdin(): Promise<string> {\n\tif (process.stdin.isTTY) {\n\t\treturn \"\";\n\t}\n\tprocess.stdin.setEncoding(\"utf8\");\n\tlet data = \"\";\n\tfor await (const chunk of process.stdin) {\n\t\tdata += chunk;\n\t}\n\treturn data;\n}\n\n/** Check selected files and the complete repository inventory. */\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 description =\n\t\t\"File policies check selected files. Repository policies always run with the full repository file inventory, \" +\n\t\t\"including with --stdin. With --fix, repository policies can modify files outside the stdin selection.\";\n\n\tpublic static override readonly flags = {\n\t\tconcurrency: Flags.integer({\n\t\t\tdescription:\n\t\t\t\t\"Maximum concurrent files in read-only checks. Fixes remain sequential.\",\n\t\t\tdefault: DEFAULT_CONCURRENCY,\n\t\t\tparse: async (value) => validateConcurrency(Number(value)),\n\t\t}),\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\t\tconst context = await this.getContext();\n\t\tconst files = await this.collectFilePaths(context.gitRoot);\n\t\tthis.verbose(`${context.policies.length} policies loaded.`);\n\t\tfor (const policy of context.policies) {\n\t\t\tthis.verbose(policy.instanceId);\n\t\t}\n\t\tconst results = await runPolicies({\n\t\t\tpolicies: context.policies,\n\t\t\troot: context.gitRoot,\n\t\t\tfiles,\n\t\t\tinventory: () => this.collectRepositoryFiles(),\n\t\t\texclude: context.excludeFromAll,\n\t\t\tfix: this.flags.fix,\n\t\t\tconcurrency: this.flags.concurrency,\n\t\t});\n\t\tfor (const finding of results.findings) {\n\t\t\tthis.reportFinding(finding);\n\t\t}\n\t\tfor (const error of results.errors) {\n\t\t\tthis.reportError(error);\n\t\t}\n\n\t\tfor (const skipped of results.skipped) {\n\t\t\tthis.verbose(\n\t\t\t\t`Skipped ${skipped.policyId}: ${skipped.scope === \"file\" ? skipped.file : \"repository\"} (${skipped.reason})`,\n\t\t\t);\n\t\t}\n\n\t\tif (!this.flags.quiet) {\n\t\t\tlogStats(results.perfStats, this.logger);\n\t\t}\n\t}\n\n\tprivate reportFinding(finding: PolicyRunFinding): void {\n\t\tconst location =\n\t\t\tfinding.scope === \"file\"\n\t\t\t\t? finding.file\n\t\t\t\t: finding.files?.join(\", \") || \"repository\";\n\t\tconst message = `${finding.policyId}: ${location}: ${finding.message}`;\n\t\tif (finding.fixStatus === \"fixed\") {\n\t\t\tthis.info(`Resolved ${message}`);\n\t\t\treturn;\n\t\t}\n\t\tprocess.exitCode = 1;\n\t\tthis.warning(message);\n\t\tif (finding.manualFix) {\n\t\t\tthis.warning(`Manual fix: ${finding.manualFix}`);\n\t\t}\n\t}\n\n\tprivate reportError(error: PolicyExecutionError): void {\n\t\tprocess.exitCode = 1;\n\t\tconst location =\n\t\t\terror.scope === \"file\"\n\t\t\t\t? error.file\n\t\t\t\t: error.files.join(\", \") || \"repository\";\n\t\tthis.warning(\n\t\t\t`Execution error (${error.kind}, ${error.phase}) ${error.policyId}: ${location}: ${error.message}`,\n\t\t);\n\t}\n\n\tprivate async collectFilePaths(gitRoot: string): Promise<string[]> {\n\t\tconst paths = this.flags.stdin\n\t\t\t? parseFilePaths(await readStdin())\n\t\t\t: await this.collectRepositoryFiles();\n\t\treturn paths.map((filePath) => {\n\t\t\ttry {\n\t\t\t\treturn normalizeRepoRelativeFilePath(gitRoot, filePath);\n\t\t\t} catch (error: unknown) {\n\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\tthrow new Error(`Invalid file path '${filePath}': ${message}`, {\n\t\t\t\t\tcause: error,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate async collectRepositoryFiles(): Promise<string[]> {\n\t\treturn readRepositoryFiles(this.git);\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;CAa1C"}
@@ -1,17 +1,17 @@
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(` scope: ${configuredPolicy.scope ?? "file"}`);
14
+ this.log(` resolver: ${configuredPolicy.scope !== "repository" && configuredPolicy.resolver !== undefined}\n`);
15
15
  }
16
16
  this.log(`${policies.length} TOTAL POLICY HANDLERS`);
17
17
  }
@@ -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,YAAY,gBAAgB,CAAC,KAAK,IAAI,MAAM,EAAE,CAAC,CAAC;YACzD,IAAI,CAAC,GAAG,CACP,eAAe,gBAAgB,CAAC,KAAK,KAAK,YAAY,IAAI,gBAAgB,CAAC,QAAQ,KAAK,SAAS,IAAI,CACrG,CAAC;QACH,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(` scope: ${configuredPolicy.scope ?? \"file\"}`);\n\t\t\tthis.log(\n\t\t\t\t` resolver: ${configuredPolicy.scope !== \"repository\" && configuredPolicy.resolver !== undefined}\\n`,\n\t\t\t);\n\t\t}\n\t\tthis.log(`${policies.length} TOTAL POLICY HANDLERS`);\n\t}\n}\n"]}
@@ -0,0 +1,3 @@
1
+ export declare const DEFAULT_CONCURRENCY = 8;
2
+ export declare function validateConcurrency(concurrency: number): number;
3
+ //# sourceMappingURL=concurrency.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"concurrency.d.ts","sourceRoot":"","sources":["../src/concurrency.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAK/D"}
@@ -0,0 +1,8 @@
1
+ export const DEFAULT_CONCURRENCY = 8;
2
+ export function validateConcurrency(concurrency) {
3
+ if (!Number.isSafeInteger(concurrency) || concurrency < 1) {
4
+ throw new Error("Concurrency must be a positive safe integer.");
5
+ }
6
+ return concurrency;
7
+ }
8
+ //# sourceMappingURL=concurrency.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"concurrency.js","sourceRoot":"","sources":["../src/concurrency.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAErC,MAAM,UAAU,mBAAmB,CAAC,WAAmB;IACtD,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,WAAW,CAAC,IAAI,WAAW,GAAG,CAAC,EAAE,CAAC;QAC3D,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,WAAW,CAAC;AACpB,CAAC","sourcesContent":["export const DEFAULT_CONCURRENCY = 8;\n\nexport function validateConcurrency(concurrency: number): number {\n\tif (!Number.isSafeInteger(concurrency) || concurrency < 1) {\n\t\tthrow new Error(\"Concurrency must be a positive safe integer.\");\n\t}\n\treturn concurrency;\n}\n"]}