renovate 44.30.0 → 44.30.1

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 (199) hide show
  1. package/dist/config/migration.js +3 -3
  2. package/dist/config/migration.js.map +1 -1
  3. package/dist/config/migrations/custom/azure-gitlab-automerge-migration.js.map +1 -1
  4. package/dist/config/migrations/custom/dep-types-migration.js.map +1 -1
  5. package/dist/config/options/env.js +2 -1
  6. package/dist/config/options/env.js.map +1 -1
  7. package/dist/logger/utils.js +3 -3
  8. package/dist/logger/utils.js.map +1 -1
  9. package/dist/modules/datasource/crate/index.js +3 -3
  10. package/dist/modules/datasource/crate/index.js.map +1 -1
  11. package/dist/modules/datasource/go/base.js +1 -1
  12. package/dist/modules/datasource/go/base.js.map +1 -1
  13. package/dist/modules/datasource/go/goproxy-parser.js +1 -1
  14. package/dist/modules/datasource/go/goproxy-parser.js.map +1 -1
  15. package/dist/modules/datasource/hexpm-bob/index.js +3 -3
  16. package/dist/modules/datasource/hexpm-bob/index.js.map +1 -1
  17. package/dist/modules/datasource/maven/util.js +1 -1
  18. package/dist/modules/datasource/maven/util.js.map +1 -1
  19. package/dist/modules/datasource/packagist/schema.js +2 -1
  20. package/dist/modules/datasource/packagist/schema.js.map +1 -1
  21. package/dist/modules/datasource/pypi/common.js +1 -1
  22. package/dist/modules/datasource/pypi/common.js.map +1 -1
  23. package/dist/modules/datasource/rpm/repomd.js +2 -1
  24. package/dist/modules/datasource/rpm/repomd.js.map +1 -1
  25. package/dist/modules/datasource/sbt-package/util.js +3 -3
  26. package/dist/modules/datasource/sbt-package/util.js.map +1 -1
  27. package/dist/modules/datasource/terraform-provider/index.js +1 -1
  28. package/dist/modules/datasource/terraform-provider/index.js.map +1 -1
  29. package/dist/modules/manager/ansible-galaxy/util.js +4 -4
  30. package/dist/modules/manager/ansible-galaxy/util.js.map +1 -1
  31. package/dist/modules/manager/asdf/upgradeable-tooling.js +5 -5
  32. package/dist/modules/manager/asdf/upgradeable-tooling.js.map +1 -1
  33. package/dist/modules/manager/bazel-module/extract.js +2 -1
  34. package/dist/modules/manager/bazel-module/extract.js.map +1 -1
  35. package/dist/modules/manager/bazel-module/parser/repo-rules.js +1 -1
  36. package/dist/modules/manager/bazel-module/parser/repo-rules.js.map +1 -1
  37. package/dist/modules/manager/bitbucket-pipelines/extract.js +2 -2
  38. package/dist/modules/manager/bitbucket-pipelines/extract.js.map +1 -1
  39. package/dist/modules/manager/bun/utils.js +2 -1
  40. package/dist/modules/manager/bun/utils.js.map +1 -1
  41. package/dist/modules/manager/bundler/extract.js +1 -1
  42. package/dist/modules/manager/bundler/extract.js.map +1 -1
  43. package/dist/modules/manager/cake/index.js.map +1 -1
  44. package/dist/modules/manager/composer/schema.js +2 -2
  45. package/dist/modules/manager/composer/schema.js.map +1 -1
  46. package/dist/modules/manager/cpanfile/language.js.map +1 -1
  47. package/dist/modules/manager/cpanfile/parser.js +4 -4
  48. package/dist/modules/manager/cpanfile/parser.js.map +1 -1
  49. package/dist/modules/manager/crossplane/extract.js +2 -1
  50. package/dist/modules/manager/crossplane/extract.js.map +1 -1
  51. package/dist/modules/manager/deps-edn/extract.js +1 -1
  52. package/dist/modules/manager/deps-edn/extract.js.map +1 -1
  53. package/dist/modules/manager/deps-edn/parser.js.map +1 -1
  54. package/dist/modules/manager/dockerfile/extract.js +2 -2
  55. package/dist/modules/manager/dockerfile/extract.js.map +1 -1
  56. package/dist/modules/manager/flux/extract.js +2 -2
  57. package/dist/modules/manager/flux/extract.js.map +1 -1
  58. package/dist/modules/manager/git-submodules/extract.js +1 -1
  59. package/dist/modules/manager/git-submodules/extract.js.map +1 -1
  60. package/dist/modules/manager/gomod/artifacts.js +1 -1
  61. package/dist/modules/manager/gomod/artifacts.js.map +1 -1
  62. package/dist/modules/manager/gradle/extract/consistent-versions-plugin.js +2 -2
  63. package/dist/modules/manager/gradle/extract/consistent-versions-plugin.js.map +1 -1
  64. package/dist/modules/manager/gradle-wrapper/artifacts.js +2 -2
  65. package/dist/modules/manager/gradle-wrapper/artifacts.js.map +1 -1
  66. package/dist/modules/manager/helmv3/utils.js +2 -1
  67. package/dist/modules/manager/helmv3/utils.js.map +1 -1
  68. package/dist/modules/manager/hermit/extract.js +1 -1
  69. package/dist/modules/manager/hermit/extract.js.map +1 -1
  70. package/dist/modules/manager/homebrew/utils.js +3 -3
  71. package/dist/modules/manager/homebrew/utils.js.map +1 -1
  72. package/dist/modules/manager/jsonnet-bundler/extract.js +2 -1
  73. package/dist/modules/manager/jsonnet-bundler/extract.js.map +1 -1
  74. package/dist/modules/manager/leiningen/extract.js +2 -2
  75. package/dist/modules/manager/leiningen/extract.js.map +1 -1
  76. package/dist/modules/manager/maven-wrapper/artifacts.js +6 -6
  77. package/dist/modules/manager/maven-wrapper/artifacts.js.map +1 -1
  78. package/dist/modules/manager/mise/backends.js +3 -3
  79. package/dist/modules/manager/mise/backends.js.map +1 -1
  80. package/dist/modules/manager/mise/upgradeable-tooling.js +1 -1
  81. package/dist/modules/manager/mise/upgradeable-tooling.js.map +1 -1
  82. package/dist/modules/manager/npm/extract/common/dependency.js +2 -2
  83. package/dist/modules/manager/npm/extract/common/dependency.js.map +1 -1
  84. package/dist/modules/manager/npm/extract/post/locked-versions.js +2 -1
  85. package/dist/modules/manager/npm/extract/post/locked-versions.js.map +1 -1
  86. package/dist/modules/manager/npm/post-update/index.js +1 -1
  87. package/dist/modules/manager/npm/post-update/index.js.map +1 -1
  88. package/dist/modules/manager/npm/post-update/npm.js +2 -1
  89. package/dist/modules/manager/npm/post-update/npm.js.map +1 -1
  90. package/dist/modules/manager/npm/post-update/yarn.js +2 -2
  91. package/dist/modules/manager/npm/post-update/yarn.js.map +1 -1
  92. package/dist/modules/manager/npm/schema.js +2 -1
  93. package/dist/modules/manager/npm/schema.js.map +1 -1
  94. package/dist/modules/manager/npm/update/locked-dependency/yarn-lock/get-locked.js +2 -1
  95. package/dist/modules/manager/npm/update/locked-dependency/yarn-lock/get-locked.js.map +1 -1
  96. package/dist/modules/manager/npm/update/locked-dependency/yarn-lock/replace.js +1 -1
  97. package/dist/modules/manager/npm/update/locked-dependency/yarn-lock/replace.js.map +1 -1
  98. package/dist/modules/manager/nuget/extract.js +1 -1
  99. package/dist/modules/manager/nuget/extract.js.map +1 -1
  100. package/dist/modules/manager/nvm/extract.js +2 -1
  101. package/dist/modules/manager/nvm/extract.js.map +1 -1
  102. package/dist/modules/manager/osgi/extract.js +2 -1
  103. package/dist/modules/manager/osgi/extract.js.map +1 -1
  104. package/dist/modules/manager/pep621/processors/uv.js +2 -1
  105. package/dist/modules/manager/pep621/processors/uv.js.map +1 -1
  106. package/dist/modules/manager/pip_requirements/extract.js +1 -1
  107. package/dist/modules/manager/pip_requirements/extract.js.map +1 -1
  108. package/dist/modules/manager/pip_setup/extract.js +3 -3
  109. package/dist/modules/manager/pip_setup/extract.js.map +1 -1
  110. package/dist/modules/manager/pixi/schema.js +2 -1
  111. package/dist/modules/manager/pixi/schema.js.map +1 -1
  112. package/dist/modules/manager/setup-cfg/extract.js +1 -1
  113. package/dist/modules/manager/setup-cfg/extract.js.map +1 -1
  114. package/dist/modules/manager/sveltos/util.js +1 -1
  115. package/dist/modules/manager/sveltos/util.js.map +1 -1
  116. package/dist/modules/manager/typst/extract.js +2 -2
  117. package/dist/modules/manager/typst/extract.js.map +1 -1
  118. package/dist/modules/platform/azure/issue.js +2 -1
  119. package/dist/modules/platform/azure/issue.js.map +1 -1
  120. package/dist/modules/platform/bitbucket/index.js +1 -1
  121. package/dist/modules/platform/bitbucket/index.js.map +1 -1
  122. package/dist/modules/platform/bitbucket/schema.js +2 -1
  123. package/dist/modules/platform/bitbucket/schema.js.map +1 -1
  124. package/dist/modules/platform/codecommit/codecommit-client.js +2 -1
  125. package/dist/modules/platform/codecommit/codecommit-client.js.map +1 -1
  126. package/dist/modules/platform/gerrit/utils.js +1 -1
  127. package/dist/modules/platform/gerrit/utils.js.map +1 -1
  128. package/dist/modules/platform/github/index.js +8 -8
  129. package/dist/modules/platform/github/index.js.map +1 -1
  130. package/dist/modules/platform/github/massage-markdown-links.js +6 -3
  131. package/dist/modules/platform/github/massage-markdown-links.js.map +1 -1
  132. package/dist/modules/versioning/apk/index.js +15 -15
  133. package/dist/modules/versioning/apk/index.js.map +1 -1
  134. package/dist/modules/versioning/bazel-module/bzlmod-version.js +3 -2
  135. package/dist/modules/versioning/bazel-module/bzlmod-version.js.map +1 -1
  136. package/dist/modules/versioning/bazel-module/index.js +2 -1
  137. package/dist/modules/versioning/bazel-module/index.js.map +1 -1
  138. package/dist/modules/versioning/composer/index.js +2 -2
  139. package/dist/modules/versioning/composer/index.js.map +1 -1
  140. package/dist/modules/versioning/conan/range.js +4 -3
  141. package/dist/modules/versioning/conan/range.js.map +1 -1
  142. package/dist/modules/versioning/conda/index.js +4 -3
  143. package/dist/modules/versioning/conda/index.js.map +1 -1
  144. package/dist/modules/versioning/distro.js +2 -1
  145. package/dist/modules/versioning/distro.js.map +1 -1
  146. package/dist/modules/versioning/generic.js +2 -1
  147. package/dist/modules/versioning/generic.js.map +1 -1
  148. package/dist/modules/versioning/hashicorp/convertor.js +1 -1
  149. package/dist/modules/versioning/hashicorp/convertor.js.map +1 -1
  150. package/dist/modules/versioning/npm/range.js +1 -1
  151. package/dist/modules/versioning/npm/range.js.map +1 -1
  152. package/dist/modules/versioning/nuget/range.js +2 -1
  153. package/dist/modules/versioning/nuget/range.js.map +1 -1
  154. package/dist/modules/versioning/perl/index.js +1 -1
  155. package/dist/modules/versioning/perl/index.js.map +1 -1
  156. package/dist/modules/versioning/poetry/transform.js +2 -2
  157. package/dist/modules/versioning/poetry/transform.js.map +1 -1
  158. package/dist/modules/versioning/rez/pattern.js.map +1 -1
  159. package/dist/modules/versioning/ruby/index.js +1 -1
  160. package/dist/modules/versioning/ruby/index.js.map +1 -1
  161. package/dist/modules/versioning/semver/index.js +2 -1
  162. package/dist/modules/versioning/semver/index.js.map +1 -1
  163. package/dist/modules/versioning/semver-coerced/index.js +1 -1
  164. package/dist/modules/versioning/semver-coerced/index.js.map +1 -1
  165. package/dist/util/emoji.js.map +1 -1
  166. package/dist/util/exec/containerbase.js +2 -1
  167. package/dist/util/exec/containerbase.js.map +1 -1
  168. package/dist/util/exec/env.js +2 -1
  169. package/dist/util/exec/env.js.map +1 -1
  170. package/dist/util/git/private-key.js +1 -1
  171. package/dist/util/git/private-key.js.map +1 -1
  172. package/dist/util/github/graphql/datasource-fetcher.js +2 -1
  173. package/dist/util/github/graphql/datasource-fetcher.js.map +1 -1
  174. package/dist/util/http/forgejo.js +2 -1
  175. package/dist/util/http/forgejo.js.map +1 -1
  176. package/dist/util/http/gitea.js +2 -1
  177. package/dist/util/http/gitea.js.map +1 -1
  178. package/dist/util/number.js +2 -1
  179. package/dist/util/number.js.map +1 -1
  180. package/dist/util/string-match.js +1 -1
  181. package/dist/util/string-match.js.map +1 -1
  182. package/dist/util/url.js +2 -2
  183. package/dist/util/url.js.map +1 -1
  184. package/dist/workers/global/config/parse/cli.js +1 -1
  185. package/dist/workers/global/config/parse/cli.js.map +1 -1
  186. package/dist/workers/global/config/parse/coersions.js +2 -1
  187. package/dist/workers/global/config/parse/coersions.js.map +1 -1
  188. package/dist/workers/global/config/parse/host-rules-from-env.js +2 -1
  189. package/dist/workers/global/config/parse/host-rules-from-env.js.map +1 -1
  190. package/dist/workers/repository/model/commit-message.js +2 -1
  191. package/dist/workers/repository/model/commit-message.js.map +1 -1
  192. package/dist/workers/repository/model/semantic-commit-message.js +2 -1
  193. package/dist/workers/repository/model/semantic-commit-message.js.map +1 -1
  194. package/dist/workers/repository/update/pr/changelog/common.js +1 -1
  195. package/dist/workers/repository/update/pr/changelog/common.js.map +1 -1
  196. package/dist/workers/repository/updates/generate.js +1 -1
  197. package/dist/workers/repository/updates/generate.js.map +1 -1
  198. package/package.json +1 -1
  199. package/renovate-schema.json +2 -2
