renovate 44.90.3 → 44.91.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.
- package/dist/config/options/index.js +1 -1
- package/dist/config/options/index.js.map +1 -1
- package/dist/global-config-option-defaults.generated.js +1 -1
- package/dist/global-config-option-defaults.generated.js.map +1 -1
- package/dist/modules/manager/ansible-galaxy/collections.js +4 -6
- package/dist/modules/manager/ansible-galaxy/collections.js.map +1 -1
- package/dist/modules/manager/azure-pipelines/extract.js +1 -0
- package/dist/modules/manager/azure-pipelines/extract.js.map +1 -1
- package/dist/modules/manager/bazel/artifacts.js +5 -1
- package/dist/modules/manager/bazel/artifacts.js.map +1 -1
- package/dist/modules/manager/bazel/parser.js +15 -0
- package/dist/modules/manager/bazel/parser.js.map +1 -1
- package/dist/modules/manager/bazel/rules/http.js.map +1 -1
- package/dist/modules/manager/bundler/common.js +1 -0
- package/dist/modules/manager/bundler/common.js.map +1 -1
- package/dist/modules/manager/cargo/artifacts.js +2 -0
- package/dist/modules/manager/cargo/artifacts.js.map +1 -1
- package/dist/modules/manager/cargo/extract.js.map +1 -1
- package/dist/modules/manager/cocoapods/extract.js +3 -0
- package/dist/modules/manager/cocoapods/extract.js.map +1 -1
- package/dist/modules/manager/composer/artifacts.js +1 -0
- package/dist/modules/manager/composer/artifacts.js.map +1 -1
- package/dist/modules/manager/composer/schema.js.map +1 -1
- package/dist/modules/manager/cpanfile/parser.js +2 -0
- package/dist/modules/manager/cpanfile/parser.js.map +1 -1
- package/dist/modules/manager/deps-edn/extract.js +3 -1
- package/dist/modules/manager/deps-edn/extract.js.map +1 -1
- package/dist/modules/manager/droneci/extract.js +4 -6
- package/dist/modules/manager/droneci/extract.js.map +1 -1
- package/dist/modules/manager/fingerprint.generated.js +11 -11
- package/dist/modules/manager/fingerprint.generated.js.map +1 -1
- package/dist/modules/manager/flux/extract.js +1 -0
- package/dist/modules/manager/flux/extract.js.map +1 -1
- package/dist/modules/manager/github-actions/extract.js +3 -0
- package/dist/modules/manager/github-actions/extract.js.map +1 -1
- package/dist/modules/manager/github-actions/known-actions.js +38 -2
- package/dist/modules/manager/github-actions/known-actions.js.map +1 -1
- package/dist/modules/manager/gitlabci/extract.js +1 -0
- package/dist/modules/manager/gitlabci/extract.js.map +1 -1
- package/dist/modules/manager/glasskube/extract.js +2 -0
- package/dist/modules/manager/glasskube/extract.js.map +1 -1
- package/dist/modules/manager/gomod/artifacts-extra.js +1 -0
- package/dist/modules/manager/gomod/artifacts-extra.js.map +1 -1
- package/dist/modules/manager/gomod/artifacts.js +1 -0
- package/dist/modules/manager/gomod/artifacts.js.map +1 -1
- package/dist/modules/manager/gomod/extract.js +1 -0
- package/dist/modules/manager/gomod/extract.js.map +1 -1
- package/dist/modules/manager/gradle/artifacts.js +1 -1
- package/dist/modules/manager/gradle/artifacts.js.map +1 -1
- package/dist/modules/manager/gradle-wrapper/utils.js +1 -0
- package/dist/modules/manager/gradle-wrapper/utils.js.map +1 -1
- package/dist/modules/manager/npm/extract/common/dependency.js +2 -1
- package/dist/modules/manager/npm/extract/common/dependency.js.map +1 -1
- package/dist/modules/manager/pep621/extract.js +1 -2
- package/dist/modules/manager/pep621/extract.js.map +1 -1
- package/dist/modules/manager/quadlet/extract.js +2 -4
- package/dist/modules/manager/quadlet/extract.js.map +1 -1
- package/dist/modules/manager/swift/artifacts.js +3 -1
- package/dist/modules/manager/swift/artifacts.js.map +1 -1
- package/dist/modules/manager/swift/extract.js +1 -0
- package/dist/modules/manager/swift/extract.js.map +1 -1
- package/dist/modules/manager/terraform/extractors/others/modules.js.map +1 -1
- package/dist/modules/manager/terraform/lockfile/index.js +1 -0
- package/dist/modules/manager/terraform/lockfile/index.js.map +1 -1
- package/dist/modules/manager/terragrunt/extract.js +1 -0
- package/dist/modules/manager/terragrunt/extract.js.map +1 -1
- package/dist/modules/manager/tflint-plugin/extract.js +1 -0
- package/dist/modules/manager/tflint-plugin/extract.js.map +1 -1
- package/dist/modules/manager/tflint-plugin/plugins.js.map +1 -1
- package/package.json +1 -1
- package/renovate-schema.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract.js","names":[],"sources":["../../../../lib/modules/manager/glasskube/extract.ts"],"sourcesContent":["import { isFalsy } from '@sindresorhus/is';\nimport { readLocalFile } from '../../../util/fs/index.ts';\nimport { parseYaml } from '../../../util/yaml.ts';\nimport { GlasskubePackagesDatasource } from '../../datasource/glasskube-packages/index.ts';\nimport type {\n ExtractConfig,\n PackageDependency,\n PackageFile,\n PackageFileContent,\n} from '../types.ts';\nimport {\n GlasskubeResource,\n type Package,\n type PackageRepository,\n} from './schema.ts';\nimport type { GlasskubeResources } from './types.ts';\n\nfunction parseResources(\n content: string,\n packageFile: string,\n): GlasskubeResources {\n const resources: GlasskubeResource[] = parseYaml(content, {\n customSchema: GlasskubeResource,\n failureBehaviour: 'filter',\n });\n\n const packages: Package[] = [];\n const repositories: PackageRepository[] = [];\n\n for (const resource of resources) {\n if (resource.kind === 'ClusterPackage' || resource.kind === 'Package') {\n packages.push(resource);\n } else if (resource.kind === 'PackageRepository') {\n repositories.push(resource);\n }\n }\n\n return { packageFile, repositories, packages };\n}\n\nfunction resolvePackageDependencies(\n packages: Package[],\n repositories: PackageRepository[],\n): PackageDependency[] {\n const deps: PackageDependency[] = [];\n for (const pkg of packages) {\n const dep: PackageDependency = {\n depName: pkg.spec.packageInfo.name,\n currentValue: pkg.spec.packageInfo.version,\n datasource: GlasskubePackagesDatasource.id,\n };\n\n const repository = findRepository(\n pkg.spec.packageInfo.repositoryName ?? null,\n repositories,\n );\n\n if (repository === null) {\n dep.skipReason = 'unknown-registry';\n } else {\n dep.registryUrls = [repository.spec.url];\n }\n\n deps.push(dep);\n }\n return deps;\n}\n\nfunction findRepository(\n name: string | null,\n repositories: PackageRepository[],\n): PackageRepository | null {\n for (const repository of repositories) {\n if (name === repository.metadata.name) {\n return repository;\n }\n if (isFalsy(name) && isDefaultRepository(repository)) {\n return repository;\n }\n }\n return null;\n}\n\nfunction isDefaultRepository(repository: PackageRepository): boolean {\n return (\n repository.metadata.annotations?.[\n 'packages.glasskube.dev/default-repository'\n ] === 'true'\n );\n}\n\nexport function extractPackageFile(\n content: string,\n packageFile: string,\n _config?: ExtractConfig,\n): PackageFileContent | null {\n const { packages, repositories } = parseResources(content, packageFile);\n const deps = resolvePackageDependencies(packages, repositories);\n return { deps };\n}\n\nexport async function extractAllPackageFiles(\n _config: ExtractConfig,\n packageFiles: string[],\n): Promise<PackageFile[] | null> {\n const allRepositories: PackageRepository[] = [];\n const glasskubeResourceFiles: GlasskubeResources[] = [];\n for (const packageFile of packageFiles) {\n const content = await readLocalFile(packageFile, 'utf8');\n if (content !== null) {\n const resources = parseResources(content, packageFile);\n allRepositories.push(...resources.repositories);\n glasskubeResourceFiles.push(resources);\n }\n }\n\n const result: PackageFile[] = [];\n for (const file of glasskubeResourceFiles) {\n const deps = resolvePackageDependencies(file.packages, allRepositories);\n if (deps.length > 0) {\n result.push({ packageFile: file.packageFile, deps });\n }\n }\n return result.length ? result : null;\n}\n"],"mappings":";;;;;;AAiBA,SAAS,eACP,SACA,aACoB;CACpB,MAAM,YAAiC,UAAU,SAAS;EACxD,cAAc;EACd,kBAAkB;CACpB,CAAC;CAED,MAAM,WAAsB,CAAC;CAC7B,MAAM,eAAoC,CAAC;CAE3C,KAAK,MAAM,YAAY,WACrB,IAAI,SAAS,SAAS,oBAAoB,SAAS,SAAS,WAC1D,SAAS,KAAK,QAAQ;
|
|
1
|
+
{"version":3,"file":"extract.js","names":[],"sources":["../../../../lib/modules/manager/glasskube/extract.ts"],"sourcesContent":["import { isFalsy } from '@sindresorhus/is';\nimport { readLocalFile } from '../../../util/fs/index.ts';\nimport { parseYaml } from '../../../util/yaml.ts';\nimport { GlasskubePackagesDatasource } from '../../datasource/glasskube-packages/index.ts';\nimport type {\n ExtractConfig,\n PackageDependency,\n PackageFile,\n PackageFileContent,\n} from '../types.ts';\nimport {\n GlasskubeResource,\n type Package,\n type PackageRepository,\n} from './schema.ts';\nimport type { GlasskubeResources } from './types.ts';\n\nfunction parseResources(\n content: string,\n packageFile: string,\n): GlasskubeResources {\n const resources: GlasskubeResource[] = parseYaml(content, {\n customSchema: GlasskubeResource,\n failureBehaviour: 'filter',\n });\n\n const packages: Package[] = [];\n const repositories: PackageRepository[] = [];\n\n for (const resource of resources) {\n if (resource.kind === 'ClusterPackage' || resource.kind === 'Package') {\n packages.push(resource);\n // NOTE: the schema only parses these two kinds, so the implicit else\n // never runs. A coverage-ignore hint cannot suppress it on an `else if`.\n } else if (resource.kind === 'PackageRepository') {\n repositories.push(resource);\n }\n }\n\n return { packageFile, repositories, packages };\n}\n\nfunction resolvePackageDependencies(\n packages: Package[],\n repositories: PackageRepository[],\n): PackageDependency[] {\n const deps: PackageDependency[] = [];\n for (const pkg of packages) {\n const dep: PackageDependency = {\n depName: pkg.spec.packageInfo.name,\n currentValue: pkg.spec.packageInfo.version,\n datasource: GlasskubePackagesDatasource.id,\n };\n\n const repository = findRepository(\n pkg.spec.packageInfo.repositoryName ?? null,\n repositories,\n );\n\n if (repository === null) {\n dep.skipReason = 'unknown-registry';\n } else {\n dep.registryUrls = [repository.spec.url];\n }\n\n deps.push(dep);\n }\n return deps;\n}\n\nfunction findRepository(\n name: string | null,\n repositories: PackageRepository[],\n): PackageRepository | null {\n for (const repository of repositories) {\n if (name === repository.metadata.name) {\n return repository;\n }\n // v8 ignore else -- needs a manifest whose repositories match no name\n if (isFalsy(name) && isDefaultRepository(repository)) {\n return repository;\n }\n }\n return null;\n}\n\nfunction isDefaultRepository(repository: PackageRepository): boolean {\n return (\n repository.metadata.annotations?.[\n 'packages.glasskube.dev/default-repository'\n ] === 'true'\n );\n}\n\nexport function extractPackageFile(\n content: string,\n packageFile: string,\n _config?: ExtractConfig,\n): PackageFileContent | null {\n const { packages, repositories } = parseResources(content, packageFile);\n const deps = resolvePackageDependencies(packages, repositories);\n return { deps };\n}\n\nexport async function extractAllPackageFiles(\n _config: ExtractConfig,\n packageFiles: string[],\n): Promise<PackageFile[] | null> {\n const allRepositories: PackageRepository[] = [];\n const glasskubeResourceFiles: GlasskubeResources[] = [];\n for (const packageFile of packageFiles) {\n const content = await readLocalFile(packageFile, 'utf8');\n // v8 ignore else -- needs a listed package file that cannot be read\n if (content !== null) {\n const resources = parseResources(content, packageFile);\n allRepositories.push(...resources.repositories);\n glasskubeResourceFiles.push(resources);\n }\n }\n\n const result: PackageFile[] = [];\n for (const file of glasskubeResourceFiles) {\n const deps = resolvePackageDependencies(file.packages, allRepositories);\n if (deps.length > 0) {\n result.push({ packageFile: file.packageFile, deps });\n }\n }\n return result.length ? result : null;\n}\n"],"mappings":";;;;;;AAiBA,SAAS,eACP,SACA,aACoB;CACpB,MAAM,YAAiC,UAAU,SAAS;EACxD,cAAc;EACd,kBAAkB;CACpB,CAAC;CAED,MAAM,WAAsB,CAAC;CAC7B,MAAM,eAAoC,CAAC;CAE3C,KAAK,MAAM,YAAY,WACrB,IAAI,SAAS,SAAS,oBAAoB,SAAS,SAAS,WAC1D,SAAS,KAAK,QAAQ;MAGjB,IAAI,SAAS,SAAS,qBAC3B,aAAa,KAAK,QAAQ;CAI9B,OAAO;EAAE;EAAa;EAAc;CAAS;AAC/C;AAEA,SAAS,2BACP,UACA,cACqB;CACrB,MAAM,OAA4B,CAAC;CACnC,KAAK,MAAM,OAAO,UAAU;EAC1B,MAAM,MAAyB;GAC7B,SAAS,IAAI,KAAK,YAAY;GAC9B,cAAc,IAAI,KAAK,YAAY;GACnC,YAAY,4BAA4B;EAC1C;EAEA,MAAM,aAAa,eACjB,IAAI,KAAK,YAAY,kBAAkB,MACvC,YACF;EAEA,IAAI,eAAe,MACjB,IAAI,aAAa;OAEjB,IAAI,eAAe,CAAC,WAAW,KAAK,GAAG;EAGzC,KAAK,KAAK,GAAG;CACf;CACA,OAAO;AACT;AAEA,SAAS,eACP,MACA,cAC0B;CAC1B,KAAK,MAAM,cAAc,cAAc;EACrC,IAAI,SAAS,WAAW,SAAS,MAC/B,OAAO;;EAGT,IAAI,QAAQ,IAAI,KAAK,oBAAoB,UAAU,GACjD,OAAO;CAEX;CACA,OAAO;AACT;AAEA,SAAS,oBAAoB,YAAwC;CACnE,OACE,WAAW,SAAS,cAClB,iDACI;AAEV;AAEA,SAAgB,mBACd,SACA,aACA,SAC2B;CAC3B,MAAM,EAAE,UAAU,iBAAiB,eAAe,SAAS,WAAW;CAEtE,OAAO,EAAE,MADI,2BAA2B,UAAU,YACtC,EAAE;AAChB;AAEA,eAAsB,uBACpB,SACA,cAC+B;CAC/B,MAAM,kBAAuC,CAAC;CAC9C,MAAM,yBAA+C,CAAC;CACtD,KAAK,MAAM,eAAe,cAAc;EACtC,MAAM,UAAU,MAAM,cAAc,aAAa,MAAM;;EAEvD,IAAI,YAAY,MAAM;GACpB,MAAM,YAAY,eAAe,SAAS,WAAW;GACrD,gBAAgB,KAAK,GAAG,UAAU,YAAY;GAC9C,uBAAuB,KAAK,SAAS;EACvC;CACF;CAEA,MAAM,SAAwB,CAAC;CAC/B,KAAK,MAAM,QAAQ,wBAAwB;EACzC,MAAM,OAAO,2BAA2B,KAAK,UAAU,eAAe;EACtE,IAAI,KAAK,SAAS,GAChB,OAAO,KAAK;GAAE,aAAa,KAAK;GAAa;EAAK,CAAC;CAEvD;CACA,OAAO,OAAO,SAAS,SAAS;AAClC"}
|
|
@@ -21,6 +21,7 @@ function getExtraDeps(goModBefore, goModAfter, excludeDeps) {
|
|
|
21
21
|
for (const [depName, currentValue] of Object.entries(rmDeps)) {
|
|
22
22
|
if (excludeDeps.includes(depName)) continue;
|
|
23
23
|
const newValue = addDeps[depName];
|
|
24
|
+
// v8 ignore else -- needs a removed dep that is not added back
|
|
24
25
|
if (newValue) result.push({
|
|
25
26
|
depName,
|
|
26
27
|
currentValue,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifacts-extra.js","names":[],"sources":["../../../../lib/modules/manager/gomod/artifacts-extra.ts"],"sourcesContent":["import { diffLines } from 'diff';\nimport { markdownTable } from 'markdown-table';\nimport type { UpdateArtifactsConfig } from '../types.ts';\nimport { parseLine } from './line-parser.ts';\nimport type { ExtraDep } from './types.ts';\n\nexport function getExtraDeps(\n goModBefore: string,\n goModAfter: string,\n excludeDeps: string[],\n): ExtraDep[] {\n const result: ExtraDep[] = [];\n\n const diff = diffLines(goModBefore, goModAfter, {\n newlineIsToken: true,\n });\n\n const addDeps: Record<string, string> = {};\n const rmDeps: Record<string, string> = {};\n for (const { added, removed, value } of diff) {\n if (!added && !removed) {\n continue;\n }\n\n const res = parseLine(value);\n if (!res) {\n continue;\n }\n\n const { depName, depType, currentValue } = res;\n if (!depName || !currentValue) {\n continue;\n }\n\n let expandedDepName = depName;\n // NOTE: Right now the only special depType we care about is 'toolchain' because the table\n // rendering prior to this change was ambiguous with regards to go version vs toolchain\n // version updates.\n if (depType === 'toolchain') {\n expandedDepName = `${depName} (${depType})`;\n }\n\n if (added) {\n addDeps[expandedDepName] = currentValue;\n } else {\n rmDeps[expandedDepName] = currentValue;\n }\n }\n\n for (const [depName, currentValue] of Object.entries(rmDeps)) {\n if (excludeDeps.includes(depName)) {\n continue;\n }\n\n const newValue = addDeps[depName];\n if (newValue) {\n result.push({\n depName,\n currentValue,\n newValue,\n });\n }\n }\n\n return result;\n}\n\nexport function extraDepsTable(extraDeps: ExtraDep[]): string {\n const tableLines: string[][] = [];\n\n tableLines.push(['**Package**', '**Change**']);\n\n for (const { depName, currentValue, newValue } of extraDeps) {\n const depNameQuoted = `\\`${depName}\\``;\n const versionChangeQuoted = `\\`${currentValue}\\` -> \\`${newValue}\\``;\n tableLines.push([depNameQuoted, versionChangeQuoted]);\n }\n\n return markdownTable(tableLines, {\n align: ['l', 'l'],\n });\n}\n\nexport function getExtraDepsNotice(\n goModBefore: string | null,\n goModAfter: string | null,\n excludeDeps: string[],\n { minimumReleaseAge }: Pick<UpdateArtifactsConfig, 'minimumReleaseAge'>,\n): string | null {\n if (!goModBefore || !goModAfter) {\n return null;\n }\n\n const extraDeps = getExtraDeps(goModBefore, goModAfter, excludeDeps);\n if (extraDeps.length === 0) {\n return null;\n }\n\n const noticeLines: string[] = [\n 'In order to perform the update(s) described in the table above, Renovate ran the `go get` command, which resulted in the following additional change(s):',\n '\\n',\n ];\n\n const goUpdated = extraDeps.some(({ depName }) => depName === 'go');\n const toolchainUpdated = extraDeps.some(\n ({ depName }) => depName === 'go (toolchain)',\n );\n const otherDepsCount =\n extraDeps.length - (goUpdated ? 1 : 0) - (toolchainUpdated ? 1 : 0);\n\n if (otherDepsCount === 1) {\n noticeLines.push(`- ${otherDepsCount} additional dependency was updated`);\n } else if (otherDepsCount > 1) {\n noticeLines.push(\n `- ${otherDepsCount} additional dependencies were updated`,\n );\n }\n\n if (goUpdated) {\n noticeLines.push(\n '- The `go` directive was updated for compatibility reasons',\n );\n }\n\n if (minimumReleaseAge) {\n noticeLines.push('\\n');\n noticeLines.push(\n `Due to Go's usage of [Minimal Version Selection (MVS)](https://go.dev/ref/mod#minimal-version-selection), these packages have been updated to the minimum version available, so will still abide by \\`minimumReleaseAge=${minimumReleaseAge}\\``,\n );\n }\n\n noticeLines.push('\\n');\n noticeLines.push('Details:');\n noticeLines.push('\\n');\n noticeLines.push(extraDepsTable(extraDeps));\n\n return noticeLines.join('\\n');\n}\n"],"mappings":";;;;AAMA,SAAgB,aACd,aACA,YACA,aACY;CACZ,MAAM,SAAqB,CAAC;CAE5B,MAAM,OAAO,UAAU,aAAa,YAAY,EAC9C,gBAAgB,KAClB,CAAC;CAED,MAAM,UAAkC,CAAC;CACzC,MAAM,SAAiC,CAAC;CACxC,KAAK,MAAM,EAAE,OAAO,SAAS,WAAW,MAAM;EAC5C,IAAI,CAAC,SAAS,CAAC,SACb;EAGF,MAAM,MAAM,UAAU,KAAK;EAC3B,IAAI,CAAC,KACH;EAGF,MAAM,EAAE,SAAS,SAAS,iBAAiB;EAC3C,IAAI,CAAC,WAAW,CAAC,cACf;EAGF,IAAI,kBAAkB;EAItB,IAAI,YAAY,aACd,kBAAkB,GAAG,QAAQ,IAAI,QAAQ;EAG3C,IAAI,OACF,QAAQ,mBAAmB;OAE3B,OAAO,mBAAmB;CAE9B;CAEA,KAAK,MAAM,CAAC,SAAS,iBAAiB,OAAO,QAAQ,MAAM,GAAG;EAC5D,IAAI,YAAY,SAAS,OAAO,GAC9B;EAGF,MAAM,WAAW,QAAQ
|
|
1
|
+
{"version":3,"file":"artifacts-extra.js","names":[],"sources":["../../../../lib/modules/manager/gomod/artifacts-extra.ts"],"sourcesContent":["import { diffLines } from 'diff';\nimport { markdownTable } from 'markdown-table';\nimport type { UpdateArtifactsConfig } from '../types.ts';\nimport { parseLine } from './line-parser.ts';\nimport type { ExtraDep } from './types.ts';\n\nexport function getExtraDeps(\n goModBefore: string,\n goModAfter: string,\n excludeDeps: string[],\n): ExtraDep[] {\n const result: ExtraDep[] = [];\n\n const diff = diffLines(goModBefore, goModAfter, {\n newlineIsToken: true,\n });\n\n const addDeps: Record<string, string> = {};\n const rmDeps: Record<string, string> = {};\n for (const { added, removed, value } of diff) {\n if (!added && !removed) {\n continue;\n }\n\n const res = parseLine(value);\n if (!res) {\n continue;\n }\n\n const { depName, depType, currentValue } = res;\n if (!depName || !currentValue) {\n continue;\n }\n\n let expandedDepName = depName;\n // NOTE: Right now the only special depType we care about is 'toolchain' because the table\n // rendering prior to this change was ambiguous with regards to go version vs toolchain\n // version updates.\n if (depType === 'toolchain') {\n expandedDepName = `${depName} (${depType})`;\n }\n\n if (added) {\n addDeps[expandedDepName] = currentValue;\n } else {\n rmDeps[expandedDepName] = currentValue;\n }\n }\n\n for (const [depName, currentValue] of Object.entries(rmDeps)) {\n if (excludeDeps.includes(depName)) {\n continue;\n }\n\n const newValue = addDeps[depName];\n // v8 ignore else -- needs a removed dep that is not added back\n if (newValue) {\n result.push({\n depName,\n currentValue,\n newValue,\n });\n }\n }\n\n return result;\n}\n\nexport function extraDepsTable(extraDeps: ExtraDep[]): string {\n const tableLines: string[][] = [];\n\n tableLines.push(['**Package**', '**Change**']);\n\n for (const { depName, currentValue, newValue } of extraDeps) {\n const depNameQuoted = `\\`${depName}\\``;\n const versionChangeQuoted = `\\`${currentValue}\\` -> \\`${newValue}\\``;\n tableLines.push([depNameQuoted, versionChangeQuoted]);\n }\n\n return markdownTable(tableLines, {\n align: ['l', 'l'],\n });\n}\n\nexport function getExtraDepsNotice(\n goModBefore: string | null,\n goModAfter: string | null,\n excludeDeps: string[],\n { minimumReleaseAge }: Pick<UpdateArtifactsConfig, 'minimumReleaseAge'>,\n): string | null {\n if (!goModBefore || !goModAfter) {\n return null;\n }\n\n const extraDeps = getExtraDeps(goModBefore, goModAfter, excludeDeps);\n if (extraDeps.length === 0) {\n return null;\n }\n\n const noticeLines: string[] = [\n 'In order to perform the update(s) described in the table above, Renovate ran the `go get` command, which resulted in the following additional change(s):',\n '\\n',\n ];\n\n const goUpdated = extraDeps.some(({ depName }) => depName === 'go');\n const toolchainUpdated = extraDeps.some(\n ({ depName }) => depName === 'go (toolchain)',\n );\n const otherDepsCount =\n extraDeps.length - (goUpdated ? 1 : 0) - (toolchainUpdated ? 1 : 0);\n\n if (otherDepsCount === 1) {\n noticeLines.push(`- ${otherDepsCount} additional dependency was updated`);\n // NOTE: a zero count adds no line. A coverage-ignore hint cannot suppress\n // the implicit else on an `else if`.\n } else if (otherDepsCount > 1) {\n noticeLines.push(\n `- ${otherDepsCount} additional dependencies were updated`,\n );\n }\n\n if (goUpdated) {\n noticeLines.push(\n '- The `go` directive was updated for compatibility reasons',\n );\n }\n\n if (minimumReleaseAge) {\n noticeLines.push('\\n');\n noticeLines.push(\n `Due to Go's usage of [Minimal Version Selection (MVS)](https://go.dev/ref/mod#minimal-version-selection), these packages have been updated to the minimum version available, so will still abide by \\`minimumReleaseAge=${minimumReleaseAge}\\``,\n );\n }\n\n noticeLines.push('\\n');\n noticeLines.push('Details:');\n noticeLines.push('\\n');\n noticeLines.push(extraDepsTable(extraDeps));\n\n return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AAY,WAAW;CACnE,IAAI,UAAU,WAAW,GACvB,OAAO;CAGT,MAAM,cAAwB,CAC5B,4JACA,IACF;CAEA,MAAM,YAAY,UAAU,MAAM,EAAE,cAAc,YAAY,IAAI;CAClE,MAAM,mBAAmB,UAAU,MAChC,EAAE,cAAc,YAAY,gBAC/B;CACA,MAAM,iBACJ,UAAU,UAAU,YAAY,IAAI,MAAM,mBAAmB,IAAI;CAEnE,IAAI,mBAAmB,GACrB,YAAY,KAAK,KAAK,eAAe,mCAAmC;MAGnE,IAAI,iBAAiB,GAC1B,YAAY,KACV,KAAK,eAAe,sCACtB;CAGF,IAAI,WACF,YAAY,KACV,4DACF;CAGF,IAAI,mBAAmB;EACrB,YAAY,KAAK,IAAI;EACrB,YAAY,KACV,2NAA2N,kBAAkB,GAC/O;CACF;CAEA,YAAY,KAAK,IAAI;CACrB,YAAY,KAAK,UAAU;CAC3B,YAAY,KAAK,IAAI;CACrB,YAAY,KAAK,eAAe,SAAS,CAAC;CAE1C,OAAO,YAAY,KAAK,IAAI;AAC9B"}
|
|
@@ -74,6 +74,7 @@ async function updateArtifacts({ packageFileName: goModFileName, updatedDeps, ne
|
|
|
74
74
|
return match.replace(regEx(/(?<newline>\r?\n)/g), "$<newline>// renovate-replace ");
|
|
75
75
|
}
|
|
76
76
|
massagedGoMod = massagedGoMod.replace(inlineReplaceRegEx, inlineCommentOut).replace(blockReplaceRegEx, blockCommentOut);
|
|
77
|
+
// v8 ignore else -- needs a go.mod the replace massaging leaves unchanged
|
|
77
78
|
if (massagedGoMod !== newGoModContent) logger.debug("Removed some relative replace statements and comments from go.mod");
|
|
78
79
|
}
|
|
79
80
|
const goConstraints = await deriveGoToolchainConstraints(config, newGoModContent);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifacts.js","names":["valid","major","isValid"],"sources":["../../../../lib/modules/manager/gomod/artifacts.ts"],"sourcesContent":["import { isString } from '@sindresorhus/is';\nimport semver from 'semver';\nimport { quote } from 'shlex';\nimport upath from 'upath';\nimport { GlobalConfig } from '../../../config/global.ts';\nimport { TEMPORARY_ERROR } from '../../../constants/error-messages.ts';\nimport { logger } from '../../../logger/index.ts';\nimport { coerceArray } from '../../../util/array.ts';\nimport { getEnv } from '../../../util/env.ts';\nimport type { ExecOptions } from '../../../util/exec/types.ts';\nimport { filterMap } from '../../../util/filter-map.ts';\nimport {\n ensureCacheDir,\n findLocalSiblingOrParent,\n isValidLocalPath,\n readLocalFile,\n writeLocalFile,\n} from '../../../util/fs/index.ts';\nimport { withGitEnvironment } from '../../../util/git/exec.ts';\nimport { getRepoStatus } from '../../../util/git/index.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { isValid } from '../../versioning/semver/index.ts';\nimport type {\n PackageDependency,\n UpdateArtifact,\n UpdateArtifactsConfig,\n UpdateArtifactsResult,\n} from '../types.ts';\nimport { resolveToolConstraint } from '../util.ts';\nimport { getExtraDepsNotice } from './artifacts-extra.ts';\nimport { getGoModulesInTidyOrder } from './package-tree.ts';\n\nconst { major, valid } = semver;\nconst gitExec = withGitEnvironment(['go']);\n\nasync function getUpdateImportPathCmds(\n updatedDeps: PackageDependency[],\n config: UpdateArtifactsConfig,\n): Promise<string[]> {\n // Check if we fail to parse any major versions and log that they're skipped\n const invalidMajorDeps = updatedDeps.filter(\n ({ newVersion }) => !valid(newVersion),\n );\n if (invalidMajorDeps.length > 0) {\n invalidMajorDeps.forEach(({ depName }) =>\n logger.warn(\n { depName },\n 'Ignoring dependency: Could not get major version',\n ),\n );\n }\n\n const updateImportCommands = updatedDeps\n .filter(\n ({ newVersion }) =>\n valid(newVersion) && !newVersion!.endsWith('+incompatible'),\n )\n .map(({ depName, newVersion }) => ({\n depName: depName!,\n newMajor: major(newVersion!),\n }))\n // Skip path updates going from v0 to v1\n .filter(\n ({ depName, newMajor }) =>\n depName.startsWith('gopkg.in/') || newMajor > 1,\n )\n\n .map(\n ({ depName, newMajor }) =>\n `mod upgrade --mod-name=${quote(depName)} -t=${newMajor}`,\n );\n\n if (updateImportCommands.length > 0) {\n let installMarwanModArgs =\n 'install github.com/marwan-at-work/mod/cmd/mod@latest';\n const gomodModCompatibility = await resolveToolConstraint(\n config,\n 'gomodMod',\n );\n if (gomodModCompatibility) {\n if (\n gomodModCompatibility.startsWith('v') &&\n isValid(gomodModCompatibility.replace(regEx(/^v/), ''))\n ) {\n installMarwanModArgs = installMarwanModArgs.replace(\n regEx(/@latest$/),\n `@${gomodModCompatibility}`,\n );\n } else {\n logger.debug(\n { gomodModCompatibility },\n 'marwan-at-work/mod compatibility range is not valid - skipping',\n );\n }\n } else {\n logger.debug(\n 'No marwan-at-work/mod compatibility range found - installing marwan-at-work/mod latest',\n );\n }\n updateImportCommands.unshift(`go ${installMarwanModArgs}`);\n }\n\n return updateImportCommands;\n}\n\nfunction useModcacherw(goVersion: string | undefined): boolean {\n if (!isString(goVersion)) {\n return true;\n }\n\n return semver.intersects(goVersion, `>=1.14`);\n}\n\nexport async function updateArtifacts({\n packageFileName: goModFileName,\n updatedDeps,\n newPackageFileContent: newGoModContent,\n config,\n}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {\n logger.debug(`gomod.updateArtifacts(${goModFileName})`);\n\n const sumFileName = goModFileName.replace(regEx(/\\.mod$/), '.sum');\n const existingGoSumContent = await readLocalFile(sumFileName);\n if (!existingGoSumContent) {\n logger.debug('No go.sum found');\n return null;\n }\n const goModDir = upath.dirname(goModFileName);\n const goModFileBaseName = upath.basename(goModFileName);\n const modFileFlag =\n goModFileBaseName === 'go.mod'\n ? ''\n : ` -modfile=${quote(goModFileBaseName)}`;\n\n // The \"vendor\" directory can be next to the go.mod, but also in the parent directory in case\n // the go workspaces are used.\n const vendorDir = await findLocalSiblingOrParent(goModFileName, 'vendor');\n const vendorModulesFileName = upath.join(vendorDir ?? '', 'modules.txt');\n const useVendor =\n !!config.postUpdateOptions?.includes('gomodVendor') ||\n (!config.postUpdateOptions?.includes('gomodSkipVendor') &&\n vendorDir &&\n (await readLocalFile(vendorModulesFileName)) !== null);\n let massagedGoMod = newGoModContent;\n const useGoGenerate = !!config.postUpdateOptions?.includes('goGenerate');\n const allowedUnsafeExecutions = GlobalConfig.get('allowedUnsafeExecutions');\n const goGenerateAllowed = allowedUnsafeExecutions?.includes('goGenerate');\n\n if (config.postUpdateOptions?.includes('gomodMassage')) {\n // Regex match inline replace directive, example:\n // replace golang.org/x/net v1.2.3 => example.com/fork/net v1.4.5\n // https://go.dev/ref/mod#go-mod-file-replace\n\n // replace bracket after comments, so it doesn't break the regex, doing a complex regex causes problems\n // when there's a comment and \")\" after it, the regex will read replace block until comment.. and stop.\n massagedGoMod = massagedGoMod\n .split('\\n')\n .map((line) => {\n if (line.trim().startsWith('//')) {\n return line.replace(')', 'renovate-replace-bracket');\n }\n return line;\n })\n .join('\\n');\n\n const inlineReplaceRegEx = regEx(\n /(?<newline>\\r?\\n)(?<directive>replace\\s+[^\\s]+\\s+=>\\s+\\.\\.\\/.*)/g,\n );\n\n // $<newline> will be matched with the (\\r?\\n) group\n // $<directive> will be matched with the inline replace match, example\n // \"// renovate-replace replace golang.org/x/net v1.2.3 => example.com/fork/net v1.4.5\"\n const inlineCommentOut = '$<newline>// renovate-replace $<directive>';\n\n // Regex match replace directive block, example:\n // replace (\n // golang.org/x/net v1.2.3 => example.com/fork/net v1.4.5\n // )\n const blockReplaceRegEx = regEx(/(?:\\r?\\n)replace\\s*\\([^)]+\\s*\\)/g);\n\n /**\n * replacerFunction for commenting out replace blocks\n * @param match A string representing a golang replace directive block\n * @returns A commented out block with // renovate-replace\n */\n function blockCommentOut(match: string): string {\n return match.replace(\n regEx(/(?<newline>\\r?\\n)/g),\n '$<newline>// renovate-replace ',\n );\n }\n\n // Comment out golang replace directives\n massagedGoMod = massagedGoMod\n .replace(inlineReplaceRegEx, inlineCommentOut)\n .replace(blockReplaceRegEx, blockCommentOut);\n\n if (massagedGoMod !== newGoModContent) {\n logger.debug(\n 'Removed some relative replace statements and comments from go.mod',\n );\n }\n }\n const goConstraints = await deriveGoToolchainConstraints(\n config,\n newGoModContent,\n );\n\n try {\n await writeLocalFile(goModFileName, massagedGoMod);\n\n const cmd = 'go';\n const env = getEnv();\n const execOptions: ExecOptions = {\n cwdFile: goModFileName,\n extraEnv: {\n GOPATH: await ensureCacheDir('go'),\n GOPROXY: env.GOPROXY,\n GOPRIVATE: env.GOPRIVATE,\n GONOPROXY: env.GONOPROXY,\n GONOSUMDB: env.GONOSUMDB,\n GOSUMDB: env.GOSUMDB,\n GOINSECURE: env.GOINSECURE,\n /* v8 ignore next -- TODO: add test */\n GOFLAGS: useModcacherw(goConstraints) ? '-modcacherw' : null,\n CGO_ENABLED: GlobalConfig.get('binarySource') === 'docker' ? '0' : null,\n },\n docker: {},\n toolConstraints: [\n {\n toolName: 'golang',\n constraint: goConstraints,\n },\n ],\n };\n\n const execCommands: string[] = [];\n\n let goGetDirs: string | undefined;\n if (config.goGetDirs) {\n goGetDirs = config.goGetDirs\n .filter((dir) => {\n const isValid = isValidLocalPath(dir);\n if (!isValid) {\n logger.warn({ dir }, 'Invalid path in goGetDirs');\n }\n return isValid;\n })\n .map(quote)\n .join(' ');\n\n if (goGetDirs === '') {\n throw new Error('Invalid goGetDirs');\n }\n }\n\n let args = `get${modFileFlag} `;\n\n if (goConstraints && !semver.intersects(goConstraints, `>=1.18`)) {\n // For Go versions < 1.18, we need to use the -d flag to avoid builds or installs\n // https://go.dev/doc/go1.18#go-get\n args += `-d `;\n }\n\n args += `-t ${goGetDirs ?? './...'}`;\n logger.trace({ cmd, args }, 'go get command included');\n execCommands.push(`${cmd} ${args}`);\n\n // Update import paths on major updates\n const isImportPathUpdateRequired =\n config.postUpdateOptions?.includes('gomodUpdateImportPaths') &&\n config.updateType === 'major';\n\n if (isImportPathUpdateRequired) {\n const updateImportCmds = await getUpdateImportPathCmds(\n updatedDeps,\n config,\n );\n if (updateImportCmds.length > 0) {\n logger.debug(updateImportCmds, 'update import path commands included');\n // The updates\n execCommands.push(...updateImportCmds);\n }\n }\n\n const mustSkipGoModTidy =\n !config.postUpdateOptions?.includes('gomodUpdateImportPaths') &&\n config.updateType === 'major';\n if (mustSkipGoModTidy) {\n logger.debug('go mod tidy command skipped');\n }\n\n let tidyOpts = '';\n if (config.postUpdateOptions?.includes('gomodTidy1.17')) {\n tidyOpts += ' -compat=1.17';\n }\n if (config.postUpdateOptions?.includes('gomodTidyE')) {\n tidyOpts += ' -e';\n }\n\n // dependent modules can only be tidied once the updated module is settled\n const isGoModTidyAllRequired =\n config.postUpdateOptions?.includes('gomodTidyAll') === true;\n const isGoModTidyRequired =\n !mustSkipGoModTidy &&\n (config.postUpdateOptions?.includes('gomodTidy') === true ||\n config.postUpdateOptions?.includes('gomodTidy1.17') === true ||\n config.postUpdateOptions?.includes('gomodTidyE') === true ||\n isGoModTidyAllRequired ||\n (config.updateType === 'major' && isImportPathUpdateRequired));\n if (isGoModTidyRequired) {\n args = `mod tidy${modFileFlag}${tidyOpts}`;\n logger.debug('go mod tidy command included');\n execCommands.push(`${cmd} ${args}`);\n }\n\n let goWorkSumFileName = upath.join(goModDir, 'go.work.sum');\n if (useVendor) {\n // If we find a go.work, then use go workspace vendoring.\n const goWorkFile = await findLocalSiblingOrParent(\n goModFileName,\n 'go.work',\n );\n\n if (goWorkFile) {\n goWorkSumFileName = upath.join(\n upath.dirname(goWorkFile),\n 'go.work.sum',\n );\n\n args = 'work vendor';\n logger.debug('using go work vendor');\n execCommands.push(`${cmd} ${args}`);\n\n args = 'work sync';\n logger.debug('using go work sync');\n execCommands.push(`${cmd} ${args}`);\n } else {\n args = `mod vendor${modFileFlag}`;\n logger.debug('using go mod vendor');\n execCommands.push(`${cmd} ${args}`);\n }\n\n if (isGoModTidyRequired) {\n args = `mod tidy${modFileFlag}${tidyOpts}`;\n logger.debug('go mod tidy command included');\n execCommands.push(`${cmd} ${args}`);\n }\n }\n\n // We tidy one more time as a solution for #6795\n if (isGoModTidyRequired) {\n args = `mod tidy${modFileFlag}${tidyOpts}`;\n logger.debug('go mod tidy command included');\n execCommands.push(`${cmd} ${args}`);\n }\n\n let dependentModules: string[] = [];\n if (isGoModTidyAllRequired) {\n try {\n dependentModules = await getGoModulesInTidyOrder(goModFileName);\n for (const dependent of dependentModules) {\n const dir = upath.relative(goModDir, upath.dirname(dependent));\n execCommands.push(`${cmd} -C ${quote(dir)} mod tidy${tidyOpts}`);\n }\n logger.debug({ dependentModules }, 'go mod tidy commands included');\n } catch (err) {\n logger.warn({ err }, 'Failed to find dependent Go modules');\n }\n }\n\n if (useGoGenerate) {\n if (goGenerateAllowed) {\n logger.debug('go generate command included');\n execCommands.push(`${cmd} generate ./...`);\n } else {\n logger.once.warn(\n `go generate command requested as a post update action, but goGenerate is not permitted in the allowedUnsafeExecutions`,\n );\n }\n }\n\n await gitExec(execCommands, execOptions);\n\n const status = await getRepoStatus();\n const dependentFiles = dependentModules.flatMap((f) => [\n f,\n f.replace(regEx(/\\.mod$/), '.sum'),\n ]);\n\n if (\n !status.modified.includes(sumFileName) &&\n !status.modified.includes(goModFileName) &&\n !status.modified.includes(goWorkSumFileName) &&\n !dependentFiles.some((f) => status.modified.includes(f))\n ) {\n return null;\n }\n\n const res: UpdateArtifactsResult[] = [];\n if (status.modified.includes(sumFileName)) {\n logger.debug('Returning updated go.sum');\n res.push({\n file: {\n type: 'addition',\n path: sumFileName,\n contents: await readLocalFile(sumFileName),\n },\n });\n }\n\n if (status.modified.includes(goWorkSumFileName)) {\n logger.debug('Returning updated go.work.sum');\n res.push({\n file: {\n type: 'addition',\n path: goWorkSumFileName,\n contents: await readLocalFile(goWorkSumFileName),\n },\n });\n }\n\n for (const f of dependentFiles) {\n if (status.modified.includes(f)) {\n logger.trace(`Returning updated ${f}`);\n res.push({\n file: {\n type: 'addition',\n path: f,\n contents: await readLocalFile(f),\n },\n });\n }\n }\n\n // Include all the .go file import changes\n if (isImportPathUpdateRequired) {\n logger.debug('Returning updated go source files for import path changes');\n for (const f of status.modified) {\n if (f.endsWith('.go')) {\n res.push({\n file: {\n type: 'addition',\n path: f,\n contents: await readLocalFile(f),\n },\n });\n }\n }\n }\n\n const alreadyAdded = new Set<string>();\n const alreadyDeleted = new Set<string>();\n if (useVendor) {\n for (const f of status.modified.concat(status.not_added)) {\n if (vendorDir && f.startsWith(vendorDir)) {\n alreadyAdded.add(f);\n res.push({\n file: {\n type: 'addition',\n path: f,\n contents: await readLocalFile(f),\n },\n });\n }\n }\n for (const f of coerceArray(status.deleted)) {\n if (vendorDir && f.startsWith(vendorDir)) {\n alreadyDeleted.add(f);\n res.push({\n file: {\n type: 'deletion',\n path: f,\n },\n });\n }\n }\n }\n\n // TODO: throws in tests (#22198)\n const finalGoModContent = (await readLocalFile(goModFileName, 'utf8'))!\n .replace(regEx(/\\/\\/ renovate-replace /g), '')\n .replace(regEx(/renovate-replace-bracket/g), ')');\n if (finalGoModContent !== newGoModContent) {\n const artifactResult: UpdateArtifactsResult = {\n file: {\n type: 'addition',\n path: goModFileName,\n contents: finalGoModContent,\n },\n };\n\n const updatedDepNames = filterMap(updatedDeps, (dep) => dep?.depName);\n const extraDepsNotice = getExtraDepsNotice(\n newGoModContent,\n finalGoModContent,\n updatedDepNames,\n config,\n );\n\n if (extraDepsNotice) {\n artifactResult.notice = {\n file: goModFileName,\n message: extraDepsNotice,\n };\n }\n\n logger.debug('Found updated go.mod after go.sum update');\n res.push(artifactResult);\n alreadyAdded.add(goModFileName);\n }\n\n // add all files added when in `go generate` mode.\n // unfortunately there is not a good way as there is with vendoring or go import path updates to detect this.\n // Do this at the very very end to ensure we only capture files which would have been explicitly\n // modified, added, or deleted from a `go generate` invocation\n if (useGoGenerate && goGenerateAllowed) {\n logger.debug(\n 'Updating all modified files since generated files were added',\n );\n for (const f of status.modified.concat(status.created)) {\n if (!alreadyAdded.has(f)) {\n res.push({\n file: {\n type: 'addition',\n path: f,\n contents: await readLocalFile(f),\n },\n });\n }\n }\n for (const f of coerceArray(status.deleted)) {\n if (!alreadyDeleted.has(f)) {\n res.push({\n file: {\n type: 'deletion',\n path: f,\n },\n });\n }\n }\n }\n return res;\n } catch (err) {\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n logger.debug({ err }, 'Failed to update go.sum');\n return [\n {\n artifactError: {\n fileName: sumFileName,\n stderr: err.message,\n },\n },\n ];\n }\n}\n\nfunction getGoConstraints(content: string): string | undefined {\n // prefer toolchain directive when go.mod has one\n const toolchainMatch = regEx(/^toolchain\\s*go(?<gover>\\d+\\.\\d+\\.\\d+)$/m).exec(\n content,\n );\n const toolchainVer = toolchainMatch?.groups?.gover;\n if (toolchainVer) {\n logger.debug(\n `Using go version ${toolchainVer} found in toolchain directive`,\n );\n return toolchainVer;\n }\n\n // If go.mod doesn't have toolchain directive and has a full go version spec,\n // for example `go 1.23.6`, pick this version, this doesn't match major.minor version spec.\n //\n // This is because when go.mod have same version defined in go directive and toolchain directive,\n // go will remove toolchain directive from go.mod.\n //\n // For example, go will rewrite `go 1.23.5\\ntoolchain go1.23.5` to `go 1.23.5` by default,\n // in this case, the go directive is the toolchain directive.\n const goFullVersion = regEx(/^go\\s*(?<gover>\\d+\\.\\d+\\.\\d+)$/m).exec(content)\n ?.groups?.gover;\n if (goFullVersion) {\n return goFullVersion;\n }\n\n const re = regEx(/^go\\s*(?<gover>\\d+\\.\\d+)$/m);\n const match = re.exec(content);\n if (!match?.groups?.gover) {\n return undefined;\n }\n return `^${match.groups.gover}`;\n}\n\n/**\n * Derive the version of the Go toolchain needed to run this project.\n *\n * This matches with the `golang` Containerbase tool.\n *\n * In precedence order:\n *\n * 1. config: \\`constraints.go\\`\n * 1. \\`go.mod\\`: \\`toolchain\\` directive\n * 1. \\`go.mod\\`: \\`go\\` directive\n * 1. the \\`go\\` constraint collected during extraction\n *\n * NOTE that the \\`constraints.golang\\` is not used (TODO #42601)\n */\nexport async function deriveGoToolchainConstraints(\n config: UpdateArtifactsConfig,\n newGoModContent: string,\n): Promise<string | undefined> {\n return await resolveToolConstraint(config, 'go', () =>\n getGoConstraints(newGoModContent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AgBA,eAAsB,6BACpB,QACA,iBAC6B;CAC7B,OAAO,MAAM,sBAAsB,QAAQ,YACzC,iBAAiB,eAAe,CAClC;AACF"}
|
|
1
|
+
{"version":3,"file":"artifacts.js","names":["valid","major","isValid"],"sources":["../../../../lib/modules/manager/gomod/artifacts.ts"],"sourcesContent":["import { isString } from '@sindresorhus/is';\nimport semver from 'semver';\nimport { quote } from 'shlex';\nimport upath from 'upath';\nimport { GlobalConfig } from '../../../config/global.ts';\nimport { TEMPORARY_ERROR } from '../../../constants/error-messages.ts';\nimport { logger } from '../../../logger/index.ts';\nimport { coerceArray } from '../../../util/array.ts';\nimport { getEnv } from '../../../util/env.ts';\nimport type { ExecOptions } from '../../../util/exec/types.ts';\nimport { filterMap } from '../../../util/filter-map.ts';\nimport {\n ensureCacheDir,\n findLocalSiblingOrParent,\n isValidLocalPath,\n readLocalFile,\n writeLocalFile,\n} from '../../../util/fs/index.ts';\nimport { withGitEnvironment } from '../../../util/git/exec.ts';\nimport { getRepoStatus } from '../../../util/git/index.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { isValid } from '../../versioning/semver/index.ts';\nimport type {\n PackageDependency,\n UpdateArtifact,\n UpdateArtifactsConfig,\n UpdateArtifactsResult,\n} from '../types.ts';\nimport { resolveToolConstraint } from '../util.ts';\nimport { getExtraDepsNotice } from './artifacts-extra.ts';\nimport { getGoModulesInTidyOrder } from './package-tree.ts';\n\nconst { major, valid } = semver;\nconst gitExec = withGitEnvironment(['go']);\n\nasync function getUpdateImportPathCmds(\n updatedDeps: PackageDependency[],\n config: UpdateArtifactsConfig,\n): Promise<string[]> {\n // Check if we fail to parse any major versions and log that they're skipped\n const invalidMajorDeps = updatedDeps.filter(\n ({ newVersion }) => !valid(newVersion),\n );\n if (invalidMajorDeps.length > 0) {\n invalidMajorDeps.forEach(({ depName }) =>\n logger.warn(\n { depName },\n 'Ignoring dependency: Could not get major version',\n ),\n );\n }\n\n const updateImportCommands = updatedDeps\n .filter(\n ({ newVersion }) =>\n valid(newVersion) && !newVersion!.endsWith('+incompatible'),\n )\n .map(({ depName, newVersion }) => ({\n depName: depName!,\n newMajor: major(newVersion!),\n }))\n // Skip path updates going from v0 to v1\n .filter(\n ({ depName, newMajor }) =>\n depName.startsWith('gopkg.in/') || newMajor > 1,\n )\n\n .map(\n ({ depName, newMajor }) =>\n `mod upgrade --mod-name=${quote(depName)} -t=${newMajor}`,\n );\n\n if (updateImportCommands.length > 0) {\n let installMarwanModArgs =\n 'install github.com/marwan-at-work/mod/cmd/mod@latest';\n const gomodModCompatibility = await resolveToolConstraint(\n config,\n 'gomodMod',\n );\n if (gomodModCompatibility) {\n if (\n gomodModCompatibility.startsWith('v') &&\n isValid(gomodModCompatibility.replace(regEx(/^v/), ''))\n ) {\n installMarwanModArgs = installMarwanModArgs.replace(\n regEx(/@latest$/),\n `@${gomodModCompatibility}`,\n );\n } else {\n logger.debug(\n { gomodModCompatibility },\n 'marwan-at-work/mod compatibility range is not valid - skipping',\n );\n }\n } else {\n logger.debug(\n 'No marwan-at-work/mod compatibility range found - installing marwan-at-work/mod latest',\n );\n }\n updateImportCommands.unshift(`go ${installMarwanModArgs}`);\n }\n\n return updateImportCommands;\n}\n\nfunction useModcacherw(goVersion: string | undefined): boolean {\n if (!isString(goVersion)) {\n return true;\n }\n\n return semver.intersects(goVersion, `>=1.14`);\n}\n\nexport async function updateArtifacts({\n packageFileName: goModFileName,\n updatedDeps,\n newPackageFileContent: newGoModContent,\n config,\n}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {\n logger.debug(`gomod.updateArtifacts(${goModFileName})`);\n\n const sumFileName = goModFileName.replace(regEx(/\\.mod$/), '.sum');\n const existingGoSumContent = await readLocalFile(sumFileName);\n if (!existingGoSumContent) {\n logger.debug('No go.sum found');\n return null;\n }\n const goModDir = upath.dirname(goModFileName);\n const goModFileBaseName = upath.basename(goModFileName);\n const modFileFlag =\n goModFileBaseName === 'go.mod'\n ? ''\n : ` -modfile=${quote(goModFileBaseName)}`;\n\n // The \"vendor\" directory can be next to the go.mod, but also in the parent directory in case\n // the go workspaces are used.\n const vendorDir = await findLocalSiblingOrParent(goModFileName, 'vendor');\n const vendorModulesFileName = upath.join(vendorDir ?? '', 'modules.txt');\n const useVendor =\n !!config.postUpdateOptions?.includes('gomodVendor') ||\n (!config.postUpdateOptions?.includes('gomodSkipVendor') &&\n vendorDir &&\n (await readLocalFile(vendorModulesFileName)) !== null);\n let massagedGoMod = newGoModContent;\n const useGoGenerate = !!config.postUpdateOptions?.includes('goGenerate');\n const allowedUnsafeExecutions = GlobalConfig.get('allowedUnsafeExecutions');\n const goGenerateAllowed = allowedUnsafeExecutions?.includes('goGenerate');\n\n if (config.postUpdateOptions?.includes('gomodMassage')) {\n // Regex match inline replace directive, example:\n // replace golang.org/x/net v1.2.3 => example.com/fork/net v1.4.5\n // https://go.dev/ref/mod#go-mod-file-replace\n\n // replace bracket after comments, so it doesn't break the regex, doing a complex regex causes problems\n // when there's a comment and \")\" after it, the regex will read replace block until comment.. and stop.\n massagedGoMod = massagedGoMod\n .split('\\n')\n .map((line) => {\n if (line.trim().startsWith('//')) {\n return line.replace(')', 'renovate-replace-bracket');\n }\n return line;\n })\n .join('\\n');\n\n const inlineReplaceRegEx = regEx(\n /(?<newline>\\r?\\n)(?<directive>replace\\s+[^\\s]+\\s+=>\\s+\\.\\.\\/.*)/g,\n );\n\n // $<newline> will be matched with the (\\r?\\n) group\n // $<directive> will be matched with the inline replace match, example\n // \"// renovate-replace replace golang.org/x/net v1.2.3 => example.com/fork/net v1.4.5\"\n const inlineCommentOut = '$<newline>// renovate-replace $<directive>';\n\n // Regex match replace directive block, example:\n // replace (\n // golang.org/x/net v1.2.3 => example.com/fork/net v1.4.5\n // )\n const blockReplaceRegEx = regEx(/(?:\\r?\\n)replace\\s*\\([^)]+\\s*\\)/g);\n\n /**\n * replacerFunction for commenting out replace blocks\n * @param match A string representing a golang replace directive block\n * @returns A commented out block with // renovate-replace\n */\n function blockCommentOut(match: string): string {\n return match.replace(\n regEx(/(?<newline>\\r?\\n)/g),\n '$<newline>// renovate-replace ',\n );\n }\n\n // Comment out golang replace directives\n massagedGoMod = massagedGoMod\n .replace(inlineReplaceRegEx, inlineCommentOut)\n .replace(blockReplaceRegEx, blockCommentOut);\n\n // v8 ignore else -- needs a go.mod the replace massaging leaves unchanged\n if (massagedGoMod !== newGoModContent) {\n logger.debug(\n 'Removed some relative replace statements and comments from go.mod',\n );\n }\n }\n const goConstraints = await deriveGoToolchainConstraints(\n config,\n newGoModContent,\n );\n\n try {\n await writeLocalFile(goModFileName, massagedGoMod);\n\n const cmd = 'go';\n const env = getEnv();\n const execOptions: ExecOptions = {\n cwdFile: goModFileName,\n extraEnv: {\n GOPATH: await ensureCacheDir('go'),\n GOPROXY: env.GOPROXY,\n GOPRIVATE: env.GOPRIVATE,\n GONOPROXY: env.GONOPROXY,\n GONOSUMDB: env.GONOSUMDB,\n GOSUMDB: env.GOSUMDB,\n GOINSECURE: env.GOINSECURE,\n /* v8 ignore next -- TODO: add test */\n GOFLAGS: useModcacherw(goConstraints) ? '-modcacherw' : null,\n CGO_ENABLED: GlobalConfig.get('binarySource') === 'docker' ? '0' : null,\n },\n docker: {},\n toolConstraints: [\n {\n toolName: 'golang',\n constraint: goConstraints,\n },\n ],\n };\n\n const execCommands: string[] = [];\n\n let goGetDirs: string | undefined;\n if (config.goGetDirs) {\n goGetDirs = config.goGetDirs\n .filter((dir) => {\n const isValid = isValidLocalPath(dir);\n if (!isValid) {\n logger.warn({ dir }, 'Invalid path in goGetDirs');\n }\n return isValid;\n })\n .map(quote)\n .join(' ');\n\n if (goGetDirs === '') {\n throw new Error('Invalid goGetDirs');\n }\n }\n\n let args = `get${modFileFlag} `;\n\n if (goConstraints && !semver.intersects(goConstraints, `>=1.18`)) {\n // For Go versions < 1.18, we need to use the -d flag to avoid builds or installs\n // https://go.dev/doc/go1.18#go-get\n args += `-d `;\n }\n\n args += `-t ${goGetDirs ?? './...'}`;\n logger.trace({ cmd, args }, 'go get command included');\n execCommands.push(`${cmd} ${args}`);\n\n // Update import paths on major updates\n const isImportPathUpdateRequired =\n config.postUpdateOptions?.includes('gomodUpdateImportPaths') &&\n config.updateType === 'major';\n\n if (isImportPathUpdateRequired) {\n const updateImportCmds = await getUpdateImportPathCmds(\n updatedDeps,\n config,\n );\n if (updateImportCmds.length > 0) {\n logger.debug(updateImportCmds, 'update import path commands included');\n // The updates\n execCommands.push(...updateImportCmds);\n }\n }\n\n const mustSkipGoModTidy =\n !config.postUpdateOptions?.includes('gomodUpdateImportPaths') &&\n config.updateType === 'major';\n if (mustSkipGoModTidy) {\n logger.debug('go mod tidy command skipped');\n }\n\n let tidyOpts = '';\n if (config.postUpdateOptions?.includes('gomodTidy1.17')) {\n tidyOpts += ' -compat=1.17';\n }\n if (config.postUpdateOptions?.includes('gomodTidyE')) {\n tidyOpts += ' -e';\n }\n\n // dependent modules can only be tidied once the updated module is settled\n const isGoModTidyAllRequired =\n config.postUpdateOptions?.includes('gomodTidyAll') === true;\n const isGoModTidyRequired =\n !mustSkipGoModTidy &&\n (config.postUpdateOptions?.includes('gomodTidy') === true ||\n config.postUpdateOptions?.includes('gomodTidy1.17') === true ||\n config.postUpdateOptions?.includes('gomodTidyE') === true ||\n isGoModTidyAllRequired ||\n (config.updateType === 'major' && isImportPathUpdateRequired));\n if (isGoModTidyRequired) {\n args = `mod tidy${modFileFlag}${tidyOpts}`;\n logger.debug('go mod tidy command included');\n execCommands.push(`${cmd} ${args}`);\n }\n\n let goWorkSumFileName = upath.join(goModDir, 'go.work.sum');\n if (useVendor) {\n // If we find a go.work, then use go workspace vendoring.\n const goWorkFile = await findLocalSiblingOrParent(\n goModFileName,\n 'go.work',\n );\n\n if (goWorkFile) {\n goWorkSumFileName = upath.join(\n upath.dirname(goWorkFile),\n 'go.work.sum',\n );\n\n args = 'work vendor';\n logger.debug('using go work vendor');\n execCommands.push(`${cmd} ${args}`);\n\n args = 'work sync';\n logger.debug('using go work sync');\n execCommands.push(`${cmd} ${args}`);\n } else {\n args = `mod vendor${modFileFlag}`;\n logger.debug('using go mod vendor');\n execCommands.push(`${cmd} ${args}`);\n }\n\n if (isGoModTidyRequired) {\n args = `mod tidy${modFileFlag}${tidyOpts}`;\n logger.debug('go mod tidy command included');\n execCommands.push(`${cmd} ${args}`);\n }\n }\n\n // We tidy one more time as a solution for #6795\n if (isGoModTidyRequired) {\n args = `mod tidy${modFileFlag}${tidyOpts}`;\n logger.debug('go mod tidy command included');\n execCommands.push(`${cmd} ${args}`);\n }\n\n let dependentModules: string[] = [];\n if (isGoModTidyAllRequired) {\n try {\n dependentModules = await getGoModulesInTidyOrder(goModFileName);\n for (const dependent of dependentModules) {\n const dir = upath.relative(goModDir, upath.dirname(dependent));\n execCommands.push(`${cmd} -C ${quote(dir)} mod tidy${tidyOpts}`);\n }\n logger.debug({ dependentModules }, 'go mod tidy commands included');\n } catch (err) {\n logger.warn({ err }, 'Failed to find dependent Go modules');\n }\n }\n\n if (useGoGenerate) {\n if (goGenerateAllowed) {\n logger.debug('go generate command included');\n execCommands.push(`${cmd} generate ./...`);\n } else {\n logger.once.warn(\n `go generate command requested as a post update action, but goGenerate is not permitted in the allowedUnsafeExecutions`,\n );\n }\n }\n\n await gitExec(execCommands, execOptions);\n\n const status = await getRepoStatus();\n const dependentFiles = dependentModules.flatMap((f) => [\n f,\n f.replace(regEx(/\\.mod$/), '.sum'),\n ]);\n\n if (\n !status.modified.includes(sumFileName) &&\n !status.modified.includes(goModFileName) &&\n !status.modified.includes(goWorkSumFileName) &&\n !dependentFiles.some((f) => status.modified.includes(f))\n ) {\n return null;\n }\n\n const res: UpdateArtifactsResult[] = [];\n if (status.modified.includes(sumFileName)) {\n logger.debug('Returning updated go.sum');\n res.push({\n file: {\n type: 'addition',\n path: sumFileName,\n contents: await readLocalFile(sumFileName),\n },\n });\n }\n\n if (status.modified.includes(goWorkSumFileName)) {\n logger.debug('Returning updated go.work.sum');\n res.push({\n file: {\n type: 'addition',\n path: goWorkSumFileName,\n contents: await readLocalFile(goWorkSumFileName),\n },\n });\n }\n\n for (const f of dependentFiles) {\n if (status.modified.includes(f)) {\n logger.trace(`Returning updated ${f}`);\n res.push({\n file: {\n type: 'addition',\n path: f,\n contents: await readLocalFile(f),\n },\n });\n }\n }\n\n // Include all the .go file import changes\n if (isImportPathUpdateRequired) {\n logger.debug('Returning updated go source files for import path changes');\n for (const f of status.modified) {\n if (f.endsWith('.go')) {\n res.push({\n file: {\n type: 'addition',\n path: f,\n contents: await readLocalFile(f),\n },\n });\n }\n }\n }\n\n const alreadyAdded = new Set<string>();\n const alreadyDeleted = new Set<string>();\n if (useVendor) {\n for (const f of status.modified.concat(status.not_added)) {\n if (vendorDir && f.startsWith(vendorDir)) {\n alreadyAdded.add(f);\n res.push({\n file: {\n type: 'addition',\n path: f,\n contents: await readLocalFile(f),\n },\n });\n }\n }\n for (const f of coerceArray(status.deleted)) {\n if (vendorDir && f.startsWith(vendorDir)) {\n alreadyDeleted.add(f);\n res.push({\n file: {\n type: 'deletion',\n path: f,\n },\n });\n }\n }\n }\n\n // TODO: throws in tests (#22198)\n const finalGoModContent = (await readLocalFile(goModFileName, 'utf8'))!\n .replace(regEx(/\\/\\/ renovate-replace /g), '')\n .replace(regEx(/renovate-replace-bracket/g), ')');\n if (finalGoModContent !== newGoModContent) {\n const artifactResult: UpdateArtifactsResult = {\n file: {\n type: 'addition',\n path: goModFileName,\n contents: finalGoModContent,\n },\n };\n\n const updatedDepNames = filterMap(updatedDeps, (dep) => dep?.depName);\n const extraDepsNotice = getExtraDepsNotice(\n newGoModContent,\n finalGoModContent,\n updatedDepNames,\n config,\n );\n\n if (extraDepsNotice) {\n artifactResult.notice = {\n file: goModFileName,\n message: extraDepsNotice,\n };\n }\n\n logger.debug('Found updated go.mod after go.sum update');\n res.push(artifactResult);\n alreadyAdded.add(goModFileName);\n }\n\n // add all files added when in `go generate` mode.\n // unfortunately there is not a good way as there is with vendoring or go import path updates to detect this.\n // Do this at the very very end to ensure we only capture files which would have been explicitly\n // modified, added, or deleted from a `go generate` invocation\n if (useGoGenerate && goGenerateAllowed) {\n logger.debug(\n 'Updating all modified files since generated files were added',\n );\n for (const f of status.modified.concat(status.created)) {\n if (!alreadyAdded.has(f)) {\n res.push({\n file: {\n type: 'addition',\n path: f,\n contents: await readLocalFile(f),\n },\n });\n }\n }\n for (const f of coerceArray(status.deleted)) {\n if (!alreadyDeleted.has(f)) {\n res.push({\n file: {\n type: 'deletion',\n path: f,\n },\n });\n }\n }\n }\n return res;\n } catch (err) {\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n logger.debug({ err }, 'Failed to update go.sum');\n return [\n {\n artifactError: {\n fileName: sumFileName,\n stderr: err.message,\n },\n },\n ];\n }\n}\n\nfunction getGoConstraints(content: string): string | undefined {\n // prefer toolchain directive when go.mod has one\n const toolchainMatch = regEx(/^toolchain\\s*go(?<gover>\\d+\\.\\d+\\.\\d+)$/m).exec(\n content,\n );\n const toolchainVer = toolchainMatch?.groups?.gover;\n if (toolchainVer) {\n logger.debug(\n `Using go version ${toolchainVer} found in toolchain directive`,\n );\n return toolchainVer;\n }\n\n // If go.mod doesn't have toolchain directive and has a full go version spec,\n // for example `go 1.23.6`, pick this version, this doesn't match major.minor version spec.\n //\n // This is because when go.mod have same version defined in go directive and toolchain directive,\n // go will remove toolchain directive from go.mod.\n //\n // For example, go will rewrite `go 1.23.5\\ntoolchain go1.23.5` to `go 1.23.5` by default,\n // in this case, the go directive is the toolchain directive.\n const goFullVersion = regEx(/^go\\s*(?<gover>\\d+\\.\\d+\\.\\d+)$/m).exec(content)\n ?.groups?.gover;\n if (goFullVersion) {\n return goFullVersion;\n }\n\n const re = regEx(/^go\\s*(?<gover>\\d+\\.\\d+)$/m);\n const match = re.exec(content);\n if (!match?.groups?.gover) {\n return undefined;\n }\n return `^${match.groups.gover}`;\n}\n\n/**\n * Derive the version of the Go toolchain needed to run this project.\n *\n * This matches with the `golang` Containerbase tool.\n *\n * In precedence order:\n *\n * 1. config: \\`constraints.go\\`\n * 1. \\`go.mod\\`: \\`toolchain\\` directive\n * 1. \\`go.mod\\`: \\`go\\` directive\n * 1. the \\`go\\` constraint collected during extraction\n *\n * NOTE that the \\`constraints.golang\\` is not used (TODO #42601)\n */\nexport async function deriveGoToolchainConstraints(\n config: UpdateArtifactsConfig,\n newGoModContent: string,\n): Promise<string | undefined> {\n return await resolveToolConstraint(config, 'go', () =>\n getGoConstraints(newGoModContent),\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAgCA,MAAM,EAAE,OAAA,SAAO,OAAA,YAAU;AACzB,MAAM,UAAU,mBAAmB,CAAC,IAAI,CAAC;AAEzC,eAAe,wBACb,aACA,QACmB;CAEnB,MAAM,mBAAmB,YAAY,QAClC,EAAE,iBAAiB,CAACA,QAAM,UAAU,CACvC;CACA,IAAI,iBAAiB,SAAS,GAC5B,iBAAiB,SAAS,EAAE,cAC1B,OAAO,KACL,EAAE,QAAQ,GACV,kDACF,CACF;CAGF,MAAM,uBAAuB,YAC1B,QACE,EAAE,iBACDA,QAAM,UAAU,KAAK,CAAC,WAAY,SAAS,eAAe,CAC9D,CAAC,CACA,KAAK,EAAE,SAAS,kBAAkB;EACxB;EACT,UAAUC,QAAM,UAAW;CAC7B,EAAE,CAAC,CAEF,QACE,EAAE,SAAS,eACV,QAAQ,WAAW,WAAW,KAAK,WAAW,CAClD,CAAC,CAEA,KACE,EAAE,SAAS,eACV,0BAA0B,MAAM,OAAO,EAAE,MAAM,UACnD;CAEF,IAAI,qBAAqB,SAAS,GAAG;EACnC,IAAI,uBACF;EACF,MAAM,wBAAwB,MAAM,sBAClC,QACA,UACF;EACA,IAAI,uBAAuB;GACzB,IACE,sBAAsB,WAAW,GAAG,KACpCC,UAAQ,sBAAsB,QAAQ,MAAM,IAAI,GAAG,EAAE,CAAC,GAEtD,uBAAuB,qBAAqB,QAC1C,MAAM,UAAU,GAChB,IAAI,uBACN;QAEA,OAAO,MACL,EAAE,sBAAs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ACL,oBAAoB,aAAa,8BACnC;EACA,OAAO;CACT;CAUA,MAAM,gBAAgB,MAAM,iCAAiC,CAAC,CAAC,KAAK,OAAO,CAAC,EACxE,QAAQ;CACZ,IAAI,eACF,OAAO;CAIT,MAAM,QADK,MAAM,4BACF,CAAC,CAAC,KAAK,OAAO;CAC7B,IAAI,CAAC,OAAO,QAAQ,OAClB;CAEF,OAAO,IAAI,MAAM,OAAO;AAC1B;;;;;;;;;;;;;;;AAgBA,eAAsB,6BACpB,QACA,iBAC6B;CAC7B,OAAO,MAAM,sBAAsB,QAAQ,YACzC,iBAAiB,eAAe,CAClC;AACF"}
|
|
@@ -41,6 +41,7 @@ function extractPackageFile(content) {
|
|
|
41
41
|
if (goDirective?.currentValue) {
|
|
42
42
|
packageFile.extractedConstraints ??= {};
|
|
43
43
|
const range = convertGoDirectiveToSemVerRange(goDirective.currentValue);
|
|
44
|
+
// v8 ignore else -- a parsed go directive always yields a version
|
|
44
45
|
if (range.version) {
|
|
45
46
|
packageFile.extractedConstraints["%goMod"] = range.version;
|
|
46
47
|
packageFile.constraintsVersioning ??= {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract.js","names":[],"sources":["../../../../lib/modules/manager/gomod/extract.ts"],"sourcesContent":["import { newlineRegex } from '../../../util/regex.ts';\nimport type { PackageDependency, PackageFileContent } from '../types.ts';\nimport {\n endBlockRegex,\n excludeBlockStartRegex,\n parseLine,\n} from './line-parser.ts';\n\nfunction findMatchingModule(\n tool: PackageDependency,\n deps: PackageDependency[],\n): PackageDependency | undefined {\n let bestMatch: PackageDependency | undefined;\n const normalizedTool = `${tool.depName!}/`;\n\n // Find the longest matching prefix for the tool within the dependencies\n for (const dep of deps) {\n if (\n normalizedTool.startsWith(`${dep.depName!}/`) &&\n dep.depName!.length > (bestMatch?.depName!.length ?? 0)\n ) {\n bestMatch = dep;\n }\n }\n\n return bestMatch;\n}\n\nexport function extractPackageFile(content: string): PackageFileContent | null {\n const deps: PackageDependency[] = [];\n const tools: PackageDependency[] = [];\n let inExcludeBlock = false;\n\n const lines = content.split(newlineRegex);\n for (let lineNumber = 0; lineNumber < lines.length; lineNumber += 1) {\n const line = lines[lineNumber];\n const dep = parseLine(line);\n\n if (inExcludeBlock) {\n if (endBlockRegex.test(line)) {\n inExcludeBlock = false;\n }\n continue;\n }\n\n if (!dep) {\n if (excludeBlockStartRegex.test(line)) {\n inExcludeBlock = true;\n }\n continue;\n }\n\n if (dep.depType === 'tool') {\n tools.push(dep);\n continue;\n }\n\n dep.managerData ??= {};\n dep.managerData.lineNumber = lineNumber;\n\n deps.push(dep);\n }\n\n for (const tool of tools) {\n const match = findMatchingModule(tool, deps);\n if (match?.depType === 'indirect') {\n delete match.enabled;\n }\n }\n\n if (!deps.length) {\n return null;\n }\n\n const packageFile: PackageFileContent = {\n deps,\n };\n\n const goDirective = packageFile.deps.find(\n (dep) =>\n dep.depName === 'go' &&\n dep.depType === 'golang' &&\n dep.datasource === 'golang-version',\n );\n if (goDirective?.currentValue) {\n packageFile.extractedConstraints ??= {};\n const range = convertGoDirectiveToSemVerRange(goDirective.currentValue);\n if (range.version) {\n packageFile.extractedConstraints['%goMod'] = range.version;\n\n packageFile.constraintsVersioning ??= {};\n packageFile.constraintsVersioning['%goMod'] = range.versioning;\n }\n }\n\n const toolchainDirective = packageFile.deps.find(\n (dep) =>\n dep.depName === 'go' &&\n dep.depType === 'toolchain' &&\n dep.datasource === 'golang-version',\n );\n if (toolchainDirective?.currentValue) {\n packageFile.extractedConstraints ??= {};\n packageFile.extractedConstraints.golang = toolchainDirective.currentValue;\n }\n\n return packageFile;\n}\n\nexport function convertGoDirectiveToSemVerRange(\n goDirective: string | undefined,\n):\n | {\n version: string;\n versioning: string;\n }\n | {\n version: undefined;\n } {\n if (!goDirective) {\n return {\n version: undefined,\n };\n }\n\n const parts = goDirective.split('.');\n return {\n version: `~${parts[0]}.${parts[1]}.x`,\n versioning: 'semver-coerced',\n };\n}\n"],"mappings":";;;AAQ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cesContent":["import { newlineRegex } from '../../../util/regex.ts';\nimport type { PackageDependency, PackageFileContent } from '../types.ts';\nimport {\n endBlockRegex,\n excludeBlockStartRegex,\n parseLine,\n} from './line-parser.ts';\n\nfunction findMatchingModule(\n tool: PackageDependency,\n deps: PackageDependency[],\n): PackageDependency | undefined {\n let bestMatch: PackageDependency | undefined;\n const normalizedTool = `${tool.depName!}/`;\n\n // Find the longest matching prefix for the tool within the dependencies\n for (const dep of deps) {\n if (\n normalizedTool.startsWith(`${dep.depName!}/`) &&\n dep.depName!.length > (bestMatch?.depName!.length ?? 0)\n ) {\n bestMatch = dep;\n }\n }\n\n return bestMatch;\n}\n\nexport function extractPackageFile(content: string): PackageFileContent | null {\n const deps: PackageDependency[] = [];\n const tools: PackageDependency[] = [];\n let inExcludeBlock = false;\n\n const lines = content.split(newlineRegex);\n for (let lineNumber = 0; lineNumber < lines.length; lineNumber += 1) {\n const line = lines[lineNumber];\n const dep = parseLine(line);\n\n if (inExcludeBlock) {\n if (endBlockRegex.test(line)) {\n inExcludeBlock = false;\n }\n continue;\n }\n\n if (!dep) {\n if (excludeBlockStartRegex.test(line)) {\n inExcludeBlock = true;\n }\n continue;\n }\n\n if (dep.depType === 'tool') {\n tools.push(dep);\n continue;\n }\n\n dep.managerData ??= {};\n dep.managerData.lineNumber = lineNumber;\n\n deps.push(dep);\n }\n\n for (const tool of tools) {\n const match = findMatchingModule(tool, deps);\n if (match?.depType === 'indirect') {\n delete match.enabled;\n }\n }\n\n if (!deps.length) {\n return null;\n }\n\n const packageFile: PackageFileContent = {\n deps,\n };\n\n const goDirective = packageFile.deps.find(\n (dep) =>\n dep.depName === 'go' &&\n dep.depType === 'golang' &&\n dep.datasource === 'golang-version',\n );\n if (goDirective?.currentValue) {\n packageFile.extractedConstraints ??= {};\n const range = convertGoDirectiveToSemVerRange(goDirective.currentValue);\n // v8 ignore else -- a parsed go directive always yields a version\n if (range.version) {\n packageFile.extractedConstraints['%goMod'] = range.version;\n\n packageFile.constraintsVersioning ??= {};\n packageFile.constraintsVersioning['%goMod'] = range.versioning;\n }\n }\n\n const toolchainDirective = packageFile.deps.find(\n (dep) =>\n dep.depName === 'go' &&\n dep.depType === 'toolchain' &&\n dep.datasource === 'golang-version',\n );\n if (toolchainDirective?.currentValue) {\n packageFile.extractedConstraints ??= {};\n packageFile.extractedConstraints.golang = toolchainDirective.currentValue;\n }\n\n return packageFile;\n}\n\nexport function convertGoDirectiveToSemVerRange(\n goDirective: string | undefined,\n):\n | {\n version: string;\n versioning: string;\n }\n | {\n version: undefined;\n } {\n if (!goDirective) {\n return {\n version: undefined,\n };\n }\n\n const parts = goDirective.split('.');\n return {\n version: `~${parts[0]}.${parts[1]}.x`,\n versioning: 'semver-coerced',\n };\n}\n"],"mappings":";;;AAQA,SAAS,mBACP,MACA,MAC+B;CAC/B,IAAI;CACJ,MAAM,iBAAiB,GAAG,KAAK,QAAS;CAGxC,KAAK,MAAM,OAAO,MAChB,IACE,eAAe,WAAW,GAAG,IAAI,QAAS,EAAE,KAC5C,IAAI,QAAS,UAAU,WAAW,QAAS,UAAU,IAErD,YAAY;CAIhB,OAAO;AACT;AAEA,SAAgB,mBAAmB,SAA4C;CAC7E,MAAM,OAA4B,CAAC;CACnC,MAAM,QAA6B,CAAC;CACpC,IAAI,iBAAiB;CAErB,MAAM,QAAQ,QAAQ,MAAM,YAAY;CACxC,KAAK,IAAI,aAAa,GAAG,aAAa,MAAM,QAAQ,cAAc,GAAG;EACnE,MAAM,OAAO,MAAM;EACnB,MAAM,MAAM,UAAU,IAAI;EAE1B,IAAI,gBAAgB;GAClB,IAAI,cAAc,KAAK,IAAI,GACzB,iBAAiB;GAEnB;EACF;EAEA,IAAI,CAAC,KAAK;GACR,IAAI,uBAAuB,KAAK,IAAI,GAClC,iBAAiB;GAEnB;EACF;EAEA,IAAI,IAAI,YAAY,QAAQ;GAC1B,MAAM,KAAK,GAAG;GACd;EACF;EAEA,IAAI,gBAAgB,CAAC;EACrB,IAAI,YAAY,aAAa;EAE7B,KAAK,KAAK,GAAG;CACf;CAEA,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,QAAQ,mBAAmB,MAAM,IAAI;EAC3C,IAAI,OAAO,YAAY,YACrB,OAAO,MAAM;CAEjB;CAEA,IAAI,CAAC,KAAK,QACR,OAAO;CAGT,MAAM,cAAkC,EACtC,KACF;CAEA,MAAM,cAAc,YAAY,KAAK,MAClC,QACC,IAAI,YAAY,QAChB,IAAI,YAAY,YAChB,IAAI,eAAe,gBACvB;CACA,IAAI,aAAa,cAAc;EAC7B,YAAY,yBAAyB,CAAC;EACtC,MAAM,QAAQ,gCAAgC,YAAY,YAAY;;EAEtE,IAAI,MAAM,SAAS;GACjB,YAAY,qBAAqB,YAAY,MAAM;GAEnD,YAAY,0BAA0B,CAAC;GACvC,YAAY,sBAAsB,YAAY,MAAM;EACtD;CACF;CAEA,MAAM,qBAAqB,YAAY,KAAK,MACzC,QACC,IAAI,YAAY,QAChB,IAAI,YAAY,eAChB,IAAI,eAAe,gBACvB;CACA,IAAI,oBAAoB,cAAc;EACpC,YAAY,yBAAyB,CAAC;EACtC,YAAY,qBAAqB,SAAS,mBAAmB;CAC/D;CAEA,OAAO;AACT;AAEA,SAAgB,gCACd,aAQI;CACJ,IAAI,CAAC,aACH,OAAO,EACL,SAAS,KAAA,EACX;CAGF,MAAM,QAAQ,YAAY,MAAM,GAAG;CACnC,OAAO;EACL,SAAS,IAAI,MAAM,GAAG,GAAG,MAAM,GAAG;EAClC,YAAY;CACd;AACF"}
|
|
@@ -44,7 +44,7 @@ async function getSubProjectList(cmd, execOptions) {
|
|
|
44
44
|
if (subprojectsMatch?.groups?.subprojects) {
|
|
45
45
|
const projectRegex = regEx(/project '(?<name>.+?)'/g);
|
|
46
46
|
const matches = subprojectsMatch.groups.subprojects.matchAll(projectRegex);
|
|
47
|
-
for (const match of matches)
|
|
47
|
+
for (const match of matches) subprojects.push(match.groups.name);
|
|
48
48
|
}
|
|
49
49
|
return subprojects;
|
|
50
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifacts.js","names":[],"sources":["../../../../lib/modules/manager/gradle/artifacts.ts"],"sourcesContent":["import { isNonEmptyStringAndNotWhitespace } from '@sindresorhus/is';\nimport { quote } from 'shlex';\nimport upath from 'upath';\nimport { GlobalConfig } from '../../../config/global.ts';\nimport { TEMPORARY_ERROR } from '../../../constants/error-messages.ts';\nimport { logger } from '../../../logger/index.ts';\nimport {\n exec,\n getToolSettingsOptions,\n gradleJvmArg,\n} from '../../../util/exec/index.ts';\nimport type { ExecOptions } from '../../../util/exec/types.ts';\nimport {\n findUpLocal,\n readLocalFile,\n writeLocalFile,\n} from '../../../util/fs/index.ts';\nimport { getFiles, getRepoStatus } from '../../../util/git/index.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { scm } from '../../platform/scm.ts';\nimport {\n extraEnv,\n extractGradleVersion,\n getJavaConstraint,\n gradleWrapperFileName,\n prepareGradleCommand,\n} from '../gradle-wrapper/utils.ts';\nimport type { UpdateArtifact, UpdateArtifactsResult } from '../types.ts';\nimport { resolveToolConstraint } from '../util.ts';\nimport {\n isGcvLockFile,\n isGcvPropsFile,\n} from './extract/consistent-versions-plugin.ts';\nimport { isGradleBuildFile } from './utils.ts';\n\nexport function isGradleExecutionAllowed(command: string): boolean {\n const allowlist = GlobalConfig.get('allowedUnsafeExecutions');\n\n if (!allowlist.includes('gradleWrapper')) {\n logger.once.warn(\n { command },\n 'Gradle wrapper command was requested to run, but `gradleWrapper` is not permitted in the allowedUnsafeExecutions',\n );\n return false;\n }\n\n return true;\n}\n\n// .lockfile is gradle default lockfile, /versions.lock is gradle-consistent-versions plugin lockfile\nfunction isLockFile(fileName: string): boolean {\n return fileName.endsWith('.lockfile') || isGcvLockFile(fileName);\n}\n\nasync function getUpdatedLockfiles(\n oldLockFileContentMap: Record<string, string | null>,\n): Promise<UpdateArtifactsResult[]> {\n const res: UpdateArtifactsResult[] = [];\n\n const status = await getRepoStatus();\n\n for (const modifiedFile of status.modified) {\n if (\n isLockFile(modifiedFile) ||\n modifiedFile.endsWith('gradle/verification-metadata.xml')\n ) {\n const newContent = await readLocalFile(modifiedFile, 'utf8');\n if (oldLockFileContentMap[modifiedFile] !== newContent) {\n res.push({\n file: {\n type: 'addition',\n path: modifiedFile,\n contents: newContent,\n },\n });\n }\n }\n }\n\n return res;\n}\n\nasync function getSubProjectList(\n cmd: string,\n execOptions: ExecOptions,\n): Promise<string[]> {\n const subprojects = ['']; // = root project\n const subprojectsRegex = regEx(/^[ \\t]*subprojects: \\[(?<subprojects>.+)\\]/m);\n\n const gradleProperties = await exec(`${cmd} properties`, execOptions);\n const subprojectsMatch = gradleProperties.stdout.match(subprojectsRegex);\n if (subprojectsMatch?.groups?.subprojects) {\n const projectRegex = regEx(/project '(?<name>.+?)'/g);\n const matches = subprojectsMatch.groups.subprojects.matchAll(projectRegex);\n for (const match of matches) {\n if (match?.groups?.name) {\n subprojects.push(match.groups.name);\n }\n }\n }\n\n return subprojects;\n}\n\nasync function getGradleVersion(gradlewFile: string): Promise<string | null> {\n const propertiesFile = upath.join(\n upath.dirname(gradlewFile),\n 'gradle/wrapper/gradle-wrapper.properties',\n );\n const properties = await readLocalFile(propertiesFile, 'utf8');\n const extractResult = extractGradleVersion(properties ?? '');\n\n return extractResult ? extractResult.version : null;\n}\n\nasync function buildUpdateVerificationMetadataCmd(\n verificationMetadataFile: string | undefined,\n baseCmd: string,\n): Promise<string | null> {\n if (!verificationMetadataFile) {\n return null;\n }\n\n const verificationMetadata = await readLocalFile(verificationMetadataFile);\n const verifiesChecksums = verificationMetadata?.includes(\n '<verify-metadata>true</verify-metadata>',\n );\n const verifiesSignatures = verificationMetadata?.includes(\n '<verify-signatures>true</verify-signatures>',\n );\n\n const hashTypes = ['sha256', 'sha512'].filter((type) =>\n verificationMetadata?.includes(`<${type} `),\n );\n\n if (verifiesChecksums || hashTypes.length) {\n logger.debug(\n 'Dependency metadata verification enabled or checksums present - generating checksums',\n );\n }\n\n if ((verifiesChecksums || verifiesSignatures) && !hashTypes.length) {\n // fallback algorithm for pgp and in case a weak algorithm (md5, sha1) is used for checksums\n hashTypes.push('sha256');\n }\n\n if (verifiesSignatures) {\n logger.debug(\n 'Dependency signature verification enabled - generating PGP signatures',\n );\n hashTypes.push('pgp');\n }\n\n if (!hashTypes.length) {\n return null;\n }\n\n return `${baseCmd} --write-verification-metadata ${hashTypes.join(',')} dependencies`;\n}\n\nexport async function updateArtifacts({\n packageFileName,\n updatedDeps,\n newPackageFileContent,\n config,\n}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {\n logger.debug(`gradle.updateArtifacts(${packageFileName})`);\n\n const fileList = await scm.getFileList();\n const lockFiles = fileList.filter((file) => isLockFile(file));\n const verificationMetadataFile = fileList.find((fileName) =>\n fileName.endsWith('gradle/verification-metadata.xml'),\n );\n if (!lockFiles.length && !verificationMetadataFile) {\n logger.debug(\n 'No Gradle dependency lockfiles or verification metadata found - skipping update',\n );\n return null;\n }\n\n const gradlewName = gradleWrapperFileName();\n const gradlewFile = await findUpLocal(\n gradlewName,\n upath.dirname(packageFileName),\n );\n if (!gradlewFile) {\n logger.debug(\n 'Found Gradle dependency lockfiles but no gradlew - aborting update',\n );\n return null;\n }\n\n if (\n config.isLockFileMaintenance &&\n (!isGradleBuildFile(packageFileName) ||\n upath.dirname(packageFileName) !== upath.dirname(gradlewFile))\n ) {\n logger.trace(\n 'No build.gradle(.kts) file or not in root project - skipping lock file maintenance',\n );\n return null;\n }\n\n if (!isGradleExecutionAllowed(gradlewFile)) {\n logger.trace(\n 'Not allowed to execute gradle due to allowedUnsafeExecutions - aborting update',\n );\n return null;\n }\n\n logger.debug('Updating found Gradle dependency lockfiles');\n\n try {\n const oldLockFileContentMap = await getFiles(lockFiles);\n await prepareGradleCommand(gradlewFile);\n\n const baseCmd = `${gradlewName}${gradleJvmArg(getToolSettingsOptions(config.toolSettings))} --console=plain --dependency-verification lenient -q`;\n const execOptions: ExecOptions = {\n cwdFile: gradlewFile,\n docker: {},\n extraEnv,\n toolConstraints: [\n {\n toolName: 'java',\n constraint: await resolveToolConstraint(config, 'java', async () =>\n getJavaConstraint(await getGradleVersion(gradlewFile), gradlewFile),\n ),\n },\n ],\n };\n\n const cmds = [];\n if (lockFiles.length) {\n const subprojects = await getSubProjectList(baseCmd, execOptions);\n let lockfileCmd = `${baseCmd} ${subprojects\n .map((project) => `${project}:dependencies`)\n .map(quote)\n .join(' ')}`;\n\n if (\n config.isLockFileMaintenance === true ||\n !updatedDeps.length ||\n isGcvPropsFile(packageFileName)\n ) {\n lockfileCmd += ' --write-locks';\n } else {\n const updatedDepNames = updatedDeps\n .map(({ depName, packageName }) => packageName ?? depName)\n .filter(isNonEmptyStringAndNotWhitespace);\n\n lockfileCmd += ` --update-locks ${updatedDepNames\n .map(quote)\n .join(',')}`;\n }\n cmds.push(lockfileCmd);\n }\n\n const updateVerificationMetadataCmd =\n await buildUpdateVerificationMetadataCmd(\n verificationMetadataFile,\n baseCmd,\n );\n if (updateVerificationMetadataCmd) {\n cmds.push(updateVerificationMetadataCmd);\n }\n\n if (!cmds.length) {\n logger.debug('No lockfile or verification metadata update necessary');\n return null;\n }\n\n await writeLocalFile(packageFileName, newPackageFileContent);\n await exec(cmds, { ...execOptions, ignoreStdout: true });\n\n const res = await getUpdatedLockfiles(oldLockFileContentMap);\n logger.debug('Returning updated Gradle dependency lockfiles');\n\n return res.length > 0 ? res : null;\n } catch (err) {\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n\n logger.debug({ err }, 'Error while updating Gradle dependency lockfiles');\n return [\n {\n artifactError: {\n fileName: packageFileName,\n stderr: err.message,\n },\n },\n ];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAmCA,SAAgB,yBAAyB,SAA0B;CAGjE,IAAI,CAFc,aAAa,IAAI,yBAEtB,CAAC,CAAC,SAAS,eAAe,GAAG;EACxC,OAAO,KAAK,KACV,EAAE,QAAQ,GACV,kHACF;EAC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AU;GACV,QAAQ,IAAI;EACd,EACF,CACF;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"artifacts.js","names":[],"sources":["../../../../lib/modules/manager/gradle/artifacts.ts"],"sourcesContent":["import { isNonEmptyStringAndNotWhitespace } from '@sindresorhus/is';\nimport { quote } from 'shlex';\nimport upath from 'upath';\nimport { GlobalConfig } from '../../../config/global.ts';\nimport { TEMPORARY_ERROR } from '../../../constants/error-messages.ts';\nimport { logger } from '../../../logger/index.ts';\nimport {\n exec,\n getToolSettingsOptions,\n gradleJvmArg,\n} from '../../../util/exec/index.ts';\nimport type { ExecOptions } from '../../../util/exec/types.ts';\nimport {\n findUpLocal,\n readLocalFile,\n writeLocalFile,\n} from '../../../util/fs/index.ts';\nimport { getFiles, getRepoStatus } from '../../../util/git/index.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { scm } from '../../platform/scm.ts';\nimport {\n extraEnv,\n extractGradleVersion,\n getJavaConstraint,\n gradleWrapperFileName,\n prepareGradleCommand,\n} from '../gradle-wrapper/utils.ts';\nimport type { UpdateArtifact, UpdateArtifactsResult } from '../types.ts';\nimport { resolveToolConstraint } from '../util.ts';\nimport {\n isGcvLockFile,\n isGcvPropsFile,\n} from './extract/consistent-versions-plugin.ts';\nimport { isGradleBuildFile } from './utils.ts';\n\nexport function isGradleExecutionAllowed(command: string): boolean {\n const allowlist = GlobalConfig.get('allowedUnsafeExecutions');\n\n if (!allowlist.includes('gradleWrapper')) {\n logger.once.warn(\n { command },\n 'Gradle wrapper command was requested to run, but `gradleWrapper` is not permitted in the allowedUnsafeExecutions',\n );\n return false;\n }\n\n return true;\n}\n\n// .lockfile is gradle default lockfile, /versions.lock is gradle-consistent-versions plugin lockfile\nfunction isLockFile(fileName: string): boolean {\n return fileName.endsWith('.lockfile') || isGcvLockFile(fileName);\n}\n\nasync function getUpdatedLockfiles(\n oldLockFileContentMap: Record<string, string | null>,\n): Promise<UpdateArtifactsResult[]> {\n const res: UpdateArtifactsResult[] = [];\n\n const status = await getRepoStatus();\n\n for (const modifiedFile of status.modified) {\n if (\n isLockFile(modifiedFile) ||\n modifiedFile.endsWith('gradle/verification-metadata.xml')\n ) {\n const newContent = await readLocalFile(modifiedFile, 'utf8');\n if (oldLockFileContentMap[modifiedFile] !== newContent) {\n res.push({\n file: {\n type: 'addition',\n path: modifiedFile,\n contents: newContent,\n },\n });\n }\n }\n }\n\n return res;\n}\n\nasync function getSubProjectList(\n cmd: string,\n execOptions: ExecOptions,\n): Promise<string[]> {\n const subprojects = ['']; // = root project\n const subprojectsRegex = regEx(/^[ \\t]*subprojects: \\[(?<subprojects>.+)\\]/m);\n\n const gradleProperties = await exec(`${cmd} properties`, execOptions);\n const subprojectsMatch = gradleProperties.stdout.match(subprojectsRegex);\n if (subprojectsMatch?.groups?.subprojects) {\n const projectRegex = regEx(/project '(?<name>.+?)'/g);\n const matches = subprojectsMatch.groups.subprojects.matchAll(projectRegex);\n for (const match of matches) {\n subprojects.push(match.groups!.name);\n }\n }\n\n return subprojects;\n}\n\nasync function getGradleVersion(gradlewFile: string): Promise<string | null> {\n const propertiesFile = upath.join(\n upath.dirname(gradlewFile),\n 'gradle/wrapper/gradle-wrapper.properties',\n );\n const properties = await readLocalFile(propertiesFile, 'utf8');\n const extractResult = extractGradleVersion(properties ?? '');\n\n return extractResult ? extractResult.version : null;\n}\n\nasync function buildUpdateVerificationMetadataCmd(\n verificationMetadataFile: string | undefined,\n baseCmd: string,\n): Promise<string | null> {\n if (!verificationMetadataFile) {\n return null;\n }\n\n const verificationMetadata = await readLocalFile(verificationMetadataFile);\n const verifiesChecksums = verificationMetadata?.includes(\n '<verify-metadata>true</verify-metadata>',\n );\n const verifiesSignatures = verificationMetadata?.includes(\n '<verify-signatures>true</verify-signatures>',\n );\n\n const hashTypes = ['sha256', 'sha512'].filter((type) =>\n verificationMetadata?.includes(`<${type} `),\n );\n\n if (verifiesChecksums || hashTypes.length) {\n logger.debug(\n 'Dependency metadata verification enabled or checksums present - generating checksums',\n );\n }\n\n if ((verifiesChecksums || verifiesSignatures) && !hashTypes.length) {\n // fallback algorithm for pgp and in case a weak algorithm (md5, sha1) is used for checksums\n hashTypes.push('sha256');\n }\n\n if (verifiesSignatures) {\n logger.debug(\n 'Dependency signature verification enabled - generating PGP signatures',\n );\n hashTypes.push('pgp');\n }\n\n if (!hashTypes.length) {\n return null;\n }\n\n return `${baseCmd} --write-verification-metadata ${hashTypes.join(',')} dependencies`;\n}\n\nexport async function updateArtifacts({\n packageFileName,\n updatedDeps,\n newPackageFileContent,\n config,\n}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {\n logger.debug(`gradle.updateArtifacts(${packageFileName})`);\n\n const fileList = await scm.getFileList();\n const lockFiles = fileList.filter((file) => isLockFile(file));\n const verificationMetadataFile = fileList.find((fileName) =>\n fileName.endsWith('gradle/verification-metadata.xml'),\n );\n if (!lockFiles.length && !verificationMetadataFile) {\n logger.debug(\n 'No Gradle dependency lockfiles or verification metadata found - skipping update',\n );\n return null;\n }\n\n const gradlewName = gradleWrapperFileName();\n const gradlewFile = await findUpLocal(\n gradlewName,\n upath.dirname(packageFileName),\n );\n if (!gradlewFile) {\n logger.debug(\n 'Found Gradle dependency lockfiles but no gradlew - aborting update',\n );\n return null;\n }\n\n if (\n config.isLockFileMaintenance &&\n (!isGradleBuildFile(packageFileName) ||\n upath.dirname(packageFileName) !== upath.dirname(gradlewFile))\n ) {\n logger.trace(\n 'No build.gradle(.kts) file or not in root project - skipping lock file maintenance',\n );\n return null;\n }\n\n if (!isGradleExecutionAllowed(gradlewFile)) {\n logger.trace(\n 'Not allowed to execute gradle due to allowedUnsafeExecutions - aborting update',\n );\n return null;\n }\n\n logger.debug('Updating found Gradle dependency lockfiles');\n\n try {\n const oldLockFileContentMap = await getFiles(lockFiles);\n await prepareGradleCommand(gradlewFile);\n\n const baseCmd = `${gradlewName}${gradleJvmArg(getToolSettingsOptions(config.toolSettings))} --console=plain --dependency-verification lenient -q`;\n const execOptions: ExecOptions = {\n cwdFile: gradlewFile,\n docker: {},\n extraEnv,\n toolConstraints: [\n {\n toolName: 'java',\n constraint: await resolveToolConstraint(config, 'java', async () =>\n getJavaConstraint(await getGradleVersion(gradlewFile), gradlewFile),\n ),\n },\n ],\n };\n\n const cmds = [];\n if (lockFiles.length) {\n const subprojects = await getSubProjectList(baseCmd, execOptions);\n let lockfileCmd = `${baseCmd} ${subprojects\n .map((project) => `${project}:dependencies`)\n .map(quote)\n .join(' ')}`;\n\n if (\n config.isLockFileMaintenance === true ||\n !updatedDeps.length ||\n isGcvPropsFile(packageFileName)\n ) {\n lockfileCmd += ' --write-locks';\n } else {\n const updatedDepNames = updatedDeps\n .map(({ depName, packageName }) => packageName ?? depName)\n .filter(isNonEmptyStringAndNotWhitespace);\n\n lockfileCmd += ` --update-locks ${updatedDepNames\n .map(quote)\n .join(',')}`;\n }\n cmds.push(lockfileCmd);\n }\n\n const updateVerificationMetadataCmd =\n await buildUpdateVerificationMetadataCmd(\n verificationMetadataFile,\n baseCmd,\n );\n if (updateVerificationMetadataCmd) {\n cmds.push(updateVerificationMetadataCmd);\n }\n\n if (!cmds.length) {\n logger.debug('No lockfile or verification metadata update necessary');\n return null;\n }\n\n await writeLocalFile(packageFileName, newPackageFileContent);\n await exec(cmds, { ...execOptions, ignoreStdout: true });\n\n const res = await getUpdatedLockfiles(oldLockFileContentMap);\n logger.debug('Returning updated Gradle dependency lockfiles');\n\n return res.length > 0 ? res : null;\n } catch (err) {\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n\n logger.debug({ err }, 'Error while updating Gradle dependency lockfiles');\n return [\n {\n artifactError: {\n fileName: packageFileName,\n stderr: err.message,\n },\n },\n ];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAmCA,SAAgB,yBAAyB,SAA0B;CAGjE,IAAI,CAFc,aAAa,IAAI,yBAEtB,CAAC,CAAC,SAAS,eAAe,GAAG;EACxC,OAAO,KAAK,KACV,EAAE,QAAQ,GACV,kHACF;EACA,OA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F,CACF;CACF;AACF"}
|
|
@@ -58,6 +58,7 @@ async function getJvmConfiguration(gradlewFile) {
|
|
|
58
58
|
const daemonJvm = await readLocalFile(daemonJvmFile, "utf8");
|
|
59
59
|
if (daemonJvm) {
|
|
60
60
|
const toolChainMatch = regEx("^(?:toolchainVersion\\s*=\\s*)(?<version>\\d+)$", "m").exec(daemonJvm);
|
|
61
|
+
// v8 ignore else -- needs a daemon-jvm file without a toolchain version
|
|
61
62
|
if (toolChainMatch?.groups) return toolChainMatch.groups.version;
|
|
62
63
|
}
|
|
63
64
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["gradleVersioning"],"sources":["../../../../lib/modules/manager/gradle-wrapper/utils.ts"],"sourcesContent":["import os from 'node:os';\nimport upath from 'upath';\nimport { GlobalConfig } from '../../../config/global.ts';\nimport { logger } from '../../../logger/index.ts';\nimport {\n chmodLocalFile,\n localPathExists,\n readLocalFile,\n statLocalFile,\n} from '../../../util/fs/index.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport gradleVersioning from '../../versioning/gradle/index.ts';\nimport { parseJavaToolchainVersion } from '../gradle/parser.ts';\nimport type { GradleVersionExtract } from './types.ts';\n\nexport const extraEnv = {\n GRADLE_OPTS:\n '-Dorg.gradle.parallel=true -Dorg.gradle.configureondemand=true -Dorg.gradle.daemon=false -Dorg.gradle.caching=false',\n};\n\nexport function gradleWrapperFileName(): string {\n if (\n os.platform() === 'win32' &&\n GlobalConfig.get('binarySource') !== 'docker'\n ) {\n return 'gradlew.bat';\n }\n return './gradlew';\n}\n\nexport async function prepareGradleCommand(\n gradlewFile: string,\n): Promise<string | null> {\n const gradlewStat = await statLocalFile(gradlewFile);\n if (gradlewStat?.isFile() === true) {\n // if the file is not executable by others\n if (os.platform() !== 'win32' && (gradlewStat.mode & 0o1) === 0) {\n logger.debug('Gradle wrapper is missing the executable bit');\n // add the execution permission to the owner, group and others\n await chmodLocalFile(gradlewFile, gradlewStat.mode | 0o111);\n }\n return gradleWrapperFileName();\n }\n return null;\n}\n\n/**\n * Find compatible java version for gradle.\n * see https://docs.gradle.org/current/userguide/compatibility.html\n * @param gradleVersion current gradle version\n * @param gradlewFile path to gradle wrapper\n * @returns A Java semver range\n */\nexport async function getJavaConstraint(\n gradleVersion: string | null | undefined,\n gradlewFile: string,\n): Promise<string> {\n const major = gradleVersion ? gradleVersioning.getMajor(gradleVersion) : null;\n const minor = gradleVersion ? gradleVersioning.getMinor(gradleVersion) : null;\n\n if (major) {\n // https://docs.gradle.org/8.8/release-notes.html#daemon-toolchains\n if (major > 8 || (major === 8 && minor && minor >= 8)) {\n const toolChainVersion = await getJvmConfiguration(gradlewFile);\n if (toolChainVersion) {\n return `^${toolChainVersion}.0.0`;\n }\n }\n // https://docs.gradle.org/6.7/release-notes.html#new-jvm-ecosystem-features\n if (major > 6 || (major === 6 && minor && minor >= 7)) {\n const languageVersion = await getJavaLanguageVersion(gradlewFile);\n if (languageVersion) {\n return `^${languageVersion}.0.0`;\n }\n }\n if (major > 9 || (major === 9 && minor && minor >= 1)) {\n return '^25.0.0';\n }\n if (major > 8 || (major === 8 && minor && minor >= 5)) {\n return '^21.0.0';\n }\n if (major > 7 || (major === 7 && minor && minor >= 3)) {\n return '^17.0.0';\n }\n if (major === 7) {\n return '^16.0.0';\n }\n // first public gradle version was 2.0\n if (major > 0 && major < 5) {\n return '^8.0.0';\n }\n }\n\n return '^11.0.0';\n}\n\n/**\n * https://docs.gradle.org/current/userguide/gradle_daemon.html#sec:daemon_jvm_criteria\n */\nexport async function getJvmConfiguration(\n gradlewFile: string,\n): Promise<string | null> {\n const daemonJvmFile = upath.join(\n upath.dirname(gradlewFile),\n 'gradle/gradle-daemon-jvm.properties',\n );\n const daemonJvm = await readLocalFile(daemonJvmFile, 'utf8');\n if (daemonJvm) {\n const TOOLCHAIN_VERSION_REGEX = regEx(\n '^(?:toolchainVersion\\\\s*=\\\\s*)(?<version>\\\\d+)$',\n 'm',\n );\n const toolChainMatch = TOOLCHAIN_VERSION_REGEX.exec(daemonJvm);\n if (toolChainMatch?.groups) {\n return toolChainMatch.groups.version;\n }\n }\n\n return null;\n}\n\n/**\n * https://docs.gradle.org/current/userguide/toolchains.html#sec:consuming\n */\nexport async function getJavaLanguageVersion(\n gradlewFile: string,\n): Promise<string | null> {\n const localGradleDir = upath.dirname(gradlewFile);\n let buildFileName = upath.join(localGradleDir, 'build.gradle');\n if (!(await localPathExists(buildFileName))) {\n buildFileName = upath.join(localGradleDir, 'build.gradle.kts');\n }\n\n const buildFileContent = await readLocalFile(buildFileName, 'utf8');\n if (!buildFileContent) {\n logger.debug('build.gradle or build.gradle.kts not found');\n return null;\n }\n\n return parseJavaToolchainVersion(buildFileContent);\n}\n\n// https://regex101.com/r/IcOs7P/1\nconst DISTRIBUTION_URL_REGEX = regEx(\n '^(?:distributionUrl\\\\s*=\\\\s*)(?<url>\\\\S*-(?<version>\\\\d+\\\\.\\\\d+(?:\\\\.\\\\d+)?(?:-\\\\w+)*)-(?<type>bin|all)\\\\.zip)\\\\s*$',\n 'm',\n);\n\nexport function extractGradleVersion(\n fileContent: string,\n): GradleVersionExtract | null {\n const distributionUrlMatch = DISTRIBUTION_URL_REGEX.exec(fileContent);\n if (distributionUrlMatch?.groups) {\n return {\n url: distributionUrlMatch.groups.url,\n version: distributionUrlMatch.groups.version,\n };\n }\n logger.debug(\n 'Gradle wrapper version and url could not be extracted from properties - skipping update',\n );\n\n return null;\n}\n"],"mappings":";;;;;;;;;AAeA,MAAa,WAAW,EACtB,aACE,sHACJ;AAEA,SAAgB,wBAAgC;CAC9C,IACE,GAAG,SAAS,MAAM,WAClB,aAAa,IAAI,cAAc,MAAM,UAErC,OAAO;CAET,OAAO;AACT;AAEA,eAAsB,qBACpB,aACwB;CACxB,MAAM,cAAc,MAAM,cAAc,WAAW;CACnD,IAAI,aAAa,OAAO,MAAM,MAAM;EAElC,IAAI,GAAG,SAAS,MAAM,YAAY,YAAY,OAAO,OAAS,GAAG;GAC/D,OAAO,MAAM,8CAA8C;GAE3D,MAAM,eAAe,aAAa,YAAY,OAAO,EAAK;EAC5D;EACA,OAAO,sBAAsB;CAC/B;CACA,OAAO;AACT;;;;;;;;AASA,eAAsB,kBACpB,eACA,aACiB;CACjB,MAAM,QAAQ,gBAAgBA,IAAiB,SAAS,aAAa,IAAI;CACzE,MAAM,QAAQ,gBAAgBA,IAAiB,SAAS,aAAa,IAAI;CAEzE,IAAI,OAAO;EAET,IAAI,QAAQ,KAAM,UAAU,KAAK,SAAS,SAAS,GAAI;GACrD,MAAM,mBAAmB,MAAM,oBAAoB,WAAW;GAC9D,IAAI,kBACF,OAAO,IAAI,iBAAiB;EAEhC;EAEA,IAAI,QAAQ,KAAM,UAAU,KAAK,SAAS,SAAS,GAAI;GACrD,MAAM,kBAAkB,MAAM,uBAAuB,WAAW;GAChE,IAAI,iBACF,OAAO,IAAI,gBAAgB;EAE/B;EACA,IAAI,QAAQ,KAAM,UAAU,KAAK,SAAS,SAAS,GACjD,OAAO;EAET,IAAI,QAAQ,KAAM,UAAU,KAAK,SAAS,SAAS,GACjD,OAAO;EAET,IAAI,QAAQ,KAAM,UAAU,KAAK,SAAS,SAAS,GACjD,OAAO;EAET,IAAI,UAAU,GACZ,OAAO;EAGT,IAAI,QAAQ,KAAK,QAAQ,GACvB,OAAO;CAEX;CAEA,OAAO;AACT;;;;AAKA,eAAsB,oBACpB,aACwB;CACxB,MAAM,gBAAgB,MAAM,KAC1B,MAAM,QAAQ,WAAW,GACzB,qCACF;CACA,MAAM,YAAY,MAAM,cAAc,eAAe,MAAM;CAC3D,IAAI,WAAW;EAKb,MAAM,iBAJ0B,MAC9B,mDACA,GAE2C,CAAC,CAAC,KAAK,SAAS
|
|
1
|
+
{"version":3,"file":"utils.js","names":["gradleVersioning"],"sources":["../../../../lib/modules/manager/gradle-wrapper/utils.ts"],"sourcesContent":["import os from 'node:os';\nimport upath from 'upath';\nimport { GlobalConfig } from '../../../config/global.ts';\nimport { logger } from '../../../logger/index.ts';\nimport {\n chmodLocalFile,\n localPathExists,\n readLocalFile,\n statLocalFile,\n} from '../../../util/fs/index.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport gradleVersioning from '../../versioning/gradle/index.ts';\nimport { parseJavaToolchainVersion } from '../gradle/parser.ts';\nimport type { GradleVersionExtract } from './types.ts';\n\nexport const extraEnv = {\n GRADLE_OPTS:\n '-Dorg.gradle.parallel=true -Dorg.gradle.configureondemand=true -Dorg.gradle.daemon=false -Dorg.gradle.caching=false',\n};\n\nexport function gradleWrapperFileName(): string {\n if (\n os.platform() === 'win32' &&\n GlobalConfig.get('binarySource') !== 'docker'\n ) {\n return 'gradlew.bat';\n }\n return './gradlew';\n}\n\nexport async function prepareGradleCommand(\n gradlewFile: string,\n): Promise<string | null> {\n const gradlewStat = await statLocalFile(gradlewFile);\n if (gradlewStat?.isFile() === true) {\n // if the file is not executable by others\n if (os.platform() !== 'win32' && (gradlewStat.mode & 0o1) === 0) {\n logger.debug('Gradle wrapper is missing the executable bit');\n // add the execution permission to the owner, group and others\n await chmodLocalFile(gradlewFile, gradlewStat.mode | 0o111);\n }\n return gradleWrapperFileName();\n }\n return null;\n}\n\n/**\n * Find compatible java version for gradle.\n * see https://docs.gradle.org/current/userguide/compatibility.html\n * @param gradleVersion current gradle version\n * @param gradlewFile path to gradle wrapper\n * @returns A Java semver range\n */\nexport async function getJavaConstraint(\n gradleVersion: string | null | undefined,\n gradlewFile: string,\n): Promise<string> {\n const major = gradleVersion ? gradleVersioning.getMajor(gradleVersion) : null;\n const minor = gradleVersion ? gradleVersioning.getMinor(gradleVersion) : null;\n\n if (major) {\n // https://docs.gradle.org/8.8/release-notes.html#daemon-toolchains\n if (major > 8 || (major === 8 && minor && minor >= 8)) {\n const toolChainVersion = await getJvmConfiguration(gradlewFile);\n if (toolChainVersion) {\n return `^${toolChainVersion}.0.0`;\n }\n }\n // https://docs.gradle.org/6.7/release-notes.html#new-jvm-ecosystem-features\n if (major > 6 || (major === 6 && minor && minor >= 7)) {\n const languageVersion = await getJavaLanguageVersion(gradlewFile);\n if (languageVersion) {\n return `^${languageVersion}.0.0`;\n }\n }\n if (major > 9 || (major === 9 && minor && minor >= 1)) {\n return '^25.0.0';\n }\n if (major > 8 || (major === 8 && minor && minor >= 5)) {\n return '^21.0.0';\n }\n if (major > 7 || (major === 7 && minor && minor >= 3)) {\n return '^17.0.0';\n }\n if (major === 7) {\n return '^16.0.0';\n }\n // first public gradle version was 2.0\n if (major > 0 && major < 5) {\n return '^8.0.0';\n }\n }\n\n return '^11.0.0';\n}\n\n/**\n * https://docs.gradle.org/current/userguide/gradle_daemon.html#sec:daemon_jvm_criteria\n */\nexport async function getJvmConfiguration(\n gradlewFile: string,\n): Promise<string | null> {\n const daemonJvmFile = upath.join(\n upath.dirname(gradlewFile),\n 'gradle/gradle-daemon-jvm.properties',\n );\n const daemonJvm = await readLocalFile(daemonJvmFile, 'utf8');\n if (daemonJvm) {\n const TOOLCHAIN_VERSION_REGEX = regEx(\n '^(?:toolchainVersion\\\\s*=\\\\s*)(?<version>\\\\d+)$',\n 'm',\n );\n const toolChainMatch = TOOLCHAIN_VERSION_REGEX.exec(daemonJvm);\n // v8 ignore else -- needs a daemon-jvm file without a toolchain version\n if (toolChainMatch?.groups) {\n return toolChainMatch.groups.version;\n }\n }\n\n return null;\n}\n\n/**\n * https://docs.gradle.org/current/userguide/toolchains.html#sec:consuming\n */\nexport async function getJavaLanguageVersion(\n gradlewFile: string,\n): Promise<string | null> {\n const localGradleDir = upath.dirname(gradlewFile);\n let buildFileName = upath.join(localGradleDir, 'build.gradle');\n if (!(await localPathExists(buildFileName))) {\n buildFileName = upath.join(localGradleDir, 'build.gradle.kts');\n }\n\n const buildFileContent = await readLocalFile(buildFileName, 'utf8');\n if (!buildFileContent) {\n logger.debug('build.gradle or build.gradle.kts not found');\n return null;\n }\n\n return parseJavaToolchainVersion(buildFileContent);\n}\n\n// https://regex101.com/r/IcOs7P/1\nconst DISTRIBUTION_URL_REGEX = regEx(\n '^(?:distributionUrl\\\\s*=\\\\s*)(?<url>\\\\S*-(?<version>\\\\d+\\\\.\\\\d+(?:\\\\.\\\\d+)?(?:-\\\\w+)*)-(?<type>bin|all)\\\\.zip)\\\\s*$',\n 'm',\n);\n\nexport function extractGradleVersion(\n fileContent: string,\n): GradleVersionExtract | null {\n const distributionUrlMatch = DISTRIBUTION_URL_REGEX.exec(fileContent);\n if (distributionUrlMatch?.groups) {\n return {\n url: distributionUrlMatch.groups.url,\n version: distributionUrlMatch.groups.version,\n };\n }\n logger.debug(\n 'Gradle wrapper version and url could not be extracted from properties - skipping update',\n );\n\n return null;\n}\n"],"mappings":";;;;;;;;;AAeA,MAAa,WAAW,EACtB,aACE,sHACJ;AAEA,SAAgB,wBAAgC;CAC9C,IACE,GAAG,SAAS,MAAM,WAClB,aAAa,IAAI,cAAc,MAAM,UAErC,OAAO;CAET,OAAO;AACT;AAEA,eAAsB,qBACpB,aACwB;CACxB,MAAM,cAAc,MAAM,cAAc,WAAW;CACnD,IAAI,aAAa,OAAO,MAAM,MAAM;EAElC,IAAI,GAAG,SAAS,MAAM,YAAY,YAAY,OAAO,OAAS,GAAG;GAC/D,OAAO,MAAM,8CAA8C;GAE3D,MAAM,eAAe,aAAa,YAAY,OAAO,EAAK;EAC5D;EACA,OAAO,sBAAsB;CAC/B;CACA,OAAO;AACT;;;;;;;;AASA,eAAsB,kBACpB,eACA,aACiB;CACjB,MAAM,QAAQ,gBAAgBA,IAAiB,SAAS,aAAa,IAAI;CACzE,MAAM,QAAQ,gBAAgBA,IAAiB,SAAS,aAAa,IAAI;CAEzE,IAAI,OAAO;EAET,IAAI,QAAQ,KAAM,UAAU,KAAK,SAAS,SAAS,GAAI;GACrD,MAAM,mBAAmB,MAAM,oBAAoB,WAAW;GAC9D,IAAI,kBACF,OAAO,IAAI,iBAAiB;EAEhC;EAEA,IAAI,QAAQ,KAAM,UAAU,KAAK,SAAS,SAAS,GAAI;GACrD,MAAM,kBAAkB,MA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1,5 +1,6 @@
|
|
|
1
1
|
import { regEx } from "../../../../../util/regex.js";
|
|
2
2
|
import { coerceArray } from "../../../../../util/array.js";
|
|
3
|
+
import { coerceString } from "../../../../../util/string.js";
|
|
3
4
|
import { logger } from "../../../../../logger/index.js";
|
|
4
5
|
import { isConstraintName } from "../../../../../util/exec/types.js";
|
|
5
6
|
import { api, isValid, isVersion } from "../../../../versioning/npm/index.js";
|
|
@@ -22,7 +23,7 @@ function parseDepName(depType, key) {
|
|
|
22
23
|
} else segments.push(part);
|
|
23
24
|
}
|
|
24
25
|
const lastSegment = segments.at(-1);
|
|
25
|
-
const [, depName] = coerceArray(regEx(/^(?<depName>(?:@[^/]+\/)?[^@]+)/).exec(lastSegment
|
|
26
|
+
const [, depName] = coerceArray(regEx(/^(?<depName>(?:@[^/]+\/)?[^@]+)/).exec(coerceString(lastSegment)));
|
|
26
27
|
return depName;
|
|
27
28
|
}
|
|
28
29
|
function extractDependency(depType, depName, input) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependency.js","names":[],"sources":["../../../../../../lib/modules/manager/npm/extract/common/dependency.ts"],"sourcesContent":["import { isString } from '@sindresorhus/is';\nimport validateNpmPackageName from 'validate-npm-package-name';\nimport { logger } from '../../../../../logger/index.ts';\nimport { coerceArray } from '../../../../../util/array.ts';\nimport type { ConstraintName } from '../../../../../util/exec/types.ts';\nimport { isConstraintName } from '../../../../../util/exec/types.ts';\nimport { regEx } from '../../../../../util/regex.ts';\nimport { GithubTagsDatasource } from '../../../../datasource/github-tags/index.ts';\nimport { NodeVersionDatasource } from '../../../../datasource/node-version/index.ts';\nimport { NpmDatasource } from '../../../../datasource/npm/index.ts';\nimport {\n api,\n isValid,\n isVersion,\n id as npmVersioningId,\n} from '../../../../versioning/npm/index.ts';\nimport type { PackageDependency } from '../../../types.ts';\n\nconst RE_REPOSITORY_GITHUB_SSH_FORMAT = regEx(\n /(?:git@)github.com:(?<owner>[^/]+)\\/(?<repo>[^/]+?)(?:\\.git)?$/,\n);\n\nexport function parseDepName(depType: string, key: string): string {\n if (depType !== 'resolutions') {\n return key;\n }\n\n // Yarn selective dependency resolutions may nest a path of parent\n // packages before the target package, e.g. `parent/child` or\n // `@scope/parent/child`, and any segment (including the last) may carry\n // a `@range` suffix used to disambiguate which version of that package\n // to match, e.g. `@cypress/request/qs@~6.14.1`.\n const parts = key.split('/');\n const segments: string[] = [];\n for (let i = 0; i < parts.length; i += 1) {\n const part = parts[i];\n if (part.startsWith('@') && i + 1 < parts.length) {\n i += 1;\n segments.push(`${part}/${parts[i]}`);\n } else {\n segments.push(part);\n }\n }\n\n const lastSegment = segments.at(-1);\n const [, depName] = coerceArray(\n regEx(/^(?<depName>(?:@[^/]+\\/)?[^@]+)/).exec(lastSegment ?? ''),\n );\n return depName;\n}\n\nexport function extractDependency(\n depType: string,\n depName: string,\n input: string,\n): PackageDependency {\n const dep: PackageDependency = {};\n if (!validateNpmPackageName(depName).validForOldPackages) {\n dep.skipReason = 'invalid-name';\n return dep;\n }\n if (!isString(input)) {\n dep.skipReason = 'invalid-value';\n return dep;\n }\n dep.currentValue = input.trim();\n if (depType === 'engines' || depType === 'packageManager') {\n if (depName === 'node') {\n dep.datasource = NodeVersionDatasource.id;\n } else if (depName === 'yarn') {\n dep.datasource = NpmDatasource.id;\n dep.commitMessageTopic = 'Yarn';\n const major =\n isVersion(dep.currentValue) && api.getMajor(dep.currentValue);\n if (major && major > 1) {\n dep.packageName = '@yarnpkg/cli';\n }\n } else if (depName === 'npm') {\n dep.datasource = NpmDatasource.id;\n dep.commitMessageTopic = 'npm';\n } else if (depName === 'pnpm') {\n dep.datasource = NpmDatasource.id;\n dep.commitMessageTopic = 'pnpm';\n } else if (depName === 'vscode') {\n dep.datasource = GithubTagsDatasource.id;\n dep.packageName = 'microsoft/vscode';\n dep.versioning = npmVersioningId;\n } else if (depName === 'bun') {\n dep.datasource = NpmDatasource.id;\n dep.commitMessageTopic = 'Bun';\n } else {\n dep.skipReason = 'unknown-engines';\n }\n if (!isValid(dep.currentValue)) {\n dep.skipReason = 'unspecified-version';\n }\n return dep;\n }\n\n // support for volta\n if (depType === 'volta') {\n if (depName === 'node') {\n dep.datasource = NodeVersionDatasource.id;\n } else if (depName === 'yarn') {\n dep.datasource = NpmDatasource.id;\n dep.commitMessageTopic = 'Yarn';\n const major =\n isVersion(dep.currentValue) && api.getMajor(dep.currentValue);\n if (major && major > 1) {\n dep.packageName = '@yarnpkg/cli';\n }\n } else if (depName === 'npm') {\n dep.datasource = NpmDatasource.id;\n } else if (depName === 'pnpm') {\n dep.datasource = NpmDatasource.id;\n dep.commitMessageTopic = 'pnpm';\n } else {\n dep.skipReason = 'unknown-volta';\n }\n if (!isValid(dep.currentValue)) {\n dep.skipReason = 'unspecified-version';\n }\n return dep;\n }\n\n if (dep.currentValue.startsWith('npm:')) {\n dep.npmPackageAlias = true;\n const valSplit = dep.currentValue.replace('npm:', '').split('@');\n if (valSplit.length === 1) {\n dep.packageName = depName;\n dep.currentValue = valSplit[0];\n } else if (valSplit.length === 2) {\n dep.packageName = valSplit[0];\n dep.currentValue = valSplit[1];\n } else if (valSplit.length === 3) {\n dep.packageName = `${valSplit[0]}@${valSplit[1]}`;\n dep.currentValue = valSplit[2];\n } else {\n logger.debug(\n `Invalid npm package alias for dependency: \"${depName}\":\"${dep.currentValue}\"`,\n );\n }\n }\n if (dep.currentValue.startsWith('file:')) {\n dep.skipReason = 'file';\n return dep;\n }\n\n if (isValid(dep.currentValue)) {\n dep.datasource = NpmDatasource.id;\n if (dep.currentValue === '') {\n dep.skipReason = 'empty';\n }\n return dep;\n }\n const hashSplit = dep.currentValue.split('#');\n if (hashSplit.length !== 2) {\n dep.skipReason = 'unspecified-version';\n return dep;\n }\n const [depNamePart, depRefPart] = hashSplit;\n\n let githubOwnerRepo: string;\n let githubOwner: string;\n let githubRepo: string;\n const matchUrlSshFormat = RE_REPOSITORY_GITHUB_SSH_FORMAT.exec(depNamePart);\n if (matchUrlSshFormat === null) {\n githubOwnerRepo = depNamePart\n .replace(regEx(/^github:/), '')\n .replace(regEx(/^git\\+/), '')\n .replace(regEx(/^https:\\/\\/github\\.com\\//), '')\n .replace(regEx(/\\.git$/), '');\n const githubRepoSplit = githubOwnerRepo.split('/');\n if (githubRepoSplit.length !== 2) {\n dep.skipReason = 'unspecified-version';\n return dep;\n }\n [githubOwner, githubRepo] = githubRepoSplit;\n } else {\n githubOwner = matchUrlSshFormat.groups!.owner;\n githubRepo = matchUrlSshFormat.groups!.repo;\n githubOwnerRepo = `${githubOwner}/${githubRepo}`;\n }\n // combined with the length check below, this is equivalent to\n // /^[a-z\\d](?:[a-z\\d]|-(?=[a-z\\d])){0,38}$/i without the lookahead\n const githubOwnerRegex = regEx(/^[a-z\\d](?:-?[a-z\\d]){0,38}$/i);\n const githubRepoRegex = regEx(/^[a-zA-Z0-9._-]{1,100}$/);\n if (\n githubOwner.length > 39 ||\n !githubOwnerRegex.test(githubOwner) ||\n !githubRepoRegex.test(githubRepo)\n ) {\n dep.skipReason = 'unspecified-version';\n return dep;\n }\n if (isVersion(depRefPart)) {\n dep.currentRawValue = dep.currentValue;\n dep.currentValue = depRefPart;\n dep.datasource = GithubTagsDatasource.id;\n dep.versioning = npmVersioningId;\n dep.packageName = githubOwnerRepo;\n dep.pinDigests = false;\n } else if (\n regEx(/^[0-9a-f]{7}$/).test(depRefPart) ||\n regEx(/^[0-9a-f]{40}$/).test(depRefPart)\n ) {\n dep.currentRawValue = dep.currentValue;\n dep.currentValue = null;\n dep.currentDigest = depRefPart;\n dep.datasource = GithubTagsDatasource.id;\n dep.versioning = npmVersioningId;\n dep.packageName = githubOwnerRepo;\n } else {\n // <protocol>://[<user>[:<password>]@]<hostname>[:<port>][:][/]<path>[#<commit-ish> | #semver:<semver>]\n // https://docs.npmjs.com/cli/v10/configuring-npm/package-json#git-urls-as-dependencies\n const len = 7; // length of 'semver:'\n const maybeVersion = depRefPart.substring(len);\n\n if (depRefPart.startsWith('semver:') && isValid(maybeVersion)) {\n dep.currentRawValue = dep.currentValue;\n dep.currentValue = maybeVersion;\n dep.datasource = GithubTagsDatasource.id;\n dep.versioning = npmVersioningId;\n dep.packageName = githubOwnerRepo;\n dep.pinDigests = false;\n } else {\n dep.skipReason = 'unversioned-reference';\n return dep;\n }\n }\n dep.sourceUrl = `https://github.com/${githubOwnerRepo}`;\n dep.gitRef = true;\n return dep;\n}\n\nexport function getExtractedConstraints(\n deps: PackageDependency[],\n): Partial<Record<ConstraintName, string>> {\n const extractedConstraints: Partial<Record<ConstraintName, string>> = {};\n const constraints: ConstraintName[] = [\n 'bun',\n 'node',\n 'yarn',\n 'npm',\n 'pnpm',\n 'vscode',\n ];\n for (const dep of deps) {\n if (\n !dep.skipReason &&\n (dep.depType === 'engines' || dep.depType === 'packageManager') &&\n dep.depName &&\n isConstraintName(dep.depName) &&\n constraints.includes(dep.depName) &&\n isString(dep.currentValue)\n ) {\n extractedConstraints[dep.depName] = dep.currentValue;\n }\n }\n return extractedConstraints;\n}\n"],"mappings":";;;;;;;;;;;AAkBA,MAAM,kCAAkC,MACtC,gEACF;AAEA,SAAgB,aAAa,SAAiB,KAAqB;CACjE,IAAI,YAAY,eACd,OAAO;CAQT,MAAM,QAAQ,IAAI,MAAM,GAAG;CAC3B,MAAM,WAAqB,CAAC;CAC5B,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK,GAAG;EACxC,MAAM,OAAO,MAAM;EACnB,IAAI,KAAK,WAAW,GAAG,KAAK,IAAI,IAAI,MAAM,QAAQ;GAChD,KAAK;GACL,SAAS,KAAK,GAAG,KAAK,GAAG,MAAM,IAAI;EACrC,OACE,SAAS,KAAK,IAAI;CAEtB;CAEA,MAAM,cAAc,SAAS,GAAG,EAAE;CAClC,MAAM,GAAG,WAAW,YAClB,MAAM,iCAAiC,CAAC,CAAC,KAAK,eAAe,EAAE,CACjE;CACA,OAAO;AACT;AAEA,SAAgB,kBACd,SACA,SACA,OACmB;CACnB,MAAM,MAAy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,MAAM,cAAgC;EACpC;EACA;EACA;EACA;EACA;EACA;CACF;CACA,KAAK,MAAM,OAAO,MAChB,IACE,CAAC,IAAI,eACJ,IAAI,YAAY,aAAa,IAAI,YAAY,qBAC9C,IAAI,WACJ,iBAAiB,IAAI,OAAO,KAC5B,YAAY,SAAS,IAAI,OAAO,KAChC,SAAS,IAAI,YAAY,GAEzB,qBAAqB,IAAI,WAAW,IAAI;CAG5C,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"dependency.js","names":[],"sources":["../../../../../../lib/modules/manager/npm/extract/common/dependency.ts"],"sourcesContent":["import { isString } from '@sindresorhus/is';\nimport validateNpmPackageName from 'validate-npm-package-name';\nimport { logger } from '../../../../../logger/index.ts';\nimport { coerceArray } from '../../../../../util/array.ts';\nimport type { ConstraintName } from '../../../../../util/exec/types.ts';\nimport { isConstraintName } from '../../../../../util/exec/types.ts';\nimport { regEx } from '../../../../../util/regex.ts';\nimport { coerceString } from '../../../../../util/string.ts';\nimport { GithubTagsDatasource } from '../../../../datasource/github-tags/index.ts';\nimport { NodeVersionDatasource } from '../../../../datasource/node-version/index.ts';\nimport { NpmDatasource } from '../../../../datasource/npm/index.ts';\nimport {\n api,\n isValid,\n isVersion,\n id as npmVersioningId,\n} from '../../../../versioning/npm/index.ts';\nimport type { PackageDependency } from '../../../types.ts';\n\nconst RE_REPOSITORY_GITHUB_SSH_FORMAT = regEx(\n /(?:git@)github.com:(?<owner>[^/]+)\\/(?<repo>[^/]+?)(?:\\.git)?$/,\n);\n\nexport function parseDepName(depType: string, key: string): string {\n if (depType !== 'resolutions') {\n return key;\n }\n\n // Yarn selective dependency resolutions may nest a path of parent\n // packages before the target package, e.g. `parent/child` or\n // `@scope/parent/child`, and any segment (including the last) may carry\n // a `@range` suffix used to disambiguate which version of that package\n // to match, e.g. `@cypress/request/qs@~6.14.1`.\n const parts = key.split('/');\n const segments: string[] = [];\n for (let i = 0; i < parts.length; i += 1) {\n const part = parts[i];\n if (part.startsWith('@') && i + 1 < parts.length) {\n i += 1;\n segments.push(`${part}/${parts[i]}`);\n } else {\n segments.push(part);\n }\n }\n\n const lastSegment = segments.at(-1);\n const [, depName] = coerceArray(\n regEx(/^(?<depName>(?:@[^/]+\\/)?[^@]+)/).exec(coerceString(lastSegment)),\n );\n return depName;\n}\n\nexport function extractDependency(\n depType: string,\n depName: string,\n input: string,\n): PackageDependency {\n const dep: PackageDependency = {};\n if (!validateNpmPackageName(depName).validForOldPackages) {\n dep.skipReason = 'invalid-name';\n return dep;\n }\n if (!isString(input)) {\n dep.skipReason = 'invalid-value';\n return dep;\n }\n dep.currentValue = input.trim();\n if (depType === 'engines' || depType === 'packageManager') {\n if (depName === 'node') {\n dep.datasource = NodeVersionDatasource.id;\n } else if (depName === 'yarn') {\n dep.datasource = NpmDatasource.id;\n dep.commitMessageTopic = 'Yarn';\n const major =\n isVersion(dep.currentValue) && api.getMajor(dep.currentValue);\n if (major && major > 1) {\n dep.packageName = '@yarnpkg/cli';\n }\n } else if (depName === 'npm') {\n dep.datasource = NpmDatasource.id;\n dep.commitMessageTopic = 'npm';\n } else if (depName === 'pnpm') {\n dep.datasource = NpmDatasource.id;\n dep.commitMessageTopic = 'pnpm';\n } else if (depName === 'vscode') {\n dep.datasource = GithubTagsDatasource.id;\n dep.packageName = 'microsoft/vscode';\n dep.versioning = npmVersioningId;\n } else if (depName === 'bun') {\n dep.datasource = NpmDatasource.id;\n dep.commitMessageTopic = 'Bun';\n } else {\n dep.skipReason = 'unknown-engines';\n }\n if (!isValid(dep.currentValue)) {\n dep.skipReason = 'unspecified-version';\n }\n return dep;\n }\n\n // support for volta\n if (depType === 'volta') {\n if (depName === 'node') {\n dep.datasource = NodeVersionDatasource.id;\n } else if (depName === 'yarn') {\n dep.datasource = NpmDatasource.id;\n dep.commitMessageTopic = 'Yarn';\n const major =\n isVersion(dep.currentValue) && api.getMajor(dep.currentValue);\n if (major && major > 1) {\n dep.packageName = '@yarnpkg/cli';\n }\n } else if (depName === 'npm') {\n dep.datasource = NpmDatasource.id;\n } else if (depName === 'pnpm') {\n dep.datasource = NpmDatasource.id;\n dep.commitMessageTopic = 'pnpm';\n } else {\n dep.skipReason = 'unknown-volta';\n }\n if (!isValid(dep.currentValue)) {\n dep.skipReason = 'unspecified-version';\n }\n return dep;\n }\n\n if (dep.currentValue.startsWith('npm:')) {\n dep.npmPackageAlias = true;\n const valSplit = dep.currentValue.replace('npm:', '').split('@');\n if (valSplit.length === 1) {\n dep.packageName = depName;\n dep.currentValue = valSplit[0];\n } else if (valSplit.length === 2) {\n dep.packageName = valSplit[0];\n dep.currentValue = valSplit[1];\n } else if (valSplit.length === 3) {\n dep.packageName = `${valSplit[0]}@${valSplit[1]}`;\n dep.currentValue = valSplit[2];\n } else {\n logger.debug(\n `Invalid npm package alias for dependency: \"${depName}\":\"${dep.currentValue}\"`,\n );\n }\n }\n if (dep.currentValue.startsWith('file:')) {\n dep.skipReason = 'file';\n return dep;\n }\n\n if (isValid(dep.currentValue)) {\n dep.datasource = NpmDatasource.id;\n if (dep.currentValue === '') {\n dep.skipReason = 'empty';\n }\n return dep;\n }\n const hashSplit = dep.currentValue.split('#');\n if (hashSplit.length !== 2) {\n dep.skipReason = 'unspecified-version';\n return dep;\n }\n const [depNamePart, depRefPart] = hashSplit;\n\n let githubOwnerRepo: string;\n let githubOwner: string;\n let githubRepo: string;\n const matchUrlSshFormat = RE_REPOSITORY_GITHUB_SSH_FORMAT.exec(depNamePart);\n if (matchUrlSshFormat === null) {\n githubOwnerRepo = depNamePart\n .replace(regEx(/^github:/), '')\n .replace(regEx(/^git\\+/), '')\n .replace(regEx(/^https:\\/\\/github\\.com\\//), '')\n .replace(regEx(/\\.git$/), '');\n const githubRepoSplit = githubOwnerRepo.split('/');\n if (githubRepoSplit.length !== 2) {\n dep.skipReason = 'unspecified-version';\n return dep;\n }\n [githubOwner, githubRepo] = githubRepoSplit;\n } else {\n githubOwner = matchUrlSshFormat.groups!.owner;\n githubRepo = matchUrlSshFormat.groups!.repo;\n githubOwnerRepo = `${githubOwner}/${githubRepo}`;\n }\n // combined with the length check below, this is equivalent to\n // /^[a-z\\d](?:[a-z\\d]|-(?=[a-z\\d])){0,38}$/i without the lookahead\n const githubOwnerRegex = regEx(/^[a-z\\d](?:-?[a-z\\d]){0,38}$/i);\n const githubRepoRegex = regEx(/^[a-zA-Z0-9._-]{1,100}$/);\n if (\n githubOwner.length > 39 ||\n !githubOwnerRegex.test(githubOwner) ||\n !githubRepoRegex.test(githubRepo)\n ) {\n dep.skipReason = 'unspecified-version';\n return dep;\n }\n if (isVersion(depRefPart)) {\n dep.currentRawValue = dep.currentValue;\n dep.currentValue = depRefPart;\n dep.datasource = GithubTagsDatasource.id;\n dep.versioning = npmVersioningId;\n dep.packageName = githubOwnerRepo;\n dep.pinDigests = false;\n } else if (\n regEx(/^[0-9a-f]{7}$/).test(depRefPart) ||\n regEx(/^[0-9a-f]{40}$/).test(depRefPart)\n ) {\n dep.currentRawValue = dep.currentValue;\n dep.currentValue = null;\n dep.currentDigest = depRefPart;\n dep.datasource = GithubTagsDatasource.id;\n dep.versioning = npmVersioningId;\n dep.packageName = githubOwnerRepo;\n } else {\n // <protocol>://[<user>[:<password>]@]<hostname>[:<port>][:][/]<path>[#<commit-ish> | #semver:<semver>]\n // https://docs.npmjs.com/cli/v10/configuring-npm/package-json#git-urls-as-dependencies\n const len = 7; // length of 'semver:'\n const maybeVersion = depRefPart.substring(len);\n\n if (depRefPart.startsWith('semver:') && isValid(maybeVersion)) {\n dep.currentRawValue = dep.currentValue;\n dep.currentValue = maybeVersion;\n dep.datasource = GithubTagsDatasource.id;\n dep.versioning = npmVersioningId;\n dep.packageName = githubOwnerRepo;\n dep.pinDigests = false;\n } else {\n dep.skipReason = 'unversioned-reference';\n return dep;\n }\n }\n dep.sourceUrl = `https://github.com/${githubOwnerRepo}`;\n dep.gitRef = true;\n return dep;\n}\n\nexport function getExtractedConstraints(\n deps: PackageDependency[],\n): Partial<Record<ConstraintName, string>> {\n const extractedConstraints: Partial<Record<ConstraintName, string>> = {};\n const constraints: ConstraintName[] = [\n 'bun',\n 'node',\n 'yarn',\n 'npm',\n 'pnpm',\n 'vscode',\n ];\n for (const dep of deps) {\n if (\n !dep.skipReason &&\n (dep.depType === 'engines' || dep.depType === 'packageManager') &&\n dep.depName &&\n isConstraintName(dep.depName) &&\n constraints.includes(dep.depName) &&\n isString(dep.currentValue)\n ) {\n extractedConstraints[dep.depName] = dep.currentValue;\n }\n }\n return extractedConstraints;\n}\n"],"mappings":";;;;;;;;;;;;AAmBA,MAAM,kCAAkC,MACtC,gEACF;AAEA,SAAgB,aAAa,SAAiB,KAAqB;CACjE,IAAI,YAAY,eACd,OAAO;CAQT,MAAM,QAAQ,IAAI,MAAM,GAAG;CAC3B,MAAM,WAAqB,CAAC;CAC5B,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK,GAAG;EACxC,MAAM,OAAO,MAAM;EACnB,IAAI,KAAK,WAAW,GAAG,KAAK,IAAI,IAAI,MAAM,QAAQ;GAChD,KAAK;GACL,SAAS,KAAK,GAAG,KAAK,GAAG,MAAM,IAAI;EACrC,OACE,SAAS,KAAK,IAAI;CAEtB;CAEA,MAAM,cAAc,SAAS,GAAG,EAAE;CAClC,MAAM,GAAG,WAAW,YAClB,MAAM,iCAAiC,CAAC,CAAC,KAAK,aAAa,WAAW,CAAC,CACzE;CACA,OAAO;AACT;AAEA,SAAgB,kBACd,SACA,SACA,OACmB;CACnB,MAAM,MAAyB,CAAC;CAChC,IAAI,CAAC,uBAAuB,OAAO,CAAC,CAAC,qBAAqB;EACxD,IAAI,aAAa;EACjB,OAAO;CACT;CACA,IAAI,CAAC,SAAS,KAAK,GAAG;EACpB,IAAI,aAAa;EACjB,OAAO;CACT;CACA,IAAI,eAAe,MAAM,KAAK;CAC9B,IAAI,YAAY,aAAa,YAAY,kBAAkB;EACzD,IAAI,YAAY,QACd,IAAI,aAAa,sBAAsB;OAClC,IAAI,YAAY,QAAQ;G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 async function extractPackageFile(content, packageFile, _config) {
|
|
|
37
37
|
}
|
|
38
38
|
const projectDependencies = def.project?.dependencies;
|
|
39
39
|
if (projectDependencies) deps.push(...projectDependencies);
|
|
40
|
-
|
|
41
|
-
if (dependencyGroups) deps.push(...dependencyGroups);
|
|
40
|
+
deps.push(...def["dependency-groups"]);
|
|
42
41
|
const projectOptionalDependencies = def.project?.["optional-dependencies"];
|
|
43
42
|
if (projectOptionalDependencies) deps.push(...projectOptionalDependencies);
|
|
44
43
|
const buildSystemRequires = def["build-system"]?.requires;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract.js","names":["parseToml","massageToml","pep440.id"],"sources":["../../../../lib/modules/manager/pep621/extract.ts"],"sourcesContent":["import { logger } from '../../../logger/index.ts';\nimport type { ConstraintName } from '../../../util/exec/types.ts';\nimport {\n massage as massageToml,\n parse as parseToml,\n} from '../../../util/toml.ts';\nimport { PythonVersionDatasource } from '../../datasource/python-version/index.ts';\nimport * as pep440 from '../../versioning/pep440/index.ts';\nimport type {\n ExtractConfig,\n PackageDependency,\n PackageFileContent,\n} from '../types.ts';\nimport { processors } from './processors/index.ts';\nimport { PyProject } from './schema.ts';\n\nexport function parsePyProject(\n content: string,\n packageFile?: string,\n): PyProject | null {\n try {\n const jsonMap = parseToml(massageToml(content));\n return PyProject.parse(jsonMap);\n } catch (err) {\n logger.debug(\n { packageFile, err },\n `Failed to parse and validate pyproject file`,\n );\n return null;\n }\n}\n\nexport async function extractPackageFile(\n content: string,\n packageFile: string,\n _config?: ExtractConfig,\n): Promise<PackageFileContent | null> {\n logger.trace(`pep621.extractPackageFile(${packageFile})`);\n\n const def = parsePyProject(content, packageFile);\n if (!def) {\n return null;\n }\n\n const deps: PackageDependency[] = [];\n\n const pythonConstraint = def.project?.['requires-python'];\n const extractedConstraints: Partial<Record<ConstraintName, string>> = {};\n if (pythonConstraint) {\n extractedConstraints.python = pythonConstraint;\n deps.push({\n packageName: 'python',\n depType: 'requires-python',\n currentValue: pythonConstraint,\n commitMessageTopic: 'Python',\n datasource: PythonVersionDatasource.id,\n versioning: pep440.id,\n });\n }\n\n const projectDependencies = def.project?.dependencies;\n if (projectDependencies) {\n deps.push(...projectDependencies);\n }\n\n
|
|
1
|
+
{"version":3,"file":"extract.js","names":["parseToml","massageToml","pep440.id"],"sources":["../../../../lib/modules/manager/pep621/extract.ts"],"sourcesContent":["import { logger } from '../../../logger/index.ts';\nimport type { ConstraintName } from '../../../util/exec/types.ts';\nimport {\n massage as massageToml,\n parse as parseToml,\n} from '../../../util/toml.ts';\nimport { PythonVersionDatasource } from '../../datasource/python-version/index.ts';\nimport * as pep440 from '../../versioning/pep440/index.ts';\nimport type {\n ExtractConfig,\n PackageDependency,\n PackageFileContent,\n} from '../types.ts';\nimport { processors } from './processors/index.ts';\nimport { PyProject } from './schema.ts';\n\nexport function parsePyProject(\n content: string,\n packageFile?: string,\n): PyProject | null {\n try {\n const jsonMap = parseToml(massageToml(content));\n return PyProject.parse(jsonMap);\n } catch (err) {\n logger.debug(\n { packageFile, err },\n `Failed to parse and validate pyproject file`,\n );\n return null;\n }\n}\n\nexport async function extractPackageFile(\n content: string,\n packageFile: string,\n _config?: ExtractConfig,\n): Promise<PackageFileContent | null> {\n logger.trace(`pep621.extractPackageFile(${packageFile})`);\n\n const def = parsePyProject(content, packageFile);\n if (!def) {\n return null;\n }\n\n const deps: PackageDependency[] = [];\n\n const pythonConstraint = def.project?.['requires-python'];\n const extractedConstraints: Partial<Record<ConstraintName, string>> = {};\n if (pythonConstraint) {\n extractedConstraints.python = pythonConstraint;\n deps.push({\n packageName: 'python',\n depType: 'requires-python',\n currentValue: pythonConstraint,\n commitMessageTopic: 'Python',\n datasource: PythonVersionDatasource.id,\n versioning: pep440.id,\n });\n }\n\n const projectDependencies = def.project?.dependencies;\n if (projectDependencies) {\n deps.push(...projectDependencies);\n }\n\n deps.push(...def['dependency-groups']);\n\n const projectOptionalDependencies = def.project?.['optional-dependencies'];\n if (projectOptionalDependencies) {\n deps.push(...projectOptionalDependencies);\n }\n\n const buildSystemRequires = def['build-system']?.requires;\n if (buildSystemRequires) {\n deps.push(...buildSystemRequires);\n }\n\n // process specific tool sets\n let processedDeps = deps;\n const lockFiles: string[] = [];\n for (const processor of processors) {\n processedDeps = processor.process(def, processedDeps);\n processedDeps = await processor.extractLockedVersions(\n def,\n processedDeps,\n packageFile,\n );\n\n const processedLockFiles = await processor.getLockfiles(def, packageFile);\n lockFiles.push(...processedLockFiles);\n }\n\n const packageFileVersion = def.project?.version;\n return processedDeps.length || lockFiles.length\n ? {\n extractedConstraints,\n deps: processedDeps,\n packageFileVersion,\n lockFiles,\n }\n : null;\n}\n"],"mappings":";;;;;;;AAgBA,SAAgB,eACd,SACA,aACkB;CAClB,IAAI;EACF,MAAM,UAAUA,MAAUC,QAAY,OAAO,CAAC;EAC9C,OAAO,UAAU,MAAM,OAAO;CAChC,SAAS,KAAK;EACZ,OAAO,MACL;GAAE;GAAa;EAAI,GACnB,6CACF;EACA,OAAO;CACT;AACF;AAEA,eAAsB,mBACpB,SACA,aACA,SACoC;CACpC,OAAO,MAAM,6BAA6B,YAAY,EAAE;CAExD,MAAM,MAAM,eAAe,SAAS,WAAW;CAC/C,IAAI,CAAC,KACH,OAAO;CAGT,MAAM,OAA4B,CAAC;CAEnC,MAAM,mBAAmB,IAAI,UAAU;CACvC,MAAM,uBAAgE,CAAC;CACvE,IAAI,kBAAkB;EACpB,qBAAqB,SAAS;EAC9B,KAAK,KAAK;GACR,aAAa;GACb,SAAS;GACT,cAAc;GACd,oBAAoB;GACpB,YAAY,wBAAwB;GACpC,YAAYC;EACd,CAAC;CACH;CAEA,MAAM,sBAAsB,IAAI,SAAS;CACzC,IAAI,qBACF,KAAK,KAAK,GAAG,mBAAmB;CAGlC,KAAK,KAAK,GAAG,IAAI,oBAAoB;CAErC,MAAM,8BAA8B,IAAI,UAAU;CAClD,IAAI,6BACF,KAAK,KAAK,GAAG,2BAA2B;CAG1C,MAAM,sBAAsB,IAAI,eAAe,EAAE;CACjD,IAAI,qBACF,KAAK,KAAK,GAAG,mBAAmB;CAIlC,IAAI,gBAAgB;CACpB,MAAM,YAAsB,CAAC;CAC7B,KAAK,MAAM,aAAa,YAAY;EAClC,gBAAgB,UAAU,QAAQ,KAAK,aAAa;EACpD,gBAAgB,MAAM,UAAU,sBAC9B,KACA,eACA,WACF;EAEA,MAAM,qBAAqB,MAAM,UAAU,aAAa,KAAK,WAAW;EACxE,UAAU,KAAK,GAAG,kBAAkB;CACtC;CAEA,MAAM,qBAAqB,IAAI,SAAS;CACxC,OAAO,cAAc,UAAU,UAAU,SACrC;EACE;EACA,MAAM;EACN;EACA;CACF,IACA;AACN"}
|
|
@@ -20,10 +20,8 @@ function getQuadletImage(image, ignoredSuffixes, deps, config) {
|
|
|
20
20
|
]) && !endsWithAny(image, ignoredSuffixes)) {
|
|
21
21
|
const cleanedImage = image.replace(regEx(/^docker:\/\//), "").replace(regEx(/^docker-daemon:/), "");
|
|
22
22
|
const dep = getDep(cleanedImage, true, config.registryAliases);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
deps.push(dep);
|
|
26
|
-
}
|
|
23
|
+
dep.depType = "image";
|
|
24
|
+
deps.push(dep);
|
|
27
25
|
}
|
|
28
26
|
}
|
|
29
27
|
function extractPackageFile(content, packageFile, config) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract.js","names":[],"sources":["../../../../lib/modules/manager/quadlet/extract.ts"],"sourcesContent":["import { logger } from '../../../logger/index.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { getDep } from '../dockerfile/extract.ts';\nimport type {\n ExtractConfig,\n PackageDependency,\n PackageFileContent,\n} from '../types.ts';\nimport { QuadletFile } from './schema.ts';\n\nfunction startsWithAny(image: string, prefixes: string[]): boolean {\n return !!prefixes.find((prefix) => image.startsWith(prefix));\n}\n\nfunction endsWithAny(image: string, suffixes: string[]): boolean {\n return !!suffixes.find((suffix) => image.endsWith(suffix));\n}\n\nfunction getQuadletImage(\n image: string | null | undefined,\n ignoredSuffixes: string[],\n deps: PackageDependency[],\n config: ExtractConfig,\n): void {\n if (\n image &&\n // Ignore transports that do not resolve to a registry\n // https://github.com/containers/image/blob/main/docs/containers-transports.5.md\n !startsWithAny(image, [\n 'dir:',\n 'docker-archive:',\n 'oci-archive:',\n 'oci:',\n 'containers-storage:',\n 'sif:',\n ]) &&\n !endsWithAny(image, ignoredSuffixes)\n ) {\n // Remove the docker:// or docker-daemon: transport prefix, if present\n const cleanedImage = image\n .replace(regEx(/^docker:\\/\\//), '')\n .replace(regEx(/^docker-daemon:/), '');\n const dep = getDep(cleanedImage, true, config.registryAliases);\n
|
|
1
|
+
{"version":3,"file":"extract.js","names":[],"sources":["../../../../lib/modules/manager/quadlet/extract.ts"],"sourcesContent":["import { logger } from '../../../logger/index.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { getDep } from '../dockerfile/extract.ts';\nimport type {\n ExtractConfig,\n PackageDependency,\n PackageFileContent,\n} from '../types.ts';\nimport { QuadletFile } from './schema.ts';\n\nfunction startsWithAny(image: string, prefixes: string[]): boolean {\n return !!prefixes.find((prefix) => image.startsWith(prefix));\n}\n\nfunction endsWithAny(image: string, suffixes: string[]): boolean {\n return !!suffixes.find((suffix) => image.endsWith(suffix));\n}\n\nfunction getQuadletImage(\n image: string | null | undefined,\n ignoredSuffixes: string[],\n deps: PackageDependency[],\n config: ExtractConfig,\n): void {\n if (\n image &&\n // Ignore transports that do not resolve to a registry\n // https://github.com/containers/image/blob/main/docs/containers-transports.5.md\n !startsWithAny(image, [\n 'dir:',\n 'docker-archive:',\n 'oci-archive:',\n 'oci:',\n 'containers-storage:',\n 'sif:',\n ]) &&\n !endsWithAny(image, ignoredSuffixes)\n ) {\n // Remove the docker:// or docker-daemon: transport prefix, if present\n const cleanedImage = image\n .replace(regEx(/^docker:\\/\\//), '')\n .replace(regEx(/^docker-daemon:/), '');\n const dep = getDep(cleanedImage, true, config.registryAliases);\n dep.depType = 'image';\n deps.push(dep);\n }\n}\n\nexport function extractPackageFile(\n content: string,\n packageFile: string,\n config: ExtractConfig,\n): PackageFileContent | null {\n const deps: PackageDependency[] = [];\n\n const res = QuadletFile.safeParse(content);\n if (!res.success) {\n logger.debug(\n { err: res.error, packageFile },\n 'Error parsing Quadlet file.',\n );\n return null;\n }\n\n const quadletFile: QuadletFile = res.data;\n\n getQuadletImage(\n quadletFile?.Container?.Image,\n ['.image', '.build'],\n deps,\n config,\n );\n getQuadletImage(quadletFile?.Image?.Image, [], deps, config);\n getQuadletImage(quadletFile?.Volume?.Image, ['.image'], deps, config);\n\n if (deps.length) {\n return { deps };\n }\n return null;\n}\n"],"mappings":";;;;;AAUA,SAAS,cAAc,OAAe,UAA6B;CACjE,OAAO,CAAC,CAAC,SAAS,MAAM,WAAW,MAAM,WAAW,MAAM,CAAC;AAC7D;AAEA,SAAS,YAAY,OAAe,UAA6B;CAC/D,OAAO,CAAC,CAAC,SAAS,MAAM,WAAW,MAAM,SAAS,MAAM,CAAC;AAC3D;AAEA,SAAS,gBACP,OACA,iBACA,MACA,QACM;CACN,IACE,SAGA,CAAC,cAAc,OAAO;EACpB;EACA;EACA;EACA;EACA;EACA;CACF,CAAC,KACD,CAAC,YAAY,OAAO,eAAe,GACnC;EAEA,MAAM,eAAe,MAClB,QAAQ,MAAM,cAAc,GAAG,EAAE,CAAC,CAClC,QAAQ,MAAM,iBAAiB,GAAG,EAAE;EACvC,MAAM,MAAM,OAAO,cAAc,MAAM,OAAO,eAAe;EAC7D,IAAI,UAAU;EACd,KAAK,KAAK,GAAG;CACf;AACF;AAEA,SAAgB,mBACd,SACA,aACA,QAC2B;CAC3B,MAAM,OAA4B,CAAC;CAEnC,MAAM,MAAM,YAAY,UAAU,OAAO;CACzC,IAAI,CAAC,IAAI,SAAS;EAChB,OAAO,MACL;GAAE,KAAK,IAAI;GAAO;EAAY,GAC9B,6BACF;EACA,OAAO;CACT;CAEA,MAAM,cAA2B,IAAI;CAErC,gBACE,aAAa,WAAW,OACxB,CAAC,UAAU,QAAQ,GACnB,MACA,MACF;CACA,gBAAgB,aAAa,OAAO,OAAO,CAAC,GAAG,MAAM,MAAM;CAC3D,gBAAgB,aAAa,QAAQ,OAAO,CAAC,QAAQ,GAAG,MAAM,MAAM;CAEpE,IAAI,KAAK,QACP,OAAO,EAAE,KAAK;CAEhB,OAAO;AACT"}
|
|
@@ -20,7 +20,9 @@ function normalizeUrl(url) {
|
|
|
20
20
|
}
|
|
21
21
|
function matchPinForDep(dep, pins) {
|
|
22
22
|
let depUrl;
|
|
23
|
-
if (dep.datasource === GitTagsDatasource.id)
|
|
23
|
+
if (dep.datasource === GitTagsDatasource.id)
|
|
24
|
+
/* v8 ignore next -- extract always sets depName for a git-tags dep */
|
|
25
|
+
depUrl = dep.depName ?? "";
|
|
24
26
|
else depUrl = `${dep.registryUrls?.[0] ?? "https://github.com"}/${dep.depName}`;
|
|
25
27
|
const normalizedDepUrl = normalizeUrl(depUrl);
|
|
26
28
|
return pins.find((pin) => normalizeUrl(pin.location) === normalizedDepUrl) ?? null;
|