renovate 44.85.1 → 44.87.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 (138) hide show
  1. package/dist/data/replacements.js +11 -0
  2. package/dist/modules/datasource/conan/index.js +2 -0
  3. package/dist/modules/datasource/conan/index.js.map +1 -1
  4. package/dist/modules/datasource/cpan/index.js +1 -0
  5. package/dist/modules/datasource/cpan/index.js.map +1 -1
  6. package/dist/modules/datasource/dart/index.js +1 -0
  7. package/dist/modules/datasource/dart/index.js.map +1 -1
  8. package/dist/modules/datasource/deb/index.js +3 -0
  9. package/dist/modules/datasource/deb/index.js.map +1 -1
  10. package/dist/modules/datasource/deno/index.js +1 -0
  11. package/dist/modules/datasource/deno/index.js.map +1 -1
  12. package/dist/modules/datasource/docker/dockerhub-cache.js +1 -0
  13. package/dist/modules/datasource/docker/dockerhub-cache.js.map +1 -1
  14. package/dist/modules/datasource/docker/index.js +5 -0
  15. package/dist/modules/datasource/docker/index.js.map +1 -1
  16. package/dist/modules/datasource/go/releases-goproxy.js +4 -2
  17. package/dist/modules/datasource/go/releases-goproxy.js.map +1 -1
  18. package/dist/modules/datasource/index.js +3 -0
  19. package/dist/modules/datasource/index.js.map +1 -1
  20. package/dist/modules/datasource/npm/npmrc.js.map +1 -1
  21. package/dist/modules/datasource/nuget/v3.js +1 -0
  22. package/dist/modules/datasource/nuget/v3.js.map +1 -1
  23. package/dist/modules/datasource/pod/index.js +1 -0
  24. package/dist/modules/datasource/pod/index.js.map +1 -1
  25. package/dist/modules/datasource/repology/index.js +1 -0
  26. package/dist/modules/datasource/repology/index.js.map +1 -1
  27. package/dist/modules/datasource/rubygems/metadata-cache.js +2 -0
  28. package/dist/modules/datasource/rubygems/metadata-cache.js.map +1 -1
  29. package/dist/modules/datasource/rubygems/versions-endpoint-cache.js +6 -1
  30. package/dist/modules/datasource/rubygems/versions-endpoint-cache.js.map +1 -1
  31. package/dist/modules/datasource/sbt-package/index.js +3 -0
  32. package/dist/modules/datasource/sbt-package/index.js.map +1 -1
  33. package/dist/modules/datasource/sbt-plugin/index.js +3 -0
  34. package/dist/modules/datasource/sbt-plugin/index.js.map +1 -1
  35. package/dist/modules/manager/apm/artifacts.js +2 -1
  36. package/dist/modules/manager/apm/artifacts.js.map +1 -1
  37. package/dist/modules/manager/bazel-module/artifacts.js +2 -1
  38. package/dist/modules/manager/bazel-module/artifacts.js.map +1 -1
  39. package/dist/modules/manager/bazelisk/artifacts.js +2 -1
  40. package/dist/modules/manager/bazelisk/artifacts.js.map +1 -1
  41. package/dist/modules/manager/bun/artifacts.js +2 -1
  42. package/dist/modules/manager/bun/artifacts.js.map +1 -1
  43. package/dist/modules/manager/bundler/artifacts.js +1 -1
  44. package/dist/modules/manager/bundler/artifacts.js.map +1 -1
  45. package/dist/modules/manager/bundler/common.js +11 -16
  46. package/dist/modules/manager/bundler/common.js.map +1 -1
  47. package/dist/modules/manager/cargo/artifacts.js +5 -3
  48. package/dist/modules/manager/cargo/artifacts.js.map +1 -1
  49. package/dist/modules/manager/composer/artifacts.js +6 -7
  50. package/dist/modules/manager/composer/artifacts.js.map +1 -1
  51. package/dist/modules/manager/composer/utils.js +1 -10
  52. package/dist/modules/manager/composer/utils.js.map +1 -1
  53. package/dist/modules/manager/conan/artifacts.js +2 -1
  54. package/dist/modules/manager/conan/artifacts.js.map +1 -1
  55. package/dist/modules/manager/copier/artifacts.js +3 -3
  56. package/dist/modules/manager/copier/artifacts.js.map +1 -1
  57. package/dist/modules/manager/deno/artifacts.js +2 -1
  58. package/dist/modules/manager/deno/artifacts.js.map +1 -1
  59. package/dist/modules/manager/devbox/artifacts.js +8 -5
  60. package/dist/modules/manager/devbox/artifacts.js.map +1 -1
  61. package/dist/modules/manager/fingerprint.generated.js +34 -34
  62. package/dist/modules/manager/fingerprint.generated.js.map +1 -1
  63. package/dist/modules/manager/github-actions/artifacts.js +6 -4
  64. package/dist/modules/manager/github-actions/artifacts.js.map +1 -1
  65. package/dist/modules/manager/gleam/artifacts.js +2 -1
  66. package/dist/modules/manager/gleam/artifacts.js.map +1 -1
  67. package/dist/modules/manager/gomod/artifacts.js +8 -6
  68. package/dist/modules/manager/gomod/artifacts.js.map +1 -1
  69. package/dist/modules/manager/gradle/artifacts.js +2 -1
  70. package/dist/modules/manager/gradle/artifacts.js.map +1 -1
  71. package/dist/modules/manager/gradle-wrapper/artifacts.js +2 -1
  72. package/dist/modules/manager/gradle-wrapper/artifacts.js.map +1 -1
  73. package/dist/modules/manager/helmfile/artifacts.js +4 -3
  74. package/dist/modules/manager/helmfile/artifacts.js.map +1 -1
  75. package/dist/modules/manager/helmv3/artifacts.js +2 -1
  76. package/dist/modules/manager/helmv3/artifacts.js.map +1 -1
  77. package/dist/modules/manager/jsonnet-bundler/artifacts.js +2 -1
  78. package/dist/modules/manager/jsonnet-bundler/artifacts.js.map +1 -1
  79. package/dist/modules/manager/kustomize/artifacts.js +4 -2
  80. package/dist/modules/manager/kustomize/artifacts.js.map +1 -1
  81. package/dist/modules/manager/kustomize/common.js +2 -2
  82. package/dist/modules/manager/kustomize/common.js.map +1 -1
  83. package/dist/modules/manager/maven-wrapper/artifacts.js +2 -1
  84. package/dist/modules/manager/maven-wrapper/artifacts.js.map +1 -1
  85. package/dist/modules/manager/mise/artifacts.js +13 -11
  86. package/dist/modules/manager/mise/artifacts.js.map +1 -1
  87. package/dist/modules/manager/mix/artifacts.js +3 -2
  88. package/dist/modules/manager/mix/artifacts.js.map +1 -1
  89. package/dist/modules/manager/nix/artifacts.js +2 -1
  90. package/dist/modules/manager/nix/artifacts.js.map +1 -1
  91. package/dist/modules/manager/npm/artifacts.js +2 -1
  92. package/dist/modules/manager/npm/artifacts.js.map +1 -1
  93. package/dist/modules/manager/npm/post-update/node-version.js +2 -1
  94. package/dist/modules/manager/npm/post-update/node-version.js.map +1 -1
  95. package/dist/modules/manager/npm/post-update/npm.js +2 -1
  96. package/dist/modules/manager/npm/post-update/npm.js.map +1 -1
  97. package/dist/modules/manager/npm/post-update/pnpm.js +2 -1
  98. package/dist/modules/manager/npm/post-update/pnpm.js.map +1 -1
  99. package/dist/modules/manager/npm/post-update/yarn.js +5 -3
  100. package/dist/modules/manager/npm/post-update/yarn.js.map +1 -1
  101. package/dist/modules/manager/nuget/artifacts.js +2 -1
  102. package/dist/modules/manager/nuget/artifacts.js.map +1 -1
  103. package/dist/modules/manager/pep621/processors/pdm.js +3 -2
  104. package/dist/modules/manager/pep621/processors/pdm.js.map +1 -1
  105. package/dist/modules/manager/pep621/processors/pixi.js +4 -3
  106. package/dist/modules/manager/pep621/processors/pixi.js.map +1 -1
  107. package/dist/modules/manager/pep621/processors/uv.js +3 -3
  108. package/dist/modules/manager/pep621/processors/uv.js.map +1 -1
  109. package/dist/modules/manager/pip-compile/common.js +14 -36
  110. package/dist/modules/manager/pip-compile/common.js.map +1 -1
  111. package/dist/modules/manager/pip_requirements/artifacts.js +3 -2
  112. package/dist/modules/manager/pip_requirements/artifacts.js.map +1 -1
  113. package/dist/modules/manager/pipenv/artifacts.js +3 -2
  114. package/dist/modules/manager/pipenv/artifacts.js.map +1 -1
  115. package/dist/modules/manager/pixi/artifacts.js +2 -1
  116. package/dist/modules/manager/pixi/artifacts.js.map +1 -1
  117. package/dist/modules/manager/poetry/artifacts.js +3 -2
  118. package/dist/modules/manager/poetry/artifacts.js.map +1 -1
  119. package/dist/modules/manager/pub/artifacts.js +11 -10
  120. package/dist/modules/manager/pub/artifacts.js.map +1 -1
  121. package/dist/modules/manager/types.d.ts +23 -3
  122. package/dist/modules/manager/util.js +28 -1
  123. package/dist/modules/manager/util.js.map +1 -1
  124. package/dist/modules/manager/vendir/artifacts.js +3 -2
  125. package/dist/modules/manager/vendir/artifacts.js.map +1 -1
  126. package/dist/workers/repository/process/lookup/filter.js +1 -1
  127. package/dist/workers/repository/process/lookup/filter.js.map +1 -1
  128. package/dist/workers/repository/process/lookup/generate.js +1 -7
  129. package/dist/workers/repository/process/lookup/generate.js.map +1 -1
  130. package/dist/workers/repository/process/lookup/index.js +2 -2
  131. package/dist/workers/repository/process/lookup/index.js.map +1 -1
  132. package/dist/workers/repository/process/lookup/rollback.js.map +1 -1
  133. package/dist/workers/repository/updates/generate.js +11 -4
  134. package/dist/workers/repository/updates/generate.js.map +1 -1
  135. package/package.json +1 -1
  136. package/renovate-schema.json +2 -2
  137. package/dist/modules/manager/copier/utils.js +0 -24
  138. package/dist/modules/manager/copier/utils.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../../lib/modules/datasource/sbt-plugin/index.ts"],"sourcesContent":["import { XmlDocument } from 'xmldoc';\nimport { logger } from '../../../logger/index.ts';\nimport { Http } from '../../../util/http/index.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { ensureTrailingSlash } from '../../../util/url.ts';\nimport * as ivyVersioning from '../../versioning/ivy/index.ts';\nimport { compare } from '../../versioning/maven/compare.ts';\nimport { Datasource } from '../datasource.ts';\nimport { MAVEN_REPO } from '../maven/common.ts';\nimport { downloadHttpContent } from '../maven/util.ts';\nimport { extractPageLinks, getLatestVersion } from '../sbt-package/util.ts';\nimport type {\n GetReleasesConfig,\n RegistryStrategy,\n ReleaseResult,\n} from '../types.ts';\n\nexport const SBT_PLUGINS_REPO =\n 'https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases';\n\nexport class SbtPluginDatasource extends Datasource {\n static readonly id = 'sbt-plugin';\n\n override readonly defaultRegistryUrls = [SBT_PLUGINS_REPO, MAVEN_REPO];\n\n override readonly defaultVersioning = ivyVersioning.id;\n\n override readonly registryStrategy: RegistryStrategy = 'merge';\n\n override readonly sourceUrlSupport = 'package';\n override readonly sourceUrlNote =\n 'The source URL is determined from the `scm` tags in the results.';\n\n constructor() {\n super(SbtPluginDatasource.id);\n this.http = new Http('sbt');\n }\n\n // istanbul ignore next: to be rewritten\n async getArtifactSubdirs(\n searchRoot: string,\n artifact: string,\n scalaVersion: string,\n ): Promise<string[] | null> {\n const pkgUrl = ensureTrailingSlash(searchRoot);\n const indexContent = await downloadHttpContent(this.http, pkgUrl);\n if (indexContent) {\n let artifactSubdirs = extractPageLinks(indexContent, (href) => {\n const path = href.split('/').at(-1)!;\n if (\n path.startsWith(`${artifact}_native`) ||\n path.startsWith(`${artifact}_sjs`)\n ) {\n return null;\n }\n\n if (path === artifact || path.startsWith(`${artifact}_`)) {\n return path;\n }\n\n return null;\n });\n\n if (\n scalaVersion &&\n artifactSubdirs.includes(`${artifact}_${scalaVersion}`)\n ) {\n artifactSubdirs = [`${artifact}_${scalaVersion}`];\n }\n return artifactSubdirs;\n }\n\n return null;\n }\n\n // istanbul ignore next: to be rewritten\n async getPackageReleases(\n searchRoot: string,\n artifactSubdirs: string[] | null,\n ): Promise<string[] | null> {\n if (artifactSubdirs) {\n const releases: string[] = [];\n for (const searchSubdir of artifactSubdirs) {\n const pkgUrl = ensureTrailingSlash(`${searchRoot}/${searchSubdir}`);\n const content = await downloadHttpContent(this.http, pkgUrl);\n if (content) {\n const subdirReleases = extractPageLinks(content, (href) => {\n const path = href.split('/').at(-1)!;\n if (path.startsWith('.')) {\n return null;\n }\n\n return path;\n });\n\n subdirReleases.forEach((x) => releases.push(x));\n }\n }\n if (releases.length) {\n return [...new Set(releases)].sort(compare);\n }\n }\n\n return null;\n }\n\n // istanbul ignore next: to be rewritten\n async getUrls(\n searchRoot: string,\n artifactDirs: string[] | null,\n version: string | null,\n ): Promise<Partial<ReleaseResult>> {\n const result: Partial<ReleaseResult> = {};\n\n if (!artifactDirs?.length) {\n return result;\n }\n\n if (!version) {\n return result;\n }\n\n for (const artifactDir of artifactDirs) {\n const [artifact] = artifactDir.split('_');\n const pomFileNames = [\n `${artifactDir}-${version}.pom`,\n `${artifact}-${version}.pom`,\n ];\n\n for (const pomFileName of pomFileNames) {\n const pomUrl = `${searchRoot}/${artifactDir}/${version}/${pomFileName}`;\n const content = await downloadHttpContent(this.http, pomUrl);\n if (content) {\n const pomXml = new XmlDocument(content);\n\n const homepage = pomXml.valueWithPath('url');\n if (homepage) {\n result.homepage = homepage;\n }\n\n const sourceUrl = pomXml.valueWithPath('scm.url');\n if (sourceUrl) {\n result.sourceUrl = sourceUrl\n .replace(regEx(/^scm:/), '')\n .replace(regEx(/^git:/), '')\n .replace(regEx(/^git@github.com:/), 'https://github.com/')\n .replace(regEx(/\\.git$/), '');\n }\n\n return result;\n }\n }\n }\n\n return result;\n }\n\n async resolvePluginReleases(\n rootUrl: string,\n artifact: string,\n scalaVersion: string,\n ): Promise<string[] | null> {\n const searchRoot = `${rootUrl}/${artifact}`;\n function hrefFilterMap(href: string): string | null {\n if (href.startsWith('.')) {\n return null;\n }\n\n return href;\n }\n const searchRootContent = await downloadHttpContent(\n this.http,\n ensureTrailingSlash(searchRoot),\n );\n if (searchRootContent) {\n const releases: string[] = [];\n const scalaVersionItems = extractPageLinks(\n searchRootContent,\n hrefFilterMap,\n );\n const scalaVersions = scalaVersionItems.map((x) =>\n x.replace(regEx(/^scala_/), ''),\n );\n const searchVersions = scalaVersions.includes(scalaVersion)\n ? [scalaVersion]\n : scalaVersions;\n for (const searchVersion of searchVersions) {\n const searchSubRoot = `${searchRoot}/scala_${searchVersion}`;\n const subRootContent = await downloadHttpContent(\n this.http,\n ensureTrailingSlash(searchSubRoot),\n );\n if (subRootContent) {\n const sbtVersionItems = extractPageLinks(\n subRootContent,\n hrefFilterMap,\n );\n for (const sbtItem of sbtVersionItems) {\n const releasesRoot = `${searchSubRoot}/${sbtItem}`;\n const releasesIndexContent = await downloadHttpContent(\n this.http,\n ensureTrailingSlash(releasesRoot),\n );\n if (releasesIndexContent) {\n const releasesParsed = extractPageLinks(\n releasesIndexContent,\n hrefFilterMap,\n );\n releasesParsed.forEach((x) => releases.push(x));\n }\n }\n }\n }\n if (releases.length) {\n return [...new Set(releases)].sort(compare);\n }\n }\n return null;\n }\n\n override async getReleases({\n packageName,\n registryUrl,\n }: GetReleasesConfig): Promise<ReleaseResult | null> {\n /* v8 ignore next -- should never happen */\n if (!registryUrl) {\n return null;\n }\n\n const [groupId, artifactId] = packageName.split(':');\n const groupIdSplit = groupId.split('.');\n const artifactIdSplit = artifactId.split('_');\n const [artifact, scalaVersion] = artifactIdSplit;\n\n const repoRoot = ensureTrailingSlash(registryUrl);\n const searchRoots: string[] = [];\n // Optimize lookup order\n if (!registryUrl.startsWith(MAVEN_REPO)) {\n searchRoots.push(`${repoRoot}${groupIdSplit.join('.')}`);\n }\n searchRoots.push(`${repoRoot}${groupIdSplit.join('/')}`);\n\n for (const searchRoot of searchRoots) {\n let versions = await this.resolvePluginReleases(\n searchRoot,\n artifact,\n scalaVersion,\n );\n let urls = {};\n\n if (!versions?.length) {\n const artifactSubdirs = await this.getArtifactSubdirs(\n searchRoot,\n artifact,\n scalaVersion,\n );\n versions = await this.getPackageReleases(searchRoot, artifactSubdirs);\n const latestVersion = getLatestVersion(versions);\n urls = await this.getUrls(searchRoot, artifactSubdirs, latestVersion);\n }\n\n const dependencyUrl = `${searchRoot}/${artifact}`;\n\n logger.trace({ dependency: packageName, versions }, `Package versions`);\n if (versions) {\n return {\n ...urls,\n dependencyUrl,\n releases: versions.map((v) => ({ version: v })),\n };\n }\n }\n\n logger.debug(\n `No versions found for ${packageName} in ${searchRoots.length} repositories`,\n );\n return null;\n }\n}\n"],"mappings":";;;;;;;;;;;;AAiBA,MAAa,mBACX;AAEF,IAAa,sBAAb,MAAa,4BAA4B,WAAW;CAClD,OAAgB,KAAK;CAErB,sBAAwC,CAAC,kBAAkB,UAAU;CAErE,oBAAsC;CAEtC,mBAAuD;CAEvD,mBAAqC;CACrC,gBACE;CAEF,cAAc;EACZ,MAAM,oBAAoB,EAAE;EAC5B,KAAK,OAAO,IAAI,KAAK,KAAK;CAC5B;;CAGA,MAAM,mBACJ,YACA,UACA,cAC0B;EAC1B,MAAM,SAAS,oBAAoB,UAAU;EAC7C,MAAM,eAAe,MAAM,oBAAoB,KAAK,MAAM,MAAM;EAChE,IAAI,cAAc;GAChB,IAAI,kBAAkB,iBAAiB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;EAEA,OAAO,MACL,yBAAyB,YAAY,MAAM,YAAY,OAAO,cAChE;EACA,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../lib/modules/datasource/sbt-plugin/index.ts"],"sourcesContent":["import { XmlDocument } from 'xmldoc';\nimport { logger } from '../../../logger/index.ts';\nimport { Http } from '../../../util/http/index.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { ensureTrailingSlash } from '../../../util/url.ts';\nimport * as ivyVersioning from '../../versioning/ivy/index.ts';\nimport { compare } from '../../versioning/maven/compare.ts';\nimport { Datasource } from '../datasource.ts';\nimport { MAVEN_REPO } from '../maven/common.ts';\nimport { downloadHttpContent } from '../maven/util.ts';\nimport { extractPageLinks, getLatestVersion } from '../sbt-package/util.ts';\nimport type {\n GetReleasesConfig,\n RegistryStrategy,\n ReleaseResult,\n} from '../types.ts';\n\nexport const SBT_PLUGINS_REPO =\n 'https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases';\n\nexport class SbtPluginDatasource extends Datasource {\n static readonly id = 'sbt-plugin';\n\n override readonly defaultRegistryUrls = [SBT_PLUGINS_REPO, MAVEN_REPO];\n\n override readonly defaultVersioning = ivyVersioning.id;\n\n override readonly registryStrategy: RegistryStrategy = 'merge';\n\n override readonly sourceUrlSupport = 'package';\n override readonly sourceUrlNote =\n 'The source URL is determined from the `scm` tags in the results.';\n\n constructor() {\n super(SbtPluginDatasource.id);\n this.http = new Http('sbt');\n }\n\n // istanbul ignore next: to be rewritten\n async getArtifactSubdirs(\n searchRoot: string,\n artifact: string,\n scalaVersion: string,\n ): Promise<string[] | null> {\n const pkgUrl = ensureTrailingSlash(searchRoot);\n const indexContent = await downloadHttpContent(this.http, pkgUrl);\n if (indexContent) {\n let artifactSubdirs = extractPageLinks(indexContent, (href) => {\n const path = href.split('/').at(-1)!;\n if (\n path.startsWith(`${artifact}_native`) ||\n path.startsWith(`${artifact}_sjs`)\n ) {\n return null;\n }\n\n if (path === artifact || path.startsWith(`${artifact}_`)) {\n return path;\n }\n\n return null;\n });\n\n if (\n scalaVersion &&\n artifactSubdirs.includes(`${artifact}_${scalaVersion}`)\n ) {\n artifactSubdirs = [`${artifact}_${scalaVersion}`];\n }\n return artifactSubdirs;\n }\n\n return null;\n }\n\n // istanbul ignore next: to be rewritten\n async getPackageReleases(\n searchRoot: string,\n artifactSubdirs: string[] | null,\n ): Promise<string[] | null> {\n if (artifactSubdirs) {\n const releases: string[] = [];\n for (const searchSubdir of artifactSubdirs) {\n const pkgUrl = ensureTrailingSlash(`${searchRoot}/${searchSubdir}`);\n const content = await downloadHttpContent(this.http, pkgUrl);\n if (content) {\n const subdirReleases = extractPageLinks(content, (href) => {\n const path = href.split('/').at(-1)!;\n if (path.startsWith('.')) {\n return null;\n }\n\n return path;\n });\n\n subdirReleases.forEach((x) => releases.push(x));\n }\n }\n if (releases.length) {\n return [...new Set(releases)].sort(compare);\n }\n }\n\n return null;\n }\n\n // istanbul ignore next: to be rewritten\n async getUrls(\n searchRoot: string,\n artifactDirs: string[] | null,\n version: string | null,\n ): Promise<Partial<ReleaseResult>> {\n const result: Partial<ReleaseResult> = {};\n\n if (!artifactDirs?.length) {\n return result;\n }\n\n if (!version) {\n return result;\n }\n\n for (const artifactDir of artifactDirs) {\n const [artifact] = artifactDir.split('_');\n const pomFileNames = [\n `${artifactDir}-${version}.pom`,\n `${artifact}-${version}.pom`,\n ];\n\n for (const pomFileName of pomFileNames) {\n const pomUrl = `${searchRoot}/${artifactDir}/${version}/${pomFileName}`;\n const content = await downloadHttpContent(this.http, pomUrl);\n if (content) {\n const pomXml = new XmlDocument(content);\n\n const homepage = pomXml.valueWithPath('url');\n if (homepage) {\n result.homepage = homepage;\n }\n\n const sourceUrl = pomXml.valueWithPath('scm.url');\n if (sourceUrl) {\n result.sourceUrl = sourceUrl\n .replace(regEx(/^scm:/), '')\n .replace(regEx(/^git:/), '')\n .replace(regEx(/^git@github.com:/), 'https://github.com/')\n .replace(regEx(/\\.git$/), '');\n }\n\n return result;\n }\n }\n }\n\n return result;\n }\n\n async resolvePluginReleases(\n rootUrl: string,\n artifact: string,\n scalaVersion: string,\n ): Promise<string[] | null> {\n const searchRoot = `${rootUrl}/${artifact}`;\n function hrefFilterMap(href: string): string | null {\n if (href.startsWith('.')) {\n return null;\n }\n\n return href;\n }\n const searchRootContent = await downloadHttpContent(\n this.http,\n ensureTrailingSlash(searchRoot),\n );\n if (searchRootContent) {\n const releases: string[] = [];\n const scalaVersionItems = extractPageLinks(\n searchRootContent,\n hrefFilterMap,\n );\n const scalaVersions = scalaVersionItems.map((x) =>\n x.replace(regEx(/^scala_/), ''),\n );\n const searchVersions = scalaVersions.includes(scalaVersion)\n ? [scalaVersion]\n : scalaVersions;\n for (const searchVersion of searchVersions) {\n const searchSubRoot = `${searchRoot}/scala_${searchVersion}`;\n const subRootContent = await downloadHttpContent(\n this.http,\n ensureTrailingSlash(searchSubRoot),\n );\n // v8 ignore else -- needs a nested directory listing fixture\n if (subRootContent) {\n const sbtVersionItems = extractPageLinks(\n subRootContent,\n hrefFilterMap,\n );\n for (const sbtItem of sbtVersionItems) {\n const releasesRoot = `${searchSubRoot}/${sbtItem}`;\n const releasesIndexContent = await downloadHttpContent(\n this.http,\n ensureTrailingSlash(releasesRoot),\n );\n // v8 ignore else -- needs a nested directory listing fixture\n if (releasesIndexContent) {\n const releasesParsed = extractPageLinks(\n releasesIndexContent,\n hrefFilterMap,\n );\n releasesParsed.forEach((x) => releases.push(x));\n }\n }\n }\n }\n // v8 ignore else -- needs a nested directory listing fixture\n if (releases.length) {\n return [...new Set(releases)].sort(compare);\n }\n }\n return null;\n }\n\n override async getReleases({\n packageName,\n registryUrl,\n }: GetReleasesConfig): Promise<ReleaseResult | null> {\n /* v8 ignore next -- should never happen */\n if (!registryUrl) {\n return null;\n }\n\n const [groupId, artifactId] = packageName.split(':');\n const groupIdSplit = groupId.split('.');\n const artifactIdSplit = artifactId.split('_');\n const [artifact, scalaVersion] = artifactIdSplit;\n\n const repoRoot = ensureTrailingSlash(registryUrl);\n const searchRoots: string[] = [];\n // Optimize lookup order\n if (!registryUrl.startsWith(MAVEN_REPO)) {\n searchRoots.push(`${repoRoot}${groupIdSplit.join('.')}`);\n }\n searchRoots.push(`${repoRoot}${groupIdSplit.join('/')}`);\n\n for (const searchRoot of searchRoots) {\n let versions = await this.resolvePluginReleases(\n searchRoot,\n artifact,\n scalaVersion,\n );\n let urls = {};\n\n if (!versions?.length) {\n const artifactSubdirs = await this.getArtifactSubdirs(\n searchRoot,\n artifact,\n scalaVersion,\n );\n versions = await this.getPackageReleases(searchRoot, artifactSubdirs);\n const latestVersion = getLatestVersion(versions);\n urls = await this.getUrls(searchRoot, artifactSubdirs, latestVersion);\n }\n\n const dependencyUrl = `${searchRoot}/${artifact}`;\n\n logger.trace({ dependency: packageName, versions }, `Package versions`);\n if (versions) {\n return {\n ...urls,\n dependencyUrl,\n releases: versions.map((v) => ({ version: v })),\n };\n }\n }\n\n logger.debug(\n `No versions found for ${packageName} in ${searchRoots.length} repositories`,\n );\n return null;\n }\n}\n"],"mappings":";;;;;;;;;;;;AAiBA,MAAa,mBACX;AAEF,IAAa,sBAAb,MAAa,4BAA4B,WAAW;CAClD,OAAgB,KAAK;CAErB,sBAAwC,CAAC,kBAAkB,UAAU;CAErE,oBAAsC;CAEtC,mBAAuD;CAEvD,mBAAqC;CACrC,gBACE;CAEF,cAAc;EACZ,MAAM,oBAAoB,EAAE;EAC5B,KAAK,OAAO,IAAI,KAAK,KAAK;CAC5B;;CAGA,MAAM,mBACJ,YACA,UACA,cAC0B;EAC1B,MAAM,SAAS,oBAAoB,UAAU;EAC7C,MAAM,eAAe,MAAM,oBAAoB,KAAK,MAAM,MAAM;EAChE,IAAI,cAAc;GAChB,IAAI,kBAAkB,iBAAiB,eAAe,SAAS;IAC7D,MAAM,OAAO,KAAK,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE;IAClC,IACE,KAAK,WAAW,GAAG,SAAS,QAAQ,KACpC,K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.js";
