renovate 44.85.1 → 44.86.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 (97) hide show
  1. package/dist/modules/manager/apm/artifacts.js +2 -1
  2. package/dist/modules/manager/apm/artifacts.js.map +1 -1
  3. package/dist/modules/manager/bazel-module/artifacts.js +2 -1
  4. package/dist/modules/manager/bazel-module/artifacts.js.map +1 -1
  5. package/dist/modules/manager/bazelisk/artifacts.js +2 -1
  6. package/dist/modules/manager/bazelisk/artifacts.js.map +1 -1
  7. package/dist/modules/manager/bun/artifacts.js +2 -1
  8. package/dist/modules/manager/bun/artifacts.js.map +1 -1
  9. package/dist/modules/manager/bundler/artifacts.js +1 -1
  10. package/dist/modules/manager/bundler/artifacts.js.map +1 -1
  11. package/dist/modules/manager/bundler/common.js +11 -16
  12. package/dist/modules/manager/bundler/common.js.map +1 -1
  13. package/dist/modules/manager/cargo/artifacts.js +5 -3
  14. package/dist/modules/manager/cargo/artifacts.js.map +1 -1
  15. package/dist/modules/manager/composer/artifacts.js +6 -7
  16. package/dist/modules/manager/composer/artifacts.js.map +1 -1
  17. package/dist/modules/manager/composer/utils.js +1 -10
  18. package/dist/modules/manager/composer/utils.js.map +1 -1
  19. package/dist/modules/manager/conan/artifacts.js +2 -1
  20. package/dist/modules/manager/conan/artifacts.js.map +1 -1
  21. package/dist/modules/manager/copier/artifacts.js +3 -3
  22. package/dist/modules/manager/copier/artifacts.js.map +1 -1
  23. package/dist/modules/manager/deno/artifacts.js +2 -1
  24. package/dist/modules/manager/deno/artifacts.js.map +1 -1
  25. package/dist/modules/manager/devbox/artifacts.js +8 -5
  26. package/dist/modules/manager/devbox/artifacts.js.map +1 -1
  27. package/dist/modules/manager/fingerprint.generated.js +34 -34
  28. package/dist/modules/manager/fingerprint.generated.js.map +1 -1
  29. package/dist/modules/manager/github-actions/artifacts.js +6 -4
  30. package/dist/modules/manager/github-actions/artifacts.js.map +1 -1
  31. package/dist/modules/manager/gleam/artifacts.js +2 -1
  32. package/dist/modules/manager/gleam/artifacts.js.map +1 -1
  33. package/dist/modules/manager/gomod/artifacts.js +8 -6
  34. package/dist/modules/manager/gomod/artifacts.js.map +1 -1
  35. package/dist/modules/manager/gradle/artifacts.js +2 -1
  36. package/dist/modules/manager/gradle/artifacts.js.map +1 -1
  37. package/dist/modules/manager/gradle-wrapper/artifacts.js +2 -1
  38. package/dist/modules/manager/gradle-wrapper/artifacts.js.map +1 -1
  39. package/dist/modules/manager/helmfile/artifacts.js +4 -3
  40. package/dist/modules/manager/helmfile/artifacts.js.map +1 -1
  41. package/dist/modules/manager/helmv3/artifacts.js +2 -1
  42. package/dist/modules/manager/helmv3/artifacts.js.map +1 -1
  43. package/dist/modules/manager/jsonnet-bundler/artifacts.js +2 -1
  44. package/dist/modules/manager/jsonnet-bundler/artifacts.js.map +1 -1
  45. package/dist/modules/manager/kustomize/artifacts.js +4 -2
  46. package/dist/modules/manager/kustomize/artifacts.js.map +1 -1
  47. package/dist/modules/manager/kustomize/common.js +2 -2
  48. package/dist/modules/manager/kustomize/common.js.map +1 -1
  49. package/dist/modules/manager/maven-wrapper/artifacts.js +2 -1
  50. package/dist/modules/manager/maven-wrapper/artifacts.js.map +1 -1
  51. package/dist/modules/manager/mise/artifacts.js +13 -11
  52. package/dist/modules/manager/mise/artifacts.js.map +1 -1
  53. package/dist/modules/manager/mix/artifacts.js +3 -2
  54. package/dist/modules/manager/mix/artifacts.js.map +1 -1
  55. package/dist/modules/manager/nix/artifacts.js +2 -1
  56. package/dist/modules/manager/nix/artifacts.js.map +1 -1
  57. package/dist/modules/manager/npm/artifacts.js +2 -1
  58. package/dist/modules/manager/npm/artifacts.js.map +1 -1
  59. package/dist/modules/manager/npm/post-update/node-version.js +2 -1
  60. package/dist/modules/manager/npm/post-update/node-version.js.map +1 -1
  61. package/dist/modules/manager/npm/post-update/npm.js +2 -1
  62. package/dist/modules/manager/npm/post-update/npm.js.map +1 -1
  63. package/dist/modules/manager/npm/post-update/pnpm.js +2 -1
  64. package/dist/modules/manager/npm/post-update/pnpm.js.map +1 -1
  65. package/dist/modules/manager/npm/post-update/yarn.js +5 -3
  66. package/dist/modules/manager/npm/post-update/yarn.js.map +1 -1
  67. package/dist/modules/manager/nuget/artifacts.js +2 -1
  68. package/dist/modules/manager/nuget/artifacts.js.map +1 -1
  69. package/dist/modules/manager/pep621/processors/pdm.js +3 -2
  70. package/dist/modules/manager/pep621/processors/pdm.js.map +1 -1
  71. package/dist/modules/manager/pep621/processors/pixi.js +4 -3
  72. package/dist/modules/manager/pep621/processors/pixi.js.map +1 -1
  73. package/dist/modules/manager/pep621/processors/uv.js +3 -3
  74. package/dist/modules/manager/pep621/processors/uv.js.map +1 -1
  75. package/dist/modules/manager/pip-compile/common.js +14 -36
  76. package/dist/modules/manager/pip-compile/common.js.map +1 -1
  77. package/dist/modules/manager/pip_requirements/artifacts.js +3 -2
  78. package/dist/modules/manager/pip_requirements/artifacts.js.map +1 -1
  79. package/dist/modules/manager/pipenv/artifacts.js +3 -2
  80. package/dist/modules/manager/pipenv/artifacts.js.map +1 -1
  81. package/dist/modules/manager/pixi/artifacts.js +2 -1
  82. package/dist/modules/manager/pixi/artifacts.js.map +1 -1
  83. package/dist/modules/manager/poetry/artifacts.js +3 -2
  84. package/dist/modules/manager/poetry/artifacts.js.map +1 -1
  85. package/dist/modules/manager/pub/artifacts.js +11 -10
  86. package/dist/modules/manager/pub/artifacts.js.map +1 -1
  87. package/dist/modules/manager/types.d.ts +23 -3
  88. package/dist/modules/manager/util.js +28 -1
  89. package/dist/modules/manager/util.js.map +1 -1
  90. package/dist/modules/manager/vendir/artifacts.js +3 -2
  91. package/dist/modules/manager/vendir/artifacts.js.map +1 -1
  92. package/dist/workers/repository/updates/generate.js +11 -4
  93. package/dist/workers/repository/updates/generate.js.map +1 -1
  94. package/package.json +1 -1
  95. package/renovate-schema.json +2 -2
  96. package/dist/modules/manager/copier/utils.js +0 -24
  97. package/dist/modules/manager/copier/utils.js.map +0 -1
