repopo 0.10.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 (229) hide show
  1. package/CHANGELOG.md +60 -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 -20
  14. package/esm/commands/check.d.ts.map +1 -1
  15. package/esm/commands/check.js +77 -186
  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/context.d.ts +13 -3
  21. package/esm/context.d.ts.map +1 -1
  22. package/esm/context.js +11 -1
  23. package/esm/context.js.map +1 -1
  24. package/esm/index.d.ts +6 -1
  25. package/esm/index.d.ts.map +1 -1
  26. package/esm/index.js +3 -0
  27. package/esm/index.js.map +1 -1
  28. package/esm/makePolicy.d.ts +29 -2
  29. package/esm/makePolicy.d.ts.map +1 -1
  30. package/esm/makePolicy.js +46 -2
  31. package/esm/makePolicy.js.map +1 -1
  32. package/esm/perf.d.ts +7 -2
  33. package/esm/perf.d.ts.map +1 -1
  34. package/esm/perf.js.map +1 -1
  35. package/esm/policies/CargoLicenceValidated.d.ts +41 -0
  36. package/esm/policies/CargoLicenceValidated.d.ts.map +1 -0
  37. package/esm/policies/CargoLicenceValidated.js +45 -0
  38. package/esm/policies/CargoLicenceValidated.js.map +1 -0
  39. package/esm/policies/CargoLintsConfigured.d.ts +30 -0
  40. package/esm/policies/CargoLintsConfigured.d.ts.map +1 -0
  41. package/esm/policies/CargoLintsConfigured.js +61 -0
  42. package/esm/policies/CargoLintsConfigured.js.map +1 -0
  43. package/esm/policies/CargoLockPolicy.d.ts +34 -0
  44. package/esm/policies/CargoLockPolicy.d.ts.map +1 -0
  45. package/esm/policies/CargoLockPolicy.js +57 -0
  46. package/esm/policies/CargoLockPolicy.js.map +1 -0
  47. package/esm/policies/CargoTomlRequired.d.ts +34 -0
  48. package/esm/policies/CargoTomlRequired.d.ts.map +1 -0
  49. package/esm/policies/CargoTomlRequired.js +77 -0
  50. package/esm/policies/CargoTomlRequired.js.map +1 -0
  51. package/esm/policies/CargoTomlSorted.d.ts +20 -0
  52. package/esm/policies/CargoTomlSorted.d.ts.map +1 -0
  53. package/esm/policies/CargoTomlSorted.js +164 -0
  54. package/esm/policies/CargoTomlSorted.js.map +1 -0
  55. package/esm/policies/ConditionalScripts.d.ts.map +1 -1
  56. package/esm/policies/ConditionalScripts.js +3 -2
  57. package/esm/policies/ConditionalScripts.js.map +1 -1
  58. package/esm/policies/ExactScripts.d.ts.map +1 -1
  59. package/esm/policies/ExactScripts.js +3 -2
  60. package/esm/policies/ExactScripts.js.map +1 -1
  61. package/esm/policies/GleamDepVersions.d.ts +25 -0
  62. package/esm/policies/GleamDepVersions.d.ts.map +1 -0
  63. package/esm/policies/GleamDepVersions.js +67 -0
  64. package/esm/policies/GleamDepVersions.js.map +1 -0
  65. package/esm/policies/GleamDocExists.d.ts +24 -0
  66. package/esm/policies/GleamDocExists.d.ts.map +1 -0
  67. package/esm/policies/GleamDocExists.js +39 -0
  68. package/esm/policies/GleamDocExists.js.map +1 -0
  69. package/esm/policies/GleamInternalModulesConfigured.d.ts +21 -0
  70. package/esm/policies/GleamInternalModulesConfigured.d.ts.map +1 -0
  71. package/esm/policies/GleamInternalModulesConfigured.js +30 -0
  72. package/esm/policies/GleamInternalModulesConfigured.js.map +1 -0
  73. package/esm/policies/GleamLicenceConfigured.d.ts +29 -0
  74. package/esm/policies/GleamLicenceConfigured.d.ts.map +1 -0
  75. package/esm/policies/GleamLicenceConfigured.js +34 -0
  76. package/esm/policies/GleamLicenceConfigured.js.map +1 -0
  77. package/esm/policies/GleamManifestCommitted.d.ts +9 -0
  78. package/esm/policies/GleamManifestCommitted.d.ts.map +1 -0
  79. package/esm/policies/GleamManifestCommitted.js +26 -0
  80. package/esm/policies/GleamManifestCommitted.js.map +1 -0
  81. package/esm/policies/GleamMonorepoConsistency.d.ts +30 -0
  82. package/esm/policies/GleamMonorepoConsistency.d.ts.map +1 -0
  83. package/esm/policies/GleamMonorepoConsistency.js +74 -0
  84. package/esm/policies/GleamMonorepoConsistency.js.map +1 -0
  85. package/esm/policies/GleamNameRestrictions.d.ts +25 -0
  86. package/esm/policies/GleamNameRestrictions.d.ts.map +1 -0
  87. package/esm/policies/GleamNameRestrictions.js +44 -0
  88. package/esm/policies/GleamNameRestrictions.js.map +1 -0
  89. package/esm/policies/GleamNoPathDepsInPublished.d.ts +22 -0
  90. package/esm/policies/GleamNoPathDepsInPublished.d.ts.map +1 -0
  91. package/esm/policies/GleamNoPathDepsInPublished.js +43 -0
  92. package/esm/policies/GleamNoPathDepsInPublished.js.map +1 -0
  93. package/esm/policies/GleamPathDepsValid.d.ts +9 -0
  94. package/esm/policies/GleamPathDepsValid.d.ts.map +1 -0
  95. package/esm/policies/GleamPathDepsValid.js +59 -0
  96. package/esm/policies/GleamPathDepsValid.js.map +1 -0
  97. package/esm/policies/GleamProjectStructure.d.ts +25 -0
  98. package/esm/policies/GleamProjectStructure.d.ts.map +1 -0
  99. package/esm/policies/GleamProjectStructure.js +33 -0
  100. package/esm/policies/GleamProjectStructure.js.map +1 -0
  101. package/esm/policies/GleamSharedDependencyVersions.d.ts +29 -0
  102. package/esm/policies/GleamSharedDependencyVersions.d.ts.map +1 -0
  103. package/esm/policies/GleamSharedDependencyVersions.js +101 -0
  104. package/esm/policies/GleamSharedDependencyVersions.js.map +1 -0
  105. package/esm/policies/GleamTomlRequired.d.ts +30 -0
  106. package/esm/policies/GleamTomlRequired.d.ts.map +1 -0
  107. package/esm/policies/GleamTomlRequired.js +37 -0
  108. package/esm/policies/GleamTomlRequired.js.map +1 -0
  109. package/esm/policies/GleamTomlSorted.d.ts +20 -0
  110. package/esm/policies/GleamTomlSorted.d.ts.map +1 -0
  111. package/esm/policies/GleamTomlSorted.js +153 -0
  112. package/esm/policies/GleamTomlSorted.js.map +1 -0
  113. package/esm/policies/GleamVersionConstraint.d.ts +20 -0
  114. package/esm/policies/GleamVersionConstraint.d.ts.map +1 -0
  115. package/esm/policies/GleamVersionConstraint.js +64 -0
  116. package/esm/policies/GleamVersionConstraint.js.map +1 -0
  117. package/esm/policies/HtmlFileHeaders.js +1 -1
  118. package/esm/policies/HtmlFileHeaders.js.map +1 -1
  119. package/esm/policies/NoBuildDirectory.d.ts +9 -0
  120. package/esm/policies/NoBuildDirectory.d.ts.map +1 -0
  121. package/esm/policies/NoBuildDirectory.js +29 -0
  122. package/esm/policies/NoBuildDirectory.js.map +1 -0
  123. package/esm/policies/NoTargetArtifacts.d.ts +8 -0
  124. package/esm/policies/NoTargetArtifacts.d.ts.map +1 -0
  125. package/esm/policies/NoTargetArtifacts.js +42 -0
  126. package/esm/policies/NoTargetArtifacts.js.map +1 -0
  127. package/esm/policies/NoUnsafeWithoutJustification.d.ts +24 -0
  128. package/esm/policies/NoUnsafeWithoutJustification.d.ts.map +1 -0
  129. package/esm/policies/NoUnsafeWithoutJustification.js +80 -0
  130. package/esm/policies/NoUnsafeWithoutJustification.js.map +1 -0
  131. package/esm/policies/NoWildcardDependencies.d.ts +30 -0
  132. package/esm/policies/NoWildcardDependencies.d.ts.map +1 -0
  133. package/esm/policies/NoWildcardDependencies.js +83 -0
  134. package/esm/policies/NoWildcardDependencies.js.map +1 -0
  135. package/esm/policies/PackageEsmType.d.ts.map +1 -1
  136. package/esm/policies/PackageEsmType.js +7 -5
  137. package/esm/policies/PackageEsmType.js.map +1 -1
  138. package/esm/policies/PackageJsonProperties.d.ts.map +1 -1
  139. package/esm/policies/PackageJsonProperties.js +12 -4
  140. package/esm/policies/PackageJsonProperties.js.map +1 -1
  141. package/esm/policies/PackageJsonRepoDirectoryProperty.d.ts.map +1 -1
  142. package/esm/policies/PackageJsonRepoDirectoryProperty.js +3 -2
  143. package/esm/policies/PackageJsonRepoDirectoryProperty.js.map +1 -1
  144. package/esm/policies/PackageJsonSorted.d.ts.map +1 -1
  145. package/esm/policies/PackageJsonSorted.js +42 -7
  146. package/esm/policies/PackageJsonSorted.js.map +1 -1
  147. package/esm/policies/PackageLicense.d.ts.map +1 -1
  148. package/esm/policies/PackageLicense.js +1 -2
  149. package/esm/policies/PackageLicense.js.map +1 -1
  150. package/esm/policies/PackagePrivateField.d.ts.map +1 -1
  151. package/esm/policies/PackagePrivateField.js +3 -2
  152. package/esm/policies/PackagePrivateField.js.map +1 -1
  153. package/esm/policies/PackageReadme.js +2 -2
  154. package/esm/policies/PackageReadme.js.map +1 -1
  155. package/esm/policies/PackageScripts.d.ts.map +1 -1
  156. package/esm/policies/PackageScripts.js +3 -2
  157. package/esm/policies/PackageScripts.js.map +1 -1
  158. package/esm/policies/PackageTestScripts.js +3 -3
  159. package/esm/policies/PackageTestScripts.js.map +1 -1
  160. package/esm/policies/PublicApiDocumented.d.ts +21 -0
  161. package/esm/policies/PublicApiDocumented.d.ts.map +1 -0
  162. package/esm/policies/PublicApiDocumented.js +36 -0
  163. package/esm/policies/PublicApiDocumented.js.map +1 -0
  164. package/esm/policies/RequiredScripts.d.ts.map +1 -1
  165. package/esm/policies/RequiredScripts.js +3 -2
  166. package/esm/policies/RequiredScripts.js.map +1 -1
  167. package/esm/policies/RustDocExists.d.ts +24 -0
  168. package/esm/policies/RustDocExists.d.ts.map +1 -0
  169. package/esm/policies/RustDocExists.js +49 -0
  170. package/esm/policies/RustDocExists.js.map +1 -0
  171. package/esm/policies/RustToolchainExists.d.ts +20 -0
  172. package/esm/policies/RustToolchainExists.d.ts.map +1 -0
  173. package/esm/policies/RustToolchainExists.js +27 -0
  174. package/esm/policies/RustToolchainExists.js.map +1 -0
  175. package/esm/policies/RustfmtConfigExists.d.ts +20 -0
  176. package/esm/policies/RustfmtConfigExists.d.ts.map +1 -0
  177. package/esm/policies/RustfmtConfigExists.js +27 -0
  178. package/esm/policies/RustfmtConfigExists.js.map +1 -0
  179. package/esm/policies/SharedDependencyVersions.d.ts +24 -0
  180. package/esm/policies/SharedDependencyVersions.d.ts.map +1 -0
  181. package/esm/policies/SharedDependencyVersions.js +135 -0
  182. package/esm/policies/SharedDependencyVersions.js.map +1 -0
  183. package/esm/policies/WorkspaceInheritance.d.ts +24 -0
  184. package/esm/policies/WorkspaceInheritance.d.ts.map +1 -0
  185. package/esm/policies/WorkspaceInheritance.js +94 -0
  186. package/esm/policies/WorkspaceInheritance.js.map +1 -0
  187. package/esm/policies/WorkspaceMembersValid.d.ts +20 -0
  188. package/esm/policies/WorkspaceMembersValid.d.ts.map +1 -0
  189. package/esm/policies/WorkspaceMembersValid.js +88 -0
  190. package/esm/policies/WorkspaceMembersValid.js.map +1 -0
  191. package/esm/policies/constants.d.ts +8 -0
  192. package/esm/policies/constants.d.ts.map +1 -1
  193. package/esm/policies/constants.js +8 -0
  194. package/esm/policies/constants.js.map +1 -1
  195. package/esm/policies.d.ts +30 -0
  196. package/esm/policies.d.ts.map +1 -1
  197. package/esm/policies.js +51 -1
  198. package/esm/policies.js.map +1 -1
  199. package/esm/policy.d.ts +24 -0
  200. package/esm/policy.d.ts.map +1 -1
  201. package/esm/policy.js.map +1 -1
  202. package/esm/policyDefiners/defineCargoPolicy.d.ts +66 -0
  203. package/esm/policyDefiners/defineCargoPolicy.d.ts.map +1 -0
  204. package/esm/policyDefiners/defineCargoPolicy.js +60 -0
  205. package/esm/policyDefiners/defineCargoPolicy.js.map +1 -0
  206. package/esm/policyDefiners/defineFileHeaderPolicy.d.ts.map +1 -1
  207. package/esm/policyDefiners/defineFileHeaderPolicy.js +6 -7
  208. package/esm/policyDefiners/defineFileHeaderPolicy.js.map +1 -1
  209. package/esm/policyDefiners/defineGleamPolicy.d.ts +65 -0
  210. package/esm/policyDefiners/defineGleamPolicy.d.ts.map +1 -0
  211. package/esm/policyDefiners/defineGleamPolicy.js +59 -0
  212. package/esm/policyDefiners/defineGleamPolicy.js.map +1 -0
  213. package/esm/policyDefiners/spdxValidator.d.ts +74 -0
  214. package/esm/policyDefiners/spdxValidator.d.ts.map +1 -0
  215. package/esm/policyDefiners/spdxValidator.js +127 -0
  216. package/esm/policyDefiners/spdxValidator.js.map +1 -0
  217. package/esm/policyDefiners/tomlParser.d.ts +8 -0
  218. package/esm/policyDefiners/tomlParser.d.ts.map +1 -0
  219. package/esm/policyDefiners/tomlParser.js +17 -0
  220. package/esm/policyDefiners/tomlParser.js.map +1 -0
  221. package/esm/runner.d.ts +60 -0
  222. package/esm/runner.d.ts.map +1 -0
  223. package/esm/runner.js +174 -0
  224. package/esm/runner.js.map +1 -0
  225. package/esm/tsdoc-metadata.json +1 -1
  226. package/oclif.manifest.json +100 -3
  227. package/package.json +46 -31
  228. package/scripts/postinstall.mjs +154 -0
  229. package/sidecar/sidecar.mjs +468 -0