@@ -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 /(\\r?\\n)(replace\\s+[^\\s]+\\s+=>\\s+\\.\\.\\/.*)/g,\n );\n\n // $1 will be matched with the (\\r?n) group\n // $2 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 = '$1// renovate-replace $2';\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(/(\\r?\\n)/g, '$1// renovate-replace ');\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 );\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 ?? getGoConstraints(newGoModContent);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA+BA,MAAM,EAAE,OAAA,SAAO,OAAA,YAAU;AACzB,MAAM,UAA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MAAM,0CAA0C;GACvD,IAAI,KAAK,cAAc;GACvB,aAAa,IAAI,aAAa;EAChC;EAMA,IAAI,iBAAiB,mBAAmB;GACtC,OAAO,MACL,8DACF;GACA,KAAK,MAAM,KAAK,OAAO,SAAS,OAAO,OAAO,OAAO,GACnD,IAAI,CAAC,aAAa,IAAI,CAAC,GACrB,IAAI,KAAK,EACP,MAAM;IACJ,MAAM;IACN,MAAM;IACN,UAAU,MAAM,cAAc,CAAC;GACjC,EACF,CAAC;GAGL,KAAK,MAAM,KAAK,YAAY,OAAO,OAAO,GACxC,IAAI,CAAC,eAAe,IAAI,CAAC,GACvB,IAAI,KAAK,EACP,MAAM;IACJ,MAAM;IACN,MAAM;GACR,EACF,CAAC;EAGP;EACA,OAAO;CACT,SAAS,KAAK;EACZ,IAAI,IAAI,YAAA,mBACN,MAAM;EAER,OAAO,MAAM,EAAE,IAAI,GAAG,yBAAyB;EAC/C,OAAO,CACL,EACE,eAAe;GACb,UAAU;GACV,QAAQ,IAAI;EACd,EACF,CACF;CACF;AACF;AAEA,SAAS,iBAAiB,SAAqC;CAK7D,MAAM,eAHiB,MAAM,0CAA0C,CAAC,CAAC,KACvE,OAEgC,CAAC,EAAE,QAAQ;CAC7C,IAAI,cAAc;EAChB,OAAO,MACL,oBAAoB,aAAa,8BACnC;EACA,OAAO;CACT;CAUA,MAAM,gBAAgB,MAAM,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;;;;;;;;;;;;;;AAeA,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 { 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 /(\\r?\\n)(replace\\s+[^\\s]+\\s+=>\\s+\\.\\.\\/.*)/g,\n );\n\n // $1 will be matched with the (\\r?n) group\n // $2 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 = '$1// renovate-replace $2';\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(regEx(/(\\r?\\n)/g), '$1// renovate-replace ');\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 );\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 ?? getGoConstraints(newGoModContent);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA+BA,MAAM,EAAE,OAAA,SAAO,OAAA,YAAU;AACzB,MAAM,UAAU,mBAA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83
  function globToRegex(depName) {
84
- return regEx(depName.replace(/\*/g, "_WC_CHAR_").replace(/[/\-\\^$*+?.()|[\]{}]/g, "\\$&").replace(/_WC_CHAR_/g, ".*?"));
84
+ return regEx(depName.replace(regEx(/\*/g), "_WC_CHAR_").replace(regEx(/[/\-\\^$*+?.()|[\]{}]/g), "\\$&").replace(regEx(/_WC_CHAR_/g), ".*?"));
85
85
  }
86
86
  /**
87
87
  * Parses `versions.lock`
@@ -114,7 +114,7 @@ function parsePropsFile(input) {
114
114
  const depVerRegexMap = /* @__PURE__ */ new Map();
115
115
  let startOfLineIdx = 0;
116
116
  const isCrLf = input.indexOf("\r\n") > 0;
