repopo 0.9.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (271) hide show
  1. package/CHANGELOG.md +81 -0
  2. package/README.md +41 -2
  3. package/THIRD-PARTY-LICENSES.txt +71 -11
  4. package/bin/dev.js +5 -1
  5. package/esm/baseCommand.d.ts +1 -1
  6. package/esm/baseCommand.d.ts.map +1 -1
  7. package/esm/baseCommand.js +6 -9
  8. package/esm/baseCommand.js.map +1 -1
  9. package/esm/commands/check-native.d.ts +25 -0
  10. package/esm/commands/check-native.d.ts.map +1 -0
  11. package/esm/commands/check-native.js +137 -0
  12. package/esm/commands/check-native.js.map +1 -0
  13. package/esm/commands/check.d.ts +8 -19
  14. package/esm/commands/check.d.ts.map +1 -1
  15. package/esm/commands/check.js +97 -169
  16. package/esm/commands/check.js.map +1 -1
  17. package/esm/commands/list.d.ts.map +1 -1
  18. package/esm/commands/list.js +5 -6
  19. package/esm/commands/list.js.map +1 -1
  20. package/esm/config.d.ts +19 -4
  21. package/esm/config.d.ts.map +1 -1
  22. package/esm/config.js +2 -3
  23. package/esm/config.js.map +1 -1
  24. package/esm/context.d.ts +13 -3
  25. package/esm/context.d.ts.map +1 -1
  26. package/esm/context.js +11 -1
  27. package/esm/context.js.map +1 -1
  28. package/esm/index.d.ts +7 -2
  29. package/esm/index.d.ts.map +1 -1
  30. package/esm/index.js +9 -1
  31. package/esm/index.js.map +1 -1
  32. package/esm/makePolicy.d.ts +77 -8
  33. package/esm/makePolicy.d.ts.map +1 -1
  34. package/esm/makePolicy.js +108 -4
  35. package/esm/makePolicy.js.map +1 -1
  36. package/esm/perf.d.ts +7 -2
  37. package/esm/perf.d.ts.map +1 -1
  38. package/esm/perf.js.map +1 -1
  39. package/esm/policies/CargoLicenceValidated.d.ts +41 -0
  40. package/esm/policies/CargoLicenceValidated.d.ts.map +1 -0
  41. package/esm/policies/CargoLicenceValidated.js +45 -0
  42. package/esm/policies/CargoLicenceValidated.js.map +1 -0
  43. package/esm/policies/CargoLintsConfigured.d.ts +30 -0
  44. package/esm/policies/CargoLintsConfigured.d.ts.map +1 -0
  45. package/esm/policies/CargoLintsConfigured.js +61 -0
  46. package/esm/policies/CargoLintsConfigured.js.map +1 -0
  47. package/esm/policies/CargoLockPolicy.d.ts +34 -0
  48. package/esm/policies/CargoLockPolicy.d.ts.map +1 -0
  49. package/esm/policies/CargoLockPolicy.js +57 -0
  50. package/esm/policies/CargoLockPolicy.js.map +1 -0
  51. package/esm/policies/CargoTomlRequired.d.ts +34 -0
  52. package/esm/policies/CargoTomlRequired.d.ts.map +1 -0
  53. package/esm/policies/CargoTomlRequired.js +77 -0
  54. package/esm/policies/CargoTomlRequired.js.map +1 -0
  55. package/esm/policies/CargoTomlSorted.d.ts +20 -0
  56. package/esm/policies/CargoTomlSorted.d.ts.map +1 -0
  57. package/esm/policies/CargoTomlSorted.js +164 -0
  58. package/esm/policies/CargoTomlSorted.js.map +1 -0
  59. package/esm/policies/ConditionalScripts.d.ts +94 -0
  60. package/esm/policies/ConditionalScripts.d.ts.map +1 -0
  61. package/esm/policies/ConditionalScripts.js +145 -0
  62. package/esm/policies/ConditionalScripts.js.map +1 -0
  63. package/esm/policies/ExactScripts.d.ts +51 -0
  64. package/esm/policies/ExactScripts.d.ts.map +1 -0
  65. package/esm/policies/ExactScripts.js +108 -0
  66. package/esm/policies/ExactScripts.js.map +1 -0
  67. package/esm/policies/GleamDepVersions.d.ts +25 -0
  68. package/esm/policies/GleamDepVersions.d.ts.map +1 -0
  69. package/esm/policies/GleamDepVersions.js +67 -0
  70. package/esm/policies/GleamDepVersions.js.map +1 -0
  71. package/esm/policies/GleamDocExists.d.ts +24 -0
  72. package/esm/policies/GleamDocExists.d.ts.map +1 -0
  73. package/esm/policies/GleamDocExists.js +39 -0
  74. package/esm/policies/GleamDocExists.js.map +1 -0
  75. package/esm/policies/GleamInternalModulesConfigured.d.ts +21 -0
  76. package/esm/policies/GleamInternalModulesConfigured.d.ts.map +1 -0
  77. package/esm/policies/GleamInternalModulesConfigured.js +30 -0
  78. package/esm/policies/GleamInternalModulesConfigured.js.map +1 -0
  79. package/esm/policies/GleamLicenceConfigured.d.ts +29 -0
  80. package/esm/policies/GleamLicenceConfigured.d.ts.map +1 -0
  81. package/esm/policies/GleamLicenceConfigured.js +34 -0
  82. package/esm/policies/GleamLicenceConfigured.js.map +1 -0
  83. package/esm/policies/GleamManifestCommitted.d.ts +9 -0
  84. package/esm/policies/GleamManifestCommitted.d.ts.map +1 -0
  85. package/esm/policies/GleamManifestCommitted.js +26 -0
  86. package/esm/policies/GleamManifestCommitted.js.map +1 -0
  87. package/esm/policies/GleamMonorepoConsistency.d.ts +30 -0
  88. package/esm/policies/GleamMonorepoConsistency.d.ts.map +1 -0
  89. package/esm/policies/GleamMonorepoConsistency.js +74 -0
  90. package/esm/policies/GleamMonorepoConsistency.js.map +1 -0
  91. package/esm/policies/GleamNameRestrictions.d.ts +25 -0
  92. package/esm/policies/GleamNameRestrictions.d.ts.map +1 -0
  93. package/esm/policies/GleamNameRestrictions.js +44 -0
  94. package/esm/policies/GleamNameRestrictions.js.map +1 -0
  95. package/esm/policies/GleamNoPathDepsInPublished.d.ts +22 -0
  96. package/esm/policies/GleamNoPathDepsInPublished.d.ts.map +1 -0
  97. package/esm/policies/GleamNoPathDepsInPublished.js +43 -0
  98. package/esm/policies/GleamNoPathDepsInPublished.js.map +1 -0
  99. package/esm/policies/GleamPathDepsValid.d.ts +9 -0
  100. package/esm/policies/GleamPathDepsValid.d.ts.map +1 -0
  101. package/esm/policies/GleamPathDepsValid.js +59 -0
  102. package/esm/policies/GleamPathDepsValid.js.map +1 -0
  103. package/esm/policies/GleamProjectStructure.d.ts +25 -0
  104. package/esm/policies/GleamProjectStructure.d.ts.map +1 -0
  105. package/esm/policies/GleamProjectStructure.js +33 -0
  106. package/esm/policies/GleamProjectStructure.js.map +1 -0
  107. package/esm/policies/GleamSharedDependencyVersions.d.ts +29 -0
  108. package/esm/policies/GleamSharedDependencyVersions.d.ts.map +1 -0
  109. package/esm/policies/GleamSharedDependencyVersions.js +101 -0
  110. package/esm/policies/GleamSharedDependencyVersions.js.map +1 -0
  111. package/esm/policies/GleamTomlRequired.d.ts +30 -0
  112. package/esm/policies/GleamTomlRequired.d.ts.map +1 -0
  113. package/esm/policies/GleamTomlRequired.js +37 -0
  114. package/esm/policies/GleamTomlRequired.js.map +1 -0
  115. package/esm/policies/GleamTomlSorted.d.ts +20 -0
  116. package/esm/policies/GleamTomlSorted.d.ts.map +1 -0
  117. package/esm/policies/GleamTomlSorted.js +153 -0
  118. package/esm/policies/GleamTomlSorted.js.map +1 -0
  119. package/esm/policies/GleamVersionConstraint.d.ts +20 -0
  120. package/esm/policies/GleamVersionConstraint.d.ts.map +1 -0
  121. package/esm/policies/GleamVersionConstraint.js +64 -0
  122. package/esm/policies/GleamVersionConstraint.js.map +1 -0
  123. package/esm/policies/HtmlFileHeaders.d.ts +1 -1
  124. package/esm/policies/HtmlFileHeaders.d.ts.map +1 -1
  125. package/esm/policies/HtmlFileHeaders.js +1 -1
  126. package/esm/policies/HtmlFileHeaders.js.map +1 -1
  127. package/esm/policies/JsTsFileHeaders.d.ts +1 -1
  128. package/esm/policies/JsTsFileHeaders.d.ts.map +1 -1
  129. package/esm/policies/MutuallyExclusiveScripts.d.ts +46 -0
  130. package/esm/policies/MutuallyExclusiveScripts.d.ts.map +1 -0
  131. package/esm/policies/MutuallyExclusiveScripts.js +52 -0
  132. package/esm/policies/MutuallyExclusiveScripts.js.map +1 -0
  133. package/esm/policies/NoBuildDirectory.d.ts +9 -0
  134. package/esm/policies/NoBuildDirectory.d.ts.map +1 -0
  135. package/esm/policies/NoBuildDirectory.js +29 -0
  136. package/esm/policies/NoBuildDirectory.js.map +1 -0
  137. package/esm/policies/NoPrivateWorkspaceDependencies.d.ts +1 -1
  138. package/esm/policies/NoPrivateWorkspaceDependencies.d.ts.map +1 -1
  139. package/esm/policies/NoTargetArtifacts.d.ts +8 -0
  140. package/esm/policies/NoTargetArtifacts.d.ts.map +1 -0
  141. package/esm/policies/NoTargetArtifacts.js +42 -0
  142. package/esm/policies/NoTargetArtifacts.js.map +1 -0
  143. package/esm/policies/NoUnsafeWithoutJustification.d.ts +24 -0
  144. package/esm/policies/NoUnsafeWithoutJustification.d.ts.map +1 -0
  145. package/esm/policies/NoUnsafeWithoutJustification.js +80 -0
  146. package/esm/policies/NoUnsafeWithoutJustification.js.map +1 -0
  147. package/esm/policies/NoWildcardDependencies.d.ts +30 -0
  148. package/esm/policies/NoWildcardDependencies.d.ts.map +1 -0
  149. package/esm/policies/NoWildcardDependencies.js +83 -0
  150. package/esm/policies/NoWildcardDependencies.js.map +1 -0
  151. package/esm/policies/PackageAllowedScopes.d.ts +1 -1
  152. package/esm/policies/PackageAllowedScopes.d.ts.map +1 -1
  153. package/esm/policies/PackageEsmType.d.ts +1 -1
  154. package/esm/policies/PackageEsmType.d.ts.map +1 -1
  155. package/esm/policies/PackageEsmType.js +7 -5
  156. package/esm/policies/PackageEsmType.js.map +1 -1
  157. package/esm/policies/PackageFolderName.d.ts +1 -1
  158. package/esm/policies/PackageFolderName.d.ts.map +1 -1
  159. package/esm/policies/PackageJsonProperties.d.ts +1 -1
  160. package/esm/policies/PackageJsonProperties.d.ts.map +1 -1
  161. package/esm/policies/PackageJsonProperties.js +12 -4
  162. package/esm/policies/PackageJsonProperties.js.map +1 -1
  163. package/esm/policies/PackageJsonRepoDirectoryProperty.d.ts +1 -1
  164. package/esm/policies/PackageJsonRepoDirectoryProperty.d.ts.map +1 -1
  165. package/esm/policies/PackageJsonRepoDirectoryProperty.js +3 -2
  166. package/esm/policies/PackageJsonRepoDirectoryProperty.js.map +1 -1
  167. package/esm/policies/PackageJsonSorted.d.ts +1 -1
  168. package/esm/policies/PackageJsonSorted.d.ts.map +1 -1
  169. package/esm/policies/PackageJsonSorted.js +42 -7
  170. package/esm/policies/PackageJsonSorted.js.map +1 -1
  171. package/esm/policies/PackageLicense.d.ts +1 -1
  172. package/esm/policies/PackageLicense.d.ts.map +1 -1
  173. package/esm/policies/PackageLicense.js +1 -2
  174. package/esm/policies/PackageLicense.js.map +1 -1
  175. package/esm/policies/PackagePrivateField.d.ts +1 -1
  176. package/esm/policies/PackagePrivateField.d.ts.map +1 -1
  177. package/esm/policies/PackagePrivateField.js +3 -2
  178. package/esm/policies/PackagePrivateField.js.map +1 -1
  179. package/esm/policies/PackageReadme.d.ts +1 -1
  180. package/esm/policies/PackageReadme.d.ts.map +1 -1
  181. package/esm/policies/PackageReadme.js +2 -2
  182. package/esm/policies/PackageReadme.js.map +1 -1
  183. package/esm/policies/PackageScripts.d.ts +1 -1
  184. package/esm/policies/PackageScripts.d.ts.map +1 -1
  185. package/esm/policies/PackageScripts.js +3 -2
  186. package/esm/policies/PackageScripts.js.map +1 -1
  187. package/esm/policies/PackageTestScripts.d.ts +1 -1
  188. package/esm/policies/PackageTestScripts.d.ts.map +1 -1
  189. package/esm/policies/PackageTestScripts.js +3 -3
  190. package/esm/policies/PackageTestScripts.js.map +1 -1
  191. package/esm/policies/PublicApiDocumented.d.ts +21 -0
  192. package/esm/policies/PublicApiDocumented.d.ts.map +1 -0
  193. package/esm/policies/PublicApiDocumented.js +36 -0
  194. package/esm/policies/PublicApiDocumented.js.map +1 -0
  195. package/esm/policies/RequiredScripts.d.ts +71 -0
  196. package/esm/policies/RequiredScripts.d.ts.map +1 -0
  197. package/esm/policies/RequiredScripts.js +121 -0
  198. package/esm/policies/RequiredScripts.js.map +1 -0
  199. package/esm/policies/RustDocExists.d.ts +24 -0
  200. package/esm/policies/RustDocExists.d.ts.map +1 -0
  201. package/esm/policies/RustDocExists.js +49 -0
  202. package/esm/policies/RustDocExists.js.map +1 -0
  203. package/esm/policies/RustToolchainExists.d.ts +20 -0
  204. package/esm/policies/RustToolchainExists.d.ts.map +1 -0
  205. package/esm/policies/RustToolchainExists.js +27 -0
  206. package/esm/policies/RustToolchainExists.js.map +1 -0
  207. package/esm/policies/RustfmtConfigExists.d.ts +20 -0
  208. package/esm/policies/RustfmtConfigExists.d.ts.map +1 -0
  209. package/esm/policies/RustfmtConfigExists.js +27 -0
  210. package/esm/policies/RustfmtConfigExists.js.map +1 -0
  211. package/esm/policies/ScriptContains.d.ts +64 -0
  212. package/esm/policies/ScriptContains.d.ts.map +1 -0
  213. package/esm/policies/ScriptContains.js +62 -0
  214. package/esm/policies/ScriptContains.js.map +1 -0
  215. package/esm/policies/SharedDependencyVersions.d.ts +24 -0
  216. package/esm/policies/SharedDependencyVersions.d.ts.map +1 -0
  217. package/esm/policies/SharedDependencyVersions.js +135 -0
  218. package/esm/policies/SharedDependencyVersions.js.map +1 -0
  219. package/esm/policies/WorkspaceInheritance.d.ts +24 -0
  220. package/esm/policies/WorkspaceInheritance.d.ts.map +1 -0
  221. package/esm/policies/WorkspaceInheritance.js +94 -0
  222. package/esm/policies/WorkspaceInheritance.js.map +1 -0
  223. package/esm/policies/WorkspaceMembersValid.d.ts +20 -0
  224. package/esm/policies/WorkspaceMembersValid.d.ts.map +1 -0
  225. package/esm/policies/WorkspaceMembersValid.js +88 -0
  226. package/esm/policies/WorkspaceMembersValid.js.map +1 -0
  227. package/esm/policies/constants.d.ts +8 -0
  228. package/esm/policies/constants.d.ts.map +1 -1
  229. package/esm/policies/constants.js +8 -0
  230. package/esm/policies/constants.js.map +1 -1
  231. package/esm/policies.d.ts +36 -1
  232. package/esm/policies.d.ts.map +1 -1
  233. package/esm/policies.js +68 -0
  234. package/esm/policies.js.map +1 -1
  235. package/esm/policy.d.ts +202 -84
  236. package/esm/policy.d.ts.map +1 -1
  237. package/esm/policy.js +103 -21
  238. package/esm/policy.js.map +1 -1
  239. package/esm/policyDefiners/defineCargoPolicy.d.ts +66 -0
  240. package/esm/policyDefiners/defineCargoPolicy.d.ts.map +1 -0
  241. package/esm/policyDefiners/defineCargoPolicy.js +60 -0
  242. package/esm/policyDefiners/defineCargoPolicy.js.map +1 -0
  243. package/esm/policyDefiners/defineFileHeaderPolicy.d.ts +7 -2
  244. package/esm/policyDefiners/defineFileHeaderPolicy.d.ts.map +1 -1
  245. package/esm/policyDefiners/defineFileHeaderPolicy.js +11 -7
  246. package/esm/policyDefiners/defineFileHeaderPolicy.js.map +1 -1
  247. package/esm/policyDefiners/defineGleamPolicy.d.ts +65 -0
  248. package/esm/policyDefiners/defineGleamPolicy.d.ts.map +1 -0
  249. package/esm/policyDefiners/defineGleamPolicy.js +59 -0
  250. package/esm/policyDefiners/defineGleamPolicy.js.map +1 -0
  251. package/esm/policyDefiners/definePackagePolicy.d.ts +18 -5
  252. package/esm/policyDefiners/definePackagePolicy.d.ts.map +1 -1
  253. package/esm/policyDefiners/definePackagePolicy.js +14 -4
  254. package/esm/policyDefiners/definePackagePolicy.js.map +1 -1
  255. package/esm/policyDefiners/spdxValidator.d.ts +74 -0
  256. package/esm/policyDefiners/spdxValidator.d.ts.map +1 -0
  257. package/esm/policyDefiners/spdxValidator.js +127 -0
  258. package/esm/policyDefiners/spdxValidator.js.map +1 -0
  259. package/esm/policyDefiners/tomlParser.d.ts +8 -0
  260. package/esm/policyDefiners/tomlParser.d.ts.map +1 -0
  261. package/esm/policyDefiners/tomlParser.js +17 -0
  262. package/esm/policyDefiners/tomlParser.js.map +1 -0
  263. package/esm/runner.d.ts +60 -0
  264. package/esm/runner.d.ts.map +1 -0
  265. package/esm/runner.js +174 -0
  266. package/esm/runner.js.map +1 -0
  267. package/esm/tsdoc-metadata.json +1 -1
  268. package/oclif.manifest.json +100 -3
  269. package/package.json +46 -31
  270. package/scripts/postinstall.mjs +154 -0
  271. package/sidecar/sidecar.mjs +468 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConditionalScripts.js","sourceRoot":"","sources":["../../src/policies/ConditionalScripts.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,OAAO,CAAC;AAE/C,OAAO,EAA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from \"pathe\";\nimport type { PackageJson } from \"type-fest\";\nimport { definePackagePolicy } from \"../policyDefiners/definePackagePolicy.js\";\n\n/**\n * A required script entry for conditional requirements. Can be either:\n * - A string (script name only, no default value)\n * - An object with a single key-value pair (script name → default value for auto-fix)\n *\n * @example\n * ```typescript\n * // Script must exist, no auto-fix available\n * \"test\"\n *\n * // Script must exist, auto-fix will add this value if missing\n * { clean: \"rimraf dist\" }\n * ```\n *\n * @alpha\n */\nexport type ConditionalScriptEntry = string | Record<string, string>;\n\n/**\n * Configuration for a conditional script requirement.\n *\n * @alpha\n */\nexport interface ConditionalScriptRule {\n\t/**\n\t * The script that triggers the requirement.\n\t * If this script exists, then `requires` must also exist.\n\t */\n\tifPresent: string;\n\n\t/**\n\t * Scripts that must be present if `ifPresent` script exists.\n\t *\n\t * @remarks\n\t * Each entry can be:\n\t * - A string: Script must exist, no auto-fix available\n\t * - An object `{ scriptName: \"default value\" }`: Script must exist, auto-fix adds the\n\t * default value if missing\n\t *\n\t * @example\n\t * ```typescript\n\t * requires: [\"test\", { clean: \"rimraf dist\" }]\n\t * ```\n\t */\n\trequires: ConditionalScriptEntry[];\n}\n\n/**\n * Configuration for the ConditionalScripts policy.\n *\n * @alpha\n */\nexport interface ConditionalScriptsConfig {\n\t/**\n\t * Conditional script requirements. If a script is present, other scripts must also exist.\n\t *\n\t * @remarks\n\t * This is useful for enforcing that packages with a \"build\" script also have a \"clean\" script,\n\t * or packages with \"test\" also have \"test:coverage\".\n\t *\n\t * @example\n\t * ```typescript\n\t * rules: [\n\t * { ifPresent: \"build\", requires: [{ clean: \"rimraf dist\" }] },\n\t * { ifPresent: \"test\", requires: [\"test:coverage\"] },\n\t * ]\n\t * ```\n\t */\n\trules: ConditionalScriptRule[];\n}\n\nconst POLICY_NAME = \"ConditionalScripts\";\n\ninterface ParsedEntry {\n\tname: string;\n\tdefaultValue?: string;\n}\n\n/**\n * Extracts script name and optional default value from a ConditionalScriptEntry.\n */\nfunction parseEntry(entry: ConditionalScriptEntry): ParsedEntry {\n\tif (typeof entry === \"string\") {\n\t\treturn { name: entry };\n\t}\n\tconst keys = Object.keys(entry);\n\tif (keys.length !== 1) {\n\t\tthrow new Error(\n\t\t\t`Invalid conditional script entry: expected single key-value pair, got ${keys.length} keys`,\n\t\t);\n\t}\n\t// biome-ignore lint/style/noNonNullAssertion: we verified length is 1\n\tconst name = keys[0]!;\n\tconst defaultValue = entry[name];\n\treturn defaultValue !== undefined ? { name, defaultValue } : { name };\n}\n\ninterface RuleViolation {\n\ttriggerScript: string;\n\tmissingScripts: string[];\n}\n\ninterface ValidationResult {\n\tviolations: RuleViolation[];\n\tmissingWithDefaults: Array<{ name: string; defaultValue: string }>;\n}\n\nfunction validateConditionalRules(\n\tscripts: Record<string, string | undefined>,\n\trules: ConditionalScriptRule[],\n): ValidationResult {\n\tconst violations: RuleViolation[] = [];\n\tconst missingWithDefaults: Array<{ name: string; defaultValue: string }> = [];\n\tconst seenMissing = new Set<string>();\n\n\tfor (const rule of rules) {\n\t\t// Skip if the triggering script doesn't exist\n\t\tif (!Object.hasOwn(scripts, rule.ifPresent)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst missingScripts: string[] = [];\n\t\tfor (const entry of rule.requires) {\n\t\t\tconst { name, defaultValue } = parseEntry(entry);\n\t\t\tif (!Object.hasOwn(scripts, name)) {\n\t\t\t\tmissingScripts.push(name);\n\t\t\t\tif (defaultValue !== undefined && !seenMissing.has(name)) {\n\t\t\t\t\tmissingWithDefaults.push({ name, defaultValue });\n\t\t\t\t\tseenMissing.add(name);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (missingScripts.length > 0) {\n\t\t\tviolations.push({\n\t\t\t\ttriggerScript: rule.ifPresent,\n\t\t\t\tmissingScripts,\n\t\t\t});\n\t\t}\n\t}\n\n\treturn { violations, missingWithDefaults };\n}\n\nfunction formatViolationErrors(violations: RuleViolation[]): string[] {\n\treturn violations.map(\n\t\t(v) =>\n\t\t\t`Script \"${v.triggerScript}\" is present, but required companion script(s) missing: ${v.missingScripts.join(\", \")}`,\n\t);\n}\n\nasync function fixMissingScripts(\n\tjson: PackageJson,\n\tfile: string,\n\tmissingWithDefaults: Array<{ name: string; defaultValue: string }>,\n\texistingScripts: Record<string, string | undefined>,\n): Promise<string[]> {\n\tconst updatedScripts: Record<string, string> = {};\n\n\t// Copy existing scripts\n\tfor (const [key, value] of Object.entries(existingScripts)) {\n\t\tif (value !== undefined) {\n\t\t\tupdatedScripts[key] = value;\n\t\t}\n\t}\n\n\t// Add missing scripts with defaults\n\tconst fixedScripts: string[] = [];\n\tfor (const { name, defaultValue } of missingWithDefaults) {\n\t\tupdatedScripts[name] = defaultValue;\n\t\tfixedScripts.push(name);\n\t}\n\n\tawait jsonfile.writeFile(\n\t\tfile,\n\t\t{ ...json, scripts: updatedScripts },\n\t\t{ spaces: 2 },\n\t);\n\n\treturn fixedScripts;\n}\n\n/**\n * A policy that validates conditional script requirements in package.json.\n *\n * @remarks\n * Use this policy when you want to enforce that the presence of one script\n * requires other scripts to also exist. For example, if \"build\" exists,\n * then \"clean\" must also exist.\n *\n * @example\n * ```typescript\n * import { policy } from \"repopo\";\n * import { ConditionalScripts } from \"repopo/policies\";\n *\n * policy(ConditionalScripts, {\n * rules: [\n * // If \"build\" exists, \"clean\" must also exist (with auto-fix default)\n * { ifPresent: \"build\", requires: [{ clean: \"rimraf dist\" }] },\n * // If \"test\" exists, \"test:coverage\" must also exist (no auto-fix)\n * { ifPresent: \"test\", requires: [\"test:coverage\"] },\n * ],\n * })\n * ```\n *\n * @alpha\n */\nexport const ConditionalScripts = definePackagePolicy<\n\tPackageJson,\n\tConditionalScriptsConfig | undefined\n>({\n\tname: POLICY_NAME,\n\tdescription:\n\t\t\"Validates that if certain scripts exist, other required scripts must also exist.\",\n\thandler: async (json, { file, root, resolve, config }) => {\n\t\tif (config === undefined || config.rules.length === 0) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst scripts = json.scripts ?? {};\n\t\tconst validation = validateConditionalRules(scripts, config.rules);\n\n\t\tif (validation.violations.length === 0) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst errors = formatViolationErrors(validation.violations);\n\t\tconst hasAutoFixableErrors = validation.missingWithDefaults.length > 0;\n\n\t\tif (resolve && hasAutoFixableErrors) {\n\t\t\ttry {\n\t\t\t\tconst fixedScripts = await fixMissingScripts(\n\t\t\t\t\tjson,\n\t\t\t\t\tresolvePath(root, file),\n\t\t\t\t\tvalidation.missingWithDefaults,\n\t\t\t\t\tscripts,\n\t\t\t\t);\n\n\t\t\t\t// Re-validate after fix to check for remaining errors\n\t\t\t\tconst updatedScripts = { ...scripts };\n\t\t\t\tfor (const name of fixedScripts) {\n\t\t\t\t\tconst entry = validation.missingWithDefaults.find(\n\t\t\t\t\t\t(m) => m.name === name,\n\t\t\t\t\t);\n\t\t\t\t\tif (entry) {\n\t\t\t\t\t\tupdatedScripts[name] = entry.defaultValue;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst revalidation = validateConditionalRules(\n\t\t\t\t\tupdatedScripts,\n\t\t\t\t\tconfig.rules,\n\t\t\t\t);\n\t\t\t\tconst remainingErrors = formatViolationErrors(revalidation.violations);\n\n\t\t\t\treturn {\n\t\t\t\t\tname: POLICY_NAME,\n\t\t\t\t\tfile,\n\t\t\t\t\tresolved: remainingErrors.length === 0,\n\t\t\t\t\terrorMessages:\n\t\t\t\t\t\tremainingErrors.length > 0\n\t\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t\t`Fixed scripts: ${fixedScripts.join(\", \")}. Remaining errors:\\n${remainingErrors.join(\"\\n\")}`,\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t: [`Fixed scripts: ${fixedScripts.join(\", \")}`],\n\t\t\t\t};\n\t\t\t} catch {\n\t\t\t\t// Fall through to return regular failure\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tname: POLICY_NAME,\n\t\t\tfile,\n\t\t\tautoFixable: hasAutoFixableErrors,\n\t\t\terrorMessages: errors,\n\t\t};\n\t},\n});\n"]}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Configuration for the ExactScripts policy.