@@ -8,6 +8,7 @@ import { ensureCacheDir, findLocalSiblingOrParent, isValidLocalPath, readLocalFi
8
8
  import { filterMap } from "../../../util/filter-map.js";
9
9
  import { isValid as isVersion } from "../../versioning/semver/index.js";
10
10
  import { getRepoStatus } from "../../../util/git/index.js";
11
+ import { resolveToolConstraint } from "../util.js";
11
12
  import { withGitEnvironment } from "../../../util/git/exec.js";
12
13
  import { getExtraDepsNotice } from "./artifacts-extra.js";
13
14
  import { getGoModulesInTidyOrder } from "./package-tree.js";
@@ -18,7 +19,7 @@ import semver from "semver";
18
19
  //#region lib/modules/manager/gomod/artifacts.ts
19
20
  const { major: major$1, valid: valid$1 } = semver;
20
21
  const gitExec = withGitEnvironment(["go"]);
21
- function getUpdateImportPathCmds(updatedDeps, { constraints }) {
22
+ async function getUpdateImportPathCmds(updatedDeps, config) {
22
23
  const invalidMajorDeps = updatedDeps.filter(({ newVersion }) => !valid$1(newVersion));
23
24
  if (invalidMajorDeps.length > 0) invalidMajorDeps.forEach(({ depName }) => logger.warn({ depName }, "Ignoring dependency: Could not get major version"));
24
25
  const updateImportCommands = updatedDeps.filter(({ newVersion }) => valid$1(newVersion) && !newVersion.endsWith("+incompatible")).map(({ depName, newVersion }) => ({
@@ -27,7 +28,7 @@ function getUpdateImportPathCmds(updatedDeps, { constraints }) {
27
28
  })).filter(({ depName, newMajor }) => depName.startsWith("gopkg.in/") || newMajor > 1).map(({ depName, newMajor }) => `mod upgrade --mod-name=${quote(depName)} -t=${newMajor}`);
28
29
  if (updateImportCommands.length > 0) {
29
30
  let installMarwanModArgs = "install github.com/marwan-at-work/mod/cmd/mod@latest";
30
- const gomodModCompatibility = constraints?.gomodMod;
31
+ const gomodModCompatibility = await resolveToolConstraint(config, "gomodMod");
31
32
  if (gomodModCompatibility) {
32
33
  if (gomodModCompatibility.startsWith("v") && isVersion(gomodModCompatibility.replace(regEx(/^v/), ""))) installMarwanModArgs = installMarwanModArgs.replace(regEx(/@latest$/), `@${gomodModCompatibility}`);
33
34
  else logger.debug({ gomodModCompatibility }, "marwan-at-work/mod compatibility range is not valid - skipping");
@@ -75,7 +76,7 @@ async function updateArtifacts({ packageFileName: goModFileName, updatedDeps, ne
75
76
  massagedGoMod = massagedGoMod.replace(inlineReplaceRegEx, inlineCommentOut).replace(blockReplaceRegEx, blockCommentOut);
76
77
  if (massagedGoMod !== newGoModContent) logger.debug("Removed some relative replace statements and comments from go.mod");
77
78
  }
78
- const goConstraints = deriveGoToolchainConstraints(config, newGoModContent);
79
+ const goConstraints = await deriveGoToolchainConstraints(config, newGoModContent);
79
80
  try {
80
81
  await writeLocalFile(goModFileName, massagedGoMod);
81
82
  const cmd = "go";
@@ -120,7 +121,7 @@ async function updateArtifacts({ packageFileName: goModFileName, updatedDeps, ne
120
121
  execCommands.push(`${cmd} ${args}`);
121
122
  const isImportPathUpdateRequired = config.postUpdateOptions?.includes("gomodUpdateImportPaths") && config.updateType === "major";
122
123
  if (isImportPathUpdateRequired) {
123
- const updateImportCmds = getUpdateImportPathCmds(updatedDeps, config);
124
+ const updateImportCmds = await getUpdateImportPathCmds(updatedDeps, config);
124
125
  if (updateImportCmds.length > 0) {
125
126
  logger.debug(updateImportCmds, "update import path commands included");
126
127
  execCommands.push(...updateImportCmds);
@@ -299,11 +300,12 @@ function getGoConstraints(content) {
299
300
  * 1. config: \`constraints.go\`
300
301
  * 1. \`go.mod\`: \`toolchain\` directive
301
302
  * 1. \`go.mod\`: \`go\` directive
303
+ * 1. the \`go\` constraint collected during extraction
302
304
  *
303
305
  * NOTE that the \`constraints.golang\` is not used (TODO #42601)
304
306
  */
305
- function deriveGoToolchainConstraints(config, newGoModContent) {
306
- return config.constraints?.go ?? getGoConstraints(newGoModContent);
307
+ async function deriveGoToolchainConstraints(config, newGoModContent) {
308
+ return await resolveToolConstraint(config, "go", () => getGoConstraints(newGoModContent));
307
309
  }
308
310
  //#endregion
309
311
  export { deriveGoToolchainConstraints, updateArtifacts };
@@ -1 +1 @@
1
- {"version":3,"file":"artifacts.js","names":["valid","major","isValid"],"sources":["../../../../lib/modules/manager/gomod/artifacts.ts"],"sourcesContent":["import { isString } from '@sindresorhus/is';\nimport semver from 'semver';\nimport { quote } from 'shlex';\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 { coerceArray } from '../../../util/array.ts';\nimport { getEnv } from '../../../util/env.ts';\nimport type { ExecOptions } from '../../../util/exec/types.ts';\nimport { filterMap } from '../../../util/filter-map.ts';\nimport {\n ensureCacheDir,\n findLocalSiblingOrParent,\n isValidLocalPath,\n readLocalFile,\n writeLocalFile,\n} from '../../../util/fs/index.ts';\nimport { withGitEnvironment } from '../../../util/git/exec.ts';\nimport { getRepoStatus } from '../../../util/git/index.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { isValid } from '../../versioning/semver/index.ts';\nimport type {\n PackageDependency,\n UpdateArtifact,\n UpdateArtifactsConfig,\n UpdateArtifactsResult,\n} from '../types.ts';\nimport { getExtraDepsNotice } from './artifacts-extra.ts';\nimport { getGoModulesInTidyOrder } from './package-tree.ts';\n\nconst { major, valid } = semver;\nconst gitExec = withGitEnvironment(['go']);\n\nfunction getUpdateImportPathCmds(\n updatedDeps: PackageDependency[],\n { constraints }: UpdateArtifactsConfig,\n): string[] {\n // Check if we fail to parse any major versions and log that they're skipped\n const invalidMajorDeps = updatedDeps.filter(\n ({ newVersion }) => !valid(newVersion),\n );\n if (invalidMajorDeps.length > 0) {\n invalidMajorDeps.forEach(({ depName }) =>\n logger.warn(\n { depName },\n 'Ignoring dependency: Could not get major version',\n ),\n );\n }\n\n const updateImportCommands = updatedDeps\n .filter(\n ({ newVersion }) =>\n valid(newVersion) && !newVersion!.endsWith('+incompatible'),\n )\n .map(({ depName, newVersion }) => ({\n depName: depName!,\n newMajor: major(newVersion!),\n }))\n // Skip path updates going from v0 to v1\n .filter(\n ({ depName, newMajor }) =>\n depName.startsWith('gopkg.in/') || newMajor > 1,\n )\n\n .map(\n ({ depName, newMajor }) =>\n `mod upgrade --mod-name=${quote(depName)} -t=${newMajor}`,\n );\n\n if (updateImportCommands.length > 0) {\n let installMarwanModArgs =\n 'install github.com/marwan-at-work/mod/cmd/mod@latest';\n const gomodModCompatibility = constraints?.gomodMod;\n if (gomodModCompatibility) {\n if (\n gomodModCompatibility.startsWith('v') &&\n isValid(gomodModCompatibility.replace(regEx(/^v/), ''))\n ) {\n installMarwanModArgs = installMarwanModArgs.replace(\n regEx(/@latest$/),\n `@${gomodModCompatibility}`,\n );\n } else {\n logger.debug(\n { gomodModCompatibility },\n 'marwan-at-work/mod compatibility range is not valid - skipping',\n );\n }\n } else {\n logger.debug(\n 'No marwan-at-work/mod compatibility range found - installing marwan-at-work/mod latest',\n );\n }\n updateImportCommands.unshift(`go ${installMarwanModArgs}`);\n }\n\n return updateImportCommands;\n}\n\nfunction useModcacherw(goVersion: string | undefined): boolean {\n if (!isString(goVersion)) {\n return true;\n }\n\n return semver.intersects(goVersion, `>=1.14`);\n}\n\nexport async function updateArtifacts({\n packageFileName: goModFileName,\n updatedDeps,\n newPackageFileContent: newGoModContent,\n config,\n}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {\n logger.debug(`gomod.updateArtifacts(${goModFileName})`);\n\n const sumFileName = goModFileName.replace(regEx(/\\.mod$/), '.sum');\n const existingGoSumContent = await readLocalFile(sumFileName);\n if (!existingGoSumContent) {\n logger.debug('No go.sum found');\n return null;\n }\n const goModDir = upath.dirname(goModFileName);\n const goModFileBaseName = upath.basename(goModFileName);\n const modFileFlag =\n goModFileBaseName === 'go.mod'\n ? ''\n : ` -modfile=${quote(goModFileBaseName)}`;\n\n // The \"vendor\" directory can be next to the go.mod, but also in the parent directory in case\n // the go workspaces are used.\n const vendorDir = await findLocalSiblingOrParent(goModFileName, 'vendor');\n const vendorModulesFileName = upath.join(vendorDir ?? '', 'modules.txt');\n const useVendor =\n !!config.postUpdateOptions?.includes('gomodVendor') ||\n (!config.postUpdateOptions?.includes('gomodSkipVendor') &&\n vendorDir &&\n (await readLocalFile(vendorModulesFileName)) !== null);\n let massagedGoMod = newGoModContent;\n const useGoGenerate = !!config.postUpdateOptions?.includes('goGenerate');\n const allowedUnsafeExecutions = GlobalConfig.get('allowedUnsafeExecutions');\n const goGenerateAllowed = allowedUnsafeExecutions?.includes('goGenerate');\n\n if (config.postUpdateOptions?.includes('gomodMassage')) {\n // Regex match inline replace directive, example:\n // replace golang.org/x/net v1.2.3 => example.com/fork/net v1.4.5\n // https://go.dev/ref/mod#go-mod-file-replace\n\n // replace bracket after comments, so it doesn't break the regex, doing a complex regex causes problems\n // when there's a comment and \")\" after it, the regex will read replace block until comment.. and stop.\n massagedGoMod = massagedGoMod\n .split('\\n')\n .map((line) => {\n if (line.trim().startsWith('//')) {\n return line.replace(')', 'renovate-replace-bracket');\n }\n return line;\n })\n .join('\\n');\n\n const inlineReplaceRegEx = regEx(\n /(?<newline>\\r?\\n)(?<directive>replace\\s+[^\\s]+\\s+=>\\s+\\.\\.\\/.*)/g,\n );\n\n // $<newline> will be matched with the (\\r?\\n) group\n // $<directive> will be matched with the inline replace match, example\n // \"// renovate-replace replace golang.org/x/net v1.2.3 => example.com/fork/net v1.4.5\"\n const inlineCommentOut = '$<newline>// renovate-replace $<directive>';\n\n // Regex match replace directive block, example:\n // replace (\n // golang.org/x/net v1.2.3 => example.com/fork/net v1.4.5\n // )\n const blockReplaceRegEx = regEx(/(?:\\r?\\n)replace\\s*\\([^)]+\\s*\\)/g);\n\n /**\n * replacerFunction for commenting out replace blocks\n * @param match A string representing a golang replace directive block\n * @returns A commented out block with // renovate-replace\n */\n function blockCommentOut(match: string): string {\n return match.replace(\n regEx(/(?<newline>\\r?\\n)/g),\n '$<newline>// renovate-replace ',\n );\n }\n\n // Comment out golang replace directives\n massagedGoMod = massagedGoMod\n .replace(inlineReplaceRegEx, inlineCommentOut)\n .replace(blockReplaceRegEx, blockCommentOut);\n\n if (massagedGoMod !== newGoModContent) {\n logger.debug(\n 'Removed some relative replace statements and comments from go.mod',\n );\n }\n }\n const goConstraints = deriveGoToolchainConstraints(config, newGoModContent);\n\n try {\n await writeLocalFile(goModFileName, massagedGoMod);\n\n const cmd = 'go';\n const env = getEnv();\n const execOptions: ExecOptions = {\n cwdFile: goModFileName,\n extraEnv: {\n GOPATH: await ensureCacheDir('go'),\n GOPROXY: env.GOPROXY,\n GOPRIVATE: env.GOPRIVATE,\n GONOPROXY: env.GONOPROXY,\n GONOSUMDB: env.GONOSUMDB,\n GOSUMDB: env.GOSUMDB,\n GOINSECURE: env.GOINSECURE,\n /* v8 ignore next -- TODO: add test */\n GOFLAGS: useModcacherw(goConstraints) ? '-modcacherw' : null,\n CGO_ENABLED: GlobalConfig.get('binarySource') === 'docker' ? '0' : null,\n },\n docker: {},\n toolConstraints: [\n {\n toolName: 'golang',\n constraint: goConstraints,\n },\n ],\n };\n\n const execCommands: string[] = [];\n\n let goGetDirs: string | undefined;\n if (config.goGetDirs) {\n goGetDirs = config.goGetDirs\n .filter((dir) => {\n const isValid = isValidLocalPath(dir);\n if (!isValid) {\n logger.warn({ dir }, 'Invalid path in goGetDirs');\n }\n return isValid;\n })\n .map(quote)\n .join(' ');\n\n if (goGetDirs === '') {\n throw new Error('Invalid goGetDirs');\n }\n }\n\n let args = `get${modFileFlag} `;\n\n if (goConstraints && !semver.intersects(goConstraints, `>=1.18`)) {\n // For Go versions < 1.18, we need to use the -d flag to avoid builds or installs\n // https://go.dev/doc/go1.18#go-get\n args += `-d `;\n }\n\n args += `-t ${goGetDirs ?? './...'}`;\n logger.trace({ cmd, args }, 'go get command included');\n execCommands.push(`${cmd} ${args}`);\n\n // Update import paths on major updates\n const isImportPathUpdateRequired =\n config.postUpdateOptions?.includes('gomodUpdateImportPaths') &&\n config.updateType === 'major';\n\n if (isImportPathUpdateRequired) {\n const updateImportCmds = getUpdateImportPathCmds(updatedDeps, config);\n if (updateImportCmds.length > 0) {\n logger.debug(updateImportCmds, 'update import path commands included');\n // The updates\n execCommands.push(...updateImportCmds);\n }\n }\n\n const mustSkipGoModTidy =\n !config.postUpdateOptions?.includes('gomodUpdateImportPaths') &&\n config.updateType === 'major';\n if (mustSkipGoModTidy) {\n logger.debug('go mod tidy command skipped');\n }\n\n let tidyOpts = '';\n if (config.postUpdateOptions?.includes('gomodTidy1.17')) {\n tidyOpts += ' -compat=1.17';\n }\n if (config.postUpdateOptions?.includes('gomodTidyE')) {\n tidyOpts += ' -e';\n }\n\n // dependent modules can only be tidied once the updated module is settled\n const isGoModTidyAllRequired =\n config.postUpdateOptions?.includes('gomodTidyAll') === true;\n const isGoModTidyRequired =\n !mustSkipGoModTidy &&\n (config.postUpdateOptions?.includes('gomodTidy') === true ||\n config.postUpdateOptions?.includes('gomodTidy1.17') === true ||\n config.postUpdateOptions?.includes('gomodTidyE') === true ||\n isGoModTidyAllRequired ||\n (config.updateType === 'major' && isImportPathUpdateRequired));\n if (isGoModTidyRequired) {\n args = `mod tidy${modFileFlag}${tidyOpts}`;\n logger.debug('go mod tidy command included');\n execCommands.push(`${cmd} ${args}`);\n }\n\n let goWorkSumFileName = upath.join(goModDir, 'go.work.sum');\n if (useVendor) {\n // If we find a go.work, then use go workspace vendoring.\n const goWorkFile = await findLocalSiblingOrParent(\n goModFileName,\n 'go.work',\n );\n\n if (goWorkFile) {\n goWorkSumFileName = upath.join(\n upath.dirname(goWorkFile),\n 'go.work.sum',\n );\n\n args = 'work vendor';\n logger.debug('using go work vendor');\n execCommands.push(`${cmd} ${args}`);\n\n args = 'work sync';\n logger.debug('using go work sync');\n execCommands.push(`${cmd} ${args}`);\n } else {\n args = `mod vendor${modFileFlag}`;\n logger.debug('using go mod vendor');\n execCommands.push(`${cmd} ${args}`);\n }\n\n if (isGoModTidyRequired) {\n args = `mod tidy${modFileFlag}${tidyOpts}`;\n logger.debug('go mod tidy command included');\n execCommands.push(`${cmd} ${args}`);\n }\n }\n\n // We tidy one more time as a solution for #6795\n if (isGoModTidyRequired) {\n args = `mod tidy${modFileFlag}${tidyOpts}`;\n logger.debug('go mod tidy command included');\n execCommands.push(`${cmd} ${args}`);\n }\n\n let dependentModules: string[] = [];\n if (isGoModTidyAllRequired) {\n try {\n dependentModules = await getGoModulesInTidyOrder(goModFileName);\n for (const dependent of dependentModules) {\n const dir = upath.relative(goModDir, upath.dirname(dependent));\n execCommands.push(`${cmd} -C ${quote(dir)} mod tidy${tidyOpts}`);\n }\n logger.debug({ dependentModules }, 'go mod tidy commands included');\n } catch (err) {\n logger.warn({ err }, 'Failed to find dependent Go modules');\n }\n }\n\n if (useGoGenerate) {\n if (goGenerateAllowed) {\n logger.debug('go generate command included');\n execCommands.push(`${cmd} generate ./...`);\n } else {\n logger.once.warn(\n `go generate command requested as a post update action, but goGenerate is not permitted in the allowedUnsafeExecutions`,\n );\n }\n }\n\n await gitExec(execCommands, execOptions);\n\n const status = await getRepoStatus();\n const dependentFiles = dependentModules.flatMap((f) => [\n f,\n f.replace(regEx(/\\.mod$/), '.sum'),\n ]);\n\n if (\n !status.modified.includes(sumFileName) &&\n !status.modified.includes(goModFileName) &&\n !status.modified.includes(goWorkSumFileName) &&\n !dependentFiles.some((f) => status.modified.includes(f))\n ) {\n return null;\n }\n\n const res: UpdateArtifactsResult[] = [];\n if (status.modified.includes(sumFileName)) {\n logger.debug('Returning updated go.sum');\n res.push({\n file: {\n type: 'addition',\n path: sumFileName,\n contents: await readLocalFile(sumFileName),\n },\n });\n }\n\n if (status.modified.includes(goWorkSumFileName)) {\n logger.debug('Returning updated go.work.sum');\n res.push({\n file: {\n type: 'addition',\n path: goWorkSumFileName,\n contents: await readLocalFile(goWorkSumFileName),\n },\n });\n }\n\n for (const f of dependentFiles) {\n if (status.modified.includes(f)) {\n logger.trace(`Returning updated ${f}`);\n res.push({\n file: {\n type: 'addition',\n path: f,\n contents: await readLocalFile(f),\n },\n });\n }\n }\n\n // Include all the .go file import changes\n if (isImportPathUpdateRequired) {\n logger.debug('Returning updated go source files for import path changes');\n for (const f of status.modified) {\n if (f.endsWith('.go')) {\n res.push({\n file: {\n type: 'addition',\n path: f,\n contents: await readLocalFile(f),\n },\n });\n }\n }\n }\n\n const alreadyAdded = new Set<string>();\n const alreadyDeleted = new Set<string>();\n if (useVendor) {\n for (const f of status.modified.concat(status.not_added)) {\n if (vendorDir && f.startsWith(vendorDir)) {\n alreadyAdded.add(f);\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 coerceArray(status.deleted)) {\n if (vendorDir && f.startsWith(vendorDir)) {\n alreadyDeleted.add(f);\n res.push({\n file: {\n type: 'deletion',\n path: f,\n },\n });\n }\n }\n }\n\n // TODO: throws in tests (#22198)\n const finalGoModContent = (await readLocalFile(goModFileName, 'utf8'))!\n .replace(regEx(/\\/\\/ renovate-replace /g), '')\n .replace(regEx(/renovate-replace-bracket/g), ')');\n if (finalGoModContent !== newGoModContent) {\n const artifactResult: UpdateArtifactsResult = {\n file: {\n type: 'addition',\n path: goModFileName,\n contents: finalGoModContent,\n },\n };\n\n const updatedDepNames = filterMap(updatedDeps, (dep) => dep?.depName);\n const extraDepsNotice = getExtraDepsNotice(\n newGoModContent,\n finalGoModContent,\n updatedDepNames,\n config,\n );\n\n if (extraDepsNotice) {\n artifactResult.notice = {\n file: goModFileName,\n message: extraDepsNotice,\n };\n }\n\n logger.debug('Found updated go.mod after go.sum update');\n res.push(artifactResult);\n alreadyAdded.add(goModFileName);\n }\n\n // add all files added when in `go generate` mode.\n // unfortunately there is not a good way as there is with vendoring or go import path updates to detect this.\n // Do this at the very very end to ensure we only capture files which would have been explicitly\n // modified, added, or deleted from a `go generate` invocation\n if (useGoGenerate && goGenerateAllowed) {\n logger.debug(\n 'Updating all modified files since generated files were added',\n );\n for (const f of status.modified.concat(status.created)) {\n if (!alreadyAdded.has(f)) {\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 coerceArray(status.deleted)) {\n if (!alreadyDeleted.has(f)) {\n res.push({\n file: {\n type: 'deletion',\n path: f,\n },\n });\n }\n }\n }\n return res;\n } catch (err) {\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n logger.debug({ err }, 'Failed to update go.sum');\n return [\n {\n artifactError: {\n fileName: sumFileName,\n stderr: err.message,\n },\n },\n ];\n }\n}\n\nfunction getGoConstraints(content: string): string | undefined {\n // prefer toolchain directive when go.mod has one\n const toolchainMatch = regEx(/^toolchain\\s*go(?<gover>\\d+\\.\\d+\\.\\d+)$/m).exec(\n content,\n );\n const toolchainVer = toolchainMatch?.groups?.gover;\n if (toolchainVer) {\n logger.debug(\n `Using go version ${toolchainVer} found in toolchain directive`,\n );\n return toolchainVer;\n }\n\n // If go.mod doesn't have toolchain directive and has a full go version spec,\n // for example `go 1.23.6`, pick this version, this doesn't match major.minor version spec.\n //\n // This is because when go.mod have same version defined in go directive and toolchain directive,\n // go will remove toolchain directive from go.mod.\n //\n // For example, go will rewrite `go 1.23.5\\ntoolchain go1.23.5` to `go 1.23.5` by default,\n // in this case, the go directive is the toolchain directive.\n const goFullVersion = regEx(/^go\\s*(?<gover>\\d+\\.\\d+\\.\\d+)$/m).exec(content)\n ?.groups?.gover;\n if (goFullVersion) {\n return goFullVersion;\n }\n\n const re = regEx(/^go\\s*(?<gover>\\d+\\.\\d+)$/m);\n const match = re.exec(content);\n if (!match?.groups?.gover) {\n return undefined;\n }\n return `^${match.groups.gover}`;\n}\n\n/**\n * Derive the version of the Go toolchain needed to run this project.\n *\n * This matches with the `golang` Containerbase tool.\n *\n * In precedence order:\n *\n * 1. config: \\`constraints.go\\`\n * 1. \\`go.mod\\`: \\`toolchain\\` directive\n * 1. \\`go.mod\\`: \\`go\\` directive\n *\n * NOTE that the \\`constraints.golang\\` is not used (TODO #42601)\n */\nexport function deriveGoToolchainConstraints(\n config: UpdateArtifactsConfig,\n newGoModContent: string,\n): string | undefined {\n return config.constraints?.go ?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eA,SAAgB,6BACd,QACA,iBACoB;CACpB,OAAO,OAAO,aAAa,MAAM,iBAAiB,eAAe;AACnE"}
1
+ {"version":3,"file":"artifacts.js","names":["valid","major","isValid"],"sources":["../../../../lib/modules/manager/gomod/artifacts.ts"],"sourcesContent":["import { isString } from '@sindresorhus/is';\nimport semver from 'semver';\nimport { quote } from 'shlex';\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 { coerceArray } from '../../../util/array.ts';\nimport { getEnv } from '../../../util/env.ts';\nimport type { ExecOptions } from '../../../util/exec/types.ts';\nimport { filterMap } from '../../../util/filter-map.ts';\nimport {\n ensureCacheDir,\n findLocalSiblingOrParent,\n isValidLocalPath,\n readLocalFile,\n writeLocalFile,\n} from '../../../util/fs/index.ts';\nimport { withGitEnvironment } from '../../../util/git/exec.ts';\nimport { getRepoStatus } from '../../../util/git/index.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { isValid } from '../../versioning/semver/index.ts';\nimport type {\n PackageDependency,\n UpdateArtifact,\n UpdateArtifactsConfig,\n UpdateArtifactsResult,\n} from '../types.ts';\nimport { resolveToolConstraint } from '../util.ts';\nimport { getExtraDepsNotice } from './artifacts-extra.ts';\nimport { getGoModulesInTidyOrder } from './package-tree.ts';\n\nconst { major, valid } = semver;\nconst gitExec = withGitEnvironment(['go']);\n\nasync function getUpdateImportPathCmds(\n updatedDeps: PackageDependency[],\n config: UpdateArtifactsConfig,\n): Promise<string[]> {\n // Check if we fail to parse any major versions and log that they're skipped\n const invalidMajorDeps = updatedDeps.filter(\n ({ newVersion }) => !valid(newVersion),\n );\n if (invalidMajorDeps.length > 0) {\n invalidMajorDeps.forEach(({ depName }) =>\n logger.warn(\n { depName },\n 'Ignoring dependency: Could not get major version',\n ),\n );\n }\n\n const updateImportCommands = updatedDeps\n .filter(\n ({ newVersion }) =>\n valid(newVersion) && !newVersion!.endsWith('+incompatible'),\n )\n .map(({ depName, newVersion }) => ({\n depName: depName!,\n newMajor: major(newVersion!),\n }))\n // Skip path updates going from v0 to v1\n .filter(\n ({ depName, newMajor }) =>\n depName.startsWith('gopkg.in/') || newMajor > 1,\n )\n\n .map(\n ({ depName, newMajor }) =>\n `mod upgrade --mod-name=${quote(depName)} -t=${newMajor}`,\n );\n\n if (updateImportCommands.length > 0) {\n let installMarwanModArgs =\n 'install github.com/marwan-at-work/mod/cmd/mod@latest';\n const gomodModCompatibility = await resolveToolConstraint(\n config,\n 'gomodMod',\n );\n if (gomodModCompatibility) {\n if (\n gomodModCompatibility.startsWith('v') &&\n isValid(gomodModCompatibility.replace(regEx(/^v/), ''))\n ) {\n installMarwanModArgs = installMarwanModArgs.replace(\n regEx(/@latest$/),\n `@${gomodModCompatibility}`,\n );\n } else {\n logger.debug(\n { gomodModCompatibility },\n 'marwan-at-work/mod compatibility range is not valid - skipping',\n );\n }\n } else {\n logger.debug(\n 'No marwan-at-work/mod compatibility range found - installing marwan-at-work/mod latest',\n );\n }\n updateImportCommands.unshift(`go ${installMarwanModArgs}`);\n }\n\n return updateImportCommands;\n}\n\nfunction useModcacherw(goVersion: string | undefined): boolean {\n if (!isString(goVersion)) {\n return true;\n }\n\n return semver.intersects(goVersion, `>=1.14`);\n}\n\nexport async function updateArtifacts({\n packageFileName: goModFileName,\n updatedDeps,\n newPackageFileContent: newGoModContent,\n config,\n}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {\n logger.debug(`gomod.updateArtifacts(${goModFileName})`);\n\n const sumFileName = goModFileName.replace(regEx(/\\.mod$/), '.sum');\n const existingGoSumContent = await readLocalFile(sumFileName);\n if (!existingGoSumContent) {\n logger.debug('No go.sum found');\n return null;\n }\n const goModDir = upath.dirname(goModFileName);\n const goModFileBaseName = upath.basename(goModFileName);\n const modFileFlag =\n goModFileBaseName === 'go.mod'\n ? ''\n : ` -modfile=${quote(goModFileBaseName)}`;\n\n // The \"vendor\" directory can be next to the go.mod, but also in the parent directory in case\n // the go workspaces are used.\n const vendorDir = await findLocalSiblingOrParent(goModFileName, 'vendor');\n const vendorModulesFileName = upath.join(vendorDir ?? '', 'modules.txt');\n const useVendor =\n !!config.postUpdateOptions?.includes('gomodVendor') ||\n (!config.postUpdateOptions?.includes('gomodSkipVendor') &&\n vendorDir &&\n (await readLocalFile(vendorModulesFileName)) !== null);\n let massagedGoMod = newGoModContent;\n const useGoGenerate = !!config.postUpdateOptions?.includes('goGenerate');\n const allowedUnsafeExecutions = GlobalConfig.get('allowedUnsafeExecutions');\n const goGenerateAllowed = allowedUnsafeExecutions?.includes('goGenerate');\n\n if (config.postUpdateOptions?.includes('gomodMassage')) {\n // Regex match inline replace directive, example:\n // replace golang.org/x/net v1.2.3 => example.com/fork/net v1.4.5\n // https://go.dev/ref/mod#go-mod-file-replace\n\n // replace bracket after comments, so it doesn't break the regex, doing a complex regex causes problems\n // when there's a comment and \")\" after it, the regex will read replace block until comment.. and stop.\n massagedGoMod = massagedGoMod\n .split('\\n')\n .map((line) => {\n if (line.trim().startsWith('//')) {\n return line.replace(')', 'renovate-replace-bracket');\n }\n return line;\n })\n .join('\\n');\n\n const inlineReplaceRegEx = regEx(\n /(?<newline>\\r?\\n)(?<directive>replace\\s+[^\\s]+\\s+=>\\s+\\.\\.\\/.*)/g,\n );\n\n // $<newline> will be matched with the (\\r?\\n) group\n // $<directive> will be matched with the inline replace match, example\n // \"// renovate-replace replace golang.org/x/net v1.2.3 => example.com/fork/net v1.4.5\"\n const inlineCommentOut = '$<newline>// renovate-replace $<directive>';\n\n // Regex match replace directive block, example:\n // replace (\n // golang.org/x/net v1.2.3 => example.com/fork/net v1.4.5\n // )\n const blockReplaceRegEx = regEx(/(?:\\r?\\n)replace\\s*\\([^)]+\\s*\\)/g);\n\n /**\n * replacerFunction for commenting out replace blocks\n * @param match A string representing a golang replace directive block\n * @returns A commented out block with // renovate-replace\n */\n function blockCommentOut(match: string): string {\n return match.replace(\n regEx(/(?<newline>\\r?\\n)/g),\n '$<newline>// renovate-replace ',\n );\n }\n\n // Comment out golang replace directives\n massagedGoMod = massagedGoMod\n .replace(inlineReplaceRegEx, inlineCommentOut)\n .replace(blockReplaceRegEx, blockCommentOut);\n\n if (massagedGoMod !== newGoModContent) {\n logger.debug(\n 'Removed some relative replace statements and comments from go.mod',\n );\n }\n }\n const goConstraints = await deriveGoToolchainConstraints(\n config,\n newGoModContent,\n );\n\n try {\n await writeLocalFile(goModFileName, massagedGoMod);\n\n const cmd = 'go';\n const env = getEnv();\n const execOptions: ExecOptions = {\n cwdFile: goModFileName,\n extraEnv: {\n GOPATH: await ensureCacheDir('go'),\n GOPROXY: env.GOPROXY,\n GOPRIVATE: env.GOPRIVATE,\n GONOPROXY: env.GONOPROXY,\n GONOSUMDB: env.GONOSUMDB,\n GOSUMDB: env.GOSUMDB,\n GOINSECURE: env.GOINSECURE,\n /* v8 ignore next -- TODO: add test */\n GOFLAGS: useModcacherw(goConstraints) ? '-modcacherw' : null,\n CGO_ENABLED: GlobalConfig.get('binarySource') === 'docker' ? '0' : null,\n },\n docker: {},\n toolConstraints: [\n {\n toolName: 'golang',\n constraint: goConstraints,\n },\n ],\n };\n\n const execCommands: string[] = [];\n\n let goGetDirs: string | undefined;\n if (config.goGetDirs) {\n goGetDirs = config.goGetDirs\n .filter((dir) => {\n const isValid = isValidLocalPath(dir);\n if (!isValid) {\n logger.warn({ dir }, 'Invalid path in goGetDirs');\n }\n return isValid;\n })\n .map(quote)\n .join(' ');\n\n if (goGetDirs === '') {\n throw new Error('Invalid goGetDirs');\n }\n }\n\n let args = `get${modFileFlag} `;\n\n if (goConstraints && !semver.intersects(goConstraints, `>=1.18`)) {\n // For Go versions < 1.18, we need to use the -d flag to avoid builds or installs\n // https://go.dev/doc/go1.18#go-get\n args += `-d `;\n }\n\n args += `-t ${goGetDirs ?? './...'}`;\n logger.trace({ cmd, args }, 'go get command included');\n execCommands.push(`${cmd} ${args}`);\n\n // Update import paths on major updates\n const isImportPathUpdateRequired =\n config.postUpdateOptions?.includes('gomodUpdateImportPaths') &&\n config.updateType === 'major';\n\n if (isImportPathUpdateRequired) {\n const updateImportCmds = await getUpdateImportPathCmds(\n updatedDeps,\n config,\n );\n if (updateImportCmds.length > 0) {\n logger.debug(updateImportCmds, 'update import path commands included');\n // The updates\n execCommands.push(...updateImportCmds);\n }\n }\n\n const mustSkipGoModTidy =\n !config.postUpdateOptions?.includes('gomodUpdateImportPaths') &&\n config.updateType === 'major';\n if (mustSkipGoModTidy) {\n logger.debug('go mod tidy command skipped');\n }\n\n let tidyOpts = '';\n if (config.postUpdateOptions?.includes('gomodTidy1.17')) {\n tidyOpts += ' -compat=1.17';\n }\n if (config.postUpdateOptions?.includes('gomodTidyE')) {\n tidyOpts += ' -e';\n }\n\n // dependent modules can only be tidied once the updated module is settled\n const isGoModTidyAllRequired =\n config.postUpdateOptions?.includes('gomodTidyAll') === true;\n const isGoModTidyRequired =\n !mustSkipGoModTidy &&\n (config.postUpdateOptions?.includes('gomodTidy') === true ||\n config.postUpdateOptions?.includes('gomodTidy1.17') === true ||\n config.postUpdateOptions?.includes('gomodTidyE') === true ||\n isGoModTidyAllRequired ||\n (config.updateType === 'major' && isImportPathUpdateRequired));\n if (isGoModTidyRequired) {\n args = `mod tidy${modFileFlag}${tidyOpts}`;\n logger.debug('go mod tidy command included');\n execCommands.push(`${cmd} ${args}`);\n }\n\n let goWorkSumFileName = upath.join(goModDir, 'go.work.sum');\n if (useVendor) {\n // If we find a go.work, then use go workspace vendoring.\n const goWorkFile = await findLocalSiblingOrParent(\n goModFileName,\n 'go.work',\n );\n\n if (goWorkFile) {\n goWorkSumFileName = upath.join(\n upath.dirname(goWorkFile),\n 'go.work.sum',\n );\n\n args = 'work vendor';\n logger.debug('using go work vendor');\n execCommands.push(`${cmd} ${args}`);\n\n args = 'work sync';\n logger.debug('using go work sync');\n execCommands.push(`${cmd} ${args}`);\n } else {\n args = `mod vendor${modFileFlag}`;\n logger.debug('using go mod vendor');\n execCommands.push(`${cmd} ${args}`);\n }\n\n if (isGoModTidyRequired) {\n args = `mod tidy${modFileFlag}${tidyOpts}`;\n logger.debug('go mod tidy command included');\n execCommands.push(`${cmd} ${args}`);\n }\n }\n\n // We tidy one more time as a solution for #6795\n if (isGoModTidyRequired) {\n args = `mod tidy${modFileFlag}${tidyOpts}`;\n logger.debug('go mod tidy command included');\n execCommands.push(`${cmd} ${args}`);\n }\n\n let dependentModules: string[] = [];\n if (isGoModTidyAllRequired) {\n try {\n dependentModules = await getGoModulesInTidyOrder(goModFileName);\n for (const dependent of dependentModules) {\n const dir = upath.relative(goModDir, upath.dirname(dependent));\n execCommands.push(`${cmd} -C ${quote(dir)} mod tidy${tidyOpts}`);\n }\n logger.debug({ dependentModules }, 'go mod tidy commands included');\n } catch (err) {\n logger.warn({ err }, 'Failed to find dependent Go modules');\n }\n }\n\n if (useGoGenerate) {\n if (goGenerateAllowed) {\n logger.debug('go generate command included');\n execCommands.push(`${cmd} generate ./...`);\n } else {\n logger.once.warn(\n `go generate command requested as a post update action, but goGenerate is not permitted in the allowedUnsafeExecutions`,\n );\n }\n }\n\n await gitExec(execCommands, execOptions);\n\n const status = await getRepoStatus();\n const dependentFiles = dependentModules.flatMap((f) => [\n f,\n f.replace(regEx(/\\.mod$/), '.sum'),\n ]);\n\n if (\n !status.modified.includes(sumFileName) &&\n !status.modified.includes(goModFileName) &&\n !status.modified.includes(goWorkSumFileName) &&\n !dependentFiles.some((f) => status.modified.includes(f))\n ) {\n return null;\n }\n\n const res: UpdateArtifactsResult[] = [];\n if (status.modified.includes(sumFileName)) {\n logger.debug('Returning updated go.sum');\n res.push({\n file: {\n type: 'addition',\n path: sumFileName,\n contents: await readLocalFile(sumFileName),\n },\n });\n }\n\n if (status.modified.includes(goWorkSumFileName)) {\n logger.debug('Returning updated go.work.sum');\n res.push({\n file: {\n type: 'addition',\n path: goWorkSumFileName,\n contents: await readLocalFile(goWorkSumFileName),\n },\n });\n }\n\n for (const f of dependentFiles) {\n if (status.modified.includes(f)) {\n logger.trace(`Returning updated ${f}`);\n res.push({\n file: {\n type: 'addition',\n path: f,\n contents: await readLocalFile(f),\n },\n });\n }\n }\n\n // Include all the .go file import changes\n if (isImportPathUpdateRequired) {\n logger.debug('Returning updated go source files for import path changes');\n for (const f of status.modified) {\n if (f.endsWith('.go')) {\n res.push({\n file: {\n type: 'addition',\n path: f,\n contents: await readLocalFile(f),\n },\n });\n }\n }\n }\n\n const alreadyAdded = new Set<string>();\n const alreadyDeleted = new Set<string>();\n if (useVendor) {\n for (const f of status.modified.concat(status.not_added)) {\n if (vendorDir && f.startsWith(vendorDir)) {\n alreadyAdded.add(f);\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 coerceArray(status.deleted)) {\n if (vendorDir && f.startsWith(vendorDir)) {\n alreadyDeleted.add(f);\n res.push({\n file: {\n type: 'deletion',\n path: f,\n },\n });\n }\n }\n }\n\n // TODO: throws in tests (#22198)\n const finalGoModContent = (await readLocalFile(goModFileName, 'utf8'))!\n .replace(regEx(/\\/\\/ renovate-replace /g), '')\n .replace(regEx(/renovate-replace-bracket/g), ')');\n if (finalGoModContent !== newGoModContent) {\n const artifactResult: UpdateArtifactsResult = {\n file: {\n type: 'addition',\n path: goModFileName,\n contents: finalGoModContent,\n },\n };\n\n const updatedDepNames = filterMap(updatedDeps, (dep) => dep?.depName);\n const extraDepsNotice = getExtraDepsNotice(\n newGoModContent,\n finalGoModContent,\n updatedDepNames,\n config,\n );\n\n if (extraDepsNotice) {\n artifactResult.notice = {\n file: goModFileName,\n message: extraDepsNotice,\n };\n }\n\n logger.debug('Found updated go.mod after go.sum update');\n res.push(artifactResult);\n alreadyAdded.add(goModFileName);\n }\n\n // add all files added when in `go generate` mode.\n // unfortunately there is not a good way as there is with vendoring or go import path updates to detect this.\n // Do this at the very very end to ensure we only capture files which would have been explicitly\n // modified, added, or deleted from a `go generate` invocation\n if (useGoGenerate && goGenerateAllowed) {\n logger.debug(\n 'Updating all modified files since generated files were added',\n );\n for (const f of status.modified.concat(status.created)) {\n if (!alreadyAdded.has(f)) {\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 coerceArray(status.deleted)) {\n if (!alreadyDeleted.has(f)) {\n res.push({\n file: {\n type: 'deletion',\n path: f,\n },\n });\n }\n }\n }\n return res;\n } catch (err) {\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n logger.debug({ err }, 'Failed to update go.sum');\n return [\n {\n artifactError: {\n fileName: sumFileName,\n stderr: err.message,\n },\n },\n ];\n }\n}\n\nfunction getGoConstraints(content: string): string | undefined {\n // prefer toolchain directive when go.mod has one\n const toolchainMatch = regEx(/^toolchain\\s*go(?<gover>\\d+\\.\\d+\\.\\d+)$/m).exec(\n content,\n );\n const toolchainVer = toolchainMatch?.groups?.gover;\n if (toolchainVer) {\n logger.debug(\n `Using go version ${toolchainVer} found in toolchain directive`,\n );\n return toolchainVer;\n }\n\n // If go.mod doesn't have toolchain directive and has a full go version spec,\n // for example `go 1.23.6`, pick this version, this doesn't match major.minor version spec.\n //\n // This is because when go.mod have same version defined in go directive and toolchain directive,\n // go will remove toolchain directive from go.mod.\n //\n // For example, go will rewrite `go 1.23.5\\ntoolchain go1.23.5` to `go 1.23.5` by default,\n // in this case, the go directive is the toolchain directive.\n const goFullVersion = regEx(/^go\\s*(?<gover>\\d+\\.\\d+\\.\\d+)$/m).exec(content)\n ?.groups?.gover;\n if (goFullVersion) {\n return goFullVersion;\n }\n\n const re = regEx(/^go\\s*(?<gover>\\d+\\.\\d+)$/m);\n const match = re.exec(content);\n if (!match?.groups?.gover) {\n return undefined;\n }\n return `^${match.groups.gover}`;\n}\n\n/**\n * Derive the version of the Go toolchain needed to run this project.\n *\n * This matches with the `golang` Containerbase tool.\n *\n * In precedence order:\n *\n * 1. config: \\`constraints.go\\`\n * 1. \\`go.mod\\`: \\`toolchain\\` directive\n * 1. \\`go.mod\\`: \\`go\\` directive\n * 1. the \\`go\\` constraint collected during extraction\n *\n * NOTE that the \\`constraints.golang\\` is not used (TODO #42601)\n */\nexport async function deriveGoToolchainConstraints(\n config: UpdateArtifactsConfig,\n newGoModContent: string,\n): Promise<string | undefined> {\n return await resolveToolConstraint(config, 'go', () =>\n getGoConstraints(newGoModContent),\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAgCA,MAAM,EAAE,OAAA,SAAO,OAAA,YAAU;AACzB,MAAM,UAAU,mBAAmB,CAAC,IAAI,CAAC;AAEzC,eAAe,wBACb,aACA,QACmB;CAEnB,MAAM,mBAAmB,YAAY,QAClC,EAAE,iBAAiB,CAACA,QAAM,UAAU,CACvC;CACA,IAAI,iBAAiB,SAAS,GAC5B,iBAAiB,SAAS,EAAE,cAC1B,OAAO,KACL,EAAE,QAAQ,GACV,kDACF,CACF;CAGF,MAAM,uBAAuB,YAC1B,QACE,EAAE,iBACDA,QAAM,UAAU,KAAK,CAAC,WAAY,SAAS,eAAe,CAC9D,CAAC,CACA,KAAK,EAAE,SAAS,kBAAkB;EACxB;EACT,UAAUC,QAAM,UAAW;CAC7B,EAAE,CAAC,CAEF,QACE,EAAE,SAAS,eACV,QAAQ,WAAW,WAAW,KAAK,WAAW,CAClD,CAAC,CAEA,KACE,EAAE,SAAS,eACV,0BAA0B,MAAM,OAAO,EAAE,MAAM,UACnD;CAEF,IAAI,qBAAqB,SAAS,GAAG;EACnC,IAAI,uBACF;EACF,MAAM,wBAAwB,MAAM,sBAClC,QACA,UACF;EACA,IAAI,uBAAuB;GACzB,IACE,sBAAsB,WAAW,GAAG,KACpCC,UAAQ,sBAAsB,QAAQ,MAAM,IAAI,GAAG,EAAE,CAAC,GAEtD,uBAAuB,qBAAqB,QAC1C,MAAM,UAAU,GAChB,IAAI,uBACN;QAEA,OAAO,MACL,EAAE,sBAAsB,GACxB,gEACF;EAEJ,OACE,OAAO,MACL,wFACF;EAEF,qBAAqB,QAAQ,M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iCAAiC,CAAC,CAAC,KAAK,OAAO,CAAC,EACxE,QAAQ;CACZ,IAAI,eACF,OAAO;CAIT,MAAM,QADK,MAAM,4BACF,CAAC,CAAC,KAAK,OAAO;CAC7B,IAAI,CAAC,OAAO,QAAQ,OAClB;CAEF,OAAO,IAAI,MAAM,OAAO;AAC1B;;;;;;;;;;;;;;;AAgBA,eAAsB,6BACpB,QACA,iBAC6B;CAC7B,OAAO,MAAM,sBAAsB,QAAQ,YACzC,iBAAiB,eAAe,CAClC;AACF"}
@@ -5,6 +5,7 @@ import { logger } from "../../../logger/index.js";
5
5
  import { findUpLocal, readLocalFile, writeLocalFile } from "../../../util/fs/index.js";
6
6
  import { exec, getToolSettingsOptions, gradleJvmArg } from "../../../util/exec/index.js";
7
7
  import { getFiles, getRepoStatus } from "../../../util/git/index.js";
8
+ import { resolveToolConstraint } from "../util.js";
8
9
  import { scm } from "../../platform/scm.js";
9
10
  import { isGradleBuildFile } from "./utils.js";
10
11
  import { extraEnv, extractGradleVersion, getJavaConstraint, gradleWrapperFileName, prepareGradleCommand } from "../gradle-wrapper/utils.js";
@@ -102,7 +103,7 @@ async function updateArtifacts({ packageFileName, updatedDeps, newPackageFileCon
102
103
  extraEnv,
103
104
  toolConstraints: [{
104
105
  toolName: "java",
105
- constraint: config.constraints?.java ?? await getJavaConstraint(await getGradleVersion(gradlewFile), gradlewFile)
106
+ constraint: await resolveToolConstraint(config, "java", async () => getJavaConstraint(await getGradleVersion(gradlewFile), gradlewFile))
106
107
  }]
107
108
  };
108
109
  const cmds = [];
@@ -1 +1 @@
1
- {"version":3,"file":"artifacts.js","names":[],"sources":["../../../../lib/modules/manager/gradle/artifacts.ts"],"sourcesContent":["import { isNonEmptyStringAndNotWhitespace } from '@sindresorhus/is';\nimport { quote } from 'shlex';\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 {\n exec,\n getToolSettingsOptions,\n gradleJvmArg,\n} from '../../../util/exec/index.ts';\nimport type { ExecOptions } from '../../../util/exec/types.ts';\nimport {\n findUpLocal,\n readLocalFile,\n writeLocalFile,\n} from '../../../util/fs/index.ts';\nimport { getFiles, getRepoStatus } from '../../../util/git/index.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { scm } from '../../platform/scm.ts';\nimport {\n extraEnv,\n extractGradleVersion,\n getJavaConstraint,\n gradleWrapperFileName,\n prepareGradleCommand,\n} from '../gradle-wrapper/utils.ts';\nimport type { UpdateArtifact, UpdateArtifactsResult } from '../types.ts';\nimport {\n isGcvLockFile,\n isGcvPropsFile,\n} from './extract/consistent-versions-plugin.ts';\nimport { isGradleBuildFile } from './utils.ts';\n\nexport function isGradleExecutionAllowed(command: string): boolean {\n const allowlist = GlobalConfig.get('allowedUnsafeExecutions');\n\n if (!allowlist.includes('gradleWrapper')) {\n logger.once.warn(\n { command },\n 'Gradle wrapper command was requested to run, but `gradleWrapper` is not permitted in the allowedUnsafeExecutions',\n );\n return false;\n }\n\n return true;\n}\n\n// .lockfile is gradle default lockfile, /versions.lock is gradle-consistent-versions plugin lockfile\nfunction isLockFile(fileName: string): boolean {\n return fileName.endsWith('.lockfile') || isGcvLockFile(fileName);\n}\n\nasync function getUpdatedLockfiles(\n oldLockFileContentMap: Record<string, string | null>,\n): Promise<UpdateArtifactsResult[]> {\n const res: UpdateArtifactsResult[] = [];\n\n const status = await getRepoStatus();\n\n for (const modifiedFile of status.modified) {\n if (\n isLockFile(modifiedFile) ||\n modifiedFile.endsWith('gradle/verification-metadata.xml')\n ) {\n const newContent = await readLocalFile(modifiedFile, 'utf8');\n if (oldLockFileContentMap[modifiedFile] !== newContent) {\n res.push({\n file: {\n type: 'addition',\n path: modifiedFile,\n contents: newContent,\n },\n });\n }\n }\n }\n\n return res;\n}\n\nasync function getSubProjectList(\n cmd: string,\n execOptions: ExecOptions,\n): Promise<string[]> {\n const subprojects = ['']; // = root project\n const subprojectsRegex = regEx(/^[ \\t]*subprojects: \\[(?<subprojects>.+)\\]/m);\n\n const gradleProperties = await exec(`${cmd} properties`, execOptions);\n const subprojectsMatch = gradleProperties.stdout.match(subprojectsRegex);\n if (subprojectsMatch?.groups?.subprojects) {\n const projectRegex = regEx(/project '(?<name>.+?)'/g);\n const matches = subprojectsMatch.groups.subprojects.matchAll(projectRegex);\n for (const match of matches) {\n if (match?.groups?.name) {\n subprojects.push(match.groups.name);\n }\n }\n }\n\n return subprojects;\n}\n\nasync function getGradleVersion(gradlewFile: string): Promise<string | null> {\n const propertiesFile = upath.join(\n upath.dirname(gradlewFile),\n 'gradle/wrapper/gradle-wrapper.properties',\n );\n const properties = await readLocalFile(propertiesFile, 'utf8');\n const extractResult = extractGradleVersion(properties ?? '');\n\n return extractResult ? extractResult.version : null;\n}\n\nasync function buildUpdateVerificationMetadataCmd(\n verificationMetadataFile: string | undefined,\n baseCmd: string,\n): Promise<string | null> {\n if (!verificationMetadataFile) {\n return null;\n }\n\n const verificationMetadata = await readLocalFile(verificationMetadataFile);\n const verifiesChecksums = verificationMetadata?.includes(\n '<verify-metadata>true</verify-metadata>',\n );\n const verifiesSignatures = verificationMetadata?.includes(\n '<verify-signatures>true</verify-signatures>',\n );\n\n const hashTypes = ['sha256', 'sha512'].filter((type) =>\n verificationMetadata?.includes(`<${type} `),\n );\n\n if (verifiesChecksums || hashTypes.length) {\n logger.debug(\n 'Dependency metadata verification enabled or checksums present - generating checksums',\n );\n }\n\n if ((verifiesChecksums || verifiesSignatures) && !hashTypes.length) {\n // fallback algorithm for pgp and in case a weak algorithm (md5, sha1) is used for checksums\n hashTypes.push('sha256');\n }\n\n if (verifiesSignatures) {\n logger.debug(\n 'Dependency signature verification enabled - generating PGP signatures',\n );\n hashTypes.push('pgp');\n }\n\n if (!hashTypes.length) {\n return null;\n }\n\n return `${baseCmd} --write-verification-metadata ${hashTypes.join(',')} dependencies`;\n}\n\nexport async function updateArtifacts({\n packageFileName,\n updatedDeps,\n newPackageFileContent,\n config,\n}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {\n logger.debug(`gradle.updateArtifacts(${packageFileName})`);\n\n const fileList = await scm.getFileList();\n const lockFiles = fileList.filter((file) => isLockFile(file));\n const verificationMetadataFile = fileList.find((fileName) =>\n fileName.endsWith('gradle/verification-metadata.xml'),\n );\n if (!lockFiles.length && !verificationMetadataFile) {\n logger.debug(\n 'No Gradle dependency lockfiles or verification metadata found - skipping update',\n );\n return null;\n }\n\n const gradlewName = gradleWrapperFileName();\n const gradlewFile = await findUpLocal(\n gradlewName,\n upath.dirname(packageFileName),\n );\n if (!gradlewFile) {\n logger.debug(\n 'Found Gradle dependency lockfiles but no gradlew - aborting update',\n );\n return null;\n }\n\n if (\n config.isLockFileMaintenance &&\n (!isGradleBuildFile(packageFileName) ||\n upath.dirname(packageFileName) !== upath.dirname(gradlewFile))\n ) {\n logger.trace(\n 'No build.gradle(.kts) file or not in root project - skipping lock file maintenance',\n );\n return null;\n }\n\n if (!isGradleExecutionAllowed(gradlewFile)) {\n logger.trace(\n 'Not allowed to execute gradle due to allowedUnsafeExecutions - aborting update',\n );\n return null;\n }\n\n logger.debug('Updating found Gradle dependency lockfiles');\n\n try {\n const oldLockFileContentMap = await getFiles(lockFiles);\n await prepareGradleCommand(gradlewFile);\n\n const baseCmd = `${gradlewName}${gradleJvmArg(getToolSettingsOptions(config.toolSettings))} --console=plain --dependency-verification lenient -q`;\n const execOptions: ExecOptions = {\n cwdFile: gradlewFile,\n docker: {},\n extraEnv,\n toolConstraints: [\n {\n toolName: 'java',\n constraint:\n config.constraints?.java ??\n (await getJavaConstraint(\n await getGradleVersion(gradlewFile),\n gradlewFile,\n )),\n },\n ],\n };\n\n const cmds = [];\n if (lockFiles.length) {\n const subprojects = await getSubProjectList(baseCmd, execOptions);\n let lockfileCmd = `${baseCmd} ${subprojects\n .map((project) => `${project}:dependencies`)\n .map(quote)\n .join(' ')}`;\n\n if (\n config.isLockFileMaintenance === true ||\n !updatedDeps.length ||\n isGcvPropsFile(packageFileName)\n ) {\n lockfileCmd += ' --write-locks';\n } else {\n const updatedDepNames = updatedDeps\n .map(({ depName, packageName }) => packageName ?? depName)\n .filter(isNonEmptyStringAndNotWhitespace);\n\n lockfileCmd += ` --update-locks ${updatedDepNames\n .map(quote)\n .join(',')}`;\n }\n cmds.push(lockfileCmd);\n }\n\n const updateVerificationMetadataCmd =\n await buildUpdateVerificationMetadataCmd(\n verificationMetadataFile,\n baseCmd,\n );\n if (updateVerificationMetadataCmd) {\n cmds.push(updateVerificationMetadataCmd);\n }\n\n if (!cmds.length) {\n logger.debug('No lockfile or verification metadata update necessary');\n return null;\n }\n\n await writeLocalFile(packageFileName, newPackageFileContent);\n await exec(cmds, { ...execOptions, ignoreStdout: true });\n\n const res = await getUpdatedLockfiles(oldLockFileContentMap);\n logger.debug('Returning updated Gradle dependency lockfiles');\n\n return res.length > 0 ? res : null;\n } catch (err) {\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n\n logger.debug({ err }, 'Error while updating Gradle dependency lockfiles');\n return [\n {\n artifactError: {\n fileName: packageFileName,\n stderr: err.message,\n },\n },\n ];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAkCA,SAAgB,yBAAyB,SAA0B;CAGjE,IAAI,CAFc,aAAa,IAAI,yBAEtB,CAAC,CAAC,SAAS,eAAe,GAAG;EACxC,OAAO,KAAK,KACV,EAAE,QAAQ,GACV,kHACF;EACA,OAAO;CACT;CAEA,OAAO;AACT;AAGA,SAAS,WAAW,UAA2B;CAC7C,OAAO,SAAS,SAAS,WAAW,KAAK,cAAc,QAAQ;AACjE;AAEA,eAAe,oBACb,uBACkC;CAClC,MAAM,MAA+B,CAAC;CAEtC,MAAM,SAAS,MAAM,cAAc;CAEnC,KAAK,MAAM,gBAAgB,OAAO,UAChC,IACE,WAAW,YAAY,KACvB,aAAa,SAAS,kCAAkC,GACxD;EACA,MAAM,aAAa,MAAM,cAAc,cAAc,MAAM;EAC3D,I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,MADN,kBAAkB,SAAS,WAAW,EAAA,CAE7D,KAAK,YAAY,GAAG,QAAQ,cAAc,CAAC,CAC3C,IAAI,KAAK,CAAC,CACV,KAAK,GAAG;GAEX,IACE,OAAO,0BAA0B,QACjC,CAAC,YAAY,UACb,eAAe,eAAe,GAE9B,eAAe;QACV;IACL,MAAM,kBAAkB,YACrB,KAAK,EAAE,SAAS,kBAAkB,eAAe,OAAO,CAAC,CACzD,OAAO,gCAAgC;IAE1C,eAAe,mBAAmB,gBAC/B,IAAI,KAAK,CAAC,CACV,KAAK,GAAG;GACb;GACA,KAAK,KAAK,WAAW;EACvB;EAEA,MAAM,gCACJ,MAAM,mCACJ,0BACA,OACF;EACF,IAAI,+BACF,KAAK,KAAK,6BAA6B;EAGzC,IAAI,CAAC,KAAK,QAAQ;GAChB,OAAO,MAAM,uDAAuD;GACpE,OAAO;EACT;EAEA,MAAM,eAAe,iBAAiB,qBAAqB;EAC3D,MAAM,KAAK,MAAM;GAAE,GAAG;GAAa,cAAc;EAAK,CAAC;EAEvD,MAAM,MAAM,MAAM,oBAAoB,qBAAqB;EAC3D,OAAO,MAAM,+CAA+C;EAE5D,OAAO,IAAI,SAAS,IAAI,MAAM;CAChC,SAAS,KAAK;EACZ,IAAI,IAAI,YAAA,mBACN,MAAM;EAGR,OAAO,MAAM,EAAE,IAAI,GAAG,kDAAkD;EACxE,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/gradle/artifacts.ts"],"sourcesContent":["import { isNonEmptyStringAndNotWhitespace } from '@sindresorhus/is';\nimport { quote } from 'shlex';\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 {\n exec,\n getToolSettingsOptions,\n gradleJvmArg,\n} from '../../../util/exec/index.ts';\nimport type { ExecOptions } from '../../../util/exec/types.ts';\nimport {\n findUpLocal,\n readLocalFile,\n writeLocalFile,\n} from '../../../util/fs/index.ts';\nimport { getFiles, getRepoStatus } from '../../../util/git/index.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { scm } from '../../platform/scm.ts';\nimport {\n extraEnv,\n extractGradleVersion,\n getJavaConstraint,\n gradleWrapperFileName,\n prepareGradleCommand,\n} from '../gradle-wrapper/utils.ts';\nimport type { UpdateArtifact, UpdateArtifactsResult } from '../types.ts';\nimport { resolveToolConstraint } from '../util.ts';\nimport {\n isGcvLockFile,\n isGcvPropsFile,\n} from './extract/consistent-versions-plugin.ts';\nimport { isGradleBuildFile } from './utils.ts';\n\nexport function isGradleExecutionAllowed(command: string): boolean {\n const allowlist = GlobalConfig.get('allowedUnsafeExecutions');\n\n if (!allowlist.includes('gradleWrapper')) {\n logger.once.warn(\n { command },\n 'Gradle wrapper command was requested to run, but `gradleWrapper` is not permitted in the allowedUnsafeExecutions',\n );\n return false;\n }\n\n return true;\n}\n\n// .lockfile is gradle default lockfile, /versions.lock is gradle-consistent-versions plugin lockfile\nfunction isLockFile(fileName: string): boolean {\n return fileName.endsWith('.lockfile') || isGcvLockFile(fileName);\n}\n\nasync function getUpdatedLockfiles(\n oldLockFileContentMap: Record<string, string | null>,\n): Promise<UpdateArtifactsResult[]> {\n const res: UpdateArtifactsResult[] = [];\n\n const status = await getRepoStatus();\n\n for (const modifiedFile of status.modified) {\n if (\n isLockFile(modifiedFile) ||\n modifiedFile.endsWith('gradle/verification-metadata.xml')\n ) {\n const newContent = await readLocalFile(modifiedFile, 'utf8');\n if (oldLockFileContentMap[modifiedFile] !== newContent) {\n res.push({\n file: {\n type: 'addition',\n path: modifiedFile,\n contents: newContent,\n },\n });\n }\n }\n }\n\n return res;\n}\n\nasync function getSubProjectList(\n cmd: string,\n execOptions: ExecOptions,\n): Promise<string[]> {\n const subprojects = ['']; // = root project\n const subprojectsRegex = regEx(/^[ \\t]*subprojects: \\[(?<subprojects>.+)\\]/m);\n\n const gradleProperties = await exec(`${cmd} properties`, execOptions);\n const subprojectsMatch = gradleProperties.stdout.match(subprojectsRegex);\n if (subprojectsMatch?.groups?.subprojects) {\n const projectRegex = regEx(/project '(?<name>.+?)'/g);\n const matches = subprojectsMatch.groups.subprojects.matchAll(projectRegex);\n for (const match of matches) {\n if (match?.groups?.name) {\n subprojects.push(match.groups.name);\n }\n }\n }\n\n return subprojects;\n}\n\nasync function getGradleVersion(gradlewFile: string): Promise<string | null> {\n const propertiesFile = upath.join(\n upath.dirname(gradlewFile),\n 'gradle/wrapper/gradle-wrapper.properties',\n );\n const properties = await readLocalFile(propertiesFile, 'utf8');\n const extractResult = extractGradleVersion(properties ?? '');\n\n return extractResult ? extractResult.version : null;\n}\n\nasync function buildUpdateVerificationMetadataCmd(\n verificationMetadataFile: string | undefined,\n baseCmd: string,\n): Promise<string | null> {\n if (!verificationMetadataFile) {\n return null;\n }\n\n const verificationMetadata = await readLocalFile(verificationMetadataFile);\n const verifiesChecksums = verificationMetadata?.includes(\n '<verify-metadata>true</verify-metadata>',\n );\n const verifiesSignatures = verificationMetadata?.includes(\n '<verify-signatures>true</verify-signatures>',\n );\n\n const hashTypes = ['sha256', 'sha512'].filter((type) =>\n verificationMetadata?.includes(`<${type} `),\n );\n\n if (verifiesChecksums || hashTypes.length) {\n logger.debug(\n 'Dependency metadata verification enabled or checksums present - generating checksums',\n );\n }\n\n if ((verifiesChecksums || verifiesSignatures) && !hashTypes.length) {\n // fallback algorithm for pgp and in case a weak algorithm (md5, sha1) is used for checksums\n hashTypes.push('sha256');\n }\n\n if (verifiesSignatures) {\n logger.debug(\n 'Dependency signature verification enabled - generating PGP signatures',\n );\n hashTypes.push('pgp');\n }\n\n if (!hashTypes.length) {\n return null;\n }\n\n return `${baseCmd} --write-verification-metadata ${hashTypes.join(',')} dependencies`;\n}\n\nexport async function updateArtifacts({\n packageFileName,\n updatedDeps,\n newPackageFileContent,\n config,\n}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {\n logger.debug(`gradle.updateArtifacts(${packageFileName})`);\n\n const fileList = await scm.getFileList();\n const lockFiles = fileList.filter((file) => isLockFile(file));\n const verificationMetadataFile = fileList.find((fileName) =>\n fileName.endsWith('gradle/verification-metadata.xml'),\n );\n if (!lockFiles.length && !verificationMetadataFile) {\n logger.debug(\n 'No Gradle dependency lockfiles or verification metadata found - skipping update',\n );\n return null;\n }\n\n const gradlewName = gradleWrapperFileName();\n const gradlewFile = await findUpLocal(\n gradlewName,\n upath.dirname(packageFileName),\n );\n if (!gradlewFile) {\n logger.debug(\n 'Found Gradle dependency lockfiles but no gradlew - aborting update',\n );\n return null;\n }\n\n if (\n config.isLockFileMaintenance &&\n (!isGradleBuildFile(packageFileName) ||\n upath.dirname(packageFileName) !== upath.dirname(gradlewFile))\n ) {\n logger.trace(\n 'No build.gradle(.kts) file or not in root project - skipping lock file maintenance',\n );\n return null;\n }\n\n if (!isGradleExecutionAllowed(gradlewFile)) {\n logger.trace(\n 'Not allowed to execute gradle due to allowedUnsafeExecutions - aborting update',\n );\n return null;\n }\n\n logger.debug('Updating found Gradle dependency lockfiles');\n\n try {\n const oldLockFileContentMap = await getFiles(lockFiles);\n await prepareGradleCommand(gradlewFile);\n\n const baseCmd = `${gradlewName}${gradleJvmArg(getToolSettingsOptions(config.toolSettings))} --console=plain --dependency-verification lenient -q`;\n const execOptions: ExecOptions = {\n cwdFile: gradlewFile,\n docker: {},\n extraEnv,\n toolConstraints: [\n {\n toolName: 'java',\n constraint: await resolveToolConstraint(config, 'java', async () =>\n getJavaConstraint(await getGradleVersion(gradlewFile), gradlewFile),\n ),\n },\n ],\n };\n\n const cmds = [];\n if (lockFiles.length) {\n const subprojects = await getSubProjectList(baseCmd, execOptions);\n let lockfileCmd = `${baseCmd} ${subprojects\n .map((project) => `${project}:dependencies`)\n .map(quote)\n .join(' ')}`;\n\n if (\n config.isLockFileMaintenance === true ||\n !updatedDeps.length ||\n isGcvPropsFile(packageFileName)\n ) {\n lockfileCmd += ' --write-locks';\n } else {\n const updatedDepNames = updatedDeps\n .map(({ depName, packageName }) => packageName ?? depName)\n .filter(isNonEmptyStringAndNotWhitespace);\n\n lockfileCmd += ` --update-locks ${updatedDepNames\n .map(quote)\n .join(',')}`;\n }\n cmds.push(lockfileCmd);\n }\n\n const updateVerificationMetadataCmd =\n await buildUpdateVerificationMetadataCmd(\n verificationMetadataFile,\n baseCmd,\n );\n if (updateVerificationMetadataCmd) {\n cmds.push(updateVerificationMetadataCmd);\n }\n\n if (!cmds.length) {\n logger.debug('No lockfile or verification metadata update necessary');\n return null;\n }\n\n await writeLocalFile(packageFileName, newPackageFileContent);\n await exec(cmds, { ...execOptions, ignoreStdout: true });\n\n const res = await getUpdatedLockfiles(oldLockFileContentMap);\n logger.debug('Returning updated Gradle dependency lockfiles');\n\n return res.length > 0 ? res : null;\n } catch (err) {\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n\n logger.debug({ err }, 'Error while updating Gradle dependency lockfiles');\n return [\n {\n artifactError: {\n fileName: packageFileName,\n stderr: err.message,\n },\n },\n ];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAmCA,SAAgB,yBAAyB,SAA0B;CAGjE,IAAI,CAFc,aAAa,IAAI,yBAEtB,CAAC,CAAC,SAAS,eAAe,GAAG;EACxC,OAAO,KAAK,KACV,EAAE,QAAQ,GACV,kHACF;EACA,OAAO;CACT;CAEA,OAAO;AACT;AAGA,SAAS,WAAW,UAA2B;CAC7C,OAAO,SAAS,SAAS,WAAW,KAAK,cAAc,QAAQ;AACjE;AAEA,eAAe,oBACb,uBACkC;CAClC,MAAM,MAA+B,CAAC;CAEtC,MAAM,SAAS,MAAM,cAAc;CAEnC,KAAK,MAAM,gBAAgB,OAAO,UAChC,IACE,WAAW,YAAY,KACvB,aAAa,SAAS,kCAAkC,GACxD;EACA,MAAM,aAAa,MAAM,cAAc,cAAc,MAAM;EAC3D,IAAI,sBAAsB,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,IAAG,MADN,kBAAkB,SAAS,WAAW,EAAA,CAE7D,KAAK,YAAY,GAAG,QAAQ,cAAc,CAAC,CAC3C,IAAI,KAAK,CAAC,CACV,KAAK,GAAG;GAEX,IACE,OAAO,0BAA0B,QACjC,CAAC,YAAY,UACb,eAAe,eAAe,GAE9B,eAAe;QACV;IACL,MAAM,kBAAkB,YACrB,KAAK,EAAE,SAAS,kBAAkB,eAAe,OAAO,CAAC,CACzD,OAAO,gCAAgC;IAE1C,eAAe,mBAAmB,gBAC/B,IAAI,KAAK,CAAC,CACV,KAAK,GAAG;GACb;GACA,KAAK,KAAK,WAAW;EACvB;EAEA,MAAM,gCACJ,MAAM,mCACJ,0BACA,OACF;EACF,IAAI,+BACF,KAAK,KAAK,6BAA6B;EAGzC,IAAI,CAAC,KAAK,QAAQ;GAChB,OAAO,MAAM,uDAAuD;GACpE,OAAO;EACT;EAEA,MAAM,eAAe,iBAAiB,qBAAqB;EAC3D,MAAM,KAAK,MAAM;GAAE,GAAG;GAAa,cAAc;EAAK,CAAC;EAEvD,MAAM,MAAM,MAAM,oBAAoB,qBAAqB;EAC3D,OAAO,MAAM,+CAA+C;EAE5D,OAAO,IAAI,SAAS,IAAI,MAAM;CAChC,SAAS,KAAK;EACZ,IAAI,IAAI,YAAA,mBACN,MAAM;EAGR,OAAO,MAAM,EAAE,IAAI,GAAG,kDAAkD;EACxE,OAAO,CACL,EACE,eAAe;GACb,UAAU;GACV,QAAQ,IAAI;EACd,EACF,CACF;CACF;AACF"}
@@ -6,6 +6,7 @@ import { localPathExists, readLocalFile, writeLocalFile } from "../../../util/fs
6
6
  import { Http } from "../../../util/http/index.js";
7
7
  import { exec, getToolSettingsOptions, gradleJvmArg } from "../../../util/exec/index.js";
8
8
  import { getRepoStatus } from "../../../util/git/index.js";
9
+ import { resolveToolConstraint } from "../util.js";
9
10
  import { extraEnv, getJavaConstraint, gradleWrapperFileName, prepareGradleCommand } from "./utils.js";
10
11
  import { isGradleExecutionAllowed, updateArtifacts as updateArtifacts$1 } from "../gradle/artifacts.js";
11
12
  import "../gradle/index.js";
@@ -103,7 +104,7 @@ async function updateArtifacts({ packageFileName, newPackageFileContent, updated
103
104
  extraEnv,
104
105
  toolConstraints: [{
105
106
  toolName: "java",
106
- constraint: config.constraints?.java ?? await getJavaConstraint(config.currentValue, gradlewFile)
107
+ constraint: await resolveToolConstraint(config, "java", () => getJavaConstraint(config.currentValue, gradlewFile))
107
108
  }]
108
109
  };
109
110
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"artifacts.js","names":["query","q","gradleUpdateArtifacts"],"sources":["../../../../lib/modules/manager/gradle-wrapper/artifacts.ts"],"sourcesContent":["import { lang, query as q } from '@renovatebot/good-enough-parser';\nimport { isTruthy } from '@sindresorhus/is';\nimport { quote } from 'shlex';\nimport upath from 'upath';\nimport { TEMPORARY_ERROR } from '../../../constants/error-messages.ts';\nimport { logger } from '../../../logger/index.ts';\nimport {\n exec,\n getToolSettingsOptions,\n gradleJvmArg,\n} from '../../../util/exec/index.ts';\nimport type { ExecOptions } from '../../../util/exec/types.ts';\nimport {\n localPathExists,\n readLocalFile,\n writeLocalFile,\n} from '../../../util/fs/index.ts';\nimport { getRepoStatus } from '../../../util/git/index.ts';\nimport type { StatusResult } from '../../../util/git/types.ts';\nimport { Http } from '../../../util/http/index.ts';\nimport { newlineRegex, regEx } from '../../../util/regex.ts';\nimport { replaceAt } from '../../../util/string.ts';\nimport { isGradleExecutionAllowed } from '../gradle/artifacts.ts';\nimport { updateArtifacts as gradleUpdateArtifacts } from '../gradle/index.ts';\nimport type {\n UpdateArtifact,\n UpdateArtifactsConfig,\n UpdateArtifactsResult,\n} from '../types.ts';\nimport {\n extraEnv,\n getJavaConstraint,\n gradleWrapperFileName,\n prepareGradleCommand,\n} from './utils.ts';\n\nconst http = new Http('gradle-wrapper');\nconst groovy = lang.createLang('groovy');\n\ntype Ctx = string[];\n\nasync function addIfUpdated(\n status: StatusResult,\n fileProjectPath: string,\n): Promise<UpdateArtifactsResult | null> {\n if (status.modified.includes(fileProjectPath)) {\n return {\n file: {\n type: 'addition',\n path: fileProjectPath,\n contents: await readLocalFile(fileProjectPath),\n },\n };\n }\n return null;\n}\n\nfunction getDistributionUrl(newPackageFileContent: string): string | null {\n const distributionUrlLine = newPackageFileContent\n .split(newlineRegex)\n .find((line) => line.startsWith('distributionUrl='));\n if (distributionUrlLine) {\n return distributionUrlLine\n .replace('distributionUrl=', '')\n .replace('https\\\\:', 'https:');\n }\n return null;\n}\n\nasync function getDistributionChecksum(url: string): Promise<string> {\n const { body } = await http.getText(`${url}.sha256`);\n return body;\n}\n\nexport async function updateBuildFile(\n localGradleDir: string,\n wrapperProperties: Record<string, string | undefined | null>,\n): Promise<string> {\n let buildFileName = upath.join(localGradleDir, 'build.gradle');\n if (!(await localPathExists(buildFileName))) {\n buildFileName = upath.join(localGradleDir, 'build.gradle.kts');\n }\n\n const buildFileContent = await readLocalFile(buildFileName, 'utf8');\n if (!buildFileContent) {\n logger.debug('build.gradle or build.gradle.kts not found');\n return buildFileName;\n }\n\n let buildFileUpdated = buildFileContent;\n for (const [propertyName, newValue] of Object.entries(wrapperProperties)) {\n if (!newValue) {\n continue;\n }\n\n const query = q.tree({\n type: 'wrapped-tree',\n maxDepth: 1,\n search: q\n .sym<Ctx>(propertyName)\n .op('=')\n .str((ctx, { value, offset }) => {\n buildFileUpdated = replaceAt(\n buildFileUpdated,\n offset,\n value,\n newValue,\n );\n return ctx;\n }),\n });\n groovy.query(buildFileUpdated, query, []);\n }\n\n await writeLocalFile(buildFileName, buildFileUpdated);\n\n return buildFileName;\n}\n\nexport async function updateLockFiles(\n buildFileName: string,\n config: UpdateArtifactsConfig,\n): Promise<UpdateArtifactsResult[] | null> {\n const buildFileContent = await readLocalFile(buildFileName, 'utf8');\n if (!buildFileContent) {\n logger.debug('build.gradle or build.gradle.kts not found');\n return null;\n }\n\n return await gradleUpdateArtifacts({\n packageFileName: buildFileName,\n updatedDeps: [],\n newPackageFileContent: buildFileContent,\n config,\n });\n}\n\nexport async function updateArtifacts({\n packageFileName,\n newPackageFileContent,\n updatedDeps,\n config,\n}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {\n try {\n logger.debug({ updatedDeps }, 'gradle-wrapper.updateArtifacts()');\n const localGradleDir = upath.join(upath.dirname(packageFileName), '../../');\n const gradlewFile = upath.join(localGradleDir, gradleWrapperFileName());\n\n let cmd = await prepareGradleCommand(gradlewFile);\n if (!cmd) {\n logger.info('No gradlew found - skipping Artifacts update');\n return null;\n }\n\n if (!isGradleExecutionAllowed(gradlewFile)) {\n logger.trace(\n 'Not allowed to execute gradle due to allowedUnsafeExecutions - aborting update',\n );\n\n return null;\n }\n\n // Limit the Gradle daemon Java heap memory size to prevent OOM errors\n // leading to Renovate kernel-OOMs and timeouts. See #39558\n cmd += gradleJvmArg(getToolSettingsOptions(config.toolSettings));\n cmd += ' :wrapper';\n\n let checksum: string | null = null;\n const distributionUrl = getDistributionUrl(newPackageFileContent);\n if (distributionUrl) {\n cmd += ` --gradle-distribution-url ${quote(distributionUrl)}`;\n if (newPackageFileContent.includes('distributionSha256Sum=')) {\n //update checksum in case of distributionSha256Sum in properties then run wrapper\n checksum = await getDistributionChecksum(distributionUrl);\n await writeLocalFile(\n packageFileName,\n newPackageFileContent.replace(\n regEx(/distributionSha256Sum=.*/),\n `distributionSha256Sum=${checksum}`,\n ),\n );\n cmd += ` --gradle-distribution-sha256-sum ${quote(checksum)}`;\n }\n } else {\n cmd += ` --gradle-version ${quote(config.newValue!)}`;\n }\n logger.debug(`Updating gradle wrapper: \"${cmd}\"`);\n const execOptions: ExecOptions = {\n cwdFile: gradlewFile,\n docker: {},\n extraEnv,\n toolConstraints: [\n {\n toolName: 'java',\n constraint:\n config.constraints?.java ??\n (await getJavaConstraint(config.currentValue, gradlewFile)),\n },\n ],\n };\n try {\n await exec(cmd, execOptions);\n } catch (err) {\n // istanbul ignore if\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n logger.warn(\n { err },\n 'Error executing gradle wrapper update command. This may not necessarily be a blocker to the update, so please verify with the gradle wrapper output logs.',\n );\n }\n\n const buildFileName = await updateBuildFile(localGradleDir, {\n gradleVersion: config.newValue,\n distributionSha256Sum: checksum,\n distributionUrl,\n });\n const lockFiles = await updateLockFiles(buildFileName, config);\n\n const status = await getRepoStatus();\n const artifactFileNames = [\n packageFileName,\n buildFileName,\n ...['gradle/wrapper/gradle-wrapper.jar', 'gradlew', 'gradlew.bat'].map(\n (filename) => upath.join(localGradleDir, filename),\n ),\n ];\n const updateArtifactsResult = (\n await Promise.all(\n artifactFileNames.map((fileProjectPath) =>\n addIfUpdated(status, fileProjectPath),\n ),\n )\n ).filter(isTruthy);\n if (lockFiles) {\n updateArtifactsResult.push(...lockFiles);\n }\n\n logger.debug(\n { files: updateArtifactsResult.map((r) => r.file?.path) },\n `Returning updated gradle-wrapper files`,\n );\n return updateArtifactsResult;\n } catch (err) {\n logger.debug({ err }, 'Error setting new Gradle Wrapper release value');\n return [\n {\n artifactError: {\n fileName: packageFileName,\n stderr: err.message,\n },\n },\n ];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAoCA,MAAM,OAAO,IAAI,KAAK,gBAAgB;AACtC,MAAM,SAAS,KAAK,WAAW,QAAQ;AAIvC,eAAe,aACb,QACA,iBACuC;CACvC,IAAI,OAAO,SAAS,SAAS,eAAe,GAC1C,OAAO,EACL,MAAM;EACJ,MAAM;EACN,MAAM;EACN,UAAU,MAAM,cAAc,eAAe;CAC/C,EACF;CAEF,OAAO;AACT;AAEA,SAAS,mBAAmB,uBAA8C;CACxE,MAAM,sBAAsB,sBACzB,MAAM,YAAY,CAAC,CACnB,MAAM,SAAS,KAAK,WAAW,kBAAkB,CAAC;CACrD,IAAI,qBACF,OAAO,oBACJ,QAAQ,oBAAoB,EAAE,CAAC,CAC/B,QAAQ,YAAY,QAAQ;CAEjC,OAAO;AACT;AAEA,eAAe,wBAAwB,KAA8B;CACnE,MAAM,EAAE,SAA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EACF;EACA,MAAM,yBACJ,MAAM,QAAQ,IACZ,kBAAkB,KAAK,oBACrB,aAAa,QAAQ,eAAe,CACtC,CACF,EAAA,CACA,OAAO,QAAQ;EACjB,IAAI,WACF,sBAAsB,KAAK,GAAG,SAAS;EAGzC,OAAO,MACL,EAAE,OAAO,sBAAsB,KAAK,MAAM,EAAE,MAAM,IAAI,EAAE,GACxD,wCACF;EACA,OAAO;CACT,SAAS,KAAK;EACZ,OAAO,MAAM,EAAE,IAAI,GAAG,gDAAgD;EACtE,OAAO,CACL,EACE,eAAe;GACb,UAAU;GACV,QAAQ,IAAI;EACd,EACF,CACF;CACF;AACF"}
1
+ {"version":3,"file":"artifacts.js","names":["query","q","gradleUpdateArtifacts"],"sources":["../../../../lib/modules/manager/gradle-wrapper/artifacts.ts"],"sourcesContent":["import { lang, query as q } from '@renovatebot/good-enough-parser';\nimport { isTruthy } from '@sindresorhus/is';\nimport { quote } from 'shlex';\nimport upath from 'upath';\nimport { TEMPORARY_ERROR } from '../../../constants/error-messages.ts';\nimport { logger } from '../../../logger/index.ts';\nimport {\n exec,\n getToolSettingsOptions,\n gradleJvmArg,\n} from '../../../util/exec/index.ts';\nimport type { ExecOptions } from '../../../util/exec/types.ts';\nimport {\n localPathExists,\n readLocalFile,\n writeLocalFile,\n} from '../../../util/fs/index.ts';\nimport { getRepoStatus } from '../../../util/git/index.ts';\nimport type { StatusResult } from '../../../util/git/types.ts';\nimport { Http } from '../../../util/http/index.ts';\nimport { newlineRegex, regEx } from '../../../util/regex.ts';\nimport { replaceAt } from '../../../util/string.ts';\nimport { isGradleExecutionAllowed } from '../gradle/artifacts.ts';\nimport { updateArtifacts as gradleUpdateArtifacts } from '../gradle/index.ts';\nimport type {\n UpdateArtifact,\n UpdateArtifactsConfig,\n UpdateArtifactsResult,\n} from '../types.ts';\nimport { resolveToolConstraint } from '../util.ts';\nimport {\n extraEnv,\n getJavaConstraint,\n gradleWrapperFileName,\n prepareGradleCommand,\n} from './utils.ts';\n\nconst http = new Http('gradle-wrapper');\nconst groovy = lang.createLang('groovy');\n\ntype Ctx = string[];\n\nasync function addIfUpdated(\n status: StatusResult,\n fileProjectPath: string,\n): Promise<UpdateArtifactsResult | null> {\n if (status.modified.includes(fileProjectPath)) {\n return {\n file: {\n type: 'addition',\n path: fileProjectPath,\n contents: await readLocalFile(fileProjectPath),\n },\n };\n }\n return null;\n}\n\nfunction getDistributionUrl(newPackageFileContent: string): string | null {\n const distributionUrlLine = newPackageFileContent\n .split(newlineRegex)\n .find((line) => line.startsWith('distributionUrl='));\n if (distributionUrlLine) {\n return distributionUrlLine\n .replace('distributionUrl=', '')\n .replace('https\\\\:', 'https:');\n }\n return null;\n}\n\nasync function getDistributionChecksum(url: string): Promise<string> {\n const { body } = await http.getText(`${url}.sha256`);\n return body;\n}\n\nexport async function updateBuildFile(\n localGradleDir: string,\n wrapperProperties: Record<string, string | undefined | null>,\n): Promise<string> {\n let buildFileName = upath.join(localGradleDir, 'build.gradle');\n if (!(await localPathExists(buildFileName))) {\n buildFileName = upath.join(localGradleDir, 'build.gradle.kts');\n }\n\n const buildFileContent = await readLocalFile(buildFileName, 'utf8');\n if (!buildFileContent) {\n logger.debug('build.gradle or build.gradle.kts not found');\n return buildFileName;\n }\n\n let buildFileUpdated = buildFileContent;\n for (const [propertyName, newValue] of Object.entries(wrapperProperties)) {\n if (!newValue) {\n continue;\n }\n\n const query = q.tree({\n type: 'wrapped-tree',\n maxDepth: 1,\n search: q\n .sym<Ctx>(propertyName)\n .op('=')\n .str((ctx, { value, offset }) => {\n buildFileUpdated = replaceAt(\n buildFileUpdated,\n offset,\n value,\n newValue,\n );\n return ctx;\n }),\n });\n groovy.query(buildFileUpdated, query, []);\n }\n\n await writeLocalFile(buildFileName, buildFileUpdated);\n\n return buildFileName;\n}\n\nexport async function updateLockFiles(\n buildFileName: string,\n config: UpdateArtifactsConfig,\n): Promise<UpdateArtifactsResult[] | null> {\n const buildFileContent = await readLocalFile(buildFileName, 'utf8');\n if (!buildFileContent) {\n logger.debug('build.gradle or build.gradle.kts not found');\n return null;\n }\n\n return await gradleUpdateArtifacts({\n packageFileName: buildFileName,\n updatedDeps: [],\n newPackageFileContent: buildFileContent,\n config,\n });\n}\n\nexport async function updateArtifacts({\n packageFileName,\n newPackageFileContent,\n updatedDeps,\n config,\n}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {\n try {\n logger.debug({ updatedDeps }, 'gradle-wrapper.updateArtifacts()');\n const localGradleDir = upath.join(upath.dirname(packageFileName), '../../');\n const gradlewFile = upath.join(localGradleDir, gradleWrapperFileName());\n\n let cmd = await prepareGradleCommand(gradlewFile);\n if (!cmd) {\n logger.info('No gradlew found - skipping Artifacts update');\n return null;\n }\n\n if (!isGradleExecutionAllowed(gradlewFile)) {\n logger.trace(\n 'Not allowed to execute gradle due to allowedUnsafeExecutions - aborting update',\n );\n\n return null;\n }\n\n // Limit the Gradle daemon Java heap memory size to prevent OOM errors\n // leading to Renovate kernel-OOMs and timeouts. See #39558\n cmd += gradleJvmArg(getToolSettingsOptions(config.toolSettings));\n cmd += ' :wrapper';\n\n let checksum: string | null = null;\n const distributionUrl = getDistributionUrl(newPackageFileContent);\n if (distributionUrl) {\n cmd += ` --gradle-distribution-url ${quote(distributionUrl)}`;\n if (newPackageFileContent.includes('distributionSha256Sum=')) {\n //update checksum in case of distributionSha256Sum in properties then run wrapper\n checksum = await getDistributionChecksum(distributionUrl);\n await writeLocalFile(\n packageFileName,\n newPackageFileContent.replace(\n regEx(/distributionSha256Sum=.*/),\n `distributionSha256Sum=${checksum}`,\n ),\n );\n cmd += ` --gradle-distribution-sha256-sum ${quote(checksum)}`;\n }\n } else {\n cmd += ` --gradle-version ${quote(config.newValue!)}`;\n }\n logger.debug(`Updating gradle wrapper: \"${cmd}\"`);\n const execOptions: ExecOptions = {\n cwdFile: gradlewFile,\n docker: {},\n extraEnv,\n toolConstraints: [\n {\n toolName: 'java',\n constraint: await resolveToolConstraint(config, 'java', () =>\n getJavaConstraint(config.currentValue, gradlewFile),\n ),\n },\n ],\n };\n try {\n await exec(cmd, execOptions);\n } catch (err) {\n // istanbul ignore if\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n logger.warn(\n { err },\n 'Error executing gradle wrapper update command. This may not necessarily be a blocker to the update, so please verify with the gradle wrapper output logs.',\n );\n }\n\n const buildFileName = await updateBuildFile(localGradleDir, {\n gradleVersion: config.newValue,\n distributionSha256Sum: checksum,\n distributionUrl,\n });\n const lockFiles = await updateLockFiles(buildFileName, config);\n\n const status = await getRepoStatus();\n const artifactFileNames = [\n packageFileName,\n buildFileName,\n ...['gradle/wrapper/gradle-wrapper.jar', 'gradlew', 'gradlew.bat'].map(\n (filename) => upath.join(localGradleDir, filename),\n ),\n ];\n const updateArtifactsResult = (\n await Promise.all(\n artifactFileNames.map((fileProjectPath) =>\n addIfUpdated(status, fileProjectPath),\n ),\n )\n ).filter(isTruthy);\n if (lockFiles) {\n updateArtifactsResult.push(...lockFiles);\n }\n\n logger.debug(\n { files: updateArtifactsResult.map((r) => r.file?.path) },\n `Returning updated gradle-wrapper files`,\n );\n return updateArtifactsResult;\n } catch (err) {\n logger.debug({ err }, 'Error setting new Gradle Wrapper release value');\n return [\n {\n artifactError: {\n fileName: packageFileName,\n stderr: err.message,\n },\n },\n ];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAqCA,MAAM,OAAO,IAAI,KAAK,gBAAgB;AACtC,MAAM,SAAS,KAAK,WAAW,QAAQ;AAIvC,eAAe,aACb,QACA,iBACuC;CACvC,IAAI,OAAO,SAAS,SAAS,eAAe,GAC1C,OAAO,EACL,MAAM;EACJ,MAAM;EACN,MAAM;EACN,UAAU,MAAM,cAAc,eAAe;CAC/C,EACF;CAEF,OAAO;AACT;AAEA,SAAS,mBAAmB,uBAA8C;CACxE,MAAM,sBAAsB,sBACzB,MAAM,YAAY,CAAC,CACnB,MAAM,SAAS,KAAK,WAAW,kBAAkB,CAAC;CACrD,IAAI,qBACF,OAAO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AS,MAAM,cAAc;EACnC,MAAM,oBAAoB;GACxB;GACA;GACA,GAAG;IAAC;IAAqC;IAAW;GAAa,CAAC,CAAC,KAChE,aAAa,MAAM,KAAK,gBAAgB,QAAQ,CACnD;EACF;EACA,MAAM,yBACJ,MAAM,QAAQ,IACZ,kBAAkB,KAAK,oBACrB,aAAa,QAAQ,eAAe,CACtC,CACF,EAAA,CACA,OAAO,QAAQ;EACjB,IAAI,WACF,sBAAsB,KAAK,GAAG,SAAS;EAGzC,OAAO,MACL,EAAE,OAAO,sBAAsB,KAAK,MAAM,EAAE,MAAM,IAAI,EAAE,GACxD,wCACF;EACA,OAAO;CACT,SAAS,KAAK;EACZ,OAAO,MAAM,EAAE,IAAI,GAAG,gDAAgD;EACtE,OAAO,CACL,EACE,eAAe;GACb,UAAU;GACV,QAAQ,IAAI;EACd,EACF,CACF;CACF;AACF"}
@@ -7,6 +7,7 @@ import { getSiblingFileName, readLocalFile, writeLocalFile } from "../../../util
7
7
  import { Result } from "../../../util/result.js";
8
8
  import { exec } from "../../../util/exec/index.js";
9
9
  import { getFile } from "../../../util/git/index.js";
10
+ import { resolveToolConstraint } from "../util.js";
10
11
  import { generateHelmEnvs } from "../helmv3/common.js";
11
12
  import { Doc, LockVersion } from "./schema.js";
12
13
  import { generateRegistryLoginCmd, isOCIRegistry } from "./utils.js";
@@ -30,14 +31,14 @@ async function updateArtifacts({ packageFileName, updatedDeps, newPackageFileCon
30
31
  await writeLocalFile(packageFileName, newPackageFileContent);
31
32
  const toolConstraints = [{
32
33
  toolName: "helm",
33
- constraint: config.constraints?.helm
34
+ constraint: await resolveToolConstraint(config, "helm")
34
35
  }, {
35
36
  toolName: "helmfile",
36
- constraint: config.constraints?.helmfile ?? Result.parse(existingLockFileContent, LockVersion).unwrapOrNull()
37
+ constraint: await resolveToolConstraint(config, "helmfile", () => Result.parse(existingLockFileContent, LockVersion).unwrapOrNull())
37
38
  }];
38
39
  if (updatedDeps.some((dep) => dep.managerData?.needKustomize)) toolConstraints.push({
39
40
  toolName: "kustomize",
40
- constraint: config.constraints?.kustomize
41
+ constraint: await resolveToolConstraint(config, "kustomize")
41
42
  });
42
43
  const cmd = [];
43
44
  const docs = parseYaml(newPackageFileContent, {
@@ -1 +1 @@
1
- {"version":3,"file":"artifacts.js","names":[],"sources":["../../../../lib/modules/manager/helmfile/artifacts.ts"],"sourcesContent":["import { isFalsy } from '@sindresorhus/is';\nimport { quote } from 'shlex';\nimport { TEMPORARY_ERROR } from '../../../constants/error-messages.ts';\nimport { logger } from '../../../logger/index.ts';\nimport { coerceArray } from '../../../util/array.ts';\nimport { exec } from '../../../util/exec/index.ts';\nimport type { ToolConstraint } from '../../../util/exec/types.ts';\nimport {\n getSiblingFileName,\n readLocalFile,\n writeLocalFile,\n} from '../../../util/fs/index.ts';\nimport { getFile } from '../../../util/git/index.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { Result } from '../../../util/result.ts';\nimport { parseYaml } from '../../../util/yaml.ts';\nimport { generateHelmEnvs } from '../helmv3/common.ts';\nimport type { UpdateArtifact, UpdateArtifactsResult } from '../types.ts';\nimport { Doc, LockVersion } from './schema.ts';\nimport { generateRegistryLoginCmd, isOCIRegistry } from './utils.ts';\n\nexport async function updateArtifacts({\n packageFileName,\n updatedDeps,\n newPackageFileContent,\n config,\n}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {\n logger.trace(`helmfile.updateArtifacts(${packageFileName})`);\n\n const { isLockFileMaintenance } = config;\n if (\n !isLockFileMaintenance &&\n (updatedDeps === undefined || updatedDeps.length < 1)\n ) {\n logger.debug('No updated helmfile deps - returning null');\n return null;\n }\n\n const lockFileName = getSiblingFileName(packageFileName, 'helmfile.lock');\n const existingLockFileContent = await getFile(lockFileName);\n\n if (isFalsy(existingLockFileContent)) {\n logger.debug('No helmfile.lock found');\n return null;\n }\n\n try {\n await writeLocalFile(packageFileName, newPackageFileContent);\n\n const toolConstraints: ToolConstraint[] = [\n {\n toolName: 'helm',\n constraint: config.constraints?.helm,\n },\n {\n toolName: 'helmfile',\n constraint:\n config.constraints?.helmfile ??\n Result.parse(existingLockFileContent, LockVersion).unwrapOrNull(),\n },\n ];\n const needKustomize = updatedDeps.some(\n (dep) => dep.managerData?.needKustomize,\n );\n if (needKustomize) {\n toolConstraints.push({\n toolName: 'kustomize',\n constraint: config.constraints?.kustomize,\n });\n }\n\n const cmd: string[] = [];\n const docs = parseYaml(newPackageFileContent, {\n removeTemplates: true,\n customSchema: Doc,\n failureBehaviour: 'filter',\n });\n\n for (const doc of docs) {\n for (const value of coerceArray(doc.repositories).filter(isOCIRegistry)) {\n const loginCmd = await generateRegistryLoginCmd(\n value.name,\n `https://${value.url}`,\n // this extracts the hostname from url like format ghcr.ip/helm-charts\n value.url.replace(regEx(/\\/.*/), ''),\n );\n\n if (loginCmd) {\n cmd.push(loginCmd);\n }\n }\n }\n\n cmd.push(`helmfile deps -f ${quote(packageFileName)}`);\n await exec(cmd, {\n docker: {},\n extraEnv: generateHelmEnvs(),\n toolConstraints,\n });\n\n const newHelmLockContent = await readLocalFile(lockFileName, 'utf8');\n if (existingLockFileContent === newHelmLockContent) {\n logger.debug('helmfile.lock is unchanged');\n return null;\n }\n\n return [\n {\n file: {\n type: 'addition',\n path: lockFileName,\n contents: newHelmLockContent,\n },\n },\n ];\n } catch (err) {\n // istanbul ignore if\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n logger.debug({ err }, 'Failed to update Helmfile lock file');\n return [\n {\n artifactError: {\n fileName: lockFileName,\n stderr: err.message,\n },\n },\n ];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAqBA,eAAsB,gBAAgB,EACpC,iBACA,aACA,uBACA,UAC0D;CAC1D,OAAO,MAAM,4BAA4B,gBAAgB,EAAE;CAE3D,MAAM,EAAE,0BAA0B;CAClC,IACE,CAAC,0BACA,gBAAgB,KAAA,KAAa,YAAY,SAAS,IACnD;EACA,OAAO,MAAM,2CAA2C;EACxD,OAAO;CACT;CAEA,MAAM,e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AI,GAAG,qCAAqC;EAC3D,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/helmfile/artifacts.ts"],"sourcesContent":["import { isFalsy } from '@sindresorhus/is';\nimport { quote } from 'shlex';\nimport { TEMPORARY_ERROR } from '../../../constants/error-messages.ts';\nimport { logger } from '../../../logger/index.ts';\nimport { coerceArray } from '../../../util/array.ts';\nimport { exec } from '../../../util/exec/index.ts';\nimport type { ToolConstraint } from '../../../util/exec/types.ts';\nimport {\n getSiblingFileName,\n readLocalFile,\n writeLocalFile,\n} from '../../../util/fs/index.ts';\nimport { getFile } from '../../../util/git/index.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { Result } from '../../../util/result.ts';\nimport { parseYaml } from '../../../util/yaml.ts';\nimport { generateHelmEnvs } from '../helmv3/common.ts';\nimport type { UpdateArtifact, UpdateArtifactsResult } from '../types.ts';\nimport { resolveToolConstraint } from '../util.ts';\nimport { Doc, LockVersion } from './schema.ts';\nimport { generateRegistryLoginCmd, isOCIRegistry } from './utils.ts';\n\nexport async function updateArtifacts({\n packageFileName,\n updatedDeps,\n newPackageFileContent,\n config,\n}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {\n logger.trace(`helmfile.updateArtifacts(${packageFileName})`);\n\n const { isLockFileMaintenance } = config;\n if (\n !isLockFileMaintenance &&\n (updatedDeps === undefined || updatedDeps.length < 1)\n ) {\n logger.debug('No updated helmfile deps - returning null');\n return null;\n }\n\n const lockFileName = getSiblingFileName(packageFileName, 'helmfile.lock');\n const existingLockFileContent = await getFile(lockFileName);\n\n if (isFalsy(existingLockFileContent)) {\n logger.debug('No helmfile.lock found');\n return null;\n }\n\n try {\n await writeLocalFile(packageFileName, newPackageFileContent);\n\n const toolConstraints: ToolConstraint[] = [\n {\n toolName: 'helm',\n constraint: await resolveToolConstraint(config, 'helm'),\n },\n {\n toolName: 'helmfile',\n constraint: await resolveToolConstraint(config, 'helmfile', () =>\n Result.parse(existingLockFileContent, LockVersion).unwrapOrNull(),\n ),\n },\n ];\n const needKustomize = updatedDeps.some(\n (dep) => dep.managerData?.needKustomize,\n );\n if (needKustomize) {\n toolConstraints.push({\n toolName: 'kustomize',\n constraint: await resolveToolConstraint(config, 'kustomize'),\n });\n }\n\n const cmd: string[] = [];\n const docs = parseYaml(newPackageFileContent, {\n removeTemplates: true,\n customSchema: Doc,\n failureBehaviour: 'filter',\n });\n\n for (const doc of docs) {\n for (const value of coerceArray(doc.repositories).filter(isOCIRegistry)) {\n const loginCmd = await generateRegistryLoginCmd(\n value.name,\n `https://${value.url}`,\n // this extracts the hostname from url like format ghcr.ip/helm-charts\n value.url.replace(regEx(/\\/.*/), ''),\n );\n\n if (loginCmd) {\n cmd.push(loginCmd);\n }\n }\n }\n\n cmd.push(`helmfile deps -f ${quote(packageFileName)}`);\n await exec(cmd, {\n docker: {},\n extraEnv: generateHelmEnvs(),\n toolConstraints,\n });\n\n const newHelmLockContent = await readLocalFile(lockFileName, 'utf8');\n if (existingLockFileContent === newHelmLockContent) {\n logger.debug('helmfile.lock is unchanged');\n return null;\n }\n\n return [\n {\n file: {\n type: 'addition',\n path: lockFileName,\n contents: newHelmLockContent,\n },\n },\n ];\n } catch (err) {\n // istanbul ignore if\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n logger.debug({ err }, 'Failed to update Helmfile lock file');\n return [\n {\n artifactError: {\n fileName: lockFileName,\n stderr: err.message,\n },\n },\n ];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAsBA,eAAsB,gBAAgB,EACpC,iBACA,aACA,uBACA,UAC0D;CAC1D,OAAO,MAAM,4BAA4B,gBAAgB,EAAE;CAE3D,MAAM,EAAE,0BAA0B;CAClC,IACE,CAAC,0BACA,gBAAgB,KAAA,KAAa,YAAY,SAAS,IACnD;EACA,OAAO,MAAM,2CAA2C;EACxD,OAAO;CACT;C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EAEZ,IAAI,IAAI,YAAA,mBACN,MAAM;EAER,OAAO,MAAM,EAAE,IAAI,GAAG,qCAAqC;EAC3D,OAAO,CACL,EACE,eAAe;GACb,UAAU;GACV,QAAQ,IAAI;EACd,EACF,CACF;CACF;AACF"}
@@ -9,6 +9,7 @@ import { exec } from "../../../util/exec/index.js";
9
9
  import { getRepoStatus } from "../../../util/git/index.js";
10
10
  import { DockerDatasource } from "../../datasource/docker/index.js";
11
11
  import { HelmDatasource } from "../../datasource/helm/index.js";
12
+ import { resolveToolConstraint } from "../util.js";
12
13
  import { isOCIRegistry, removeOCIPrefix } from "./oci.js";
13
14
  import { generateHelmEnvs, generateLoginCmd } from "./common.js";
14
15
  import { aliasRecordToRepositories, getRepositories, isFileInDir } from "./utils.js";
@@ -77,7 +78,7 @@ async function updateArtifacts({ packageFileName, updatedDeps, newPackageFileCon
77
78
  logger.debug("Updating Helm artifacts");
78
79
  const helmToolConstraint = {
79
80
  toolName: "helm",
80
- constraint: config.constraints?.helm
81
+ constraint: await resolveToolConstraint(config, "helm")
81
82
  };
82
83
  await helmCommands({
83
84
  docker: {},
@@ -1 +1 @@
1
- {"version":3,"file":"artifacts.js","names":["hostRules.find","yaml.parseSingleYaml"],"sources":["../../../../lib/modules/manager/helmv3/artifacts.ts"],"sourcesContent":["import { isString, isTruthy } from '@sindresorhus/is';\nimport pMap from 'p-map';\nimport { quote } from 'shlex';\nimport { TEMPORARY_ERROR } from '../../../constants/error-messages.ts';\nimport { logger } from '../../../logger/index.ts';\nimport { coerceArray } from '../../../util/array.ts';\nimport { exec } from '../../../util/exec/index.ts';\nimport type { ExecOptions, ToolConstraint } from '../../../util/exec/types.ts';\nimport {\n getParentDir,\n getSiblingFileName,\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 { regEx } from '../../../util/regex.ts';\nimport * as yaml from '../../../util/yaml.ts';\nimport { DockerDatasource } from '../../datasource/docker/index.ts';\nimport { HelmDatasource } from '../../datasource/helm/index.ts';\nimport type { UpdateArtifact, UpdateArtifactsResult } from '../types.ts';\nimport { generateHelmEnvs, generateLoginCmd } from './common.ts';\nimport { isOCIRegistry, removeOCIPrefix } from './oci.ts';\nimport type { ChartDefinition, Repository, RepositoryRule } from './types.ts';\nimport {\n aliasRecordToRepositories,\n getRepositories,\n isFileInDir,\n} from './utils.ts';\n\nasync function helmCommands(\n execOptions: ExecOptions,\n manifestPath: string,\n repositories: Repository[],\n): Promise<void> {\n const cmd: string[] = [];\n // get OCI registries and detect host rules\n const registries: RepositoryRule[] = repositories\n .filter(isOCIRegistry)\n .map((value) => {\n return {\n ...value,\n repository: removeOCIPrefix(value.repository),\n hostRule: hostRules.find({\n url: value.repository.replace('oci://', 'https://'), //TODO we need to replace this, as oci:// will not be accepted as protocol\n hostType: DockerDatasource.id,\n }),\n };\n });\n\n // if credentials for the registry have been found, log into it\n await pMap(registries, async (value) => {\n const loginCmd = await generateLoginCmd(value);\n if (loginCmd) {\n cmd.push(loginCmd);\n }\n });\n\n // find classic Chart repositories and fitting host rules\n const classicRepositories: RepositoryRule[] = repositories\n .filter((repository) => !isOCIRegistry(repository))\n .map((value) => {\n return {\n ...value,\n hostRule: hostRules.find({\n url: value.repository,\n hostType: HelmDatasource.id,\n }),\n };\n });\n\n // add helm repos if an alias or credentials for the url are defined\n classicRepositories.forEach((value) => {\n const { username, password } = value.hostRule;\n const parameters = [`${quote(value.repository)}`, `--force-update`];\n const isPrivateRepo = username && password;\n if (isPrivateRepo) {\n parameters.push(`--username ${quote(username)}`);\n parameters.push(`--password ${quote(password)}`);\n }\n\n cmd.push(`helm repo add ${quote(value.name)} ${parameters.join(' ')}`);\n });\n\n cmd.push(`helm dependency update ${quote(getParentDir(manifestPath))}`);\n\n await exec(cmd, execOptions);\n}\n\nexport async function updateArtifacts({\n packageFileName,\n updatedDeps,\n newPackageFileContent,\n config,\n}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {\n logger.debug(`helmv3.updateArtifacts(${packageFileName})`);\n\n const { isLockFileMaintenance } = config;\n const isUpdateOptionAddChartArchives = config.postUpdateOptions?.includes(\n 'helmUpdateSubChartArchives',\n );\n\n if (\n !isLockFileMaintenance &&\n (updatedDeps === undefined || updatedDeps.length < 1)\n ) {\n logger.debug('No updated helmv3 deps - returning null');\n return null;\n }\n\n const lockFileName = getSiblingFileName(packageFileName, 'Chart.lock');\n const existingLockFileContent = await readLocalFile(lockFileName, 'utf8');\n if (!existingLockFileContent && !isUpdateOptionAddChartArchives) {\n logger.debug('No Chart.lock found');\n return null;\n }\n try {\n // get repositories and registries defined in the package file\n // TODO: use schema (#9610)\n const packages = yaml.parseSingleYaml<ChartDefinition>(\n newPackageFileContent,\n );\n const locks = existingLockFileContent\n ? yaml.parseSingleYaml<ChartDefinition>(existingLockFileContent)\n : { dependencies: [] };\n\n const chartDefinitions: ChartDefinition[] = [];\n // prioritize registryAlias naming for Helm repositories\n if (config.registryAliases) {\n chartDefinitions.push({\n dependencies: aliasRecordToRepositories(config.registryAliases),\n });\n }\n chartDefinitions.push(packages, locks);\n\n const repositories = getRepositories(chartDefinitions);\n\n await writeLocalFile(packageFileName, newPackageFileContent);\n logger.debug('Updating Helm artifacts');\n const helmToolConstraint: ToolConstraint = {\n toolName: 'helm',\n constraint: config.constraints?.helm,\n };\n\n const execOptions: ExecOptions = {\n docker: {},\n extraEnv: generateHelmEnvs(),\n toolConstraints: [helmToolConstraint],\n };\n await helmCommands(execOptions, packageFileName, repositories);\n logger.debug('Returning updated Helm artifacts');\n\n const fileChanges: UpdateArtifactsResult[] = [];\n\n if (isTruthy(existingLockFileContent)) {\n const newHelmLockContent = await readLocalFile(lockFileName, 'utf8');\n const isLockFileChanged =\n !isString(newHelmLockContent) ||\n isHelmLockChanged(existingLockFileContent, newHelmLockContent);\n if (isLockFileChanged) {\n fileChanges.push({\n file: {\n type: 'addition',\n path: lockFileName,\n contents: newHelmLockContent,\n },\n });\n } else {\n logger.debug('Chart.lock is unchanged');\n }\n }\n\n // add modified helm chart archives to artifacts\n if (isTruthy(isUpdateOptionAddChartArchives)) {\n const chartsPath = getSiblingFileName(packageFileName, 'charts');\n const status = await getRepoStatus();\n const chartsAddition = coerceArray(status.not_added);\n const chartsDeletion = coerceArray(status.deleted);\n\n for (const file of chartsAddition) {\n // only add artifacts in the chart sub path\n if (!isFileInDir(chartsPath, file)) {\n continue;\n }\n fileChanges.push({\n file: {\n type: 'addition',\n path: file,\n contents: await readLocalFile(file),\n },\n });\n }\n\n for (const file of chartsDeletion) {\n // only add artifacts in the chart sub path\n if (!isFileInDir(chartsPath, file)) {\n continue;\n }\n fileChanges.push({\n file: {\n type: 'deletion',\n path: file,\n },\n });\n }\n }\n\n return fileChanges.length > 0 ? fileChanges : null;\n } catch (err) {\n // istanbul ignore if\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n logger.debug({ err }, 'Failed to update Helm lock file');\n return [\n {\n artifactError: {\n fileName: lockFileName,\n stderr: err.message,\n },\n },\n ];\n }\n}\n\nfunction isHelmLockChanged(oldContent: string, newContent: string): boolean {\n const regex = regEx(/^generated: \".+\"$/m);\n return newContent.replace(regex, '') !== oldContent.replace(regex, '');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA8BA,eAAe,aACb,aACA,cACA,cACe;CACf,MAAM,MAAgB,CAAC;CAEvB,MAAM,aAA+B,aAClC,OAAO,aAAa,CAAC,CACrB,KAAK,UAAU;EACd,OAAO;GACL,GAAG;GACH,YAAY,gBAAgB,MAAM,UAAU;GAC5C,UAAUA,KAAe;IACvB,KAAK,MAAM,WAAW,QAAQ,UAAU,UAAU;IAClD,UAAU,iBAAiB;GAC7B,CAAC;EACH;CACF,CAAC;CAGH,MAAM,KAAK,YAAY,OAAO,UAAU;EACtC,MAAM,WAAW,MAAM,iBAAiB,KAAK;EAC7C,IAAI,UACF,IAAI,KAAK,QAAQ;CAErB,CAAC;CAgBD,aAZG,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AI,IAAI,YAAA,mBACN,MAAM;EAER,OAAO,MAAM,EAAE,IAAI,GAAG,iCAAiC;EACvD,OAAO,CACL,EACE,eAAe;GACb,UAAU;GACV,QAAQ,IAAI;EACd,EACF,CACF;CACF;AACF;AAEA,SAAS,kBAAkB,YAAoB,YAA6B;CAC1E,MAAM,QAAQ,MAAM,oBAAoB;CACxC,OAAO,WAAW,QAAQ,OAAO,EAAE,MAAM,WAAW,QAAQ,OAAO,EAAE;AACvE"}
1
+ {"version":3,"file":"artifacts.js","names":["hostRules.find","yaml.parseSingleYaml"],"sources":["../../../../lib/modules/manager/helmv3/artifacts.ts"],"sourcesContent":["import { isString, isTruthy } from '@sindresorhus/is';\nimport pMap from 'p-map';\nimport { quote } from 'shlex';\nimport { TEMPORARY_ERROR } from '../../../constants/error-messages.ts';\nimport { logger } from '../../../logger/index.ts';\nimport { coerceArray } from '../../../util/array.ts';\nimport { exec } from '../../../util/exec/index.ts';\nimport type { ExecOptions, ToolConstraint } from '../../../util/exec/types.ts';\nimport {\n getParentDir,\n getSiblingFileName,\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 { regEx } from '../../../util/regex.ts';\nimport * as yaml from '../../../util/yaml.ts';\nimport { DockerDatasource } from '../../datasource/docker/index.ts';\nimport { HelmDatasource } from '../../datasource/helm/index.ts';\nimport type { UpdateArtifact, UpdateArtifactsResult } from '../types.ts';\nimport { resolveToolConstraint } from '../util.ts';\nimport { generateHelmEnvs, generateLoginCmd } from './common.ts';\nimport { isOCIRegistry, removeOCIPrefix } from './oci.ts';\nimport type { ChartDefinition, Repository, RepositoryRule } from './types.ts';\nimport {\n aliasRecordToRepositories,\n getRepositories,\n isFileInDir,\n} from './utils.ts';\n\nasync function helmCommands(\n execOptions: ExecOptions,\n manifestPath: string,\n repositories: Repository[],\n): Promise<void> {\n const cmd: string[] = [];\n // get OCI registries and detect host rules\n const registries: RepositoryRule[] = repositories\n .filter(isOCIRegistry)\n .map((value) => {\n return {\n ...value,\n repository: removeOCIPrefix(value.repository),\n hostRule: hostRules.find({\n url: value.repository.replace('oci://', 'https://'), //TODO we need to replace this, as oci:// will not be accepted as protocol\n hostType: DockerDatasource.id,\n }),\n };\n });\n\n // if credentials for the registry have been found, log into it\n await pMap(registries, async (value) => {\n const loginCmd = await generateLoginCmd(value);\n if (loginCmd) {\n cmd.push(loginCmd);\n }\n });\n\n // find classic Chart repositories and fitting host rules\n const classicRepositories: RepositoryRule[] = repositories\n .filter((repository) => !isOCIRegistry(repository))\n .map((value) => {\n return {\n ...value,\n hostRule: hostRules.find({\n url: value.repository,\n hostType: HelmDatasource.id,\n }),\n };\n });\n\n // add helm repos if an alias or credentials for the url are defined\n classicRepositories.forEach((value) => {\n const { username, password } = value.hostRule;\n const parameters = [`${quote(value.repository)}`, `--force-update`];\n const isPrivateRepo = username && password;\n if (isPrivateRepo) {\n parameters.push(`--username ${quote(username)}`);\n parameters.push(`--password ${quote(password)}`);\n }\n\n cmd.push(`helm repo add ${quote(value.name)} ${parameters.join(' ')}`);\n });\n\n cmd.push(`helm dependency update ${quote(getParentDir(manifestPath))}`);\n\n await exec(cmd, execOptions);\n}\n\nexport async function updateArtifacts({\n packageFileName,\n updatedDeps,\n newPackageFileContent,\n config,\n}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {\n logger.debug(`helmv3.updateArtifacts(${packageFileName})`);\n\n const { isLockFileMaintenance } = config;\n const isUpdateOptionAddChartArchives = config.postUpdateOptions?.includes(\n 'helmUpdateSubChartArchives',\n );\n\n if (\n !isLockFileMaintenance &&\n (updatedDeps === undefined || updatedDeps.length < 1)\n ) {\n logger.debug('No updated helmv3 deps - returning null');\n return null;\n }\n\n const lockFileName = getSiblingFileName(packageFileName, 'Chart.lock');\n const existingLockFileContent = await readLocalFile(lockFileName, 'utf8');\n if (!existingLockFileContent && !isUpdateOptionAddChartArchives) {\n logger.debug('No Chart.lock found');\n return null;\n }\n try {\n // get repositories and registries defined in the package file\n // TODO: use schema (#9610)\n const packages = yaml.parseSingleYaml<ChartDefinition>(\n newPackageFileContent,\n );\n const locks = existingLockFileContent\n ? yaml.parseSingleYaml<ChartDefinition>(existingLockFileContent)\n : { dependencies: [] };\n\n const chartDefinitions: ChartDefinition[] = [];\n // prioritize registryAlias naming for Helm repositories\n if (config.registryAliases) {\n chartDefinitions.push({\n dependencies: aliasRecordToRepositories(config.registryAliases),\n });\n }\n chartDefinitions.push(packages, locks);\n\n const repositories = getRepositories(chartDefinitions);\n\n await writeLocalFile(packageFileName, newPackageFileContent);\n logger.debug('Updating Helm artifacts');\n const helmToolConstraint: ToolConstraint = {\n toolName: 'helm',\n constraint: await resolveToolConstraint(config, 'helm'),\n };\n\n const execOptions: ExecOptions = {\n docker: {},\n extraEnv: generateHelmEnvs(),\n toolConstraints: [helmToolConstraint],\n };\n await helmCommands(execOptions, packageFileName, repositories);\n logger.debug('Returning updated Helm artifacts');\n\n const fileChanges: UpdateArtifactsResult[] = [];\n\n if (isTruthy(existingLockFileContent)) {\n const newHelmLockContent = await readLocalFile(lockFileName, 'utf8');\n const isLockFileChanged =\n !isString(newHelmLockContent) ||\n isHelmLockChanged(existingLockFileContent, newHelmLockContent);\n if (isLockFileChanged) {\n fileChanges.push({\n file: {\n type: 'addition',\n path: lockFileName,\n contents: newHelmLockContent,\n },\n });\n } else {\n logger.debug('Chart.lock is unchanged');\n }\n }\n\n // add modified helm chart archives to artifacts\n if (isTruthy(isUpdateOptionAddChartArchives)) {\n const chartsPath = getSiblingFileName(packageFileName, 'charts');\n const status = await getRepoStatus();\n const chartsAddition = coerceArray(status.not_added);\n const chartsDeletion = coerceArray(status.deleted);\n\n for (const file of chartsAddition) {\n // only add artifacts in the chart sub path\n if (!isFileInDir(chartsPath, file)) {\n continue;\n }\n fileChanges.push({\n file: {\n type: 'addition',\n path: file,\n contents: await readLocalFile(file),\n },\n });\n }\n\n for (const file of chartsDeletion) {\n // only add artifacts in the chart sub path\n if (!isFileInDir(chartsPath, file)) {\n continue;\n }\n fileChanges.push({\n file: {\n type: 'deletion',\n path: file,\n },\n });\n }\n }\n\n return fileChanges.length > 0 ? fileChanges : null;\n } catch (err) {\n // istanbul ignore if\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n logger.debug({ err }, 'Failed to update Helm lock file');\n return [\n {\n artifactError: {\n fileName: lockFileName,\n stderr: err.message,\n },\n },\n ];\n }\n}\n\nfunction isHelmLockChanged(oldContent: string, newContent: string): boolean {\n const regex = regEx(/^generated: \".+\"$/m);\n return newContent.replace(regex, '') !== oldContent.replace(regex, '');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA+BA,eAAe,aACb,aACA,cACA,cACe;CACf,MAAM,MAAgB,CAAC;CAEvB,MAAM,aAA+B,aAClC,OAAO,aAAa,CAAC,CACrB,KAAK,UAAU;EACd,OAAO;GACL,GAAG;GACH,YAAY,gBAAgB,MAAM,UAAU;GAC5C,UAAUA,KAAe;IACvB,KAAK,MAAM,WAAW,QAAQ,UAAU,UAAU;IAClD,UAAU,iBAAiB;GAC7B,CAAC;EACH;CACF,CAAC;CAGH,MAAM,KAAK,YAAY,OAAO,UAAU;EACtC,MAAM,WAAW,MAAM,iBAAiB,KAAK;EAC7C,IAAI,UACF,IAAI,KAAK,QAAQ;CAErB,CAAC;CAgBD,aAZG,QAAQ,eAAe,CAAC,cAAc,UAAU,CAAC,CAAC,CAClD,KAAK,UAAU;EACd,OAAO;GACL,GAAG;GACH,UAAUA,KAAe;IACvB,KAAK,MAAM;IACX,UAAU,eAAe;GAC3B,CAAC;EACH;CACF,CAGgB,CAAC,CAAC,SAAS,UAAU;EACrC,MAAM,EAAE,UAAU,aAAa,MAAM;EACrC,MAAM,aAAa,CAAC,GAAG,MAAM,MAAM,UAAU,KAAK,gBAAgB;EAElE,IADsB,YAAY,UACf;GACjB,WAAW,KAAK,cAAc,MAAM,QAAQ,GAAG;GAC/C,WAAW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alFile } from "../../../util/fs/index.js";
6
6
  import { exec } from "../../../util/exec/index.js";
7
7
  import { getRepoStatus } from "../../../util/git/index.js";
8
+ import { resolveToolConstraint } from "../util.js";
8
9
  import { quote } from "shlex";
9
10
  //#region lib/modules/manager/jsonnet-bundler/artifacts.ts
10
11
  function dependencyUrl(dep) {
@@ -25,7 +26,7 @@ async function updateArtifacts(updateArtifact) {
25
26
  docker: {},
26
27
  toolConstraints: [{
27
28
  toolName: "jb",
28
- constraint: config.constraints?.jb
29
+ constraint: await resolveToolConstraint(config, "jb")
29
30
  }]
30
31
  };
31
32
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"artifacts.js","names":[],"sources":["../../../../lib/modules/manager/jsonnet-bundler/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 { exec } from '../../../util/exec/index.ts';\nimport type { ExecOptions, ToolConstraint } from '../../../util/exec/types.ts';\nimport { readLocalFile } from '../../../util/fs/index.ts';\nimport { getRepoStatus } from '../../../util/git/index.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport type {\n PackageDependency,\n UpdateArtifact,\n UpdateArtifactsResult,\n} from '../types.ts';\n\nfunction dependencyUrl(dep: PackageDependency): string {\n const url = dep.packageName!;\n if (dep.managerData?.subdir) {\n return url.concat('/', dep.managerData.subdir);\n }\n return url;\n}\n\nexport async function updateArtifacts(\n updateArtifact: UpdateArtifact,\n): Promise<UpdateArtifactsResult[] | null> {\n const { packageFileName, updatedDeps, config } = updateArtifact;\n logger.trace({ packageFileName }, 'jsonnet-bundler.updateArtifacts()');\n\n const lockFileName = packageFileName.replace(regEx(/\\.json$/), '.lock.json');\n const existingLockFileContent = await readLocalFile(lockFileName, 'utf8');\n\n if (!existingLockFileContent) {\n logger.debug('No jsonnetfile.lock.json found');\n return null;\n }\n\n const jsonnetBundlerToolConstraint: ToolConstraint = {\n toolName: 'jb',\n constraint: config.constraints?.jb,\n };\n\n const execOptions: ExecOptions = {\n cwdFile: packageFileName,\n docker: {},\n toolConstraints: [jsonnetBundlerToolConstraint],\n };\n\n try {\n if (config.isLockFileMaintenance) {\n await exec('jb update', execOptions);\n } else {\n const dependencyUrls = updatedDeps.map(dependencyUrl);\n if (dependencyUrls.length > 0) {\n await exec(\n `jb update ${dependencyUrls.map(quote).join(' ')}`,\n execOptions,\n );\n }\n }\n\n const status = await getRepoStatus();\n\n if (status.isClean()) {\n return null;\n }\n\n const res: UpdateArtifactsResult[] = [];\n\n for (const f of coerceArray(status.modified)) {\n res.push({\n file: {\n type: 'addition',\n path: f,\n contents: await readLocalFile(f),\n },\n });\n }\n for (const f of coerceArray(status.not_added)) {\n res.push({\n file: {\n type: 'addition',\n path: f,\n contents: await readLocalFile(f),\n },\n });\n }\n for (const f of coerceArray(status.deleted)) {\n res.push({\n file: {\n type: 'deletion',\n path: f,\n },\n });\n }\n\n return res;\n } catch (err) /* istanbul ignore next */ {\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n return [\n {\n artifactError: {\n fileName: lockFileName,\n stderr: err.stderr,\n },\n },\n ];\n }\n}\n"],"mappings":";;;;;;;;;AAeA,SAAS,cAAc,KAAgC;CACrD,MAAM,MAAM,IAAI;CAChB,IAAI,IAAI,aAAa,QACnB,OAAO,IAAI,OAAO,KAAK,IAAI,YAAY,MAAM;CAE/C,OAAO;AACT;AAEA,eAAsB,gBACpB,gBACyC;CACzC,MAAM,EAAE,iBAAiB,aAAa,WAAW;CACjD,OAAO,MAAM,EAAE,gBAAgB,GAAG,mCAAmC;CAErE,MAAM,eAAe,gBAAgB,QAAQ,MAAM,SAAS,GAAG,YAAY;CAG3E,IAAI,CAAC,MAFiC,cAAc,cAAc,MAAM,GAE1C;EAC5B,OAAO,MAAM,gCAAgC;EAC7C,OAAO;CACT;CAOA,MAAM,cAA2B;EAC/B,SAAS;EACT,QAAQ,CAAC;EACT,iBAAiB,CAAC;GAPlB,UAAU;GACV,YAAY,OAAO,aAAa;EAMa,CAAC;CAChD;CAEA,IAAI;EACF,IAAI,OAAO,uBACT,MAAM,KAAK,aAAa,WAAW;OAC9B;GACL,MAAM,iBAAiB,YAAY,IAAI,aAAa;GACpD,IAAI,eAAe,SAAS,GAC1B,MAAM,KACJ,aAAa,eAAe,IAAI,KAAK,CAAC,CAAC,KAAK,GAAG,KAC/C,WACF;EAEJ;EAEA,MAAM,SAAS,MAAM,cAAc;EAEnC,IAAI,OAAO,QAAQ,GACjB,OAAO;EAGT,MAAM,MAA+B,CAAC;EAEtC,KAAK,MAAM,KAAK,YAAY,OAAO,QAAQ,GACzC,IAAI,KAAK,EACP,MAAM;GACJ,MAAM;GACN,MAAM;GACN,UAAU,MAAM,cAAc,CAAC;EACjC,EACF,CAAC;EAEH,KAAK,MAAM,KAAK,YAAY,OAAO,SAAS,GAC1C,IAAI,KAAK,EACP,MAAM;GACJ,MAAM;GACN,MAAM;GACN,UAAU,MAAM,cAAc,CAAC;EACjC,EACF,CAAC;EAEH,KAAK,MAAM,KAAK,YAAY,OAAO,OAAO,GACxC,IAAI,KAAK,EACP,MAAM;GACJ,MAAM;GACN,MAAM;EACR,EACF,CAAC;EAGH,OAAO;CACT,SAAS,gCAAgC;EACvC,IAAI,IAAI,YAAA,mBACN,MAAM;EAER,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/jsonnet-bundler/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 { exec } from '../../../util/exec/index.ts';\nimport type { ExecOptions, ToolConstraint } from '../../../util/exec/types.ts';\nimport { readLocalFile } from '../../../util/fs/index.ts';\nimport { getRepoStatus } from '../../../util/git/index.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport type {\n PackageDependency,\n UpdateArtifact,\n UpdateArtifactsResult,\n} from '../types.ts';\nimport { resolveToolConstraint } from '../util.ts';\n\nfunction dependencyUrl(dep: PackageDependency): string {\n const url = dep.packageName!;\n if (dep.managerData?.subdir) {\n return url.concat('/', dep.managerData.subdir);\n }\n return url;\n}\n\nexport async function updateArtifacts(\n updateArtifact: UpdateArtifact,\n): Promise<UpdateArtifactsResult[] | null> {\n const { packageFileName, updatedDeps, config } = updateArtifact;\n logger.trace({ packageFileName }, 'jsonnet-bundler.updateArtifacts()');\n\n const lockFileName = packageFileName.replace(regEx(/\\.json$/), '.lock.json');\n const existingLockFileContent = await readLocalFile(lockFileName, 'utf8');\n\n if (!existingLockFileContent) {\n logger.debug('No jsonnetfile.lock.json found');\n return null;\n }\n\n const jsonnetBundlerToolConstraint: ToolConstraint = {\n toolName: 'jb',\n constraint: await resolveToolConstraint(config, 'jb'),\n };\n\n const execOptions: ExecOptions = {\n cwdFile: packageFileName,\n docker: {},\n toolConstraints: [jsonnetBundlerToolConstraint],\n };\n\n try {\n if (config.isLockFileMaintenance) {\n await exec('jb update', execOptions);\n } else {\n const dependencyUrls = updatedDeps.map(dependencyUrl);\n if (dependencyUrls.length > 0) {\n await exec(\n `jb update ${dependencyUrls.map(quote).join(' ')}`,\n execOptions,\n );\n }\n }\n\n const status = await getRepoStatus();\n\n if (status.isClean()) {\n return null;\n }\n\n const res: UpdateArtifactsResult[] = [];\n\n for (const f of coerceArray(status.modified)) {\n res.push({\n file: {\n type: 'addition',\n path: f,\n contents: await readLocalFile(f),\n },\n });\n }\n for (const f of coerceArray(status.not_added)) {\n res.push({\n file: {\n type: 'addition',\n path: f,\n contents: await readLocalFile(f),\n },\n });\n }\n for (const f of coerceArray(status.deleted)) {\n res.push({\n file: {\n type: 'deletion',\n path: f,\n },\n });\n }\n\n return res;\n } catch (err) /* istanbul ignore next */ {\n if (err.message === TEMPORARY_ERROR) {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,CAAC;EAEH,KAAK,MAAM,KAAK,YAAY,OAAO,OAAO,GACxC,IAAI,KAAK,EACP,MAAM;GACJ,MAAM;GACN,MAAM;EACR,EACF,CAAC;EAGH,OAAO;CACT,SAAS,gCAAgC;EACvC,IAAI,IAAI,YAAA,mBACN,MAAM;EAER,OAAO,CACL,EACE,eAAe;GACb,UAAU;GACV,QAAQ,IAAI;EACd,EACF,CACF;CACF;AACF"}
@@ -6,6 +6,7 @@ import { exec } from "../../../util/exec/index.js";
6
6
  import { getRepoStatus } from "../../../util/git/index.js";
7
7
  import { DockerDatasource } from "../../datasource/docker/index.js";
8
8
  import { HelmDatasource } from "../../datasource/helm/index.js";
9
+ import { resolveToolConstraint } from "../util.js";
9
10
  import { parseKustomize } from "./extract.js";
10
11
  import { generateHelmEnvs } from "./common.js";
11
12
  import { isNonEmptyString, isNullOrUndefined } from "@sindresorhus/is";
@@ -54,13 +55,14 @@ async function updateArtifacts({ packageFileName, updatedDeps, newPackageFileCon
54
55
  if (isNullOrUndefined(project)) return [{ artifactError: { stderr: "Failed to parse new package file content" } }];
55
56
  const chartHome = getSiblingFileName(packageFileName, project.helmGlobals?.chartHome ?? "charts");
56
57
  try {
58
+ const helmConstraint = await resolveToolConstraint(config, "helm");
57
59
  const helmToolConstraint = {
58
60
  toolName: "helm",
59
- constraint: config.constraints?.helm
61
+ constraint: helmConstraint
60
62
  };
61
63
  const execOptions = {
62
64
  docker: {},
63
- extraEnv: generateHelmEnvs(config),
65
+ extraEnv: generateHelmEnvs(helmConstraint),
64
66
  toolConstraints: [helmToolConstraint]
65
67
  };
66
68
  for (const dependency of updatedDeps) {