repopo 0.12.0 → 0.14.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 (345) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/README.md +57 -90
  3. package/THIRD-PARTY-LICENSES.txt +169 -11
  4. package/bin/dev.js +0 -0
  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 +66 -1
  10. package/esm/api.d.ts.map +1 -1
  11. package/esm/api.js +18 -1
  12. package/esm/api.js.map +1 -1
  13. package/esm/baseCommand.d.ts.map +1 -1
  14. package/esm/baseCommand.js +2 -2
  15. package/esm/baseCommand.js.map +1 -1
  16. package/esm/commands/check-native.d.ts +5 -3
  17. package/esm/commands/check-native.d.ts.map +1 -1
  18. package/esm/commands/check-native.js +35 -7
  19. package/esm/commands/check-native.js.map +1 -1
  20. package/esm/commands/check.d.ts +8 -21
  21. package/esm/commands/check.d.ts.map +1 -1
  22. package/esm/commands/check.js +98 -154
  23. package/esm/commands/check.js.map +1 -1
  24. package/esm/commands/list.d.ts.map +1 -1
  25. package/esm/commands/list.js +1 -0
  26. package/esm/commands/list.js.map +1 -1
  27. package/esm/concurrency.d.ts +3 -0
  28. package/esm/concurrency.d.ts.map +1 -0
  29. package/esm/concurrency.js +8 -0
  30. package/esm/concurrency.js.map +1 -0
  31. package/esm/config.d.ts +10 -39
  32. package/esm/config.d.ts.map +1 -1
  33. package/esm/config.js +3 -7
  34. package/esm/config.js.map +1 -1
  35. package/esm/context.d.ts +10 -1
  36. package/esm/context.d.ts.map +1 -1
  37. package/esm/context.js +19 -1
  38. package/esm/context.js.map +1 -1
  39. package/esm/executionContractError.d.ts +4 -0
  40. package/esm/executionContractError.d.ts.map +1 -0
  41. package/esm/executionContractError.js +4 -0
  42. package/esm/executionContractError.js.map +1 -0
  43. package/esm/fileCache.d.ts +12 -0
  44. package/esm/fileCache.d.ts.map +1 -0
  45. package/esm/fileCache.js +37 -0
  46. package/esm/fileCache.js.map +1 -0
  47. package/esm/filePaths.d.ts +2 -0
  48. package/esm/filePaths.d.ts.map +1 -0
  49. package/esm/filePaths.js +9 -0
  50. package/esm/filePaths.js.map +1 -0
  51. package/esm/generators.d.ts +0 -20
  52. package/esm/generators.d.ts.map +1 -1
  53. package/esm/generators.js.map +1 -1
  54. package/esm/index.d.ts +3 -16
  55. package/esm/index.d.ts.map +1 -1
  56. package/esm/index.js +3 -17
  57. package/esm/index.js.map +1 -1
  58. package/esm/makePolicy.d.ts +20 -100
  59. package/esm/makePolicy.d.ts.map +1 -1
  60. package/esm/makePolicy.js +46 -132
  61. package/esm/makePolicy.js.map +1 -1
  62. package/esm/perf.d.ts +5 -2
  63. package/esm/perf.d.ts.map +1 -1
  64. package/esm/perf.js +10 -9
  65. package/esm/perf.js.map +1 -1
  66. package/esm/policies/CargoLicenceValidated.d.ts +4 -4
  67. package/esm/policies/CargoLicenceValidated.d.ts.map +1 -1
  68. package/esm/policies/CargoLicenceValidated.js +9 -7
  69. package/esm/policies/CargoLicenceValidated.js.map +1 -1
  70. package/esm/policies/CargoLintsConfigured.d.ts +4 -4
  71. package/esm/policies/CargoLintsConfigured.d.ts.map +1 -1
  72. package/esm/policies/CargoLintsConfigured.js +19 -15
  73. package/esm/policies/CargoLintsConfigured.js.map +1 -1
  74. package/esm/policies/CargoLockPolicy.d.ts +4 -4
  75. package/esm/policies/CargoLockPolicy.d.ts.map +1 -1
  76. package/esm/policies/CargoLockPolicy.js +15 -11
  77. package/esm/policies/CargoLockPolicy.js.map +1 -1
  78. package/esm/policies/CargoTomlRequired.d.ts +5 -5
  79. package/esm/policies/CargoTomlRequired.d.ts.map +1 -1
  80. package/esm/policies/CargoTomlRequired.js +7 -7
  81. package/esm/policies/CargoTomlRequired.js.map +1 -1
  82. package/esm/policies/CargoTomlSorted.d.ts +4 -4
  83. package/esm/policies/CargoTomlSorted.d.ts.map +1 -1
  84. package/esm/policies/CargoTomlSorted.js +21 -17
  85. package/esm/policies/CargoTomlSorted.js.map +1 -1
  86. package/esm/policies/ConditionalScripts.d.ts +10 -8
  87. package/esm/policies/ConditionalScripts.d.ts.map +1 -1
  88. package/esm/policies/ConditionalScripts.js +24 -22
  89. package/esm/policies/ConditionalScripts.js.map +1 -1
  90. package/esm/policies/ExactScripts.d.ts +8 -6
  91. package/esm/policies/ExactScripts.d.ts.map +1 -1
  92. package/esm/policies/ExactScripts.js +15 -18
  93. package/esm/policies/ExactScripts.js.map +1 -1
  94. package/esm/policies/GleamDepVersions.d.ts +5 -5
  95. package/esm/policies/GleamDepVersions.d.ts.map +1 -1
  96. package/esm/policies/GleamDepVersions.js +5 -5
  97. package/esm/policies/GleamDepVersions.js.map +1 -1
  98. package/esm/policies/GleamDocExists.d.ts +4 -4
  99. package/esm/policies/GleamDocExists.d.ts.map +1 -1
  100. package/esm/policies/GleamDocExists.js +6 -6
  101. package/esm/policies/GleamDocExists.js.map +1 -1
  102. package/esm/policies/GleamInternalModulesConfigured.d.ts +4 -4
  103. package/esm/policies/GleamInternalModulesConfigured.d.ts.map +1 -1
  104. package/esm/policies/GleamInternalModulesConfigured.js +8 -6
  105. package/esm/policies/GleamInternalModulesConfigured.js.map +1 -1
  106. package/esm/policies/GleamLicenceConfigured.d.ts +4 -4
  107. package/esm/policies/GleamLicenceConfigured.d.ts.map +1 -1
  108. package/esm/policies/GleamLicenceConfigured.js +8 -6
  109. package/esm/policies/GleamLicenceConfigured.js.map +1 -1
  110. package/esm/policies/GleamManifestCommitted.d.ts +10 -3
  111. package/esm/policies/GleamManifestCommitted.d.ts.map +1 -1
  112. package/esm/policies/GleamManifestCommitted.js +10 -9
  113. package/esm/policies/GleamManifestCommitted.js.map +1 -1
  114. package/esm/policies/GleamMonorepoConsistency.d.ts +13 -5
  115. package/esm/policies/GleamMonorepoConsistency.d.ts.map +1 -1
  116. package/esm/policies/GleamMonorepoConsistency.js +10 -10
  117. package/esm/policies/GleamMonorepoConsistency.js.map +1 -1
  118. package/esm/policies/GleamNameRestrictions.d.ts +4 -4
  119. package/esm/policies/GleamNameRestrictions.d.ts.map +1 -1
  120. package/esm/policies/GleamNameRestrictions.js +6 -6
  121. package/esm/policies/GleamNameRestrictions.js.map +1 -1
  122. package/esm/policies/GleamNoPathDepsInPublished.d.ts +4 -4
  123. package/esm/policies/GleamNoPathDepsInPublished.d.ts.map +1 -1
  124. package/esm/policies/GleamNoPathDepsInPublished.js +6 -6
  125. package/esm/policies/GleamNoPathDepsInPublished.js.map +1 -1
  126. package/esm/policies/GleamPathDepsValid.d.ts +3 -3
  127. package/esm/policies/GleamPathDepsValid.d.ts.map +1 -1
  128. package/esm/policies/GleamPathDepsValid.js +5 -5
  129. package/esm/policies/GleamPathDepsValid.js.map +1 -1
  130. package/esm/policies/GleamProjectStructure.d.ts +11 -4
  131. package/esm/policies/GleamProjectStructure.d.ts.map +1 -1
  132. package/esm/policies/GleamProjectStructure.js +7 -8
  133. package/esm/policies/GleamProjectStructure.js.map +1 -1
  134. package/esm/policies/GleamSharedDependencyVersions.d.ts +12 -4
  135. package/esm/policies/GleamSharedDependencyVersions.d.ts.map +1 -1
  136. package/esm/policies/GleamSharedDependencyVersions.js +10 -10
  137. package/esm/policies/GleamSharedDependencyVersions.js.map +1 -1
  138. package/esm/policies/GleamTomlRequired.d.ts +4 -4
  139. package/esm/policies/GleamTomlRequired.d.ts.map +1 -1
  140. package/esm/policies/GleamTomlRequired.js +5 -5
  141. package/esm/policies/GleamTomlRequired.js.map +1 -1
  142. package/esm/policies/GleamTomlSorted.d.ts +4 -4
  143. package/esm/policies/GleamTomlSorted.d.ts.map +1 -1
  144. package/esm/policies/GleamTomlSorted.js +21 -17
  145. package/esm/policies/GleamTomlSorted.js.map +1 -1
  146. package/esm/policies/GleamVersionConstraint.d.ts +4 -4
  147. package/esm/policies/GleamVersionConstraint.d.ts.map +1 -1
  148. package/esm/policies/GleamVersionConstraint.js +14 -10
  149. package/esm/policies/GleamVersionConstraint.js.map +1 -1
  150. package/esm/policies/HtmlFileHeaders.d.ts +4 -2
  151. package/esm/policies/HtmlFileHeaders.d.ts.map +1 -1
  152. package/esm/policies/HtmlFileHeaders.js +1 -1
  153. package/esm/policies/HtmlFileHeaders.js.map +1 -1
  154. package/esm/policies/JsTsFileHeaders.d.ts +4 -2
  155. package/esm/policies/JsTsFileHeaders.d.ts.map +1 -1
  156. package/esm/policies/JsTsFileHeaders.js +1 -1
  157. package/esm/policies/JsTsFileHeaders.js.map +1 -1
  158. package/esm/policies/LicenseFileExists.d.ts +10 -4
  159. package/esm/policies/LicenseFileExists.d.ts.map +1 -1
  160. package/esm/policies/LicenseFileExists.js +27 -20
  161. package/esm/policies/LicenseFileExists.js.map +1 -1
  162. package/esm/policies/MaxChangedFiles.d.ts +17 -0
  163. package/esm/policies/MaxChangedFiles.d.ts.map +1 -0
  164. package/esm/policies/MaxChangedFiles.js +22 -0
  165. package/esm/policies/MaxChangedFiles.js.map +1 -0
  166. package/esm/policies/MutuallyExclusiveScripts.d.ts +8 -6
  167. package/esm/policies/MutuallyExclusiveScripts.d.ts.map +1 -1
  168. package/esm/policies/MutuallyExclusiveScripts.js +9 -13
  169. package/esm/policies/MutuallyExclusiveScripts.js.map +1 -1
  170. package/esm/policies/NoBuildDirectory.d.ts +9 -3
  171. package/esm/policies/NoBuildDirectory.d.ts.map +1 -1
  172. package/esm/policies/NoBuildDirectory.js +8 -13
  173. package/esm/policies/NoBuildDirectory.js.map +1 -1
  174. package/esm/policies/NoJsFileExtensions.d.ts +9 -3
  175. package/esm/policies/NoJsFileExtensions.d.ts.map +1 -1
  176. package/esm/policies/NoJsFileExtensions.js +9 -14
  177. package/esm/policies/NoJsFileExtensions.js.map +1 -1
  178. package/esm/policies/NoLargeBinaryFiles.d.ts +9 -4
  179. package/esm/policies/NoLargeBinaryFiles.d.ts.map +1 -1
  180. package/esm/policies/NoLargeBinaryFiles.js +10 -16
  181. package/esm/policies/NoLargeBinaryFiles.js.map +1 -1
  182. package/esm/policies/NoPrivateWorkspaceDependencies.d.ts +10 -6
  183. package/esm/policies/NoPrivateWorkspaceDependencies.d.ts.map +1 -1
  184. package/esm/policies/NoPrivateWorkspaceDependencies.js +12 -14
  185. package/esm/policies/NoPrivateWorkspaceDependencies.js.map +1 -1
  186. package/esm/policies/NoTargetArtifacts.d.ts +9 -3
  187. package/esm/policies/NoTargetArtifacts.d.ts.map +1 -1
  188. package/esm/policies/NoTargetArtifacts.js +9 -14
  189. package/esm/policies/NoTargetArtifacts.js.map +1 -1
  190. package/esm/policies/NoUnsafeWithoutJustification.d.ts +11 -4
  191. package/esm/policies/NoUnsafeWithoutJustification.d.ts.map +1 -1
  192. package/esm/policies/NoUnsafeWithoutJustification.js +8 -9
  193. package/esm/policies/NoUnsafeWithoutJustification.js.map +1 -1
  194. package/esm/policies/NoWildcardDependencies.d.ts +5 -5
  195. package/esm/policies/NoWildcardDependencies.d.ts.map +1 -1
  196. package/esm/policies/NoWildcardDependencies.js +6 -6
  197. package/esm/policies/NoWildcardDependencies.js.map +1 -1
  198. package/esm/policies/PackageAllowedScopes.d.ts +9 -5
  199. package/esm/policies/PackageAllowedScopes.d.ts.map +1 -1
  200. package/esm/policies/PackageAllowedScopes.js +15 -16
  201. package/esm/policies/PackageAllowedScopes.js.map +1 -1
  202. package/esm/policies/PackageEsmType.d.ts +7 -5
  203. package/esm/policies/PackageEsmType.d.ts.map +1 -1
  204. package/esm/policies/PackageEsmType.js +31 -31
  205. package/esm/policies/PackageEsmType.js.map +1 -1
  206. package/esm/policies/PackageFolderName.d.ts +8 -6
  207. package/esm/policies/PackageFolderName.d.ts.map +1 -1
  208. package/esm/policies/PackageFolderName.js +13 -16
  209. package/esm/policies/PackageFolderName.js.map +1 -1
  210. package/esm/policies/PackageJsonProperties.d.ts +5 -3
  211. package/esm/policies/PackageJsonProperties.d.ts.map +1 -1
  212. package/esm/policies/PackageJsonProperties.js +6 -17
  213. package/esm/policies/PackageJsonProperties.js.map +1 -1
  214. package/esm/policies/PackageJsonRepoDirectoryProperty.d.ts +2 -7
  215. package/esm/policies/PackageJsonRepoDirectoryProperty.d.ts.map +1 -1
  216. package/esm/policies/PackageJsonRepoDirectoryProperty.js +28 -42
  217. package/esm/policies/PackageJsonRepoDirectoryProperty.js.map +1 -1
  218. package/esm/policies/PackageJsonSorted.d.ts +2 -2
  219. package/esm/policies/PackageJsonSorted.d.ts.map +1 -1
  220. package/esm/policies/PackageJsonSorted.js +15 -30
  221. package/esm/policies/PackageJsonSorted.js.map +1 -1
  222. package/esm/policies/PackageLicense.d.ts +4 -4
  223. package/esm/policies/PackageLicense.d.ts.map +1 -1
  224. package/esm/policies/PackageLicense.js +31 -52
  225. package/esm/policies/PackageLicense.js.map +1 -1
  226. package/esm/policies/PackagePrivateField.d.ts +12 -8
  227. package/esm/policies/PackagePrivateField.d.ts.map +1 -1
  228. package/esm/policies/PackagePrivateField.js +31 -23
  229. package/esm/policies/PackagePrivateField.js.map +1 -1
  230. package/esm/policies/PackageReadme.d.ts +6 -5
  231. package/esm/policies/PackageReadme.d.ts.map +1 -1
  232. package/esm/policies/PackageReadme.js +22 -59
  233. package/esm/policies/PackageReadme.js.map +1 -1
  234. package/esm/policies/PackageScripts.d.ts +26 -22
  235. package/esm/policies/PackageScripts.d.ts.map +1 -1
  236. package/esm/policies/PackageScripts.js +39 -36
  237. package/esm/policies/PackageScripts.js.map +1 -1
  238. package/esm/policies/PackageTestScripts.d.ts +10 -6
  239. package/esm/policies/PackageTestScripts.d.ts.map +1 -1
  240. package/esm/policies/PackageTestScripts.js +14 -16
  241. package/esm/policies/PackageTestScripts.js.map +1 -1
  242. package/esm/policies/PublicApiDocumented.d.ts +4 -4
  243. package/esm/policies/PublicApiDocumented.d.ts.map +1 -1
  244. package/esm/policies/PublicApiDocumented.js +10 -8
  245. package/esm/policies/PublicApiDocumented.js.map +1 -1
  246. package/esm/policies/RequireCompanionChanges.d.ts +16 -0
  247. package/esm/policies/RequireCompanionChanges.d.ts.map +1 -0
  248. package/esm/policies/RequireCompanionChanges.js +42 -0
  249. package/esm/policies/RequireCompanionChanges.js.map +1 -0
  250. package/esm/policies/RequiredGitignorePatterns.d.ts +11 -4
  251. package/esm/policies/RequiredGitignorePatterns.d.ts.map +1 -1
  252. package/esm/policies/RequiredGitignorePatterns.js +29 -36
  253. package/esm/policies/RequiredGitignorePatterns.js.map +1 -1
  254. package/esm/policies/RequiredScripts.d.ts +9 -7
  255. package/esm/policies/RequiredScripts.d.ts.map +1 -1
  256. package/esm/policies/RequiredScripts.js +24 -24
  257. package/esm/policies/RequiredScripts.js.map +1 -1
  258. package/esm/policies/RustDocExists.d.ts +4 -4
  259. package/esm/policies/RustDocExists.d.ts.map +1 -1
  260. package/esm/policies/RustDocExists.js +6 -6
  261. package/esm/policies/RustDocExists.js.map +1 -1
  262. package/esm/policies/RustToolchainExists.d.ts +11 -4
  263. package/esm/policies/RustToolchainExists.d.ts.map +1 -1
  264. package/esm/policies/RustToolchainExists.js +10 -9
  265. package/esm/policies/RustToolchainExists.js.map +1 -1
  266. package/esm/policies/RustfmtConfigExists.d.ts +11 -4
  267. package/esm/policies/RustfmtConfigExists.d.ts.map +1 -1
  268. package/esm/policies/RustfmtConfigExists.js +10 -9
  269. package/esm/policies/RustfmtConfigExists.js.map +1 -1
  270. package/esm/policies/ScriptContains.d.ts +9 -7
  271. package/esm/policies/ScriptContains.d.ts.map +1 -1
  272. package/esm/policies/ScriptContains.js +9 -13
  273. package/esm/policies/ScriptContains.js.map +1 -1
  274. package/esm/policies/SharedDependencyVersions.d.ts +9 -4
  275. package/esm/policies/SharedDependencyVersions.d.ts.map +1 -1
  276. package/esm/policies/SharedDependencyVersions.js +28 -20
  277. package/esm/policies/SharedDependencyVersions.js.map +1 -1
  278. package/esm/policies/WorkspaceInheritance.d.ts +11 -4
  279. package/esm/policies/WorkspaceInheritance.d.ts.map +1 -1
  280. package/esm/policies/WorkspaceInheritance.js +10 -11
  281. package/esm/policies/WorkspaceInheritance.js.map +1 -1
  282. package/esm/policies/WorkspaceMembersValid.d.ts +11 -4
  283. package/esm/policies/WorkspaceMembersValid.d.ts.map +1 -1
  284. package/esm/policies/WorkspaceMembersValid.js +10 -11
  285. package/esm/policies/WorkspaceMembersValid.js.map +1 -1
  286. package/esm/policies/constants.d.ts.map +1 -1
  287. package/esm/policies/constants.js +1 -1
  288. package/esm/policies/constants.js.map +1 -1
  289. package/esm/policies.d.ts +15 -5
  290. package/esm/policies.d.ts.map +1 -1
  291. package/esm/policies.js +14 -5
  292. package/esm/policies.js.map +1 -1
  293. package/esm/policy.d.ts +67 -289
  294. package/esm/policy.d.ts.map +1 -1
  295. package/esm/policy.js +1 -122
  296. package/esm/policy.js.map +1 -1
  297. package/esm/policyDefiners/defineCargoPolicy.d.ts +25 -9
  298. package/esm/policyDefiners/defineCargoPolicy.d.ts.map +1 -1
  299. package/esm/policyDefiners/defineCargoPolicy.js +10 -28
  300. package/esm/policyDefiners/defineCargoPolicy.js.map +1 -1
  301. package/esm/policyDefiners/defineFileHeaderPolicy.d.ts +27 -14
  302. package/esm/policyDefiners/defineFileHeaderPolicy.d.ts.map +1 -1
  303. package/esm/policyDefiners/defineFileHeaderPolicy.js +16 -35
  304. package/esm/policyDefiners/defineFileHeaderPolicy.js.map +1 -1
  305. package/esm/policyDefiners/defineGleamPolicy.d.ts +25 -9
  306. package/esm/policyDefiners/defineGleamPolicy.d.ts.map +1 -1
  307. package/esm/policyDefiners/defineGleamPolicy.js +10 -27
  308. package/esm/policyDefiners/defineGleamPolicy.js.map +1 -1
  309. package/esm/policyDefiners/definePackagePolicy.d.ts +24 -13
  310. package/esm/policyDefiners/definePackagePolicy.d.ts.map +1 -1
  311. package/esm/policyDefiners/definePackagePolicy.js +9 -32
  312. package/esm/policyDefiners/definePackagePolicy.js.map +1 -1
  313. package/esm/policyDefiners/spdxValidator.d.ts +4 -12
  314. package/esm/policyDefiners/spdxValidator.d.ts.map +1 -1
  315. package/esm/policyDefiners/spdxValidator.js +26 -14
  316. package/esm/policyDefiners/spdxValidator.js.map +1 -1
  317. package/esm/policyExecution.d.ts +20 -0
  318. package/esm/policyExecution.d.ts.map +1 -0
  319. package/esm/policyExecution.js +234 -0
  320. package/esm/policyExecution.js.map +1 -0
  321. package/esm/repositoryChanges.d.ts +26 -0
  322. package/esm/repositoryChanges.d.ts.map +1 -0
  323. package/esm/repositoryChanges.js +172 -0
  324. package/esm/repositoryChanges.js.map +1 -0
  325. package/esm/repositoryFiles.d.ts +6 -0
  326. package/esm/repositoryFiles.d.ts.map +1 -0
  327. package/esm/repositoryFiles.js +11 -0
  328. package/esm/repositoryFiles.js.map +1 -0
  329. package/esm/runner.d.ts +73 -47
  330. package/esm/runner.d.ts.map +1 -1
  331. package/esm/runner.js +158 -144
  332. package/esm/runner.js.map +1 -1
  333. package/esm/settlePolicyPromise.d.ts +4 -0
  334. package/esm/settlePolicyPromise.d.ts.map +1 -0
  335. package/esm/settlePolicyPromise.js +10 -0
  336. package/esm/settlePolicyPromise.js.map +1 -0
  337. package/esm/tsdoc-metadata.json +1 -1
  338. package/esm/utils/safePaths.d.ts +9 -0
  339. package/esm/utils/safePaths.d.ts.map +1 -0
  340. package/esm/utils/safePaths.js +40 -0
  341. package/esm/utils/safePaths.js.map +1 -0
  342. package/oclif.manifest.json +57 -2
  343. package/package.json +42 -27
  344. package/scripts/benchmark.mjs +341 -0
  345. package/sidecar/sidecar.mjs +388 -417
