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
@@ -1,10 +1,10 @@
1
- import type { PolicyDefinition } from "../policy.js";
1
+ import type { FilePolicyDefinition } from "../policy.js";
2
2
  /**
3
3
  * A FluidFramework build-tools policy handler interface.
4
4
  *
5
5
  * This interface matches the `Handler` interface from `@fluidframework/build-tools`.
6
6
  *
7
- * @alpha
7
+ * @public
8
8
  */
9
9
  export interface FluidHandler {
10
10
  /**
@@ -31,17 +31,21 @@ export interface FluidHandler {
31
31
  * @returns An object indicating whether the fix was successful.
32
32
  */
33
33
  resolver?: (file: string, root: string) => Promise<{
34
+ /** Whether the violation was fixed. */
34
35
  resolved: boolean;
36
+ /** Optional explanation of the fix result. */
35
37
  message?: string;
36
38
  }> | {
39
+ /** Whether the violation was fixed. */
37
40
  resolved: boolean;
41
+ /** Optional explanation of the fix result. */
38
42
  message?: string;
39
43
  };
40
44
  }
41
45
  /**
42
46
  * Options for converting FluidFramework handlers to repopo policies.
43
47
  *
44
- * @alpha
48
+ * @public
45
49
  */
46
50
  export interface FluidAdapterOptions {
47
51
  /**
@@ -62,19 +66,19 @@ export interface FluidAdapterOptions {
62
66
  * Key differences handled by this adapter:
63
67
  *
64
68
  * - **Handler signature**: Fluid uses `(file, root) => string | undefined`,
65
- * repopo uses `(args) => PolicyHandlerResult`
69
+ * repopo uses `(args) => Promise<PolicyResult> | Operation<PolicyResult>`
66
70
  *
67
71
  * - **File paths**: Fluid passes absolute paths, repopo passes repo-relative paths.
68
72
  * The adapter converts between the two.
69
73
  *
70
74
  * - **Return types**: Fluid returns `string | undefined` (error message or success),
71
- * repopo returns `true | PolicyFailure | PolicyFixResult`
75
+ * repopo returns `readonly PolicyFinding[]`
72
76
  *
73
77
  * For a single handler, wrap it in an array: `fromFluidHandlers([handler])`.
74
78
  *
75
79
  * @example
76
80
  * ```typescript
77
- * import { fromFluidHandlers, makePolicy } from "repopo";
81
+ * import { fromFluidHandlers, makePolicy, type RepopoConfig } from "repopo";
78
82
  * import { copyrightFileHeaderHandlers, fluidCaseHandler } from "@fluidframework/build-tools";
79
83
  *
80
84
  * // Convert multiple handlers with a namespace prefix
@@ -87,7 +91,7 @@ export interface FluidAdapterOptions {
87
91
  *
88
92
  * const config: RepopoConfig = {
89
93
  * policies: [
90
- * ...FluidCopyrightPolicies.map(p => makePolicy(p)),
94
+ * ...FluidCopyrightPolicies.map((p) => makePolicy(p)),
91
95
  * makePolicy(FluidCasePolicy),
92
96
  * ],
93
97
  * };
@@ -97,7 +101,7 @@ export interface FluidAdapterOptions {
97
101
  * @param options - Optional configuration applied to all conversions.
98
102
  * @returns An array of repopo PolicyDefinitions.
99
103
  *
100
- * @alpha
104
+ * @public
101
105
  */
102
- export declare function fromFluidHandlers(fluidHandlers: FluidHandler[], options?: FluidAdapterOptions): PolicyDefinition[];
106
+ export declare function fromFluidHandlers(fluidHandlers: FluidHandler[], options?: FluidAdapterOptions): FilePolicyDefinition[];
103
107
  //# sourceMappingURL=fluidFramework.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fluidFramework.d.ts","sourceRoot":"","sources":["../../src/adapters/fluidFramework.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACX,gBAAgB,EAIhB,MAAM,cAAc,CAAC;AAEtB;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC5B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;;;;OAMG;IACH,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAErE;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,CACV,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,KAEV,OAAO,CAAC;QAAE,QAAQ,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAChD;QAAE,QAAQ,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC3C;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IACnC;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAwFD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,wBAAgB,iBAAiB,CAChC,aAAa,EAAE,YAAY,EAAE,EAC7B,OAAO,CAAC,EAAE,mBAAmB,GAC3B,gBAAgB,EAAE,CAEpB"}
1
+ {"version":3,"file":"fluidFramework.d.ts","sourceRoot":"","sources":["../../src/adapters/fluidFramework.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAiB,MAAM,cAAc,CAAC;AAExE;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC5B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;;;;OAMG;IACH,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAErE;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,CACV,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,KAEV,OAAO,CAAC;QACR,uCAAuC;QACvC,QAAQ,EAAE,OAAO,CAAC;QAClB,8CAA8C;QAC9C,OAAO,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC,GACF;QACA,uCAAuC;QACvC,QAAQ,EAAE,OAAO,CAAC;QAClB,8CAA8C;QAC9C,OAAO,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;CACL;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IACnC;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AA8DD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,wBAAgB,iBAAiB,CAChC,aAAa,EAAE,YAAY,EAAE,EAC7B,OAAO,CAAC,EAAE,mBAAmB,GAC3B,oBAAoB,EAAE,CAExB"}
@@ -1,5 +1,4 @@
1
1
  import path from "pathe";
2
- import { makePolicyDefinition } from "../makePolicy.js";
3
2
  /**
4
3
  * Converts a FluidFramework handler to a repopo PolicyDefinition.
5
4
  *
@@ -19,56 +18,34 @@ function fromFluidHandler(fluidHandler, options) {
19
18
  const absolutePath = path.join(root, file);
20
19
  const errorMessage = await fluidHandler.handler(absolutePath, root);
21
20
  if (errorMessage === undefined) {
22
- return true;
21
+ return [];
23
22
  }
24
23
  // Check if resolver exists to determine if auto-fixable
25
24
  const autoFixable = fluidHandler.resolver !== undefined;
26
25
  // If resolve is requested and we have a resolver, try to fix
27
26
  if (resolve && fluidHandler.resolver !== undefined) {
28
27
  const resolveResult = await fluidHandler.resolver(absolutePath, root);
29
- return {
30
- name: policyName,
31
- file,
32
- errorMessages: [resolveResult.message ?? errorMessage],
33
- autoFixable: true,
34
- resolved: resolveResult.resolved,
35
- };
28
+ return [
29
+ {
30
+ message: resolveResult.message ?? errorMessage,
31
+ fixStatus: resolveResult.resolved ? "fixed" : "failed",
32
+ },
33
+ ];
36
34
  }
37
- return {
38
- name: policyName,
39
- file,
40
- errorMessages: [errorMessage],
41
- autoFixable,
42
- };
35
+ return [
36
+ {
37
+ message: errorMessage,
38
+ fixStatus: autoFixable ? "available" : undefined,
39
+ },
40
+ ];
43
41
  };
44
- // Create standalone resolver if Fluid handler has one
45
- let resolver;
46
- if (fluidHandler.resolver !== undefined) {
47
- resolver = async ({ file, root }) => {
48
- const absolutePath = path.join(root, file);
49
- // First get the error message for context
50
- const errorMessage = await fluidHandler.handler(absolutePath, root);
51
- // biome-ignore lint/style/noNonNullAssertion: we checked this is defined above
52
- const resolveResult = await fluidHandler.resolver(absolutePath, root);
53
- return {
54
- name: policyName,
55
- file,
56
- errorMessages: [
57
- resolveResult.message ?? errorMessage ?? "Unknown error",
58
- ],
59
- autoFixable: true,
60
- resolved: resolveResult.resolved,
61
- };
62
- };
63
- }
64
- return makePolicyDefinition({
42
+ return {
65
43
  name: policyName,
66
44
  description: `FluidFramework policy: ${fluidHandler.name}`,
67
45
  match: fluidHandler.match,
68
46
  handler,
69
47
  defaultConfig: undefined, // no config
70
- resolver,
71
- });
48
+ };
72
49
  }
73
50
  /**
74
51
  * Converts FluidFramework handlers to repopo PolicyDefinitions.
@@ -81,19 +58,19 @@ function fromFluidHandler(fluidHandler, options) {
81
58
  * Key differences handled by this adapter:
82
59
  *
83
60
  * - **Handler signature**: Fluid uses `(file, root) => string | undefined`,
84
- * repopo uses `(args) => PolicyHandlerResult`
61
+ * repopo uses `(args) => Promise<PolicyResult> | Operation<PolicyResult>`
85
62
  *
86
63
  * - **File paths**: Fluid passes absolute paths, repopo passes repo-relative paths.
87
64
  * The adapter converts between the two.
88
65
  *
89
66
  * - **Return types**: Fluid returns `string | undefined` (error message or success),
90
- * repopo returns `true | PolicyFailure | PolicyFixResult`
67
+ * repopo returns `readonly PolicyFinding[]`
91
68
  *
92
69
  * For a single handler, wrap it in an array: `fromFluidHandlers([handler])`.
93
70
  *
94
71
  * @example
95
72
  * ```typescript
96
- * import { fromFluidHandlers, makePolicy } from "repopo";
73
+ * import { fromFluidHandlers, makePolicy, type RepopoConfig } from "repopo";
97
74
  * import { copyrightFileHeaderHandlers, fluidCaseHandler } from "@fluidframework/build-tools";
98
75
  *
99
76
  * // Convert multiple handlers with a namespace prefix
@@ -106,7 +83,7 @@ function fromFluidHandler(fluidHandler, options) {
106
83
  *
107
84
  * const config: RepopoConfig = {
108
85
  * policies: [
109
- * ...FluidCopyrightPolicies.map(p => makePolicy(p)),
86
+ * ...FluidCopyrightPolicies.map((p) => makePolicy(p)),
110
87
  * makePolicy(FluidCasePolicy),
111
88
  * ],
112
89
  * };
@@ -116,7 +93,7 @@ function fromFluidHandler(fluidHandler, options) {
116
93
  * @param options - Optional configuration applied to all conversions.
117
94
  * @returns An array of repopo PolicyDefinitions.
118
95
  *
119
- * @alpha
96
+ * @public
120
97
  */
121
98
  export function fromFluidHandlers(fluidHandlers, options) {
122
99
  return fluidHandlers.map((h) => fromFluidHandler(h, options));
@@ -1 +1 @@
1
- {"version":3,"file":"fluidFramework.js","sourceRoot":"","sources":["../../src/adapters/fluidFramework.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,OAAO,CAAC;AACzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAgExD;;;;;;;;;;GAUG;AACH,SAAS,gBAAgB,CACxB,YAA0B,EAC1B,OAA6B;IAE7B,MAAM,EAAE,UAAU,GAAG,EAAE,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IAC1C,MAAM,UAAU,GAAG,GA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AAM,YAAY,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;YAEpE,+EAA+E;YAC/E,MAAM,aAAa,GAAG,MAAM,YAAY,CAAC,QAAS,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;YAEvE,OAAO;gBACN,IAAI,EAAE,UAAU;gBAChB,IAAI;gBACJ,aAAa,EAAE;oBACd,aAAa,CAAC,OAAO,IAAI,YAAY,IAAI,eAAe;iBACxD;gBACD,WAAW,EAAE,IAAI;gBACjB,QAAQ,EAAE,aAAa,CAAC,QAAQ;aAChC,CAAC;QACH,CAAC,CAAC;IACH,CAAC;IAED,OAAO,oBAAoB,CAAC;QAC3B,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE,0BAA0B,YAAY,CAAC,IAAI,EAAE;QAC1D,KAAK,EAAE,YAAY,CAAC,KAAK;QACzB,OAAO;QACP,aAAa,EAAE,SAAS,EAAE,YAAY;QACtC,QAAQ;KACR,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,MAAM,UAAU,iBAAiB,CAChC,aAA6B,EAC7B,OAA6B;IAE7B,OAAO,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,gBAAgB,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;AAC/D,CAAC","sourcesContent":["import path from \"pathe\";\nimport { makePolicyDefinition } from \"../makePolicy.js\";\nimport type {\n\tPolicyDefinition,\n\tPolicyFixResult,\n\tPolicyHandler,\n\tPolicyStandaloneResolver,\n} from \"../policy.js\";\n\n/**\n * A FluidFramework build-tools policy handler interface.\n *\n * This interface matches the `Handler` interface from `@fluidframework/build-tools`.\n *\n * @alpha\n */\nexport interface FluidHandler {\n\t/**\n\t * The name of the handler, used for filtering and display.\n\t */\n\tname: string;\n\n\t/**\n\t * A regex pattern that determines which files this handler applies to.\n\t */\n\tmatch: RegExp;\n\n\t/**\n\t * The handler function that checks a file against the policy.\n\t *\n\t * @param file - Absolute path to the file.\n\t * @param root - Path to the repo root.\n\t * @returns `undefined` if the check passes, otherwise an error message string.\n\t */\n\thandler: (file: string, root: string) => Promise<string | undefined>;\n\n\t/**\n\t * Optional resolver function that attempts to fix policy violations.\n\t *\n\t * @param file - Absolute path to the file.\n\t * @param root - Path to the repo root.\n\t * @returns An object indicating whether the fix was successful.\n\t */\n\tresolver?: (\n\t\tfile: string,\n\t\troot: string,\n\t) =>\n\t\t| Promise<{ resolved: boolean; message?: string }>\n\t\t| { resolved: boolean; message?: string };\n}\n\n/**\n * Options for converting FluidFramework handlers to repopo policies.\n *\n * @alpha\n */\nexport interface FluidAdapterOptions {\n\t/**\n\t * Optional prefix to add to policy names. Useful for namespacing Fluid policies.\n\t *\n\t * @example \"Fluid:\" would result in \"Fluid:my-handler-name\"\n\t */\n\tnamePrefix?: string;\n}\n\n/**\n * Converts a FluidFramework handler to a repopo PolicyDefinition.\n *\n * This is an internal function used by {@link fromFluidHandlers}.\n *\n * @param fluidHandler - A FluidFramework Handler object to convert.\n * @param options - Optional configuration for the conversion.\n * @returns A repopo PolicyDefinition that wraps the Fluid handler.\n *\n * @internal\n */\nfunction fromFluidHandler(\n\tfluidHandler: FluidHandler,\n\toptions?: FluidAdapterOptions,\n): PolicyDefinition {\n\tconst { namePrefix = \"\" } = options ?? {};\n\tconst policyName = `${namePrefix}${fluidHandler.name}`;\n\n\tconst handler: PolicyHandler = async ({ file, root, resolve }) => {\n\t\t// Fluid handlers expect absolute paths\n\t\tconst absolutePath = path.join(root, file);\n\n\t\tconst errorMessage = await fluidHandler.handler(absolutePath, root);\n\n\t\tif (errorMessage === undefined) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Check if resolver exists to determine if auto-fixable\n\t\tconst autoFixable = fluidHandler.resolver !== undefined;\n\n\t\t// If resolve is requested and we have a resolver, try to fix\n\t\tif (resolve && fluidHandler.resolver !== undefined) {\n\t\t\tconst resolveResult = await fluidHandler.resolver(absolutePath, root);\n\n\t\t\treturn {\n\t\t\t\tname: policyName,\n\t\t\t\tfile,\n\t\t\t\terrorMessages: [resolveResult.message ?? errorMessage],\n\t\t\t\tautoFixable: true,\n\t\t\t\tresolved: resolveResult.resolved,\n\t\t\t} satisfies PolicyFixResult;\n\t\t}\n\n\t\treturn {\n\t\t\tname: policyName,\n\t\t\tfile,\n\t\t\terrorMessages: [errorMessage],\n\t\t\tautoFixable,\n\t\t};\n\t};\n\n\t// Create standalone resolver if Fluid handler has one\n\tlet resolver: PolicyStandaloneResolver | undefined;\n\tif (fluidHandler.resolver !== undefined) {\n\t\tresolver = async ({ file, root }) => {\n\t\t\tconst absolutePath = path.join(root, file);\n\n\t\t\t// First get the error message for context\n\t\t\tconst errorMessage = await fluidHandler.handler(absolutePath, root);\n\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: we checked this is defined above\n\t\t\tconst resolveResult = await fluidHandler.resolver!(absolutePath, root);\n\n\t\t\treturn {\n\t\t\t\tname: policyName,\n\t\t\t\tfile,\n\t\t\t\terrorMessages: [\n\t\t\t\t\tresolveResult.message ?? errorMessage ?? \"Unknown error\",\n\t\t\t\t],\n\t\t\t\tautoFixable: true,\n\t\t\t\tresolved: resolveResult.resolved,\n\t\t\t};\n\t\t};\n\t}\n\n\treturn makePolicyDefinition({\n\t\tname: policyName,\n\t\tdescription: `FluidFramework policy: ${fluidHandler.name}`,\n\t\tmatch: fluidHandler.match,\n\t\thandler,\n\t\tdefaultConfig: undefined, // no config\n\t\tresolver,\n\t});\n}\n\n/**\n * Converts FluidFramework handlers to repopo PolicyDefinitions.\n *\n * This adapter bridges the gap between FluidFramework's build-tools policy system\n * and repopo's policy system, allowing you to reuse existing Fluid policies in repopo.\n *\n * @remarks\n *\n * Key differences handled by this adapter:\n *\n * - **Handler signature**: Fluid uses `(file, root) => string | undefined`,\n * repopo uses `(args) => PolicyHandlerResult`\n *\n * - **File paths**: Fluid passes absolute paths, repopo passes repo-relative paths.\n * The adapter converts between the two.\n *\n * - **Return types**: Fluid returns `string | undefined` (error message or success),\n * repopo returns `true | PolicyFailure | PolicyFixResult`\n *\n * For a single handler, wrap it in an array: `fromFluidHandlers([handler])`.\n *\n * @example\n * ```typescript\n * import { fromFluidHandlers, makePolicy } from \"repopo\";\n * import { copyrightFileHeaderHandlers, fluidCaseHandler } from \"@fluidframework/build-tools\";\n *\n * // Convert multiple handlers with a namespace prefix\n * const FluidCopyrightPolicies = fromFluidHandlers(copyrightFileHeaderHandlers, {\n * namePrefix: \"Fluid:\",\n * });\n *\n * // For a single handler, wrap it in an array\n * const [FluidCasePolicy] = fromFluidHandlers([fluidCaseHandler]);\n *\n * const config: RepopoConfig = {\n * policies: [\n * ...FluidCopyrightPolicies.map(p => makePolicy(p)),\n * makePolicy(FluidCasePolicy),\n * ],\n * };\n * ```\n *\n * @param fluidHandlers - An array of FluidFramework Handler objects to convert.\n * @param options - Optional configuration applied to all conversions.\n * @returns An array of repopo PolicyDefinitions.\n *\n * @alpha\n */\nexport function fromFluidHandlers(\n\tfluidHandlers: FluidHandler[],\n\toptions?: FluidAdapterOptions,\n): PolicyDefinition[] {\n\treturn fluidHandlers.map((h) => fromFluidHandler(h, options));\n}\n"]}
1
+ {"version":3,"file":"fluidFramework.js","sourceRoot":"","sources":["../../src/adapters/fluidFramework.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,OAAO,CAAC;AAqEzB;;;;;;;;;;GAUG;AACH,SAAS,gBAAgB,CACxB,YAA0B,EAC1B,OAA6B;IAE7B,MAAM,EAAE,UAAU,GAAG,EAAE,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IAC1C,MAAM,UAAU,GAAG,GAAG,UAAU,GAAG,YAAY,CAAC,IAAI,EAAE,CAAC;IAEvD,MAAM,OAAO,GAAkB,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;QAChE,uCAAuC;QACvC,MAAM,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AC;AAC/D,CAAC","sourcesContent":["import path from \"pathe\";\nimport type { FilePolicyDefinition, PolicyHandler } from \"../policy.js\";\n\n/**\n * A FluidFramework build-tools policy handler interface.\n *\n * This interface matches the `Handler` interface from `@fluidframework/build-tools`.\n *\n * @public\n */\nexport interface FluidHandler {\n\t/**\n\t * The name of the handler, used for filtering and display.\n\t */\n\tname: string;\n\n\t/**\n\t * A regex pattern that determines which files this handler applies to.\n\t */\n\tmatch: RegExp;\n\n\t/**\n\t * The handler function that checks a file against the policy.\n\t *\n\t * @param file - Absolute path to the file.\n\t * @param root - Path to the repo root.\n\t * @returns `undefined` if the check passes, otherwise an error message string.\n\t */\n\thandler: (file: string, root: string) => Promise<string | undefined>;\n\n\t/**\n\t * Optional resolver function that attempts to fix policy violations.\n\t *\n\t * @param file - Absolute path to the file.\n\t * @param root - Path to the repo root.\n\t * @returns An object indicating whether the fix was successful.\n\t */\n\tresolver?: (\n\t\tfile: string,\n\t\troot: string,\n\t) =>\n\t\t| Promise<{\n\t\t\t\t/** Whether the violation was fixed. */\n\t\t\t\tresolved: boolean;\n\t\t\t\t/** Optional explanation of the fix result. */\n\t\t\t\tmessage?: string;\n\t\t }>\n\t\t| {\n\t\t\t\t/** Whether the violation was fixed. */\n\t\t\t\tresolved: boolean;\n\t\t\t\t/** Optional explanation of the fix result. */\n\t\t\t\tmessage?: string;\n\t\t };\n}\n\n/**\n * Options for converting FluidFramework handlers to repopo policies.\n *\n * @public\n */\nexport interface FluidAdapterOptions {\n\t/**\n\t * Optional prefix to add to policy names. Useful for namespacing Fluid policies.\n\t *\n\t * @example \"Fluid:\" would result in \"Fluid:my-handler-name\"\n\t */\n\tnamePrefix?: string;\n}\n\n/**\n * Converts a FluidFramework handler to a repopo PolicyDefinition.\n *\n * This is an internal function used by {@link fromFluidHandlers}.\n *\n * @param fluidHandler - A FluidFramework Handler object to convert.\n * @param options - Optional configuration for the conversion.\n * @returns A repopo PolicyDefinition that wraps the Fluid handler.\n *\n * @internal\n */\nfunction fromFluidHandler(\n\tfluidHandler: FluidHandler,\n\toptions?: FluidAdapterOptions,\n): FilePolicyDefinition {\n\tconst { namePrefix = \"\" } = options ?? {};\n\tconst policyName = `${namePrefix}${fluidHandler.name}`;\n\n\tconst handler: PolicyHandler = async ({ file, root, resolve }) => {\n\t\t// Fluid handlers expect absolute paths\n\t\tconst absolutePath = path.join(root, file);\n\n\t\tconst errorMessage = await fluidHandler.handler(absolutePath, root);\n\n\t\tif (errorMessage === undefined) {\n\t\t\treturn [];\n\t\t}\n\n\t\t// Check if resolver exists to determine if auto-fixable\n\t\tconst autoFixable = fluidHandler.resolver !== undefined;\n\n\t\t// If resolve is requested and we have a resolver, try to fix\n\t\tif (resolve && fluidHandler.resolver !== undefined) {\n\t\t\tconst resolveResult = await fluidHandler.resolver(absolutePath, root);\n\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tmessage: resolveResult.message ?? errorMessage,\n\t\t\t\t\tfixStatus: resolveResult.resolved ? \"fixed\" : \"failed\",\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tmessage: errorMessage,\n\t\t\t\tfixStatus: autoFixable ? \"available\" : undefined,\n\t\t\t},\n\t\t];\n\t};\n\n\treturn {\n\t\tname: policyName,\n\t\tdescription: `FluidFramework policy: ${fluidHandler.name}`,\n\t\tmatch: fluidHandler.match,\n\t\thandler,\n\t\tdefaultConfig: undefined, // no config\n\t} satisfies FilePolicyDefinition;\n}\n\n/**\n * Converts FluidFramework handlers to repopo PolicyDefinitions.\n *\n * This adapter bridges the gap between FluidFramework's build-tools policy system\n * and repopo's policy system, allowing you to reuse existing Fluid policies in repopo.\n *\n * @remarks\n *\n * Key differences handled by this adapter:\n *\n * - **Handler signature**: Fluid uses `(file, root) => string | undefined`,\n * repopo uses `(args) => Promise<PolicyResult> | Operation<PolicyResult>`\n *\n * - **File paths**: Fluid passes absolute paths, repopo passes repo-relative paths.\n * The adapter converts between the two.\n *\n * - **Return types**: Fluid returns `string | undefined` (error message or success),\n * repopo returns `readonly PolicyFinding[]`\n *\n * For a single handler, wrap it in an array: `fromFluidHandlers([handler])`.\n *\n * @example\n * ```typescript\n * import { fromFluidHandlers, makePolicy, type RepopoConfig } from \"repopo\";\n * import { copyrightFileHeaderHandlers, fluidCaseHandler } from \"@fluidframework/build-tools\";\n *\n * // Convert multiple handlers with a namespace prefix\n * const FluidCopyrightPolicies = fromFluidHandlers(copyrightFileHeaderHandlers, {\n * namePrefix: \"Fluid:\",\n * });\n *\n * // For a single handler, wrap it in an array\n * const [FluidCasePolicy] = fromFluidHandlers([fluidCaseHandler]);\n *\n * const config: RepopoConfig = {\n * policies: [\n * ...FluidCopyrightPolicies.map((p) => makePolicy(p)),\n * makePolicy(FluidCasePolicy),\n * ],\n * };\n * ```\n *\n * @param fluidHandlers - An array of FluidFramework Handler objects to convert.\n * @param options - Optional configuration applied to all conversions.\n * @returns An array of repopo PolicyDefinitions.\n *\n * @public\n */\nexport function fromFluidHandlers(\n\tfluidHandlers: FluidHandler[],\n\toptions?: FluidAdapterOptions,\n): FilePolicyDefinition[] {\n\treturn fluidHandlers.map((h) => fromFluidHandler(h, options));\n}\n"]}
package/esm/api.d.ts CHANGED
@@ -1,2 +1,65 @@
1
- export {};
1
+ /**
2
+ * A tool for enforcing repository policies and standards across codebases.
3
+ *
4
+ * @remarks
5
+ * Repopo provides a framework for defining and enforcing policies across repositories,
6
+ * such as file headers, package.json consistency, and other code standards.
7
+ * It can be used as a CLI tool or integrated into CI/CD pipelines.
8
+ *
9
+ * @packageDocumentation
10
+ */
11
+ export { type FluidAdapterOptions, type FluidHandler, fromFluidHandlers, } from "./adapters/fluidFramework.js";
12
+ export type { RepopoConfig } from "./config.js";
13
+ export { makePolicy } from "./makePolicy.js";
14
+ export type { PolicyAction, PolicyHandlerPerfStats } from "./perf.js";
15
+ export type { CargoLicenceValidatedConfig } from "./policies/CargoLicenceValidated.js";
16
+ export type { CargoLintsConfiguredConfig } from "./policies/CargoLintsConfigured.js";
17
+ export type { CargoLockPolicyConfig } from "./policies/CargoLockPolicy.js";
18
+ export type { CargoTomlRequiredConfig } from "./policies/CargoTomlRequired.js";
19
+ export type { CargoTomlSortedConfig } from "./policies/CargoTomlSorted.js";
20
+ export type { ConditionalScriptEntry, ConditionalScriptRule, ConditionalScriptsConfig, } from "./policies/ConditionalScripts.js";
21
+ export type { ExactScriptsConfig } from "./policies/ExactScripts.js";
22
+ export type { GleamDepVersionsConfig } from "./policies/GleamDepVersions.js";
23
+ export type { GleamDocExistsConfig } from "./policies/GleamDocExists.js";
24
+ export type { GleamInternalModulesConfiguredConfig } from "./policies/GleamInternalModulesConfigured.js";
25
+ export type { GleamLicenceConfiguredConfig } from "./policies/GleamLicenceConfigured.js";
26
+ export type { GleamMonorepoConsistencyConfig } from "./policies/GleamMonorepoConsistency.js";
27
+ export type { GleamNameRestrictionsConfig } from "./policies/GleamNameRestrictions.js";
28
+ export type { GleamNoPathDepsInPublishedConfig } from "./policies/GleamNoPathDepsInPublished.js";
29
+ export type { GleamProjectStructureConfig } from "./policies/GleamProjectStructure.js";
30
+ export type { GleamSharedDependencyVersionsConfig } from "./policies/GleamSharedDependencyVersions.js";
31
+ export type { GleamTomlRequiredConfig } from "./policies/GleamTomlRequired.js";
32
+ export type { GleamTomlSortedConfig } from "./policies/GleamTomlSorted.js";
33
+ export type { GleamVersionConstraintConfig } from "./policies/GleamVersionConstraint.js";
34
+ export type { LicenseFileExistsSettings } from "./policies/LicenseFileExists.js";
35
+ export type { MutuallyExclusiveScriptsConfig } from "./policies/MutuallyExclusiveScripts.js";
36
+ export type { NoLargeBinaryFilesSettings } from "./policies/NoLargeBinaryFiles.js";
37
+ export type { NoPrivateWorkspaceDependenciesSettings } from "./policies/NoPrivateWorkspaceDependencies.js";
38
+ export type { NoUnsafeWithoutJustificationConfig } from "./policies/NoUnsafeWithoutJustification.js";
39
+ export type { NoWildcardDependenciesConfig } from "./policies/NoWildcardDependencies.js";
40
+ export type { PackageAllowedScopesConfig } from "./policies/PackageAllowedScopes.js";
41
+ export type { PackageEsmTypeConfig } from "./policies/PackageEsmType.js";
42
+ export type { PackageFolderNameConfig } from "./policies/PackageFolderName.js";
43
+ export type { PackageJsonPropertiesSettings } from "./policies/PackageJsonProperties.js";
44
+ export type { PackageLicenseSettings } from "./policies/PackageLicense.js";
45
+ export type { PackagePrivateFieldConfig } from "./policies/PackagePrivateField.js";
46
+ export type { PackageReadmeSettings } from "./policies/PackageReadme.js";
47
+ export type { PackageScriptsSettings, ScriptMustContainRule, } from "./policies/PackageScripts.js";
48
+ export type { PackageTestScriptsConfig } from "./policies/PackageTestScripts.js";
49
+ export type { PublicApiDocumentedConfig } from "./policies/PublicApiDocumented.js";
50
+ export type { RequiredGitignorePatternsSettings } from "./policies/RequiredGitignorePatterns.js";
51
+ export type { RequiredScriptEntry, RequiredScriptsConfig, } from "./policies/RequiredScripts.js";
52
+ export type { RustDocExistsConfig } from "./policies/RustDocExists.js";
53
+ export type { RustfmtConfigExistsConfig } from "./policies/RustfmtConfigExists.js";
54
+ export type { RustToolchainExistsConfig } from "./policies/RustToolchainExists.js";
55
+ export type { ScriptContainsConfig, ScriptContainsRule, } from "./policies/ScriptContains.js";
56
+ export type { SharedDependencyVersionsConfig } from "./policies/SharedDependencyVersions.js";
57
+ export type { WorkspaceInheritanceConfig } from "./policies/WorkspaceInheritance.js";
58
+ export type { WorkspaceMembersValidConfig } from "./policies/WorkspaceMembersValid.js";
59
+ export type { ConfiguredFilePolicy, ConfiguredPolicy, ConfiguredRepositoryPolicy, FilePolicyDefinition, IdentifiedPolicy, PolicyArgs, PolicyDefinition, PolicyFinding, PolicyHandler, PolicyInstanceId, PolicyName, PolicyOptions, PolicyResolver, PolicyResult, RepositoryPolicyArgs, RepositoryPolicyDefinition, RepositoryPolicyHandler, } from "./policy.js";
60
+ export { type CargoToml, type CargoTomlHandler, type DefineCargoPolicyArgs, defineCargoPolicy, } from "./policyDefiners/defineCargoPolicy.js";
61
+ export { type DefineFileHeaderPolicyArgs, defineFileHeaderPolicy, type FileHeaderGeneratorConfig, type FileHeaderPolicyConfig, } from "./policyDefiners/defineFileHeaderPolicy.js";
62
+ export { type DefineGleamPolicyArgs, defineGleamPolicy, type GleamToml, type GleamTomlHandler, } from "./policyDefiners/defineGleamPolicy.js";
63
+ export { type DefinePackagePolicyArgs, definePackagePolicy, type PackageJsonHandler, } from "./policyDefiners/definePackagePolicy.js";
64
+ export { type PolicyExecutionError, type PolicyRunFinding, PolicyRunner, type PolicyRunnerOptions, type PolicyRunResults, type PolicySkippedWork, type RepositoryInventory, runPolicies, } from "./runner.js";
2
65
  //# sourceMappingURL=api.d.ts.map
package/esm/api.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACN,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,iBAAiB,GACjB,MAAM,8BAA8B,CAAC;AACtC,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,YAAY,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACtE,YAAY,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AACvF,YAAY,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AACrF,YAAY,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAC3E,YAAY,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC/E,YAAY,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAC3E,YAAY,EACX,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,GACxB,MAAM,kCAAkC,CAAC;AAC1C,YAAY,EA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,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,EACnB,KAAK,kBAAkB,GACvB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACN,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,YAAY,EACZ,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,WAAW,GACX,MAAM,aAAa,CAAC"}
package/esm/api.js CHANGED
@@ -1,2 +1,18 @@
1
- export {};
1
+ /**
2
+ * A tool for enforcing repository policies and standards across codebases.
3
+ *
4
+ * @remarks
5
+ * Repopo provides a framework for defining and enforcing policies across repositories,
6
+ * such as file headers, package.json consistency, and other code standards.
7
+ * It can be used as a CLI tool or integrated into CI/CD pipelines.
8
+ *
9
+ * @packageDocumentation
10
+ */
11
+ export { fromFluidHandlers, } from "./adapters/fluidFramework.js";
12
+ export { makePolicy } from "./makePolicy.js";
13
+ export { defineCargoPolicy, } from "./policyDefiners/defineCargoPolicy.js";
14
+ export { defineFileHeaderPolicy, } from "./policyDefiners/defineFileHeaderPolicy.js";
15
+ export { defineGleamPolicy, } from "./policyDefiners/defineGleamPolicy.js";
16
+ export { definePackagePolicy, } from "./policyDefiners/definePackagePolicy.js";
17
+ export { PolicyRunner, runPolicies, } from "./runner.js";
2
18
  //# sourceMappingURL=api.js.map
package/esm/api.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"","sourcesContent":[""]}
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAGN,iBAAiB,GACjB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AA8E7C,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,GAEnB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAGN,YAAY,EAKZ,WAAW,GACX,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 {\n\ttype FluidAdapterOptions,\n\ttype FluidHandler,\n\tfromFluidHandlers,\n} from \"./adapters/fluidFramework.js\";\nexport type { RepopoConfig } from \"./config.js\";\nexport { makePolicy } from \"./makePolicy.js\";\nexport type { PolicyAction, PolicyHandlerPerfStats } from \"./perf.js\";\nexport type { CargoLicenceValidatedConfig } from \"./policies/CargoLicenceValidated.js\";\nexport type { CargoLintsConfiguredConfig } from \"./policies/CargoLintsConfigured.js\";\nexport type { CargoLockPolicyConfig } from \"./policies/CargoLockPolicy.js\";\nexport type { CargoTomlRequiredConfig } from \"./policies/CargoTomlRequired.js\";\nexport type { CargoTomlSortedConfig } from \"./policies/CargoTomlSorted.js\";\nexport type {\n\tConditionalScriptEntry,\n\tConditionalScriptRule,\n\tConditionalScriptsConfig,\n} from \"./policies/ConditionalScripts.js\";\nexport type { ExactScriptsConfig } from \"./policies/ExactScripts.js\";\nexport type { GleamDepVersionsConfig } from \"./policies/GleamDepVersions.js\";\nexport type { GleamDocExistsConfig } from \"./policies/GleamDocExists.js\";\nexport type { GleamInternalModulesConfiguredConfig } from \"./policies/GleamInternalModulesConfigured.js\";\nexport type { GleamLicenceConfiguredConfig } from \"./policies/GleamLicenceConfigured.js\";\nexport type { GleamMonorepoConsistencyConfig } from \"./policies/GleamMonorepoConsistency.js\";\nexport type { GleamNameRestrictionsConfig } from \"./policies/GleamNameRestrictions.js\";\nexport type { GleamNoPathDepsInPublishedConfig } from \"./policies/GleamNoPathDepsInPublished.js\";\nexport type { GleamProjectStructureConfig } from \"./policies/GleamProjectStructure.js\";\nexport type { GleamSharedDependencyVersionsConfig } from \"./policies/GleamSharedDependencyVersions.js\";\nexport type { GleamTomlRequiredConfig } from \"./policies/GleamTomlRequired.js\";\nexport type { GleamTomlSortedConfig } from \"./policies/GleamTomlSorted.js\";\nexport type { GleamVersionConstraintConfig } from \"./policies/GleamVersionConstraint.js\";\nexport type { LicenseFileExistsSettings } from \"./policies/LicenseFileExists.js\";\nexport type { MutuallyExclusiveScriptsConfig } from \"./policies/MutuallyExclusiveScripts.js\";\nexport type { NoLargeBinaryFilesSettings } from \"./policies/NoLargeBinaryFiles.js\";\nexport type { NoPrivateWorkspaceDependenciesSettings } from \"./policies/NoPrivateWorkspaceDependencies.js\";\nexport type { NoUnsafeWithoutJustificationConfig } from \"./policies/NoUnsafeWithoutJustification.js\";\nexport type { NoWildcardDependenciesConfig } from \"./policies/NoWildcardDependencies.js\";\nexport type { PackageAllowedScopesConfig } from \"./policies/PackageAllowedScopes.js\";\nexport type { PackageEsmTypeConfig } from \"./policies/PackageEsmType.js\";\nexport type { PackageFolderNameConfig } from \"./policies/PackageFolderName.js\";\nexport type { PackageJsonPropertiesSettings } from \"./policies/PackageJsonProperties.js\";\nexport type { PackageLicenseSettings } from \"./policies/PackageLicense.js\";\nexport type { PackagePrivateFieldConfig } from \"./policies/PackagePrivateField.js\";\nexport type { PackageReadmeSettings } from \"./policies/PackageReadme.js\";\nexport type {\n\tPackageScriptsSettings,\n\tScriptMustContainRule,\n} from \"./policies/PackageScripts.js\";\nexport type { PackageTestScriptsConfig } from \"./policies/PackageTestScripts.js\";\nexport type { PublicApiDocumentedConfig } from \"./policies/PublicApiDocumented.js\";\nexport type { RequiredGitignorePatternsSettings } from \"./policies/RequiredGitignorePatterns.js\";\nexport type {\n\tRequiredScriptEntry,\n\tRequiredScriptsConfig,\n} from \"./policies/RequiredScripts.js\";\nexport type { RustDocExistsConfig } from \"./policies/RustDocExists.js\";\nexport type { RustfmtConfigExistsConfig } from \"./policies/RustfmtConfigExists.js\";\nexport type { RustToolchainExistsConfig } from \"./policies/RustToolchainExists.js\";\nexport type {\n\tScriptContainsConfig,\n\tScriptContainsRule,\n} from \"./policies/ScriptContains.js\";\nexport type { SharedDependencyVersionsConfig } from \"./policies/SharedDependencyVersions.js\";\nexport type { WorkspaceInheritanceConfig } from \"./policies/WorkspaceInheritance.js\";\nexport type { WorkspaceMembersValidConfig } from \"./policies/WorkspaceMembersValid.js\";\nexport type {\n\tConfiguredFilePolicy,\n\tConfiguredPolicy,\n\tConfiguredRepositoryPolicy,\n\tFilePolicyDefinition,\n\tIdentifiedPolicy,\n\tPolicyArgs,\n\tPolicyDefinition,\n\tPolicyFinding,\n\tPolicyHandler,\n\tPolicyInstanceId,\n\tPolicyName,\n\tPolicyOptions,\n\tPolicyResolver,\n\tPolicyResult,\n\tRepositoryPolicyArgs,\n\tRepositoryPolicyDefinition,\n\tRepositoryPolicyHandler,\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,\n\ttype PackageJsonHandler,\n} from \"./policyDefiners/definePackagePolicy.js\";\nexport {\n\ttype PolicyExecutionError,\n\ttype PolicyRunFinding,\n\tPolicyRunner,\n\ttype PolicyRunnerOptions,\n\ttype PolicyRunResults,\n\ttype PolicySkippedWork,\n\ttype RepositoryInventory,\n\trunPolicies,\n} from \"./runner.js\";\n"]}
@@ -1,7 +1,7 @@
1
1
  import { CommandWithConfig, type CommandWithContext, type RequiresGit } from "@tylerbu/cli-api";
2
2
  import { type SimpleGit } from "simple-git";
3
3
  import { type RepopoConfig } from "./config.js";
4
- import type { RepopoCommandContext } from "./context.js";
4
+ import { type RepopoCommandContext } from "./context.js";
5
5
  /**
6
6
  * This class is the base for all repopo commands. It contains common flags and config loading.
7
7
  */
@@ -1 +1 @@
1
- {"version":3,"file":"baseCommand.d.ts","sourceRoot":"","sources":["../src/baseCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,iBAAiB,EACjB,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAChB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,KAAK,SAAS,EAAa,MAAM,YAAY,CAAC;AACvD,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,KAAK,EAAyB,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAKhF;;GAEG;AACH,8BAAsB,iBAAiB,CACrC,CAAC,SAAS,OAAO,iBAAiB,GAAG;IACpC,IAAI,EAAE,OAAO,iBAAiB,CAAC,IAAI,CAAC;IACpC,KAAK,EAAE,OAAO,iBAAiB,CAAC,KAAK,CAAC;CACtC,CAEF,SAAQ,iBAAiB,CAAC,CAAC,EAAE,YAAY,CACzC,YAAW,kBAAkB,CAAC,oBAAoB,CAAC,EAAE,WAAW;IAEhE,UAAmB,aAAa,eAAuB;IACvD,UAAmB,OAAO,oCAAyB;IAEnD,gBAAgC,KAAK;;MAE1B;IAEX,OAAO,CAAC,IAAI,CAAwB;IACpC,IAAW,GAAG,IAAI,SAAS,CAK1B;IAEqB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAyB3C,OAAO,CAAC,QAAQ,CAAmC;IAEtC,UAAU,IAAI,OAAO,CAAC,oBAAoB,CAAC;CAMxD"}
1
+ {"version":3,"file":"baseCommand.d.ts","sourceRoot":"","sources":["../src/baseCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,iBAAiB,EACjB,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAChB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,KAAK,SAAS,EAAa,MAAM,YAAY,CAAC;AACvD,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAGN,KAAK,oBAAoB,EACzB,MAAM,cAAc,CAAC;AAKtB;;GAEG;AACH,8BAAsB,iBAAiB,CACrC,CAAC,SAAS,OAAO,iBAAiB,GAAG;IACpC,IAAI,EAAE,OAAO,iBAAiB,CAAC,IAAI,CAAC;IACpC,KAAK,EAAE,OAAO,iBAAiB,CAAC,KAAK,CAAC;CACtC,CAEF,SAAQ,iBAAiB,CAAC,CAAC,EAAE,YAAY,CACzC,YAAW,kBAAkB,CAAC,oBAAoB,CAAC,EAAE,WAAW;IAEhE,UAAmB,aAAa,eAAuB;IACvD,UAAmB,OAAO,oCAAyB;IAEnD,gBAAgC,KAAK;;MAE1B;IAEX,OAAO,CAAC,IAAI,CAAwB;IACpC,IAAW,GAAG,IAAI,SAAS,CAK1B;IAEqB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAqB3C,OAAO,CAAC,QAAQ,CAAmC;IAEtC,UAAU,IAAI,OAAO,CAAC,oBAAoB,CAAC;CAMxD"}
@@ -3,7 +3,8 @@ import { createConsolaLogger } from "@tylerbu/cli-api/loggers/consola";
3
3
  import { findGitRootSync } from "@tylerbu/fundamentals/git";
4
4
  import { simpleGit } from "simple-git";
5
5
  import { DefaultPolicyConfig } from "./config.js";
6
- import { makePolicy } from "./makePolicy.js";
6
+ import { createExcludedPolicyFileMap, exclusionRegex, } from "./context.js";
7
+ import { identifyPolicyInstances, makePolicy } from "./makePolicy.js";
7
8
  import { newPerfStats } from "./perf.js";
8
9
  import { DefaultPolicies } from "./policy.js";
9
10
  /**
@@ -24,19 +25,15 @@ export class BaseRepopoCommand extends CommandWithConfig {
24
25
  }
25
26
  async init() {
26
27
  await super.init();
27
- const excludeFiles = this.commandConfig?.excludeFiles?.map((e) => new RegExp(e, "i")) ?? [];
28
- const excludePoliciesForFiles = new Map();
29
- for (const policy of this.commandConfig?.policies ?? []) {
30
- const regexes = policy.excludeFiles?.map((e) => new RegExp(e, "i")) ?? [];
31
- excludePoliciesForFiles.set(policy.name, regexes);
32
- }
28
+ const excludeFiles = this.commandConfig?.excludeFiles?.map(exclusionRegex) ?? [];
29
+ const policies = identifyPolicyInstances(this.commandConfig?.policies ??
30
+ DefaultPolicies.map((configuredPolicy) => makePolicy(configuredPolicy)));
33
31
  const gitRoot = findGitRootSync();
34
32
  this._git = simpleGit({ baseDir: gitRoot });
35
33
  this._context = {
36
34
  excludeFromAll: excludeFiles,
37
- policies: this.commandConfig?.policies ??
38
- DefaultPolicies.map((p) => makePolicy(p)),
39
- excludePoliciesForFiles,
35
+ policies,
36
+ excludePoliciesForFiles: createExcludedPolicyFileMap(policies),
40
37
  gitRoot,
41
38
  perfStats: newPerfStats(),
42
39
  };
@@ -1 +1 @@
1
- {"version":3,"file":"baseCommand.js","sourceRoot":"","sources":["../src/baseCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,iBAAiB,GAGjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAkB,SAAS,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAqB,MAAM,aAAa,CAA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C,IAAI,GAAG,SAAS,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;QAC5C,IAAI,CAAC,QAAQ,GAAG;YACf,cAAc,EAAE,YAAY;YAC5B,QAAQ,EACP,IAAI,CAAC,aAAa,EAAE,QAAQ;gBAC5B,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YAC1C,uBAAuB;YACvB,OAAO;YACP,SAAS,EAAE,YAAY,EAAE;SACzB,CAAC;IACH,CAAC;IAEO,QAAQ,CAAmC;IAE5C,KAAK,CAAC,UAAU;QACtB,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtB,CAAC","sourcesContent":["import {\n\tCommandWithConfig,\n\ttype CommandWithContext,\n\ttype RequiresGit,\n} from \"@tylerbu/cli-api\";\nimport { createConsolaLogger } from \"@tylerbu/cli-api/loggers/consola\";\nimport { findGitRootSync } from \"@tylerbu/fundamentals/git\";\nimport { type SimpleGit, simpleGit } from \"simple-git\";\nimport { DefaultPolicyConfig, type RepopoConfig } from \"./config.js\";\nimport type { ExcludedPolicyFileMap, RepopoCommandContext } from \"./context.js\";\nimport { makePolicy } from \"./makePolicy.js\";\nimport { newPerfStats } from \"./perf.js\";\nimport { DefaultPolicies } from \"./policy.js\";\n\n/**\n * This class is the base for all repopo commands. It contains common flags and config loading.\n */\nexport abstract class BaseRepopoCommand<\n\t\tT extends typeof BaseRepopoCommand & {\n\t\t\targs: typeof CommandWithConfig.args;\n\t\t\tflags: typeof CommandWithConfig.flags;\n\t\t},\n\t>\n\textends CommandWithConfig<T, RepopoConfig>\n\timplements CommandWithContext<RepopoCommandContext>, RequiresGit\n{\n\tprotected override defaultConfig = DefaultPolicyConfig;\n\tprotected override _logger = createConsolaLogger();\n\n\tpublic static override readonly flags = {\n\t\t...CommandWithConfig.flags,\n\t} as const;\n\n\tprivate _git: SimpleGit | undefined;\n\tpublic get git(): SimpleGit {\n\t\tif (this._git === undefined) {\n\t\t\tthrow new Error(\"git property is undefined\");\n\t\t}\n\t\treturn this._git;\n\t}\n\n\tpublic override async init(): Promise<void> {\n\t\tawait super.init();\n\n\t\tconst excludeFiles: RegExp[] =\n\t\t\tthis.commandConfig?.excludeFiles?.map((e) => new RegExp(e, \"i\")) ?? [];\n\n\t\tconst excludePoliciesForFiles: ExcludedPolicyFileMap = new Map();\n\t\tfor (const policy of this.commandConfig?.policies ?? []) {\n\t\t\tconst regexes = policy.excludeFiles?.map((e) => new RegExp(e, \"i\")) ?? [];\n\t\t\texcludePoliciesForFiles.set(policy.name, regexes);\n\t\t}\n\n\t\tconst gitRoot = findGitRootSync();\n\t\tthis._git = simpleGit({ baseDir: gitRoot });\n\t\tthis._context = {\n\t\t\texcludeFromAll: excludeFiles,\n\t\t\tpolicies:\n\t\t\t\tthis.commandConfig?.policies ??\n\t\t\t\tDefaultPolicies.map((p) => makePolicy(p)),\n\t\t\texcludePoliciesForFiles,\n\t\t\tgitRoot,\n\t\t\tperfStats: newPerfStats(),\n\t\t};\n\t}\n\n\tprivate _context: RepopoCommandContext | undefined;\n\n\tpublic async getContext(): Promise<RepopoCommandContext> {\n\t\tif (this._context === undefined) {\n\t\t\tthrow new Error(\"Context not initialized.\");\n\t\t}\n\t\treturn this._context;\n\t}\n}\n"]}
1
+ {"version":3,"file":"baseCommand.js","sourceRoot":"","sources":["../src/baseCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,iBAAiB,GAGjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAkB,SAAS,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,mBAAmB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AAC,QAAQ,CAAC;YAC9D,OAAO;YACP,SAAS,EAAE,YAAY,EAAE;SACzB,CAAC;IACH,CAAC;IAEO,QAAQ,CAAmC;IAE5C,KAAK,CAAC,UAAU;QACtB,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtB,CAAC","sourcesContent":["import {\n\tCommandWithConfig,\n\ttype CommandWithContext,\n\ttype RequiresGit,\n} from \"@tylerbu/cli-api\";\nimport { createConsolaLogger } from \"@tylerbu/cli-api/loggers/consola\";\nimport { findGitRootSync } from \"@tylerbu/fundamentals/git\";\nimport { type SimpleGit, simpleGit } from \"simple-git\";\nimport { DefaultPolicyConfig, type RepopoConfig } from \"./config.js\";\nimport {\n\tcreateExcludedPolicyFileMap,\n\texclusionRegex,\n\ttype RepopoCommandContext,\n} from \"./context.js\";\nimport { identifyPolicyInstances, makePolicy } from \"./makePolicy.js\";\nimport { newPerfStats } from \"./perf.js\";\nimport { DefaultPolicies } from \"./policy.js\";\n\n/**\n * This class is the base for all repopo commands. It contains common flags and config loading.\n */\nexport abstract class BaseRepopoCommand<\n\t\tT extends typeof BaseRepopoCommand & {\n\t\t\targs: typeof CommandWithConfig.args;\n\t\t\tflags: typeof CommandWithConfig.flags;\n\t\t},\n\t>\n\textends CommandWithConfig<T, RepopoConfig>\n\timplements CommandWithContext<RepopoCommandContext>, RequiresGit\n{\n\tprotected override defaultConfig = DefaultPolicyConfig;\n\tprotected override _logger = createConsolaLogger();\n\n\tpublic static override readonly flags = {\n\t\t...CommandWithConfig.flags,\n\t} as const;\n\n\tprivate _git: SimpleGit | undefined;\n\tpublic get git(): SimpleGit {\n\t\tif (this._git === undefined) {\n\t\t\tthrow new Error(\"git property is undefined\");\n\t\t}\n\t\treturn this._git;\n\t}\n\n\tpublic override async init(): Promise<void> {\n\t\tawait super.init();\n\n\t\tconst excludeFiles: RegExp[] =\n\t\t\tthis.commandConfig?.excludeFiles?.map(exclusionRegex) ?? [];\n\n\t\tconst policies = identifyPolicyInstances(\n\t\t\tthis.commandConfig?.policies ??\n\t\t\t\tDefaultPolicies.map((configuredPolicy) => makePolicy(configuredPolicy)),\n\t\t);\n\t\tconst gitRoot = findGitRootSync();\n\t\tthis._git = simpleGit({ baseDir: gitRoot });\n\t\tthis._context = {\n\t\t\texcludeFromAll: excludeFiles,\n\t\t\tpolicies,\n\t\t\texcludePoliciesForFiles: createExcludedPolicyFileMap(policies),\n\t\t\tgitRoot,\n\t\t\tperfStats: newPerfStats(),\n\t\t};\n\t}\n\n\tprivate _context: RepopoCommandContext | undefined;\n\n\tpublic async getContext(): Promise<RepopoCommandContext> {\n\t\tif (this._context === undefined) {\n\t\t\tthrow new Error(\"Context not initialized.\");\n\t\t}\n\t\treturn this._context;\n\t}\n}\n"]}
@@ -0,0 +1,25 @@
1
+ import { Command } from "@oclif/core";
2
+ /**
3
+ * Runs the Rust-based repopo-core engine with the Node.js sidecar for
4
+ * per-policy execution. Rust owns matching, ordering, concurrency, exception
5
+ * boundaries, repository scheduling and aggregation.
6
+ */
7
+ export declare class CheckNative extends Command {
8
+ static readonly summary = "Checks and applies policies using the Rust engine.";
9
+ static readonly description: string;
10
+ static readonly flags: {
11
+ readonly concurrency: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
12
+ readonly fix: import("@oclif/core/interfaces").BooleanFlag<boolean>;
13
+ readonly stdin: import("@oclif/core/interfaces").BooleanFlag<boolean>;
14
+ readonly verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
15
+ readonly quiet: import("@oclif/core/interfaces").BooleanFlag<boolean>;
16
+ readonly config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
+ readonly "sidecar-path": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
18
+ readonly "binary-path": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
19
+ readonly runtime: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
20
+ };
21
+ run(): Promise<void>;
22
+ private resolveBinaryPath;
23
+ private resolveSidecarPath;
24
+ }
25
+ //# sourceMappingURL=check-native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-native.d.ts","sourceRoot":"","sources":["../../src/commands/check-native.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAC;AAM7C;;;;GAIG;AACH,qBAAa,WAAY,SAAQ,OAAO;IACvC,gBAAgC,OAAO,wDACe;IAEtD,gBAAgC,WAAW,SAIsC;IAEjF,gBAAgC,KAAK;;;;;;;;;;MAgD1B;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAkE1C,OAAO,CAAC,iBAAiB;IAiDzB,OAAO,CAAC,kBAAkB;CAQ1B"}
@@ -0,0 +1,156 @@
1
+ import { spawn } from "node:child_process";
2
+ import { existsSync } from "node:fs";
3
+ import { fileURLToPath } from "node:url";
4
+ import { Command, Flags } from "@oclif/core";
5
+ import { dirname, resolve } from "pathe";
6
+ import { DEFAULT_CONCURRENCY, validateConcurrency } from "../concurrency.js";
7
+ const __dirname = dirname(fileURLToPath(import.meta.url));
8
+ /**
9
+ * Runs the Rust-based repopo-core engine with the Node.js sidecar for
10
+ * per-policy execution. Rust owns matching, ordering, concurrency, exception
11
+ * boundaries, repository scheduling and aggregation.
12
+ */
13
+ export class CheckNative extends Command {
14
+ static summary = "Checks and applies policies using the Rust engine.";
15
+ static description = "Runs the Rust-based repopo-core engine with the Node.js sidecar. " +
16
+ "Rust handles file matching, scheduling and reporting; the sidecar shares per-policy contracts with 'check'. " +
17
+ "Repository policies always run with the full repository inventory, including with --stdin. " +
18
+ "With --fix, repository policies can modify files outside the stdin selection.";
19
+ static flags = {
20
+ concurrency: Flags.integer({
21
+ description: "Maximum concurrent files in read-only checks. Fixes remain sequential.",
22
+ default: DEFAULT_CONCURRENCY,
23
+ parse: async (value) => validateConcurrency(Number(value)),
24
+ }),
25
+ fix: Flags.boolean({
26
+ aliases: ["resolve"],
27
+ description: "Fix errors if possible.",
28
+ required: false,
29
+ char: "f",
30
+ }),
31
+ stdin: Flags.boolean({
32
+ description: "Read list of files from stdin.",
33
+ required: false,
34
+ }),
35
+ verbose: Flags.boolean({
36
+ description: "Show verbose output including per-policy timing.",
37
+ required: false,
38
+ char: "v",
39
+ }),
40
+ quiet: Flags.boolean({
41
+ description: "Suppress all output except errors.",
42
+ required: false,
43
+ char: "q",
44
+ }),
45
+ config: Flags.string({
46
+ description: "Path to the config file.",
47
+ required: false,
48
+ char: "c",
49
+ }),
50
+ "sidecar-path": Flags.string({
51
+ description: "Path to the Node.js sidecar script.",
52
+ required: false,
53
+ env: "REPOPO_SIDECAR_PATH",
54
+ }),
55
+ "binary-path": Flags.string({
56
+ description: "Path to the repopo-core Rust binary.",
57
+ required: false,
58
+ env: "REPOPO_CORE_PATH",
59
+ }),
60
+ runtime: Flags.string({
61
+ description: "JS runtime for the sidecar process (auto, node, bun).",
62
+ required: false,
63
+ env: "REPOPO_RUNTIME",
64
+ options: ["auto", "node", "bun"],
65
+ }),
66
+ };
67
+ async run() {
68
+ const { flags } = await this.parse(CheckNative);
69
+ const binaryPath = this.resolveBinaryPath(flags["binary-path"]);
70
+ const sidecarPath = this.resolveSidecarPath(flags["sidecar-path"]);
71
+ const args = ["check", "--sidecar-path", sidecarPath];
72
+ args.push("--concurrency", String(flags.concurrency));
73
+ if (flags.fix) {
74
+ args.push("--fix");
75
+ }
76
+ if (flags.stdin) {
77
+ args.push("--stdin");
78
+ }
79
+ if (flags.verbose) {
80
+ args.push("--verbose");
81
+ }
82
+ if (flags.quiet) {
83
+ args.push("--quiet");
84
+ }
85
+ if (flags.config) {
86
+ args.push("--config", flags.config);
87
+ }
88
+ if (flags.runtime) {
89
+ args.push("--runtime", flags.runtime);
90
+ }
91
+ return new Promise((resolvePromise, reject) => {
92
+ const child = spawn(binaryPath, args, {
93
+ stdio: "inherit",
94
+ // biome-ignore lint/style/noProcessEnv: Need to pass parent environment to child process
95
+ env: { ...process.env },
96
+ });
97
+ const interrupt = () => child.kill("SIGINT");
98
+ const terminate = () => child.kill("SIGTERM");
99
+ const cleanup = () => {
100
+ process.removeListener("SIGINT", interrupt);
101
+ process.removeListener("SIGTERM", terminate);
102
+ };
103
+ process.on("SIGINT", interrupt);
104
+ process.on("SIGTERM", terminate);
105
+ child.on("error", (err) => {
106
+ cleanup();
107
+ reject(new Error(`Failed to spawn repopo-core: ${err.message}\n` +
108
+ `Binary path: ${binaryPath}\n` +
109
+ "Make sure the Rust binary has been built: cargo build --manifest-path crates/core/Cargo.toml"));
110
+ });
111
+ child.on("close", (code, signal) => {
112
+ cleanup();
113
+ if (code !== 0) {
114
+ process.exitCode =
115
+ code ??
116
+ (signal === "SIGINT" ? 130 : signal === "SIGTERM" ? 143 : 1);
117
+ }
118
+ resolvePromise();
119
+ });
120
+ });
121
+ }
122
+ resolveBinaryPath(explicit) {
123
+ if (explicit) {
124
+ return explicit;
125
+ }
126
+ const packageRoot = resolve(__dirname, "..", "..");
127
+ const binaryName = process.platform === "win32" ? "repopo-core.exe" : "repopo-core";
128
+ // Check paths in priority order:
129
+ // 1. Postinstall-downloaded binary (npm install)
130
+ const nativePath = resolve(packageRoot, "native", binaryName);
131
+ if (existsSync(nativePath)) {
132
+ return nativePath;
133
+ }
134
+ // 2. Local release build (cargo build --release)
135
+ const releasePath = resolve(packageRoot, "crates", "core", "target", "release", binaryName);
136
+ if (existsSync(releasePath)) {
137
+ return releasePath;
138
+ }
139
+ // 3. Local debug build (cargo build)
140
+ const debugPath = resolve(packageRoot, "crates", "core", "target", "debug", binaryName);
141
+ if (existsSync(debugPath)) {
142
+ return debugPath;
143
+ }
144
+ throw new Error("repopo-core binary not found. Either:\n" +
145
+ " - Install the package (npm install repopo) to download pre-built binaries\n" +
146
+ " - Build from source: cargo build --manifest-path crates/core/Cargo.toml");
147
+ }
148
+ resolveSidecarPath(explicit) {
149
+ if (explicit) {
150
+ return explicit;
151
+ }
152
+ const packageRoot = resolve(__dirname, "..", "..");
153
+ return resolve(packageRoot, "sidecar", "sidecar.mjs");
154
+ }
155
+ }
156
+ //# sourceMappingURL=check-native.js.map