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
package/esm/config.d.ts CHANGED
@@ -1,44 +1,10 @@
1
- import type { PolicyCreator } from "./generators.js";
2
- import type { ConfiguredPolicy, PolicyInstance } from "./policy.js";
3
- /**
4
- * @alpha
5
- */
6
- export type PolicyList = PolicyCreator[];
7
- /**
8
- * @alpha
9
- */
1
+ import { type ConfiguredPolicy } from "./policy.js";
2
+ /** Repository-wide policy configuration. @public */
10
3
  export interface RepopoConfig {
11
- /**
12
- * An array of configured policies that are enabled.
13
- *
14
- * Use the `policy()` function to configure policies before adding them to this array.
15
- *
16
- * @example
17
- * ```typescript
18
- * import { policy, type RepopoConfig } from "repopo";
19
- * import { NoJsFileExtensions, PackageJsonProperties } from "repopo/policies";
20
- *
21
- * const config: RepopoConfig = {
22
- * policies: [
23
- * policy(NoJsFileExtensions, { exclude: ["bin/*"] }),
24
- * policy(PackageJsonProperties, { verbatim: { license: "MIT" } }),
25
- * ],
26
- * };
27
- * ```
28
- *
29
- * See `DefaultPolicies` for the policies that will be enabled by default if this is `undefined`.
30
- */
31
- policies?: (ConfiguredPolicy<any> | PolicyInstance<any>)[];
32
- /**
33
- * An array of strings/regular expressions. File paths that match any of these expressions will be completely excluded
34
- * from all policies.
35
- */
4
+ policies?: ConfiguredPolicy[];
5
+ /** Repo-relative regex exclusions. Strings are case-insensitive. */
36
6
  excludeFiles?: (string | RegExp)[];
37
7
  }
38
- /**
39
- * The default config applied when no config is found.
40
- *
41
- * @alpha
42
- */
8
+ /** The default configuration when no config file is found. @alpha */
43
9
  export declare const DefaultPolicyConfig: RepopoConfig;
44
10
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGpE;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;AAEzC;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B;;;;;;;;;;;;;;;;;;;OAmBG;IAEH,QAAQ,CAAC,EAAE,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;IAE3D;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;CACnC;AAED;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,EAAE,YAGjC,CAAC"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,gBAAgB,EAAmB,MAAM,aAAa,CAAC;AAErE,oDAAoD;AACpD,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC9B,oEAAoE;IACpE,YAAY,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;CACnC;AAED,qEAAqE;AACrE,eAAO,MAAM,mBAAmB,EAAE,YAGjC,CAAC"}
package/esm/config.js CHANGED
@@ -1,12 +1,8 @@
1
- import { policy } from "./makePolicy.js";
1
+ import { makePolicy } from "./makePolicy.js";
2
2
  import { DefaultPolicies } from "./policy.js";
3
- /**
4
- * The default config applied when no config is found.
5
- *
6
- * @alpha
7
- */
3
+ /** The default configuration when no config file is found. @alpha */
8
4
  export const DefaultPolicyConfig = {
9
- policies: DefaultPolicies.map((p) => policy(p)),
5
+ policies: DefaultPolicies.map((definition) => makePolicy(definition)),
10
6
  excludeFiles: [],
11
7
  };
12
8
  //# sourceMappingURL=config.js.map
package/esm/config.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAyC9C;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAiB;IAChD,QAAQ,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC/C,YAAY,EAAE,EAAE;CAChB,CAAC","sourcesContent":["import type { PolicyCreator } from \"./generators.js\";\nimport { policy } from \"./makePolicy.js\";\nimport type { ConfiguredPolicy, PolicyInstance } from \"./policy.js\";\nimport { DefaultPolicies } from \"./policy.js\";\n\n/**\n * @alpha\n */\nexport type PolicyList = PolicyCreator[];\n\n/**\n * @alpha\n */\nexport interface RepopoConfig {\n\t/**\n\t * An array of configured policies that are enabled.\n\t *\n\t * Use the `policy()` function to configure policies before adding them to this array.\n\t *\n\t * @example\n\t * ```typescript\n\t * import { policy, type RepopoConfig } from \"repopo\";\n\t * import { NoJsFileExtensions, PackageJsonProperties } from \"repopo/policies\";\n\t *\n\t * const config: RepopoConfig = {\n\t * policies: [\n\t * policy(NoJsFileExtensions, { exclude: [\"bin/*\"] }),\n\t * policy(PackageJsonProperties, { verbatim: { license: \"MIT\" } }),\n\t * ],\n\t * };\n\t * ```\n\t *\n\t * See `DefaultPolicies` for the policies that will be enabled by default if this is `undefined`.\n\t */\n\t// biome-ignore lint/suspicious/noExplicitAny: FIXME\n\tpolicies?: (ConfiguredPolicy<any> | PolicyInstance<any>)[];\n\n\t/**\n\t * An array of strings/regular expressions. File paths that match any of these expressions will be completely excluded\n\t * from all policies.\n\t */\n\texcludeFiles?: (string | RegExp)[];\n}\n\n/**\n * The default config applied when no config is found.\n *\n * @alpha\n */\nexport const DefaultPolicyConfig: RepopoConfig = {\n\tpolicies: DefaultPolicies.map((p) => policy(p)),\n\texcludeFiles: [],\n};\n"]}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAyB,eAAe,EAAE,MAAM,aAAa,CAAC;AASrE,qEAAqE;AACrE,MAAM,CAAC,MAAM,mBAAmB,GAAiB;IAChD,QAAQ,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IACrE,YAAY,EAAE,EAAE;CAChB,CAAC","sourcesContent":["import { makePolicy } from \"./makePolicy.js\";\nimport { type ConfiguredPolicy, DefaultPolicies } from \"./policy.js\";\n\n/** Repository-wide policy configuration. @public */\nexport interface RepopoConfig {\n\tpolicies?: ConfiguredPolicy[];\n\t/** Repo-relative regex exclusions. Strings are case-insensitive. */\n\texcludeFiles?: (string | RegExp)[];\n}\n\n/** The default configuration when no config file is found. @alpha */\nexport const DefaultPolicyConfig: RepopoConfig = {\n\tpolicies: DefaultPolicies.map((definition) => makePolicy(definition)),\n\texcludeFiles: [],\n};\n"]}
package/esm/context.d.ts CHANGED
@@ -1,6 +1,23 @@
1
1
  import type { PolicyHandlerPerfStats } from "./perf.js";