117
- const validGlob = /^[a-zA-Z][-_a-zA-Z0-9.:*]+$/;
117
+ const validGlob = regEx(/^[a-zA-Z][-_a-zA-Z0-9.:*]+$/);
118
118
  for (const line of input.split(newlineRegex)) {
119
119
  const lineMatch = propsLineRegex.exec(line);
120
120
  if (lineMatch?.groups) {
@@ -1 +1 @@
1
- {"version":3,"file":"consistent-versions-plugin.js","names":["fs.getSiblingFileName"],"sources":["../../../../../lib/modules/manager/gradle/extract/consistent-versions-plugin.ts"],"sourcesContent":["import { logger } from '../../../../logger/index.ts';\nimport * as fs from '../../../../util/fs/index.ts';\nimport { newlineRegex, regEx } from '../../../../util/regex.ts';\nimport { coerceString } from '../../../../util/string.ts';\nimport type { PackageDependency } from '../../types.ts';\nimport type { GradleManagerData } from '../types.ts';\nimport { isDependencyString, versionLikeSubstring } from '../utils.ts';\n\nexport const VERSIONS_PROPS = 'versions.props';\nexport const VERSIONS_LOCK = 'versions.lock';\nexport const LOCKFIlE_HEADER_TEXT = regEx(\n /^# Run \\.\\/gradlew (?:--write-locks|writeVersionsLock|writeVersionsLocks) to regenerate this file/,\n);\n\n/**\n * Determines if Palantir gradle-consistent-versions is in use, https://github.com/palantir/gradle-consistent-versions.\n * Both `versions.props` and `versions.lock` must exist and the special header line of lock file must match\n *\n * @param versionsPropsFilename is the full file name path of `versions.props`\n * @param fileContents map with file contents of all files\n */\nexport function usesGcv(\n versionsPropsFilename: string,\n fileContents: Record<string, string | null>,\n): boolean {\n const versionsLockFile: string = fs.getSiblingFileName(\n versionsPropsFilename,\n VERSIONS_LOCK,\n );\n\n return !!fileContents[versionsLockFile]?.match(LOCKFIlE_HEADER_TEXT);\n}\n\n/**\n * Confirms whether the provided file name is the props file\n */\nexport function isGcvPropsFile(fileName: string): boolean {\n return fileName === VERSIONS_PROPS || fileName.endsWith(`/${VERSIONS_PROPS}`);\n}\n\n/**\n * Confirms whether the provided file name is the lock file\n */\nexport function isGcvLockFile(fileName: string): boolean {\n return fileName === VERSIONS_LOCK || fileName.endsWith(`/${VERSIONS_LOCK}`);\n}\n\n/**\n * Parses Gradle-Consistent-Versions files to figure out what dependencies, versions\n * and groups they contain. The parsing goes like this:\n * - Parse `versions.props` into deps (or groups) and versions, remembering file offsets\n * - Parse `versions.lock` into deps and lock-versions\n * - For each exact dep in props file, lookup the lock-version from lock file\n * - For each group/regex dep in props file, lookup the set of exact deps and versions in lock file\n *\n * @param propsFileName name and path of the props file\n * @param fileContents text content of all files\n */\nexport function parseGcv(\n propsFileName: string,\n fileContents: Record<string, string | null>,\n): PackageDependency<GradleManagerData>[] {\n const propsFileContent = coerceString(fileContents[propsFileName]);\n const lockFileName = fs.getSiblingFileName(propsFileName, VERSIONS_LOCK);\n const lockFileContent = coerceString(fileContents[lockFileName]);\n const lockFileMap = parseLockFile(lockFileContent);\n const [propsFileExactMap, propsFileRegexMap] =\n parsePropsFile(propsFileContent);\n\n const extractedDeps: PackageDependency<GradleManagerData>[] = [];\n\n // For each exact dep in props file\n for (const [propDep, versionAndPosition] of propsFileExactMap) {\n if (lockFileMap.has(propDep)) {\n const newDep: Record<string, any> = {\n managerData: {\n packageFile: propsFileName,\n fileReplacePosition: versionAndPosition.filePos,\n },\n depName: propDep,\n currentValue: versionAndPosition.version,\n lockedVersion: lockFileMap.get(propDep)?.version,\n depType: lockFileMap.get(propDep)?.depType,\n } satisfies PackageDependency<GradleManagerData>;\n extractedDeps.push(newDep);\n // Remove from the lockfile map so the same exact lib will not be included in globbing\n lockFileMap.delete(propDep);\n }\n }\n\n // For each regular expression dep in props file (starting with the longest glob string)...\n for (const [propDepGlob, propVerAndPos] of propsFileRegexMap) {\n const globRegex = globToRegex(propDepGlob);\n for (const [exactDep, lockVersionAndDepType] of lockFileMap) {\n if (globRegex.test(exactDep)) {\n const newDep: Record<string, any> = {\n managerData: {\n packageFile: propsFileName,\n fileReplacePosition: propVerAndPos.filePos,\n },\n depName: exactDep,\n currentValue: propVerAndPos.version,\n lockedVersion: lockVersionAndDepType.version,\n depType: lockVersionAndDepType.depType,\n sharedVariableName: propDepGlob,\n } satisfies PackageDependency<GradleManagerData>;\n extractedDeps.push(newDep);\n // Remove from the lockfile map so the same lib will not be included in more generic globs later\n lockFileMap.delete(exactDep);\n }\n }\n }\n return extractedDeps;\n}\n\n// Translate glob syntax to a regex that does the same. Note that we cannot use replaceAll as it does not exist in Node14\n// Loosely borrowed mapping to regex from https://github.com/palantir/gradle-consistent-versions/blob/develop/src/main/java/com/palantir/gradle/versions/FuzzyPatternResolver.java\nfunction globToRegex(depName: string): RegExp {\n return regEx(\n depName\n .replace(/\\*/g, '_WC_CHAR_')\n .replace(/[/\\-\\\\^$*+?.()|[\\]{}]/g, '\\\\$&')\n .replace(/_WC_CHAR_/g, '.*?'),\n );\n}\n\ninterface VersionWithPosition {\n version: string;\n filePos: number;\n}\n\ninterface VersionWithDepType {\n version: string;\n depType: string;\n}\n\n/**\n * Parses `versions.lock`\n */\nexport function parseLockFile(input: string): Map<string, VersionWithDepType> {\n const lockLineRegex = regEx(\n `^(?<depName>[^:]+:[^:]+):(?<lockVersion>[^ ]+) \\\\(\\\\d+ constraints: [0-9a-f]+\\\\)$`,\n );\n\n const depVerMap = new Map<string, VersionWithDepType>();\n let isTestDepType = false;\n for (const line of input.split(newlineRegex)) {\n const lineMatch = lockLineRegex.exec(line);\n if (lineMatch?.groups) {\n const { depName, lockVersion } = lineMatch.groups;\n if (isDependencyString(`${depName}:${lockVersion}`)) {\n depVerMap.set(depName, {\n version: lockVersion,\n depType: isTestDepType ? 'test' : 'dependencies',\n });\n }\n } else if (line === '[Test dependencies]') {\n isTestDepType = true; // We know that all lines below this header are test dependencies\n }\n }\n logger.trace(\n `Found ${depVerMap.size} locked dependencies in ${VERSIONS_LOCK}.`,\n );\n return depVerMap;\n}\n\n/**\n * Parses `versions.props`, this is CR/LF safe\n * @param input the entire property file from file system\n * @return two maps, first being exact matches, second regex matches\n */\nexport function parsePropsFile(\n input: string,\n): [Map<string, VersionWithPosition>, Map<string, VersionWithPosition>] {\n const propsLineRegex = regEx(\n `^(?<depName>[^:]+:[^=]+?) *= *(?<propsVersion>.*)$`,\n );\n const depVerExactMap = new Map<string, VersionWithPosition>();\n const depVerRegexMap = new Map<string, VersionWithPosition>();\n\n let startOfLineIdx = 0;\n const isCrLf = input.indexOf('\\r\\n') > 0;\n const validGlob = /^[a-zA-Z][-_a-zA-Z0-9.:*]+$/;\n for (const line of input.split(newlineRegex)) {\n const lineMatch = propsLineRegex.exec(line);\n if (lineMatch?.groups) {\n const { depName, propsVersion } = lineMatch.groups;\n if (\n validGlob.test(depName) &&\n versionLikeSubstring(propsVersion) !== null\n ) {\n const startPosInLine = line.lastIndexOf(propsVersion);\n const propVersionPos = startOfLineIdx + startPosInLine;\n if (depName.includes('*')) {\n depVerRegexMap.set(depName, {\n version: propsVersion,\n filePos: propVersionPos,\n });\n } else {\n depVerExactMap.set(depName, {\n version: propsVersion,\n filePos: propVersionPos,\n });\n }\n }\n }\n startOfLineIdx += line.length + (isCrLf ? 2 : 1);\n }\n logger.trace(\n `Found ${depVerExactMap.size} dependencies and ${depVerRegexMap.size} wildcard dependencies in ${VERSIONS_PROPS}.`,\n );\n return [\n depVerExactMap,\n new Map(\n [...depVerRegexMap].sort(([ka], [kb]) => ka.localeCompare(kb)).reverse(),\n ),\n ];\n}\n"],"mappings":";;;;;;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BAAiB;IACxC,IAAI,QAAQ,SAAS,GAAG,GACtB,eAAe,IAAI,SAAS;KAC1B,SAAS;KACT,SAAS;IACX,CAAC;SAED,eAAe,IAAI,SAAS;KAC1B,SAAS;KACT,SAAS;IACX,CAAC;GAEL;EACF;EACA,kBAAkB,KAAK,UAAU,SAAS,IAAI;CAChD;CACA,OAAO,MACL,SAAS,eAAe,KAAK,oBAAoB,eAAe,KAAK,4BAA4B,eAAe,EAClH;CACA,OAAO,CACL,gBACA,IAAI,IACF,CAAC,GAAG,cAAc,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,GAAG,cAAc,EAAE,CAAC,CAAC,CAAC,QAAQ,CACzE,CACF;AACF"}
1
+ {"version":3,"file":"consistent-versions-plugin.js","names":["fs.getSiblingFileName"],"sources":["../../../../../lib/modules/manager/gradle/extract/consistent-versions-plugin.ts"],"sourcesContent":["import { logger } from '../../../../logger/index.ts';\nimport * as fs from '../../../../util/fs/index.ts';\nimport { newlineRegex, regEx } from '../../../../util/regex.ts';\nimport { coerceString } from '../../../../util/string.ts';\nimport type { PackageDependency } from '../../types.ts';\nimport type { GradleManagerData } from '../types.ts';\nimport { isDependencyString, versionLikeSubstring } from '../utils.ts';\n\nexport const VERSIONS_PROPS = 'versions.props';\nexport const VERSIONS_LOCK = 'versions.lock';\nexport const LOCKFIlE_HEADER_TEXT = regEx(\n /^# Run \\.\\/gradlew (?:--write-locks|writeVersionsLock|writeVersionsLocks) to regenerate this file/,\n);\n\n/**\n * Determines if Palantir gradle-consistent-versions is in use, https://github.com/palantir/gradle-consistent-versions.\n * Both `versions.props` and `versions.lock` must exist and the special header line of lock file must match\n *\n * @param versionsPropsFilename is the full file name path of `versions.props`\n * @param fileContents map with file contents of all files\n */\nexport function usesGcv(\n versionsPropsFilename: string,\n fileContents: Record<string, string | null>,\n): boolean {\n const versionsLockFile: string = fs.getSiblingFileName(\n versionsPropsFilename,\n VERSIONS_LOCK,\n );\n\n return !!fileContents[versionsLockFile]?.match(LOCKFIlE_HEADER_TEXT);\n}\n\n/**\n * Confirms whether the provided file name is the props file\n */\nexport function isGcvPropsFile(fileName: string): boolean {\n return fileName === VERSIONS_PROPS || fileName.endsWith(`/${VERSIONS_PROPS}`);\n}\n\n/**\n * Confirms whether the provided file name is the lock file\n */\nexport function isGcvLockFile(fileName: string): boolean {\n return fileName === VERSIONS_LOCK || fileName.endsWith(`/${VERSIONS_LOCK}`);\n}\n\n/**\n * Parses Gradle-Consistent-Versions files to figure out what dependencies, versions\n * and groups they contain. The parsing goes like this:\n * - Parse `versions.props` into deps (or groups) and versions, remembering file offsets\n * - Parse `versions.lock` into deps and lock-versions\n * - For each exact dep in props file, lookup the lock-version from lock file\n * - For each group/regex dep in props file, lookup the set of exact deps and versions in lock file\n *\n * @param propsFileName name and path of the props file\n * @param fileContents text content of all files\n */\nexport function parseGcv(\n propsFileName: string,\n fileContents: Record<string, string | null>,\n): PackageDependency<GradleManagerData>[] {\n const propsFileContent = coerceString(fileContents[propsFileName]);\n const lockFileName = fs.getSiblingFileName(propsFileName, VERSIONS_LOCK);\n const lockFileContent = coerceString(fileContents[lockFileName]);\n const lockFileMap = parseLockFile(lockFileContent);\n const [propsFileExactMap, propsFileRegexMap] =\n parsePropsFile(propsFileContent);\n\n const extractedDeps: PackageDependency<GradleManagerData>[] = [];\n\n // For each exact dep in props file\n for (const [propDep, versionAndPosition] of propsFileExactMap) {\n if (lockFileMap.has(propDep)) {\n const newDep: Record<string, any> = {\n managerData: {\n packageFile: propsFileName,\n fileReplacePosition: versionAndPosition.filePos,\n },\n depName: propDep,\n currentValue: versionAndPosition.version,\n lockedVersion: lockFileMap.get(propDep)?.version,\n depType: lockFileMap.get(propDep)?.depType,\n } satisfies PackageDependency<GradleManagerData>;\n extractedDeps.push(newDep);\n // Remove from the lockfile map so the same exact lib will not be included in globbing\n lockFileMap.delete(propDep);\n }\n }\n\n // For each regular expression dep in props file (starting with the longest glob string)...\n for (const [propDepGlob, propVerAndPos] of propsFileRegexMap) {\n const globRegex = globToRegex(propDepGlob);\n for (const [exactDep, lockVersionAndDepType] of lockFileMap) {\n if (globRegex.test(exactDep)) {\n const newDep: Record<string, any> = {\n managerData: {\n packageFile: propsFileName,\n fileReplacePosition: propVerAndPos.filePos,\n },\n depName: exactDep,\n currentValue: propVerAndPos.version,\n lockedVersion: lockVersionAndDepType.version,\n depType: lockVersionAndDepType.depType,\n sharedVariableName: propDepGlob,\n } satisfies PackageDependency<GradleManagerData>;\n extractedDeps.push(newDep);\n // Remove from the lockfile map so the same lib will not be included in more generic globs later\n lockFileMap.delete(exactDep);\n }\n }\n }\n return extractedDeps;\n}\n\n// Translate glob syntax to a regex that does the same. Note that we cannot use replaceAll as it does not exist in Node14\n// Loosely borrowed mapping to regex from https://github.com/palantir/gradle-consistent-versions/blob/develop/src/main/java/com/palantir/gradle/versions/FuzzyPatternResolver.java\nfunction globToRegex(depName: string): RegExp {\n return regEx(\n depName\n .replace(regEx(/\\*/g), '_WC_CHAR_')\n .replace(regEx(/[/\\-\\\\^$*+?.()|[\\]{}]/g), '\\\\$&')\n .replace(regEx(/_WC_CHAR_/g), '.*?'),\n );\n}\n\ninterface VersionWithPosition {\n version: string;\n filePos: number;\n}\n\ninterface VersionWithDepType {\n version: string;\n depType: string;\n}\n\n/**\n * Parses `versions.lock`\n */\nexport function parseLockFile(input: string): Map<string, VersionWithDepType> {\n const lockLineRegex = regEx(\n `^(?<depName>[^:]+:[^:]+):(?<lockVersion>[^ ]+) \\\\(\\\\d+ constraints: [0-9a-f]+\\\\)$`,\n );\n\n const depVerMap = new Map<string, VersionWithDepType>();\n let isTestDepType = false;\n for (const line of input.split(newlineRegex)) {\n const lineMatch = lockLineRegex.exec(line);\n if (lineMatch?.groups) {\n const { depName, lockVersion } = lineMatch.groups;\n if (isDependencyString(`${depName}:${lockVersion}`)) {\n depVerMap.set(depName, {\n version: lockVersion,\n depType: isTestDepType ? 'test' : 'dependencies',\n });\n }\n } else if (line === '[Test dependencies]') {\n isTestDepType = true; // We know that all lines below this header are test dependencies\n }\n }\n logger.trace(\n `Found ${depVerMap.size} locked dependencies in ${VERSIONS_LOCK}.`,\n );\n return depVerMap;\n}\n\n/**\n * Parses `versions.props`, this is CR/LF safe\n * @param input the entire property file from file system\n * @return two maps, first being exact matches, second regex matches\n */\nexport function parsePropsFile(\n input: string,\n): [Map<string, VersionWithPosition>, Map<string, VersionWithPosition>] {\n const propsLineRegex = regEx(\n `^(?<depName>[^:]+:[^=]+?) *= *(?<propsVersion>.*)$`,\n );\n const depVerExactMap = new Map<string, VersionWithPosition>();\n const depVerRegexMap = new Map<string, VersionWithPosition>();\n\n let startOfLineIdx = 0;\n const isCrLf = input.indexOf('\\r\\n') > 0;\n const validGlob = regEx(/^[a-zA-Z][-_a-zA-Z0-9.:*]+$/);\n for (const line of input.split(newlineRegex)) {\n const lineMatch = propsLineRegex.exec(line);\n if (lineMatch?.groups) {\n const { depName, propsVersion } = lineMatch.groups;\n if (\n validGlob.test(depName) &&\n versionLikeSubstring(propsVersion) !== null\n ) {\n const startPosInLine = line.lastIndexOf(propsVersion);\n const propVersionPos = startOfLineIdx + startPosInLine;\n if (depName.includes('*')) {\n depVerRegexMap.set(depName, {\n version: propsVersion,\n filePos: propVersionPos,\n });\n } else {\n depVerExactMap.set(depName, {\n version: propsVersion,\n filePos: propVersionPos,\n });\n }\n }\n }\n startOfLineIdx += line.length + (isCrLf ? 2 : 1);\n }\n logger.trace(\n `Found ${depVerExactMap.size} dependencies and ${depVerRegexMap.size} wildcard dependencies in ${VERSIONS_PROPS}.`,\n );\n return [\n depVerExactMap,\n new Map(\n [...depVerRegexMap].sort(([ka], [kb]) => ka.localeCompare(kb)).reverse(),\n ),\n ];\n}\n"],"mappings":";;;;;;AAQA,MAAa,iBAAiB;AAC9B,MAAa,gBAAgB;AAC7B,MAAa,uBAAuB,MAClC,mGACF;;;;;;;;AASA,SAAgB,QACd,uBACA,cACS;CAMT,OAAO,CAAC,CAAC,aALwBA,mBAC/B,uB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Ae,IAAI,SAAS;KAC1B,SAAS;KACT,SAAS;IACX,CAAC;GAEL;EACF;EACA,kBAAkB,KAAK,UAAU,SAAS,IAAI;CAChD;CACA,OAAO,MACL,SAAS,eAAe,KAAK,oBAAoB,eAAe,KAAK,4BAA4B,eAAe,EAClH;CACA,OAAO,CACL,gBACA,IAAI,IACF,CAAC,GAAG,cAAc,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,GAAG,cAAc,EAAE,CAAC,CAAC,CAAC,QAAQ,CACzE,CACF;AACF"}
@@ -1,5 +1,5 @@
1
1
  import "../../../constants/error-messages.js";
2
- import { newlineRegex } from "../../../util/regex.js";
2
+ import { newlineRegex, regEx } from "../../../util/regex.js";
3
3
  import { replaceAt } from "../../../util/string.js";
4
4
  import { logger } from "../../../logger/index.js";
5
5
  import { localPathExists, readLocalFile, writeLocalFile } from "../../../util/fs/index.js";
@@ -92,7 +92,7 @@ async function updateArtifacts({ packageFileName, newPackageFileContent, updated
92
92
  cmd += ` --gradle-distribution-url ${quote(distributionUrl)}`;
93
93
  if (newPackageFileContent.includes("distributionSha256Sum=")) {
94
94
  checksum = await getDistributionChecksum(distributionUrl);
95
- await writeLocalFile(packageFileName, newPackageFileContent.replace(/distributionSha256Sum=.*/, `distributionSha256Sum=${checksum}`));
95
+ await writeLocalFile(packageFileName, newPackageFileContent.replace(regEx(/distributionSha256Sum=.*/), `distributionSha256Sum=${checksum}`));
96
96
  cmd += ` --gradle-distribution-sha256-sum ${quote(checksum)}`;
97
97
  }
98
98
  } else cmd += ` --gradle-version ${quote(config.newValue)}`;
@@ -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 } 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 /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,SAAS,MAAM,KAAK,QAAQ,GAAG,IAAI,QAAQ;CACnD,OAAO;AACT;AAEA,eAAsB,gBACpB,gBACA,mBACiB;CACjB,IAAI,gBAAgB,MAAM,KAAK,gBAAgB,cAAc;CAC7D,IAAI,CAAE,MAAM,gBAAgB,aAAa,GACvC,gBAAgB,MAAM,KAAK,gBAAgB,kBAAkB;CAG/D,MAAM,mBAAmB,MAAM,cAAc,eAAe,MAAM;CAClE,IAAI,CAAC,kBAAkB;EACrB,OAAO,MAAM,4CAA4C;EACzD,OAAO;CACT;CAEA,IAAI,mBAAmB;CACvB,KAAK,MAAM,CAAC,cAAc,aAAa,OAAO,QAAQ,iBAAiB,GAAG;EACxE,IAAI,CAAC,UACH;EAGF,MAAMA,UAAQC,MAAE,KAAK;GACnB,MAAM;GACN,UAAU;GACV,QAAQA,MACL,IAAS,YAAY,CAAC,CACtB,GAAG,GAAG,CAAC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BAAqB,MAAM,OAAO,QAAS;EAEpD,OAAO,MAAM,6BAA6B,IAAI,EAAE;EAChD,MAAM,cAA2B;GAC/B,SAAS;GACT,QAAQ,CAAC;GACT;GACA,iBAAiB,CACf;IACE,UAAU;IACV,YACE,OAAO,aAAa,QACnB,MAAM,kBAAkB,OAAO,cAAc,WAAW;GAC7D,CACF;EACF;EACA,IAAI;GACF,MAAM,KAAK,KAAK,WAAW;EAC7B,SAAS,KAAK;;GAEZ,IAAI,IAAI,YAAA,mBACN,MAAM;GAER,OAAO,KACL,EAAE,IAAI,GACN,2JACF;EACF;EAEA,MAAM,gBAAgB,MAAM,gBAAgB,gBAAgB;GAC1D,eAAe,OAAO;GACtB,uBAAuB;GACvB;EACF,CAAC;EACD,MAAM,YAAY,MAAM,gBAAgB,eAAe,MAAM;EAE7D,MAAM,SAAS,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"}
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,SAAS,MAAM,KAAK,QAAQ,GAAG,IAAI,QAAQ;CACnD,OAAO;AACT;AAEA,eAAsB,gBACpB,gBACA,mBACiB;CACjB,IAAI,gBAAgB,MAAM,KAAK,gBAAgB,cAAc;CAC7D,IAAI,CAAE,MAAM,gBAAgB,aAAa,GACvC,gBAAgB,MAAM,KAAK,gBAAgB,kBAAkB;CAG/D,MAAM,mBAAmB,MAAM,cAAc,eAAe,MAAM;CAClE,IAAI,CAAC,kBAAkB;EACrB,OAAO,MAAM,4CAA4C;EACzD,OAAO;CACT;CAEA,IAAI,mBAAmB;CACvB,KAAK,MAAM,CAAC,cAAc,aAAa,OAAO,QAAQ,iBAAiB,GAAG;EACxE,IAAI,CAAC,UACH;EAGF,MAAMA,UAAQC,MAAE,KAAK;GACn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0BAA0B,GAChC,yBAAyB,UAC3B,CACF;IACA,OAAO,qCAAqC,MAAM,QAAQ;GAC5D;EACF,OACE,OAAO,qBAAqB,MAAM,OAAO,QAAS;EAEpD,OAAO,MAAM,6BAA6B,IAAI,EAAE;EAChD,MAAM,cAA2B;GAC/B,SAAS;GACT,QAAQ,CAAC;GACT;GACA,iBAAiB,CACf;IACE,UAAU;IACV,YACE,OAAO,aAAa,QACnB,MAAM,kBAAkB,OAAO,cAAc,WAAW;GAC7D,CACF;EACF;EACA,IAAI;GACF,MAAM,KAAK,KAAK,WAAW;EAC7B,SAAS,KAAK;;GAEZ,IAAI,IAAI,YAAA,mBACN,MAAM;GAER,OAAO,KACL,EAAE,IAAI,GACN,2JACF;EACF;EAEA,MAAM,gBAAgB,MAAM,gBAAgB,gBAAgB;GAC1D,eAAe,OAAO;GACtB,uBAAuB;GACvB;EACF,CAAC;EACD,MAAM,YAAY,MAAM,gBAAgB,eAAe,MAAM;EAE7D,MAAM,SAAS,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"}
@@ -1,3 +1,4 @@
1
+ import { regEx } from "../../../util/regex.js";
1
2
  import { logger } from "../../../logger/index.js";
2
3
  import { parseUrl } from "../../../util/url.js";
3
4
  import { DockerDatasource } from "../../datasource/docker/index.js";
@@ -58,7 +59,7 @@ function isAlias(repository) {
58
59
  return repository.startsWith("@") || repository.startsWith("alias:");
59
60
  }
60
61
  function aliasRecordToRepositories(registryAliases) {
61
- return Object.entries(registryAliases).filter(([, url]) => /^(https?|oci):\/\/.+/.exec(url)).map(([alias, url]) => {
62
+ return Object.entries(registryAliases).filter(([, url]) => regEx(/^(https?|oci):\/\/.+/).exec(url)).map(([alias, url]) => {
62
63
  return {
63
64
  name: alias,
64
65
  repository: url
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":[],"sources":["../../../../lib/modules/manager/helmv3/utils.ts"],"sourcesContent":["import upath from 'upath';\nimport { logger } from '../../../logger/index.ts';\nimport { parseUrl } from '../../../util/url.ts';\nimport { DockerDatasource } from '../../datasource/docker/index.ts';\nimport type { PackageDependency } from '../types.ts';\nimport { removeOCIPrefix } from './oci.ts';\nimport type { ChartDefinition, Repository } from './types.ts';\n\nexport function parseRepository(\n depName: string,\n repositoryURL: string,\n): PackageDependency {\n const res: PackageDependency = {};\n\n const url = parseUrl(repositoryURL);\n if (!url) {\n logger.debug({ repositoryURL }, 'Error parsing url');\n res.skipReason = 'invalid-url';\n return res;\n }\n switch (url.protocol) {\n case 'oci:':\n res.datasource = DockerDatasource.id;\n res.packageName = `${removeOCIPrefix(repositoryURL)}/${depName}`;\n // https://github.com/helm/helm/issues/10312\n // https://github.com/helm/helm/issues/10678\n res.pinDigests = false;\n break;\n case 'file:':\n res.skipReason = 'local-dependency';\n break;\n default:\n res.registryUrls = [repositoryURL];\n }\n return res;\n}\n\n/**\n * Resolves alias in repository string.\n *\n * @param repository to be resolved string\n * @param registryAliases Records containing registryAliases as key and to be resolved URLs as values\n *\n * @returns resolved alias. If repository does not contain an alias the repository string will be returned. Should it contain an alias which can not be resolved using `registryAliases`, null will be returned\n */\nexport function resolveAlias(\n repository: string,\n registryAliases: Record<string, string>,\n): string | null {\n if (!isAlias(repository)) {\n return repository;\n }\n\n const repoWithPrefixRemoved = repository.slice(\n repository.startsWith('@') ? 1 : 6,\n );\n const alias = registryAliases[repoWithPrefixRemoved];\n if (alias) {\n return alias;\n }\n return null;\n}\n\nexport function getRepositories(definitions: ChartDefinition[]): Repository[] {\n const repositoryList = definitions\n .flatMap((value) => value.dependencies)\n .filter((dependency) => dependency.repository) // only keep non-local references --> if no repository is defined the chart will be searched in charts/<name>\n .filter((dependency) => !isAlias(dependency.repository)) // do not add registryAliases\n .filter((dependency) => !dependency.repository.startsWith('file:')) // skip repositories which are locally referenced\n .map((dependency) => {\n // remove additional keys to prevent interference at deduplication\n return {\n name: dependency.name,\n repository: dependency.repository,\n };\n });\n const dedup = new Set();\n return repositoryList.filter((el) => {\n const duplicate = dedup.has(el.repository);\n dedup.add(el.repository);\n return !duplicate;\n });\n}\n\nexport function isAlias(repository: string): boolean {\n if (!repository) {\n return false;\n }\n return repository.startsWith('@') || repository.startsWith('alias:');\n}\n\nexport function aliasRecordToRepositories(\n registryAliases: Record<string, string>,\n): Repository[] {\n return Object.entries(registryAliases)\n .filter(([, url]) => /^(https?|oci):\\/\\/.+/.exec(url))\n .map(([alias, url]) => {\n return {\n name: alias,\n repository: url,\n };\n });\n}\n\nexport function isFileInDir(dir: string, file: string): boolean {\n return upath.dirname(file) === dir;\n}\n"],"mappings":";;;;;;AAQA,SAAgB,gBACd,SACA,eACmB;CACnB,MAAM,MAAyB,CAAC;CAEhC,MAAM,MAAM,SAAS,aAAa;CAClC,IAAI,CAAC,KAAK;EACR,OAAO,MAAM,EAAE,cAAc,GAAG,mBAAmB;EACnD,IAAI,aAAa;EACjB,OAAO;CACT;CACA,QAAQ,IAAI,UAAZ;EACE,KAAK;GACH,IAAI,aAAa,iBAAiB;GAClC,IAAI,cAAc,GAAG,gBAAgB,aAAa,EAAE,GAAG;GAGvD,IAAI,aAAa;GACjB;EACF,KAAK;GACH,IAAI,aAAa;GACjB;EACF,SACE,IAAI,eAAe,CAAC,aAAa;CACrC;CACA,OAAO;AACT;;;;;;;;;AAUA,SAAgB,aACd,YACA,iBACe;CACf,IAAI,CAAC,QAAQ,UAAU,GACrB,OAAO;CAMT,MAAM,QAAQ,gBAHgB,WAAW,MACvC,WAAW,WAAW,GAAG,IAAI,IAAI,CAEe;CAClD,IAAI,OACF,OAAO;CAET,OAAO;AACT;AAEA,SAAgB,gBAAgB,aAA8C;CAC5E,MAAM,iBAAiB,YACpB,SAAS,UAAU,MAAM,YAAY,CAAC,CACtC,QAAQ,eAAe,WAAW,UAAU,CAAC,CAC7C,QAAQ,eAAe,CAAC,QAAQ,WAAW,UAAU,CAAC,CAAC,CACvD,QAAQ,eAAe,CAAC,WAAW,WAAW,WAAW,OAAO,CAAC,CAAC,CAClE,KAAK,eAAe;EAEnB,OAAO;GACL,MAAM,WAAW;GACjB,YAAY,WAAW;EACzB;CACF,CAAC;CACH,MAAM,wBAAQ,IAAI,IAAI;CACtB,OAAO,eAAe,QAAQ,OAAO;EACnC,MAAM,YAAY,MAAM,IAAI,GAAG,UAAU;EACzC,MAAM,IAAI,GAAG,UAAU;EACvB,OAAO,CAAC;CACV,CAAC;AACH;AAEA,SAAgB,QAAQ,YAA6B;CACnD,IAAI,CAAC,YACH,OAAO;CAET,OAAO,WAAW,WAAW,GAAG,KAAK,WAAW,WAAW,QAAQ;AACrE;AAEA,SAAgB,0BACd,iBACc;CACd,OAAO,OAAO,QAAQ,eAAe,CAAC,CACnC,QAAQ,GAAG,SAAS,uBAAuB,KAAK,GAAG,CAAC,CAAC,CACrD,KAAK,CAAC,OAAO,SAAS;EACrB,OAAO;GACL,MAAM;GACN,YAAY;EACd;CACF,CAAC;AACL;AAEA,SAAgB,YAAY,KAAa,MAAuB;CAC9D,OAAO,MAAM,QAAQ,IAAI,MAAM;AACjC"}
1
+ {"version":3,"file":"utils.js","names":[],"sources":["../../../../lib/modules/manager/helmv3/utils.ts"],"sourcesContent":["import upath from 'upath';\nimport { logger } from '../../../logger/index.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { parseUrl } from '../../../util/url.ts';\nimport { DockerDatasource } from '../../datasource/docker/index.ts';\nimport type { PackageDependency } from '../types.ts';\nimport { removeOCIPrefix } from './oci.ts';\nimport type { ChartDefinition, Repository } from './types.ts';\n\nexport function parseRepository(\n depName: string,\n repositoryURL: string,\n): PackageDependency {\n const res: PackageDependency = {};\n\n const url = parseUrl(repositoryURL);\n if (!url) {\n logger.debug({ repositoryURL }, 'Error parsing url');\n res.skipReason = 'invalid-url';\n return res;\n }\n switch (url.protocol) {\n case 'oci:':\n res.datasource = DockerDatasource.id;\n res.packageName = `${removeOCIPrefix(repositoryURL)}/${depName}`;\n // https://github.com/helm/helm/issues/10312\n // https://github.com/helm/helm/issues/10678\n res.pinDigests = false;\n break;\n case 'file:':\n res.skipReason = 'local-dependency';\n break;\n default:\n res.registryUrls = [repositoryURL];\n }\n return res;\n}\n\n/**\n * Resolves alias in repository string.\n *\n * @param repository to be resolved string\n * @param registryAliases Records containing registryAliases as key and to be resolved URLs as values\n *\n * @returns resolved alias. If repository does not contain an alias the repository string will be returned. Should it contain an alias which can not be resolved using `registryAliases`, null will be returned\n */\nexport function resolveAlias(\n repository: string,\n registryAliases: Record<string, string>,\n): string | null {\n if (!isAlias(repository)) {\n return repository;\n }\n\n const repoWithPrefixRemoved = repository.slice(\n repository.startsWith('@') ? 1 : 6,\n );\n const alias = registryAliases[repoWithPrefixRemoved];\n if (alias) {\n return alias;\n }\n return null;\n}\n\nexport function getRepositories(definitions: ChartDefinition[]): Repository[] {\n const repositoryList = definitions\n .flatMap((value) => value.dependencies)\n .filter((dependency) => dependency.repository) // only keep non-local references --> if no repository is defined the chart will be searched in charts/<name>\n .filter((dependency) => !isAlias(dependency.repository)) // do not add registryAliases\n .filter((dependency) => !dependency.repository.startsWith('file:')) // skip repositories which are locally referenced\n .map((dependency) => {\n // remove additional keys to prevent interference at deduplication\n return {\n name: dependency.name,\n repository: dependency.repository,\n };\n });\n const dedup = new Set();\n return repositoryList.filter((el) => {\n const duplicate = dedup.has(el.repository);\n dedup.add(el.repository);\n return !duplicate;\n });\n}\n\nexport function isAlias(repository: string): boolean {\n if (!repository) {\n return false;\n }\n return repository.startsWith('@') || repository.startsWith('alias:');\n}\n\nexport function aliasRecordToRepositories(\n registryAliases: Record<string, string>,\n): Repository[] {\n return Object.entries(registryAliases)\n .filter(([, url]) => regEx(/^(https?|oci):\\/\\/.+/).exec(url))\n .map(([alias, url]) => {\n return {\n name: alias,\n repository: url,\n };\n });\n}\n\nexport function isFileInDir(dir: string, file: string): boolean {\n return upath.dirname(file) === dir;\n}\n"],"mappings":";;;;;;;AASA,SAAgB,gBACd,SACA,eACmB;CACnB,MAAM,MAAyB,CAAC;CAEhC,MAAM,MAAM,SAAS,aAAa;CAClC,IAAI,CAAC,KAAK;EACR,OAAO,MAAM,EAAE,cAAc,GAAG,mBAAmB;EACnD,IAAI,aAAa;EACjB,OAAO;CACT;CACA,QAAQ,IAAI,UAAZ;EACE,KAAK;GACH,IAAI,aAAa,iBAAiB;GAClC,IAAI,cAAc,GAAG,gBAAgB,aAAa,EAAE,GAAG;GAGvD,IAAI,aAAa;GACjB;EACF,KAAK;GACH,IAAI,aAAa;GACjB;EACF,SACE,IAAI,eAAe,CAAC,aAAa;CACrC;CACA,OAAO;AACT;;;;;;;;;AAUA,SAAgB,aACd,YACA,iBACe;CACf,IAAI,CAAC,QAAQ,UAAU,GACrB,OAAO;CAMT,MAAM,QAAQ,gBAHgB,WAAW,MACvC,WAAW,WAAW,GAAG,IAAI,IAAI,CAEe;CAClD,IAAI,OACF,OAAO;CAET,OAAO;AACT;AAEA,SAAgB,gBAAgB,aAA8C;CAC5E,MAAM,iBAAiB,YACpB,SAAS,UAAU,MAAM,YAAY,CAAC,CACtC,QAAQ,eAAe,WAAW,UAAU,CAAC,CAC7C,QAAQ,eAAe,CAAC,QAAQ,WAAW,UAAU,CAAC,CAAC,CACvD,QAAQ,eAAe,CAAC,WAAW,WAAW,WAAW,OAAO,CAAC,CAAC,CAClE,KAAK,eAAe;EAEnB,OAAO;GACL,MAAM,WAAW;GACjB,YAAY,WAAW;EACzB;CACF,CAAC;CACH,MAAM,wBAAQ,IAAI,IAAI;CACtB,OAAO,eAAe,QAAQ,OAAO;EACnC,MAAM,YAAY,MAAM,IAAI,GAAG,UAAU;EACzC,MAAM,IAAI,GAAG,UAAU;EACvB,OAAO,CAAC;CACV,CAAC;AACH;AAEA,SAAgB,QAAQ,YAA6B;CACnD,IAAI,CAAC,YACH,OAAO;CAET,OAAO,WAAW,WAAW,GAAG,KAAK,WAAW,WAAW,QAAQ;AACrE;AAEA,SAAgB,0BACd,iBACc;CACd,OAAO,OAAO,QAAQ,eAAe,CAAC,CACnC,QAAQ,GAAG,SAAS,MAAM,sBAAsB,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAC5D,KAAK,CAAC,OAAO,SAAS;EACrB,OAAO;GACL,MAAM;GACN,YAAY;EACd;CACF,CAAC;AACL;AAEA,SAAgB,YAAY,KAAa,MAAuB;CAC9D,OAAO,MAAM,QAAQ,IAAI,MAAM;AACjC"}
@@ -50,7 +50,7 @@ async function listHermitPackages(packageFile) {
50
50
  const out = [];
51
51
  for (const f of files) {
52
52
  if (!minimatch(".*.pkg").match(f)) continue;
53
- const fileName = f.replace(`${hermitFolder}/`, "").substring(1).replace(/\.pkg$/, "");
53
+ const fileName = f.replace(`${hermitFolder}/`, "").substring(1).replace(regEx(/\.pkg$/), "");
54
54
  const channelParts = fileName.split("@");
55
55
  if (channelParts.length > 1) out.push({
56
56
  Name: channelParts[0],
@@ -1 +1 @@
1
- {"version":3,"file":"extract.js","names":[],"sources":["../../../../lib/modules/manager/hermit/extract.ts"],"sourcesContent":["import upath from 'upath';\nimport { logger } from '../../../logger/index.ts';\nimport { readLocalDirectory } from '../../../util/fs/index.ts';\nimport { minimatch } from '../../../util/minimatch.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { HermitDatasource } from '../../datasource/hermit/index.ts';\nimport type { PackageDependency, PackageFileContent } from '../types.ts';\nimport type { HermitListItem } from './types.ts';\n\nconst pkgReferenceRegex = regEx(`(?<packageName>.*?)-(?<version>[0-9]{1}.*)`);\n\n/**\n * extractPackageFile scans the folder of the package files\n * and looking for .{packageName}-{version}.pkg\n */\nexport async function extractPackageFile(\n _content: string,\n packageFile: string,\n): Promise<PackageFileContent | null> {\n logger.trace(`hermit.extractPackageFile(${packageFile})`);\n const dependencies = [] as PackageDependency[];\n const packages = await listHermitPackages(packageFile);\n\n if (!packages?.length) {\n return null;\n }\n\n for (const p of packages) {\n // version of a hermit package is either a Version or a Channel\n // Channel will prepend with @ to distinguish from normal version\n const version = p.Version === '' ? `@${p.Channel}` : p.Version;\n\n const dep: PackageDependency = {\n datasource: HermitDatasource.id,\n depName: p.Name,\n currentValue: version,\n };\n\n dependencies.push(dep);\n }\n\n return { deps: dependencies };\n}\n\n/**\n * listHermitPackages will fetch all installed packages from the bin folder\n */\nasync function listHermitPackages(\n packageFile: string,\n): Promise<HermitListItem[] | null> {\n logger.trace('hermit.listHermitPackages()');\n const hermitFolder = upath.dirname(packageFile);\n\n let files: string[] = [];\n\n try {\n files = await readLocalDirectory(hermitFolder);\n } catch (err) {\n logger.debug(\n { hermitFolder, err, packageFile },\n 'error listing hermit package references',\n );\n return null;\n }\n\n logger.trace({ files, hermitFolder }, 'files for hermit package list');\n\n const out = [] as HermitListItem[];\n\n for (const f of files) {\n if (!minimatch('.*.pkg').match(f)) {\n continue;\n }\n\n const fileName = f\n .replace(`${hermitFolder}/`, '')\n .substring(1)\n .replace(/\\.pkg$/, '');\n const channelParts = fileName.split('@');\n\n if (channelParts.length > 1) {\n out.push({\n Name: channelParts[0],\n Channel: channelParts[1],\n Version: '',\n });\n }\n\n const groups = pkgReferenceRegex.exec(fileName)?.groups;\n if (!groups) {\n logger.debug(\n { fileName },\n 'invalid hermit package reference file name found',\n );\n continue;\n }\n\n out.push({\n Name: groups.packageName,\n Version: groups.version,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AQ;GACX,OAAO,MACL,EAAE,SAAS,GACX,kDACF;GACA;EACF;EAEA,IAAI,KAAK;GACP,MAAM,OAAO;GACb,SAAS,OAAO;GAChB,SAAS;EACX,CAAC;CACH;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"extract.js","names":[],"sources":["../../../../lib/modules/manager/hermit/extract.ts"],"sourcesContent":["import upath from 'upath';\nimport { logger } from '../../../logger/index.ts';\nimport { readLocalDirectory } from '../../../util/fs/index.ts';\nimport { minimatch } from '../../../util/minimatch.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { HermitDatasource } from '../../datasource/hermit/index.ts';\nimport type { PackageDependency, PackageFileContent } from '../types.ts';\nimport type { HermitListItem } from './types.ts';\n\nconst pkgReferenceRegex = regEx(`(?<packageName>.*?)-(?<version>[0-9]{1}.*)`);\n\n/**\n * extractPackageFile scans the folder of the package files\n * and looking for .{packageName}-{version}.pkg\n */\nexport async function extractPackageFile(\n _content: string,\n packageFile: string,\n): Promise<PackageFileContent | null> {\n logger.trace(`hermit.extractPackageFile(${packageFile})`);\n const dependencies = [] as PackageDependency[];\n const packages = await listHermitPackages(packageFile);\n\n if (!packages?.length) {\n return null;\n }\n\n for (const p of packages) {\n // version of a hermit package is either a Version or a Channel\n // Channel will prepend with @ to distinguish from normal version\n const version = p.Version === '' ? `@${p.Channel}` : p.Version;\n\n const dep: PackageDependency = {\n datasource: HermitDatasource.id,\n depName: p.Name,\n currentValue: version,\n };\n\n dependencies.push(dep);\n }\n\n return { deps: dependencies };\n}\n\n/**\n * listHermitPackages will fetch all installed packages from the bin folder\n */\nasync function listHermitPackages(\n packageFile: string,\n): Promise<HermitListItem[] | null> {\n logger.trace('hermit.listHermitPackages()');\n const hermitFolder = upath.dirname(packageFile);\n\n let files: string[] = [];\n\n try {\n files = await readLocalDirectory(hermitFolder);\n } catch (err) {\n logger.debug(\n { hermitFolder, err, packageFile },\n 'error listing hermit package references',\n );\n return null;\n }\n\n logger.trace({ files, hermitFolder }, 'files for hermit package list');\n\n const out = [] as HermitListItem[];\n\n for (const f of files) {\n if (!minimatch('.*.pkg').match(f)) {\n continue;\n }\n\n const fileName = f\n .replace(`${hermitFolder}/`, '')\n .substring(1)\n .replace(regEx(/\\.pkg$/), '');\n const channelParts = fileName.split('@');\n\n if (channelParts.length > 1) {\n out.push({\n Name: channelParts[0],\n Channel: channelParts[1],\n Version: '',\n });\n }\n\n const groups = pkgReferenceRegex.exec(fileName)?.groups;\n if (!groups) {\n logger.debug(\n { fileName },\n 'invalid hermit package reference file name found',\n );\n continue;\n }\n\n out.push({\n Name: groups.packageName,\n Version: groups.version,\n Channel: '',\n });\n }\n\n return out;\n}\n"],"mappings":";;;;;;;AASA,MAAM,oBAAoB,MAAM,4CAA4C;;;;;AAM5E,eAAsB,mBACpB,UACA,aACoC;CACpC,OAAO,MAAM,6BAA6B,YAAY,EAAE;CACxD,MAAM,eAAe,CAAC;CACtB,MAAM,WAAW,MAAM,mBAAmB,WAAW;CAErD,IAAI,CAAC,UAAU,QACb,OAAO;CAGT,KAAK,MAAM,KAAK,UAAU;EAGxB,MAAM,UAAU,EAAE,YAAY,KAAK,IAAI,EAAE,YAAY,EAAE;EAEvD,MAAM,MAAyB;GAC7B,YAAY,iBAAiB;GAC7B,SAAS,EAAE;GACX,cAAc;EAChB;EAEA,aAAa,KAAK,GAAG;CACvB;CAEA,OAAO,EAAE,MAAM,aAAa;AAC9B;;;;AAKA,eAAe,mBACb,aACkC;CAClC,OAAO,MAAM,6BAA6B;CAC1C,MAAM,eAAe,MAAM,QAAQ,WAAW;CAE9C,IAAI,QAAkB,CAAC;CAEvB,IAAI;EACF,QAAQ,MAAM,mBAAmB,YAAY;CAC/C,SAAS,KAAK;EACZ,OAAO,MACL;GAAE;GAAc;GAAK;EAAY,GACjC,yCACF;EACA,OAAO;CACT;CAEA,OAAO,MAAM;EAAE;EAAO;CAAa,GAAG,+BAA+B;CAErE,MAAM,MAAM,CAAC;CAEb,KAAK,MAAM,KAAK,OAAO;EACrB,IAAI,CAAC,UAAU,QAAQ,CAAC,CAAC,MAAM,CAAC,GAC9B;EAGF,MAAM,WAAW,EACd,QAAQ,GAAG,aAAa,IAAI,EAAE,CAAC,CAC/B,UAAU,CAAC,CAAC,CACZ,QAAQ,MAAM,QAAQ,GAAG,EAAE;EAC9B,MAAM,eAAe,SAAS,MAAM,GAAG;EAEvC,IAAI,aAAa,SAAS,GACxB,IAAI,KAAK;GACP,MAAM,aAAa;GACnB,SAAS,aAAa;GACtB,SAAS;EACX,CAAC;EAGH,MAAM,SAAS,kBAAkB,KAAK,QAAQ,CAAC,EAAE;EACjD,IAAI,CAAC,QAAQ;GACX,OAAO,MACL,EAAE,SAAS,GACX,kDACF;GACA;EACF;EAEA,IAAI,KAAK;GACP,MAAM,OAAO;GACb,SAAS,OAAO;GAChB,SAAS;EACX,CAAC;CACH;CAEA,OAAO;AACT"}
@@ -1,13 +1,13 @@
1
1
  import { escapeRegExp, regEx } from "../../../util/regex.js";
2
2
  //#region lib/modules/manager/homebrew/utils.ts
3
3
  function extractRubyString(content, keyword) {
4
- const regex = regEx(new RegExp(`\\b${keyword}\\s+(?:"(?<double>[^"]+)"|'(?<single>[^']+)')`));
4
+ const regex = regEx(`\\b${keyword}\\s+(?:"(?<double>[^"]+)"|'(?<single>[^']+)')`);
5
5
  const match = content.match(regex);
6
6
  return match?.groups?.double ?? match?.groups?.single ?? null;
7
7
  }
8
8
  function updateRubyString(content, keyword, oldValue, newValue) {
9
- const doubleQuote = new RegExp(`(\\b${keyword}\\s+)"${escapeRegExp(oldValue)}"`, "g");
10
- const singleQuote = new RegExp(`(\\b${keyword}\\s+)'${escapeRegExp(oldValue)}'`, "g");
9
+ const doubleQuote = regEx(`(\\b${keyword}\\s+)"${escapeRegExp(oldValue)}"`, "g");
10
+ const singleQuote = regEx(`(\\b${keyword}\\s+)'${escapeRegExp(oldValue)}'`, "g");
11
11
  const result = content.replace(doubleQuote, `$1"${newValue}"`).replace(singleQuote, `$1'${newValue}'`);
12
12
  return result === content ? null : result;
13
13
  }
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":[],"sources":["../../../../lib/modules/manager/homebrew/utils.ts"],"sourcesContent":["import { escapeRegExp, regEx } from '../../../util/regex.ts';\n\n// Extract Ruby string value (handles both quote styles)\nexport function extractRubyString(\n content: string,\n keyword: string,\n): string | null {\n const regex = regEx(\n new RegExp(`\\\\b${keyword}\\\\s+(?:\"(?<double>[^\"]+)\"|'(?<single>[^']+)')`),\n );\n const match = content.match(regex);\n return match?.groups?.double ?? match?.groups?.single ?? null;\n}\n\n// Update Ruby string value (preserves quote style)\nexport function updateRubyString(\n content: string,\n keyword: string,\n oldValue: string,\n newValue: string,\n): string | null {\n const doubleQuote = new RegExp(\n `(\\\\b${keyword}\\\\s+)\"${escapeRegExp(oldValue)}\"`,\n 'g',\n );\n const singleQuote = new RegExp(\n `(\\\\b${keyword}\\\\s+)'${escapeRegExp(oldValue)}'`,\n 'g',\n );\n const result = content\n .replace(doubleQuote, `$1\"${newValue}\"`)\n .replace(singleQuote, `$1'${newValue}'`);\n\n return result === content ? null : result;\n}\n"],"mappings":";;AAGA,SAAgB,kBACd,SACA,SACe;CACf,MAAM,QAAQ,MACZ,IAAI,OAAO,MAAM,QAAQ,8CAA8C,CACzE;CACA,MAAM,QAAQ,QAAQ,MAAM,KAAK;CACjC,OAAO,OAAO,QAAQ,UAAU,OAAO,QAAQ,UAAU;AAC3D;AAGA,SAAgB,iBACd,SACA,SACA,UACA,UACe;CACf,MAAM,cAAc,IAAI,OACtB,OAAO,QAAQ,QAAQ,aAAa,QAAQ,EAAE,IAC9C,GACF;CACA,MAAM,cAAc,IAAI,OACtB,OAAO,QAAQ,QAAQ,aAAa,QAAQ,EAAE,IAC9C,GACF;CACA,MAAM,SAAS,QACZ,QAAQ,aAAa,MAAM,SAAS,EAAE,CAAC,CACvC,QAAQ,aAAa,MAAM,SAAS,EAAE;CAEzC,OAAO,WAAW,UAAU,OAAO;AACrC"}
1
+ {"version":3,"file":"utils.js","names":[],"sources":["../../../../lib/modules/manager/homebrew/utils.ts"],"sourcesContent":["import { escapeRegExp, regEx } from '../../../util/regex.ts';\n\n// Extract Ruby string value (handles both quote styles)\nexport function extractRubyString(\n content: string,\n keyword: string,\n): string | null {\n const regex = regEx(\n `\\\\b${keyword}\\\\s+(?:\"(?<double>[^\"]+)\"|'(?<single>[^']+)')`,\n );\n const match = content.match(regex);\n return match?.groups?.double ?? match?.groups?.single ?? null;\n}\n\n// Update Ruby string value (preserves quote style)\nexport function updateRubyString(\n content: string,\n keyword: string,\n oldValue: string,\n newValue: string,\n): string | null {\n const doubleQuote = regEx(\n `(\\\\b${keyword}\\\\s+)\"${escapeRegExp(oldValue)}\"`,\n 'g',\n );\n const singleQuote = regEx(\n `(\\\\b${keyword}\\\\s+)'${escapeRegExp(oldValue)}'`,\n 'g',\n );\n const result = content\n .replace(doubleQuote, `$1\"${newValue}\"`)\n .replace(singleQuote, `$1'${newValue}'`);\n\n return result === content ? null : result;\n}\n"],"mappings":";;AAGA,SAAgB,kBACd,SACA,SACe;CACf,MAAM,QAAQ,MACZ,MAAM,QAAQ,8CAChB;CACA,MAAM,QAAQ,QAAQ,MAAM,KAAK;CACjC,OAAO,OAAO,QAAQ,UAAU,OAAO,QAAQ,UAAU;AAC3D;AAGA,SAAgB,iBACd,SACA,SACA,UACA,UACe;CACf,MAAM,cAAc,MAClB,OAAO,QAAQ,QAAQ,aAAa,QAAQ,EAAE,IAC9C,GACF;CACA,MAAM,cAAc,MAClB,OAAO,QAAQ,QAAQ,aAAa,QAAQ,EAAE,IAC9C,GACF;CACA,MAAM,SAAS,QACZ,QAAQ,aAAa,MAAM,SAAS,EAAE,CAAC,CACvC,QAAQ,aAAa,MAAM,SAAS,EAAE;CAEzC,OAAO,WAAW,UAAU,OAAO;AACrC"}
@@ -1,3 +1,4 @@
1
+ import { regEx } from "../../../util/regex.js";
1
2
  import { coerceString } from "../../../util/string.js";
2
3
  import { logger } from "../../../logger/index.js";
3
4
  import { parseUrl } from "../../../util/url.js";
@@ -30,7 +31,7 @@ function extractDependency(dependency) {
30
31
  return null;
31
32
  }
32
33
  return {
33
- depName: upath.join(gitRemote.host, gitRemote.pathname.replace(/\.git$/, ""), coerceString(dependency.source.git.subdir)),
34
+ depName: upath.join(gitRemote.host, gitRemote.pathname.replace(regEx(/\.git$/), ""), coerceString(dependency.source.git.subdir)),
34
35
  packageName: dependency.source.git.remote,
35
36
  currentValue: dependency.version,
36
37
  managerData: { subdir: dependency.source.git.subdir }
@@ -1 +1 @@
1
- {"version":3,"file":"extract.js","names":[],"sources":["../../../../lib/modules/manager/jsonnet-bundler/extract.ts"],"sourcesContent":["import upath from 'upath';\nimport { logger } from '../../../logger/index.ts';\nimport { coerceArray } from '../../../util/array.ts';\nimport { coerceString } from '../../../util/string.ts';\nimport { parseUrl } from '../../../util/url.ts';\nimport type { PackageDependency, PackageFileContent } from '../types.ts';\nimport type { Dependency, JsonnetFile } from './types.ts';\n\nexport function extractPackageFile(\n content: string,\n packageFile: string,\n): PackageFileContent | null {\n logger.trace({ packageFile }, 'jsonnet-bundler.extractPackageFile()');\n\n if (packageFile.includes('vendor/')) {\n return null;\n }\n\n const deps: PackageDependency[] = [];\n let jsonnetFile: JsonnetFile;\n try {\n jsonnetFile = JSON.parse(content) as JsonnetFile;\n } catch {\n logger.debug({ packageFile }, `Invalid JSON`);\n return null;\n }\n\n for (const dependency of coerceArray(jsonnetFile.dependencies)) {\n const dep = extractDependency(dependency);\n if (dep) {\n deps.push(dep);\n }\n }\n\n if (!deps.length) {\n return null;\n }\n\n return { deps };\n}\n\nfunction extractDependency(dependency: Dependency): PackageDependency | null {\n if (!dependency.source.git) {\n return null;\n }\n\n const gitRemote = parseUrl(dependency.source.git.remote);\n if (!gitRemote) {\n logger.debug({ dependency }, 'Invalid Git remote URL');\n return null;\n }\n\n const depName = upath.join(\n gitRemote.host,\n gitRemote.pathname.replace(/\\.git$/, ''),\n coerceString(dependency.source.git.subdir),\n );\n\n return {\n depName,\n packageName: dependency.source.git.remote,\n currentValue: dependency.version,\n managerData: { subdir: dependency.source.git.subdir },\n };\n}\n"],"mappings":";;;;;;AAQA,SAAgB,mBACd,SACA,aAC2B;CAC3B,OAAO,MAAM,EAAE,YAAY,GAAG,sCAAsC;CAEpE,IAAI,YAAY,SAAS,SAAS,GAChC,OAAO;CAGT,MAAM,OAA4B,CAAC;CACnC,IAAI;CACJ,IAAI;EACF,cAAc,KAAK,MAAM,OAAO;CAClC,QAAQ;EACN,OAAO,MAAM,EAAE,YAAY,GAAG,cAAc;EAC5C,OAAO;CACT;CAEA,KAAK,MAAM,cAAc,YAAY,YAAY,YAAY,GAAG;EAC9D,MAAM,MAAM,kBAAkB,UAAU;EACxC,IAAI,KACF,KAAK,KAAK,GAAG;CAEjB;CAEA,IAAI,CAAC,KAAK,QACR,OAAO;CAGT,OAAO,EAAE,KAAK;AAChB;AAEA,SAAS,kBAAkB,YAAkD;CAC3E,IAAI,CAAC,WAAW,OAAO,KACrB,OAAO;CAGT,MAAM,YAAY,SAAS,WAAW,OAAO,IAAI,MAAM;CACvD,IAAI,CAAC,WAAW;EACd,OAAO,MAAM,EAAE,WAAW,GAAG,wBAAwB;EACrD,OAAO;CACT;CAQA,OAAO;EACL,SAPc,MAAM,KACpB,UAAU,MACV,UAAU,SAAS,QAAQ,UAAU,EAAE,GACvC,aAAa,WAAW,OAAO,IAAI,MAAM,CAInC;EACN,aAAa,WAAW,OAAO,IAAI;EACnC,cAAc,WAAW;EACzB,aAAa,EAAE,QAAQ,WAAW,OAAO,IAAI,OAAO;CACtD;AACF"}
1
+ {"version":3,"file":"extract.js","names":[],"sources":["../../../../lib/modules/manager/jsonnet-bundler/extract.ts"],"sourcesContent":["import upath from 'upath';\nimport { logger } from '../../../logger/index.ts';\nimport { coerceArray } from '../../../util/array.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { coerceString } from '../../../util/string.ts';\nimport { parseUrl } from '../../../util/url.ts';\nimport type { PackageDependency, PackageFileContent } from '../types.ts';\nimport type { Dependency, JsonnetFile } from './types.ts';\n\nexport function extractPackageFile(\n content: string,\n packageFile: string,\n): PackageFileContent | null {\n logger.trace({ packageFile }, 'jsonnet-bundler.extractPackageFile()');\n\n if (packageFile.includes('vendor/')) {\n return null;\n }\n\n const deps: PackageDependency[] = [];\n let jsonnetFile: JsonnetFile;\n try {\n jsonnetFile = JSON.parse(content) as JsonnetFile;\n } catch {\n logger.debug({ packageFile }, `Invalid JSON`);\n return null;\n }\n\n for (const dependency of coerceArray(jsonnetFile.dependencies)) {\n const dep = extractDependency(dependency);\n if (dep) {\n deps.push(dep);\n }\n }\n\n if (!deps.length) {\n return null;\n }\n\n return { deps };\n}\n\nfunction extractDependency(dependency: Dependency): PackageDependency | null {\n if (!dependency.source.git) {\n return null;\n }\n\n const gitRemote = parseUrl(dependency.source.git.remote);\n if (!gitRemote) {\n logger.debug({ dependency }, 'Invalid Git remote URL');\n return null;\n }\n\n const depName = upath.join(\n gitRemote.host,\n gitRemote.pathname.replace(regEx(/\\.git$/), ''),\n coerceString(dependency.source.git.subdir),\n );\n\n return {\n depName,\n packageName: dependency.source.git.remote,\n currentValue: dependency.version,\n managerData: { subdir: dependency.source.git.subdir },\n };\n}\n"],"mappings":";;;;;;;AASA,SAAgB,mBACd,SACA,aAC2B;CAC3B,OAAO,MAAM,EAAE,YAAY,GAAG,sCAAsC;CAEpE,IAAI,YAAY,SAAS,SAAS,GAChC,OAAO;CAGT,MAAM,OAA4B,CAAC;CACnC,IAAI;CACJ,IAAI;EACF,cAAc,KAAK,MAAM,OAAO;CAClC,QAAQ;EACN,OAAO,MAAM,EAAE,YAAY,GAAG,cAAc;EAC5C,OAAO;CACT;CAEA,KAAK,MAAM,cAAc,YAAY,YAAY,YAAY,GAAG;EAC9D,MAAM,MAAM,kBAAkB,UAAU;EACxC,IAAI,KACF,KAAK,KAAK,GAAG;CAEjB;CAEA,IAAI,CAAC,KAAK,QACR,OAAO;CAGT,OAAO,EAAE,KAAK;AAChB;AAEA,SAAS,kBAAkB,YAAkD;CAC3E,IAAI,CAAC,WAAW,OAAO,KACrB,OAAO;CAGT,MAAM,YAAY,SAAS,WAAW,OAAO,IAAI,MAAM;CACvD,IAAI,CAAC,WAAW;EACd,OAAO,MAAM,EAAE,WAAW,GAAG,wBAAwB;EACrD,OAAO;CACT;CAQA,OAAO;EACL,SAPc,MAAM,KACpB,UAAU,MACV,UAAU,SAAS,QAAQ,MAAM,QAAQ,GAAG,EAAE,GAC9C,aAAa,WAAW,OAAO,IAAI,MAAM,CAInC;EACN,aAAa,WAAW,OAAO,IAAI;EACnC,cAAc,WAAW;EACzB,aAAa,EAAE,QAAQ,WAAW,OAAO,IAAI,OAAO;CACtD;AACF"}
@@ -3,7 +3,7 @@ import { coerceArray } from "../../../util/array.js";
3
3
  import { ClojureDatasource } from "../../datasource/clojure/index.js";
4
4
  //#region lib/modules/manager/leiningen/extract.ts
5
5
  function trimAtKey(str, kwName) {
6
- const regex = new RegExp(`:${kwName}(?=\\s)`);
6
+ const regex = regEx(`:${kwName}\\s`);
7
7
  const keyOffset = str.search(regex);
8
8
  if (keyOffset < 0) return null;
9
9
  const withSpaces = str.slice(keyOffset + kwName.length + 1);
@@ -81,7 +81,7 @@ function extractFromVectors(str, ctx = {}, vars = {}, dimensions = 2) {
81
81
  }
82
82
  function extractLeinRepos(content) {
83
83
  const result = [];
84
- const repoContent = trimAtKey(content.replace(/;;.*(?=[\r\n])/g, ""), "repositories");
84
+ const repoContent = trimAtKey(content.replace(regEx(/;;.*([\r\n])/g), "$1"), "repositories");
85
85
  if (repoContent) {
86
86
  let balance = 0;
87
87
  let endIdx = 0;
@@ -1 +1 @@
1
- {"version":3,"file":"extract.js","names":[],"sources":["../../../../lib/modules/manager/leiningen/extract.ts"],"sourcesContent":["import { coerceArray } from '../../../util/array.ts';\nimport { newlineRegex, regEx } from '../../../util/regex.ts';\nimport { ClojureDatasource } from '../../datasource/clojure/index.ts';\nimport type { PackageDependency, PackageFileContent } from '../types.ts';\nimport type { ExtractContext, ExtractedVariables } from './types.ts';\n\nexport function trimAtKey(str: string, kwName: string): string | null {\n const regex = new RegExp(`:${kwName}(?=\\\\s)`); // TODO #12872 lookahead\n const keyOffset = str.search(regex);\n if (keyOffset < 0) {\n return null;\n }\n const withSpaces = str.slice(keyOffset + kwName.length + 1);\n const valueOffset = withSpaces.search(regEx(/[^\\s]/));\n if (valueOffset < 0) {\n return null;\n }\n return withSpaces.slice(valueOffset);\n}\n\nexport function expandDepName(name: string): string {\n return name.includes('/') ? name.replace('/', ':') : `${name}:${name}`;\n}\n\nexport function extractFromVectors(\n str: string,\n ctx: ExtractContext = {},\n vars: ExtractedVariables = {},\n dimensions: 1 | 2 = 2,\n): PackageDependency[] {\n if (!str.startsWith('[')) {\n return [];\n }\n let balance = 0;\n const result: PackageDependency[] = [];\n let idx = 0;\n let vecPos = 0;\n let artifactId = '';\n let version = '';\n // Are we currently parsing a comment? If so, at what depth?\n let commentLevel: number | null = null;\n\n function isSpace(ch: string | null): boolean {\n return !!ch && regEx(/[\\s,]/).test(ch);\n }\n\n function cleanStrLiteral(s: string): string {\n return s.replace(regEx(/^\"/), '').replace(regEx(/\"$/), '');\n }\n\n function yieldDep(): void {\n if (!commentLevel && artifactId && version) {\n const depName = expandDepName(cleanStrLiteral(artifactId));\n if (version.startsWith('~')) {\n const varName = version.replace(regEx(/^~\\s*/), '');\n const currentValue = vars[varName];\n if (currentValue) {\n result.push({\n ...ctx,\n datasource: ClojureDatasource.id,\n depName,\n currentValue,\n sharedVariableName: varName,\n });\n }\n } else {\n result.push({\n ...ctx,\n datasource: ClojureDatasource.id,\n depName,\n currentValue: cleanStrLiteral(version),\n });\n }\n }\n artifactId = '';\n version = '';\n }\n\n let prevChar: string | null = null;\n while (idx < str.length) {\n const char = str.charAt(idx);\n\n if (str.substring(idx).startsWith('#_[')) {\n commentLevel = balance;\n }\n\n if (char === '[') {\n balance += 1;\n if (balance === dimensions) {\n vecPos = 0;\n }\n } else if (char === ']') {\n balance -= 1;\n\n if (commentLevel === balance) {\n artifactId = '';\n version = '';\n commentLevel = null;\n }\n\n if (balance === dimensions - 1) {\n yieldDep();\n }\n\n if (balance === 0) {\n break;\n }\n } else if (balance === dimensions) {\n if (isSpace(char)) {\n if (!isSpace(prevChar)) {\n vecPos += 1;\n }\n } else if (vecPos === 0) {\n artifactId += char;\n } else if (vecPos === 1) {\n version += char;\n }\n }\n prevChar = char;\n idx += 1;\n }\n return result;\n}\n\nfunction extractLeinRepos(content: string): string[] {\n const result: string[] = [];\n\n const repoContent = trimAtKey(\n content.replace(/;;.*(?=[\\r\\n])/g, ''), // get rid of comments // TODO #12872 lookahead\n 'repositories',\n );\n\n if (repoContent) {\n let balance = 0;\n let endIdx = 0;\n for (let idx = 0; idx < repoContent.length; idx += 1) {\n const char = repoContent.charAt(idx);\n if (char === '[') {\n balance += 1;\n } else if (char === ']') {\n balance -= 1;\n if (balance <= 0) {\n endIdx = idx;\n break;\n }\n }\n }\n const repoSectionContent = repoContent.slice(0, endIdx);\n const matches = coerceArray(\n repoSectionContent.match(regEx(/\"https?:\\/\\/[^\"]*\"/g)),\n );\n const urls = matches.map((x) =>\n x.replace(regEx(/^\"/), '').replace(regEx(/\"$/), ''),\n );\n urls.forEach((url) => result.push(url));\n }\n\n return result;\n}\n\nconst defRegex = regEx(\n /^[\\s,]*\\([\\s,]*def[\\s,]+(?<varName>[-+*=<>.!?#$%&_|a-zA-Z][-+*=<>.!?#$%&_|a-zA-Z0-9']+)[\\s,]*\"(?<stringValue>[^\"]*)\"[\\s,]*\\)[\\s,]*$/,\n);\n\nexport function extractVariables(content: string): ExtractedVariables {\n const result: ExtractedVariables = {};\n const lines = content.split(newlineRegex);\n for (const line of lines) {\n const match = defRegex.exec(line);\n if (match?.groups) {\n const { varName: key, stringValue: val } = match.groups;\n result[key] = val;\n }\n }\n return result;\n}\n\ninterface CollectDepsOptions {\n nested: boolean;\n depType?: string;\n}\n\nfunction collectDeps(\n content: string,\n key: string,\n registryUrls: string[],\n vars: ExtractedVariables,\n options: CollectDepsOptions = {\n nested: true,\n },\n): PackageDependency[] {\n const ctx = {\n depType: options.depType ?? key,\n registryUrls,\n };\n // A vector like [[\"dep-1\" \"1.0.0\"] [\"dep-2\" \"0.0.0\"]] is nested\n // A vector like [\"dep-1\" \"1.0.0\"] is not\n const dimensions = options.nested ? 2 : 1;\n let result: PackageDependency[] = [];\n let restContent = trimAtKey(content, key);\n while (restContent) {\n result = [\n ...result,\n ...extractFromVectors(restContent, ctx, vars, dimensions),\n ];\n restContent = trimAtKey(restContent, key);\n }\n return result;\n}\n\nexport function extractPackageFile(content: string): PackageFileContent {\n const registryUrls = extractLeinRepos(content);\n const vars = extractVariables(content);\n\n const deps: PackageDependency[] = [\n ...collectDeps(content, 'dependencies', registryUrls, vars),\n ...collectDeps(content, 'managed-dependencies', registryUrls, vars),\n ...collectDeps(content, 'plugins', registryUrls, vars),\n ...collectDeps(content, 'pom-plugins', registryUrls, vars),\n // 'coords' is used in lein parent, and specifies zero or one\n // dependencies. These are not wrapped in a vector in the way other\n // dependencies are. The project.clj fragment looks like\n //\n // :parent-project {... :coords [\"parent\" \"version\"] ...}\n //\n // - https://github.com/achin/lein-parent\n ...collectDeps(content, 'coords', registryUrls, vars, {\n nested: false,\n // The top-level key is 'parent-project', but we skip directly to 'coords'.\n // So fix the dep type label\n depType: 'parent-project',\n }),\n ];\n\n return { deps };\n}\n"],"mappings":";;;;AAMA,SAAgB,UAAU,KAAa,QAA+B;CACpE,MAAM,QAAQ,IAAI,OAAO,IAAI,OAAO,QAAQ;CAC5C,MAAM,YAAY,IAAI,OAAO,KAAK;CAClC,IAAI,YAAY,GACd,OAAO;CAET,MAAM,aAAa,IAAI,MAAM,YAAY,OAAO,SAAS,CAAC;CAC1D,MAAM,cAAc,WAAW,OAAO,MAAM,OAAO,CAAC;CACpD,IAAI,cAAc,GAChB,OAAO;CAET,OAAO,WAAW,MAAM,WAAW;AACrC;AAEA,SAAgB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ACxB,MAAM,QAAQ,SAAS,KAAK,IAAI;EAChC,IAAI,OAAO,QAAQ;GACjB,MAAM,EAAE,SAAS,KAAK,aAAa,QAAQ,MAAM;GACjD,OAAO,OAAO;EAChB;CACF;CACA,OAAO;AACT;AAOA,SAAS,YACP,SACA,KACA,cACA,MACA,UAA8B,EAC5B,QAAQ,KACV,GACqB;CACrB,MAAM,MAAM;EACV,SAAS,QAAQ,WAAW;EAC5B;CACF;CAGA,MAAM,aAAa,QAAQ,SAAS,IAAI;CACxC,IAAI,SAA8B,CAAC;CACnC,IAAI,cAAc,UAAU,SAAS,GAAG;CACxC,OAAO,aAAa;EAClB,SAAS,CACP,GAAG,QACH,GAAG,mBAAmB,aAAa,KAAK,MAAM,UAAU,CAC1D;EACA,cAAc,UAAU,aAAa,GAAG;CAC1C;CACA,OAAO;AACT;AAEA,SAAgB,mBAAmB,SAAqC;CACtE,MAAM,eAAe,iBAAiB,OAAO;CAC7C,MAAM,OAAO,iBAAiB,OAAO;CAsBrC,OAAO,EAAE,MAAA;EAnBP,GAAG,YAAY,SAAS,gBAAgB,cAAc,IAAI;EAC1D,GAAG,YAAY,SAAS,wBAAwB,cAAc,IAAI;EAClE,GAAG,YAAY,SAAS,WAAW,cAAc,IAAI;EACrD,GAAG,YAAY,SAAS,eAAe,cAAc,IAAI;EAQzD,GAAG,YAAY,SAAS,UAAU,cAAc,MAAM;GACpD,QAAQ;GAGR,SAAS;EACX,CAAC;CAGS,EAAE;AAChB"}
1
+ {"version":3,"file":"extract.js","names":[],"sources":["../../../../lib/modules/manager/leiningen/extract.ts"],"sourcesContent":["import { coerceArray } from '../../../util/array.ts';\nimport { newlineRegex, regEx } from '../../../util/regex.ts';\nimport { ClojureDatasource } from '../../datasource/clojure/index.ts';\nimport type { PackageDependency, PackageFileContent } from '../types.ts';\nimport type { ExtractContext, ExtractedVariables } from './types.ts';\n\nexport function trimAtKey(str: string, kwName: string): string | null {\n // matching the whitespace instead of a lookahead is equivalent here,\n // as only the match offset is used\n const regex = regEx(`:${kwName}\\\\s`);\n const keyOffset = str.search(regex);\n if (keyOffset < 0) {\n return null;\n }\n const withSpaces = str.slice(keyOffset + kwName.length + 1);\n const valueOffset = withSpaces.search(regEx(/[^\\s]/));\n if (valueOffset < 0) {\n return null;\n }\n return withSpaces.slice(valueOffset);\n}\n\nexport function expandDepName(name: string): string {\n return name.includes('/') ? name.replace('/', ':') : `${name}:${name}`;\n}\n\nexport function extractFromVectors(\n str: string,\n ctx: ExtractContext = {},\n vars: ExtractedVariables = {},\n dimensions: 1 | 2 = 2,\n): PackageDependency[] {\n if (!str.startsWith('[')) {\n return [];\n }\n let balance = 0;\n const result: PackageDependency[] = [];\n let idx = 0;\n let vecPos = 0;\n let artifactId = '';\n let version = '';\n // Are we currently parsing a comment? If so, at what depth?\n let commentLevel: number | null = null;\n\n function isSpace(ch: string | null): boolean {\n return !!ch && regEx(/[\\s,]/).test(ch);\n }\n\n function cleanStrLiteral(s: string): string {\n return s.replace(regEx(/^\"/), '').replace(regEx(/\"$/), '');\n }\n\n function yieldDep(): void {\n if (!commentLevel && artifactId && version) {\n const depName = expandDepName(cleanStrLiteral(artifactId));\n if (version.startsWith('~')) {\n const varName = version.replace(regEx(/^~\\s*/), '');\n const currentValue = vars[varName];\n if (currentValue) {\n result.push({\n ...ctx,\n datasource: ClojureDatasource.id,\n depName,\n currentValue,\n sharedVariableName: varName,\n });\n }\n } else {\n result.push({\n ...ctx,\n datasource: ClojureDatasource.id,\n depName,\n currentValue: cleanStrLiteral(version),\n });\n }\n }\n artifactId = '';\n version = '';\n }\n\n let prevChar: string | null = null;\n while (idx < str.length) {\n const char = str.charAt(idx);\n\n if (str.substring(idx).startsWith('#_[')) {\n commentLevel = balance;\n }\n\n if (char === '[') {\n balance += 1;\n if (balance === dimensions) {\n vecPos = 0;\n }\n } else if (char === ']') {\n balance -= 1;\n\n if (commentLevel === balance) {\n artifactId = '';\n version = '';\n commentLevel = null;\n }\n\n if (balance === dimensions - 1) {\n yieldDep();\n }\n\n if (balance === 0) {\n break;\n }\n } else if (balance === dimensions) {\n if (isSpace(char)) {\n if (!isSpace(prevChar)) {\n vecPos += 1;\n }\n } else if (vecPos === 0) {\n artifactId += char;\n } else if (vecPos === 1) {\n version += char;\n }\n }\n prevChar = char;\n idx += 1;\n }\n return result;\n}\n\nfunction extractLeinRepos(content: string): string[] {\n const result: string[] = [];\n\n const repoContent = trimAtKey(\n content.replace(regEx(/;;.*([\\r\\n])/g), '$1'), // get rid of comments\n 'repositories',\n );\n\n if (repoContent) {\n let balance = 0;\n let endIdx = 0;\n for (let idx = 0; idx < repoContent.length; idx += 1) {\n const char = repoContent.charAt(idx);\n if (char === '[') {\n balance += 1;\n } else if (char === ']') {\n balance -= 1;\n if (balance <= 0) {\n endIdx = idx;\n break;\n }\n }\n }\n const repoSectionContent = repoContent.slice(0, endIdx);\n const matches = coerceArray(\n repoSectionContent.match(regEx(/\"https?:\\/\\/[^\"]*\"/g)),\n );\n const urls = matches.map((x) =>\n x.replace(regEx(/^\"/), '').replace(regEx(/\"$/), ''),\n );\n urls.forEach((url) => result.push(url));\n }\n\n return result;\n}\n\nconst defRegex = regEx(\n /^[\\s,]*\\([\\s,]*def[\\s,]+(?<varName>[-+*=<>.!?#$%&_|a-zA-Z][-+*=<>.!?#$%&_|a-zA-Z0-9']+)[\\s,]*\"(?<stringValue>[^\"]*)\"[\\s,]*\\)[\\s,]*$/,\n);\n\nexport function extractVariables(content: string): ExtractedVariables {\n const result: ExtractedVariables = {};\n const lines = content.split(newlineRegex);\n for (const line of lines) {\n const match = defRegex.exec(line);\n if (match?.groups) {\n const { varName: key, stringValue: val } = match.groups;\n result[key] = val;\n }\n }\n return result;\n}\n\ninterface CollectDepsOptions {\n nested: boolean;\n depType?: string;\n}\n\nfunction collectDeps(\n content: string,\n key: string,\n registryUrls: string[],\n vars: ExtractedVariables,\n options: CollectDepsOptions = {\n nested: true,\n },\n): PackageDependency[] {\n const ctx = {\n depType: options.depType ?? key,\n registryUrls,\n };\n // A vector like [[\"dep-1\" \"1.0.0\"] [\"dep-2\" \"0.0.0\"]] is nested\n // A vector like [\"dep-1\" \"1.0.0\"] is not\n const dimensions = options.nested ? 2 : 1;\n let result: PackageDependency[] = [];\n let restContent = trimAtKey(content, key);\n while (restContent) {\n result = [\n ...result,\n ...extractFromVectors(restContent, ctx, vars, dimensions),\n ];\n restContent = trimAtKey(restContent, key);\n }\n return result;\n}\n\nexport function extractPackageFile(content: string): PackageFileContent {\n const registryUrls = extractLeinRepos(content);\n const vars = extractVariables(content);\n\n const deps: PackageDependency[] = [\n ...collectDeps(content, 'dependencies', registryUrls, vars),\n ...collectDeps(content, 'managed-dependencies', registryUrls, vars),\n ...collectDeps(content, 'plugins', registryUrls, vars),\n ...collectDeps(content, 'pom-plugins', registryUrls, vars),\n // 'coords' is used in lein parent, and specifies zero or one\n // dependencies. These are not wrapped in a vector in the way other\n // dependencies are. The project.clj fragment looks like\n //\n // :parent-project {... :coords [\"parent\" \"version\"] ...}\n //\n // - https://github.com/achin/lein-parent\n ...collectDeps(content, 'coords', registryUrls, vars, {\n nested: false,\n // The top-level key is 'parent-project', but we skip directly to 'coords'.\n // So fix the dep type label\n depType: 'parent-project',\n }),\n ];\n\n return { deps };\n}\n"],"mappings":";;;;AAMA,SAAgB,UAAU,KAAa,QAA+B;CAGpE,MAAM,QAAQ,MAAM,IAAI,OAAO,IAAI;CACnC,MAAM,YAAY,IAAI,OAAO,KAAK;CAClC,IAAI,YAAY,GACd,OAAO;CAET,MAAM,aAAa,IAAI,MAAM,YAAY,OAAO,SAAS,CAAC;CAC1D,MAAM,cAAc,WAAW,OAAO,MAAM,OAAO,CAAC;CACpD,IAAI,cAAc,GAChB,OAAO;CAET,OAAO,WAAW,MAAM,WAAW;AACrC;AAEA,SAAgB,cAAc,MAAsB;CAClD,OAAO,KAAK,SAAS,GAAG,IAAI,KAAK,QAAQ,KAAK,GAAG,IAAI,GAAG,KAAK,GAAG;AAClE;AAEA,SAAgB,mBAC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ACjD,OAAO,OAAO;EAChB;CACF;CACA,OAAO;AACT;AAOA,SAAS,YACP,SACA,KACA,cACA,MACA,UAA8B,EAC5B,QAAQ,KACV,GACqB;CACrB,MAAM,MAAM;EACV,SAAS,QAAQ,WAAW;EAC5B;CACF;CAGA,MAAM,aAAa,QAAQ,SAAS,IAAI;CACxC,IAAI,SAA8B,CAAC;CACnC,IAAI,cAAc,UAAU,SAAS,GAAG;CACxC,OAAO,aAAa;EAClB,SAAS,CACP,GAAG,QACH,GAAG,mBAAmB,aAAa,KAAK,MAAM,UAAU,CAC1D;EACA,cAAc,UAAU,aAAa,GAAG;CAC1C;CACA,OAAO;AACT;AAEA,SAAgB,mBAAmB,SAAqC;CACtE,MAAM,eAAe,iBAAiB,OAAO;CAC7C,MAAM,OAAO,iBAAiB,OAAO;CAsBrC,OAAO,EAAE,MAAA;EAnBP,GAAG,YAAY,SAAS,gBAAgB,cAAc,IAAI;EAC1D,GAAG,YAAY,SAAS,wBAAwB,cAAc,IAAI;EAClE,GAAG,YAAY,SAAS,WAAW,cAAc,IAAI;EACrD,GAAG,YAAY,SAAS,eAAe,cAAc,IAAI;EAQzD,GAAG,YAAY,SAAS,UAAU,cAAc,MAAM;GACpD,QAAQ;GAGR,SAAS;EACX,CAAC;CAGS,EAAE;AAChB"}
@@ -23,10 +23,10 @@ function getChecksumFromUrl(url) {
23
23
  }, () => hashStream(http.stream(url), "sha256"));
24
24
  }
25
25
  function getDistributionUrl(content) {
26
- return regEx(/^distributionUrl\s*=\s*(?<distributionUrl>.+)$/m).exec(content)?.groups?.distributionUrl?.replace(/\\:/g, ":").trim() ?? null;
26
+ return regEx(/^distributionUrl\s*=\s*(?<distributionUrl>.+)$/m).exec(content)?.groups?.distributionUrl?.replace(regEx(/\\:/g), ":").trim() ?? null;
27
27
  }
28
28
  function getWrapperUrl(content) {
29
- return regEx(/^wrapperUrl\s*=\s*(?<wrapperUrl>.+)$/m).exec(content)?.groups?.wrapperUrl?.replace(/\\:/g, ":").trim() ?? null;
29
+ return regEx(/^wrapperUrl\s*=\s*(?<wrapperUrl>.+)$/m).exec(content)?.groups?.wrapperUrl?.replace(regEx(/\\:/g), ":").trim() ?? null;
30
30
  }
31
31
  function constructWrapperUrl(version, repoUrl = DEFAULT_MAVEN_REPO_URL) {
32
32
  return `${repoUrl}/org/apache/maven/wrapper/maven-wrapper/${version}/maven-wrapper-${version}.jar`;
@@ -52,13 +52,13 @@ async function updateChecksums(content, updatedDeps, addDistributionChecksum, ad
52
52
  if (distUrl) try {
53
53
  const checksum = await getChecksumFromUrl(distUrl);
54
54
  if (existingChecksum) updatedContent = updatedContent.replace(regEx(/distributionSha256Sum=.*/), `distributionSha256Sum=${checksum}`);
55
- else updatedContent = addChecksumAfterLine(updatedContent, /^(distributionUrl\s*=\s*.+)$/m, "distributionSha256Sum", checksum);
55
+ else updatedContent = addChecksumAfterLine(updatedContent, regEx(/^(distributionUrl\s*=\s*.+)$/m), "distributionSha256Sum", checksum);
56
56
  } catch (err) {
57
57
  logger.warn({
58
58
  err,
59
59
  url: distUrl
60
60
  }, "Failed to fetch distribution checksum");
61
- if (!existingChecksum && fallbackChecksum) updatedContent = addChecksumAfterLine(updatedContent, /^(distributionUrl\s*=\s*.+)$/m, "distributionSha256Sum", fallbackChecksum);
61
+ if (!existingChecksum && fallbackChecksum) updatedContent = addChecksumAfterLine(updatedContent, regEx(/^(distributionUrl\s*=\s*.+)$/m), "distributionSha256Sum", fallbackChecksum);
62
62
  }
63
63
  }
64
64
  if (addWrapperChecksum) {
@@ -72,13 +72,13 @@ async function updateChecksums(content, updatedDeps, addDistributionChecksum, ad
72
72
  if (wrapperUrl) try {
73
73
  const checksum = await getChecksumFromUrl(wrapperUrl);
74
74
  if (existingChecksum) updatedContent = updatedContent.replace(regEx(/wrapperSha256Sum=.*/), `wrapperSha256Sum=${checksum}`);
75
- else updatedContent = addChecksumAfterLine(updatedContent, /^(wrapperUrl\s*=\s*.+|wrapperVersion\s*=\s*.+)$/m, "wrapperSha256Sum", checksum);
75
+ else updatedContent = addChecksumAfterLine(updatedContent, regEx(/^(wrapperUrl\s*=\s*.+|wrapperVersion\s*=\s*.+)$/m), "wrapperSha256Sum", checksum);
76
76
  } catch (err) {
77
77
  logger.warn({
78
78
  err,
79
79
  url: wrapperUrl
80
80
  }, "Failed to fetch wrapper checksum");
81
- if (!existingChecksum && fallbackChecksum) updatedContent = addChecksumAfterLine(updatedContent, /^(wrapperUrl\s*=\s*.+|wrapperVersion\s*=\s*.+)$/m, "wrapperSha256Sum", fallbackChecksum);
81
+ if (!existingChecksum && fallbackChecksum) updatedContent = addChecksumAfterLine(updatedContent, regEx(/^(wrapperUrl\s*=\s*.+|wrapperVersion\s*=\s*.+)$/m), "wrapperSha256Sum", fallbackChecksum);
82
82
  }
83
83
  }
84
84
  return updatedContent;