renovate 44.210.2 → 44.211.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 (307) 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/global-config-option-defaults.generated.js +1 -1
  13. package/dist/global-config-option-defaults.generated.js.map +1 -1
  14. package/dist/instrumentation/index.js +3 -2
  15. package/dist/instrumentation/index.js.map +1 -1
  16. package/dist/logger/bunyan.js +3 -2
  17. package/dist/logger/bunyan.js.map +1 -1
  18. package/dist/logger/pretty-stdout.js +2 -1
  19. package/dist/logger/pretty-stdout.js.map +1 -1
  20. package/dist/modules/datasource/apk/index.js +2 -2
  21. package/dist/modules/datasource/apk/index.js.map +1 -1
  22. package/dist/modules/datasource/artifactory/index.js +2 -3
  23. package/dist/modules/datasource/artifactory/index.js.map +1 -1
  24. package/dist/modules/datasource/bazel/index.js +2 -1
  25. package/dist/modules/datasource/bazel/index.js.map +1 -1
  26. package/dist/modules/datasource/cdnjs/index.js +2 -1
  27. package/dist/modules/datasource/cdnjs/index.js.map +1 -1
  28. package/dist/modules/datasource/conda/index.js +2 -1
  29. package/dist/modules/datasource/conda/index.js.map +1 -1
  30. package/dist/modules/datasource/crate/index.js +2 -1
  31. package/dist/modules/datasource/crate/index.js.map +1 -1
  32. package/dist/modules/datasource/dart-version/index.js +2 -1
  33. package/dist/modules/datasource/dart-version/index.js.map +1 -1
  34. package/dist/modules/datasource/datasource.js +2 -2
  35. package/dist/modules/datasource/datasource.js.map +1 -1
  36. package/dist/modules/datasource/deb/url.js +3 -1
  37. package/dist/modules/datasource/deb/url.js.map +1 -1
  38. package/dist/modules/datasource/devbox/index.js +2 -1
  39. package/dist/modules/datasource/devbox/index.js.map +1 -1
  40. package/dist/modules/datasource/docker/common.js +10 -8
  41. package/dist/modules/datasource/docker/common.js.map +1 -1
  42. package/dist/modules/datasource/docker/ecr.js +2 -1
  43. package/dist/modules/datasource/docker/ecr.js.map +1 -1
  44. package/dist/modules/datasource/docker/index.js +20 -17
  45. package/dist/modules/datasource/docker/index.js.map +1 -1
  46. package/dist/modules/datasource/gitea-tags/base.js +2 -3
  47. package/dist/modules/datasource/gitea-tags/base.js.map +1 -1
  48. package/dist/modules/datasource/github-tags/index.js +2 -1
  49. package/dist/modules/datasource/github-tags/index.js.map +1 -1
  50. package/dist/modules/datasource/gitlab-tags/index.js +2 -3
  51. package/dist/modules/datasource/gitlab-tags/index.js.map +1 -1
  52. package/dist/modules/datasource/go/base.js +1 -1
  53. package/dist/modules/datasource/go/base.js.map +1 -1
  54. package/dist/modules/datasource/go/common.js +8 -2
  55. package/dist/modules/datasource/go/common.js.map +1 -1
  56. package/dist/modules/datasource/go/env.js +2 -1
  57. package/dist/modules/datasource/go/env.js.map +1 -1
  58. package/dist/modules/datasource/go/releases-goproxy.js +7 -5
  59. package/dist/modules/datasource/go/releases-goproxy.js.map +1 -1
  60. package/dist/modules/datasource/helm/index.js +2 -1
  61. package/dist/modules/datasource/helm/index.js.map +1 -1
  62. package/dist/modules/datasource/hexpm-bob/index.js +2 -1
  63. package/dist/modules/datasource/hexpm-bob/index.js.map +1 -1
  64. package/dist/modules/datasource/index.js +4 -3
  65. package/dist/modules/datasource/index.js.map +1 -1
  66. package/dist/modules/datasource/java-version/adoptium.js +3 -2
  67. package/dist/modules/datasource/java-version/adoptium.js.map +1 -1
  68. package/dist/modules/datasource/java-version/graalvm.js +2 -1
  69. package/dist/modules/datasource/java-version/graalvm.js.map +1 -1
  70. package/dist/modules/datasource/maven/index.js.map +1 -1
  71. package/dist/modules/datasource/maven/util.js +7 -10
  72. package/dist/modules/datasource/maven/util.js.map +1 -1
  73. package/dist/modules/datasource/npm/npmrc.js +2 -2
  74. package/dist/modules/datasource/npm/npmrc.js.map +1 -1
  75. package/dist/modules/datasource/nuget/v3.js +3 -5
  76. package/dist/modules/datasource/nuget/v3.js.map +1 -1
  77. package/dist/modules/datasource/packagist/index.js +4 -5
  78. package/dist/modules/datasource/packagist/index.js.map +1 -1
  79. package/dist/modules/datasource/pod/index.js +4 -4
  80. package/dist/modules/datasource/pod/index.js.map +1 -1
  81. package/dist/modules/datasource/pypi/index.js +19 -11
  82. package/dist/modules/datasource/pypi/index.js.map +1 -1
  83. package/dist/modules/datasource/python-version/index.js +2 -3
  84. package/dist/modules/datasource/python-version/index.js.map +1 -1
  85. package/dist/modules/datasource/repology/index.js +4 -3
  86. package/dist/modules/datasource/repology/index.js.map +1 -1
  87. package/dist/modules/datasource/rpm/providers/common.js +3 -1
  88. package/dist/modules/datasource/rpm/providers/common.js.map +1 -1
  89. package/dist/modules/datasource/rubygems/index.js +2 -5
  90. package/dist/modules/datasource/rubygems/index.js.map +1 -1
  91. package/dist/modules/datasource/rubygems/versions-endpoint-cache.js +13 -18
  92. package/dist/modules/datasource/rubygems/versions-endpoint-cache.js.map +1 -1
  93. package/dist/modules/datasource/terraform-module/base.js +2 -1
  94. package/dist/modules/datasource/terraform-module/base.js.map +1 -1
  95. package/dist/modules/datasource/terraform-provider/index.js +2 -3
  96. package/dist/modules/datasource/terraform-provider/index.js.map +1 -1
  97. package/dist/modules/manager/bazel-module/parser/context.js +0 -1
  98. package/dist/modules/manager/bazel-module/parser/context.js.map +1 -1
  99. package/dist/modules/manager/bundler/host-rules.js +4 -1
  100. package/dist/modules/manager/bundler/host-rules.js.map +1 -1
  101. package/dist/modules/manager/composer/range.js +1 -1
  102. package/dist/modules/manager/composer/range.js.map +1 -1
  103. package/dist/modules/manager/custom/utils.js +3 -1
  104. package/dist/modules/manager/custom/utils.js.map +1 -1
  105. package/dist/modules/manager/devbox/schema.js +2 -1
  106. package/dist/modules/manager/devbox/schema.js.map +1 -1
  107. package/dist/modules/manager/dockerfile/extract.js +10 -2
  108. package/dist/modules/manager/dockerfile/extract.js.map +1 -1
  109. package/dist/modules/manager/fingerprint.generated.js +1 -1
  110. package/dist/modules/manager/fingerprint.generated.js.map +1 -1
  111. package/dist/modules/manager/github-actions/parse.js +2 -1
  112. package/dist/modules/manager/github-actions/parse.js.map +1 -1
  113. package/dist/modules/manager/gomod/artifacts.js +5 -2
  114. package/dist/modules/manager/gomod/artifacts.js.map +1 -1
  115. package/dist/modules/manager/gradle/artifacts.js +5 -2
  116. package/dist/modules/manager/gradle/artifacts.js.map +1 -1
  117. package/dist/modules/manager/gradle/utils.js +2 -1
  118. package/dist/modules/manager/gradle/utils.js.map +1 -1
  119. package/dist/modules/manager/gradle-wrapper/utils.js +9 -5
  120. package/dist/modules/manager/gradle-wrapper/utils.js.map +1 -1
  121. package/dist/modules/manager/helm-values/util.js +1 -1
  122. package/dist/modules/manager/helm-values/util.js.map +1 -1
  123. package/dist/modules/manager/helmfile/artifacts.js +1 -1
  124. package/dist/modules/manager/helmfile/artifacts.js.map +1 -1
  125. package/dist/modules/manager/helmv3/artifacts.js +1 -1
  126. package/dist/modules/manager/helmv3/artifacts.js.map +1 -1
  127. package/dist/modules/manager/maven/extract.js +5 -2
  128. package/dist/modules/manager/maven/extract.js.map +1 -1
  129. package/dist/modules/manager/maven-wrapper/artifacts.js +3 -2
  130. package/dist/modules/manager/maven-wrapper/artifacts.js.map +1 -1
  131. package/dist/modules/manager/mise/artifacts.js +2 -1
  132. package/dist/modules/manager/mise/artifacts.js.map +1 -1
  133. package/dist/modules/manager/mise/extract.js.map +1 -1
  134. package/dist/modules/manager/npm/artifacts.js +3 -1
  135. package/dist/modules/manager/npm/artifacts.js.map +1 -1
  136. package/dist/modules/manager/npm/extract/common/dependency.js +4 -1
  137. package/dist/modules/manager/npm/extract/common/dependency.js.map +1 -1
  138. package/dist/modules/manager/npm/extract/common/package-file.js +2 -1
  139. package/dist/modules/manager/npm/extract/common/package-file.js.map +1 -1
  140. package/dist/modules/manager/npm/extract/index.js.map +1 -1
  141. package/dist/modules/manager/npm/extract/post/locked-versions.js.map +1 -1
  142. package/dist/modules/manager/npm/npmrc.js +2 -1
  143. package/dist/modules/manager/npm/npmrc.js.map +1 -1
  144. package/dist/modules/manager/npm/post-update/index.js +2 -1
  145. package/dist/modules/manager/npm/post-update/index.js.map +1 -1
  146. package/dist/modules/manager/npm/post-update/npm.js +2 -3
  147. package/dist/modules/manager/npm/post-update/npm.js.map +1 -1
  148. package/dist/modules/manager/npm/post-update/yarn.js.map +1 -1
  149. package/dist/modules/manager/npm/schema.js +6 -2
  150. package/dist/modules/manager/npm/schema.js.map +1 -1
  151. package/dist/modules/manager/npm/update/dependency/index.js +3 -2
  152. package/dist/modules/manager/npm/update/dependency/index.js.map +1 -1
  153. package/dist/modules/manager/npm/update/locked-dependency/common/parent-version.js +6 -2
  154. package/dist/modules/manager/npm/update/locked-dependency/common/parent-version.js.map +1 -1
  155. package/dist/modules/manager/npm/update/locked-dependency/package-lock/get-locked.js +2 -1
  156. package/dist/modules/manager/npm/update/locked-dependency/package-lock/get-locked.js.map +1 -1
  157. package/dist/modules/manager/nuget/package-tree.js +2 -1
  158. package/dist/modules/manager/nuget/package-tree.js.map +1 -1
  159. package/dist/modules/manager/paket/update-locked.js +4 -1
  160. package/dist/modules/manager/paket/update-locked.js.map +1 -1
  161. package/dist/modules/manager/pipenv/extract.js +4 -1
  162. package/dist/modules/manager/pipenv/extract.js.map +1 -1
  163. package/dist/modules/platform/azure/azure-helper.js +2 -1
  164. package/dist/modules/platform/azure/azure-helper.js.map +1 -1
  165. package/dist/modules/platform/azure/index.js +7 -3
  166. package/dist/modules/platform/azure/index.js.map +1 -1
  167. package/dist/modules/platform/bitbucket/index.js +13 -6
  168. package/dist/modules/platform/bitbucket/index.js.map +1 -1
  169. package/dist/modules/platform/bitbucket-server/index.js +13 -9
  170. package/dist/modules/platform/bitbucket-server/index.js.map +1 -1
  171. package/dist/modules/platform/codecommit/index.js +2 -2
  172. package/dist/modules/platform/codecommit/index.js.map +1 -1
  173. package/dist/modules/platform/gerrit/client.js +4 -1
  174. package/dist/modules/platform/gerrit/client.js.map +1 -1
  175. package/dist/modules/platform/gerrit/index.js +3 -2
  176. package/dist/modules/platform/gerrit/index.js.map +1 -1
  177. package/dist/modules/platform/gitea/gitea-helper.js +5 -4
  178. package/dist/modules/platform/gitea/gitea-helper.js.map +1 -1
  179. package/dist/modules/platform/gitea/index.js +11 -4
  180. package/dist/modules/platform/gitea/index.js.map +1 -1
  181. package/dist/modules/platform/github/index.js +36 -23
  182. package/dist/modules/platform/github/index.js.map +1 -1
  183. package/dist/modules/platform/gitlab/index.js +16 -9
  184. package/dist/modules/platform/gitlab/index.js.map +1 -1
  185. package/dist/modules/platform/scm-manager/index.js +4 -1
  186. package/dist/modules/platform/scm-manager/index.js.map +1 -1
  187. package/dist/modules/platform/scm-manager/utils.js +2 -1
  188. package/dist/modules/platform/scm-manager/utils.js.map +1 -1
  189. package/dist/modules/versioning/cargo/index.js.map +1 -1
  190. package/dist/modules/versioning/composer/index.js +2 -1
  191. package/dist/modules/versioning/composer/index.js.map +1 -1
  192. package/dist/modules/versioning/conan/common.js +4 -1
  193. package/dist/modules/versioning/conan/common.js.map +1 -1
  194. package/dist/modules/versioning/debian/index.js +2 -1
  195. package/dist/modules/versioning/debian/index.js.map +1 -1
  196. package/dist/modules/versioning/gradle/compare.js +2 -1
  197. package/dist/modules/versioning/gradle/compare.js.map +1 -1
  198. package/dist/modules/versioning/hex/index.js +2 -1
  199. package/dist/modules/versioning/hex/index.js.map +1 -1
  200. package/dist/modules/versioning/julia/index.js.map +1 -1
  201. package/dist/modules/versioning/maven/compare.js +17 -7
  202. package/dist/modules/versioning/maven/compare.js.map +1 -1
  203. package/dist/modules/versioning/npm/index.js +2 -1
  204. package/dist/modules/versioning/npm/index.js.map +1 -1
  205. package/dist/modules/versioning/npm/range.js.map +1 -1
  206. package/dist/modules/versioning/paket/index.js +2 -1
  207. package/dist/modules/versioning/paket/index.js.map +1 -1
  208. package/dist/modules/versioning/paket/range.js +7 -3
  209. package/dist/modules/versioning/paket/range.js.map +1 -1
  210. package/dist/modules/versioning/pep440/index.js +2 -1
  211. package/dist/modules/versioning/pep440/index.js.map +1 -1
  212. package/dist/modules/versioning/poetry/index.js +2 -1
  213. package/dist/modules/versioning/poetry/index.js.map +1 -1
  214. package/dist/modules/versioning/regex/index.js +1 -1
  215. package/dist/modules/versioning/regex/index.js.map +1 -1
  216. package/dist/modules/versioning/rez/index.js +2 -1
  217. package/dist/modules/versioning/rez/index.js.map +1 -1
  218. package/dist/modules/versioning/vcpkg/index.js +2 -1
  219. package/dist/modules/versioning/vcpkg/index.js.map +1 -1
  220. package/dist/util/cache/package/impl/base.js +2 -1
  221. package/dist/util/cache/package/impl/base.js.map +1 -1
  222. package/dist/util/cache/package/with-cache.js +2 -1
  223. package/dist/util/cache/package/with-cache.js.map +1 -1
  224. package/dist/util/check-token.js +7 -4
  225. package/dist/util/check-token.js.map +1 -1
  226. package/dist/util/exec/utils.js +4 -1
  227. package/dist/util/exec/utils.js.map +1 -1
  228. package/dist/util/git/auth.js +5 -1
  229. package/dist/util/git/auth.js.map +1 -1
  230. package/dist/util/git/error.js.map +1 -1
  231. package/dist/util/host-rules.js +5 -3
  232. package/dist/util/host-rules.js.map +1 -1
  233. package/dist/util/http/cache/abstract-http-cache-provider.js +3 -2
  234. package/dist/util/http/cache/abstract-http-cache-provider.js.map +1 -1
  235. package/dist/util/http/cache/package-http-cache-provider.js +2 -1
  236. package/dist/util/http/cache/package-http-cache-provider.js.map +1 -1
  237. package/dist/util/http/github.js +15 -11
  238. package/dist/util/http/github.js.map +1 -1
  239. package/dist/util/http/gitlab.js +5 -4
  240. package/dist/util/http/gitlab.js.map +1 -1
  241. package/dist/util/http/http.js +2 -1
  242. package/dist/util/http/http.js.map +1 -1
  243. package/dist/util/http/jwt.js +2 -1
  244. package/dist/util/http/jwt.js.map +1 -1
  245. package/dist/util/http/retry-after.js +2 -1
  246. package/dist/util/http/retry-after.js.map +1 -1
  247. package/dist/util/http/status.js +95 -0
  248. package/dist/util/http/status.js.map +1 -0
  249. package/dist/util/merge-confidence/index.js +3 -2
  250. package/dist/util/merge-confidence/index.js.map +1 -1
  251. package/dist/util/package-rules/current-version.js +4 -1
  252. package/dist/util/package-rules/current-version.js.map +1 -1
  253. package/dist/util/package-rules/index.js +7 -3
  254. package/dist/util/package-rules/index.js.map +1 -1
  255. package/dist/util/schema-utils/index.js +5 -0
  256. package/dist/util/schema-utils/index.js.map +1 -1
  257. package/dist/workers/global/config/parse/host-rules-from-env.js +2 -1
  258. package/dist/workers/global/config/parse/host-rules-from-env.js.map +1 -1
  259. package/dist/workers/repository/common.js +4 -1
  260. package/dist/workers/repository/common.js.map +1 -1
  261. package/dist/workers/repository/config-migration/branch/index.js +2 -1
  262. package/dist/workers/repository/config-migration/branch/index.js.map +1 -1
  263. package/dist/workers/repository/dependency-dashboard.js +6 -2
  264. package/dist/workers/repository/dependency-dashboard.js.map +1 -1
  265. package/dist/workers/repository/finalize/repository-statistics.js +4 -1
  266. package/dist/workers/repository/finalize/repository-statistics.js.map +1 -1
  267. package/dist/workers/repository/init/merge.js +13 -3
  268. package/dist/workers/repository/init/merge.js.map +1 -1
  269. package/dist/workers/repository/onboarding/branch/check.js +2 -1
  270. package/dist/workers/repository/onboarding/branch/check.js.map +1 -1
  271. package/dist/workers/repository/onboarding/pr/pr-list.js +4 -2
  272. package/dist/workers/repository/onboarding/pr/pr-list.js.map +1 -1
  273. package/dist/workers/repository/process/extract-update.js +4 -1
  274. package/dist/workers/repository/process/extract-update.js.map +1 -1
  275. package/dist/workers/repository/process/lookup/digest.js +2 -1
  276. package/dist/workers/repository/process/lookup/digest.js.map +1 -1
  277. package/dist/workers/repository/process/lookup/generate.js +1 -1
  278. package/dist/workers/repository/process/lookup/generate.js.map +1 -1
  279. package/dist/workers/repository/process/lookup/index.js +4 -1
  280. package/dist/workers/repository/process/lookup/index.js.map +1 -1
  281. package/dist/workers/repository/process/lookup/utils.js +7 -1
  282. package/dist/workers/repository/process/lookup/utils.js.map +1 -1
  283. package/dist/workers/repository/process/vulnerabilities.js +10 -3
  284. package/dist/workers/repository/process/vulnerabilities.js.map +1 -1
  285. package/dist/workers/repository/reconfigure/index.js +2 -1
  286. package/dist/workers/repository/reconfigure/index.js.map +1 -1
  287. package/dist/workers/repository/update/branch/auto-replace.js +6 -2
  288. package/dist/workers/repository/update/branch/auto-replace.js.map +1 -1
  289. package/dist/workers/repository/update/branch/errors.js +2 -1
  290. package/dist/workers/repository/update/branch/errors.js.map +1 -1
  291. package/dist/workers/repository/update/branch/execute-post-upgrade-commands.js +2 -2
  292. package/dist/workers/repository/update/branch/execute-post-upgrade-commands.js.map +1 -1
  293. package/dist/workers/repository/update/branch/get-updated.js +1 -2
  294. package/dist/workers/repository/update/branch/get-updated.js.map +1 -1
  295. package/dist/workers/repository/update/branch/index.js +2 -1
  296. package/dist/workers/repository/update/branch/index.js.map +1 -1
  297. package/dist/workers/repository/update/branch/status-checks.js +2 -1
  298. package/dist/workers/repository/update/branch/status-checks.js.map +1 -1
  299. package/dist/workers/repository/update/pr/body/index.js.map +1 -1
  300. package/dist/workers/repository/update/pr/changelog/release-notes.js +3 -2
  301. package/dist/workers/repository/update/pr/changelog/release-notes.js.map +1 -1
  302. package/dist/workers/repository/update/pr/index.js +7 -3
  303. package/dist/workers/repository/update/pr/index.js.map +1 -1
  304. package/dist/workers/repository/updates/generate.js +6 -3
  305. package/dist/workers/repository/updates/generate.js.map +1 -1
  306. package/package.json +2 -2
  307. package/renovate-schema.json +2 -2