@@ -1 +1 @@
1
- {"version":3,"file":"LicenseFileExists.d.ts","sourceRoot":"","sources":["../../src/policies/LicenseFileExists.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAiB,MAAM,cAAc,CAAC;AAEpE;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACzC;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAgBD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,EAAE,gBAAgB,CAAC,yBAAyB,CA8BvE,CAAC"}
1
+ {"version":3,"file":"LicenseFileExists.d.ts","sourceRoot":"","sources":["../../src/policies/LicenseFileExists.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACzC;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAgBD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB;;;;;;;CAoCmC,CAAC"}
@@ -1,6 +1,5 @@
1
- import { existsSync } from "node:fs";
1
+ import { stat } from "node:fs/promises";
2
2
  import path from "pathe";
3
- import { makePolicyDefinition } from "../makePolicy.js";
4
3
  /**
5
4
  * Default license file names to check for.
6
5
  */
@@ -18,29 +17,37 @@ const DEFAULT_LICENSE_NAMES = [
18
17
  * A repo policy that checks that a LICENSE file exists in the repository root.
19
18
  * This is essential for open source projects to clarify usage rights and obligations.
20
19
  *
21
- * @alpha
20
+ * @public
22
21
  */
23
- export const LicenseFileExists = makePolicyDefinition({
22
+ export const LicenseFileExists = {
24
23
  name: "LicenseFileExists",
25
24
  description: "Ensures a LICENSE file exists in the repository root for open source projects.",
26
- // Only trigger on package.json to check once per repository
27
- match: /^package\.json$/,
28
- handler: async ({ root, config }) => {
25
+ scope: "repository",
26
+ handler: async ({ root, files, config }) => {
29
27
  const acceptedNames = config?.acceptedNames ?? DEFAULT_LICENSE_NAMES;
30
28
  // Check if any of the accepted license files exist in the root
31
- const hasLicenseFile = acceptedNames.some((name) => existsSync(path.join(root, name)));
32
- if (hasLicenseFile) {
33
- return true;
29
+ for (const name of acceptedNames) {
30
+ if (!files.includes(name)) {
31
+ continue;
32
+ }
33
+ try {
34
+ if ((await stat(path.join(root, name))).isFile()) {
35
+ return [];
36
+ }
37
+ }
38
+ catch (error) {
39
+ if (!(error instanceof Error &&
40
+ "code" in error &&
41
+ error.code === "ENOENT")) {
42
+ throw error;
43
+ }
44
+ }
34
45
  }
35
- const result = {
36
- name: LicenseFileExists.name,
37
- file: ".", // Report against repository root
38
- autoFixable: false,
39
- errorMessages: [
40
- `No LICENSE file found in repository root. Expected one of: ${acceptedNames.join(", ")}`,
41
- ],
42
- };
43
- return result;
46
+ return [
47
+ {
48
+ message: `No LICENSE file found in repository root. Expected one of: ${acceptedNames.join(", ")}`,
49
+ },
50
+ ];
44
51
  },
45
- });
52
+ };
46
53
  //# sourceMappingURL=LicenseFileExists.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LicenseFileExists.js","sourceRoot":"","sources":["../../src/policies/LicenseFileExists.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,IAAI,MAAM,OAAO,CAAC;AACzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAexD;;GAEG;AACH,MAAM,qBAAqB,GAAG;IAC7B,SAAS;IACT,aAAa;IACb,YAAY;IACZ,aAAa;IACb,SAAS;IACT,aAAa;IACb,YAAY;IACZ,aAAa;CACb,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAC7B,oBAAoB,CAAC;IACpB,IAAI,EAAE,mBAAmB;IACzB,WAAW,EACV,gFAAgF;IACjF,4DAA4D;IAC5D,KAAK,EAAE,iBAAiB;IACxB,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE;QACnC,MAAM,aAAa,GAAG,MAAM,EAAE,aAAa,IAAI,qBAAqB,CAAC;QAErE,+DAA+D;QAC/D,MAAM,cAAc,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAClD,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CACjC,CAAC;QAEF,IAAI,cAAc,EAAE,CAAC;YACpB,OAAO,IAAI,CAAC;QACb,CAAC;QAED,MAAM,MAAM,GAAkB;YAC7B,IAAI,EAAE,iBAAiB,CAAC,IAAI;YAC5B,IAAI,EAAE,GAAG,EAAE,iCAAiC;YAC5C,WAAW,EAAE,KAAK;YAClB,aAAa,EAAE;gBACd,8DAA8D,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;aACxF;SACD,CAAC;QAEF,OAAO,MAAM,CAAC;IACf,CAAC;CACD,CAAC,CAAC","sourcesContent":["import { existsSync } from \"node:fs\";\nimport path from \"pathe\";\nimport { makePolicyDefinition } from \"../makePolicy.js\";\nimport type { PolicyDefinition, PolicyFailure } from \"../policy.js\";\n\n/**\n * Policy settings for the LicenseFileExists repo policy.\n *\n * @alpha\n */\nexport interface LicenseFileExistsSettings {\n\t/**\n\t * Array of acceptable license file names. Defaults to common variations.\n\t */\n\tacceptedNames?: string[];\n}\n\n/**\n * Default license file names to check for.\n */\nconst DEFAULT_LICENSE_NAMES = [\n\t\"LICENSE\",\n\t\"LICENSE.txt\",\n\t\"LICENSE.md\",\n\t\"LICENSE.rst\",\n\t\"LICENCE\",\n\t\"LICENCE.txt\",\n\t\"LICENCE.md\",\n\t\"LICENCE.rst\",\n];\n\n/**\n * A repo policy that checks that a LICENSE file exists in the repository root.\n * This is essential for open source projects to clarify usage rights and obligations.\n *\n * @alpha\n */\nexport const LicenseFileExists: PolicyDefinition<LicenseFileExistsSettings> =\n\tmakePolicyDefinition({\n\t\tname: \"LicenseFileExists\",\n\t\tdescription:\n\t\t\t\"Ensures a LICENSE file exists in the repository root for open source projects.\",\n\t\t// Only trigger on package.json to check once per repository\n\t\tmatch: /^package\\.json$/,\n\t\thandler: async ({ root, config }) => {\n\t\t\tconst acceptedNames = config?.acceptedNames ?? DEFAULT_LICENSE_NAMES;\n\n\t\t\t// Check if any of the accepted license files exist in the root\n\t\t\tconst hasLicenseFile = acceptedNames.some((name) =>\n\t\t\t\texistsSync(path.join(root, name)),\n\t\t\t);\n\n\t\t\tif (hasLicenseFile) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tconst result: PolicyFailure = {\n\t\t\t\tname: LicenseFileExists.name,\n\t\t\t\tfile: \".\", // Report against repository root\n\t\t\t\tautoFixable: false,\n\t\t\t\terrorMessages: [\n\t\t\t\t\t`No LICENSE file found in repository root. Expected one of: ${acceptedNames.join(\", \")}`,\n\t\t\t\t],\n\t\t\t};\n\n\t\t\treturn result;\n\t\t},\n\t});\n"]}
1
+ {"version":3,"file":"LicenseFileExists.js","sourceRoot":"","sources":["../../src/policies/LicenseFileExists.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,IAAI,MAAM,OAAO,CAAC;AAezB;;GAEG;AACH,MAAM,qBAAqB,GAAG;IAC7B,SAAS;IACT,aAAa;IACb,YAAY;IACZ,aAAa;IACb,SAAS;IACT,aAAa;IACb,YAAY;IACZ,aAAa;CACb,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAChC,IAAI,EAAE,mBAAmB;IACzB,WAAW,EACV,gFAAgF;IACjF,KAAK,EAAE,YAAY;IACnB,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE;QAC1C,MAAM,aAAa,GAAG,MAAM,EAAE,aAAa,IAAI,qBAAqB,CAAC;QAErE,+DAA+D;QAC/D,KAAK,MAAM,IAAI,IAAI,aAAa,EAAE,CAAC;YAClC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC3B,SAAS;YACV,CAAC;YACD,IAAI,CAAC;gBACJ,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;oBAClD,OAAO,EAAE,CAAC;gBACX,CAAC;YACF,CAAC;YAAC,OAAO,KAAc,EAAE,CAAC;gBACzB,IACC,CAAC,CACA,KAAK,YAAY,KAAK;oBACtB,MAAM,IAAI,KAAK;oBACf,KAAK,CAAC,IAAI,KAAK,QAAQ,CACvB,EACA,CAAC;oBACF,MAAM,KAAK,CAAC;gBACb,CAAC;YACF,CAAC;QACF,CAAC;QAED,OAAO;YACN;gBACC,OAAO,EAAE,8DAA8D,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;aACjG;SACD,CAAC;IACH,CAAC;CAC+D,CAAC","sourcesContent":["import { stat } from \"node:fs/promises\";\nimport path from \"pathe\";\nimport type { RepositoryPolicyDefinition } from \"../policy.js\";\n\n/**\n * Policy settings for the LicenseFileExists repo policy.\n *\n * @public\n */\nexport interface LicenseFileExistsSettings {\n\t/**\n\t * Array of acceptable license file names. Defaults to common variations.\n\t */\n\tacceptedNames?: string[];\n}\n\n/**\n * Default license file names to check for.\n */\nconst DEFAULT_LICENSE_NAMES = [\n\t\"LICENSE\",\n\t\"LICENSE.txt\",\n\t\"LICENSE.md\",\n\t\"LICENSE.rst\",\n\t\"LICENCE\",\n\t\"LICENCE.txt\",\n\t\"LICENCE.md\",\n\t\"LICENCE.rst\",\n];\n\n/**\n * A repo policy that checks that a LICENSE file exists in the repository root.\n * This is essential for open source projects to clarify usage rights and obligations.\n *\n * @public\n */\nexport const LicenseFileExists = {\n\tname: \"LicenseFileExists\",\n\tdescription:\n\t\t\"Ensures a LICENSE file exists in the repository root for open source projects.\",\n\tscope: \"repository\",\n\thandler: async ({ root, files, config }) => {\n\t\tconst acceptedNames = config?.acceptedNames ?? DEFAULT_LICENSE_NAMES;\n\n\t\t// Check if any of the accepted license files exist in the root\n\t\tfor (const name of acceptedNames) {\n\t\t\tif (!files.includes(name)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tif ((await stat(path.join(root, name))).isFile()) {\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\t\t\t} catch (error: unknown) {\n\t\t\t\tif (\n\t\t\t\t\t!(\n\t\t\t\t\t\terror instanceof Error &&\n\t\t\t\t\t\t\"code\" in error &&\n\t\t\t\t\t\terror.code === \"ENOENT\"\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tthrow error;\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: `No LICENSE file found in repository root. Expected one of: ${acceptedNames.join(\", \")}`,\n\t\t\t},\n\t\t];\n\t},\n} satisfies RepositoryPolicyDefinition<LicenseFileExistsSettings>;\n"]}
@@ -0,0 +1,17 @@
1
+ /** Configuration for the changed-file limit. @public */
2
+ export interface MaxChangedFilesConfig {
3
+ /** Maximum number of eligible changed files; must be a nonnegative integer. */
4
+ maxFiles: number;
5
+ }
6
+ /** Limit the number of files in the selected change set. @public */
7
+ export declare const MaxChangedFiles: {
8
+ name: string;
9
+ description: string;
10
+ scope: "changes";
11
+ requiresConfig: true;
12
+ handler: ({ entries, config }: import("../policy.js").RepositoryPolicyArgs<MaxChangedFilesConfig>) => Promise<{
13
+ message: string;
14
+ manualFix: string;
15
+ }[]>;
16
+ };
17
+ //# sourceMappingURL=MaxChangedFiles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MaxChangedFiles.d.ts","sourceRoot":"","sources":["../../src/policies/MaxChangedFiles.ts"],"names":[],"mappings":"AAEA,wDAAwD;AACxD,MAAM,WAAW,qBAAqB;IACrC,+EAA+E;IAC/E,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED,oEAAoE;AACpE,eAAO,MAAM,eAAe;;;;;;;;;CAwBiC,CAAC"}
@@ -0,0 +1,22 @@
1
+ /** Limit the number of files in the selected change set. @public */
2
+ export const MaxChangedFiles = {
3
+ name: "MaxChangedFiles",
4
+ description: "Limits the number of changed files in a change set.",
5
+ scope: "changes",
6
+ requiresConfig: true,
7
+ handler: async ({ entries, config }) => {
8
+ if (!(config && Number.isInteger(config.maxFiles)) || config.maxFiles < 0) {
9
+ throw new TypeError("MaxChangedFiles requires maxFiles to be a nonnegative integer.");
10
+ }
11
+ const count = entries.filter((entry) => entry.status !== "unchanged").length;
12
+ return count > config.maxFiles
13
+ ? [
14
+ {
15
+ message: `Change set contains ${count} changed files; maximum allowed is ${config.maxFiles}.`,
16
+ manualFix: "Reduce the number of changed files or split the change into smaller change sets.",
17
+ },
18
+ ]
19
+ : [];
20
+ },
21
+ };
22
+ //# sourceMappingURL=MaxChangedFiles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MaxChangedFiles.js","sourceRoot":"","sources":["../../src/policies/MaxChangedFiles.ts"],"names":[],"mappings":"AAQA,oEAAoE;AACpE,MAAM,CAAC,MAAM,eAAe,GAAG;IAC9B,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,qDAAqD;IAClE,KAAK,EAAE,SAAS;IAChB,cAAc,EAAE,IAAI;IACpB,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE;QACtC,IAAI,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,MAAM,CAAC,QAAQ,GAAG,CAAC,EAAE,CAAC;YAC3E,MAAM,IAAI,SAAS,CAClB,gEAAgE,CAChE,CAAC;QACH,CAAC;QACD,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAC3B,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,KAAK,WAAW,CACvC,CAAC,MAAM,CAAC;QACT,OAAO,KAAK,GAAG,MAAM,CAAC,QAAQ;YAC7B,CAAC,CAAC;gBACA;oBACC,OAAO,EAAE,uBAAuB,KAAK,sCAAsC,MAAM,CAAC,QAAQ,GAAG;oBAC7F,SAAS,EACR,kFAAkF;iBACnF;aACD;YACF,CAAC,CAAC,EAAE,CAAC;IACP,CAAC;CAC2D,CAAC","sourcesContent":["import type { RepositoryPolicyDefinition } from \"../policy.js\";\n\n/** Configuration for the changed-file limit. @public */\nexport interface MaxChangedFilesConfig {\n\t/** Maximum number of eligible changed files; must be a nonnegative integer. */\n\tmaxFiles: number;\n}\n\n/** Limit the number of files in the selected change set. @public */\nexport const MaxChangedFiles = {\n\tname: \"MaxChangedFiles\",\n\tdescription: \"Limits the number of changed files in a change set.\",\n\tscope: \"changes\",\n\trequiresConfig: true,\n\thandler: async ({ entries, config }) => {\n\t\tif (!(config && Number.isInteger(config.maxFiles)) || config.maxFiles < 0) {\n\t\t\tthrow new TypeError(\n\t\t\t\t\"MaxChangedFiles requires maxFiles to be a nonnegative integer.\",\n\t\t\t);\n\t\t}\n\t\tconst count = entries.filter(\n\t\t\t(entry) => entry.status !== \"unchanged\",\n\t\t).length;\n\t\treturn count > config.maxFiles\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\tmessage: `Change set contains ${count} changed files; maximum allowed is ${config.maxFiles}.`,\n\t\t\t\t\t\tmanualFix:\n\t\t\t\t\t\t\t\"Reduce the number of changed files or split the change into smaller change sets.\",\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t: [];\n\t},\n} satisfies RepositoryPolicyDefinition<MaxChangedFilesConfig>;\n"]}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Configuration for the MutuallyExclusiveScripts policy.
3
3
  *
4
- * @alpha
4
+ * @public
5
5
  */
6
6
  export interface MutuallyExclusiveScriptsConfig {
7
7
  /**
@@ -29,18 +29,20 @@ export interface MutuallyExclusiveScriptsConfig {
29
29
  *
30
30
  * @example
31
31
  * ```typescript
32
- * import { policy } from "repopo";
32
+ * import { makePolicy } from "repopo";
33
33
  * import { MutuallyExclusiveScripts } from "repopo/policies";
34
34
  *
35
- * policy(MutuallyExclusiveScripts, {
35
+ * makePolicy(MutuallyExclusiveScripts, { config: {
36
36
  * groups: [
37
37
  * ["lint:eslint", "lint:biome"],
38
38
  * ["test:jest", "test:vitest"],
39
39
  * ],
40
- * })
40
+ * } })
41
41
  * ```
42
42
  *
43
- * @alpha
43
+ * @public
44
44
  */
45
- export declare const MutuallyExclusiveScripts: import("../policy.js").PolicyShape<MutuallyExclusiveScriptsConfig | undefined>;
45
+ export declare const MutuallyExclusiveScripts: import("../policy.js").FilePolicyDefinition<MutuallyExclusiveScriptsConfig | undefined> & {
46
+ requiresConfig: true;
47
+ };
46
48
  //# sourceMappingURL=MutuallyExclusiveScripts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MutuallyExclusiveScripts.d.ts","sourceRoot":"","sources":["../../src/policies/MutuallyExclusiveScripts.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,MAAM,WAAW,8BAA8B;IAC9C;;;;;;;;;;;;OAYG;IACH,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;CACnB;AAID;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,wBAAwB,gFAsCnC,CAAC"}
1
+ {"version":3,"file":"MutuallyExclusiveScripts.d.ts","sourceRoot":"","sources":["../../src/policies/MutuallyExclusiveScripts.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,MAAM,WAAW,8BAA8B;IAC9C;;;;;;;;;;;;OAYG;IACH,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;CACnB;AAID;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,wBAAwB;;CAiCnC,CAAC"}
@@ -10,25 +10,26 @@ const POLICY_NAME = "MutuallyExclusiveScripts";
10
10
  *
11
11
  * @example
12
12
  * ```typescript
13
- * import { policy } from "repopo";
13
+ * import { makePolicy } from "repopo";
14
14
  * import { MutuallyExclusiveScripts } from "repopo/policies";
15
15
  *
16
- * policy(MutuallyExclusiveScripts, {
16
+ * makePolicy(MutuallyExclusiveScripts, { config: {
17
17
  * groups: [
18
18
  * ["lint:eslint", "lint:biome"],
19
19
  * ["test:jest", "test:vitest"],
20
20
  * ],
21
- * })
21
+ * } })
22
22
  * ```
23
23
  *
24
- * @alpha
24
+ * @public
25
25
  */
26
26
  export const MutuallyExclusiveScripts = definePackagePolicy({
27
+ requiresConfig: true,
27
28
  name: POLICY_NAME,
28
29
  description: "Validates that at most one script from each exclusive group exists in package.json.",
29
- handler: async (json, { file, config }) => {
30
+ handler: async (json, { config }) => {
30
31
  if (config === undefined || config.groups.length === 0) {
31
- return true;
32
+ return [];
32
33
  }
33
34
  const scripts = json.scripts ?? {};
34
35
  const errors = [];
@@ -39,14 +40,9 @@ export const MutuallyExclusiveScripts = definePackagePolicy({
39
40
  }
40
41
  }
41
42
  if (errors.length === 0) {
42
- return true;
43
+ return [];
43
44
  }
44
- return {
45
- name: POLICY_NAME,
46
- file,
47
- autoFixable: false,
48
- errorMessages: errors,
49
- };
45
+ return errors.map((message) => ({ message }));
50
46
  },
51
47
  });
52
48
  //# sourceMappingURL=MutuallyExclusiveScripts.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MutuallyExclusiveScripts.js","sourceRoot":"","sources":["../../src/policies/MutuallyExclusiveScripts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAwB/E,MAAM,WAAW,GAAG,0BAA0B,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,mBAAmB,CAGzD;IACD,IAAI,EAAE,WAAW;IACjB,WAAW,EACV,qFAAqF;IACtF,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE;QACzC,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxD,OAAO,IAAI,CAAC;QACb,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC;QACnC,MAAM,MAAM,GAAa,EAAE,CAAC;QAE5B,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YACnC,MAAM,cAAc,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE,CAClD,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,CAClC,CAAC;YAEF,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC/B,MAAM,CAAC,IAAI,CACV,6CAA6C,cAAc,CAAC,MAAM,KAAK,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAClG,CAAC;YACH,CAAC;QACF,CAAC;QAED,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,IAAI,CAAC;QACb,CAAC;QAED,OAAO;YACN,IAAI,EAAE,WAAW;YACjB,IAAI;YACJ,WAAW,EAAE,KAAK;YAClB,aAAa,EAAE,MAAM;SACrB,CAAC;IACH,CAAC;CACD,CAAC,CAAC","sourcesContent":["import type { PackageJson } from \"type-fest\";\nimport { definePackagePolicy } from \"../policyDefiners/definePackagePolicy.js\";\n\n/**\n * Configuration for the MutuallyExclusiveScripts policy.\n *\n * @alpha\n */\nexport interface MutuallyExclusiveScriptsConfig {\n\t/**\n\t * List of mutually exclusive script groups. Each group is an array of script names\n\t * where at most one script from the group can be present.\n\t *\n\t * Packages can have zero scripts from the group (all optional), but cannot have\n\t * multiple scripts from the same group.\n\t *\n\t * @example\n\t * ```typescript\n\t * // Allow \"test:unit\" OR \"test:vitest\" OR neither, but not both\n\t * groups: [[\"test:unit\", \"test:vitest\"]]\n\t * ```\n\t */\n\tgroups: string[][];\n}\n\nconst POLICY_NAME = \"MutuallyExclusiveScripts\";\n\n/**\n * A policy that validates mutually exclusive script groups in package.json.\n *\n * @remarks\n * Use this policy when you want to enforce that only one script from a group\n * can exist in a package. This is useful for ensuring that packages don't have\n * conflicting scripts (e.g., both \"lint:eslint\" and \"lint:biome\").\n *\n * @example\n * ```typescript\n * import { policy } from \"repopo\";\n * import { MutuallyExclusiveScripts } from \"repopo/policies\";\n *\n * policy(MutuallyExclusiveScripts, {\n * groups: [\n * [\"lint:eslint\", \"lint:biome\"],\n * [\"test:jest\", \"test:vitest\"],\n * ],\n * })\n * ```\n *\n * @alpha\n */\nexport const MutuallyExclusiveScripts = definePackagePolicy<\n\tPackageJson,\n\tMutuallyExclusiveScriptsConfig | undefined\n>({\n\tname: POLICY_NAME,\n\tdescription:\n\t\t\"Validates that at most one script from each exclusive group exists in package.json.\",\n\thandler: async (json, { file, config }) => {\n\t\tif (config === undefined || config.groups.length === 0) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst scripts = json.scripts ?? {};\n\t\tconst errors: string[] = [];\n\n\t\tfor (const group of config.groups) {\n\t\t\tconst presentScripts = group.filter((scriptName) =>\n\t\t\t\tObject.hasOwn(scripts, scriptName),\n\t\t\t);\n\n\t\t\tif (presentScripts.length > 1) {\n\t\t\t\terrors.push(\n\t\t\t\t\t`Scripts are mutually exclusive, but found ${presentScripts.length}: ${presentScripts.join(\", \")}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (errors.length === 0) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn {\n\t\t\tname: POLICY_NAME,\n\t\t\tfile,\n\t\t\tautoFixable: false,\n\t\t\terrorMessages: errors,\n\t\t};\n\t},\n});\n"]}
1
+ {"version":3,"file":"MutuallyExclusiveScripts.js","sourceRoot":"","sources":["../../src/policies/MutuallyExclusiveScripts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAwB/E,MAAM,WAAW,GAAG,0BAA0B,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,mBAAmB,CAGzD;IACD,cAAc,EAAE,IAAI;IACpB,IAAI,EAAE,WAAW;IACjB,WAAW,EACV,qFAAqF;IACtF,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;QACnC,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxD,OAAO,EAAE,CAAC;QACX,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC;QACnC,MAAM,MAAM,GAAa,EAAE,CAAC;QAE5B,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YACnC,MAAM,cAAc,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE,CAClD,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,CAClC,CAAC;YAEF,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC/B,MAAM,CAAC,IAAI,CACV,6CAA6C,cAAc,CAAC,MAAM,KAAK,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAClG,CAAC;YACH,CAAC;QACF,CAAC;QAED,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,EAAE,CAAC;QACX,CAAC;QACD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;IAC/C,CAAC;CACD,CAAC,CAAC","sourcesContent":["import type { PackageJson } from \"type-fest\";\nimport { definePackagePolicy } from \"../policyDefiners/definePackagePolicy.js\";\n\n/**\n * Configuration for the MutuallyExclusiveScripts policy.\n *\n * @public\n */\nexport interface MutuallyExclusiveScriptsConfig {\n\t/**\n\t * List of mutually exclusive script groups. Each group is an array of script names\n\t * where at most one script from the group can be present.\n\t *\n\t * Packages can have zero scripts from the group (all optional), but cannot have\n\t * multiple scripts from the same group.\n\t *\n\t * @example\n\t * ```typescript\n\t * // Allow \"test:unit\" OR \"test:vitest\" OR neither, but not both\n\t * groups: [[\"test:unit\", \"test:vitest\"]]\n\t * ```\n\t */\n\tgroups: string[][];\n}\n\nconst POLICY_NAME = \"MutuallyExclusiveScripts\";\n\n/**\n * A policy that validates mutually exclusive script groups in package.json.\n *\n * @remarks\n * Use this policy when you want to enforce that only one script from a group\n * can exist in a package. This is useful for ensuring that packages don't have\n * conflicting scripts (e.g., both \"lint:eslint\" and \"lint:biome\").\n *\n * @example\n * ```typescript\n * import { makePolicy } from \"repopo\";\n * import { MutuallyExclusiveScripts } from \"repopo/policies\";\n *\n * makePolicy(MutuallyExclusiveScripts, { config: {\n * groups: [\n * [\"lint:eslint\", \"lint:biome\"],\n * [\"test:jest\", \"test:vitest\"],\n * ],\n * } })\n * ```\n *\n * @public\n */\nexport const MutuallyExclusiveScripts = definePackagePolicy<\n\tPackageJson,\n\tMutuallyExclusiveScriptsConfig | undefined\n>({\n\trequiresConfig: true,\n\tname: POLICY_NAME,\n\tdescription:\n\t\t\"Validates that at most one script from each exclusive group exists in package.json.\",\n\thandler: async (json, { config }) => {\n\t\tif (config === undefined || config.groups.length === 0) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst scripts = json.scripts ?? {};\n\t\tconst errors: string[] = [];\n\n\t\tfor (const group of config.groups) {\n\t\t\tconst presentScripts = group.filter((scriptName) =>\n\t\t\t\tObject.hasOwn(scripts, scriptName),\n\t\t\t);\n\n\t\t\tif (presentScripts.length > 1) {\n\t\t\t\terrors.push(\n\t\t\t\t\t`Scripts are mutually exclusive, but found ${presentScripts.length}: ${presentScripts.join(\", \")}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (errors.length === 0) {\n\t\t\treturn [];\n\t\t}\n\t\treturn errors.map((message) => ({ message }));\n\t},\n});\n"]}
@@ -1,9 +1,15 @@
1
- import type { PolicyDefinition } from "../policy.js";
1
+ import type { Operation } from "effection";
2
+ import type { PolicyFinding } from "../policy.js";
2
3
  /**
3
4
  * A policy that prevents accidental commits of build directory contents.
4
5
  * Applies to Gleam's `build/` output directory.
5
6
  *
6
- * @alpha
7
+ * @public
7
8
  */
8
- export declare const NoBuildDirectory: PolicyDefinition;
9
+ export declare const NoBuildDirectory: {
10
+ name: string;
11
+ description: string;
12
+ match: RegExp;
13
+ handler: ({ file }: import("../policy.js").PolicyArgs<void>) => Operation<PolicyFinding[]>;
14
+ };
9
15
  //# sourceMappingURL=NoBuildDirectory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"NoBuildDirectory.d.ts","sourceRoot":"","sources":["../../src/policies/NoBuildDirectory.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAiB,MAAM,cAAc,CAAC;AAOpE;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,gBAkB7B,CAAC"}
1
+ {"version":3,"file":"NoBuildDirectory.d.ts","sourceRoot":"","sources":["../../src/policies/NoBuildDirectory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAwB,aAAa,EAAE,MAAM,cAAc,CAAC;AAOxE;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB;;;;oEAKG,SAAS,CAAC,aAAa,EAAE,CAAC;CAS1B,CAAC"}
@@ -1,4 +1,3 @@
1
- import { makePolicyDefinition } from "../makePolicy.js";
2
1
  /**
3
2
  * Build output extensions and directory patterns that should not be committed.
4
3
  */
@@ -7,23 +6,19 @@ const BUILD_DIR_REGEX = /(?:^|\/)(build)\//;
7
6
  * A policy that prevents accidental commits of build directory contents.
8
7
  * Applies to Gleam's `build/` output directory.
9
8
  *
10
- * @alpha
9
+ * @public
11
10
  */
12
- export const NoBuildDirectory = makePolicyDefinition({
11
+ export const NoBuildDirectory = {
13
12
  name: "NoBuildDirectory",
14
13
  description: "Prevents accidental commits of build directory contents (Gleam build/ output).",
15
14
  match: BUILD_DIR_REGEX,
16
- // biome-ignore lint/correctness/useYield: no yield needed
17
15
  handler: function* ({ file }) {
18
- return {
19
- name: NoBuildDirectory.name,
20
- file,
21
- autoFixable: false,
22
- errorMessages: [
23
- `Build artifact detected in build/ directory: ${file}. The build/ directory should be in .gitignore.`,
24
- ],
16
+ return [
17
+ `Build artifact detected in build/ directory: ${file}. The build/ directory should be in .gitignore.`,
18
+ ].map((message) => ({
19
+ message,
25
20
  manualFix: "Remove the build/ directory from source control and add it to .gitignore.",
26
- };
21
+ }));
27
22
  },
28
- });
23
+ };
29
24
  //# sourceMappingURL=NoBuildDirectory.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NoBuildDirectory.js","sourceRoot":"","sources":["../../src/policies/NoBuildDirectory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAGxD;;GAEG;AACH,MAAM,eAAe,GAAG,mBAAmB,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAqB,oBAAoB,CAAC;IACtE,IAAI,EAAE,kBAAkB;IACxB,WAAW,EACV,gFAAgF;IACjF,KAAK,EAAE,eAAe;IACtB,0DAA0D;IAC1D,OAAO,EAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,EAAE;QAC3B,OAAO;YACN,IAAI,EAAE,gBAAgB,CAAC,IAAI;YAC3B,IAAI;YACJ,WAAW,EAAE,KAAK;YAClB,aAAa,EAAE;gBACd,gDAAgD,IAAI,iDAAiD;aACrG;YACD,SAAS,EACR,2EAA2E;SAC5E,CAAC;IACH,CAAC;CACD,CAAC,CAAC","sourcesContent":["import type { Operation } from \"effection\";\nimport { makePolicyDefinition } from \"../makePolicy.js\";\nimport type { PolicyDefinition, PolicyFailure } from \"../policy.js\";\n\n/**\n * Build output extensions and directory patterns that should not be committed.\n */\nconst BUILD_DIR_REGEX = /(?:^|\\/)(build)\\//;\n\n/**\n * A policy that prevents accidental commits of build directory contents.\n * Applies to Gleam's `build/` output directory.\n *\n * @alpha\n */\nexport const NoBuildDirectory: PolicyDefinition = makePolicyDefinition({\n\tname: \"NoBuildDirectory\",\n\tdescription:\n\t\t\"Prevents accidental commits of build directory contents (Gleam build/ output).\",\n\tmatch: BUILD_DIR_REGEX,\n\t// biome-ignore lint/correctness/useYield: no yield needed\n\thandler: function* ({ file }): Operation<PolicyFailure> {\n\t\treturn {\n\t\t\tname: NoBuildDirectory.name,\n\t\t\tfile,\n\t\t\tautoFixable: false,\n\t\t\terrorMessages: [\n\t\t\t\t`Build artifact detected in build/ directory: ${file}. The build/ directory should be in .gitignore.`,\n\t\t\t],\n\t\t\tmanualFix:\n\t\t\t\t\"Remove the build/ directory from source control and add it to .gitignore.\",\n\t\t};\n\t},\n});\n"]}
1
+ {"version":3,"file":"NoBuildDirectory.js","sourceRoot":"","sources":["../../src/policies/NoBuildDirectory.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,eAAe,GAAG,mBAAmB,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC/B,IAAI,EAAE,kBAAkB;IACxB,WAAW,EACV,gFAAgF;IACjF,KAAK,EAAE,eAAe;IACtB,OAAO,EAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,EAAE;QAC3B,OAAO;YACN,gDAAgD,IAAI,iDAAiD;SACrG,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YACnB,OAAO;YACP,SAAS,EACR,2EAA2E;SAC5E,CAAC,CAAC,CAAC;IACL,CAAC;CAC8B,CAAC","sourcesContent":["import type { Operation } from \"effection\";\nimport type { FilePolicyDefinition, PolicyFinding } from \"../policy.js\";\n\n/**\n * Build output extensions and directory patterns that should not be committed.\n */\nconst BUILD_DIR_REGEX = /(?:^|\\/)(build)\\//;\n\n/**\n * A policy that prevents accidental commits of build directory contents.\n * Applies to Gleam's `build/` output directory.\n *\n * @public\n */\nexport const NoBuildDirectory = {\n\tname: \"NoBuildDirectory\",\n\tdescription:\n\t\t\"Prevents accidental commits of build directory contents (Gleam build/ output).\",\n\tmatch: BUILD_DIR_REGEX,\n\thandler: function* ({ file }): Operation<PolicyFinding[]> {\n\t\treturn [\n\t\t\t`Build artifact detected in build/ directory: ${file}. The build/ directory should be in .gitignore.`,\n\t\t].map((message) => ({\n\t\t\tmessage,\n\t\t\tmanualFix:\n\t\t\t\t\"Remove the build/ directory from source control and add it to .gitignore.\",\n\t\t}));\n\t},\n} satisfies FilePolicyDefinition;\n"]}
@@ -1,4 +1,5 @@
1
- import type { PolicyDefinition } from "../policy.js";
1
+ import type { Operation } from "effection";
2
+ import type { PolicyFinding } from "../policy.js";
2
3
  /**
3
4
  * A repo policy that checks for JavaScript source files that just use the .js file extension. Such files may be
4
5
  * interpreted by node as either CommonJS or ESM based on the `type` field in the nearest package.json file. This
@@ -6,7 +7,12 @@ import type { PolicyDefinition } from "../policy.js";
6
7
  * is processed by node. Using explicit file extensions reduces ambiguity and ensures a CJS file isn't suddenly treated
7
8
  * like an ESM file.
8
9
  *
9
- * @alpha
10
+ * @public
10
11
  */
11
- export declare const NoJsFileExtensions: PolicyDefinition;
12
+ export declare const NoJsFileExtensions: {
13
+ name: string;
14
+ description: string;
15
+ match: RegExp;
16
+ handler: () => Operation<PolicyFinding[]>;
17
+ };
12
18
  //# sourceMappingURL=NoJsFileExtensions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"NoJsFileExtensions.d.ts","sourceRoot":"","sources":["../../src/policies/NoJsFileExtensions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAiB,MAAM,cAAc,CAAC;AAEpE;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,EAAE,gBAiB/B,CAAC"}
1
+ {"version":3,"file":"NoJsFileExtensions.d.ts","sourceRoot":"","sources":["../../src/policies/NoJsFileExtensions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAwB,aAAa,EAAE,MAAM,cAAc,CAAC;AACxE;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB;;;;mBAKP,SAAS,CAAC,aAAa,EAAE,CAAC;CAQlB,CAAC"}
@@ -1,4 +1,3 @@
1
- import { makePolicyDefinition } from "../makePolicy.js";
2
1
  /**
3
2
  * A repo policy that checks for JavaScript source files that just use the .js file extension. Such files may be
4
3
  * interpreted by node as either CommonJS or ESM based on the `type` field in the nearest package.json file. This
@@ -6,23 +5,19 @@ import { makePolicyDefinition } from "../makePolicy.js";
6
5
  * is processed by node. Using explicit file extensions reduces ambiguity and ensures a CJS file isn't suddenly treated
7
6
  * like an ESM file.
8
7
  *
9
- * @alpha
8
+ * @public
10
9
  */
11
- export const NoJsFileExtensions = makePolicyDefinition({
10
+ export const NoJsFileExtensions = {
12
11
  name: "NoJsFileExtensions",
13
12
  description: "Prevents ambiguous .js files by requiring explicit .mjs or .cjs extensions based on module format.",
14
13
  match: /(^|\/)[^/]+\.js$/i,
15
- // biome-ignore lint/correctness/useYield: no yield needed
16
- handler: function* ({ file }) {
17
- return {
18
- name: NoJsFileExtensions.name,
19
- file,
20
- autoFixable: false,
21
- errorMessages: [
22
- "JavaScript files should have a .cjs or .mjs file extension based on the module format of the file.",
23
- ],
14
+ handler: function* () {
15
+ return [
16
+ "JavaScript files should have a .cjs or .mjs file extension based on the module format of the file.",
17
+ ].map((message) => ({
18
+ message,
24
19
  manualFix: "Rename the file to have a .cjs or .mjs file extension.",
25
- };
20
+ }));
26
21
  },
27
- });
22
+ };
28
23
  //# sourceMappingURL=NoJsFileExtensions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NoJsFileExtensions.js","sourceRoot":"","sources":["../../src/policies/NoJsFileExtensions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAGxD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAqB,oBAAoB,CAAC;IACxE,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EACV,oGAAoG;IACrG,KAAK,EAAE,mBAAmB;IAC1B,0DAA0D;IAC1D,OAAO,EAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,EAAE;QAC3B,OAAO;YACN,IAAI,EAAE,kBAAkB,CAAC,IAAI;YAC7B,IAAI;YACJ,WAAW,EAAE,KAAK;YAClB,aAAa,EAAE;gBACd,oGAAoG;aACpG;YACD,SAAS,EAAE,wDAAwD;SACnE,CAAC;IACH,CAAC;CACD,CAAC,CAAC","sourcesContent":["import type { Operation } from \"effection\";\nimport { makePolicyDefinition } from \"../makePolicy.js\";\nimport type { PolicyDefinition, PolicyFailure } from \"../policy.js\";\n\n/**\n * A repo policy that checks for JavaScript source files that just use the .js file extension. Such files may be\n * interpreted by node as either CommonJS or ESM based on the `type` field in the nearest package.json file. This\n * can create unexpected behavior for JS files; changing the package.json nearest to one will change how the JS\n * is processed by node. Using explicit file extensions reduces ambiguity and ensures a CJS file isn't suddenly treated\n * like an ESM file.\n *\n * @alpha\n */\nexport const NoJsFileExtensions: PolicyDefinition = makePolicyDefinition({\n\tname: \"NoJsFileExtensions\",\n\tdescription:\n\t\t\"Prevents ambiguous .js files by requiring explicit .mjs or .cjs extensions based on module format.\",\n\tmatch: /(^|\\/)[^/]+\\.js$/i,\n\t// biome-ignore lint/correctness/useYield: no yield needed\n\thandler: function* ({ file }): Operation<PolicyFailure> {\n\t\treturn {\n\t\t\tname: NoJsFileExtensions.name,\n\t\t\tfile,\n\t\t\tautoFixable: false,\n\t\t\terrorMessages: [\n\t\t\t\t\"JavaScript files should have a .cjs or .mjs file extension based on the module format of the file.\",\n\t\t\t],\n\t\t\tmanualFix: \"Rename the file to have a .cjs or .mjs file extension.\",\n\t\t};\n\t},\n});\n"]}
1
+ {"version":3,"file":"NoJsFileExtensions.js","sourceRoot":"","sources":["../../src/policies/NoJsFileExtensions.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IACjC,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EACV,oGAAoG;IACrG,KAAK,EAAE,mBAAmB;IAC1B,OAAO,EAAE,QAAQ,CAAC;QACjB,OAAO;YACN,oGAAoG;SACpG,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YACnB,OAAO;YACP,SAAS,EAAE,wDAAwD;SACnE,CAAC,CAAC,CAAC;IACL,CAAC;CAC8B,CAAC","sourcesContent":["import type { Operation } from \"effection\";\nimport type { FilePolicyDefinition, PolicyFinding } from \"../policy.js\";\n/**\n * A repo policy that checks for JavaScript source files that just use the .js file extension. Such files may be\n * interpreted by node as either CommonJS or ESM based on the `type` field in the nearest package.json file. This\n * can create unexpected behavior for JS files; changing the package.json nearest to one will change how the JS\n * is processed by node. Using explicit file extensions reduces ambiguity and ensures a CJS file isn't suddenly treated\n * like an ESM file.\n *\n * @public\n */\nexport const NoJsFileExtensions = {\n\tname: \"NoJsFileExtensions\",\n\tdescription:\n\t\t\"Prevents ambiguous .js files by requiring explicit .mjs or .cjs extensions based on module format.\",\n\tmatch: /(^|\\/)[^/]+\\.js$/i,\n\thandler: function* (): Operation<PolicyFinding[]> {\n\t\treturn [\n\t\t\t\"JavaScript files should have a .cjs or .mjs file extension based on the module format of the file.\",\n\t\t].map((message) => ({\n\t\t\tmessage,\n\t\t\tmanualFix: \"Rename the file to have a .cjs or .mjs file extension.\",\n\t\t}));\n\t},\n} satisfies FilePolicyDefinition;\n"]}
@@ -1,8 +1,8 @@
1
- import type { PolicyDefinition } from "../policy.js";
1
+ import type { PolicyFinding } from "../policy.js";
2
2
  /**
3
3
  * Policy settings for the NoLargeBinaryFiles repo policy.
4
4
  *
5
- * @alpha
5
+ * @public
6
6
  */
7
7
  export interface NoLargeBinaryFilesSettings {
8
8
  /**
@@ -24,7 +24,12 @@ export interface NoLargeBinaryFilesSettings {
24
24
  * A repo policy that prevents large binary files from being committed to the repository.
25
25
  * Large files can bloat the repository and slow down clones. Consider using Git LFS for large assets.
26
26
  *
27
- * @alpha
27
+ * @public
28
28
  */
29
- export declare const NoLargeBinaryFiles: PolicyDefinition<NoLargeBinaryFilesSettings>;
29
+ export declare const NoLargeBinaryFiles: {
30
+ name: string;
31
+ description: string;
32
+ match: RegExp;
33
+ handler: ({ file, root, config }: import("../policy.js").PolicyArgs<NoLargeBinaryFilesSettings>) => Promise<PolicyFinding[]>;
34
+ };
30
35
  //# sourceMappingURL=NoLargeBinaryFiles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"NoLargeBinaryFiles.d.ts","sourceRoot":"","sources":["../../src/policies/NoLargeBinaryFiles.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAiB,MAAM,cAAc,CAAC;AAEpE;;;;GAIG;AACH,MAAM,WAAW,0BAA0B;IAC1C;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAE7B;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AA2FD;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,EAAE,gBAAgB,CAAC,0BAA0B,CA8CzE,CAAC"}
1
+ {"version":3,"file":"NoLargeBinaryFiles.d.ts","sourceRoot":"","sources":["../../src/policies/NoLargeBinaryFiles.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAwB,aAAa,EAAE,MAAM,cAAc,CAAC;AACxE;;;;GAIG;AACH,MAAM,WAAW,0BAA0B;IAC1C;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAE7B;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AA2FD;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB;;;;;CAsC6B,CAAC"}
@@ -1,6 +1,5 @@
1
1
  import { statSync } from "node:fs";
2
2
  import path from "pathe";
3
- import { makePolicyDefinition } from "../makePolicy.js";
4
3
  /**
5
4
  * Default maximum file size (10MB in bytes).
6
5
  */
@@ -80,9 +79,9 @@ function formatBytes(bytes) {
80
79
  * A repo policy that prevents large binary files from being committed to the repository.
81
80
  * Large files can bloat the repository and slow down clones. Consider using Git LFS for large assets.
82
81
  *
83
- * @alpha
82
+ * @public
84
83
  */
85
- export const NoLargeBinaryFiles = makePolicyDefinition({
84
+ export const NoLargeBinaryFiles = {
86
85
  name: "NoLargeBinaryFiles",
87
86
  description: "Prevents large binary files from being committed to avoid repository bloat; consider using Git LFS for large assets.",
88
87
  // Match all files
@@ -93,32 +92,27 @@ export const NoLargeBinaryFiles = makePolicyDefinition({
93
92
  const excludePatterns = config?.excludePatterns ?? [];
94
93
  // Skip excluded files
95
94
  if (isExcluded(file, excludePatterns, excludeExtensions)) {
96
- return true;
95
+ return [];
97
96
  }
98
97
  try {
99
98
  const filePath = path.resolve(root, file);
100
99
  const stats = statSync(filePath);
101
100
  // Skip directories
102
101
  if (stats.isDirectory()) {
103
- return true;
102
+ return [];
104
103
  }
105
104
  if (stats.size > maxSizeBytes) {
106
- const result = {
107
- name: NoLargeBinaryFiles.name,
108
- file,
109
- autoFixable: false,
110
- errorMessages: [
111
- `File is too large: ${formatBytes(stats.size)} (max: ${formatBytes(maxSizeBytes)}). Consider using Git LFS or removing the file.`,
112
- ],
113
- };
105
+ const result = [
106
+ `File is too large: ${formatBytes(stats.size)} (max: ${formatBytes(maxSizeBytes)}). Consider using Git LFS or removing the file.`,
107
+ ].map((message) => ({ message }));
114
108
  return result;
115
109
  }
116
- return true;
110
+ return [];
117
111
  }
118
112
  catch (_error) {
119
113
  // File doesn't exist or can't be accessed, skip it
120
- return true;
114
+ return [];
121
115
  }
122
116
  },
123
- });
117
+ };
124
118
  //# sourceMappingURL=NoLargeBinaryFiles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NoLargeBinaryFiles.js","sourceRoot":"","sources":["../../src/policies/NoLargeBinaryFiles.ts"],"names":[],"mappings":"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","sourcesContent":["import { statSync } from \"node:fs\";\nimport path from \"pathe\";\nimport { makePolicyDefinition } from \"../makePolicy.js\";\nimport type { PolicyDefinition, PolicyFailure } from \"../policy.js\";\n\n/**\n * Policy settings for the NoLargeBinaryFiles repo policy.\n *\n * @alpha\n */\nexport interface NoLargeBinaryFilesSettings {\n\t/**\n\t * Maximum file size in bytes. Defaults to 10MB.\n\t */\n\tmaxSizeBytes?: number;\n\n\t/**\n\t * File extensions to exclude from size checking.\n\t * Useful for known large files that should be allowed.\n\t */\n\texcludeExtensions?: string[];\n\n\t/**\n\t * File patterns to exclude from size checking.\n\t * Uses glob-style patterns.\n\t */\n\texcludePatterns?: string[];\n}\n\n/**\n * Default maximum file size (10MB in bytes).\n */\nconst DEFAULT_MAX_SIZE = 10 * 1024 * 1024;\n\n/**\n * Default file extensions that are typically safe to exclude from size limits.\n */\nconst DEFAULT_EXCLUDE_EXTENSIONS = [\n\t\".md\",\n\t\".txt\",\n\t\".json\",\n\t\".js\",\n\t\".ts\",\n\t\".jsx\",\n\t\".tsx\",\n\t\".css\",\n\t\".scss\",\n\t\".sass\",\n\t\".less\",\n\t\".html\",\n\t\".xml\",\n\t\".yml\",\n\t\".yaml\",\n\t\".toml\",\n\t\".ini\",\n\t\".conf\",\n\t\".config\",\n];\n\n/**\n * Convert a glob pattern to a regex pattern by escaping special characters\n * and converting * to .* for wildcard matching.\n */\nfunction globToRegex(pattern: string): RegExp {\n\t// Escape all regex special characters except *\n\tconst escaped = pattern.replace(/[.+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\t// Convert * to .* for wildcard matching\n\tconst regexPattern = escaped.replace(/\\*/g, \".*\");\n\treturn new RegExp(`^${regexPattern}$`);\n}\n\n/**\n * Check if a file matches any of the exclude patterns.\n */\nfunction isExcluded(\n\tfilePath: string,\n\texcludePatterns: string[],\n\texcludeExtensions: string[],\n): boolean {\n\tconst ext = path.extname(filePath).toLowerCase();\n\n\t// Check extensions\n\tif (excludeExtensions.includes(ext)) {\n\t\treturn true;\n\t}\n\n\t// Check patterns (simple glob-like matching)\n\tfor (const pattern of excludePatterns) {\n\t\tif (pattern.includes(\"*\")) {\n\t\t\tconst regex = globToRegex(pattern);\n\t\t\tif (regex.test(filePath)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} else if (filePath.includes(pattern)) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/**\n * Format bytes in a human-readable format.\n */\nfunction formatBytes(bytes: number): string {\n\tif (bytes === 0) {\n\t\treturn \"0 B\";\n\t}\n\tconst k = 1024;\n\tconst sizes = [\"B\", \"KB\", \"MB\", \"GB\", \"TB\"];\n\tconst i = Math.min(\n\t\tMath.floor(Math.log(bytes) / Math.log(k)),\n\t\tsizes.length - 1,\n\t);\n\tconst formatted = (bytes / k ** i).toFixed(1);\n\treturn `${formatted} ${sizes[i]}`;\n}\n\n/**\n * A repo policy that prevents large binary files from being committed to the repository.\n * Large files can bloat the repository and slow down clones. Consider using Git LFS for large assets.\n *\n * @alpha\n */\nexport const NoLargeBinaryFiles: PolicyDefinition<NoLargeBinaryFilesSettings> =\n\tmakePolicyDefinition({\n\t\tname: \"NoLargeBinaryFiles\",\n\t\tdescription:\n\t\t\t\"Prevents large binary files from being committed to avoid repository bloat; consider using Git LFS for large assets.\",\n\t\t// Match all files\n\t\tmatch: /.*/,\n\t\thandler: async ({ file, root, config }) => {\n\t\t\tconst maxSizeBytes = config?.maxSizeBytes ?? DEFAULT_MAX_SIZE;\n\t\t\tconst excludeExtensions =\n\t\t\t\tconfig?.excludeExtensions ?? DEFAULT_EXCLUDE_EXTENSIONS;\n\t\t\tconst excludePatterns = config?.excludePatterns ?? [];\n\n\t\t\t// Skip excluded files\n\t\t\tif (isExcluded(file, excludePatterns, excludeExtensions)) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tconst filePath = path.resolve(root, file);\n\t\t\t\tconst stats = statSync(filePath);\n\n\t\t\t\t// Skip directories\n\t\t\t\tif (stats.isDirectory()) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tif (stats.size > maxSizeBytes) {\n\t\t\t\t\tconst result: PolicyFailure = {\n\t\t\t\t\t\tname: NoLargeBinaryFiles.name,\n\t\t\t\t\t\tfile,\n\t\t\t\t\t\tautoFixable: false,\n\t\t\t\t\t\terrorMessages: [\n\t\t\t\t\t\t\t`File is too large: ${formatBytes(stats.size)} (max: ${formatBytes(maxSizeBytes)}). Consider using Git LFS or removing the file.`,\n\t\t\t\t\t\t],\n\t\t\t\t\t};\n\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t} catch (_error: unknown) {\n\t\t\t\t// File doesn't exist or can't be accessed, skip it\n\t\t\t\treturn true;\n\t\t\t}\n\t\t},\n\t});\n"]}
1
+ {"version":3,"file":"NoLargeBinaryFiles.js","sourceRoot":"","sources":["../../src/policies/NoLargeBinaryFiles.ts"],"names":[],"mappings":"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","sourcesContent":["import { statSync } from \"node:fs\";\nimport path from \"pathe\";\nimport type { FilePolicyDefinition, PolicyFinding } from \"../policy.js\";\n/**\n * Policy settings for the NoLargeBinaryFiles repo policy.\n *\n * @public\n */\nexport interface NoLargeBinaryFilesSettings {\n\t/**\n\t * Maximum file size in bytes. Defaults to 10MB.\n\t */\n\tmaxSizeBytes?: number;\n\n\t/**\n\t * File extensions to exclude from size checking.\n\t * Useful for known large files that should be allowed.\n\t */\n\texcludeExtensions?: string[];\n\n\t/**\n\t * File patterns to exclude from size checking.\n\t * Uses glob-style patterns.\n\t */\n\texcludePatterns?: string[];\n}\n\n/**\n * Default maximum file size (10MB in bytes).\n */\nconst DEFAULT_MAX_SIZE = 10 * 1024 * 1024;\n\n/**\n * Default file extensions that are typically safe to exclude from size limits.\n */\nconst DEFAULT_EXCLUDE_EXTENSIONS = [\n\t\".md\",\n\t\".txt\",\n\t\".json\",\n\t\".js\",\n\t\".ts\",\n\t\".jsx\",\n\t\".tsx\",\n\t\".css\",\n\t\".scss\",\n\t\".sass\",\n\t\".less\",\n\t\".html\",\n\t\".xml\",\n\t\".yml\",\n\t\".yaml\",\n\t\".toml\",\n\t\".ini\",\n\t\".conf\",\n\t\".config\",\n];\n\n/**\n * Convert a glob pattern to a regex pattern by escaping special characters\n * and converting * to .* for wildcard matching.\n */\nfunction globToRegex(pattern: string): RegExp {\n\t// Escape all regex special characters except *\n\tconst escaped = pattern.replace(/[.+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\t// Convert * to .* for wildcard matching\n\tconst regexPattern = escaped.replace(/\\*/g, \".*\");\n\treturn new RegExp(`^${regexPattern}$`);\n}\n\n/**\n * Check if a file matches any of the exclude patterns.\n */\nfunction isExcluded(\n\tfilePath: string,\n\texcludePatterns: string[],\n\texcludeExtensions: string[],\n): boolean {\n\tconst ext = path.extname(filePath).toLowerCase();\n\n\t// Check extensions\n\tif (excludeExtensions.includes(ext)) {\n\t\treturn true;\n\t}\n\n\t// Check patterns (simple glob-like matching)\n\tfor (const pattern of excludePatterns) {\n\t\tif (pattern.includes(\"*\")) {\n\t\t\tconst regex = globToRegex(pattern);\n\t\t\tif (regex.test(filePath)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} else if (filePath.includes(pattern)) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/**\n * Format bytes in a human-readable format.\n */\nfunction formatBytes(bytes: number): string {\n\tif (bytes === 0) {\n\t\treturn \"0 B\";\n\t}\n\tconst k = 1024;\n\tconst sizes = [\"B\", \"KB\", \"MB\", \"GB\", \"TB\"];\n\tconst i = Math.min(\n\t\tMath.floor(Math.log(bytes) / Math.log(k)),\n\t\tsizes.length - 1,\n\t);\n\tconst formatted = (bytes / k ** i).toFixed(1);\n\treturn `${formatted} ${sizes[i]}`;\n}\n\n/**\n * A repo policy that prevents large binary files from being committed to the repository.\n * Large files can bloat the repository and slow down clones. Consider using Git LFS for large assets.\n *\n * @public\n */\nexport const NoLargeBinaryFiles = {\n\tname: \"NoLargeBinaryFiles\",\n\tdescription:\n\t\t\"Prevents large binary files from being committed to avoid repository bloat; consider using Git LFS for large assets.\",\n\t// Match all files\n\tmatch: /.*/,\n\thandler: async ({ file, root, config }) => {\n\t\tconst maxSizeBytes = config?.maxSizeBytes ?? DEFAULT_MAX_SIZE;\n\t\tconst excludeExtensions =\n\t\t\tconfig?.excludeExtensions ?? DEFAULT_EXCLUDE_EXTENSIONS;\n\t\tconst excludePatterns = config?.excludePatterns ?? [];\n\n\t\t// Skip excluded files\n\t\tif (isExcluded(file, excludePatterns, excludeExtensions)) {\n\t\t\treturn [];\n\t\t}\n\n\t\ttry {\n\t\t\tconst filePath = path.resolve(root, file);\n\t\t\tconst stats = statSync(filePath);\n\n\t\t\t// Skip directories\n\t\t\tif (stats.isDirectory()) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tif (stats.size > maxSizeBytes) {\n\t\t\t\tconst result: PolicyFinding[] = [\n\t\t\t\t\t`File is too large: ${formatBytes(stats.size)} (max: ${formatBytes(maxSizeBytes)}). Consider using Git LFS or removing the file.`,\n\t\t\t\t].map((message) => ({ message }));\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\treturn [];\n\t\t} catch (_error: unknown) {\n\t\t\t// File doesn't exist or can't be accessed, skip it\n\t\t\treturn [];\n\t\t}\n\t},\n} satisfies FilePolicyDefinition<NoLargeBinaryFilesSettings>;\n"]}
@@ -1,10 +1,12 @@
1
1
  /**
2
2
  * Configuration for the NoPrivateWorkspaceDependencies policy.
3
+ *
4
+ * @public
3
5
  */
4
6
  export interface NoPrivateWorkspaceDependenciesSettings {
5
7
  /**
6
8
  * Whether to check devDependencies in addition to dependencies.
7
- * @default false
9
+ * @defaultValue false
8
10
  */
9
11
  checkDevDependencies?: boolean;
10
12
  }
@@ -21,17 +23,19 @@ export interface NoPrivateWorkspaceDependenciesSettings {
21
23
  * @example
22
24
  * ```typescript
23
25
  * // In repopo.config.ts
26
+ * import { makePolicy } from "repopo";
24
27
  * import { NoPrivateWorkspaceDependencies } from "repopo/policies";
25
28
  *
26
- * makePolicy(NoPrivateWorkspaceDependencies, {
27
- * checkDevDependencies: false, // Only check production dependencies (default)
28
- * });
29
+ * // Only check production dependencies (default)
30
+ * makePolicy(NoPrivateWorkspaceDependencies);
29
31
  *
30
32
  * // Or check both dependencies and devDependencies
31
33
  * makePolicy(NoPrivateWorkspaceDependencies, {
32
- * checkDevDependencies: true,
34
+ * config: { checkDevDependencies: true },
33
35
  * });
34
36
  * ```
37
+ *
38
+ * @public
35
39
  */
36
- export declare const NoPrivateWorkspaceDependencies: import("../policy.js").PolicyShape<NoPrivateWorkspaceDependenciesSettings | undefined>;
40
+ export declare const NoPrivateWorkspaceDependencies: import("../policy.js").FilePolicyDefinition<NoPrivateWorkspaceDependenciesSettings | undefined>;
37
41
  //# sourceMappingURL=NoPrivateWorkspaceDependencies.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"NoPrivateWorkspaceDependencies.d.ts","sourceRoot":"","sources":["../../src/policies/NoPrivateWorkspaceDependencies.ts"],"names":[],"mappings":"AAYA;;GAEG;AACH,MAAM,WAAW,sCAAsC;IACtD;;;OAGG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAC/B;AA6ED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,8BAA8B,wFAyEzC,CAAC"}
1
+ {"version":3,"file":"NoPrivateWorkspaceDependencies.d.ts","sourceRoot":"","sources":["../../src/policies/NoPrivateWorkspaceDependencies.ts"],"names":[],"mappings":"AAYA;;;;GAIG;AACH,MAAM,WAAW,sCAAsC;IACtD;;;OAGG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAC/B;AA6ED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,8BAA8B,iGAoEzC,CAAC"}