2
- import type { PolicyInstance, PolicyName } from "./policy.js";
3
- export type ExcludedPolicyFileMap = Map<PolicyName, RegExp[]>;
2
+ import type { IdentifiedPolicy, PolicyInstanceId } from "./policy.js";
3
+ /**
4
+ * A map of policy instance IDs to file-path regexes that should be excluded from those policies.
5
+ * Paths are relative to the repository root.
6
+ *
7
+ * @public
8
+ */
9
+ export type ExcludedPolicyFileMap = Map<PolicyInstanceId, RegExp[]>;
10
+ /**
11
+ * Preserve explicit regex flags; string exclusions remain case-insensitive.
12
+ * @internal
13
+ */
14
+ export declare function exclusionRegex(pattern: string | RegExp): RegExp;
15
+ /**
16
+ * Creates the per-instance exclusion map used by policy runners.
17
+ *
18
+ * @internal
19
+ */
20
+ export declare function createExcludedPolicyFileMap(policies: IdentifiedPolicy[]): ExcludedPolicyFileMap;
4
21
  /**
5
22
  * Contextual data available to all Repopo commands.
6
23
  */
@@ -12,7 +29,7 @@ export interface RepopoCommandContext {
12
29
  /**
13
30
  * A list of handlers to apply to selected files.
14
31
  */
15
- policies: PolicyInstance[];
32
+ policies: IdentifiedPolicy[];
16
33
  /**
17
34
  * A per-handler list of regular expressions used to exclude files from specific handlers.
18
35
  */
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9D,MAAM,MAAM,qBAAqB,GAAG,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC;;OAEG;IACH,cAAc,EAAE,MAAM,EAAE,CAAC;IAEzB;;OAEG;IACH,QAAQ,EAAE,cAAc,EAAE,CAAC;IAE3B;;OAEG;IACH,uBAAuB,EAAE,qBAAqB,CAAC;IAE/C;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,SAAS,EAAE,sBAAsB,CAAC;CAClC"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEtE;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,GAAG,GAAG,CAAC,gBAAgB,EAAE,MAAM,EAAE,CAAC,CAAC;AAEpE;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAE/D;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAC1C,QAAQ,EAAE,gBAAgB,EAAE,GAC1B,qBAAqB,CAOvB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC;;OAEG;IACH,cAAc,EAAE,MAAM,EAAE,CAAC;IAEzB;;OAEG;IACH,QAAQ,EAAE,gBAAgB,EAAE,CAAC;IAE7B;;OAEG;IACH,uBAAuB,EAAE,qBAAqB,CAAC;IAE/C;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,SAAS,EAAE,sBAAsB,CAAC;CAClC"}
package/esm/context.js CHANGED
@@ -1,2 +1,19 @@
1
- export {};
1
+ /**
2
+ * Preserve explicit regex flags; string exclusions remain case-insensitive.
3
+ * @internal
4
+ */
5
+ export function exclusionRegex(pattern) {
6
+ return typeof pattern === "string" ? new RegExp(pattern, "i") : pattern;
7
+ }
8
+ /**
9
+ * Creates the per-instance exclusion map used by policy runners.
10
+ *
11
+ * @internal
12
+ */
13
+ export function createExcludedPolicyFileMap(policies) {
14
+ return new Map(policies.map((configuredPolicy) => [
15
+ configuredPolicy.instanceId,
16
+ configuredPolicy.exclude?.map(exclusionRegex) ?? [],
17
+ ]));
18
+ }
2
19
  //# sourceMappingURL=context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"","sourcesContent":["import type { PolicyHandlerPerfStats } from \"./perf.js\";\nimport type { PolicyInstance, PolicyName } from \"./policy.js\";\n\nexport type ExcludedPolicyFileMap = Map<PolicyName, RegExp[]>;\n\n/**\n * Contextual data available to all Repopo commands.\n */\nexport interface RepopoCommandContext {\n\t/**\n\t * A list of regular expressions used to exclude files from all handlers.\n\t */\n\texcludeFromAll: RegExp[];\n\n\t/**\n\t * A list of handlers to apply to selected files.\n\t */\n\tpolicies: PolicyInstance[];\n\n\t/**\n\t * A per-handler list of regular expressions used to exclude files from specific handlers.\n\t */\n\texcludePoliciesForFiles: ExcludedPolicyFileMap;\n\n\t/**\n\t * Path to the root of the git repo.\n\t */\n\tgitRoot: string;\n\n\t/**\n\t * Stores performance data for each handler. Used to collect and display performance stats.\n\t */\n\tperfStats: PolicyHandlerPerfStats;\n}\n"]}
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAWA;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,OAAwB;IACtD,OAAO,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;AACzE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CAC1C,QAA4B;IAE5B,OAAO,IAAI,GAAG,CACb,QAAQ,CAAC,GAAG,CAAC,CAAC,gBAAgB,EAAE,EAAE,CAAC;QAClC,gBAAgB,CAAC,UAAU;QAC3B,gBAAgB,CAAC,OAAO,EAAE,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE;KACnD,CAAC,CACF,CAAC;AACH,CAAC","sourcesContent":["import type { PolicyHandlerPerfStats } from \"./perf.js\";\nimport type { IdentifiedPolicy, PolicyInstanceId } from \"./policy.js\";\n\n/**\n * A map of policy instance IDs to file-path regexes that should be excluded from those policies.\n * Paths are relative to the repository root.\n *\n * @public\n */\nexport type ExcludedPolicyFileMap = Map<PolicyInstanceId, RegExp[]>;\n\n/**\n * Preserve explicit regex flags; string exclusions remain case-insensitive.\n * @internal\n */\nexport function exclusionRegex(pattern: string | RegExp): RegExp {\n\treturn typeof pattern === \"string\" ? new RegExp(pattern, \"i\") : pattern;\n}\n\n/**\n * Creates the per-instance exclusion map used by policy runners.\n *\n * @internal\n */\nexport function createExcludedPolicyFileMap(\n\tpolicies: IdentifiedPolicy[],\n): ExcludedPolicyFileMap {\n\treturn new Map(\n\t\tpolicies.map((configuredPolicy) => [\n\t\t\tconfiguredPolicy.instanceId,\n\t\t\tconfiguredPolicy.exclude?.map(exclusionRegex) ?? [],\n\t\t]),\n\t);\n}\n\n/**\n * Contextual data available to all Repopo commands.\n */\nexport interface RepopoCommandContext {\n\t/**\n\t * A list of regular expressions used to exclude files from all handlers.\n\t */\n\texcludeFromAll: RegExp[];\n\n\t/**\n\t * A list of handlers to apply to selected files.\n\t */\n\tpolicies: IdentifiedPolicy[];\n\n\t/**\n\t * A per-handler list of regular expressions used to exclude files from specific handlers.\n\t */\n\texcludePoliciesForFiles: ExcludedPolicyFileMap;\n\n\t/**\n\t * Path to the root of the git repo.\n\t */\n\tgitRoot: string;\n\n\t/**\n\t * Stores performance data for each handler. Used to collect and display performance stats.\n\t */\n\tperfStats: PolicyHandlerPerfStats;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ /** An invalid handler invocation or result at a runtime boundary. @internal */
2
+ export declare class ExecutionContractError extends TypeError {
3
+ }
4
+ //# sourceMappingURL=executionContractError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executionContractError.d.ts","sourceRoot":"","sources":["../src/executionContractError.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,qBAAa,sBAAuB,SAAQ,SAAS;CAAG"}
@@ -0,0 +1,4 @@
1
+ /** An invalid handler invocation or result at a runtime boundary. @internal */
2
+ export class ExecutionContractError extends TypeError {
3
+ }
4
+ //# sourceMappingURL=executionContractError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executionContractError.js","sourceRoot":"","sources":["../src/executionContractError.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,MAAM,OAAO,sBAAuB,SAAQ,SAAS;CAAG","sourcesContent":["/** An invalid handler invocation or result at a runtime boundary. @internal */\nexport class ExecutionContractError extends TypeError {}\n"]}
@@ -0,0 +1,12 @@
1
+ import type { PolicyArgs } from "./policy.js";
2
+ /** Internal context shared with policies loaded through different module loaders. */
3
+ export declare const fileCache: unique symbol;
4
+ export declare class ParsedFileCache {
5
+ private readonly entries;
6
+ read<T>(key: string, load: () => Promise<T>, clone?: (value: unknown) => unknown): Promise<T>;
7
+ clear(): void;
8
+ }
9
+ export declare function readParsedFile<T>(args: PolicyArgs<unknown> & {
10
+ [fileCache]?: ParsedFileCache | undefined;
11
+ }, format: "json" | "toml", load: () => Promise<T>): Promise<T>;
12
+ //# sourceMappingURL=fileCache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileCache.d.ts","sourceRoot":"","sources":["../src/fileCache.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,qFAAqF;AACrF,eAAO,MAAM,SAAS,eAAiC,CAAC;AAkBxD,qBAAa,eAAe;IAC3B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAuC;IAElD,IAAI,CAAC,CAAC,EAClB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACtB,KAAK,GAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAyB,GAClD,OAAO,CAAC,CAAC,CAAC;IASN,KAAK,IAAI,IAAI;CAGpB;AAED,wBAAgB,cAAc,CAAC,CAAC,EAC/B,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG;IAAE,CAAC,SAAS,CAAC,CAAC,EAAE,eAAe,GAAG,SAAS,CAAA;CAAE,EACzE,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACpB,OAAO,CAAC,CAAC,CAAC,CASZ"}
@@ -0,0 +1,37 @@
1
+ import { resolve } from "pathe";
2
+ /** Internal context shared with policies loaded through different module loaders. */
3
+ export const fileCache = Symbol.for("repopo.fileCache");
4
+ function cloneToml(value) {
5
+ if (value instanceof Date) {
6
+ // TomlDate stores date/time kind and offset in private fields.
7
+ return Reflect.construct(value.constructor, [value.toISOString()]);
8
+ }
9
+ if (Array.isArray(value)) {
10
+ return value.map(cloneToml);
11
+ }
12
+ if (value !== null && typeof value === "object") {
13
+ return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, cloneToml(entry)]));
14
+ }
15
+ return value;
16
+ }
17
+ export class ParsedFileCache {
18
+ entries = new Map();
19
+ async read(key, load, clone = structuredClone) {
20
+ let pending = this.entries.get(key);
21
+ if (pending === undefined) {
22
+ pending = load();
23
+ this.entries.set(key, pending);
24
+ }
25
+ return clone(await pending);
26
+ }
27
+ clear() {
28
+ this.entries.clear();
29
+ }
30
+ }
31
+ export function readParsedFile(args, format, load) {
32
+ const cache = args.resolve ? undefined : args[fileCache];
33
+ return cache
34
+ ? cache.read(JSON.stringify([format, resolve(args.root, args.file)]), load, format === "toml" ? cloneToml : structuredClone)
35
+ : load();
36
+ }
37
+ //# sourceMappingURL=fileCache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileCache.js","sourceRoot":"","sources":["../src/fileCache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAGhC,qFAAqF;AACrF,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;AAExD,SAAS,SAAS,CAAC,KAAc;IAChC,IAAI,KAAK,YAAY,IAAI,EAAE,CAAC;QAC3B,+DAA+D;QAC/D,OAAO,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;IACpE,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC7B,CAAC;IACD,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACjD,OAAO,MAAM,CAAC,WAAW,CACxB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CACpE,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAED,MAAM,OAAO,eAAe;IACV,OAAO,GAAG,IAAI,GAAG,EAA4B,CAAC;IAExD,KAAK,CAAC,IAAI,CAChB,GAAW,EACX,IAAsB,EACtB,QAAqC,eAAe;QAEpD,IAAI,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACpC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC3B,OAAO,GAAG,IAAI,EAAE,CAAC;YACjB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAChC,CAAC;QACD,OAAO,KAAK,CAAC,MAAM,OAAO,CAAM,CAAC;IAClC,CAAC;IAEM,KAAK;QACX,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;CACD;AAED,MAAM,UAAU,cAAc,CAC7B,IAAyE,EACzE,MAAuB,EACvB,IAAsB;IAEtB,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACzD,OAAO,KAAK;QACX,CAAC,CAAC,KAAK,CAAC,IAAI,CACV,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EACvD,IAAI,EACJ,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,eAAe,CAC/C;QACF,CAAC,CAAC,IAAI,EAAE,CAAC;AACX,CAAC","sourcesContent":["import { resolve } from \"pathe\";\nimport type { PolicyArgs } from \"./policy.js\";\n\n/** Internal context shared with policies loaded through different module loaders. */\nexport const fileCache = Symbol.for(\"repopo.fileCache\");\n\nfunction cloneToml(value: unknown): unknown {\n\tif (value instanceof Date) {\n\t\t// TomlDate stores date/time kind and offset in private fields.\n\t\treturn Reflect.construct(value.constructor, [value.toISOString()]);\n\t}\n\tif (Array.isArray(value)) {\n\t\treturn value.map(cloneToml);\n\t}\n\tif (value !== null && typeof value === \"object\") {\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries(value).map(([key, entry]) => [key, cloneToml(entry)]),\n\t\t);\n\t}\n\treturn value;\n}\n\nexport class ParsedFileCache {\n\tprivate readonly entries = new Map<string, Promise<unknown>>();\n\n\tpublic async read<T>(\n\t\tkey: string,\n\t\tload: () => Promise<T>,\n\t\tclone: (value: unknown) => unknown = structuredClone,\n\t): Promise<T> {\n\t\tlet pending = this.entries.get(key);\n\t\tif (pending === undefined) {\n\t\t\tpending = load();\n\t\t\tthis.entries.set(key, pending);\n\t\t}\n\t\treturn clone(await pending) as T;\n\t}\n\n\tpublic clear(): void {\n\t\tthis.entries.clear();\n\t}\n}\n\nexport function readParsedFile<T>(\n\targs: PolicyArgs<unknown> & { [fileCache]?: ParsedFileCache | undefined },\n\tformat: \"json\" | \"toml\",\n\tload: () => Promise<T>,\n): Promise<T> {\n\tconst cache = args.resolve ? undefined : args[fileCache];\n\treturn cache\n\t\t? cache.read(\n\t\t\t\tJSON.stringify([format, resolve(args.root, args.file)]),\n\t\t\t\tload,\n\t\t\t\tformat === \"toml\" ? cloneToml : structuredClone,\n\t\t\t)\n\t\t: load();\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare function parseFilePaths(input: string): string[];
2
+ //# sourceMappingURL=filePaths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filePaths.d.ts","sourceRoot":"","sources":["../src/filePaths.ts"],"names":[],"mappings":"AAGA,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAKtD"}
@@ -0,0 +1,9 @@
1
+ const WINDOWS_SEPARATOR = /\\/g;
2
+ const LINE_BREAK = /\r?\n/;
3
+ export function parseFilePaths(input) {
4
+ return input
5
+ .replace(WINDOWS_SEPARATOR, "/")
6
+ .split(input.includes("\0") ? "\0" : LINE_BREAK)
7
+ .filter((filePath) => filePath.length > 0);
8
+ }
9
+ //# sourceMappingURL=filePaths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filePaths.js","sourceRoot":"","sources":["../src/filePaths.ts"],"names":[],"mappings":"AAAA,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAChC,MAAM,UAAU,GAAG,OAAO,CAAC;AAE3B,MAAM,UAAU,cAAc,CAAC,KAAa;IAC3C,OAAO,KAAK;SACV,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC;SAC/B,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC;SAC/C,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["const WINDOWS_SEPARATOR = /\\\\/g;\nconst LINE_BREAK = /\\r?\\n/;\n\nexport function parseFilePaths(input: string): string[] {\n\treturn input\n\t\t.replace(WINDOWS_SEPARATOR, \"/\")\n\t\t.split(input.includes(\"\\0\") ? \"\\0\" : LINE_BREAK)\n\t\t.filter((filePath) => filePath.length > 0);\n}\n"]}
@@ -1,23 +1,3 @@
1
- import type { PolicyDefinition } from "./policy.js";
2
- /**
3
- * The definition of a free function that returns a RepoPolicy.
4
- *
5
- * @alpha
6
- */
7
- export type PolicyCreatorFunction<C = undefined> = (args: PolicyDefinition<C>) => PolicyDefinition<C>;
8
- /**
9
- * The definition of a constructor function that returns a RepoPolicy.
10
- *
11
- * @alpha
12
- */
13
- export type PolicyCreatorConstructor<C = undefined> = new (args: PolicyDefinition<C>) => PolicyDefinition<C>;
14
- /**
15
- * A PolicyCreator is a function that can be used to generate a {@link PolicyDefinition}. The function can be a free
16
- * function or a constructor that creates a class implementing the {@link PolicyDefinition} interface.
17
- *
18
- * @alpha
19
- */
20
- export type PolicyCreator = PolicyCreatorConstructor | PolicyCreatorFunction;
21
1
  /**
22
2
  * Checks if a given function is a generator function.
23
3
  *
@@ -1 +1 @@
1
- {"version":3,"file":"generators.d.ts","sourceRoot":"","sources":["../src/generators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,CAAC,CAAC,GAAG,SAAS,IAAI,CAClD,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,KACrB,gBAAgB,CAAC,CAAC,CAAC,CAAC;AAEzB;;;;GAIG;AACH,MAAM,MAAM,wBAAwB,CAAC,CAAC,GAAG,SAAS,IAAI,KACrD,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,KACrB,gBAAgB,CAAC,CAAC,CAAC,CAAC;AAEzB;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,wBAAwB,GAAG,qBAAqB,CAAC;AAE7E;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,QAAQ,GAAG,EAAE,IAAI,iBAAiB,CAEzE"}
1
+ {"version":3,"file":"generators.d.ts","sourceRoot":"","sources":["../src/generators.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,QAAQ,GAAG,EAAE,IAAI,iBAAiB,CAEzE"}
@@ -1 +1 @@
1
- {"version":3,"file":"generators.js","sourceRoot":"","sources":["../src/generators.ts"],"names":[],"mappings":"AA4BA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,oEAAoE;AACpE,MAAM,UAAU,mBAAmB,CAAC,EAAY;IAC/C,OAAO,EAAE,CAAC,WAAW,CAAC,IAAI,KAAK,mBAAmB,CAAC;AACpD,CAAC","sourcesContent":["import type { PolicyDefinition } from \"./policy.js\";\n\n/**\n * The definition of a free function that returns a RepoPolicy.\n *\n * @alpha\n */\nexport type PolicyCreatorFunction<C = undefined> = (\n\targs: PolicyDefinition<C>,\n) => PolicyDefinition<C>;\n\n/**\n * The definition of a constructor function that returns a RepoPolicy.\n *\n * @alpha\n */\nexport type PolicyCreatorConstructor<C = undefined> = new (\n\targs: PolicyDefinition<C>,\n) => PolicyDefinition<C>;\n\n/**\n * A PolicyCreator is a function that can be used to generate a {@link PolicyDefinition}. The function can be a free\n * function or a constructor that creates a class implementing the {@link PolicyDefinition} interface.\n *\n * @alpha\n */\nexport type PolicyCreator = PolicyCreatorConstructor | PolicyCreatorFunction;\n\n/**\n * Checks if a given function is a generator function.\n *\n * A generator function is a function that can be paused and resumed, and can yield\n * multiple values over time. This utility function helps identify such functions\n * by checking their constructor name.\n *\n * @param fn - The function to check\n * @returns `true` if the function is a generator function, `false` otherwise\n *\n * @example\n * ```typescript\n * function* myGenerator() {\n * yield 1;\n * yield 2;\n * }\n *\n * function regularFunction() {\n * return 1;\n * }\n *\n * console.log(isGeneratorFunction(myGenerator)); // true\n * console.log(isGeneratorFunction(regularFunction)); // false\n * ```\n *\n * @alpha\n */\n// biome-ignore lint/complexity/noBannedTypes: broad type is OK here\nexport function isGeneratorFunction(fn: Function): fn is GeneratorFunction {\n\treturn fn.constructor.name === \"GeneratorFunction\";\n}\n"]}
1
+ {"version":3,"file":"generators.js","sourceRoot":"","sources":["../src/generators.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,oEAAoE;AACpE,MAAM,UAAU,mBAAmB,CAAC,EAAY;IAC/C,OAAO,EAAE,CAAC,WAAW,CAAC,IAAI,KAAK,mBAAmB,CAAC;AACpD,CAAC","sourcesContent":["/**\n * Checks if a given function is a generator function.\n *\n * A generator function is a function that can be paused and resumed, and can yield\n * multiple values over time. This utility function helps identify such functions\n * by checking their constructor name.\n *\n * @param fn - The function to check\n * @returns `true` if the function is a generator function, `false` otherwise\n *\n * @example\n * ```typescript\n * function* myGenerator() {\n * yield 1;\n * yield 2;\n * }\n *\n * function regularFunction() {\n * return 1;\n * }\n *\n * console.log(isGeneratorFunction(myGenerator)); // true\n * console.log(isGeneratorFunction(regularFunction)); // false\n * ```\n *\n * @alpha\n */\n// biome-ignore lint/complexity/noBannedTypes: broad type is OK here\nexport function isGeneratorFunction(fn: Function): fn is GeneratorFunction {\n\treturn fn.constructor.name === \"GeneratorFunction\";\n}\n"]}
package/esm/index.d.ts CHANGED
@@ -1,18 +1,10 @@
1
1
  /**
2
- * A tool for enforcing repository policies and standards across codebases.
2
+ * Repository policy authoring, execution, and CLI entry point.
3
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.
4
+ * Import `repopo/api` for the programmatic API without the CLI entry point.
8
5
  *
9
6
  * @packageDocumentation
10
7
  */
11
8
  export { run } from "@oclif/core";
12
- export { type FluidAdapterOptions, type FluidHandler, fromFluidHandlers, } from "./adapters/fluidFramework.js";
13
- export type { RepopoConfig, } from "./config.js";
14
- export { makePolicy, makePolicyDefinition, type PolicyDefinitionInput, type PolicyOptions, policy, } from "./makePolicy.js";
15
- export { type ConfiguredPolicy, isPolicyError, isPolicyFailure, isPolicyFixResult, Policy, type PolicyArgs, type PolicyDefinition, type PolicyError, type PolicyFailure, type PolicyFixResult, type PolicyFunctionArguments, type PolicyHandler, type PolicyHandlerResult, type PolicyInstance, type PolicyInstanceSettings, type PolicyName, type PolicyResolver, type PolicyResult, type PolicyShape, type PolicyStandaloneResolver, } from "./policy.js";
16
- export { type DefineFileHeaderPolicyArgs, defineFileHeaderPolicy, type FileHeaderGeneratorConfig, type FileHeaderPolicyConfig, } from "./policyDefiners/defineFileHeaderPolicy.js";
17
- export { type DefinePackagePolicyArgs, definePackagePolicy as generatePackagePolicy, type PackageJsonHandler, } from "./policyDefiners/definePackagePolicy.js";
9
+ export * from "./api.js";
18
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EACN,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,iBAAiB,GACjB,MAAM,8BAA8B,CAAC;AACtC,YAAY,EAEX,YAAY,GACZ,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,UAAU,EACV,oBAAoB,EACpB,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAClB,MAAM,GACN,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,KAAK,gBAAgB,EAErB,aAAa,EACb,eAAe,EACf,iBAAiB,EAEjB,MAAM,EACN,KAAK,UAAU,EAEf,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,wBAAwB,GAC7B,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,KAAK,0BAA0B,EAC/B,sBAAsB,EACtB,KAAK,yBAAyB,EAC9B,KAAK,sBAAsB,GAC3B,MAAM,4CAA4C,CAAC;AACpD,OAAO,EACN,KAAK,uBAAuB,EAC5B,mBAAmB,IAAI,qBAAqB,EAC5C,KAAK,kBAAkB,GACvB,MAAM,yCAAyC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,cAAc,UAAU,CAAC"}
package/esm/index.js CHANGED
@@ -1,21 +1,10 @@
1
1
  /**
2
- * A tool for enforcing repository policies and standards across codebases.
2
+ * Repository policy authoring, execution, and CLI entry point.
3
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.
4
+ * Import `repopo/api` for the programmatic API without the CLI entry point.
8
5
  *
9
6
  * @packageDocumentation
10
7
  */
11
8
  export { run } from "@oclif/core";
12
- export { fromFluidHandlers, } from "./adapters/fluidFramework.js";
13
- export { makePolicy, makePolicyDefinition, policy, } from "./makePolicy.js";
14
- export {
15
- // Type guards
16
- isPolicyError, isPolicyFailure, isPolicyFixResult,
17
- // New types
18
- Policy, } from "./policy.js";
19
- export { defineFileHeaderPolicy, } from "./policyDefiners/defineFileHeaderPolicy.js";
20
- export { definePackagePolicy as generatePackagePolicy, } from "./policyDefiners/definePackagePolicy.js";
9
+ export * from "./api.js";
21
10
  //# sourceMappingURL=index.js.map
package/esm/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAGN,iBAAiB,GACjB,MAAM,8BAA8B,CAAC;AAKtC,OAAO,EACN,UAAU,EACV,oBAAoB,EAGpB,MAAM,GACN,MAAM,iBAAiB,CAAC;AACzB,OAAO;AAEN,cAAc;AACd,aAAa,EACb,eAAe,EACf,iBAAiB;AACjB,YAAY;AACZ,MAAM,GAiBN,MAAM,aAAa,CAAC;AACrB,OAAO,EAEN,sBAAsB,GAGtB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAEN,mBAAmB,IAAI,qBAAqB,GAE5C,MAAM,yCAAyC,CAAC","sourcesContent":["/**\n * A tool for enforcing repository policies and standards across codebases.\n *\n * @remarks\n * Repopo provides a framework for defining and enforcing policies across repositories,\n * such as file headers, package.json consistency, and other code standards.\n * It can be used as a CLI tool or integrated into CI/CD pipelines.\n *\n * @packageDocumentation\n */\n\nexport { run } from \"@oclif/core\";\nexport {\n\ttype FluidAdapterOptions,\n\ttype FluidHandler,\n\tfromFluidHandlers,\n} from \"./adapters/fluidFramework.js\";\nexport type {\n\t// PolicyList,\n\tRepopoConfig,\n} from \"./config.js\";\nexport {\n\tmakePolicy,\n\tmakePolicyDefinition,\n\ttype PolicyDefinitionInput,\n\ttype PolicyOptions,\n\tpolicy,\n} from \"./makePolicy.js\";\nexport {\n\ttype ConfiguredPolicy,\n\t// Type guards\n\tisPolicyError,\n\tisPolicyFailure,\n\tisPolicyFixResult,\n\t// New types\n\tPolicy,\n\ttype PolicyArgs,\n\t// Legacy types (for backward compatibility)\n\ttype PolicyDefinition,\n\ttype PolicyError,\n\ttype PolicyFailure,\n\ttype PolicyFixResult,\n\ttype PolicyFunctionArguments,\n\ttype PolicyHandler,\n\ttype PolicyHandlerResult,\n\ttype PolicyInstance,\n\ttype PolicyInstanceSettings,\n\ttype PolicyName,\n\ttype PolicyResolver,\n\ttype PolicyResult,\n\ttype PolicyShape,\n\ttype PolicyStandaloneResolver,\n} from \"./policy.js\";\nexport {\n\ttype DefineFileHeaderPolicyArgs,\n\tdefineFileHeaderPolicy,\n\ttype FileHeaderGeneratorConfig,\n\ttype FileHeaderPolicyConfig,\n} from \"./policyDefiners/defineFileHeaderPolicy.js\";\nexport {\n\ttype DefinePackagePolicyArgs,\n\tdefinePackagePolicy as generatePackagePolicy,\n\ttype PackageJsonHandler,\n} from \"./policyDefiners/definePackagePolicy.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,cAAc,UAAU,CAAC","sourcesContent":["/**\n * Repository policy authoring, execution, and CLI entry point.\n *\n * Import `repopo/api` for the programmatic API without the CLI entry point.\n *\n * @packageDocumentation\n */\n\nexport { run } from \"@oclif/core\";\nexport * from \"./api.js\";\n"]}
@@ -1,80 +1,27 @@
1
- import type { ConfiguredPolicy, PolicyDefinition, PolicyInstance, PolicyInstanceSettings, PolicyShape } from "./policy.js";
2
- /**
3
- * Options for configuring a policy instance.
4
- *
5
- * @alpha
6
- */
7
- export interface PolicyOptions {
8
- /**
9
- * File paths matching these patterns will be excluded from this policy.
10
- * Patterns are matched against repo-relative paths.
11
- */
12
- exclude?: (string | RegExp)[];
13
- }
14
- /**
15
- * Configure a policy for use in repopo.
16
- *
17
- * @remarks
18
- * This function takes a policy definition and returns a configured policy instance
19
- * that can be added to the `policies` array in `repopo.config.ts`.
20
- *
21
- * Handlers are automatically normalized: async functions are wrapped for Effection
22
- * compatibility, while generator functions are used directly.
23
- *
24
- * @example
25
- * ```typescript
26
- * // Policy with no config, just options
27
- * policy(NoJsFileExtensions, { exclude: ["bin/*"] })
28
- *
29
- * // Policy with config
30
- * policy(PackageJsonProperties, { verbatim: { license: "MIT" } })
31
- *
32
- * // Policy with config and options
33
- * policy(PackageJsonProperties, { verbatim: { license: "MIT" } }, { exclude: ["vendor/*"] })
34
- * ```
35
- *
36
- * @alpha
37
- */
38
- export declare function policy<C = void>(policyDef: PolicyShape<C>, options?: PolicyOptions): ConfiguredPolicy<C>;
39
- /** @alpha */
40
- export declare function policy<C>(policyDef: PolicyShape<C>, config: C, options?: PolicyOptions): ConfiguredPolicy<C>;
41
- /**
42
- * Input arguments for creating a policy definition.
43
- *
44
- * @deprecated Use {@link PolicyShape} directly instead.
45
- *
46
- * @alpha
47
- */
48
- export type PolicyDefinitionInput<C = undefined> = PolicyDefinition<C>;
49
- /**
50
- * Creates a {@link PolicyDefinition} from the provided arguments.
51
- *
52
- * @deprecated Define policies as object literals satisfying {@link PolicyShape} instead.
53
- *
54
- * @example
55
- * ```typescript
56
- * const MyPolicy = makePolicyDefinition({
57
- * name: "MyPolicy",
58
- * description: "Ensures files follow conventions",
59
- * match: /\.ts$/,
60
- * handler: async ({ file }) => true,
61
- * });
62
- * ```
63
- *
64
- * @alpha
65
- */
66
- export declare function makePolicyDefinition<C = undefined>(args: PolicyDefinitionInput<C>): PolicyDefinition<C>;
67
- /**
68
- * Combine a {@link PolicyDefinition} with a policy-specific config and other settings.
69
- *
70
- * @deprecated Use the `policy` function instead, which has a simpler API.
71
- *
72
- * @example
73
- * ```typescript
74
- * makePolicy(NoJsFileExtensions, undefined, { excludeFiles: ["bin/*"] })
75
- * ```
76
- *
77
- * @alpha
78
- */
79
- export declare function makePolicy<C>(definition: PolicyDefinition<C>, config?: C, settings?: PolicyInstanceSettings<C>): PolicyInstance<C>;
1
+ import type { ConfiguredFilePolicy, ConfiguredPolicy, ConfiguredRepositoryPolicy, DefinedConfig, FilePolicyDefinition, PolicyDefinition, PolicyInstanceId, PolicyName, PolicyOptions, RepositoryPolicyDefinition } from "./policy.js";
2
+ type ConfigOf<D> = D extends PolicyDefinition<infer C> ? C : never;
3
+ type RequiredConfigDefinitions<D> = D extends {
4
+ requiresConfig: true;
5
+ } ? D extends {
6
+ defaultConfig: infer Default;
7
+ } ? undefined extends Default ? D : never : D : never;
8
+ type OptionsFor<D> = [RequiredConfigDefinitions<D>] extends [never] ? [options?: PolicyOptions<ConfigOf<D>>] : [
9
+ options: PolicyOptions<ConfigOf<D>> & {
10
+ config: DefinedConfig<ConfigOf<RequiredConfigDefinitions<D>>>;
11
+ }
12
+ ];
13
+ /** Configure a file definition using a single options object. @public */
14
+ export declare function makePolicy<D extends FilePolicyDefinition<unknown>>(definition: D, ...options: OptionsFor<D>): ConfiguredFilePolicy<ConfigOf<D>>;
15
+ /** Configure a repository definition using a single options object. @public */
16
+ export declare function makePolicy<D extends RepositoryPolicyDefinition<unknown>>(definition: D, ...options: OptionsFor<D>): ConfiguredRepositoryPolicy<ConfigOf<D>>;
17
+ /** Configure a common-union definition without losing scope discrimination. @public */
18
+ export declare function makePolicy<D extends PolicyDefinition<unknown>>(definition: D, ...options: OptionsFor<D>): ConfiguredPolicy<ConfigOf<D>>;
19
+ /** Assign stable IDs, rejecting ambiguous duplicates. @internal */
20
+ export declare function identifyPolicyInstances<T extends {
21
+ name: PolicyName;
22
+ instanceId?: PolicyInstanceId | undefined;
23
+ }>(policies: readonly T[]): (T & {
24
+ instanceId: PolicyInstanceId;
25
+ })[];
26
+ export {};
80
27
  //# sourceMappingURL=makePolicy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"makePolicy.d.ts","sourceRoot":"","sources":["../src/makePolicy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACX,gBAAgB,EAEhB,gBAAgB,EAGhB,cAAc,EACd,sBAAsB,EACtB,WAAW,EACX,MAAM,aAAa,CAAC;AAMrB;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC7B;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;CAC9B;AAuBD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,MAAM,CAAC,CAAC,GAAG,IAAI,EAC9B,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC,EACzB,OAAO,CAAC,EAAE,aAAa,GACrB,gBAAgB,CAAC,CAAC,CAAC,CAAC;AACvB,aAAa;AACb,wBAAgB,MAAM,CAAC,CAAC,EACvB,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC,EACzB,MAAM,EAAE,CAAC,EACT,OAAO,CAAC,EAAE,aAAa,GACrB,gBAAgB,CAAC,CAAC,CAAC,CAAC;AAoDvB;;;;;;GAMG;AACH,MAAM,MAAM,qBAAqB,CAAC,CAAC,GAAG,SAAS,IAAI,gBAAgB,CAAC,CAAC,CAAC,CAAC;AAEvE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,GAAG,SAAS,EACjD,IAAI,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAC5B,gBAAgB,CAAC,CAAC,CAAC,CASrB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAC3B,UAAU,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAC/B,MAAM,CAAC,EAAE,CAAC,EACV,QAAQ,CAAC,EAAE,sBAAsB,CAAC,CAAC,CAAC,GAClC,cAAc,CAAC,CAAC,CAAC,CAMnB"}
