renovate 44.210.2 → 44.212.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 (319) hide show
  1. package/dist/config/options/index.js +1 -1
  2. package/dist/config/options/index.js.map +1 -1
  3. package/dist/config/utils.js +2 -1
  4. package/dist/config/utils.js.map +1 -1
  5. package/dist/config/validation-helpers/regex-glob-matchers.js.map +1 -1
  6. package/dist/config/validation-helpers/utils.js +5 -1
  7. package/dist/config/validation-helpers/utils.js.map +1 -1
  8. package/dist/config/validation.js +8 -2
  9. package/dist/config/validation.js.map +1 -1
  10. package/dist/config-validator.js +1 -1
  11. package/dist/config-validator.js.map +1 -1
  12. package/dist/data/monorepo.js +8 -0
  13. package/dist/global-config-option-defaults.generated.js +1 -1
  14. package/dist/global-config-option-defaults.generated.js.map +1 -1
  15. package/dist/instrumentation/index.js +3 -2
  16. package/dist/instrumentation/index.js.map +1 -1
  17. package/dist/logger/bunyan.js +3 -2
  18. package/dist/logger/bunyan.js.map +1 -1
  19. package/dist/logger/pretty-stdout.js +2 -1
  20. package/dist/logger/pretty-stdout.js.map +1 -1
  21. package/dist/modules/datasource/apk/index.js +2 -2
  22. package/dist/modules/datasource/apk/index.js.map +1 -1
  23. package/dist/modules/datasource/artifactory/index.js +2 -3
  24. package/dist/modules/datasource/artifactory/index.js.map +1 -1
  25. package/dist/modules/datasource/bazel/index.js +2 -1
  26. package/dist/modules/datasource/bazel/index.js.map +1 -1
  27. package/dist/modules/datasource/cdnjs/index.js +2 -1
  28. package/dist/modules/datasource/cdnjs/index.js.map +1 -1
  29. package/dist/modules/datasource/common.d.ts +9 -0
  30. package/dist/modules/datasource/common.js +20 -2
  31. package/dist/modules/datasource/common.js.map +1 -1
  32. package/dist/modules/datasource/conda/index.js +2 -1
  33. package/dist/modules/datasource/conda/index.js.map +1 -1
  34. package/dist/modules/datasource/crate/index.js +2 -1
  35. package/dist/modules/datasource/crate/index.js.map +1 -1
  36. package/dist/modules/datasource/dart-version/index.js +2 -1
  37. package/dist/modules/datasource/dart-version/index.js.map +1 -1
  38. package/dist/modules/datasource/datasource.js +2 -2
  39. package/dist/modules/datasource/datasource.js.map +1 -1
  40. package/dist/modules/datasource/deb/url.js +3 -1
  41. package/dist/modules/datasource/deb/url.js.map +1 -1
  42. package/dist/modules/datasource/devbox/index.js +2 -1
  43. package/dist/modules/datasource/devbox/index.js.map +1 -1
  44. package/dist/modules/datasource/docker/common.js +10 -8
  45. package/dist/modules/datasource/docker/common.js.map +1 -1
  46. package/dist/modules/datasource/docker/ecr.js +2 -1
  47. package/dist/modules/datasource/docker/ecr.js.map +1 -1
  48. package/dist/modules/datasource/docker/index.js +20 -17
  49. package/dist/modules/datasource/docker/index.js.map +1 -1
  50. package/dist/modules/datasource/gitea-tags/base.js +2 -3
  51. package/dist/modules/datasource/gitea-tags/base.js.map +1 -1
  52. package/dist/modules/datasource/github-tags/index.js +2 -1
  53. package/dist/modules/datasource/github-tags/index.js.map +1 -1
  54. package/dist/modules/datasource/gitlab-tags/index.js +2 -3
  55. package/dist/modules/datasource/gitlab-tags/index.js.map +1 -1
  56. package/dist/modules/datasource/go/base.js +1 -1
  57. package/dist/modules/datasource/go/base.js.map +1 -1
  58. package/dist/modules/datasource/go/common.js +8 -2
  59. package/dist/modules/datasource/go/common.js.map +1 -1
  60. package/dist/modules/datasource/go/env.js +2 -1
  61. package/dist/modules/datasource/go/env.js.map +1 -1
  62. package/dist/modules/datasource/go/releases-goproxy.js +7 -5
  63. package/dist/modules/datasource/go/releases-goproxy.js.map +1 -1
  64. package/dist/modules/datasource/helm/index.js +2 -1
  65. package/dist/modules/datasource/helm/index.js.map +1 -1
  66. package/dist/modules/datasource/hexpm-bob/index.js +2 -1
  67. package/dist/modules/datasource/hexpm-bob/index.js.map +1 -1
  68. package/dist/modules/datasource/index.js +4 -3
  69. package/dist/modules/datasource/index.js.map +1 -1
  70. package/dist/modules/datasource/java-version/adoptium.js +3 -2
  71. package/dist/modules/datasource/java-version/adoptium.js.map +1 -1
  72. package/dist/modules/datasource/java-version/graalvm.js +2 -1
  73. package/dist/modules/datasource/java-version/graalvm.js.map +1 -1
  74. package/dist/modules/datasource/maven/index.js.map +1 -1
  75. package/dist/modules/datasource/maven/util.js +7 -10
  76. package/dist/modules/datasource/maven/util.js.map +1 -1
  77. package/dist/modules/datasource/npm/npmrc.js +2 -2
  78. package/dist/modules/datasource/npm/npmrc.js.map +1 -1
  79. package/dist/modules/datasource/nuget/v3.js +3 -5
  80. package/dist/modules/datasource/nuget/v3.js.map +1 -1
  81. package/dist/modules/datasource/packagist/index.js +4 -5
  82. package/dist/modules/datasource/packagist/index.js.map +1 -1
  83. package/dist/modules/datasource/pod/index.js +4 -4
  84. package/dist/modules/datasource/pod/index.js.map +1 -1
  85. package/dist/modules/datasource/pypi/index.js +19 -11
  86. package/dist/modules/datasource/pypi/index.js.map +1 -1
  87. package/dist/modules/datasource/python-version/index.js +2 -3
  88. package/dist/modules/datasource/python-version/index.js.map +1 -1
  89. package/dist/modules/datasource/repology/index.js +4 -3
  90. package/dist/modules/datasource/repology/index.js.map +1 -1
  91. package/dist/modules/datasource/rpm/providers/common.js +3 -1
  92. package/dist/modules/datasource/rpm/providers/common.js.map +1 -1
  93. package/dist/modules/datasource/rubygems/index.js +2 -5
  94. package/dist/modules/datasource/rubygems/index.js.map +1 -1
  95. package/dist/modules/datasource/rubygems/versions-endpoint-cache.js +13 -18
  96. package/dist/modules/datasource/rubygems/versions-endpoint-cache.js.map +1 -1
  97. package/dist/modules/datasource/terraform-module/base.js +2 -1
  98. package/dist/modules/datasource/terraform-module/base.js.map +1 -1
  99. package/dist/modules/datasource/terraform-provider/index.js +2 -3
  100. package/dist/modules/datasource/terraform-provider/index.js.map +1 -1
  101. package/dist/modules/manager/apm/extract.js +44 -17
  102. package/dist/modules/manager/apm/extract.js.map +1 -1
  103. package/dist/modules/manager/apm/index.js +5 -1
  104. package/dist/modules/manager/apm/index.js.map +1 -1
  105. package/dist/modules/manager/bazel-module/parser/context.js +0 -1
  106. package/dist/modules/manager/bazel-module/parser/context.js.map +1 -1
  107. package/dist/modules/manager/bundler/host-rules.js +4 -1
  108. package/dist/modules/manager/bundler/host-rules.js.map +1 -1
  109. package/dist/modules/manager/composer/range.js +1 -1
  110. package/dist/modules/manager/composer/range.js.map +1 -1
  111. package/dist/modules/manager/custom/utils.js +3 -1
  112. package/dist/modules/manager/custom/utils.js.map +1 -1
  113. package/dist/modules/manager/devbox/schema.js +2 -1
  114. package/dist/modules/manager/devbox/schema.js.map +1 -1
  115. package/dist/modules/manager/dockerfile/extract.js +10 -2
  116. package/dist/modules/manager/dockerfile/extract.js.map +1 -1
  117. package/dist/modules/manager/fingerprint.generated.js +3 -3
  118. package/dist/modules/manager/fingerprint.generated.js.map +1 -1
  119. package/dist/modules/manager/github-actions/parse.js +2 -1
  120. package/dist/modules/manager/github-actions/parse.js.map +1 -1
  121. package/dist/modules/manager/gomod/artifacts.js +5 -2
  122. package/dist/modules/manager/gomod/artifacts.js.map +1 -1
  123. package/dist/modules/manager/gradle/artifacts.js +5 -2
  124. package/dist/modules/manager/gradle/artifacts.js.map +1 -1
  125. package/dist/modules/manager/gradle/utils.js +2 -1
  126. package/dist/modules/manager/gradle/utils.js.map +1 -1
  127. package/dist/modules/manager/gradle-wrapper/utils.js +9 -5
  128. package/dist/modules/manager/gradle-wrapper/utils.js.map +1 -1
  129. package/dist/modules/manager/helm-values/util.js +1 -1
  130. package/dist/modules/manager/helm-values/util.js.map +1 -1
  131. package/dist/modules/manager/helmfile/artifacts.js +1 -1
  132. package/dist/modules/manager/helmfile/artifacts.js.map +1 -1
  133. package/dist/modules/manager/helmv3/artifacts.js +1 -1
  134. package/dist/modules/manager/helmv3/artifacts.js.map +1 -1
  135. package/dist/modules/manager/maven/extract.js +5 -2
  136. package/dist/modules/manager/maven/extract.js.map +1 -1
  137. package/dist/modules/manager/maven-wrapper/artifacts.js +3 -2
  138. package/dist/modules/manager/maven-wrapper/artifacts.js.map +1 -1
  139. package/dist/modules/manager/mise/artifacts.js +2 -1
  140. package/dist/modules/manager/mise/artifacts.js.map +1 -1
  141. package/dist/modules/manager/mise/extract.js.map +1 -1
  142. package/dist/modules/manager/nix/extract.js +1 -2
  143. package/dist/modules/manager/nix/extract.js.map +1 -1
  144. package/dist/modules/manager/npm/artifacts.js +3 -1
  145. package/dist/modules/manager/npm/artifacts.js.map +1 -1
  146. package/dist/modules/manager/npm/extract/common/dependency.js +4 -1
  147. package/dist/modules/manager/npm/extract/common/dependency.js.map +1 -1
  148. package/dist/modules/manager/npm/extract/common/package-file.js +2 -1
  149. package/dist/modules/manager/npm/extract/common/package-file.js.map +1 -1
  150. package/dist/modules/manager/npm/extract/index.js.map +1 -1
  151. package/dist/modules/manager/npm/extract/post/locked-versions.js.map +1 -1
  152. package/dist/modules/manager/npm/npmrc.js +2 -1
  153. package/dist/modules/manager/npm/npmrc.js.map +1 -1
  154. package/dist/modules/manager/npm/post-update/index.js +2 -1
  155. package/dist/modules/manager/npm/post-update/index.js.map +1 -1
  156. package/dist/modules/manager/npm/post-update/npm.js +2 -3
  157. package/dist/modules/manager/npm/post-update/npm.js.map +1 -1
  158. package/dist/modules/manager/npm/post-update/yarn.js.map +1 -1
  159. package/dist/modules/manager/npm/schema.js +6 -2
  160. package/dist/modules/manager/npm/schema.js.map +1 -1
  161. package/dist/modules/manager/npm/update/dependency/index.js +3 -2
  162. package/dist/modules/manager/npm/update/dependency/index.js.map +1 -1
  163. package/dist/modules/manager/npm/update/locked-dependency/common/parent-version.js +6 -2
  164. package/dist/modules/manager/npm/update/locked-dependency/common/parent-version.js.map +1 -1
  165. package/dist/modules/manager/npm/update/locked-dependency/package-lock/get-locked.js +2 -1
  166. package/dist/modules/manager/npm/update/locked-dependency/package-lock/get-locked.js.map +1 -1
  167. package/dist/modules/manager/nuget/package-tree.js +2 -1
  168. package/dist/modules/manager/nuget/package-tree.js.map +1 -1
  169. package/dist/modules/manager/paket/update-locked.js +4 -1
  170. package/dist/modules/manager/paket/update-locked.js.map +1 -1
  171. package/dist/modules/manager/pipenv/extract.js +4 -1
  172. package/dist/modules/manager/pipenv/extract.js.map +1 -1
  173. package/dist/modules/platform/azure/azure-helper.js +2 -1
  174. package/dist/modules/platform/azure/azure-helper.js.map +1 -1
  175. package/dist/modules/platform/azure/index.js +10 -6
  176. package/dist/modules/platform/azure/index.js.map +1 -1
  177. package/dist/modules/platform/bitbucket/index.js +13 -6
  178. package/dist/modules/platform/bitbucket/index.js.map +1 -1
  179. package/dist/modules/platform/bitbucket-server/index.js +13 -9
  180. package/dist/modules/platform/bitbucket-server/index.js.map +1 -1
  181. package/dist/modules/platform/codecommit/index.js +2 -2
  182. package/dist/modules/platform/codecommit/index.js.map +1 -1
  183. package/dist/modules/platform/gerrit/client.js +4 -1
  184. package/dist/modules/platform/gerrit/client.js.map +1 -1
  185. package/dist/modules/platform/gerrit/index.js +3 -2
  186. package/dist/modules/platform/gerrit/index.js.map +1 -1
  187. package/dist/modules/platform/gitea/gitea-helper.js +5 -4
  188. package/dist/modules/platform/gitea/gitea-helper.js.map +1 -1
  189. package/dist/modules/platform/gitea/index.js +11 -4
  190. package/dist/modules/platform/gitea/index.js.map +1 -1
  191. package/dist/modules/platform/github/index.js +37 -24
  192. package/dist/modules/platform/github/index.js.map +1 -1
  193. package/dist/modules/platform/gitlab/index.js +16 -9
  194. package/dist/modules/platform/gitlab/index.js.map +1 -1
  195. package/dist/modules/platform/scm-manager/index.js +4 -1
  196. package/dist/modules/platform/scm-manager/index.js.map +1 -1
  197. package/dist/modules/platform/scm-manager/utils.js +2 -1
  198. package/dist/modules/platform/scm-manager/utils.js.map +1 -1
  199. package/dist/modules/versioning/cargo/index.js.map +1 -1
  200. package/dist/modules/versioning/composer/index.js +2 -1
  201. package/dist/modules/versioning/composer/index.js.map +1 -1
  202. package/dist/modules/versioning/conan/common.js +4 -1
  203. package/dist/modules/versioning/conan/common.js.map +1 -1
  204. package/dist/modules/versioning/debian/index.js +2 -1
  205. package/dist/modules/versioning/debian/index.js.map +1 -1
  206. package/dist/modules/versioning/gradle/compare.js +2 -1
  207. package/dist/modules/versioning/gradle/compare.js.map +1 -1
  208. package/dist/modules/versioning/hex/index.js +2 -1
  209. package/dist/modules/versioning/hex/index.js.map +1 -1
  210. package/dist/modules/versioning/julia/index.js.map +1 -1
  211. package/dist/modules/versioning/maven/compare.js +17 -7
  212. package/dist/modules/versioning/maven/compare.js.map +1 -1
  213. package/dist/modules/versioning/npm/index.js +2 -1
  214. package/dist/modules/versioning/npm/index.js.map +1 -1
  215. package/dist/modules/versioning/npm/range.js.map +1 -1
  216. package/dist/modules/versioning/paket/index.js +2 -1
  217. package/dist/modules/versioning/paket/index.js.map +1 -1
  218. package/dist/modules/versioning/paket/range.js +7 -3
  219. package/dist/modules/versioning/paket/range.js.map +1 -1
  220. package/dist/modules/versioning/pep440/index.js +2 -1
  221. package/dist/modules/versioning/pep440/index.js.map +1 -1
  222. package/dist/modules/versioning/poetry/index.js +2 -1
  223. package/dist/modules/versioning/poetry/index.js.map +1 -1
  224. package/dist/modules/versioning/regex/index.js +1 -1
  225. package/dist/modules/versioning/regex/index.js.map +1 -1
  226. package/dist/modules/versioning/rez/index.js +2 -1
  227. package/dist/modules/versioning/rez/index.js.map +1 -1
  228. package/dist/modules/versioning/vcpkg/index.js +2 -1
  229. package/dist/modules/versioning/vcpkg/index.js.map +1 -1
  230. package/dist/util/cache/package/impl/base.js +2 -1
  231. package/dist/util/cache/package/impl/base.js.map +1 -1
  232. package/dist/util/cache/package/with-cache.js +2 -1
  233. package/dist/util/cache/package/with-cache.js.map +1 -1
  234. package/dist/util/check-token.js +7 -4
  235. package/dist/util/check-token.js.map +1 -1
  236. package/dist/util/exec/utils.js +4 -1
  237. package/dist/util/exec/utils.js.map +1 -1
  238. package/dist/util/git/auth.js +5 -1
  239. package/dist/util/git/auth.js.map +1 -1
  240. package/dist/util/git/error.js.map +1 -1
  241. package/dist/util/git/private-key.js +5 -0
  242. package/dist/util/git/private-key.js.map +1 -1
  243. package/dist/util/host-rules.js +5 -3
  244. package/dist/util/host-rules.js.map +1 -1
  245. package/dist/util/http/cache/abstract-http-cache-provider.js +3 -2
  246. package/dist/util/http/cache/abstract-http-cache-provider.js.map +1 -1
  247. package/dist/util/http/cache/package-http-cache-provider.js +2 -1
  248. package/dist/util/http/cache/package-http-cache-provider.js.map +1 -1
  249. package/dist/util/http/github.js +15 -11
  250. package/dist/util/http/github.js.map +1 -1
  251. package/dist/util/http/gitlab.js +5 -4
  252. package/dist/util/http/gitlab.js.map +1 -1
  253. package/dist/util/http/http.js +2 -1
  254. package/dist/util/http/http.js.map +1 -1
  255. package/dist/util/http/jwt.js +2 -1
  256. package/dist/util/http/jwt.js.map +1 -1
  257. package/dist/util/http/retry-after.js +2 -1
  258. package/dist/util/http/retry-after.js.map +1 -1
  259. package/dist/util/http/status.js +95 -0
  260. package/dist/util/http/status.js.map +1 -0
  261. package/dist/util/merge-confidence/index.js +3 -2
  262. package/dist/util/merge-confidence/index.js.map +1 -1
  263. package/dist/util/package-rules/current-version.js +4 -1
  264. package/dist/util/package-rules/current-version.js.map +1 -1
  265. package/dist/util/package-rules/index.js +7 -3
  266. package/dist/util/package-rules/index.js.map +1 -1
  267. package/dist/util/schema-utils/index.js +5 -0
  268. package/dist/util/schema-utils/index.js.map +1 -1
  269. package/dist/workers/global/config/parse/host-rules-from-env.js +2 -1
  270. package/dist/workers/global/config/parse/host-rules-from-env.js.map +1 -1
  271. package/dist/workers/repository/common.js +4 -1
  272. package/dist/workers/repository/common.js.map +1 -1
  273. package/dist/workers/repository/config-migration/branch/index.js +2 -1
  274. package/dist/workers/repository/config-migration/branch/index.js.map +1 -1
  275. package/dist/workers/repository/dependency-dashboard.js +6 -2
  276. package/dist/workers/repository/dependency-dashboard.js.map +1 -1
  277. package/dist/workers/repository/finalize/repository-statistics.js +4 -1
  278. package/dist/workers/repository/finalize/repository-statistics.js.map +1 -1
  279. package/dist/workers/repository/init/merge.js +13 -3
  280. package/dist/workers/repository/init/merge.js.map +1 -1
  281. package/dist/workers/repository/onboarding/branch/check.js +2 -1
  282. package/dist/workers/repository/onboarding/branch/check.js.map +1 -1
  283. package/dist/workers/repository/onboarding/pr/pr-list.js +4 -2
  284. package/dist/workers/repository/onboarding/pr/pr-list.js.map +1 -1
  285. package/dist/workers/repository/process/extract-update.js +4 -1
  286. package/dist/workers/repository/process/extract-update.js.map +1 -1
  287. package/dist/workers/repository/process/lookup/digest.js +2 -1
  288. package/dist/workers/repository/process/lookup/digest.js.map +1 -1
  289. package/dist/workers/repository/process/lookup/generate.js +1 -1
  290. package/dist/workers/repository/process/lookup/generate.js.map +1 -1
  291. package/dist/workers/repository/process/lookup/index.js +4 -1
  292. package/dist/workers/repository/process/lookup/index.js.map +1 -1
  293. package/dist/workers/repository/process/lookup/utils.js +7 -1
  294. package/dist/workers/repository/process/lookup/utils.js.map +1 -1
  295. package/dist/workers/repository/process/vulnerabilities.js +10 -3
  296. package/dist/workers/repository/process/vulnerabilities.js.map +1 -1
  297. package/dist/workers/repository/reconfigure/index.js +2 -1
  298. package/dist/workers/repository/reconfigure/index.js.map +1 -1
  299. package/dist/workers/repository/update/branch/auto-replace.js +6 -2
  300. package/dist/workers/repository/update/branch/auto-replace.js.map +1 -1
  301. package/dist/workers/repository/update/branch/errors.js +2 -1
  302. package/dist/workers/repository/update/branch/errors.js.map +1 -1
  303. package/dist/workers/repository/update/branch/execute-post-upgrade-commands.js +2 -2
  304. package/dist/workers/repository/update/branch/execute-post-upgrade-commands.js.map +1 -1
  305. package/dist/workers/repository/update/branch/get-updated.js +1 -2
  306. package/dist/workers/repository/update/branch/get-updated.js.map +1 -1
  307. package/dist/workers/repository/update/branch/index.js +2 -1
  308. package/dist/workers/repository/update/branch/index.js.map +1 -1
  309. package/dist/workers/repository/update/branch/status-checks.js +2 -1
  310. package/dist/workers/repository/update/branch/status-checks.js.map +1 -1
  311. package/dist/workers/repository/update/pr/body/index.js.map +1 -1
  312. package/dist/workers/repository/update/pr/changelog/release-notes.js +6 -3
  313. package/dist/workers/repository/update/pr/changelog/release-notes.js.map +1 -1
  314. package/dist/workers/repository/update/pr/index.js +7 -3
  315. package/dist/workers/repository/update/pr/index.js.map +1 -1
  316. package/dist/workers/repository/updates/generate.js +6 -3
  317. package/dist/workers/repository/updates/generate.js.map +1 -1
  318. package/package.json +2 -2
  319. package/renovate-schema.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","names":["HttpError"],"sources":["../../../../lib/modules/datasource/gitea-tags/base.ts"],"sourcesContent":["import { logger } from '../../../logger/index.ts';\nimport type { PackageCacheNamespace } from '../../../util/cache/package/types.ts';\nimport { GiteaHttp } from '../../../util/http/gitea.ts';\nimport { HttpError } from '../../../util/http/index.ts';\nimport { parseUrl } from '../../../util/url.ts';\nimport { GitHostTagsDigestDatasource } from '../git-host-tags.ts';\nimport type { DigestConfig } from '../types.ts';\nimport { Commits, Tag } from './schema.ts';\nimport { getApiUrl, getSourceUrl } from './util.ts';\n\n/**\n * Shared implementation of the datasources which speak the Gitea API.\n *\n * Forgejo is a fork of Gitea and serves the same API, so the Forgejo\n * datasources extend the Gitea ones and only differ in their id, their default\n * registry URL and their cache namespace. The digest lookup is the same for\n * tags and releases, so it lives here and a subclass only fetches and maps the\n * releases of its own endpoint.\n */\nexport abstract class GiteaDatasource extends GitHostTagsDigestDatasource<GiteaHttp> {\n static readonly defaultRegistryUrls = ['https://gitea.com'];\n\n override getDefaultRegistryUrls(_packageName: string): string[] {\n return GiteaDatasource.defaultRegistryUrls;\n }\n\n protected abstract override readonly cacheNamespace: PackageCacheNamespace;\n\n override readonly releaseTimestampSupport = true;\n override readonly releaseTimestampNote: string;\n override readonly sourceUrlSupport = 'package';\n override readonly sourceUrlNote =\n 'The source URL is determined by using the `packageName` and `registryUrl`.';\n\n /**\n * @param releaseTimestampField the field of the endpoint `getReleases()` reads\n * which the release timestamp comes from, rendered into the generated\n * documentation.\n * @param http lets a subclass for another Gitea-compatible host supply a\n * client scoped to its own host type.\n */\n protected constructor(\n id: string,\n releaseTimestampField: string,\n http: GiteaHttp = new GiteaHttp(id),\n ) {\n super(id, http);\n this.releaseTimestampNote = `The release timestamp is determined from the \\`${releaseTimestampField}\\` field in the results.`;\n }\n\n static getSourceUrl(packageName: string, registryUrl?: string): string {\n return getSourceUrl(\n packageName,\n registryUrl ?? this.defaultRegistryUrls[0],\n );\n }\n\n protected getSourceUrl(packageName: string, registryUrl?: string): string {\n return getSourceUrl(packageName, this.getRegistryUrl(registryUrl));\n }\n\n /**\n * Self-hosted instances can serve private repositories.\n */\n protected override isPublic(registryUrl: string): boolean {\n return (\n parseUrl(registryUrl)?.hostname ===\n parseUrl(this.getDefaultRegistryUrls('')[0])?.hostname\n );\n }\n\n // fetchTagCommit fetches the commit hash for the specified tag\n protected async fetchTagCommit(\n registryUrl: string | undefined,\n repo: string,\n tag: string,\n ): Promise<string | null> {\n const url = `${getApiUrl(this.getRegistryUrl(registryUrl))}repos/${repo}/tags/${tag}`;\n\n const { body } = await this.http.getJson(url, Tag);\n\n return body.commit.sha;\n }\n\n // fetchLatestCommit fetches the latest commit of the main branch\n protected async fetchLatestCommit(\n registryUrl: string | undefined,\n repo: string,\n ): Promise<string | null> {\n const url = `${getApiUrl(\n this.getRegistryUrl(registryUrl),\n )}repos/${repo}/commits?stat=false&verification=false&files=false&page=1&limit=1`;\n const { body } = await this.http.getJson(url, Commits);\n\n if (body.length === 0) {\n return null;\n }\n\n return body[0].sha;\n }\n\n protected override async fetchDigest(\n config: DigestConfig,\n newValue?: string,\n ): Promise<string | null> {\n try {\n return await super.fetchDigest(config, newValue);\n } catch (err) {\n if (err instanceof HttpError && err.response?.statusCode === 404) {\n logger.debug(\n {\n giteaRepo: config.packageName,\n err,\n registryUrl: config.registryUrl,\n },\n 'Gitea repo or ref not found when getting commit',\n );\n return null;\n }\n this.handleGenericErrors(err);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmBA,IAAsB,kBA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AAO;IACtB,GACA,iDACF;IACA,OAAO;GACT;GACA,KAAK,oBAAoB,GAAG;EAC9B;CACF;AACF"}
1
+ {"version":3,"file":"base.js","names":[],"sources":["../../../../lib/modules/datasource/gitea-tags/base.ts"],"sourcesContent":["import { logger } from '../../../logger/index.ts';\nimport type { PackageCacheNamespace } from '../../../util/cache/package/types.ts';\nimport { GiteaHttp } from '../../../util/http/gitea.ts';\nimport { isNotFound } from '../../../util/http/status.ts';\nimport { parseUrl } from '../../../util/url.ts';\nimport { GitHostTagsDigestDatasource } from '../git-host-tags.ts';\nimport type { DigestConfig } from '../types.ts';\nimport { Commits, Tag } from './schema.ts';\nimport { getApiUrl, getSourceUrl } from './util.ts';\n\n/**\n * Shared implementation of the datasources which speak the Gitea API.\n *\n * Forgejo is a fork of Gitea and serves the same API, so the Forgejo\n * datasources extend the Gitea ones and only differ in their id, their default\n * registry URL and their cache namespace. The digest lookup is the same for\n * tags and releases, so it lives here and a subclass only fetches and maps the\n * releases of its own endpoint.\n */\nexport abstract class GiteaDatasource extends GitHostTagsDigestDatasource<GiteaHttp> {\n static readonly defaultRegistryUrls = ['https://gitea.com'];\n\n override getDefaultRegistryUrls(_packageName: string): string[] {\n return GiteaDatasource.defaultRegistryUrls;\n }\n\n protected abstract override readonly cacheNamespace: PackageCacheNamespace;\n\n override readonly releaseTimestampSupport = true;\n override readonly releaseTimestampNote: string;\n override readonly sourceUrlSupport = 'package';\n override readonly sourceUrlNote =\n 'The source URL is determined by using the `packageName` and `registryUrl`.';\n\n /**\n * @param releaseTimestampField the field of the endpoint `getReleases()` reads\n * which the release timestamp comes from, rendered into the generated\n * documentation.\n * @param http lets a subclass for another Gitea-compatible host supply a\n * client scoped to its own host type.\n */\n protected constructor(\n id: string,\n releaseTimestampField: string,\n http: GiteaHttp = new GiteaHttp(id),\n ) {\n super(id, http);\n this.releaseTimestampNote = `The release timestamp is determined from the \\`${releaseTimestampField}\\` field in the results.`;\n }\n\n static getSourceUrl(packageName: string, registryUrl?: string): string {\n return getSourceUrl(\n packageName,\n registryUrl ?? this.defaultRegistryUrls[0],\n );\n }\n\n protected getSourceUrl(packageName: string, registryUrl?: string): string {\n return getSourceUrl(packageName, this.getRegistryUrl(registryUrl));\n }\n\n /**\n * Self-hosted instances can serve private repositories.\n */\n protected override isPublic(registryUrl: string): boolean {\n return (\n parseUrl(registryUrl)?.hostname ===\n parseUrl(this.getDefaultRegistryUrls('')[0])?.hostname\n );\n }\n\n // fetchTagCommit fetches the commit hash for the specified tag\n protected async fetchTagCommit(\n registryUrl: string | undefined,\n repo: string,\n tag: string,\n ): Promise<string | null> {\n const url = `${getApiUrl(this.getRegistryUrl(registryUrl))}repos/${repo}/tags/${tag}`;\n\n const { body } = await this.http.getJson(url, Tag);\n\n return body.commit.sha;\n }\n\n // fetchLatestCommit fetches the latest commit of the main branch\n protected async fetchLatestCommit(\n registryUrl: string | undefined,\n repo: string,\n ): Promise<string | null> {\n const url = `${getApiUrl(\n this.getRegistryUrl(registryUrl),\n )}repos/${repo}/commits?stat=false&verification=false&files=false&page=1&limit=1`;\n const { body } = await this.http.getJson(url, Commits);\n\n if (body.length === 0) {\n return null;\n }\n\n return body[0].sha;\n }\n\n protected override async fetchDigest(\n config: DigestConfig,\n newValue?: string,\n ): Promise<string | null> {\n try {\n return await super.fetchDigest(config, newValue);\n } catch (err) {\n if (isNotFound(err)) {\n logger.debug(\n {\n giteaRepo: config.packageName,\n err,\n registryUrl: config.registryUrl,\n },\n 'Gitea repo or ref not found when getting commit',\n );\n return null;\n }\n this.handleGenericErrors(err);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAmBA,IAAsB,kBAAtB,MAAsB,wBAAwB,4BAAuC;CACnF,OAAgB,sBAAsB,CAAC,mBAAmB;CAE1D,uBAAgC,cAAgC;EAC9D,OAAO,gBAAgB;CACzB;CAIA,0BAA4C;CAC5C;CACA,mBAAqC;CACrC,gBACE;;;;;;;;CASF,YACE,IACA,uBACA,OAAkB,IAAI,UAAU,EAAE,GAClC;EACA,MAAM,IAAI,IAAI;EACd,KAAK,uBAAuB,kDAAkD,sBAAsB;CACtG;CAEA,OAAO,aAAa,aAAqB,aAA8B;EACrE,OAAO,aACL,aACA,eAAe,KAAK,oBAAoB,EAC1C;CACF;CAEA,aAAuB,aAAqB,aAA8B;EACxE,OAAO,aAAa,aAAa,KAAK,eAAe,WAAW,CAAC;CACnE;;;;CAKA,SAA4B,aAA8B;EACxD,OACE,SAAS,WAAW,CAAC,EAAE,aACvB,SAAS,KAAK,uBAAuB,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE;CAElD;CAGA,MAAgB,eACd,aACA,MACA,KACwB;EACxB,MAAM,MAAM,GAAG,UAAU,KAAK,eAAe,WAAW,CAAC,EAAE,QAAQ,KAAK,QAAQ;EAEhF,MAAM,EAAE,SAAS,MAAM,KAAK,KAAK,QAAQ,KAAK,GAAG;EAEjD,OAAO,KAAK,OAAO;CACrB;CAGA,MAAgB,kBACd,aACA,MACwB;EACxB,MAAM,MAAM,GAAG,UACb,KAAK,eAAe,WAAW,CACjC,EAAE,QAAQ,KAAK;EACf,MAAM,EAAE,SAAS,MAAM,KAAK,KAAK,QAAQ,KAAK,OAAO;EAErD,IAAI,KAAK,WAAW,GAClB,OAAO;EAGT,OAAO,KAAK,EAAE,CAAC;CACjB;CAEA,MAAyB,YACvB,QACA,UACwB;EACxB,IAAI;GACF,OAAO,MAAM,MAAM,YAAY,QAAQ,QAAQ;EACjD,SAAS,KAAK;GACZ,IAAI,WAAW,GAAG,GAAG;IACnB,OAAO,MACL;KACE,WAAW,OAAO;KAClB;KACA,aAAa,OAAO;IACtB,GACA,iDACF;IACA,OAAO;GACT;GACA,KAAK,oBAAoB,GAAG;EAC9B;CACF;AACF"}
@@ -58,7 +58,8 @@ var GithubTagsDatasource = class GithubTagsDatasource extends GitHostTagsDigestD
58
58
  const isReleaseStable = releasesMap.get(release.version)?.isStable;
59
59
  if (isBoolean(isReleaseStable)) release.isStable = isReleaseStable;
60
60
  const releaseTimestamp = releasesMap.get(release.version)?.releaseTimestamp;
61
- if (releaseTimestamp && (isNullOrUndefined(release.releaseTimestamp) || releaseTimestamp > release.releaseTimestamp)) release.releaseTimestamp = releaseTimestamp;
61
+ if (!releaseTimestamp) continue;
62
+ if (isNullOrUndefined(release.releaseTimestamp) || releaseTimestamp > release.releaseTimestamp) release.releaseTimestamp = releaseTimestamp;
62
63
  }
63
64
  } catch (err) /* istanbul ignore next */ {
64
65
  logger.debug({ err }, `Error fetching additional info for GitHub tags`);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../../lib/modules/datasource/github-tags/index.ts"],"sourcesContent":["import { isBoolean, isNullOrUndefined } from '@sindresorhus/is';\nimport { logger } from '../../../logger/index.ts';\nimport {\n queryReleases,\n queryTags,\n} from '../../../util/github/graphql/index.ts';\nimport type { GithubReleaseItem } from '../../../util/github/graphql/types.ts';\nimport { findCommitOfTag } from '../../../util/github/tags.ts';\nimport { getApiBaseUrl, getSourceUrl } from '../../../util/github/url.ts';\nimport { memCacheProvider } from '../../../util/http/cache/memory-http-cache-provider.ts';\nimport { GithubHttp } from '../../../util/http/github.ts';\nimport { GitHostTagsDigestDatasource } from '../git-host-tags.ts';\nimport type { GetReleasesConfig, GitHostTag } from '../types.ts';\n\nexport class GithubTagsDatasource extends GitHostTagsDigestDatasource<GithubHttp> {\n static readonly id = 'github-tags';\n\n protected getSourceUrl(packageName: string, registryUrl?: string): string {\n return getSourceUrl(packageName, registryUrl);\n }\n\n override getDefaultRegistryUrls(_packageName: string): string[] {\n return ['https://github.com'];\n }\n\n override readonly registryStrategy = 'hunt';\n\n // the GraphQL fetcher caches the tags and releases itself, and the latest\n // commit lookup uses the HTTP memory cache\n protected override cachedLookup<T>(\n _registryUrl: string | undefined,\n _key: string,\n fn: () => Promise<T>,\n ): Promise<T> {\n return fn();\n }\n\n override readonly releaseTimestampSupport = true;\n // Note: not sure\n override readonly releaseTimestampNote =\n 'The get release timestamp is determined from the `releaseTimestamp` field in the results.';\n override readonly sourceUrlSupport = 'package';\n override readonly sourceUrlNote =\n 'The source URL is determined by using the `packageName` and `registryUrl`.';\n\n constructor() {\n super(GithubTagsDatasource.id, new GithubHttp(GithubTagsDatasource.id));\n }\n\n protected fetchTagCommit(\n registryUrl: string | undefined,\n repo: string,\n tag: string,\n ): Promise<string | null> {\n return findCommitOfTag(registryUrl, repo, tag, this.http);\n }\n\n protected async fetchLatestCommit(\n registryUrl: string | undefined,\n githubRepo: string,\n ): Promise<string | null> {\n const apiBaseUrl = getApiBaseUrl(registryUrl);\n let digest: string | null = null;\n try {\n const url = `${apiBaseUrl}repos/${githubRepo}/commits?per_page=1`;\n const res = await this.http.getJsonUnchecked<{ sha: string }[]>(url, {\n cacheProvider: memCacheProvider,\n });\n digest = res.body[0].sha;\n } catch (err) {\n logger.debug(\n { githubRepo, err, registryUrl },\n 'Error getting latest commit from GitHub repo',\n );\n }\n return digest;\n }\n\n protected async fetchTags(config: GetReleasesConfig): Promise<GitHostTag[]> {\n const tagsResult = await queryTags(config, this.http);\n const releases: GitHostTag[] = tagsResult.map(\n ({ version, releaseTimestamp, hash }) => ({\n newDigest: hash,\n version,\n releaseTimestamp,\n }),\n );\n\n try {\n // Fetch additional data from releases endpoint when possible\n const releasesResult = await queryReleases(config, this.http);\n const releasesMap = new Map<string, GithubReleaseItem>();\n for (const release of releasesResult) {\n releasesMap.set(release.version, release);\n }\n\n for (const release of releases) {\n const isReleaseStable = releasesMap.get(release.version)?.isStable;\n if (isBoolean(isReleaseStable)) {\n release.isStable = isReleaseStable;\n }\n\n const releaseTimestamp = releasesMap.get(\n release.version,\n )?.releaseTimestamp;\n if (\n releaseTimestamp &&\n (isNullOrUndefined(release.releaseTimestamp) ||\n releaseTimestamp > release.releaseTimestamp)\n ) {\n release.releaseTimestamp = releaseTimestamp;\n }\n }\n } catch (err) /* istanbul ignore next */ {\n logger.debug({ err }, `Error fetching additional info for GitHub tags`);\n }\n\n return releases;\n }\n}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,eAAe,GAC3B,QAAQ,WAAW;IAGrB,MAAM,mBAAmB,YAAY,IACnC,QAAQ,OACV,CAAC,EAAE;IACH,IACE,qBACC,kBAAkB,QAAQ,gBAAgB,KACzC,mBAAmB,QAAQ,mBAE7B,QAAQ,mBAAmB;GAE/B;EACF,SAAS,gCAAgC;GACvC,OAAO,MAAM,EAAE,IAAI,GAAG,gDAAgD;EACxE;EAEA,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../lib/modules/datasource/github-tags/index.ts"],"sourcesContent":["import { isBoolean, isNullOrUndefined } from '@sindresorhus/is';\nimport { logger } from '../../../logger/index.ts';\nimport {\n queryReleases,\n queryTags,\n} from '../../../util/github/graphql/index.ts';\nimport type { GithubReleaseItem } from '../../../util/github/graphql/types.ts';\nimport { findCommitOfTag } from '../../../util/github/tags.ts';\nimport { getApiBaseUrl, getSourceUrl } from '../../../util/github/url.ts';\nimport { memCacheProvider } from '../../../util/http/cache/memory-http-cache-provider.ts';\nimport { GithubHttp } from '../../../util/http/github.ts';\nimport { GitHostTagsDigestDatasource } from '../git-host-tags.ts';\nimport type { GetReleasesConfig, GitHostTag } from '../types.ts';\n\nexport class GithubTagsDatasource extends GitHostTagsDigestDatasource<GithubHttp> {\n static readonly id = 'github-tags';\n\n protected getSourceUrl(packageName: string, registryUrl?: string): string {\n return getSourceUrl(packageName, registryUrl);\n }\n\n override getDefaultRegistryUrls(_packageName: string): string[] {\n return ['https://github.com'];\n }\n\n override readonly registryStrategy = 'hunt';\n\n // the GraphQL fetcher caches the tags and releases itself, and the latest\n // commit lookup uses the HTTP memory cache\n protected override cachedLookup<T>(\n _registryUrl: string | undefined,\n _key: string,\n fn: () => Promise<T>,\n ): Promise<T> {\n return fn();\n }\n\n override readonly releaseTimestampSupport = true;\n // Note: not sure\n override readonly releaseTimestampNote =\n 'The get release timestamp is determined from the `releaseTimestamp` field in the results.';\n override readonly sourceUrlSupport = 'package';\n override readonly sourceUrlNote =\n 'The source URL is determined by using the `packageName` and `registryUrl`.';\n\n constructor() {\n super(GithubTagsDatasource.id, new GithubHttp(GithubTagsDatasource.id));\n }\n\n protected fetchTagCommit(\n registryUrl: string | undefined,\n repo: string,\n tag: string,\n ): Promise<string | null> {\n return findCommitOfTag(registryUrl, repo, tag, this.http);\n }\n\n protected async fetchLatestCommit(\n registryUrl: string | undefined,\n githubRepo: string,\n ): Promise<string | null> {\n const apiBaseUrl = getApiBaseUrl(registryUrl);\n let digest: string | null = null;\n try {\n const url = `${apiBaseUrl}repos/${githubRepo}/commits?per_page=1`;\n const res = await this.http.getJsonUnchecked<{ sha: string }[]>(url, {\n cacheProvider: memCacheProvider,\n });\n digest = res.body[0].sha;\n } catch (err) {\n logger.debug(\n { githubRepo, err, registryUrl },\n 'Error getting latest commit from GitHub repo',\n );\n }\n return digest;\n }\n\n protected async fetchTags(config: GetReleasesConfig): Promise<GitHostTag[]> {\n const tagsResult = await queryTags(config, this.http);\n const releases: GitHostTag[] = tagsResult.map(\n ({ version, releaseTimestamp, hash }) => ({\n newDigest: hash,\n version,\n releaseTimestamp,\n }),\n );\n\n try {\n // Fetch additional data from releases endpoint when possible\n const releasesResult = await queryReleases(config, this.http);\n const releasesMap = new Map<string, GithubReleaseItem>();\n for (const release of releasesResult) {\n releasesMap.set(release.version, release);\n }\n\n for (const release of releases) {\n const isReleaseStable = releasesMap.get(release.version)?.isStable;\n if (isBoolean(isReleaseStable)) {\n release.isStable = isReleaseStable;\n }\n\n const releaseTimestamp = releasesMap.get(\n release.version,\n )?.releaseTimestamp;\n if (!releaseTimestamp) {\n continue;\n }\n\n if (\n isNullOrUndefined(release.releaseTimestamp) ||\n releaseTimestamp > release.releaseTimestamp\n ) {\n release.releaseTimestamp = releaseTimestamp;\n }\n }\n } catch (err) /* istanbul ignore next */ {\n logger.debug({ err }, `Error fetching additional info for GitHub tags`);\n }\n\n return releases;\n }\n}\n"],"mappings":";;;;;;;;;AAcA,IAAa,uBAAb,MAAa,6BAA6B,4B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nC,QAAQ,OACV,CAAC,EAAE;IACH,IAAI,CAAC,kBACH;IAGF,IACE,kBAAkB,QAAQ,gBAAgB,KAC1C,mBAAmB,QAAQ,kBAE3B,QAAQ,mBAAmB;GAE/B;EACF,SAAS,gCAAgC;GACvC,OAAO,MAAM,EAAE,IAAI,GAAG,gDAAgD;EACxE;EAEA,OAAO;CACT;AACF"}
@@ -1,7 +1,6 @@
1
1
  import { logger } from "../../../logger/index.js";
2
2
  import { joinUrlParts } from "../../../util/url.js";
3
- import { RequestError } from "../../../util/http/got.js";
4
- import "../../../util/http/index.js";
3
+ import { isNotFound } from "../../../util/http/status.js";
5
4
  import { asTimestamp } from "../../../util/timestamp.js";
6
5
  import { GitHostTagsDigestDatasource } from "../git-host-tags.js";
7
6
  import { defaultRegistryUrl, getApiBaseUrl, getDepHost, getSourceUrl } from "../../../util/gitlab/url.js";
@@ -47,7 +46,7 @@ var GitlabTagsDatasource = class GitlabTagsDatasource extends GitHostTagsDigestD
47
46
  try {
48
47
  return await super.fetchDigest(config, newValue);
49
48
  } catch (err) {
50
- if (err instanceof RequestError && err.response?.statusCode === 404) {
49
+ if (isNotFound(err)) {
51
50
  logger.debug({
52
51
  gitlabRepo: config.packageName,
53
52
  err,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["HttpError"],"sources":["../../../../lib/modules/datasource/gitlab-tags/index.ts"],"sourcesContent":["import { logger } from '../../../logger/index.ts';\nimport {\n defaultRegistryUrl,\n getApiBaseUrl,\n getDepHost,\n getSourceUrl,\n} from '../../../util/gitlab/url.ts';\nimport { GitlabHttp } from '../../../util/http/gitlab.ts';\nimport { HttpError } from '../../../util/http/index.ts';\nimport { asTimestamp } from '../../../util/timestamp.ts';\nimport { joinUrlParts } from '../../../util/url.ts';\nimport { GitHostTagsDigestDatasource } from '../git-host-tags.ts';\nimport type { DigestConfig, GetReleasesConfig, GitHostTag } from '../types.ts';\nimport { GitlabCommit, GitlabCommits, GitlabTags } from './schema.ts';\n\nexport class GitlabTagsDatasource extends GitHostTagsDigestDatasource<GitlabHttp> {\n static readonly id = 'gitlab-tags';\n\n protected getSourceUrl(packageName: string, registryUrl?: string): string {\n return getSourceUrl(packageName, registryUrl);\n }\n\n override readonly releaseTimestampSupport = true;\n override readonly releaseTimestampNote =\n 'To get release timestamp we use the `created_at` field from the response.';\n override readonly sourceUrlSupport = 'package';\n override readonly sourceUrlNote =\n 'The source URL is determined by using the `packageName` and `registryUrl`.';\n\n constructor() {\n super(GitlabTagsDatasource.id, new GitlabHttp(GitlabTagsDatasource.id));\n }\n\n override getDefaultRegistryUrls(_packageName: string): string[] {\n return [defaultRegistryUrl];\n }\n\n /** Strips the `/api/v4` suffix, so both spellings share a cache key. */\n protected override getRegistryUrl(registryUrl?: string): string {\n return getDepHost(registryUrl);\n }\n\n protected async fetchTags({\n registryUrl,\n packageName: repo,\n }: GetReleasesConfig): Promise<GitHostTag[]> {\n const apiBaseUrl = getApiBaseUrl(registryUrl);\n\n const urlEncodedRepo = encodeURIComponent(repo);\n\n // tag\n const url = joinUrlParts(\n apiBaseUrl,\n `projects`,\n urlEncodedRepo,\n `repository/tags?per_page=100`,\n );\n\n const gitlabTags = (\n await this.http.getJson(url, { paginate: true }, GitlabTags)\n ).body;\n\n return gitlabTags.map(({ name, commit }) => ({\n version: name,\n releaseTimestamp: asTimestamp(commit.created_at),\n }));\n }\n\n protected async fetchTagCommit(\n registryUrl: string | undefined,\n repo: string,\n tag: string,\n ): Promise<string | null> {\n const url = joinUrlParts(\n getApiBaseUrl(registryUrl),\n `projects`,\n encodeURIComponent(repo),\n `repository/commits/`,\n encodeURIComponent(tag),\n );\n const gitlabCommit = await this.http.getJson(url, GitlabCommit);\n return gitlabCommit.body.id;\n }\n\n protected async fetchLatestCommit(\n registryUrl: string | undefined,\n repo: string,\n ): Promise<string | null> {\n const url = joinUrlParts(\n getApiBaseUrl(registryUrl),\n `projects`,\n encodeURIComponent(repo),\n `repository/commits?per_page=1`,\n );\n const gitlabCommits = await this.http.getJson(url, GitlabCommits);\n return gitlabCommits.body[0]?.id ?? null;\n }\n\n protected override async fetchDigest(\n config: DigestConfig,\n newValue?: string,\n ): Promise<string | null> {\n try {\n return await super.fetchDigest(config, newValue);\n } catch (err) {\n if (err instanceof HttpError && err.response?.statusCode === 404) {\n logger.debug(\n {\n gitlabRepo: config.packageName,\n err,\n registryUrl: config.registryUrl,\n },\n 'Gitlab repo or ref not found when getting commit',\n );\n return null;\n }\n this.handleGenericErrors(err);\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAeA,IAAa,uBAAb,MAAa,6BAA6B,4BAAwC;CAChF,OAAgB,KAAK;CAErB,aAAuB,aAAqB,aAA8B;EACxE,OAAO,aAAa,aAAa,WAAW;CAC9C;CAEA,0BAA4C;CAC5C,uBACE;CACF,mBAAqC;CACrC,gBACE;CAEF,cAAc;EACZ,MAAM,qBAAqB,IAAI,IAAI,WAAW,qBAAqB,EAAE,CAAC;CACxE;CAEA,uBAAgC,cAAgC;EAC9D,OAAO,CAAC,kBAAkB;CAC5B;;CAGA,eAAkC,aAA8B;EAC9D,OAAO,WAAW,WAAW;CAC/B;CAEA,MAAgB,UAAU,EACxB,aACA,aAAa,QAC8B;EAC3C,MAAM,aAAa,cAAc,WAAW;EAK5C,MAAM,MAAM,aACV,YACA,YALqB,mBAAmB,IAM3B,GACb,8BACF;EAMA,QAHE,MAAM,KAAK,KAAK,QAAQ,KAAK,EAAE,UAAU,KAAK,GAAG,UAAU,EAAA,CAC3D,KAEgB,KAAK,EAAE,MAAM,cAAc;GAC3C,SAAS;GACT,kBAAkB,YAAY,OAAO,UAAU;EACjD,EAAE;CACJ;CAEA,MAAgB,eACd,aACA,MACA,KACwB;EACxB,MAAM,MAAM,aACV,cAAc,WAAW,GACzB,YACA,mBAAmB,IAAI,GACvB,uBACA,mBAAmB,GAAG,CACxB;EAEA,QAAO,MADoB,KAAK,KAAK,QAAQ,KAAK,YAAY,EAAA,CAC1C,KAAK;CAC3B;CAEA,MAAgB,kBACd,aACA,MACwB;EACxB,MAAM,MAAM,aACV,cAAc,WAAW,GACzB,YACA,mBAAmB,IAAI,GACvB,+BACF;EAEA,QAAO,MADqB,KAAK,KAAK,QAAQ,KAAK,aAAa,EAAA,CAC3C,KAAK,EAAE,EAAE,MAAM;CACtC;CAEA,MAAyB,YACvB,QACA,UACwB;EACxB,IAAI;GACF,OAAO,MAAM,MAAM,YAAY,QAAQ,QAAQ;EACjD,SAAS,KAAK;GACZ,IAAI,eAAeA,gBAAa,IAAI,UAAU,eAAe,KAAK;IAChE,OAAO,MACL;KACE,YAAY,OAAO;KACnB;KACA,aAAa,OAAO;IACtB,GACA,kDACF;IACA,OAAO;GACT;GACA,KAAK,oBAAoB,GAAG;EAC9B;CACF;AACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../lib/modules/datasource/gitlab-tags/index.ts"],"sourcesContent":["import { logger } from '../../../logger/index.ts';\nimport {\n defaultRegistryUrl,\n getApiBaseUrl,\n getDepHost,\n getSourceUrl,\n} from '../../../util/gitlab/url.ts';\nimport { GitlabHttp } from '../../../util/http/gitlab.ts';\nimport { isNotFound } from '../../../util/http/status.ts';\nimport { asTimestamp } from '../../../util/timestamp.ts';\nimport { joinUrlParts } from '../../../util/url.ts';\nimport { GitHostTagsDigestDatasource } from '../git-host-tags.ts';\nimport type { DigestConfig, GetReleasesConfig, GitHostTag } from '../types.ts';\nimport { GitlabCommit, GitlabCommits, GitlabTags } from './schema.ts';\n\nexport class GitlabTagsDatasource extends GitHostTagsDigestDatasource<GitlabHttp> {\n static readonly id = 'gitlab-tags';\n\n protected getSourceUrl(packageName: string, registryUrl?: string): string {\n return getSourceUrl(packageName, registryUrl);\n }\n\n override readonly releaseTimestampSupport = true;\n override readonly releaseTimestampNote =\n 'To get release timestamp we use the `created_at` field from the response.';\n override readonly sourceUrlSupport = 'package';\n override readonly sourceUrlNote =\n 'The source URL is determined by using the `packageName` and `registryUrl`.';\n\n constructor() {\n super(GitlabTagsDatasource.id, new GitlabHttp(GitlabTagsDatasource.id));\n }\n\n override getDefaultRegistryUrls(_packageName: string): string[] {\n return [defaultRegistryUrl];\n }\n\n /** Strips the `/api/v4` suffix, so both spellings share a cache key. */\n protected override getRegistryUrl(registryUrl?: string): string {\n return getDepHost(registryUrl);\n }\n\n protected async fetchTags({\n registryUrl,\n packageName: repo,\n }: GetReleasesConfig): Promise<GitHostTag[]> {\n const apiBaseUrl = getApiBaseUrl(registryUrl);\n\n const urlEncodedRepo = encodeURIComponent(repo);\n\n // tag\n const url = joinUrlParts(\n apiBaseUrl,\n `projects`,\n urlEncodedRepo,\n `repository/tags?per_page=100`,\n );\n\n const gitlabTags = (\n await this.http.getJson(url, { paginate: true }, GitlabTags)\n ).body;\n\n return gitlabTags.map(({ name, commit }) => ({\n version: name,\n releaseTimestamp: asTimestamp(commit.created_at),\n }));\n }\n\n protected async fetchTagCommit(\n registryUrl: string | undefined,\n repo: string,\n tag: string,\n ): Promise<string | null> {\n const url = joinUrlParts(\n getApiBaseUrl(registryUrl),\n `projects`,\n encodeURIComponent(repo),\n `repository/commits/`,\n encodeURIComponent(tag),\n );\n const gitlabCommit = await this.http.getJson(url, GitlabCommit);\n return gitlabCommit.body.id;\n }\n\n protected async fetchLatestCommit(\n registryUrl: string | undefined,\n repo: string,\n ): Promise<string | null> {\n const url = joinUrlParts(\n getApiBaseUrl(registryUrl),\n `projects`,\n encodeURIComponent(repo),\n `repository/commits?per_page=1`,\n );\n const gitlabCommits = await this.http.getJson(url, GitlabCommits);\n return gitlabCommits.body[0]?.id ?? null;\n }\n\n protected override async fetchDigest(\n config: DigestConfig,\n newValue?: string,\n ): Promise<string | null> {\n try {\n return await super.fetchDigest(config, newValue);\n } catch (err) {\n if (isNotFound(err)) {\n logger.debug(\n {\n gitlabRepo: config.packageName,\n err,\n registryUrl: config.registryUrl,\n },\n 'Gitlab repo or ref not found when getting commit',\n );\n return null;\n }\n this.handleGenericErrors(err);\n }\n }\n}\n"],"mappings":";;;;;;;;;AAe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YAAY,OAAO;KACnB;KACA,aAAa,OAAO;IACtB,GACA,kDACF;IACA,OAAO;GACT;GACA,KAAK,oBAAoB,GAAG;EAC9B;CACF;AACF"}
@@ -58,7 +58,7 @@ var BaseGoDatasource = class BaseGoDatasource {
58
58
  }
59
59
  if (goModule.startsWith("dev.azure.com/")) {
60
60
  const split = goModule.split("/");
61
- if (split.length > 4 && split[3] === "_git" || split.length > 3) {
61
+ if (split.length > 3) {
62
62
  const packageName = `https://dev.azure.com/${split[1]}/${split[2]}/_git/${(split[3] === "_git" ? split[4] : split[3]).replace(regEx(/\.git$/), "")}`;
63
63
  return {
64
64
  datasource: GitTagsDatasource.id,
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","names":["modulePath","hostRules.hostType"],"sources":["../../../../lib/modules/datasource/go/base.ts"],"sourcesContent":["// TODO: types (#22198)\nimport { GlobalConfig } from '../../../config/global.ts';\nimport { logger } from '../../../logger/index.ts';\nimport { detectPlatform } from '../../../util/common.ts';\nimport * as hostRules from '../../../util/host-rules.ts';\nimport { Http } from '../../../util/http/index.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport {\n parseUrl,\n trimLeadingSlash,\n trimTrailingSlash,\n} from '../../../util/url.ts';\nimport { BitbucketTagsDatasource } from '../bitbucket-tags/index.ts';\nimport { ForgejoTagsDatasource } from '../forgejo-tags/index.ts';\nimport { GitTagsDatasource } from '../git-tags/index.ts';\nimport { GiteaTagsDatasource } from '../gitea-tags/index.ts';\nimport { GithubTagsDatasource } from '../github-tags/index.ts';\nimport { GitlabTagsDatasource } from '../gitlab-tags/index.ts';\nimport type { DataSource } from './types.ts';\n\n// TODO: figure out class hierarchy (#10532)\nexport class BaseGoDatasource {\n private static readonly gitlabHttpsRegExp = regEx(\n /^(?<httpsRegExpUrl>https:\\/\\/[^/]*gitlab\\.[^/]*)\\/(?<httpsRegExpName>.+?)(?:\\/v\\d+)?[/]?$/,\n );\n private static readonly gitlabRegExp = regEx(\n /^(?<regExpUrl>gitlab\\.[^/]*)\\/(?<regExpPath>.+?)(?:\\/v\\d+)?[/]?$/,\n );\n private static readonly gitVcsRegexp = regEx(\n /^(?:[^/]+)\\/(?<module>.*)\\.git(?:$|\\/)/,\n );\n private static readonly goImportRegexp = regEx(\n /<meta\\s+name=\"?go-import\"?\\s+content=\"(?<prefix>[^\"\\s]+)\\s+(?<proto>[^\"\\s]+)\\s+(?<goImportURL>[^\"\\s]+)/,\n );\n private static readonly goImportAllRegexp = regEx(\n BaseGoDatasource.goImportRegexp.source,\n 'g',\n );\n\n private static readonly id = 'go';\n private static readonly http = new Http(BaseGoDatasource.id);\n\n static async getDatasource(goModule: string): Promise<DataSource | null> {\n if (goModule.startsWith('gopkg.in/')) {\n const [pkg] = goModule.replace('gopkg.in/', '').split('.');\n const packageName = pkg.includes('/') ? pkg : `go-${pkg}/${pkg}`;\n return {\n datasource: GithubTagsDatasource.id,\n packageName,\n registryUrl: 'https://github.com',\n };\n }\n\n if (goModule.startsWith('github.com/')) {\n const split = goModule.split('/');\n const packageName = `${split[1]}/${split[2]}`;\n return {\n datasource: GithubTagsDatasource.id,\n packageName,\n registryUrl: 'https://github.com',\n };\n }\n\n if (goModule.startsWith('bitbucket.org/')) {\n const split = goModule.split('/');\n const packageName = `${split[1]}/${split[2]}`;\n return {\n datasource: BitbucketTagsDatasource.id,\n packageName,\n registryUrl: 'https://bitbucket.org',\n };\n }\n\n if (goModule.startsWith('code.cloudfoundry.org/')) {\n const packageName = goModule.replace(\n 'code.cloudfoundry.org',\n 'cloudfoundry',\n );\n return {\n datasource: GithubTagsDatasource.id,\n packageName,\n registryUrl: 'https://github.com',\n };\n }\n\n if (goModule.startsWith('dev.azure.com/')) {\n const split = goModule.split('/');\n if ((split.length > 4 && split[3] === '_git') || split.length > 3) {\n const packageName = `https://dev.azure.com/${split[1]}/${split[2]}/_git/${(split[3] === '_git' ? split[4] : split[3]).replace(regEx(/\\.git$/), '')}`;\n return {\n datasource: GitTagsDatasource.id,\n packageName,\n };\n }\n }\n\n //#region known gitea compatible hosts\n if (goModule.startsWith('gitea.com/')) {\n const split = goModule.split('/');\n const packageName = `${split[1]}/${split[2]}`;\n return {\n datasource: GiteaTagsDatasource.id,\n packageName,\n registryUrl: 'https://gitea.com',\n };\n }\n\n if (goModule.startsWith('code.forgejo.org/')) {\n const split = goModule.split('/');\n const packageName = `${split[1]}/${split[2]}`;\n return {\n datasource: ForgejoTagsDatasource.id,\n packageName,\n registryUrl: 'https://code.forgejo.org',\n };\n }\n\n if (goModule.startsWith('codeberg.org/')) {\n const split = goModule.split('/');\n const packageName = `${split[1]}/${split[2]}`;\n return {\n datasource: ForgejoTagsDatasource.id,\n packageName,\n registryUrl: 'https://codeberg.org',\n };\n }\n //#endregion\n\n return await BaseGoDatasource.goGetDatasource(goModule);\n }\n\n /**\n * Returns the module proxy URL that a `go-import` meta tag with the `mod` VCS advertises for the module.\n *\n * @see https://go.dev/ref/mod#serving-from-proxy\n */\n static async getModProxyUrl(goModule: string): Promise<string | null> {\n const html = await BaseGoDatasource.goGet(goModule);\n return BaseGoDatasource.findModProxyUrl(html, goModule);\n }\n\n /**\n * Finds the first `go-import` meta tag with the `mod` VCS whose prefix is a path prefix of the module.\n *\n * The proxy URL is controlled by the host serving the page, so only a valid `https:` URL is accepted, as with `go` (unless `GOINSECURE` is set).\n */\n private static findModProxyUrl(\n html: string,\n goModule: string,\n ): string | null {\n for (const match of html.matchAll(BaseGoDatasource.goImportAllRegexp)) {\n const { prefix, proto, goImportURL } = match.groups as Record<\n string,\n string\n >;\n\n if (\n proto !== 'mod' ||\n !(goModule === prefix || goModule.startsWith(`${prefix}/`))\n ) {\n continue;\n }\n\n if (parseUrl(goImportURL)?.protocol !== 'https:') {\n logger.debug(\n { goModule, goImportURL },\n 'Ignoring go-import mod proxy URL which is not a valid https URL',\n );\n continue;\n }\n\n return goImportURL;\n }\n\n return null;\n }\n\n private static async goGet(goModule: string): Promise<string> {\n const goModuleUrl = goModule.replace(regEx(/\\.git(?:\\/[a-z0-9/]*)?$/), '');\n const pkgUrl = `https://${goModuleUrl}?go-get=1`;\n const { body } = await BaseGoDatasource.http.getText(pkgUrl);\n return body;\n }\n\n private static async goGetDatasource(\n goModule: string,\n ): Promise<DataSource | null> {\n const html = await BaseGoDatasource.goGet(goModule);\n\n // `go` prefers a `mod` proxy over a VCS for the same module, so leave it to the caller to look it up\n if (BaseGoDatasource.findModProxyUrl(html, goModule)) {\n logger.debug(\n { goModule },\n 'Preferring go-import mod proxy over other go-import and go-source entries',\n );\n return null;\n }\n\n const goSourceHeader = BaseGoDatasource.goSourceHeader(html, goModule);\n if (goSourceHeader) {\n return goSourceHeader;\n }\n\n // GitHub Enterprise only returns a go-import meta\n const goImport = BaseGoDatasource.goImportHeader(html, goModule);\n if (goImport) {\n return goImport;\n }\n\n logger.trace({ goModule }, 'No go-source or go-import header found');\n /* istanbul ignore next */\n return null;\n }\n\n private static goSourceHeader(\n html: string,\n goModule: string,\n ): DataSource | null {\n const sourceMatchGroups = regEx(\n /<meta\\s+name=\"?go-source\"?\\s+content=\"(?<prefix>[^\"\\s]+)\\s+(?<goSourceUrl>[^\"\\s]+)/,\n ).exec(html)?.groups;\n if (!sourceMatchGroups) {\n return null;\n }\n const { prefix, goSourceUrl } = sourceMatchGroups;\n\n if (!goModule.startsWith(prefix)) {\n logger.trace({ goModule }, 'go-source header prefix not match');\n return null;\n }\n\n logger.debug(`Go lookup source url ${goSourceUrl} for module ${goModule}`);\n return this.detectDatasource(goSourceUrl, goModule);\n }\n\n private static detectDatasource(\n metadataUrl: string,\n goModule: string,\n ): DataSource | null {\n if (metadataUrl.startsWith('https://github.com/')) {\n return {\n datasource: GithubTagsDatasource.id,\n packageName: metadataUrl\n .replace('https://github.com/', '')\n .replace(regEx(/\\/$/), ''),\n registryUrl: 'https://github.com',\n };\n }\n\n const gitlabModuleName =\n BaseGoDatasource.gitlabRegExp.exec(goModule)?.groups?.regExpPath;\n const vcsIndicatedModule =\n BaseGoDatasource.gitVcsRegexp.exec(goModule)?.groups?.module;\n\n const metadataUrlMatchGroups =\n BaseGoDatasource.gitlabHttpsRegExp.exec(metadataUrl)?.groups;\n if (metadataUrlMatchGroups) {\n const { httpsRegExpUrl, httpsRegExpName } = metadataUrlMatchGroups;\n\n let packageName = vcsIndicatedModule ?? gitlabModuleName;\n\n // Detect submodules in monorepos by comparing metadata path and module path\n if (!vcsIndicatedModule && httpsRegExpName && gitlabModuleName) {\n const metadataPath = httpsRegExpName;\n const modulePath = gitlabModuleName;\n\n if (modulePath.startsWith(`${metadataPath}/`)) {\n packageName = metadataPath;\n }\n }\n\n // If we still don't have a package name, fall back to the metadata URL path\n packageName = packageName ?? httpsRegExpName;\n\n return {\n datasource: GitlabTagsDatasource.id,\n registryUrl: httpsRegExpUrl,\n packageName,\n };\n }\n\n if (hostRules.hostType({ url: metadataUrl }) === 'gitlab') {\n const parsedUrl = parseUrl(metadataUrl);\n if (!parsedUrl) {\n logger.trace({ goModule }, 'Could not parse go-source URL');\n return null;\n }\n\n const endpoint = GlobalConfig.get('endpoint');\n const endpointPrefix = regEx(\n /https:\\/\\/[^/]+\\/(?<prefix>.*?\\/)(?:api\\/v4\\/?)?/,\n ).exec(endpoint)?.groups?.prefix;\n\n let packageName =\n // a .git path indicates a concrete git repository, which can be different from metadata returned by gitlab\n vcsIndicatedModule ?? trimLeadingSlash(parsedUrl.pathname);\n if (endpointPrefix && endpointPrefix !== 'api/') {\n packageName = packageName.replace(endpointPrefix, '');\n }\n\n const registryUrl = endpointPrefix\n ? endpoint.replace(regEx(/\\/api\\/v4\\/?$/), '/')\n : `${parsedUrl.protocol}//${parsedUrl.host}`;\n\n return {\n datasource: GitlabTagsDatasource.id,\n registryUrl,\n packageName,\n };\n }\n return null;\n }\n\n private static goImportHeader(\n html: string,\n goModule: string,\n ): DataSource | null {\n const importMatchGroups =\n BaseGoDatasource.goImportRegexp.exec(html)?.groups;\n if (!importMatchGroups) {\n logger.trace({ goModule }, 'No go-source or go-import header found');\n return null;\n }\n const { prefix, proto, goImportURL } = importMatchGroups;\n\n if (!goModule.startsWith(prefix)) {\n logger.trace({ goModule }, 'go-import header prefix not match');\n return null;\n }\n\n if (proto !== 'git') {\n logger.trace({ goModule }, 'go-import header proto not git');\n return null;\n }\n\n // get server base url from import url\n const parsedUrl = parseUrl(goImportURL);\n if (!parsedUrl) {\n logger.trace({ goModule }, 'Could not parse go-import URL');\n return null;\n }\n\n logger.debug(`Go module: ${goModule} lookup import url ${goImportURL}`);\n\n const datasource = this.detectDatasource(\n goImportURL.replace(regEx(/\\.git$/), ''),\n goModule,\n );\n if (datasource !== null) {\n return datasource;\n }\n // fall back to old behavior if detection did not work\n\n switch (detectPlatform(goImportURL)) {\n case 'github': {\n // split the go module from the URL: host/go/module -> go/module\n // TODO: `parsedUrl.pathname` can be undefined\n const packageName = trimTrailingSlash(`${parsedUrl.pathname}`)\n .replace(regEx(/\\.git$/), '')\n .split('/')\n .slice(-2)\n .join('/');\n\n return {\n datasource: GithubTagsDatasource.id,\n registryUrl: `${parsedUrl.protocol}//${parsedUrl.host}`,\n packageName,\n };\n }\n case 'azure': {\n return {\n datasource: GitTagsDatasource.id,\n packageName: goImportURL.replace(regEx(/\\.git$/), ''),\n };\n }\n default: {\n return {\n datasource: GitTagsDatasource.id,\n packageName: goImportURL,\n };\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAqBA,IAAa,mBAAb,MAAa,iBAAiB;CAC5B,OAAwB,oBAAoB,MAC1C,2FACF;CACA,OAAwB,eAAe,MACrC,kEACF;CACA,OAAwB,eAAe,MACrC,wCACF;CACA,OAAwB,iBAAiB,MACvC,wGACF;CACA,OAAwB,oBAAoB,MAC1C,iBAAiB,eAAe,QAChC,GACF;CAEA,OAAwB,KAAK;CAC7B,OAAwB,OAAO,IAAI,KAAK,iBAAiB,EAAE;CAE3D,aAAa,cAAc,UAA8C;EACvE,IAAI,SAAS,WAAW,WAAW,GAAG;GACpC,MAAM,CAAC,OAAO,SAAS,QAAQ,aAAa,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C;GACE,KAAK,UAAU;IAGb,MAAM,cAAc,kBAAkB,GAAG,UAAU,UAAU,CAAC,CAC3D,QAAQ,MAAM,QAAQ,GAAG,EAAE,CAAC,CAC5B,MAAM,GAAG,CAAC,CACV,MAAM,EAAE,CAAC,CACT,KAAK,GAAG;IAEX,OAAO;KACL,YAAY,qBAAqB;KACjC,aAAa,GAAG,UAAU,SAAS,IAAI,UAAU;KACjD;IACF;GACF;GACA,KAAK,SACH,OAAO;IACL,YAAY,kBAAkB;IAC9B,aAAa,YAAY,QAAQ,MAAM,QAAQ,GAAG,EAAE;GACtD;GAEF,SACE,OAAO;IACL,YAAY,kBAAkB;IAC9B,aAAa;GACf;EAEJ;CACF;AACF"}
1
+ {"version":3,"file":"base.js","names":["modulePath","hostRules.hostType"],"sources":["../../../../lib/modules/datasource/go/base.ts"],"sourcesContent":["// TODO: types (#22198)\nimport { GlobalConfig } from '../../../config/global.ts';\nimport { logger } from '../../../logger/index.ts';\nimport { detectPlatform } from '../../../util/common.ts';\nimport * as hostRules from '../../../util/host-rules.ts';\nimport { Http } from '../../../util/http/index.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport {\n parseUrl,\n trimLeadingSlash,\n trimTrailingSlash,\n} from '../../../util/url.ts';\nimport { BitbucketTagsDatasource } from '../bitbucket-tags/index.ts';\nimport { ForgejoTagsDatasource } from '../forgejo-tags/index.ts';\nimport { GitTagsDatasource } from '../git-tags/index.ts';\nimport { GiteaTagsDatasource } from '../gitea-tags/index.ts';\nimport { GithubTagsDatasource } from '../github-tags/index.ts';\nimport { GitlabTagsDatasource } from '../gitlab-tags/index.ts';\nimport type { DataSource } from './types.ts';\n\n// TODO: figure out class hierarchy (#10532)\nexport class BaseGoDatasource {\n private static readonly gitlabHttpsRegExp = regEx(\n /^(?<httpsRegExpUrl>https:\\/\\/[^/]*gitlab\\.[^/]*)\\/(?<httpsRegExpName>.+?)(?:\\/v\\d+)?[/]?$/,\n );\n private static readonly gitlabRegExp = regEx(\n /^(?<regExpUrl>gitlab\\.[^/]*)\\/(?<regExpPath>.+?)(?:\\/v\\d+)?[/]?$/,\n );\n private static readonly gitVcsRegexp = regEx(\n /^(?:[^/]+)\\/(?<module>.*)\\.git(?:$|\\/)/,\n );\n private static readonly goImportRegexp = regEx(\n /<meta\\s+name=\"?go-import\"?\\s+content=\"(?<prefix>[^\"\\s]+)\\s+(?<proto>[^\"\\s]+)\\s+(?<goImportURL>[^\"\\s]+)/,\n );\n private static readonly goImportAllRegexp = regEx(\n BaseGoDatasource.goImportRegexp.source,\n 'g',\n );\n\n private static readonly id = 'go';\n private static readonly http = new Http(BaseGoDatasource.id);\n\n static async getDatasource(goModule: string): Promise<DataSource | null> {\n if (goModule.startsWith('gopkg.in/')) {\n const [pkg] = goModule.replace('gopkg.in/', '').split('.');\n const packageName = pkg.includes('/') ? pkg : `go-${pkg}/${pkg}`;\n return {\n datasource: GithubTagsDatasource.id,\n packageName,\n registryUrl: 'https://github.com',\n };\n }\n\n if (goModule.startsWith('github.com/')) {\n const split = goModule.split('/');\n const packageName = `${split[1]}/${split[2]}`;\n return {\n datasource: GithubTagsDatasource.id,\n packageName,\n registryUrl: 'https://github.com',\n };\n }\n\n if (goModule.startsWith('bitbucket.org/')) {\n const split = goModule.split('/');\n const packageName = `${split[1]}/${split[2]}`;\n return {\n datasource: BitbucketTagsDatasource.id,\n packageName,\n registryUrl: 'https://bitbucket.org',\n };\n }\n\n if (goModule.startsWith('code.cloudfoundry.org/')) {\n const packageName = goModule.replace(\n 'code.cloudfoundry.org',\n 'cloudfoundry',\n );\n return {\n datasource: GithubTagsDatasource.id,\n packageName,\n registryUrl: 'https://github.com',\n };\n }\n\n if (goModule.startsWith('dev.azure.com/')) {\n const split = goModule.split('/');\n if (split.length > 3) {\n const packageName = `https://dev.azure.com/${split[1]}/${split[2]}/_git/${(split[3] === '_git' ? split[4] : split[3]).replace(regEx(/\\.git$/), '')}`;\n return {\n datasource: GitTagsDatasource.id,\n packageName,\n };\n }\n }\n\n //#region known gitea compatible hosts\n if (goModule.startsWith('gitea.com/')) {\n const split = goModule.split('/');\n const packageName = `${split[1]}/${split[2]}`;\n return {\n datasource: GiteaTagsDatasource.id,\n packageName,\n registryUrl: 'https://gitea.com',\n };\n }\n\n if (goModule.startsWith('code.forgejo.org/')) {\n const split = goModule.split('/');\n const packageName = `${split[1]}/${split[2]}`;\n return {\n datasource: ForgejoTagsDatasource.id,\n packageName,\n registryUrl: 'https://code.forgejo.org',\n };\n }\n\n if (goModule.startsWith('codeberg.org/')) {\n const split = goModule.split('/');\n const packageName = `${split[1]}/${split[2]}`;\n return {\n datasource: ForgejoTagsDatasource.id,\n packageName,\n registryUrl: 'https://codeberg.org',\n };\n }\n //#endregion\n\n return await BaseGoDatasource.goGetDatasource(goModule);\n }\n\n /**\n * Returns the module proxy URL that a `go-import` meta tag with the `mod` VCS advertises for the module.\n *\n * @see https://go.dev/ref/mod#serving-from-proxy\n */\n static async getModProxyUrl(goModule: string): Promise<string | null> {\n const html = await BaseGoDatasource.goGet(goModule);\n return BaseGoDatasource.findModProxyUrl(html, goModule);\n }\n\n /**\n * Finds the first `go-import` meta tag with the `mod` VCS whose prefix is a path prefix of the module.\n *\n * The proxy URL is controlled by the host serving the page, so only a valid `https:` URL is accepted, as with `go` (unless `GOINSECURE` is set).\n */\n private static findModProxyUrl(\n html: string,\n goModule: string,\n ): string | null {\n for (const match of html.matchAll(BaseGoDatasource.goImportAllRegexp)) {\n const { prefix, proto, goImportURL } = match.groups as Record<\n string,\n string\n >;\n\n if (\n proto !== 'mod' ||\n !(goModule === prefix || goModule.startsWith(`${prefix}/`))\n ) {\n continue;\n }\n\n if (parseUrl(goImportURL)?.protocol !== 'https:') {\n logger.debug(\n { goModule, goImportURL },\n 'Ignoring go-import mod proxy URL which is not a valid https URL',\n );\n continue;\n }\n\n return goImportURL;\n }\n\n return null;\n }\n\n private static async goGet(goModule: string): Promise<string> {\n const goModuleUrl = goModule.replace(regEx(/\\.git(?:\\/[a-z0-9/]*)?$/), '');\n const pkgUrl = `https://${goModuleUrl}?go-get=1`;\n const { body } = await BaseGoDatasource.http.getText(pkgUrl);\n return body;\n }\n\n private static async goGetDatasource(\n goModule: string,\n ): Promise<DataSource | null> {\n const html = await BaseGoDatasource.goGet(goModule);\n\n // `go` prefers a `mod` proxy over a VCS for the same module, so leave it to the caller to look it up\n if (BaseGoDatasource.findModProxyUrl(html, goModule)) {\n logger.debug(\n { goModule },\n 'Preferring go-import mod proxy over other go-import and go-source entries',\n );\n return null;\n }\n\n const goSourceHeader = BaseGoDatasource.goSourceHeader(html, goModule);\n if (goSourceHeader) {\n return goSourceHeader;\n }\n\n // GitHub Enterprise only returns a go-import meta\n const goImport = BaseGoDatasource.goImportHeader(html, goModule);\n if (goImport) {\n return goImport;\n }\n\n logger.trace({ goModule }, 'No go-source or go-import header found');\n /* istanbul ignore next */\n return null;\n }\n\n private static goSourceHeader(\n html: string,\n goModule: string,\n ): DataSource | null {\n const sourceMatchGroups = regEx(\n /<meta\\s+name=\"?go-source\"?\\s+content=\"(?<prefix>[^\"\\s]+)\\s+(?<goSourceUrl>[^\"\\s]+)/,\n ).exec(html)?.groups;\n if (!sourceMatchGroups) {\n return null;\n }\n const { prefix, goSourceUrl } = sourceMatchGroups;\n\n if (!goModule.startsWith(prefix)) {\n logger.trace({ goModule }, 'go-source header prefix not match');\n return null;\n }\n\n logger.debug(`Go lookup source url ${goSourceUrl} for module ${goModule}`);\n return this.detectDatasource(goSourceUrl, goModule);\n }\n\n private static detectDatasource(\n metadataUrl: string,\n goModule: string,\n ): DataSource | null {\n if (metadataUrl.startsWith('https://github.com/')) {\n return {\n datasource: GithubTagsDatasource.id,\n packageName: metadataUrl\n .replace('https://github.com/', '')\n .replace(regEx(/\\/$/), ''),\n registryUrl: 'https://github.com',\n };\n }\n\n const gitlabModuleName =\n BaseGoDatasource.gitlabRegExp.exec(goModule)?.groups?.regExpPath;\n const vcsIndicatedModule =\n BaseGoDatasource.gitVcsRegexp.exec(goModule)?.groups?.module;\n\n const metadataUrlMatchGroups =\n BaseGoDatasource.gitlabHttpsRegExp.exec(metadataUrl)?.groups;\n if (metadataUrlMatchGroups) {\n const { httpsRegExpUrl, httpsRegExpName } = metadataUrlMatchGroups;\n\n let packageName = vcsIndicatedModule ?? gitlabModuleName;\n\n // Detect submodules in monorepos by comparing metadata path and module path\n if (!vcsIndicatedModule && httpsRegExpName && gitlabModuleName) {\n const metadataPath = httpsRegExpName;\n const modulePath = gitlabModuleName;\n\n if (modulePath.startsWith(`${metadataPath}/`)) {\n packageName = metadataPath;\n }\n }\n\n // If we still don't have a package name, fall back to the metadata URL path\n packageName = packageName ?? httpsRegExpName;\n\n return {\n datasource: GitlabTagsDatasource.id,\n registryUrl: httpsRegExpUrl,\n packageName,\n };\n }\n\n if (hostRules.hostType({ url: metadataUrl }) === 'gitlab') {\n const parsedUrl = parseUrl(metadataUrl);\n if (!parsedUrl) {\n logger.trace({ goModule }, 'Could not parse go-source URL');\n return null;\n }\n\n const endpoint = GlobalConfig.get('endpoint');\n const endpointPrefix = regEx(\n /https:\\/\\/[^/]+\\/(?<prefix>.*?\\/)(?:api\\/v4\\/?)?/,\n ).exec(endpoint)?.groups?.prefix;\n\n let packageName =\n // a .git path indicates a concrete git repository, which can be different from metadata returned by gitlab\n vcsIndicatedModule ?? trimLeadingSlash(parsedUrl.pathname);\n if (endpointPrefix && endpointPrefix !== 'api/') {\n packageName = packageName.replace(endpointPrefix, '');\n }\n\n const registryUrl = endpointPrefix\n ? endpoint.replace(regEx(/\\/api\\/v4\\/?$/), '/')\n : `${parsedUrl.protocol}//${parsedUrl.host}`;\n\n return {\n datasource: GitlabTagsDatasource.id,\n registryUrl,\n packageName,\n };\n }\n return null;\n }\n\n private static goImportHeader(\n html: string,\n goModule: string,\n ): DataSource | null {\n const importMatchGroups =\n BaseGoDatasource.goImportRegexp.exec(html)?.groups;\n if (!importMatchGroups) {\n logger.trace({ goModule }, 'No go-source or go-import header found');\n return null;\n }\n const { prefix, proto, goImportURL } = importMatchGroups;\n\n if (!goModule.startsWith(prefix)) {\n logger.trace({ goModule }, 'go-import header prefix not match');\n return null;\n }\n\n if (proto !== 'git') {\n logger.trace({ goModule }, 'go-import header proto not git');\n return null;\n }\n\n // get server base url from import url\n const parsedUrl = parseUrl(goImportURL);\n if (!parsedUrl) {\n logger.trace({ goModule }, 'Could not parse go-import URL');\n return null;\n }\n\n logger.debug(`Go module: ${goModule} lookup import url ${goImportURL}`);\n\n const datasource = this.detectDatasource(\n goImportURL.replace(regEx(/\\.git$/), ''),\n goModule,\n );\n if (datasource !== null) {\n return datasource;\n }\n // fall back to old behavior if detection did not work\n\n switch (detectPlatform(goImportURL)) {\n case 'github': {\n // split the go module from the URL: host/go/module -> go/module\n // TODO: `parsedUrl.pathname` can be undefined\n const packageName = trimTrailingSlash(`${parsedUrl.pathname}`)\n .replace(regEx(/\\.git$/), '')\n .split('/')\n .slice(-2)\n .join('/');\n\n return {\n datasource: GithubTagsDatasource.id,\n registryUrl: `${parsedUrl.protocol}//${parsedUrl.host}`,\n packageName,\n };\n }\n case 'azure': {\n return {\n datasource: GitTagsDatasource.id,\n packageName: goImportURL.replace(regEx(/\\.git$/), ''),\n };\n }\n default: {\n return {\n datasource: GitTagsDatasource.id,\n packageName: goImportURL,\n };\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAqBA,IAAa,mBAAb,MAAa,iBAAiB;CAC5B,OAAwB,oBAAoB,MAC1C,2FACF;CACA,OAAwB,eAAe,MACrC,kEACF;CACA,OAAwB,eAAe,MACrC,wCACF;CACA,OAAwB,iBAAiB,MACvC,wGACF;CACA,OAAwB,oBAAoB,MAC1C,iBAAiB,eAAe,QAChC,GACF;CAEA,OAAwB,KAAK;CAC7B,OAAwB,OAAO,IAAI,KAAK,iBAAiB,EAAE;CAE3D,aAAa,cAAc,UAA8C;EACvE,IAAI,SAAS,WAAW,WAAW,GAAG;GACpC,MAAM,CAAC,OAAO,SAAS,QAAQ,aAAa,EAAE,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kB,GAAG,UAAU,UAAU,CAAC,CAC3D,QAAQ,MAAM,QAAQ,GAAG,EAAE,CAAC,CAC5B,MAAM,GAAG,CAAC,CACV,MAAM,EAAE,CAAC,CACT,KAAK,GAAG;IAEX,OAAO;KACL,YAAY,qBAAqB;KACjC,aAAa,GAAG,UAAU,SAAS,IAAI,UAAU;KACjD;IACF;GACF;GACA,KAAK,SACH,OAAO;IACL,YAAY,kBAAkB;IAC9B,aAAa,YAAY,QAAQ,MAAM,QAAQ,GAAG,EAAE;GACtD;GAEF,SACE,OAAO;IACL,YAAY,kBAAkB;IAC9B,aAAa;GACf;EAEJ;CACF;AACF"}
@@ -27,9 +27,12 @@ import { isNonEmptyString } from "@sindresorhus/is";
27
27
  function isPublicProxy({ url }) {
28
28
  return trimTrailingSlash(url) === publicGoproxyUrl;
29
29
  }
30
+ function matchesRuleHost(rule, url) {
31
+ return !rule.matchHost || matchesHost(url, rule.matchHost);
32
+ }
30
33
  function hasGoHostRuleCredentials(packageName) {
31
34
  const url = `https://${packageName}`;
32
- return [...findAll({ hostType: "go" }), ...findAll({ hostType: "go-proxy" })].some((rule) => (!rule.matchHost || matchesHost(url, rule.matchHost)) && [
35
+ return [...findAll({ hostType: "go" }), ...findAll({ hostType: "go-proxy" })].some((rule) => matchesRuleHost(rule, url) && [
33
36
  rule.token,
34
37
  rule.password,
35
38
  rule.httpsPrivateKey
@@ -39,7 +42,10 @@ function isPublicGoPackage(packageName) {
39
42
  if (parseNoproxy()?.test(packageName)) return false;
40
43
  if (hasGoHostRuleCredentials(packageName)) return false;
41
44
  const proxies = parseGoproxy();
42
- return proxies.every((proxy) => proxy.url === "off" || isPublicProxy(proxy) || proxy.url === "direct" && proxies.some(isPublicProxy));
45
+ return proxies.every((proxy) => {
46
+ if (proxy.url === "off" || isPublicProxy(proxy)) return true;
47
+ return proxy.url === "direct" && proxies.some(isPublicProxy);
48
+ });
43
49
  }
44
50
  function getSourceUrl(dataSource) {
45
51
  if (dataSource) {
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","names":["hostRules.findAll","hostRules.matchesHost","githubSourceUrl","gitlabSourceUrl"],"sources":["../../../../lib/modules/datasource/go/common.ts"],"sourcesContent":["import { isNonEmptyString } from '@sindresorhus/is';\nimport { getSourceUrl as githubSourceUrl } from '../../../util/github/url.ts';\nimport { getSourceUrl as gitlabSourceUrl } from '../../../util/gitlab/url.ts';\nimport * as hostRules from '../../../util/host-rules.ts';\nimport { trimTrailingSlash } from '../../../util/url.ts';\nimport { BitbucketTagsDatasource } from '../bitbucket-tags/index.ts';\nimport { ForgejoTagsDatasource } from '../forgejo-tags/index.ts';\nimport { GiteaTagsDatasource } from '../gitea-tags/index.ts';\nimport { GithubTagsDatasource } from '../github-tags/index.ts';\nimport { GitlabTagsDatasource } from '../gitlab-tags/index.ts';\n\nimport { publicGoproxyUrl } from './env.ts';\nimport { parseGoproxy, parseNoproxy } from './goproxy-parser.ts';\nimport type { DataSource, GoproxyItem } from './types.ts';\n\n/**\n * Whether a module's data may be written to a package cache which is shared with others.\n *\n * `GOPRIVATE`/`GONOPROXY` is how the user declares which modules are private, and `GOPROXY` decides who serves the rest: whatever the public proxy serves is public by definition, whereas a self-hosted proxy may serve modules which are not.\n *\n * `direct` only counts as public alongside the public proxy, which is how Go's own default `GOPROXY` is written: there, it is the fallback for what the public proxy doesn't have. On its own it means every module comes from its source, which tells us nothing about who may read it.\n *\n * An unset `GOPROXY` is the default, so it is public too.\n *\n * A `hostType: go` (or `go-proxy`) host rule with credentials for the module's host is also a declaration that the module is private, as it can't be read without them.\n *\n * @see https://go.dev/ref/mod#private-modules\n */\nfunction isPublicProxy({ url }: GoproxyItem): boolean {\n return trimTrailingSlash(url) === publicGoproxyUrl;\n}\n\nfunction hasGoHostRuleCredentials(packageName: string): boolean {\n const url = `https://${packageName}`;\n return [\n ...hostRules.findAll({ hostType: 'go' }),\n ...hostRules.findAll({ hostType: 'go-proxy' }),\n ].some(\n (rule) =>\n (!rule.matchHost || hostRules.matchesHost(url, rule.matchHost)) &&\n [rule.token, rule.password, rule.httpsPrivateKey].some(isNonEmptyString),\n );\n}\n\nexport function isPublicGoPackage(packageName: string): boolean {\n if (parseNoproxy()?.test(packageName)) {\n return false;\n }\n\n if (hasGoHostRuleCredentials(packageName)) {\n return false;\n }\n\n const proxies = parseGoproxy();\n\n return proxies.every(\n (proxy) =>\n proxy.url === 'off' ||\n isPublicProxy(proxy) ||\n (proxy.url === 'direct' && proxies.some(isPublicProxy)),\n );\n}\n\nexport function getSourceUrl(\n dataSource?: DataSource | null,\n): string | undefined {\n if (dataSource) {\n const { datasource, registryUrl, packageName } = dataSource;\n\n switch (datasource) {\n case ForgejoTagsDatasource.id:\n return ForgejoTagsDatasource.getSourceUrl(packageName, registryUrl);\n case GiteaTagsDatasource.id:\n return GiteaTagsDatasource.getSourceUrl(packageName, registryUrl);\n case GithubTagsDatasource.id:\n return githubSourceUrl(packageName, registryUrl);\n case GitlabTagsDatasource.id:\n return gitlabSourceUrl(packageName, registryUrl);\n case BitbucketTagsDatasource.id:\n return BitbucketTagsDatasource.getSourceUrl(packageName, registryUrl);\n }\n }\n\n return undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,SAAS,cAAc,EAAE,OAA6B;CACpD,OAAO,kBAAkB,GAAG,MAAM;AACpC;AAEA,SAAS,yBAAyB,aAA8B;CAC9D,MAAM,MAAM,WAAW;CACvB,OAAO,CACL,GAAGA,QAAkB,EAAE,UAAU,KAAK,CAAC,GACvC,GAAGA,QAAkB,EAAE,UAAU,WAAW,CAAC,CAC/C,CAAC,CAAC,MACC,UACE,CAAC,KAAK,aAAaC,YAAsB,KAAK,KAAK,SAAS,MAC7D;EAAC,KAAK;EAAO,KAAK;EAAU,KAAK;CAAe,CAAC,CAAC,KAAK,gBAAgB,CAC3E;AACF;AAEA,SAAgB,kBAAkB,aAA8B;CAC9D,IAAI,aAAa,CAAC,EAAE,KAAK,WAAW,GAClC,OAAO;CAGT,IAAI,yBAAyB,WAAW,GACtC,OAAO;CAGT,MAAM,UAAU,aAAa;CAE7B,OAAO,QAAQ,OACZ,UACC,MAAM,QAAQ,SACd,cAAc,KAAK,KAClB,MAAM,QAAQ,YAAY,QAAQ,KAAK,aAAa,CACzD;AACF;AAEA,SAAgB,aACd,YACoB;CACpB,IAAI,YAAY;EACd,MAAM,EAAE,YAAY,aAAa,gBAAgB;EAEjD,QAAQ,YAAR;GACE,KAAK,sBAAsB,IACzB,OAAO,sBAAsB,aAAa,aAAa,WAAW;GACpE,KAAK,oBAAoB,IACvB,OAAO,oBAAoB,aAAa,aAAa,WAAW;GAClE,KAAK,qBAAqB,IACxB,OAAOC,eAAgB,aAAa,WAAW;GACjD,KAAK,qBAAqB,IACxB,OAAOC,eAAgB,aAAa,WAAW;GACjD,KAAK,wBAAwB,IAC3B,OAAO,wBAAwB,aAAa,aAAa,WAAW;EACxE;CACF;AAGF"}
1
+ {"version":3,"file":"common.js","names":["hostRules.matchesHost","hostRules.findAll","githubSourceUrl","gitlabSourceUrl"],"sources":["../../../../lib/modules/datasource/go/common.ts"],"sourcesContent":["import { isNonEmptyString } from '@sindresorhus/is';\nimport type { HostRule } from '../../../types/index.ts';\nimport { getSourceUrl as githubSourceUrl } from '../../../util/github/url.ts';\nimport { getSourceUrl as gitlabSourceUrl } from '../../../util/gitlab/url.ts';\nimport * as hostRules from '../../../util/host-rules.ts';\nimport { trimTrailingSlash } from '../../../util/url.ts';\nimport { BitbucketTagsDatasource } from '../bitbucket-tags/index.ts';\nimport { ForgejoTagsDatasource } from '../forgejo-tags/index.ts';\nimport { GiteaTagsDatasource } from '../gitea-tags/index.ts';\nimport { GithubTagsDatasource } from '../github-tags/index.ts';\nimport { GitlabTagsDatasource } from '../gitlab-tags/index.ts';\n\nimport { publicGoproxyUrl } from './env.ts';\nimport { parseGoproxy, parseNoproxy } from './goproxy-parser.ts';\nimport type { DataSource, GoproxyItem } from './types.ts';\n\n/**\n * Whether a module's data may be written to a package cache which is shared with others.\n *\n * `GOPRIVATE`/`GONOPROXY` is how the user declares which modules are private, and `GOPROXY` decides who serves the rest: whatever the public proxy serves is public by definition, whereas a self-hosted proxy may serve modules which are not.\n *\n * `direct` only counts as public alongside the public proxy, which is how Go's own default `GOPROXY` is written: there, it is the fallback for what the public proxy doesn't have. On its own it means every module comes from its source, which tells us nothing about who may read it.\n *\n * An unset `GOPROXY` is the default, so it is public too.\n *\n * A `hostType: go` (or `go-proxy`) host rule with credentials for the module's host is also a declaration that the module is private, as it can't be read without them.\n *\n * @see https://go.dev/ref/mod#private-modules\n */\nfunction isPublicProxy({ url }: GoproxyItem): boolean {\n return trimTrailingSlash(url) === publicGoproxyUrl;\n}\n\nfunction matchesRuleHost(rule: HostRule, url: string): boolean {\n return !rule.matchHost || hostRules.matchesHost(url, rule.matchHost);\n}\n\nfunction hasGoHostRuleCredentials(packageName: string): boolean {\n const url = `https://${packageName}`;\n return [\n ...hostRules.findAll({ hostType: 'go' }),\n ...hostRules.findAll({ hostType: 'go-proxy' }),\n ].some(\n (rule) =>\n matchesRuleHost(rule, url) &&\n [rule.token, rule.password, rule.httpsPrivateKey].some(isNonEmptyString),\n );\n}\n\nexport function isPublicGoPackage(packageName: string): boolean {\n if (parseNoproxy()?.test(packageName)) {\n return false;\n }\n\n if (hasGoHostRuleCredentials(packageName)) {\n return false;\n }\n\n const proxies = parseGoproxy();\n\n return proxies.every((proxy) => {\n if (proxy.url === 'off' || isPublicProxy(proxy)) {\n return true;\n }\n return proxy.url === 'direct' && proxies.some(isPublicProxy);\n });\n}\n\nexport function getSourceUrl(\n dataSource?: DataSource | null,\n): string | undefined {\n if (dataSource) {\n const { datasource, registryUrl, packageName } = dataSource;\n\n switch (datasource) {\n case ForgejoTagsDatasource.id:\n return ForgejoTagsDatasource.getSourceUrl(packageName, registryUrl);\n case GiteaTagsDatasource.id:\n return GiteaTagsDatasource.getSourceUrl(packageName, registryUrl);\n case GithubTagsDatasource.id:\n return githubSourceUrl(packageName, registryUrl);\n case GitlabTagsDatasource.id:\n return gitlabSourceUrl(packageName, registryUrl);\n case BitbucketTagsDatasource.id:\n return BitbucketTagsDatasource.getSourceUrl(packageName, registryUrl);\n }\n }\n\n return undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,SAAS,cAAc,EAAE,OAA6B;CACpD,OAAO,kBAAkB,GAAG,MAAM;AACpC;AAEA,SAAS,gBAAgB,MAAgB,KAAsB;CAC7D,OAAO,CAAC,KAAK,aAAaA,YAAsB,KAAK,KAAK,SAAS;AACrE;AAEA,SAAS,yBAAyB,aAA8B;CAC9D,MAAM,MAAM,WAAW;CACvB,OAAO,CACL,GAAGC,QAAkB,EAAE,UAAU,KAAK,CAAC,GACvC,GAAGA,QAAkB,EAAE,UAAU,WAAW,CAAC,CAC/C,CAAC,CAAC,MACC,SACC,gBAAgB,MAAM,GAAG,KACzB;EAAC,KAAK;EAAO,KAAK;EAAU,KAAK;CAAe,CAAC,CAAC,KAAK,gBAAgB,CAC3E;AACF;AAEA,SAAgB,kBAAkB,aAA8B;CAC9D,IAAI,aAAa,CAAC,EAAE,KAAK,WAAW,GAClC,OAAO;CAGT,IAAI,yBAAyB,WAAW,GACtC,OAAO;CAGT,MAAM,UAAU,aAAa;CAE7B,OAAO,QAAQ,OAAO,UAAU;EAC9B,IAAI,MAAM,QAAQ,SAAS,cAAc,KAAK,GAC5C,OAAO;EAET,OAAO,MAAM,QAAQ,YAAY,QAAQ,KAAK,aAAa;CAC7D,CAAC;AACH;AAEA,SAAgB,aACd,YACoB;CACpB,IAAI,YAAY;EACd,MAAM,EAAE,YAAY,aAAa,gBAAgB;EAEjD,QAAQ,YAAR;GACE,KAAK,sBAAsB,IACzB,OAAO,sBAAsB,aAAa,aAAa,WAAW;GACpE,KAAK,oBAAoB,IACvB,OAAO,oBAAoB,aAAa,aAAa,WAAW;GAClE,KAAK,qBAAqB,IACxB,OAAOC,eAAgB,aAAa,WAAW;GACjD,KAAK,qBAAqB,IACxB,OAAOC,eAAgB,aAAa,WAAW;GACjD,KAAK,wBAAwB,IAC3B,OAAO,wBAAwB,aAAa,aAAa,WAAW;EACxE;CACF;AAGF"}
@@ -20,7 +20,8 @@ function toUrl(matchHost) {
20
20
  * `go` only sends basic auth from a `GOPROXY` URL, and fails without falling back on a 401/403, so a token-only rule can't be used.
21
21
  */
22
22
  function canAuthenticateGo(rule) {
23
- if (!isNonEmptyString(rule.token) || isNonEmptyString(rule.username) && isNonEmptyString(rule.password)) return true;
23
+ const hasBasicAuth = isNonEmptyString(rule.username) && isNonEmptyString(rule.password);
24
+ if (!isNonEmptyString(rule.token) || hasBasicAuth) return true;
24
25
  logger.once.warn({ matchHost: rule.matchHost }, "go-proxy host rule with only a token is not added to GOPROXY");
25
26
  return false;
26
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"env.js","names":["hostRules\n .findAll"],"sources":["../../../../lib/modules/datasource/go/env.ts"],"sourcesContent":["import { isNonEmptyString } from '@sindresorhus/is';\nimport { GlobalConfig } from '../../../config/global.ts';\nimport { logger } from '../../../logger/index.ts';\nimport type { HostRule } from '../../../types/index.ts';\nimport { getEnv } from '../../../util/env.ts';\nimport * as hostRules from '../../../util/host-rules.ts';\nimport { addSecretForSanitizing } from '../../../util/sanitize.ts';\nimport { parseUrl, trimTrailingSlash } from '../../../util/url.ts';\nimport type { GoEnv } from './types.ts';\n\n/**\n * The Go module proxy which serves public modules only, and which the Go toolchain uses by default.\n *\n * @see https://go.dev/ref/mod#module-proxy\n */\nexport const publicGoproxyUrl = 'https://proxy.golang.org';\n\nfunction toUrl(matchHost: string | undefined): URL | null {\n // a leading dot matches any subdomain, so it can't be turned into one host\n if (!isNonEmptyString(matchHost) || matchHost.startsWith('.')) {\n return null;\n }\n return parseUrl(\n matchHost.includes('://') ? matchHost : `https://${matchHost}`,\n );\n}\n\n/**\n * `go` only sends basic auth from a `GOPROXY` URL, and fails without falling back on a 401/403, so a token-only rule can't be used.\n */\nfunction canAuthenticateGo(rule: HostRule): boolean {\n if (\n !isNonEmptyString(rule.token) ||\n (isNonEmptyString(rule.username) && isNonEmptyString(rule.password))\n ) {\n return true;\n }\n logger.once.warn(\n { matchHost: rule.matchHost },\n 'go-proxy host rule with only a token is not added to GOPROXY',\n );\n return false;\n}\n\nfunction toGoproxyUrl(rule: HostRule, withCredentials: boolean): string | null {\n const url = toUrl(rule.matchHost);\n if (!url) {\n return null;\n }\n\n if (\n withCredentials &&\n isNonEmptyString(rule.username) &&\n isNonEmptyString(rule.password)\n ) {\n url.username = encodeURIComponent(rule.username);\n url.password = encodeURIComponent(rule.password);\n // the encoded password differs from the one registered by the host rule\n addSecretForSanitizing(url.password);\n }\n\n return trimTrailingSlash(url.href);\n}\n\n/**\n * Returns the module path pattern of a `hostType: go` rule whose `matchHost` includes a path, e.g. `https://github.com/org` → `github.com/org`.\n */\nfunction toPrivateModulePattern(rule: HostRule): string | null {\n const url = toUrl(rule.matchHost);\n const path = trimTrailingSlash(url?.pathname ?? '');\n if (!url || !path) {\n return null;\n }\n return `${url.hostname}${path}`;\n}\n\nfunction joinNonEmpty(values: (string | null)[]): string | undefined {\n const list = new Set(values.filter(isNonEmptyString));\n return list.size ? [...list].join(',') : undefined;\n}\n\n/**\n * Returns the `GOPROXY`, `GONOPROXY`, `GOPRIVATE` and `GONOSUMDB` values to use.\n *\n * Each value set in the environment is used as-is.\n * With `goEnvFromHostRules` enabled, unset values are derived from host rules:\n * - `GOPROXY`: one URL per `hostType: go-proxy` rule, followed by the public proxy and `direct`\n * - `GONOPROXY`: `hostType: go` rules whose `matchHost` includes a path\n * - `GONOSUMDB`: the `go-proxy` hosts and the derived `GONOPROXY` patterns\n *\n * When `GOPRIVATE` is set, `GONOPROXY` isn't derived, as it would override it, and `GONOSUMDB` is `GOPRIVATE` followed by the `go-proxy` hosts.\n *\n * @param withCredentials embed `go-proxy` rule credentials in the derived `GOPROXY`, for running `go`\n */\nexport function getGoEnv(withCredentials = false): GoEnv {\n const { GOPROXY, GONOPROXY, GOPRIVATE, GONOSUMDB } = getEnv();\n const env: GoEnv = { GOPROXY, GONOPROXY, GOPRIVATE, GONOSUMDB };\n\n if (!GlobalConfig.get('goEnvFromHostRules')) {\n return env;\n }\n\n const proxyRules = hostRules\n .findAll({ hostType: 'go-proxy' })\n .filter(canAuthenticateGo);\n\n if (GOPROXY === undefined) {\n const proxies = joinNonEmpty(\n proxyRules.map((rule) => toGoproxyUrl(rule, withCredentials)),\n );\n if (proxies) {\n env.GOPROXY = `${proxies},${publicGoproxyUrl},direct`;\n }\n }\n\n const proxyHosts = proxyRules.map(\n (rule) => toUrl(rule.matchHost)?.hostname ?? null,\n );\n\n if (GOPRIVATE !== undefined) {\n // `GONOSUMDB` replaces `GOPRIVATE` for the checksum database, so it has to keep the `GOPRIVATE` patterns\n env.GONOSUMDB ??= proxyHosts.some(isNonEmptyString)\n ? joinNonEmpty([GOPRIVATE, ...proxyHosts])\n : undefined;\n return env;\n }\n\n const privatePatterns = hostRules\n .findAll({ hostType: 'go' })\n .map(toPrivateModulePattern);\n\n env.GONOPROXY ??= joinNonEmpty(privatePatterns);\n env.GONOSUMDB ??= joinNonEmpty([...proxyHosts, ...privatePatterns]);\n\n return env;\n}\n"],"mappings":";;;;;;;;;;;;;AAeA,MAAa,mBAAmB;AAEhC,SAAS,MAAM,WAA2C;CAExD,IAAI,CAAC,iBAAiB,SAAS,KAAK,UAAU,WAAW,GAAG,GAC1D,OAAO;CAET,OAAO,SACL,UAAU,SAAS,KAAK,IAAI,YAAY,WAAW,WACrD;AACF;;;;AAKA,SAAS,kBAAkB,MAAyB;CAClD,IACE,CAAC,iBAAiB,KAAK,KAAK,KAC3B,iBAAiB,KAAK,QAAQ,KAAK,iBAAiB,KAAK,QAAQ,GAElE,OAAO;CAET,OAAO,KAAK,KACV,EAAE,WAAW,KAAK,UAAU,GAC5B,8DACF;CACA,OAAO;AACT;AAEA,SAAS,aAAa,MAAgB,iBAAyC;CAC7E,MAAM,MAAM,MAAM,KAAK,SAAS;CA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UAAU,CAAC,IACvC,KAAA;EACJ,OAAO;CACT;CAEA,MAAM,kBAAkBA,QACb,EAAE,UAAU,KAAK,CAAC,CAAC,CAC3B,IAAI,sBAAsB;CAE7B,IAAI,cAAc,aAAa,eAAe;CAC9C,IAAI,cAAc,aAAa,CAAC,GAAG,YAAY,GAAG,eAAe,CAAC;CAElE,OAAO;AACT"}
1
+ {"version":3,"file":"env.js","names":["hostRules\n .findAll"],"sources":["../../../../lib/modules/datasource/go/env.ts"],"sourcesContent":["import { isNonEmptyString } from '@sindresorhus/is';\nimport { GlobalConfig } from '../../../config/global.ts';\nimport { logger } from '../../../logger/index.ts';\nimport type { HostRule } from '../../../types/index.ts';\nimport { getEnv } from '../../../util/env.ts';\nimport * as hostRules from '../../../util/host-rules.ts';\nimport { addSecretForSanitizing } from '../../../util/sanitize.ts';\nimport { parseUrl, trimTrailingSlash } from '../../../util/url.ts';\nimport type { GoEnv } from './types.ts';\n\n/**\n * The Go module proxy which serves public modules only, and which the Go toolchain uses by default.\n *\n * @see https://go.dev/ref/mod#module-proxy\n */\nexport const publicGoproxyUrl = 'https://proxy.golang.org';\n\nfunction toUrl(matchHost: string | undefined): URL | null {\n // a leading dot matches any subdomain, so it can't be turned into one host\n if (!isNonEmptyString(matchHost) || matchHost.startsWith('.')) {\n return null;\n }\n return parseUrl(\n matchHost.includes('://') ? matchHost : `https://${matchHost}`,\n );\n}\n\n/**\n * `go` only sends basic auth from a `GOPROXY` URL, and fails without falling back on a 401/403, so a token-only rule can't be used.\n */\nfunction canAuthenticateGo(rule: HostRule): boolean {\n const hasBasicAuth =\n isNonEmptyString(rule.username) && isNonEmptyString(rule.password);\n if (!isNonEmptyString(rule.token) || hasBasicAuth) {\n return true;\n }\n logger.once.warn(\n { matchHost: rule.matchHost },\n 'go-proxy host rule with only a token is not added to GOPROXY',\n );\n return false;\n}\n\nfunction toGoproxyUrl(rule: HostRule, withCredentials: boolean): string | null {\n const url = toUrl(rule.matchHost);\n if (!url) {\n return null;\n }\n\n if (\n withCredentials &&\n isNonEmptyString(rule.username) &&\n isNonEmptyString(rule.password)\n ) {\n url.username = encodeURIComponent(rule.username);\n url.password = encodeURIComponent(rule.password);\n // the encoded password differs from the one registered by the host rule\n addSecretForSanitizing(url.password);\n }\n\n return trimTrailingSlash(url.href);\n}\n\n/**\n * Returns the module path pattern of a `hostType: go` rule whose `matchHost` includes a path, e.g. `https://github.com/org` → `github.com/org`.\n */\nfunction toPrivateModulePattern(rule: HostRule): string | null {\n const url = toUrl(rule.matchHost);\n const path = trimTrailingSlash(url?.pathname ?? '');\n if (!url || !path) {\n return null;\n }\n return `${url.hostname}${path}`;\n}\n\nfunction joinNonEmpty(values: (string | null)[]): string | undefined {\n const list = new Set(values.filter(isNonEmptyString));\n return list.size ? [...list].join(',') : undefined;\n}\n\n/**\n * Returns the `GOPROXY`, `GONOPROXY`, `GOPRIVATE` and `GONOSUMDB` values to use.\n *\n * Each value set in the environment is used as-is.\n * With `goEnvFromHostRules` enabled, unset values are derived from host rules:\n * - `GOPROXY`: one URL per `hostType: go-proxy` rule, followed by the public proxy and `direct`\n * - `GONOPROXY`: `hostType: go` rules whose `matchHost` includes a path\n * - `GONOSUMDB`: the `go-proxy` hosts and the derived `GONOPROXY` patterns\n *\n * When `GOPRIVATE` is set, `GONOPROXY` isn't derived, as it would override it, and `GONOSUMDB` is `GOPRIVATE` followed by the `go-proxy` hosts.\n *\n * @param withCredentials embed `go-proxy` rule credentials in the derived `GOPROXY`, for running `go`\n */\nexport function getGoEnv(withCredentials = false): GoEnv {\n const { GOPROXY, GONOPROXY, GOPRIVATE, GONOSUMDB } = getEnv();\n const env: GoEnv = { GOPROXY, GONOPROXY, GOPRIVATE, GONOSUMDB };\n\n if (!GlobalConfig.get('goEnvFromHostRules')) {\n return env;\n }\n\n const proxyRules = hostRules\n .findAll({ hostType: 'go-proxy' })\n .filter(canAuthenticateGo);\n\n if (GOPROXY === undefined) {\n const proxies = joinNonEmpty(\n proxyRules.map((rule) => toGoproxyUrl(rule, withCredentials)),\n );\n if (proxies) {\n env.GOPROXY = `${proxies},${publicGoproxyUrl},direct`;\n }\n }\n\n const proxyHosts = proxyRules.map(\n (rule) => toUrl(rule.matchHost)?.hostname ?? null,\n );\n\n if (GOPRIVATE !== undefined) {\n // `GONOSUMDB` replaces `GOPRIVATE` for the checksum database, so it has to keep the `GOPRIVATE` patterns\n env.GONOSUMDB ??= proxyHosts.some(isNonEmptyString)\n ? joinNonEmpty([GOPRIVATE, ...proxyHosts])\n : undefined;\n return env;\n }\n\n const privatePatterns = hostRules\n .findAll({ hostType: 'go' })\n .map(toPrivateModulePattern);\n\n env.GONOPROXY ??= joinNonEmpty(privatePatterns);\n env.GONOSUMDB ??= joinNonEmpty([...proxyHosts, ...privatePatterns]);\n\n return env;\n}\n"],"mappings":";;;;;;;;;;;;;AAeA,MAAa,mBAAmB;AAEhC,SAAS,MAAM,WAA2C;CAExD,IAAI,CAAC,iBAAiB,SAAS,KAAK,UAAU,WAAW,GAAG,GAC1D,OAAO;CAET,OAAO,SACL,UAAU,SAAS,KAAK,IAAI,YAAY,WAAW,WACrD;AACF;;;;AAKA,SAAS,kBAAkB,MAAyB;CAClD,MAAM,eACJ,iBAAiB,KAAK,QAAQ,KAAK,iBAAiB,KAAK,QAAQ;CACnE,IAAI,CAAC,iBAAiB,KAAK,KAAK,KAAK,cACnC,OAAO;CAET,OAAO,KAAK,KACV,EAAE,WAAW,KAAK,UAAU,GAC5B,8DACF;CACA,OAAO;AACT;AAEA,SAAS,aAAa,MAAgB,iBAAyC;CAC7E,MAAM,MAAM,MAAM,KAAK,SAAS;CAChC,IAAI,CAAC,KACH,OAAO;CAGT,IACE,mBACA,iBAAiB,KAAK,QAAQ,KAC9B,iBAAiB,KAAK,QAAQ,GAC9B;EACA,IAAI,WAAW,mBAAmB,KAAK,QAAQ;EAC/C,IAAI,WAAW,mBAAmB,KAAK,QAAQ;EAE/C,uBAAuB,IAAI,QAAQ;CACrC;CAEA,OAAO,kBAAk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 -2,6 +2,7 @@ import { newlineRegex, regEx } from "../../../util/regex.js";
2
2
  import { logger } from "../../../logger/index.js";
3
3
  import { buildCacheKey } from "../../../util/cache/package/key.js";
4
4
  import { joinUrlParts, parseUrl, trimLeadingSlash, trimTrailingSlash } from "../../../util/url.js";
5
+ import { isForbidden, isGone, isNotFound } from "../../../util/http/status.js";
5
6
  import { detectPlatform } from "../../../util/common.js";
6
7
  import { ExternalHostError } from "../../../types/errors/external-host-error.js";
7
8
  import { filterMap } from "../../../util/filter-map.js";
@@ -95,8 +96,8 @@ var GoProxyDatasource = class GoProxyDatasource extends Datasource {
95
96
  break;
96
97
  }
97
98
  } catch (err) {
98
- const statusCode = (err instanceof ExternalHostError ? err.err : err)?.response?.statusCode;
99
- if (!(fallback === "|" ? true : statusCode === 404 || statusCode === 410)) {
99
+ const potentialHttpError = err instanceof ExternalHostError ? err.err : err;
100
+ if (!(fallback === "|" ? true : isNotFound(potentialHttpError) || isGone(potentialHttpError))) {
100
101
  logger.debug({ err }, "Goproxy error: not falling back to other URLs provided with GOPROXY, rethrowing");
101
102
  this.handleGenericErrors(err);
102
103
  }
@@ -161,7 +162,8 @@ var GoProxyDatasource = class GoProxyDatasource extends Datasource {
161
162
  for (const release of releases) {
162
163
  const version = release.version.replace(incompatibleSuffixRegex, "");
163
164
  const releaseTimestamp = timestamps.get(`${tagPrefix}${version}`);
164
- if (releaseTimestamp && (!release.releaseTimestamp || releaseTimestamp > release.releaseTimestamp)) release.releaseTimestamp = releaseTimestamp;
165
+ if (!releaseTimestamp) continue;
166
+ if (!release.releaseTimestamp || releaseTimestamp > release.releaseTimestamp) release.releaseTimestamp = releaseTimestamp;
165
167
  }
166
168
  }
167
169
  getReleases(config) {
@@ -303,8 +305,8 @@ var GoProxyDatasource = class GoProxyDatasource extends Datasource {
303
305
  result.releases.push(...releases);
304
306
  } catch (err) {
305
307
  const potentialHttpError = err instanceof ExternalHostError ? err.err : err;
306
- const status = potentialHttpError.response?.statusCode;
307
- if (potentialHttpError instanceof RequestError && (status === 404 || status === 403) && major !== packageMajor) break;
308
+ const isNotFoundOrForbidden = isNotFound(potentialHttpError) || isForbidden(potentialHttpError);
309
+ if (potentialHttpError instanceof RequestError && isNotFoundOrForbidden && major !== packageMajor) break;
308
310
  throw err;
309
311
  }
310
312
  const latest = await this.getLatestVersion(baseUrl, pkg);
@@ -1 +1 @@
1
- {"version":3,"file":"releases-goproxy.js","names":["p.map","HttpError","goVersioning"],"sources":["../../../../lib/modules/datasource/go/releases-goproxy.ts"],"sourcesContent":["import {\n isNonEmptyString,\n isNonEmptyStringAndNotWhitespace,\n isTruthy,\n} from '@sindresorhus/is';\nimport type { ConstraintsFilter } from '../../../config/types.ts';\nimport { logger } from '../../../logger/index.ts';\nimport { ExternalHostError } from '../../../types/errors/external-host-error.ts';\nimport { buildCacheKey } from '../../../util/cache/package/key.ts';\nimport { withCache } from '../../../util/cache/package/with-cache.ts';\nimport { detectPlatform } from '../../../util/common.ts';\nimport { filterMap } from '../../../util/filter-map.ts';\nimport {\n queryReleases,\n queryTags,\n} from '../../../util/github/graphql/index.ts';\nimport { GithubHttp } from '../../../util/http/github.ts';\nimport { HttpError } from '../../../util/http/index.ts';\nimport * as p from '../../../util/promises.ts';\nimport { newlineRegex, regEx } from '../../../util/regex.ts';\nimport type { Timestamp } from '../../../util/timestamp.ts';\nimport { asTimestamp } from '../../../util/timestamp.ts';\nimport {\n joinUrlParts,\n parseUrl,\n trimLeadingSlash,\n trimTrailingSlash,\n} from '../../../util/url.ts';\nimport goVersioning from '../../versioning/go-mod-directive/index.ts';\nimport { parseVersionCommit } from '../../versioning/gomod/index.ts';\nimport { Datasource } from '../datasource.ts';\nimport { GithubReleasesDatasource } from '../github-releases/index.ts';\nimport type { GetReleasesConfig, Release, ReleaseResult } from '../types.ts';\nimport { BaseGoDatasource } from './base.ts';\nimport { getSourceUrl, isPublicGoPackage } from './common.ts';\nimport { getGoEnv, publicGoproxyUrl } from './env.ts';\nimport { parseGoproxy, parseNoproxy } from './goproxy-parser.ts';\nimport { GoDirectDatasource } from './releases-direct.ts';\nimport { VersionInfo } from './schema.ts';\nimport { GoVersionTimestampCache } from './timestamp-cache.ts';\n\n/** TODO #42566 */\nconst goVersionRegex = regEx(/^\\s*go\\s+(?<version>[^\\s]+)\\s*$/);\n\nconst modRegex = regEx(/^(?<baseMod>.*?)(?:[./]v(?<majorVersion>\\d+))?$/);\n\nconst versionTagRegex = regEx(/^v\\d/);\n\n/**\n * Modules with a major version of v2 or above which have no `go.mod` are reported by a Go proxy with a `+incompatible` suffix, which is absent from the tag they were published as.\n *\n * @see https://go.dev/ref/mod#non-module-compat\n */\nconst incompatibleSuffixRegex = regEx(/\\+incompatible$/);\n\nexport function pseudoVersionToRelease(pseudoVersion: string): Release | null {\n const commit = parseVersionCommit(pseudoVersion);\n if (!commit) {\n return null;\n }\n\n return {\n version: pseudoVersion,\n newDigest: commit.revision,\n releaseTimestamp: asTimestamp(commit.timestamp),\n };\n}\n\n/**\n * A Go module which lives in a subdirectory of its repository is tagged with that subdirectory as a prefix, so `github.com/aws/aws-sdk-go-v2/service/s3` publishes `v1.2.3` as the tag `service/s3/v1.2.3`.\n *\n * @see https://go.dev/ref/mod#vcs-version\n *\n * Because we can't tell from the module path alone where the repository ends and the subdirectory begins, we try each candidate prefix - longest first - against the tags we actually found, in the same way as `filterByPrefix` does for direct lookups.\n */\nexport function getTagPrefix(goModule: string, tags: Iterable<string>): string {\n const nameParts = goModule\n .replace(regEx(/\\/v\\d+$/), '')\n .split('/')\n .slice(1);\n const tagNames = [...tags];\n\n while (nameParts.length) {\n const prefix = `${nameParts.join('/')}/`;\n\n const isUsed = tagNames.some(\n (tag) =>\n tag.startsWith(prefix) &&\n versionTagRegex.test(tag.slice(prefix.length)),\n );\n if (isUsed) {\n return prefix;\n }\n\n nameParts.shift();\n }\n\n return '';\n}\n\nexport class GoProxyDatasource extends Datasource {\n static readonly id = 'go-proxy';\n\n constructor() {\n super(GoProxyDatasource.id);\n }\n\n readonly direct = new GoDirectDatasource();\n\n private readonly githubHttp = new GithubHttp(GithubReleasesDatasource.id);\n\n private async _getReleases(\n config: GetReleasesConfig,\n ): Promise<ReleaseResult | null> {\n const { packageName } = config;\n logger.trace(`goproxy.getReleases(${packageName})`);\n const goproxy = getGoEnv().GOPROXY ?? `${publicGoproxyUrl},direct`;\n if (goproxy === 'direct') {\n return this.getDirectReleases(config);\n }\n const proxyList = parseGoproxy(goproxy);\n const noproxy = parseNoproxy();\n\n let result: ReleaseResult | null = null;\n let servedByProxy = false;\n\n if (noproxy?.test(packageName)) {\n logger.debug(`Fetching ${packageName} via GONOPROXY match`);\n result = await this.getDirectReleases(config);\n return result;\n }\n\n for (const { url, fallback } of proxyList) {\n try {\n if (url === 'off') {\n break;\n } else if (url === 'direct') {\n result = await this.getDirectReleases(config);\n break;\n }\n\n const res = await this.getVersionsWithInfo(\n url,\n packageName,\n config.constraintsFiltering,\n );\n if (res.releases.length) {\n result = res;\n servedByProxy = true;\n break;\n }\n } catch (err) {\n const potentialHttpError =\n err instanceof ExternalHostError ? err.err : err;\n const statusCode = potentialHttpError?.response?.statusCode;\n const canFallback =\n fallback === '|' ? true : statusCode === 404 || statusCode === 410;\n if (!canFallback) {\n logger.debug(\n { err },\n 'Goproxy error: not falling back to other URLs provided with GOPROXY, rethrowing',\n );\n this.handleGenericErrors(err);\n }\n logger.debug(\n { err },\n 'Goproxy error: trying next URL provided with GOPROXY',\n );\n }\n }\n\n if (result && !result.sourceUrl) {\n try {\n const datasource = await BaseGoDatasource.getDatasource(packageName);\n const sourceUrl = getSourceUrl(datasource);\n if (sourceUrl) {\n result.sourceUrl = sourceUrl;\n }\n } catch (err) {\n logger.trace({ err }, `Can't get datasource for ${packageName}`);\n }\n }\n\n if (result?.sourceUrl && servedByProxy) {\n await this.addGithubTimestamps(\n packageName,\n result.sourceUrl,\n result.releases,\n );\n }\n\n return result;\n }\n\n /**\n * Looks up a module directly from its source, or from the module proxy its `go-import` meta tag advertises with the `mod` VCS, as with private Buf Schema Registries.\n */\n private async getDirectReleases(\n config: GetReleasesConfig,\n ): Promise<ReleaseResult | null> {\n const { packageName } = config;\n\n const source = await BaseGoDatasource.getDatasource(packageName);\n if (!source) {\n const modProxyUrl = await BaseGoDatasource.getModProxyUrl(packageName);\n if (modProxyUrl) {\n logger.debug(\n `Fetching ${packageName} via go-import mod proxy ${modProxyUrl}`,\n );\n const res = await this.getVersionsWithInfo(\n modProxyUrl,\n packageName,\n config.constraintsFiltering,\n );\n return res.releases.length ? res : null;\n }\n }\n\n return this.direct.getReleases(config);\n }\n\n /**\n * A Go proxy reports the commit time of the tagged commit as a version's `Time`, which can be much earlier than the point at which that version was released.\n *\n * When the module is hosted on GitHub, a GitHub Release's publication time, or - if there's no Release - the git tag's own creation time (distinct from the commit time for an annotated tag), is a better indicator of when the version became available. A Release is preferred over a tag when both exist for the same version.\n */\n async addGithubTimestamps(\n packageName: string,\n sourceUrl: string,\n releases: Release[],\n ): Promise<void> {\n if (detectPlatform(sourceUrl) !== 'github') {\n return;\n }\n\n const parsedUrl = parseUrl(sourceUrl);\n /* v8 ignore next -- detectPlatform only returns a platform for parseable URLs */\n if (!parsedUrl) {\n return;\n }\n\n const repository = trimTrailingSlash(\n trimLeadingSlash(parsedUrl.pathname),\n ).replace(regEx(/\\.git$/), '');\n const githubConfig = {\n packageName: repository,\n registryUrl: parsedUrl.origin,\n };\n\n const [githubTags, githubReleases] = await Promise.all([\n queryTags(githubConfig, this.githubHttp).catch((err) => {\n logger.debug(\n { err, packageName },\n 'Error fetching GitHub Tags for Go module',\n );\n return [];\n }),\n queryReleases(githubConfig, this.githubHttp).catch((err) => {\n logger.debug(\n { err, packageName },\n 'Error fetching GitHub Releases for Go module',\n );\n return [];\n }),\n ]);\n\n const timestamps = new Map<string, Timestamp>();\n for (const { version, releaseTimestamp } of githubTags) {\n timestamps.set(version, releaseTimestamp);\n }\n for (const { version, releaseTimestamp } of githubReleases) {\n timestamps.set(version, releaseTimestamp);\n }\n\n const tagPrefix = getTagPrefix(packageName, timestamps.keys());\n for (const release of releases) {\n const version = release.version.replace(incompatibleSuffixRegex, '');\n const releaseTimestamp = timestamps.get(`${tagPrefix}${version}`);\n if (\n releaseTimestamp &&\n (!release.releaseTimestamp ||\n releaseTimestamp > release.releaseTimestamp)\n ) {\n release.releaseTimestamp = releaseTimestamp;\n }\n }\n }\n\n getReleases(config: GetReleasesConfig): Promise<ReleaseResult | null> {\n return withCache(\n {\n namespace: `datasource-${GoProxyDatasource.id}`,\n key: GoProxyDatasource.getCacheKey(config),\n public: isPublicGoPackage(config.packageName),\n fallback: true,\n },\n () => this._getReleases(config),\n );\n }\n\n /**\n * Avoid ambiguity when serving from case-insensitive file systems.\n *\n * @see https://golang.org/ref/mod#goproxy-protocol\n */\n encodeCase(input: string): string {\n return input.replace(regEx(/(?:[A-Z])/g), (x) => `!${x.toLowerCase()}`);\n }\n\n async listVersions(baseUrl: string, packageName: string): Promise<Release[]> {\n const url = joinUrlParts(\n baseUrl,\n this.encodeCase(packageName),\n '@v',\n 'list',\n );\n const { body } = await this.http.getText(url);\n return filterMap(body.split(newlineRegex), (str) => {\n if (!isNonEmptyStringAndNotWhitespace(str)) {\n return null;\n }\n\n const [version, timestamp] = str.trim().split(regEx(/\\s+/));\n const release: Release = pseudoVersionToRelease(version) ?? { version };\n\n const releaseTimestamp = asTimestamp(timestamp);\n if (releaseTimestamp) {\n release.releaseTimestamp = releaseTimestamp;\n }\n\n return release;\n });\n }\n\n async versionInfo(\n baseUrl: string,\n packageName: string,\n version: string,\n ): Promise<Release> {\n const url = joinUrlParts(\n baseUrl,\n this.encodeCase(packageName),\n '@v',\n `${version}.info`,\n );\n const res = await this.http.getJson(url, VersionInfo);\n\n const result: Release = {\n version: res.body.Version,\n };\n\n const releaseTimestamp = asTimestamp(res.body.Time);\n if (releaseTimestamp) {\n result.releaseTimestamp = releaseTimestamp;\n }\n\n return result;\n }\n\n /**\n * Retrieve the `go` directive for a given Go Module.\n *\n * NOTE that this means the `go` directive, not the `toolchain` directive.\n */\n async retrieveGoDirectiveForModule(\n baseUrl: string,\n packageName: string,\n version: string,\n ): Promise<string | undefined> {\n return withCache(\n {\n namespace: `datasource-${GoProxyDatasource.id}`,\n key: GoProxyDatasource.getVersionedCacheKey(packageName, version),\n // a module's `go.mod` should /never/ change after it's published. If going via the Go Proxy and the Go Checksum Database, a change in this value will result in build failures.\n ttlMinutes: 100 * 24 * 60,\n public: isPublicGoPackage(packageName),\n },\n () => this._retrieveGoDirectiveForModule(baseUrl, packageName, version),\n );\n }\n\n async _retrieveGoDirectiveForModule(\n baseUrl: string,\n packageName: string,\n version: string,\n ): Promise<string | undefined> {\n const url = joinUrlParts(\n baseUrl,\n this.encodeCase(packageName),\n '@v',\n `${version}.mod`,\n );\n const res = await this.http.getText(url);\n\n let goDirective: string | undefined = undefined;\n\n for (const line of res.body.split('\\n')) {\n const goVersionMatches = goVersionRegex.exec(line)?.groups;\n if (goVersionMatches) {\n goDirective = goVersionMatches.version;\n break;\n }\n }\n\n if (!goDirective) {\n return goDirective;\n }\n\n // always return it in full SemVer format, which can then be matched on using `semver` or `semver-coerced`\n const parts = goDirective.split('.');\n if (parts.length === 1) {\n return `${parts[0]}.0.0`;\n }\n if (parts.length === 2) {\n return `${parts[0]}.${parts[1]}.0`;\n }\n return `${parts[0]}.${parts[1]}.${parts[2]}`;\n }\n\n async getLatestVersion(\n baseUrl: string,\n packageName: string,\n ): Promise<{ version: string; sourceUrl?: string } | null> {\n try {\n const url = joinUrlParts(\n baseUrl,\n this.encodeCase(packageName),\n '@latest',\n );\n const res = await this.http.getJson(url, VersionInfo);\n const { Version: version, Origin: origin } = res.body;\n // Extract sourceUrl from GOPROXY Origin when present, avoiding go-get to\n // vanity hosts (https://github.com/renovatebot/renovate/discussions/44898)\n const sourceUrl =\n origin?.VCS === 'git' && isNonEmptyString(origin.URL)\n ? origin.URL.replace(regEx(/\\.git$/), '')\n : undefined;\n return { version, sourceUrl };\n } catch (err) {\n logger.trace({ err }, 'Failed to get latest version');\n return null;\n }\n }\n\n async getVersionsWithInfo(\n baseUrl: string,\n packageName: string,\n constraintsFiltering: ConstraintsFilter | undefined,\n ): Promise<ReleaseResult> {\n const isGopkgin = packageName.startsWith('gopkg.in/');\n const majorSuffixSeparator = isGopkgin ? '.' : '/';\n const modParts = packageName.match(modRegex)?.groups;\n /* v8 ignore start: defensive - modRegex matches any non-empty package name, so baseMod is always set */\n const baseMod = modParts?.baseMod ?? packageName;\n /* v8 ignore stop */\n const packageMajor = parseInt(modParts?.majorVersion ?? '0', 10);\n\n const result: ReleaseResult = { releases: [] };\n for (let major = packageMajor; ; major += 1) {\n let pkg = `${baseMod}${majorSuffixSeparator}v${major}`;\n if (!isGopkgin && major < 2) {\n pkg = baseMod;\n major += 1; // v0 and v1 are the same module\n }\n\n let releases: Release[] = [];\n\n try {\n const res = await this.listVersions(baseUrl, pkg);\n\n // Artifactory returns all versions in any major (past and future),\n // so starting from v2, we filter them in order to avoid the infinite loop\n const filteredReleases = res.filter(({ version }) => {\n if (major < 2) {\n return true;\n }\n\n return (\n version.split(regEx(/[^\\d]+/)).find(isTruthy) === major.toString()\n );\n });\n\n const timestamps = await GoVersionTimestampCache.init(baseUrl, pkg);\n\n releases = await p.map(filteredReleases, async (versionInfo) => {\n const { version, newDigest, releaseTimestamp } = versionInfo;\n\n if (releaseTimestamp) {\n return { version, newDigest, releaseTimestamp };\n }\n\n const cachedTimestamp = timestamps.get(version);\n if (cachedTimestamp) {\n return { version, releaseTimestamp: cachedTimestamp };\n }\n\n try {\n const release = await this.versionInfo(baseUrl, pkg, version);\n if (release.releaseTimestamp) {\n timestamps.set(version, release.releaseTimestamp);\n }\n return release;\n } catch (err) {\n logger.trace({ err }, `Can't obtain data from ${baseUrl}`);\n return { version };\n }\n });\n\n await timestamps.save();\n\n if (constraintsFiltering === 'strict') {\n releases = await p.map(releases, async (rel) => {\n try {\n const goDirective = await this.retrieveGoDirectiveForModule(\n baseUrl,\n pkg,\n rel.version,\n );\n if (goDirective) {\n rel.constraints ??= {};\n rel.constraints['%goMod'] ??= [];\n rel.constraints['%goMod'].push(goDirective);\n }\n } catch (err) {\n logger.trace(\n { err },\n `Can't obtain \\`go\\` directive from ${baseUrl}`,\n );\n }\n\n return rel;\n });\n }\n\n result.releases.push(...releases);\n } catch (err) {\n const potentialHttpError =\n err instanceof ExternalHostError ? err.err : err;\n const status = potentialHttpError.response?.statusCode;\n if (\n potentialHttpError instanceof HttpError &&\n (status === 404 || status === 403) &&\n major !== packageMajor\n ) {\n break;\n }\n\n throw err;\n }\n\n const latest = await this.getLatestVersion(baseUrl, pkg);\n if (latest) {\n const { version: latestVersion, sourceUrl } = latest;\n result.tags ??= {};\n result.tags.latest ??= latestVersion;\n if (goVersioning.isGreaterThan(latestVersion, result.tags.latest)) {\n result.tags.latest = latestVersion;\n }\n if (sourceUrl) {\n result.sourceUrl ??= sourceUrl;\n }\n if (!result.releases.length) {\n const releaseFromLatest = pseudoVersionToRelease(latestVersion);\n // v8 ignore else -- needs an empty version list plus a non-pseudo latest\n if (releaseFromLatest) {\n result.releases.push(releaseFromLatest);\n }\n }\n }\n\n if (!releases.length) {\n break;\n }\n }\n\n return result;\n }\n\n static getCacheKey({\n packageName,\n constraintsFiltering,\n }: GetReleasesConfig): string {\n const goproxy = getGoEnv().GOPROXY;\n const noproxy = parseNoproxy();\n const constraintsFilteringKey =\n constraintsFiltering === 'none' ? '' : constraintsFiltering;\n return buildCacheKey(\n 'getReleases',\n packageName,\n goproxy,\n noproxy?.toString(),\n constraintsFilteringKey,\n );\n }\n\n static getVersionedCacheKey(packageName: string, version: string): string {\n const goproxy = getGoEnv().GOPROXY;\n const noproxy = parseNoproxy();\n return buildCacheKey(\n 'goDirective',\n packageName,\n version,\n goproxy,\n noproxy?.toString(),\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAM,iBAAiB,MAAM,iCAAiC;AAE9D,MAAM,WAAW,MAAM,iD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F;KAEA,OAAO;IACT,CAAC;IAGH,OAAO,SAAS,KAAK,GAAG,QAAQ;GAClC,SAAS,KAAK;IACZ,MAAM,qBACJ,eAAe,oBAAoB,IAAI,MAAM;IAC/C,MAAM,SAAS,mBAAmB,UAAU;IAC5C,IACE,8BAA8BC,iBAC7B,WAAW,OAAO,WAAW,QAC9B,UAAU,cAEV;IAGF,MAAM;GACR;GAEA,MAAM,SAAS,MAAM,KAAK,iBAAiB,SAAS,GAAG;GACvD,IAAI,QAAQ;IACV,MAAM,EAAE,SAAS,eAAe,cAAc;IAC9C,OAAO,SAAS,CAAC;IACjB,OAAO,KAAK,WAAW;IACvB,IAAIC,IAAa,cAAc,eAAe,OAAO,KAAK,MAAM,GAC9D,OAAO,KAAK,SAAS;IAEvB,IAAI,WACF,OAAO,cAAc;IAEvB,IAAI,CAAC,OAAO,SAAS,QAAQ;KAC3B,MAAM,oBAAoB,uBAAuB,aAAa;;KAE9D,IAAI,mBACF,OAAO,SAAS,KAAK,iBAAiB;IAE1C;GACF;GAEA,IAAI,CAAC,SAAS,QACZ;EAEJ;EAEA,OAAO;CACT;CAEA,OAAO,YAAY,EACjB,aACA,wBAC4B;EAC5B,MAAM,UAAU,SAAS,CAAC,CAAC;EAC3B,MAAM,UAAU,aAAa;EAC7B,MAAM,0BACJ,yBAAyB,SAAS,KAAK;EACzC,OAAO,cACL,eACA,aACA,SACA,SAAS,SAAS,GAClB,uBACF;CACF;CAEA,OAAO,qBAAqB,aAAqB,SAAyB;EACxE,MAAM,UAAU,SAAS,CAAC,CAAC;EAC3B,MAAM,UAAU,aAAa;EAC7B,OAAO,cACL,eACA,aACA,SACA,SACA,SAAS,SAAS,CACpB;CACF;AACF"}
1
+ {"version":3,"file":"releases-goproxy.js","names":["p.map","HttpError","goVersioning"],"sources":["../../../../lib/modules/datasource/go/releases-goproxy.ts"],"sourcesContent":["import {\n isNonEmptyString,\n isNonEmptyStringAndNotWhitespace,\n isTruthy,\n} from '@sindresorhus/is';\nimport type { ConstraintsFilter } from '../../../config/types.ts';\nimport { logger } from '../../../logger/index.ts';\nimport { ExternalHostError } from '../../../types/errors/external-host-error.ts';\nimport { buildCacheKey } from '../../../util/cache/package/key.ts';\nimport { withCache } from '../../../util/cache/package/with-cache.ts';\nimport { detectPlatform } from '../../../util/common.ts';\nimport { filterMap } from '../../../util/filter-map.ts';\nimport {\n queryReleases,\n queryTags,\n} from '../../../util/github/graphql/index.ts';\nimport { GithubHttp } from '../../../util/http/github.ts';\nimport { HttpError } from '../../../util/http/index.ts';\nimport { isForbidden, isGone, isNotFound } from '../../../util/http/status.ts';\nimport * as p from '../../../util/promises.ts';\nimport { newlineRegex, regEx } from '../../../util/regex.ts';\nimport type { Timestamp } from '../../../util/timestamp.ts';\nimport { asTimestamp } from '../../../util/timestamp.ts';\nimport {\n joinUrlParts,\n parseUrl,\n trimLeadingSlash,\n trimTrailingSlash,\n} from '../../../util/url.ts';\nimport goVersioning from '../../versioning/go-mod-directive/index.ts';\nimport { parseVersionCommit } from '../../versioning/gomod/index.ts';\nimport { Datasource } from '../datasource.ts';\nimport { GithubReleasesDatasource } from '../github-releases/index.ts';\nimport type { GetReleasesConfig, Release, ReleaseResult } from '../types.ts';\nimport { BaseGoDatasource } from './base.ts';\nimport { getSourceUrl, isPublicGoPackage } from './common.ts';\nimport { getGoEnv, publicGoproxyUrl } from './env.ts';\nimport { parseGoproxy, parseNoproxy } from './goproxy-parser.ts';\nimport { GoDirectDatasource } from './releases-direct.ts';\nimport { VersionInfo } from './schema.ts';\nimport { GoVersionTimestampCache } from './timestamp-cache.ts';\n\n/** TODO #42566 */\nconst goVersionRegex = regEx(/^\\s*go\\s+(?<version>[^\\s]+)\\s*$/);\n\nconst modRegex = regEx(/^(?<baseMod>.*?)(?:[./]v(?<majorVersion>\\d+))?$/);\n\nconst versionTagRegex = regEx(/^v\\d/);\n\n/**\n * Modules with a major version of v2 or above which have no `go.mod` are reported by a Go proxy with a `+incompatible` suffix, which is absent from the tag they were published as.\n *\n * @see https://go.dev/ref/mod#non-module-compat\n */\nconst incompatibleSuffixRegex = regEx(/\\+incompatible$/);\n\nexport function pseudoVersionToRelease(pseudoVersion: string): Release | null {\n const commit = parseVersionCommit(pseudoVersion);\n if (!commit) {\n return null;\n }\n\n return {\n version: pseudoVersion,\n newDigest: commit.revision,\n releaseTimestamp: asTimestamp(commit.timestamp),\n };\n}\n\n/**\n * A Go module which lives in a subdirectory of its repository is tagged with that subdirectory as a prefix, so `github.com/aws/aws-sdk-go-v2/service/s3` publishes `v1.2.3` as the tag `service/s3/v1.2.3`.\n *\n * @see https://go.dev/ref/mod#vcs-version\n *\n * Because we can't tell from the module path alone where the repository ends and the subdirectory begins, we try each candidate prefix - longest first - against the tags we actually found, in the same way as `filterByPrefix` does for direct lookups.\n */\nexport function getTagPrefix(goModule: string, tags: Iterable<string>): string {\n const nameParts = goModule\n .replace(regEx(/\\/v\\d+$/), '')\n .split('/')\n .slice(1);\n const tagNames = [...tags];\n\n while (nameParts.length) {\n const prefix = `${nameParts.join('/')}/`;\n\n const isUsed = tagNames.some(\n (tag) =>\n tag.startsWith(prefix) &&\n versionTagRegex.test(tag.slice(prefix.length)),\n );\n if (isUsed) {\n return prefix;\n }\n\n nameParts.shift();\n }\n\n return '';\n}\n\nexport class GoProxyDatasource extends Datasource {\n static readonly id = 'go-proxy';\n\n constructor() {\n super(GoProxyDatasource.id);\n }\n\n readonly direct = new GoDirectDatasource();\n\n private readonly githubHttp = new GithubHttp(GithubReleasesDatasource.id);\n\n private async _getReleases(\n config: GetReleasesConfig,\n ): Promise<ReleaseResult | null> {\n const { packageName } = config;\n logger.trace(`goproxy.getReleases(${packageName})`);\n const goproxy = getGoEnv().GOPROXY ?? `${publicGoproxyUrl},direct`;\n if (goproxy === 'direct') {\n return this.getDirectReleases(config);\n }\n const proxyList = parseGoproxy(goproxy);\n const noproxy = parseNoproxy();\n\n let result: ReleaseResult | null = null;\n let servedByProxy = false;\n\n if (noproxy?.test(packageName)) {\n logger.debug(`Fetching ${packageName} via GONOPROXY match`);\n result = await this.getDirectReleases(config);\n return result;\n }\n\n for (const { url, fallback } of proxyList) {\n try {\n if (url === 'off') {\n break;\n } else if (url === 'direct') {\n result = await this.getDirectReleases(config);\n break;\n }\n\n const res = await this.getVersionsWithInfo(\n url,\n packageName,\n config.constraintsFiltering,\n );\n if (res.releases.length) {\n result = res;\n servedByProxy = true;\n break;\n }\n } catch (err) {\n const potentialHttpError =\n err instanceof ExternalHostError ? err.err : err;\n const canFallback =\n fallback === '|'\n ? true\n : isNotFound(potentialHttpError) || isGone(potentialHttpError);\n if (!canFallback) {\n logger.debug(\n { err },\n 'Goproxy error: not falling back to other URLs provided with GOPROXY, rethrowing',\n );\n this.handleGenericErrors(err);\n }\n logger.debug(\n { err },\n 'Goproxy error: trying next URL provided with GOPROXY',\n );\n }\n }\n\n if (result && !result.sourceUrl) {\n try {\n const datasource = await BaseGoDatasource.getDatasource(packageName);\n const sourceUrl = getSourceUrl(datasource);\n if (sourceUrl) {\n result.sourceUrl = sourceUrl;\n }\n } catch (err) {\n logger.trace({ err }, `Can't get datasource for ${packageName}`);\n }\n }\n\n if (result?.sourceUrl && servedByProxy) {\n await this.addGithubTimestamps(\n packageName,\n result.sourceUrl,\n result.releases,\n );\n }\n\n return result;\n }\n\n /**\n * Looks up a module directly from its source, or from the module proxy its `go-import` meta tag advertises with the `mod` VCS, as with private Buf Schema Registries.\n */\n private async getDirectReleases(\n config: GetReleasesConfig,\n ): Promise<ReleaseResult | null> {\n const { packageName } = config;\n\n const source = await BaseGoDatasource.getDatasource(packageName);\n if (!source) {\n const modProxyUrl = await BaseGoDatasource.getModProxyUrl(packageName);\n if (modProxyUrl) {\n logger.debug(\n `Fetching ${packageName} via go-import mod proxy ${modProxyUrl}`,\n );\n const res = await this.getVersionsWithInfo(\n modProxyUrl,\n packageName,\n config.constraintsFiltering,\n );\n return res.releases.length ? res : null;\n }\n }\n\n return this.direct.getReleases(config);\n }\n\n /**\n * A Go proxy reports the commit time of the tagged commit as a version's `Time`, which can be much earlier than the point at which that version was released.\n *\n * When the module is hosted on GitHub, a GitHub Release's publication time, or - if there's no Release - the git tag's own creation time (distinct from the commit time for an annotated tag), is a better indicator of when the version became available. A Release is preferred over a tag when both exist for the same version.\n */\n async addGithubTimestamps(\n packageName: string,\n sourceUrl: string,\n releases: Release[],\n ): Promise<void> {\n if (detectPlatform(sourceUrl) !== 'github') {\n return;\n }\n\n const parsedUrl = parseUrl(sourceUrl);\n /* v8 ignore next -- detectPlatform only returns a platform for parseable URLs */\n if (!parsedUrl) {\n return;\n }\n\n const repository = trimTrailingSlash(\n trimLeadingSlash(parsedUrl.pathname),\n ).replace(regEx(/\\.git$/), '');\n const githubConfig = {\n packageName: repository,\n registryUrl: parsedUrl.origin,\n };\n\n const [githubTags, githubReleases] = await Promise.all([\n queryTags(githubConfig, this.githubHttp).catch((err) => {\n logger.debug(\n { err, packageName },\n 'Error fetching GitHub Tags for Go module',\n );\n return [];\n }),\n queryReleases(githubConfig, this.githubHttp).catch((err) => {\n logger.debug(\n { err, packageName },\n 'Error fetching GitHub Releases for Go module',\n );\n return [];\n }),\n ]);\n\n const timestamps = new Map<string, Timestamp>();\n for (const { version, releaseTimestamp } of githubTags) {\n timestamps.set(version, releaseTimestamp);\n }\n for (const { version, releaseTimestamp } of githubReleases) {\n timestamps.set(version, releaseTimestamp);\n }\n\n const tagPrefix = getTagPrefix(packageName, timestamps.keys());\n for (const release of releases) {\n const version = release.version.replace(incompatibleSuffixRegex, '');\n const releaseTimestamp = timestamps.get(`${tagPrefix}${version}`);\n if (!releaseTimestamp) {\n continue;\n }\n\n if (\n !release.releaseTimestamp ||\n releaseTimestamp > release.releaseTimestamp\n ) {\n release.releaseTimestamp = releaseTimestamp;\n }\n }\n }\n\n getReleases(config: GetReleasesConfig): Promise<ReleaseResult | null> {\n return withCache(\n {\n namespace: `datasource-${GoProxyDatasource.id}`,\n key: GoProxyDatasource.getCacheKey(config),\n public: isPublicGoPackage(config.packageName),\n fallback: true,\n },\n () => this._getReleases(config),\n );\n }\n\n /**\n * Avoid ambiguity when serving from case-insensitive file systems.\n *\n * @see https://golang.org/ref/mod#goproxy-protocol\n */\n encodeCase(input: string): string {\n return input.replace(regEx(/(?:[A-Z])/g), (x) => `!${x.toLowerCase()}`);\n }\n\n async listVersions(baseUrl: string, packageName: string): Promise<Release[]> {\n const url = joinUrlParts(\n baseUrl,\n this.encodeCase(packageName),\n '@v',\n 'list',\n );\n const { body } = await this.http.getText(url);\n return filterMap(body.split(newlineRegex), (str) => {\n if (!isNonEmptyStringAndNotWhitespace(str)) {\n return null;\n }\n\n const [version, timestamp] = str.trim().split(regEx(/\\s+/));\n const release: Release = pseudoVersionToRelease(version) ?? { version };\n\n const releaseTimestamp = asTimestamp(timestamp);\n if (releaseTimestamp) {\n release.releaseTimestamp = releaseTimestamp;\n }\n\n return release;\n });\n }\n\n async versionInfo(\n baseUrl: string,\n packageName: string,\n version: string,\n ): Promise<Release> {\n const url = joinUrlParts(\n baseUrl,\n this.encodeCase(packageName),\n '@v',\n `${version}.info`,\n );\n const res = await this.http.getJson(url, VersionInfo);\n\n const result: Release = {\n version: res.body.Version,\n };\n\n const releaseTimestamp = asTimestamp(res.body.Time);\n if (releaseTimestamp) {\n result.releaseTimestamp = releaseTimestamp;\n }\n\n return result;\n }\n\n /**\n * Retrieve the `go` directive for a given Go Module.\n *\n * NOTE that this means the `go` directive, not the `toolchain` directive.\n */\n async retrieveGoDirectiveForModule(\n baseUrl: string,\n packageName: string,\n version: string,\n ): Promise<string | undefined> {\n return withCache(\n {\n namespace: `datasource-${GoProxyDatasource.id}`,\n key: GoProxyDatasource.getVersionedCacheKey(packageName, version),\n // a module's `go.mod` should /never/ change after it's published. If going via the Go Proxy and the Go Checksum Database, a change in this value will result in build failures.\n ttlMinutes: 100 * 24 * 60,\n public: isPublicGoPackage(packageName),\n },\n () => this._retrieveGoDirectiveForModule(baseUrl, packageName, version),\n );\n }\n\n async _retrieveGoDirectiveForModule(\n baseUrl: string,\n packageName: string,\n version: string,\n ): Promise<string | undefined> {\n const url = joinUrlParts(\n baseUrl,\n this.encodeCase(packageName),\n '@v',\n `${version}.mod`,\n );\n const res = await this.http.getText(url);\n\n let goDirective: string | undefined = undefined;\n\n for (const line of res.body.split('\\n')) {\n const goVersionMatches = goVersionRegex.exec(line)?.groups;\n if (goVersionMatches) {\n goDirective = goVersionMatches.version;\n break;\n }\n }\n\n if (!goDirective) {\n return goDirective;\n }\n\n // always return it in full SemVer format, which can then be matched on using `semver` or `semver-coerced`\n const parts = goDirective.split('.');\n if (parts.length === 1) {\n return `${parts[0]}.0.0`;\n }\n if (parts.length === 2) {\n return `${parts[0]}.${parts[1]}.0`;\n }\n return `${parts[0]}.${parts[1]}.${parts[2]}`;\n }\n\n async getLatestVersion(\n baseUrl: string,\n packageName: string,\n ): Promise<{ version: string; sourceUrl?: string } | null> {\n try {\n const url = joinUrlParts(\n baseUrl,\n this.encodeCase(packageName),\n '@latest',\n );\n const res = await this.http.getJson(url, VersionInfo);\n const { Version: version, Origin: origin } = res.body;\n // Extract sourceUrl from GOPROXY Origin when present, avoiding go-get to\n // vanity hosts (https://github.com/renovatebot/renovate/discussions/44898)\n const sourceUrl =\n origin?.VCS === 'git' && isNonEmptyString(origin.URL)\n ? origin.URL.replace(regEx(/\\.git$/), '')\n : undefined;\n return { version, sourceUrl };\n } catch (err) {\n logger.trace({ err }, 'Failed to get latest version');\n return null;\n }\n }\n\n async getVersionsWithInfo(\n baseUrl: string,\n packageName: string,\n constraintsFiltering: ConstraintsFilter | undefined,\n ): Promise<ReleaseResult> {\n const isGopkgin = packageName.startsWith('gopkg.in/');\n const majorSuffixSeparator = isGopkgin ? '.' : '/';\n const modParts = packageName.match(modRegex)?.groups;\n /* v8 ignore start: defensive - modRegex matches any non-empty package name, so baseMod is always set */\n const baseMod = modParts?.baseMod ?? packageName;\n /* v8 ignore stop */\n const packageMajor = parseInt(modParts?.majorVersion ?? '0', 10);\n\n const result: ReleaseResult = { releases: [] };\n for (let major = packageMajor; ; major += 1) {\n let pkg = `${baseMod}${majorSuffixSeparator}v${major}`;\n if (!isGopkgin && major < 2) {\n pkg = baseMod;\n major += 1; // v0 and v1 are the same module\n }\n\n let releases: Release[] = [];\n\n try {\n const res = await this.listVersions(baseUrl, pkg);\n\n // Artifactory returns all versions in any major (past and future),\n // so starting from v2, we filter them in order to avoid the infinite loop\n const filteredReleases = res.filter(({ version }) => {\n if (major < 2) {\n return true;\n }\n\n return (\n version.split(regEx(/[^\\d]+/)).find(isTruthy) === major.toString()\n );\n });\n\n const timestamps = await GoVersionTimestampCache.init(baseUrl, pkg);\n\n releases = await p.map(filteredReleases, async (versionInfo) => {\n const { version, newDigest, releaseTimestamp } = versionInfo;\n\n if (releaseTimestamp) {\n return { version, newDigest, releaseTimestamp };\n }\n\n const cachedTimestamp = timestamps.get(version);\n if (cachedTimestamp) {\n return { version, releaseTimestamp: cachedTimestamp };\n }\n\n try {\n const release = await this.versionInfo(baseUrl, pkg, version);\n if (release.releaseTimestamp) {\n timestamps.set(version, release.releaseTimestamp);\n }\n return release;\n } catch (err) {\n logger.trace({ err }, `Can't obtain data from ${baseUrl}`);\n return { version };\n }\n });\n\n await timestamps.save();\n\n if (constraintsFiltering === 'strict') {\n releases = await p.map(releases, async (rel) => {\n try {\n const goDirective = await this.retrieveGoDirectiveForModule(\n baseUrl,\n pkg,\n rel.version,\n );\n if (goDirective) {\n rel.constraints ??= {};\n rel.constraints['%goMod'] ??= [];\n rel.constraints['%goMod'].push(goDirective);\n }\n } catch (err) {\n logger.trace(\n { err },\n `Can't obtain \\`go\\` directive from ${baseUrl}`,\n );\n }\n\n return rel;\n });\n }\n\n result.releases.push(...releases);\n } catch (err) {\n const potentialHttpError =\n err instanceof ExternalHostError ? err.err : err;\n const isNotFoundOrForbidden =\n isNotFound(potentialHttpError) || isForbidden(potentialHttpError);\n if (\n potentialHttpError instanceof HttpError &&\n isNotFoundOrForbidden &&\n major !== packageMajor\n ) {\n break;\n }\n\n throw err;\n }\n\n const latest = await this.getLatestVersion(baseUrl, pkg);\n if (latest) {\n const { version: latestVersion, sourceUrl } = latest;\n result.tags ??= {};\n result.tags.latest ??= latestVersion;\n if (goVersioning.isGreaterThan(latestVersion, result.tags.latest)) {\n result.tags.latest = latestVersion;\n }\n if (sourceUrl) {\n result.sourceUrl ??= sourceUrl;\n }\n if (!result.releases.length) {\n const releaseFromLatest = pseudoVersionToRelease(latestVersion);\n // v8 ignore else -- needs an empty version list plus a non-pseudo latest\n if (releaseFromLatest) {\n result.releases.push(releaseFromLatest);\n }\n }\n }\n\n if (!releases.length) {\n break;\n }\n }\n\n return result;\n }\n\n static getCacheKey({\n packageName,\n constraintsFiltering,\n }: GetReleasesConfig): string {\n const goproxy = getGoEnv().GOPROXY;\n const noproxy = parseNoproxy();\n const constraintsFilteringKey =\n constraintsFiltering === 'none' ? '' : constraintsFiltering;\n return buildCacheKey(\n 'getReleases',\n packageName,\n goproxy,\n noproxy?.toString(),\n constraintsFilteringKey,\n );\n }\n\n static getVersionedCacheKey(packageName: string, version: string): string {\n const goproxy = getGoEnv().GOPROXY;\n const noproxy = parseNoproxy();\n return buildCacheKey(\n 'goDirective',\n packageName,\n version,\n goproxy,\n noproxy?.toString(),\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAM,iBAAiB,MAAM,iCAAiC;AAE9D,MAAM,WAAW,MAAM,iDAAiD;AAExE,MAAM,kBAAkB,MAAM,MAAM;;;;;;AAOpC,MAAM,0BAA0B,MAAM,iBAAiB;AAEvD,SAAgB,uBAAuB,eAAuC;CAC5E,MAAM,SAAS,mBAAmB,aAAa;CAC/C,IAAI,CAAC,QACH,OAAO;CAGT,OAAO;EACL,SAAS;EACT,WAAW,OAAO;EAClB,kBAAkB,YAAY,OAAO,SAAS;CAChD;AACF;;;;;;;;AASA,SAAgB,aAAa,UAAkB,MAAgC;CAC7E,MAAM,YAAY,SACf,QAAQ,MAAM,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,MAAM,EAAE,SAAS,eAAe,cAAc;IAC9C,OAAO,SAAS,CAAC;IACjB,OAAO,KAAK,WAAW;IACvB,IAAIC,IAAa,cAAc,eAAe,OAAO,KAAK,MAAM,GAC9D,OAAO,KAAK,SAAS;IAEvB,IAAI,WACF,OAAO,cAAc;IAEvB,IAAI,CAAC,OAAO,SAAS,QAAQ;KAC3B,MAAM,oBAAoB,uBAAuB,aAAa;;KAE9D,IAAI,mBACF,OAAO,SAAS,KAAK,iBAAiB;IAE1C;GACF;GAEA,IAAI,CAAC,SAAS,QACZ;EAEJ;EAEA,OAAO;CACT;CAEA,OAAO,YAAY,EACjB,aACA,wBAC4B;EAC5B,MAAM,UAAU,SAAS,CAAC,CAAC;EAC3B,MAAM,UAAU,aAAa;EAC7B,MAAM,0BACJ,yBAAyB,SAAS,KAAK;EACzC,OAAO,cACL,eACA,aACA,SACA,SAAS,SAAS,GAClB,uBACF;CACF;CAEA,OAAO,qBAAqB,aAAqB,SAAyB;EACxE,MAAM,UAAU,SAAS,CAAC,CAAC;EAC3B,MAAM,UAAU,aAAa;EAC7B,OAAO,cACL,eACA,aACA,SACA,SACA,SAAS,SAAS,CACpB;CACF;AACF"}
@@ -1,6 +1,7 @@
1
1
  import { logger } from "../../../logger/index.js";
2
2
  import { buildCacheKey } from "../../../util/cache/package/key.js";
3
3
  import { ensureTrailingSlash } from "../../../util/url.js";
4
+ import { isForbidden } from "../../../util/http/status.js";
4
5
  import { find } from "../../../util/host-rules.js";
5
6
  import { parseSingleYaml } from "../../../util/yaml.js";
6
7
  import { ExternalHostError } from "../../../types/errors/external-host-error.js";
@@ -82,7 +83,7 @@ function classifyS3Error(err, indexUrl) {
82
83
  logger.debug({ indexUrl }, "Helm S3 lookup error: object not found");
83
84
  return err;
84
85
  }
85
- if (err.name === "CredentialsProviderError" || err.$metadata?.httpStatusCode === 403) logger.debug({
86
+ if (err.name === "CredentialsProviderError" || isForbidden(err.$metadata?.httpStatusCode)) logger.debug({
86
87
  indexUrl,
87
88
  err
88
89
  }, "Helm S3 lookup error: credentials error, check \"AWS_ACCESS_KEY_ID\" and \"AWS_SECRET_ACCESS_KEY\" variables or the matching `hostRules` entry");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["helmVersioning.id","hostRules.find"],"sources":["../../../../lib/modules/datasource/helm/index.ts"],"sourcesContent":["import { Readable } from 'node:stream';\nimport type {\n GetObjectCommandOutput,\n S3ClientConfig,\n} from '@aws-sdk/client-s3';\nimport { GetObjectCommand } from '@aws-sdk/client-s3';\nimport { logger } from '../../../logger/index.ts';\nimport { ExternalHostError } from '../../../types/errors/external-host-error.ts';\nimport { buildCacheKey } from '../../../util/cache/package/key.ts';\nimport { withCache } from '../../../util/cache/package/with-cache.ts';\nimport * as hostRules from '../../../util/host-rules.ts';\nimport type { S3UrlParts } from '../../../util/s3.ts';\nimport { getS3Client, parseS3Url } from '../../../util/s3.ts';\nimport { streamToString } from '../../../util/streams.ts';\nimport { ensureTrailingSlash } from '../../../util/url.ts';\nimport { parseSingleYaml } from '../../../util/yaml.ts';\nimport * as helmVersioning from '../../versioning/helm/index.ts';\nimport { Datasource } from '../datasource.ts';\nimport type { GetReleasesConfig, ReleaseResult } from '../types.ts';\nimport { HelmRepository } from './schema.ts';\n\nexport class HelmDatasource extends Datasource {\n static readonly id = 'helm';\n\n constructor() {\n super(HelmDatasource.id);\n }\n\n override getDefaultRegistryUrls(_packageName: string): string[] {\n return ['https://charts.helm.sh/stable'];\n }\n\n override readonly defaultConfig = {\n commitMessageTopic: 'Helm release {{depName}}',\n };\n\n override readonly defaultVersioning = helmVersioning.id;\n\n override readonly releaseTimestampSupport = true;\n override readonly releaseTimestampNote =\n 'The release timstamp is determined from the `created` field in the results.';\n override readonly sourceUrlSupport = 'package';\n override readonly sourceUrlNote =\n 'The source URL is determined from the `home` field or the `sources` field in the results.';\n\n private async _getRepositoryData(\n helmRepository: string,\n ): Promise<HelmRepository> {\n const baseUrl = ensureTrailingSlash(helmRepository);\n const indexUrl = `${baseUrl}index.yaml`;\n\n const s3Url = parseS3Url(indexUrl);\n if (s3Url) {\n return await getS3RepositoryData(s3Url, indexUrl);\n }\n\n const { val, err } = await this.http\n .getYamlSafe('index.yaml', { baseUrl }, HelmRepository)\n .unwrap();\n\n if (err) {\n this.handleGenericErrors(err);\n }\n\n return val;\n }\n\n getRepositoryData(helmRepository: string): Promise<HelmRepository> {\n return withCache(\n {\n namespace: `datasource-${HelmDatasource.id}`,\n key: buildCacheKey('repository-data', helmRepository),\n },\n () => this._getRepositoryData(helmRepository),\n );\n }\n\n async getReleases({\n packageName,\n registryUrl: helmRepository,\n }: GetReleasesConfig): Promise<ReleaseResult | null> {\n /* v8 ignore next -- should never happen */\n if (!helmRepository) {\n return null;\n }\n\n const repositoryData = await this.getRepositoryData(helmRepository);\n const releases = repositoryData[packageName];\n if (!releases) {\n logger.debug(\n { dependency: packageName },\n `Entry ${packageName} doesn't exist in index.yaml from ${helmRepository}`,\n );\n return null;\n }\n return releases;\n }\n}\n\nasync function getS3RepositoryData(\n s3Url: S3UrlParts,\n indexUrl: string,\n): Promise<HelmRepository> {\n const client = getS3Client(undefined, undefined, getS3Credentials(indexUrl));\n\n let res: GetObjectCommandOutput;\n try {\n res = await client.send(new GetObjectCommand(s3Url));\n } catch (err) {\n throw classifyS3Error(err, indexUrl);\n }\n\n if (res.DeleteMarker) {\n logger.debug(\n { indexUrl },\n 'Helm S3 lookup error: DeleteMarker encountered',\n );\n throw new Error(`No index.yaml found at ${indexUrl}`);\n }\n\n if (!(res.Body instanceof Readable)) {\n logger.debug({ indexUrl }, 'Helm S3 lookup error: unsupported Body type');\n throw new Error(`Unsupported S3 response body for ${indexUrl}`);\n }\n\n return parseSingleYaml(await streamToString(res.Body), {\n customSchema: HelmRepository,\n });\n}\n\n/**\n * Only a missing object means \"this chart repository has no releases\", so that\n * error is rethrown as-is and the lookup resolves to `null`.\n * Everything else becomes an `ExternalHostError` to abort the run, otherwise a\n * transient S3 failure looks like a deleted chart and closes open PRs.\n */\nfunction classifyS3Error(\n // `name` holds the S3 error code, `message` holds server-supplied prose\n err: Error & { $metadata?: { httpStatusCode?: number } },\n indexUrl: string,\n): Error {\n if (err.name === 'NotFound' || err.name === 'NoSuchKey') {\n logger.debug({ indexUrl }, 'Helm S3 lookup error: object not found');\n return err;\n }\n\n if (\n err.name === 'CredentialsProviderError' ||\n err.$metadata?.httpStatusCode === 403\n ) {\n logger.debug(\n { indexUrl, err },\n 'Helm S3 lookup error: credentials error, check \"AWS_ACCESS_KEY_ID\" and \"AWS_SECRET_ACCESS_KEY\" variables or the matching `hostRules` entry',\n );\n } else if (err.message === 'Region is missing') {\n // Thrown client-side by the SDK region resolver, so this string is stable\n logger.debug(\n { indexUrl },\n 'Helm S3 lookup error: missing region, check \"AWS_REGION\" variable',\n );\n } else {\n logger.debug({ indexUrl, err }, 'Helm S3 lookup error: unknown error');\n }\n\n return new ExternalHostError(err, HelmDatasource.id);\n}\n\nfunction getS3Credentials(\n indexUrl: string,\n): S3ClientConfig['credentials'] | undefined {\n const { username, password, token } = hostRules.find({\n hostType: HelmDatasource.id,\n url: indexUrl,\n });\n\n // Fall back to the default AWS credential provider chain\n if (!username || !password) {\n return undefined;\n }\n\n return {\n accessKeyId: username,\n secretAccessKey: password,\n sessionToken: token,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;AAqBA,IAAa,iBAAb,MAAa,uBAAuB,WAAW;CAC7C,OAAgB,KAAK;CAErB,cAAc;EACZ,MAAM,eAAe,EAAE;CACzB;CAEA,uBAAgC,cAAgC;EAC9D,OAAO,CAAC,+BAA+B;CACzC;CAEA,gBAAkC,EAChC,oBAAoB,2BACtB;CAEA,oBAAsCA;CAEtC,0BAA4C;CAC5C,uBACE;CACF,mBAAqC;CACrC,gBACE;CAEF,MAAc,mBACZ,gBACyB;EACzB,MAAM,UAAU,oBAAoB,cAAc;EAClD,MAAM,WAAW,GAAG,QAAQ;EAE5B,MAAM,QAAQ,WAAW,QAAQ;EACjC,IAAI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a;EACvD,OAAO,MAAM,EAAE,SAAS,GAAG,wCAAwC;EACnE,OAAO;CACT;CAEA,IACE,IAAI,SAAS,8BACb,IAAI,WAAW,mBAAmB,KAElC,OAAO,MACL;EAAE;EAAU;CAAI,GAChB,gJACF;MACK,IAAI,IAAI,YAAY,qBAEzB,OAAO,MACL,EAAE,SAAS,GACX,qEACF;MAEA,OAAO,MAAM;EAAE;EAAU;CAAI,GAAG,qCAAqC;CAGvE,OAAO,IAAI,kBAAkB,KAAK,eAAe,EAAE;AACrD;AAEA,SAAS,iBACP,UAC2C;CAC3C,MAAM,EAAE,UAAU,UAAU,UAAUC,KAAe;EACnD,UAAU,eAAe;EACzB,KAAK;CACP,CAAC;CAGD,IAAI,CAAC,YAAY,CAAC,UAChB;CAGF,OAAO;EACL,aAAa;EACb,iBAAiB;EACjB,cAAc;CAChB;AACF"}
1
+ {"version":3,"file":"index.js","names":["helmVersioning.id","hostRules.find"],"sources":["../../../../lib/modules/datasource/helm/index.ts"],"sourcesContent":["import { Readable } from 'node:stream';\nimport type {\n GetObjectCommandOutput,\n S3ClientConfig,\n} from '@aws-sdk/client-s3';\nimport { GetObjectCommand } from '@aws-sdk/client-s3';\nimport { logger } from '../../../logger/index.ts';\nimport { ExternalHostError } from '../../../types/errors/external-host-error.ts';\nimport { buildCacheKey } from '../../../util/cache/package/key.ts';\nimport { withCache } from '../../../util/cache/package/with-cache.ts';\nimport * as hostRules from '../../../util/host-rules.ts';\nimport { isForbidden } from '../../../util/http/status.ts';\nimport type { S3UrlParts } from '../../../util/s3.ts';\nimport { getS3Client, parseS3Url } from '../../../util/s3.ts';\nimport { streamToString } from '../../../util/streams.ts';\nimport { ensureTrailingSlash } from '../../../util/url.ts';\nimport { parseSingleYaml } from '../../../util/yaml.ts';\nimport * as helmVersioning from '../../versioning/helm/index.ts';\nimport { Datasource } from '../datasource.ts';\nimport type { GetReleasesConfig, ReleaseResult } from '../types.ts';\nimport { HelmRepository } from './schema.ts';\n\nexport class HelmDatasource extends Datasource {\n static readonly id = 'helm';\n\n constructor() {\n super(HelmDatasource.id);\n }\n\n override getDefaultRegistryUrls(_packageName: string): string[] {\n return ['https://charts.helm.sh/stable'];\n }\n\n override readonly defaultConfig = {\n commitMessageTopic: 'Helm release {{depName}}',\n };\n\n override readonly defaultVersioning = helmVersioning.id;\n\n override readonly releaseTimestampSupport = true;\n override readonly releaseTimestampNote =\n 'The release timstamp is determined from the `created` field in the results.';\n override readonly sourceUrlSupport = 'package';\n override readonly sourceUrlNote =\n 'The source URL is determined from the `home` field or the `sources` field in the results.';\n\n private async _getRepositoryData(\n helmRepository: string,\n ): Promise<HelmRepository> {\n const baseUrl = ensureTrailingSlash(helmRepository);\n const indexUrl = `${baseUrl}index.yaml`;\n\n const s3Url = parseS3Url(indexUrl);\n if (s3Url) {\n return await getS3RepositoryData(s3Url, indexUrl);\n }\n\n const { val, err } = await this.http\n .getYamlSafe('index.yaml', { baseUrl }, HelmRepository)\n .unwrap();\n\n if (err) {\n this.handleGenericErrors(err);\n }\n\n return val;\n }\n\n getRepositoryData(helmRepository: string): Promise<HelmRepository> {\n return withCache(\n {\n namespace: `datasource-${HelmDatasource.id}`,\n key: buildCacheKey('repository-data', helmRepository),\n },\n () => this._getRepositoryData(helmRepository),\n );\n }\n\n async getReleases({\n packageName,\n registryUrl: helmRepository,\n }: GetReleasesConfig): Promise<ReleaseResult | null> {\n /* v8 ignore next -- should never happen */\n if (!helmRepository) {\n return null;\n }\n\n const repositoryData = await this.getRepositoryData(helmRepository);\n const releases = repositoryData[packageName];\n if (!releases) {\n logger.debug(\n { dependency: packageName },\n `Entry ${packageName} doesn't exist in index.yaml from ${helmRepository}`,\n );\n return null;\n }\n return releases;\n }\n}\n\nasync function getS3RepositoryData(\n s3Url: S3UrlParts,\n indexUrl: string,\n): Promise<HelmRepository> {\n const client = getS3Client(undefined, undefined, getS3Credentials(indexUrl));\n\n let res: GetObjectCommandOutput;\n try {\n res = await client.send(new GetObjectCommand(s3Url));\n } catch (err) {\n throw classifyS3Error(err, indexUrl);\n }\n\n if (res.DeleteMarker) {\n logger.debug(\n { indexUrl },\n 'Helm S3 lookup error: DeleteMarker encountered',\n );\n throw new Error(`No index.yaml found at ${indexUrl}`);\n }\n\n if (!(res.Body instanceof Readable)) {\n logger.debug({ indexUrl }, 'Helm S3 lookup error: unsupported Body type');\n throw new Error(`Unsupported S3 response body for ${indexUrl}`);\n }\n\n return parseSingleYaml(await streamToString(res.Body), {\n customSchema: HelmRepository,\n });\n}\n\n/**\n * Only a missing object means \"this chart repository has no releases\", so that\n * error is rethrown as-is and the lookup resolves to `null`.\n * Everything else becomes an `ExternalHostError` to abort the run, otherwise a\n * transient S3 failure looks like a deleted chart and closes open PRs.\n */\nfunction classifyS3Error(\n // `name` holds the S3 error code, `message` holds server-supplied prose\n err: Error & { $metadata?: { httpStatusCode?: number } },\n indexUrl: string,\n): Error {\n if (err.name === 'NotFound' || err.name === 'NoSuchKey') {\n logger.debug({ indexUrl }, 'Helm S3 lookup error: object not found');\n return err;\n }\n\n if (\n err.name === 'CredentialsProviderError' ||\n isForbidden(err.$metadata?.httpStatusCode)\n ) {\n logger.debug(\n { indexUrl, err },\n 'Helm S3 lookup error: credentials error, check \"AWS_ACCESS_KEY_ID\" and \"AWS_SECRET_ACCESS_KEY\" variables or the matching `hostRules` entry',\n );\n } else if (err.message === 'Region is missing') {\n // Thrown client-side by the SDK region resolver, so this string is stable\n logger.debug(\n { indexUrl },\n 'Helm S3 lookup error: missing region, check \"AWS_REGION\" variable',\n );\n } else {\n logger.debug({ indexUrl, err }, 'Helm S3 lookup error: unknown error');\n }\n\n return new ExternalHostError(err, HelmDatasource.id);\n}\n\nfunction getS3Credentials(\n indexUrl: string,\n): S3ClientConfig['credentials'] | undefined {\n const { username, password, token } = hostRules.find({\n hostType: HelmDatasource.id,\n url: indexUrl,\n });\n\n // Fall back to the default AWS credential provider chain\n if (!username || !password) {\n return undefined;\n }\n\n return {\n accessKeyId: username,\n secretAccessKey: password,\n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SAAS,KAAK;EACZ,MAAM,gBAAgB,KAAK,QAAQ;CACrC;CAEA,IAAI,IAAI,cAAc;EACpB,OAAO,MACL,EAAE,SAAS,GACX,gDACF;EACA,MAAM,IAAI,MAAM,0BAA0B,UAAU;CACtD;CAEA,IAAI,EAAE,IAAI,gBAAgB,WAAW;EACnC,OAAO,MAAM,EAAE,SAAS,GAAG,6CAA6C;EACxE,MAAM,IAAI,MAAM,oCAAoC,UAAU;CAChE;CAEA,OAAO,gBAAgB,MAAM,eAAe,IAAI,IAAI,GAAG,EACrD,cAAc,eAChB,CAAC;AACH;;;;;;;AAQA,SAAS,gBAEP,KACA,UACO;CACP,IAAI,IAAI,SAAS,cAAc,IAAI,SAAS,aAAa;EACvD,OAAO,MAAM,EAAE,SAAS,GAAG,wCAAwC;EACnE,OAAO;CACT;CAEA,IACE,IAAI,SAAS,8BACb,YAAY,IAAI,WAAW,cAAc,GAEzC,OAAO,MACL;EAAE;EAAU;CAAI,GAChB,gJACF;MACK,IAAI,IAAI,YAAY,qBAEzB,OAAO,MACL,EAAE,SAAS,GACX,qEACF;MAEA,OAAO,MAAM;EAAE;EAAU;CAAI,GAAG,qCAAqC;CAGvE,OAAO,IAAI,kBAAkB,KAAK,eAAe,EAAE;AACrD;AAEA,SAAS,iBACP,UAC2C;CAC3C,MAAM,EAAE,UAAU,UAAU,UAAUC,KAAe;EACnD,UAAU,eAAe;EACzB,KAAK;CACP,CAAC;CAGD,IAAI,CAAC,YAAY,CAAC,UAChB;CAGF,OAAO;EACL,aAAa;EACb,iBAAiB;EACjB,cAAc;CAChB;AACF"}
@@ -1,6 +1,7 @@
1
1
  import { regEx } from "../../../util/regex.js";
2
2
  import { logger } from "../../../logger/index.js";
3
3
  import { buildCacheKey } from "../../../util/cache/package/key.js";
4
+ import { isNotFound } from "../../../util/http/status.js";
4
5
  import { ExternalHostError } from "../../../types/errors/external-host-error.js";
5
6
  import { id } from "../../versioning/semver/index.js";
6
7
  import { RequestError } from "../../../util/http/got.js";
@@ -50,7 +51,7 @@ var HexpmBobDatasource = class HexpmBobDatasource extends Datasource {
50
51
  };
51
52
  });
52
53
  } catch (err) {
53
- if (err instanceof RequestError && err.response?.statusCode !== 404) throw new ExternalHostError(err);
54
+ if (err instanceof RequestError && !isNotFound(err)) throw new ExternalHostError(err);
54
55
  this.handleGenericErrors(err);
55
56
  }
56
57
  return result.releases.length > 0 ? result : null;