@@ -61,7 +61,8 @@ function minSatisfyingVersion(versions, range) {
61
61
  return api$1.minSatisfyingVersion(versions, rez2npm(range));
62
62
  }
63
63
  function isSingleVersion(constraint) {
64
- return constraint.trim().startsWith("==") && isVersion(constraint.trim().substring(2).trim()) || isVersion(constraint.trim());
64
+ if (constraint.trim().startsWith("==") && isVersion(constraint.trim().substring(2).trim())) return true;
65
+ return isVersion(constraint.trim());
65
66
  }
66
67
  function sortVersions(a, b) {
67
68
  return api$1.sortVersions(padZeroes(a), padZeroes(b));
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["npm","pep440"],"sources":["../../../../lib/modules/versioning/rez/index.ts"],"sourcesContent":["import type { RangeStrategy } from '../../../types/versioning.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { coerceString } from '../../../util/string.ts';\nimport { api as npm } from '../npm/index.ts';\nimport { api as pep440 } from '../pep440/index.ts';\nimport type { NewValueConfig, VersioningApi } from '../types.ts';\n\nimport {\n ascendingRange,\n descendingRange,\n exactVersion,\n inclusiveBound,\n lowerBound,\n matchVersion,\n upperBound,\n versionGroup,\n} from './pattern.ts';\nimport {\n npm2rezplus,\n padZeroes,\n pep4402rezInclusiveBound,\n rez2npm,\n rez2pep440,\n} from './transform.ts';\n\nexport const id = 'rez';\nexport const displayName = 'rez';\nexport const urls = ['[Rez package manager](https://github.com/nerdvegas/rez)'];\nexport const supportsRanges = true;\nexport const supportedRangeStrategies: RangeStrategy[] = [\n 'bump',\n 'widen',\n 'replace',\n];\n\nfunction equals(a: string, b: string): boolean {\n try {\n return npm.equals(padZeroes(a), padZeroes(b));\n } catch /* istanbul ignore next */ {\n return pep440.equals(a, b);\n }\n}\n\nfunction getMajor(version: string): number | null {\n try {\n return npm.getMajor(padZeroes(version));\n } catch /* istanbul ignore next */ {\n return pep440.getMajor(version);\n }\n}\n\nfunction getMinor(version: string): number | null {\n try {\n return npm.getMinor(padZeroes(version));\n } catch /* istanbul ignore next */ {\n return pep440.getMinor(version);\n }\n}\n\nfunction getPatch(version: string): number | null {\n try {\n return npm.getPatch(padZeroes(version));\n } catch /* istanbul ignore next */ {\n return pep440.getPatch(version);\n }\n}\n\nfunction isGreaterThan(a: string, b: string): boolean {\n try {\n return npm.isGreaterThan(padZeroes(a), padZeroes(b));\n } catch /* istanbul ignore next */ {\n return pep440.isGreaterThan(a, b);\n }\n}\n\nfunction isLessThanRange(version: string, range: string): boolean {\n return (\n npm.isVersion(padZeroes(version)) &&\n !!npm.isLessThanRange?.(padZeroes(version), rez2npm(range))\n );\n}\n\nexport function isValid(input: string): boolean {\n return npm.isValid(rez2npm(input));\n}\n\nfunction isStable(version: string): boolean {\n return npm.isStable(padZeroes(version));\n}\n\nfunction isVersion(input: string): boolean {\n return npm.isVersion(padZeroes(rez2npm(input)));\n}\n\nfunction matches(version: string, range: string): boolean {\n return (\n npm.isVersion(padZeroes(version)) &&\n npm.matches(padZeroes(version), rez2npm(range))\n );\n}\n\nfunction getSatisfyingVersion(\n versions: string[],\n range: string,\n): string | null {\n return npm.getSatisfyingVersion(versions, rez2npm(range));\n}\n\nfunction minSatisfyingVersion(\n versions: string[],\n range: string,\n): string | null {\n return npm.minSatisfyingVersion(versions, rez2npm(range));\n}\n\nfunction isSingleVersion(constraint: string): boolean {\n return (\n (constraint.trim().startsWith('==') &&\n isVersion(constraint.trim().substring(2).trim())) ||\n isVersion(constraint.trim())\n );\n}\n\nfunction sortVersions(a: string, b: string): number {\n return npm.sortVersions(padZeroes(a), padZeroes(b));\n}\n\nfunction matchVersionPrecision(\n currentValue: string,\n newVersion: string,\n): string | null {\n if (!matchVersion.test(currentValue) || !isVersion(newVersion)) {\n return null;\n }\n const precision = currentValue.split('.').length;\n return newVersion.split('.').slice(0, precision).join('.');\n}\n\nfunction getNewValue({\n currentValue,\n rangeStrategy,\n currentVersion,\n newVersion,\n}: NewValueConfig): string | null {\n const precisionMatchedVersion = matchVersionPrecision(\n currentValue,\n newVersion,\n );\n if (precisionMatchedVersion) {\n return precisionMatchedVersion;\n }\n const pep440Value = pep440.getNewValue({\n currentValue: rez2pep440(currentValue),\n rangeStrategy,\n currentVersion,\n newVersion,\n });\n if (exactVersion.test(currentValue)) {\n return pep440Value;\n }\n if (pep440Value && inclusiveBound.test(currentValue)) {\n return pep4402rezInclusiveBound(pep440Value);\n }\n if (pep440Value && lowerBound.test(currentValue)) {\n if (currentValue.includes('+')) {\n return npm2rezplus(pep440Value);\n }\n return pep440Value;\n }\n if (pep440Value && upperBound.test(currentValue)) {\n return pep440Value;\n }\n const matchAscRange = ascendingRange.exec(currentValue);\n if (pep440Value && matchAscRange?.groups) {\n // Replace version numbers but keep rez format, otherwise we just end up trying\n // to convert every single case separately.\n const lowerBoundAscCurrent = matchAscRange.groups.range_lower_asc;\n const upperBoundAscCurrent = matchAscRange.groups.range_upper_asc;\n const lowerAscVersionCurrent = matchAscRange.groups.range_lower_asc_version;\n const upperAscVersionCurrent = matchAscRange.groups.range_upper_asc_version;\n const [lowerBoundAscPep440, upperBoundAscPep440] = pep440Value.split(', ');\n const lowerAscVersionNew = coerceString(\n regEx(versionGroup).exec(lowerBoundAscPep440)?.[0],\n );\n const upperAscVersionNew = coerceString(\n regEx(versionGroup).exec(upperBoundAscPep440)?.[0],\n );\n const lowerBoundAscNew = lowerBoundAscCurrent.replace(\n lowerAscVersionCurrent,\n lowerAscVersionNew,\n );\n const upperBoundAscNew = upperBoundAscCurrent.replace(\n upperAscVersionCurrent,\n upperAscVersionNew,\n );\n const separator = currentValue.includes(',') ? ',' : '';\n\n return lowerBoundAscNew + separator + upperBoundAscNew;\n }\n const matchDscRange = descendingRange.exec(currentValue);\n if (pep440Value && matchDscRange?.groups) {\n // Replace version numbers but keep rez format, otherwise we just end up trying\n // to convert every single case separately.\n const upperBoundDescCurrent = matchDscRange.groups.range_upper_desc;\n const lowerBoundDescCurrent = matchDscRange.groups.range_lower_desc;\n const upperDescVersionCurrent =\n matchDscRange.groups.range_upper_desc_version;\n const lowerDescVersionCurrent =\n matchDscRange.groups.range_lower_desc_version;\n const [lowerBoundDescPep440, upperBoundDescPep440] =\n pep440Value.split(', ');\n\n const upperDescVersionNew = coerceString(\n regEx(versionGroup).exec(upperBoundDescPep440)?.[0],\n );\n const lowerDescVersionNew = coerceString(\n regEx(versionGroup).exec(lowerBoundDescPep440)?.[0],\n );\n const upperBoundDescNew = upperBoundDescCurrent.replace(\n upperDescVersionCurrent,\n upperDescVersionNew,\n );\n const lowerBoundDescNew = lowerBoundDescCurrent.replace(\n lowerDescVersionCurrent,\n lowerDescVersionNew,\n );\n // Descending ranges are only supported with a comma.\n const separator = ',';\n\n return upperBoundDescNew + separator + lowerBoundDescNew;\n }\n return null;\n}\n\nfunction isCompatible(version: string): boolean {\n return isVersion(version);\n}\n\nexport const api: VersioningApi = {\n equals,\n getMajor,\n getMinor,\n getPatch,\n getNewValue,\n getSatisfyingVersion,\n isCompatible,\n isGreaterThan,\n isLessThanRange,\n isSingleVersion,\n isStable,\n isValid,\n isVersion,\n matches,\n minSatisfyingVersion,\n sortVersions,\n};\nexport default api;\n"],"mappings":";;;;;;AAmCA,SAAS,OAAO,GAAW,GAAoB;CAC7C,IAAI;EACF,OAAOA,MAAI,OAAO,UAAU,CAAC,GAAG,UAAU,CAAC,CAAC;CAC9C,mCAAmC;EACjC,OAAOC,MAAO,OAAO,GAAG,CAAC;CAC3B;AACF;AAEA,SAAS,SAAS,SAAgC;CAChD,IAAI;EACF,OAAOD,MAAI,SAAS,UAAU,OAAO,CAAC;CACxC,mCAAmC;EACjC,OAAOC,MAAO,SAAS,OAAO;CAChC;AACF;AAEA,SAAS,SAAS,SAAgC;CAChD,IAAI;EACF,OAAOD,MAAI,SAAS,UAAU,OAAO,CAAC;CACxC,mCAAmC;EACjC,OAAOC,MAAO,SAAS,OAAO;CAChC;AACF;AAEA,SAAS,SAAS,SAAgC;CAChD,IAAI;EACF,OAAOD,MAAI,SAAS,UAAU,OAAO,CAAC;CACxC,mCAAmC;EACjC,OAAOC,MAAO,SAAS,OAAO;CAChC;AACF;AAEA,SAAS,cAAc,GAAW,GAAoB;CACpD,IAAI;EACF,OAAOD,MAAI,cAAc,UAAU,CAAC,GAAG,UAAU,CAAC,CAAC;CACrD,mCAA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J,cAAc,OAAO;EACvB,MAAM,0BACJ,cAAc,OAAO;EACvB,MAAM,CAAC,sBAAsB,wBAC3B,YAAY,MAAM,IAAI;EAExB,MAAM,sBAAsB,aAC1B,MAAM,YAAY,CAAC,CAAC,KAAK,oBAAoB,CAAC,GAAG,EACnD;EACA,MAAM,sBAAsB,aAC1B,MAAM,YAAY,CAAC,CAAC,KAAK,oBAAoB,CAAC,GAAG,EACnD;EACA,MAAM,oBAAoB,sBAAsB,QAC9C,yBACA,mBACF;EACA,MAAM,oBAAoB,sBAAsB,QAC9C,yBACA,mBACF;EAIA,OAAO,oBAAoB,MAAY;CACzC;CACA,OAAO;AACT;AAEA,SAAS,aAAa,SAA0B;CAC9C,OAAO,UAAU,OAAO;AAC1B;AAEA,MAAa,MAAqB;CAChC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF"}
1
+ {"version":3,"file":"index.js","names":["npm","pep440"],"sources":["../../../../lib/modules/versioning/rez/index.ts"],"sourcesContent":["import type { RangeStrategy } from '../../../types/versioning.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { coerceString } from '../../../util/string.ts';\nimport { api as npm } from '../npm/index.ts';\nimport { api as pep440 } from '../pep440/index.ts';\nimport type { NewValueConfig, VersioningApi } from '../types.ts';\n\nimport {\n ascendingRange,\n descendingRange,\n exactVersion,\n inclusiveBound,\n lowerBound,\n matchVersion,\n upperBound,\n versionGroup,\n} from './pattern.ts';\nimport {\n npm2rezplus,\n padZeroes,\n pep4402rezInclusiveBound,\n rez2npm,\n rez2pep440,\n} from './transform.ts';\n\nexport const id = 'rez';\nexport const displayName = 'rez';\nexport const urls = ['[Rez package manager](https://github.com/nerdvegas/rez)'];\nexport const supportsRanges = true;\nexport const supportedRangeStrategies: RangeStrategy[] = [\n 'bump',\n 'widen',\n 'replace',\n];\n\nfunction equals(a: string, b: string): boolean {\n try {\n return npm.equals(padZeroes(a), padZeroes(b));\n } catch /* istanbul ignore next */ {\n return pep440.equals(a, b);\n }\n}\n\nfunction getMajor(version: string): number | null {\n try {\n return npm.getMajor(padZeroes(version));\n } catch /* istanbul ignore next */ {\n return pep440.getMajor(version);\n }\n}\n\nfunction getMinor(version: string): number | null {\n try {\n return npm.getMinor(padZeroes(version));\n } catch /* istanbul ignore next */ {\n return pep440.getMinor(version);\n }\n}\n\nfunction getPatch(version: string): number | null {\n try {\n return npm.getPatch(padZeroes(version));\n } catch /* istanbul ignore next */ {\n return pep440.getPatch(version);\n }\n}\n\nfunction isGreaterThan(a: string, b: string): boolean {\n try {\n return npm.isGreaterThan(padZeroes(a), padZeroes(b));\n } catch /* istanbul ignore next */ {\n return pep440.isGreaterThan(a, b);\n }\n}\n\nfunction isLessThanRange(version: string, range: string): boolean {\n return (\n npm.isVersion(padZeroes(version)) &&\n !!npm.isLessThanRange?.(padZeroes(version), rez2npm(range))\n );\n}\n\nexport function isValid(input: string): boolean {\n return npm.isValid(rez2npm(input));\n}\n\nfunction isStable(version: string): boolean {\n return npm.isStable(padZeroes(version));\n}\n\nfunction isVersion(input: string): boolean {\n return npm.isVersion(padZeroes(rez2npm(input)));\n}\n\nfunction matches(version: string, range: string): boolean {\n return (\n npm.isVersion(padZeroes(version)) &&\n npm.matches(padZeroes(version), rez2npm(range))\n );\n}\n\nfunction getSatisfyingVersion(\n versions: string[],\n range: string,\n): string | null {\n return npm.getSatisfyingVersion(versions, rez2npm(range));\n}\n\nfunction minSatisfyingVersion(\n versions: string[],\n range: string,\n): string | null {\n return npm.minSatisfyingVersion(versions, rez2npm(range));\n}\n\nfunction isSingleVersion(constraint: string): boolean {\n if (\n constraint.trim().startsWith('==') &&\n isVersion(constraint.trim().substring(2).trim())\n ) {\n return true;\n }\n return isVersion(constraint.trim());\n}\n\nfunction sortVersions(a: string, b: string): number {\n return npm.sortVersions(padZeroes(a), padZeroes(b));\n}\n\nfunction matchVersionPrecision(\n currentValue: string,\n newVersion: string,\n): string | null {\n if (!matchVersion.test(currentValue) || !isVersion(newVersion)) {\n return null;\n }\n const precision = currentValue.split('.').length;\n return newVersion.split('.').slice(0, precision).join('.');\n}\n\nfunction getNewValue({\n currentValue,\n rangeStrategy,\n currentVersion,\n newVersion,\n}: NewValueConfig): string | null {\n const precisionMatchedVersion = matchVersionPrecision(\n currentValue,\n newVersion,\n );\n if (precisionMatchedVersion) {\n return precisionMatchedVersion;\n }\n const pep440Value = pep440.getNewValue({\n currentValue: rez2pep440(currentValue),\n rangeStrategy,\n currentVersion,\n newVersion,\n });\n if (exactVersion.test(currentValue)) {\n return pep440Value;\n }\n if (pep440Value && inclusiveBound.test(currentValue)) {\n return pep4402rezInclusiveBound(pep440Value);\n }\n if (pep440Value && lowerBound.test(currentValue)) {\n if (currentValue.includes('+')) {\n return npm2rezplus(pep440Value);\n }\n return pep440Value;\n }\n if (pep440Value && upperBound.test(currentValue)) {\n return pep440Value;\n }\n const matchAscRange = ascendingRange.exec(currentValue);\n if (pep440Value && matchAscRange?.groups) {\n // Replace version numbers but keep rez format, otherwise we just end up trying\n // to convert every single case separately.\n const lowerBoundAscCurrent = matchAscRange.groups.range_lower_asc;\n const upperBoundAscCurrent = matchAscRange.groups.range_upper_asc;\n const lowerAscVersionCurrent = matchAscRange.groups.range_lower_asc_version;\n const upperAscVersionCurrent = matchAscRange.groups.range_upper_asc_version;\n const [lowerBoundAscPep440, upperBoundAscPep440] = pep440Value.split(', ');\n const lowerAscVersionNew = coerceString(\n regEx(versionGroup).exec(lowerBoundAscPep440)?.[0],\n );\n const upperAscVersionNew = coerceString(\n regEx(versionGroup).exec(upperBoundAscPep440)?.[0],\n );\n const lowerBoundAscNew = lowerBoundAscCurrent.replace(\n lowerAscVersionCurrent,\n lowerAscVersionNew,\n );\n const upperBoundAscNew = upperBoundAscCurrent.replace(\n upperAscVersionCurrent,\n upperAscVersionNew,\n );\n const separator = currentValue.includes(',') ? ',' : '';\n\n return lowerBoundAscNew + separator + upperBoundAscNew;\n }\n const matchDscRange = descendingRange.exec(currentValue);\n if (pep440Value && matchDscRange?.groups) {\n // Replace version numbers but keep rez format, otherwise we just end up trying\n // to convert every single case separately.\n const upperBoundDescCurrent = matchDscRange.groups.range_upper_desc;\n const lowerBoundDescCurrent = matchDscRange.groups.range_lower_desc;\n const upperDescVersionCurrent =\n matchDscRange.groups.range_upper_desc_version;\n const lowerDescVersionCurrent =\n matchDscRange.groups.range_lower_desc_version;\n const [lowerBoundDescPep440, upperBoundDescPep440] =\n pep440Value.split(', ');\n\n const upperDescVersionNew = coerceString(\n regEx(versionGroup).exec(upperBoundDescPep440)?.[0],\n );\n const lowerDescVersionNew = coerceString(\n regEx(versionGroup).exec(lowerBoundDescPep440)?.[0],\n );\n const upperBoundDescNew = upperBoundDescCurrent.replace(\n upperDescVersionCurrent,\n upperDescVersionNew,\n );\n const lowerBoundDescNew = lowerBoundDescCurrent.replace(\n lowerDescVersionCurrent,\n lowerDescVersionNew,\n );\n // Descending ranges are only supported with a comma.\n const separator = ',';\n\n return upperBoundDescNew + separator + lowerBoundDescNew;\n }\n return null;\n}\n\nfunction isCompatible(version: string): boolean {\n return isVersion(version);\n}\n\nexport const api: VersioningApi = {\n equals,\n getMajor,\n getMinor,\n getPatch,\n getNewValue,\n getSatisfyingVersion,\n isCompatible,\n isGreaterThan,\n isLessThanRange,\n isSingleVersion,\n isStable,\n isValid,\n isVersion,\n matches,\n minSatisfyingVersion,\n sortVersions,\n};\nexport default api;\n"],"mappings":";;;;;;AAmCA,SAAS,OAAO,GAAW,GAAoB;CAC7C,IAAI;EACF,OAAOA,MAAI,OAAO,UAAU,CAAC,GAAG,UAAU,CAAC,CAAC;CAC9C,mCAAmC;EACjC,OAAOC,MAAO,OAAO,GAAG,CAAC;CAC3B;AACF;AAEA,SAAS,SAAS,SAAgC;CAChD,IAAI;EACF,OAAOD,MAAI,SAAS,UAAU,OAAO,CAAC;CACxC,mCAAmC;EACjC,OAAOC,MAAO,SAAS,OAAO;CAChC;AACF;AAEA,SAAS,SAAS,SAAg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,qBAAqB,aACzB,MAAM,YAAY,CAAC,CAAC,KAAK,mBAAmB,CAAC,GAAG,EAClD;EACA,MAAM,mBAAmB,qBAAqB,QAC5C,wBACA,kBACF;EACA,MAAM,mBAAmB,qBAAqB,QAC5C,wBACA,kBACF;EAGA,OAAO,oBAFW,aAAa,SAAS,GAAG,IAAI,MAAM,MAEf;CACxC;CACA,MAAM,gBAAgB,gBAAgB,KAAK,YAAY;CACvD,IAAI,eAAe,eAAe,QAAQ;EAGxC,MAAM,wBAAwB,cAAc,OAAO;EACnD,MAAM,wBAAwB,cAAc,OAAO;EACnD,MAAM,0BACJ,cAAc,OAAO;EACvB,MAAM,0BACJ,cAAc,OAAO;EACvB,MAAM,CAAC,sBAAsB,wBAC3B,YAAY,MAAM,IAAI;EAExB,MAAM,sBAAsB,aAC1B,MAAM,YAAY,CAAC,CAAC,KAAK,oBAAoB,CAAC,GAAG,EACnD;EACA,MAAM,sBAAsB,aAC1B,MAAM,YAAY,CAAC,CAAC,KAAK,oBAAoB,CAAC,GAAG,EACnD;EACA,MAAM,oBAAoB,sBAAsB,QAC9C,yBACA,mBACF;EACA,MAAM,oBAAoB,sBAAsB,QAC9C,yBACA,mBACF;EAIA,OAAO,oBAAoB,MAAY;CACzC;CACA,OAAO;AACT;AAEA,SAAS,aAAa,SAA0B;CAC9C,OAAO,UAAU,OAAO;AAC1B;AAEA,MAAa,MAAqB;CAChC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF"}
@@ -99,7 +99,8 @@ function isValid(input) {
99
99
  function isCompatible(version, current) {
100
100
  const v = parse(version);
101
101
  const c = current ? parse(current) : null;
102
- return !!v && (!c || v.scheme === c.scheme);
102
+ if (!v) return false;
103
+ return !c || v.scheme === c.scheme;
103
104
  }
104
105
  function isStable(version) {
105
106
  const parsed = parse(version);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["semver","loose"],"sources":["../../../../lib/modules/versioning/vcpkg/index.ts"],"sourcesContent":["import { isString } from '@sindresorhus/is';\nimport { DateTime } from 'luxon';\nimport type { SemVer } from 'semver';\nimport { coerce } from 'semver';\nimport { regEx } from '../../../util/regex.ts';\nimport { api as loose } from '../loose/index.ts';\nimport { api as semver } from '../semver/index.ts';\nimport type { NewValueConfig, VersioningApi } from '../types.ts';\n\nexport const id = 'vcpkg';\nexport const displayName = 'vcpkg';\nexport const urls = [\n '[vcpkg - Versioning](https://learn.microsoft.com/vcpkg/users/versioning)',\n];\nexport const supportsRanges = false;\n\ntype Scheme = 'date' | 'numeric' | 'string' | 'invalid';\n\ninterface ParsedVersion {\n base: string;\n portVersion: number;\n scheme: Scheme;\n strictSemver: boolean;\n dateHead?: string;\n dateTail?: number[];\n}\n\nconst portVersionRegex = regEx(/^(?<base>.*)#(?<port>\\d+)$/);\nconst dateRegex = regEx(\n /^(?<head>\\d{4}-\\d{2}-\\d{2})(?<tail>(?:\\.(?:0|[1-9]\\d*))*)$/,\n);\n// vcpkg-tool's dot-version grammar: numbers and numeric prerelease\n// identifiers without leading zeros.\nconst numericRegex = regEx(\n /^(?:0|[1-9]\\d*)(?:\\.(?:0|[1-9]\\d*))*(?:-(?:0|[1-9]\\d*|\\d*[A-Za-z-][0-9A-Za-z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[A-Za-z-][0-9A-Za-z-]*))*)?(?:\\+[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$/,\n);\nconst numericPrereleaseRegex = regEx(/-[0-9A-Za-z.-]+(?:\\+[0-9A-Za-z.-]+)?$/);\nconst numericBuildRegex = regEx(/\\+[0-9A-Za-z.-]+$/);\nconst strictSemverRegex = regEx(\n /^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?$/,\n);\n\nfunction splitPortVersion(input: string): {\n base: string;\n portVersion: number;\n} {\n const match = portVersionRegex.exec(input);\n if (match?.groups) {\n return {\n base: match.groups.base,\n portVersion: Number.parseInt(match.groups.port, 10),\n };\n }\n return { base: input, portVersion: 0 };\n}\n\nfunction isValidDateHead(head: string): boolean {\n return DateTime.fromISO(head, { zone: 'utc' }).isValid;\n}\n\nfunction matchDate(base: string): { head: string; tail: number[] } | null {\n const match = dateRegex.exec(base);\n if (!match?.groups) {\n return null;\n }\n const tail = match.groups.tail\n ? match.groups.tail\n .slice(1)\n .split('.')\n .map((s) => Number.parseInt(s, 10))\n : [];\n return { head: match.groups.head, tail };\n}\n\nfunction detectScheme(base: string): Scheme {\n const dateParts = matchDate(base);\n if (dateParts) {\n // A date-shaped base must parse as a real calendar date, otherwise the\n // whole version is rejected rather than falling back to another scheme.\n return isValidDateHead(dateParts.head) ? 'date' : 'invalid';\n }\n if (numericRegex.test(base)) {\n return 'numeric';\n }\n return 'string';\n}\n\nfunction parse(input: string | undefined | null): ParsedVersion | null {\n if (!isString(input)) {\n return null;\n }\n const trimmed = input.trim();\n if (trimmed === '') {\n return null;\n }\n const { base, portVersion } = splitPortVersion(trimmed);\n // `#` only introduces a port-version, so one left in the base is invalid.\n if (base === '' || base.includes('#')) {\n return null;\n }\n const scheme = detectScheme(base);\n if (scheme === 'invalid') {\n return null;\n }\n const strictSemver =\n scheme === 'numeric' &&\n strictSemverRegex.test(base) &&\n semver.isValid(base);\n if (scheme === 'date') {\n // detectScheme guarantees matchDate succeeds\n const dateParts = matchDate(base)!;\n return {\n base,\n portVersion,\n scheme,\n strictSemver,\n dateHead: dateParts.head,\n dateTail: dateParts.tail,\n };\n }\n return { base, portVersion, scheme, strictSemver };\n}\n\nfunction compareBase(a: ParsedVersion, b: ParsedVersion): number | null {\n if (a.scheme !== b.scheme) {\n return null;\n }\n if (a.scheme === 'date') {\n // `parse` guarantees `dateHead` and `dateTail` are populated for the\n // `date` scheme, so the non-null assertions are safe.\n const aHead = a.dateHead!;\n const bHead = b.dateHead!;\n if (aHead !== bHead) {\n return aHead < bHead ? -1 : 1;\n }\n // Same date head, compare disambiguation tail per the relaxed `version`\n // scheme rule, so a version with the smaller set of sections takes\n // precedence (i.e. sorts earlier).\n const aTail = a.dateTail!;\n const bTail = b.dateTail!;\n const minLen = Math.min(aTail.length, bTail.length);\n for (let i = 0; i < minLen; i += 1) {\n if (aTail[i] !== bTail[i]) {\n return aTail[i] < bTail[i] ? -1 : 1;\n }\n }\n if (aTail.length !== bTail.length) {\n return aTail.length < bTail.length ? -1 : 1;\n }\n return 0;\n }\n if (a.scheme === 'numeric') {\n if (a.strictSemver && b.strictSemver) {\n return semver.sortVersions(a.base, b.base);\n }\n return loose.sortVersions(a.base, b.base);\n }\n // Opaque strings order only against an identical base.\n return a.base === b.base ? 0 : null;\n}\n\nfunction compare(a: ParsedVersion, b: ParsedVersion): number | null {\n const baseResult = compareBase(a, b);\n if (baseResult === null) {\n return null;\n }\n if (baseResult !== 0) {\n return baseResult;\n }\n return a.portVersion - b.portVersion;\n}\n\nfunction isValid(input: string | undefined | null): boolean {\n return parse(input) !== null;\n}\n\n// vcpkg does not compare versions across schemes, so a candidate using a\n// different scheme is not an upgrade of the current one.\nfunction isCompatible(version: string, current?: string): boolean {\n const v = parse(version);\n const c = current ? parse(current) : null;\n return !!v && (!c || v.scheme === c.scheme);\n}\n\nfunction isStable(version: string): boolean {\n const parsed = parse(version);\n if (!parsed) {\n return false;\n }\n if (parsed.scheme === 'numeric') {\n // A pre-release suffix (`-...`) marks the version as unstable.\n // Pure build metadata (`+...`) is ignored, matching SemVer.\n const withoutBuild = parsed.base.replace(numericBuildRegex, '');\n return !numericPrereleaseRegex.test(withoutBuild);\n }\n // Date and opaque-string versions have no prerelease concept, treat as stable.\n return true;\n}\n\n// Returns null when a component exceeds semver's 16-digit limit.\nfunction coerceNumeric(base: string, strictSemver: boolean): SemVer | null {\n if (strictSemver) {\n return coerce(base);\n }\n // Strip any pre-release or build suffix before coercion so loose forms like\n // `1.2-alpha` map to `1.2.0` instead of failing.\n const stripped = base\n .replace(numericBuildRegex, '')\n .replace(numericPrereleaseRegex, '');\n return coerce(stripped);\n}\n\nfunction getMajor(version: string): number | null {\n const parsed = parse(version);\n if (parsed?.scheme !== 'numeric') {\n return null;\n }\n return coerceNumeric(parsed.base, parsed.strictSemver)?.major ?? null;\n}\n\nfunction getMinor(version: string): number | null {\n const parsed = parse(version);\n if (parsed?.scheme !== 'numeric') {\n return null;\n }\n return coerceNumeric(parsed.base, parsed.strictSemver)?.minor ?? null;\n}\n\nfunction getPatch(version: string): number | null {\n const parsed = parse(version);\n if (parsed?.scheme !== 'numeric') {\n return null;\n }\n return coerceNumeric(parsed.base, parsed.strictSemver)?.patch ?? null;\n}\n\nfunction equals(version: string, other: string): boolean {\n const a = parse(version);\n const b = parse(other);\n return !!a && !!b && compare(a, b) === 0;\n}\n\nfunction isGreaterThan(version: string, other: string): boolean {\n const a = parse(version);\n const b = parse(other);\n if (!a || !b) {\n return false;\n }\n const result = compare(a, b);\n return result !== null && result > 0;\n}\n\nfunction sortVersions(version: string, other: string): number {\n const a = parse(version);\n const b = parse(other);\n if (!a || !b) {\n return 0;\n }\n // Lookup sorts only releases that `isGreaterThan` the current version,\n // and those order against each other.\n return compare(a, b) ?? 0;\n}\n\nfunction matches(version: string, range: string): boolean {\n return equals(version, range);\n}\n\nfunction getSatisfyingVersion(\n versions: string[],\n range: string,\n): string | null {\n return versions.find((version) => equals(version, range)) ?? null;\n}\n\nfunction getNewValue({ newVersion }: NewValueConfig): string {\n return newVersion;\n}\n\nexport const api: VersioningApi = {\n equals,\n getMajor,\n getMinor,\n getPatch,\n isCompatible,\n isGreaterThan,\n isSingleVersion: isValid,\n isStable,\n isValid,\n isVersion: isValid,\n matches,\n getSatisfyingVersion,\n minSatisfyingVersion: getSatisfyingVersion,\n getNewValue,\n sortVersions,\n};\n\nexport default api;\n"],"mappings":";;;;;;;AASA,MAAa,KAAK;AAkBlB,MAAM,mBAAmB,MAAM,4BAA4B;AAC3D,MAAM,YAAY,MAChB,4DACF;AAGA,MAAM,eAAe,MACnB,4KACF;AACA,MAAM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O;CACvB,MAAM,IAAI,MAAM,KAAK;CACrB,IAAI,CAAC,KAAK,CAAC,GACT,OAAO;CAET,MAAM,SAAS,QAAQ,GAAG,CAAC;CAC3B,OAAO,WAAW,QAAQ,SAAS;AACrC;AAEA,SAAS,aAAa,SAAiB,OAAuB;CAC5D,MAAM,IAAI,MAAM,OAAO;CACvB,MAAM,IAAI,MAAM,KAAK;CACrB,IAAI,CAAC,KAAK,CAAC,GACT,OAAO;CAIT,OAAO,QAAQ,GAAG,CAAC,KAAK;AAC1B;AAEA,SAAS,QAAQ,SAAiB,OAAwB;CACxD,OAAO,OAAO,SAAS,KAAK;AAC9B;AAEA,SAAS,qBACP,UACA,OACe;CACf,OAAO,SAAS,MAAM,YAAY,OAAO,SAAS,KAAK,CAAC,KAAK;AAC/D;AAEA,SAAS,YAAY,EAAE,cAAsC;CAC3D,OAAO;AACT;AAEA,MAAa,MAAqB;CAChC;CACA;CACA;CACA;CACA;CACA;CACA,iBAAiB;CACjB;CACA;CACA,WAAW;CACX;CACA;CACA,sBAAsB;CACtB;CACA;AACF"}
1
+ {"version":3,"file":"index.js","names":["semver","loose"],"sources":["../../../../lib/modules/versioning/vcpkg/index.ts"],"sourcesContent":["import { isString } from '@sindresorhus/is';\nimport { DateTime } from 'luxon';\nimport type { SemVer } from 'semver';\nimport { coerce } from 'semver';\nimport { regEx } from '../../../util/regex.ts';\nimport { api as loose } from '../loose/index.ts';\nimport { api as semver } from '../semver/index.ts';\nimport type { NewValueConfig, VersioningApi } from '../types.ts';\n\nexport const id = 'vcpkg';\nexport const displayName = 'vcpkg';\nexport const urls = [\n '[vcpkg - Versioning](https://learn.microsoft.com/vcpkg/users/versioning)',\n];\nexport const supportsRanges = false;\n\ntype Scheme = 'date' | 'numeric' | 'string' | 'invalid';\n\ninterface ParsedVersion {\n base: string;\n portVersion: number;\n scheme: Scheme;\n strictSemver: boolean;\n dateHead?: string;\n dateTail?: number[];\n}\n\nconst portVersionRegex = regEx(/^(?<base>.*)#(?<port>\\d+)$/);\nconst dateRegex = regEx(\n /^(?<head>\\d{4}-\\d{2}-\\d{2})(?<tail>(?:\\.(?:0|[1-9]\\d*))*)$/,\n);\n// vcpkg-tool's dot-version grammar: numbers and numeric prerelease\n// identifiers without leading zeros.\nconst numericRegex = regEx(\n /^(?:0|[1-9]\\d*)(?:\\.(?:0|[1-9]\\d*))*(?:-(?:0|[1-9]\\d*|\\d*[A-Za-z-][0-9A-Za-z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[A-Za-z-][0-9A-Za-z-]*))*)?(?:\\+[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$/,\n);\nconst numericPrereleaseRegex = regEx(/-[0-9A-Za-z.-]+(?:\\+[0-9A-Za-z.-]+)?$/);\nconst numericBuildRegex = regEx(/\\+[0-9A-Za-z.-]+$/);\nconst strictSemverRegex = regEx(\n /^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?$/,\n);\n\nfunction splitPortVersion(input: string): {\n base: string;\n portVersion: number;\n} {\n const match = portVersionRegex.exec(input);\n if (match?.groups) {\n return {\n base: match.groups.base,\n portVersion: Number.parseInt(match.groups.port, 10),\n };\n }\n return { base: input, portVersion: 0 };\n}\n\nfunction isValidDateHead(head: string): boolean {\n return DateTime.fromISO(head, { zone: 'utc' }).isValid;\n}\n\nfunction matchDate(base: string): { head: string; tail: number[] } | null {\n const match = dateRegex.exec(base);\n if (!match?.groups) {\n return null;\n }\n const tail = match.groups.tail\n ? match.groups.tail\n .slice(1)\n .split('.')\n .map((s) => Number.parseInt(s, 10))\n : [];\n return { head: match.groups.head, tail };\n}\n\nfunction detectScheme(base: string): Scheme {\n const dateParts = matchDate(base);\n if (dateParts) {\n // A date-shaped base must parse as a real calendar date, otherwise the\n // whole version is rejected rather than falling back to another scheme.\n return isValidDateHead(dateParts.head) ? 'date' : 'invalid';\n }\n if (numericRegex.test(base)) {\n return 'numeric';\n }\n return 'string';\n}\n\nfunction parse(input: string | undefined | null): ParsedVersion | null {\n if (!isString(input)) {\n return null;\n }\n const trimmed = input.trim();\n if (trimmed === '') {\n return null;\n }\n const { base, portVersion } = splitPortVersion(trimmed);\n // `#` only introduces a port-version, so one left in the base is invalid.\n if (base === '' || base.includes('#')) {\n return null;\n }\n const scheme = detectScheme(base);\n if (scheme === 'invalid') {\n return null;\n }\n const strictSemver =\n scheme === 'numeric' &&\n strictSemverRegex.test(base) &&\n semver.isValid(base);\n if (scheme === 'date') {\n // detectScheme guarantees matchDate succeeds\n const dateParts = matchDate(base)!;\n return {\n base,\n portVersion,\n scheme,\n strictSemver,\n dateHead: dateParts.head,\n dateTail: dateParts.tail,\n };\n }\n return { base, portVersion, scheme, strictSemver };\n}\n\nfunction compareBase(a: ParsedVersion, b: ParsedVersion): number | null {\n if (a.scheme !== b.scheme) {\n return null;\n }\n if (a.scheme === 'date') {\n // `parse` guarantees `dateHead` and `dateTail` are populated for the\n // `date` scheme, so the non-null assertions are safe.\n const aHead = a.dateHead!;\n const bHead = b.dateHead!;\n if (aHead !== bHead) {\n return aHead < bHead ? -1 : 1;\n }\n // Same date head, compare disambiguation tail per the relaxed `version`\n // scheme rule, so a version with the smaller set of sections takes\n // precedence (i.e. sorts earlier).\n const aTail = a.dateTail!;\n const bTail = b.dateTail!;\n const minLen = Math.min(aTail.length, bTail.length);\n for (let i = 0; i < minLen; i += 1) {\n if (aTail[i] !== bTail[i]) {\n return aTail[i] < bTail[i] ? -1 : 1;\n }\n }\n if (aTail.length !== bTail.length) {\n return aTail.length < bTail.length ? -1 : 1;\n }\n return 0;\n }\n if (a.scheme === 'numeric') {\n if (a.strictSemver && b.strictSemver) {\n return semver.sortVersions(a.base, b.base);\n }\n return loose.sortVersions(a.base, b.base);\n }\n // Opaque strings order only against an identical base.\n return a.base === b.base ? 0 : null;\n}\n\nfunction compare(a: ParsedVersion, b: ParsedVersion): number | null {\n const baseResult = compareBase(a, b);\n if (baseResult === null) {\n return null;\n }\n if (baseResult !== 0) {\n return baseResult;\n }\n return a.portVersion - b.portVersion;\n}\n\nfunction isValid(input: string | undefined | null): boolean {\n return parse(input) !== null;\n}\n\n// vcpkg does not compare versions across schemes, so a candidate using a\n// different scheme is not an upgrade of the current one.\nfunction isCompatible(version: string, current?: string): boolean {\n const v = parse(version);\n const c = current ? parse(current) : null;\n if (!v) {\n return false;\n }\n return !c || v.scheme === c.scheme;\n}\n\nfunction isStable(version: string): boolean {\n const parsed = parse(version);\n if (!parsed) {\n return false;\n }\n if (parsed.scheme === 'numeric') {\n // A pre-release suffix (`-...`) marks the version as unstable.\n // Pure build metadata (`+...`) is ignored, matching SemVer.\n const withoutBuild = parsed.base.replace(numericBuildRegex, '');\n return !numericPrereleaseRegex.test(withoutBuild);\n }\n // Date and opaque-string versions have no prerelease concept, treat as stable.\n return true;\n}\n\n// Returns null when a component exceeds semver's 16-digit limit.\nfunction coerceNumeric(base: string, strictSemver: boolean): SemVer | null {\n if (strictSemver) {\n return coerce(base);\n }\n // Strip any pre-release or build suffix before coercion so loose forms like\n // `1.2-alpha` map to `1.2.0` instead of failing.\n const stripped = base\n .replace(numericBuildRegex, '')\n .replace(numericPrereleaseRegex, '');\n return coerce(stripped);\n}\n\nfunction getMajor(version: string): number | null {\n const parsed = parse(version);\n if (parsed?.scheme !== 'numeric') {\n return null;\n }\n return coerceNumeric(parsed.base, parsed.strictSemver)?.major ?? null;\n}\n\nfunction getMinor(version: string): number | null {\n const parsed = parse(version);\n if (parsed?.scheme !== 'numeric') {\n return null;\n }\n return coerceNumeric(parsed.base, parsed.strictSemver)?.minor ?? null;\n}\n\nfunction getPatch(version: string): number | null {\n const parsed = parse(version);\n if (parsed?.scheme !== 'numeric') {\n return null;\n }\n return coerceNumeric(parsed.base, parsed.strictSemver)?.patch ?? null;\n}\n\nfunction equals(version: string, other: string): boolean {\n const a = parse(version);\n const b = parse(other);\n return !!a && !!b && compare(a, b) === 0;\n}\n\nfunction isGreaterThan(version: string, other: string): boolean {\n const a = parse(version);\n const b = parse(other);\n if (!a || !b) {\n return false;\n }\n const result = compare(a, b);\n return result !== null && result > 0;\n}\n\nfunction sortVersions(version: string, other: string): number {\n const a = parse(version);\n const b = parse(other);\n if (!a || !b) {\n return 0;\n }\n // Lookup sorts only releases that `isGreaterThan` the current version,\n // and those order against each other.\n return compare(a, b) ?? 0;\n}\n\nfunction matches(version: string, range: string): boolean {\n return equals(version, range);\n}\n\nfunction getSatisfyingVersion(\n versions: string[],\n range: string,\n): string | null {\n return versions.find((version) => equals(version, range)) ?? null;\n}\n\nfunction getNewValue({ newVersion }: NewValueConfig): string {\n return newVersion;\n}\n\nexport const api: VersioningApi = {\n equals,\n getMajor,\n getMinor,\n getPatch,\n isCompatible,\n isGreaterThan,\n isSingleVersion: isValid,\n isStable,\n isValid,\n isVersion: isValid,\n matches,\n getSatisfyingVersion,\n minSatisfyingVersion: getSatisfyingVersion,\n getNewValue,\n sortVersions,\n};\n\nexport default api;\n"],"mappings":";;;;;;;AASA,MAAa,KAAK;AAkBlB,MAAM,mBAAmB,MAAM,4BAA4B;AAC3D,MAAM,YAAY,MAChB,4DACF;AAGA,MAAM,eAAe,MACnB,4KACF;AACA,MAAM,yBAAyB,MAAM,uCAAuC;AAC5E,MAAM,oBAAoB,MAAM,mBAAmB;AACnD,MAAM,oBAAoB,MACxB,0DACF;AAEA,SAAS,iBAAiB,OAGxB;CACA,MAAM,QAAQ,iBAAiB,KAAK,KAAK;CACzC,IAAI,OAAO,QACT,OAAO;EACL,MAAM,MAAM,OAAO;EACnB,aAAa,OAAO,SAAS,MAAM,OAAO,MAAM,EAAE;CACpD;CAEF,OAAO;EAAE,MAAM;EAAO,aAAa;CAAE;AACvC;AAEA,SAAS,gBAAgB,MAAuB;CAC9C,OAAO,SAAS,QAAQ,MAAM,EAAE,MAAM,MAAM,CAAC,CAAC,CAAC;AACjD;AAEA,SAAS,UAAU,MAAuD;CACxE,MAAM,QAAQ,UAAU,KAAK,IAAI;CACjC,IAAI,CAA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K;AAC/D;AAEA,SAAS,YAAY,EAAE,cAAsC;CAC3D,OAAO;AACT;AAEA,MAAa,MAAqB;CAChC;CACA;CACA;CACA;CACA;CACA;CACA,iBAAiB;CACjB;CACA;CACA,WAAW;CACX;CACA;CACA,sBAAsB;CACtB;CACA;AACF"}
@@ -73,7 +73,8 @@ var PackageCacheBase = class {
73
73
  };
74
74
  function isExpiredLegacyEntry(entry) {
75
75
  const { expiry } = entry;
76
- return expiry !== void 0 && (!expiry.isValid || DateTime.local() >= expiry);
76
+ if (expiry === void 0) return false;
77
+ return !expiry.isValid || DateTime.local() >= expiry;
77
78
  }
78
79
  export { PackageCacheBase };
79
80
 
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","names":[],"sources":["../../../../../lib/util/cache/package/impl/base.ts"],"sourcesContent":["import { DateTime } from 'luxon';\nimport { logger } from '../../../../logger/index.ts';\nimport type { MaybePromise } from '../../../../types/index.ts';\nimport { decodeEntry, encodeEntry, isEnvelope } from '../codec.ts';\nimport type { LegacyEntry } from '../legacy.ts';\nimport { decodeLegacyEntry } from '../legacy.ts';\nimport type { PackageCacheNamespace } from '../types.ts';\n\nexport abstract class PackageCacheBase {\n async get<T = unknown>(\n namespace: PackageCacheNamespace,\n key: string,\n ): Promise<T | undefined> {\n let raw: Buffer | undefined;\n try {\n raw = await this.readRaw(namespace, key);\n } catch (err) {\n logger.once.debug({ err }, 'Error while reading package cache value');\n return undefined;\n }\n\n if (!raw) {\n logger.trace({ namespace, key }, 'Cache miss');\n return undefined;\n }\n\n try {\n if (isEnvelope(raw)) {\n const entry = await decodeEntry(raw);\n logger.trace({ namespace, key }, 'Returning cached value');\n return entry.value as T;\n }\n\n // TODO: Delete this legacy cache fallback once pre-envelope entries have\n // expired.\n const entry = await decodeLegacyEntry(raw);\n if (isExpiredLegacyEntry(entry)) {\n await this.removeInvalidEntry(namespace, key);\n return undefined;\n }\n\n await this.upgradeLegacyEntry(namespace, key, entry);\n\n logger.trace({ namespace, key }, 'Returning cached value');\n return entry.value as T;\n } catch (err) {\n logger.once.debug({ err }, 'Error while reading package cache value');\n await this.removeInvalidEntry(namespace, key);\n return undefined;\n }\n }\n\n async set(\n namespace: PackageCacheNamespace,\n key: string,\n value: unknown,\n hardTtlMinutes: number,\n ): Promise<void> {\n logger.trace({ namespace, key, hardTtlMinutes }, 'Saving cached value');\n\n const ttlSeconds = Math.floor(hardTtlMinutes * 60);\n\n try {\n if (ttlSeconds <= 0) {\n await this.rm(namespace, key);\n return;\n }\n\n await this.writeRaw(\n namespace,\n key,\n await encodeEntry(value, DateTime.local()),\n ttlSeconds,\n );\n } catch (err) {\n logger.once.warn({ err }, 'Error while setting package cache value');\n }\n }\n\n abstract destroy(): Promise<void>;\n\n protected abstract readRaw(\n namespace: PackageCacheNamespace,\n key: string,\n ): MaybePromise<Buffer | undefined>;\n\n protected abstract writeRaw(\n namespace: PackageCacheNamespace,\n key: string,\n data: Buffer,\n ttlSeconds: number,\n ): MaybePromise<void>;\n\n protected abstract rm(\n namespace: PackageCacheNamespace,\n key: string,\n ): MaybePromise<void>;\n\n // The file backend's cleanup can't read a legacy entry's in-payload expiry, so\n // it overrides this to rewrite the entry as an envelope on read and avoid\n // purging it. Best-effort: overrides must not throw or change the read result.\n // TODO: Delete with the legacy decoder once pre-envelope entries have expired.\n protected upgradeLegacyEntry(\n _namespace: PackageCacheNamespace,\n _key: string,\n _entry: LegacyEntry,\n ): MaybePromise<void> {\n // Default: no upgrade.\n }\n\n private async removeInvalidEntry(\n namespace: PackageCacheNamespace,\n key: string,\n ): Promise<void> {\n try {\n await this.rm(namespace, key);\n } catch (err) {\n logger.once.debug({ err }, 'Error while removing package cache value');\n }\n }\n}\n\n// TODO: Delete with the legacy JSON-wrapper decoder; envelopes use\n// backend-native TTL.\nfunction isExpiredLegacyEntry(entry: LegacyEntry): boolean {\n const { expiry } = entry;\n return (\n expiry !== undefined && (!expiry.isValid || DateTime.local() >= expiry)\n );\n}\n"],"mappings":";;;;;AAQA,IAAsB,m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ACf,IAAI;GACF,MAAM,KAAK,GAAG,WAAW,GAAG;EAC9B,SAAS,KAAK;GACZ,OAAO,KAAK,MAAM,EAAE,IAAI,GAAG,0CAA0C;EACvE;CACF;AACF;AAIA,SAAS,qBAAqB,OAA6B;CACzD,MAAM,EAAE,WAAW;CACnB,OACE,WAAW,KAAA,MAAc,CAAC,OAAO,WAAW,SAAS,MAAM,KAAK;AAEpE"}
1
+ {"version":3,"file":"base.js","names":[],"sources":["../../../../../lib/util/cache/package/impl/base.ts"],"sourcesContent":["import { DateTime } from 'luxon';\nimport { logger } from '../../../../logger/index.ts';\nimport type { MaybePromise } from '../../../../types/index.ts';\nimport { decodeEntry, encodeEntry, isEnvelope } from '../codec.ts';\nimport type { LegacyEntry } from '../legacy.ts';\nimport { decodeLegacyEntry } from '../legacy.ts';\nimport type { PackageCacheNamespace } from '../types.ts';\n\nexport abstract class PackageCacheBase {\n async get<T = unknown>(\n namespace: PackageCacheNamespace,\n key: string,\n ): Promise<T | undefined> {\n let raw: Buffer | undefined;\n try {\n raw = await this.readRaw(namespace, key);\n } catch (err) {\n logger.once.debug({ err }, 'Error while reading package cache value');\n return undefined;\n }\n\n if (!raw) {\n logger.trace({ namespace, key }, 'Cache miss');\n return undefined;\n }\n\n try {\n if (isEnvelope(raw)) {\n const entry = await decodeEntry(raw);\n logger.trace({ namespace, key }, 'Returning cached value');\n return entry.value as T;\n }\n\n // TODO: Delete this legacy cache fallback once pre-envelope entries have\n // expired.\n const entry = await decodeLegacyEntry(raw);\n if (isExpiredLegacyEntry(entry)) {\n await this.removeInvalidEntry(namespace, key);\n return undefined;\n }\n\n await this.upgradeLegacyEntry(namespace, key, entry);\n\n logger.trace({ namespace, key }, 'Returning cached value');\n return entry.value as T;\n } catch (err) {\n logger.once.debug({ err }, 'Error while reading package cache value');\n await this.removeInvalidEntry(namespace, key);\n return undefined;\n }\n }\n\n async set(\n namespace: PackageCacheNamespace,\n key: string,\n value: unknown,\n hardTtlMinutes: number,\n ): Promise<void> {\n logger.trace({ namespace, key, hardTtlMinutes }, 'Saving cached value');\n\n const ttlSeconds = Math.floor(hardTtlMinutes * 60);\n\n try {\n if (ttlSeconds <= 0) {\n await this.rm(namespace, key);\n return;\n }\n\n await this.writeRaw(\n namespace,\n key,\n await encodeEntry(value, DateTime.local()),\n ttlSeconds,\n );\n } catch (err) {\n logger.once.warn({ err }, 'Error while setting package cache value');\n }\n }\n\n abstract destroy(): Promise<void>;\n\n protected abstract readRaw(\n namespace: PackageCacheNamespace,\n key: string,\n ): MaybePromise<Buffer | undefined>;\n\n protected abstract writeRaw(\n namespace: PackageCacheNamespace,\n key: string,\n data: Buffer,\n ttlSeconds: number,\n ): MaybePromise<void>;\n\n protected abstract rm(\n namespace: PackageCacheNamespace,\n key: string,\n ): MaybePromise<void>;\n\n // The file backend's cleanup can't read a legacy entry's in-payload expiry, so\n // it overrides this to rewrite the entry as an envelope on read and avoid\n // purging it. Best-effort: overrides must not throw or change the read result.\n // TODO: Delete with the legacy decoder once pre-envelope entries have expired.\n protected upgradeLegacyEntry(\n _namespace: PackageCacheNamespace,\n _key: string,\n _entry: LegacyEntry,\n ): MaybePromise<void> {\n // Default: no upgrade.\n }\n\n private async removeInvalidEntry(\n namespace: PackageCacheNamespace,\n key: string,\n ): Promise<void> {\n try {\n await this.rm(namespace, key);\n } catch (err) {\n logger.once.debug({ err }, 'Error while removing package cache value');\n }\n }\n}\n\n// TODO: Delete with the legacy JSON-wrapper decoder; envelopes use\n// backend-native TTL.\nfunction isExpiredLegacyEntry(entry: LegacyEntry): boolean {\n const { expiry } = entry;\n if (expiry === undefined) {\n return false;\n }\n return !expiry.isValid || DateTime.local() >= expiry;\n}\n"],"mappings":";;;;;AAQA,IAAsB,mBAAtB,MAAuC;CACrC,MAAM,IACJ,WACA,KACwB;EACxB,IAAI;EACJ,IAAI;GACF,MAAM,MAAM,KAAK,QAAQ,WAAW,GAAG;EACzC,SAAS,KAAK;GACZ,OAAO,KAAK,MAAM,EAAE,IAAI,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MAAM,EAAE,WAAW;CACnB,IAAI,WAAW,KAAA,GACb,OAAO;CAET,OAAO,CAAC,OAAO,WAAW,SAAS,MAAM,KAAK;AAChD"}
@@ -22,7 +22,8 @@ async function withCache(options, fn) {
22
22
  };
23
23
  const cachePrivatePackages = GlobalConfig.get("cachePrivatePackages");
24
24
  function canUseCache() {
25
- return ctx.cacheable && (ctx.public || cachePrivatePackages);
25
+ if (!ctx.cacheable) return false;
26
+ return ctx.public || cachePrivatePackages;
26
27
  }
27
28
  if (!canUseCache()) return await fn(ctx);
28
29
  // istanbul ignore if -- TODO: add test #40625
@@ -1 +1 @@
1
- {"version":3,"file":"with-cache.js","names":["packageCache.get","packageCache.setWithRawTtl"],"sources":["../../../../lib/util/cache/package/with-cache.ts"],"sourcesContent":["import { isUndefined } from '@sindresorhus/is';\nimport { DateTime } from 'luxon';\nimport { GlobalConfig } from '../../../config/global.ts';\nimport { logger } from '../../../logger/index.ts';\nimport { acquireLock } from '../../mutex.ts';\nimport * as packageCache from './index.ts';\nimport { buildCacheKey } from './key.ts';\nimport { resolveTtlValues } from './ttl.ts';\nimport type { CachedRecord, PackageCacheNamespace } from './types.ts';\n\nexport interface CacheContext {\n /**\n * Whether the result may be shared through the package cache.\n * `cachePrivatePackages` allows storage when this is `false`.\n * @default true\n */\n public: boolean;\n\n /**\n * Whether the result should be stored in the cache.\n * `false` prevents storage even when `cachePrivatePackages` is enabled.\n * @default true\n */\n cacheable: boolean;\n}\n\nexport interface CachedOptions {\n /**\n * The cache namespace.\n */\n namespace: PackageCacheNamespace;\n\n /**\n * The cache key.\n */\n key: string;\n\n /**\n * The TTL (or expiry) of the key in minutes.\n * @default 30\n */\n ttlMinutes?: number;\n\n /**\n * Whether the result may be shared through the package cache.\n * @default true\n */\n public?: boolean;\n\n /**\n * Enable extended hard TTL for graceful degradation.\n * When true and upstream errors occur, stale cached data is returned.\n * @default false\n */\n fallback?: boolean;\n}\n\n/**\n * Caches the result of a function.\n *\n * @param options - Cache options\n * @param fn - The function to cache\n * @returns The cached or fresh result\n */\nexport async function withCache<T>(\n options: CachedOptions,\n fn: (ctx: CacheContext) => T | PromiseLike<T>,\n): Promise<Awaited<T>> {\n const { namespace, key, ttlMinutes = 30, fallback = false } = options;\n\n const ctx: CacheContext = {\n public: options.public ?? true,\n cacheable: true,\n };\n const cachePrivatePackages = GlobalConfig.get('cachePrivatePackages');\n\n function canUseCache(): boolean {\n return ctx.cacheable && (ctx.public || cachePrivatePackages);\n }\n\n if (!canUseCache()) {\n return await fn(ctx);\n }\n\n // istanbul ignore if -- TODO: add test #40625\n if (!namespace || !key) {\n return await fn(ctx);\n }\n\n const cacheKey = buildCacheKey('cache-decorator', key);\n\n // prevent concurrent processing and cache writes\n const releaseLock = await acquireLock(cacheKey, namespace);\n\n try {\n const cachedRecord = await packageCache.get<CachedRecord>(\n namespace,\n cacheKey,\n );\n\n const { softTtlMinutes, hardTtlMinutes: resolvedHardTtl } =\n resolveTtlValues(namespace, ttlMinutes);\n\n // The separation between \"soft\" and \"hard\" TTL allows us to treat\n // data as obsolete according to the \"soft\" TTL while physically storing it\n // according to the \"hard\" TTL.\n //\n // This helps us return obsolete data in case of upstream server errors,\n // which is more useful than throwing exceptions ourselves.\n //\n // The `fallback` option controls whether this extended TTL behavior is used.\n // When false, the \"soft\" just equals the \"hard\" ttl.\n const hardTtlMinutes = fallback ? resolvedHardTtl : softTtlMinutes;\n\n let fallbackValue: unknown;\n if (cachedRecord) {\n const now = DateTime.local();\n const cachedAt = DateTime.fromISO(cachedRecord.cachedAt);\n\n const softDeadline = cachedAt.plus({ minutes: softTtlMinutes });\n if (now < softDeadline) {\n return cachedRecord.value as Awaited<T>;\n }\n\n const hardDeadline = cachedAt.plus({ minutes: hardTtlMinutes });\n if (now < hardDeadline) {\n fallbackValue = cachedRecord.value;\n }\n }\n\n let newValue: Awaited<T>;\n try {\n newValue = await fn(ctx);\n } catch (err) {\n if (!isUndefined(fallbackValue)) {\n logger.debug(\n { err },\n 'Package cache: callback error, returning stale data',\n );\n return fallbackValue as Awaited<T>;\n }\n throw err;\n }\n\n if (!isUndefined(newValue) && canUseCache()) {\n const newRecord: CachedRecord = {\n cachedAt: DateTime.local().toISO(),\n value: newValue,\n };\n await packageCache.setWithRawTtl(\n namespace,\n cacheKey,\n newRecord,\n hardTtlMinutes,\n );\n }\n\n return newValue;\n } finally {\n releaseLock();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgEA,eAAsB,UACpB,SACA,IACqB;CACrB,MAAM,EAAE,WAAW,KAAK,aAAa,IAAI,WAAW,UAAU;CAE9D,MAAM,MAAoB;EACxB,QAAQ,QAAQ,UAAU;EAC1B,WAAW;CACb;CACA,MAAM,uBAAuB,aAAa,IAAI,sBAAsB;CAEpE,SAAS,cAAuB;EAC9B,OAAO,IAAI,cAAc,IAAI,UAAU;CACzC;CAEA,IAAI,CAAC,YAAY,GACf,OAAO,MAAM,GAAG,GAAG;;CAIrB,IAAI,CAAC,aAAa,CAAC,KACjB,OAAO,MAAM,GAAG,GAAG;CAGrB,MAAM,WAAW,cAAc,mBAAmB,GAAG;CAGrD,MAAM,cAAc,MAAM,YAAY,UAAU,SAAS;CAEzD,IAAI;EACF,MAAM,eAAe,MAAMA,IACzB,WACA,QACF;EAEA,MAAM,EAAE,gBAAgB,gBAAgB,oBACtC,iBAAiB,WAAW,UAAU;EAWxC,MAAM,iBAAiB,WAAW,kBAAkB;EAEpD,IAAI;EACJ,IAAI,cAAc;GAChB,MAAM,MAAM,SAAS,MAAM;GAC3B,MAAM,WAAW,SAAS,QAAQ,aAAa,QAAQ;GAGvD,IAAI,MADiB,SAAS,KAAK,EAAE,SAAS,eAAe,CACxC,GACnB,OAAO,aAAa;GAItB,IAAI,MADiB,SAAS,KAAK,EAAE,SAAS,eAAe,CACxC,GACnB,gBAAgB,aAAa;EAEjC;EAEA,IAAI;EACJ,IAAI;GACF,WAAW,MAAM,GAAG,GAAG;EACzB,SAAS,KAAK;GACZ,IAAI,CAAC,YAAY,aAAa,GAAG;IAC/B,OAAO,MACL,EAAE,IAAI,GACN,qDACF;IACA,OAAO;GACT;GACA,MAAM;EACR;EAEA,IAAI,CAAC,YAAY,QAAQ,KAAK,YAAY,GAAG;GAC3C,MAAM,YAA0B;IAC9B,UAAU,SAAS,MAAM,CAAC,CAAC,MAAM;IACjC,OAAO;GACT;GACA,MAAMC,cACJ,WACA,UACA,WACA,cACF;EACF;EAEA,OAAO;CACT,UAAU;EACR,YAAY;CACd;AACF"}
1
+ {"version":3,"file":"with-cache.js","names":["packageCache.get","packageCache.setWithRawTtl"],"sources":["../../../../lib/util/cache/package/with-cache.ts"],"sourcesContent":["import { isUndefined } from '@sindresorhus/is';\nimport { DateTime } from 'luxon';\nimport { GlobalConfig } from '../../../config/global.ts';\nimport { logger } from '../../../logger/index.ts';\nimport { acquireLock } from '../../mutex.ts';\nimport * as packageCache from './index.ts';\nimport { buildCacheKey } from './key.ts';\nimport { resolveTtlValues } from './ttl.ts';\nimport type { CachedRecord, PackageCacheNamespace } from './types.ts';\n\nexport interface CacheContext {\n /**\n * Whether the result may be shared through the package cache.\n * `cachePrivatePackages` allows storage when this is `false`.\n * @default true\n */\n public: boolean;\n\n /**\n * Whether the result should be stored in the cache.\n * `false` prevents storage even when `cachePrivatePackages` is enabled.\n * @default true\n */\n cacheable: boolean;\n}\n\nexport interface CachedOptions {\n /**\n * The cache namespace.\n */\n namespace: PackageCacheNamespace;\n\n /**\n * The cache key.\n */\n key: string;\n\n /**\n * The TTL (or expiry) of the key in minutes.\n * @default 30\n */\n ttlMinutes?: number;\n\n /**\n * Whether the result may be shared through the package cache.\n * @default true\n */\n public?: boolean;\n\n /**\n * Enable extended hard TTL for graceful degradation.\n * When true and upstream errors occur, stale cached data is returned.\n * @default false\n */\n fallback?: boolean;\n}\n\n/**\n * Caches the result of a function.\n *\n * @param options - Cache options\n * @param fn - The function to cache\n * @returns The cached or fresh result\n */\nexport async function withCache<T>(\n options: CachedOptions,\n fn: (ctx: CacheContext) => T | PromiseLike<T>,\n): Promise<Awaited<T>> {\n const { namespace, key, ttlMinutes = 30, fallback = false } = options;\n\n const ctx: CacheContext = {\n public: options.public ?? true,\n cacheable: true,\n };\n const cachePrivatePackages = GlobalConfig.get('cachePrivatePackages');\n\n function canUseCache(): boolean {\n if (!ctx.cacheable) {\n return false;\n }\n return ctx.public || cachePrivatePackages;\n }\n\n if (!canUseCache()) {\n return await fn(ctx);\n }\n\n // istanbul ignore if -- TODO: add test #40625\n if (!namespace || !key) {\n return await fn(ctx);\n }\n\n const cacheKey = buildCacheKey('cache-decorator', key);\n\n // prevent concurrent processing and cache writes\n const releaseLock = await acquireLock(cacheKey, namespace);\n\n try {\n const cachedRecord = await packageCache.get<CachedRecord>(\n namespace,\n cacheKey,\n );\n\n const { softTtlMinutes, hardTtlMinutes: resolvedHardTtl } =\n resolveTtlValues(namespace, ttlMinutes);\n\n // The separation between \"soft\" and \"hard\" TTL allows us to treat\n // data as obsolete according to the \"soft\" TTL while physically storing it\n // according to the \"hard\" TTL.\n //\n // This helps us return obsolete data in case of upstream server errors,\n // which is more useful than throwing exceptions ourselves.\n //\n // The `fallback` option controls whether this extended TTL behavior is used.\n // When false, the \"soft\" just equals the \"hard\" ttl.\n const hardTtlMinutes = fallback ? resolvedHardTtl : softTtlMinutes;\n\n let fallbackValue: unknown;\n if (cachedRecord) {\n const now = DateTime.local();\n const cachedAt = DateTime.fromISO(cachedRecord.cachedAt);\n\n const softDeadline = cachedAt.plus({ minutes: softTtlMinutes });\n if (now < softDeadline) {\n return cachedRecord.value as Awaited<T>;\n }\n\n const hardDeadline = cachedAt.plus({ minutes: hardTtlMinutes });\n if (now < hardDeadline) {\n fallbackValue = cachedRecord.value;\n }\n }\n\n let newValue: Awaited<T>;\n try {\n newValue = await fn(ctx);\n } catch (err) {\n if (!isUndefined(fallbackValue)) {\n logger.debug(\n { err },\n 'Package cache: callback error, returning stale data',\n );\n return fallbackValue as Awaited<T>;\n }\n throw err;\n }\n\n if (!isUndefined(newValue) && canUseCache()) {\n const newRecord: CachedRecord = {\n cachedAt: DateTime.local().toISO(),\n value: newValue,\n };\n await packageCache.setWithRawTtl(\n namespace,\n cacheKey,\n newRecord,\n hardTtlMinutes,\n );\n }\n\n return newValue;\n } finally {\n releaseLock();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgEA,eAAsB,UACpB,SACA,IACqB;CACrB,MAAM,EAAE,WAAW,KAAK,aAAa,IAAI,WAAW,UAAU;CAE9D,MAAM,MAAoB;EACxB,QAAQ,QAAQ,UAAU;EAC1B,WAAW;CACb;CACA,MAAM,uBAAuB,aAAa,IAAI,sBAAsB;CAEpE,SAAS,cAAuB;EAC9B,IAAI,CAAC,IAAI,WACP,OAAO;EAET,OAAO,IAAI,UAAU;CACvB;CAEA,IAAI,CAAC,YAAY,GACf,OAAO,MAAM,GAAG,GAAG;;CAIrB,IAAI,CAAC,aAAa,CAAC,KACjB,OAAO,MAAM,GAAG,GAAG;CAGrB,MAAM,WAAW,cAAc,mBAAmB,GAAG;CAGrD,MAAM,cAAc,MAAM,YAAY,UAAU,SAAS;CAEzD,IAAI;EACF,MAAM,eAAe,MAAMA,IACzB,WACA,QACF;EAEA,MAAM,EAAE,gBAAgB,gBAAgB,oBACtC,iBAAiB,WAAW,UAAU;EAWxC,MAAM,iBAAiB,WAAW,kBAAkB;EAEpD,IAAI;EACJ,IAAI,cAAc;GAChB,MAAM,MAAM,SAAS,MAAM;GAC3B,MAAM,WAAW,SAAS,QAAQ,aAAa,QAAQ;GAGvD,IAAI,MADiB,SAAS,KAAK,EAAE,SAAS,eAAe,CACxC,GACnB,OAAO,aAAa;GAItB,IAAI,MADiB,SAAS,KAAK,EAAE,SAAS,eAAe,CACxC,GACnB,gBAAgB,aAAa;EAEjC;EAEA,IAAI;EACJ,IAAI;GACF,WAAW,MAAM,GAAG,GAAG;EACzB,SAAS,KAAK;GACZ,IAAI,CAAC,YAAY,aAAa,GAAG;IAC/B,OAAO,MACL,EAAE,IAAI,GACN,qDACF;IACA,OAAO;GACT;GACA,MAAM;EACR;EAEA,IAAI,CAAC,YAAY,QAAQ,KAAK,YAAY,GAAG;GAC3C,MAAM,YAA0B;IAC9B,UAAU,SAAS,MAAM,CAAC,CAAC,MAAM;IACjC,OAAO;GACT;GACA,MAAMC,cACJ,WACA,UACA,WACA,cACF;EACF;EAEA,OAAO;CACT,UAAU;EACR,YAAY;CACd;AACF"}
@@ -21,10 +21,13 @@ function checkGithubToken(packageFiles = {}) {
21
21
  }
22
22
  const githubDeps = [];
23
23
  const deps = Object.values(packageFiles).flat().map((file) => file.deps).flat();
24
- for (const dep of deps) if (!dep.skipReason && (dep.datasource === GithubTagsDatasource.id || dep.datasource === GithubReleasesDatasource.id || dep.datasource === GithubReleaseAttachmentsDatasource.id)) {
25
- dep.skipReason = "github-token-required";
26
- // v8 ignore else -- TODO: add test #40625
27
- if (dep.depName) githubDeps.push(dep.depName);
24
+ for (const dep of deps) {
25
+ const isGithubDatasource = dep.datasource === GithubTagsDatasource.id || dep.datasource === GithubReleasesDatasource.id || dep.datasource === GithubReleaseAttachmentsDatasource.id;
26
+ if (!dep.skipReason && isGithubDatasource) {
27
+ dep.skipReason = "github-token-required";
28
+ // v8 ignore else -- TODO: add test #40625
29
+ if (dep.depName) githubDeps.push(dep.depName);
30
+ }
28
31
  }
29
32
  if (githubDeps.length > 0) {
30
33
  // v8 ignore else -- TODO: add test #40625
@@ -1 +1 @@
1
- {"version":3,"file":"check-token.js","names":["hostRules.find","memCache.get"],"sources":["../../lib/util/check-token.ts"],"sourcesContent":["import { GlobalConfig } from '../config/global.ts';\nimport { logger } from '../logger/index.ts';\nimport { GithubReleaseAttachmentsDatasource } from '../modules/datasource/github-release-attachments/index.ts';\nimport { GithubReleasesDatasource } from '../modules/datasource/github-releases/index.ts';\nimport { GithubTagsDatasource } from '../modules/datasource/github-tags/index.ts';\nimport type { PackageFileContent } from '../modules/manager/types.ts';\nimport type { CombinedHostRule } from '../types/index.ts';\nimport * as memCache from '../util/cache/memory/index.ts';\nimport * as hostRules from './host-rules.ts';\n\nexport function checkGithubToken(\n packageFiles: Record<string, PackageFileContent[]> = {},\n): void {\n const { token } = hostRules.find({\n hostType: 'github',\n url: 'https://api.github.com',\n });\n\n if (token) {\n logger.trace('GitHub token is found');\n return;\n }\n\n if (!GlobalConfig.get('githubTokenWarn')) {\n logger.trace('GitHub token warning is disabled');\n return;\n }\n\n const githubDeps: string[] = [];\n const deps = Object.values(packageFiles)\n .flat()\n .map((file) => file.deps)\n .flat();\n for (const dep of deps) {\n if (\n !dep.skipReason &&\n (dep.datasource === GithubTagsDatasource.id ||\n dep.datasource === GithubReleasesDatasource.id ||\n dep.datasource === GithubReleaseAttachmentsDatasource.id)\n ) {\n dep.skipReason = 'github-token-required';\n // v8 ignore else -- TODO: add test #40625\n if (dep.depName) {\n githubDeps.push(dep.depName);\n }\n }\n }\n\n if (githubDeps.length > 0) {\n const warningLogged = memCache.get<boolean | undefined>(\n 'github-token-required-warning-logged',\n );\n // v8 ignore else -- TODO: add test #40625\n if (!warningLogged) {\n const withoutDuplicates = [...new Set(githubDeps)];\n logger.warn(\n { githubDeps: withoutDuplicates },\n `GitHub token is required for some dependencies`,\n );\n memCache.set('github-token-required-warning-logged', true);\n }\n }\n}\n\nexport function isGithubPersonalAccessToken(token: string): boolean {\n return token.startsWith('ghp_');\n}\n\nexport function isGithubServerToServerToken(token: string): boolean {\n return token.startsWith('ghs_');\n}\n\nexport function isGithubFineGrainedPersonalAccessToken(token: string): boolean {\n return token.startsWith('github_pat_');\n}\n\nexport function findGithubToken(\n searchResult: CombinedHostRule,\n): string | undefined {\n return searchResult?.token?.replace('x-access-token:', '');\n}\n\nexport function takePersonalAccessTokenIfPossible(\n githubToken: string | undefined,\n gitTagsGithubToken: string | undefined,\n): string | undefined {\n if (gitTagsGithubToken && isGithubPersonalAccessToken(gitTagsGithubToken)) {\n logger.debug('Using GitHub Personal Access Token (git-tags)');\n return gitTagsGithubToken;\n }\n\n if (githubToken && isGithubPersonalAccessToken(githubToken)) {\n logger.debug('Using GitHub Personal Access Token');\n return githubToken;\n }\n\n if (\n gitTagsGithubToken &&\n isGithubFineGrainedPersonalAccessToken(gitTagsGithubToken)\n ) {\n logger.debug('Using GitHub Fine-grained Personal Access Token (git-tags)');\n return gitTagsGithubToken;\n }\n\n if (githubToken && isGithubFineGrainedPersonalAccessToken(githubToken)) {\n logger.debug('Using GitHub Fine-grained Personal Access Token');\n return githubToken;\n }\n\n if (gitTagsGithubToken) {\n if (isGithubServerToServerToken(gitTagsGithubToken)) {\n logger.debug('Using GitHub Server-to-Server token (git-tags)');\n } else {\n logger.debug('Using unknown GitHub token type (git-tags)');\n }\n return gitTagsGithubToken;\n }\n\n if (githubToken) {\n if (isGithubServerToServerToken(githubToken)) {\n logger.debug('Using GitHub Server-to-Server token');\n } else {\n logger.debug('Using unknown GitHub token type');\n }\n }\n\n return githubToken;\n}\n"],"mappings":";;;;;;;;AAUA,SAAgB,iBACd,eAAqD,CAAC,GAChD;CACN,MAAM,EAAE,UAAUA,KAAe;EAC/B,UAAU;EACV,KAAK;CACP,CAAC;CAED,IAAI,OAAO;EACT,OAAO,MAAM,uBAAuB;EACpC;CACF;CAEA,IAAI,CAAC,aAAa,IAAI,iBAAiB,GAAG;EACxC,OAAO,MAAM,kCAAkC;EAC/C;CACF;CAEA,MAAM,aAAuB,CAAC;CAC9B,MAAM,OAAO,OAAO,OAAO,YAAY,CAAC,CACrC,KAAK,CAAC,CACN,KAAK,SAAS,KAAK,IAAI,CAAC,CACxB,KAAK;CACR,KAAK,MAAM,OAAO,MAChB,IACE,CAAC,IAAI,eACJ,IAAI,eAAe,qBAAqB,MACvC,IAAI,eAAe,yBAAyB,MAC5C,IAAI,eAAe,mCAAmC,KACxD;EACA,IAAI,aAAa;;EAEjB,IAAI,IAAI,SACN,WAAW,KAAK,IAAI,OAAO;CAE/B;CAGF,IAAI,WAAW,SAAS,GAKlB;;MAAA,CAJkBC,IACpB,sCAGe,GAAG;GAClB,MAAM,oBAAoB,CAAC,GAAG,IAAI,IAAI,UAAU,CAAC;GACjD,OAAO,KACL,EAAE,YAAY,kBAAkB,GAChC,gDACF;GACA,IAAa,wCAAwC,IAAI;EAC3D;;AAEJ;AAEA,SAAgB,4BAA4B,OAAwB;CAClE,OAAO,MAAM,WAAW,MAAM;AAChC;AAEA,SAAgB,4BAA4B,OAAwB;CAClE,OAAO,MAAM,WAAW,MAAM;AAChC;AAEA,SAAgB,uCAAuC,OAAwB;CAC7E,OAAO,MAAM,WAAW,aAAa;AACvC;AAEA,SAAgB,gBACd,cACoB;CACpB,OAAO,cAAc,OAAO,QAAQ,mBAAmB,EAAE;AAC3D;AAEA,SAAgB,kCACd,aACA,oBACoB;CACpB,IAAI,sBAAsB,4BAA4B,kBAAkB,GAAG;EACzE,OAAO,MAAM,+CAA+C;EAC5D,OAAO;CACT;CAEA,IAAI,eAAe,4BAA4B,WAAW,GAAG;EAC3D,OAAO,MAAM,oCAAoC;EACjD,OAAO;CACT;CAEA,IACE,sBACA,uCAAuC,kBAAkB,GACzD;EACA,OAAO,MAAM,4DAA4D;EACzE,OAAO;CACT;CAEA,IAAI,eAAe,uCAAuC,WAAW,GAAG;EACtE,OAAO,MAAM,iDAAiD;EAC9D,OAAO;CACT;CAEA,IAAI,oBAAoB;EACtB,IAAI,4BAA4B,kBAAkB,GAChD,OAAO,MAAM,gDAAgD;OAE7D,OAAO,MAAM,4CAA4C;EAE3D,OAAO;CACT;CAEA,IAAI,aAAa;EACf,IAAI,4BAA4B,WAAW,GACzC,OAAO,MAAM,qCAAqC;OAElD,OAAO,MAAM,iCAAiC;CAElD;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"check-token.js","names":["hostRules.find","memCache.get"],"sources":["../../lib/util/check-token.ts"],"sourcesContent":["import { GlobalConfig } from '../config/global.ts';\nimport { logger } from '../logger/index.ts';\nimport { GithubReleaseAttachmentsDatasource } from '../modules/datasource/github-release-attachments/index.ts';\nimport { GithubReleasesDatasource } from '../modules/datasource/github-releases/index.ts';\nimport { GithubTagsDatasource } from '../modules/datasource/github-tags/index.ts';\nimport type { PackageFileContent } from '../modules/manager/types.ts';\nimport type { CombinedHostRule } from '../types/index.ts';\nimport * as memCache from '../util/cache/memory/index.ts';\nimport * as hostRules from './host-rules.ts';\n\nexport function checkGithubToken(\n packageFiles: Record<string, PackageFileContent[]> = {},\n): void {\n const { token } = hostRules.find({\n hostType: 'github',\n url: 'https://api.github.com',\n });\n\n if (token) {\n logger.trace('GitHub token is found');\n return;\n }\n\n if (!GlobalConfig.get('githubTokenWarn')) {\n logger.trace('GitHub token warning is disabled');\n return;\n }\n\n const githubDeps: string[] = [];\n const deps = Object.values(packageFiles)\n .flat()\n .map((file) => file.deps)\n .flat();\n for (const dep of deps) {\n const isGithubDatasource =\n dep.datasource === GithubTagsDatasource.id ||\n dep.datasource === GithubReleasesDatasource.id ||\n dep.datasource === GithubReleaseAttachmentsDatasource.id;\n if (!dep.skipReason && isGithubDatasource) {\n dep.skipReason = 'github-token-required';\n // v8 ignore else -- TODO: add test #40625\n if (dep.depName) {\n githubDeps.push(dep.depName);\n }\n }\n }\n\n if (githubDeps.length > 0) {\n const warningLogged = memCache.get<boolean | undefined>(\n 'github-token-required-warning-logged',\n );\n // v8 ignore else -- TODO: add test #40625\n if (!warningLogged) {\n const withoutDuplicates = [...new Set(githubDeps)];\n logger.warn(\n { githubDeps: withoutDuplicates },\n `GitHub token is required for some dependencies`,\n );\n memCache.set('github-token-required-warning-logged', true);\n }\n }\n}\n\nexport function isGithubPersonalAccessToken(token: string): boolean {\n return token.startsWith('ghp_');\n}\n\nexport function isGithubServerToServerToken(token: string): boolean {\n return token.startsWith('ghs_');\n}\n\nexport function isGithubFineGrainedPersonalAccessToken(token: string): boolean {\n return token.startsWith('github_pat_');\n}\n\nexport function findGithubToken(\n searchResult: CombinedHostRule,\n): string | undefined {\n return searchResult?.token?.replace('x-access-token:', '');\n}\n\nexport function takePersonalAccessTokenIfPossible(\n githubToken: string | undefined,\n gitTagsGithubToken: string | undefined,\n): string | undefined {\n if (gitTagsGithubToken && isGithubPersonalAccessToken(gitTagsGithubToken)) {\n logger.debug('Using GitHub Personal Access Token (git-tags)');\n return gitTagsGithubToken;\n }\n\n if (githubToken && isGithubPersonalAccessToken(githubToken)) {\n logger.debug('Using GitHub Personal Access Token');\n return githubToken;\n }\n\n if (\n gitTagsGithubToken &&\n isGithubFineGrainedPersonalAccessToken(gitTagsGithubToken)\n ) {\n logger.debug('Using GitHub Fine-grained Personal Access Token (git-tags)');\n return gitTagsGithubToken;\n }\n\n if (githubToken && isGithubFineGrainedPersonalAccessToken(githubToken)) {\n logger.debug('Using GitHub Fine-grained Personal Access Token');\n return githubToken;\n }\n\n if (gitTagsGithubToken) {\n if (isGithubServerToServerToken(gitTagsGithubToken)) {\n logger.debug('Using GitHub Server-to-Server token (git-tags)');\n } else {\n logger.debug('Using unknown GitHub token type (git-tags)');\n }\n return gitTagsGithubToken;\n }\n\n if (githubToken) {\n if (isGithubServerToServerToken(githubToken)) {\n logger.debug('Using GitHub Server-to-Server token');\n } else {\n logger.debug('Using unknown GitHub token type');\n }\n }\n\n return githubToken;\n}\n"],"mappings":";;;;;;;;AAUA,SAAgB,iBACd,eAAqD,CAAC,GAChD;CACN,MAAM,EAAE,UAAUA,KAAe;EAC/B,UAAU;EACV,KAAK;CACP,CAAC;CAED,IAAI,OAAO;EACT,OAAO,MAAM,uBAAuB;EACpC;CACF;CAEA,IAAI,CAAC,aAAa,IAAI,iBAAiB,GAAG;EACxC,OAAO,MAAM,kCAAkC;EAC/C;CACF;CAEA,MAAM,aAAuB,CAAC;CAC9B,MAAM,OAAO,OAAO,OAAO,YAAY,CAAC,CACrC,KAAK,CAAC,CACN,KAAK,SAAS,KAAK,IAAI,CAAC,CACxB,KAAK;CACR,KAAK,MAAM,OAAO,MAAM;EACtB,MAAM,qBACJ,IAAI,eAAe,qBAAqB,MACxC,IAAI,eAAe,yBAAyB,MAC5C,IAAI,eAAe,m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+21,16 @@ function getChildEnv({ extraEnv, env: forcedEnv = {} } = {}) {
21
21
  for (const [key, val] of Object.entries(combinedEnv)) if (isString(val)) result[key] = `${val}`;
22
22
  return result;
23
23
  }
24
+ function isValidShell(shell) {
25
+ return isBoolean(shell) || isNonEmptyStringAndNotWhitespace(shell);
26
+ }
24
27
  function isCommandWithOptions(cmd) {
25
28
  if (!(isObject(cmd) && "command" in cmd)) return false;
26
29
  if (!Array.isArray(cmd.command)) return false;
27
30
  if (!cmd.command.length) return false;
28
31
  if (cmd.command.some((v) => !isString(v))) return false;
29
32
  if ("ignoreFailure" in cmd && !isBoolean(cmd.ignoreFailure)) return false;
30
- if ("shell" in cmd && !(isBoolean(cmd.shell) || isNonEmptyStringAndNotWhitespace(cmd.shell))) return false;
33
+ if ("shell" in cmd && !isValidShell(cmd.shell)) return false;
31
34
  return true;
32
35
  }
33
36
  function asRawCommand(cmd) {
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":[],"sources":["../../../lib/util/exec/utils.ts"],"sourcesContent":["import {\n isBoolean,\n isNonEmptyStringAndNotWhitespace,\n isObject,\n isString,\n} from '@sindresorhus/is';\nimport { join } from 'shlex';\nimport { getCustomEnv, getUserEnv } from '../env.ts';\nimport { coerceObject } from '../object.ts';\nimport { getChildProcessEnv } from './env.ts';\nimport type { CommandWithOptions, ExecOptions } from './types.ts';\n\nexport type ResolvedChildEnv = Record<string, string>;\n\nexport function getChildEnv({\n extraEnv,\n env: forcedEnv = {},\n}: Pick<ExecOptions, 'env' | 'extraEnv'> = {}): ResolvedChildEnv {\n const globalConfigEnv = getCustomEnv();\n const userConfiguredEnv = getUserEnv();\n\n const inheritedKeys: string[] = [];\n for (const [key, val] of Object.entries(coerceObject(extraEnv))) {\n if (isString(val)) {\n inheritedKeys.push(key);\n }\n }\n\n const parentEnv = getChildProcessEnv(inheritedKeys);\n const combinedEnv = {\n ...extraEnv,\n ...parentEnv,\n ...globalConfigEnv,\n ...userConfiguredEnv,\n ...forcedEnv,\n };\n\n const result: Record<string, string> = {};\n for (const [key, val] of Object.entries(combinedEnv)) {\n if (isString(val)) {\n result[key] = `${val}`;\n }\n }\n\n return result;\n}\n\nexport function isCommandWithOptions(cmd: unknown): cmd is CommandWithOptions {\n if (!(isObject(cmd) && 'command' in cmd)) {\n return false;\n }\n\n if (!Array.isArray(cmd.command)) {\n return false;\n }\n\n if (!cmd.command.length) {\n return false;\n }\n\n if (cmd.command.some((v) => !isString(v))) {\n return false;\n }\n\n if ('ignoreFailure' in cmd && !isBoolean(cmd.ignoreFailure)) {\n return false;\n }\n\n if (\n 'shell' in cmd &&\n !(isBoolean(cmd.shell) || isNonEmptyStringAndNotWhitespace(cmd.shell))\n ) {\n return false;\n }\n\n return true;\n}\n\nexport function asRawCommand(cmd: string | CommandWithOptions): string {\n if (isCommandWithOptions(cmd)) {\n return join(cmd.command);\n }\n\n return cmd;\n}\n\nexport function asRawCommands(\n cmds: string | (string | CommandWithOptions)[],\n): string[] {\n if (isString(cmds)) {\n return [cmds];\n }\n return cmds.map((cmd) => asRawCommand(cmd));\n}\n"],"mappings":";;;;;;AAcA,SAAgB,YAAY,EAC1B,UACA,KAAK,YAAY,CAAC,MACuB,CAAC,GAAqB;CAC/D,MAAM,kBAAkB,aAAa;CACrC,MAAM,oBAAoB,WAAW;CAErC,MAAM,gBAA0B,CAAC;CACjC,KAAK,MAAM,CAAC,KAAK,QAAQ,OAAO,QAAQ,aAAa,QAAQ,CAAC,GAC5D,IAAI,SAAS,GAAG,GACd,cAAc,KAAK,GAAG;CAI1B,MAAM,YAAY,mBAAmB,aAAa;CAClD,MAAM,cAAc;EAClB,GAAG;EACH,GAAG;EACH,GAAG;EACH,GAAG;EACH,GAAG;CACL;CAEA,MAAM,SAAiC,CAAC;CACxC,KAAK,MAAM,CAAC,KAAK,QAAQ,OAAO,QAAQ,WAAW,GACjD,IAAI,SAAS,GAAG,GACd,OAAO,OAAO,GAAG;CAIrB,OAAO;AACT;AAEA,SAAgB,qBAAqB,KAAyC;CAC5E,IAAI,EAAE,SAAS,GAAG,KAAK,aAAa,MAClC,OAAO;CAGT,IAAI,CAAC,MAAM,QAAQ,IAAI,OAAO,GAC5B,OAAO;CAGT,IAAI,CAAC,IAAI,QAAQ,QACf,OAAO;CAGT,IAAI,IAAI,QAAQ,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC,GACtC,OAAO;CAGT,IAAI,mBAAmB,OAAO,CAAC,UAAU,IAAI,aAAa,GACxD,OAAO;CAGT,IACE,WAAW,OACX,EAAE,UAAU,IAAI,KAAK,KAAK,iCAAiC,IAAI,KAAK,IAEpE,OAAO;CAGT,OAAO;AACT;AAEA,SAAgB,aAAa,KAA0C;CACrE,IAAI,qBAAqB,GAAG,GAC1B,OAAO,KAAK,IAAI,OAAO;CAGzB,OAAO;AACT"}
1
+ {"version":3,"file":"utils.js","names":[],"sources":["../../../lib/util/exec/utils.ts"],"sourcesContent":["import {\n isBoolean,\n isNonEmptyStringAndNotWhitespace,\n isObject,\n isString,\n} from '@sindresorhus/is';\nimport { join } from 'shlex';\nimport { getCustomEnv, getUserEnv } from '../env.ts';\nimport { coerceObject } from '../object.ts';\nimport { getChildProcessEnv } from './env.ts';\nimport type { CommandWithOptions, ExecOptions } from './types.ts';\n\nexport type ResolvedChildEnv = Record<string, string>;\n\nexport function getChildEnv({\n extraEnv,\n env: forcedEnv = {},\n}: Pick<ExecOptions, 'env' | 'extraEnv'> = {}): ResolvedChildEnv {\n const globalConfigEnv = getCustomEnv();\n const userConfiguredEnv = getUserEnv();\n\n const inheritedKeys: string[] = [];\n for (const [key, val] of Object.entries(coerceObject(extraEnv))) {\n if (isString(val)) {\n inheritedKeys.push(key);\n }\n }\n\n const parentEnv = getChildProcessEnv(inheritedKeys);\n const combinedEnv = {\n ...extraEnv,\n ...parentEnv,\n ...globalConfigEnv,\n ...userConfiguredEnv,\n ...forcedEnv,\n };\n\n const result: Record<string, string> = {};\n for (const [key, val] of Object.entries(combinedEnv)) {\n if (isString(val)) {\n result[key] = `${val}`;\n }\n }\n\n return result;\n}\n\nfunction isValidShell(shell: unknown): boolean {\n return isBoolean(shell) || isNonEmptyStringAndNotWhitespace(shell);\n}\n\nexport function isCommandWithOptions(cmd: unknown): cmd is CommandWithOptions {\n if (!(isObject(cmd) && 'command' in cmd)) {\n return false;\n }\n\n if (!Array.isArray(cmd.command)) {\n return false;\n }\n\n if (!cmd.command.length) {\n return false;\n }\n\n if (cmd.command.some((v) => !isString(v))) {\n return false;\n }\n\n if ('ignoreFailure' in cmd && !isBoolean(cmd.ignoreFailure)) {\n return false;\n }\n\n if ('shell' in cmd && !isValidShell(cmd.shell)) {\n return false;\n }\n\n return true;\n}\n\nexport function asRawCommand(cmd: string | CommandWithOptions): string {\n if (isCommandWithOptions(cmd)) {\n return join(cmd.command);\n }\n\n return cmd;\n}\n\nexport function asRawCommands(\n cmds: string | (string | CommandWithOptions)[],\n): string[] {\n if (isString(cmds)) {\n return [cmds];\n }\n return cmds.map((cmd) => asRawCommand(cmd));\n}\n"],"mappings":";;;;;;AAcA,SAAgB,YAAY,EAC1B,UACA,KAAK,YAAY,CAAC,MACuB,CAAC,GAAqB;CAC/D,MAAM,kBAAkB,aAAa;CACrC,MAAM,oBAAoB,WAAW;CAErC,MAAM,gBAA0B,CAAC;CACjC,KAAK,MAAM,CAAC,KAAK,QAAQ,OAAO,QAAQ,aAAa,QAAQ,CAAC,GAC5D,IAAI,SAAS,GAAG,GACd,cAAc,KAAK,GAAG;CAI1B,MAAM,YAAY,mBAAmB,aAAa;CAClD,MAAM,cAAc;EAClB,GAAG;EACH,GAAG;EACH,GAAG;EACH,GAAG;EACH,GAAG;CACL;CAEA,MAAM,SAAiC,CAAC;CACxC,KAAK,MAAM,CAAC,KAAK,QAAQ,OAAO,QAAQ,WAAW,GACjD,IAAI,SAAS,GAAG,GACd,OAAO,OAAO,GAAG;CAIrB,OAAO;AACT;AAEA,SAAS,aAAa,OAAyB;CAC7C,OAAO,UAAU,KAAK,KAAK,iCAAiC,KAAK;AACnE;AAEA,SAAgB,qBAAqB,KAAyC;CAC5E,IAAI,EAAE,SAAS,GAAG,KAAK,aAAa,MAClC,OAAO;CAGT,IAAI,CAAC,MAAM,QAAQ,IAAI,OAAO,GAC5B,OAAO;CAGT,IAAI,CAAC,IAAI,QAAQ,QACf,OAAO;CAGT,IAAI,IAAI,QAAQ,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC,GACtC,OAAO;CAGT,IAAI,mBAAmB,OAAO,CAAC,UAAU,IAAI,aAAa,GACxD,OAAO;CAGT,IAAI,WAAW,OAAO,CAAC,aAAa,IAAI,KAAK,GAC3C,OAAO;CAGT,OAAO;AACT;AAEA,SAAgB,aAAa,KAA0C;CACrE,IAAI,qBAAqB,GAAG,GAC1B,OAAO,KAAK,IAAI,OAAO;CAGzB,OAAO;AACT"}
@@ -77,6 +77,10 @@ function getAuthenticationRules(gitUrl, hostType, token) {
77
77
  });
78
78
  return authenticationRules;
79
79
  }
80
+ function hasCredentials(rule) {
81
+ const basicAuth = rule.username && rule.password;
82
+ return !!(rule.token ?? basicAuth);
83
+ }
80
84
  /**
81
85
  * Appends Git authentication for the repository `url` from the credentials registered from URL credentials for it with `hostType`, a username without a password as a percent-encoded token; configured host rules come through `getAll()` instead.
82
86
  * @returns a new environment without modifying the input
@@ -104,7 +108,7 @@ function getGitEnvironmentVariables(environmentVariables, hostTypes = [], url) {
104
108
  });
105
109
  if (gitHubHostRule?.token) gitEnvironmentVariables = getGitAuthenticatedEnvironmentVariables(gitEnvironmentVariables, "https://github.com/", gitHubHostRule);
106
110
  const gitAllowedHostTypes = /* @__PURE__ */ new Set([...PLATFORM_HOST_TYPES, ...hostTypes]);
107
- const hostRules = getAll().filter((r) => r.matchHost && (r.token ?? (r.username && r.password))).filter((r) => !gitHubHostRule || !githubApiUrls.has(r.matchHost));
111
+ const hostRules = getAll().filter((r) => r.matchHost && hasCredentials(r)).filter((r) => !gitHubHostRule || !githubApiUrls.has(r.matchHost));
108
112
  for (const hostRule of hostRules) if (!hostRule.hostType || gitAllowedHostTypes.has(hostRule.hostType)) gitEnvironmentVariables = addAuthFromHostRule(hostRule, gitEnvironmentVariables);
109
113
  if (url) for (const hostType of hostTypes) gitEnvironmentVariables = getGitUrlEnvironmentVariables(gitEnvironmentVariables, url, hostType);
110
114
  return gitEnvironmentVariables;
@@ -1 +1 @@
1
- {"version":3,"file":"auth.js","names":[],"sources":["../../../lib/util/git/auth.ts"],"sourcesContent":["import { isEmptyString } from '@sindresorhus/is';\nimport { PLATFORM_HOST_TYPES } from '../../constants/platforms.ts';\nimport { logger } from '../../logger/index.ts';\nimport type { HostRule } from '../../types/index.ts';\nimport { detectPlatform } from '../common.ts';\nimport type { ResolvedChildEnv } from '../exec/utils.ts';\nimport { find, findDetachedCredentials, getAll } from '../host-rules.ts';\nimport { regEx } from '../regex.ts';\nimport { createURLFromHostOrURL, isHttpUrl } from '../url.ts';\nimport { addGitConfigEnvironmentVariables } from './config.ts';\nimport type { AuthenticationRule } from './types.ts';\nimport { getTokenCredentials, parseGitUrl } from './url.ts';\n\nconst platformHostTypes = new Set<string>(PLATFORM_HOST_TYPES);\n\nconst githubApiUrls = new Set([\n 'github.com',\n 'api.github.com',\n 'https://api.github.com',\n 'https://api.github.com/',\n]);\n\n/**\n * Append Git authentication configuration to a resolved child environment.\n * @returns a new environment without modifying the input\n */\nexport function getGitAuthenticatedEnvironmentVariables(\n environmentVariables: Readonly<ResolvedChildEnv>,\n originalGitUrl: string,\n { token, username, password, hostType, matchHost }: HostRule,\n): ResolvedChildEnv {\n if (!token && !(username && password)) {\n logger.warn(\n { host: matchHost },\n `Could not create environment variable for host as neither token or username and password was set`,\n );\n return { ...environmentVariables };\n }\n\n let authenticationRules: AuthenticationRule[];\n if (token) {\n authenticationRules = getAuthenticationRulesWithToken(\n originalGitUrl,\n hostType,\n token,\n );\n } else {\n const encodedUsername = encodeURIComponent(username!);\n const encodedPassword = encodeURIComponent(password!);\n\n authenticationRules = getAuthenticationRules(\n originalGitUrl,\n hostType,\n `${encodedUsername}:${encodedPassword}`,\n );\n }\n\n return addGitConfigEnvironmentVariables(\n environmentVariables,\n authenticationRules.map((rule) => ({\n key: `url.${rule.url}.insteadOf`,\n value: rule.insteadOf,\n })),\n );\n}\n\nfunction getAuthenticationRulesWithToken(\n url: string,\n hostType: string | undefined | null,\n authToken: string,\n): AuthenticationRule[] {\n const type = hostType ?? detectPlatform(url);\n const platform =\n hostType && platformHostTypes.has(hostType)\n ? hostType\n : detectPlatform(url);\n return getAuthenticationRules(\n url,\n type,\n getTokenCredentials(platform, authToken),\n );\n}\n\n/**\n * Generates the authentication rules for later git usage for the given host\n * @link https://coolaj86.com/articles/vanilla-devops-git-credentials-cheatsheet/\n * @param gitUrl Git repository URL\n * @param hostType Git host type\n * @param token Authentication token or `username:password` string\n */\nexport function getAuthenticationRules(\n gitUrl: string,\n hostType: string | undefined | null,\n token: string,\n): AuthenticationRule[] {\n const authenticationRules = [];\n const hasUser = token.split(':').length > 1;\n const insteadUrl = parseGitUrl(gitUrl);\n let sshPort = insteadUrl.port;\n\n if (hostType === 'bitbucket-server') {\n // For Bitbucket Server/Data Center, `source` must be `bitbucket-server`\n // to generate HTTP(s) URLs correctly.\n // https://github.com/IonicaBizau/git-url-parse/blob/28828546c148d58bbcff61409915a4e1e8f7eb11/lib/index.js#L304\n insteadUrl.source = 'bitbucket-server';\n\n // sshPort is string, wrong type!\n // https://github.com/DefinitelyTyped/DefinitelyTyped/pull/72361\n // https://github.com/IonicaBizau/parse-path/blob/87f71f273da90f85f6845937a70b7c032eeae4e3/lib/index.js#L45\n // v8 ignore next -- TODO: add test #40625\n if (!sshPort || isEmptyString(sshPort)) {\n // By default, bitbucket-server SSH port is 7999.\n // For non-default port, the generated auth config will likely be incorrect.\n sshPort = '7999';\n }\n }\n\n const url = { ...insteadUrl };\n // git-url-parse would prefix `x-token-auth:` again on bitbucket.org\n if (hasUser && url.source === 'bitbucket.org') {\n url.source = 'bitbucket';\n }\n const protocol = regEx(/^https?$/).test(url.protocol)\n ? url.protocol\n : 'https';\n\n // ssh protocol with user if empty\n url.token = hasUser ? token : `ssh:${token}`;\n authenticationRules.push({\n url: url.toString(protocol),\n // only edge case, need to stringify ourself because the exact syntax is not supported by the library\n // https://github.com/IonicaBizau/git-url-parse/blob/246c9119fb42c2ea1c280028fe77c53eb34c190c/lib/index.js#L246\n insteadOf: `ssh://git@${insteadUrl.resource}${\n sshPort ? `:${sshPort}` : ''\n }/${insteadUrl.full_name}${insteadUrl.git_suffix ? '.git' : ''}`,\n });\n\n // alternative ssh protocol with user if empty\n url.token = hasUser ? token : `git:${token}`;\n authenticationRules.push({\n url: url.toString(protocol),\n insteadOf: { ...insteadUrl, port: sshPort }.toString('ssh'),\n });\n\n // https protocol with no user as default fallback\n url.token = token;\n authenticationRules.push({\n url: url.toString(protocol),\n insteadOf: insteadUrl.toString(protocol),\n });\n\n return authenticationRules;\n}\n\n/**\n * Appends Git authentication for the repository `url` from the credentials registered from URL credentials for it with `hostType`, a username without a password as a percent-encoded token; configured host rules come through `getAll()` instead.\n * @returns a new environment without modifying the input\n */\nfunction getGitUrlEnvironmentVariables(\n environmentVariables: Readonly<ResolvedChildEnv>,\n url: string,\n hostType: string,\n): ResolvedChildEnv {\n const credentials = findDetachedCredentials({ hostType, url });\n if (!credentials?.username) {\n return { ...environmentVariables };\n }\n const auth: HostRule = credentials.password\n ? credentials\n : { token: encodeURIComponent(credentials.username) };\n return getGitAuthenticatedEnvironmentVariables(environmentVariables, url, {\n ...auth,\n hostType,\n });\n}\n\n/**\n * Appends Git authentication from the host rules with a `matchHost` for the platform host types and `hostTypes`, and, when `url` is given, for that single repository from the credentials registered from URL credentials for it with each of `hostTypes`.\n * @returns a new environment without modifying the input\n */\nexport function getGitEnvironmentVariables(\n environmentVariables: Readonly<ResolvedChildEnv>,\n hostTypes: readonly string[] = [],\n url?: string,\n): ResolvedChildEnv {\n let gitEnvironmentVariables: ResolvedChildEnv = { ...environmentVariables };\n\n // hard-coded logic to use authentication for github.com based on the githubToken for api.github.com\n const gitHubHostRule = find({\n hostType: 'github',\n url: 'https://api.github.com/',\n });\n\n if (gitHubHostRule?.token) {\n gitEnvironmentVariables = getGitAuthenticatedEnvironmentVariables(\n gitEnvironmentVariables,\n 'https://github.com/',\n gitHubHostRule,\n );\n }\n\n // Manager-scoped rules are opt-in so unrelated credentials are not exposed to Git.\n const gitAllowedHostTypes = new Set<string>([\n ...PLATFORM_HOST_TYPES,\n ...hostTypes,\n ]);\n\n // filter rules without `matchHost` and `token` or username and password and github api github rules\n const hostRules = getAll()\n .filter((r) => r.matchHost && (r.token ?? (r.username && r.password)))\n .filter((r) => !gitHubHostRule || !githubApiUrls.has(r.matchHost!));\n\n // for each hostRule without hostType we add additional authentication variables to the environmentVariables\n // for each hostRule with hostType we add additional authentication variables to the environmentVariables\n for (const hostRule of hostRules) {\n if (!hostRule.hostType || gitAllowedHostTypes.has(hostRule.hostType)) {\n gitEnvironmentVariables = addAuthFromHostRule(\n hostRule,\n gitEnvironmentVariables,\n );\n }\n }\n\n // `getAll()` leaves out the rules registered from URL credentials, which only apply to the repository they came from\n if (url) {\n for (const hostType of hostTypes) {\n gitEnvironmentVariables = getGitUrlEnvironmentVariables(\n gitEnvironmentVariables,\n url,\n hostType,\n );\n }\n }\n return gitEnvironmentVariables;\n}\n\nfunction addAuthFromHostRule(\n hostRule: HostRule,\n environmentVariables: Readonly<ResolvedChildEnv>,\n): ResolvedChildEnv {\n const httpUrl = createURLFromHostOrURL(hostRule.matchHost!)?.toString();\n if (isHttpUrl(httpUrl)) {\n logger.trace(`Adding Git authentication for ${httpUrl} using token auth.`);\n return getGitAuthenticatedEnvironmentVariables(\n environmentVariables,\n httpUrl!,\n hostRule,\n );\n }\n\n logger.debug(\n `Could not parse registryUrl ${hostRule.matchHost!} or not using http(s). Ignoring`,\n );\n return { ...environmentVariables };\n}\n"],"mappings":";;;;;;;;;;AAaA,MAAM,oBAAoB,IAAI,IAAY,mBAAmB;AAE7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AAI,SAAS,QAAQ,GACjE,0BAA0B,oBACxB,UACA,uBACF;CAKJ,IAAI,KACF,KAAK,MAAM,YAAY,WACrB,0BAA0B,8BACxB,yBACA,KACA,QACF;CAGJ,OAAO;AACT;AAEA,SAAS,oBACP,UACA,sBACkB;CAClB,MAAM,UAAU,uBAAuB,SAAS,SAAU,CAAC,EAAE,SAAS;CACtE,IAAI,UAAU,OAAO,GAAG;EACtB,OAAO,MAAM,iCAAiC,QAAQ,mBAAmB;EACzE,OAAO,wCACL,sBACA,SACA,QACF;CACF;CAEA,OAAO,MACL,+BAA+B,SAAS,UAAW,gCACrD;CACA,OAAO,EAAE,GAAG,qBAAqB;AACnC"}
1
+ {"version":3,"file":"auth.js","names":[],"sources":["../../../lib/util/git/auth.ts"],"sourcesContent":["import { isEmptyString } from '@sindresorhus/is';\nimport { PLATFORM_HOST_TYPES } from '../../constants/platforms.ts';\nimport { logger } from '../../logger/index.ts';\nimport type { HostRule } from '../../types/index.ts';\nimport { detectPlatform } from '../common.ts';\nimport type { ResolvedChildEnv } from '../exec/utils.ts';\nimport { find, findDetachedCredentials, getAll } from '../host-rules.ts';\nimport { regEx } from '../regex.ts';\nimport { createURLFromHostOrURL, isHttpUrl } from '../url.ts';\nimport { addGitConfigEnvironmentVariables } from './config.ts';\nimport type { AuthenticationRule } from './types.ts';\nimport { getTokenCredentials, parseGitUrl } from './url.ts';\n\nconst platformHostTypes = new Set<string>(PLATFORM_HOST_TYPES);\n\nconst githubApiUrls = new Set([\n 'github.com',\n 'api.github.com',\n 'https://api.github.com',\n 'https://api.github.com/',\n]);\n\n/**\n * Append Git authentication configuration to a resolved child environment.\n * @returns a new environment without modifying the input\n */\nexport function getGitAuthenticatedEnvironmentVariables(\n environmentVariables: Readonly<ResolvedChildEnv>,\n originalGitUrl: string,\n { token, username, password, hostType, matchHost }: HostRule,\n): ResolvedChildEnv {\n if (!token && !(username && password)) {\n logger.warn(\n { host: matchHost },\n `Could not create environment variable for host as neither token or username and password was set`,\n );\n return { ...environmentVariables };\n }\n\n let authenticationRules: AuthenticationRule[];\n if (token) {\n authenticationRules = getAuthenticationRulesWithToken(\n originalGitUrl,\n hostType,\n token,\n );\n } else {\n const encodedUsername = encodeURIComponent(username!);\n const encodedPassword = encodeURIComponent(password!);\n\n authenticationRules = getAuthenticationRules(\n originalGitUrl,\n hostType,\n `${encodedUsername}:${encodedPassword}`,\n );\n }\n\n return addGitConfigEnvironmentVariables(\n environmentVariables,\n authenticationRules.map((rule) => ({\n key: `url.${rule.url}.insteadOf`,\n value: rule.insteadOf,\n })),\n );\n}\n\nfunction getAuthenticationRulesWithToken(\n url: string,\n hostType: string | undefined | null,\n authToken: string,\n): AuthenticationRule[] {\n const type = hostType ?? detectPlatform(url);\n const platform =\n hostType && platformHostTypes.has(hostType)\n ? hostType\n : detectPlatform(url);\n return getAuthenticationRules(\n url,\n type,\n getTokenCredentials(platform, authToken),\n );\n}\n\n/**\n * Generates the authentication rules for later git usage for the given host\n * @link https://coolaj86.com/articles/vanilla-devops-git-credentials-cheatsheet/\n * @param gitUrl Git repository URL\n * @param hostType Git host type\n * @param token Authentication token or `username:password` string\n */\nexport function getAuthenticationRules(\n gitUrl: string,\n hostType: string | undefined | null,\n token: string,\n): AuthenticationRule[] {\n const authenticationRules = [];\n const hasUser = token.split(':').length > 1;\n const insteadUrl = parseGitUrl(gitUrl);\n let sshPort = insteadUrl.port;\n\n if (hostType === 'bitbucket-server') {\n // For Bitbucket Server/Data Center, `source` must be `bitbucket-server`\n // to generate HTTP(s) URLs correctly.\n // https://github.com/IonicaBizau/git-url-parse/blob/28828546c148d58bbcff61409915a4e1e8f7eb11/lib/index.js#L304\n insteadUrl.source = 'bitbucket-server';\n\n // sshPort is string, wrong type!\n // https://github.com/DefinitelyTyped/DefinitelyTyped/pull/72361\n // https://github.com/IonicaBizau/parse-path/blob/87f71f273da90f85f6845937a70b7c032eeae4e3/lib/index.js#L45\n // v8 ignore next -- TODO: add test #40625\n if (!sshPort || isEmptyString(sshPort)) {\n // By default, bitbucket-server SSH port is 7999.\n // For non-default port, the generated auth config will likely be incorrect.\n sshPort = '7999';\n }\n }\n\n const url = { ...insteadUrl };\n // git-url-parse would prefix `x-token-auth:` again on bitbucket.org\n if (hasUser && url.source === 'bitbucket.org') {\n url.source = 'bitbucket';\n }\n const protocol = regEx(/^https?$/).test(url.protocol)\n ? url.protocol\n : 'https';\n\n // ssh protocol with user if empty\n url.token = hasUser ? token : `ssh:${token}`;\n authenticationRules.push({\n url: url.toString(protocol),\n // only edge case, need to stringify ourself because the exact syntax is not supported by the library\n // https://github.com/IonicaBizau/git-url-parse/blob/246c9119fb42c2ea1c280028fe77c53eb34c190c/lib/index.js#L246\n insteadOf: `ssh://git@${insteadUrl.resource}${\n sshPort ? `:${sshPort}` : ''\n }/${insteadUrl.full_name}${insteadUrl.git_suffix ? '.git' : ''}`,\n });\n\n // alternative ssh protocol with user if empty\n url.token = hasUser ? token : `git:${token}`;\n authenticationRules.push({\n url: url.toString(protocol),\n insteadOf: { ...insteadUrl, port: sshPort }.toString('ssh'),\n });\n\n // https protocol with no user as default fallback\n url.token = token;\n authenticationRules.push({\n url: url.toString(protocol),\n insteadOf: insteadUrl.toString(protocol),\n });\n\n return authenticationRules;\n}\n\nfunction hasCredentials(rule: HostRule): boolean {\n const basicAuth = rule.username && rule.password;\n return !!(rule.token ?? basicAuth);\n}\n\n/**\n * Appends Git authentication for the repository `url` from the credentials registered from URL credentials for it with `hostType`, a username without a password as a percent-encoded token; configured host rules come through `getAll()` instead.\n * @returns a new environment without modifying the input\n */\nfunction getGitUrlEnvironmentVariables(\n environmentVariables: Readonly<ResolvedChildEnv>,\n url: string,\n hostType: string,\n): ResolvedChildEnv {\n const credentials = findDetachedCredentials({ hostType, url });\n if (!credentials?.username) {\n return { ...environmentVariables };\n }\n const auth: HostRule = credentials.password\n ? credentials\n : { token: encodeURIComponent(credentials.username) };\n return getGitAuthenticatedEnvironmentVariables(environmentVariables, url, {\n ...auth,\n hostType,\n });\n}\n\n/**\n * Appends Git authentication from the host rules with a `matchHost` for the platform host types and `hostTypes`, and, when `url` is given, for that single repository from the credentials registered from URL credentials for it with each of `hostTypes`.\n * @returns a new environment without modifying the input\n */\nexport function getGitEnvironmentVariables(\n environmentVariables: Readonly<ResolvedChildEnv>,\n hostTypes: readonly string[] = [],\n url?: string,\n): ResolvedChildEnv {\n let gitEnvironmentVariables: ResolvedChildEnv = { ...environmentVariables };\n\n // hard-coded logic to use authentication for github.com based on the githubToken for api.github.com\n const gitHubHostRule = find({\n hostType: 'github',\n url: 'https://api.github.com/',\n });\n\n if (gitHubHostRule?.token) {\n gitEnvironmentVariables = getGitAuthenticatedEnvironmentVariables(\n gitEnvironmentVariables,\n 'https://github.com/',\n gitHubHostRule,\n );\n }\n\n // Manager-scoped rules are opt-in so unrelated credentials are not exposed to Git.\n const gitAllowedHostTypes = new Set<string>([\n ...PLATFORM_HOST_TYPES,\n ...hostTypes,\n ]);\n\n // filter rules without `matchHost` and `token` or username and password and github api github rules\n const hostRules = getAll()\n .filter((r) => r.matchHost && hasCredentials(r))\n .filter((r) => !gitHubHostRule || !githubApiUrls.has(r.matchHost!));\n\n // for each hostRule without hostType we add additional authentication variables to the environmentVariables\n // for each hostRule with hostType we add additional authentication variables to the environmentVariables\n for (const hostRule of hostRules) {\n if (!hostRule.hostType || gitAllowedHostTypes.has(hostRule.hostType)) {\n gitEnvironmentVariables = addAuthFromHostRule(\n hostRule,\n gitEnvironmentVariables,\n );\n }\n }\n\n // `getAll()` leaves out the rules registered from URL credentials, which only apply to the repository they came from\n if (url) {\n for (const hostType of hostTypes) {\n gitEnvironmentVariables = getGitUrlEnvironmentVariables(\n gitEnvironmentVariables,\n url,\n hostType,\n );\n }\n }\n return gitEnvironmentVariables;\n}\n\nfunction addAuthFromHostRule(\n hostRule: HostRule,\n environmentVariables: Readonly<ResolvedChildEnv>,\n): ResolvedChildEnv {\n const httpUrl = createURLFromHostOrURL(hostRule.matchHost!)?.toString();\n if (isHttpUrl(httpUrl)) {\n logger.trace(`Adding Git authentication for ${httpUrl} using token auth.`);\n return getGitAuthenticatedEnvironmentVariables(\n environmentVariables,\n httpUrl!,\n hostRule,\n );\n }\n\n logger.debug(\n `Could not parse registryUrl ${hostRule.matchHost!} or not using http(s). Ignoring`,\n );\n return { ...environmentVariables };\n}\n"],"mappings":";;;;;;;;;;AAaA,MAAM,oBAAoB,IAAI,IAAY,mBAAmB;AAE7D,MAAM,gCAAgB,IAAI,IAAI;CAC5B;CACA;CACA;CACA;AACF,CAAC;;;;;AAMD,SAAgB,wCACd,sBACA,gBACA,EAAE,OAAO,UAAU,UAAU,UAAU,aACrB;CAClB,IAAI,CAAC,SAAS,EAAE,YAAY,WAAW;EACrC,OAAO,KACL,EAAE,MAAM,UAAU,GAClB,kGACF;EACA,OAAO,EAAE,GAAG,qBAAqB;CACnC;CAEA,IAAI;CACJ,IAAI,OACF,sBAAsB,gCACpB,gBACA,UACA,KACF;MAKA,sBAAsB,uBACpB,gBACA,UACA,GANsB,mBAAmB,QAMxB,EAAE,GALG,mBAAmB,QAKL,GACtC;CAGF,OAAO,iCACL,sBACA,oBAAoB,KAAK,UAAU;EACjC,KAAK,OAAO,KAAK,IAAI;EACrB,OAAO,KAAK;CACd,EAAE,CACJ;AACF;AAEA,SAAS,gCACP,KACA,UACA,WACsB;CACtB,MAAM,OAAO,YAAY,eAAe,GAAG;CAC3C,MAAM,WACJ,YAAY,kBAAkB,IAAI,QAAQ,IACtC,WACA,eAAe,GAAG;CACxB,OAAO,uBACL,KACA,MACA,oBAAoB,UAAU,SAAS,CACzC;AACF;;;;;;;;AASA,SAAgB,uBACd,QACA,UACA,OACsB;CACtB,MAAM,sBAAsB,CAAC;CAC7B,MAAM,UAAU,MAAM,MAAM,GAAG,CAAC,CAAC,SAAS;CAC1C,MAAM,aAAa,YAAY,MAAM;CACrC,IAAI,UAAU,WAAW;CAEzB,IAAI,aAAa,oBAAoB;EAInC,WAAW,SAAS;;EAMpB,IAAI,CAA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;CACP,CAAC;CAED,IAAI,gBAAgB,OAClB,0BAA0B,wCACxB,yBACA,uBACA,cACF;CAIF,MAAM,sCAAsB,IAAI,IAAY,CAC1C,GAAG,qBACH,GAAG,SACL,CAAC;CAGD,MAAM,YAAY,OAAO,CAAC,CACvB,QAAQ,MAAM,EAAE,aAAa,eAAe,CAAC,CAAC,CAAC,CAC/C,QAAQ,MAAM,CAAC,kBAAkB,CAAC,cAAc,IAAI,EAAE,SAAU,CAAC;CAIpE,KAAK,MAAM,YAAY,WACrB,IAAI,CAAC,SAAS,YAAY,oBAAoB,IAAI,SAAS,QAAQ,GACjE,0BAA0B,oBACxB,UACA,uBACF;CAKJ,IAAI,KACF,KAAK,MAAM,YAAY,WACrB,0BAA0B,8BACxB,yBACA,KACA,QACF;CAGJ,OAAO;AACT;AAEA,SAAS,oBACP,UACA,sBACkB;CAClB,MAAM,UAAU,uBAAuB,SAAS,SAAU,CAAC,EAAE,SAAS;CACtE,IAAI,UAAU,OAAO,GAAG;EACtB,OAAO,MAAM,iCAAiC,QAAQ,mBAAmB;EACzE,OAAO,wCACL,sBACA,SACA,QACF;CACF;CAEA,OAAO,MACL,+BAA+B,SAAS,UAAW,gCACrD;CACA,OAAO,EAAE,GAAG,qBAAqB;AACnC"}
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","names":[],"sources":["../../../lib/util/git/error.ts"],"sourcesContent":["import { CONFIG_VALIDATION } from '../../constants/error-messages.ts';\nimport { logger } from '../../logger/index.ts';\nimport { ExternalHostError } from '../../types/errors/external-host-error.ts';\nimport { getEnv } from '../env.ts';\nimport type { FileChange } from './types.ts';\n\nexport function checkForPlatformFailure(err: Error): Error | null {\n if (getEnv().NODE_ENV === 'test') {\n return null;\n }\n const externalHostFailureStrings = [\n 'remote: Invalid username or password',\n 'gnutls_handshake() failed',\n 'The requested URL returned error: 403',\n 'The requested URL returned error: 5',\n 'The remote end hung up unexpectedly',\n 'access denied or repository not exported',\n 'Could not write new index file',\n 'Failed to connect to',\n 'Connection timed out',\n 'malformed object name',\n 'Could not resolve host',\n 'early EOF',\n 'fatal: bad config', // .gitmodules problem\n 'expected flush after ref listing',\n ];\n for (const errorStr of externalHostFailureStrings) {\n if (err.message.includes(errorStr)) {\n logger.debug({ err }, 'Converting git error to ExternalHostError');\n return new ExternalHostError(err, 'git');\n }\n /* v8 ignore next -- TODO: add test */\n }\n\n /* v8 ignore next -- TODO: add test */\n const configErrorStrings = [\n {\n error: 'GitLab: Branch name does not follow the pattern',\n message:\n \"Cannot push because branch name does not follow project's push rules\",\n },\n {\n error: 'GitLab: Commit message does not follow the pattern',\n message:\n \"Cannot push because commit message does not follow project's push rules\",\n },\n {\n error: ' is not a member of team',\n message:\n 'The `Restrict commits to existing GitLab users` rule is blocking Renovate push. Check the Renovate `gitAuthor` setting',\n },\n {\n error: 'TF401027:',\n message:\n 'You need the Git `GenericContribute` permission to perform this action',\n },\n {\n error: 'matches more than one',\n message:\n \"Renovate cannot push branches if there are tags with names the same as Renovate's branches. Please remove conflicting tag names or change Renovate's branchPrefix to avoid conflicts.\",\n },\n ];\n /* v8 ignore next -- TODO: add test */\n for (const { error, message } of configErrorStrings) {\n if (err.message.includes(error)) {\n logger.debug({ err }, 'Converting git error to CONFIG_VALIDATION error');\n const res = new Error(CONFIG_VALIDATION);\n res.validationError = message;\n res.validationMessage = `\\`${err.message.replaceAll('`', \"'\")}\\``;\n return res;\n }\n }\n\n /* v8 ignore next -- TODO: add test */\n return null;\n}\n\n/* v8 ignore next -- TODO: add tests */\nexport function handleCommitError(\n err: Error,\n branchName: string,\n files?: FileChange[],\n): null {\n checkForPlatformFailure(err);\n if (err.message.includes(`'refs/heads/renovate' exists`)) {\n const error = new Error(CONFIG_VALIDATION);\n error.validationSource = 'None';\n error.validationError = 'An existing branch is blocking Renovate';\n error.validationMessage = `Renovate needs to create the branch \\`${branchName}\\` but is blocked from doing so because of an existing branch called \\`renovate\\`. Please remove it so that Renovate can proceed.`;\n throw error;\n }\n if (\n err.message.includes(\n 'refusing to allow a GitHub App to create or update workflow',\n )\n ) {\n logger.warn(\n 'App has not been granted permissions to update Workflows - aborting branch.',\n );\n return null;\n }\n if (err.message.includes('GH013')) {\n logger.debug({ err }, 'GitHub repository ruleset blocked push');\n const error = new Error(CONFIG_VALIDATION);\n error.validationSource = branchName;\n error.validationError = 'GitHub repository ruleset violation';\n error.validationMessage =\n `Renovate cannot push to \\`${branchName}\\` because a GitHub ` +\n `repository ruleset rejected the push (GH013). Update the ` +\n `ruleset - or grant Renovate a bypass actor - so Renovate can ` +\n `proceed. Original error: \\`${err.message.replaceAll('`', \"'\")}\\``;\n throw error;\n }\n if (\n (err.message.includes('remote rejected') || err.message.includes('403')) &&\n files?.some((file) => file.path?.startsWith('.github/workflows/'))\n ) {\n logger.debug({ err }, 'commitFiles error');\n logger.info('Workflows update rejection - aborting branch.');\n return null;\n }\n if (err.message.includes('protected branch hook declined')) {\n const error = new Error(CONFIG_VALIDATION);\n error.validationSource = branchName;\n error.validationError = 'Renovate branch is protected';\n error.validationMessage = `Renovate cannot push to its branch because branch protection has been enabled.`;\n throw error;\n }\n if (err.message.includes('can only push your own commits')) {\n const error = new Error(CONFIG_VALIDATION);\n error.validationSource = branchName;\n error.validationError = 'Bitbucket committer error';\n error.validationMessage = `Renovate has experienced the following error when attempting to push its branch to the server: \\`${err.message.replaceAll(\n '`',\n \"'\",\n )}\\``;\n throw error;\n }\n if (err.message.includes('remote: error: cannot lock ref')) {\n logger.error({ err }, 'Error committing files.');\n return null;\n }\n if (\n err.message.includes('denying non-fast-forward') ||\n err.message.includes('GH003: Sorry, force-pushing')\n ) {\n logger.debug({ err }, 'Permission denied to update branch');\n const error = new Error(CONFIG_VALIDATION);\n error.validationSource = branchName;\n error.validationError = 'Force push denied';\n error.validationMessage = `Renovate is unable to update branch(es) due to force pushes being disallowed.`;\n throw error;\n }\n logger.debug({ err }, 'Unknown error committing files');\n // We don't know why this happened, so this will cause bubble up to a branch error\n throw err;\n}\n\nexport function bulkChangesDisallowed(err: Error): boolean {\n return err.message.includes('update more than');\n}\n"],"mappings":";;;;;AAMA,SAAgB,wBAAwB,KAA0B;CAChE,IAAI,OAAO,CAAC,CAAC,aAAa,QACxB,OAAO;CAkBT,KAAK,MAAM,YAAY;EAfrB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CAE8C,GAC9C,IAAI,IAAI,QAAQ,SAAS,QAAQ,GAAG;EAClC,OAAO,MAAM,EAAE,IAAI,GAAG,2CAA2C;EACjE,OAAO,IAAI,kBAAkB,KAAK,KAAK;CACzC;;CAiCF,KAAK,MAAM,EAAE,OAAO,aAAa;EA3B/B;GACE,OAAO;GACP,SACE;EACJ;EACA;GACE,OAAO;GACP,SACE;EACJ;EACA;GACE,OAAO;GACP,SACE;EACJ;EACA;GACE,OAAO;GACP,SACE;EACJ;EACA;GACE,OAAO;GACP,SACE;EACJ;CAGgD,GAChD,IAAI,IAAI,QAAQ,SAAS,KAAK,GAAG;EAC/B,OAAO,MAAM,EAAE,IAAI,GAAG,iDAAiD;EACvE,MAAM,MAAM,IAAI,MAAM,iBAAiB;EACvC,IAAI,kBAAkB;EACtB,IAAI,oBAAoB,KAAK,IAAI,QAAQ,WAAW,KAAK,GAAG,EAAE;EAC9D,OAAO;CACT;;CAIF,OAAO;AACT;;AAGA,SAAgB,kBACd,KACA,YACA,OACM;CACN,wBAAwB,GAAG;CAC3B,IAAI,IAAI,QAAQ,SAAS,8BAA8B,GAAG;EACxD,MAAM,QAAQ,IAAI,MAAM,iBAAiB;EACzC,MAAM,mBAAmB;EACzB,MAAM,kBAAkB;EACxB,MAAM,oBAAoB,yCAAyC,WAAW;EAC9E,MAAM;CACR;CACA,IACE,IAAI,QAAQ,SACV,6DACF,GACA;EACA,OAAO,KACL,6EACF;EACA,OAAO;CACT;CACA,IAAI,IAAI,QAAQ,SAAS,OAAO,GAAG;EACjC,OAAO,MAAM,EAAE,IAAI,GAAG,wCAAwC;EAC9D,MAAM,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;AAChD"}
1
+ {"version":3,"file":"error.js","names":[],"sources":["../../../lib/util/git/error.ts"],"sourcesContent":["import { CONFIG_VALIDATION } from '../../constants/error-messages.ts';\nimport { logger } from '../../logger/index.ts';\nimport { ExternalHostError } from '../../types/errors/external-host-error.ts';\nimport { getEnv } from '../env.ts';\nimport type { FileChange } from './types.ts';\n\nexport function checkForPlatformFailure(err: Error): Error | null {\n if (getEnv().NODE_ENV === 'test') {\n return null;\n }\n const externalHostFailureStrings = [\n 'remote: Invalid username or password',\n 'gnutls_handshake() failed',\n 'The requested URL returned error: 403',\n 'The requested URL returned error: 5',\n 'The remote end hung up unexpectedly',\n 'access denied or repository not exported',\n 'Could not write new index file',\n 'Failed to connect to',\n 'Connection timed out',\n 'malformed object name',\n 'Could not resolve host',\n 'early EOF',\n 'fatal: bad config', // .gitmodules problem\n 'expected flush after ref listing',\n ];\n for (const errorStr of externalHostFailureStrings) {\n if (err.message.includes(errorStr)) {\n logger.debug({ err }, 'Converting git error to ExternalHostError');\n return new ExternalHostError(err, 'git');\n }\n /* v8 ignore next -- TODO: add test */\n }\n\n /* v8 ignore next -- TODO: add test */\n const configErrorStrings = [\n {\n error: 'GitLab: Branch name does not follow the pattern',\n message:\n \"Cannot push because branch name does not follow project's push rules\",\n },\n {\n error: 'GitLab: Commit message does not follow the pattern',\n message:\n \"Cannot push because commit message does not follow project's push rules\",\n },\n {\n error: ' is not a member of team',\n message:\n 'The `Restrict commits to existing GitLab users` rule is blocking Renovate push. Check the Renovate `gitAuthor` setting',\n },\n {\n error: 'TF401027:',\n message:\n 'You need the Git `GenericContribute` permission to perform this action',\n },\n {\n error: 'matches more than one',\n message:\n \"Renovate cannot push branches if there are tags with names the same as Renovate's branches. Please remove conflicting tag names or change Renovate's branchPrefix to avoid conflicts.\",\n },\n ];\n /* v8 ignore next -- TODO: add test */\n for (const { error, message } of configErrorStrings) {\n if (err.message.includes(error)) {\n logger.debug({ err }, 'Converting git error to CONFIG_VALIDATION error');\n const res = new Error(CONFIG_VALIDATION);\n res.validationError = message;\n res.validationMessage = `\\`${err.message.replaceAll('`', \"'\")}\\``;\n return res;\n }\n }\n\n /* v8 ignore next -- TODO: add test */\n return null;\n}\n\n/* v8 ignore next -- TODO: add tests */\nexport function handleCommitError(\n err: Error,\n branchName: string,\n files?: FileChange[],\n): null {\n checkForPlatformFailure(err);\n if (err.message.includes(`'refs/heads/renovate' exists`)) {\n const error = new Error(CONFIG_VALIDATION);\n error.validationSource = 'None';\n error.validationError = 'An existing branch is blocking Renovate';\n error.validationMessage = `Renovate needs to create the branch \\`${branchName}\\` but is blocked from doing so because of an existing branch called \\`renovate\\`. Please remove it so that Renovate can proceed.`;\n throw error;\n }\n if (\n err.message.includes(\n 'refusing to allow a GitHub App to create or update workflow',\n )\n ) {\n logger.warn(\n 'App has not been granted permissions to update Workflows - aborting branch.',\n );\n return null;\n }\n if (err.message.includes('GH013')) {\n logger.debug({ err }, 'GitHub repository ruleset blocked push');\n const error = new Error(CONFIG_VALIDATION);\n error.validationSource = branchName;\n error.validationError = 'GitHub repository ruleset violation';\n error.validationMessage =\n `Renovate cannot push to \\`${branchName}\\` because a GitHub ` +\n `repository ruleset rejected the push (GH013). Update the ` +\n `ruleset - or grant Renovate a bypass actor - so Renovate can ` +\n `proceed. Original error: \\`${err.message.replaceAll('`', \"'\")}\\``;\n throw error;\n }\n const isRejected =\n err.message.includes('remote rejected') || err.message.includes('403');\n if (\n isRejected &&\n files?.some((file) => file.path?.startsWith('.github/workflows/'))\n ) {\n logger.debug({ err }, 'commitFiles error');\n logger.info('Workflows update rejection - aborting branch.');\n return null;\n }\n if (err.message.includes('protected branch hook declined')) {\n const error = new Error(CONFIG_VALIDATION);\n error.validationSource = branchName;\n error.validationError = 'Renovate branch is protected';\n error.validationMessage = `Renovate cannot push to its branch because branch protection has been enabled.`;\n throw error;\n }\n if (err.message.includes('can only push your own commits')) {\n const error = new Error(CONFIG_VALIDATION);\n error.validationSource = branchName;\n error.validationError = 'Bitbucket committer error';\n error.validationMessage = `Renovate has experienced the following error when attempting to push its branch to the server: \\`${err.message.replaceAll(\n '`',\n \"'\",\n )}\\``;\n throw error;\n }\n if (err.message.includes('remote: error: cannot lock ref')) {\n logger.error({ err }, 'Error committing files.');\n return null;\n }\n if (\n err.message.includes('denying non-fast-forward') ||\n err.message.includes('GH003: Sorry, force-pushing')\n ) {\n logger.debug({ err }, 'Permission denied to update branch');\n const error = new Error(CONFIG_VALIDATION);\n error.validationSource = branchName;\n error.validationError = 'Force push denied';\n error.validationMessage = `Renovate is unable to update branch(es) due to force pushes being disallowed.`;\n throw error;\n }\n logger.debug({ err }, 'Unknown error committing files');\n // We don't know why this happened, so this will cause bubble up to a branch error\n throw err;\n}\n\nexport function bulkChangesDisallowed(err: Error): boolean {\n return err.message.includes('update more than');\n}\n"],"mappings":";;;;;AAMA,SAAgB,wBAAwB,KAA0B;CAChE,IAAI,OAAO,CAAC,CAAC,aAAa,QACxB,OAAO;CAkBT,KAAK,MAAM,YAAY;EAfrB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CAE8C,GAC9C,IAAI,IAAI,QAAQ,SAAS,QAAQ,GAAG;EAClC,OAAO,MAAM,EAAE,IAAI,GAAG,2CAA2C;EACjE,OAAO,IAAI,kBAAkB,KAAK,KAAK;CACzC;;CAiCF,KAAK,MAAM,EAAE,OAAO,aAAa;EA3B/B;GACE,OAAO;GACP,SACE;EACJ;EACA;GACE,OAAO;GACP,SACE;EACJ;EACA;GACE,OAAO;GACP,SACE;EACJ;EACA;GACE,OAAO;GACP,SACE;EACJ;EACA;GACE,OAAO;GACP,SACE;EACJ;CAGgD,GAChD,IAAI,IAAI,QAAQ,SAAS,KAAK,GAAG;EAC/B,OAAO,MAAM,EAAE,IAAI,GAAG,iDAAiD;EACvE,MAAM,MAAM,IAAI,MAAM,iBAAiB;EACvC,IAAI,kBAAkB;EACtB,IAAI,oBAAoB,KAAK,IAAI,QAAQ,WAAW,KAAK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QAAQ,SAAS,gCAAgC,GAAG;EAC1D,OAAO,MAAM,EAAE,IAAI,GAAG,yBAAyB;EAC/C,OAAO;CACT;CACA,IACE,IAAI,QAAQ,SAAS,0BAA0B,KAC/C,IAAI,QAAQ,SAAS,6BAA6B,GAClD;EACA,OAAO,MAAM,EAAE,IAAI,GAAG,oCAAoC;EAC1D,MAAM,QAAQ,IAAI,MAAM,iBAAiB;EACzC,MAAM,mBAAmB;EACzB,MAAM,kBAAkB;EACxB,MAAM,oBAAoB;EAC1B,MAAM;CACR;CACA,OAAO,MAAM,EAAE,IAAI,GAAG,gCAAgC;CAEtD,MAAM;AACR;AAEA,SAAgB,sBAAsB,KAAqB;CACzD,OAAO,IAAI,QAAQ,SAAS,kBAAkB;AAChD"}
@@ -211,7 +211,8 @@ function withoutUserinfo(url, parsed) {
211
211
  function parseUserinfoUrl(url) {
212
212
  if (!url.includes("@")) return null;
213
213
  const parsed = parseUrl(url);
214
- if (!parsed || !isHttpUrl(parsed) || !parsed.username && !parsed.password) return null;
214
+ if (!parsed || !isHttpUrl(parsed)) return null;
215
+ if (!parsed.username && !parsed.password) return null;
215
216
  if (!parsed.password && isPlaceholderUsername(parsed.username)) return null;
216
217
  return parsed;
217
218
  }
@@ -331,7 +332,8 @@ function matchesHost(url, matchHost, { prefixOnly = false } = {}) {
331
332
  const parsedMatchHost = parseUrl(matchHost);
332
333
  if (isHttpUrl(parsedUrl) && isHttpUrl(parsedMatchHost)) {
333
334
  const { href } = parsedMatchHost;
334
- return stripUrlCredentials(parsedUrl).startsWith(href) || !prefixOnly && ensureTrailingSlash(`${parsedUrl.origin}${parsedUrl.pathname}`) === href;
335
+ if (stripUrlCredentials(parsedUrl).startsWith(href)) return true;
336
+ return !prefixOnly && ensureTrailingSlash(`${parsedUrl.origin}${parsedUrl.pathname}`) === href;
335
337
  }
336
338
  const { hostname } = parsedUrl;
337
339
  if (!hostname) return false;
@@ -344,7 +346,7 @@ function fromShorterToLongerMatchHost(a, b) {
344
346
  return a.matchHost.length - b.matchHost.length;
345
347
  }
346
348
  function hostRuleRank({ hostType, matchHost, readOnly }) {
347
- if ((hostType || readOnly) && matchHost) return 3;
349
+ if ((!!hostType || !!readOnly) && matchHost) return 3;
348
350
  if (matchHost) return 2;
349
351
  if (hostType) return 1;
350
352
  return 0;