3
3
  import { deleteLocalFile, getSiblingFileName, readLocalFile, writeLocalFile } from "../../../util/fs/index.js";
4
4
  import { exec } from "../../../util/exec/index.js";
5
5
  import { getRepoStatus } from "../../../util/git/index.js";
6
+ import { resolveToolConstraint } from "../util.js";
6
7
  import { isNonEmptyArray } from "@sindresorhus/is";
7
8
  //#region lib/modules/manager/apm/artifacts.ts
8
9
  async function updateArtifacts({ packageFileName, updatedDeps, newPackageFileContent, config }) {
@@ -25,7 +26,7 @@ async function updateArtifacts({ packageFileName, updatedDeps, newPackageFileCon
25
26
  docker: {},
26
27
  toolConstraints: [{
27
28
  toolName: "apm",
28
- constraint: config.constraints?.apm
29
+ constraint: await resolveToolConstraint(config, "apm")
29
30
  }]
30
31
  };
31
32
  await exec("apm install", execOptions);
@@ -1 +1 @@
1
- {"version":3,"file":"artifacts.js","names":[],"sources":["../../../../lib/modules/manager/apm/artifacts.ts"],"sourcesContent":["import { isNonEmptyArray } from '@sindresorhus/is';\nimport { TEMPORARY_ERROR } from '../../../constants/error-messages.ts';\nimport { logger } from '../../../logger/index.ts';\nimport { exec } from '../../../util/exec/index.ts';\nimport type { ExecOptions } from '../../../util/exec/types.ts';\nimport {\n deleteLocalFile,\n getSiblingFileName,\n readLocalFile,\n writeLocalFile,\n} from '../../../util/fs/index.ts';\nimport { getRepoStatus } from '../../../util/git/index.ts';\nimport type { UpdateArtifact, UpdateArtifactsResult } from '../types.ts';\n\nexport async function updateArtifacts({\n packageFileName,\n updatedDeps,\n newPackageFileContent,\n config,\n}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {\n logger.debug(`apm.updateArtifacts(${packageFileName})`);\n const { isLockFileMaintenance } = config;\n\n if (!isNonEmptyArray(updatedDeps) && !isLockFileMaintenance) {\n logger.debug('apm: no updated deps - returning null');\n return null;\n }\n\n const lockFileName = getSiblingFileName(packageFileName, 'apm.lock.yaml');\n const existingLockFileContent = await readLocalFile(lockFileName, 'utf8');\n if (!existingLockFileContent) {\n logger.debug('apm: no lock file found');\n return null;\n }\n\n try {\n await writeLocalFile(packageFileName, newPackageFileContent);\n if (isLockFileMaintenance) {\n await deleteLocalFile(lockFileName);\n }\n\n const execOptions: ExecOptions = {\n cwdFile: packageFileName,\n docker: {},\n toolConstraints: [\n { toolName: 'apm', constraint: config.constraints?.apm },\n ],\n };\n await exec('apm install', execOptions);\n\n // `apm install` regenerates the lockfile and re-deploys the harness\n // directories (`.github/`, `.claude/`, ...) that APM consumers commit, so\n // return every file it changed - not just the lockfile - or the committed\n // instruction files go stale after a bump. `apm_modules/` is the gitignored\n // cache, so it is not reported here.\n const status = await getRepoStatus();\n const res: UpdateArtifactsResult[] = [];\n for (const path of [...status.modified, ...status.not_added]) {\n // the manifest itself is committed as an updated package file\n if (path === packageFileName) {\n continue;\n }\n res.push({\n file: { type: 'addition', path, contents: await readLocalFile(path) },\n });\n }\n for (const path of status.deleted) {\n res.push({ file: { type: 'deletion', path } });\n }\n if (!res.length) {\n logger.debug('apm: no changed files after install');\n return null;\n }\n return res;\n } catch (err) {\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n logger.debug({ err }, `Failed to update ${lockFileName}`);\n return [\n {\n artifactError: {\n fileName: lockFileName,\n stderr: `${err}`,\n },\n },\n ];\n }\n}\n"],"mappings":";;;;;;;AAcA,eAAsB,gBAAgB,EACpC,iBACA,aACA,uBACA,UAC0D;CAC1D,OAAO,MAAM,uBAAuB,gBAAgB,EAAE;CACtD,MAAM,EAAE,0BAA0B;CAElC,IAAI,CAAC,gBAAgB,WAAW,KAAK,CAAC,uBAAuB;EAC3D,OAAO,MAAM,uCAAuC;EACpD,OAAO;CACT;CAEA,MAAM,eAAe,mBAAmB,iBAAiB,eAAe;CAExE,IAAI,CAAC,MADiC,cAAc,cAAc,MAAM,GAC1C;EAC5B,OAAO,MAAM,yBAAyB;EACtC,OAAO;CACT;CAEA,IAAI;EACF,MAAM,eAAe,iBAAiB,qBAAqB;EAC3D,IAAI,uBACF,MAAM,gBAAgB,YAAY;EAGpC,MAAM,cAA2B;GAC/B,SAAS;GACT,QAAQ,CAAC;GACT,iBAAiB,CACf;IAAE,UAAU;IAAO,YAAY,OAAO,aAAa;GAAI,CACzD;EACF;EACA,MAAM,KAAK,eAAe,WAAW;EAOrC,MAAM,SAAS,MAAM,cAAc;EACnC,MAAM,MAA+B,CAAC;EACtC,KAAK,MAAM,QAAQ,CAAC,GAAG,OAAO,UAAU,GAAG,OAAO,SAAS,GAAG;GAE5D,IAAI,SAAS,iBACX;GAEF,IAAI,KAAK,EACP,MAAM;IAAE,MAAM;IAAY;IAAM,UAAU,MAAM,cAAc,IAAI;GAAE,EACtE,CAAC;EACH;EACA,KAAK,MAAM,QAAQ,OAAO,SACxB,IAAI,KAAK,EAAE,MAAM;GAAE,MAAM;GAAY;EAAK,EAAE,CAAC;EAE/C,IAAI,CAAC,IAAI,QAAQ;GACf,OAAO,MAAM,qCAAqC;GAClD,OAAO;EACT;EACA,OAAO;CACT,SAAS,KAAK;EACZ,IAAI,IAAI,YAAA,mBACN,MAAM;EAER,OAAO,MAAM,EAAE,IAAI,GAAG,oBAAoB,cAAc;EACxD,OAAO,CACL,EACE,eAAe;GACb,UAAU;GACV,QAAQ,GAAG;EACb,EACF,CACF;CACF;AACF"}
1
+ {"version":3,"file":"artifacts.js","names":[],"sources":["../../../../lib/modules/manager/apm/artifacts.ts"],"sourcesContent":["import { isNonEmptyArray } from '@sindresorhus/is';\nimport { TEMPORARY_ERROR } from '../../../constants/error-messages.ts';\nimport { logger } from '../../../logger/index.ts';\nimport { exec } from '../../../util/exec/index.ts';\nimport type { ExecOptions } from '../../../util/exec/types.ts';\nimport {\n deleteLocalFile,\n getSiblingFileName,\n readLocalFile,\n writeLocalFile,\n} from '../../../util/fs/index.ts';\nimport { getRepoStatus } from '../../../util/git/index.ts';\nimport type { UpdateArtifact, UpdateArtifactsResult } from '../types.ts';\nimport { resolveToolConstraint } from '../util.ts';\n\nexport async function updateArtifacts({\n packageFileName,\n updatedDeps,\n newPackageFileContent,\n config,\n}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {\n logger.debug(`apm.updateArtifacts(${packageFileName})`);\n const { isLockFileMaintenance } = config;\n\n if (!isNonEmptyArray(updatedDeps) && !isLockFileMaintenance) {\n logger.debug('apm: no updated deps - returning null');\n return null;\n }\n\n const lockFileName = getSiblingFileName(packageFileName, 'apm.lock.yaml');\n const existingLockFileContent = await readLocalFile(lockFileName, 'utf8');\n if (!existingLockFileContent) {\n logger.debug('apm: no lock file found');\n return null;\n }\n\n try {\n await writeLocalFile(packageFileName, newPackageFileContent);\n if (isLockFileMaintenance) {\n await deleteLocalFile(lockFileName);\n }\n\n const execOptions: ExecOptions = {\n cwdFile: packageFileName,\n docker: {},\n toolConstraints: [\n {\n toolName: 'apm',\n constraint: await resolveToolConstraint(config, 'apm'),\n },\n ],\n };\n await exec('apm install', execOptions);\n\n // `apm install` regenerates the lockfile and re-deploys the harness\n // directories (`.github/`, `.claude/`, ...) that APM consumers commit, so\n // return every file it changed - not just the lockfile - or the committed\n // instruction files go stale after a bump. `apm_modules/` is the gitignored\n // cache, so it is not reported here.\n const status = await getRepoStatus();\n const res: UpdateArtifactsResult[] = [];\n for (const path of [...status.modified, ...status.not_added]) {\n // the manifest itself is committed as an updated package file\n if (path === packageFileName) {\n continue;\n }\n res.push({\n file: { type: 'addition', path, contents: await readLocalFile(path) },\n });\n }\n for (const path of status.deleted) {\n res.push({ file: { type: 'deletion', path } });\n }\n if (!res.length) {\n logger.debug('apm: no changed files after install');\n return null;\n }\n return res;\n } catch (err) {\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n logger.debug({ err }, `Failed to update ${lockFileName}`);\n return [\n {\n artifactError: {\n fileName: lockFileName,\n stderr: `${err}`,\n },\n },\n ];\n }\n}\n"],"mappings":";;;;;;;;AAeA,eAAsB,gBAAgB,EACpC,iBACA,aACA,uBACA,UAC0D;CAC1D,OAAO,MAAM,uBAAuB,gBAAgB,EAAE;CACtD,MAAM,EAAE,0BAA0B;CAElC,IAAI,CAAC,gBAAgB,WAAW,KAAK,CAAC,uBAAuB;EAC3D,OAAO,MAAM,uCAAuC;EACpD,OAAO;CACT;CAEA,MAAM,eAAe,mBAAmB,iBAAiB,eAAe;CAExE,IAAI,CAAC,MADiC,cAAc,cAAc,MAAM,GAC1C;EAC5B,OAAO,MAAM,yBAAyB;EACtC,OAAO;CACT;CAEA,IAAI;EACF,MAAM,eAAe,iBAAiB,qBAAqB;EAC3D,IAAI,uBACF,MAAM,gBAAgB,YAAY;EAGpC,MAAM,cAA2B;GAC/B,SAAS;GACT,QAAQ,CAAC;GACT,iBAAiB,CACf;IACE,UAAU;IACV,YAAY,MAAM,sBAAsB,QAAQ,KAAK;GACvD,CACF;EACF;EACA,MAAM,KAAK,eAAe,WAAW;EAOrC,MAAM,SAAS,MAAM,cAAc;EACnC,MAAM,MAA+B,CAAC;EACtC,KAAK,MAAM,QAAQ,CAAC,GAAG,OAAO,UAAU,GAAG,OAAO,SAAS,GAAG;GAE5D,IAAI,SAAS,iBACX;GAEF,IAAI,KAAK,EACP,MAAM;IAAE,MAAM;IAAY;IAAM,UAAU,MAAM,cAAc,IAAI;GAAE,EACtE,CAAC;EACH;EACA,KAAK,MAAM,QAAQ,OAAO,SACxB,IAAI,KAAK,EAAE,MAAM;GAAE,MAAM;GAAY;EAAK,EAAE,CAAC;EAE/C,IAAI,CAAC,IAAI,QAAQ;GACf,OAAO,MAAM,qCAAqC;GAClD,OAAO;EACT;EACA,OAAO;CACT,SAAS,KAAK;EACZ,IAAI,IAAI,YAAA,mBACN,MAAM;EAER,OAAO,MAAM,EAAE,IAAI,GAAG,oBAAoB,cAAc;EACxD,OAAO,CACL,EACE,eAAe;GACb,UAAU;GACV,QAAQ,GAAG;EACb,EACF,CACF;CACF;AACF"}
@@ -1,5 +1,6 @@
1
1
  import { logger } from "../../../logger/index.js";
2
2
  import { getSiblingFileName, readLocalFile, writeLocalFile } from "../../../util/fs/index.js";
3
+ import { resolveToolConstraint } from "../util.js";
3
4
  import { updateBazelLockfile } from "./lockfile.js";
4
5
  //#region lib/modules/manager/bazel-module/artifacts.ts
5
6
  async function updateArtifacts({ packageFileName, updatedDeps, newPackageFileContent, config }) {
@@ -15,7 +16,7 @@ async function updateArtifacts({ packageFileName, updatedDeps, newPackageFileCon
15
16
  return null;
16
17
  }
17
18
  await writeLocalFile(packageFileName, newPackageFileContent);
18
- return await updateBazelLockfile(lockFileName, packageFileName, isLockFileMaintenance, config.constraints?.bazelisk);
19
+ return await updateBazelLockfile(lockFileName, packageFileName, isLockFileMaintenance, await resolveToolConstraint(config, "bazelisk"));
19
20
  }
20
21
  //#endregion
21
22
  export { updateArtifacts };
@@ -1 +1 @@
1
- {"version":3,"file":"artifacts.js","names":[],"sources":["../../../../lib/modules/manager/bazel-module/artifacts.ts"],"sourcesContent":["import { logger } from '../../../logger/index.ts';\nimport {\n getSiblingFileName,\n readLocalFile,\n writeLocalFile,\n} from '../../../util/fs/index.ts';\nimport type { UpdateArtifact, UpdateArtifactsResult } from '../types.ts';\nimport { updateBazelLockfile } from './lockfile.ts';\n\nexport async function updateArtifacts({\n packageFileName,\n updatedDeps,\n newPackageFileContent,\n config,\n}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {\n logger.debug(`bazel-module.updateArtifacts(${packageFileName})`);\n const { isLockFileMaintenance } = config;\n\n if (!updatedDeps.length && !isLockFileMaintenance) {\n logger.debug('No updated bazel-module deps - returning null');\n return null;\n }\n\n const lockFileName = getSiblingFileName(packageFileName, 'MODULE.bazel.lock');\n\n const existingLockContent = await readLocalFile(lockFileName, 'utf8');\n if (!existingLockContent) {\n logger.debug('No MODULE.bazel.lock found - skipping artifact update');\n return null;\n }\n\n await writeLocalFile(packageFileName, newPackageFileContent);\n\n return await updateBazelLockfile(\n lockFileName,\n packageFileName,\n isLockFileMaintenance,\n config.constraints?.bazelisk,\n );\n}\n"],"mappings":";;;;AASA,eAAsB,gBAAgB,EACpC,iBACA,aACA,uBACA,UAC0D;CAC1D,OAAO,MAAM,gCAAgC,gBAAgB,EAAE;CAC/D,MAAM,EAAE,0BAA0B;CAElC,IAAI,CAAC,YAAY,UAAU,CAAC,uBAAuB;EACjD,OAAO,MAAM,+CAA+C;EAC5D,OAAO;CACT;CAEA,MAAM,eAAe,mBAAmB,iBAAiB,mBAAmB;CAG5E,IAAI,CAAC,MAD6B,cAAc,cAAc,MAAM,GAC1C;EACxB,OAAO,MAAM,uDAAuD;EACpE,OAAO;CACT;CAEA,MAAM,eAAe,iBAAiB,qBAAqB;CAE3D,OAAO,MAAM,oBACX,cACA,iBACA,uBACA,OAAO,aAAa,QACtB;AACF"}
1
+ {"version":3,"file":"artifacts.js","names":[],"sources":["../../../../lib/modules/manager/bazel-module/artifacts.ts"],"sourcesContent":["import { logger } from '../../../logger/index.ts';\nimport {\n getSiblingFileName,\n readLocalFile,\n writeLocalFile,\n} from '../../../util/fs/index.ts';\nimport type { UpdateArtifact, UpdateArtifactsResult } from '../types.ts';\nimport { resolveToolConstraint } from '../util.ts';\nimport { updateBazelLockfile } from './lockfile.ts';\n\nexport async function updateArtifacts({\n packageFileName,\n updatedDeps,\n newPackageFileContent,\n config,\n}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {\n logger.debug(`bazel-module.updateArtifacts(${packageFileName})`);\n const { isLockFileMaintenance } = config;\n\n if (!updatedDeps.length && !isLockFileMaintenance) {\n logger.debug('No updated bazel-module deps - returning null');\n return null;\n }\n\n const lockFileName = getSiblingFileName(packageFileName, 'MODULE.bazel.lock');\n\n const existingLockContent = await readLocalFile(lockFileName, 'utf8');\n if (!existingLockContent) {\n logger.debug('No MODULE.bazel.lock found - skipping artifact update');\n return null;\n }\n\n await writeLocalFile(packageFileName, newPackageFileContent);\n\n return await updateBazelLockfile(\n lockFileName,\n packageFileName,\n isLockFileMaintenance,\n await resolveToolConstraint(config, 'bazelisk'),\n );\n}\n"],"mappings":";;;;;AAUA,eAAsB,gBAAgB,EACpC,iBACA,aACA,uBACA,UAC0D;CAC1D,OAAO,MAAM,gCAAgC,gBAAgB,EAAE;CAC/D,MAAM,EAAE,0BAA0B;CAElC,IAAI,CAAC,YAAY,UAAU,CAAC,uBAAuB;EACjD,OAAO,MAAM,+CAA+C;EAC5D,OAAO;CACT;CAEA,MAAM,eAAe,mBAAmB,iBAAiB,mBAAmB;CAG5E,IAAI,CAAC,MAD6B,cAAc,cAAc,MAAM,GAC1C;EACxB,OAAO,MAAM,uDAAuD;EACpE,OAAO;CACT;CAEA,MAAM,eAAe,iBAAiB,qBAAqB;CAE3D,OAAO,MAAM,oBACX,cACA,iBACA,uBACA,MAAM,sBAAsB,QAAQ,UAAU,CAChD;AACF"}
@@ -1,5 +1,6 @@
1
1
  import { logger } from "../../../logger/index.js";
2
2
  import { getSiblingFileName, readLocalFile, writeLocalFile } from "../../../util/fs/index.js";
3
+ import { resolveToolConstraint } from "../util.js";
3
4
  import { updateBazelLockfile } from "../bazel-module/lockfile.js";
4
5
  //#region lib/modules/manager/bazelisk/artifacts.ts
5
6
  async function updateArtifacts({ packageFileName, updatedDeps, newPackageFileContent, config }) {
@@ -19,7 +20,7 @@ async function updateArtifacts({ packageFileName, updatedDeps, newPackageFileCon
19
20
  return null;
20
21
  }
21
22
  await writeLocalFile(packageFileName, newPackageFileContent);
22
- return await updateBazelLockfile(lockFileName, moduleFileName, config.isLockFileMaintenance, config.constraints?.bazelisk);
23
+ return await updateBazelLockfile(lockFileName, moduleFileName, config.isLockFileMaintenance, await resolveToolConstraint(config, "bazelisk"));
23
24
  }
24
25
  //#endregion
25
26
  export { updateArtifacts };
@@ -1 +1 @@
1
- {"version":3,"file":"artifacts.js","names":[],"sources":["../../../../lib/modules/manager/bazelisk/artifacts.ts"],"sourcesContent":["import { logger } from '../../../logger/index.ts';\nimport {\n getSiblingFileName,\n readLocalFile,\n writeLocalFile,\n} from '../../../util/fs/index.ts';\nimport { updateBazelLockfile } from '../bazel-module/lockfile.ts';\nimport type { UpdateArtifact, UpdateArtifactsResult } from '../types.ts';\n\nexport async function updateArtifacts({\n packageFileName,\n updatedDeps,\n newPackageFileContent,\n config,\n}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {\n logger.debug(`bazelisk.updateArtifacts(${packageFileName})`);\n\n if (!updatedDeps.length && !config.isLockFileMaintenance) {\n logger.debug('No updated bazelisk deps - returning null');\n return null;\n }\n\n const moduleFileName = getSiblingFileName(packageFileName, 'MODULE.bazel');\n const existingModuleContent = await readLocalFile(moduleFileName, 'utf8');\n if (!existingModuleContent) {\n logger.debug('No MODULE.bazel found - skipping artifact update');\n return null;\n }\n\n const lockFileName = getSiblingFileName(packageFileName, 'MODULE.bazel.lock');\n const existingLockContent = await readLocalFile(lockFileName, 'utf8');\n if (!existingLockContent) {\n logger.debug('No MODULE.bazel.lock found - skipping artifact update');\n return null;\n }\n\n await writeLocalFile(packageFileName, newPackageFileContent);\n\n return await updateBazelLockfile(\n lockFileName,\n moduleFileName,\n config.isLockFileMaintenance,\n config.constraints?.bazelisk,\n );\n}\n"],"mappings":";;;;AASA,eAAsB,gBAAgB,EACpC,iBACA,aACA,uBACA,UAC0D;CAC1D,OAAO,MAAM,4BAA4B,gBAAgB,EAAE;CAE3D,IAAI,CAAC,YAAY,UAAU,CAAC,OAAO,uBAAuB;EACxD,OAAO,MAAM,2CAA2C;EACxD,OAAO;CACT;CAEA,MAAM,iBAAiB,mBAAmB,iBAAiB,cAAc;CAEzE,IAAI,CAAC,MAD+B,cAAc,gBAAgB,MAAM,GAC5C;EAC1B,OAAO,MAAM,kDAAkD;EAC/D,OAAO;CACT;CAEA,MAAM,eAAe,mBAAmB,iBAAiB,mBAAmB;CAE5E,IAAI,CAAC,MAD6B,cAAc,cAAc,MAAM,GAC1C;EACxB,OAAO,MAAM,uDAAuD;EACpE,OAAO;CACT;CAEA,MAAM,eAAe,iBAAiB,qBAAqB;CAE3D,OAAO,MAAM,oBACX,cACA,gBACA,OAAO,uBACP,OAAO,aAAa,QACtB;AACF"}
1
+ {"version":3,"file":"artifacts.js","names":[],"sources":["../../../../lib/modules/manager/bazelisk/artifacts.ts"],"sourcesContent":["import { logger } from '../../../logger/index.ts';\nimport {\n getSiblingFileName,\n readLocalFile,\n writeLocalFile,\n} from '../../../util/fs/index.ts';\nimport { updateBazelLockfile } from '../bazel-module/lockfile.ts';\nimport type { UpdateArtifact, UpdateArtifactsResult } from '../types.ts';\nimport { resolveToolConstraint } from '../util.ts';\n\nexport async function updateArtifacts({\n packageFileName,\n updatedDeps,\n newPackageFileContent,\n config,\n}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {\n logger.debug(`bazelisk.updateArtifacts(${packageFileName})`);\n\n if (!updatedDeps.length && !config.isLockFileMaintenance) {\n logger.debug('No updated bazelisk deps - returning null');\n return null;\n }\n\n const moduleFileName = getSiblingFileName(packageFileName, 'MODULE.bazel');\n const existingModuleContent = await readLocalFile(moduleFileName, 'utf8');\n if (!existingModuleContent) {\n logger.debug('No MODULE.bazel found - skipping artifact update');\n return null;\n }\n\n const lockFileName = getSiblingFileName(packageFileName, 'MODULE.bazel.lock');\n const existingLockContent = await readLocalFile(lockFileName, 'utf8');\n if (!existingLockContent) {\n logger.debug('No MODULE.bazel.lock found - skipping artifact update');\n return null;\n }\n\n await writeLocalFile(packageFileName, newPackageFileContent);\n\n return await updateBazelLockfile(\n lockFileName,\n moduleFileName,\n config.isLockFileMaintenance,\n await resolveToolConstraint(config, 'bazelisk'),\n );\n}\n"],"mappings":";;;;;AAUA,eAAsB,gBAAgB,EACpC,iBACA,aACA,uBACA,UAC0D;CAC1D,OAAO,MAAM,4BAA4B,gBAAgB,EAAE;CAE3D,IAAI,CAAC,YAAY,UAAU,CAAC,OAAO,uBAAuB;EACxD,OAAO,MAAM,2CAA2C;EACxD,OAAO;CACT;CAEA,MAAM,iBAAiB,mBAAmB,iBAAiB,cAAc;CAEzE,IAAI,CAAC,MAD+B,cAAc,gBAAgB,MAAM,GAC5C;EAC1B,OAAO,MAAM,kDAAkD;EAC/D,OAAO;CACT;CAEA,MAAM,eAAe,mBAAmB,iBAAiB,mBAAmB;CAE5E,IAAI,CAAC,MAD6B,cAAc,cAAc,MAAM,GAC1C;EACxB,OAAO,MAAM,uDAAuD;EACpE,OAAO;CACT;CAEA,MAAM,eAAe,iBAAiB,qBAAqB;CAE3D,OAAO,MAAM,oBACX,cACA,gBACA,OAAO,uBACP,MAAM,sBAAsB,QAAQ,UAAU,CAChD;AACF"}
@@ -3,6 +3,7 @@ import { GlobalConfig } from "../../../config/global.js";
3
3
  import { logger } from "../../../logger/index.js";
4
4
  import { deleteLocalFile, readLocalFile, writeLocalFile } from "../../../util/fs/index.js";
5
5
  import { exec } from "../../../util/exec/index.js";
6
+ import { resolveToolConstraint } from "../util.js";
6
7
  import { processHostRules } from "../npm/post-update/rules.js";
7
8
  import { getNpmrcContent, resetNpmrcContent, updateNpmrcContent } from "../npm/utils.js";
8
9
  import { isEmptyArray } from "@sindresorhus/is";
@@ -40,7 +41,7 @@ async function updateArtifacts(updateArtifact) {
40
41
  docker: {},
41
42
  toolConstraints: [{
42
43
  toolName: "bun",
43
- constraint: updateArtifact?.config?.constraints?.bun
44
+ constraint: await resolveToolConstraint(config, "bun")
44
45
  }]
45
46
  };
46
47
  await exec(cmd, execOptions);
@@ -1 +1 @@
1
- {"version":3,"file":"artifacts.js","names":[],"sources":["../../../../lib/modules/manager/bun/artifacts.ts"],"sourcesContent":["import { isEmptyArray } from '@sindresorhus/is';\nimport upath from 'upath';\nimport { GlobalConfig } from '../../../config/global.ts';\nimport { TEMPORARY_ERROR } from '../../../constants/error-messages.ts';\nimport { logger } from '../../../logger/index.ts';\nimport { exec } from '../../../util/exec/index.ts';\nimport type { ExecOptions } from '../../../util/exec/types.ts';\nimport {\n deleteLocalFile,\n readLocalFile,\n writeLocalFile,\n} from '../../../util/fs/index.ts';\nimport { processHostRules } from '../npm/post-update/rules.ts';\nimport {\n getNpmrcContent,\n resetNpmrcContent,\n updateNpmrcContent,\n} from '../npm/utils.ts';\nimport type { UpdateArtifact, UpdateArtifactsResult } from '../types.ts';\n\nexport async function updateArtifacts(\n updateArtifact: UpdateArtifact,\n): Promise<UpdateArtifactsResult[] | null> {\n const { packageFileName, updatedDeps, newPackageFileContent, config } =\n updateArtifact;\n logger.debug(`bun.updateArtifacts(${packageFileName})`);\n const { isLockFileMaintenance } = config;\n\n if (isEmptyArray(updatedDeps) && !isLockFileMaintenance) {\n logger.debug('No updated bun deps - returning null');\n return null;\n }\n\n // Find the first bun dependency in order to handle mixed manager updates,\n // eventually falling back to the first lock file from config.\n const lockFileName =\n updatedDeps.find((dep) => dep.manager === 'bun')?.lockFiles?.[0] ??\n config.lockFiles?.[0];\n\n if (!lockFileName) {\n logger.debug(`bun: No lock file found`);\n return null;\n }\n\n const oldLockFileContent = await readLocalFile(lockFileName);\n if (!oldLockFileContent) {\n logger.debug(`No ${lockFileName} found`);\n return null;\n }\n\n const pkgFileDir = upath.dirname(packageFileName);\n const npmrcContent = await getNpmrcContent(pkgFileDir);\n const { additionalNpmrcContent } = processHostRules();\n await updateNpmrcContent(pkgFileDir, npmrcContent, additionalNpmrcContent);\n\n try {\n await writeLocalFile(packageFileName, newPackageFileContent);\n if (isLockFileMaintenance) {\n await deleteLocalFile(lockFileName);\n }\n\n let cmd = 'bun install';\n\n if (!GlobalConfig.get('allowScripts') || config.ignoreScripts) {\n cmd += ' --ignore-scripts';\n }\n\n const execOptions: ExecOptions = {\n cwdFile: lockFileName,\n docker: {},\n toolConstraints: [\n {\n toolName: 'bun',\n constraint: updateArtifact?.config?.constraints?.bun,\n },\n ],\n };\n\n await exec(cmd, execOptions);\n await resetNpmrcContent(pkgFileDir, npmrcContent);\n\n const newLockFileContent = await readLocalFile(lockFileName);\n if (\n !newLockFileContent ||\n Buffer.compare(oldLockFileContent, newLockFileContent) === 0\n ) {\n return null;\n }\n return [\n {\n file: {\n type: 'addition',\n path: lockFileName,\n contents: newLockFileContent,\n },\n },\n ];\n } catch (err) {\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n logger.warn({ lockfile: lockFileName, err }, `Failed to update lock file`);\n return [\n {\n artifactError: {\n fileName: lockFileName,\n stderr: err.message,\n },\n },\n ];\n }\n}\n"],"mappings":";;;;;;;;;;AAoBA,eAAsB,gBACpB,gBACyC;CACzC,MAAM,EAAE,iBAAiB,aAAa,uBAAuB,WAC3D;CACF,OAAO,MAAM,uBAAuB,gBAAgB,EAAE;CACtD,MAAM,EAAE,0BAA0B;CAElC,IAAI,aAAa,WAAW,KAAK,CAAC,uBAAuB;EACvD,OAAO,MAAM,sCAAsC;EACnD,OAAO;CACT;CAIA,MAAM,eACJ,YAAY,MAAM,QAAQ,IAAI,YAAY,KAAK,CAAC,EAAE,YAAY,MAC9D,OAAO,YAAY;CAErB,IAAI,CAAC,cAAc;EACjB,OAAO,MAAM,yBAAyB;EACtC,OAAO;CACT;CAEA,MAAM,qBAAqB,MAAM,cAAc,YAAY;CAC3D,IAAI,CAAC,oBAAoB;EACvB,OAAO,MAAM,MAAM,aAAa,OAAO;EACvC,OAAO;CACT;CAEA,MAAM,aAAa,MAAM,QAAQ,eAAe;CAChD,MAAM,eAAe,MAAM,gBAAgB,UAAU;CACrD,MAAM,EAAE,2BAA2B,iBAAiB;CACpD,MAAM,mBAAmB,YAAY,cAAc,sBAAsB;CAEzE,IAAI;EACF,MAAM,eAAe,iBAAiB,qBAAqB;EAC3D,IAAI,uBACF,MAAM,gBAAgB,YAAY;EAGpC,IAAI,MAAM;EAEV,IAAI,CAAC,aAAa,IAAI,cAAc,KAAK,OAAO,eAC9C,OAAO;EAGT,MAAM,cAA2B;GAC/B,SAAS;GACT,QAAQ,CAAC;GACT,iBAAiB,CACf;IACE,UAAU;IACV,YAAY,gBAAgB,QAAQ,aAAa;GACnD,CACF;EACF;EAEA,MAAM,KAAK,KAAK,WAAW;EAC3B,MAAM,kBAAkB,YAAY,YAAY;EAEhD,MAAM,qBAAqB,MAAM,cAAc,YAAY;EAC3D,IACE,CAAC,sBACD,OAAO,QAAQ,oBAAoB,kBAAkB,MAAM,GAE3D,OAAO;EAET,OAAO,CACL,EACE,MAAM;GACJ,MAAM;GACN,MAAM;GACN,UAAU;EACZ,EACF,CACF;CACF,SAAS,KAAK;EACZ,IAAI,IAAI,YAAA,mBACN,MAAM;EAER,OAAO,KAAK;GAAE,UAAU;GAAc;EAAI,GAAG,4BAA4B;EACzE,OAAO,CACL,EACE,eAAe;GACb,UAAU;GACV,QAAQ,IAAI;EACd,EACF,CACF;CACF;AACF"}
1
+ {"version":3,"file":"artifacts.js","names":[],"sources":["../../../../lib/modules/manager/bun/artifacts.ts"],"sourcesContent":["import { isEmptyArray } from '@sindresorhus/is';\nimport upath from 'upath';\nimport { GlobalConfig } from '../../../config/global.ts';\nimport { TEMPORARY_ERROR } from '../../../constants/error-messages.ts';\nimport { logger } from '../../../logger/index.ts';\nimport { exec } from '../../../util/exec/index.ts';\nimport type { ExecOptions } from '../../../util/exec/types.ts';\nimport {\n deleteLocalFile,\n readLocalFile,\n writeLocalFile,\n} from '../../../util/fs/index.ts';\nimport { processHostRules } from '../npm/post-update/rules.ts';\nimport {\n getNpmrcContent,\n resetNpmrcContent,\n updateNpmrcContent,\n} from '../npm/utils.ts';\nimport type { UpdateArtifact, UpdateArtifactsResult } from '../types.ts';\nimport { resolveToolConstraint } from '../util.ts';\n\nexport async function updateArtifacts(\n updateArtifact: UpdateArtifact,\n): Promise<UpdateArtifactsResult[] | null> {\n const { packageFileName, updatedDeps, newPackageFileContent, config } =\n updateArtifact;\n logger.debug(`bun.updateArtifacts(${packageFileName})`);\n const { isLockFileMaintenance } = config;\n\n if (isEmptyArray(updatedDeps) && !isLockFileMaintenance) {\n logger.debug('No updated bun deps - returning null');\n return null;\n }\n\n // Find the first bun dependency in order to handle mixed manager updates,\n // eventually falling back to the first lock file from config.\n const lockFileName =\n updatedDeps.find((dep) => dep.manager === 'bun')?.lockFiles?.[0] ??\n config.lockFiles?.[0];\n\n if (!lockFileName) {\n logger.debug(`bun: No lock file found`);\n return null;\n }\n\n const oldLockFileContent = await readLocalFile(lockFileName);\n if (!oldLockFileContent) {\n logger.debug(`No ${lockFileName} found`);\n return null;\n }\n\n const pkgFileDir = upath.dirname(packageFileName);\n const npmrcContent = await getNpmrcContent(pkgFileDir);\n const { additionalNpmrcContent } = processHostRules();\n await updateNpmrcContent(pkgFileDir, npmrcContent, additionalNpmrcContent);\n\n try {\n await writeLocalFile(packageFileName, newPackageFileContent);\n if (isLockFileMaintenance) {\n await deleteLocalFile(lockFileName);\n }\n\n let cmd = 'bun install';\n\n if (!GlobalConfig.get('allowScripts') || config.ignoreScripts) {\n cmd += ' --ignore-scripts';\n }\n\n const execOptions: ExecOptions = {\n cwdFile: lockFileName,\n docker: {},\n toolConstraints: [\n {\n toolName: 'bun',\n constraint: await resolveToolConstraint(config, 'bun'),\n },\n ],\n };\n\n await exec(cmd, execOptions);\n await resetNpmrcContent(pkgFileDir, npmrcContent);\n\n const newLockFileContent = await readLocalFile(lockFileName);\n if (\n !newLockFileContent ||\n Buffer.compare(oldLockFileContent, newLockFileContent) === 0\n ) {\n return null;\n }\n return [\n {\n file: {\n type: 'addition',\n path: lockFileName,\n contents: newLockFileContent,\n },\n },\n ];\n } catch (err) {\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n logger.warn({ lockfile: lockFileName, err }, `Failed to update lock file`);\n return [\n {\n artifactError: {\n fileName: lockFileName,\n stderr: err.message,\n },\n },\n ];\n }\n}\n"],"mappings":";;;;;;;;;;;AAqBA,eAAsB,gBACpB,gBACyC;CACzC,MAAM,EAAE,iBAAiB,aAAa,uBAAuB,WAC3D;CACF,OAAO,MAAM,uBAAuB,gBAAgB,EAAE;CACtD,MAAM,EAAE,0BAA0B;CAElC,IAAI,aAAa,WAAW,KAAK,CAAC,uBAAuB;EACvD,OAAO,MAAM,sCAAsC;EACnD,OAAO;CACT;CAIA,MAAM,eACJ,YAAY,MAAM,QAAQ,IAAI,YAAY,KAAK,CAAC,EAAE,YAAY,MAC9D,OAAO,YAAY;CAErB,IAAI,CAAC,cAAc;EACjB,OAAO,MAAM,yBAAyB;EACtC,OAAO;CACT;CAEA,MAAM,qBAAqB,MAAM,cAAc,YAAY;CAC3D,IAAI,CAAC,oBAAoB;EACvB,OAAO,MAAM,MAAM,aAAa,OAAO;EACvC,OAAO;CACT;CAEA,MAAM,aAAa,MAAM,QAAQ,eAAe;CAChD,MAAM,eAAe,MAAM,gBAAgB,UAAU;CACrD,MAAM,EAAE,2BAA2B,iBAAiB;CACpD,MAAM,mBAAmB,YAAY,cAAc,sBAAsB;CAEzE,IAAI;EACF,MAAM,eAAe,iBAAiB,qBAAqB;EAC3D,IAAI,uBACF,MAAM,gBAAgB,YAAY;EAGpC,IAAI,MAAM;EAEV,IAAI,CAAC,aAAa,IAAI,cAAc,KAAK,OAAO,eAC9C,OAAO;EAGT,MAAM,cAA2B;GAC/B,SAAS;GACT,QAAQ,CAAC;GACT,iBAAiB,CACf;IACE,UAAU;IACV,YAAY,MAAM,sBAAsB,QAAQ,KAAK;GACvD,CACF;EACF;EAEA,MAAM,KAAK,KAAK,WAAW;EAC3B,MAAM,kBAAkB,YAAY,YAAY;EAEhD,MAAM,qBAAqB,MAAM,cAAc,YAAY;EAC3D,IACE,CAAC,sBACD,OAAO,QAAQ,oBAAoB,kBAAkB,MAAM,GAE3D,OAAO;EAET,OAAO,CACL,EACE,MAAM;GACJ,MAAM;GACN,MAAM;GACN,UAAU;EACZ,EACF,CACF;CACF,SAAS,KAAK;EACZ,IAAI,IAAI,YAAA,mBACN,MAAM;EAER,OAAO,KAAK;GAAE,UAAU;GAAc;EAAI,GAAG,4BAA4B;EACzE,OAAO,CACL,EACE,eAAe;GACb,UAAU;GACV,QAAQ,IAAI;EACd,EACF,CACF;CACF;AACF"}
@@ -70,7 +70,7 @@ async function updateArtifacts(updateArtifact, recursionLimit = 10) {
70
70
  ...variables,
71
71
  ...buildBundleHostVariable(hostRule)
72
72
  }), {});
73
- const bundler = getBundlerConstraint(updateArtifact, existingLockFileContent);
73
+ const bundler = await getBundlerConstraint(updateArtifact, existingLockFileContent);
74
74
  const preCommands = ["ruby --version"];
75
75
  const execOptions = {
76
76
  cwdFile: lockFileName,
@@ -1 +1 @@
1
- {"version":3,"file":"artifacts.js","names":["memCache.get"],"sources":["../../../../lib/modules/manager/bundler/artifacts.ts"],"sourcesContent":["import { isNonEmptyStringAndNotWhitespace, isString } from '@sindresorhus/is';\nimport { quote } from 'shlex';\nimport {\n BUNDLER_INVALID_CREDENTIALS,\n TEMPORARY_ERROR,\n} from '../../../constants/error-messages.ts';\nimport { logger } from '../../../logger/index.ts';\nimport type { HostRule } from '../../../types/index.ts';\nimport * as memCache from '../../../util/cache/memory/index.ts';\nimport { exec } from '../../../util/exec/index.ts';\nimport type { ExecOptions } from '../../../util/exec/types.ts';\nimport {\n ensureCacheDir,\n readLocalFile,\n writeLocalFile,\n} from '../../../util/fs/index.ts';\nimport { getRepoStatus } from '../../../util/git/index.ts';\nimport { newlineRegex, regEx } from '../../../util/regex.ts';\nimport type { UpdateArtifact, UpdateArtifactsResult } from '../types.ts';\nimport {\n getBundlerConstraint,\n getLockFilePath,\n getRubyConstraint,\n} from './common.ts';\nimport {\n findAllAuthenticatable,\n getAuthenticationHeaderValue,\n} from './host-rules.ts';\n\nconst hostConfigVariablePrefix = 'BUNDLE_';\n\nfunction buildBundleHostVariable(hostRule: HostRule): Record<string, string> {\n // istanbul ignore if: doesn't happen in practice\n if (!hostRule.resolvedHost) {\n return {};\n }\n const varName = hostConfigVariablePrefix.concat(\n hostRule.resolvedHost\n .toUpperCase()\n .split('.')\n .join('__')\n .split('-')\n .join('___'),\n );\n return {\n [varName]: `${getAuthenticationHeaderValue(hostRule)}`,\n };\n}\n\nconst resolvedPkgRegex = regEx(\n /(?<pkg>\\S+)(?:\\s*\\([^)]+\\)\\s*)? was resolved to/,\n);\n\nfunction getResolvedPackages(input: string): string[] {\n const lines = input.split(newlineRegex);\n const result: string[] = [];\n for (const line of lines) {\n const resolveMatchGroups = line.match(resolvedPkgRegex)?.groups;\n if (resolveMatchGroups) {\n const { pkg } = resolveMatchGroups;\n result.push(pkg);\n }\n }\n\n return [...new Set(result)];\n}\n\nexport async function updateArtifacts(\n updateArtifact: UpdateArtifact,\n recursionLimit = 10,\n): Promise<UpdateArtifactsResult[] | null> {\n const { packageFileName, updatedDeps, newPackageFileContent, config } =\n updateArtifact;\n logger.debug(`bundler.updateArtifacts(${packageFileName})`);\n const existingError = memCache.get<string>('bundlerArtifactsError');\n // istanbul ignore if\n if (existingError) {\n logger.debug('Aborting Bundler artifacts due to previous failed attempt');\n throw new Error(existingError);\n }\n const lockFileName = await getLockFilePath(packageFileName);\n const existingLockFileContent = await readLocalFile(lockFileName, 'utf8');\n if (!existingLockFileContent) {\n logger.debug('No Gemfile.lock found');\n return null;\n }\n\n const updatedDepNames: string[] = updatedDeps\n .map(({ depName }) => depName)\n .filter(isNonEmptyStringAndNotWhitespace);\n\n try {\n await writeLocalFile(packageFileName, newPackageFileContent);\n\n const commands: string[] = [];\n\n if (config.isLockFileMaintenance) {\n commands.push('bundler lock --update');\n } else {\n const bundlerUpgraded = updatedDeps\n .map((dep) => dep.depName)\n .includes('bundler');\n if (bundlerUpgraded) {\n commands.push('bundler lock --update --bundler');\n }\n\n const updateTypes = {\n patch: '--patch ',\n minor: '--minor ',\n major: '',\n };\n for (const [updateType, updateArg] of Object.entries(updateTypes)) {\n const deps = updatedDeps\n .filter((dep) => (dep.updateType ?? 'major') === updateType)\n .map((dep) => dep.depName)\n .filter(isString)\n .filter((dep) => dep !== 'ruby' && dep !== 'bundler');\n let additionalArgs = '';\n if (config.postUpdateOptions?.includes('bundlerConservative')) {\n additionalArgs = '--conservative ';\n }\n if (deps.length) {\n const cmd = `bundler lock ${updateArg}${additionalArgs}--update ${deps\n .map(quote)\n .join(' ')}`;\n commands.push(cmd);\n }\n }\n\n const rubyUpgraded = updatedDeps\n .map((dep) => dep.depName)\n .includes('ruby');\n if (rubyUpgraded) {\n commands.push('bundler lock');\n }\n }\n\n const bundlerHostRules = findAllAuthenticatable({\n hostType: 'rubygems',\n });\n\n const bundlerHostRulesVariables = bundlerHostRules.reduce(\n (variables, hostRule) => ({\n ...variables,\n ...buildBundleHostVariable(hostRule),\n }),\n {} as Record<string, string>,\n );\n\n const bundler = getBundlerConstraint(\n updateArtifact,\n existingLockFileContent,\n );\n const preCommands = ['ruby --version'];\n\n const execOptions: ExecOptions = {\n cwdFile: lockFileName,\n extraEnv: {\n ...bundlerHostRulesVariables,\n GEM_HOME: await ensureCacheDir('bundler'),\n },\n docker: {},\n toolConstraints: [\n {\n toolName: 'ruby',\n constraint: await getRubyConstraint(updateArtifact),\n },\n {\n toolName: 'bundler',\n constraint: bundler,\n },\n ],\n preCommands,\n };\n await exec(commands, execOptions);\n\n const status = await getRepoStatus();\n if (!status.modified.includes(lockFileName)) {\n return null;\n }\n logger.debug('Returning updated Gemfile.lock');\n const lockFileContent = await readLocalFile(lockFileName);\n return [\n {\n file: {\n type: 'addition',\n path: lockFileName,\n contents: lockFileContent,\n },\n },\n ];\n } catch (err) {\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n const output = `${String(err.stdout)}\\n${String(err.stderr)}`;\n if (\n err.message.includes('fatal: Could not parse object') ||\n output.includes('but that version could not be found')\n ) {\n return [\n {\n artifactError: {\n fileName: lockFileName,\n stderr: output,\n },\n },\n ];\n }\n if (\n err.stdout?.includes('Please supply credentials for this source') ||\n err.stderr?.includes('Authentication is required') ||\n err.stderr?.includes(\n 'Please make sure you have the correct access rights',\n )\n ) {\n logger.debug(\n { err },\n 'Gemfile.lock update failed due to missing credentials - skipping branch',\n );\n // Do not generate these PRs because we don't yet support Bundler authentication\n memCache.set('bundlerArtifactsError', BUNDLER_INVALID_CREDENTIALS);\n throw new Error(BUNDLER_INVALID_CREDENTIALS);\n }\n const resolveMatches: string[] = getResolvedPackages(output).filter(\n (depName) => !updatedDepNames.includes(depName),\n );\n if (\n recursionLimit > 0 &&\n resolveMatches.length &&\n !config.isLockFileMaintenance\n ) {\n logger.debug(\n { resolveMatches, updatedDeps },\n 'Found new resolve matches - reattempting recursively',\n );\n const newUpdatedDeps = [\n ...new Set([\n ...updatedDeps,\n ...resolveMatches.map((match) => ({ depName: match })),\n ]),\n ];\n return updateArtifacts(\n {\n packageFileName,\n updatedDeps: newUpdatedDeps,\n newPackageFileContent,\n config,\n },\n recursionLimit - 1,\n );\n }\n\n logger.info({ err }, 'Gemfile.lock update failed due to an unknown reason');\n return [\n {\n artifactError: {\n fileName: lockFileName,\n stderr: `${String(err.stdout)}\\n${String(err.stderr)}`,\n },\n },\n ];\n }\n}\n"],"mappings":";;;;;;;;;;;;AA6BA,MAAM,2BAA2B;AAEjC,SAAS,wBAAwB,UAA4C;;CAE3E,IAAI,CAAC,SAAS,cACZ,OAAO,CAAC;CAUV,OAAO,GARS,yBAAyB,OACvC,SAAS,aACN,YAAY,CAAC,CACb,MAAM,GAAG,CAAC,CACV,KAAK,IAAI,CAAC,CACV,MAAM,GAAG,CAAC,CACV,KAAK,KAAK,CAGN,IAAI,GAAG,6BAA6B,QAAQ,IACrD;AACF;AAEA,MAAM,mBAAmB,MACvB,iDACF;AAEA,SAAS,oBAAoB,OAAyB;CACpD,MAAM,QAAQ,MAAM,MAAM,YAAY;CACtC,MAAM,SAAmB,CAAC;CAC1B,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,qBAAqB,KAAK,MAAM,gBAAgB,CAAC,EAAE;EACzD,IAAI,oBAAoB;GACtB,MAAM,EAAE,QAAQ;GAChB,OAAO,KAAK,GAAG;EACjB;CACF;CAEA,OAAO,CAAC,GAAG,IAAI,IAAI,MAAM,CAAC;AAC5B;AAEA,eAAsB,gBACpB,gBACA,iBAAiB,IACwB;CACzC,MAAM,EAAE,iBAAiB,aAAa,uBAAuB,WAC3D;CACF,OAAO,MAAM,2BAA2B,gBAAgB,EAAE;CAC1D,MAAM,gBAAgBA,IAAqB,uBAAuB;;CAElE,IAAI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E;IACA,aAAa,CARf,mBAAG,IAAI,IAAI,CACT,GAAG,aACH,GAAG,eAAe,KAAK,WAAW,EAAE,SAAS,MAAM,EAAE,CACvD,CAAC,CAK2B;IAC1B;IACA;GACF,GACA,iBAAiB,CACnB;EACF;EAEA,OAAO,KAAK,EAAE,IAAI,GAAG,qDAAqD;EAC1E,OAAO,CACL,EACE,eAAe;GACb,UAAU;GACV,QAAQ,GAAG,OAAO,IAAI,MAAM,EAAE,IAAI,OAAO,IAAI,MAAM;EACrD,EACF,CACF;CACF;AACF"}
1
+ {"version":3,"file":"artifacts.js","names":["memCache.get"],"sources":["../../../../lib/modules/manager/bundler/artifacts.ts"],"sourcesContent":["import { isNonEmptyStringAndNotWhitespace, isString } from '@sindresorhus/is';\nimport { quote } from 'shlex';\nimport {\n BUNDLER_INVALID_CREDENTIALS,\n TEMPORARY_ERROR,\n} from '../../../constants/error-messages.ts';\nimport { logger } from '../../../logger/index.ts';\nimport type { HostRule } from '../../../types/index.ts';\nimport * as memCache from '../../../util/cache/memory/index.ts';\nimport { exec } from '../../../util/exec/index.ts';\nimport type { ExecOptions } from '../../../util/exec/types.ts';\nimport {\n ensureCacheDir,\n readLocalFile,\n writeLocalFile,\n} from '../../../util/fs/index.ts';\nimport { getRepoStatus } from '../../../util/git/index.ts';\nimport { newlineRegex, regEx } from '../../../util/regex.ts';\nimport type { UpdateArtifact, UpdateArtifactsResult } from '../types.ts';\nimport {\n getBundlerConstraint,\n getLockFilePath,\n getRubyConstraint,\n} from './common.ts';\nimport {\n findAllAuthenticatable,\n getAuthenticationHeaderValue,\n} from './host-rules.ts';\n\nconst hostConfigVariablePrefix = 'BUNDLE_';\n\nfunction buildBundleHostVariable(hostRule: HostRule): Record<string, string> {\n // istanbul ignore if: doesn't happen in practice\n if (!hostRule.resolvedHost) {\n return {};\n }\n const varName = hostConfigVariablePrefix.concat(\n hostRule.resolvedHost\n .toUpperCase()\n .split('.')\n .join('__')\n .split('-')\n .join('___'),\n );\n return {\n [varName]: `${getAuthenticationHeaderValue(hostRule)}`,\n };\n}\n\nconst resolvedPkgRegex = regEx(\n /(?<pkg>\\S+)(?:\\s*\\([^)]+\\)\\s*)? was resolved to/,\n);\n\nfunction getResolvedPackages(input: string): string[] {\n const lines = input.split(newlineRegex);\n const result: string[] = [];\n for (const line of lines) {\n const resolveMatchGroups = line.match(resolvedPkgRegex)?.groups;\n if (resolveMatchGroups) {\n const { pkg } = resolveMatchGroups;\n result.push(pkg);\n }\n }\n\n return [...new Set(result)];\n}\n\nexport async function updateArtifacts(\n updateArtifact: UpdateArtifact,\n recursionLimit = 10,\n): Promise<UpdateArtifactsResult[] | null> {\n const { packageFileName, updatedDeps, newPackageFileContent, config } =\n updateArtifact;\n logger.debug(`bundler.updateArtifacts(${packageFileName})`);\n const existingError = memCache.get<string>('bundlerArtifactsError');\n // istanbul ignore if\n if (existingError) {\n logger.debug('Aborting Bundler artifacts due to previous failed attempt');\n throw new Error(existingError);\n }\n const lockFileName = await getLockFilePath(packageFileName);\n const existingLockFileContent = await readLocalFile(lockFileName, 'utf8');\n if (!existingLockFileContent) {\n logger.debug('No Gemfile.lock found');\n return null;\n }\n\n const updatedDepNames: string[] = updatedDeps\n .map(({ depName }) => depName)\n .filter(isNonEmptyStringAndNotWhitespace);\n\n try {\n await writeLocalFile(packageFileName, newPackageFileContent);\n\n const commands: string[] = [];\n\n if (config.isLockFileMaintenance) {\n commands.push('bundler lock --update');\n } else {\n const bundlerUpgraded = updatedDeps\n .map((dep) => dep.depName)\n .includes('bundler');\n if (bundlerUpgraded) {\n commands.push('bundler lock --update --bundler');\n }\n\n const updateTypes = {\n patch: '--patch ',\n minor: '--minor ',\n major: '',\n };\n for (const [updateType, updateArg] of Object.entries(updateTypes)) {\n const deps = updatedDeps\n .filter((dep) => (dep.updateType ?? 'major') === updateType)\n .map((dep) => dep.depName)\n .filter(isString)\n .filter((dep) => dep !== 'ruby' && dep !== 'bundler');\n let additionalArgs = '';\n if (config.postUpdateOptions?.includes('bundlerConservative')) {\n additionalArgs = '--conservative ';\n }\n if (deps.length) {\n const cmd = `bundler lock ${updateArg}${additionalArgs}--update ${deps\n .map(quote)\n .join(' ')}`;\n commands.push(cmd);\n }\n }\n\n const rubyUpgraded = updatedDeps\n .map((dep) => dep.depName)\n .includes('ruby');\n if (rubyUpgraded) {\n commands.push('bundler lock');\n }\n }\n\n const bundlerHostRules = findAllAuthenticatable({\n hostType: 'rubygems',\n });\n\n const bundlerHostRulesVariables = bundlerHostRules.reduce(\n (variables, hostRule) => ({\n ...variables,\n ...buildBundleHostVariable(hostRule),\n }),\n {} as Record<string, string>,\n );\n\n const bundler = await getBundlerConstraint(\n updateArtifact,\n existingLockFileContent,\n );\n const preCommands = ['ruby --version'];\n\n const execOptions: ExecOptions = {\n cwdFile: lockFileName,\n extraEnv: {\n ...bundlerHostRulesVariables,\n GEM_HOME: await ensureCacheDir('bundler'),\n },\n docker: {},\n toolConstraints: [\n {\n toolName: 'ruby',\n constraint: await getRubyConstraint(updateArtifact),\n },\n {\n toolName: 'bundler',\n constraint: bundler,\n },\n ],\n preCommands,\n };\n await exec(commands, execOptions);\n\n const status = await getRepoStatus();\n if (!status.modified.includes(lockFileName)) {\n return null;\n }\n logger.debug('Returning updated Gemfile.lock');\n const lockFileContent = await readLocalFile(lockFileName);\n return [\n {\n file: {\n type: 'addition',\n path: lockFileName,\n contents: lockFileContent,\n },\n },\n ];\n } catch (err) {\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n const output = `${String(err.stdout)}\\n${String(err.stderr)}`;\n if (\n err.message.includes('fatal: Could not parse object') ||\n output.includes('but that version could not be found')\n ) {\n return [\n {\n artifactError: {\n fileName: lockFileName,\n stderr: output,\n },\n },\n ];\n }\n if (\n err.stdout?.includes('Please supply credentials for this source') ||\n err.stderr?.includes('Authentication is required') ||\n err.stderr?.includes(\n 'Please make sure you have the correct access rights',\n )\n ) {\n logger.debug(\n { err },\n 'Gemfile.lock update failed due to missing credentials - skipping branch',\n );\n // Do not generate these PRs because we don't yet support Bundler authentication\n memCache.set('bundlerArtifactsError', BUNDLER_INVALID_CREDENTIALS);\n throw new Error(BUNDLER_INVALID_CREDENTIALS);\n }\n const resolveMatches: string[] = getResolvedPackages(output).filter(\n (depName) => !updatedDepNames.includes(depName),\n );\n if (\n recursionLimit > 0 &&\n resolveMatches.length &&\n !config.isLockFileMaintenance\n ) {\n logger.debug(\n { resolveMatches, updatedDeps },\n 'Found new resolve matches - reattempting recursively',\n );\n const newUpdatedDeps = [\n ...new Set([\n ...updatedDeps,\n ...resolveMatches.map((match) => ({ depName: match })),\n ]),\n ];\n return updateArtifacts(\n {\n packageFileName,\n updatedDeps: newUpdatedDeps,\n newPackageFileContent,\n config,\n },\n recursionLimit - 1,\n );\n }\n\n logger.info({ err }, 'Gemfile.lock update failed due to an unknown reason');\n return [\n {\n artifactError: {\n fileName: lockFileName,\n stderr: `${String(err.stdout)}\\n${String(err.stderr)}`,\n },\n },\n ];\n }\n}\n"],"mappings":";;;;;;;;;;;;AA6BA,MAAM,2BAA2B;AAEjC,SAAS,wBAAwB,UAA4C;;CAE3E,IAAI,CAAC,SAAS,cACZ,OAAO,CAAC;CAUV,OAAO,GARS,yBAAyB,OACvC,SAAS,aACN,YAAY,CAAC,CACb,MAAM,GAAG,CAAC,CACV,KAAK,IAAI,CAAC,CACV,MAAM,GAAG,CAAC,CACV,KAAK,KAAK,CAGN,IAAI,GAAG,6BAA6B,QAAQ,IACrD;AACF;AAEA,MAAM,mBAAmB,MACvB,iDACF;AAEA,SAAS,oBAAoB,OAAyB;CACpD,MAAM,QAAQ,MAAM,MAAM,YAAY;CACtC,MAAM,SAAmB,CAAC;CAC1B,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,qBAAqB,KAAK,MAAM,gBAAgB,CAAC,EAAE;EACzD,IAAI,oBAAoB;GACtB,MAAM,EAAE,QAAQ;GAChB,OAAO,KAAK,GAAG;EACjB;CACF;CAEA,OAAO,CAAC,GAAG,IAAI,IAAI,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AM,iBAA2B,oBAAoB,MAAM,CAAC,CAAC,QAC1D,YAAY,CAAC,gBAAgB,SAAS,OAAO,CAChD;EACA,IACE,iBAAiB,KACjB,eAAe,UACf,CAAC,OAAO,uBACR;GACA,OAAO,MACL;IAAE;IAAgB;GAAY,GAC9B,sDACF;GAOA,OAAO,gBACL;IACE;IACA,aAAa,CARf,mBAAG,IAAI,IAAI,CACT,GAAG,aACH,GAAG,eAAe,KAAK,WAAW,EAAE,SAAS,MAAM,EAAE,CACvD,CAAC,CAK2B;IAC1B;IACA;GACF,GACA,iBAAiB,CACnB;EACF;EAEA,OAAO,KAAK,EAAE,IAAI,GAAG,qDAAqD;EAC1E,OAAO,CACL,EACE,eAAe;GACb,UAAU;GACV,QAAQ,GAAG,OAAO,IAAI,MAAM,EAAE,IAAI,OAAO,IAAI,MAAM;EACrD,EACF,CACF;CACF;AACF"}
@@ -1,6 +1,7 @@
1
1
  import { regEx } from "../../../util/regex.js";
2
2
  import { logger } from "../../../logger/index.js";
3
3
  import { getSiblingFileName, localPathExists, readLocalFile } from "../../../util/fs/index.js";
4
+ import { resolveToolConstraint } from "../util.js";
4
5
  //#region lib/modules/manager/bundler/common.ts
5
6
  const delimiters = ["\"", "'"];
6
7
  function extractRubyVersion(txt) {
@@ -9,14 +10,7 @@ function extractRubyVersion(txt) {
9
10
  const quotedVersion = rubyMatch.groups.version;
10
11
  return quotedVersion.substring(1, quotedVersion.length - 1);
11
12
  }
12
- async function getRubyConstraint(updateArtifact) {
13
- const { packageFileName, config, newPackageFileContent } = updateArtifact;
14
- const { constraints = {} } = config;
15
- const { ruby } = constraints;
16
- if (ruby) {
17
- logger.debug("Using ruby constraint from config");
18
- return ruby;
19
- }
13
+ async function getRubyConstraintFromFiles(packageFileName, newPackageFileContent) {
20
14
  const rubyMatch = extractRubyVersion(newPackageFileContent);
21
15
  if (rubyMatch) {
22
16
  logger.debug("Using ruby version from gemfile");
@@ -39,14 +33,11 @@ async function getRubyConstraint(updateArtifact) {
39
33
  }
40
34
  return null;
41
35
  }
42
- function getBundlerConstraint(updateArtifact, existingLockFileContent) {
43
- const { config } = updateArtifact;
44
- const { constraints = {} } = config;
45
- const { bundler } = constraints;
46
- if (bundler) {
47
- logger.debug("Using bundler constraint from config");
48
- return bundler;
49
- }
36
+ async function getRubyConstraint(updateArtifact) {
37
+ const { packageFileName, config, newPackageFileContent } = updateArtifact;
38
+ return await resolveToolConstraint(config, "ruby", () => getRubyConstraintFromFiles(packageFileName, newPackageFileContent));
39
+ }
40
+ function getBundlerConstraintFromLockFile(existingLockFileContent) {
50
41
  const bundledWith = regEx(/\nBUNDLED WITH\n\s+(?<version>.*?)(?:\n|$)/).exec(existingLockFileContent);
51
42
  if (bundledWith) {
52
43
  logger.debug("Using bundler version specified in lockfile");
@@ -54,6 +45,10 @@ function getBundlerConstraint(updateArtifact, existingLockFileContent) {
54
45
  }
55
46
  return null;
56
47
  }
48
+ async function getBundlerConstraint(updateArtifact, existingLockFileContent) {
49
+ const { config } = updateArtifact;
50
+ return await resolveToolConstraint(config, "bundler", () => getBundlerConstraintFromLockFile(existingLockFileContent));
51
+ }
57
52
  async function getLockFilePath(packageFilePath) {
58
53
  const lockFilePath = await localPathExists(`${packageFilePath}.lock`) ? `${packageFilePath}.lock` : `Gemfile.lock`;
59
54
  logger.debug(`Lockfile for ${packageFilePath} found in ${lockFilePath}`);
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","names":[],"sources":["../../../../lib/modules/manager/bundler/common.ts"],"sourcesContent":["import { logger } from '../../../logger/index.ts';\nimport {\n getSiblingFileName,\n localPathExists,\n readLocalFile,\n} from '../../../util/fs/index.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport type { UpdateArtifact } from '../types.ts';\n\nexport const delimiters = ['\"', \"'\"];\n\nexport function extractRubyVersion(txt: string): string | null {\n const rubyMatch = regEx(/^ruby\\s+(?<version>\"[^\"]+\"|'[^']+')\\s*$/gm).exec(\n txt,\n );\n if (!rubyMatch?.groups) {\n return null;\n }\n const quotedVersion = rubyMatch.groups.version;\n return quotedVersion.substring(1, quotedVersion.length - 1);\n}\n\nexport async function getRubyConstraint(\n updateArtifact: UpdateArtifact,\n): Promise<string | null> {\n const { packageFileName, config, newPackageFileContent } = updateArtifact;\n const { constraints = {} } = config;\n const { ruby } = constraints;\n\n if (ruby) {\n logger.debug('Using ruby constraint from config');\n return ruby;\n }\n const rubyMatch = extractRubyVersion(newPackageFileContent);\n if (rubyMatch) {\n logger.debug('Using ruby version from gemfile');\n return rubyMatch;\n }\n for (const file of ['.ruby-version', '.tool-versions']) {\n const rubyVersion = (\n await readLocalFile(getSiblingFileName(packageFileName, file), 'utf8')\n )?.match(regEx(/^(?:ruby(?:-|\\s+))?(?<version>\\d[\\d.]*)/m))?.groups\n ?.version;\n if (rubyVersion) {\n logger.debug(`Using ruby version specified in ${file}`);\n return rubyVersion;\n }\n }\n const lockFile = await getLockFilePath(packageFileName);\n if (lockFile) {\n const rubyVersion = (await readLocalFile(lockFile, 'utf8'))?.match(\n regEx(/^ {3}ruby (?<version>\\d[\\d.]*)(?:[a-z]|\\s|$)/m),\n )?.groups?.version;\n if (rubyVersion) {\n logger.debug(`Using ruby version specified in lock file`);\n return rubyVersion;\n }\n }\n\n return null;\n}\n\nexport function getBundlerConstraint(\n updateArtifact: Pick<UpdateArtifact, 'config'>,\n existingLockFileContent: string,\n): string | null {\n const { config } = updateArtifact;\n const { constraints = {} } = config;\n const { bundler } = constraints;\n\n if (bundler) {\n logger.debug('Using bundler constraint from config');\n return bundler;\n }\n const bundledWith = regEx(/\\nBUNDLED WITH\\n\\s+(?<version>.*?)(?:\\n|$)/).exec(\n existingLockFileContent,\n );\n if (bundledWith) {\n logger.debug('Using bundler version specified in lockfile');\n return bundledWith.groups!.version;\n }\n\n return null;\n}\n\nexport async function getLockFilePath(\n packageFilePath: string,\n): Promise<string> {\n const lockFilePath = (await localPathExists(`${packageFilePath}.lock`))\n ? `${packageFilePath}.lock`\n : `Gemfile.lock`;\n logger.deb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M,sCAAsC;EACnD,OAAO;CACT;CACA,MAAM,cAAc,MAAM,4CAA4C,CAAC,CAAC,KACtE,uBACF;CACA,IAAI,aAAa;EACf,OAAO,MAAM,6CAA6C;EAC1D,OAAO,YAAY,OAAQ;CAC7B;CAEA,OAAO;AACT;AAEA,eAAsB,gBACpB,iBACiB;CACjB,MAAM,eAAgB,MAAM,gBAAgB,GAAG,gBAAgB,MAAM,IACjE,GAAG,gBAAgB,SACnB;CACJ,OAAO,MAAM,gBAAgB,gBAAgB,YAAY,cAAc;CACvE,OAAO;AACT"}
1
+ {"version":3,"file":"common.js","names":[],"sources":["../../../../lib/modules/manager/bundler/common.ts"],"sourcesContent":["import { logger } from '../../../logger/index.ts';\nimport {\n getSiblingFileName,\n localPathExists,\n readLocalFile,\n} from '../../../util/fs/index.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport type { UpdateArtifact } from '../types.ts';\nimport { resolveToolConstraint } from '../util.ts';\n\nexport const delimiters = ['\"', \"'\"];\n\nexport function extractRubyVersion(txt: string): string | null {\n const rubyMatch = regEx(/^ruby\\s+(?<version>\"[^\"]+\"|'[^']+')\\s*$/gm).exec(\n txt,\n );\n if (!rubyMatch?.groups) {\n return null;\n }\n const quotedVersion = rubyMatch.groups.version;\n return quotedVersion.substring(1, quotedVersion.length - 1);\n}\n\nasync function getRubyConstraintFromFiles(\n packageFileName: string,\n newPackageFileContent: string,\n): Promise<string | null> {\n const rubyMatch = extractRubyVersion(newPackageFileContent);\n if (rubyMatch) {\n logger.debug('Using ruby version from gemfile');\n return rubyMatch;\n }\n for (const file of ['.ruby-version', '.tool-versions']) {\n const rubyVersion = (\n await readLocalFile(getSiblingFileName(packageFileName, file), 'utf8')\n )?.match(regEx(/^(?:ruby(?:-|\\s+))?(?<version>\\d[\\d.]*)/m))?.groups\n ?.version;\n if (rubyVersion) {\n logger.debug(`Using ruby version specified in ${file}`);\n return rubyVersion;\n }\n }\n const lockFile = await getLockFilePath(packageFileName);\n if (lockFile) {\n const rubyVersion = (await readLocalFile(lockFile, 'utf8'))?.match(\n regEx(/^ {3}ruby (?<version>\\d[\\d.]*)(?:[a-z]|\\s|$)/m),\n )?.groups?.version;\n if (rubyVersion) {\n logger.debug(`Using ruby version specified in lock file`);\n return rubyVersion;\n }\n }\n\n return null;\n}\n\nexport async function getRubyConstraint(\n updateArtifact: UpdateArtifact,\n): Promise<string | undefined> {\n const { packageFileName, config, newPackageFileContent } = updateArtifact;\n return await resolveToolConstraint(config, 'ruby', () =>\n getRubyConstraintFromFiles(packageFileName, newPackageFileContent),\n );\n}\n\nfunction getBundlerConstraintFromLockFile(\n existingLockFileContent: string,\n): string | null {\n const bundledWith = regEx(/\\nBUNDLED WITH\\n\\s+(?<version>.*?)(?:\\n|$)/).exec(\n existingLockFileContent,\n );\n if (bundledWith) {\n logger.debug('Using bundler version specified in lockfile');\n return bundledWith.groups!.version;\n }\n\n return null;\n}\n\nexport async function getBundlerConstraint(\n updateArtifact: Pick<UpdateArtifact, 'config'>,\n existingLockFileContent: string,\n): Promise<string | undefined> {\n const { config } = updateArtifact;\n return await resolveToolConstraint(config, 'bundler', () =>\n getBundlerConstraintFromLockFile(existingLockFileContent),\n );\n}\n\nexport async function getLockFilePath(\n packageFilePath: string,\n): Promise<string> {\n const lockFilePath = (await localPathExists(`${packageFilePath}.lock`))\n ? `${packageFilePath}.lock`\n : `Gemfile.lock`;\n logger.debug(`Lockfile for ${packageFilePath} found in ${lockFilePath}`);\n return lockFilePath;\n}\n"],"mappings":";;;;;AAUA,MAAa,aAAa,CAAC,MAAK,GAAG;AAEnC,SAAgB,mBAAmB,KAA4B;CAC7D,MAAM,YAAY,MAAM,2CAA2C,CAAC,CAAC,KACnE,GACF;CACA,IAAI,CAAC,WAAW,QACd,OAAO;CAET,MAAM,gBAAgB,UAAU,OAAO;CACvC,OAAO,cAAc,UAAU,GAAG,cAAc,SAAS,CAAC;AAC5D;AAEA,eAAe,2BACb,iBACA,uBACwB;CACxB,MAAM,YAAY,mBAAm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{ logger } from "../../../logger/index.js";
5
5
  import { findLocalSiblingOrParent, readLocalFile, writeLocalFile } from "../../../util/fs/index.js";
6
6
  import { CrateDatasource } from "../../datasource/crate/index.js";
7
+ import { resolveToolConstraint } from "../util.js";
7
8
  import { withGitEnvironment } from "../../../util/git/exec.js";
8
9
  import { extractLockFileContentVersions } from "./locked-version.js";
9
10
  import { quote } from "shlex";
@@ -55,17 +56,18 @@ async function updateArtifactsImpl({ packageFileName, updatedDeps, newPackageFil
55
56
  contents: existingLockFileContent
56
57
  } }];
57
58
  }
59
+ const rustConstraint = await resolveToolConstraint(config, "rust");
58
60
  try {
59
61
  await writeLocalFile(packageFileName, newPackageFileContent);
60
62
  logger.debug(`Updating ${lockFileName}`);
61
- if (isLockFileMaintenance) await cargoUpdate(packageFileName, true, config.constraints?.rust);
63
+ if (isLockFileMaintenance) await cargoUpdate(packageFileName, true, rustConstraint);
62
64
  else {
63
65
  const hasNonCrateDep = updatedDeps.some((dep) => dep.datasource !== CrateDatasource.id);
64
66
  const crateDepWithoutLockedVersion = updatedDeps.find((dep) => !dep.lockedVersion && dep.datasource === CrateDatasource.id);
65
67
  if (hasNonCrateDep || crateDepWithoutLockedVersion) {
66
68
  if (crateDepWithoutLockedVersion) logger.warn({ dependency: crateDepWithoutLockedVersion.depName }, "Missing locked version for dependency");
67
- await cargoUpdate(packageFileName, false, config.constraints?.rust);
68
- } else await cargoUpdatePrecise(packageFileName, updatedDeps, config.constraints?.rust);
69
+ await cargoUpdate(packageFileName, false, rustConstraint);
70
+ } else await cargoUpdatePrecise(packageFileName, updatedDeps, rustConstraint);
69
71
  }
70
72
  logger.debug("Returning updated Cargo.lock");
71
73
  const newCargoLockContent = await readLocalFile(lockFileName);
@@ -1 +1 @@
1
- {"version":3,"file":"artifacts.js","names":[],"sources":["../../../../lib/modules/manager/cargo/artifacts.ts"],"sourcesContent":["import { quote } from 'shlex';\nimport { TEMPORARY_ERROR } from '../../../constants/error-messages.ts';\nimport { logger } from '../../../logger/index.ts';\nimport { coerceArray } from '../../../util/array.ts';\nimport type { ExecOptions } from '../../../util/exec/types.ts';\nimport {\n findLocalSiblingOrParent,\n readLocalFile,\n writeLocalFile,\n} from '../../../util/fs/index.ts';\nimport { withGitEnvironment } from '../../../util/git/exec.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { CrateDatasource } from '../../datasource/crate/index.ts';\nimport type {\n UpdateArtifact,\n UpdateArtifactsResult,\n Upgrade,\n} from '../types.ts';\nimport { extractLockFileContentVersions } from './locked-version.ts';\n\nconst gitExec = withGitEnvironment(['cargo']);\n\nasync function cargoUpdate(\n manifestPath: string,\n isLockFileMaintenance: boolean,\n constraint: string | undefined,\n): Promise<void> {\n let cmd = `cargo update --config net.git-fetch-with-cli=true --manifest-path ${quote(\n manifestPath,\n )}`;\n // If we're updating a specific crate, `cargo-update` requires `--workspace`\n // for more information, see: https://github.com/renovatebot/renovate/issues/12332\n if (!isLockFileMaintenance) {\n cmd += ` --workspace`;\n }\n\n const execOptions: ExecOptions = {\n docker: {},\n toolConstraints: [{ toolName: 'rust', constraint }],\n };\n await gitExec(cmd, execOptions);\n}\n\nasync function cargoUpdatePrecise(\n manifestPath: string,\n updatedDeps: Upgrade[],\n constraint: string | undefined,\n): Promise<void> {\n const cmds = [];\n\n // First update individual dependencies to their `newVersion`. Necessary when\n // using the `update-lockfile` rangeStrategy which doesn't touch Cargo.toml.\n for (const dep of updatedDeps) {\n // If the range is bumped in Cargo.toml, the old lockedVersion may no longer\n // exist in Cargo's dependency graph, so let the --workspace update at the\n // end re-resolve it instead.\n if (dep.currentValue && dep.newValue && dep.currentValue !== dep.newValue) {\n continue;\n }\n\n cmds.push(\n `cargo update --config net.git-fetch-with-cli=true` +\n ` --manifest-path ${quote(manifestPath)}` +\n ` --package ${quote(`${dep.packageName}@${dep.lockedVersion}`)}` +\n ` --precise ${quote(dep.newVersion!)}`,\n );\n }\n\n // Then update all dependencies that have been bumped in `Cargo.toml`.\n cmds.push(\n `cargo update --config net.git-fetch-with-cli=true --manifest-path ${quote(manifestPath)} --workspace`,\n );\n\n const execOptions: ExecOptions = {\n docker: {},\n toolConstraints: [{ toolName: 'rust', constraint }],\n };\n\n await gitExec(cmds, execOptions);\n}\n\nexport async function updateArtifacts(\n updateArtifact: UpdateArtifact,\n): Promise<UpdateArtifactsResult[] | null> {\n return await updateArtifactsImpl(updateArtifact);\n}\n\nasync function updateArtifactsImpl(\n {\n packageFileName,\n updatedDeps,\n newPackageFileContent,\n config,\n }: UpdateArtifact,\n recursionLimit = 10,\n): Promise<UpdateArtifactsResult[] | null> {\n logger.debug(`cargo.updateArtifacts(${packageFileName})`);\n\n // For standalone package crates, the `Cargo.lock` will be in the same\n // directory as `Cargo.toml` (ie. a sibling). For cargo workspaces, it\n // will be further up.\n const lockFileName = await findLocalSiblingOrParent(\n packageFileName,\n 'Cargo.lock',\n );\n const existingLockFileContent = lockFileName\n ? await readLocalFile(lockFileName)\n : null;\n if (!existingLockFileContent || !lockFileName) {\n logger.debug('No Cargo.lock found');\n return null;\n }\n\n const { isLockFileMaintenance } = config;\n if (!isLockFileMaintenance && !updatedDeps?.length) {\n logger.debug('No more dependencies to update');\n return [\n {\n file: {\n type: 'addition',\n path: lockFileName,\n contents: existingLockFileContent,\n },\n },\n ];\n }\n\n try {\n await writeLocalFile(packageFileName, newPackageFileContent);\n logger.debug(`Updating ${lockFileName}`);\n\n if (isLockFileMaintenance) {\n await cargoUpdate(packageFileName, true, config.constraints?.rust);\n } else {\n const hasNonCrateDep = updatedDeps.some(\n (dep) => dep.datasource !== CrateDatasource.id,\n );\n const crateDepWithoutLockedVersion = updatedDeps.find(\n (dep) => !dep.lockedVersion && dep.datasource === CrateDatasource.id,\n );\n // Non-crate dependencies (like git ones) do not have locked versions.\n // For crate dependencies, a locked version is expected.\n // In both situations, perform a regular workspace lockfile update.\n if (hasNonCrateDep || crateDepWithoutLockedVersion) {\n if (crateDepWithoutLockedVersion) {\n // Only warn when a crate dependency has no locked version\n logger.warn(\n { dependency: crateDepWithoutLockedVersion.depName },\n 'Missing locked version for dependency',\n );\n }\n await cargoUpdate(packageFileName, false, config.constraints?.rust);\n } else {\n // If all dependencies have locked versions then update them precisely.\n await cargoUpdatePrecise(\n packageFileName,\n updatedDeps,\n config.constraints?.rust,\n );\n }\n }\n\n logger.debug('Returning updated Cargo.lock');\n const newCargoLockContent = await readLocalFile(lockFileName);\n if (existingLockFileContent === newCargoLockContent) {\n logger.debug('Cargo.lock is unchanged');\n return null;\n }\n return [\n {\n file: {\n type: 'addition',\n path: lockFileName,\n contents: newCargoLockContent,\n },\n },\n ];\n } catch (err) {\n // istanbul ignore if\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n\n // Sometimes `cargo update` will fail when a preceding dependency update\n // causes another dependency to update. In this case we can no longer\n // reference the dependency by its old version, so we filter it out\n // and retry recursively.\n const newCargoLockContent = await readLocalFile(lockFileName, 'utf8');\n if (\n recursionLimit > 0 &&\n newCargoLockContent &&\n regEx(/error: package ID specification/).test(err.stderr)\n ) {\n const versions = extractLockFileContentVersions(newCargoLockContent);\n const newUpdatedDeps = updatedDeps.filter(\n (dep) =>\n !coerceArray(versions?.get(dep.packageName!)).includes(\n dep.newVersion!,\n ),\n );\n\n if (newUpdatedDeps.length < updatedDeps.length) {\n logger.debug(\n 'Dependency already up to date - reattempting recursively',\n );\n return updateArtifactsImpl(\n {\n packageFileName,\n updatedDeps: newUpdatedDeps,\n newPackageFileContent,\n config,\n },\n recursionLimit - 1,\n );\n }\n }\n\n logger.debug({ err }, 'Failed to update Cargo lock file');\n\n return [\n {\n artifactError: {\n fileName: lockFileName,\n stderr: err.message,\n },\n },\n ];\n }\n}\n"],"mappings":";;;;;;;;;;AAoBA,MAAM,UAAU,mBAAmB,CAAC,OAAO,CAAC;AAE5C,eAAe,YACb,cACA,uBACA,YACe;CACf,IAAI,MAAM,qEAAqE,MAC7E,YACF;CAGA,IAAI,CAAC,uBACH,OAAO;CAOT,MAAM,QAAQ,KAAK;EAHjB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,MAChC,QAAQ,IAAI,eAAe,gBAAgB,EAC9C;GACA,MAAM,+BAA+B,YAAY,MAC9C,QAAQ,CAAC,IAAI,iBAAiB,IAAI,eAAe,gBAAgB,EACpE;GAIA,IAAI,kBAAkB,8BAA8B;IAClD,IAAI,8BAEF,OAAO,KACL,EAAE,YAAY,6BAA6B,QAAQ,GACnD,uCACF;IAEF,MAAM,YAAY,iBAAiB,OAAO,OAAO,aAAa,IAAI;GACpE,OAEE,MAAM,mBACJ,iBACA,aACA,OAAO,aAAa,IACtB;EAEJ;EAEA,OAAO,MAAM,8BAA8B;EAC3C,MAAM,sBAAsB,MAAM,cAAc,YAAY;EAC5D,IAAI,4BAA4B,qBAAqB;GACnD,OAAO,MAAM,yBAAyB;GACtC,OAAO;EACT;EACA,OAAO,CACL,EACE,MAAM;GACJ,MAAM;GACN,MAAM;GACN,UAAU;EACZ,EACF,CACF;CACF,SAAS,KAAK;;EAEZ,IAAI,IAAI,YAAA,mBACN,MAAM;EAOR,MAAM,sBAAsB,MAAM,cAAc,cAAc,MAAM;EACpE,IACE,iBAAiB,KACjB,uBACA,MAAM,iCAAiC,CAAC,CAAC,KAAK,IAAI,MAAM,GACxD;GACA,MAAM,WAAW,+BAA+B,mBAAmB;GACnE,MAAM,iBAAiB,YAAY,QAChC,QACC,CAAC,YAAY,UAAU,IAAI,IAAI,WAAY,CAAC,CAAC,CAAC,SAC5C,IAAI,UACN,CACJ;GAEA,IAAI,eAAe,SAAS,YAAY,QAAQ;IAC9C,OAAO,MACL,0DACF;IACA,OAAO,oBACL;KACE;KACA,aAAa;KACb;KACA;IACF,GACA,iBAAiB,CACnB;GACF;EACF;EAEA,OAAO,MAAM,EAAE,IAAI,GAAG,kCAAkC;EAExD,OAAO,CACL,EACE,eAAe;GACb,UAAU;GACV,QAAQ,IAAI;EACd,EACF,CACF;CACF;AACF"}
1
+ {"version":3,"file":"artifacts.js","names":[],"sources":["../../../../lib/modules/manager/cargo/artifacts.ts"],"sourcesContent":["import { quote } from 'shlex';\nimport { TEMPORARY_ERROR } from '../../../constants/error-messages.ts';\nimport { logger } from '../../../logger/index.ts';\nimport { coerceArray } from '../../../util/array.ts';\nimport type { ExecOptions } from '../../../util/exec/types.ts';\nimport {\n findLocalSiblingOrParent,\n readLocalFile,\n writeLocalFile,\n} from '../../../util/fs/index.ts';\nimport { withGitEnvironment } from '../../../util/git/exec.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { CrateDatasource } from '../../datasource/crate/index.ts';\nimport type {\n UpdateArtifact,\n UpdateArtifactsResult,\n Upgrade,\n} from '../types.ts';\nimport { resolveToolConstraint } from '../util.ts';\nimport { extractLockFileContentVersions } from './locked-version.ts';\n\nconst gitExec = withGitEnvironment(['cargo']);\n\nasync function cargoUpdate(\n manifestPath: string,\n isLockFileMaintenance: boolean,\n constraint: string | undefined,\n): Promise<void> {\n let cmd = `cargo update --config net.git-fetch-with-cli=true --manifest-path ${quote(\n manifestPath,\n )}`;\n // If we're updating a specific crate, `cargo-update` requires `--workspace`\n // for more information, see: https://github.com/renovatebot/renovate/issues/12332\n if (!isLockFileMaintenance) {\n cmd += ` --workspace`;\n }\n\n const execOptions: ExecOptions = {\n docker: {},\n toolConstraints: [{ toolName: 'rust', constraint }],\n };\n await gitExec(cmd, execOptions);\n}\n\nasync function cargoUpdatePrecise(\n manifestPath: string,\n updatedDeps: Upgrade[],\n constraint: string | undefined,\n): Promise<void> {\n const cmds = [];\n\n // First update individual dependencies to their `newVersion`. Necessary when\n // using the `update-lockfile` rangeStrategy which doesn't touch Cargo.toml.\n for (const dep of updatedDeps) {\n // If the range is bumped in Cargo.toml, the old lockedVersion may no longer\n // exist in Cargo's dependency graph, so let the --workspace update at the\n // end re-resolve it instead.\n if (dep.currentValue && dep.newValue && dep.currentValue !== dep.newValue) {\n continue;\n }\n\n cmds.push(\n `cargo update --config net.git-fetch-with-cli=true` +\n ` --manifest-path ${quote(manifestPath)}` +\n ` --package ${quote(`${dep.packageName}@${dep.lockedVersion}`)}` +\n ` --precise ${quote(dep.newVersion!)}`,\n );\n }\n\n // Then update all dependencies that have been bumped in `Cargo.toml`.\n cmds.push(\n `cargo update --config net.git-fetch-with-cli=true --manifest-path ${quote(manifestPath)} --workspace`,\n );\n\n const execOptions: ExecOptions = {\n docker: {},\n toolConstraints: [{ toolName: 'rust', constraint }],\n };\n\n await gitExec(cmds, execOptions);\n}\n\nexport async function updateArtifacts(\n updateArtifact: UpdateArtifact,\n): Promise<UpdateArtifactsResult[] | null> {\n return await updateArtifactsImpl(updateArtifact);\n}\n\nasync function updateArtifactsImpl(\n {\n packageFileName,\n updatedDeps,\n newPackageFileContent,\n config,\n }: UpdateArtifact,\n recursionLimit = 10,\n): Promise<UpdateArtifactsResult[] | null> {\n logger.debug(`cargo.updateArtifacts(${packageFileName})`);\n\n // For standalone package crates, the `Cargo.lock` will be in the same\n // directory as `Cargo.toml` (ie. a sibling). For cargo workspaces, it\n // will be further up.\n const lockFileName = await findLocalSiblingOrParent(\n packageFileName,\n 'Cargo.lock',\n );\n const existingLockFileContent = lockFileName\n ? await readLocalFile(lockFileName)\n : null;\n if (!existingLockFileContent || !lockFileName) {\n logger.debug('No Cargo.lock found');\n return null;\n }\n\n const { isLockFileMaintenance } = config;\n if (!isLockFileMaintenance && !updatedDeps?.length) {\n logger.debug('No more dependencies to update');\n return [\n {\n file: {\n type: 'addition',\n path: lockFileName,\n contents: existingLockFileContent,\n },\n },\n ];\n }\n\n const rustConstraint = await resolveToolConstraint(config, 'rust');\n\n try {\n await writeLocalFile(packageFileName, newPackageFileContent);\n logger.debug(`Updating ${lockFileName}`);\n\n if (isLockFileMaintenance) {\n await cargoUpdate(packageFileName, true, rustConstraint);\n } else {\n const hasNonCrateDep = updatedDeps.some(\n (dep) => dep.datasource !== CrateDatasource.id,\n );\n const crateDepWithoutLockedVersion = updatedDeps.find(\n (dep) => !dep.lockedVersion && dep.datasource === CrateDatasource.id,\n );\n // Non-crate dependencies (like git ones) do not have locked versions.\n // For crate dependencies, a locked version is expected.\n // In both situations, perform a regular workspace lockfile update.\n if (hasNonCrateDep || crateDepWithoutLockedVersion) {\n if (crateDepWithoutLockedVersion) {\n // Only warn when a crate dependency has no locked version\n logger.warn(\n { dependency: crateDepWithoutLockedVersion.depName },\n 'Missing locked version for dependency',\n );\n }\n await cargoUpdate(packageFileName, false, rustConstraint);\n } else {\n // If all dependencies have locked versions then update them precisely.\n await cargoUpdatePrecise(packageFileName, updatedDeps, rustConstraint);\n }\n }\n\n logger.debug('Returning updated Cargo.lock');\n const newCargoLockContent = await readLocalFile(lockFileName);\n if (existingLockFileContent === newCargoLockContent) {\n logger.debug('Cargo.lock is unchanged');\n return null;\n }\n return [\n {\n file: {\n type: 'addition',\n path: lockFileName,\n contents: newCargoLockContent,\n },\n },\n ];\n } catch (err) {\n // istanbul ignore if\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n\n // Sometimes `cargo update` will fail when a preceding dependency update\n // causes another dependency to update. In this case we can no longer\n // reference the dependency by its old version, so we filter it out\n // and retry recursively.\n const newCargoLockContent = await readLocalFile(lockFileName, 'utf8');\n if (\n recursionLimit > 0 &&\n newCargoLockContent &&\n regEx(/error: package ID specification/).test(err.stderr)\n ) {\n const versions = extractLockFileContentVersions(newCargoLockContent);\n const newUpdatedDeps = updatedDeps.filter(\n (dep) =>\n !coerceArray(versions?.get(dep.packageName!)).includes(\n dep.newVersion!,\n ),\n );\n\n if (newUpdatedDeps.length < updatedDeps.length) {\n logger.debug(\n 'Dependency already up to date - reattempting recursively',\n );\n return updateArtifactsImpl(\n {\n packageFileName,\n updatedDeps: newUpdatedDeps,\n newPackageFileContent,\n config,\n },\n recursionLimit - 1,\n );\n }\n }\n\n logger.debug({ err }, 'Failed to update Cargo lock file');\n\n return [\n {\n artifactError: {\n fileName: lockFileName,\n stderr: err.message,\n },\n },\n ];\n }\n}\n"],"mappings":";;;;;;;;;;;AAqBA,MAAM,UAAU,mBAAmB,CAAC,OAAO,CAAC;AAE5C,eAAe,YACb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,UAAU;GACV,QAAQ,IAAI;EACd,EACF,CACF;CACF;AACF"}
@@ -7,13 +7,15 @@ import { logger } from "../../../logger/index.js";
7
7
  import { find, findAll } from "../../../util/host-rules.js";
8
8
  import { deleteLocalFile, ensureCacheDir, ensureLocalDir, getSiblingFileName, localPathExists, readLocalFile, writeLocalFile } from "../../../util/fs/index.js";
9
9
  import { Json } from "../../../util/schema-utils/index.js";
10
+ import { Lazy } from "../../../util/lazy.js";
10
11
  import { exec } from "../../../util/exec/index.js";
11
12
  import { getRepoStatus } from "../../../util/git/index.js";
12
13
  import { GitTagsDatasource } from "../../datasource/git-tags/index.js";
13
14
  import { PackagistDatasource } from "../../datasource/packagist/index.js";
15
+ import { resolveToolConstraint } from "../util.js";
14
16
  import { findGithubToken, takePersonalAccessTokenIfPossible } from "../../../util/check-token.js";
15
17
  import { Lockfile, PackageFile } from "./schema.js";
16
- import { extractConstraints, getComposerArguments, getComposerUpdateArguments, getPhpConstraint, isArtifactAuthEnabled, requireComposerDependencyInstallation } from "./utils.js";
18
+ import { extractConstraints, getComposerArguments, getComposerUpdateArguments, isArtifactAuthEnabled, requireComposerDependencyInstallation } from "./utils.js";
17
19
  import { isEmptyObject, isString } from "@sindresorhus/is";
18
20
  import { z } from "zod/v4";
19
21
  import { quote } from "shlex";
@@ -69,17 +71,14 @@ async function updateArtifacts({ packageFileName, updatedDeps, newPackageFileCon
69
71
  await ensureLocalDir(vendorDir);
70
72
  try {
71
73
  await writeLocalFile(packageFileName, newPackageFileContent);
72
- const constraints = {
73
- ...extractConstraints(file, lockfile),
74
- ...config.constraints
75
- };
74
+ const fileConstraints = new Lazy(() => extractConstraints(file, lockfile));
76
75
  const composerToolConstraint = {
77
76
  toolName: "composer",
78
- constraint: constraints.composer
77
+ constraint: await resolveToolConstraint(config, "composer", () => fileConstraints.getValue().composer)
79
78
  };
80
79
  const phpToolConstraint = {
81
80
  toolName: "php",
82
- constraint: getPhpConstraint(constraints)
81
+ constraint: await resolveToolConstraint(config, "php", () => fileConstraints.getValue().php)
83
82
  };
84
83
  const execOptions = {
85
84
  cwdFile: packageFileName,
@@ -1 +1 @@
1
- {"version":3,"file":"artifacts.js","names":["hostRules.find","hostRules.findAll"],"sources":["../../../../lib/modules/manager/composer/artifacts.ts"],"sourcesContent":["import { isEmptyObject, isString } from '@sindresorhus/is';\nimport { quote } from 'shlex';\nimport { z } from 'zod/v4';\nimport {\n SYSTEM_INSUFFICIENT_DISK_SPACE,\n TEMPORARY_ERROR,\n} from '../../../constants/error-messages.ts';\nimport { logger } from '../../../logger/index.ts';\nimport { coerceArray } from '../../../util/array.ts';\nimport {\n findGithubToken,\n takePersonalAccessTokenIfPossible,\n} from '../../../util/check-token.ts';\nimport { exec } from '../../../util/exec/index.ts';\nimport type {\n CommandWithOptions,\n ExecOptions,\n ToolConstraint,\n} from '../../../util/exec/types.ts';\nimport {\n deleteLocalFile,\n ensureCacheDir,\n ensureLocalDir,\n getSiblingFileName,\n localPathExists,\n readLocalFile,\n writeLocalFile,\n} from '../../../util/fs/index.ts';\nimport { getRepoStatus } from '../../../util/git/index.ts';\nimport * as hostRules from '../../../util/host-rules.ts';\nimport { coerceObject } from '../../../util/object.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { Json } from '../../../util/schema-utils/index.ts';\nimport { coerceString } from '../../../util/string.ts';\nimport { GitTagsDatasource } from '../../datasource/git-tags/index.ts';\nimport { PackagistDatasource } from '../../datasource/packagist/index.ts';\nimport type { UpdateArtifact, UpdateArtifactsResult } from '../types.ts';\nimport { Lockfile, PackageFile } from './schema.ts';\nimport type { AuthJson } from './types.ts';\nimport {\n extractConstraints,\n getComposerArguments,\n getComposerUpdateArguments,\n getPhpConstraint,\n isArtifactAuthEnabled,\n requireComposerDependencyInstallation,\n} from './utils.ts';\n\nfunction getAuthJson(): string | null {\n const authJson: AuthJson = {};\n\n const githubHostRule = hostRules.find({\n hostType: 'github',\n url: 'https://api.github.com/',\n });\n\n const gitTagsHostRule = hostRules.find({\n hostType: GitTagsDatasource.id,\n url: 'https://github.com',\n });\n\n const selectedGithubToken = takePersonalAccessTokenIfPossible(\n isArtifactAuthEnabled(githubHostRule)\n ? findGithubToken(githubHostRule)\n : undefined,\n isArtifactAuthEnabled(gitTagsHostRule)\n ? findGithubToken(gitTagsHostRule)\n : undefined,\n );\n\n if (selectedGithubToken) {\n authJson['github-oauth'] = {\n 'github.com': selectedGithubToken,\n };\n }\n\n for (const gitlabHostRule of hostRules.findAll({ hostType: 'gitlab' })) {\n if (!isArtifactAuthEnabled(gitlabHostRule)) {\n continue;\n }\n\n if (gitlabHostRule?.token) {\n const host = coerceString(gitlabHostRule.resolvedHost, 'gitlab.com');\n authJson['gitlab-token'] = coerceObject(authJson['gitlab-token']);\n authJson['gitlab-token'][host] = gitlabHostRule.token;\n // https://getcomposer.org/doc/articles/authentication-for-private-packages.md#gitlab-token\n authJson['gitlab-domains'] = [\n host,\n ...coerceArray(authJson['gitlab-domains']),\n ];\n }\n }\n\n for (const packagistHostRule of hostRules.findAll({\n hostType: PackagistDatasource.id,\n })) {\n if (!isArtifactAuthEnabled(packagistHostRule)) {\n continue;\n }\n\n const { resolvedHost, username, password, token } = packagistHostRule;\n if (resolvedHost && username && password) {\n authJson['http-basic'] = coerceObject(authJson['http-basic']);\n authJson['http-basic'][resolvedHost] = { username, password };\n } else if (resolvedHost && token) {\n authJson.bearer = coerceObject(authJson.bearer);\n authJson.bearer[resolvedHost] = token;\n }\n }\n\n return isEmptyObject(authJson) ? null : JSON.stringify(authJson);\n}\n\nexport async function updateArtifacts({\n packageFileName,\n updatedDeps,\n newPackageFileContent,\n config,\n}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {\n logger.debug(`composer.updateArtifacts(${packageFileName})`);\n\n const file = Json.pipe(PackageFile).parse(newPackageFileContent);\n\n const lockFileName = packageFileName.replace(regEx(/\\.json$/), '.lock');\n const lockfile = await z\n .string()\n .transform((f) => readLocalFile(f, 'utf8'))\n .pipe(Json)\n .pipe(Lockfile)\n .nullable()\n .catch(null)\n .parseAsync(lockFileName);\n if (!lockfile) {\n logger.debug('Composer: unable to read lockfile');\n return null;\n }\n\n const vendorDir = getSiblingFileName(packageFileName, 'vendor');\n const commitVendorFiles = await localPathExists(vendorDir);\n await ensureLocalDir(vendorDir);\n try {\n await writeLocalFile(packageFileName, newPackageFileContent);\n\n const constraints = {\n ...extractConstraints(file, lockfile),\n ...config.constraints,\n };\n\n const composerToolConstraint: ToolConstraint = {\n toolName: 'composer',\n constraint: constraints.composer,\n };\n\n const phpToolConstraint: ToolConstraint = {\n toolName: 'php',\n constraint: getPhpConstraint(constraints),\n };\n\n const execOptions: ExecOptions = {\n cwdFile: packageFileName,\n extraEnv: {\n COMPOSER_CACHE_DIR: await ensureCacheDir('composer'),\n COMPOSER_AUTH: getAuthJson(),\n },\n toolConstraints: [phpToolConstraint, composerToolConstraint],\n docker: {},\n };\n\n const commands: (string | CommandWithOptions)[] = [];\n\n // Determine whether install is required before update\n if (requireComposerDependencyInstallation(lockfile)) {\n const preCmd = 'composer';\n const preArgs = `install${getComposerArguments(config, composerToolConstraint)}`;\n logger.trace({ preCmd, preArgs }, 'composer pre-update command');\n commands.push('git stash -- composer.json');\n commands.push(`${preCmd} ${preArgs}`);\n commands.push({ command: ['git', 'stash', 'pop'], ignoreFailure: true });\n }\n\n if (config.isLockFileMaintenance) {\n logger.debug(\n `Removing ${lockFileName} first due to lock file maintenance upgrade`,\n );\n await deleteLocalFile(lockFileName);\n }\n\n const cmd = 'composer';\n let args: string;\n if (config.isLockFileMaintenance) {\n args = 'update';\n } else {\n args =\n (\n 'update ' +\n updatedDeps\n .map((dep) =>\n dep.newVersion\n ? quote(`${dep.depName}:${dep.newVersion}`)\n : quote(dep.depName!),\n )\n .filter(isString)\n .map((dep) => quote(dep))\n .join(' ')\n ).trim() +\n (config.postUpdateOptions?.includes('composerWithAll')\n ? ' --with-all-dependencies'\n : ' --with-dependencies');\n }\n args += getComposerUpdateArguments(config, composerToolConstraint);\n logger.trace({ cmd, args }, 'composer command');\n commands.push(`${cmd} ${args}`);\n\n await exec(commands, execOptions);\n const status = await getRepoStatus();\n if (!status.modified.includes(lockFileName)) {\n return null;\n }\n logger.debug('Returning updated composer.lock');\n const res: UpdateArtifactsResult[] = [\n {\n file: {\n type: 'addition',\n path: lockFileName,\n contents: await readLocalFile(lockFileName),\n },\n },\n ];\n\n if (!commitVendorFiles) {\n return res;\n }\n\n logger.debug(`Committing vendor files in ${vendorDir}`);\n for (const f of [...status.modified, ...status.not_added]) {\n if (f.startsWith(vendorDir)) {\n res.push({\n file: {\n type: 'addition',\n path: f,\n contents: await readLocalFile(f),\n },\n });\n }\n }\n for (const f of status.deleted) {\n res.push({\n file: {\n type: 'deletion',\n path: f,\n },\n });\n }\n\n return res;\n } catch (err) {\n // istanbul ignore if\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n if (\n err.message?.includes(\n 'Your requirements could not be resolved to an installable set of packages.',\n )\n ) {\n logger.info('Composer requirements cannot be resolved');\n } else if (err.message?.includes('write error (disk full?)')) {\n throw new Error(SYSTEM_INSUFFICIENT_DISK_SPACE);\n } else {\n logger.debug({ err }, 'Failed to generate composer.lock');\n }\n return [\n {\n artifactError: {\n fileName: lockFileName,\n stderr: err.message,\n },\n },\n ];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAgDA,SAAS,cAA6B;CACpC,MAAM,WAAqB,CAAC;CAE5B,MAAM,iBAAiBA,KAAe;EACpC,UAAU;EACV,KAAK;CACP,CAAC;CAED,MAAM,kBAAkBA,KAAe;EACrC,UAAU,kBAAkB;EAC5B,KAAK;CACP,CAAC;CAED,MAAM,sBAAsB,kCAC1B,sBAAsB,cAAc,IAChC,gBAAgB,cAAc,IAC9B,KAAA,GACJ,sBAAsB,eAAe,IACjC,gBAAgB,eAAe,IAC/B,KAAA,CACN;CAEA,IAAI,qBACF,SAAS,kBAAkB,EACzB,cAAc,oBAChB;CAGF,KAAK,MAAM,kBAAkBC,QAAkB,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BAAmB,SAAS,iBAAiB,IACjD,6BACA;EAER,QAAQ,2BAA2B,QAAQ,sBAAsB;EACjE,OAAO,MAAM;GAAE;GAAK;EAAK,GAAG,kBAAkB;EAC9C,SAAS,KAAK,GAAG,IAAI,GAAG,MAAM;EAE9B,MAAM,KAAK,UAAU,WAAW;EAChC,MAAM,SAAS,MAAM,cAAc;EACnC,IAAI,CAAC,OAAO,SAAS,SAAS,YAAY,GACxC,OAAO;EAET,OAAO,MAAM,iCAAiC;EAC9C,MAAM,MAA+B,CACnC,EACE,MAAM;GACJ,MAAM;GACN,MAAM;GACN,UAAU,MAAM,cAAc,YAAY;EAC5C,EACF,CACF;EAEA,IAAI,CAAC,mBACH,OAAO;EAGT,OAAO,MAAM,8BAA8B,WAAW;EACtD,KAAK,MAAM,KAAK,CAAC,GAAG,OAAO,UAAU,GAAG,OAAO,SAAS,GACtD,IAAI,EAAE,WAAW,SAAS,GACxB,IAAI,KAAK,EACP,MAAM;GACJ,MAAM;GACN,MAAM;GACN,UAAU,MAAM,cAAc,CAAC;EACjC,EACF,CAAC;EAGL,KAAK,MAAM,KAAK,OAAO,SACrB,IAAI,KAAK,EACP,MAAM;GACJ,MAAM;GACN,MAAM;EACR,EACF,CAAC;EAGH,OAAO;CACT,SAAS,KAAK;;EAEZ,IAAI,IAAI,YAAA,mBACN,MAAM;EAER,IACE,IAAI,SAAS,SACX,4EACF,GAEA,OAAO,KAAK,0CAA0C;OACjD,IAAI,IAAI,SAAS,SAAS,0BAA0B,GACzD,MAAM,IAAI,MAAM,8BAA8B;OAE9C,OAAO,MAAM,EAAE,IAAI,GAAG,kCAAkC;EAE1D,OAAO,CACL,EACE,eAAe;GACb,UAAU;GACV,QAAQ,IAAI;EACd,EACF,CACF;CACF;AACF"}
1
+ {"version":3,"file":"artifacts.js","names":["hostRules.find","hostRules.findAll"],"sources":["../../../../lib/modules/manager/composer/artifacts.ts"],"sourcesContent":["import { isEmptyObject, isString } from '@sindresorhus/is';\nimport { quote } from 'shlex';\nimport { z } from 'zod/v4';\nimport {\n SYSTEM_INSUFFICIENT_DISK_SPACE,\n TEMPORARY_ERROR,\n} from '../../../constants/error-messages.ts';\nimport { logger } from '../../../logger/index.ts';\nimport { coerceArray } from '../../../util/array.ts';\nimport {\n findGithubToken,\n takePersonalAccessTokenIfPossible,\n} from '../../../util/check-token.ts';\nimport { exec } from '../../../util/exec/index.ts';\nimport type {\n CommandWithOptions,\n ExecOptions,\n ToolConstraint,\n} from '../../../util/exec/types.ts';\nimport {\n deleteLocalFile,\n ensureCacheDir,\n ensureLocalDir,\n getSiblingFileName,\n localPathExists,\n readLocalFile,\n writeLocalFile,\n} from '../../../util/fs/index.ts';\nimport { getRepoStatus } from '../../../util/git/index.ts';\nimport * as hostRules from '../../../util/host-rules.ts';\nimport { Lazy } from '../../../util/lazy.ts';\nimport { coerceObject } from '../../../util/object.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { Json } from '../../../util/schema-utils/index.ts';\nimport { coerceString } from '../../../util/string.ts';\nimport { GitTagsDatasource } from '../../datasource/git-tags/index.ts';\nimport { PackagistDatasource } from '../../datasource/packagist/index.ts';\nimport type { UpdateArtifact, UpdateArtifactsResult } from '../types.ts';\nimport { resolveToolConstraint } from '../util.ts';\nimport { Lockfile, PackageFile } from './schema.ts';\nimport type { AuthJson } from './types.ts';\nimport {\n extractConstraints,\n getComposerArguments,\n getComposerUpdateArguments,\n isArtifactAuthEnabled,\n requireComposerDependencyInstallation,\n} from './utils.ts';\n\nfunction getAuthJson(): string | null {\n const authJson: AuthJson = {};\n\n const githubHostRule = hostRules.find({\n hostType: 'github',\n url: 'https://api.github.com/',\n });\n\n const gitTagsHostRule = hostRules.find({\n hostType: GitTagsDatasource.id,\n url: 'https://github.com',\n });\n\n const selectedGithubToken = takePersonalAccessTokenIfPossible(\n isArtifactAuthEnabled(githubHostRule)\n ? findGithubToken(githubHostRule)\n : undefined,\n isArtifactAuthEnabled(gitTagsHostRule)\n ? findGithubToken(gitTagsHostRule)\n : undefined,\n );\n\n if (selectedGithubToken) {\n authJson['github-oauth'] = {\n 'github.com': selectedGithubToken,\n };\n }\n\n for (const gitlabHostRule of hostRules.findAll({ hostType: 'gitlab' })) {\n if (!isArtifactAuthEnabled(gitlabHostRule)) {\n continue;\n }\n\n if (gitlabHostRule?.token) {\n const host = coerceString(gitlabHostRule.resolvedHost, 'gitlab.com');\n authJson['gitlab-token'] = coerceObject(authJson['gitlab-token']);\n authJson['gitlab-token'][host] = gitlabHostRule.token;\n // https://getcomposer.org/doc/articles/authentication-for-private-packages.md#gitlab-token\n authJson['gitlab-domains'] = [\n host,\n ...coerceArray(authJson['gitlab-domains']),\n ];\n }\n }\n\n for (const packagistHostRule of hostRules.findAll({\n hostType: PackagistDatasource.id,\n })) {\n if (!isArtifactAuthEnabled(packagistHostRule)) {\n continue;\n }\n\n const { resolvedHost, username, password, token } = packagistHostRule;\n if (resolvedHost && username && password) {\n authJson['http-basic'] = coerceObject(authJson['http-basic']);\n authJson['http-basic'][resolvedHost] = { username, password };\n } else if (resolvedHost && token) {\n authJson.bearer = coerceObject(authJson.bearer);\n authJson.bearer[resolvedHost] = token;\n }\n }\n\n return isEmptyObject(authJson) ? null : JSON.stringify(authJson);\n}\n\nexport async function updateArtifacts({\n packageFileName,\n updatedDeps,\n newPackageFileContent,\n config,\n}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {\n logger.debug(`composer.updateArtifacts(${packageFileName})`);\n\n const file = Json.pipe(PackageFile).parse(newPackageFileContent);\n\n const lockFileName = packageFileName.replace(regEx(/\\.json$/), '.lock');\n const lockfile = await z\n .string()\n .transform((f) => readLocalFile(f, 'utf8'))\n .pipe(Json)\n .pipe(Lockfile)\n .nullable()\n .catch(null)\n .parseAsync(lockFileName);\n if (!lockfile) {\n logger.debug('Composer: unable to read lockfile');\n return null;\n }\n\n const vendorDir = getSiblingFileName(packageFileName, 'vendor');\n const commitVendorFiles = await localPathExists(vendorDir);\n await ensureLocalDir(vendorDir);\n try {\n await writeLocalFile(packageFileName, newPackageFileContent);\n\n // `extractConstraints()` re-reads the updated package file, so its values win\n // over what extraction saw on the base branch. It only runs when a user\n // constraint is missing for at least one of the tools.\n const fileConstraints = new Lazy(() => extractConstraints(file, lockfile));\n\n const composerToolConstraint: ToolConstraint = {\n toolName: 'composer',\n constraint: await resolveToolConstraint(\n config,\n 'composer',\n () => fileConstraints.getValue().composer,\n ),\n };\n\n const phpToolConstraint: ToolConstraint = {\n toolName: 'php',\n constraint: await resolveToolConstraint(\n config,\n 'php',\n () => fileConstraints.getValue().php,\n ),\n };\n\n const execOptions: ExecOptions = {\n cwdFile: packageFileName,\n extraEnv: {\n COMPOSER_CACHE_DIR: await ensureCacheDir('composer'),\n COMPOSER_AUTH: getAuthJson(),\n },\n toolConstraints: [phpToolConstraint, composerToolConstraint],\n docker: {},\n };\n\n const commands: (string | CommandWithOptions)[] = [];\n\n // Determine whether install is required before update\n if (requireComposerDependencyInstallation(lockfile)) {\n const preCmd = 'composer';\n const preArgs = `install${getComposerArguments(config, composerToolConstraint)}`;\n logger.trace({ preCmd, preArgs }, 'composer pre-update command');\n commands.push('git stash -- composer.json');\n commands.push(`${preCmd} ${preArgs}`);\n commands.push({ command: ['git', 'stash', 'pop'], ignoreFailure: true });\n }\n\n if (config.isLockFileMaintenance) {\n logger.debug(\n `Removing ${lockFileName} first due to lock file maintenance upgrade`,\n );\n await deleteLocalFile(lockFileName);\n }\n\n const cmd = 'composer';\n let args: string;\n if (config.isLockFileMaintenance) {\n args = 'update';\n } else {\n args =\n (\n 'update ' +\n updatedDeps\n .map((dep) =>\n dep.newVersion\n ? quote(`${dep.depName}:${dep.newVersion}`)\n : quote(dep.depName!),\n )\n .filter(isString)\n .map((dep) => quote(dep))\n .join(' ')\n ).trim() +\n (config.postUpdateOptions?.includes('composerWithAll')\n ? ' --with-all-dependencies'\n : ' --with-dependencies');\n }\n args += getComposerUpdateArguments(config, composerToolConstraint);\n logger.trace({ cmd, args }, 'composer command');\n commands.push(`${cmd} ${args}`);\n\n await exec(commands, execOptions);\n const status = await getRepoStatus();\n if (!status.modified.includes(lockFileName)) {\n return null;\n }\n logger.debug('Returning updated composer.lock');\n const res: UpdateArtifactsResult[] = [\n {\n file: {\n type: 'addition',\n path: lockFileName,\n contents: await readLocalFile(lockFileName),\n },\n },\n ];\n\n if (!commitVendorFiles) {\n return res;\n }\n\n logger.debug(`Committing vendor files in ${vendorDir}`);\n for (const f of [...status.modified, ...status.not_added]) {\n if (f.startsWith(vendorDir)) {\n res.push({\n file: {\n type: 'addition',\n path: f,\n contents: await readLocalFile(f),\n },\n });\n }\n }\n for (const f of status.deleted) {\n res.push({\n file: {\n type: 'deletion',\n path: f,\n },\n });\n }\n\n return res;\n } catch (err) {\n // istanbul ignore if\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n if (\n err.message?.includes(\n 'Your requirements could not be resolved to an installable set of packages.',\n )\n ) {\n logger.info('Composer requirements cannot be resolved');\n } else if (err.message?.includes('write error (disk full?)')) {\n throw new Error(SYSTEM_INSUFFICIENT_DISK_SPACE);\n } else {\n logger.debug({ err }, 'Failed to generate composer.lock');\n }\n return [\n {\n artifactError: {\n fileName: lockFileName,\n stderr: err.message,\n },\n },\n ];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAiDA,SAAS,cAA6B;CACpC,MAAM,WAAqB,CAAC;CAE5B,MAAM,iBAAiBA,KAAe;EACpC,UAAU;EACV,KAAK;CACP,CAAC;CAED,MAAM,kBAAkBA,KAAe;EACrC,UAAU,kBAAkB;EAC5B,KAAK;CACP,CAAC;CAED,MAAM,sBAAsB,kCAC1B,sBAAsB,cAAc,IAChC,gBAAgB,cAAc,IAC9B,KAAA,GACJ,sBAAsB,eAAe,IACjC,gBAAgB,eAAe,IAC/B,KAAA,CACN;CAEA,IAAI,qBACF,SAAS,kBAAkB,EACzB,cAAc,oBAChB;CAGF,KAAK,MAAM,kBAAkBC,QAAkB,EAAE,UAAU,SAAS,CAAC,G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CACxB,KAAK,GAAG,EAAA,CACX,KAAK,KACN,OAAO,mBAAmB,SAAS,iBAAiB,IACjD,6BACA;EAER,QAAQ,2BAA2B,QAAQ,sBAAsB;EACjE,OAAO,MAAM;GAAE;GAAK;EAAK,GAAG,kBAAkB;EAC9C,SAAS,KAAK,GAAG,IAAI,GAAG,MAAM;EAE9B,MAAM,KAAK,UAAU,WAAW;EAChC,MAAM,SAAS,MAAM,cAAc;EACnC,IAAI,CAAC,OAAO,SAAS,SAAS,YAAY,GACxC,OAAO;EAET,OAAO,MAAM,iCAAiC;EAC9C,MAAM,MAA+B,CACnC,EACE,MAAM;GACJ,MAAM;GACN,MAAM;GACN,UAAU,MAAM,cAAc,YAAY;EAC5C,EACF,CACF;EAEA,IAAI,CAAC,mBACH,OAAO;EAGT,OAAO,MAAM,8BAA8B,WAAW;EACtD,KAAK,MAAM,KAAK,CAAC,GAAG,OAAO,UAAU,GAAG,OAAO,SAAS,GACtD,IAAI,EAAE,WAAW,SAAS,GACxB,IAAI,KAAK,EACP,MAAM;GACJ,MAAM;GACN,MAAM;GACN,UAAU,MAAM,cAAc,CAAC;EACjC,EACF,CAAC;EAGL,KAAK,MAAM,KAAK,OAAO,SACrB,IAAI,KAAK,EACP,MAAM;GACJ,MAAM;GACN,MAAM;EACR,EACF,CAAC;EAGH,OAAO;CACT,SAAS,KAAK;;EAEZ,IAAI,IAAI,YAAA,mBACN,MAAM;EAER,IACE,IAAI,SAAS,SACX,4EACF,GAEA,OAAO,KAAK,0CAA0C;OACjD,IAAI,IAAI,SAAS,SAAS,0BAA0B,GACzD,MAAM,IAAI,MAAM,8BAA8B;OAE9C,OAAO,MAAM,EAAE,IAAI,GAAG,kCAAkC;EAE1D,OAAO,CACL,EACE,eAAe;GACb,UAAU;GACV,QAAQ,IAAI;EACd,EACF,CACF;CACF;AACF"}
@@ -1,5 +1,4 @@
1
1
  import { GlobalConfig } from "../../../config/global.js";
2
- import { logger } from "../../../logger/index.js";
3
2
  import { api, id } from "../../versioning/composer/index.js";
4
3
  import { coerceNumber } from "../../../util/number.js";
5
4
  import { isString } from "@sindresorhus/is";
@@ -26,14 +25,6 @@ function getComposerUpdateArguments(config, toolConstraint) {
26
25
  if (!config.isLockFileMaintenance && !config.postUpdateOptions?.includes("composerNoMinimalChanges") && isString(toolConstraint.constraint) && api.intersects(toolConstraint.constraint, ">=2.7")) args += " --minimal-changes";
27
26
  return args;
28
27
  }
29
- function getPhpConstraint(constraints) {
30
- const { php } = constraints;
31
- if (php) {
32
- logger.debug("Using php constraint from config");
33
- return php;
34
- }
35
- return null;
36
- }
37
28
  function requireComposerDependencyInstallation({ packages, packagesDev }) {
38
29
  return packages.some((p) => depRequireInstall.has(p.name)) === true || packagesDev.some((p) => depRequireInstall.has(p.name)) === true;
39
30
  }
@@ -54,6 +45,6 @@ function isArtifactAuthEnabled(rule) {
54
45
  return !rule.artifactAuth || rule.artifactAuth.includes("composer");
55
46
  }
56
47
  //#endregion
57
- export { id as composerVersioningId, extractConstraints, getComposerArguments, getComposerUpdateArguments, getPhpConstraint, isArtifactAuthEnabled, requireComposerDependencyInstallation };
48
+ export { id as composerVersioningId, extractConstraints, getComposerArguments, getComposerUpdateArguments, isArtifactAuthEnabled, requireComposerDependencyInstallation };
58
49
 
59
50
  //# sourceMappingURL=utils.js.map