renovate 44.61.0 → 44.61.2
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/migration.js +1 -1
- package/dist/config/migration.js.map +1 -1
- package/dist/config/migrations/custom/schedule-migration.js +8 -8
- package/dist/config/migrations/custom/schedule-migration.js.map +1 -1
- package/dist/config/options/env.js +1 -1
- package/dist/config/options/env.js.map +1 -1
- package/dist/config/parse.js +1 -1
- package/dist/config/parse.js.map +1 -1
- package/dist/config/presets/parse.js +1 -1
- package/dist/config/presets/parse.js.map +1 -1
- package/dist/config/validation.js +1 -1
- package/dist/config/validation.js.map +1 -1
- package/dist/logger/utils.js +2 -2
- package/dist/logger/utils.js.map +1 -1
- package/dist/modules/datasource/deno/index.js +1 -1
- package/dist/modules/datasource/deno/index.js.map +1 -1
- package/dist/modules/datasource/docker/ecr.js +1 -1
- package/dist/modules/datasource/docker/ecr.js.map +1 -1
- package/dist/modules/datasource/docker/google.js +1 -1
- package/dist/modules/datasource/docker/google.js.map +1 -1
- package/dist/modules/datasource/go/base.js +1 -1
- package/dist/modules/datasource/go/base.js.map +1 -1
- package/dist/modules/datasource/go/goproxy-parser.js +1 -1
- package/dist/modules/datasource/go/goproxy-parser.js.map +1 -1
- package/dist/modules/datasource/go/releases-goproxy.js +1 -1
- package/dist/modules/datasource/go/releases-goproxy.js.map +1 -1
- package/dist/modules/datasource/gradle-version/index.js +1 -1
- package/dist/modules/datasource/gradle-version/index.js.map +1 -1
- package/dist/modules/datasource/helm/schema.js +2 -2
- package/dist/modules/datasource/helm/schema.js.map +1 -1
- package/dist/modules/datasource/hexpm-bob/index.js +1 -1
- package/dist/modules/datasource/hexpm-bob/index.js.map +1 -1
- package/dist/modules/datasource/npm/get.js +1 -1
- package/dist/modules/datasource/npm/get.js.map +1 -1
- package/dist/modules/datasource/npm/npmrc.js +1 -1
- package/dist/modules/datasource/npm/npmrc.js.map +1 -1
- package/dist/modules/datasource/pypi/common.js +2 -2
- package/dist/modules/datasource/pypi/common.js.map +1 -1
- package/dist/modules/datasource/pypi/index.js +1 -1
- package/dist/modules/datasource/pypi/index.js.map +1 -1
- package/dist/modules/manager/ansible/extract.js +2 -2
- package/dist/modules/manager/ansible/extract.js.map +1 -1
- package/dist/modules/manager/ansible-galaxy/collections.js +2 -2
- package/dist/modules/manager/ansible-galaxy/collections.js.map +1 -1
- package/dist/modules/manager/ansible-galaxy/roles.js +2 -2
- package/dist/modules/manager/ansible-galaxy/roles.js.map +1 -1
- package/dist/modules/manager/ansible-galaxy/util.js +4 -4
- package/dist/modules/manager/ansible-galaxy/util.js.map +1 -1
- package/dist/modules/manager/ant/properties.js +9 -9
- package/dist/modules/manager/ant/properties.js.map +1 -1
- package/dist/modules/manager/asdf/extract.js +1 -1
- package/dist/modules/manager/asdf/extract.js.map +1 -1
- package/dist/modules/manager/asdf/upgradeable-tooling.js +1 -1
- package/dist/modules/manager/asdf/upgradeable-tooling.js.map +1 -1
- package/dist/modules/manager/batect-wrapper/extract.js +2 -2
- package/dist/modules/manager/batect-wrapper/extract.js.map +1 -1
- package/dist/modules/manager/bazel/rules/go.js +1 -1
- package/dist/modules/manager/bazel/rules/go.js.map +1 -1
- package/dist/modules/manager/buildkite/extract.js +1 -1
- package/dist/modules/manager/buildkite/extract.js.map +1 -1
- package/dist/modules/manager/buildpacks/extract.js +1 -1
- package/dist/modules/manager/buildpacks/extract.js.map +1 -1
- package/dist/modules/manager/bundler/common.js +7 -7
- package/dist/modules/manager/bundler/common.js.map +1 -1
- package/dist/modules/manager/bundler/extract.js +4 -4
- package/dist/modules/manager/bundler/extract.js.map +1 -1
- package/dist/modules/manager/deno/utils.js +1 -1
- package/dist/modules/manager/deno/utils.js.map +1 -1
- package/dist/modules/manager/dockerfile/extract.js +11 -4
- package/dist/modules/manager/dockerfile/extract.js.map +1 -1
- package/dist/modules/manager/fingerprint.generated.js +4 -4
- package/dist/modules/manager/fingerprint.generated.js.map +1 -1
- package/dist/modules/manager/flux/extract.js +2 -1
- package/dist/modules/manager/flux/extract.js.map +1 -1
- package/dist/modules/manager/git-submodules/extract.js +1 -1
- package/dist/modules/manager/git-submodules/extract.js.map +1 -1
- package/dist/modules/manager/github-actions/common.js +3 -3
- package/dist/modules/manager/github-actions/common.js.map +1 -1
- package/dist/modules/manager/github-actions/parse.js +1 -1
- package/dist/modules/manager/github-actions/parse.js.map +1 -1
- package/dist/modules/manager/gomod/artifacts.js +4 -4
- package/dist/modules/manager/gomod/artifacts.js.map +1 -1
- package/dist/modules/manager/gomod/line-parser.js +1 -1
- package/dist/modules/manager/gomod/line-parser.js.map +1 -1
- package/dist/modules/manager/gomod/update.js +1 -1
- package/dist/modules/manager/gomod/update.js.map +1 -1
- package/dist/modules/manager/gradle/parser/handlers.js +1 -1
- package/dist/modules/manager/gradle/parser/handlers.js.map +1 -1
- package/dist/modules/manager/helmv3/utils.js +1 -1
- package/dist/modules/manager/helmv3/utils.js.map +1 -1
- package/dist/modules/manager/html/extract.js +2 -2
- package/dist/modules/manager/html/extract.js.map +1 -1
- package/dist/modules/manager/kustomize/extract.js +3 -3
- package/dist/modules/manager/kustomize/extract.js.map +1 -1
- package/dist/modules/manager/leiningen/extract.js +1 -1
- package/dist/modules/manager/leiningen/extract.js.map +1 -1
- package/dist/modules/manager/maven-wrapper/artifacts.js +6 -6
- package/dist/modules/manager/maven-wrapper/artifacts.js.map +1 -1
- package/dist/modules/manager/meteor/extract.js +2 -2
- package/dist/modules/manager/meteor/extract.js.map +1 -1
- package/dist/modules/manager/mise/upgradeable-tooling.js +2 -2
- package/dist/modules/manager/mise/upgradeable-tooling.js.map +1 -1
- package/dist/modules/manager/mix/extract.js +3 -3
- package/dist/modules/manager/mix/extract.js.map +1 -1
- package/dist/modules/manager/npm/extract/common/dependency.js +4 -4
- package/dist/modules/manager/npm/extract/common/dependency.js.map +1 -1
- package/dist/modules/manager/npm/extract/yarnrc.js +1 -1
- package/dist/modules/manager/npm/extract/yarnrc.js.map +1 -1
- package/dist/modules/manager/npm/npmrc.js +1 -1
- package/dist/modules/manager/npm/npmrc.js.map +1 -1
- package/dist/modules/manager/npm/post-update/yarn.js +1 -1
- package/dist/modules/manager/npm/post-update/yarn.js.map +1 -1
- package/dist/modules/manager/npm/update/locked-dependency/package-lock/dep-constraints.js +1 -1
- package/dist/modules/manager/npm/update/locked-dependency/package-lock/dep-constraints.js.map +1 -1
- package/dist/modules/manager/npm/update/locked-dependency/yarn-lock/replace.js +1 -1
- package/dist/modules/manager/npm/update/locked-dependency/yarn-lock/replace.js.map +1 -1
- package/dist/modules/manager/nuget/extract.js +1 -1
- package/dist/modules/manager/nuget/extract.js.map +1 -1
- package/dist/modules/manager/pep621/utils.js +1 -1
- package/dist/modules/manager/pep621/utils.js.map +1 -1
- package/dist/modules/manager/pep723/utils.js +1 -1
- package/dist/modules/manager/pep723/utils.js.map +1 -1
- package/dist/modules/manager/pip-compile/common.js +2 -2
- package/dist/modules/manager/pip-compile/common.js.map +1 -1
- package/dist/modules/manager/pip_requirements/common.js +1 -1
- package/dist/modules/manager/pip_requirements/common.js.map +1 -1
- package/dist/modules/manager/pip_requirements/extract.js +1 -1
- package/dist/modules/manager/pip_requirements/extract.js.map +1 -1
- package/dist/modules/manager/poetry/artifacts.js +4 -4
- package/dist/modules/manager/poetry/artifacts.js.map +1 -1
- package/dist/modules/manager/puppet/puppetfile-parser.js +5 -5
- package/dist/modules/manager/puppet/puppetfile-parser.js.map +1 -1
- package/dist/modules/manager/sbt/update.js +1 -1
- package/dist/modules/manager/sbt/update.js.map +1 -1
- package/dist/modules/manager/sbt/util.js +2 -2
- package/dist/modules/manager/sbt/util.js.map +1 -1
- package/dist/modules/manager/setup-cfg/extract.js +2 -2
- package/dist/modules/manager/setup-cfg/extract.js.map +1 -1
- package/dist/modules/manager/swift/artifacts.js +4 -4
- package/dist/modules/manager/swift/artifacts.js.map +1 -1
- package/dist/modules/manager/swift/extract.js +1 -1
- package/dist/modules/manager/swift/extract.js.map +1 -1
- package/dist/modules/manager/tekton/extract.js +1 -1
- package/dist/modules/manager/tekton/extract.js.map +1 -1
- package/dist/modules/manager/terraform/extractors/others/modules.js +5 -5
- package/dist/modules/manager/terraform/extractors/others/modules.js.map +1 -1
- package/dist/modules/manager/terraform/util.js +1 -1
- package/dist/modules/manager/terraform/util.js.map +1 -1
- package/dist/modules/manager/terragrunt/modules.js +3 -3
- package/dist/modules/manager/terragrunt/modules.js.map +1 -1
- package/dist/modules/platform/azure/azure-got-wrapper.js +15 -5
- package/dist/modules/platform/azure/azure-got-wrapper.js.map +1 -1
- package/dist/modules/platform/azure/index.js +28 -8
- package/dist/modules/platform/azure/index.js.map +1 -1
- package/dist/modules/platform/azure/types.js.map +1 -1
- package/dist/modules/platform/bitbucket/index.js +4 -4
- package/dist/modules/platform/bitbucket/index.js.map +1 -1
- package/dist/modules/platform/bitbucket-server/index.js +1 -1
- package/dist/modules/platform/bitbucket-server/index.js.map +1 -1
- package/dist/modules/platform/gerrit/index.js +1 -1
- package/dist/modules/platform/gerrit/index.js.map +1 -1
- package/dist/modules/platform/gerrit/utils.js +3 -3
- package/dist/modules/platform/gerrit/utils.js.map +1 -1
- package/dist/modules/versioning/apk/index.js +3 -3
- package/dist/modules/versioning/apk/index.js.map +1 -1
- package/dist/modules/versioning/composer/index.js +11 -11
- package/dist/modules/versioning/composer/index.js.map +1 -1
- package/dist/modules/versioning/conan/range.js +1 -1
- package/dist/modules/versioning/conan/range.js.map +1 -1
- package/dist/modules/versioning/conda/index.js +1 -1
- package/dist/modules/versioning/conda/index.js.map +1 -1
- package/dist/modules/versioning/devbox/index.js +2 -2
- package/dist/modules/versioning/devbox/index.js.map +1 -1
- package/dist/modules/versioning/distro.js +1 -1
- package/dist/modules/versioning/distro.js.map +1 -1
- package/dist/modules/versioning/github-actions/index.js +2 -2
- package/dist/modules/versioning/github-actions/index.js.map +1 -1
- package/dist/modules/versioning/go-mod-directive/index.js +1 -1
- package/dist/modules/versioning/go-mod-directive/index.js.map +1 -1
- package/dist/modules/versioning/hashicorp/convertor.js +5 -5
- package/dist/modules/versioning/hashicorp/convertor.js.map +1 -1
- package/dist/modules/versioning/hex/index.js +4 -4
- package/dist/modules/versioning/hex/index.js.map +1 -1
- package/dist/modules/versioning/lambda-node/schedule.js +2 -2
- package/dist/modules/versioning/lambda-node/schedule.js.map +1 -1
- package/dist/modules/versioning/loose/index.js +2 -2
- package/dist/modules/versioning/loose/index.js.map +1 -1
- package/dist/modules/versioning/pep440/range.js +1 -1
- package/dist/modules/versioning/pep440/range.js.map +1 -1
- package/dist/modules/versioning/perl/index.js +4 -4
- package/dist/modules/versioning/perl/index.js.map +1 -1
- package/dist/modules/versioning/poetry/patterns.js +1 -1
- package/dist/modules/versioning/poetry/patterns.js.map +1 -1
- package/dist/modules/versioning/poetry/transform.js +3 -3
- package/dist/modules/versioning/poetry/transform.js.map +1 -1
- package/dist/modules/versioning/redhat/index.js +1 -1
- package/dist/modules/versioning/redhat/index.js.map +1 -1
- package/dist/modules/versioning/rpm/index.js +1 -1
- package/dist/modules/versioning/rpm/index.js.map +1 -1
- package/dist/modules/versioning/ruby/index.js +2 -2
- package/dist/modules/versioning/ruby/index.js.map +1 -1
- package/dist/modules/versioning/semver/common.js +1 -1
- package/dist/modules/versioning/semver/common.js.map +1 -1
- package/dist/modules/versioning/swift/range.js +13 -13
- package/dist/modules/versioning/swift/range.js.map +1 -1
- package/dist/modules/versioning/ubuntu/index.js +1 -1
- package/dist/modules/versioning/ubuntu/index.js.map +1 -1
- package/dist/modules/versioning/unity3d-packages/index.js +2 -2
- package/dist/modules/versioning/unity3d-packages/index.js.map +1 -1
- package/dist/util/cache/package/impl/redis.js +1 -1
- package/dist/util/cache/package/impl/redis.js.map +1 -1
- package/dist/util/exec/common.js +3 -3
- package/dist/util/exec/common.js.map +1 -1
- package/dist/util/git/author.js +1 -1
- package/dist/util/git/author.js.map +1 -1
- package/dist/util/git/semantic.js +1 -1
- package/dist/util/git/semantic.js.map +1 -1
- package/dist/util/http/www-authenticate.js +4 -4
- package/dist/util/http/www-authenticate.js.map +1 -1
- package/dist/util/ignore.js +1 -1
- package/dist/util/ignore.js.map +1 -1
- package/dist/util/markdown.js +8 -8
- package/dist/util/markdown.js.map +1 -1
- package/dist/util/pretty-time.js +3 -3
- package/dist/util/pretty-time.js.map +1 -1
- package/dist/util/regex.js +1 -1
- package/dist/util/regex.js.map +1 -1
- package/dist/workers/global/config/parse/cli.js +1 -1
- package/dist/workers/global/config/parse/cli.js.map +1 -1
- package/dist/workers/repository/model/semantic-commit-message.js +1 -1
- package/dist/workers/repository/model/semantic-commit-message.js.map +1 -1
- package/dist/workers/repository/onboarding/pr/pr-list.js +2 -2
- package/dist/workers/repository/onboarding/pr/pr-list.js.map +1 -1
- package/dist/workers/repository/update/pr/changelog/release-notes.js +3 -3
- package/dist/workers/repository/update/pr/changelog/release-notes.js.map +1 -1
- package/dist/workers/repository/updates/branch-name.js +1 -1
- package/dist/workers/repository/updates/branch-name.js.map +1 -1
- package/dist/workers/repository/updates/flatten.js +1 -1
- package/dist/workers/repository/updates/flatten.js.map +1 -1
- package/dist/workers/repository/updates/generate.js +1 -1
- package/dist/workers/repository/updates/generate.js.map +1 -1
- package/package.json +2 -2
- package/renovate-schema.json +2 -2
|
@@ -19,7 +19,7 @@ async function resolveNpmrc(packageFile, config) {
|
|
|
19
19
|
if (npmrc.length && !npmrc.endsWith("\n")) npmrc += "\n";
|
|
20
20
|
if (repoNpmrc?.includes("package-lock")) {
|
|
21
21
|
logger.debug("Stripping package-lock setting from .npmrc");
|
|
22
|
-
repoNpmrc = repoNpmrc.replace(regEx(/(
|
|
22
|
+
repoNpmrc = repoNpmrc.replace(regEx(/(?:^|\n)package-lock.*?(?:\n|$)/g), "\n");
|
|
23
23
|
}
|
|
24
24
|
if (repoNpmrc.includes("=${") && !GlobalConfig.get("exposeAllEnv")) {
|
|
25
25
|
logger.debug({ npmrcFileName }, "Stripping .npmrc file of lines with variables");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"npmrc.js","names":[],"sources":["../../../../lib/modules/manager/npm/npmrc.ts"],"sourcesContent":["import { isString } from '@sindresorhus/is';\nimport { GlobalConfig } from '../../../config/global.ts';\nimport { logger } from '../../../logger/index.ts';\nimport {\n findLocalSiblingOrParent,\n readLocalFile,\n} from '../../../util/fs/index.ts';\nimport { newlineRegex, regEx } from '../../../util/regex.ts';\nimport type { NpmrcResult } from './types.ts';\n\nexport async function resolveNpmrc(\n packageFile: string,\n config: { npmrc?: string; npmrcMerge?: boolean },\n): Promise<NpmrcResult> {\n let npmrc: string | undefined;\n const npmrcFileName = await findLocalSiblingOrParent(packageFile, '.npmrc');\n if (npmrcFileName) {\n let repoNpmrc = await readLocalFile(npmrcFileName, 'utf8');\n // v8 ignore else -- TODO: add test #40625\n if (isString(repoNpmrc)) {\n if (isString(config.npmrc) && !config.npmrcMerge) {\n logger.debug(\n { npmrcFileName },\n 'Repo .npmrc file is ignored due to config.npmrc with config.npmrcMerge=false',\n );\n npmrc = config.npmrc;\n } else {\n npmrc = config.npmrc ?? '';\n if (npmrc.length && !npmrc.endsWith('\\n')) {\n npmrc += '\\n';\n }\n if (repoNpmrc?.includes('package-lock')) {\n logger.debug('Stripping package-lock setting from .npmrc');\n repoNpmrc = repoNpmrc.replace(\n regEx(/(
|
|
1
|
+
{"version":3,"file":"npmrc.js","names":[],"sources":["../../../../lib/modules/manager/npm/npmrc.ts"],"sourcesContent":["import { isString } from '@sindresorhus/is';\nimport { GlobalConfig } from '../../../config/global.ts';\nimport { logger } from '../../../logger/index.ts';\nimport {\n findLocalSiblingOrParent,\n readLocalFile,\n} from '../../../util/fs/index.ts';\nimport { newlineRegex, regEx } from '../../../util/regex.ts';\nimport type { NpmrcResult } from './types.ts';\n\nexport async function resolveNpmrc(\n packageFile: string,\n config: { npmrc?: string; npmrcMerge?: boolean },\n): Promise<NpmrcResult> {\n let npmrc: string | undefined;\n const npmrcFileName = await findLocalSiblingOrParent(packageFile, '.npmrc');\n if (npmrcFileName) {\n let repoNpmrc = await readLocalFile(npmrcFileName, 'utf8');\n // v8 ignore else -- TODO: add test #40625\n if (isString(repoNpmrc)) {\n if (isString(config.npmrc) && !config.npmrcMerge) {\n logger.debug(\n { npmrcFileName },\n 'Repo .npmrc file is ignored due to config.npmrc with config.npmrcMerge=false',\n );\n npmrc = config.npmrc;\n } else {\n npmrc = config.npmrc ?? '';\n if (npmrc.length && !npmrc.endsWith('\\n')) {\n npmrc += '\\n';\n }\n if (repoNpmrc?.includes('package-lock')) {\n logger.debug('Stripping package-lock setting from .npmrc');\n repoNpmrc = repoNpmrc.replace(\n regEx(/(?:^|\\n)package-lock.*?(?:\\n|$)/g),\n '\\n',\n );\n }\n if (repoNpmrc.includes('=${') && !GlobalConfig.get('exposeAllEnv')) {\n logger.debug(\n { npmrcFileName },\n 'Stripping .npmrc file of lines with variables',\n );\n repoNpmrc = repoNpmrc\n .split(newlineRegex)\n .filter((line) => !line.includes('=${'))\n .join('\\n');\n }\n npmrc += repoNpmrc;\n }\n }\n } else if (isString(config.npmrc)) {\n npmrc = config.npmrc;\n }\n return { npmrc, npmrcFileName };\n}\n"],"mappings":";;;;;;AAUA,eAAsB,aACpB,aACA,QACsB;CACtB,IAAI;CACJ,MAAM,gBAAgB,MAAM,yBAAyB,aAAa,QAAQ;CAC1E,IAAI,eAAe;EACjB,IAAI,YAAY,MAAM,cAAc,eAAe,MAAM;;EAEzD,IAAI,SAAS,SAAS,GAAG;GACvB,IAAI,SAAS,OAAO,KAAK,KAAK,CAAC,OAAO,YAAY;IAChD,OAAO,MACL,EAAE,cAAc,GAChB,8EACF;IACA,QAAQ,OAAO;GACjB,OAAO;IACL,QAAQ,OAAO,SAAS;IACxB,IAAI,MAAM,UAAU,CAAC,MAAM,SAAS,IAAI,GACtC,SAAS;IAEX,IAAI,WAAW,SAAS,cAAc,GAAG;KACvC,OAAO,MAAM,4CAA4C;KACzD,YAAY,UAAU,QACpB,MAAM,kCAAkC,GACxC,IACF;IACF;IACA,IAAI,UAAU,SAAS,KAAK,KAAK,CAAC,aAAa,IAAI,cAAc,GAAG;KAClE,OAAO,MACL,EAAE,cAAc,GAChB,+CACF;KACA,YAAY,UACT,MAAM,YAAY,CAAC,CACnB,QAAQ,SAAS,CAAC,KAAK,SAAS,KAAK,CAAC,CAAC,CACvC,KAAK,IAAI;IACd;IACA,SAAS;GACX;EACF;CACF,OAAO,IAAI,SAAS,OAAO,KAAK,GAC9B,QAAQ,OAAO;CAEjB,OAAO;EAAE;EAAO;CAAc;AAChC"}
|
|
@@ -25,7 +25,7 @@ async function checkYarnrc(lockFileDir) {
|
|
|
25
25
|
if (isString(yarnrc)) {
|
|
26
26
|
offlineMirror = !!yarnrc.split(newlineRegex).find((line) => line.startsWith("yarn-offline-mirror "));
|
|
27
27
|
const pathLine = yarnrc.split(newlineRegex).find((line) => line.startsWith("yarn-path "));
|
|
28
|
-
if (pathLine) yarnPath = pathLine.replace(regEx(/^yarn-path\s+"?(
|
|
28
|
+
if (pathLine) yarnPath = pathLine.replace(regEx(/^yarn-path\s+"?(?<path>.+?)"?$/), "$<path>");
|
|
29
29
|
if (yarnPath) yarnPath = upath.join(lockFileDir, yarnPath);
|
|
30
30
|
const yarnBinaryExists = yarnPath ? await localPathIsFile(yarnPath) : false;
|
|
31
31
|
let scrubbedYarnrc = yarnrc.replace("--install.pure-lockfile true", "").replace("--install.frozen-lockfile true", "");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yarn.js","names":[],"sources":["../../../../../lib/modules/manager/npm/post-update/yarn.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 {\n SYSTEM_INSUFFICIENT_DISK_SPACE,\n TEMPORARY_ERROR,\n} from '../../../../constants/error-messages.ts';\nimport { logger } from '../../../../logger/index.ts';\nimport { ExternalHostError } from '../../../../types/errors/external-host-error.ts';\nimport { getEnv } from '../../../../util/env.ts';\nimport { exec, getToolSettingsOptions } from '../../../../util/exec/index.ts';\nimport type {\n CommandWithOptions,\n ExecOptions,\n ExtraEnv,\n ToolConstraint,\n} from '../../../../util/exec/types.ts';\nimport {\n localPathIsFile,\n readLocalFile,\n writeLocalFile,\n} from '../../../../util/fs/index.ts';\nimport { coerceObject } from '../../../../util/object.ts';\nimport { newlineRegex, regEx } from '../../../../util/regex.ts';\nimport { uniqueStrings } from '../../../../util/string.ts';\nimport { NpmDatasource } from '../../../datasource/npm/index.ts';\nimport type { PostUpdateConfig, Upgrade } from '../../types.ts';\nimport { getYarnLock, getYarnVersionFromLock } from '../extract/yarn.ts';\nimport type { NpmManagerData } from '../types.ts';\nimport { getNodeToolConstraint } from './node-version.ts';\nimport type { GenerateLockFileResult } from './types.ts';\nimport {\n getNodeOptions,\n getPackageManagerVersion,\n lazyLoadPackageJson,\n} from './utils.ts';\n\nexport async function checkYarnrc(\n lockFileDir: string,\n): Promise<{ offlineMirror: boolean; yarnPath: string | null }> {\n let offlineMirror = false;\n let yarnPath: string | null = null;\n try {\n const yarnrc = await readLocalFile(\n upath.join(lockFileDir, '.yarnrc'),\n 'utf8',\n );\n if (isString(yarnrc)) {\n const mirrorLine = yarnrc\n .split(newlineRegex)\n .find((line) => line.startsWith('yarn-offline-mirror '));\n offlineMirror = !!mirrorLine;\n const pathLine = yarnrc\n .split(newlineRegex)\n .find((line) => line.startsWith('yarn-path '));\n if (pathLine) {\n yarnPath = pathLine.replace(regEx(/^yarn-path\\s+\"?(.+?)\"?$/), '$1');\n }\n if (yarnPath) {\n // resolve binary relative to `yarnrc`\n yarnPath = upath.join(lockFileDir, yarnPath);\n }\n const yarnBinaryExists = yarnPath\n ? await localPathIsFile(yarnPath)\n : false;\n let scrubbedYarnrc = yarnrc\n .replace('--install.pure-lockfile true', '')\n .replace('--install.frozen-lockfile true', '');\n if (!yarnBinaryExists) {\n scrubbedYarnrc = scrubbedYarnrc.replace(\n regEx(/^yarn-path\\s+\"?.+?\"?$/gm),\n '',\n );\n yarnPath = null;\n }\n if (yarnrc !== scrubbedYarnrc) {\n logger.debug(`Writing scrubbed .yarnrc to ${lockFileDir}`);\n await writeLocalFile(\n upath.join(lockFileDir, '.yarnrc'),\n scrubbedYarnrc,\n );\n }\n }\n /* v8 ignore next -- needs test */\n } catch {\n // not found\n }\n return { offlineMirror, yarnPath };\n}\n\nexport function getOptimizeCommand(fileName: string): string[] {\n return ['sed', '-i', 's/ steps,/ steps.slice(0,1),/', fileName];\n}\n\nexport function isYarnUpdate(upgrade: Upgrade): boolean {\n return upgrade.depType === 'packageManager' && upgrade.depName === 'yarn';\n}\n\nexport async function generateLockFile(\n lockFileDir: string,\n env: NodeJS.ProcessEnv,\n config: Partial<PostUpdateConfig<NpmManagerData>> = {},\n upgrades: Upgrade[] = [],\n): Promise<GenerateLockFileResult> {\n const lockFileName = upath.join(lockFileDir, 'yarn.lock');\n logger.debug(`Spawning yarn install to create ${lockFileName}`);\n let lockFile: string | null = null;\n try {\n const lazyPgkJson = lazyLoadPackageJson(lockFileDir);\n const toolConstraints: ToolConstraint[] = [\n await getNodeToolConstraint(config, upgrades, lockFileDir, lazyPgkJson),\n ];\n const yarnUpdate = upgrades.find(isYarnUpdate);\n const yarnCompatibility =\n (yarnUpdate ? yarnUpdate.newValue : config.constraints?.yarn) ??\n getPackageManagerVersion('yarn', await lazyPgkJson.getValue()) ??\n getYarnVersionFromLock(await getYarnLock(lockFileName));\n const minYarnVersion =\n semver.validRange(yarnCompatibility) &&\n semver.minVersion(yarnCompatibility);\n const isYarn1 = !minYarnVersion || minYarnVersion.major === 1;\n const isYarnDedupeAvailable =\n minYarnVersion && semver.gte(minYarnVersion, '2.2.0');\n const isYarnModeAvailable =\n minYarnVersion && semver.gte(minYarnVersion, '3.0.0');\n\n const yarnTool: ToolConstraint = {\n toolName: 'yarn',\n constraint: '^1.22.18', // needs to be a v1 yarn, otherwise v2 will be installed\n };\n\n // check first upgrade, see #17786\n const hasPackageManager =\n !!config.managerData?.hasPackageManager ||\n !!upgrades[0]?.managerData?.hasPackageManager;\n\n if (!isYarn1 && hasPackageManager) {\n toolConstraints.push({\n toolName: 'corepack',\n constraint: config.constraints?.corepack,\n });\n } else {\n toolConstraints.push(yarnTool);\n if (isYarn1 && minYarnVersion) {\n yarnTool.constraint = yarnCompatibility;\n }\n }\n\n const extraEnv: ExtraEnv = {\n NPM_CONFIG_CACHE: env.NPM_CONFIG_CACHE,\n npm_config_store: env.npm_config_store,\n };\n\n const commands: (string | CommandWithOptions)[] = [];\n let cmdOptions = ''; // should have a leading space\n if (config.skipInstalls !== false) {\n if (isYarn1) {\n const { offlineMirror, yarnPath } = await checkYarnrc(lockFileDir);\n // v8 ignore else -- TODO: add test #40625\n if (!offlineMirror) {\n logger.debug('Updating yarn.lock only - skipping node_modules');\n // The following change causes Yarn 1.x to exit gracefully after updating the lock file but without installing node_modules\n yarnTool.toolName = 'yarn-slim';\n if (yarnPath) {\n commands.push({\n command: getOptimizeCommand(yarnPath),\n ignoreFailure: true,\n });\n }\n }\n } else if (isYarnModeAvailable) {\n // Don't run the link step and only fetch what's necessary to compute an updated lockfile\n cmdOptions += ' --mode=update-lockfile';\n }\n }\n\n if (isYarn1) {\n cmdOptions +=\n ' --ignore-engines --ignore-platform --network-timeout 100000';\n extraEnv.YARN_CACHE_FOLDER = env.YARN_CACHE_FOLDER;\n } else {\n extraEnv.YARN_ENABLE_IMMUTABLE_INSTALLS = 'false';\n extraEnv.YARN_HTTP_TIMEOUT = '100000';\n extraEnv.YARN_GLOBAL_FOLDER = env.YARN_GLOBAL_FOLDER;\n if (!config.managerData?.yarnZeroInstall) {\n logger.debug('Enabling global cache as zero-install is not detected');\n extraEnv.YARN_ENABLE_GLOBAL_CACHE = '1';\n }\n }\n if (!GlobalConfig.get('allowScripts') || config.ignoreScripts) {\n if (isYarn1) {\n cmdOptions += ' --ignore-scripts';\n } else if (isYarnModeAvailable) {\n if (config.skipInstalls === false) {\n // Don't run the build scripts\n cmdOptions += ' --mode=skip-build';\n }\n } else {\n extraEnv.YARN_ENABLE_SCRIPTS = '0';\n }\n }\n\n const { nodeMaxMemory } = getToolSettingsOptions(config.toolSettings);\n if (nodeMaxMemory) {\n extraEnv.NODE_OPTIONS = getNodeOptions(nodeMaxMemory);\n }\n\n const execOptions: ExecOptions = {\n cwdFile: lockFileName,\n extraEnv,\n docker: {},\n toolConstraints,\n };\n /* v8 ignore next -- needs test */\n if (GlobalConfig.get('exposeAllEnv')) {\n extraEnv.NPM_AUTH = env.NPM_AUTH;\n extraEnv.NPM_EMAIL = env.NPM_EMAIL;\n }\n\n if (yarnUpdate && !isYarn1) {\n logger.debug('Updating Yarn binary');\n // TODO: types (#22198)\n commands.push(`yarn set version ${quote(yarnUpdate.newValue!)}`);\n }\n\n const allEnv = getEnv();\n if (allEnv.RENOVATE_X_YARN_PROXY) {\n // v8 ignore else -- TODO: add test #40625\n if (allEnv.HTTP_PROXY && !isYarn1) {\n commands.push('yarn config unset --home httpProxy');\n commands.push(\n `yarn config set --home httpProxy ${quote(allEnv.HTTP_PROXY)}`,\n );\n }\n // v8 ignore else -- TODO: add test #40625\n if (allEnv.HTTPS_PROXY && !isYarn1) {\n commands.push('yarn config unset --home httpsProxy');\n commands.push(\n `yarn config set --home httpsProxy ${quote(allEnv.HTTPS_PROXY)}`,\n );\n }\n }\n\n // This command updates the lock file based on package.json\n commands.push(`yarn install${cmdOptions}`);\n\n // rangeStrategy = update-lockfile\n const lockUpdates = upgrades.filter((upgrade) => upgrade.isLockfileUpdate);\n if (lockUpdates.length) {\n logger.debug('Performing lockfileUpdate (yarn)');\n if (isYarn1) {\n // `yarn upgrade` updates based on the version range specified in the package file\n // note - this can hit a yarn bug, see https://github.com/yarnpkg/yarn/issues/8236\n commands.push(\n `yarn upgrade ${lockUpdates\n .map((update) => update.depName)\n .filter(isString)\n .filter(uniqueStrings)\n .map(quote)\n .join(' ')}${cmdOptions}`,\n );\n } else {\n // `yarn up -R` updates to the latest release in each range\n commands.push(\n `yarn up -R ${lockUpdates\n // TODO: types (#22198)\n .map((update) => `${update.depName!}`)\n .filter(uniqueStrings)\n .map(quote)\n .join(' ')}${cmdOptions}`,\n );\n }\n }\n\n // postUpdateOptions\n ['fewer', 'highest'].forEach((s) => {\n if (\n config.postUpdateOptions?.includes(\n `yarnDedupe${s.charAt(0).toUpperCase()}${s.slice(1)}`,\n )\n ) {\n logger.debug(`Performing yarn dedupe ${s}`);\n if (isYarn1) {\n commands.push(`npx yarn-deduplicate --strategy ${s}`);\n // Run yarn again in case any changes are necessary\n commands.push(`yarn install${cmdOptions}`);\n } else if (isYarnDedupeAvailable && s === 'highest') {\n commands.push(`yarn dedupe --strategy ${s}${cmdOptions}`);\n } else {\n logger.debug(`yarn dedupe ${s} not available`);\n }\n }\n });\n\n if (upgrades.find((upgrade) => upgrade.isLockFileMaintenance)) {\n logger.debug(\n `Removing ${lockFileName} first due to lock file maintenance upgrade`,\n );\n\n // Note: Instead of just deleting the `yarn.lock` file, we just wipe it\n // and keep an empty lock file. Deleting the lock file could result in different\n // Yarn semantics. e.g. Yarn 2+ will error when `yarn install` is executed in\n // a subdirectory which is not part of a Yarn workspace. Yarn suggests to create\n // an empty lock file if a subdirectory should be treated as its own workspace.\n // https://github.com/yarnpkg/berry/blob/20612e82d26ead5928cc27bf482bb8d62dde87d3/packages/yarnpkg-core/sources/Project.ts#L284.\n try {\n await writeLocalFile(lockFileName, '');\n } catch (err) {\n // v8 ignore next -- TODO: add test #40625\n logger.debug(\n { err, lockFileName },\n 'Error clearing `yarn.lock` for lock file maintenance',\n );\n }\n }\n\n // Run the commands\n await exec(commands, execOptions);\n\n // Read the result\n lockFile = await readLocalFile(lockFileName, 'utf8');\n } catch (err) {\n // v8 ignore if -- TODO: add test #40625\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n logger.debug(\n {\n err,\n type: 'yarn',\n },\n 'lock file error',\n );\n const stdouterr = String(err.stdout) + String(err.stderr);\n // v8 ignore if -- TODO: add test #40625\n if (\n stdouterr.includes('ENOSPC: no space left on device') ||\n stdouterr.includes('Out of diskspace')\n ) {\n throw new Error(SYSTEM_INSUFFICIENT_DISK_SPACE);\n }\n // v8 ignore if -- TODO: add test #40625\n if (\n stdouterr.includes('The registry may be down.') ||\n stdouterr.includes('getaddrinfo ENOTFOUND registry.yarnpkg.com') ||\n stdouterr.includes('getaddrinfo ENOTFOUND registry.npmjs.org')\n ) {\n throw new ExternalHostError(err, NpmDatasource.id);\n }\n return { error: true, stderr: err.stderr, stdout: err.stdout };\n }\n return { lockFile };\n}\n\nexport function fuzzyMatchAdditionalYarnrcYml<\n T extends { npmRegistries?: Record<string, unknown> },\n>(additionalYarnRcYml: T, existingYarnrRcYml: T): T {\n const keys = new Map(\n Object.keys(coerceObject(existingYarnrRcYml.npmRegistries)).map((x) => [\n x.replace(regEx(/\\/$/), '').replace(regEx(/^https?:/), ''),\n x,\n ]),\n );\n\n return {\n ...additionalYarnRcYml,\n npmRegistries: Object.entries(\n coerceObject(additionalYarnRcYml.npmRegistries),\n )\n .map(([k, v]) => {\n const key = keys.get(k.replace(regEx(/\\/$/), '')) ?? k;\n return { [key]: v };\n })\n .reduce((acc, cur) => ({ ...acc, ...cur }), {}),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAuCA,eAAsB,YACpB,aAC8D;CAC9D,IAAI,gBAAgB;CACpB,IAAI,WAA0B;CAC9B,IAAI;EACF,MAAM,SAAS,MAAM,cACnB,MAAM,KAAK,aAAa,SAAS,GACjC,MACF;EACA,IAAI,SAAS,MAAM,GAAG;GAIpB,gBAAgB,CAAC,CAHE,OAChB,MAAM,YAAY,CAAC,CACnB,MAAM,SAAS,KAAK,WAAW,sBAAsB,CAC7B;GAC3B,MAAM,WAAW,OACd,MAAM,YAAY,CAAC,CACnB,MAAM,SAAS,KAAK,WAAW,YAAY,CAAC;GAC/C,IAAI,UACF,WAAW,SAAS,QAAQ,MAAM,yBAAyB,GAAG,IAAI;GAE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;EACH,eAAe,OAAO,QACpB,aAAa,oBAAoB,aAAa,CAChD,CAAC,CACE,KAAK,CAAC,GAAG,OAAO;GAEf,OAAO,GADK,KAAK,IAAI,EAAE,QAAQ,MAAM,KAAK,GAAG,EAAE,CAAC,KAAK,IACrC,EAAE;EACpB,CAAC,CAAC,CACD,QAAQ,KAAK,SAAS;GAAE,GAAG;GAAK,GAAG;EAAI,IAAI,CAAC,CAAC;CAClD;AACF"}
|
|
1
|
+
{"version":3,"file":"yarn.js","names":[],"sources":["../../../../../lib/modules/manager/npm/post-update/yarn.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 {\n SYSTEM_INSUFFICIENT_DISK_SPACE,\n TEMPORARY_ERROR,\n} from '../../../../constants/error-messages.ts';\nimport { logger } from '../../../../logger/index.ts';\nimport { ExternalHostError } from '../../../../types/errors/external-host-error.ts';\nimport { getEnv } from '../../../../util/env.ts';\nimport { exec, getToolSettingsOptions } from '../../../../util/exec/index.ts';\nimport type {\n CommandWithOptions,\n ExecOptions,\n ExtraEnv,\n ToolConstraint,\n} from '../../../../util/exec/types.ts';\nimport {\n localPathIsFile,\n readLocalFile,\n writeLocalFile,\n} from '../../../../util/fs/index.ts';\nimport { coerceObject } from '../../../../util/object.ts';\nimport { newlineRegex, regEx } from '../../../../util/regex.ts';\nimport { uniqueStrings } from '../../../../util/string.ts';\nimport { NpmDatasource } from '../../../datasource/npm/index.ts';\nimport type { PostUpdateConfig, Upgrade } from '../../types.ts';\nimport { getYarnLock, getYarnVersionFromLock } from '../extract/yarn.ts';\nimport type { NpmManagerData } from '../types.ts';\nimport { getNodeToolConstraint } from './node-version.ts';\nimport type { GenerateLockFileResult } from './types.ts';\nimport {\n getNodeOptions,\n getPackageManagerVersion,\n lazyLoadPackageJson,\n} from './utils.ts';\n\nexport async function checkYarnrc(\n lockFileDir: string,\n): Promise<{ offlineMirror: boolean; yarnPath: string | null }> {\n let offlineMirror = false;\n let yarnPath: string | null = null;\n try {\n const yarnrc = await readLocalFile(\n upath.join(lockFileDir, '.yarnrc'),\n 'utf8',\n );\n if (isString(yarnrc)) {\n const mirrorLine = yarnrc\n .split(newlineRegex)\n .find((line) => line.startsWith('yarn-offline-mirror '));\n offlineMirror = !!mirrorLine;\n const pathLine = yarnrc\n .split(newlineRegex)\n .find((line) => line.startsWith('yarn-path '));\n if (pathLine) {\n yarnPath = pathLine.replace(\n regEx(/^yarn-path\\s+\"?(?<path>.+?)\"?$/),\n '$<path>',\n );\n }\n if (yarnPath) {\n // resolve binary relative to `yarnrc`\n yarnPath = upath.join(lockFileDir, yarnPath);\n }\n const yarnBinaryExists = yarnPath\n ? await localPathIsFile(yarnPath)\n : false;\n let scrubbedYarnrc = yarnrc\n .replace('--install.pure-lockfile true', '')\n .replace('--install.frozen-lockfile true', '');\n if (!yarnBinaryExists) {\n scrubbedYarnrc = scrubbedYarnrc.replace(\n regEx(/^yarn-path\\s+\"?.+?\"?$/gm),\n '',\n );\n yarnPath = null;\n }\n if (yarnrc !== scrubbedYarnrc) {\n logger.debug(`Writing scrubbed .yarnrc to ${lockFileDir}`);\n await writeLocalFile(\n upath.join(lockFileDir, '.yarnrc'),\n scrubbedYarnrc,\n );\n }\n }\n /* v8 ignore next -- needs test */\n } catch {\n // not found\n }\n return { offlineMirror, yarnPath };\n}\n\nexport function getOptimizeCommand(fileName: string): string[] {\n return ['sed', '-i', 's/ steps,/ steps.slice(0,1),/', fileName];\n}\n\nexport function isYarnUpdate(upgrade: Upgrade): boolean {\n return upgrade.depType === 'packageManager' && upgrade.depName === 'yarn';\n}\n\nexport async function generateLockFile(\n lockFileDir: string,\n env: NodeJS.ProcessEnv,\n config: Partial<PostUpdateConfig<NpmManagerData>> = {},\n upgrades: Upgrade[] = [],\n): Promise<GenerateLockFileResult> {\n const lockFileName = upath.join(lockFileDir, 'yarn.lock');\n logger.debug(`Spawning yarn install to create ${lockFileName}`);\n let lockFile: string | null = null;\n try {\n const lazyPgkJson = lazyLoadPackageJson(lockFileDir);\n const toolConstraints: ToolConstraint[] = [\n await getNodeToolConstraint(config, upgrades, lockFileDir, lazyPgkJson),\n ];\n const yarnUpdate = upgrades.find(isYarnUpdate);\n const yarnCompatibility =\n (yarnUpdate ? yarnUpdate.newValue : config.constraints?.yarn) ??\n getPackageManagerVersion('yarn', await lazyPgkJson.getValue()) ??\n getYarnVersionFromLock(await getYarnLock(lockFileName));\n const minYarnVersion =\n semver.validRange(yarnCompatibility) &&\n semver.minVersion(yarnCompatibility);\n const isYarn1 = !minYarnVersion || minYarnVersion.major === 1;\n const isYarnDedupeAvailable =\n minYarnVersion && semver.gte(minYarnVersion, '2.2.0');\n const isYarnModeAvailable =\n minYarnVersion && semver.gte(minYarnVersion, '3.0.0');\n\n const yarnTool: ToolConstraint = {\n toolName: 'yarn',\n constraint: '^1.22.18', // needs to be a v1 yarn, otherwise v2 will be installed\n };\n\n // check first upgrade, see #17786\n const hasPackageManager =\n !!config.managerData?.hasPackageManager ||\n !!upgrades[0]?.managerData?.hasPackageManager;\n\n if (!isYarn1 && hasPackageManager) {\n toolConstraints.push({\n toolName: 'corepack',\n constraint: config.constraints?.corepack,\n });\n } else {\n toolConstraints.push(yarnTool);\n if (isYarn1 && minYarnVersion) {\n yarnTool.constraint = yarnCompatibility;\n }\n }\n\n const extraEnv: ExtraEnv = {\n NPM_CONFIG_CACHE: env.NPM_CONFIG_CACHE,\n npm_config_store: env.npm_config_store,\n };\n\n const commands: (string | CommandWithOptions)[] = [];\n let cmdOptions = ''; // should have a leading space\n if (config.skipInstalls !== false) {\n if (isYarn1) {\n const { offlineMirror, yarnPath } = await checkYarnrc(lockFileDir);\n // v8 ignore else -- TODO: add test #40625\n if (!offlineMirror) {\n logger.debug('Updating yarn.lock only - skipping node_modules');\n // The following change causes Yarn 1.x to exit gracefully after updating the lock file but without installing node_modules\n yarnTool.toolName = 'yarn-slim';\n if (yarnPath) {\n commands.push({\n command: getOptimizeCommand(yarnPath),\n ignoreFailure: true,\n });\n }\n }\n } else if (isYarnModeAvailable) {\n // Don't run the link step and only fetch what's necessary to compute an updated lockfile\n cmdOptions += ' --mode=update-lockfile';\n }\n }\n\n if (isYarn1) {\n cmdOptions +=\n ' --ignore-engines --ignore-platform --network-timeout 100000';\n extraEnv.YARN_CACHE_FOLDER = env.YARN_CACHE_FOLDER;\n } else {\n extraEnv.YARN_ENABLE_IMMUTABLE_INSTALLS = 'false';\n extraEnv.YARN_HTTP_TIMEOUT = '100000';\n extraEnv.YARN_GLOBAL_FOLDER = env.YARN_GLOBAL_FOLDER;\n if (!config.managerData?.yarnZeroInstall) {\n logger.debug('Enabling global cache as zero-install is not detected');\n extraEnv.YARN_ENABLE_GLOBAL_CACHE = '1';\n }\n }\n if (!GlobalConfig.get('allowScripts') || config.ignoreScripts) {\n if (isYarn1) {\n cmdOptions += ' --ignore-scripts';\n } else if (isYarnModeAvailable) {\n if (config.skipInstalls === false) {\n // Don't run the build scripts\n cmdOptions += ' --mode=skip-build';\n }\n } else {\n extraEnv.YARN_ENABLE_SCRIPTS = '0';\n }\n }\n\n const { nodeMaxMemory } = getToolSettingsOptions(config.toolSettings);\n if (nodeMaxMemory) {\n extraEnv.NODE_OPTIONS = getNodeOptions(nodeMaxMemory);\n }\n\n const execOptions: ExecOptions = {\n cwdFile: lockFileName,\n extraEnv,\n docker: {},\n toolConstraints,\n };\n /* v8 ignore next -- needs test */\n if (GlobalConfig.get('exposeAllEnv')) {\n extraEnv.NPM_AUTH = env.NPM_AUTH;\n extraEnv.NPM_EMAIL = env.NPM_EMAIL;\n }\n\n if (yarnUpdate && !isYarn1) {\n logger.debug('Updating Yarn binary');\n // TODO: types (#22198)\n commands.push(`yarn set version ${quote(yarnUpdate.newValue!)}`);\n }\n\n const allEnv = getEnv();\n if (allEnv.RENOVATE_X_YARN_PROXY) {\n // v8 ignore else -- TODO: add test #40625\n if (allEnv.HTTP_PROXY && !isYarn1) {\n commands.push('yarn config unset --home httpProxy');\n commands.push(\n `yarn config set --home httpProxy ${quote(allEnv.HTTP_PROXY)}`,\n );\n }\n // v8 ignore else -- TODO: add test #40625\n if (allEnv.HTTPS_PROXY && !isYarn1) {\n commands.push('yarn config unset --home httpsProxy');\n commands.push(\n `yarn config set --home httpsProxy ${quote(allEnv.HTTPS_PROXY)}`,\n );\n }\n }\n\n // This command updates the lock file based on package.json\n commands.push(`yarn install${cmdOptions}`);\n\n // rangeStrategy = update-lockfile\n const lockUpdates = upgrades.filter((upgrade) => upgrade.isLockfileUpdate);\n if (lockUpdates.length) {\n logger.debug('Performing lockfileUpdate (yarn)');\n if (isYarn1) {\n // `yarn upgrade` updates based on the version range specified in the package file\n // note - this can hit a yarn bug, see https://github.com/yarnpkg/yarn/issues/8236\n commands.push(\n `yarn upgrade ${lockUpdates\n .map((update) => update.depName)\n .filter(isString)\n .filter(uniqueStrings)\n .map(quote)\n .join(' ')}${cmdOptions}`,\n );\n } else {\n // `yarn up -R` updates to the latest release in each range\n commands.push(\n `yarn up -R ${lockUpdates\n // TODO: types (#22198)\n .map((update) => `${update.depName!}`)\n .filter(uniqueStrings)\n .map(quote)\n .join(' ')}${cmdOptions}`,\n );\n }\n }\n\n // postUpdateOptions\n ['fewer', 'highest'].forEach((s) => {\n if (\n config.postUpdateOptions?.includes(\n `yarnDedupe${s.charAt(0).toUpperCase()}${s.slice(1)}`,\n )\n ) {\n logger.debug(`Performing yarn dedupe ${s}`);\n if (isYarn1) {\n commands.push(`npx yarn-deduplicate --strategy ${s}`);\n // Run yarn again in case any changes are necessary\n commands.push(`yarn install${cmdOptions}`);\n } else if (isYarnDedupeAvailable && s === 'highest') {\n commands.push(`yarn dedupe --strategy ${s}${cmdOptions}`);\n } else {\n logger.debug(`yarn dedupe ${s} not available`);\n }\n }\n });\n\n if (upgrades.find((upgrade) => upgrade.isLockFileMaintenance)) {\n logger.debug(\n `Removing ${lockFileName} first due to lock file maintenance upgrade`,\n );\n\n // Note: Instead of just deleting the `yarn.lock` file, we just wipe it\n // and keep an empty lock file. Deleting the lock file could result in different\n // Yarn semantics. e.g. Yarn 2+ will error when `yarn install` is executed in\n // a subdirectory which is not part of a Yarn workspace. Yarn suggests to create\n // an empty lock file if a subdirectory should be treated as its own workspace.\n // https://github.com/yarnpkg/berry/blob/20612e82d26ead5928cc27bf482bb8d62dde87d3/packages/yarnpkg-core/sources/Project.ts#L284.\n try {\n await writeLocalFile(lockFileName, '');\n } catch (err) {\n // v8 ignore next -- TODO: add test #40625\n logger.debug(\n { err, lockFileName },\n 'Error clearing `yarn.lock` for lock file maintenance',\n );\n }\n }\n\n // Run the commands\n await exec(commands, execOptions);\n\n // Read the result\n lockFile = await readLocalFile(lockFileName, 'utf8');\n } catch (err) {\n // v8 ignore if -- TODO: add test #40625\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n logger.debug(\n {\n err,\n type: 'yarn',\n },\n 'lock file error',\n );\n const stdouterr = String(err.stdout) + String(err.stderr);\n // v8 ignore if -- TODO: add test #40625\n if (\n stdouterr.includes('ENOSPC: no space left on device') ||\n stdouterr.includes('Out of diskspace')\n ) {\n throw new Error(SYSTEM_INSUFFICIENT_DISK_SPACE);\n }\n // v8 ignore if -- TODO: add test #40625\n if (\n stdouterr.includes('The registry may be down.') ||\n stdouterr.includes('getaddrinfo ENOTFOUND registry.yarnpkg.com') ||\n stdouterr.includes('getaddrinfo ENOTFOUND registry.npmjs.org')\n ) {\n throw new ExternalHostError(err, NpmDatasource.id);\n }\n return { error: true, stderr: err.stderr, stdout: err.stdout };\n }\n return { lockFile };\n}\n\nexport function fuzzyMatchAdditionalYarnrcYml<\n T extends { npmRegistries?: Record<string, unknown> },\n>(additionalYarnRcYml: T, existingYarnrRcYml: T): T {\n const keys = new Map(\n Object.keys(coerceObject(existingYarnrRcYml.npmRegistries)).map((x) => [\n x.replace(regEx(/\\/$/), '').replace(regEx(/^https?:/), ''),\n x,\n ]),\n );\n\n return {\n ...additionalYarnRcYml,\n npmRegistries: Object.entries(\n coerceObject(additionalYarnRcYml.npmRegistries),\n )\n .map(([k, v]) => {\n const key = keys.get(k.replace(regEx(/\\/$/), '')) ?? k;\n return { [key]: v };\n })\n .reduce((acc, cur) => ({ ...acc, ...cur }), {}),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAuCA,eAAsB,YACpB,aAC8D;CAC9D,IAAI,gBAAgB;CACpB,IAAI,WAA0B;CAC9B,IAAI;EACF,MAAM,SAAS,MAAM,cACnB,MAAM,KAAK,aAAa,SAAS,GACjC,MACF;EACA,IAAI,SAAS,MAAM,GAAG;GAIpB,gBAAgB,CAAC,CAHE,OAChB,MAAM,YAAY,CAAC,CACnB,MAAM,SAAS,KAAK,WAAW,sBAAsB,CAC7B;GAC3B,MAAM,WAAW,OACd,MAAM,YAAY,CAAC,CACnB,MAAM,SAAS,KAAK,WAAW,YAAY,CAAC;GAC/C,IAAI,UACF,WAAW,SAAS,QAClB,MAAM,gCAAgC,GACtC,SACF;GAEF,IAAI,UAEF,WAAW,MAAM,KAAK,aAAa,QAAQ;GAE7C,MAAM,mBAAmB,WACrB,MAAM,gBAAgB,QAAQ,IAC9B;GACJ,IAAI,iBAAiB,OAClB,QAAQ,gCAAgC,EAAE,CAAC,CAC3C,QAAQ,kCAAkC,EAAE;GAC/C,IAAI,CAAC,kBAAkB;IACrB,iBAAiB,eAAe,QAC9B,MAAM,yBAAyB,GAC/B,EACF;IACA,WAAW;GACb;GACA,IAAI,WAAW,gBAAgB;IAC7B,OAAO,MAAM,+BAA+B,aAAa;IACzD,MAAM,eACJ,MAAM,KAAK,aAAa,SAAS,GACjC,cACF;GACF;EACF;CAEF,QAAQ,CAER;CACA,OAAO;EAAE;EAAe;CAAS;AACnC;AAEA,SAAgB,mBAAmB,UAA4B;CAC7D,OAAO;EAAC;EAAO;EAAM;EAAiC;CAAQ;AAChE;AAEA,SAAgB,aAAa,SAA2B;CACtD,OAAO,QAAQ,YAAY,oBAAoB,Q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AO,IAAI,MAAM,IAAI,OAAO,IAAI,MAAM;;EAExD,IACE,UAAU,SAAS,iCAAiC,KACpD,UAAU,SAAS,kBAAkB,GAErC,MAAM,IAAI,MAAM,8BAA8B;;EAGhD,IACE,UAAU,SAAS,2BAA2B,KAC9C,UAAU,SAAS,4CAA4C,KAC/D,UAAU,SAAS,0CAA0C,GAE7D,MAAM,IAAI,kBAAkB,KAAK,cAAc,EAAE;EAEnD,OAAO;GAAE,OAAO;GAAM,QAAQ,IAAI;GAAQ,QAAQ,IAAI;EAAO;CAC/D;CACA,OAAO,EAAE,SAAS;AACpB;AAEA,SAAgB,8BAEd,qBAAwB,oBAA0B;CAClD,MAAM,OAAO,IAAI,IACf,OAAO,KAAK,aAAa,mBAAmB,aAAa,CAAC,CAAC,CAAC,KAAK,MAAM,CACrE,EAAE,QAAQ,MAAM,KAAK,GAAG,EAAE,CAAC,CAAC,QAAQ,MAAM,UAAU,GAAG,EAAE,GACzD,CACF,CAAC,CACH;CAEA,OAAO;EACL,GAAG;EACH,eAAe,OAAO,QACpB,aAAa,oBAAoB,aAAa,CAChD,CAAC,CACE,KAAK,CAAC,GAAG,OAAO;GAEf,OAAO,GADK,KAAK,IAAI,EAAE,QAAQ,MAAM,KAAK,GAAG,EAAE,CAAC,KAAK,IACrC,EAAE;EACpB,CAAC,CAAC,CACD,QAAQ,KAAK,SAAS;GAAE,GAAG;GAAK,GAAG;EAAI,IAAI,CAAC,CAAC;CAClD;AACF"}
|
|
@@ -18,7 +18,7 @@ function findDepConstraints(packageJson, lockEntry, depName, currentVersion, new
|
|
|
18
18
|
if (parentDepName && requires) {
|
|
19
19
|
let constraint = requires[depName];
|
|
20
20
|
if (constraint) {
|
|
21
|
-
constraint = constraint.replace(regEx(/(
|
|
21
|
+
constraint = constraint.replace(regEx(/(?<digit>\d)rc$/), "$<digit>-rc");
|
|
22
22
|
// v8 ignore else -- TODO: add test #40625
|
|
23
23
|
if (api.isValid(constraint)) {
|
|
24
24
|
if (api.matches(currentVersion, constraint)) {
|
package/dist/modules/manager/npm/update/locked-dependency/package-lock/dep-constraints.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dep-constraints.js","names":["semver"],"sources":["../../../../../../../lib/modules/manager/npm/update/locked-dependency/package-lock/dep-constraints.ts"],"sourcesContent":["import type { PackageJson } from 'type-fest';\nimport { logger } from '../../../../../../logger/index.ts';\nimport { regEx } from '../../../../../../util/regex.ts';\nimport { api as semver } from '../../../../../versioning/npm/index.ts';\nimport type { PackageLockOrEntry, ParentDependency } from './types.ts';\n\n// Finds all parent dependencies for a given depName@currentVersion\nexport function findDepConstraints(\n packageJson: PackageJson,\n lockEntry: PackageLockOrEntry,\n depName: string,\n currentVersion: string,\n newVersion: string,\n parentDepName?: string,\n): ParentDependency[] {\n let parents: ParentDependency[] = [];\n let packageJsonConstraint = packageJson.dependencies?.[depName];\n if (\n packageJsonConstraint &&\n semver.matches(currentVersion, packageJsonConstraint)\n ) {\n parents.push({\n depType: 'dependencies',\n constraint: packageJsonConstraint,\n });\n }\n packageJsonConstraint = packageJson.devDependencies?.[depName];\n if (\n packageJsonConstraint &&\n semver.matches(currentVersion, packageJsonConstraint)\n ) {\n parents.push({\n depType: 'devDependencies',\n constraint: packageJsonConstraint,\n });\n }\n const { dependencies, requires, version } = lockEntry;\n if (parentDepName && requires) {\n let constraint = requires[depName];\n if (constraint) {\n constraint = constraint.replace(regEx(/(
|
|
1
|
+
{"version":3,"file":"dep-constraints.js","names":["semver"],"sources":["../../../../../../../lib/modules/manager/npm/update/locked-dependency/package-lock/dep-constraints.ts"],"sourcesContent":["import type { PackageJson } from 'type-fest';\nimport { logger } from '../../../../../../logger/index.ts';\nimport { regEx } from '../../../../../../util/regex.ts';\nimport { api as semver } from '../../../../../versioning/npm/index.ts';\nimport type { PackageLockOrEntry, ParentDependency } from './types.ts';\n\n// Finds all parent dependencies for a given depName@currentVersion\nexport function findDepConstraints(\n packageJson: PackageJson,\n lockEntry: PackageLockOrEntry,\n depName: string,\n currentVersion: string,\n newVersion: string,\n parentDepName?: string,\n): ParentDependency[] {\n let parents: ParentDependency[] = [];\n let packageJsonConstraint = packageJson.dependencies?.[depName];\n if (\n packageJsonConstraint &&\n semver.matches(currentVersion, packageJsonConstraint)\n ) {\n parents.push({\n depType: 'dependencies',\n constraint: packageJsonConstraint,\n });\n }\n packageJsonConstraint = packageJson.devDependencies?.[depName];\n if (\n packageJsonConstraint &&\n semver.matches(currentVersion, packageJsonConstraint)\n ) {\n parents.push({\n depType: 'devDependencies',\n constraint: packageJsonConstraint,\n });\n }\n const { dependencies, requires, version } = lockEntry;\n if (parentDepName && requires) {\n let constraint = requires[depName];\n if (constraint) {\n constraint = constraint.replace(regEx(/(?<digit>\\d)rc$/), '$<digit>-rc');\n // v8 ignore else -- TODO: add test #40625\n if (semver.isValid(constraint)) {\n if (semver.matches(currentVersion, constraint)) {\n if (constraint === currentVersion) {\n // Workaround for old versions of npm which wrote the exact version in requires instead of the constraint\n requires[depName] = newVersion;\n }\n parents.push({\n parentDepName,\n parentVersion: version,\n constraint,\n });\n }\n } else {\n logger.warn(\n { parentDepName, depName, currentVersion, constraint },\n 'Parent constraint is invalid',\n );\n }\n }\n }\n if (dependencies) {\n for (const [packageName, dependency] of Object.entries(dependencies)) {\n parents = parents.concat(\n findDepConstraints(\n packageJson,\n dependency,\n depName,\n currentVersion,\n newVersion,\n packageName,\n ),\n );\n }\n }\n // dedupe\n const res: ParentDependency[] = [];\n for (const req of parents) {\n const reqStringified = JSON.stringify(req);\n if (!res.find((i) => JSON.stringify(i) === reqStringified)) {\n res.push(req);\n }\n }\n return res;\n}\n"],"mappings":";;;;AAOA,SAAgB,mBACd,aACA,WACA,SACA,gBACA,YACA,eACoB;CACpB,IAAI,UAA8B,CAAC;CACnC,IAAI,wBAAwB,YAAY,eAAe;CACvD,IACE,yBACAA,IAAO,QAAQ,gBAAgB,qBAAqB,GAEpD,QAAQ,KAAK;EACX,SAAS;EACT,YAAY;CACd,CAAC;CAEH,wBAAwB,YAAY,kBAAkB;CACtD,IACE,yBACAA,IAAO,QAAQ,gBAAgB,qBAAqB,GAEpD,QAAQ,KAAK;EACX,SAAS;EACT,YAAY;CACd,CAAC;CAEH,MAAM,EAAE,cAAc,UAAU,YAAY;CAC5C,IAAI,iBAAiB,UAAU;EAC7B,IAAI,aAAa,SAAS;EAC1B,IAAI,YAAY;GACd,aAAa,WAAW,QAAQ,MAAM,iBAAiB,GAAG,aAAa;;GAEvE,IAAIA,IAAO,QAAQ,UAAU,GACvBA;QAAAA,IAAO,QAAQ,gBAAgB,UAAU,GAAG;KAC9C,IAAI,eAAe,gBAEjB,SAAS,WAAW;KAEtB,QAAQ,KAAK;MACX;MACA,eAAe;MACf;KACF,CAAC;IACH;UAEA,OAAO,KACL;IAAE;IAAe;IAAS;IAAgB;GAAW,GACrD,8BACF;EAEJ;CACF;CACA,IAAI,cACF,KAAK,MAAM,CAAC,aAAa,eAAe,OAAO,QAAQ,YAAY,GACjE,UAAU,QAAQ,OAChB,mBACE,aACA,YACA,SACA,gBACA,YACA,WACF,CACF;CAIJ,MAAM,MAA0B,CAAC;CACjC,KAAK,MAAM,OAAO,SAAS;EACzB,MAAM,iBAAiB,KAAK,UAAU,GAAG;EACzC,IAAI,CAAC,IAAI,MAAM,MAAM,KAAK,UAAU,CAAC,MAAM,cAAc,GACvD,IAAI,KAAK,GAAG;CAEhB;CACA,OAAO;AACT"}
|
|
@@ -4,7 +4,7 @@ import { logger } from "../../../../../../logger/index.js";
|
|
|
4
4
|
function replaceConstraintVersion(lockFileContent, depName, constraint, newVersion, newConstraint) {
|
|
5
5
|
if (lockFileContent.startsWith("__metadata:")) return lockFileContent;
|
|
6
6
|
const depNameConstraint = `${depName}@${constraint}`;
|
|
7
|
-
const matchString = `(${depNameConstraint.replace(regEx(/(
|
|
7
|
+
const matchString = `(${depNameConstraint.replace(regEx(/(?<special>@|\^|\.|\\|\|)/g), "\\$<special>")}(("|",|,)[^\n:]*)?:\n)(.*\n)*?(\\s+dependencies|\n[@a-z])`;
|
|
8
8
|
const matchResult = regEx(matchString).exec(lockFileContent);
|
|
9
9
|
/* v8 ignore next -- needs test */
|
|
10
10
|
if (!matchResult) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replace.js","names":[],"sources":["../../../../../../../lib/modules/manager/npm/update/locked-dependency/yarn-lock/replace.ts"],"sourcesContent":["import { logger } from '../../../../../../logger/index.ts';\nimport { regEx } from '../../../../../../util/regex.ts';\n\nexport function replaceConstraintVersion(\n lockFileContent: string,\n depName: string,\n constraint: string,\n newVersion: string,\n newConstraint?: string,\n): string {\n if (lockFileContent.startsWith('__metadata:')) {\n // Yarn 2+\n return lockFileContent;\n }\n const depNameConstraint = `${depName}@${constraint}`;\n const escaped = depNameConstraint.replace(regEx(/(
|
|
1
|
+
{"version":3,"file":"replace.js","names":[],"sources":["../../../../../../../lib/modules/manager/npm/update/locked-dependency/yarn-lock/replace.ts"],"sourcesContent":["import { logger } from '../../../../../../logger/index.ts';\nimport { regEx } from '../../../../../../util/regex.ts';\n\nexport function replaceConstraintVersion(\n lockFileContent: string,\n depName: string,\n constraint: string,\n newVersion: string,\n newConstraint?: string,\n): string {\n if (lockFileContent.startsWith('__metadata:')) {\n // Yarn 2+\n return lockFileContent;\n }\n const depNameConstraint = `${depName}@${constraint}`;\n const escaped = depNameConstraint.replace(\n regEx(/(?<special>@|\\^|\\.|\\\\|\\|)/g),\n '\\\\$<special>',\n );\n const matchString = `(${escaped}((\"|\",|,)[^\\n:]*)?:\\n)(.*\\n)*?(\\\\s+dependencies|\\n[@a-z])`;\n // yarn will fill in the details later\n const matchResult = regEx(matchString).exec(lockFileContent);\n /* v8 ignore next -- needs test */\n if (!matchResult) {\n logger.debug(\n { depName, constraint, newVersion },\n 'Could not find constraint in lock file',\n );\n return lockFileContent;\n }\n let constraintLine = matchResult[1];\n if (newConstraint) {\n const newDepNameConstraint = `${depName}@${newConstraint}`;\n constraintLine = constraintLine.replace(\n depNameConstraint,\n newDepNameConstraint,\n );\n }\n return lockFileContent.replace(\n regEx(matchString),\n `${constraintLine} version \"${newVersion}\"\\n$5`,\n );\n}\n"],"mappings":";;;AAGA,SAAgB,yBACd,iBACA,SACA,YACA,YACA,eACQ;CACR,IAAI,gBAAgB,WAAW,aAAa,GAE1C,OAAO;CAET,MAAM,oBAAoB,GAAG,QAAQ,GAAG;CAKxC,MAAM,cAAc,IAJJ,kBAAkB,QAChC,MAAM,4BAA4B,GAClC,cAE4B,EAAE;CAEhC,MAAM,cAAc,MAAM,WAAW,CAAC,CAAC,KAAK,eAAe;;CAE3D,IAAI,CAAC,aAAa;EAChB,OAAO,MACL;GAAE;GAAS;GAAY;EAAW,GAClC,wCACF;EACA,OAAO;CACT;CACA,IAAI,iBAAiB,YAAY;CACjC,IAAI,eAAe;EACjB,MAAM,uBAAuB,GAAG,QAAQ,GAAG;EAC3C,iBAAiB,eAAe,QAC9B,mBACA,oBACF;CACF;CACA,OAAO,gBAAgB,QACrB,MAAM,WAAW,GACjB,GAAG,eAAe,aAAa,WAAW,MAC5C;AACF"}
|
|
@@ -48,7 +48,7 @@ function extractDepsFromXml(xmlNode) {
|
|
|
48
48
|
let currentValue = attr?.Version ?? attr?.version ?? child.valueWithPath("Version") ?? attr?.VersionOverride ?? child.valueWithPath("VersionOverride");
|
|
49
49
|
if (!isNonEmptyStringAndNotWhitespace(currentValue)) dep.skipReason = "invalid-version";
|
|
50
50
|
let sharedVariableName;
|
|
51
|
-
currentValue = currentValue?.trim()?.replace(regEx(/^\$\((
|
|
51
|
+
currentValue = currentValue?.trim()?.replace(regEx(/^\$\((?<key>\w+)\)$/), (match, key) => {
|
|
52
52
|
sharedVariableName = key;
|
|
53
53
|
const val = vars.get(key);
|
|
54
54
|
if (val) return val;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract.js","names":["semver.isVersion"],"sources":["../../../../lib/modules/manager/nuget/extract.ts"],"sourcesContent":["import { isNonEmptyStringAndNotWhitespace, isString } from '@sindresorhus/is';\nimport type { XmlElement } from 'xmldoc';\nimport { XmlDocument } from 'xmldoc';\nimport { logger } from '../../../logger/index.ts';\nimport { getSiblingFileName, localPathExists } from '../../../util/fs/index.ts';\nimport { coerceObject } from '../../../util/object.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { NugetDatasource } from '../../datasource/nuget/index.ts';\nimport * as semver from '../../versioning/semver/index.ts';\nimport { getDep } from '../dockerfile/extract.ts';\nimport type {\n ExtractConfig,\n PackageDependency,\n PackageFileContent,\n} from '../types.ts';\nimport { extractMsbuildGlobalManifest } from './extract/global-manifest.ts';\nimport { extractPackagesFromSingleCsharpFile } from './extract/single-csharp-file.ts';\nimport type { DotnetToolsManifest, NugetPackageDependency } from './types.ts';\nimport {\n applyRegistries,\n findVersion,\n getConfiguredRegistries,\n isXmlElement,\n} from './util.ts';\n\n/**\n * https://learn.microsoft.com/nuget/concepts/package-versioning\n * This article mentions that Nuget 3.x and later tries to restore the lowest possible version\n * regarding to given version range.\n * 1.3.4 equals [1.3.4,)\n */\nconst elemNames = new Set([\n 'PackageReference',\n 'PackageVersion',\n 'DotNetCliToolReference',\n 'GlobalPackageReference',\n]);\n\nfunction extractDepsFromXml(xmlNode: XmlDocument): NugetPackageDependency[] {\n const results: NugetPackageDependency[] = [];\n const vars = new Map<string, string>();\n const todo: XmlElement[] = [xmlNode];\n while (todo.length) {\n const child = todo.pop()!;\n const { name, attr } = child;\n\n if (name === 'ContainerBaseImage') {\n const { depName, ...dep } = getDep(child.val, true);\n\n if (isNonEmptyStringAndNotWhitespace(depName)) {\n results.push({ ...dep, depName, depType: 'docker' });\n }\n } else if (elemNames.has(name)) {\n const depName = attr?.Include || attr?.Update;\n\n if (!depName) {\n continue;\n }\n\n const dep: NugetPackageDependency = {\n datasource: NugetDatasource.id,\n depType: 'nuget',\n depName,\n };\n\n let currentValue: string | undefined =\n attr?.Version ??\n attr?.version ??\n child.valueWithPath('Version') ??\n attr?.VersionOverride ??\n child.valueWithPath('VersionOverride');\n\n if (!isNonEmptyStringAndNotWhitespace(currentValue)) {\n dep.skipReason = 'invalid-version';\n }\n\n let sharedVariableName: string | undefined;\n\n currentValue = currentValue\n ?.trim()\n ?.replace(regEx(/^\\$\\((\\w+)\\)$/), (match, key) => {\n sharedVariableName = key;\n const val = vars.get(key);\n if (val) {\n return val;\n }\n return match;\n });\n\n if (sharedVariableName) {\n if (currentValue === `$(${sharedVariableName})`) {\n // this means that be failed to find/replace the variable\n dep.skipReason = 'contains-variable';\n } else {\n dep.sharedVariableName = sharedVariableName;\n }\n }\n\n dep.currentValue = currentValue;\n results.push(dep);\n } else if (name === 'Sdk') {\n const depName = attr?.Name;\n const version = attr?.Version;\n // if sdk element is present it will always have the Name field but the Version is an optional field\n if (depName && version) {\n results.push({\n depName,\n currentValue: version,\n depType: 'msbuild-sdk',\n datasource: NugetDatasource.id,\n });\n }\n } else if (name === 'Import') {\n const depName = attr?.Sdk;\n const version = attr?.Version;\n if (depName && version) {\n results.push({\n depName,\n currentValue: version,\n depType: 'msbuild-sdk',\n datasource: NugetDatasource.id,\n });\n }\n } else {\n if (name === 'Project') {\n if (attr?.Sdk) {\n const str = attr?.Sdk;\n const [name, version] = str.split('/');\n if (name && version) {\n results.push({\n depName: name,\n depType: 'msbuild-sdk',\n currentValue: version,\n datasource: NugetDatasource.id,\n });\n }\n }\n\n const propertyGroup = child.childNamed('PropertyGroup');\n if (propertyGroup) {\n for (const propChild of propertyGroup.children) {\n if (isXmlElement(propChild)) {\n const { name, val } = propChild;\n if (!['Version', 'TargetFramework'].includes(name)) {\n vars.set(name, val);\n }\n }\n }\n }\n }\n\n todo.push(...child.children.filter(isXmlElement));\n }\n }\n return results;\n}\n\nexport async function extractPackageFile(\n content: string,\n packageFile: string,\n _config: ExtractConfig,\n): Promise<PackageFileContent | null> {\n logger.trace(`nuget.extractPackageFile(${packageFile})`);\n\n const registries = await getConfiguredRegistries(packageFile);\n\n if (packageFile.endsWith('dotnet-tools.json')) {\n const deps: PackageDependency[] = [];\n let manifest: DotnetToolsManifest;\n\n try {\n manifest = JSON.parse(content);\n } catch {\n logger.debug({ packageFile }, `Invalid JSON`);\n return null;\n }\n\n if (manifest.version !== 1) {\n logger.debug({ packageFile }, 'Unsupported dotnet tools version');\n return null;\n }\n\n for (const depName of Object.keys(coerceObject(manifest.tools))) {\n const tool = manifest.tools[depName];\n const currentValue = tool.version;\n const dep: NugetPackageDependency = {\n depType: 'nuget',\n depName,\n currentValue,\n datasource: NugetDatasource.id,\n };\n if (isString(currentValue) && semver.isVersion(currentValue)) {\n // This is to avoid nuget versioning pinning to [1.2.3]\n dep.versioning = 'semver';\n }\n\n applyRegistries(dep, registries);\n\n deps.push(dep);\n }\n\n return deps.length ? { deps } : null;\n }\n\n if (packageFile.endsWith('global.json')) {\n return extractMsbuildGlobalManifest(content, packageFile, registries);\n }\n\n if (packageFile.endsWith('.cs')) {\n return extractPackagesFromSingleCsharpFile(\n content,\n packageFile,\n registries,\n );\n }\n\n // Simple xml validation.\n // Should start with `<` and end with `>` after trimming all whitespace\n if (!regEx(/^\\s*<.+>$/m).test(content.trim())) {\n logger.debug(`NuGet: Skipping ${packageFile} as it is not XML`);\n return null;\n }\n\n let deps: PackageDependency[] = [];\n let packageFileVersion: string | undefined;\n try {\n const parsedXml = new XmlDocument(content);\n deps = extractDepsFromXml(parsedXml).map((dep) =>\n applyRegistries(dep, registries),\n );\n packageFileVersion = findVersion(parsedXml)?.val;\n } catch (err) {\n logger.debug({ err, packageFile }, `Failed to parse XML`);\n }\n\n if (!deps.length) {\n return null;\n }\n\n const res: PackageFileContent = { deps, packageFileVersion };\n const lockFileName = getSiblingFileName(packageFile, 'packages.lock.json');\n if (await localPathExists(lockFileName)) {\n res.lockFiles = [lockFileName];\n }\n return res;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA+BA,MAAM,4BAAY,IAAI,IAAI;CACxB;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,mBAA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;IACA,YAAY,gBAAgB;GAC9B;GACA,IAAI,SAAS,YAAY,KAAKA,UAAiB,YAAY,GAEzD,IAAI,aAAa;GAGnB,gBAAgB,KAAK,UAAU;GAE/B,KAAK,KAAK,GAAG;EACf;EAEA,OAAO,KAAK,SAAS,EAAE,KAAK,IAAI;CAClC;CAEA,IAAI,YAAY,SAAS,aAAa,GACpC,OAAO,6BAA6B,SAAS,aAAa,UAAU;CAGtE,IAAI,YAAY,SAAS,KAAK,GAC5B,OAAO,oCACL,SACA,aACA,UACF;CAKF,IAAI,CAAC,MAAM,YAAY,CAAC,CAAC,KAAK,QAAQ,KAAK,CAAC,GAAG;EAC7C,OAAO,MAAM,mBAAmB,YAAY,kBAAkB;EAC9D,OAAO;CACT;CAEA,IAAI,OAA4B,CAAC;CACjC,IAAI;CACJ,IAAI;EACF,MAAM,YAAY,IAAI,YAAY,OAAO;EACzC,OAAO,mBAAmB,SAAS,CAAC,CAAC,KAAK,QACxC,gBAAgB,KAAK,UAAU,CACjC;EACA,qBAAqB,YAAY,SAAS,CAAC,EAAE;CAC/C,SAAS,KAAK;EACZ,OAAO,MAAM;GAAE;GAAK;EAAY,GAAG,qBAAqB;CAC1D;CAEA,IAAI,CAAC,KAAK,QACR,OAAO;CAGT,MAAM,MAA0B;EAAE;EAAM;CAAmB;CAC3D,MAAM,eAAe,mBAAmB,aAAa,oBAAoB;CACzE,IAAI,MAAM,gBAAgB,YAAY,GACpC,IAAI,YAAY,CAAC,YAAY;CAE/B,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"extract.js","names":["semver.isVersion"],"sources":["../../../../lib/modules/manager/nuget/extract.ts"],"sourcesContent":["import { isNonEmptyStringAndNotWhitespace, isString } from '@sindresorhus/is';\nimport type { XmlElement } from 'xmldoc';\nimport { XmlDocument } from 'xmldoc';\nimport { logger } from '../../../logger/index.ts';\nimport { getSiblingFileName, localPathExists } from '../../../util/fs/index.ts';\nimport { coerceObject } from '../../../util/object.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { NugetDatasource } from '../../datasource/nuget/index.ts';\nimport * as semver from '../../versioning/semver/index.ts';\nimport { getDep } from '../dockerfile/extract.ts';\nimport type {\n ExtractConfig,\n PackageDependency,\n PackageFileContent,\n} from '../types.ts';\nimport { extractMsbuildGlobalManifest } from './extract/global-manifest.ts';\nimport { extractPackagesFromSingleCsharpFile } from './extract/single-csharp-file.ts';\nimport type { DotnetToolsManifest, NugetPackageDependency } from './types.ts';\nimport {\n applyRegistries,\n findVersion,\n getConfiguredRegistries,\n isXmlElement,\n} from './util.ts';\n\n/**\n * https://learn.microsoft.com/nuget/concepts/package-versioning\n * This article mentions that Nuget 3.x and later tries to restore the lowest possible version\n * regarding to given version range.\n * 1.3.4 equals [1.3.4,)\n */\nconst elemNames = new Set([\n 'PackageReference',\n 'PackageVersion',\n 'DotNetCliToolReference',\n 'GlobalPackageReference',\n]);\n\nfunction extractDepsFromXml(xmlNode: XmlDocument): NugetPackageDependency[] {\n const results: NugetPackageDependency[] = [];\n const vars = new Map<string, string>();\n const todo: XmlElement[] = [xmlNode];\n while (todo.length) {\n const child = todo.pop()!;\n const { name, attr } = child;\n\n if (name === 'ContainerBaseImage') {\n const { depName, ...dep } = getDep(child.val, true);\n\n if (isNonEmptyStringAndNotWhitespace(depName)) {\n results.push({ ...dep, depName, depType: 'docker' });\n }\n } else if (elemNames.has(name)) {\n const depName = attr?.Include || attr?.Update;\n\n if (!depName) {\n continue;\n }\n\n const dep: NugetPackageDependency = {\n datasource: NugetDatasource.id,\n depType: 'nuget',\n depName,\n };\n\n let currentValue: string | undefined =\n attr?.Version ??\n attr?.version ??\n child.valueWithPath('Version') ??\n attr?.VersionOverride ??\n child.valueWithPath('VersionOverride');\n\n if (!isNonEmptyStringAndNotWhitespace(currentValue)) {\n dep.skipReason = 'invalid-version';\n }\n\n let sharedVariableName: string | undefined;\n\n currentValue = currentValue\n ?.trim()\n ?.replace(regEx(/^\\$\\((?<key>\\w+)\\)$/), (match, key) => {\n sharedVariableName = key;\n const val = vars.get(key);\n if (val) {\n return val;\n }\n return match;\n });\n\n if (sharedVariableName) {\n if (currentValue === `$(${sharedVariableName})`) {\n // this means that be failed to find/replace the variable\n dep.skipReason = 'contains-variable';\n } else {\n dep.sharedVariableName = sharedVariableName;\n }\n }\n\n dep.currentValue = currentValue;\n results.push(dep);\n } else if (name === 'Sdk') {\n const depName = attr?.Name;\n const version = attr?.Version;\n // if sdk element is present it will always have the Name field but the Version is an optional field\n if (depName && version) {\n results.push({\n depName,\n currentValue: version,\n depType: 'msbuild-sdk',\n datasource: NugetDatasource.id,\n });\n }\n } else if (name === 'Import') {\n const depName = attr?.Sdk;\n const version = attr?.Version;\n if (depName && version) {\n results.push({\n depName,\n currentValue: version,\n depType: 'msbuild-sdk',\n datasource: NugetDatasource.id,\n });\n }\n } else {\n if (name === 'Project') {\n if (attr?.Sdk) {\n const str = attr?.Sdk;\n const [name, version] = str.split('/');\n if (name && version) {\n results.push({\n depName: name,\n depType: 'msbuild-sdk',\n currentValue: version,\n datasource: NugetDatasource.id,\n });\n }\n }\n\n const propertyGroup = child.childNamed('PropertyGroup');\n if (propertyGroup) {\n for (const propChild of propertyGroup.children) {\n if (isXmlElement(propChild)) {\n const { name, val } = propChild;\n if (!['Version', 'TargetFramework'].includes(name)) {\n vars.set(name, val);\n }\n }\n }\n }\n }\n\n todo.push(...child.children.filter(isXmlElement));\n }\n }\n return results;\n}\n\nexport async function extractPackageFile(\n content: string,\n packageFile: string,\n _config: ExtractConfig,\n): Promise<PackageFileContent | null> {\n logger.trace(`nuget.extractPackageFile(${packageFile})`);\n\n const registries = await getConfiguredRegistries(packageFile);\n\n if (packageFile.endsWith('dotnet-tools.json')) {\n const deps: PackageDependency[] = [];\n let manifest: DotnetToolsManifest;\n\n try {\n manifest = JSON.parse(content);\n } catch {\n logger.debug({ packageFile }, `Invalid JSON`);\n return null;\n }\n\n if (manifest.version !== 1) {\n logger.debug({ packageFile }, 'Unsupported dotnet tools version');\n return null;\n }\n\n for (const depName of Object.keys(coerceObject(manifest.tools))) {\n const tool = manifest.tools[depName];\n const currentValue = tool.version;\n const dep: NugetPackageDependency = {\n depType: 'nuget',\n depName,\n currentValue,\n datasource: NugetDatasource.id,\n };\n if (isString(currentValue) && semver.isVersion(currentValue)) {\n // This is to avoid nuget versioning pinning to [1.2.3]\n dep.versioning = 'semver';\n }\n\n applyRegistries(dep, registries);\n\n deps.push(dep);\n }\n\n return deps.length ? { deps } : null;\n }\n\n if (packageFile.endsWith('global.json')) {\n return extractMsbuildGlobalManifest(content, packageFile, registries);\n }\n\n if (packageFile.endsWith('.cs')) {\n return extractPackagesFromSingleCsharpFile(\n content,\n packageFile,\n registries,\n );\n }\n\n // Simple xml validation.\n // Should start with `<` and end with `>` after trimming all whitespace\n if (!regEx(/^\\s*<.+>$/m).test(content.trim())) {\n logger.debug(`NuGet: Skipping ${packageFile} as it is not XML`);\n return null;\n }\n\n let deps: PackageDependency[] = [];\n let packageFileVersion: string | undefined;\n try {\n const parsedXml = new XmlDocument(content);\n deps = extractDepsFromXml(parsedXml).map((dep) =>\n applyRegistries(dep, registries),\n );\n packageFileVersion = findVersion(parsedXml)?.val;\n } catch (err) {\n logger.debug({ err, packageFile }, `Failed to parse XML`);\n }\n\n if (!deps.length) {\n return null;\n }\n\n const res: PackageFileContent = { deps, packageFileVersion };\n const lockFileName = getSiblingFileName(packageFile, 'packages.lock.json');\n if (await localPathExists(lockFileName)) {\n res.lockFiles = [lockFileName];\n }\n return res;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA+BA,MAAM,4BAAY,IAAI,IAAI;CACxB;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,mBAAmB,SAAgD;CAC1E,MAAM,UAAoC,CAAC;CAC3C,MAAM,uBAAO,IAAI,IAAoB;CACrC,MAAM,OAAqB,CAAC,OAAO;CACnC,OAAO,KAAK,QAAQ;EAClB,MAAM,QAAQ,KAAK,IAAI;EACvB,MAAM,EAAE,MAAM,SAAS;EA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;CAClC;CAEA,IAAI,YAAY,SAAS,aAAa,GACpC,OAAO,6BAA6B,SAAS,aAAa,UAAU;CAGtE,IAAI,YAAY,SAAS,KAAK,GAC5B,OAAO,oCACL,SACA,aACA,UACF;CAKF,IAAI,CAAC,MAAM,YAAY,CAAC,CAAC,KAAK,QAAQ,KAAK,CAAC,GAAG;EAC7C,OAAO,MAAM,mBAAmB,YAAY,kBAAkB;EAC9D,OAAO;CACT;CAEA,IAAI,OAA4B,CAAC;CACjC,IAAI;CACJ,IAAI;EACF,MAAM,YAAY,IAAI,YAAY,OAAO;EACzC,OAAO,mBAAmB,SAAS,CAAC,CAAC,KAAK,QACxC,gBAAgB,KAAK,UAAU,CACjC;EACA,qBAAqB,YAAY,SAAS,CAAC,EAAE;CAC/C,SAAS,KAAK;EACZ,OAAO,MAAM;GAAE;GAAK;EAAY,GAAG,qBAAqB;CAC1D;CAEA,IAAI,CAAC,KAAK,QACR,OAAO;CAGT,MAAM,MAA0B;EAAE;EAAM;CAAmB;CAC3D,MAAM,eAAe,mBAAmB,aAAa,oBAAoB;CACzE,IAAI,MAAM,gBAAgB,YAAY,GACpC,IAAI,YAAY,CAAC,YAAY;CAE/B,OAAO;AACT"}
|
|
@@ -4,7 +4,7 @@ import { normalizePythonDepName } from "../../datasource/pypi/common.js";
|
|
|
4
4
|
import { PypiDatasource } from "../../datasource/pypi/index.js";
|
|
5
5
|
import { isNonEmptyString, isNullOrUndefined } from "@sindresorhus/is";
|
|
6
6
|
//#region lib/modules/manager/pep621/utils.ts
|
|
7
|
-
const pep508Regex = regEx(/^(?<packageName>[A-Z0-9._-]+)\s*(
|
|
7
|
+
const pep508Regex = regEx(/^(?<packageName>[A-Z0-9._-]+)\s*(?:\[(?<extras>[A-Z0-9\s,._-]+)\])?\s*(?<currentValue>[^;]+)?(?:;\s*(?<marker>.*))?/i);
|
|
8
8
|
const depTypes = {
|
|
9
9
|
dependencies: "project.dependencies",
|
|
10
10
|
optionalDependencies: "project.optional-dependencies",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../../../../lib/modules/manager/pep621/utils.ts"],"sourcesContent":["import { isNonEmptyString, isNullOrUndefined } from '@sindresorhus/is';\nimport { logger } from '../../../logger/index.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { normalizePythonDepName } from '../../datasource/pypi/common.ts';\nimport { PypiDatasource } from '../../datasource/pypi/index.ts';\nimport type { PackageDependency } from '../types.ts';\nimport type { Pep508ParseResult } from './types.ts';\n\nconst pep508Regex = regEx(\n /^(?<packageName>[A-Z0-9._-]+)\\s*(
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../../../../lib/modules/manager/pep621/utils.ts"],"sourcesContent":["import { isNonEmptyString, isNullOrUndefined } from '@sindresorhus/is';\nimport { logger } from '../../../logger/index.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { normalizePythonDepName } from '../../datasource/pypi/common.ts';\nimport { PypiDatasource } from '../../datasource/pypi/index.ts';\nimport type { PackageDependency } from '../types.ts';\nimport type { Pep508ParseResult } from './types.ts';\n\nconst pep508Regex = regEx(\n /^(?<packageName>[A-Z0-9._-]+)\\s*(?:\\[(?<extras>[A-Z0-9\\s,._-]+)\\])?\\s*(?<currentValue>[^;]+)?(?:;\\s*(?<marker>.*))?/i,\n);\n\nexport const depTypes = {\n dependencies: 'project.dependencies',\n optionalDependencies: 'project.optional-dependencies',\n dependencyGroups: 'dependency-groups',\n pdmDevDependencies: 'tool.pdm.dev-dependencies',\n uvDevDependencies: 'tool.uv.dev-dependencies',\n uvSources: 'tool.uv.sources',\n buildSystemRequires: 'build-system.requires',\n};\n\nexport function parsePEP508(\n value: string | null | undefined,\n): Pep508ParseResult | null {\n if (isNullOrUndefined(value)) {\n return null;\n }\n\n const regExpExec = pep508Regex.exec(value);\n if (isNullOrUndefined(regExpExec) || isNullOrUndefined(regExpExec?.groups)) {\n logger.trace(`Pep508 could not be extracted`);\n return null;\n }\n\n const result: Pep508ParseResult = {\n packageName: regExpExec.groups.packageName,\n };\n if (isNonEmptyString(regExpExec.groups.currentValue)) {\n if (\n regExpExec.groups.currentValue.startsWith('(') &&\n regExpExec.groups.currentValue.endsWith(')')\n ) {\n result.currentValue = regExpExec.groups.currentValue.slice(1, -1).trim();\n } else {\n result.currentValue = regExpExec.groups.currentValue;\n }\n }\n\n if (isNonEmptyString(regExpExec.groups.marker)) {\n result.marker = regExpExec.groups.marker;\n }\n if (isNonEmptyString(regExpExec.groups.extras)) {\n // trim to remove allowed whitespace between brackets\n result.extras = regExpExec.groups.extras.split(',').map((e) => e.trim());\n }\n\n return result;\n}\n\nexport function pep508ToPackageDependency(\n depType: string,\n value: string,\n): PackageDependency | null {\n const parsed = parsePEP508(value);\n if (isNullOrUndefined(parsed)) {\n return null;\n }\n\n const dep: PackageDependency = {\n packageName: normalizePythonDepName(parsed.packageName),\n depName: parsed.packageName,\n datasource: PypiDatasource.id,\n depType,\n };\n\n if (isNullOrUndefined(parsed.currentValue)) {\n dep.skipReason = 'unspecified-version';\n } else {\n dep.currentValue = parsed.currentValue;\n\n if (parsed.currentValue.startsWith('==')) {\n dep.currentVersion = parsed.currentValue.replace(regEx(/^==\\s*/), '');\n }\n }\n return dep;\n}\n"],"mappings":";;;;;;AAQA,MAAM,cAAc,MAClB,sHACF;AAEA,MAAa,WAAW;CACtB,cAAc;CACd,sBAAsB;CACtB,kBAAkB;CAClB,oBAAoB;CACpB,mBAAmB;CACnB,WAAW;CACX,qBAAqB;AACvB;AAEA,SAAgB,YACd,OAC0B;CAC1B,IAAI,kBAAkB,KAAK,GACzB,OAAO;CAGT,MAAM,aAAa,YAAY,KAAK,KAAK;CACzC,IAAI,kBAAkB,UAAU,KAAK,kBAAkB,YAAY,MAAM,GAAG;EAC1E,OAAO,MAAM,+BAA+B;EAC5C,OAAO;CACT;CAEA,MAAM,SAA4B,EAChC,aAAa,WAAW,OAAO,YACjC;CACA,IAAI,iBAAiB,WAAW,OAAO,YAAY,GAAG;EACpD,IACE,WAAW,OAAO,aAAa,WAAW,GAAG,KAC7C,WAAW,OAAO,aAAa,SAAS,GAAG,GAE3C,OAAO,eAAe,WAAW,OAAO,aAAa,MAAM,GAAG,EAAE,CAAC,CAAC,KAAK;OAEvE,OAAO,eAAe,WAAW,OAAO;CAE5C;CAEA,IAAI,iBAAiB,WAAW,OAAO,MAAM,GAC3C,OAAO,SAAS,WAAW,OAAO;CAEpC,IAAI,iBAAiB,WAAW,OAAO,MAAM,GAE3C,OAAO,SAAS,WAAW,OAAO,OAAO,MAAM,GAAG,CAAC,CAAC,KAAK,MAAM,EAAE,KAAK,CAAC;CAGzE,OAAO;AACT;AAEA,SAAgB,0BACd,SACA,OAC0B;CAC1B,MAAM,SAAS,YAAY,KAAK;CAChC,IAAI,kBAAkB,MAAM,GAC1B,OAAO;CAGT,MAAM,MAAyB;EAC7B,aAAa,uBAAuB,OAAO,WAAW;EACtD,SAAS,OAAO;EAChB,YAAY,eAAe;EAC3B;CACF;CAEA,IAAI,kBAAkB,OAAO,YAAY,GACvC,IAAI,aAAa;MACZ;EACL,IAAI,eAAe,OAAO;EAE1B,IAAI,OAAO,aAAa,WAAW,IAAI,GACrC,IAAI,iBAAiB,OAAO,aAAa,QAAQ,MAAM,QAAQ,GAAG,EAAE;CAExE;CACA,OAAO;AACT"}
|
|
@@ -2,7 +2,7 @@ import { newlineRegex, regEx } from "../../../util/regex.js";
|
|
|
2
2
|
import { logger } from "../../../logger/index.js";
|
|
3
3
|
import { Pep723 } from "./schema.js";
|
|
4
4
|
//#region lib/modules/manager/pep723/utils.ts
|
|
5
|
-
const regex = regEx(/^# \/\/\/ (?<type>[a-zA-Z0-9-]+)$\s(?<content>(
|
|
5
|
+
const regex = regEx(/^# \/\/\/ (?<type>[a-zA-Z0-9-]+)$\s(?<content>(?:^#(?:| .*)$\s)+)^# \/\/\/$/, "m");
|
|
6
6
|
function extractPep723(content, packageFile) {
|
|
7
7
|
const matchedContent = regex.exec(content)?.groups?.content;
|
|
8
8
|
if (!matchedContent) return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../../../../lib/modules/manager/pep723/utils.ts"],"sourcesContent":["import { logger } from '../../../logger/index.ts';\nimport { newlineRegex, regEx } from '../../../util/regex.ts';\nimport type { PackageFileContent } from '../types.ts';\nimport { Pep723 } from './schema.ts';\n\n// Adapted regex from the Python reference implementation: https://packaging.python.org/en/latest/specifications/inline-script-metadata/#reference-implementation\nconst regex = regEx(\n /^# \\/\\/\\/ (?<type>[a-zA-Z0-9-]+)$\\s(?<content>(
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../../../../lib/modules/manager/pep723/utils.ts"],"sourcesContent":["import { logger } from '../../../logger/index.ts';\nimport { newlineRegex, regEx } from '../../../util/regex.ts';\nimport type { PackageFileContent } from '../types.ts';\nimport { Pep723 } from './schema.ts';\n\n// Adapted regex from the Python reference implementation: https://packaging.python.org/en/latest/specifications/inline-script-metadata/#reference-implementation\nconst regex = regEx(\n /^# \\/\\/\\/ (?<type>[a-zA-Z0-9-]+)$\\s(?<content>(?:^#(?:| .*)$\\s)+)^# \\/\\/\\/$/,\n 'm',\n);\n\nexport function extractPep723(\n content: string,\n packageFile: string,\n): PackageFileContent | null {\n const match = regex.exec(content);\n const matchedContent = match?.groups?.content;\n\n if (!matchedContent) {\n return null;\n }\n\n // Adapted code from the Python reference implementation: https://packaging.python.org/en/latest/specifications/inline-script-metadata/#reference-implementation\n const parsedToml = matchedContent\n .split(newlineRegex)\n .map((line) => line.substring(line.startsWith('# ') ? 2 : 1))\n .join('\\n');\n\n const { data: res, error } = Pep723.safeParse(parsedToml);\n\n if (error) {\n logger.debug(\n { packageFile, error },\n `Error parsing PEP 723 inline script metadata`,\n );\n return null;\n }\n\n return res.deps.length ? res : null;\n}\n"],"mappings":";;;;AAMA,MAAM,QAAQ,MACZ,+EACA,GACF;AAEA,SAAgB,cACd,SACA,aAC2B;CAE3B,MAAM,iBADQ,MAAM,KAAK,OACE,CAAC,EAAE,QAAQ;CAEtC,IAAI,CAAC,gBACH,OAAO;CAIT,MAAM,aAAa,eAChB,MAAM,YAAY,CAAC,CACnB,KAAK,SAAS,KAAK,UAAU,KAAK,WAAW,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,CAC5D,KAAK,IAAI;CAEZ,MAAM,EAAE,MAAM,KAAK,UAAU,OAAO,UAAU,UAAU;CAExD,IAAI,OAAO;EACT,OAAO,MACL;GAAE;GAAa;EAAM,GACrB,8CACF;EACA,OAAO;CACT;CAEA,OAAO,IAAI,KAAK,SAAS,MAAM;AACjC"}
|
|
@@ -67,7 +67,7 @@ async function getExecOptions(config, commandType, cwd, extraEnv, extractedPytho
|
|
|
67
67
|
}
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
|
-
const constraintLineRegex = regEx(/^(
|
|
70
|
+
const constraintLineRegex = regEx(/^(?:#.*?\r?\n)+# {4}(?<command>\S*)(?<arguments> .*?)?\r?\n/);
|
|
71
71
|
const disallowedPipOptions = ["--no-header"];
|
|
72
72
|
const commonOptionsWithArguments = [
|
|
73
73
|
"--output-file",
|
|
@@ -195,7 +195,7 @@ function extractHeaderCommand(content, fileName) {
|
|
|
195
195
|
if (result.sourceFiles.length === 0) throw new Error("No source files detected in command, pass at least one package file explicitly");
|
|
196
196
|
return result;
|
|
197
197
|
}
|
|
198
|
-
const pythonVersionRegex = regEx(/^(
|
|
198
|
+
const pythonVersionRegex = regEx(/^(?:#.*?\r?\n)*# This file is autogenerated by pip-compile with Python (?<pythonVersion>\d+(?:\.\d+)*)\s/, "i");
|
|
199
199
|
function extractPythonVersion(content, fileName) {
|
|
200
200
|
const match = pythonVersionRegex.exec(content);
|
|
201
201
|
if (match?.groups === void 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","names":["hostRules.find"],"sources":["../../../../lib/modules/manager/pip-compile/common.ts"],"sourcesContent":["import { isString } from '@sindresorhus/is';\nimport { split } from 'shlex';\nimport upath from 'upath';\nimport { logger } from '../../../logger/index.ts';\nimport { coerceArray, isNotNullOrUndefined } from '../../../util/array.ts';\nimport type {\n ExecOptions,\n ExtraEnv,\n ToolConstraint,\n} from '../../../util/exec/types.ts';\nimport { ensureCacheDir } from '../../../util/fs/index.ts';\nimport { ensureLocalPath } from '../../../util/fs/util.ts';\nimport * as hostRules from '../../../util/host-rules.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { parseUrl } from '../../../util/url.ts';\nimport type { PackageFileContent, UpdateArtifactsConfig } from '../types.ts';\nimport type {\n CommandType,\n PipCompileArgs,\n SupportedManagers,\n} from './types.ts';\n\nexport function getPythonVersionConstraint(\n config: UpdateArtifactsConfig,\n extractedPythonVersion: string | undefined,\n): string | undefined | null {\n const { constraints = {} } = config;\n const { python } = constraints;\n\n if (python) {\n logger.debug('Using python constraint from config');\n return python;\n }\n\n if (extractedPythonVersion) {\n logger.debug('Using python constraint extracted from the lock file');\n return `==${extractedPythonVersion}`;\n }\n\n return undefined;\n}\n\nexport function getPipToolsVersionConstraint(\n config: UpdateArtifactsConfig,\n): string {\n const { constraints = {} } = config;\n const { pipTools } = constraints;\n\n if (isString(pipTools)) {\n logger.debug('Using pipTools constraint from config');\n return pipTools;\n }\n\n return '';\n}\n\nexport function getUvVersionConstraint(config: UpdateArtifactsConfig): string {\n const { constraints = {} } = config;\n const { uv } = constraints;\n\n if (isString(uv)) {\n logger.debug('Using uv constraint from config');\n return uv;\n }\n\n return '';\n}\n\nexport function getToolVersionConstraint(\n config: UpdateArtifactsConfig,\n commandType: CommandType,\n): ToolConstraint {\n if (commandType === 'uv') {\n return {\n toolName: 'uv',\n constraint: getUvVersionConstraint(config),\n };\n }\n\n return {\n toolName: 'pip-tools',\n constraint: getPipToolsVersionConstraint(config),\n };\n}\n\nexport async function getExecOptions(\n config: UpdateArtifactsConfig,\n commandType: CommandType,\n cwd: string,\n extraEnv: ExtraEnv<string>,\n extractedPythonVersion: string | undefined,\n): Promise<ExecOptions> {\n const constraint = getPythonVersionConstraint(config, extractedPythonVersion);\n const execOptions: ExecOptions = {\n cwd: ensureLocalPath(cwd),\n docker: {},\n toolConstraints: [\n {\n toolName: 'python',\n constraint,\n },\n getToolVersionConstraint(config, commandType),\n ],\n extraEnv: {\n PIP_CACHE_DIR: await ensureCacheDir('pip'),\n PIP_NO_INPUT: 'true', // ensure pip doesn't block forever waiting for credentials on stdin\n PIP_KEYRING_PROVIDER: 'import',\n PYTHON_KEYRING_BACKEND: 'keyrings.envvars.keyring.EnvvarsKeyring',\n ...extraEnv,\n },\n };\n return execOptions;\n}\n\nexport const constraintLineRegex = regEx(\n /^(#.*?\\r?\\n)+# {4}(?<command>\\S*)(?<arguments> .*?)?\\r?\\n/,\n);\n\nexport const disallowedPipOptions = [\n '--no-header', // header is required by this manager\n];\nconst commonOptionsWithArguments = [\n '--output-file',\n '--extra',\n '--extra-index-url',\n];\nconst pipOptionsWithArguments = [\n '--resolver',\n '--constraint',\n ...commonOptionsWithArguments,\n];\nconst uvOptionsWithArguments = [\n '--constraints',\n '--constraint', // singular alias accepted by uv\n '--python-version',\n '--no-emit-package',\n '--prerelease',\n '--format',\n '--resolution',\n '--fork-strategy',\n '--exclude-newer',\n '--exclude-newer-package',\n '--group',\n '--override',\n '--overrides',\n ...commonOptionsWithArguments,\n];\nexport const optionsWithArguments = [\n ...pipOptionsWithArguments,\n ...uvOptionsWithArguments,\n];\nconst allowedCommonOptions = [\n '-v',\n '--generate-hashes',\n '--emit-index-url',\n '--index-url',\n '--all-extras',\n];\nexport const allowedOptions: Record<CommandType, string[]> = {\n 'pip-compile': [\n '--allow-unsafe',\n '--generate-hashes',\n '--no-emit-index-url',\n '--strip-extras',\n ...allowedCommonOptions,\n ...pipOptionsWithArguments,\n ],\n uv: [\n '--no-strip-extras',\n '--universal',\n ...allowedCommonOptions,\n ...uvOptionsWithArguments,\n ],\n custom: [],\n};\n\n// TODO(not7cd): test on all correct headers, even with CUSTOM_COMPILE_COMMAND\nexport function extractHeaderCommand(\n content: string,\n fileName: string,\n): PipCompileArgs {\n const compileCommand = constraintLineRegex.exec(content);\n if (compileCommand?.groups === undefined) {\n throw new Error(\n `Failed to extract command from header in ${fileName} ${content}`,\n );\n }\n logger.trace(\n `pip-compile: found header in ${fileName}: \\n${compileCommand[0]}`,\n );\n const command = compileCommand.groups.command;\n const argv = [command];\n let commandType: CommandType;\n if (command === 'pip-compile') {\n commandType = 'pip-compile';\n } else if (command === 'uv') {\n commandType = 'uv';\n } else {\n commandType = 'custom';\n }\n if (compileCommand.groups.arguments) {\n argv.push(...split(compileCommand.groups.arguments));\n }\n logger.debug(\n { fileName, argv, commandType },\n `pip-compile: extracted command from header`,\n );\n\n const result: PipCompileArgs = {\n argv,\n command,\n commandType,\n outputFile: '',\n sourceFiles: [],\n };\n for (const arg of argv.slice(1)) {\n if (commandType === 'uv' && ['pip', 'compile'].includes(arg)) {\n continue;\n }\n // TODO(not7cd): check for \"--option -- argument\" case\n if (!arg.startsWith('-')) {\n result.sourceFiles.push(arg);\n continue;\n }\n throwForDisallowedOption(arg);\n throwForNoEqualSignInOptionWithArgument(arg);\n throwForUnknownOption(commandType, arg);\n\n if (arg.includes('=')) {\n const [option, value] = arg.split('=');\n if (option === '--extra') {\n result.extra = coerceArray(result.extra);\n result.extra.push(value);\n } else if (option === '--extra-index-url') {\n result.extraIndexUrl = coerceArray(result.extraIndexUrl);\n result.extraIndexUrl.push(value);\n // TODO: add to secrets? next PR\n } else if (['--constraint', '--constraints'].includes(option)) {\n result.constraintsFiles = coerceArray(result.constraintsFiles);\n result.constraintsFiles.push(value);\n } else if (['--override', '--overrides'].includes(option)) {\n result.overridesFiles = coerceArray(result.overridesFiles);\n result.overridesFiles.push(value);\n } else if (option === '--output-file') {\n if (result.outputFile) {\n throw new Error('Cannot use multiple --output-file options');\n }\n result.outputFile = upath.normalize(value);\n } else if (option === '--python-version') {\n result.pythonVersion = value;\n } else if (option === '--index-url') {\n if (result.indexUrl) {\n throw new Error('Cannot use multiple --index-url options');\n }\n result.indexUrl = value;\n // TODO: add to secrets? next PR\n } else {\n logger.debug({ option }, `pip-compile: option not handled`);\n }\n continue;\n }\n if (arg === '--no-emit-index-url') {\n result.noEmitIndexUrl = true;\n continue;\n }\n if (arg === '--emit-index-url') {\n result.emitIndexUrl = true;\n continue;\n }\n if (arg === '--all-extras') {\n result.allExtras = true;\n continue;\n }\n\n logger.debug({ option: arg }, `pip-compile: option not handled`);\n }\n logger.trace(\n {\n ...result,\n },\n 'Parsed pip-compile command from header',\n );\n if (result.noEmitIndexUrl && result.emitIndexUrl) {\n throw new Error('Cannot use both --no-emit-index-url and --emit-index-url');\n }\n if (result.sourceFiles.length === 0) {\n throw new Error(\n 'No source files detected in command, pass at least one package file explicitly',\n );\n }\n return result;\n}\n\nconst pythonVersionRegex = regEx(\n /^(#.*?\\r?\\n)*# This file is autogenerated by pip-compile with Python (?<pythonVersion>\\d+(\\.\\d+)*)\\s/,\n 'i',\n);\n\nexport function extractPythonVersion(\n content: string,\n fileName: string,\n): string | undefined {\n const match = pythonVersionRegex.exec(content);\n if (match?.groups === undefined) {\n logger.warn(\n { fileName, content },\n 'pip-compile: failed to extract Python version from header in file',\n );\n return undefined;\n }\n logger.trace(\n `pip-compile: found Python version header in ${fileName}: \\n${match[0]}`,\n );\n const { pythonVersion } = match.groups;\n logger.debug(\n { fileName, pythonVersion },\n `pip-compile: extracted Python version from header`,\n );\n return pythonVersion;\n}\n\nfunction throwForDisallowedOption(arg: string): void {\n if (disallowedPipOptions.includes(arg)) {\n throw new Error(`Option ${arg} not allowed for this manager`);\n }\n}\nfunction throwForNoEqualSignInOptionWithArgument(arg: string): void {\n if (optionsWithArguments.includes(arg)) {\n throw new Error(\n `Option ${arg} must have equal sign '=' separating it's argument`,\n );\n }\n}\nfunction throwForUnknownOption(commandType: CommandType, arg: string): void {\n if (arg.includes('=')) {\n const [option] = arg.split('=');\n if (allowedOptions[commandType].includes(option)) {\n return;\n }\n }\n if (allowedOptions[commandType].includes(arg)) {\n return;\n }\n throw new Error(`Option ${arg} not supported (yet)`);\n}\n\nfunction getRegistryCredEnvVars(\n url: URL,\n index: number,\n): Record<string, string> {\n const hostRule = hostRules.find({ url: url.href });\n logger.debug(hostRule, `Found host rule for url ${url.href}`);\n const ret: Record<string, string> = {};\n if (!!hostRule.username || !!hostRule.password) {\n ret[`KEYRING_SERVICE_NAME_${index}`] = url.hostname;\n ret[`KEYRING_SERVICE_USERNAME_${index}`] = hostRule.username ?? '';\n ret[`KEYRING_SERVICE_PASSWORD_${index}`] = hostRule.password ?? '';\n }\n return ret;\n}\n\nfunction cleanUrl(url: string): URL | null {\n // Strip everything but protocol, host, and port\n const urlObj = parseUrl(url);\n if (!urlObj) {\n return null;\n }\n // origin of a valid URL is always parseable\n return parseUrl(urlObj.origin);\n}\n\nexport function getRegistryCredVarsFromPackageFiles(\n packageFiles: PackageFileContent[],\n): ExtraEnv<string> {\n const urls: string[] = [];\n for (const packageFile of packageFiles) {\n urls.push(\n ...coerceArray(packageFile.registryUrls),\n ...coerceArray(packageFile.additionalRegistryUrls),\n );\n }\n logger.debug(urls, 'Extracted registry URLs from package files');\n\n const uniqueHosts = new Set<URL>(\n urls.map(cleanUrl).filter(isNotNullOrUndefined),\n );\n\n let allCreds: ExtraEnv<string> = {};\n for (const [index, host] of [...uniqueHosts].entries()) {\n const hostCreds = getRegistryCredEnvVars(host, index);\n allCreds = {\n ...allCreds,\n ...hostCreds,\n };\n }\n\n return allCreds;\n}\n\nexport function matchManager(filename: string): SupportedManagers | 'unknown' {\n if (filename.endsWith('setup.py')) {\n return 'pip_setup';\n }\n if (filename.endsWith('setup.cfg')) {\n return 'setup-cfg';\n }\n if (filename.endsWith('pyproject.toml')) {\n return 'pep621';\n }\n // naive, could be improved, maybe use pip_requirements.managerFilePatterns\n if (filename.endsWith('.in') || filename.endsWith('.txt')) {\n return 'pip_requirements';\n }\n return 'unknown';\n}\n"],"mappings":";;;;;;;;;;;AAsBA,SAAgB,2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AAG;CAC3B,IAAI,CAAC,QACH,OAAO;CAGT,OAAO,SAAS,OAAO,MAAM;AAC/B;AAEA,SAAgB,oCACd,cACkB;CAClB,MAAM,OAAiB,CAAC;CACxB,KAAK,MAAM,eAAe,cACxB,KAAK,KACH,GAAG,YAAY,YAAY,YAAY,GACvC,GAAG,YAAY,YAAY,sBAAsB,CACnD;CAEF,OAAO,MAAM,MAAM,4CAA4C;CAE/D,MAAM,cAAc,IAAI,IACtB,KAAK,IAAI,QAAQ,CAAC,CAAC,OAAO,oBAAoB,CAChD;CAEA,IAAI,WAA6B,CAAC;CAClC,KAAK,MAAM,CAAC,OAAO,SAAS,CAAC,GAAG,WAAW,CAAC,CAAC,QAAQ,GAAG;EACtD,MAAM,YAAY,uBAAuB,MAAM,KAAK;EACpD,WAAW;GACT,GAAG;GACH,GAAG;EACL;CACF;CAEA,OAAO;AACT;AAEA,SAAgB,aAAa,UAAiD;CAC5E,IAAI,SAAS,SAAS,UAAU,GAC9B,OAAO;CAET,IAAI,SAAS,SAAS,WAAW,GAC/B,OAAO;CAET,IAAI,SAAS,SAAS,gBAAgB,GACpC,OAAO;CAGT,IAAI,SAAS,SAAS,KAAK,KAAK,SAAS,SAAS,MAAM,GACtD,OAAO;CAET,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"common.js","names":["hostRules.find"],"sources":["../../../../lib/modules/manager/pip-compile/common.ts"],"sourcesContent":["import { isString } from '@sindresorhus/is';\nimport { split } from 'shlex';\nimport upath from 'upath';\nimport { logger } from '../../../logger/index.ts';\nimport { coerceArray, isNotNullOrUndefined } from '../../../util/array.ts';\nimport type {\n ExecOptions,\n ExtraEnv,\n ToolConstraint,\n} from '../../../util/exec/types.ts';\nimport { ensureCacheDir } from '../../../util/fs/index.ts';\nimport { ensureLocalPath } from '../../../util/fs/util.ts';\nimport * as hostRules from '../../../util/host-rules.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { parseUrl } from '../../../util/url.ts';\nimport type { PackageFileContent, UpdateArtifactsConfig } from '../types.ts';\nimport type {\n CommandType,\n PipCompileArgs,\n SupportedManagers,\n} from './types.ts';\n\nexport function getPythonVersionConstraint(\n config: UpdateArtifactsConfig,\n extractedPythonVersion: string | undefined,\n): string | undefined | null {\n const { constraints = {} } = config;\n const { python } = constraints;\n\n if (python) {\n logger.debug('Using python constraint from config');\n return python;\n }\n\n if (extractedPythonVersion) {\n logger.debug('Using python constraint extracted from the lock file');\n return `==${extractedPythonVersion}`;\n }\n\n return undefined;\n}\n\nexport function getPipToolsVersionConstraint(\n config: UpdateArtifactsConfig,\n): string {\n const { constraints = {} } = config;\n const { pipTools } = constraints;\n\n if (isString(pipTools)) {\n logger.debug('Using pipTools constraint from config');\n return pipTools;\n }\n\n return '';\n}\n\nexport function getUvVersionConstraint(config: UpdateArtifactsConfig): string {\n const { constraints = {} } = config;\n const { uv } = constraints;\n\n if (isString(uv)) {\n logger.debug('Using uv constraint from config');\n return uv;\n }\n\n return '';\n}\n\nexport function getToolVersionConstraint(\n config: UpdateArtifactsConfig,\n commandType: CommandType,\n): ToolConstraint {\n if (commandType === 'uv') {\n return {\n toolName: 'uv',\n constraint: getUvVersionConstraint(config),\n };\n }\n\n return {\n toolName: 'pip-tools',\n constraint: getPipToolsVersionConstraint(config),\n };\n}\n\nexport async function getExecOptions(\n config: UpdateArtifactsConfig,\n commandType: CommandType,\n cwd: string,\n extraEnv: ExtraEnv<string>,\n extractedPythonVersion: string | undefined,\n): Promise<ExecOptions> {\n const constraint = getPythonVersionConstraint(config, extractedPythonVersion);\n const execOptions: ExecOptions = {\n cwd: ensureLocalPath(cwd),\n docker: {},\n toolConstraints: [\n {\n toolName: 'python',\n constraint,\n },\n getToolVersionConstraint(config, commandType),\n ],\n extraEnv: {\n PIP_CACHE_DIR: await ensureCacheDir('pip'),\n PIP_NO_INPUT: 'true', // ensure pip doesn't block forever waiting for credentials on stdin\n PIP_KEYRING_PROVIDER: 'import',\n PYTHON_KEYRING_BACKEND: 'keyrings.envvars.keyring.EnvvarsKeyring',\n ...extraEnv,\n },\n };\n return execOptions;\n}\n\nexport const constraintLineRegex = regEx(\n /^(?:#.*?\\r?\\n)+# {4}(?<command>\\S*)(?<arguments> .*?)?\\r?\\n/,\n);\n\nexport const disallowedPipOptions = [\n '--no-header', // header is required by this manager\n];\nconst commonOptionsWithArguments = [\n '--output-file',\n '--extra',\n '--extra-index-url',\n];\nconst pipOptionsWithArguments = [\n '--resolver',\n '--constraint',\n ...commonOptionsWithArguments,\n];\nconst uvOptionsWithArguments = [\n '--constraints',\n '--constraint', // singular alias accepted by uv\n '--python-version',\n '--no-emit-package',\n '--prerelease',\n '--format',\n '--resolution',\n '--fork-strategy',\n '--exclude-newer',\n '--exclude-newer-package',\n '--group',\n '--override',\n '--overrides',\n ...commonOptionsWithArguments,\n];\nexport const optionsWithArguments = [\n ...pipOptionsWithArguments,\n ...uvOptionsWithArguments,\n];\nconst allowedCommonOptions = [\n '-v',\n '--generate-hashes',\n '--emit-index-url',\n '--index-url',\n '--all-extras',\n];\nexport const allowedOptions: Record<CommandType, string[]> = {\n 'pip-compile': [\n '--allow-unsafe',\n '--generate-hashes',\n '--no-emit-index-url',\n '--strip-extras',\n ...allowedCommonOptions,\n ...pipOptionsWithArguments,\n ],\n uv: [\n '--no-strip-extras',\n '--universal',\n ...allowedCommonOptions,\n ...uvOptionsWithArguments,\n ],\n custom: [],\n};\n\n// TODO(not7cd): test on all correct headers, even with CUSTOM_COMPILE_COMMAND\nexport function extractHeaderCommand(\n content: string,\n fileName: string,\n): PipCompileArgs {\n const compileCommand = constraintLineRegex.exec(content);\n if (compileCommand?.groups === undefined) {\n throw new Error(\n `Failed to extract command from header in ${fileName} ${content}`,\n );\n }\n logger.trace(\n `pip-compile: found header in ${fileName}: \\n${compileCommand[0]}`,\n );\n const command = compileCommand.groups.command;\n const argv = [command];\n let commandType: CommandType;\n if (command === 'pip-compile') {\n commandType = 'pip-compile';\n } else if (command === 'uv') {\n commandType = 'uv';\n } else {\n commandType = 'custom';\n }\n if (compileCommand.groups.arguments) {\n argv.push(...split(compileCommand.groups.arguments));\n }\n logger.debug(\n { fileName, argv, commandType },\n `pip-compile: extracted command from header`,\n );\n\n const result: PipCompileArgs = {\n argv,\n command,\n commandType,\n outputFile: '',\n sourceFiles: [],\n };\n for (const arg of argv.slice(1)) {\n if (commandType === 'uv' && ['pip', 'compile'].includes(arg)) {\n continue;\n }\n // TODO(not7cd): check for \"--option -- argument\" case\n if (!arg.startsWith('-')) {\n result.sourceFiles.push(arg);\n continue;\n }\n throwForDisallowedOption(arg);\n throwForNoEqualSignInOptionWithArgument(arg);\n throwForUnknownOption(commandType, arg);\n\n if (arg.includes('=')) {\n const [option, value] = arg.split('=');\n if (option === '--extra') {\n result.extra = coerceArray(result.extra);\n result.extra.push(value);\n } else if (option === '--extra-index-url') {\n result.extraIndexUrl = coerceArray(result.extraIndexUrl);\n result.extraIndexUrl.push(value);\n // TODO: add to secrets? next PR\n } else if (['--constraint', '--constraints'].includes(option)) {\n result.constraintsFiles = coerceArray(result.constraintsFiles);\n result.constraintsFiles.push(value);\n } else if (['--override', '--overrides'].includes(option)) {\n result.overridesFiles = coerceArray(result.overridesFiles);\n result.overridesFiles.push(value);\n } else if (option === '--output-file') {\n if (result.outputFile) {\n throw new Error('Cannot use multiple --output-file options');\n }\n result.outputFile = upath.normalize(value);\n } else if (option === '--python-version') {\n result.pythonVersion = value;\n } else if (option === '--index-url') {\n if (result.indexUrl) {\n throw new Error('Cannot use multiple --index-url options');\n }\n result.indexUrl = value;\n // TODO: add to secrets? next PR\n } else {\n logger.debug({ option }, `pip-compile: option not handled`);\n }\n continue;\n }\n if (arg === '--no-emit-index-url') {\n result.noEmitIndexUrl = true;\n continue;\n }\n if (arg === '--emit-index-url') {\n result.emitIndexUrl = true;\n continue;\n }\n if (arg === '--all-extras') {\n result.allExtras = true;\n continue;\n }\n\n logger.debug({ option: arg }, `pip-compile: option not handled`);\n }\n logger.trace(\n {\n ...result,\n },\n 'Parsed pip-compile command from header',\n );\n if (result.noEmitIndexUrl && result.emitIndexUrl) {\n throw new Error('Cannot use both --no-emit-index-url and --emit-index-url');\n }\n if (result.sourceFiles.length === 0) {\n throw new Error(\n 'No source files detected in command, pass at least one package file explicitly',\n );\n }\n return result;\n}\n\nconst pythonVersionRegex = regEx(\n /^(?:#.*?\\r?\\n)*# This file is autogenerated by pip-compile with Python (?<pythonVersion>\\d+(?:\\.\\d+)*)\\s/,\n 'i',\n);\n\nexport function extractPythonVersion(\n content: string,\n fileName: string,\n): string | undefined {\n const match = pythonVersionRegex.exec(content);\n if (match?.groups === undefined) {\n logger.warn(\n { fileName, content },\n 'pip-compile: failed to extract Python version from header in file',\n );\n return undefined;\n }\n logger.trace(\n `pip-compile: found Python version header in ${fileName}: \\n${match[0]}`,\n );\n const { pythonVersion } = match.groups;\n logger.debug(\n { fileName, pythonVersion },\n `pip-compile: extracted Python version from header`,\n );\n return pythonVersion;\n}\n\nfunction throwForDisallowedOption(arg: string): void {\n if (disallowedPipOptions.includes(arg)) {\n throw new Error(`Option ${arg} not allowed for this manager`);\n }\n}\nfunction throwForNoEqualSignInOptionWithArgument(arg: string): void {\n if (optionsWithArguments.includes(arg)) {\n throw new Error(\n `Option ${arg} must have equal sign '=' separating it's argument`,\n );\n }\n}\nfunction throwForUnknownOption(commandType: CommandType, arg: string): void {\n if (arg.includes('=')) {\n const [option] = arg.split('=');\n if (allowedOptions[commandType].includes(option)) {\n return;\n }\n }\n if (allowedOptions[commandType].includes(arg)) {\n return;\n }\n throw new Error(`Option ${arg} not supported (yet)`);\n}\n\nfunction getRegistryCredEnvVars(\n url: URL,\n index: number,\n): Record<string, string> {\n const hostRule = hostRules.find({ url: url.href });\n logger.debug(hostRule, `Found host rule for url ${url.href}`);\n const ret: Record<string, string> = {};\n if (!!hostRule.username || !!hostRule.password) {\n ret[`KEYRING_SERVICE_NAME_${index}`] = url.hostname;\n ret[`KEYRING_SERVICE_USERNAME_${index}`] = hostRule.username ?? '';\n ret[`KEYRING_SERVICE_PASSWORD_${index}`] = hostRule.password ?? '';\n }\n return ret;\n}\n\nfunction cleanUrl(url: string): URL | null {\n // Strip everything but protocol, host, and port\n const urlObj = parseUrl(url);\n if (!urlObj) {\n return null;\n }\n // origin of a valid URL is always parseable\n return parseUrl(urlObj.origin);\n}\n\nexport function getRegistryCredVarsFromPackageFiles(\n packageFiles: PackageFileContent[],\n): ExtraEnv<string> {\n const urls: string[] = [];\n for (const packageFile of packageFiles) {\n urls.push(\n ...coerceArray(packageFile.registryUrls),\n ...coerceArray(packageFile.additionalRegistryUrls),\n );\n }\n logger.debug(urls, 'Extracted registry URLs from package files');\n\n const uniqueHosts = new Set<URL>(\n urls.map(cleanUrl).filter(isNotNullOrUndefined),\n );\n\n let allCreds: ExtraEnv<string> = {};\n for (const [index, host] of [...uniqueHosts].entries()) {\n const hostCreds = getRegistryCredEnvVars(host, index);\n allCreds = {\n ...allCreds,\n ...hostCreds,\n };\n }\n\n return allCreds;\n}\n\nexport function matchManager(filename: string): SupportedManagers | 'unknown' {\n if (filename.endsWith('setup.py')) {\n return 'pip_setup';\n }\n if (filename.endsWith('setup.cfg')) {\n return 'setup-cfg';\n }\n if (filename.endsWith('pyproject.toml')) {\n return 'pep621';\n }\n // naive, could be improved, maybe use pip_requirements.managerFilePatterns\n if (filename.endsWith('.in') || filename.endsWith('.txt')) {\n return 'pip_requirements';\n }\n return 'unknown';\n}\n"],"mappings":";;;;;;;;;;;AAsBA,SAAgB,2BACd,QACA,wBAC2B;CAC3B,MAAM,EAAE,cAAc,CAAC,MAAM;CAC7B,MAAM,EAAE,WAAW;CAEnB,IAAI,QAAQ;EACV,OAAO,MAAM,qCAAqC;EAClD,OAAO;CACT;CAEA,IAAI,wBAAwB;EAC1B,OAAO,MAAM,sDAAsD;EACnE,OAAO,KAAK;CACd;AAGF;AAEA,SAAgB,6BACd,QACQ;CACR,MAAM,EAAE,cAAc,CAAC,MAAM;CAC7B,MAAM,EAAE,aAAa;CAErB,IAAI,S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C,OAAO,oBAAoB,CAChD;CAEA,IAAI,WAA6B,CAAC;CAClC,KAAK,MAAM,CAAC,OAAO,SAAS,CAAC,GAAG,WAAW,CAAC,CAAC,QAAQ,GAAG;EACtD,MAAM,YAAY,uBAAuB,MAAM,KAAK;EACpD,WAAW;GACT,GAAG;GACH,GAAG;EACL;CACF;CAEA,OAAO;AACT;AAEA,SAAgB,aAAa,UAAiD;CAC5E,IAAI,SAAS,SAAS,UAAU,GAC9B,OAAO;CAET,IAAI,SAAS,SAAS,WAAW,GAC/B,OAAO;CAET,IAAI,SAAS,SAAS,gBAAgB,GACpC,OAAO;CAGT,IAAI,SAAS,SAAS,KAAK,KAAK,SAAS,SAAS,MAAM,GACtD,OAAO;CAET,OAAO;AACT"}
|
|
@@ -6,7 +6,7 @@ function cleanRegistryUrls(registryUrls) {
|
|
|
6
6
|
return registryUrls.map((url) => {
|
|
7
7
|
const cleaned = url.replace(regEx(/^"/), "").replace(regEx(/"$/), "");
|
|
8
8
|
if (!GlobalConfig.get("exposeAllEnv")) return cleaned;
|
|
9
|
-
return cleaned.replace(regEx(/(
|
|
9
|
+
return cleaned.replace(regEx(/(?:\$[A-Za-z\d_]+)|(?:\${[A-Za-z\d_]+})/g), (match) => {
|
|
10
10
|
const envvar = match.substring(1).replace(regEx(/^{/), "").replace(regEx(/}$/), "");
|
|
11
11
|
return getEnv()[envvar] ?? match;
|
|
12
12
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","names":[],"sources":["../../../../lib/modules/manager/pip_requirements/common.ts"],"sourcesContent":["import { GlobalConfig } from '../../../config/global.ts';\nimport { getEnv } from '../../../util/env.ts';\nimport { newlineRegex, regEx } from '../../../util/regex.ts';\nimport type { PackageFileContent } from '../types.ts';\nimport type { PipRequirementsManagerData } from './types.ts';\n\nfunction cleanRegistryUrls(registryUrls: string[]): string[] {\n return registryUrls.map((url) => {\n // handle the optional quotes in eg. `--extra-index-url \"https://foo.bar\"`\n const cleaned = url.replace(regEx(/^\"/), '').replace(regEx(/\"$/), '');\n if (!GlobalConfig.get('exposeAllEnv')) {\n return cleaned;\n }\n // interpolate any environment variables\n return cleaned.replace(\n regEx(/(
|
|
1
|
+
{"version":3,"file":"common.js","names":[],"sources":["../../../../lib/modules/manager/pip_requirements/common.ts"],"sourcesContent":["import { GlobalConfig } from '../../../config/global.ts';\nimport { getEnv } from '../../../util/env.ts';\nimport { newlineRegex, regEx } from '../../../util/regex.ts';\nimport type { PackageFileContent } from '../types.ts';\nimport type { PipRequirementsManagerData } from './types.ts';\n\nfunction cleanRegistryUrls(registryUrls: string[]): string[] {\n return registryUrls.map((url) => {\n // handle the optional quotes in eg. `--extra-index-url \"https://foo.bar\"`\n const cleaned = url.replace(regEx(/^\"/), '').replace(regEx(/\"$/), '');\n if (!GlobalConfig.get('exposeAllEnv')) {\n return cleaned;\n }\n // interpolate any environment variables\n return cleaned.replace(\n regEx(/(?:\\$[A-Za-z\\d_]+)|(?:\\${[A-Za-z\\d_]+})/g),\n (match) => {\n const envvar = match\n .substring(1)\n .replace(regEx(/^{/), '')\n .replace(regEx(/}$/), '');\n const sub = getEnv()[envvar];\n return sub ?? match;\n },\n );\n });\n}\n\nexport function extractPackageFileFlags(\n content: string,\n): PackageFileContent<PipRequirementsManagerData> {\n let registryUrls: string[] = [];\n const additionalRegistryUrls: string[] = [];\n const additionalRequirementsFiles: string[] = [];\n const additionalConstraintsFiles: string[] = [];\n content.split(newlineRegex).forEach((line) => {\n if (line.startsWith('-i ') || line.startsWith('--index-url ')) {\n registryUrls = [line.split(' ')[1]];\n } else if (line.startsWith('--extra-index-url ')) {\n const extraUrl = line\n .substring('--extra-index-url '.length)\n .split(' ')[0];\n additionalRegistryUrls.push(extraUrl);\n } else if (line.startsWith('-r ')) {\n additionalRequirementsFiles.push(line.split(' ')[1]);\n } else if (line.startsWith('-c ')) {\n additionalConstraintsFiles.push(line.split(' ')[1]);\n }\n });\n\n const res: PackageFileContent<PipRequirementsManagerData> = { deps: [] };\n if (registryUrls.length > 0) {\n res.registryUrls = cleanRegistryUrls(registryUrls);\n }\n if (additionalRegistryUrls.length) {\n res.additionalRegistryUrls = cleanRegistryUrls(additionalRegistryUrls);\n }\n if (additionalRequirementsFiles.length) {\n res.managerData ??= {};\n res.managerData.requirementsFiles = additionalRequirementsFiles;\n }\n if (additionalConstraintsFiles.length) {\n res.managerData ??= {};\n res.managerData.constraintsFiles = additionalConstraintsFiles;\n }\n return res;\n}\n"],"mappings":";;;;AAMA,SAAS,kBAAkB,cAAkC;CAC3D,OAAO,aAAa,KAAK,QAAQ;EAE/B,MAAM,UAAU,IAAI,QAAQ,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC,QAAQ,MAAM,IAAI,GAAG,EAAE;EACpE,IAAI,CAAC,aAAa,IAAI,cAAc,GAClC,OAAO;EAGT,OAAO,QAAQ,QACb,MAAM,0CAA0C,IAC/C,UAAU;GACT,MAAM,SAAS,MACZ,UAAU,CAAC,CAAC,CACZ,QAAQ,MAAM,IAAI,GAAG,EAAE,CAAC,CACxB,QAAQ,MAAM,IAAI,GAAG,EAAE;GAE1B,OADY,OAAO,CAAC,CAAC,WACP;EAChB,CACF;CACF,CAAC;AACH;AAEA,SAAgB,wBACd,SACgD;CAChD,IAAI,eAAyB,CAAC;CAC9B,MAAM,yBAAmC,CAAC;CAC1C,MAAM,8BAAwC,CAAC;CAC/C,MAAM,6BAAuC,CAAC;CAC9C,QAAQ,MAAM,YAAY,CAAC,CAAC,SAAS,SAAS;EAC5C,IAAI,KAAK,WAAW,KAAK,KAAK,KAAK,WAAW,cAAc,GAC1D,eAAe,CAAC,KAAK,MAAM,GAAG,CAAC,CAAC,EAAE;OAC7B,IAAI,KAAK,WAAW,oBAAoB,GAAG;GAChD,MAAM,WAAW,KACd,UAAU,EAA2B,CAAC,CACtC,MAAM,GAAG,CAAC,CAAC;GACd,uBAAuB,KAAK,QAAQ;EACtC,OAAO,IAAI,KAAK,WAAW,KAAK,GAC9B,4BAA4B,KAAK,KAAK,MAAM,GAAG,CAAC,CAAC,EAAE;OAC9C,IAAI,KAAK,WAAW,KAAK,GAC9B,2BAA2B,KAAK,KAAK,MAAM,GAAG,CAAC,CAAC,EAAE;CAEtD,CAAC;CAED,MAAM,MAAsD,EAAE,MAAM,CAAC,EAAE;CACvE,IAAI,aAAa,SAAS,GACxB,IAAI,eAAe,kBAAkB,YAAY;CAEnD,IAAI,uBAAuB,QACzB,IAAI,yBAAyB,kBAAkB,sBAAsB;CAEvE,IAAI,4BAA4B,QAAQ;EACtC,IAAI,gBAAgB,CAAC;EACrB,IAAI,YAAY,oBAAoB;CACtC;CACA,IAAI,2BAA2B,QAAQ;EACrC,IAAI,gBAAgB,CAAC;EACrB,IAAI,YAAY,mBAAmB;CACrC;CACA,OAAO;AACT"}
|
|
@@ -10,7 +10,7 @@ import { RANGE_PATTERN } from "@renovatebot/pep440";
|
|
|
10
10
|
//#region lib/modules/manager/pip_requirements/extract.ts
|
|
11
11
|
const packagePattern = "[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9]";
|
|
12
12
|
const extrasPattern = "(?:\\s*\\[[^\\]]+\\])?";
|
|
13
|
-
const packageGitRegex = regEx(/(?<source>(?:git\+)(?<protocol>git|ssh|https):\/\/(?<gitUrl>(?:(?<user>[^@]+)@)?(?<hostname>[\w.-]+)(?<delimiter>\/)(?<scmPath>.*\/(?<depName>[\w/-]+))(
|
|
13
|
+
const packageGitRegex = regEx(/(?<source>(?:git\+)(?<protocol>git|ssh|https):\/\/(?<gitUrl>(?:(?<user>[^@]+)@)?(?<hostname>[\w.-]+)(?<delimiter>\/)(?<scmPath>.*\/(?<depName>[\w/-]+))(?:\.git)?(?:@(?<version>.*))))/);
|
|
14
14
|
const specifierPartPattern = `\\s*${RANGE_PATTERN.replace(regEx(/\?<\w+>/g), "?:")}`;
|
|
15
15
|
const dependencyPattern = `(${packagePattern})(${extrasPattern})(${`${specifierPartPattern}(?:\\s*,${specifierPartPattern})*`})?`;
|
|
16
16
|
function extractPackageFile(content) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract.js","names":["rangePattern"],"sources":["../../../../lib/modules/manager/pip_requirements/extract.ts"],"sourcesContent":["// based on https://www.python.org/dev/peps/pep-0508/#names\nimport { RANGE_PATTERN } from '@renovatebot/pep440';\nimport { isTruthy } from '@sindresorhus/is';\nimport { logger } from '../../../logger/index.ts';\nimport { isSkipComment } from '../../../util/ignore.ts';\nimport { newlineRegex, regEx } from '../../../util/regex.ts';\nimport { GitTagsDatasource } from '../../datasource/git-tags/index.ts';\nimport { normalizePythonDepName } from '../../datasource/pypi/common.ts';\nimport { PypiDatasource } from '../../datasource/pypi/index.ts';\nimport type { PackageDependency, PackageFileContent } from '../types.ts';\nimport { extractPackageFileFlags } from './common.ts';\nimport type { PipRequirementsManagerData } from './types.ts';\n\nexport const packagePattern =\n '[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9]';\nexport const extrasPattern = '(?:\\\\s*\\\\[[^\\\\]]+\\\\])?';\nconst packageGitRegex = regEx(\n /(?<source>(?:git\\+)(?<protocol>git|ssh|https):\\/\\/(?<gitUrl>(?:(?<user>[^@]+)@)?(?<hostname>[\\w.-]+)(?<delimiter>\\/)(?<scmPath>.*\\/(?<depName>[\\w/-]+))(
|
|
1
|
+
{"version":3,"file":"extract.js","names":["rangePattern"],"sources":["../../../../lib/modules/manager/pip_requirements/extract.ts"],"sourcesContent":["// based on https://www.python.org/dev/peps/pep-0508/#names\nimport { RANGE_PATTERN } from '@renovatebot/pep440';\nimport { isTruthy } from '@sindresorhus/is';\nimport { logger } from '../../../logger/index.ts';\nimport { isSkipComment } from '../../../util/ignore.ts';\nimport { newlineRegex, regEx } from '../../../util/regex.ts';\nimport { GitTagsDatasource } from '../../datasource/git-tags/index.ts';\nimport { normalizePythonDepName } from '../../datasource/pypi/common.ts';\nimport { PypiDatasource } from '../../datasource/pypi/index.ts';\nimport type { PackageDependency, PackageFileContent } from '../types.ts';\nimport { extractPackageFileFlags } from './common.ts';\nimport type { PipRequirementsManagerData } from './types.ts';\n\nexport const packagePattern =\n '[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9]';\nexport const extrasPattern = '(?:\\\\s*\\\\[[^\\\\]]+\\\\])?';\nconst packageGitRegex = regEx(\n /(?<source>(?:git\\+)(?<protocol>git|ssh|https):\\/\\/(?<gitUrl>(?:(?<user>[^@]+)@)?(?<hostname>[\\w.-]+)(?<delimiter>\\/)(?<scmPath>.*\\/(?<depName>[\\w/-]+))(?:\\.git)?(?:@(?<version>.*))))/,\n);\n\nconst rangePattern: string = RANGE_PATTERN;\nconst specifierPartPattern = `\\\\s*${rangePattern.replace(\n regEx(/\\?<\\w+>/g),\n '?:',\n)}`;\nconst specifierPattern = `${specifierPartPattern}(?:\\\\s*,${specifierPartPattern})*`;\nexport const dependencyPattern = `(${packagePattern})(${extrasPattern})(${specifierPattern})?`;\n\nexport function extractPackageFile(\n content: string,\n): PackageFileContent<PipRequirementsManagerData> | null {\n logger.trace('pip_requirements.extractPackageFile()');\n\n const pkgRegex = regEx(`^(${packagePattern})$`);\n const pkgValRegex = regEx(`^${dependencyPattern}$`);\n const deps = content\n .split(newlineRegex)\n .map((rawline) => {\n let dep: PackageDependency = {};\n const [line, comment] = rawline.split('#').map((part) => part.trim());\n if (isSkipComment(comment)) {\n dep.skipReason = 'ignored';\n }\n const [lineNoEnvMarkers] = line.split(';').map((part) => part.trim());\n const lineNoHashes = lineNoEnvMarkers.split(' \\\\')[0];\n const packageMatches =\n pkgValRegex.exec(lineNoHashes) ?? pkgRegex.exec(lineNoHashes);\n const gitPackageMatches = packageGitRegex.exec(lineNoHashes);\n if (!packageMatches && !gitPackageMatches) {\n return null;\n }\n if (gitPackageMatches?.groups) {\n const currentVersion = gitPackageMatches.groups.version;\n const depName = gitPackageMatches.groups.depName;\n let packageName: string;\n if (gitPackageMatches.groups.protocol === 'https') {\n packageName = 'https://'\n .concat(gitPackageMatches.groups.gitUrl)\n .replace(`@${currentVersion}`, '');\n } else {\n // we need to replace the / with a :\n const scmPath = gitPackageMatches.groups.scmPath;\n const delimiter = gitPackageMatches.groups.delimiter;\n packageName = gitPackageMatches.groups.gitUrl\n .replace(`${delimiter}${scmPath}`, `:${scmPath}`)\n .replace(`@${currentVersion}`, '');\n }\n dep = {\n ...dep,\n depName,\n currentValue: currentVersion,\n currentVersion,\n packageName,\n datasource: GitTagsDatasource.id,\n };\n return dep;\n }\n\n // validated above\n const [, depName, , currVal] = packageMatches!;\n const currentValue = currVal?.trim();\n dep = {\n ...dep,\n depName,\n packageName: normalizePythonDepName(depName),\n currentValue,\n datasource: PypiDatasource.id,\n };\n if (currentValue?.startsWith('==')) {\n dep.currentVersion = currentValue.replace(regEx(/^==\\s*/), '');\n }\n return dep;\n })\n .filter(isTruthy);\n\n const res = extractPackageFileFlags(content);\n res.deps = deps;\n\n if (\n !res.deps.length &&\n !res.registryUrls?.length &&\n !res.additionalRegistryUrls?.length &&\n !res.managerData?.requirementsFiles?.length &&\n !res.managerData?.constraintsFiles?.length\n ) {\n return null;\n }\n return res;\n}\n"],"mappings":";;;;;;;;;;AAaA,MAAa,iBACX;AACF,MAAa,gBAAgB;AAC7B,MAAM,kBAAkB,MACtB,wLACF;AAGA,MAAM,uBAAuB,OAAOA,cAAa,QAC/C,MAAM,UAAU,GAChB,IACF;AAEA,MAAa,oBAAoB,IAAI,eAAe,IAAI,cAAc,IAAI,GAD9C,qBAAqB,UAAU,qBAAqB,IACW;AAE3F,SAAgB,mBACd,SACuD;CACvD,OAAO,MAAM,uCAAuC;CAEpD,MAAM,WAAW,MAAM,KAAK,eAAe,GAAG;CAC9C,MAAM,cAAc,MAAM,IAAI,kBAAkB,EAAE;CAClD,MAAM,OAAO,QACV,MAAM,YAAY,CAAC,CACnB,KAAK,YAAY;EAChB,IAAI,MAAyB,CAAC;EAC9B,MAAM,CAAC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AI,OAAO;CAEX,IACE,CAAC,IAAI,KAAK,UACV,CAAC,IAAI,cAAc,UACnB,CAAC,IAAI,wBAAwB,UAC7B,CAAC,IAAI,aAAa,mBAAmB,UACrC,CAAC,IAAI,aAAa,kBAAkB,QAEpC,OAAO;CAET,OAAO;AACT"}
|
|
@@ -32,9 +32,9 @@ function getPythonConstraint(pyProjectContent, existingLockFileContent) {
|
|
|
32
32
|
}
|
|
33
33
|
function getPoetryRequirement(pyProjectContent, existingLockFileContent) {
|
|
34
34
|
const firstLine = existingLockFileContent.split("\n")[0];
|
|
35
|
-
const poetryVersionMatch = regEx(/by Poetry ([\d\\.]+)/).exec(firstLine);
|
|
36
|
-
if (poetryVersionMatch?.
|
|
37
|
-
const poetryVersion = poetryVersionMatch
|
|
35
|
+
const poetryVersionMatch = regEx(/by Poetry (?<version>[\d\\.]+)/).exec(firstLine);
|
|
36
|
+
if (poetryVersionMatch?.groups?.version) {
|
|
37
|
+
const poetryVersion = poetryVersionMatch.groups.version;
|
|
38
38
|
logger.debug(`Using poetry version ${poetryVersion} from poetry.lock header`);
|
|
39
39
|
return poetryVersion;
|
|
40
40
|
}
|
|
@@ -94,7 +94,7 @@ async function getSourceCredentialVars(pyprojectContent, packageFileName) {
|
|
|
94
94
|
const envVars = {};
|
|
95
95
|
for (const source of poetrySources) {
|
|
96
96
|
const matchingHostRule = await getMatchingHostRule(source.url);
|
|
97
|
-
const formattedSourceName = source.name.replace(regEx(/(
|
|
97
|
+
const formattedSourceName = source.name.replace(regEx(/(?:\.|-)+/g), "_").toUpperCase();
|
|
98
98
|
if (matchingHostRule.username) envVars[`POETRY_HTTP_BASIC_${formattedSourceName}_USERNAME`] = matchingHostRule.username;
|
|
99
99
|
if (matchingHostRule.password) envVars[`POETRY_HTTP_BASIC_${formattedSourceName}_PASSWORD`] = matchingHostRule.password;
|
|
100
100
|
}
|