@@ -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,MAAM,wCAAwC,CAAC;AAoBhD,MAAM,gBAAgB,GAAG,CAAC,WAAW,CAAC,CAAC;AAEvC;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAC1B,iBAAiB,CAAC;IACjB,IAAI,EAAE,gBAAgB;IACtB,WAAW,EACV,gFAAgF;IACjF,OAAO,EAAE,KAAK,EAAE,IAAe,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE;QAC1D,yDAAyD;QACzD,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC1C,OAAO,IAAI,CAAC;QACb,CAAC;QAED,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;QACnD,MAAM,QAAQ,GAAG,MAAM,EAAE,QAAQ,IAAI,gBAAgB,CAAC;QACtD,MAAM,WAAW,GAAG,MAAM,EAAE,WAAW,IAAI,EAAE,CAAC;QAC9C,MAAM,MAAM,GAAa,EAAE,CAAC;QAE5B,MAAM,eAAe,GAAG,QAAQ,CAAC,MAAM,CACtC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CACrC,CAAC;QACF,MAAM,kBAAkB,GAAG,WAAW,CAAC,MAAM,CAC5C,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CACrC,CAAC;QAEF,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChC,MAAM,CAAC,IAAI,CACV,mCAAmC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC/D,CAAC;QACH,CAAC;QACD,IAAI,kBAAkB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;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"}
@@ -0,0 +1,74 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import path from "pathe";
3
+ import { makePolicyDefinition } from "../makePolicy.js";
4
+ import { parseToml } from "../policyDefiners/tomlParser.js";
5
+ const DEFAULT_SYNC_FIELDS = ["licences"];
6
+ async function loadGleamToml(filePath) {
7
+ try {
8
+ const content = await readFile(filePath, "utf-8");
9
+ return await parseToml(content);
10
+ }
11
+ catch {
12
+ return undefined;
13
+ }
14
+ }
15
+ function checkFieldConsistency(packages, field) {
16
+ const values = new Map();
17
+ for (const [pkg, toml] of packages) {
18
+ const value = JSON.stringify(toml[field] ?? null);
19
+ if (!values.has(value)) {
20
+ values.set(value, []);
21
+ }
22
+ values.get(value)?.push(pkg);
23
+ }
24
+ if (values.size <= 1) {
25
+ return [];
26
+ }
27
+ const details = [...values.entries()]
28
+ .map(([val, pkgs]) => `${val} in ${pkgs.join(", ")}`)
29
+ .join("; ");
30
+ return [`Inconsistent "${field}" across packages: ${details}`];
31
+ }
32
+ /**
33
+ * A policy that enforces consistent metadata across Gleam packages in a monorepo.
34
+ *
35
+ * @alpha
36
+ */
37
+ export const GleamMonorepoConsistency = makePolicyDefinition({
38
+ name: "GleamMonorepoConsistency",
39
+ description: "Enforces consistent metadata (licences, gleam version, etc.) across Gleam packages in a monorepo.",
40
+ match: /^gleam\.toml$/,
41
+ handler: async ({ root, config }) => {
42
+ const packagePaths = config?.packages;
43
+ if (!packagePaths || packagePaths.length < 2) {
44
+ return true;
45
+ }
46
+ const syncFields = config?.syncFields ?? DEFAULT_SYNC_FIELDS;
47
+ const syncGleamVersion = config?.syncGleamVersion ?? true;
48
+ const packages = new Map();
49
+ for (const pkgPath of packagePaths) {
50
+ const toml = await loadGleamToml(path.resolve(root, pkgPath));
51
+ if (toml) {
52
+ packages.set(pkgPath, toml);
53
+ }
54
+ }
55
+ if (packages.size < 2) {
56
+ return true;
57
+ }
58
+ const errors = [];
59
+ for (const field of syncFields) {
60
+ errors.push(...checkFieldConsistency(packages, field));
61
+ }
62
+ if (syncGleamVersion) {
63
+ errors.push(...checkFieldConsistency(packages, "gleam"));
64
+ }
65
+ if (errors.length > 0) {
66
+ return {
67
+ error: errors.join("; "),
68
+ manualFix: "Ensure all Gleam packages in the monorepo use consistent metadata values.",
69
+ };
70
+ }
71
+ return true;
72
+ },
73
+ });
74
+ //# sourceMappingURL=GleamMonorepoConsistency.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GleamMonorepoConsistency.js","sourceRoot":"","sources":["../../src/policies/GleamMonorepoConsistency.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,OAAO,CAAC;AACzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AA2B5D,MAAM,mBAAmB,GAAG,CAAC,UAAU,CAAC,CAAC;AAEzC,KAAK,UAAU,aAAa,CAC3B,QAAgB;IAEhB,IAAI,CAAC;QACJ,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAClD,OAAO,MAAM,SAAS,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,SAAS,CAAC;IAClB,CAAC;AACF,CAAC;AAED,SAAS,qBAAqB,CAC7B,QAA8C,EAC9C,KAAa;IAEb,MAAM,MAAM,GAAG,IAAI,GAAG,EAAoB,CAAC;IAE3C,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,QAAQ,EAAE,CAAC;QACpC,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC;QAClD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YACxB,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACvB,CAAC;QACD,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;IAED,IAAI,MAAM,CAAC,IAAI,IAAI,CAAC,EAAE,CAAC;QACtB,OAAO,EAAE,CAAC;IACX,CAAC;IAED,MAAM,OAAO,GAAG,CAAC,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;SACnC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;SACpD,IAAI,CAAC,IAAI,CAAC,CAAC;IACb,OAAO,CAAC,iBAAiB,KAAK,sBAAsB,OAAO,EAAE,CAAC,CAAC;AAChE,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GACpC,oBAAoB,CAAC;IACpB,IAAI,EAAE,0BAA0B;IAChC,WAAW,EACV,mGAAmG;IACpG,KAAK,EAAE,eAAe;IACtB,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE;QACnC,MAAM,YAAY,GAAG,MAAM,EAAE,QAAQ,CAAC;QACtC,IAAI,CAAC,YAAY,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC9C,OAAO,IAAI,CAAC;QACb,CAAC;QAED,MAAM,UAAU,GAAG,MAAM,EAAE,UAAU,IAAI,mBAAmB,CAAC;QAC7D,MAAM,gBAAgB,GAAG,MAAM,EAAE,gBAAgB,IAAI,IAAI,CAAC;QAE1D,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAmC,CAAC;QAC5D,KAAK,MAAM,OAAO,IAAI,YAAY,EAAE,CAAC;YACpC,MAAM,IAAI,GAAG,MAAM,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;YAC9D,IAAI,IAAI,EAAE,CAAC;gBACV,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YAC7B,CAAC;QACF,CAAC;QAED,IAAI,QAAQ,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC;QACb,CAAC;QAED,MAAM,MAAM,GAAa,EAAE,CAAC;QAE5B,KAAK,MAAM,KAAK,IAAI,UAAU,EAAE,CAAC;YAChC,MAAM,CAAC,IAAI,CAAC,GAAG,qBAAqB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;QACxD,CAAC;QAED,IAAI,gBAAgB,EAAE,CAAC;YACtB,MAAM,CAAC,IAAI,CAAC,GAAG,qBAAqB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;QAC1D,CAAC;QAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,OAAO;gBACN,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;gBACxB,SAAS,EACR,2EAA2E;aAC5E,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC;CACD,CAAC,CAAC","sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport path from \"pathe\";\nimport { makePolicyDefinition } from \"../makePolicy.js\";\nimport type { PolicyDefinition } from \"../policy.js\";\nimport { parseToml } from \"../policyDefiners/tomlParser.js\";\n\n/**\n * Configuration for the GleamMonorepoConsistency policy.\n *\n * @alpha\n */\nexport interface GleamMonorepoConsistencyConfig {\n\t/**\n\t * Top-level fields that should be consistent across all packages.\n\t * @defaultValue [\"licences\"]\n\t */\n\tsyncFields?: string[];\n\n\t/**\n\t * If true, ensure the `gleam` version constraint is consistent.\n\t * @defaultValue true\n\t */\n\tsyncGleamVersion?: boolean;\n\n\t/**\n\t * Paths to gleam.toml files to compare (relative to repo root).\n\t * If not specified, the policy only checks the file it matches against.\n\t */\n\tpackages?: string[];\n}\n\nconst DEFAULT_SYNC_FIELDS = [\"licences\"];\n\nasync function loadGleamToml(\n\tfilePath: string,\n): Promise<Record<string, unknown> | undefined> {\n\ttry {\n\t\tconst content = await readFile(filePath, \"utf-8\");\n\t\treturn await parseToml(content);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction checkFieldConsistency(\n\tpackages: Map<string, Record<string, unknown>>,\n\tfield: string,\n): string[] {\n\tconst values = new Map<string, string[]>();\n\n\tfor (const [pkg, toml] of packages) {\n\t\tconst value = JSON.stringify(toml[field] ?? null);\n\t\tif (!values.has(value)) {\n\t\t\tvalues.set(value, []);\n\t\t}\n\t\tvalues.get(value)?.push(pkg);\n\t}\n\n\tif (values.size <= 1) {\n\t\treturn [];\n\t}\n\n\tconst details = [...values.entries()]\n\t\t.map(([val, pkgs]) => `${val} in ${pkgs.join(\", \")}`)\n\t\t.join(\"; \");\n\treturn [`Inconsistent \"${field}\" across packages: ${details}`];\n}\n\n/**\n * A policy that enforces consistent metadata across Gleam packages in a monorepo.\n *\n * @alpha\n */\nexport const GleamMonorepoConsistency: PolicyDefinition<GleamMonorepoConsistencyConfig> =\n\tmakePolicyDefinition({\n\t\tname: \"GleamMonorepoConsistency\",\n\t\tdescription:\n\t\t\t\"Enforces consistent metadata (licences, gleam version, etc.) across Gleam packages in a monorepo.\",\n\t\tmatch: /^gleam\\.toml$/,\n\t\thandler: async ({ root, config }) => {\n\t\t\tconst packagePaths = config?.packages;\n\t\t\tif (!packagePaths || packagePaths.length < 2) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tconst syncFields = config?.syncFields ?? DEFAULT_SYNC_FIELDS;\n\t\t\tconst syncGleamVersion = config?.syncGleamVersion ?? true;\n\n\t\t\tconst packages = new Map<string, Record<string, unknown>>();\n\t\t\tfor (const pkgPath of packagePaths) {\n\t\t\t\tconst toml = await loadGleamToml(path.resolve(root, pkgPath));\n\t\t\t\tif (toml) {\n\t\t\t\t\tpackages.set(pkgPath, toml);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (packages.size < 2) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tconst errors: string[] = [];\n\n\t\t\tfor (const field of syncFields) {\n\t\t\t\terrors.push(...checkFieldConsistency(packages, field));\n\t\t\t}\n\n\t\t\tif (syncGleamVersion) {\n\t\t\t\terrors.push(...checkFieldConsistency(packages, \"gleam\"));\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\"Ensure all Gleam packages in the monorepo use consistent metadata values.\",\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn true;\n\t\t},\n\t});\n"]}
@@ -0,0 +1,25 @@
1
+ import type { PolicyShape } from "../policy.js";
2
+ /**
3
+ * Configuration for the GleamNameRestrictions policy.
4
+ *
5
+ * @alpha
6
+ */
7
+ export interface GleamNameRestrictionsConfig {
8
+ /**
9
+ * Prefixes that are denied for package names.
10
+ * @defaultValue ["gleam_"]
11
+ */
12
+ denyPrefixes?: string[];
13
+ /**
14
+ * If true, require snake_case naming.
15
+ * @defaultValue true
16
+ */
17
+ requireSnakeCase?: boolean;
18
+ }
19
+ /**
20
+ * A policy that enforces naming conventions for Gleam packages.
21
+ *
22
+ * @alpha
23
+ */
24
+ export declare const GleamNameRestrictions: PolicyShape<GleamNameRestrictionsConfig>;
25
+ //# sourceMappingURL=GleamNameRestrictions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GleamNameRestrictions.d.ts","sourceRoot":"","sources":["../../src/policies/GleamNameRestrictions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAMhD;;;;GAIG;AACH,MAAM,WAAW,2BAA2B;IAC3C;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IAExB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC3B;AAiBD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAE,WAAW,CAAC,2BAA2B,CAoCxE,CAAC"}
@@ -0,0 +1,44 @@
1
+ import { defineGleamPolicy, } from "../policyDefiners/defineGleamPolicy.js";
2
+ const DEFAULT_DENY_PREFIXES = ["gleam_"];
3
+ const SNAKE_CASE_REGEX = /^[a-z][a-z0-9]*(_[a-z0-9]+)*$/;
4
+ function checkDeniedPrefixes(name, prefixes) {
5
+ for (const prefix of prefixes) {
6
+ if (name.startsWith(prefix)) {
7
+ return `Package name "${name}" uses reserved prefix "${prefix}". The "gleam_" prefix is reserved for official Gleam packages.`;
8
+ }
9
+ }
10
+ return undefined;
11
+ }
12
+ /**
13
+ * A policy that enforces naming conventions for Gleam packages.
14
+ *
15
+ * @alpha
16
+ */
17
+ export const GleamNameRestrictions = defineGleamPolicy({
18
+ name: "GleamNameRestrictions",
19
+ description: 'Enforces Gleam package naming conventions: no "gleam_" prefix, snake_case required.',
20
+ handler: async (toml, { config }) => {
21
+ const name = toml.name;
22
+ if (!name) {
23
+ return true;
24
+ }
25
+ const errors = [];
26
+ const denyPrefixes = config?.denyPrefixes ?? DEFAULT_DENY_PREFIXES;
27
+ const requireSnakeCase = config?.requireSnakeCase ?? true;
28
+ const prefixError = checkDeniedPrefixes(name, denyPrefixes);
29
+ if (prefixError) {
30
+ errors.push(prefixError);
31
+ }
32
+ if (requireSnakeCase && !SNAKE_CASE_REGEX.test(name)) {
33
+ errors.push(`Package name "${name}" is not snake_case. Gleam package names should use lowercase letters, digits, and underscores.`);
34
+ }
35
+ if (errors.length > 0) {
36
+ return {
37
+ error: errors.join("; "),
38
+ manualFix: "Rename the package to follow Gleam naming conventions (snake_case, no gleam_ prefix).",
39
+ };
40
+ }
41
+ return true;
42
+ },
43
+ });
44
+ //# sourceMappingURL=GleamNameRestrictions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GleamNameRestrictions.js","sourceRoot":"","sources":["../../src/policies/GleamNameRestrictions.ts"],"names":[],"mappings":"AACA,OAAO,EACN,iBAAiB,GAEjB,MAAM,wCAAwC,CAAC;AAqBhD,MAAM,qBAAqB,GAAG,CAAC,QAAQ,CAAC,CAAC;AACzC,MAAM,gBAAgB,GAAG,+BAA+B,CAAC;AAEzD,SAAS,mBAAmB,CAC3B,IAAY,EACZ,QAAkB;IAElB,KAAK,MAAM,MAAM,IAAI,QAAQ,EAAE,CAAC;QAC/B,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;YAC7B,OAAO,iBAAiB,IAAI,2BAA2B,MAAM,iEAAiE,CAAC;QAChI,CAAC;IACF,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GACjC,iBAAiB,CAAC;IACjB,IAAI,EAAE,uBAAuB;IAC7B,WAAW,EACV,qFAAqF;IACtF,OAAO,EAAE,KAAK,EAAE,IAAe,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;QAC9C,MAAM,IAAI,GAAG,IAAI,CAAC,IAA0B,CAAC;QAC7C,IAAI,CAAC,IAAI,EAAE,CAAC;YACX,OAAO,IAAI,CAAC;QACb,CAAC;QAED,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,MAAM,YAAY,GAAG,MAAM,EAAE,YAAY,IAAI,qBAAqB,CAAC;QACnE,MAAM,gBAAgB,GAAG,MAAM,EAAE,gBAAgB,IAAI,IAAI,CAAC;QAE1D,MAAM,WAAW,GAAG,mBAAmB,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QAC5D,IAAI,WAAW,EAAE,CAAC;YACjB,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC1B,CAAC;QAED,IAAI,gBAAgB,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACtD,MAAM,CAAC,IAAI,CACV,iBAAiB,IAAI,iGAAiG,CACtH,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,uFAAuF;aACxF,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 GleamNameRestrictions policy.\n *\n * @alpha\n */\nexport interface GleamNameRestrictionsConfig {\n\t/**\n\t * Prefixes that are denied for package names.\n\t * @defaultValue [\"gleam_\"]\n\t */\n\tdenyPrefixes?: string[];\n\n\t/**\n\t * If true, require snake_case naming.\n\t * @defaultValue true\n\t */\n\trequireSnakeCase?: boolean;\n}\n\nconst DEFAULT_DENY_PREFIXES = [\"gleam_\"];\nconst SNAKE_CASE_REGEX = /^[a-z][a-z0-9]*(_[a-z0-9]+)*$/;\n\nfunction checkDeniedPrefixes(\n\tname: string,\n\tprefixes: string[],\n): string | undefined {\n\tfor (const prefix of prefixes) {\n\t\tif (name.startsWith(prefix)) {\n\t\t\treturn `Package name \"${name}\" uses reserved prefix \"${prefix}\". The \"gleam_\" prefix is reserved for official Gleam packages.`;\n\t\t}\n\t}\n\treturn undefined;\n}\n\n/**\n * A policy that enforces naming conventions for Gleam packages.\n *\n * @alpha\n */\nexport const GleamNameRestrictions: PolicyShape<GleamNameRestrictionsConfig> =\n\tdefineGleamPolicy({\n\t\tname: \"GleamNameRestrictions\",\n\t\tdescription:\n\t\t\t'Enforces Gleam package naming conventions: no \"gleam_\" prefix, snake_case required.',\n\t\thandler: async (toml: GleamToml, { config }) => {\n\t\t\tconst name = toml.name as string | undefined;\n\t\t\tif (!name) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tconst errors: string[] = [];\n\t\t\tconst denyPrefixes = config?.denyPrefixes ?? DEFAULT_DENY_PREFIXES;\n\t\t\tconst requireSnakeCase = config?.requireSnakeCase ?? true;\n\n\t\t\tconst prefixError = checkDeniedPrefixes(name, denyPrefixes);\n\t\t\tif (prefixError) {\n\t\t\t\terrors.push(prefixError);\n\t\t\t}\n\n\t\t\tif (requireSnakeCase && !SNAKE_CASE_REGEX.test(name)) {\n\t\t\t\terrors.push(\n\t\t\t\t\t`Package name \"${name}\" is not snake_case. Gleam package names should use lowercase letters, digits, and underscores.`,\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\"Rename the package to follow Gleam naming conventions (snake_case, no gleam_ prefix).\",\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn true;\n\t\t},\n\t});\n"]}
@@ -0,0 +1,22 @@
1
+ import type { PolicyShape } from "../policy.js";
2
+ /**
3
+ * Configuration for the GleamNoPathDepsInPublished policy.
4
+ *
5
+ * @alpha
6
+ */
7
+ export interface GleamNoPathDepsInPublishedConfig {
8
+ /**
9
+ * If true, only check packages that don't have a "private" marker.
10
+ * Since Gleam doesn't have a native "private" field, this checks for
11
+ * the absence of a description (unpublished packages often lack one).
12
+ * @defaultValue false
13
+ */
14
+ onlyPublishable?: boolean;
15
+ }
16
+ /**
17
+ * A policy that warns when path dependencies are used in packages intended for publishing.
18
+ *
19
+ * @alpha
20
+ */
21
+ export declare const GleamNoPathDepsInPublished: PolicyShape<GleamNoPathDepsInPublishedConfig>;
22
+ //# sourceMappingURL=GleamNoPathDepsInPublished.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GleamNoPathDepsInPublished.d.ts","sourceRoot":"","sources":["../../src/policies/GleamNoPathDepsInPublished.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAMhD;;;;GAIG;AACH,MAAM,WAAW,gCAAgC;IAChD;;;;;OAKG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC1B;AAeD;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,EAAE,WAAW,CAAC,gCAAgC,CAgClF,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { defineGleamPolicy, } from "../policyDefiners/defineGleamPolicy.js";
2
+ function findPathDeps(deps) {
3
+ const pathDeps = [];
4
+ for (const [name, value] of Object.entries(deps)) {
5
+ if (typeof value === "object" && value !== null) {
6
+ const record = value;
7
+ if (typeof record.path === "string") {
8
+ pathDeps.push(name);
9
+ }
10
+ }
11
+ }
12
+ return pathDeps;
13
+ }
14
+ /**
15
+ * A policy that warns when path dependencies are used in packages intended for publishing.
16
+ *
17
+ * @alpha
18
+ */
19
+ export const GleamNoPathDepsInPublished = defineGleamPolicy({
20
+ name: "GleamNoPathDepsInPublished",
21
+ description: "Warns when path dependencies are used in packages intended for publishing to Hex.",
22
+ handler: async (toml, { config }) => {
23
+ if (config?.onlyPublishable && !toml.description) {
24
+ return true;
25
+ }
26
+ const errors = [];
27
+ const deps = toml.dependencies;
28
+ if (deps) {
29
+ const pathDeps = findPathDeps(deps);
30
+ for (const dep of pathDeps) {
31
+ errors.push(`[dependencies] "${dep}" uses a path dependency, which will break when published to Hex`);
32
+ }
33
+ }
34
+ if (errors.length > 0) {
35
+ return {
36
+ error: errors.join("; "),
37
+ manualFix: "Replace path dependencies with version constraints before publishing.",
38
+ };
39
+ }
40
+ return true;
41
+ },
42
+ });
43
+ //# sourceMappingURL=GleamNoPathDepsInPublished.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GleamNoPathDepsInPublished.js","sourceRoot":"","sources":["../../src/policies/GleamNoPathDepsInPublished.ts"],"names":[],"mappings":"AACA,OAAO,EACN,iBAAiB,GAEjB,MAAM,wCAAwC,CAAC;AAiBhD,SAAS,YAAY,CAAC,IAA6B;IAClD,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAClD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACjD,MAAM,MAAM,GAAG,KAAgC,CAAC;YAChD,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACrC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACrB,CAAC;QACF,CAAC;IACF,CAAC;IACD,OAAO,QAAQ,CAAC;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GACtC,iBAAiB,CAAC;IACjB,IAAI,EAAE,4BAA4B;IAClC,WAAW,EACV,mFAAmF;IACpF,OAAO,EAAE,KAAK,EAAE,IAAe,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;QAC9C,IAAI,MAAM,EAAE,eAAe,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YAClD,OAAO,IAAI,CAAC;QACb,CAAC;QAED,MAAM,MAAM,GAAa,EAAE,CAAC;QAE5B,MAAM,IAAI,GAAG,IAAI,CAAC,YAAmD,CAAC;QACtE,IAAI,IAAI,EAAE,CAAC;YACV,MAAM,QAAQ,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;YACpC,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;gBAC5B,MAAM,CAAC,IAAI,CACV,mBAAmB,GAAG,kEAAkE,CACxF,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,uEAAuE;aACxE,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 GleamNoPathDepsInPublished policy.\n *\n * @alpha\n */\nexport interface GleamNoPathDepsInPublishedConfig {\n\t/**\n\t * If true, only check packages that don't have a \"private\" marker.\n\t * Since Gleam doesn't have a native \"private\" field, this checks for\n\t * the absence of a description (unpublished packages often lack one).\n\t * @defaultValue false\n\t */\n\tonlyPublishable?: boolean;\n}\n\nfunction findPathDeps(deps: Record<string, unknown>): string[] {\n\tconst pathDeps: string[] = [];\n\tfor (const [name, value] of Object.entries(deps)) {\n\t\tif (typeof value === \"object\" && value !== null) {\n\t\t\tconst record = value as Record<string, unknown>;\n\t\t\tif (typeof record.path === \"string\") {\n\t\t\t\tpathDeps.push(name);\n\t\t\t}\n\t\t}\n\t}\n\treturn pathDeps;\n}\n\n/**\n * A policy that warns when path dependencies are used in packages intended for publishing.\n *\n * @alpha\n */\nexport const GleamNoPathDepsInPublished: PolicyShape<GleamNoPathDepsInPublishedConfig> =\n\tdefineGleamPolicy({\n\t\tname: \"GleamNoPathDepsInPublished\",\n\t\tdescription:\n\t\t\t\"Warns when path dependencies are used in packages intended for publishing to Hex.\",\n\t\thandler: async (toml: GleamToml, { config }) => {\n\t\t\tif (config?.onlyPublishable && !toml.description) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tconst errors: string[] = [];\n\n\t\t\tconst deps = toml.dependencies as Record<string, unknown> | undefined;\n\t\t\tif (deps) {\n\t\t\t\tconst pathDeps = findPathDeps(deps);\n\t\t\t\tfor (const dep of pathDeps) {\n\t\t\t\t\terrors.push(\n\t\t\t\t\t\t`[dependencies] \"${dep}\" uses a path dependency, which will break when published to Hex`,\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\"Replace path dependencies with version constraints before publishing.\",\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn true;\n\t\t},\n\t});\n"]}
@@ -0,0 +1,9 @@
1
+ import type { PolicyShape } from "../policy.js";
2
+ /**
3
+ * A policy that validates all path dependency targets in gleam.toml exist
4
+ * and contain a gleam.toml file.
5
+ *
6
+ * @alpha
7
+ */
8
+ export declare const GleamPathDepsValid: PolicyShape;
9
+ //# sourceMappingURL=GleamPathDepsValid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GleamPathDepsValid.d.ts","sourceRoot":"","sources":["../../src/policies/GleamPathDepsValid.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAkDhD;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,EAAE,WAqB/B,CAAC"}
@@ -0,0 +1,59 @@
1
+ import { existsSync } from "node:fs";
2
+ import path from "pathe";
3
+ import { defineGleamPolicy, } from "../policyDefiners/defineGleamPolicy.js";
4
+ function validatePathDep(depName, depValue, sectionName, baseDir) {
5
+ if (typeof depValue !== "object" || depValue === null) {
6
+ return undefined;
7
+ }
8
+ const record = depValue;
9
+ if (typeof record.path !== "string") {
10
+ return undefined;
11
+ }
12
+ const depDir = path.resolve(baseDir, record.path);
13
+ if (!existsSync(depDir)) {
14
+ return `[${sectionName}] "${depName}" path "${record.path}" does not exist`;
15
+ }
16
+ if (!existsSync(path.join(depDir, "gleam.toml"))) {
17
+ return `[${sectionName}] "${depName}" path "${record.path}" exists but has no gleam.toml`;
18
+ }
19
+ return undefined;
20
+ }
21
+ function checkSection(sectionName, data, baseDir) {
22
+ if (!data || typeof data !== "object") {
23
+ return [];
24
+ }
25
+ const deps = data;
26
+ const errors = [];
27
+ for (const [depName, depValue] of Object.entries(deps)) {
28
+ const error = validatePathDep(depName, depValue, sectionName, baseDir);
29
+ if (error) {
30
+ errors.push(error);
31
+ }
32
+ }
33
+ return errors;
34
+ }
35
+ /**
36
+ * A policy that validates all path dependency targets in gleam.toml exist
37
+ * and contain a gleam.toml file.
38
+ *
39
+ * @alpha
40
+ */
41
+ export const GleamPathDepsValid = defineGleamPolicy({
42
+ name: "GleamPathDepsValid",
43
+ description: "Validates that all path dependency targets exist and contain a gleam.toml file.",
44
+ handler: async (toml, { file, root }) => {
45
+ const baseDir = path.resolve(root, path.dirname(file));
46
+ const errors = [
47
+ ...checkSection("dependencies", toml.dependencies, baseDir),
48
+ ...checkSection("dev-dependencies", toml["dev-dependencies"], baseDir),
49
+ ];
50
+ if (errors.length > 0) {
51
+ return {
52
+ error: errors.join("; "),
53
+ manualFix: "Fix the path dependencies to point to valid Gleam project directories.",
54
+ };
55
+ }
56
+ return true;
57
+ },
58
+ });
59
+ //# sourceMappingURL=GleamPathDepsValid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GleamPathDepsValid.js","sourceRoot":"","sources":["../../src/policies/GleamPathDepsValid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,IAAI,MAAM,OAAO,CAAC;AAEzB,OAAO,EACN,iBAAiB,GAEjB,MAAM,wCAAwC,CAAC;AAEhD,SAAS,eAAe,CACvB,OAAe,EACf,QAAiB,EACjB,WAAmB,EACnB,OAAe;IAEf,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACvD,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,MAAM,MAAM,GAAG,QAAmC,CAAC;IACnD,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACrC,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IAElD,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QACzB,OAAO,IAAI,WAAW,MAAM,OAAO,WAAW,MAAM,CAAC,IAAI,kBAAkB,CAAC;IAC7E,CAAC;IACD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC;QAClD,OAAO,IAAI,WAAW,MAAM,OAAO,WAAW,MAAM,CAAC,IAAI,gCAAgC,CAAC;IAC3F,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC;AAED,SAAS,YAAY,CACpB,WAAmB,EACnB,IAAa,EACb,OAAe;IAEf,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QACvC,OAAO,EAAE,CAAC;IACX,CAAC;IACD,MAAM,IAAI,GAAG,IAA+B,CAAC;IAC7C,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,KAAK,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACxD,MAAM,KAAK,GAAG,eAAe,CAAC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;QACvE,IAAI,KAAK,EAAE,CAAC;YACX,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC;IACF,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAgB,iBAAiB,CAAC;IAChE,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EACV,iFAAiF;IAClF,OAAO,EAAE,KAAK,EAAE,IAAe,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE;QAClD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACvD,MAAM,MAAM,GAAa;YACxB,GAAG,YAAY,CAAC,cAAc,EAAE,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC;YAC3D,GAAG,YAAY,CAAC,kBAAkB,EAAE,IAAI,CAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC;SACtE,CAAC;QAEF,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,OAAO;gBACN,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;gBACxB,SAAS,EACR,wEAAwE;aACzE,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\nfunction validatePathDep(\n\tdepName: string,\n\tdepValue: unknown,\n\tsectionName: string,\n\tbaseDir: string,\n): string | undefined {\n\tif (typeof depValue !== \"object\" || depValue === null) {\n\t\treturn undefined;\n\t}\n\tconst record = depValue as Record<string, unknown>;\n\tif (typeof record.path !== \"string\") {\n\t\treturn undefined;\n\t}\n\n\tconst depDir = path.resolve(baseDir, record.path);\n\n\tif (!existsSync(depDir)) {\n\t\treturn `[${sectionName}] \"${depName}\" path \"${record.path}\" does not exist`;\n\t}\n\tif (!existsSync(path.join(depDir, \"gleam.toml\"))) {\n\t\treturn `[${sectionName}] \"${depName}\" path \"${record.path}\" exists but has no gleam.toml`;\n\t}\n\treturn undefined;\n}\n\nfunction checkSection(\n\tsectionName: string,\n\tdata: unknown,\n\tbaseDir: string,\n): string[] {\n\tif (!data || typeof data !== \"object\") {\n\t\treturn [];\n\t}\n\tconst deps = data as Record<string, unknown>;\n\tconst errors: string[] = [];\n\tfor (const [depName, depValue] of Object.entries(deps)) {\n\t\tconst error = validatePathDep(depName, depValue, sectionName, baseDir);\n\t\tif (error) {\n\t\t\terrors.push(error);\n\t\t}\n\t}\n\treturn errors;\n}\n\n/**\n * A policy that validates all path dependency targets in gleam.toml exist\n * and contain a gleam.toml file.\n *\n * @alpha\n */\nexport const GleamPathDepsValid: PolicyShape = defineGleamPolicy({\n\tname: \"GleamPathDepsValid\",\n\tdescription:\n\t\t\"Validates that all path dependency targets exist and contain a gleam.toml file.\",\n\thandler: async (toml: GleamToml, { file, root }) => {\n\t\tconst baseDir = path.resolve(root, path.dirname(file));\n\t\tconst errors: string[] = [\n\t\t\t...checkSection(\"dependencies\", toml.dependencies, baseDir),\n\t\t\t...checkSection(\"dev-dependencies\", toml[\"dev-dependencies\"], baseDir),\n\t\t];\n\n\t\tif (errors.length > 0) {\n\t\t\treturn {\n\t\t\t\terror: errors.join(\"; \"),\n\t\t\t\tmanualFix:\n\t\t\t\t\t\"Fix the path dependencies to point to valid Gleam project directories.\",\n\t\t\t};\n\t\t}\n\n\t\treturn true;\n\t},\n});\n"]}