renovate 44.93.7 → 44.94.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/dist/config/decrypt.js +3 -1
  2. package/dist/config/decrypt.js.map +1 -1
  3. package/dist/config/presets/internal/workarounds.preset.js +2 -2
  4. package/dist/config/presets/internal/workarounds.preset.js.map +1 -1
  5. package/dist/modules/datasource/azure-bicep-resource/index.js +4 -2
  6. package/dist/modules/datasource/azure-bicep-resource/index.js.map +1 -1
  7. package/dist/modules/datasource/cpan/index.js +1 -0
  8. package/dist/modules/datasource/cpan/index.js.map +1 -1
  9. package/dist/modules/datasource/docker/common.js +3 -1
  10. package/dist/modules/datasource/docker/common.js.map +1 -1
  11. package/dist/modules/datasource/elm-package/index.js +2 -1
  12. package/dist/modules/datasource/elm-package/index.js.map +1 -1
  13. package/dist/modules/datasource/index.js +1 -1
  14. package/dist/modules/datasource/index.js.map +1 -1
  15. package/dist/modules/datasource/java-version/index.js +1 -0
  16. package/dist/modules/datasource/java-version/index.js.map +1 -1
  17. package/dist/modules/datasource/npm/npmrc.js +1 -1
  18. package/dist/modules/datasource/npm/npmrc.js.map +1 -1
  19. package/dist/modules/datasource/ruby-version/index.js +1 -0
  20. package/dist/modules/datasource/ruby-version/index.js.map +1 -1
  21. package/dist/modules/datasource/typst/index.js +10 -7
  22. package/dist/modules/datasource/typst/index.js.map +1 -1
  23. package/dist/modules/manager/apm/artifacts.js +7 -18
  24. package/dist/modules/manager/apm/artifacts.js.map +1 -1
  25. package/dist/modules/manager/bun/artifacts.js +3 -10
  26. package/dist/modules/manager/bun/artifacts.js.map +1 -1
  27. package/dist/modules/manager/cargo/artifacts.js +4 -15
  28. package/dist/modules/manager/cargo/artifacts.js.map +1 -1
  29. package/dist/modules/manager/cocoapods/artifacts.js +11 -26
  30. package/dist/modules/manager/cocoapods/artifacts.js.map +1 -1
  31. package/dist/modules/manager/composer/artifacts.js +8 -19
  32. package/dist/modules/manager/composer/artifacts.js.map +1 -1
  33. package/dist/modules/manager/conan/artifacts.js +3 -10
  34. package/dist/modules/manager/conan/artifacts.js.map +1 -1
  35. package/dist/modules/manager/copier/artifacts.js +21 -41
  36. package/dist/modules/manager/copier/artifacts.js.map +1 -1
  37. package/dist/modules/manager/deno/artifacts.js +5 -18
  38. package/dist/modules/manager/deno/artifacts.js.map +1 -1
  39. package/dist/modules/manager/devbox/artifacts.js +3 -10
  40. package/dist/modules/manager/devbox/artifacts.js.map +1 -1
  41. package/dist/modules/manager/fingerprint.generated.js +7 -7
  42. package/dist/modules/manager/fingerprint.generated.js.map +1 -1
  43. package/dist/modules/manager/github-actions/known-actions/crate-dynamic.js +20 -0
  44. package/dist/modules/manager/github-actions/known-actions/crate-dynamic.js.map +1 -0
  45. package/dist/modules/manager/github-actions/known-actions/dart-version.js +13 -0
  46. package/dist/modules/manager/github-actions/known-actions/dart-version.js.map +1 -0
  47. package/dist/modules/manager/github-actions/known-actions/docker-dynamic.js +33 -0
  48. package/dist/modules/manager/github-actions/known-actions/docker-dynamic.js.map +1 -0
  49. package/dist/modules/manager/github-actions/known-actions/docker.js +10 -0
  50. package/dist/modules/manager/github-actions/known-actions/docker.js.map +1 -0
  51. package/dist/modules/manager/github-actions/known-actions/dotnet-version.js +14 -0
  52. package/dist/modules/manager/github-actions/known-actions/dotnet-version.js.map +1 -0
  53. package/dist/modules/manager/github-actions/known-actions/github-release-attachments-dynamic.js +22 -0
  54. package/dist/modules/manager/github-actions/known-actions/github-release-attachments-dynamic.js.map +1 -0
  55. package/dist/modules/manager/github-actions/known-actions/github-releases-dynamic.js +143 -0
  56. package/dist/modules/manager/github-actions/known-actions/github-releases-dynamic.js.map +1 -0
  57. package/dist/modules/manager/github-actions/known-actions/github-releases.js +271 -0
  58. package/dist/modules/manager/github-actions/known-actions/github-releases.js.map +1 -0
  59. package/dist/modules/manager/github-actions/known-actions/gradle-version.js +25 -0
  60. package/dist/modules/manager/github-actions/known-actions/gradle-version.js.map +1 -0
  61. package/dist/modules/manager/github-actions/known-actions/java-version-dynamic.js +51 -0
  62. package/dist/modules/manager/github-actions/known-actions/java-version-dynamic.js.map +1 -0
  63. package/dist/modules/manager/github-actions/known-actions/multiple.js +106 -0
  64. package/dist/modules/manager/github-actions/known-actions/multiple.js.map +1 -0
  65. package/dist/modules/manager/github-actions/known-actions/npm.js +53 -0
  66. package/dist/modules/manager/github-actions/known-actions/npm.js.map +1 -0
  67. package/dist/modules/manager/github-actions/known-actions/pypi.js +27 -0
  68. package/dist/modules/manager/github-actions/known-actions/pypi.js.map +1 -0
  69. package/dist/modules/manager/github-actions/known-actions/ruby-version.js +12 -0
  70. package/dist/modules/manager/github-actions/known-actions/ruby-version.js.map +1 -0
  71. package/dist/modules/manager/github-actions/known-actions/rust-version-dynamic.js +14 -0
  72. package/dist/modules/manager/github-actions/known-actions/rust-version-dynamic.js.map +1 -0
  73. package/dist/modules/manager/github-actions/known-actions/rust-version.js +19 -0
  74. package/dist/modules/manager/github-actions/known-actions/rust-version.js.map +1 -0
  75. package/dist/modules/manager/github-actions/known-actions/utils.js +93 -0
  76. package/dist/modules/manager/github-actions/known-actions/utils.js.map +1 -0
  77. package/dist/modules/manager/github-actions/known-actions.js +33 -728
  78. package/dist/modules/manager/github-actions/known-actions.js.map +1 -1
  79. package/dist/modules/manager/github-actions/schema.js +2 -1
  80. package/dist/modules/manager/github-actions/schema.js.map +1 -1
  81. package/dist/modules/manager/github-actions/types.js +9 -0
  82. package/dist/modules/manager/github-actions/types.js.map +1 -0
  83. package/dist/modules/manager/gleam/artifacts.js +13 -23
  84. package/dist/modules/manager/gleam/artifacts.js.map +1 -1
  85. package/dist/modules/manager/gomod/artifacts.js +18 -50
  86. package/dist/modules/manager/gomod/artifacts.js.map +1 -1
  87. package/dist/modules/manager/helmfile/artifacts.js +16 -22
  88. package/dist/modules/manager/helmfile/artifacts.js.map +1 -1
  89. package/dist/modules/manager/helmv3/artifacts.js +8 -28
  90. package/dist/modules/manager/helmv3/artifacts.js.map +1 -1
  91. package/dist/modules/manager/jsonnet-bundler/artifacts.js +4 -22
  92. package/dist/modules/manager/jsonnet-bundler/artifacts.js.map +1 -1
  93. package/dist/modules/manager/kustomize/artifacts.js +9 -23
  94. package/dist/modules/manager/kustomize/artifacts.js.map +1 -1
  95. package/dist/modules/manager/mise/artifacts.js +13 -22
  96. package/dist/modules/manager/mise/artifacts.js.map +1 -1
  97. package/dist/modules/manager/mix/artifacts.js +5 -18
  98. package/dist/modules/manager/mix/artifacts.js.map +1 -1
  99. package/dist/modules/manager/nuget/artifacts.js +3 -10
  100. package/dist/modules/manager/nuget/artifacts.js.map +1 -1
  101. package/dist/modules/manager/pep621/processors/pdm.js +7 -15
  102. package/dist/modules/manager/pep621/processors/pdm.js.map +1 -1
  103. package/dist/modules/manager/pep621/processors/uv.js +7 -15
  104. package/dist/modules/manager/pep621/processors/uv.js.map +1 -1
  105. package/dist/modules/manager/pixi/lockfile.js +25 -28
  106. package/dist/modules/manager/pixi/lockfile.js.map +1 -1
  107. package/dist/modules/manager/poetry/artifacts.js +41 -46
  108. package/dist/modules/manager/poetry/artifacts.js.map +1 -1
  109. package/dist/modules/manager/pub/artifacts.js +13 -16
  110. package/dist/modules/manager/pub/artifacts.js.map +1 -1
  111. package/dist/modules/manager/renovate-config/extract.js +3 -1
  112. package/dist/modules/manager/renovate-config/extract.js.map +1 -1
  113. package/dist/modules/manager/terragrunt/modules.js +2 -0
  114. package/dist/modules/manager/terragrunt/modules.js.map +1 -1
  115. package/dist/modules/manager/types.d.ts +19 -1
  116. package/dist/modules/manager/util.js +60 -1
  117. package/dist/modules/manager/util.js.map +1 -1
  118. package/dist/modules/manager/vendir/artifacts.js +7 -31
  119. package/dist/modules/manager/vendir/artifacts.js.map +1 -1
  120. package/dist/modules/platform/gitea/index.js +7 -4
  121. package/dist/modules/platform/gitea/index.js.map +1 -1
  122. package/dist/modules/platform/gitea/utils.js +2 -2
  123. package/dist/modules/platform/gitea/utils.js.map +1 -1
  124. package/dist/modules/versioning/composer/index.js +1 -1
  125. package/dist/modules/versioning/composer/index.js.map +1 -1
  126. package/dist/modules/versioning/docker/index.js +1 -1
  127. package/dist/modules/versioning/docker/index.js.map +1 -1
  128. package/dist/modules/versioning/gradle/compare.js +4 -4
  129. package/dist/modules/versioning/gradle/compare.js.map +1 -1
  130. package/dist/modules/versioning/hermit/index.js +1 -2
  131. package/dist/modules/versioning/hermit/index.js.map +1 -1
  132. package/dist/modules/versioning/ivy/index.js +2 -5
  133. package/dist/modules/versioning/ivy/index.js.map +1 -1
  134. package/dist/modules/versioning/ivy/parse.js +4 -7
  135. package/dist/modules/versioning/ivy/parse.js.map +1 -1
  136. package/dist/modules/versioning/maven/compare.js +7 -10
  137. package/dist/modules/versioning/maven/compare.js.map +1 -1
  138. package/dist/modules/versioning/nuget/parser.js +2 -3
  139. package/dist/modules/versioning/nuget/parser.js.map +1 -1
  140. package/dist/modules/versioning/nuget/range.js +1 -1
  141. package/dist/modules/versioning/nuget/range.js.map +1 -1
  142. package/dist/modules/versioning/pep440/range.js +6 -21
  143. package/dist/modules/versioning/pep440/range.js.map +1 -1
  144. package/dist/modules/versioning/rpm/index.js +1 -2
  145. package/dist/modules/versioning/rpm/index.js.map +1 -1
  146. package/dist/util/git/file-changes.js +50 -0
  147. package/dist/util/git/file-changes.js.map +1 -0
  148. package/dist/util/template/index.js +1 -0
  149. package/dist/util/template/index.js.map +1 -1
  150. package/dist/workers/global/config/parse/additional-config-file.js +1 -1
  151. package/dist/workers/global/config/parse/additional-config-file.js.map +1 -1
  152. package/dist/workers/global/limits.js +0 -1
  153. package/dist/workers/global/limits.js.map +1 -1
  154. package/dist/workers/repository/onboarding/branch/index.js +4 -2
  155. package/dist/workers/repository/onboarding/branch/index.js.map +1 -1
  156. package/dist/workers/repository/onboarding/branch/rebase.js +2 -1
  157. package/dist/workers/repository/onboarding/branch/rebase.js.map +1 -1
  158. package/dist/workers/repository/update/pr/changelog/forgejo/index.js +1 -3
  159. package/dist/workers/repository/update/pr/changelog/forgejo/index.js.map +1 -1
  160. package/dist/workers/repository/update/pr/changelog/gitea/index.js +1 -3
  161. package/dist/workers/repository/update/pr/changelog/gitea/index.js.map +1 -1
  162. package/dist/workers/repository/update/pr/changelog/gitlab/index.js +1 -3
  163. package/dist/workers/repository/update/pr/changelog/gitlab/index.js.map +1 -1
  164. package/dist/workers/repository/update/pr/changelog/source.js +6 -1
  165. package/dist/workers/repository/update/pr/changelog/source.js.map +1 -1
  166. package/package.json +1 -1
  167. package/renovate-schema.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"artifacts.js","names":[],"sources":["../../../../lib/modules/manager/helmfile/artifacts.ts"],"sourcesContent":["import { isFalsy } from '@sindresorhus/is';\nimport { quote } from 'shlex';\nimport { TEMPORARY_ERROR } from '../../../constants/error-messages.ts';\nimport { logger } from '../../../logger/index.ts';\nimport { coerceArray } from '../../../util/array.ts';\nimport { exec } from '../../../util/exec/index.ts';\nimport type { ToolConstraint } from '../../../util/exec/types.ts';\nimport {\n getSiblingFileName,\n readLocalFile,\n writeLocalFile,\n} from '../../../util/fs/index.ts';\nimport { getFile } from '../../../util/git/index.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { Result } from '../../../util/result.ts';\nimport { parseYaml } from '../../../util/yaml.ts';\nimport { generateHelmEnvs } from '../helmv3/common.ts';\nimport type { UpdateArtifact, UpdateArtifactsResult } from '../types.ts';\nimport { resolveToolConstraint } from '../util.ts';\nimport { Doc, LockVersion } from './schema.ts';\nimport { generateRegistryLoginCmd, isOCIRegistry } from './utils.ts';\n\nexport async function updateArtifacts({\n packageFileName,\n updatedDeps,\n newPackageFileContent,\n config,\n}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {\n logger.trace(`helmfile.updateArtifacts(${packageFileName})`);\n\n const { isLockFileMaintenance } = config;\n if (\n !isLockFileMaintenance &&\n (updatedDeps === undefined || updatedDeps.length < 1)\n ) {\n logger.debug('No updated helmfile deps - returning null');\n return null;\n }\n\n const lockFileName = getSiblingFileName(packageFileName, 'helmfile.lock');\n const existingLockFileContent = await getFile(lockFileName);\n\n if (isFalsy(existingLockFileContent)) {\n logger.debug('No helmfile.lock found');\n return null;\n }\n\n try {\n await writeLocalFile(packageFileName, newPackageFileContent);\n\n const toolConstraints: ToolConstraint[] = [\n {\n toolName: 'helm',\n constraint: await resolveToolConstraint(config, 'helm'),\n },\n {\n toolName: 'helmfile',\n constraint: await resolveToolConstraint(config, 'helmfile', () =>\n Result.parse(existingLockFileContent, LockVersion).unwrapOrNull(),\n ),\n },\n ];\n const needKustomize = updatedDeps.some(\n (dep) => dep.managerData?.needKustomize,\n );\n if (needKustomize) {\n toolConstraints.push({\n toolName: 'kustomize',\n constraint: await resolveToolConstraint(config, 'kustomize'),\n });\n }\n\n const cmd: string[] = [];\n const docs = parseYaml(newPackageFileContent, {\n removeTemplates: true,\n customSchema: Doc,\n failureBehaviour: 'filter',\n });\n\n for (const doc of docs) {\n for (const value of coerceArray(doc.repositories).filter(isOCIRegistry)) {\n const loginCmd = await generateRegistryLoginCmd(\n value.name,\n `https://${value.url}`,\n // this extracts the hostname from url like format ghcr.ip/helm-charts\n value.url.replace(regEx(/\\/.*/), ''),\n );\n\n // v8 ignore else -- needs a repository the login helper cannot handle\n if (loginCmd) {\n cmd.push(loginCmd);\n }\n }\n }\n\n cmd.push(`helmfile deps -f ${quote(packageFileName)}`);\n await exec(cmd, {\n docker: {},\n extraEnv: generateHelmEnvs(),\n toolConstraints,\n });\n\n const newHelmLockContent = await readLocalFile(lockFileName, 'utf8');\n if (existingLockFileContent === newHelmLockContent) {\n logger.debug('helmfile.lock is unchanged');\n return null;\n }\n\n return [\n {\n file: {\n type: 'addition',\n path: lockFileName,\n contents: newHelmLockContent,\n },\n },\n ];\n } catch (err) {\n // istanbul ignore if\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n logger.debug({ err }, 'Failed to update Helmfile lock file');\n return [\n {\n artifactError: {\n fileName: lockFileName,\n st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D,MAAM,KAAK,KAAK;GACd,QAAQ,CAAC;GACT,UAAU,iBAAiB;GAC3B;EACF,CAAC;EAED,MAAM,qBAAqB,MAAM,cAAc,cAAc,MAAM;EACnE,IAAI,4BAA4B,oBAAoB;GAClD,OAAO,MAAM,4BAA4B;GACzC,OAAO;EACT;EAEA,OAAO,CACL,EACE,MAAM;GACJ,MAAM;GACN,MAAM;GACN,UAAU;EACZ,EACF,CACF;CACF,SAAS,KAAK;;EAEZ,IAAI,IAAI,YAAA,mBACN,MAAM;EAER,OAAO,MAAM,EAAE,IAAI,GAAG,qCAAqC;EAC3D,OAAO,CACL,EACE,eAAe;GACb,UAAU;GACV,QAAQ,IAAI;EACd,EACF,CACF;CACF;AACF"}