3
+ *
4
+ * @alpha
5
+ */
6
+ export interface ExactScriptsConfig {
7
+ /**
8
+ * Scripts that must exist AND have exact content.
9
+ *
10
+ * @remarks
11
+ * Unlike RequiredScripts, scripts in `exact` are validated against
12
+ * the specified value. If a script exists but has different content, it fails validation.
13
+ * Both missing and mismatched scripts are auto-fixable.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * scripts: {
18
+ * clean: "rimraf dist esm",
19
+ * format: "biome format --write .",
20
+ * }
21
+ * ```
22
+ */
23
+ scripts: Record<string, string>;
24
+ }
25
+ /**
26
+ * A policy that validates scripts exist AND have exact content in package.json.
27
+ *
28
+ * @remarks
29
+ * Use this policy when you want to enforce exact script content, not just presence.
30
+ * This is useful for scripts that must be exactly the same across packages.
31
+ *
32
+ * For scripts where you only care about presence (not content), use RequiredScripts instead.
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * import { policy } from "repopo";
37
+ * import { ExactScripts } from "repopo/policies";
38
+ *
39
+ * policy(ExactScripts, {
40
+ * scripts: {
41
+ * clean: "rimraf dist esm",
42
+ * format: "biome format --write .",
43
+ * lint: "biome lint .",
44
+ * },
45
+ * })
46
+ * ```
47
+ *
48
+ * @alpha
49
+ */
50
+ export declare const ExactScripts: import("../policy.js").PolicyShape<ExactScriptsConfig | undefined>;
51
+ //# sourceMappingURL=ExactScripts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExactScripts.d.ts","sourceRoot":"","sources":["../../src/policies/ExactScripts.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAClC;;;;;;;;;;;;;;;OAeG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC;AAuED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,YAAY,oEAqDvB,CAAC"}
@@ -0,0 +1,108 @@
1
+ import jsonfile from "jsonfile";
2
+ import { resolve as resolvePath } from "pathe";
3
+ import { definePackagePolicy } from "../policyDefiners/definePackagePolicy.js";
4
+ const POLICY_NAME = "ExactScripts";
5
+ function validateScripts(scripts, expectedScripts) {
6
+ const errors = [];
7
+ const missingScripts = [];
8
+ const mismatchedScripts = [];
9
+ for (const [scriptName, expectedValue] of Object.entries(expectedScripts)) {
10
+ if (Object.hasOwn(scripts, scriptName)) {
11
+ const actualValue = scripts[scriptName];
12
+ if (actualValue !== expectedValue) {
13
+ mismatchedScripts.push(scriptName);
14
+ errors.push(`Script "${scriptName}" must be "${expectedValue}", but found "${actualValue}"`);
15
+ }
16
+ }
17
+ else {
18
+ missingScripts.push(scriptName);
19
+ errors.push(`Missing required script: ${scriptName}`);
20
+ }
21
+ }
22
+ return { errors, missingScripts, mismatchedScripts };
23
+ }
24
+ async function fixScripts(json, file, scriptsToFix, expectedScripts, existingScripts) {
25
+ const updatedScripts = {};
26
+ // Copy existing scripts
27
+ for (const [key, value] of Object.entries(existingScripts)) {
28
+ if (value !== undefined) {
29
+ updatedScripts[key] = value;
30
+ }
31
+ }
32
+ // Add/update scripts
33
+ const fixedScripts = [];
34
+ for (const scriptName of scriptsToFix) {
35
+ const expectedValue = expectedScripts[scriptName];
36
+ if (expectedValue !== undefined) {
37
+ updatedScripts[scriptName] = expectedValue;
38
+ fixedScripts.push(scriptName);
39
+ }
40
+ }
41
+ await jsonfile.writeFile(file, { ...json, scripts: updatedScripts }, { spaces: 2 });
42
+ return fixedScripts;
43
+ }
44
+ /**
45
+ * A policy that validates scripts exist AND have exact content in package.json.
46
+ *
47
+ * @remarks
48
+ * Use this policy when you want to enforce exact script content, not just presence.
49
+ * This is useful for scripts that must be exactly the same across packages.
50
+ *
51
+ * For scripts where you only care about presence (not content), use RequiredScripts instead.
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * import { policy } from "repopo";
56
+ * import { ExactScripts } from "repopo/policies";
57
+ *
58
+ * policy(ExactScripts, {
59
+ * scripts: {
60
+ * clean: "rimraf dist esm",
61
+ * format: "biome format --write .",
62
+ * lint: "biome lint .",
63
+ * },
64
+ * })
65
+ * ```
66
+ *
67
+ * @alpha
68
+ */
69
+ export const ExactScripts = definePackagePolicy({
70
+ name: POLICY_NAME,
71
+ description: "Validates that scripts exist and have exact content in package.json.",
72
+ handler: async (json, { file, root, resolve, config }) => {
73
+ if (config === undefined || Object.keys(config.scripts).length === 0) {
74
+ return true;
75
+ }
76
+ const scripts = json.scripts ?? {};
77
+ const validation = validateScripts(scripts, config.scripts);
78
+ if (validation.errors.length === 0) {
79
+ return true;
80
+ }
81
+ const scriptsToFix = [
82
+ ...validation.missingScripts,
83
+ ...validation.mismatchedScripts,
84
+ ];
85
+ const hasAutoFixableErrors = scriptsToFix.length > 0;
86
+ if (resolve && hasAutoFixableErrors) {
87
+ try {
88
+ const fixedScripts = await fixScripts(json, resolvePath(root, file), scriptsToFix, config.scripts, scripts);
89
+ return {
90
+ name: POLICY_NAME,
91
+ file,
92
+ resolved: true,
93
+ errorMessages: [`Fixed scripts: ${fixedScripts.join(", ")}`],
94
+ };
95
+ }
96
+ catch {
97
+ // Fall through to return regular failure
98
+ }
99
+ }
100
+ return {
101
+ name: POLICY_NAME,
102
+ file,
103
+ autoFixable: hasAutoFixableErrors,
104
+ errorMessages: validation.errors,
105
+ };
106
+ },
107
+ });
108
+ //# sourceMappingURL=ExactScripts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExactScripts.js","sourceRoot":"","sources":["../../src/policies/ExactScripts.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,OAAO,CAAC;AAE/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AA2B/E,MAAM,WAAW,GAAG,cAAc,CAAC;AAQnC,SAAS,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I,OAAO,IAAI,oBAAoB,EAAE,CAAC;YACrC,IAAI,CAAC;gBACJ,MAAM,YAAY,GAAG,MAAM,UAAU,CACpC,IAAI,EACJ,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,EACvB,YAAY,EACZ,MAAM,CAAC,OAAO,EACd,OAAO,CACP,CAAC;gBAEF,OAAO;oBACN,IAAI,EAAE,WAAW;oBACjB,IAAI;oBACJ,QAAQ,EAAE,IAAI;oBACd,aAAa,EAAE,CAAC,kBAAkB,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;iBAC5D,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACR,yCAAyC;YAC1C,CAAC;QACF,CAAC;QAED,OAAO;YACN,IAAI,EAAE,WAAW;YACjB,IAAI;YACJ,WAAW,EAAE,oBAAoB;YACjC,aAAa,EAAE,UAAU,CAAC,MAAM;SAChC,CAAC;IACH,CAAC;CACD,CAAC,CAAC","sourcesContent":["import jsonfile from \"jsonfile\";\nimport { resolve as resolvePath } from \"pathe\";\nimport type { PackageJson } from \"type-fest\";\nimport { definePackagePolicy } from \"../policyDefiners/definePackagePolicy.js\";\n\n/**\n * Configuration for the ExactScripts policy.\n *\n * @alpha\n */\nexport interface ExactScriptsConfig {\n\t/**\n\t * Scripts that must exist AND have exact content.\n\t *\n\t * @remarks\n\t * Unlike RequiredScripts, scripts in `exact` are validated against\n\t * the specified value. If a script exists but has different content, it fails validation.\n\t * Both missing and mismatched scripts are auto-fixable.\n\t *\n\t * @example\n\t * ```typescript\n\t * scripts: {\n\t * clean: \"rimraf dist esm\",\n\t * format: \"biome format --write .\",\n\t * }\n\t * ```\n\t */\n\tscripts: Record<string, string>;\n}\n\nconst POLICY_NAME = \"ExactScripts\";\n\ninterface ValidationResult {\n\terrors: string[];\n\tmissingScripts: string[];\n\tmismatchedScripts: string[];\n}\n\nfunction validateScripts(\n\tscripts: Record<string, string | undefined>,\n\texpectedScripts: Record<string, string>,\n): ValidationResult {\n\tconst errors: string[] = [];\n\tconst missingScripts: string[] = [];\n\tconst mismatchedScripts: string[] = [];\n\n\tfor (const [scriptName, expectedValue] of Object.entries(expectedScripts)) {\n\t\tif (Object.hasOwn(scripts, scriptName)) {\n\t\t\tconst actualValue = scripts[scriptName];\n\t\t\tif (actualValue !== expectedValue) {\n\t\t\t\tmismatchedScripts.push(scriptName);\n\t\t\t\terrors.push(\n\t\t\t\t\t`Script \"${scriptName}\" must be \"${expectedValue}\", but found \"${actualValue}\"`,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tmissingScripts.push(scriptName);\n\t\t\terrors.push(`Missing required script: ${scriptName}`);\n\t\t}\n\t}\n\n\treturn { errors, missingScripts, mismatchedScripts };\n}\n\nasync function fixScripts(\n\tjson: PackageJson,\n\tfile: string,\n\tscriptsToFix: string[],\n\texpectedScripts: Record<string, string>,\n\texistingScripts: Record<string, string | undefined>,\n): Promise<string[]> {\n\tconst updatedScripts: Record<string, string> = {};\n\n\t// Copy existing scripts\n\tfor (const [key, value] of Object.entries(existingScripts)) {\n\t\tif (value !== undefined) {\n\t\t\tupdatedScripts[key] = value;\n\t\t}\n\t}\n\n\t// Add/update scripts\n\tconst fixedScripts: string[] = [];\n\tfor (const scriptName of scriptsToFix) {\n\t\tconst expectedValue = expectedScripts[scriptName];\n\t\tif (expectedValue !== undefined) {\n\t\t\tupdatedScripts[scriptName] = expectedValue;\n\t\t\tfixedScripts.push(scriptName);\n\t\t}\n\t}\n\n\tawait jsonfile.writeFile(\n\t\tfile,\n\t\t{ ...json, scripts: updatedScripts },\n\t\t{ spaces: 2 },\n\t);\n\n\treturn fixedScripts;\n}\n\n/**\n * A policy that validates scripts exist AND have exact content in package.json.\n *\n * @remarks\n * Use this policy when you want to enforce exact script content, not just presence.\n * This is useful for scripts that must be exactly the same across packages.\n *\n * For scripts where you only care about presence (not content), use RequiredScripts instead.\n *\n * @example\n * ```typescript\n * import { policy } from \"repopo\";\n * import { ExactScripts } from \"repopo/policies\";\n *\n * policy(ExactScripts, {\n * scripts: {\n * clean: \"rimraf dist esm\",\n * format: \"biome format --write .\",\n * lint: \"biome lint .\",\n * },\n * })\n * ```\n *\n * @alpha\n */\nexport const ExactScripts = definePackagePolicy<\n\tPackageJson,\n\tExactScriptsConfig | undefined\n>({\n\tname: POLICY_NAME,\n\tdescription:\n\t\t\"Validates that scripts exist and have exact content in package.json.\",\n\thandler: async (json, { file, root, resolve, config }) => {\n\t\tif (config === undefined || Object.keys(config.scripts).length === 0) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst scripts = json.scripts ?? {};\n\t\tconst validation = validateScripts(scripts, config.scripts);\n\n\t\tif (validation.errors.length === 0) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst scriptsToFix = [\n\t\t\t...validation.missingScripts,\n\t\t\t...validation.mismatchedScripts,\n\t\t];\n\t\tconst hasAutoFixableErrors = scriptsToFix.length > 0;\n\n\t\tif (resolve && hasAutoFixableErrors) {\n\t\t\ttry {\n\t\t\t\tconst fixedScripts = await fixScripts(\n\t\t\t\t\tjson,\n\t\t\t\t\tresolvePath(root, file),\n\t\t\t\t\tscriptsToFix,\n\t\t\t\t\tconfig.scripts,\n\t\t\t\t\tscripts,\n\t\t\t\t);\n\n\t\t\t\treturn {\n\t\t\t\t\tname: POLICY_NAME,\n\t\t\t\t\tfile,\n\t\t\t\t\tresolved: true,\n\t\t\t\t\terrorMessages: [`Fixed scripts: ${fixedScripts.join(\", \")}`],\n\t\t\t\t};\n\t\t\t} catch {\n\t\t\t\t// Fall through to return regular failure\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tname: POLICY_NAME,\n\t\t\tfile,\n\t\t\tautoFixable: hasAutoFixableErrors,\n\t\t\terrorMessages: validation.errors,\n\t\t};\n\t},\n});\n"]}
@@ -0,0 +1,25 @@
1
+ import type { PolicyShape } from "../policy.js";
2
+ /**
3
+ * Configuration for the GleamDepVersions policy.
4
+ *
5
+ * @alpha
6
+ */
7
+ export interface GleamDepVersionsConfig {
8
+ /**
9
+ * If true, require all dependencies to have version constraints.
10
+ * @defaultValue true
11
+ */
12
+ requireVersions?: boolean;
13
+ /**
14
+ * If true, warn on unbounded version ranges (e.g., ">= 1.0.0" without upper bound).
15
+ * @defaultValue false
16
+ */
17
+ warnUnbounded?: boolean;
18
+ }
19
+ /**
20
+ * A policy that prevents missing or overly loose version constraints in Gleam dependencies.
21
+ *
22
+ * @alpha
23
+ */
24
+ export declare const GleamDepVersions: PolicyShape<GleamDepVersionsConfig>;
25
+ //# sourceMappingURL=GleamDepVersions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GleamDepVersions.d.ts","sourceRoot":"","sources":["../../src/policies/GleamDepVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAMhD;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACtC;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACxB;AAkDD;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC,sBAAsB,CAsC9D,CAAC"}
@@ -0,0 +1,67 @@
1
+ import { defineGleamPolicy, } from "../policyDefiners/defineGleamPolicy.js";
2
+ function extractVersion(dep) {
3
+ if (typeof dep === "string") {
4
+ return dep;
5
+ }
6
+ if (typeof dep === "object" && dep !== null) {
7
+ const record = dep;
8
+ if (typeof record.version === "string") {
9
+ return record.version;
10
+ }
11
+ // Path-only dependencies don't need version checks
12
+ if (typeof record.path === "string") {
13
+ return undefined;
14
+ }
15
+ }
16
+ return undefined;
17
+ }
18
+ function checkSection(sectionName, deps, requireVersions, warnUnbounded) {
19
+ const errors = [];
20
+ for (const [name, value] of Object.entries(deps)) {
21
+ const version = extractVersion(value);
22
+ if (requireVersions && version === undefined) {
23
+ // Skip path dependencies
24
+ if (typeof value === "object" &&
25
+ value !== null &&
26
+ typeof value.path === "string") {
27
+ continue;
28
+ }
29
+ errors.push(`[${sectionName}] "${name}" has no version constraint`);
30
+ }
31
+ if (warnUnbounded && version !== undefined && version.startsWith(">=")) {
32
+ errors.push(`[${sectionName}] "${name}" = "${version}" uses an unbounded version range`);
33
+ }
34
+ }
35
+ return errors;
36
+ }
37
+ /**
38
+ * A policy that prevents missing or overly loose version constraints in Gleam dependencies.
39
+ *
40
+ * @alpha
41
+ */
42
+ export const GleamDepVersions = defineGleamPolicy({
43
+ name: "GleamDepVersions",
44
+ description: "Prevents missing or overly loose version constraints in gleam.toml dependencies.",
45
+ handler: async (toml, { config }) => {
46
+ const requireVersions = config?.requireVersions ?? true;
47
+ const warnUnbounded = config?.warnUnbounded ?? false;
48
+ const errors = [];
49
+ const sections = [
50
+ { name: "dependencies", data: toml.dependencies },
51
+ { name: "dev-dependencies", data: toml["dev-dependencies"] },
52
+ ];
53
+ for (const { name, data } of sections) {
54
+ if (data && typeof data === "object") {
55
+ errors.push(...checkSection(name, data, requireVersions, warnUnbounded));
56
+ }
57
+ }
58
+ if (errors.length > 0) {
59
+ return {
60
+ error: errors.join("; "),
61
+ manualFix: 'Add specific version constraints (e.g., ">= 1.0.0 and < 2.0.0") to all dependencies.',
62
+ };
63
+ }
64
+ return true;
65
+ },
66
+ });
67
+ //# sourceMappingURL=GleamDepVersions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GleamDepVersions.js","sourceRoot":"","sources":["../../src/policies/GleamDepVersions.ts"],"names":[],"mappings":"AACA,OAAO,EACN,iBAAiB,GAEjB,MAAM,wCAAwC,CAAC;AAqBhD,SAAS,cAAc,CAAC,GAAY;IACnC,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAO,GAAG,CAAC;IACZ,CAAC;IACD,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QAC7C,MAAM,MAAM,GAAG,GAA8B,CAAC;QAC9C,IAAI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EAAE,EAAE,EAAE;QAC9C,MAAM,eAAe,GAAG,MAAM,EAAE,eAAe,IAAI,IAAI,CAAC;QACxD,MAAM,aAAa,GAAG,MAAM,EAAE,aAAa,IAAI,KAAK,CAAC;QACrD,MAAM,MAAM,GAAa,EAAE,CAAC;QAE5B,MAAM,QAAQ,GAAG;YAChB,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE;YACjD,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,IAAI,CAAC,kBAAkB,CAAC,EAAE;SAC5D,CAAC;QAEF,KAAK,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,QAAQ,EAAE,CAAC;YACvC,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACtC,MAAM,CAAC,IAAI,CACV,GAAG,YAAY,CACd,IAAI,EACJ,IAA+B,EAC/B,eAAe,EACf,aAAa,CACb,CACD,CAAC;YACH,CAAC;QACF,CAAC;QAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,OAAO;gBACN,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;gBACxB,SAAS,EACR,sFAAsF;aACvF,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC;CACD,CAAC,CAAC","sourcesContent":["import type { PolicyShape } from \"../policy.js\";\nimport {\n\tdefineGleamPolicy,\n\ttype GleamToml,\n} from \"../policyDefiners/defineGleamPolicy.js\";\n\n/**\n * Configuration for the GleamDepVersions policy.\n *\n * @alpha\n */\nexport interface GleamDepVersionsConfig {\n\t/**\n\t * If true, require all dependencies to have version constraints.\n\t * @defaultValue true\n\t */\n\trequireVersions?: boolean;\n\n\t/**\n\t * If true, warn on unbounded version ranges (e.g., \">= 1.0.0\" without upper bound).\n\t * @defaultValue false\n\t */\n\twarnUnbounded?: boolean;\n}\n\nfunction extractVersion(dep: unknown): string | undefined {\n\tif (typeof dep === \"string\") {\n\t\treturn dep;\n\t}\n\tif (typeof dep === \"object\" && dep !== null) {\n\t\tconst record = dep as Record<string, unknown>;\n\t\tif (typeof record.version === \"string\") {\n\t\t\treturn record.version;\n\t\t}\n\t\t// Path-only dependencies don't need version checks\n\t\tif (typeof record.path === \"string\") {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\treturn undefined;\n}\n\nfunction checkSection(\n\tsectionName: string,\n\tdeps: Record<string, unknown>,\n\trequireVersions: boolean,\n\twarnUnbounded: boolean,\n): string[] {\n\tconst errors: string[] = [];\n\tfor (const [name, value] of Object.entries(deps)) {\n\t\tconst version = extractVersion(value);\n\n\t\tif (requireVersions && version === undefined) {\n\t\t\t// Skip path dependencies\n\t\t\tif (\n\t\t\t\ttypeof value === \"object\" &&\n\t\t\t\tvalue !== null &&\n\t\t\t\ttypeof (value as Record<string, unknown>).path === \"string\"\n\t\t\t) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\terrors.push(`[${sectionName}] \"${name}\" has no version constraint`);\n\t\t}\n\n\t\tif (warnUnbounded && version !== undefined && version.startsWith(\">=\")) {\n\t\t\terrors.push(\n\t\t\t\t`[${sectionName}] \"${name}\" = \"${version}\" uses an unbounded version range`,\n\t\t\t);\n\t\t}\n\t}\n\treturn errors;\n}\n\n/**\n * A policy that prevents missing or overly loose version constraints in Gleam dependencies.\n *\n * @alpha\n */\nexport const GleamDepVersions: PolicyShape<GleamDepVersionsConfig> =\n\tdefineGleamPolicy({\n\t\tname: \"GleamDepVersions\",\n\t\tdescription:\n\t\t\t\"Prevents missing or overly loose version constraints in gleam.toml dependencies.\",\n\t\thandler: async (toml: GleamToml, { config }) => {\n\t\t\tconst requireVersions = config?.requireVersions ?? true;\n\t\t\tconst warnUnbounded = config?.warnUnbounded ?? false;\n\t\t\tconst errors: string[] = [];\n\n\t\t\tconst sections = [\n\t\t\t\t{ name: \"dependencies\", data: toml.dependencies },\n\t\t\t\t{ name: \"dev-dependencies\", data: toml[\"dev-dependencies\"] },\n\t\t\t];\n\n\t\t\tfor (const { name, data } of sections) {\n\t\t\t\tif (data && typeof data === \"object\") {\n\t\t\t\t\terrors.push(\n\t\t\t\t\t\t...checkSection(\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\tdata as Record<string, unknown>,\n\t\t\t\t\t\t\trequireVersions,\n\t\t\t\t\t\t\twarnUnbounded,\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (errors.length > 0) {\n\t\t\t\treturn {\n\t\t\t\t\terror: errors.join(\"; \"),\n\t\t\t\t\tmanualFix:\n\t\t\t\t\t\t'Add specific version constraints (e.g., \">= 1.0.0 and < 2.0.0\") to all dependencies.',\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn true;\n\t\t},\n\t});\n"]}
@@ -0,0 +1,24 @@
1
+ import type { PolicyShape } from "../policy.js";
2
+ /**
3
+ * Configuration for the GleamDocExists policy.
4
+ *
5
+ * @alpha
6
+ */
7
+ export interface GleamDocExistsConfig {
8
+ /**
9
+ * Files that must exist alongside the gleam.toml.
10
+ * @defaultValue ["README.md"]
11
+ */
12
+ required?: string[];
13
+ /**
14
+ * Files that are recommended but not required. Missing ones produce warnings.
15
+ */
16
+ recommended?: string[];
17
+ }
18
+ /**
19
+ * A policy that validates documentation files exist for Gleam packages.
20
+ *
21
+ * @alpha
22
+ */
23
+ export declare const GleamDocExists: PolicyShape<GleamDocExistsConfig>;
24
+ //# sourceMappingURL=GleamDocExists.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GleamDocExists.d.ts","sourceRoot":"","sources":["../../src/policies/GleamDocExists.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAMhD;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACpC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IAEpB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAID;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,WAAW,CAAC,oBAAoB,CA4C1D,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { existsSync } from "node:fs";
2
+ import path from "pathe";
3
+ import { defineGleamPolicy, } from "../policyDefiners/defineGleamPolicy.js";
4
+ const DEFAULT_REQUIRED = ["README.md"];
5
+ /**
6
+ * A policy that validates documentation files exist for Gleam packages.
7
+ *
8
+ * @alpha
9
+ */
10
+ export const GleamDocExists = defineGleamPolicy({
11
+ name: "GleamDocExists",
12
+ description: "Validates that documentation files (README.md, etc.) exist for Gleam packages.",
13
+ handler: async (toml, { file, root, config }) => {
14
+ // Skip if the package looks like it's not for publishing
15
+ if (!(toml.description || toml.licences)) {
16
+ return true;
17
+ }
18
+ const dir = path.dirname(path.resolve(root, file));
19
+ const required = config?.required ?? DEFAULT_REQUIRED;
20
+ const recommended = config?.recommended ?? [];
21
+ const errors = [];
22
+ const missingRequired = required.filter((f) => !existsSync(path.join(dir, f)));
23
+ const missingRecommended = recommended.filter((f) => !existsSync(path.join(dir, f)));
24
+ if (missingRequired.length > 0) {
25
+ errors.push(`Missing required documentation: ${missingRequired.join(", ")}`);
26
+ }
27
+ if (missingRecommended.length > 0) {
28
+ errors.push(`Missing recommended documentation: ${missingRecommended.join(", ")}`);
29
+ }
30
+ if (errors.length > 0) {
31
+ return {
32
+ error: errors.join("; "),
33
+ manualFix: "Create the missing documentation files alongside gleam.toml.",
34
+ };
35
+ }
36
+ return true;
37
+ },
38
+ });
39
+ //# sourceMappingURL=GleamDocExists.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GleamDocExists.js","sourceRoot":"","sources":["../../src/policies/GleamDocExists.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,IAAI,MAAM,OAAO,CAAC;AAEzB,OAAO,EACN,iBAAiB,GAEjB,MAA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C;YACnC,MAAM,CAAC,IAAI,CACV,sCAAsC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACrE,CAAC;QACH,CAAC;QAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,OAAO;gBACN,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;gBACxB,SAAS,EACR,8DAA8D;aAC/D,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC;CACD,CAAC,CAAC","sourcesContent":["import { existsSync } from \"node:fs\";\nimport path from \"pathe\";\nimport type { PolicyShape } from \"../policy.js\";\nimport {\n\tdefineGleamPolicy,\n\ttype GleamToml,\n} from \"../policyDefiners/defineGleamPolicy.js\";\n\n/**\n * Configuration for the GleamDocExists policy.\n *\n * @alpha\n */\nexport interface GleamDocExistsConfig {\n\t/**\n\t * Files that must exist alongside the gleam.toml.\n\t * @defaultValue [\"README.md\"]\n\t */\n\trequired?: string[];\n\n\t/**\n\t * Files that are recommended but not required. Missing ones produce warnings.\n\t */\n\trecommended?: string[];\n}\n\nconst DEFAULT_REQUIRED = [\"README.md\"];\n\n/**\n * A policy that validates documentation files exist for Gleam packages.\n *\n * @alpha\n */\nexport const GleamDocExists: PolicyShape<GleamDocExistsConfig> =\n\tdefineGleamPolicy({\n\t\tname: \"GleamDocExists\",\n\t\tdescription:\n\t\t\t\"Validates that documentation files (README.md, etc.) exist for Gleam packages.\",\n\t\thandler: async (toml: GleamToml, { file, root, config }) => {\n\t\t\t// Skip if the package looks like it's not for publishing\n\t\t\tif (!(toml.description || toml.licences)) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tconst dir = path.dirname(path.resolve(root, file));\n\t\t\tconst required = config?.required ?? DEFAULT_REQUIRED;\n\t\t\tconst recommended = config?.recommended ?? [];\n\t\t\tconst errors: string[] = [];\n\n\t\t\tconst missingRequired = required.filter(\n\t\t\t\t(f) => !existsSync(path.join(dir, f)),\n\t\t\t);\n\t\t\tconst missingRecommended = recommended.filter(\n\t\t\t\t(f) => !existsSync(path.join(dir, f)),\n\t\t\t);\n\n\t\t\tif (missingRequired.length > 0) {\n\t\t\t\terrors.push(\n\t\t\t\t\t`Missing required documentation: ${missingRequired.join(\", \")}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (missingRecommended.length > 0) {\n\t\t\t\terrors.push(\n\t\t\t\t\t`Missing recommended documentation: ${missingRecommended.join(\", \")}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (errors.length > 0) {\n\t\t\t\treturn {\n\t\t\t\t\terror: errors.join(\"; \"),\n\t\t\t\t\tmanualFix:\n\t\t\t\t\t\t\"Create the missing documentation files alongside gleam.toml.\",\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn true;\n\t\t},\n\t});\n"]}
@@ -0,0 +1,21 @@
1
+ import type { PolicyShape } from "../policy.js";
2
+ /**
3
+ * Configuration for the GleamInternalModulesConfigured policy.
4
+ *
5
+ * @alpha
6
+ */
7
+ export interface GleamInternalModulesConfiguredConfig {
8
+ /**
9
+ * If true, suggest common internal_modules patterns when the field is missing.
10
+ * @defaultValue true
11
+ */
12
+ suggestPatterns?: boolean;
13
+ }
14
+ /**
15
+ * A policy that ensures `internal_modules` is configured in gleam.toml
16
+ * to hide implementation details from generated documentation.
17
+ *
18
+ * @alpha
19
+ */
20
+ export declare const GleamInternalModulesConfigured: PolicyShape<GleamInternalModulesConfiguredConfig>;
21
+ //# sourceMappingURL=GleamInternalModulesConfigured.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GleamInternalModulesConfigured.d.ts","sourceRoot":"","sources":["../../src/policies/GleamInternalModulesConfigured.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAMhD;;;;GAIG;AACH,MAAM,WAAW,oCAAoC;IACpD;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;;;;GAKG;AACH,eAAO,MAAM,8BAA8B,EAAE,WAAW,CAAC,oCAAoC,CA+B1F,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { defineGleamPolicy, } from "../policyDefiners/defineGleamPolicy.js";
2
+ /**
3
+ * A policy that ensures `internal_modules` is configured in gleam.toml
4
+ * to hide implementation details from generated documentation.
5
+ *
6
+ * @alpha
7
+ */
8
+ export const GleamInternalModulesConfigured = defineGleamPolicy({
9
+ name: "GleamInternalModulesConfigured",
10
+ description: "Ensures internal_modules is configured in gleam.toml to hide implementation details from docs.",
11
+ handler: async (toml, { config }) => {
12
+ const internalModules = toml.internal_modules;
13
+ if (internalModules !== undefined &&
14
+ Array.isArray(internalModules) &&
15
+ internalModules.length > 0) {
16
+ return true;
17
+ }
18
+ const name = toml.name;
19
+ const suggestPatterns = config?.suggestPatterns ?? true;
20
+ let manualFix = "Add an internal_modules field to gleam.toml to hide implementation details from docs.";
21
+ if (suggestPatterns && name) {
22
+ manualFix = `Add to gleam.toml:\ninternal_modules = ["${name}/internal", "${name}/internal/*"]`;
23
+ }
24
+ return {
25
+ error: "Missing internal_modules configuration in gleam.toml. Published packages should hide internal modules from documentation.",
26
+ manualFix,
27
+ };
28
+ },
29
+ });
30
+ //# sourceMappingURL=GleamInternalModulesConfigured.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GleamInternalModulesConfigured.js","sourceRoot":"","sources":["../../src/policies/GleamInternalModulesConfigured.ts"],"names":[],"mappings":"AACA,OAAO,EACN,iBAAiB,GAEjB,MAAM,wCAAwC,CAAC;AAehD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAC1C,iBAAiB,CAAC;IACjB,IAAI,EAAE,gCAAgC;IACtC,WAAW,EACV,gGAAgG;IACjG,OAAO,EAAE,KAAK,EAAE,IAAe,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;QAC9C,MAAM,eAAe,GAAG,IAAI,CAAC,gBAAwC,CAAC;QAEtE,IACC,eAAe,KAAK,SAAS;YAC7B,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC;YAC9B,eAAe,CAAC,MAAM,GAAG,CAAC,EACzB,CAAC;YACF,OAAO,IAAI,CAAC;QACb,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,IAA0B,CAAC;QAC7C,MAAM,eAAe,GAAG,MAAM,EAAE,eAAe,IAAI,IAAI,CAAC;QAExD,IAAI,SAAS,GACZ,uFAAuF,CAAC;QACzF,IAAI,eAAe,IAAI,IAAI,EAAE,CAAC;YAC7B,SAAS,GAAG,4CAA4C,IAAI,gBAAgB,IAAI,eAAe,CAAC;QACjG,CAAC;QAED,OAAO;YACN,KAAK,EACJ,2HAA2H;YAC5H,SAAS;SACT,CAAC;IACH,CAAC;CACD,CAAC,CAAC","sourcesContent":["import type { PolicyShape } from \"../policy.js\";\nimport {\n\tdefineGleamPolicy,\n\ttype GleamToml,\n} from \"../policyDefiners/defineGleamPolicy.js\";\n\n/**\n * Configuration for the GleamInternalModulesConfigured policy.\n *\n * @alpha\n */\nexport interface GleamInternalModulesConfiguredConfig {\n\t/**\n\t * If true, suggest common internal_modules patterns when the field is missing.\n\t * @defaultValue true\n\t */\n\tsuggestPatterns?: boolean;\n}\n\n/**\n * A policy that ensures `internal_modules` is configured in gleam.toml\n * to hide implementation details from generated documentation.\n *\n * @alpha\n */\nexport const GleamInternalModulesConfigured: PolicyShape<GleamInternalModulesConfiguredConfig> =\n\tdefineGleamPolicy({\n\t\tname: \"GleamInternalModulesConfigured\",\n\t\tdescription:\n\t\t\t\"Ensures internal_modules is configured in gleam.toml to hide implementation details from docs.\",\n\t\thandler: async (toml: GleamToml, { config }) => {\n\t\t\tconst internalModules = toml.internal_modules as string[] | undefined;\n\n\t\t\tif (\n\t\t\t\tinternalModules !== undefined &&\n\t\t\t\tArray.isArray(internalModules) &&\n\t\t\t\tinternalModules.length > 0\n\t\t\t) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tconst name = toml.name as string | undefined;\n\t\t\tconst suggestPatterns = config?.suggestPatterns ?? true;\n\n\t\t\tlet manualFix =\n\t\t\t\t\"Add an internal_modules field to gleam.toml to hide implementation details from docs.\";\n\t\t\tif (suggestPatterns && name) {\n\t\t\t\tmanualFix = `Add to gleam.toml:\\ninternal_modules = [\"${name}/internal\", \"${name}/internal/*\"]`;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\terror:\n\t\t\t\t\t\"Missing internal_modules configuration in gleam.toml. Published packages should hide internal modules from documentation.\",\n\t\t\t\tmanualFix,\n\t\t\t};\n\t\t},\n\t});\n"]}
@@ -0,0 +1,29 @@
1
+ import type { PolicyShape } from "../policy.js";
2
+ /**
3
+ * Configuration for the GleamLicenceConfigured policy.
4
+ *
5
+ * @alpha
6
+ */
7
+ export interface GleamLicenceConfiguredConfig {
8
+ /**
9
+ * Allowed SPDX licence identifiers. If set, only these are accepted.
10
+ */
11
+ allowedLicences?: string[];
12
+ /**
13
+ * If true, validate licence values against the SPDX licence list
14
+ * using `spdx-correct`. When enabled, typos like "MIIT" are detected
15
+ * and can be auto-fixed to the correct identifier ("MIT").
16
+ *
17
+ * Requires the optional peer dependency `spdx-correct` to be installed.
18
+ *
19
+ * @defaultValue false
20
+ */
21
+ validateSpdx?: boolean;
22
+ }
23
+ /**
24
+ * A policy that ensures licence metadata is properly configured in gleam.toml.
25
+ *
26
+ * @alpha
27
+ */
28
+ export declare const GleamLicenceConfigured: PolicyShape<GleamLicenceConfiguredConfig>;
29
+ //# sourceMappingURL=GleamLicenceConfigured.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GleamLicenceConfigured.d.ts","sourceRoot":"","sources":["../../src/policies/GleamLicenceConfigured.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAOhD;;;;GAIG;AACH,MAAM,WAAW,4BAA4B;IAC5C;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAE3B;;;;;;;;OAQG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACvB;AAKD;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAE,WAAW,CAAC,4BAA4B,CAgC1E,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { resolve } from "pathe";
2
+ import { defineGleamPolicy, } from "../policyDefiners/defineGleamPolicy.js";
3
+ import { validateLicenceField } from "../policyDefiners/spdxValidator.js";
4
+ const MANUAL_FIX = "Use valid SPDX licence identifiers (e.g., MIT, Apache-2.0, MPL-2.0).";
5
+ /**
6
+ * A policy that ensures licence metadata is properly configured in gleam.toml.
7
+ *
8
+ * @alpha
9
+ */
10
+ export const GleamLicenceConfigured = defineGleamPolicy({
11
+ name: "GleamLicenceConfigured",
12
+ description: "Ensures gleam.toml has valid SPDX licence identifiers configured.",
13
+ handler: async (toml, { file, root, resolve: shouldResolve, config }) => {
14
+ const licences = toml.licences;
15
+ if (!Array.isArray(licences) || licences.length === 0) {
16
+ return {
17
+ error: "Missing or empty licences field in gleam.toml.",
18
+ manualFix: 'Add licences = ["MIT"] (or appropriate SPDX identifier) to gleam.toml.',
19
+ };
20
+ }
21
+ const result = await validateLicenceField({
22
+ licences: licences,
23
+ ...(config?.allowedLicences !== undefined && {
24
+ allowedLicences: config.allowedLicences,
25
+ }),
26
+ validateSpdx: config?.validateSpdx ?? false,
27
+ shouldResolve,
28
+ filePath: resolve(root, file),
29
+ manualFixMessage: MANUAL_FIX,
30
+ });
31
+ return result ?? true;
32
+ },
33
+ });
34
+ //# sourceMappingURL=GleamLicenceConfigured.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GleamLicenceConfigured.js","sourceRoot":"","sources":["../../src/policies/GleamLicenceConfigured.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EACN,iBAAiB,GAEjB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAyB1E,MAAM,UAAU,GACf,sEAAsE,CAAC;AAExE;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAClC,iBAAiB,CAAC;IACjB,IAAI,EAAE,wBAAwB;IAC9B,WAAW,EACV,mEAAmE;IACpE,OAAO,EAAE,KAAK,EACb,IAAe,EACf,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,EAC7C,EAAE;QACH,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAE/B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvD,OAAO;gBACN,KAAK,EAAE,gDAAgD;gBACvD,SAAS,EACR,wEAAwE;aACzE,CAAC;QACH,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,oBAAoB,CAAC;YACzC,QAAQ,EAAE,QAAoB;YAC9B,GAAG,CAAC,MAAM,EAAE,eAAe,KAAK,SAAS,IAAI;gBAC5C,eAAe,EAAE,MAAM,CAAC,eAAe;aACvC,CAAC;YACF,YAAY,EAAE,MAAM,EAAE,YAAY,IAAI,KAAK;YAC3C,aAAa;YACb,QAAQ,EAAE,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC;YAC7B,gBAAgB,EAAE,UAAU;SAC5B,CAAC,CAAC;QAEH,OAAO,MAAM,IAAI,IAAI,CAAC;IACvB,CAAC;CACD,CAAC,CAAC","sourcesContent":["import { resolve } from \"pathe\";\nimport type { PolicyShape } from \"../policy.js\";\nimport {\n\tdefineGleamPolicy,\n\ttype GleamToml,\n} from \"../policyDefiners/defineGleamPolicy.js\";\nimport { validateLicenceField } from \"../policyDefiners/spdxValidator.js\";\n\n/**\n * Configuration for the GleamLicenceConfigured policy.\n *\n * @alpha\n */\nexport interface GleamLicenceConfiguredConfig {\n\t/**\n\t * Allowed SPDX licence identifiers. If set, only these are accepted.\n\t */\n\tallowedLicences?: string[];\n\n\t/**\n\t * If true, validate licence values against the SPDX licence list\n\t * using `spdx-correct`. When enabled, typos like \"MIIT\" are detected\n\t * and can be auto-fixed to the correct identifier (\"MIT\").\n\t *\n\t * Requires the optional peer dependency `spdx-correct` to be installed.\n\t *\n\t * @defaultValue false\n\t */\n\tvalidateSpdx?: boolean;\n}\n\nconst MANUAL_FIX =\n\t\"Use valid SPDX licence identifiers (e.g., MIT, Apache-2.0, MPL-2.0).\";\n\n/**\n * A policy that ensures licence metadata is properly configured in gleam.toml.\n *\n * @alpha\n */\nexport const GleamLicenceConfigured: PolicyShape<GleamLicenceConfiguredConfig> =\n\tdefineGleamPolicy({\n\t\tname: \"GleamLicenceConfigured\",\n\t\tdescription:\n\t\t\t\"Ensures gleam.toml has valid SPDX licence identifiers configured.\",\n\t\thandler: async (\n\t\t\ttoml: GleamToml,\n\t\t\t{ file, root, resolve: shouldResolve, config },\n\t\t) => {\n\t\t\tconst licences = toml.licences;\n\n\t\t\tif (!Array.isArray(licences) || licences.length === 0) {\n\t\t\t\treturn {\n\t\t\t\t\terror: \"Missing or empty licences field in gleam.toml.\",\n\t\t\t\t\tmanualFix:\n\t\t\t\t\t\t'Add licences = [\"MIT\"] (or appropriate SPDX identifier) to gleam.toml.',\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst result = await validateLicenceField({\n\t\t\t\tlicences: licences as string[],\n\t\t\t\t...(config?.allowedLicences !== undefined && {\n\t\t\t\t\tallowedLicences: config.allowedLicences,\n\t\t\t\t}),\n\t\t\t\tvalidateSpdx: config?.validateSpdx ?? false,\n\t\t\t\tshouldResolve,\n\t\t\t\tfilePath: resolve(root, file),\n\t\t\t\tmanualFixMessage: MANUAL_FIX,\n\t\t\t});\n\n\t\t\treturn result ?? true;\n\t\t},\n\t});\n"]}
@@ -0,0 +1,9 @@
1
+ import type { PolicyDefinition } from "../policy.js";
2
+ /**
3
+ * A policy that ensures manifest.toml is committed alongside gleam.toml
4
+ * for reproducible Gleam builds.
5
+ *
6
+ * @alpha
7
+ */
8
+ export declare const GleamManifestCommitted: PolicyDefinition;
9
+ //# sourceMappingURL=GleamManifestCommitted.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GleamManifestCommitted.d.ts","sourceRoot":"","sources":["../../src/policies/GleamManifestCommitted.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,EAAE,gBAoBnC,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { existsSync } from "node:fs";
2
+ import path from "pathe";
3
+ import { makePolicyDefinition } from "../makePolicy.js";
4
+ /**
5
+ * A policy that ensures manifest.toml is committed alongside gleam.toml
6
+ * for reproducible Gleam builds.
7
+ *
8
+ * @alpha
9
+ */
10
+ export const GleamManifestCommitted = makePolicyDefinition({
11
+ name: "GleamManifestCommitted",
12
+ description: "Ensures manifest.toml is committed alongside gleam.toml for reproducible builds.",
13
+ match: /gleam\.toml$/,
14
+ handler: async ({ file, root }) => {
15
+ const dir = path.dirname(path.resolve(root, file));
16
+ const manifestPath = path.join(dir, "manifest.toml");
17
+ if (existsSync(manifestPath)) {
18
+ return true;
19
+ }
20
+ return {
21
+ error: "Missing manifest.toml. Gleam projects should commit manifest.toml for reproducible builds.",
22
+ manualFix: "Run `gleam build` to generate manifest.toml, then commit it to source control.",
23
+ };
24
+ },
25
+ });
26
+ //# sourceMappingURL=GleamManifestCommitted.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GleamManifestCommitted.js","sourceRoot":"","sources":["../../src/policies/GleamManifestCommitted.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;AAGxD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAqB,oBAAoB,CAAC;IAC5E,IAAI,EAAE,wBAAwB;IAC9B,WAAW,EACV,kFAAkF;IACnF,KAAK,EAAE,cAAc;IACrB,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE;QACjC,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;QACnD,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;QAErD,IAAI,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;YAC9B,OAAO,IAAI,CAAC;QACb,CAAC;QAED,OAAO;YACN,KAAK,EACJ,4FAA4F;YAC7F,SAAS,EACR,gFAAgF;SACjF,CAAC;IACH,CAAC;CACD,CAAC,CAAC","sourcesContent":["import { existsSync } from \"node:fs\";\nimport path from \"pathe\";\nimport { makePolicyDefinition } from \"../makePolicy.js\";\nimport type { PolicyDefinition } from \"../policy.js\";\n\n/**\n * A policy that ensures manifest.toml is committed alongside gleam.toml\n * for reproducible Gleam builds.\n *\n * @alpha\n */\nexport const GleamManifestCommitted: PolicyDefinition = makePolicyDefinition({\n\tname: \"GleamManifestCommitted\",\n\tdescription:\n\t\t\"Ensures manifest.toml is committed alongside gleam.toml for reproducible builds.\",\n\tmatch: /gleam\\.toml$/,\n\thandler: async ({ file, root }) => {\n\t\tconst dir = path.dirname(path.resolve(root, file));\n\t\tconst manifestPath = path.join(dir, \"manifest.toml\");\n\n\t\tif (existsSync(manifestPath)) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn {\n\t\t\terror:\n\t\t\t\t\"Missing manifest.toml. Gleam projects should commit manifest.toml for reproducible builds.\",\n\t\t\tmanualFix:\n\t\t\t\t\"Run `gleam build` to generate manifest.toml, then commit it to source control.\",\n\t\t};\n\t},\n});\n"]}
@@ -0,0 +1,30 @@
1
+ import type { PolicyDefinition } from "../policy.js";
2
+ /**
3
+ * Configuration for the GleamMonorepoConsistency policy.
4
+ *
5
+ * @alpha
6
+ */
7
+ export interface GleamMonorepoConsistencyConfig {
8
+ /**
9
+ * Top-level fields that should be consistent across all packages.
10
+ * @defaultValue ["licences"]
11
+ */
12
+ syncFields?: string[];
13
+ /**
14
+ * If true, ensure the `gleam` version constraint is consistent.
15
+ * @defaultValue true
16
+ */
17
+ syncGleamVersion?: boolean;
18
+ /**
19
+ * Paths to gleam.toml files to compare (relative to repo root).
20
+ * If not specified, the policy only checks the file it matches against.
21
+ */
22
+ packages?: string[];
23
+ }
24
+ /**
25
+ * A policy that enforces consistent metadata across Gleam packages in a monorepo.
26
+ *
27
+ * @alpha
28
+ */
29
+ export declare const GleamMonorepoConsistency: PolicyDefinition<GleamMonorepoConsistencyConfig>;
30
+ //# sourceMappingURL=GleamMonorepoConsistency.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GleamMonorepoConsistency.d.ts","sourceRoot":"","sources":["../../src/policies/GleamMonorepoConsistency.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGrD;;;;GAIG;AACH,MAAM,WAAW,8BAA8B;IAC9C;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IAEtB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAuCD;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,EAAE,gBAAgB,CAAC,8BAA8B,CA+CnF,CAAC"}