1
+ {"version":3,"file":"makePolicy.d.ts","sourceRoot":"","sources":["../src/makePolicy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,oBAAoB,EACpB,gBAAgB,EAChB,0BAA0B,EAC1B,aAAa,EACb,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,0BAA0B,EAC1B,MAAM,aAAa,CAAC;AAErB,KAAK,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,gBAAgB,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AACnE,KAAK,yBAAyB,CAAC,CAAC,IAAI,CAAC,SAAS;IAAE,cAAc,EAAE,IAAI,CAAA;CAAE,GACnE,CAAC,SAAS;IAAE,aAAa,EAAE,MAAM,OAAO,CAAA;CAAE,GACzC,SAAS,SAAS,OAAO,GACxB,CAAC,GACD,KAAK,GACN,CAAC,GACF,KAAK,CAAC;AACT,KAAK,UAAU,CAAC,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAChE,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,GACtC;IACA,OAAO,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG;QACrC,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KAC9D;CACD,CAAC;AAEJ,yEAAyE;AACzE,wBAAgB,UAAU,CAAC,CAAC,SAAS,oBAAoB,CAAC,OAAO,CAAC,EACjE,UAAU,EAAE,CAAC,EACb,GAAG,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,GACvB,oBAAoB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AACrC,+EAA+E;AAC/E,wBAAgB,UAAU,CAAC,CAAC,SAAS,0BAA0B,CAAC,OAAO,CAAC,EACvE,UAAU,EAAE,CAAC,EACb,GAAG,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,GACvB,0BAA0B,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3C,uFAAuF;AACvF,wBAAgB,UAAU,CAAC,CAAC,SAAS,gBAAgB,CAAC,OAAO,CAAC,EAC7D,UAAU,EAAE,CAAC,EACb,GAAG,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,GACvB,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AAqDjC,mEAAmE;AACnE,wBAAgB,uBAAuB,CACtC,CAAC,SAAS;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,UAAU,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAA;CAAE,EACxE,QAAQ,EAAE,SAAS,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG;IAAE,UAAU,EAAE,gBAAgB,CAAA;CAAE,CAAC,EAAE,CA6BlE"}