1
+ {"version":3,"file":"artifacts.js","names":[],"sources":["../../../../lib/modules/manager/helmfile/artifacts.ts"],"sourcesContent":["import { isFalsy } from '@sindresorhus/is';\nimport { quote } from 'shlex';\nimport { TEMPORARY_ERROR } from '../../../constants/error-messages.ts';\nimport { logger } from '../../../logger/index.ts';\nimport { coerceArray } from '../../../util/array.ts';\nimport { exec } from '../../../util/exec/index.ts';\nimport type { ToolConstraint } from '../../../util/exec/types.ts';\nimport { getSiblingFileName } from '../../../util/fs/index.ts';\nimport { getFile } from '../../../util/git/index.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { Result } from '../../../util/result.ts';\nimport { parseYaml } from '../../../util/yaml.ts';\nimport { generateHelmEnvs } from '../helmv3/common.ts';\nimport type { UpdateArtifact, UpdateArtifactsResult } from '../types.ts';\nimport {\n artifactErrorResult,\n resolveToolConstraint,\n updateLockFile,\n} from '../util.ts';\nimport { Doc, LockVersion } from './schema.ts';\nimport { generateRegistryLoginCmd, isOCIRegistry } from './utils.ts';\n\nexport async function updateArtifacts({\n packageFileName,\n updatedDeps,\n newPackageFileContent,\n config,\n}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {\n logger.trace(`helmfile.updateArtifacts(${packageFileName})`);\n\n const { isLockFileMaintenance } = config;\n if (\n !isLockFileMaintenance &&\n (updatedDeps === undefined || updatedDeps.length < 1)\n ) {\n logger.debug('No updated helmfile deps - returning null');\n return null;\n }\n\n const lockFileName = getSiblingFileName(packageFileName, 'helmfile.lock');\n const existingLockFileContent = await getFile(lockFileName);\n\n if (isFalsy(existingLockFileContent)) {\n logger.debug('No helmfile.lock found');\n return null;\n }\n\n try {\n const toolConstraints: ToolConstraint[] = [\n {\n toolName: 'helm',\n constraint: await resolveToolConstraint(config, 'helm'),\n },\n {\n toolName: 'helmfile',\n constraint: await resolveToolConstraint(config, 'helmfile', () =>\n Result.parse(existingLockFileContent, LockVersion).unwrapOrNull(),\n ),\n },\n ];\n const needKustomize = updatedDeps.some(\n (dep) => dep.managerData?.needKustomize,\n );\n if (needKustomize) {\n toolConstraints.push({\n toolName: 'kustomize',\n constraint: await resolveToolConstraint(config, 'kustomize'),\n });\n }\n\n const cmd: string[] = [];\n const docs = parseYaml(newPackageFileContent, {\n removeTemplates: true,\n customSchema: Doc,\n failureBehaviour: 'filter',\n });\n\n for (const doc of docs) {\n for (const value of coerceArray(doc.repositories).filter(isOCIRegistry)) {\n const loginCmd = await generateRegistryLoginCmd(\n value.name,\n `https://${value.url}`,\n // this extracts the hostname from url like format ghcr.ip/helm-charts\n value.url.replace(regEx(/\\/.*/), ''),\n );\n\n // v8 ignore else -- needs a repository the login helper cannot handle\n if (loginCmd) {\n cmd.push(loginCmd);\n }\n }\n }\n\n cmd.push(`helmfile deps -f ${quote(packageFileName)}`);\n\n return await updateLockFile({\n lockFileName,\n existingLockFileContent,\n packageFile: { path: packageFileName, contents: newPackageFileContent },\n run: () =>\n exec(cmd, {\n docker: {},\n extraEnv: generateHelmEnvs(),\n toolConstraints,\n }),\n });\n } catch (err) {\n /* v8 ignore if -- defensive rethrow, not reproduced in the helmfile specs */\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n logger.debug({ err }, 'Failed to update Helmfile lock file');\n return artifactErrorResult(lockFileName, err);\n }\n}\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AU;GAAsB;GACtE,WACE,KAAK,KAAK;IACR,QAAQ,CAAC;IACT,UAAU,iBAAiB;IAC3B;GACF,CAAC;EACL,CAAC;CACH,SAAS,KAAK;;EAEZ,IAAI,IAAI,YAAA,mBACN,MAAM;EAER,OAAO,MAAM,EAAE,IAAI,GAAG,qCAAqC;EAC3D,OAAO,oBAAoB,cAAc,GAAG;CAC9C;AACF"}
@@ -1,6 +1,5 @@
1
1
  import "../../../constants/error-messages.js";
2
2
  import { regEx } from "../../../util/regex.js";
3
- import { coerceArray } from "../../../util/array.js";
4
3
  import { logger } from "../../../logger/index.js";
5
4
  import { find } from "../../../util/host-rules.js";
6
5
  import { parseSingleYaml } from "../../../util/yaml.js";
@@ -9,7 +8,8 @@ import { exec } from "../../../util/exec/index.js";
9
8
  import { getRepoStatus } from "../../../util/git/index.js";
10
9
  import { DockerDatasource } from "../../datasource/docker/index.js";
11
10
  import { HelmDatasource } from "../../datasource/helm/index.js";
12
- import { resolveToolConstraint } from "../util.js";
11
+ import { collectFileChanges } from "../../../util/git/file-changes.js";
12
+ import { artifactErrorResult, fileAddition, fileChangesToArtifactResults, resolveToolConstraint } from "../util.js";
13
13
  import { isOCIRegistry, removeOCIPrefix } from "./oci.js";
14
14
  import { generateHelmEnvs, generateLoginCmd } from "./common.js";
15
15
  import { aliasRecordToRepositories, getRepositories, isFileInDir } from "./utils.js";
@@ -89,43 +89,23 @@ async function updateArtifacts({ packageFileName, updatedDeps, newPackageFileCon
89
89
  const fileChanges = [];
90
90
  if (isTruthy(existingLockFileContent)) {
91
91
  const newHelmLockContent = await readLocalFile(lockFileName, "utf8");
92
- if (!isString(newHelmLockContent) || isHelmLockChanged(existingLockFileContent, newHelmLockContent)) fileChanges.push({ file: {
93
- type: "addition",
94
- path: lockFileName,
95
- contents: newHelmLockContent
96
- } });
92
+ if (!isString(newHelmLockContent) || isHelmLockChanged(existingLockFileContent, newHelmLockContent)) fileChanges.push(fileAddition(lockFileName, newHelmLockContent));
97
93
  else logger.debug("Chart.lock is unchanged");
98
94
  }
99
95
  if (isTruthy(isUpdateOptionAddChartArchives)) {
100
96
  const chartsPath = getSiblingFileName(packageFileName, "charts");
101
97
  const status = await getRepoStatus();
102
- const chartsAddition = coerceArray(status.not_added);
103
- const chartsDeletion = coerceArray(status.deleted);
104
- for (const file of chartsAddition) {
105
- if (!isFileInDir(chartsPath, file)) continue;
106
- fileChanges.push({ file: {
107
- type: "addition",
108
- path: file,
109
- contents: await readLocalFile(file)
110
- } });
111
- }
112
- for (const file of chartsDeletion) {
113
- if (!isFileInDir(chartsPath, file)) continue;
114
- fileChanges.push({ file: {
115
- type: "deletion",
116
- path: file
117
- } });
118
- }
98
+ fileChanges.push(...fileChangesToArtifactResults(await collectFileChanges(status, {
99
+ include: ["not_added", "deleted"],
100
+ filter: (file) => isFileInDir(chartsPath, file)
101
+ })));
119
102
  }
120
103
  return fileChanges.length > 0 ? fileChanges : null;
121
104
  } catch (err) {
122
105
  // istanbul ignore if
123
106
  if (err.message === "temporary-error") throw err;
124
107
  logger.debug({ err }, "Failed to update Helm lock file");
125
- return [{ artifactError: {
126
- fileName: lockFileName,
127
- stderr: err.message
128
- } }];
108
+ return artifactErrorResult(lockFileName, err);
129
109
  }
130
110
  }
131
111
  function isHelmLockChanged(oldContent, newContent) {
@@ -1 +1 @@
1
- {"version":3,"file":"artifacts.js","names":["hostRules.find","yaml.parseSingleYaml"],"sources":["../../../../lib/modules/manager/helmv3/artifacts.ts"],"sourcesContent":["import { isString, isTruthy } from '@sindresorhus/is';\nimport pMap from 'p-map';\nimport { quote } from 'shlex';\nimport { TEMPORARY_ERROR } from '../../../constants/error-messages.ts';\nimport { logger } from '../../../logger/index.ts';\nimport { coerceArray } from '../../../util/array.ts';\nimport { exec } from '../../../util/exec/index.ts';\nimport type { ExecOptions, ToolConstraint } from '../../../util/exec/types.ts';\nimport {\n getParentDir,\n getSiblingFileName,\n readLocalFile,\n writeLocalFile,\n} from '../../../util/fs/index.ts';\nimport { getRepoStatus } from '../../../util/git/index.ts';\nimport * as hostRules from '../../../util/host-rules.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport * as yaml from '../../../util/yaml.ts';\nimport { DockerDatasource } from '../../datasource/docker/index.ts';\nimport { HelmDatasource } from '../../datasource/helm/index.ts';\nimport type { UpdateArtifact, UpdateArtifactsResult } from '../types.ts';\nimport { resolveToolConstraint } from '../util.ts';\nimport { generateHelmEnvs, generateLoginCmd } from './common.ts';\nimport { isOCIRegistry, removeOCIPrefix } from './oci.ts';\nimport type { ChartDefinition, Repository, RepositoryRule } from './types.ts';\nimport {\n aliasRecordToRepositories,\n getRepositories,\n isFileInDir,\n} from './utils.ts';\n\nasync function helmCommands(\n execOptions: ExecOptions,\n manifestPath: string,\n repositories: Repository[],\n): Promise<void> {\n const cmd: string[] = [];\n // get OCI registries and detect host rules\n const registries: RepositoryRule[] = repositories\n .filter(isOCIRegistry)\n .map((value) => {\n return {\n ...value,\n repository: removeOCIPrefix(value.repository),\n hostRule: hostRules.find({\n url: value.repository.replace('oci://', 'https://'), //TODO we need to replace this, as oci:// will not be accepted as protocol\n hostType: DockerDatasource.id,\n }),\n };\n });\n\n // if credentials for the registry have been found, log into it\n await pMap(registries, async (value) => {\n const loginCmd = await generateLoginCmd(value);\n if (loginCmd) {\n cmd.push(loginCmd);\n }\n });\n\n // find classic Chart repositories and fitting host rules\n const classicRepositories: RepositoryRule[] = repositories\n .filter((repository) => !isOCIRegistry(repository))\n .map((value) => {\n return {\n ...value,\n hostRule: hostRules.find({\n url: value.repository,\n hostType: HelmDatasource.id,\n }),\n };\n });\n\n // add helm repos if an alias or credentials for the url are defined\n classicRepositories.forEach((value) => {\n const { username, password } = value.hostRule;\n const parameters = [`${quote(value.repository)}`, `--force-update`];\n const isPrivateRepo = username && password;\n if (isPrivateRepo) {\n parameters.push(`--username ${quote(username)}`);\n parameters.push(`--password ${quote(password)}`);\n }\n\n cmd.push(`helm repo add ${quote(value.name)} ${parameters.join(' ')}`);\n });\n\n cmd.push(`helm dependency update ${quote(getParentDir(manifestPath))}`);\n\n await exec(cmd, execOptions);\n}\n\nexport async function updateArtifacts({\n packageFileName,\n updatedDeps,\n newPackageFileContent,\n config,\n}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {\n logger.debug(`helmv3.updateArtifacts(${packageFileName})`);\n\n const { isLockFileMaintenance } = config;\n const isUpdateOptionAddChartArchives = config.postUpdateOptions?.includes(\n 'helmUpdateSubChartArchives',\n );\n\n if (\n !isLockFileMaintenance &&\n (updatedDeps === undefined || updatedDeps.length < 1)\n ) {\n logger.debug('No updated helmv3 deps - returning null');\n return null;\n }\n\n const lockFileName = getSiblingFileName(packageFileName, 'Chart.lock');\n const existingLockFileContent = await readLocalFile(lockFileName, 'utf8');\n if (!existingLockFileContent && !isUpdateOptionAddChartArchives) {\n logger.debug('No Chart.lock found');\n return null;\n }\n try {\n // get repositories and registries defined in the package file\n // TODO: use schema (#9610)\n const packages = yaml.parseSingleYaml<ChartDefinition>(\n newPackageFileContent,\n );\n const locks = existingLockFileContent\n ? yaml.parseSingleYaml<ChartDefinition>(existingLockFileContent)\n : { dependencies: [] };\n\n const chartDefinitions: ChartDefinition[] = [];\n // prioritize registryAlias naming for Helm repositories\n if (config.registryAliases) {\n chartDefinitions.push({\n dependencies: aliasRecordToRepositories(config.registryAliases),\n });\n }\n chartDefinitions.push(packages, locks);\n\n const repositories = getRepositories(chartDefinitions);\n\n await writeLocalFile(packageFileName, newPackageFileContent);\n logger.debug('Updating Helm artifacts');\n const helmToolConstraint: ToolConstraint = {\n toolName: 'helm',\n constraint: await resolveToolConstraint(config, 'helm'),\n };\n\n const execOptions: ExecOptions = {\n docker: {},\n extraEnv: generateHelmEnvs(),\n toolConstraints: [helmToolConstraint],\n };\n await helmCommands(execOptions, packageFileName, repositories);\n logger.debug('Returning updated Helm artifacts');\n\n const fileChanges: UpdateArtifactsResult[] = [];\n\n if (isTruthy(existingLockFileContent)) {\n const newHelmLockContent = await readLocalFile(lockFileName, 'utf8');\n const isLockFileChanged =\n !isString(newHelmLockContent) ||\n isHelmLockChanged(existingLockFileContent, newHelmLockContent);\n if (isLockFileChanged) {\n fileChanges.push({\n file: {\n type: 'addition',\n path: lockFileName,\n contents: newHelmLockContent,\n },\n });\n } else {\n logger.debug('Chart.lock is unchanged');\n }\n }\n\n // add modified helm chart archives to artifacts\n if (isTruthy(isUpdateOptionAddChartArchives)) {\n const chartsPath = getSiblingFileName(packageFileName, 'charts');\n const status = await getRepoStatus();\n const chartsAddition = coerceArray(status.not_added);\n const chartsDeletion = coerceArray(status.deleted);\n\n for (const file of chartsAddition) {\n // only add artifacts in the chart sub path\n if (!isFileInDir(chartsPath, file)) {\n continue;\n }\n fileChanges.push({\n file: {\n type: 'addition',\n path: file,\n contents: await readLocalFile(file),\n },\n });\n }\n\n for (const file of chartsDeletion) {\n // only add artifacts in the chart sub path\n if (!isFileInDir(chartsPath, file)) {\n continue;\n }\n fileChanges.push({\n file: {\n type: 'deletion',\n path: file,\n },\n });\n }\n }\n\n return fileChanges.length > 0 ? fileChanges : null;\n } catch (err) {\n // istanbul ignore if\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n logger.debug({ err }, 'Failed to update Helm lock file');\n return [\n {\n artifactError: {\n fileName: lockFileName,\n stderr: err.message,\n },\n },\n ];\n }\n}\n\nfunction isHelmLockChanged(oldContent: string, newContent: string): boolean {\n const regex = regEx(/^generated: \".+\"$/m);\n return newContent.replace(regex, '') !== oldContent.replace(regex, '');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA+BA,eAAe,aACb,aACA,cACA,cACe;CACf,MAAM,MAAgB,CAAC;CAEvB,MAAM,aAA+B,aAClC,OAAO,aAAa,CAAC,CACrB,KAAK,UAAU;EACd,OAAO;GACL,GAAG;GACH,YAAY,gBAAgB,MAAM,UAAU;GAC5C,UAAUA,KAAe;IACvB,KAAK,MAAM,WAAW,QAAQ,UAAU,UAAU;IAClD,UAAU,iBAAiB;GAC7B,CAAC;EACH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AY,YAAY,IAAI,GAC/B;IAEF,YAAY,KAAK,EACf,MAAM;KACJ,MAAM;KACN,MAAM;IACR,EACF,CAAC;GACH;EACF;EAEA,OAAO,YAAY,SAAS,IAAI,cAAc;CAChD,SAAS,KAAK;;EAEZ,IAAI,IAAI,YAAA,mBACN,MAAM;EAER,OAAO,MAAM,EAAE,IAAI,GAAG,iCAAiC;EACvD,OAAO,CACL,EACE,eAAe;GACb,UAAU;GACV,QAAQ,IAAI;EACd,EACF,CACF;CACF;AACF;AAEA,SAAS,kBAAkB,YAAoB,YAA6B;CAC1E,MAAM,QAAQ,MAAM,oBAAoB;CACxC,OAAO,WAAW,QAAQ,OAAO,EAAE,MAAM,WAAW,QAAQ,OAAO,EAAE;AACvE"}
1
+ {"version":3,"file":"artifacts.js","names":["hostRules.find","yaml.parseSingleYaml"],"sources":["../../../../lib/modules/manager/helmv3/artifacts.ts"],"sourcesContent":["import { isString, isTruthy } from '@sindresorhus/is';\nimport pMap from 'p-map';\nimport { quote } from 'shlex';\nimport { TEMPORARY_ERROR } from '../../../constants/error-messages.ts';\nimport { logger } from '../../../logger/index.ts';\nimport { exec } from '../../../util/exec/index.ts';\nimport type { ExecOptions, ToolConstraint } from '../../../util/exec/types.ts';\nimport {\n getParentDir,\n getSiblingFileName,\n readLocalFile,\n writeLocalFile,\n} from '../../../util/fs/index.ts';\nimport { collectFileChanges } from '../../../util/git/file-changes.ts';\nimport { getRepoStatus } from '../../../util/git/index.ts';\nimport * as hostRules from '../../../util/host-rules.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport * as yaml from '../../../util/yaml.ts';\nimport { DockerDatasource } from '../../datasource/docker/index.ts';\nimport { HelmDatasource } from '../../datasource/helm/index.ts';\nimport type { UpdateArtifact, UpdateArtifactsResult } from '../types.ts';\nimport {\n artifactErrorResult,\n fileAddition,\n fileChangesToArtifactResults,\n resolveToolConstraint,\n} from '../util.ts';\nimport { generateHelmEnvs, generateLoginCmd } from './common.ts';\nimport { isOCIRegistry, removeOCIPrefix } from './oci.ts';\nimport type { ChartDefinition, Repository, RepositoryRule } from './types.ts';\nimport {\n aliasRecordToRepositories,\n getRepositories,\n isFileInDir,\n} from './utils.ts';\n\nasync function helmCommands(\n execOptions: ExecOptions,\n manifestPath: string,\n repositories: Repository[],\n): Promise<void> {\n const cmd: string[] = [];\n // get OCI registries and detect host rules\n const registries: RepositoryRule[] = repositories\n .filter(isOCIRegistry)\n .map((value) => {\n return {\n ...value,\n repository: removeOCIPrefix(value.repository),\n hostRule: hostRules.find({\n url: value.repository.replace('oci://', 'https://'), //TODO we need to replace this, as oci:// will not be accepted as protocol\n hostType: DockerDatasource.id,\n }),\n };\n });\n\n // if credentials for the registry have been found, log into it\n await pMap(registries, async (value) => {\n const loginCmd = await generateLoginCmd(value);\n if (loginCmd) {\n cmd.push(loginCmd);\n }\n });\n\n // find classic Chart repositories and fitting host rules\n const classicRepositories: RepositoryRule[] = repositories\n .filter((repository) => !isOCIRegistry(repository))\n .map((value) => {\n return {\n ...value,\n hostRule: hostRules.find({\n url: value.repository,\n hostType: HelmDatasource.id,\n }),\n };\n });\n\n // add helm repos if an alias or credentials for the url are defined\n classicRepositories.forEach((value) => {\n const { username, password } = value.hostRule;\n const parameters = [`${quote(value.repository)}`, `--force-update`];\n const isPrivateRepo = username && password;\n if (isPrivateRepo) {\n parameters.push(`--username ${quote(username)}`);\n parameters.push(`--password ${quote(password)}`);\n }\n\n cmd.push(`helm repo add ${quote(value.name)} ${parameters.join(' ')}`);\n });\n\n cmd.push(`helm dependency update ${quote(getParentDir(manifestPath))}`);\n\n await exec(cmd, execOptions);\n}\n\nexport async function updateArtifacts({\n packageFileName,\n updatedDeps,\n newPackageFileContent,\n config,\n}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {\n logger.debug(`helmv3.updateArtifacts(${packageFileName})`);\n\n const { isLockFileMaintenance } = config;\n const isUpdateOptionAddChartArchives = config.postUpdateOptions?.includes(\n 'helmUpdateSubChartArchives',\n );\n\n if (\n !isLockFileMaintenance &&\n (updatedDeps === undefined || updatedDeps.length < 1)\n ) {\n logger.debug('No updated helmv3 deps - returning null');\n return null;\n }\n\n const lockFileName = getSiblingFileName(packageFileName, 'Chart.lock');\n const existingLockFileContent = await readLocalFile(lockFileName, 'utf8');\n if (!existingLockFileContent && !isUpdateOptionAddChartArchives) {\n logger.debug('No Chart.lock found');\n return null;\n }\n try {\n // get repositories and registries defined in the package file\n // TODO: use schema (#9610)\n const packages = yaml.parseSingleYaml<ChartDefinition>(\n newPackageFileContent,\n );\n const locks = existingLockFileContent\n ? yaml.parseSingleYaml<ChartDefinition>(existingLockFileContent)\n : { dependencies: [] };\n\n const chartDefinitions: ChartDefinition[] = [];\n // prioritize registryAlias naming for Helm repositories\n if (config.registryAliases) {\n chartDefinitions.push({\n dependencies: aliasRecordToRepositories(config.registryAliases),\n });\n }\n chartDefinitions.push(packages, locks);\n\n const repositories = getRepositories(chartDefinitions);\n\n await writeLocalFile(packageFileName, newPackageFileContent);\n logger.debug('Updating Helm artifacts');\n const helmToolConstraint: ToolConstraint = {\n toolName: 'helm',\n constraint: await resolveToolConstraint(config, 'helm'),\n };\n\n const execOptions: ExecOptions = {\n docker: {},\n extraEnv: generateHelmEnvs(),\n toolConstraints: [helmToolConstraint],\n };\n await helmCommands(execOptions, packageFileName, repositories);\n logger.debug('Returning updated Helm artifacts');\n\n const fileChanges: UpdateArtifactsResult[] = [];\n\n if (isTruthy(existingLockFileContent)) {\n const newHelmLockContent = await readLocalFile(lockFileName, 'utf8');\n const isLockFileChanged =\n !isString(newHelmLockContent) ||\n isHelmLockChanged(existingLockFileContent, newHelmLockContent);\n if (isLockFileChanged) {\n fileChanges.push(fileAddition(lockFileName, newHelmLockContent));\n } else {\n logger.debug('Chart.lock is unchanged');\n }\n }\n\n // add modified helm chart archives to artifacts\n if (isTruthy(isUpdateOptionAddChartArchives)) {\n const chartsPath = getSiblingFileName(packageFileName, 'charts');\n const status = await getRepoStatus();\n fileChanges.push(\n ...fileChangesToArtifactResults(\n await collectFileChanges(status, {\n include: ['not_added', 'deleted'],\n // only add artifacts in the chart sub path\n filter: (file) => isFileInDir(chartsPath, file),\n }),\n ),\n );\n }\n\n return fileChanges.length > 0 ? fileChanges : null;\n } catch (err) {\n // istanbul ignore if\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n logger.debug({ err }, 'Failed to update Helm lock file');\n return artifactErrorResult(lockFileName, err);\n }\n}\n\nfunction isHelmLockChanged(oldContent: string, newContent: string): boolean {\n const regex = regEx(/^generated: \".+\"$/m);\n return newContent.replace(regex, '') !== oldContent.replace(regex, '');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAoCA,eAAe,aACb,aACA,cACA,cACe;CACf,MAAM,MAAgB,CAAC;CAEvB,MAAM,aAA+B,aAClC,OAAO,aAAa,CAAC,CACrB,KAAK,UAAU;EACd,OAAO;GACL,GAAG;GACH,YAAY,gBAAgB,MAAM,UAAU;GAC5C,UAAUA,KAAe;IACvB,KAAK,MAAM,WAAW,QAAQ,UAAU,UAAU;IAClD,UAAU,iBAAiB;GAC7B,CAAC;EACH;CACF,CAAC;CAGH,MAAM,KAAK,YAAY,OAAO,UAAU;EACtC,MAAM,WAAW,MAAM,iBAAiB,KAAK;EAC7C,IAAI,UACF,IAAI,KAAK,QAAQ;CAErB,CAAC;CAgBD,aAZG,QAAQ,eAAe,CAAC,cAAc,UAAU,CAAC,CAAC,CAClD,KAAK,UAAU;EACd,OAAO;GACL,GAAG;GACH,UAAUA,KAAe;IACvB,KAAK,MAAM;IACX,UAAU,eAAe;GAC3B,CAAC;EACH;CACF,CAGgB,CAAC,CAAC,SAAS,UAAU;EACrC,MAAM,EAAE,UAAU,aAAa,MAAM;EACrC,MAAM,aAAa,CAAC,GAAG,MAAM,MAAM,UAAU,KAAK,gBAAgB;EAElE,IADsB,YAAY,UACf;GACjB,WAAW,KAAK,cAAc,MAAM,QAAQ,GAAG;GAC/C,WAAW,KAAK,cAAc,MAAM,QAAQ,GA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uC,CAAC;EAE9C,IAAI,SAAS,uBAAuB,GAAG;GACrC,MAAM,qBAAqB,MAAM,cAAc,cAAc,MAAM;GAInE,IAFE,CAAC,SAAS,kBAAkB,KAC5B,kBAAkB,yBAAyB,kBAAkB,GAE7D,YAAY,KAAK,aAAa,cAAc,kBAAkB,CAAC;QAE/D,OAAO,MAAM,yBAAyB;EAE1C;EAGA,IAAI,SAAS,8BAA8B,GAAG;GAC5C,MAAM,aAAa,mBAAmB,iBAAiB,QAAQ;GAC/D,MAAM,SAAS,MAAM,cAAc;GACnC,YAAY,KACV,GAAG,6BACD,MAAM,mBAAmB,QAAQ;IAC/B,SAAS,CAAC,aAAa,SAAS;IAEhC,SAAS,SAAS,YAAY,YAAY,IAAI;GAChD,CAAC,CACH,CACF;EACF;EAEA,OAAO,YAAY,SAAS,IAAI,cAAc;CAChD,SAAS,KAAK;;EAEZ,IAAI,IAAI,YAAA,mBACN,MAAM;EAER,OAAO,MAAM,EAAE,IAAI,GAAG,iCAAiC;EACvD,OAAO,oBAAoB,cAAc,GAAG;CAC9C;AACF;AAEA,SAAS,kBAAkB,YAAoB,YAA6B;CAC1E,MAAM,QAAQ,MAAM,oBAAoB;CACxC,OAAO,WAAW,QAAQ,OAAO,EAAE,MAAM,WAAW,QAAQ,OAAO,EAAE;AACvE"}
@@ -1,11 +1,11 @@
1
1
  import "../../../constants/error-messages.js";
2
2
  import { regEx } from "../../../util/regex.js";
3
- import { coerceArray } from "../../../util/array.js";
4
3
  import { logger } from "../../../logger/index.js";
5
4
  import { readLocalFile } from "../../../util/fs/index.js";
6
5
  import { exec } from "../../../util/exec/index.js";
7
6
  import { getRepoStatus } from "../../../util/git/index.js";
8
- import { resolveToolConstraint } from "../util.js";
7
+ import { collectFileChanges } from "../../../util/git/file-changes.js";
8
+ import { artifactErrorResult, fileChangesToArtifactResults, resolveToolConstraint } from "../util.js";
9
9
  import { quote } from "shlex";
10
10
  //#region lib/modules/manager/jsonnet-bundler/artifacts.ts
11
11
  function dependencyUrl(dep) {
@@ -37,28 +37,10 @@ async function updateArtifacts(updateArtifact) {
37
37
  }
38
38
  const status = await getRepoStatus();
39
39
  if (status.isClean()) return null;
40
- const res = [];
41
- for (const f of coerceArray(status.modified)) res.push({ file: {
42
- type: "addition",
43
- path: f,
44
- contents: await readLocalFile(f)
45
- } });
46
- for (const f of coerceArray(status.not_added)) res.push({ file: {
47
- type: "addition",
48
- path: f,
49
- contents: await readLocalFile(f)
50
- } });
51
- for (const f of coerceArray(status.deleted)) res.push({ file: {
52
- type: "deletion",
53
- path: f
54
- } });
55
- return res;
40
+ return fileChangesToArtifactResults(await collectFileChanges(status));
56
41
  } catch (err) /* istanbul ignore next */ {
57
42
  if (err.message === "temporary-error") throw err;
58
- return [{ artifactError: {
59
- fileName: lockFileName,
60
- stderr: err.stderr
61
- } }];
43
+ return artifactErrorResult(lockFileName, err);
62
44
  }
63
45
  }
64
46
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"artifacts.js","names":[],"sources":["../../../../lib/modules/manager/jsonnet-bundler/artifacts.ts"],"sourcesContent":["import { quote } from 'shlex';\nimport { TEMPORARY_ERROR } from '../../../constants/error-messages.ts';\nimport { logger } from '../../../logger/index.ts';\nimport { coerceArray } from '../../../util/array.ts';\nimport { exec } from '../../../util/exec/index.ts';\nimport type { ExecOptions, ToolConstraint } from '../../../util/exec/types.ts';\nimport { readLocalFile } from '../../../util/fs/index.ts';\nimport { getRepoStatus } from '../../../util/git/index.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport type {\n PackageDependency,\n UpdateArtifact,\n UpdateArtifactsResult,\n} from '../types.ts';\nimport { resolveToolConstraint } from '../util.ts';\n\nfunction dependencyUrl(dep: PackageDependency): string {\n const url = dep.packageName!;\n if (dep.managerData?.subdir) {\n return url.concat('/', dep.managerData.subdir);\n }\n return url;\n}\n\nexport async function updateArtifacts(\n updateArtifact: UpdateArtifact,\n): Promise<UpdateArtifactsResult[] | null> {\n const { packageFileName, updatedDeps, config } = updateArtifact;\n logger.trace({ packageFileName }, 'jsonnet-bundler.updateArtifacts()');\n\n const lockFileName = packageFileName.replace(regEx(/\\.json$/), '.lock.json');\n const existingLockFileContent = await readLocalFile(lockFileName, 'utf8');\n\n if (!existingLockFileContent) {\n logger.debug('No jsonnetfile.lock.json found');\n return null;\n }\n\n const jsonnetBundlerToolConstraint: ToolConstraint = {\n toolName: 'jb',\n constraint: await resolveToolConstraint(config, 'jb'),\n };\n\n const execOptions: ExecOptions = {\n cwdFile: packageFileName,\n docker: {},\n toolConstraints: [jsonnetBundlerToolConstraint],\n };\n\n try {\n if (config.isLockFileMaintenance) {\n await exec('jb update', execOptions);\n } else {\n const dependencyUrls = updatedDeps.map(dependencyUrl);\n if (dependencyUrls.length > 0) {\n await exec(\n `jb update ${dependencyUrls.map(quote).join(' ')}`,\n execOptions,\n );\n }\n }\n\n const status = await getRepoStatus();\n\n if (status.isClean()) {\n return null;\n }\n\n const res: UpdateArtifactsResult[] = [];\n\n for (const f of coerceArray(status.modified)) {\n res.push({\n file: {\n type: 'addition',\n path: f,\n contents: await readLocalFile(f),\n },\n });\n }\n for (const f of coerceArray(status.not_added)) {\n res.push({\n file: {\n type: 'addition',\n path: f,\n contents: await readLocalFile(f),\n },\n });\n }\n for (const f of coerceArray(status.deleted)) {\n res.push({\n file: {\n type: 'deletion',\n path: f,\n },\n });\n }\n\n return res;\n } catch (err) /* istanbul ignore next */ {\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n return [\n {\n artifactError: {\n fileName: lockFileName,\n stderr: err.stderr,\n },\n },\n ];\n }\n}\n"],"mappings":";;;;;;;;;;AAgBA,SAAS,cAAc,KAAgC;CACrD,MAAM,MAAM,IAAI;CAChB,IAAI,IAAI,aAAa,QACnB,OAAO,IAAI,OAAO,KAAK,IAAI,YAAY,MAAM;CAE/C,OAAO;AACT;AAEA,eAAsB,gBACpB,gBACyC;CACzC,MAAM,EAAE,iBAAiB,aAAa,WAAW;CACjD,OAAO,MAAM,EA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ler/artifacts.ts"],"sourcesContent":["import { quote } from 'shlex';\nimport { TEMPORARY_ERROR } from '../../../constants/error-messages.ts';\nimport { logger } from '../../../logger/index.ts';\nimport { exec } from '../../../util/exec/index.ts';\nimport type { ExecOptions, ToolConstraint } from '../../../util/exec/types.ts';\nimport { readLocalFile } from '../../../util/fs/index.ts';\nimport { collectFileChanges } from '../../../util/git/file-changes.ts';\nimport { getRepoStatus } from '../../../util/git/index.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport type {\n PackageDependency,\n UpdateArtifact,\n UpdateArtifactsResult,\n} from '../types.ts';\nimport {\n artifactErrorResult,\n fileChangesToArtifactResults,\n resolveToolConstraint,\n} from '../util.ts';\n\nfunction dependencyUrl(dep: PackageDependency): string {\n const url = dep.packageName!;\n if (dep.managerData?.subdir) {\n return url.concat('/', dep.managerData.subdir);\n }\n return url;\n}\n\nexport async function updateArtifacts(\n updateArtifact: UpdateArtifact,\n): Promise<UpdateArtifactsResult[] | null> {\n const { packageFileName, updatedDeps, config } = updateArtifact;\n logger.trace({ packageFileName }, 'jsonnet-bundler.updateArtifacts()');\n\n const lockFileName = packageFileName.replace(regEx(/\\.json$/), '.lock.json');\n const existingLockFileContent = await readLocalFile(lockFileName, 'utf8');\n\n if (!existingLockFileContent) {\n logger.debug('No jsonnetfile.lock.json found');\n return null;\n }\n\n const jsonnetBundlerToolConstraint: ToolConstraint = {\n toolName: 'jb',\n constraint: await resolveToolConstraint(config, 'jb'),\n };\n\n const execOptions: ExecOptions = {\n cwdFile: packageFileName,\n docker: {},\n toolConstraints: [jsonnetBundlerToolConstraint],\n };\n\n try {\n if (config.isLockFileMaintenance) {\n await exec('jb update', execOptions);\n } else {\n const dependencyUrls = updatedDeps.map(dependencyUrl);\n if (dependencyUrls.length > 0) {\n await exec(\n `jb update ${dependencyUrls.map(quote).join(' ')}`,\n execOptions,\n );\n }\n }\n\n const status = await getRepoStatus();\n\n if (status.isClean()) {\n return null;\n }\n\n return fileChangesToArtifactResults(await collectFileChanges(status));\n } catch (err) /* istanbul ignore next */ {\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n return artifactErrorResult(lockFileName, err);\n }\n}\n"],"mappings":";;;;;;;;;;AAoBA,SAAS,cAAc,KAAgC;CACrD,MAAM,MAAM,IAAI;CAChB,IAAI,IAAI,aAAa,QACnB,OAAO,IAAI,OAAO,KAAK,IAAI,YAAY,MAAM;CAE/C,OAAO;AACT;AAEA,eAAsB,gBACpB,gBACyC;CACzC,MAAM,EAAE,iBAAiB,aAAa,WAAW;CACjD,OAAO,MAAM,EAAE,gBAAgB,GAAG,mCAAmC;CAErE,MAAM,eAAe,gBAAgB,QAAQ,MAAM,SAAS,GAAG,YAAY;CAG3E,IAAI,CAAC,MAFiC,cAAc,cAAc,MAAM,GAE1C;EAC5B,OAAO,MAAM,gCAAgC;EAC7C,OAAO;CACT;CAOA,MAAM,cAA2B;EAC/B,SAAS;EACT,QAAQ,CAAC;EACT,iBAAiB,CAAC;GAPlB,UAAU;GACV,YAAY,MAAM,sBAAsB,QAAQ,IAAI;EAMP,CAAC;CAChD;CAEA,IAAI;EACF,IAAI,OAAO,uBACT,MAAM,KAAK,aAAa,WAAW;OAC9B;GACL,MAAM,iBAAiB,YAAY,IAAI,aAAa;GACpD,IAAI,eAAe,SAAS,GAC1B,MAAM,KACJ,aAAa,eAAe,IAAI,KAAK,CAAC,CAAC,KAAK,GAAG,KAC/C,WACF;EAEJ;EAEA,MAAM,SAAS,MAAM,cAAc;EAEnC,IAAI,OAAO,QAAQ,GACjB,OAAO;EAGT,OAAO,6BAA6B,MAAM,mBAAmB,MAAM,CAAC;CACtE,SAAS,gCAAgC;EACvC,IAAI,IAAI,YAAA,mBACN,MAAM;EAER,OAAO,oBAAoB,cAAc,GAAG;CAC9C;AACF"}
@@ -1,12 +1,12 @@
1
1
  import "../../../constants/error-messages.js";
2
- import { coerceArray } from "../../../util/array.js";
3
2
  import { logger } from "../../../logger/index.js";
4
- import { deleteLocalFile, getSiblingFileName, localPathExists, readLocalFile } from "../../../util/fs/index.js";
3
+ import { deleteLocalFile, getSiblingFileName, localPathExists } from "../../../util/fs/index.js";
5
4
  import { exec } from "../../../util/exec/index.js";
6
5
  import { getRepoStatus } from "../../../util/git/index.js";
7
6
  import { DockerDatasource } from "../../datasource/docker/index.js";
8
7
  import { HelmDatasource } from "../../datasource/helm/index.js";
9
- import { resolveToolConstraint } from "../util.js";
8
+ import { collectFileChanges } from "../../../util/git/file-changes.js";
9
+ import { artifactError, artifactErrorResult, fileChangesToArtifactResults, resolveToolConstraint } from "../util.js";
10
10
  import { parseKustomize } from "./extract.js";
11
11
  import { generateHelmEnvs } from "./common.js";
12
12
  import { isNonEmptyString, isNullOrUndefined } from "@sindresorhus/is";
@@ -52,7 +52,7 @@ async function updateArtifacts({ packageFileName, updatedDeps, newPackageFileCon
52
52
  logger.debug(`kustomize.updateArtifacts(${packageFileName})`);
53
53
  const project = parseKustomize(newPackageFileContent);
54
54
  const isUpdateOptionInflateChartArchives = config.postUpdateOptions?.includes("kustomizeInflateHelmCharts") === true;
55
- if (isNullOrUndefined(project)) return [{ artifactError: { stderr: "Failed to parse new package file content" } }];
55
+ if (isNullOrUndefined(project)) return [artifactError(void 0, "Failed to parse new package file content")];
56
56
  const chartHome = getSiblingFileName(packageFileName, project.helmGlobals?.chartHome ?? "charts");
57
57
  try {
58
58
  const helmConstraint = await resolveToolConstraint(config, "helm");
@@ -81,29 +81,15 @@ async function updateArtifacts({ packageFileName, updatedDeps, newPackageFileCon
81
81
  await inflateHelmChart(isUpdateOptionInflateChartArchives, execOptions, chartHome, dependency.depName, repository, dependency.currentVersion, dependency.newVersion, dependency.datasource);
82
82
  }
83
83
  const status = await getRepoStatus();
84
- const chartsAddition = coerceArray(status?.not_added);
85
- const chartsDeletion = coerceArray(status?.deleted);
86
- const fileChanges = [];
87
- for (const file of chartsAddition) {
88
- if (!file.startsWith(chartHome)) continue;
89
- fileChanges.push({ file: {
90
- type: "addition",
91
- path: file,
92
- contents: await readLocalFile(file)
93
- } });
94
- }
95
- for (const file of chartsDeletion) {
96
- if (!file.startsWith(chartHome)) continue;
97
- fileChanges.push({ file: {
98
- type: "deletion",
99
- path: file
100
- } });
101
- }
84
+ const fileChanges = fileChangesToArtifactResults(await collectFileChanges(status, {
85
+ include: ["not_added", "deleted"],
86
+ filter: (file) => file.startsWith(chartHome)
87
+ }));
102
88
  return fileChanges.length > 0 ? fileChanges : null;
103
89
  } catch (err) {
104
90
  if (err.message === "temporary-error") throw err;
105
91
  logger.debug({ err }, "Failed to inflate helm chart");
106
- return [{ artifactError: { stderr: err.message } }];
92
+ return artifactErrorResult(void 0, err);
107
93
  }
108
94
  }
109
95
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"artifacts.js","names":[],"sources":["../../../../lib/modules/manager/kustomize/artifacts.ts"],"sourcesContent":["import { isNonEmptyString, isNullOrUndefined } 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 { coerceArray } from '../../../util/array.ts';\nimport { exec } from '../../../util/exec/index.ts';\nimport type { ExecOptions, ToolConstraint } from '../../../util/exec/types.ts';\nimport {\n deleteLocalFile,\n getSiblingFileName,\n localPathExists,\n readLocalFile,\n} from '../../../util/fs/index.ts';\nimport { getRepoStatus } from '../../../util/git/index.ts';\nimport { DockerDatasource } from '../../datasource/docker/index.ts';\nimport { HelmDatasource } from '../../datasource/helm/index.ts';\nimport type { UpdateArtifact, UpdateArtifactsResult } from '../types.ts';\nimport { resolveToolConstraint } from '../util.ts';\nimport { generateHelmEnvs } from './common.ts';\nimport { parseKustomize } from './extract.ts';\n\nasync function localExistingChartPath(\n chartHome: string,\n dependencyName: string,\n version?: string,\n): Promise<string | null> {\n const folderName = `${dependencyName}-${version}`;\n const path = upath.join(chartHome, folderName);\n const pathExists = await localPathExists(path);\n\n return pathExists ? path : null;\n}\n\nfunction helmRepositoryArgs(\n repository: string,\n depName: string,\n datasource?: string,\n): string {\n switch (datasource) {\n case HelmDatasource.id:\n return `--repo ${quote(repository)} ${quote(depName)}`;\n case DockerDatasource.id:\n return quote(`oci://${repository}`);\n /* v8 ignore next: should never happen */\n default:\n throw new Error(`Unknown datasource: ${datasource}`);\n }\n}\n\nasync function inflateHelmChart(\n flagEnabled: boolean,\n execOptions: ExecOptions,\n chartHome: string,\n depName: string,\n repository: string,\n currentVersion: string,\n newVersion?: string,\n datasource?: string,\n): Promise<void> {\n const currentChartExistingPath = await localExistingChartPath(\n chartHome,\n depName,\n currentVersion,\n );\n\n if (!flagEnabled && isNullOrUndefined(currentChartExistingPath)) {\n logger.debug(\n `Not inflating Helm chart for ${depName} as kustomizeInflateHelmCharts is not enabled and the current version isn't inflated`,\n );\n return;\n }\n\n if (\n isNonEmptyString(currentChartExistingPath) &&\n isNonEmptyString(newVersion)\n ) {\n logger.debug(`Deleting previous helm chart: ${currentChartExistingPath}`);\n await deleteLocalFile(currentChartExistingPath);\n }\n\n const versionToPull = newVersion ?? currentVersion;\n const versionToPullExistingPath = await localExistingChartPath(\n chartHome,\n depName,\n versionToPull,\n );\n\n if (isNonEmptyString(versionToPullExistingPath)) {\n logger.debug(\n `Helm chart ${depName} version ${versionToPull} already exists at ${versionToPullExistingPath}`,\n );\n return;\n }\n\n const folderName = `${depName}-${versionToPull}`;\n const untarDir = upath.join(chartHome, folderName);\n logger.debug(\n `Pulling helm chart ${depName} version ${versionToPull} to ${untarDir}`,\n );\n\n const cmd =\n `helm pull --untar --untardir ${quote(untarDir)} ` +\n `--version ${quote(versionToPull)} ${helmRepositoryArgs(repository, depName, datasource)}`;\n\n await exec(cmd, execOptions);\n}\n\nexport async function updateArtifacts({\n packageFileName,\n updatedDeps,\n newPackageFileContent,\n config,\n}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {\n logger.debug(`kustomize.updateArtifacts(${packageFileName})`);\n const project = parseKustomize(newPackageFileContent);\n const isUpdateOptionInflateChartArchives =\n config.postUpdateOptions?.includes('kustomizeInflateHelmCharts') === true;\n if (isNullOrUndefined(project)) {\n return [\n {\n artifactError: {\n stderr: 'Failed to parse new package file content',\n },\n },\n ];\n }\n\n const chartHome = getSiblingFileName(\n packageFileName,\n project.helmGlobals?.chartHome ?? 'charts',\n );\n\n try {\n const helmConstraint = await resolveToolConstraint(config, 'helm');\n const helmToolConstraint: ToolConstraint = {\n toolName: 'helm',\n constraint: helmConstraint,\n };\n\n const execOptions: ExecOptions = {\n docker: {},\n extraEnv: generateHelmEnvs(helmConstraint),\n toolConstraints: [helmToolConstraint],\n };\n\n for (const dependency of updatedDeps) {\n if (!dependency.currentVersion) {\n continue;\n }\n\n if (dependency.newVersion === dependency.currentVersion) {\n continue;\n }\n\n if (!isNonEmptyString(dependency.depName)) {\n continue;\n }\n\n if (dependency.depType !== 'HelmChart') {\n continue;\n }\n\n let repository = null;\n\n switch (dependency.datasource) {\n case HelmDatasource.id:\n repository = dependency.registryUrls?.[0];\n break;\n case DockerDatasource.id:\n repository = dependency.packageName;\n break;\n }\n\n if (isNullOrUndefined(repository)) {\n continue;\n }\n\n await inflateHelmChart(\n isUpdateOptionInflateChartArchives,\n execOptions,\n chartHome,\n dependency.depName,\n repository,\n dependency.currentVersion,\n dependency.newVersion,\n dependency.datasource,\n );\n }\n\n const status = await getRepoStatus();\n const chartsAddition = coerceArray(status?.not_added);\n const chartsDeletion = coerceArray(status?.deleted);\n\n const fileChanges: UpdateArtifactsResult[] = [];\n\n for (const file of chartsAddition) {\n // only add artifacts in the chartHome path\n if (!file.startsWith(chartHome)) {\n continue;\n }\n fileChanges.push({\n file: {\n type: 'addition',\n path: file,\n contents: await readLocalFile(file),\n },\n });\n }\n\n for (const file of chartsDeletion) {\n // only add artifacts in the chartHome path\n if (!file.startsWith(chartHome)) {\n continue;\n }\n fileChanges.push({\n file: {\n type: 'deletion',\n path: file,\n },\n });\n }\n\n return fileChanges.length > 0 ? fileChanges : null;\n } catch (err) {\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n logger.debug({ err }, 'Failed to inflate helm chart');\n return [\n {\n artifactError: {\n stderr: err.message,\n },\n },\n ];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAsBA,eAAe,uBACb,WACA,gBACA,SACwB;CACxB,MAAM,aAAa,GAAG,eAAe,GAAG;CACxC,MAAM,OAAO,MAAM,KAAK,WAAW,UAAU;CAG7C,OAAO,MAFkB,gBAAgB,IAAI,IAEzB,OAAO;AAC7B;AAEA,SAAS,mBACP,YACA,SACA,YACQ;CACR,QAAQ,YAAR;EACE,KAAK,eAAe,IAClB,OAAO,UAAU,MAAM,UAAU,EAAE,GAAG,MAAM,OAAO;EACrD,KAAK,iBAAiB,IACpB,OAAO,MAAM,SAAS,YAAY;;EAEpC,SACE,MAAM,IAAI,MAAM,uBAAuB,YAAY;CACvD;AACF;AAEA,eAAe,iBACb,aACA,aACA,WACA,SACA,YACA,gBACA,YACA,YACe;CACf,MAAM,2BAA2B,MAAM,uBACrC,WACA,SACA,cACF;CAEA,IAAI,CAAC,eAAe,kBAAkB,wBAAwB,GAAG;EAC/D,OAAO,MACL,gCAAgC,QAAQ,qFAC1C;EACA;CACF;CAEA,IACE,iBAAiB,wBAAwB,KACzC,iBAAiB,UAAU,GAC3B;EACA,OAAO,MAAM,iCAAiC,0BAA0B;EACxE,MAAM,gBAAgB,wBAAwB;CAChD;CAEA,MAAM,gBAAgB,cAAc;CACpC,MAAM,4BAA4B,MAAM,uBACtC,WACA,SACA,aACF;CAEA,IAAI,iBAAiB,yBAAyB,GAAG;EAC/C,OAAO,MACL,cAAc,QAAQ,WAAW,cAAc,qBAAqB,2BACtE;EACA;CACF;CAEA,MAAM,aAAa,GAAG,QAAQ,GAAG;CACjC,MAAM,WAAW,MAAM,KAAK,WAAW,UAAU;CACjD,OAAO,MACL,sBAAsB,QAAQ,WAAW,cAAc,MAAM,UAC/D;CAEA,MAAM,MACJ,gCAAgC,MAAM,QAAQ,EAAE,a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AAI,CAAC,KAAK,WAAW,SAAS,GAC5B;GAEF,YAAY,KAAK,EACf,MAAM;IACJ,MAAM;IACN,MAAM;IACN,UAAU,MAAM,cAAc,IAAI;GACpC,EACF,CAAC;EACH;EAEA,KAAK,MAAM,QAAQ,gBAAgB;GAEjC,IAAI,CAAC,KAAK,WAAW,SAAS,GAC5B;GAEF,YAAY,KAAK,EACf,MAAM;IACJ,MAAM;IACN,MAAM;GACR,EACF,CAAC;EACH;EAEA,OAAO,YAAY,SAAS,IAAI,cAAc;CAChD,SAAS,KAAK;EACZ,IAAI,IAAI,YAAA,mBACN,MAAM;EAER,OAAO,MAAM,EAAE,IAAI,GAAG,8BAA8B;EACpD,OAAO,CACL,EACE,eAAe,EACb,QAAQ,IAAI,QACd,EACF,CACF;CACF;AACF"}
1
+ {"version":3,"file":"artifacts.js","names":[],"sources":["../../../../lib/modules/manager/kustomize/artifacts.ts"],"sourcesContent":["import { isNonEmptyString, isNullOrUndefined } 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 { exec } from '../../../util/exec/index.ts';\nimport type { ExecOptions, ToolConstraint } from '../../../util/exec/types.ts';\nimport {\n deleteLocalFile,\n getSiblingFileName,\n localPathExists,\n} from '../../../util/fs/index.ts';\nimport { collectFileChanges } from '../../../util/git/file-changes.ts';\nimport { getRepoStatus } from '../../../util/git/index.ts';\nimport { DockerDatasource } from '../../datasource/docker/index.ts';\nimport { HelmDatasource } from '../../datasource/helm/index.ts';\nimport type { UpdateArtifact, UpdateArtifactsResult } from '../types.ts';\nimport {\n artifactError,\n artifactErrorResult,\n fileChangesToArtifactResults,\n resolveToolConstraint,\n} from '../util.ts';\nimport { generateHelmEnvs } from './common.ts';\nimport { parseKustomize } from './extract.ts';\n\nasync function localExistingChartPath(\n chartHome: string,\n dependencyName: string,\n version?: string,\n): Promise<string | null> {\n const folderName = `${dependencyName}-${version}`;\n const path = upath.join(chartHome, folderName);\n const pathExists = await localPathExists(path);\n\n return pathExists ? path : null;\n}\n\nfunction helmRepositoryArgs(\n repository: string,\n depName: string,\n datasource?: string,\n): string {\n switch (datasource) {\n case HelmDatasource.id:\n return `--repo ${quote(repository)} ${quote(depName)}`;\n case DockerDatasource.id:\n return quote(`oci://${repository}`);\n /* v8 ignore next: should never happen */\n default:\n throw new Error(`Unknown datasource: ${datasource}`);\n }\n}\n\nasync function inflateHelmChart(\n flagEnabled: boolean,\n execOptions: ExecOptions,\n chartHome: string,\n depName: string,\n repository: string,\n currentVersion: string,\n newVersion?: string,\n datasource?: string,\n): Promise<void> {\n const currentChartExistingPath = await localExistingChartPath(\n chartHome,\n depName,\n currentVersion,\n );\n\n if (!flagEnabled && isNullOrUndefined(currentChartExistingPath)) {\n logger.debug(\n `Not inflating Helm chart for ${depName} as kustomizeInflateHelmCharts is not enabled and the current version isn't inflated`,\n );\n return;\n }\n\n if (\n isNonEmptyString(currentChartExistingPath) &&\n isNonEmptyString(newVersion)\n ) {\n logger.debug(`Deleting previous helm chart: ${currentChartExistingPath}`);\n await deleteLocalFile(currentChartExistingPath);\n }\n\n const versionToPull = newVersion ?? currentVersion;\n const versionToPullExistingPath = await localExistingChartPath(\n chartHome,\n depName,\n versionToPull,\n );\n\n if (isNonEmptyString(versionToPullExistingPath)) {\n logger.debug(\n `Helm chart ${depName} version ${versionToPull} already exists at ${versionToPullExistingPath}`,\n );\n return;\n }\n\n const folderName = `${depName}-${versionToPull}`;\n const untarDir = upath.join(chartHome, folderName);\n logger.debug(\n `Pulling helm chart ${depName} version ${versionToPull} to ${untarDir}`,\n );\n\n const cmd =\n `helm pull --untar --untardir ${quote(untarDir)} ` +\n `--version ${quote(versionToPull)} ${helmRepositoryArgs(repository, depName, datasource)}`;\n\n await exec(cmd, execOptions);\n}\n\nexport async function updateArtifacts({\n packageFileName,\n updatedDeps,\n newPackageFileContent,\n config,\n}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {\n logger.debug(`kustomize.updateArtifacts(${packageFileName})`);\n const project = parseKustomize(newPackageFileContent);\n const isUpdateOptionInflateChartArchives =\n config.postUpdateOptions?.includes('kustomizeInflateHelmCharts') === true;\n if (isNullOrUndefined(project)) {\n return [\n artifactError(undefined, 'Failed to parse new package file content'),\n ];\n }\n\n const chartHome = getSiblingFileName(\n packageFileName,\n project.helmGlobals?.chartHome ?? 'charts',\n );\n\n try {\n const helmConstraint = await resolveToolConstraint(config, 'helm');\n const helmToolConstraint: ToolConstraint = {\n toolName: 'helm',\n constraint: helmConstraint,\n };\n\n const execOptions: ExecOptions = {\n docker: {},\n extraEnv: generateHelmEnvs(helmConstraint),\n toolConstraints: [helmToolConstraint],\n };\n\n for (const dependency of updatedDeps) {\n if (!dependency.currentVersion) {\n continue;\n }\n\n if (dependency.newVersion === dependency.currentVersion) {\n continue;\n }\n\n if (!isNonEmptyString(dependency.depName)) {\n continue;\n }\n\n if (dependency.depType !== 'HelmChart') {\n continue;\n }\n\n let repository = null;\n\n switch (dependency.datasource) {\n case HelmDatasource.id:\n repository = dependency.registryUrls?.[0];\n break;\n case DockerDatasource.id:\n repository = dependency.packageName;\n break;\n }\n\n if (isNullOrUndefined(repository)) {\n continue;\n }\n\n await inflateHelmChart(\n isUpdateOptionInflateChartArchives,\n execOptions,\n chartHome,\n dependency.depName,\n repository,\n dependency.currentVersion,\n dependency.newVersion,\n dependency.datasource,\n );\n }\n\n const status = await getRepoStatus();\n const fileChanges = fileChangesToArtifactResults(\n await collectFileChanges(status, {\n include: ['not_added', 'deleted'],\n // only add artifacts in the chartHome path\n filter: (file) => file.startsWith(chartHome),\n }),\n );\n\n return fileChanges.length > 0 ? fileChanges : null;\n } catch (err) {\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n logger.debug({ err }, 'Failed to inflate helm chart');\n return artifactErrorResult(undefined, err);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AA0BA,eAAe,uBACb,WACA,gBACA,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10 +6,10 @@ import { find } from "../../../util/host-rules.js";
6
6
  import { readLocalFile, writeLocalFile } from "../../../util/fs/index.js";
7
7
  import { api } from "../../versioning/semver/index.js";
8
8
  import { exec } from "../../../util/exec/index.js";
9
- import { resolveToolConstraint } from "../util.js";
9
+ import { artifactErrorResult, resolveToolConstraint, updateLockFile } from "../util.js";
10
10
  import { findGithubToken } from "../../../util/check-token.js";
11
11
  import { getConfigType, getLockFileName } from "./lockfile.js";
12
- import { isNonEmptyStringAndNotWhitespace, isString } from "@sindresorhus/is";
12
+ import { isNonEmptyStringAndNotWhitespace } from "@sindresorhus/is";
13
13
  import { quote } from "shlex";
14
14
  import upath from "upath";
15
15
  //#region lib/modules/manager/mise/artifacts.ts
@@ -141,33 +141,24 @@ async function updateArtifacts({ packageFileName, updatedDeps, newPackageFileCon
141
141
  };
142
142
  const commands = safeMode ? [lockCmd] : [`mise trust ${quote(upath.basename(packageFileName))}`, lockCmd];
143
143
  try {
144
- await writeLocalFile(packageFileName, newPackageFileContent);
145
144
  if (newLockFileContent) await writeLocalFile(lockFileName, newLockFileContent);
146
- await exec(commands, execOptions);
147
- const refreshedLockFileContent = await readLocalFile(lockFileName, "utf8");
148
- if (!refreshedLockFileContent || originalLockFileContent === refreshedLockFileContent) return null;
149
- logger.debug({ lockFileName }, "Returning updated mise lock file");
150
- return [{ file: {
151
- type: "addition",
152
- path: lockFileName,
153
- contents: refreshedLockFileContent
154
- } }];
145
+ return await updateLockFile({
146
+ lockFileName,
147
+ existingLockFileContent: originalLockFileContent,
148
+ packageFile: {
149
+ path: packageFileName,
150
+ contents: newPackageFileContent
151
+ },
152
+ run: () => exec(commands, execOptions)
153
+ });
155
154
  } catch (err) {
156
- // istanbul ignore if: not worth testing
155
+ /* v8 ignore if -- defensive rethrow, not worth testing */
157
156
  if (err.message === "temporary-error") throw err;
158
- const errorOutput = [
159
- err.stdout,
160
- err.stderr,
161
- err.message
162
- ].filter(isString).join("\n");
163
157
  logger.warn({
164
158
  err,
165
159
  lockFileName
166
160
  }, "Error updating mise lock file");
167
- return [{ artifactError: {
168
- fileName: lockFileName,
169
- stderr: errorOutput
170
- } }];
161
+ return artifactErrorResult(lockFileName, err);
171
162
  }
172
163
  }
173
164
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"artifacts.js","names":["miseVersioning","hostRules.find"],"sources":["../../../../lib/modules/manager/mise/artifacts.ts"],"sourcesContent":["import { isNonEmptyStringAndNotWhitespace, isString } from '@sindresorhus/is';\nimport { quote } from 'shlex';\nimport upath from 'upath';\nimport { GlobalConfig } from '../../../config/global.ts';\nimport { TEMPORARY_ERROR } from '../../../constants/error-messages.ts';\nimport { logger } from '../../../logger/index.ts';\nimport { findGithubToken } from '../../../util/check-token.ts';\nimport { exec } from '../../../util/exec/index.ts';\nimport type {\n ExecOptions,\n ExtraEnv,\n ToolConstraint,\n} from '../../../util/exec/types.ts';\nimport { readLocalFile, writeLocalFile } from '../../../util/fs/index.ts';\nimport * as hostRules from '../../../util/host-rules.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { api as miseVersioning } from '../../versioning/semver/index.ts';\nimport type {\n ToolConstraintsConfig,\n UpdateArtifact,\n UpdateArtifactsResult,\n} from '../types.ts';\nimport { resolveToolConstraint } from '../util.ts';\nimport { getConfigType, getLockFileName } from './lockfile.ts';\n\n/**\n * First mise release that supports the features this manager relies on:\n * `MISE_SAFE=1` safe mode (a hard boundary against project config executing\n * code during `mise lock`) and `mise lock --bump` (advancing fuzzy selectors).\n *\n * Safe mode (jdx/mise#11146) and lockfile bumping (jdx/mise#11145) merged after\n * v2026.7.11 and first shipped in v2026.7.12.\n *\n * @see https://github.com/jdx/mise/pull/11146\n * @see https://github.com/jdx/mise/pull/11145\n * @see https://mise.jdx.dev/configuration/settings.html#safe\n */\nconst MISE_SAFE_MODE_MIN_VERSION = '2026.7.12';\n\n/**\n * Detects the mise version that will actually run, by executing `mise version`.\n * `mise version` only prints the binary's version — it does not load or execute\n * project configuration — so it is safe to run even without allowlisting.\n *\n * Output looks like `2026.7.12 macos-arm64 (2026-07-21)`; we take the leading\n * `major.minor.patch`. Returns `null` if the probe fails or cannot be parsed,\n * in which case callers fall back to the conservative (pre-safe-mode) behavior.\n */\nasync function detectMiseVersion(\n execOptions: ExecOptions,\n): Promise<string | null> {\n try {\n const { stdout } = await exec('mise version', execOptions);\n const version = regEx(/\\d+\\.\\d+\\.\\d+/).exec(stdout)?.[0];\n if (version && miseVersioning.isVersion(version)) {\n return version;\n }\n logger.debug({ stdout }, 'Could not parse mise version output');\n return null;\n } catch (err) {\n logger.debug({ err }, 'Failed to determine mise version');\n return null;\n }\n}\n\n/** True when `version` is at or above the safe-mode / `--bump` release. */\nfunction versionSupportsSafeFeatures(version: string | null): boolean {\n return (\n !!version &&\n (miseVersioning.equals(version, MISE_SAFE_MODE_MIN_VERSION) ||\n miseVersioning.isGreaterThan(version, MISE_SAFE_MODE_MIN_VERSION))\n );\n}\n\n/**\n * Resolver tools that mise may invoke while running `mise lock`, for instance to convert an inexact version like `1` against the npm registry.\n *\n * NOTE: this will install all relevant tools, regardless of what the given mise configuration uses.\n *\n * In safe mode these are unnecessary: npm version listing uses mise's built-in\n * registry HTTP client and go runs with `GOTOOLCHAIN=local`, so `mise lock`\n * resolves versions over HTTP without shelling out to node/npm/ruby.\n *\n * @see https://mise.jdx.dev/dev-tools/backends/npm.html\n * @see https://mise.jdx.dev/dev-tools/backends/go.html\n * @see https://mise.jdx.dev/dev-tools/backends/gem.html\n */\nasync function getMiseLockToolConstraints(\n config: ToolConstraintsConfig,\n miseConstraint: string | undefined,\n safeMode = false,\n): Promise<ToolConstraint[]> {\n const miseToolConstraint: ToolConstraint = {\n toolName: 'mise',\n constraint: miseConstraint,\n };\n if (safeMode) {\n return [miseToolConstraint];\n }\n return [\n miseToolConstraint,\n {\n toolName: 'node',\n constraint: await resolveToolConstraint(config, 'node'),\n },\n {\n toolName: 'npm',\n constraint: await resolveToolConstraint(config, 'npm'),\n },\n {\n // the golang tool is constrained by the `go` constraint\n toolName: 'golang',\n constraint: await resolveToolConstraint(config, 'go'),\n },\n {\n toolName: 'ruby',\n constraint: await resolveToolConstraint(config, 'ruby'),\n },\n ];\n}\n\n/**\n * Updates mise lock files when dependencies are updated.\n * Runs `mise lock` for lock file maintenance or `mise lock <tools>` for targeted updates.\n */\nexport async function updateArtifacts({\n packageFileName,\n updatedDeps,\n newPackageFileContent,\n newLockFileContent,\n config,\n}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {\n const lockFileName = getLockFileName(packageFileName);\n const originalLockFileContent = await readLocalFile(lockFileName, 'utf8');\n const currentLockFileContent = newLockFileContent ?? originalLockFileContent;\n if (!currentLockFileContent) {\n logger.debug({ lockFileName }, 'No mise lock file found');\n return null;\n }\n\n // `mise lock` normally executes the project's mise config, so it requires\n // `allowedUnsafeExecutions`. When the mise that will run supports safe mode,\n // we instead run with `MISE_SAFE=1`, which is a hard boundary against the\n // config executing code — so the allowlist is not required on that path.\n const allowlist = GlobalConfig.get('allowedUnsafeExecutions');\n const miseAllowlisted = allowlist.includes('mise');\n\n // The mise version is needed to decide safe mode (untrusted path) and\n // `mise lock --bump` (lock file maintenance). Detect it at runtime rather\n // than requiring a pinned `constraints.mise`. Skip the probe when it cannot\n // change the outcome: an allowlisted, non-maintenance run behaves the same\n // regardless of version.\n const miseConstraint = await resolveToolConstraint(config, 'mise');\n let miseSupportsSafeFeatures = false;\n if (!miseAllowlisted || config.isLockFileMaintenance) {\n const miseVersion = await detectMiseVersion({\n cwdFile: packageFileName,\n toolConstraints: [{ toolName: 'mise', constraint: miseConstraint }],\n docker: {},\n });\n miseSupportsSafeFeatures = versionSupportsSafeFeatures(miseVersion);\n }\n\n const safeMode = !miseAllowlisted && miseSupportsSafeFeatures;\n if (!miseAllowlisted && !safeMode) {\n logger.once.warn(\n { safeModeMinVersion: MISE_SAFE_MODE_MIN_VERSION },\n '`mise lock` requires either `mise` in `allowedUnsafeExecutions`, or a mise version that supports safe mode',\n );\n return null;\n }\n\n const { isLocal, env } = getConfigType(packageFileName);\n const localFlag = isLocal ? ' --local' : '';\n\n let lockCmd: string;\n if (config.isLockFileMaintenance) {\n // Lock file maintenance means \"update to the latest versions\". Plain\n // `mise lock` only refreshes metadata for already-locked versions, so use\n // `mise lock --bump` to also advance fuzzy selectors (e.g. `node = \"22\"`)\n // to the latest matching version. `--bump` requires a new enough mise, so\n // fall back to a plain refresh when the version cannot be guaranteed.\n const bumpFlag = miseSupportsSafeFeatures ? ' --bump' : '';\n lockCmd = `mise lock${localFlag}${bumpFlag}`;\n } else {\n const tools = updatedDeps\n .map(({ depName }) => depName)\n .filter(isNonEmptyStringAndNotWhitespace)\n .map(quote)\n .join(' ');\n lockCmd = tools\n ? `mise lock${localFlag} ${tools}`\n : `mise lock${localFlag}`;\n }\n\n const extraEnv: ExtraEnv = {};\n if (env) {\n extraEnv.MISE_ENV = env;\n }\n if (safeMode) {\n extraEnv.MISE_SAFE = '1';\n }\n const token = findGithubToken(\n hostRules.find({\n hostType: 'github',\n url: 'https://api.github.com/',\n }),\n );\n if (token) {\n extraEnv.GITHUB_TOKEN = token;\n }\n\n const execOptions: ExecOptions = {\n cwdFile: packageFileName,\n extraEnv,\n toolConstraints: await getMiseLockToolConstraints(\n config,\n miseConstraint,\n safeMode,\n ),\n docker: {},\n };\n\n // `mise trust` is only needed on the allowlisted path. In safe mode mise\n // loads untrusted config without a trust prompt (the config is inert — it\n // can neither execute code nor inject environment), so the trust step is\n // unnecessary and is skipped.\n const commands = safeMode\n ? [lockCmd]\n : [`mise trust ${quote(upath.basename(packageFileName))}`, lockCmd];\n\n try {\n await writeLocalFile(packageFileName, newPackageFileContent);\n if (newLockFileContent) {\n await writeLocalFile(lockFileName, newLockFileContent);\n }\n await exec(commands, execOptions);\n const refreshedLockFileContent = await readLocalFile(lockFileName, 'utf8');\n if (\n !refreshedLockFileContent ||\n originalLockFileContent === refreshedLockFileContent\n ) {\n return null;\n }\n\n logger.debug({ lockFileName }, 'Returning updated mise lock file');\n return [\n {\n file: {\n type: 'addition',\n path: lockFileName,\n contents: refreshedLockFileContent,\n },\n },\n ];\n } catch (err) {\n // istanbul ignore if: not worth testing\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n\n const errorOutput = [err.stdout, err.stderr, err.message]\n .filter(isString)\n .join('\\n');\n\n logger.warn({ err, lockFileName }, 'Error updating mise lock file');\n return [\n {\n artifactError: {\n fileName: lockFileName,\n stderr: errorOutput,\n },\n },\n ];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAM,6BAA6B;;;;;;;;;;AAWnC,eAAe,kBACb,aACwB;CACxB,IAAI;EACF,MAAM,EAAE,WAAW,MAAM,KAAK,gBAAgB,WAAW;EACzD,MAAM,UAAU,MAAM,eAAe,CAAC,CAAC,KAAK,MAAM,CAAC,GAAG;EACtD,IAAI,WAAWA,IAAe,UAAU,OAAO,GAC7C,OAAO;EAET,OAAO,MAAM,EAAE,OAAO,GAAG,qCAAqC;EAC9D,OAAO;CACT,SAAS,KAAK;EACZ,OAAO,MAAM,EAAE,IAAI,GAAG,kCAAkC;EACxD,OAAO;CACT;AACF;;AAGA,SAAS,4BAA4B,SAAiC;CACpE,OACE,CAAC,CAAC,YACDA,IAAe,OAAO,SAAS,0BAA0B,KACxDA,IAAe,cAAc,SAAS,0BAA0B;AAEtE;;;;;;;;;;;;;;AAeA,eAAe,2BACb,QACA,gBACA,WAAW,OACgB;CAC3B,MAAM,qBAAqC;EACzC,UAAU;EACV,YAAY;CACd;CACA,IAAI,UACF,OAAO,CAAC,kBAAkB;CAE5B,OAAO;EACL;EACA;GACE,UAAU;GACV,YAAY,MAAM,sBAAsB,QAAQ,MAAM;EACxD;EACA;GACE,UAAU;GACV,YAAY,MAAM,sBAAsB,QAAQ,KAAK;EACvD;EACA;GAEE,UAAU;GACV,YAAY,MAAM,sBAAsB,QAAQ,IAAI;EACtD;EACA;GACE,UAAU;GACV,YAAY,MAAM,sBAAsB,QAA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B,MAAM,cAA2B;EAC/B,SAAS;EACT;EACA,iBAAiB,MAAM,2BACrB,QACA,gBACA,QACF;EACA,QAAQ,CAAC;CACX;CAMA,MAAM,WAAW,WACb,CAAC,OAAO,IACR,CAAC,cAAc,MAAM,MAAM,SAAS,eAAe,CAAC,KAAK,OAAO;CAEpE,IAAI;EACF,MAAM,eAAe,iBAAiB,qBAAqB;EAC3D,IAAI,oBACF,MAAM,eAAe,cAAc,kBAAkB;EAEvD,MAAM,KAAK,UAAU,WAAW;EAChC,MAAM,2BAA2B,MAAM,cAAc,cAAc,MAAM;EACzE,IACE,CAAC,4BACD,4BAA4B,0BAE5B,OAAO;EAGT,OAAO,MAAM,EAAE,aAAa,GAAG,kCAAkC;EACjE,OAAO,CACL,EACE,MAAM;GACJ,MAAM;GACN,MAAM;GACN,UAAU;EACZ,EACF,CACF;CACF,SAAS,KAAK;;EAEZ,IAAI,IAAI,YAAA,mBACN,MAAM;EAGR,MAAM,cAAc;GAAC,IAAI;GAAQ,IAAI;GAAQ,IAAI;EAAO,CAAC,CACtD,OAAO,QAAQ,CAAC,CAChB,KAAK,IAAI;EAEZ,OAAO,KAAK;GAAE;GAAK;EAAa,GAAG,+BAA+B;EAClE,OAAO,CACL,EACE,eAAe;GACb,UAAU;GACV,QAAQ;EACV,EACF,CACF;CACF;AACF"}
1
+ {"version":3,"file":"artifacts.js","names":["miseVersioning","hostRules.find"],"sources":["../../../../lib/modules/manager/mise/artifacts.ts"],"sourcesContent":["import { isNonEmptyStringAndNotWhitespace } from '@sindresorhus/is';\nimport { quote } from 'shlex';\nimport upath from 'upath';\nimport { GlobalConfig } from '../../../config/global.ts';\nimport { TEMPORARY_ERROR } from '../../../constants/error-messages.ts';\nimport { logger } from '../../../logger/index.ts';\nimport { findGithubToken } from '../../../util/check-token.ts';\nimport { exec } from '../../../util/exec/index.ts';\nimport type {\n ExecOptions,\n ExtraEnv,\n ToolConstraint,\n} from '../../../util/exec/types.ts';\nimport { readLocalFile, writeLocalFile } from '../../../util/fs/index.ts';\nimport * as hostRules from '../../../util/host-rules.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { api as miseVersioning } from '../../versioning/semver/index.ts';\nimport type {\n ToolConstraintsConfig,\n UpdateArtifact,\n UpdateArtifactsResult,\n} from '../types.ts';\nimport {\n artifactErrorResult,\n resolveToolConstraint,\n updateLockFile,\n} from '../util.ts';\nimport { getConfigType, getLockFileName } from './lockfile.ts';\n\n/**\n * First mise release that supports the features this manager relies on:\n * `MISE_SAFE=1` safe mode (a hard boundary against project config executing\n * code during `mise lock`) and `mise lock --bump` (advancing fuzzy selectors).\n *\n * Safe mode (jdx/mise#11146) and lockfile bumping (jdx/mise#11145) merged after\n * v2026.7.11 and first shipped in v2026.7.12.\n *\n * @see https://github.com/jdx/mise/pull/11146\n * @see https://github.com/jdx/mise/pull/11145\n * @see https://mise.jdx.dev/configuration/settings.html#safe\n */\nconst MISE_SAFE_MODE_MIN_VERSION = '2026.7.12';\n\n/**\n * Detects the mise version that will actually run, by executing `mise version`.\n * `mise version` only prints the binary's version — it does not load or execute\n * project configuration — so it is safe to run even without allowlisting.\n *\n * Output looks like `2026.7.12 macos-arm64 (2026-07-21)`; we take the leading\n * `major.minor.patch`. Returns `null` if the probe fails or cannot be parsed,\n * in which case callers fall back to the conservative (pre-safe-mode) behavior.\n */\nasync function detectMiseVersion(\n execOptions: ExecOptions,\n): Promise<string | null> {\n try {\n const { stdout } = await exec('mise version', execOptions);\n const version = regEx(/\\d+\\.\\d+\\.\\d+/).exec(stdout)?.[0];\n if (version && miseVersioning.isVersion(version)) {\n return version;\n }\n logger.debug({ stdout }, 'Could not parse mise version output');\n return null;\n } catch (err) {\n logger.debug({ err }, 'Failed to determine mise version');\n return null;\n }\n}\n\n/** True when `version` is at or above the safe-mode / `--bump` release. */\nfunction versionSupportsSafeFeatures(version: string | null): boolean {\n return (\n !!version &&\n (miseVersioning.equals(version, MISE_SAFE_MODE_MIN_VERSION) ||\n miseVersioning.isGreaterThan(version, MISE_SAFE_MODE_MIN_VERSION))\n );\n}\n\n/**\n * Resolver tools that mise may invoke while running `mise lock`, for instance to convert an inexact version like `1` against the npm registry.\n *\n * NOTE: this will install all relevant tools, regardless of what the given mise configuration uses.\n *\n * In safe mode these are unnecessary: npm version listing uses mise's built-in\n * registry HTTP client and go runs with `GOTOOLCHAIN=local`, so `mise lock`\n * resolves versions over HTTP without shelling out to node/npm/ruby.\n *\n * @see https://mise.jdx.dev/dev-tools/backends/npm.html\n * @see https://mise.jdx.dev/dev-tools/backends/go.html\n * @see https://mise.jdx.dev/dev-tools/backends/gem.html\n */\nasync function getMiseLockToolConstraints(\n config: ToolConstraintsConfig,\n miseConstraint: string | undefined,\n safeMode = false,\n): Promise<ToolConstraint[]> {\n const miseToolConstraint: ToolConstraint = {\n toolName: 'mise',\n constraint: miseConstraint,\n };\n if (safeMode) {\n return [miseToolConstraint];\n }\n return [\n miseToolConstraint,\n {\n toolName: 'node',\n constraint: await resolveToolConstraint(config, 'node'),\n },\n {\n toolName: 'npm',\n constraint: await resolveToolConstraint(config, 'npm'),\n },\n {\n // the golang tool is constrained by the `go` constraint\n toolName: 'golang',\n constraint: await resolveToolConstraint(config, 'go'),\n },\n {\n toolName: 'ruby',\n constraint: await resolveToolConstraint(config, 'ruby'),\n },\n ];\n}\n\n/**\n * Updates mise lock files when dependencies are updated.\n * Runs `mise lock` for lock file maintenance or `mise lock <tools>` for targeted updates.\n */\nexport async function updateArtifacts({\n packageFileName,\n updatedDeps,\n newPackageFileContent,\n newLockFileContent,\n config,\n}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {\n const lockFileName = getLockFileName(packageFileName);\n const originalLockFileContent = await readLocalFile(lockFileName, 'utf8');\n const currentLockFileContent = newLockFileContent ?? originalLockFileContent;\n if (!currentLockFileContent) {\n logger.debug({ lockFileName }, 'No mise lock file found');\n return null;\n }\n\n // `mise lock` normally executes the project's mise config, so it requires\n // `allowedUnsafeExecutions`. When the mise that will run supports safe mode,\n // we instead run with `MISE_SAFE=1`, which is a hard boundary against the\n // config executing code — so the allowlist is not required on that path.\n const allowlist = GlobalConfig.get('allowedUnsafeExecutions');\n const miseAllowlisted = allowlist.includes('mise');\n\n // The mise version is needed to decide safe mode (untrusted path) and\n // `mise lock --bump` (lock file maintenance). Detect it at runtime rather\n // than requiring a pinned `constraints.mise`. Skip the probe when it cannot\n // change the outcome: an allowlisted, non-maintenance run behaves the same\n // regardless of version.\n const miseConstraint = await resolveToolConstraint(config, 'mise');\n let miseSupportsSafeFeatures = false;\n if (!miseAllowlisted || config.isLockFileMaintenance) {\n const miseVersion = await detectMiseVersion({\n cwdFile: packageFileName,\n toolConstraints: [{ toolName: 'mise', constraint: miseConstraint }],\n docker: {},\n });\n miseSupportsSafeFeatures = versionSupportsSafeFeatures(miseVersion);\n }\n\n const safeMode = !miseAllowlisted && miseSupportsSafeFeatures;\n if (!miseAllowlisted && !safeMode) {\n logger.once.warn(\n { safeModeMinVersion: MISE_SAFE_MODE_MIN_VERSION },\n '`mise lock` requires either `mise` in `allowedUnsafeExecutions`, or a mise version that supports safe mode',\n );\n return null;\n }\n\n const { isLocal, env } = getConfigType(packageFileName);\n const localFlag = isLocal ? ' --local' : '';\n\n let lockCmd: string;\n if (config.isLockFileMaintenance) {\n // Lock file maintenance means \"update to the latest versions\". Plain\n // `mise lock` only refreshes metadata for already-locked versions, so use\n // `mise lock --bump` to also advance fuzzy selectors (e.g. `node = \"22\"`)\n // to the latest matching version. `--bump` requires a new enough mise, so\n // fall back to a plain refresh when the version cannot be guaranteed.\n const bumpFlag = miseSupportsSafeFeatures ? ' --bump' : '';\n lockCmd = `mise lock${localFlag}${bumpFlag}`;\n } else {\n const tools = updatedDeps\n .map(({ depName }) => depName)\n .filter(isNonEmptyStringAndNotWhitespace)\n .map(quote)\n .join(' ');\n lockCmd = tools\n ? `mise lock${localFlag} ${tools}`\n : `mise lock${localFlag}`;\n }\n\n const extraEnv: ExtraEnv = {};\n if (env) {\n extraEnv.MISE_ENV = env;\n }\n if (safeMode) {\n extraEnv.MISE_SAFE = '1';\n }\n const token = findGithubToken(\n hostRules.find({\n hostType: 'github',\n url: 'https://api.github.com/',\n }),\n );\n if (token) {\n extraEnv.GITHUB_TOKEN = token;\n }\n\n const execOptions: ExecOptions = {\n cwdFile: packageFileName,\n extraEnv,\n toolConstraints: await getMiseLockToolConstraints(\n config,\n miseConstraint,\n safeMode,\n ),\n docker: {},\n };\n\n // `mise trust` is only needed on the allowlisted path. In safe mode mise\n // loads untrusted config without a trust prompt (the config is inert — it\n // can neither execute code nor inject environment), so the trust step is\n // unnecessary and is skipped.\n const commands = safeMode\n ? [lockCmd]\n : [`mise trust ${quote(upath.basename(packageFileName))}`, lockCmd];\n\n try {\n if (newLockFileContent) {\n await writeLocalFile(lockFileName, newLockFileContent);\n }\n return await updateLockFile({\n lockFileName,\n existingLockFileContent: originalLockFileContent,\n packageFile: { path: packageFileName, contents: newPackageFileContent },\n run: () => exec(commands, execOptions),\n });\n } catch (err) {\n /* v8 ignore if -- defensive rethrow, not worth testing */\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n\n logger.warn({ err, lockFileName }, 'Error updating mise lock file');\n return artifactErrorResult(lockFileName, err);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,MAAM,6BAA6B;;;;;;;;;;AAWnC,eAAe,kBACb,aACwB;CACxB,IAAI;EACF,MAAM,EAAE,WAAW,MAAM,KAAK,gBAAgB,WAAW;EACzD,MAAM,UAAU,MAAM,eAAe,CAAC,CAAC,KAAK,MAAM,CAAC,GAAG;EACtD,IAAI,WAAWA,IAAe,UAAU,OAAO,GAC7C,OAAO;EAET,OAAO,MAAM,EAAE,OAAO,GAAG,qCAAqC;EAC9D,OAAO;CACT,SAAS,KAAK;EACZ,OAAO,MAAM,EAAE,IAAI,GAAG,kCAAkC;EACxD,OAAO;CACT;AACF;;AAGA,SAAS,4BAA4B,SAAiC;CACpE,OACE,CAAC,CAAC,YACD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AAY,UAAU,aAAa;CAEzC,IAAI;CACJ,IAAI,OAAO,uBAOT,UAAU,YAAY,YADL,2BAA2B,YAAY;MAEnD;EACL,MAAM,QAAQ,YACX,KAAK,EAAE,cAAc,OAAO,CAAC,CAC7B,OAAO,gCAAgC,CAAC,CACxC,IAAI,KAAK,CAAC,CACV,KAAK,GAAG;EACX,UAAU,QACN,YAAY,UAAU,GAAG,UACzB,YAAY;CAClB;CAEA,MAAM,WAAqB,CAAC;CAC5B,IAAI,KACF,SAAS,WAAW;CAEtB,IAAI,UACF,SAAS,YAAY;CAEvB,MAAM,QAAQ,gBACZC,KAAe;EACb,UAAU;EACV,KAAK;CACP,CAAC,CACH;CACA,IAAI,OACF,SAAS,eAAe;CAG1B,MAAM,cAA2B;EAC/B,SAAS;EACT;EACA,iBAAiB,MAAM,2BACrB,QACA,gBACA,QACF;EACA,QAAQ,CAAC;CACX;CAMA,MAAM,WAAW,WACb,CAAC,OAAO,IACR,CAAC,cAAc,MAAM,MAAM,SAAS,eAAe,CAAC,KAAK,OAAO;CAEpE,IAAI;EACF,IAAI,oBACF,MAAM,eAAe,cAAc,kBAAkB;EAEvD,OAAO,MAAM,eAAe;GAC1B;GACA,yBAAyB;GACzB,aAAa;IAAE,MAAM;IAAiB,UAAU;GAAsB;GACtE,WAAW,KAAK,UAAU,WAAW;EACvC,CAAC;CACH,SAAS,KAAK;;EAEZ,IAAI,IAAI,YAAA,mBACN,MAAM;EAGR,OAAO,KAAK;GAAE;GAAK;EAAa,GAAG,+BAA+B;EAClE,OAAO,oBAAoB,cAAc,GAAG;CAC9C;AACF"}
@@ -5,7 +5,7 @@ import { logger } from "../../../logger/index.js";
5
5
  import { find, getAll } from "../../../util/host-rules.js";
6
6
  import { deleteLocalFile, ensureCacheDir, findLocalSiblingOrParent, getSiblingFileName, localPathExists, readLocalFile, writeLocalFile } from "../../../util/fs/index.js";
7
7
  import { exec } from "../../../util/exec/index.js";
8
- import { resolveToolConstraint } from "../util.js";
8
+ import { artifactError, artifactErrorResult, fileAddition, resolveToolConstraint } from "../util.js";
9
9
  import { isEmptyArray, isString } from "@sindresorhus/is";
10
10
  import { quote } from "shlex";
11
11
  //#region lib/modules/manager/mix/artifacts.ts
@@ -48,10 +48,7 @@ async function updateArtifacts({ packageFileName, updatedDeps, newPackageFileCon
48
48
  if (isLockFileMaintenance) await deleteLocalFile(lockFileName);
49
49
  } catch (err) {
50
50
  logger.warn({ err }, "mix.exs could not be written");
51
- return [{ artifactError: {
52
- fileName: lockFileName,
53
- stderr: err.message
54
- } }];
51
+ return artifactErrorResult(lockFileName, err);
55
52
  }
56
53
  if (!existingLockFileContent) {
57
54
  logger.debug("No mix.lock found");
@@ -114,10 +111,7 @@ async function updateArtifacts({ packageFileName, updatedDeps, newPackageFileCon
114
111
  message: err.message,
115
112
  command
116
113
  }, "Failed to update Mix lock file");
117
- return [{ artifactError: {
118
- fileName: lockFileName,
119
- stderr: err.message
120
- } }];
114
+ return artifactErrorResult(lockFileName, err);
121
115
  }
122
116
  const newMixLockContent = await readLocalFile(lockFileName, "utf8");
123
117
  if (existingLockFileContent === newMixLockContent) {
@@ -125,17 +119,10 @@ async function updateArtifacts({ packageFileName, updatedDeps, newPackageFileCon
125
119
  return null;
126
120
  }
127
121
  logger.debug("Returning updated mix.lock");
128
- return [{ file: {
129
- type: "addition",
130
- path: lockFileName,
131
- contents: newMixLockContent
132
- } }];
122
+ return [fileAddition(lockFileName, newMixLockContent)];
133
123
  }
134
124
  async function checkLockFileReadError(lockFileName) {
135
- if (await localPathExists(lockFileName)) return [{ artifactError: {
136
- fileName: lockFileName,
137
- stderr: `Error reading ${lockFileName}`
138
- } }];
125
+ if (await localPathExists(lockFileName)) return [artifactError(lockFileName, `Error reading ${lockFileName}`)];
139
126
  return null;
140
127
  }
141
128
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"artifacts.js","names":["hostRules\n .getAll","hostRules.find"],"sources":["../../../../lib/modules/manager/mix/artifacts.ts"],"sourcesContent":["import { isEmptyArray, isString } from '@sindresorhus/is';\nimport { quote } from 'shlex';\nimport { GlobalConfig } from '../../../config/global.ts';\nimport { TEMPORARY_ERROR } from '../../../constants/error-messages.ts';\nimport { logger } from '../../../logger/index.ts';\nimport { exec } from '../../../util/exec/index.ts';\nimport type { ExecOptions } from '../../../util/exec/types.ts';\nimport {\n deleteLocalFile,\n ensureCacheDir,\n findLocalSiblingOrParent,\n getSiblingFileName,\n localPathExists,\n readLocalFile,\n writeLocalFile,\n} from '../../../util/fs/index.ts';\nimport * as hostRules from '../../../util/host-rules.ts';\nimport { regEx } from '../../../util/regex.ts';\n\nimport type { UpdateArtifact, UpdateArtifactsResult } from '../types.ts';\nimport { resolveToolConstraint } from '../util.ts';\n\nconst hexRepoUrl = 'https://hex.pm/';\nconst hexRepoOrgUrlRegex = regEx(\n `^https://hex\\\\.pm/api/repos/(?<organization>[a-z0-9_]+)/$`,\n);\n\nexport async function updateArtifacts({\n packageFileName,\n updatedDeps,\n newPackageFileContent,\n config,\n}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {\n logger.debug(`mix.getArtifacts(${packageFileName})`);\n const { isLockFileMaintenance } = config;\n\n if (isEmptyArray(updatedDeps) && !isLockFileMaintenance) {\n logger.debug('No updated mix deps');\n return null;\n }\n\n let lockFileName = getSiblingFileName(packageFileName, 'mix.lock');\n let isUmbrella = false;\n\n let existingLockFileContent = await readLocalFile(lockFileName, 'utf8');\n if (!existingLockFileContent) {\n const lockFileError = await checkLockFileReadError(lockFileName);\n if (lockFileError) {\n return lockFileError;\n }\n\n const parentLockFileName = await findLocalSiblingOrParent(\n packageFileName,\n 'mix.lock',\n );\n existingLockFileContent =\n parentLockFileName && (await readLocalFile(parentLockFileName, 'utf8'));\n\n if (parentLockFileName && existingLockFileContent) {\n lockFileName = parentLockFileName;\n isUmbrella = true;\n } else if (parentLockFileName) {\n const lockFileError = await checkLockFileReadError(parentLockFileName);\n // v8 ignore else -- needs an umbrella parent lock file that reads cleanly\n if (lockFileError) {\n return lockFileError;\n }\n }\n }\n\n if (isLockFileMaintenance && isUmbrella) {\n logger.debug(\n `Cannot use lockFileMaintenance in an umbrella project, see ${GlobalConfig.get('productLinks').documentation}modules/manager/mix/#lockFileMaintenance`,\n );\n return null;\n }\n\n if (isLockFileMaintenance && !existingLockFileContent) {\n logger.debug(\n 'Cannot use lockFileMaintenance when no mix.lock file is present',\n );\n return null;\n }\n\n try {\n await writeLocalFile(packageFileName, newPackageFileContent);\n if (isLockFileMaintenance) {\n await deleteLocalFile(lockFileName);\n }\n } catch (err) {\n logger.warn({ err }, 'mix.exs could not be written');\n return [\n {\n artifactError: {\n fileName: lockFileName,\n stderr: err.message,\n },\n },\n ];\n }\n\n if (!existingLockFileContent) {\n logger.debug('No mix.lock found');\n return null;\n }\n\n const organizations = new Set<string>();\n\n const hexHostRulesWithMatchHost = hostRules\n .getAll()\n .filter(\n (hostRule) =>\n !!hostRule.matchHost && hexRepoOrgUrlRegex.test(hostRule.matchHost),\n );\n\n for (const { matchHost } of hexHostRulesWithMatchHost) {\n // v8 ignore else -- the filter above already required a match host\n if (matchHost) {\n const result = hexRepoOrgUrlRegex.exec(matchHost);\n\n // v8 ignore else -- the same regex already matched in that filter\n if (result?.groups) {\n const { organization } = result.groups;\n organizations.add(organization);\n }\n }\n }\n\n for (const { packageName } of updatedDeps) {\n if (packageName) {\n const [, organization] = packageName.split(':');\n\n // v8 ignore else -- needs an updated dep whose name carries no organization\n if (organization) {\n organizations.add(organization);\n }\n }\n }\n\n const preCommands = Array.from(organizations).reduce((acc, organization) => {\n const url = `${hexRepoUrl}api/repos/${organization}/`;\n const { token } = hostRules.find({ url });\n\n if (token) {\n logger.debug(`Authenticating to hex organization ${organization}`);\n const authCommand = `mix hex.organization auth ${quote(organization)} --key ${quote(token)}`;\n return [...acc, authCommand];\n }\n\n return acc;\n }, [] as string[]);\n\n // renovate: will update this\n const erlangVersion = '26';\n\n const execOptions: ExecOptions = {\n extraEnv: {\n // https://hexdocs.pm/mix/1.15.0/Mix.Tasks.Archive.html\n // TODO: should include a version constraint\n MIX_ARCHIVES: await ensureCacheDir('mix_archives'),\n },\n cwdFile: lockFileName,\n docker: {},\n toolConstraints: [\n {\n toolName: 'erlang',\n // https://hexdocs.pm/elixir/1.14.5/compatibility-and-deprecations.html#compatibility-between-elixir-and-erlang-otp\n constraint:\n (await resolveToolConstraint(config, 'erlang')) ??\n `^${erlangVersion}`,\n },\n {\n toolName: 'elixir',\n constraint: await resolveToolConstraint(config, 'elixir'),\n },\n ],\n preCommands,\n };\n\n let command: string;\n if (isLockFileMaintenance) {\n command = 'mix deps.get';\n } else {\n command = [\n 'mix',\n 'deps.update',\n ...updatedDeps\n .map((dep) => dep.depName)\n .filter(isString)\n .map((dep) => quote(dep)),\n ].join(' ');\n }\n\n try {\n await exec(command, execOptions);\n } catch (err) {\n /* v8 ignore if -- defensive rethrow of TEMPORARY_ERROR from exec, not reproduced in mix specs */\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n\n logger.debug(\n { err, message: err.message, command },\n 'Failed to update Mix lock file',\n );\n\n return [\n {\n artifactError: {\n fileName: lockFileName,\n stderr: err.message,\n },\n },\n ];\n }\n\n const newMixLockContent = await readLocalFile(lockFileName, 'utf8');\n if (existingLockFileContent === newMixLockContent) {\n logger.debug('mix.lock is unchanged');\n return null;\n }\n logger.debug('Returning updated mix.lock');\n return [\n {\n file: {\n type: 'addition',\n path: lockFileName,\n contents: newMixLockContent,\n },\n },\n ];\n}\n\nasync function checkLockFileReadError(\n lockFileName: string,\n): Promise<UpdateArtifactsResult[] | null> {\n if (await localPathExists(lockFileName)) {\n return [\n {\n artifactError: {\n fileName: lockFileName,\n stderr: `Error reading ${lockFileName}`,\n },\n },\n ];\n }\n return null;\n}\n"],"mappings":";;;;;;;;;;;AAsBA,MAAM,aAAa;AACnB,MAAM,qBAAqB,MACzB,2DACF;AAEA,eAAsB,gBAAgB,EACpC,iBACA,aACA,uBACA,UAC0D;CAC1D,OAAO,MAAM,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AS,IAAI;GAAS;EAAQ,GACrC,gCACF;EAEA,OAAO,CACL,EACE,eAAe;GACb,UAAU;GACV,QAAQ,IAAI;EACd,EACF,CACF;CACF;CAEA,MAAM,oBAAoB,MAAM,cAAc,cAAc,MAAM;CAClE,IAAI,4BAA4B,mBAAmB;EACjD,OAAO,MAAM,uBAAuB;EACpC,OAAO;CACT;CACA,OAAO,MAAM,4BAA4B;CACzC,OAAO,CACL,EACE,MAAM;EACJ,MAAM;EACN,MAAM;EACN,UAAU;CACZ,EACF,CACF;AACF;AAEA,eAAe,uBACb,cACyC;CACzC,IAAI,MAAM,gBAAgB,YAAY,GACpC,OAAO,CACL,EACE,eAAe;EACb,UAAU;EACV,QAAQ,iBAAiB;CAC3B,EACF,CACF;CAEF,OAAO;AACT"}
1
+ {"version":3,"file":"artifacts.js","names":["hostRules\n .getAll","hostRules.find"],"sources":["../../../../lib/modules/manager/mix/artifacts.ts"],"sourcesContent":["import { isEmptyArray, isString } from '@sindresorhus/is';\nimport { quote } from 'shlex';\nimport { GlobalConfig } from '../../../config/global.ts';\nimport { TEMPORARY_ERROR } from '../../../constants/error-messages.ts';\nimport { logger } from '../../../logger/index.ts';\nimport { exec } from '../../../util/exec/index.ts';\nimport type { ExecOptions } from '../../../util/exec/types.ts';\nimport {\n deleteLocalFile,\n ensureCacheDir,\n findLocalSiblingOrParent,\n getSiblingFileName,\n localPathExists,\n readLocalFile,\n writeLocalFile,\n} from '../../../util/fs/index.ts';\nimport * as hostRules from '../../../util/host-rules.ts';\nimport { regEx } from '../../../util/regex.ts';\n\nimport type { UpdateArtifact, UpdateArtifactsResult } from '../types.ts';\nimport {\n artifactError,\n artifactErrorResult,\n fileAddition,\n resolveToolConstraint,\n} from '../util.ts';\n\nconst hexRepoUrl = 'https://hex.pm/';\nconst hexRepoOrgUrlRegex = regEx(\n `^https://hex\\\\.pm/api/repos/(?<organization>[a-z0-9_]+)/$`,\n);\n\nexport async function updateArtifacts({\n packageFileName,\n updatedDeps,\n newPackageFileContent,\n config,\n}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {\n logger.debug(`mix.getArtifacts(${packageFileName})`);\n const { isLockFileMaintenance } = config;\n\n if (isEmptyArray(updatedDeps) && !isLockFileMaintenance) {\n logger.debug('No updated mix deps');\n return null;\n }\n\n let lockFileName = getSiblingFileName(packageFileName, 'mix.lock');\n let isUmbrella = false;\n\n let existingLockFileContent = await readLocalFile(lockFileName, 'utf8');\n if (!existingLockFileContent) {\n const lockFileError = await checkLockFileReadError(lockFileName);\n if (lockFileError) {\n return lockFileError;\n }\n\n const parentLockFileName = await findLocalSiblingOrParent(\n packageFileName,\n 'mix.lock',\n );\n existingLockFileContent =\n parentLockFileName && (await readLocalFile(parentLockFileName, 'utf8'));\n\n if (parentLockFileName && existingLockFileContent) {\n lockFileName = parentLockFileName;\n isUmbrella = true;\n } else if (parentLockFileName) {\n const lockFileError = await checkLockFileReadError(parentLockFileName);\n // v8 ignore else -- needs an umbrella parent lock file that reads cleanly\n if (lockFileError) {\n return lockFileError;\n }\n }\n }\n\n if (isLockFileMaintenance && isUmbrella) {\n logger.debug(\n `Cannot use lockFileMaintenance in an umbrella project, see ${GlobalConfig.get('productLinks').documentation}modules/manager/mix/#lockFileMaintenance`,\n );\n return null;\n }\n\n if (isLockFileMaintenance && !existingLockFileContent) {\n logger.debug(\n 'Cannot use lockFileMaintenance when no mix.lock file is present',\n );\n return null;\n }\n\n try {\n await writeLocalFile(packageFileName, newPackageFileContent);\n if (isLockFileMaintenance) {\n await deleteLocalFile(lockFileName);\n }\n } catch (err) {\n logger.warn({ err }, 'mix.exs could not be written');\n return artifactErrorResult(lockFileName, err);\n }\n\n if (!existingLockFileContent) {\n logger.debug('No mix.lock found');\n return null;\n }\n\n const organizations = new Set<string>();\n\n const hexHostRulesWithMatchHost = hostRules\n .getAll()\n .filter(\n (hostRule) =>\n !!hostRule.matchHost && hexRepoOrgUrlRegex.test(hostRule.matchHost),\n );\n\n for (const { matchHost } of hexHostRulesWithMatchHost) {\n // v8 ignore else -- the filter above already required a match host\n if (matchHost) {\n const result = hexRepoOrgUrlRegex.exec(matchHost);\n\n // v8 ignore else -- the same regex already matched in that filter\n if (result?.groups) {\n const { organization } = result.groups;\n organizations.add(organization);\n }\n }\n }\n\n for (const { packageName } of updatedDeps) {\n if (packageName) {\n const [, organization] = packageName.split(':');\n\n // v8 ignore else -- needs an updated dep whose name carries no organization\n if (organization) {\n organizations.add(organization);\n }\n }\n }\n\n const preCommands = Array.from(organizations).reduce((acc, organization) => {\n const url = `${hexRepoUrl}api/repos/${organization}/`;\n const { token } = hostRules.find({ url });\n\n if (token) {\n logger.debug(`Authenticating to hex organization ${organization}`);\n const authCommand = `mix hex.organization auth ${quote(organization)} --key ${quote(token)}`;\n return [...acc, authCommand];\n }\n\n return acc;\n }, [] as string[]);\n\n // renovate: will update this\n const erlangVersion = '26';\n\n const execOptions: ExecOptions = {\n extraEnv: {\n // https://hexdocs.pm/mix/1.15.0/Mix.Tasks.Archive.html\n // TODO: should include a version constraint\n MIX_ARCHIVES: await ensureCacheDir('mix_archives'),\n },\n cwdFile: lockFileName,\n docker: {},\n toolConstraints: [\n {\n toolName: 'erlang',\n // https://hexdocs.pm/elixir/1.14.5/compatibility-and-deprecations.html#compatibility-between-elixir-and-erlang-otp\n constraint:\n (await resolveToolConstraint(config, 'erlang')) ??\n `^${erlangVersion}`,\n },\n {\n toolName: 'elixir',\n constraint: await resolveToolConstraint(config, 'elixir'),\n },\n ],\n preCommands,\n };\n\n let command: string;\n if (isLockFileMaintenance) {\n command = 'mix deps.get';\n } else {\n command = [\n 'mix',\n 'deps.update',\n ...updatedDeps\n .map((dep) => dep.depName)\n .filter(isString)\n .map((dep) => quote(dep)),\n ].join(' ');\n }\n\n try {\n await exec(command, execOptions);\n } catch (err) {\n /* v8 ignore if -- defensive rethrow of TEMPORARY_ERROR from exec, not reproduced in mix specs */\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n\n logger.debug(\n { err, message: err.message, command },\n 'Failed to update Mix lock file',\n );\n\n return artifactErrorResult(lockFileName, err);\n }\n\n const newMixLockContent = await readLocalFile(lockFileName, 'utf8');\n if (existingLockFileContent === newMixLockContent) {\n logger.debug('mix.lock is unchanged');\n return null;\n }\n logger.debug('Returning updated mix.lock');\n return [fileAddition(lockFileName, newMixLockContent)];\n}\n\nasync function checkLockFileReadError(\n lockFileName: string,\n): Promise<UpdateArtifactsResult[] | null> {\n if (await localPathExists(lockFileName)) {\n return [artifactError(lockFileName, `Error reading ${lockFileName}`)];\n }\n return null;\n}\n"],"mappings":";;;;;;;;;;;AA2BA,MAAM,aAAa;AACnB,MAAM,qBAAqB,MACzB,2DACF;AAEA,eAAsB,gBAAgB,EACpC,iBACA,aACA,uBACA,UAC0D;CAC1D,OAAO,MAAM,oBAAoB,gBAAgB,EAAE;CACnD,MAAM,EAAE,0BAA0B;CAElC,IAAI,aAAa,WAAW,KAAK,CAAC,uBAAuB;EACvD,OAAO,MAAM,qBAAqB;EAClC,OAAO;CACT;CAEA,IAAI,eAAe,mBAAmB,iBAAiB,UAAU;CACjE,IAAI,aAAa;CAEjB,IAAI,0BAA0B,MAAM,cAAc,cAAc,MAAM;CACtE,IAAI,CAAC,yBAAyB;EAC5B,MAAM,gBAAgB,MAAM,uBAAuB,YAAY;EAC/D,IAAI,eACF,OAAO;EAGT,MAAM,qBAAqB,MAAM,yBAC/B,iBACA,UACF;EACA,0BACE,sBAAuB,MAAM,cAAc,oBAAoB,MAAM;EAEvE,IAAI,sBAAsB,yBAAyB;GACjD,eAAe;GACf,aAAa;EACf,OAAO,IAAI,oBAAoB;GAC7B,MAAM,gBAAgB,MAAM,uBAAuB,kBAAkB;;GAErE,IAAI,eACF,OAAO;EAEX;CACF;CAEA,IAAI,yBAAyB,YAAY;EACvC,OAAO,MACL,8DAA8D,aAAa,IAAI,cAAc,CAAC,CAAC,cAAc,yCAC/G;EACA,OAAO;CACT;CAEA,IAAI,yBAAyB,CAAC,yBAAyB;EACrD,OA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AEV,YACG,MAAM,sBAAsB,QAAQ,QAAQ,KAC7C;EACJ,GACA;GACE,UAAU;GACV,YAAY,MAAM,sBAAsB,QAAQ,QAAQ;EAC1D,CACF;EACA;CACF;CAEA,IAAI;CACJ,IAAI,uBACF,UAAU;MAEV,UAAU;EACR;EACA;EACA,GAAG,YACA,KAAK,QAAQ,IAAI,OAAO,CAAC,CACzB,OAAO,QAAQ,CAAC,CAChB,KAAK,QAAQ,MAAM,GAAG,CAAC;CAC5B,CAAC,CAAC,KAAK,GAAG;CAGZ,IAAI;EACF,MAAM,KAAK,SAAS,WAAW;CACjC,SAAS,KAAK;;EAEZ,IAAI,IAAI,YAAA,mBACN,MAAM;EAGR,OAAO,MACL;GAAE;GAAK,SAAS,IAAI;GAAS;EAAQ,GACrC,gCACF;EAEA,OAAO,oBAAoB,cAAc,GAAG;CAC9C;CAEA,MAAM,oBAAoB,MAAM,cAAc,cAAc,MAAM;CAClE,IAAI,4BAA4B,mBAAmB;EACjD,OAAO,MAAM,uBAAuB;EACpC,OAAO;CACT;CACA,OAAO,MAAM,4BAA4B;CACzC,OAAO,CAAC,aAAa,cAAc,iBAAiB,CAAC;AACvD;AAEA,eAAe,uBACb,cACyC;CACzC,IAAI,MAAM,gBAAgB,YAAY,GACpC,OAAO,CAAC,cAAc,cAAc,iBAAiB,cAAc,CAAC;CAEtE,OAAO;AACT"}
@@ -6,7 +6,7 @@ import { ensureDir, getLocalFiles, getSiblingFileName, outputCacheFile, privateC
6
6
  import { exec } from "../../../util/exec/index.js";
7
7
  import { getFiles } from "../../../util/git/index.js";
8
8
  import { findGlobalJson, getConfiguredRegistries, getDefaultRegistries } from "./util.js";
9
- import { resolveToolConstraint } from "../util.js";
9
+ import { artifactErrorResult, fileAddition, resolveToolConstraint } from "../util.js";
10
10
  import { createNuGetConfigXml } from "./config-formatter.js";
11
11
  import { GLOBAL_JSON, getDependentPackageFiles } from "./package-tree.js";
12
12
  import { isNonEmptyString } from "@sindresorhus/is";
@@ -70,19 +70,12 @@ async function updateArtifacts({ packageFileName, newPackageFileContent, config,
70
70
  const newLockFileContentMap = await getLocalFiles(lockFileNames);
71
71
  const retArray = [];
72
72
  for (const lockFileName of lockFileNames) if (existingLockFileContentMap[lockFileName] === newLockFileContentMap[lockFileName]) logger.trace(`Lock file ${lockFileName} is unchanged`);
73
- else if (newLockFileContentMap[lockFileName]) retArray.push({ file: {
74
- type: "addition",
75
- path: lockFileName,
76
- contents: newLockFileContentMap[lockFileName]
77
- } });
73
+ else if (newLockFileContentMap[lockFileName]) retArray.push(fileAddition(lockFileName, newLockFileContentMap[lockFileName]));
78
74
  return retArray.length > 0 ? retArray : null;
79
75
  } catch (err) {
80
76
  if (err.message === "temporary-error") throw err;
81
77
  logger.debug({ err }, "Failed to generate lock file");
82
- return [{ artifactError: {
83
- fileName: lockFileNames.join(", "),
84
- stderr: err.stdout ?? err.message
85
- } }];
78
+ return artifactErrorResult(lockFileNames.join(", "), err);
86
79
  }
87
80
  }
88
81
  //#endregion