renovate 44.30.0 → 44.30.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 +3 -3
- package/dist/config/migration.js.map +1 -1
- package/dist/config/migrations/custom/azure-gitlab-automerge-migration.js.map +1 -1
- package/dist/config/migrations/custom/dep-types-migration.js.map +1 -1
- package/dist/config/options/env.js +2 -1
- package/dist/config/options/env.js.map +1 -1
- package/dist/config/options/index.js +1 -1
- package/dist/config/options/index.js.map +1 -1
- package/dist/global-config-option-defaults.generated.js +1 -1
- package/dist/global-config-option-defaults.generated.js.map +1 -1
- package/dist/logger/utils.js +3 -3
- package/dist/logger/utils.js.map +1 -1
- package/dist/modules/datasource/crate/index.js +3 -3
- package/dist/modules/datasource/crate/index.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/hexpm-bob/index.js +3 -3
- package/dist/modules/datasource/hexpm-bob/index.js.map +1 -1
- package/dist/modules/datasource/maven/util.js +1 -1
- package/dist/modules/datasource/maven/util.js.map +1 -1
- package/dist/modules/datasource/packagist/schema.js +2 -1
- package/dist/modules/datasource/packagist/schema.js.map +1 -1
- package/dist/modules/datasource/pypi/common.js +1 -1
- package/dist/modules/datasource/pypi/common.js.map +1 -1
- package/dist/modules/datasource/rpm/repomd.js +2 -1
- package/dist/modules/datasource/rpm/repomd.js.map +1 -1
- package/dist/modules/datasource/sbt-package/util.js +3 -3
- package/dist/modules/datasource/sbt-package/util.js.map +1 -1
- package/dist/modules/datasource/terraform-provider/index.js +1 -1
- package/dist/modules/datasource/terraform-provider/index.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/asdf/upgradeable-tooling.js +5 -5
- package/dist/modules/manager/asdf/upgradeable-tooling.js.map +1 -1
- package/dist/modules/manager/bazel-module/extract.js +2 -1
- package/dist/modules/manager/bazel-module/extract.js.map +1 -1
- package/dist/modules/manager/bazel-module/parser/repo-rules.js +1 -1
- package/dist/modules/manager/bazel-module/parser/repo-rules.js.map +1 -1
- package/dist/modules/manager/bitbucket-pipelines/extract.js +2 -2
- package/dist/modules/manager/bitbucket-pipelines/extract.js.map +1 -1
- package/dist/modules/manager/bun/utils.js +2 -1
- package/dist/modules/manager/bun/utils.js.map +1 -1
- package/dist/modules/manager/bundler/extract.js +1 -1
- package/dist/modules/manager/bundler/extract.js.map +1 -1
- package/dist/modules/manager/cake/index.js.map +1 -1
- package/dist/modules/manager/composer/schema.js +2 -2
- package/dist/modules/manager/composer/schema.js.map +1 -1
- package/dist/modules/manager/cpanfile/language.js.map +1 -1
- package/dist/modules/manager/cpanfile/parser.js +4 -4
- package/dist/modules/manager/cpanfile/parser.js.map +1 -1
- package/dist/modules/manager/crossplane/extract.js +2 -1
- package/dist/modules/manager/crossplane/extract.js.map +1 -1
- package/dist/modules/manager/deps-edn/extract.js +1 -1
- package/dist/modules/manager/deps-edn/extract.js.map +1 -1
- package/dist/modules/manager/deps-edn/parser.js.map +1 -1
- package/dist/modules/manager/dockerfile/extract.js +2 -2
- package/dist/modules/manager/dockerfile/extract.js.map +1 -1
- package/dist/modules/manager/flux/extract.js +2 -2
- 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/gomod/artifacts.js +1 -1
- package/dist/modules/manager/gomod/artifacts.js.map +1 -1
- package/dist/modules/manager/gradle/extract/consistent-versions-plugin.js +2 -2
- package/dist/modules/manager/gradle/extract/consistent-versions-plugin.js.map +1 -1
- package/dist/modules/manager/gradle-wrapper/artifacts.js +2 -2
- package/dist/modules/manager/gradle-wrapper/artifacts.js.map +1 -1
- package/dist/modules/manager/helmv3/utils.js +2 -1
- package/dist/modules/manager/helmv3/utils.js.map +1 -1
- package/dist/modules/manager/hermit/extract.js +1 -1
- package/dist/modules/manager/hermit/extract.js.map +1 -1
- package/dist/modules/manager/homebrew/utils.js +3 -3
- package/dist/modules/manager/homebrew/utils.js.map +1 -1
- package/dist/modules/manager/jsonnet-bundler/extract.js +2 -1
- package/dist/modules/manager/jsonnet-bundler/extract.js.map +1 -1
- package/dist/modules/manager/leiningen/extract.js +2 -2
- 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/mise/backends.js +3 -3
- package/dist/modules/manager/mise/backends.js.map +1 -1
- package/dist/modules/manager/mise/upgradeable-tooling.js +1 -1
- package/dist/modules/manager/mise/upgradeable-tooling.js.map +1 -1
- package/dist/modules/manager/npm/extract/common/dependency.js +2 -2
- package/dist/modules/manager/npm/extract/common/dependency.js.map +1 -1
- package/dist/modules/manager/npm/extract/post/locked-versions.js +2 -1
- package/dist/modules/manager/npm/extract/post/locked-versions.js.map +1 -1
- package/dist/modules/manager/npm/post-update/index.js +1 -1
- package/dist/modules/manager/npm/post-update/index.js.map +1 -1
- package/dist/modules/manager/npm/post-update/npm.js +2 -1
- package/dist/modules/manager/npm/post-update/npm.js.map +1 -1
- package/dist/modules/manager/npm/post-update/yarn.js +2 -2
- package/dist/modules/manager/npm/post-update/yarn.js.map +1 -1
- package/dist/modules/manager/npm/schema.js +2 -1
- package/dist/modules/manager/npm/schema.js.map +1 -1
- package/dist/modules/manager/npm/update/locked-dependency/yarn-lock/get-locked.js +2 -1
- package/dist/modules/manager/npm/update/locked-dependency/yarn-lock/get-locked.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/nvm/extract.js +2 -1
- package/dist/modules/manager/nvm/extract.js.map +1 -1
- package/dist/modules/manager/osgi/extract.js +2 -1
- package/dist/modules/manager/osgi/extract.js.map +1 -1
- package/dist/modules/manager/pep621/processors/uv.js +2 -1
- package/dist/modules/manager/pep621/processors/uv.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/pip_setup/extract.js +3 -3
- package/dist/modules/manager/pip_setup/extract.js.map +1 -1
- package/dist/modules/manager/pixi/schema.js +2 -1
- package/dist/modules/manager/pixi/schema.js.map +1 -1
- package/dist/modules/manager/setup-cfg/extract.js +1 -1
- package/dist/modules/manager/setup-cfg/extract.js.map +1 -1
- package/dist/modules/manager/sveltos/util.js +1 -1
- package/dist/modules/manager/sveltos/util.js.map +1 -1
- package/dist/modules/manager/typst/extract.js +2 -2
- package/dist/modules/manager/typst/extract.js.map +1 -1
- package/dist/modules/platform/azure/issue.js +2 -1
- package/dist/modules/platform/azure/issue.js.map +1 -1
- package/dist/modules/platform/bitbucket/index.js +1 -1
- package/dist/modules/platform/bitbucket/index.js.map +1 -1
- package/dist/modules/platform/bitbucket/schema.js +2 -1
- package/dist/modules/platform/bitbucket/schema.js.map +1 -1
- package/dist/modules/platform/codecommit/codecommit-client.js +2 -1
- package/dist/modules/platform/codecommit/codecommit-client.js.map +1 -1
- package/dist/modules/platform/gerrit/utils.js +1 -1
- package/dist/modules/platform/gerrit/utils.js.map +1 -1
- package/dist/modules/platform/github/index.js +8 -8
- package/dist/modules/platform/github/index.js.map +1 -1
- package/dist/modules/platform/github/massage-markdown-links.js +6 -3
- package/dist/modules/platform/github/massage-markdown-links.js.map +1 -1
- package/dist/modules/versioning/apk/index.js +15 -15
- package/dist/modules/versioning/apk/index.js.map +1 -1
- package/dist/modules/versioning/bazel-module/bzlmod-version.js +3 -2
- package/dist/modules/versioning/bazel-module/bzlmod-version.js.map +1 -1
- package/dist/modules/versioning/bazel-module/index.js +2 -1
- package/dist/modules/versioning/bazel-module/index.js.map +1 -1
- package/dist/modules/versioning/composer/index.js +2 -2
- package/dist/modules/versioning/composer/index.js.map +1 -1
- package/dist/modules/versioning/conan/range.js +4 -3
- package/dist/modules/versioning/conan/range.js.map +1 -1
- package/dist/modules/versioning/conda/index.js +4 -3
- package/dist/modules/versioning/conda/index.js.map +1 -1
- package/dist/modules/versioning/distro.js +2 -1
- package/dist/modules/versioning/distro.js.map +1 -1
- package/dist/modules/versioning/generic.js +2 -1
- package/dist/modules/versioning/generic.js.map +1 -1
- package/dist/modules/versioning/hashicorp/convertor.js +1 -1
- package/dist/modules/versioning/hashicorp/convertor.js.map +1 -1
- package/dist/modules/versioning/npm/range.js +1 -1
- package/dist/modules/versioning/npm/range.js.map +1 -1
- package/dist/modules/versioning/nuget/range.js +2 -1
- package/dist/modules/versioning/nuget/range.js.map +1 -1
- package/dist/modules/versioning/perl/index.js +1 -1
- package/dist/modules/versioning/perl/index.js.map +1 -1
- package/dist/modules/versioning/poetry/transform.js +2 -2
- package/dist/modules/versioning/poetry/transform.js.map +1 -1
- package/dist/modules/versioning/rez/pattern.js.map +1 -1
- package/dist/modules/versioning/ruby/index.js +1 -1
- package/dist/modules/versioning/ruby/index.js.map +1 -1
- package/dist/modules/versioning/semver/index.js +2 -1
- package/dist/modules/versioning/semver/index.js.map +1 -1
- package/dist/modules/versioning/semver-coerced/index.js +1 -1
- package/dist/modules/versioning/semver-coerced/index.js.map +1 -1
- package/dist/util/emoji.js.map +1 -1
- package/dist/util/exec/containerbase.js +2 -1
- package/dist/util/exec/containerbase.js.map +1 -1
- package/dist/util/exec/env.js +2 -1
- package/dist/util/exec/env.js.map +1 -1
- package/dist/util/git/private-key.js +1 -1
- package/dist/util/git/private-key.js.map +1 -1
- package/dist/util/github/graphql/datasource-fetcher.js +2 -1
- package/dist/util/github/graphql/datasource-fetcher.js.map +1 -1
- package/dist/util/http/forgejo.js +2 -1
- package/dist/util/http/forgejo.js.map +1 -1
- package/dist/util/http/gitea.js +2 -1
- package/dist/util/http/gitea.js.map +1 -1
- package/dist/util/number.js +2 -1
- package/dist/util/number.js.map +1 -1
- package/dist/util/string-match.js +1 -1
- package/dist/util/string-match.js.map +1 -1
- package/dist/util/url.js +2 -2
- package/dist/util/url.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/global/config/parse/coersions.js +2 -1
- package/dist/workers/global/config/parse/coersions.js.map +1 -1
- package/dist/workers/global/config/parse/host-rules-from-env.js +2 -1
- package/dist/workers/global/config/parse/host-rules-from-env.js.map +1 -1
- package/dist/workers/repository/model/commit-message.js +2 -1
- package/dist/workers/repository/model/commit-message.js.map +1 -1
- package/dist/workers/repository/model/semantic-commit-message.js +2 -1
- package/dist/workers/repository/model/semantic-commit-message.js.map +1 -1
- package/dist/workers/repository/update/pr/changelog/common.js +1 -1
- package/dist/workers/repository/update/pr/changelog/common.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 +1 -1
- package/renovate-schema.json +2 -2
|
@@ -199,11 +199,11 @@ async function generateLockFile(lockFileDir, env, config = {}, upgrades = []) {
|
|
|
199
199
|
return { lockFile };
|
|
200
200
|
}
|
|
201
201
|
function fuzzyMatchAdditionalYarnrcYml(additionalYarnRcYml, existingYarnrRcYml) {
|
|
202
|
-
const keys = new Map(Object.keys(existingYarnrRcYml.npmRegistries ?? {}).map((x) => [x.replace(
|
|
202
|
+
const keys = new Map(Object.keys(existingYarnrRcYml.npmRegistries ?? {}).map((x) => [x.replace(regEx(/\/$/), "").replace(regEx(/^https?:/), ""), x]));
|
|
203
203
|
return {
|
|
204
204
|
...additionalYarnRcYml,
|
|
205
205
|
npmRegistries: Object.entries(additionalYarnRcYml.npmRegistries ?? {}).map(([k, v]) => {
|
|
206
|
-
return { [keys.get(k.replace(
|
|
206
|
+
return { [keys.get(k.replace(regEx(/\/$/), "")) ?? k]: v };
|
|
207
207
|
}).reduce((acc, cur) => ({
|
|
208
208
|
...acc,
|
|
209
209
|
...cur
|
|
@@ -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 { 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 CI: 'true',\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 4 -- 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(existingYarnrRcYml.npmRegistries ?? {}).map((x) => [\n x.replace(/\\/$/, '').replace(/^https?:/, ''),\n x,\n ]),\n );\n\n return {\n ...additionalYarnRcYml,\n npmRegistries: Object.entries(additionalYarnRcYml.npmRegistries ?? {})\n .map(([k, v]) => {\n const key = keys.get(k.replace(/\\/$/, '')) ?? k;\n return { [key]: v };\n })\n .reduce((acc, cur) => ({ ...acc,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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,mBAAmB,iBAAiB,CAAC,CAAC,CAAC,CAAC,KAAK,MAAM,CAC7D,EAAE,QAAQ,OAAO,EAAE,CAAC,CAAC,QAAQ,YAAY,EAAE,GAC3C,CACF,CAAC,CACH;CAEA,OAAO;EACL,GAAG;EACH,eAAe,OAAO,QAAQ,oBAAoB,iBAAiB,CAAC,CAAC,CAAC,CACnE,KAAK,CAAC,GAAG,OAAO;GAEf,OAAO,GADK,KAAK,IAAI,EAAE,QAAQ,OAAO,EAAE,CAAC,KAAK,IAC9B,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 { 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 CI: 'true',\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 4 -- 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(existingYarnrRcYml.npmRegistries ?? {}).map((x) => [\n x.replace(regEx(/\\/$/), '').replace(regEx(/^https?:/), ''),\n x,\n ]),\n );\n\n return {\n ...additionalYarnRcYml,\n npmRegistries: Object.entries(additionalYarnRcYml.npmRegistries ?? {})\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":";;;;;;;;;;;;;;;;;;AAsCA,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;GAEpE,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,IAA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D,QAAQ,KAAK,SAAS;GAAE,GAAG;GAAK,GAAG;EAAI,IAAI,CAAC,CAAC;CAClD;AACF"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { regEx } from "../../../util/regex.js";
|
|
1
2
|
import { Json, LooseRecord, Nullish, Yaml } from "../../../util/schema-utils/index.js";
|
|
2
3
|
import { z } from "zod/v4";
|
|
3
4
|
//#region lib/modules/manager/npm/schema.ts
|
|
@@ -47,7 +48,7 @@ const PackageJson = Json.pipe(z.object({
|
|
|
47
48
|
}));
|
|
48
49
|
const PackageLockV3 = z.object({
|
|
49
50
|
lockfileVersion: z.literal(3),
|
|
50
|
-
packages: LooseRecord(z.string().transform((x) => x.replace(/^node_modules
|
|
51
|
+
packages: LooseRecord(z.string().transform((x) => x.replace(regEx(/^node_modules\//), "")).refine((x) => x.trim() !== ""), z.object({ version: z.string() }))
|
|
51
52
|
});
|
|
52
53
|
const PackageLockPreV3 = z.object({
|
|
53
54
|
lockfileVersion: z.union([z.literal(2), z.literal(1)]),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","names":[],"sources":["../../../../lib/modules/manager/npm/schema.ts"],"sourcesContent":["import { z } from 'zod/v4';\nimport {\n Json,\n LooseRecord,\n Nullish,\n Yaml,\n} from '../../../util/schema-utils/index.ts';\n\n// pnpm ignores registry URLs containing `${...}` env-var interpolation since v11.5.3\nfunction hasEnvVar(value: string): boolean {\n return value.includes('${');\n}\n\nfunction withoutEnvVarRegistries(\n registries: Record<string, string>,\n): Record<string, string> {\n return Object.fromEntries(\n Object.entries(registries).filter(([, url]) => !hasEnvVar(url)),\n );\n}\n\nexport const PnpmCatalogs = z.object({\n catalog: z.optional(z.record(z.string(), z.string())),\n catalogs: z.optional(z.record(z.string(), z.record(z.string(), z.string()))),\n});\nexport type PnpmCatalogs = z.infer<typeof PnpmCatalogs>;\n\nexport const YarnCatalogs = z.object({\n catalog: z.optional(z.record(z.string(), z.string())),\n catalogs: z\n .optional(z.record(z.string(), z.record(z.string(), z.string())))\n .catch(undefined),\n});\nexport type YarnCatalogs = z.infer<typeof YarnCatalogs>;\n\nexport const YarnConfig = Yaml.pipe(\n z\n .object({\n npmRegistryServer: z.string().optional(),\n npmScopes: z\n .record(\n z.string(),\n z.object({\n npmRegistryServer: z.string().optional(),\n }),\n )\n .optional(),\n })\n .and(YarnCatalogs),\n);\nexport type YarnConfig = z.infer<typeof YarnConfig>;\n\nexport const PnpmWorkspaceFile = Yaml.pipe(\n z\n .object({\n packages: z.array(z.string()).optional(),\n minimumReleaseAge: Nullish(z.number()),\n minimumReleaseAgeExclude: z.array(z.string()).optional(),\n overrides: z.record(z.string(), z.string()).optional(),\n registry: Nullish(z.string()),\n registries: Nullish(\n z.record(z.string(), z.string()).transform(withoutEnvVarRegistries),\n ),\n })\n .and(PnpmCatalogs),\n);\nexport type PnpmWorkspaceFile = z.infer<typeof PnpmWorkspaceFile>;\n\nexport const PackageManager = z\n .string()\n .transform((val) => val.split('@'))\n .transform(([name, ...version]) => ({ name, version: version.join('@') }));\n\nconst DevEngineDependency = z.object({\n name: z.string(),\n version: z.string().optional(),\n});\n\nconst DevEngine = z.object({\n packageManager: DevEngineDependency.or(\n z.array(DevEngineDependency),\n ).optional(),\n});\n\nexport const PackageJson = Json.pipe(\n z.object({\n devEngines: DevEngine.optional(),\n engines: LooseRecord(z.string()).optional(),\n dependencies: LooseRecord(z.string()).optional(),\n devDependencies: LooseRecord(z.string()).optional(),\n peerDependencies: LooseRecord(z.string()).optional(),\n packageManager: PackageManager.optional(),\n volta: LooseRecord(z.string()).optional(),\n }),\n);\n\nexport type PackageJson = z.infer<typeof PackageJson>;\n\nexport const PackageLockV3 = z.object({\n lockfileVersion: z.literal(3),\n packages: LooseRecord(\n z\n .string()\n .transform((x) => x.replace(/^node_modules
|
|
1
|
+
{"version":3,"file":"schema.js","names":[],"sources":["../../../../lib/modules/manager/npm/schema.ts"],"sourcesContent":["import { z } from 'zod/v4';\nimport { regEx } from '../../../util/regex.ts';\nimport {\n Json,\n LooseRecord,\n Nullish,\n Yaml,\n} from '../../../util/schema-utils/index.ts';\n\n// pnpm ignores registry URLs containing `${...}` env-var interpolation since v11.5.3\nfunction hasEnvVar(value: string): boolean {\n return value.includes('${');\n}\n\nfunction withoutEnvVarRegistries(\n registries: Record<string, string>,\n): Record<string, string> {\n return Object.fromEntries(\n Object.entries(registries).filter(([, url]) => !hasEnvVar(url)),\n );\n}\n\nexport const PnpmCatalogs = z.object({\n catalog: z.optional(z.record(z.string(), z.string())),\n catalogs: z.optional(z.record(z.string(), z.record(z.string(), z.string()))),\n});\nexport type PnpmCatalogs = z.infer<typeof PnpmCatalogs>;\n\nexport const YarnCatalogs = z.object({\n catalog: z.optional(z.record(z.string(), z.string())),\n catalogs: z\n .optional(z.record(z.string(), z.record(z.string(), z.string())))\n .catch(undefined),\n});\nexport type YarnCatalogs = z.infer<typeof YarnCatalogs>;\n\nexport const YarnConfig = Yaml.pipe(\n z\n .object({\n npmRegistryServer: z.string().optional(),\n npmScopes: z\n .record(\n z.string(),\n z.object({\n npmRegistryServer: z.string().optional(),\n }),\n )\n .optional(),\n })\n .and(YarnCatalogs),\n);\nexport type YarnConfig = z.infer<typeof YarnConfig>;\n\nexport const PnpmWorkspaceFile = Yaml.pipe(\n z\n .object({\n packages: z.array(z.string()).optional(),\n minimumReleaseAge: Nullish(z.number()),\n minimumReleaseAgeExclude: z.array(z.string()).optional(),\n overrides: z.record(z.string(), z.string()).optional(),\n registry: Nullish(z.string()),\n registries: Nullish(\n z.record(z.string(), z.string()).transform(withoutEnvVarRegistries),\n ),\n })\n .and(PnpmCatalogs),\n);\nexport type PnpmWorkspaceFile = z.infer<typeof PnpmWorkspaceFile>;\n\nexport const PackageManager = z\n .string()\n .transform((val) => val.split('@'))\n .transform(([name, ...version]) => ({ name, version: version.join('@') }));\n\nconst DevEngineDependency = z.object({\n name: z.string(),\n version: z.string().optional(),\n});\n\nconst DevEngine = z.object({\n packageManager: DevEngineDependency.or(\n z.array(DevEngineDependency),\n ).optional(),\n});\n\nexport const PackageJson = Json.pipe(\n z.object({\n devEngines: DevEngine.optional(),\n engines: LooseRecord(z.string()).optional(),\n dependencies: LooseRecord(z.string()).optional(),\n devDependencies: LooseRecord(z.string()).optional(),\n peerDependencies: LooseRecord(z.string()).optional(),\n packageManager: PackageManager.optional(),\n volta: LooseRecord(z.string()).optional(),\n }),\n);\n\nexport type PackageJson = z.infer<typeof PackageJson>;\n\nexport const PackageLockV3 = z.object({\n lockfileVersion: z.literal(3),\n packages: LooseRecord(\n z\n .string()\n .transform((x) => x.replace(regEx(/^node_modules\\//), ''))\n .refine((x) => x.trim() !== ''),\n z.object({ version: z.string() }),\n ),\n});\n\nexport const PackageLockPreV3 = z\n .object({\n lockfileVersion: z.union([z.literal(2), z.literal(1)]),\n dependencies: LooseRecord(z.object({ version: z.string() })),\n })\n .transform(({ lockfileVersion, dependencies: packages }) => ({\n lockfileVersion,\n packages,\n }));\n\nexport const PackageLock = Json.pipe(\n z.union([PackageLockV3, PackageLockPreV3]),\n).transform(({ packages, lockfileVersion }) => {\n const lockedVersions: Record<string, string> = {};\n for (const [entry, val] of Object.entries(packages)) {\n lockedVersions[entry] = val.version;\n }\n return { lockedVersions, lockfileVersion };\n});\n"],"mappings":";;;;AAUA,SAAS,UAAU,OAAwB;CACzC,OAAO,MAAM,SAAS,IAAI;AAC5B;AAEA,SAAS,wBACP,YACwB;CACxB,OAAO,OAAO,YACZ,OAAO,QAAQ,UAAU,CAAC,CAAC,QAAQ,GAAG,SAAS,CAAC,UAAU,GAAG,CAAC,CAChE;AACF;AAEA,MAAa,eAAe,EAAE,OAAO;CACnC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC;CACpD,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AAC7E,CAAC;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;CAChD,KAAK,MAAM,CAAC,OAAO,QAAQ,OAAO,QAAQ,QAAQ,GAChD,eAAe,SAAS,IAAI;CAE9B,OAAO;EAAE;EAAgB;CAAgB;AAC3C,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { regEx } from "../../../../../../util/regex.js";
|
|
1
2
|
import { logger } from "../../../../../../logger/index.js";
|
|
2
3
|
//#region lib/modules/manager/npm/update/locked-dependency/yarn-lock/get-locked.ts
|
|
3
4
|
function parseEntry(depNameConstraint) {
|
|
@@ -48,7 +49,7 @@ function getYarn2LockedDependencies(yarnLock, depName, currentVersion) {
|
|
|
48
49
|
/* v8 ignore next 3 -- needs test */
|
|
49
50
|
if (!parsed) continue;
|
|
50
51
|
const { entryName } = parsed;
|
|
51
|
-
const constraint = parsed.constraint.replace(/^npm
|
|
52
|
+
const constraint = parsed.constraint.replace(regEx(/^npm:/), "");
|
|
52
53
|
if (entryName === depName && entry?.version === currentVersion) res.push({
|
|
53
54
|
entry,
|
|
54
55
|
depNameConstraint,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-locked.js","names":[],"sources":["../../../../../../../lib/modules/manager/npm/update/locked-dependency/yarn-lock/get-locked.ts"],"sourcesContent":["import { logger } from '../../../../../../logger/index.ts';\nimport type { YarnLock, YarnLockEntrySummary } from './types.ts';\n\nexport function parseEntry(depNameConstraint: string): {\n entryName: string;\n constraint: string;\n} | null {\n let entryName: string;\n let constraint: string;\n const split = depNameConstraint.split('@');\n if (split.length === 2) {\n [entryName, constraint] = split;\n } else if (split.length === 3) {\n entryName = `@${split[1]}`;\n constraint = split[2];\n } else {\n logger.debug({ depNameConstraint }, 'Unexpected depNameConstraint');\n return null;\n }\n return { entryName, constraint };\n}\n\nexport function getYarn1LockedDependencies(\n yarnLock: YarnLock,\n depName: string,\n currentVersion: string,\n): YarnLockEntrySummary[] {\n const res: YarnLockEntrySummary[] = [];\n try {\n for (const [depNameConstraint, entry] of Object.entries(yarnLock)) {\n const parsed = parseEntry(depNameConstraint);\n /* v8 ignore next 3 -- needs test */\n if (!parsed) {\n continue;\n }\n const { entryName, constraint } = parsed;\n if (entryName === depName && entry?.version === currentVersion) {\n res.push({ entry, depNameConstraint, depName, constraint });\n }\n }\n } catch (err) /* v8 ignore next -- TODO: add test #40625 */ {\n logger.warn({ err }, 'getLockedDependencies() error');\n }\n return res;\n}\n\nexport function getYarn2LockedDependencies(\n yarnLock: YarnLock,\n depName: string,\n currentVersion: string,\n): YarnLockEntrySummary[] {\n const res: YarnLockEntrySummary[] = [];\n try {\n for (const [fullConstraint, entry] of Object.entries(yarnLock)) {\n if (fullConstraint === '__metadata') {\n continue;\n }\n for (const subConstraint of fullConstraint.split(', ')) {\n const depNameConstraint = subConstraint;\n const parsed = parseEntry(depNameConstraint);\n /* v8 ignore next 3 -- needs test */\n if (!parsed) {\n continue;\n }\n const { entryName } = parsed;\n const constraint = parsed.constraint.replace(/^npm
|
|
1
|
+
{"version":3,"file":"get-locked.js","names":[],"sources":["../../../../../../../lib/modules/manager/npm/update/locked-dependency/yarn-lock/get-locked.ts"],"sourcesContent":["import { logger } from '../../../../../../logger/index.ts';\nimport { regEx } from '../../../../../../util/regex.ts';\nimport type { YarnLock, YarnLockEntrySummary } from './types.ts';\n\nexport function parseEntry(depNameConstraint: string): {\n entryName: string;\n constraint: string;\n} | null {\n let entryName: string;\n let constraint: string;\n const split = depNameConstraint.split('@');\n if (split.length === 2) {\n [entryName, constraint] = split;\n } else if (split.length === 3) {\n entryName = `@${split[1]}`;\n constraint = split[2];\n } else {\n logger.debug({ depNameConstraint }, 'Unexpected depNameConstraint');\n return null;\n }\n return { entryName, constraint };\n}\n\nexport function getYarn1LockedDependencies(\n yarnLock: YarnLock,\n depName: string,\n currentVersion: string,\n): YarnLockEntrySummary[] {\n const res: YarnLockEntrySummary[] = [];\n try {\n for (const [depNameConstraint, entry] of Object.entries(yarnLock)) {\n const parsed = parseEntry(depNameConstraint);\n /* v8 ignore next 3 -- needs test */\n if (!parsed) {\n continue;\n }\n const { entryName, constraint } = parsed;\n if (entryName === depName && entry?.version === currentVersion) {\n res.push({ entry, depNameConstraint, depName, constraint });\n }\n }\n } catch (err) /* v8 ignore next -- TODO: add test #40625 */ {\n logger.warn({ err }, 'getLockedDependencies() error');\n }\n return res;\n}\n\nexport function getYarn2LockedDependencies(\n yarnLock: YarnLock,\n depName: string,\n currentVersion: string,\n): YarnLockEntrySummary[] {\n const res: YarnLockEntrySummary[] = [];\n try {\n for (const [fullConstraint, entry] of Object.entries(yarnLock)) {\n if (fullConstraint === '__metadata') {\n continue;\n }\n for (const subConstraint of fullConstraint.split(', ')) {\n const depNameConstraint = subConstraint;\n const parsed = parseEntry(depNameConstraint);\n /* v8 ignore next 3 -- needs test */\n if (!parsed) {\n continue;\n }\n const { entryName } = parsed;\n const constraint = parsed.constraint.replace(regEx(/^npm:/), '');\n if (entryName === depName && entry?.version === currentVersion) {\n res.push({ entry, depNameConstraint, depName, constraint });\n }\n }\n }\n } catch (err) /* v8 ignore next -- TODO: add test #40625 */ {\n logger.warn({ err }, 'getLockedDependencies() error');\n }\n return res;\n}\n\n// Finds matching dependencies withing a package lock file of sub-entry\nexport function getLockedDependencies(\n yarnLock: YarnLock,\n depName: string,\n currentVersion: string,\n): YarnLockEntrySummary[] {\n if ('__metadata' in yarnLock) {\n return getYarn2LockedDependencies(yarnLock, depName, currentVersion);\n }\n return getYarn1LockedDependencies(yarnLock, depName, currentVersion);\n}\n"],"mappings":";;;AAIA,SAAgB,WAAW,mBAGlB;CACP,IAAI;CACJ,IAAI;CACJ,MAAM,QAAQ,kBAAkB,MAAM,GAAG;CACzC,IAAI,MAAM,WAAW,GACnB,CAAC,WAAW,cAAc;MACrB,IAAI,MAAM,WAAW,GAAG;EAC7B,YAAY,IAAI,MAAM;EACtB,aAAa,MAAM;CACrB,OAAO;EACL,OAAO,MAAM,EAAE,kBAAkB,GAAG,8BAA8B;EAClE,OAAO;CACT;CACA,OAAO;EAAE;EAAW;CAAW;AACjC;AAEA,SAAgB,2BACd,UACA,SACA,gBACwB;CACxB,MAAM,MAA8B,CAAC;CACrC,IAAI;EACF,KAAK,MAAM,CAAC,mBAAmB,UAAU,OAAO,QAAQ,QAAQ,GAAG;GACjE,MAAM,SAAS,WAAW,iBAAiB;;GAE3C,IAAI,CAAC,QACH;GAEF,MAAM,EAAE,WAAW,eAAe;GAClC,IAAI,cAAc,WAAW,OAAO,YAAY,gBAC9C,IAAI,KAAK;IAAE;IAAO;IAAmB;IAAS;GAAW,CAAC;EAE9D;CACF,SAAS,mDAAmD;EAC1D,OAAO,KAAK,EAAE,IAAI,GAAG,+BAA+B;CACtD;CACA,OAAO;AACT;AAEA,SAAgB,2BACd,UACA,SACA,gBACwB;CACxB,MAAM,MAA8B,CAAC;CACrC,IAAI;EACF,KAAK,MAAM,CAAC,gBAAgB,UAAU,OAAO,QAAQ,QAAQ,GAAG;GAC9D,IAAI,mBAAmB,cACrB;GAEF,KAAK,MAAM,iBAAiB,eAAe,MAAM,IAAI,GAAG;IACtD,MAAM,oBAAoB;IAC1B,MAAM,SAAS,WAAW,iBAAiB;;IAE3C,IAAI,CAAC,QACH;IAEF,MAAM,EAAE,cAAc;IACtB,MAAM,aAAa,OAAO,WAAW,QAAQ,MAAM,OAAO,GAAG,EAAE;IAC/D,IAAI,cAAc,WAAW,OAAO,YAAY,gBAC9C,IAAI,KAAK;KAAE;KAAO;KAAmB;KAAS;IAAW,CAAC;GAE9D;EACF;CACF,SAAS,mDAAmD;EAC1D,OAAO,KAAK,EAAE,IAAI,GAAG,+BAA+B;CACtD;CACA,OAAO;AACT;AAGA,SAAgB,sBACd,UACA,SACA,gBACwB;CACxB,IAAI,gBAAgB,UAClB,OAAO,2BAA2B,UAAU,SAAS,cAAc;CAErE,OAAO,2BAA2B,UAAU,SAAS,cAAc;AACrE"}
|
|
@@ -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(/(@|\^|\.|\\|\|)/g, "\\$1")}(("|",|,)[^\n:]*)?:\n)(.*\n)*?(\\s+dependencies|\n[@a-z])`;
|
|
7
|
+
const matchString = `(${depNameConstraint.replace(regEx(/(@|\^|\.|\\|\|)/g), "\\$1")}(("|",|,)[^\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(/(@|\\^|\\.|\\\\|\\|)/g, '\\\\$1');\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;CAExC,MAAM,cAAc,IADJ,kBAAkB,QAAQ,
|
|
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(/(@|\\^|\\.|\\\\|\\|)/g), '\\\\$1');\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;CAExC,MAAM,cAAc,IADJ,kBAAkB,QAAQ,MAAM,kBAAkB,GAAG,MACvC,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"}
|
|
@@ -47,7 +47,7 @@ function extractDepsFromXml(xmlNode) {
|
|
|
47
47
|
let currentValue = attr?.Version ?? attr?.version ?? child.valueWithPath("Version") ?? attr?.VersionOverride ?? child.valueWithPath("VersionOverride");
|
|
48
48
|
if (!isNonEmptyStringAndNotWhitespace(currentValue)) dep.skipReason = "invalid-version";
|
|
49
49
|
let sharedVariableName;
|
|
50
|
-
currentValue = currentValue?.trim()?.replace(/^\$\((\w+)\)
|
|
50
|
+
currentValue = currentValue?.trim()?.replace(regEx(/^\$\((\w+)\)$/), (match, key) => {
|
|
51
51
|
sharedVariableName = key;
|
|
52
52
|
const val = vars.get(key);
|
|
53
53
|
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 { 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(/^\\$\\((\\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(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":";;;;;;;;;;;;;;;;;;AA8BA,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;EAEvB,IAAI,SAAS,sBAAsB;GACjC,MAAM,EAAE,SAAS,GAAG,QAAQ,OAAO,MAAM,KAAK,IAAI;GAElD,IAAI,iCAAiC,OAAO,GAC1C,QAAQ,KAAK;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AAM,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 { 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(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":";;;;;;;;;;;;;;;;;;AA8BA,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;EAEvB,IAAI,SAAS,sBAAsB;GACjC,MAAM,EAAE,SAAS,GAAG,QAAQ,OAAO,MAAM,KAAK,IAAI;GAElD,IAAI,iCAAiC,OAAO,GAC1C,QAAQ,KAAK;IAAE,GAAG;IAAK;IAAS,SAAS;GAAS,CAAC;EAEvD,OAAO,IAAI,UAAU,IAAI,IAAI,GAAG;GAC9B,MAAM,UAAU,MAAM,WAAW,MAAM;GAEvC,IAAI,CAAC,SACH;GAGF,MAAM,MAA8B;IAClC,YAAY,gBAAgB;IAC5B,SAAS;IACT;GACF;GAEA,IAAI,eACF,MAAM,WACN,MAAM,WACN,MAA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,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,10 +1,11 @@
|
|
|
1
|
+
import { regEx } from "../../../util/regex.js";
|
|
1
2
|
import { NodeVersionDatasource } from "../../datasource/node-version/index.js";
|
|
2
3
|
import { isNonEmptyStringAndNotWhitespace } from "@sindresorhus/is";
|
|
3
4
|
//#region lib/modules/manager/nvm/extract.ts
|
|
4
5
|
function extractPackageFile(content) {
|
|
5
6
|
return { deps: [{
|
|
6
7
|
depName: "node",
|
|
7
|
-
currentValue: content.split("\n").map((line) => line.replace(
|
|
8
|
+
currentValue: content.split("\n").map((line) => line.replace(regEx(/#.*$/), "").trim()).filter(isNonEmptyStringAndNotWhitespace).join("\n").trim(),
|
|
8
9
|
datasource: NodeVersionDatasource.id
|
|
9
10
|
}] };
|
|
10
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract.js","names":[],"sources":["../../../../lib/modules/manager/nvm/extract.ts"],"sourcesContent":["import { isNonEmptyStringAndNotWhitespace } from '@sindresorhus/is';\nimport { NodeVersionDatasource } from '../../datasource/node-version/index.ts';\nimport type { PackageDependency, PackageFileContent } from '../types.ts';\n\nexport function extractPackageFile(content: string): PackageFileContent {\n const dep: PackageDependency = {\n depName: 'node',\n currentValue: content\n .split('\\n')\n // Remove code comments\n .map((line) => line.replace(
|
|
1
|
+
{"version":3,"file":"extract.js","names":[],"sources":["../../../../lib/modules/manager/nvm/extract.ts"],"sourcesContent":["import { isNonEmptyStringAndNotWhitespace } from '@sindresorhus/is';\nimport { regEx } from '../../../util/regex.ts';\nimport { NodeVersionDatasource } from '../../datasource/node-version/index.ts';\nimport type { PackageDependency, PackageFileContent } from '../types.ts';\n\nexport function extractPackageFile(content: string): PackageFileContent {\n const dep: PackageDependency = {\n depName: 'node',\n currentValue: content\n .split('\\n')\n // Remove code comments\n .map((line) => line.replace(regEx(/#.*$/), '').trim())\n .filter(isNonEmptyStringAndNotWhitespace)\n .join('\\n')\n .trim(),\n datasource: NodeVersionDatasource.id,\n };\n return { deps: [dep] };\n}\n"],"mappings":";;;;AAKA,SAAgB,mBAAmB,SAAqC;CAYtE,OAAO,EAAE,MAAM,CAAC;EAVd,SAAS;EACT,cAAc,QACX,MAAM,IAAI,CAAC,CAEX,KAAK,SAAS,KAAK,QAAQ,MAAM,MAAM,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CACrD,OAAO,gCAAgC,CAAC,CACxC,KAAK,IAAI,CAAC,CACV,KAAK;EACR,YAAY,sBAAsB;CAElB,CAAC,EAAE;AACvB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { regEx } from "../../../util/regex.js";
|
|
1
2
|
import { logger } from "../../../logger/index.js";
|
|
2
3
|
import { MavenDatasource } from "../../datasource/maven/index.js";
|
|
3
4
|
import { isArray, isNullOrUndefined, isString } from "@sindresorhus/is";
|
|
@@ -32,7 +33,7 @@ function extractPackageFile(content, packageFile, _config) {
|
|
|
32
33
|
for (const entry of allBundles) {
|
|
33
34
|
const rawGav = isString(entry) ? entry : entry.id;
|
|
34
35
|
if (!rawGav) continue;
|
|
35
|
-
const gav = rawGav.replace(/\//g, ":");
|
|
36
|
+
const gav = rawGav.replace(regEx(/\//g), ":");
|
|
36
37
|
const parts = gav.split(":");
|
|
37
38
|
if (parts.length < 3 || parts.length > 5) {
|
|
38
39
|
deps.push({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract.js","names":["json5"],"sources":["../../../../lib/modules/manager/osgi/extract.ts"],"sourcesContent":["import { isArray, isNullOrUndefined, isString } from '@sindresorhus/is';\nimport json5 from 'json5';\nimport { coerce, satisfies } from 'semver';\nimport { logger } from '../../../logger/index.ts';\nimport { MavenDatasource } from '../../datasource/maven/index.ts';\nimport type {\n ExtractConfig,\n PackageDependency,\n PackageFileContent,\n} from '../types.ts';\nimport type { Bundle, FeatureModel } from './types.ts';\n\nexport function extractPackageFile(\n content: string,\n packageFile: string,\n _config?: ExtractConfig,\n): PackageFileContent | null {\n // References:\n // - OSGi compendium release 8 ( https://docs.osgi.org/specification/osgi.cmpn/8.0.0/service.feature.html )\n // - The Sling implementation of the feature model ( https://sling.apache.org/documentation/development/feature-model.html )\n logger.trace(`osgi.extractPackageFile($packageFile)`);\n\n const deps: PackageDependency[] = [];\n let featureModel: FeatureModel;\n try {\n // Compendium R8 159.3: JS comments are supported\n featureModel = json5.parse<FeatureModel>(content);\n } catch (err) {\n logger.warn({ packageFile, err }, 'Failed to parse osgi file');\n return null;\n }\n\n if (\n // for empty an empty result\n isNullOrUndefined(featureModel) ||\n // Compendium R8 159.9: resource versioning\n !isSupportedFeatureResourceVersion(featureModel, packageFile)\n ) {\n return null;\n }\n\n // OSGi Compendium R8 159.4: bundles entry\n const allBundles = featureModel.bundles ?? [];\n\n // The 'execution-environment' key is supported by the Sling/OSGi feature model implementation\n const execEnvFramework =\n featureModel['execution-environment:JSON|false']?.framework;\n if (!isNullOrUndefined(execEnvFramework)) {\n allBundles.push(execEnvFramework);\n }\n\n // parse custom sections\n //\n // Note: we do not support artifact list extensions as defined in\n // section 159.7.3 yet. As of 05-12-2022, there is no implementation that\n // supports this\n for (const [section, value] of Object.entries(featureModel)) {\n logger.trace({ fileName: packageFile, section }, 'Parsing section');\n const customSectionEntries = extractArtifactList(section, value);\n allBundles.push(...customSectionEntries);\n }\n\n // convert bundles to dependencies\n for (const entry of allBundles) {\n const rawGav = isString(entry) ? entry : entry.id;\n // skip invalid definitions, such as objects without an id set\n if (!rawGav) {\n continue;\n }\n\n // both '/' and ':' are valid separators, but the Maven datasource\n // expects the separator to be ':'\n const gav = rawGav.replace(/\\//g, ':');\n\n // identifiers support 3-5 parts, see OSGi R8 - 159.2.1 Identifiers\n // groupId ':' artifactId ( ':' type ( ':' classifier )? )? ':' version\n const parts = gav.split(':');\n if (parts.length < 3 || parts.length > 5) {\n deps.push({\n depName: gav,\n skipReason: 'invalid-value',\n });\n continue;\n }\n // parsing should use the last entry for the version\n const currentValue = parts.at(-1)!;\n const result: PackageDependency = {\n datasource: MavenDatasource.id,\n depName: `${parts[0]}:${parts[1]}`,\n };\n if (currentValue.includes('${')) {\n result.skipReason = 'contains-variable';\n } else {\n result.currentValue = currentValue;\n }\n\n deps.push(result);\n }\n\n return deps.length ? { deps } : null;\n}\n\nfunction isSupportedFeatureResourceVersion(\n featureModel: FeatureModel,\n fileName: string,\n): boolean {\n const resourceVersion = featureModel['feature-resource-version'];\n if (resourceVersion) {\n const resourceSemVer = coerce(resourceVersion);\n if (!resourceSemVer) {\n logger.debug(\n `Skipping file ${fileName} due to invalid feature-resource-version '${resourceVersion}'`,\n );\n return false;\n }\n\n // we only support 1.x, although no over version has been defined\n if (!satisfies(resourceSemVer, '^1')) {\n logger.debug(\n `Skipping file ${fileName} due to unsupported feature-resource-version '${resourceVersion}'`,\n );\n return false;\n }\n }\n\n return true;\n}\n\nfunction extractArtifactList(\n sectionName: string,\n sectionValue: unknown,\n): Bundle[] {\n // The 'ARTIFACTS' key is supported by the Sling/OSGi feature model implementation\n if (sectionName.includes(':ARTIFACTS|') && isArray(sectionValue)) {\n return sectionValue as Bundle[];\n }\n\n return [];\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"extract.js","names":["json5"],"sources":["../../../../lib/modules/manager/osgi/extract.ts"],"sourcesContent":["import { isArray, isNullOrUndefined, isString } from '@sindresorhus/is';\nimport json5 from 'json5';\nimport { coerce, satisfies } from 'semver';\nimport { logger } from '../../../logger/index.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { MavenDatasource } from '../../datasource/maven/index.ts';\nimport type {\n ExtractConfig,\n PackageDependency,\n PackageFileContent,\n} from '../types.ts';\nimport type { Bundle, FeatureModel } from './types.ts';\n\nexport function extractPackageFile(\n content: string,\n packageFile: string,\n _config?: ExtractConfig,\n): PackageFileContent | null {\n // References:\n // - OSGi compendium release 8 ( https://docs.osgi.org/specification/osgi.cmpn/8.0.0/service.feature.html )\n // - The Sling implementation of the feature model ( https://sling.apache.org/documentation/development/feature-model.html )\n logger.trace(`osgi.extractPackageFile($packageFile)`);\n\n const deps: PackageDependency[] = [];\n let featureModel: FeatureModel;\n try {\n // Compendium R8 159.3: JS comments are supported\n featureModel = json5.parse<FeatureModel>(content);\n } catch (err) {\n logger.warn({ packageFile, err }, 'Failed to parse osgi file');\n return null;\n }\n\n if (\n // for empty an empty result\n isNullOrUndefined(featureModel) ||\n // Compendium R8 159.9: resource versioning\n !isSupportedFeatureResourceVersion(featureModel, packageFile)\n ) {\n return null;\n }\n\n // OSGi Compendium R8 159.4: bundles entry\n const allBundles = featureModel.bundles ?? [];\n\n // The 'execution-environment' key is supported by the Sling/OSGi feature model implementation\n const execEnvFramework =\n featureModel['execution-environment:JSON|false']?.framework;\n if (!isNullOrUndefined(execEnvFramework)) {\n allBundles.push(execEnvFramework);\n }\n\n // parse custom sections\n //\n // Note: we do not support artifact list extensions as defined in\n // section 159.7.3 yet. As of 05-12-2022, there is no implementation that\n // supports this\n for (const [section, value] of Object.entries(featureModel)) {\n logger.trace({ fileName: packageFile, section }, 'Parsing section');\n const customSectionEntries = extractArtifactList(section, value);\n allBundles.push(...customSectionEntries);\n }\n\n // convert bundles to dependencies\n for (const entry of allBundles) {\n const rawGav = isString(entry) ? entry : entry.id;\n // skip invalid definitions, such as objects without an id set\n if (!rawGav) {\n continue;\n }\n\n // both '/' and ':' are valid separators, but the Maven datasource\n // expects the separator to be ':'\n const gav = rawGav.replace(regEx(/\\//g), ':');\n\n // identifiers support 3-5 parts, see OSGi R8 - 159.2.1 Identifiers\n // groupId ':' artifactId ( ':' type ( ':' classifier )? )? ':' version\n const parts = gav.split(':');\n if (parts.length < 3 || parts.length > 5) {\n deps.push({\n depName: gav,\n skipReason: 'invalid-value',\n });\n continue;\n }\n // parsing should use the last entry for the version\n const currentValue = parts.at(-1)!;\n const result: PackageDependency = {\n datasource: MavenDatasource.id,\n depName: `${parts[0]}:${parts[1]}`,\n };\n if (currentValue.includes('${')) {\n result.skipReason = 'contains-variable';\n } else {\n result.currentValue = currentValue;\n }\n\n deps.push(result);\n }\n\n return deps.length ? { deps } : null;\n}\n\nfunction isSupportedFeatureResourceVersion(\n featureModel: FeatureModel,\n fileName: string,\n): boolean {\n const resourceVersion = featureModel['feature-resource-version'];\n if (resourceVersion) {\n const resourceSemVer = coerce(resourceVersion);\n if (!resourceSemVer) {\n logger.debug(\n `Skipping file ${fileName} due to invalid feature-resource-version '${resourceVersion}'`,\n );\n return false;\n }\n\n // we only support 1.x, although no over version has been defined\n if (!satisfies(resourceSemVer, '^1')) {\n logger.debug(\n `Skipping file ${fileName} due to unsupported feature-resource-version '${resourceVersion}'`,\n );\n return false;\n }\n }\n\n return true;\n}\n\nfunction extractArtifactList(\n sectionName: string,\n sectionValue: unknown,\n): Bundle[] {\n // The 'ARTIFACTS' key is supported by the Sling/OSGi feature model implementation\n if (sectionName.includes(':ARTIFACTS|') && isArray(sectionValue)) {\n return sectionValue as Bundle[];\n }\n\n return [];\n}\n"],"mappings":";;;;;;;AAaA,SAAgB,mBACd,SACA,aACA,SAC2B;CAI3B,OAAO,MAAM,uCAAuC;CAEpD,MAAM,OAA4B,CAAC;CACnC,IAAI;CACJ,IAAI;EAEF,eAAeA,MAAM,MAAoB,OAAO;CAClD,SAAS,KAAK;EACZ,OAAO,KAAK;GAAE;GAAa;EAAI,GAAG,2BAA2B;EAC7D,OAAO;CACT;CAEA,IAEE,kBAAkB,YAAY,KAE9B,CAAC,kCAAkC,cAAc,WAAW,GA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F;GACA,OAAO;EACT;CACF;CAEA,OAAO;AACT;AAEA,SAAS,oBACP,aACA,cACU;CAEV,IAAI,YAAY,SAAS,aAAa,KAAK,QAAQ,YAAY,GAC7D,OAAO;CAGT,OAAO,CAAC;AACV"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import "../../../../constants/error-messages.js";
|
|
2
|
+
import { regEx } from "../../../../util/regex.js";
|
|
2
3
|
import { logger } from "../../../../logger/index.js";
|
|
3
4
|
import { parseUrl } from "../../../../util/url.js";
|
|
4
5
|
import { find } from "../../../../util/host-rules.js";
|
|
@@ -188,7 +189,7 @@ async function getUvIndexCredentials(project) {
|
|
|
188
189
|
if (!parsedUrl) continue;
|
|
189
190
|
if (!name) continue;
|
|
190
191
|
const { username, password } = await getUsernamePassword(parsedUrl);
|
|
191
|
-
const NAME = name.toUpperCase().replace(/[^A-Z0-9]/g, "_");
|
|
192
|
+
const NAME = name.toUpperCase().replace(regEx(/[^A-Z0-9]/g), "_");
|
|
192
193
|
if (username) entries.push([`UV_INDEX_${NAME}_USERNAME`, username]);
|
|
193
194
|
if (password) entries.push([`UV_INDEX_${NAME}_PASSWORD`, password]);
|
|
194
195
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uv.js","names":[],"sources":["../../../../../lib/modules/manager/pep621/processors/uv.ts"],"sourcesContent":["import { isString } from '@sindresorhus/is';\nimport { quote } from 'shlex';\nimport { TEMPORARY_ERROR } from '../../../../constants/error-messages.ts';\nimport { logger } from '../../../../logger/index.ts';\nimport type { HostRule } from '../../../../types/index.ts';\nimport type {\n ExecOptions,\n ToolConstraint,\n} from '../../../../util/exec/types.ts';\nimport {\n findLocalSiblingOrParent,\n readLocalFile,\n} from '../../../../util/fs/index.ts';\nimport { withGitEnvironment } from '../../../../util/git/exec.ts';\nimport { find } from '../../../../util/host-rules.ts';\nimport { Result } from '../../../../util/result.ts';\nimport { parseUrl } from '../../../../util/url.ts';\nimport { PypiDatasource } from '../../../datasource/pypi/index.ts';\nimport { getGoogleAuthHostRule } from '../../../datasource/util.ts';\nimport type {\n PackageDependency,\n UpdateArtifact,\n UpdateArtifactsResult,\n Upgrade,\n} from '../../types.ts';\nimport { applyGitSource } from '../../util.ts';\nimport { type PyProject, UvLockfile } from '../schema.ts';\nimport { depTypes } from '../utils.ts';\n\nimport { BasePyProjectProcessor } from './abstract.ts';\n\nconst uvUpdateCMD = 'uv lock';\nconst gitExec = withGitEnvironment(['pep621']);\n\nexport class UvProcessor extends BasePyProjectProcessor {\n override lockfileName = 'uv.lock';\n\n process(project: PyProject, deps: PackageDependency[]): PackageDependency[] {\n const uv = project.tool?.uv;\n if (!uv) {\n return deps;\n }\n\n const hasExplicitDefault = uv.index?.some(\n (index) => index.default && index.explicit,\n );\n const defaultIndex = uv.index?.find(\n (index) => index.default && !index.explicit,\n );\n const implicitIndexUrls = uv.index\n ?.filter((index) => !index.explicit && index.name !== defaultIndex?.name)\n ?.map(({ url }) => url);\n\n const devDependencies = uv['dev-dependencies'];\n if (devDependencies) {\n deps.push(...devDependencies);\n }\n\n // https://docs.astral.sh/uv/concepts/dependencies/#dependency-sources\n // Skip sources that do not make sense to handle (e.g. path).\n if (uv.sources || defaultIndex || implicitIndexUrls) {\n for (const dep of deps) {\n /* v8 ignore next 3 -- needs test */\n if (!dep.packageName) {\n continue;\n }\n\n if (dep.depType === 'requires-python') {\n continue;\n }\n\n // Using `packageName` as it applies PEP 508 normalization, which is\n // also applied by uv when matching a source to a dependency.\n const depSource = uv.sources?.[dep.packageName];\n if (depSource) {\n // Dependency is pinned to a specific source.\n dep.depType = depTypes.uvSources;\n if ('index' in depSource) {\n const index = uv.index?.find(\n ({ name }) => name === depSource.index,\n );\n if (index) {\n dep.registryUrls = [index.url];\n }\n } else if ('git' in depSource) {\n applyGitSource(\n dep,\n depSource.git,\n depSource.rev,\n depSource.tag,\n depSource.branch,\n );\n } else if ('url' in depSource) {\n dep.skipReason = 'unsupported-url';\n } else if ('path' in depSource) {\n dep.skipReason = 'path-dependency';\n } else if ('workspace' in depSource) {\n dep.skipReason = 'inherited-dependency';\n } else {\n /* v8 ignore next -- unreachable through schema */\n dep.skipReason = 'unknown-registry';\n }\n } else {\n // Dependency is not pinned to a specific source, so we need to\n // determine the source based on the index configuration.\n if (hasExplicitDefault) {\n // don't fall back to pypi if there is an explicit default index\n dep.registryUrls = [];\n } else if (defaultIndex) {\n // There is a default index configured, so use it.\n dep.registryUrls = [defaultIndex.url];\n }\n\n if (implicitIndexUrls?.length) {\n // If there are implicit indexes, check them first and fall back\n // to the default.\n dep.registryUrls = implicitIndexUrls.concat(\n dep.registryUrls ?? PypiDatasource.defaultURL,\n );\n }\n }\n }\n }\n\n return deps;\n }\n\n async extractLockedVersions(\n project: PyProject,\n deps: PackageDependency[],\n packageFile: string,\n ): Promise<PackageDependency[]> {\n const lockFileName = await findLocalSiblingOrParent(\n packageFile,\n this.lockfileName,\n );\n if (lockFileName === null) {\n logger.debug({ packageFile }, `No uv lock file found`);\n } else {\n const lockFileContent = await readLocalFile(lockFileName, 'utf8');\n if (lockFileContent) {\n const { val: lockFileMapping, err } = Result.parse(\n lockFileContent,\n UvLockfile,\n ).unwrap();\n\n if (err) {\n logger.debug({ packageFile, err }, `Error parsing uv lock file`);\n } else {\n for (const dep of deps) {\n const packageName = dep.packageName;\n if (packageName && packageName in lockFileMapping) {\n dep.lockedVersion = lockFileMapping[packageName];\n }\n }\n }\n }\n }\n\n return Promise.resolve(deps);\n }\n\n async updateArtifacts(\n updateArtifact: UpdateArtifact,\n project: PyProject,\n ): Promise<UpdateArtifactsResult[] | null> {\n const { config, updatedDeps, packageFileName } = updateArtifact;\n\n const { isLockFileMaintenance } = config;\n\n // abort if no lockfile is defined\n const lockFileName = await findLocalSiblingOrParent(\n packageFileName,\n 'uv.lock',\n );\n if (lockFileName === null) {\n logger.debug({ packageFileName }, `No uv lock file found`);\n return null;\n }\n try {\n const existingLockFileContent = await readLocalFile(lockFileName, 'utf8');\n if (!existingLockFileContent) {\n logger.debug('No uv.lock found');\n return null;\n }\n\n const pythonConstraint: ToolConstraint = {\n toolName: 'python',\n constraint:\n config.constraints?.python ?? project.project?.['requires-python'],\n };\n const uvConstraint: ToolConstraint = {\n toolName: 'uv',\n constraint:\n config.constraints?.uv ?? project.tool?.uv?.['required-version'],\n };\n\n const extraEnv = {\n ...(await getUvExtraIndexUrl(project, updateArtifact.updatedDeps)),\n ...(await getUvIndexCredentials(project)),\n };\n const execOptions: ExecOptions = {\n cwdFile: packageFileName,\n extraEnv,\n docker: {},\n toolConstraints: [pythonConstraint, uvConstraint],\n };\n\n // on lockFileMaintenance do not specify any packages and update the complete lock file\n // else only update specific packages\n let cmd: string;\n if (isLockFileMaintenance) {\n cmd = `${uvUpdateCMD} --upgrade`;\n } else {\n cmd = generateCMD(updatedDeps);\n }\n await gitExec(cmd, execOptions);\n\n // check for changes\n const fileChanges: UpdateArtifactsResult[] = [];\n const newLockContent = await readLocalFile(lockFileName, 'utf8');\n const isLockFileChanged = existingLockFileContent !== newLockContent;\n if (isLockFileChanged) {\n fileChanges.push({\n file: {\n type: 'addition',\n path: lockFileName,\n contents: newLockContent,\n },\n });\n } else {\n logger.debug('uv.lock is unchanged');\n }\n\n return fileChanges.length ? fileChanges : null;\n } catch (err) {\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n logger.debug({ err }, 'Failed to update uv lock file');\n return [\n {\n artifactError: {\n fileName: lockFileName,\n stderr: err.message,\n },\n },\n ];\n }\n }\n}\n\nfunction generateCMD(updatedDeps: Upgrade[]): string {\n const deps: string[] = [];\n\n for (const dep of updatedDeps) {\n switch (dep.depType) {\n case depTypes.optionalDependencies: {\n deps.push(dep.depName!);\n break;\n }\n case depTypes.uvDevDependencies:\n case depTypes.uvSources: {\n deps.push(dep.depName!);\n break;\n }\n case depTypes.buildSystemRequires:\n // build requirements are not locked in the lock files, no need to update.\n break;\n default: {\n deps.push(dep.packageName!);\n }\n }\n }\n\n return `${uvUpdateCMD} ${deps.map((dep) => `--upgrade-package ${quote(dep)}`).join(' ')}`;\n}\n\nfunction getMatchingHostRule(url: string | undefined): HostRule {\n return find({ hostType: PypiDatasource.id, url });\n}\n\nasync function getUsernamePassword(\n url: URL,\n): Promise<{ username?: string; password?: string }> {\n const rule = getMatchingHostRule(url.toString());\n if (rule.username || rule.password) {\n return rule;\n }\n\n if (url.hostname.endsWith('.pkg.dev')) {\n const hostRule = await getGoogleAuthHostRule();\n if (hostRule) {\n return hostRule;\n }\n logger.once.debug({ url }, 'Could not get Google access token');\n }\n\n return {};\n}\n\nasync function getUvExtraIndexUrl(\n project: PyProject,\n deps: Upgrade[],\n): Promise<NodeJS.ProcessEnv> {\n const pyPiRegistryUrls = deps\n .filter((dep) => dep.datasource === PypiDatasource.id)\n .filter((dep) => {\n // Remove dependencies that are pinned to a specific index\n const sources = project.tool?.uv?.sources;\n const packageName = dep.packageName!;\n return !sources || !(packageName in sources);\n })\n .flatMap((dep) => dep.registryUrls)\n .filter(isString)\n .filter((registryUrl) => {\n // Check if the registry URL is not the default one and not already configured\n const configuredIndexUrls =\n project.tool?.uv?.index?.map(({ url }) => url) ?? [];\n return (\n registryUrl !== PypiDatasource.defaultURL &&\n !configuredIndexUrls.includes(registryUrl)\n );\n });\n\n const registryUrls = new Set(pyPiRegistryUrls);\n const extraIndexUrls: string[] = [];\n\n for (const registryUrl of registryUrls) {\n const parsedUrl = parseUrl(registryUrl);\n if (!parsedUrl) {\n continue;\n }\n\n const { username, password } = await getUsernamePassword(parsedUrl);\n if (username || password) {\n if (username) {\n parsedUrl.username = username;\n }\n if (password) {\n parsedUrl.password = password;\n }\n }\n\n extraIndexUrls.push(parsedUrl.toString());\n }\n\n return {\n UV_EXTRA_INDEX_URL: extraIndexUrls.join(' '),\n };\n}\n\nasync function getUvIndexCredentials(\n project: PyProject,\n): Promise<NodeJS.ProcessEnv> {\n const uv_indexes = project.tool?.uv?.index;\n\n if (!uv_indexes) {\n return {};\n }\n\n const entries = [];\n\n for (const { name, url } of uv_indexes) {\n const parsedUrl = parseUrl(url);\n /* v8 ignore next 3 -- needs test */\n if (!parsedUrl) {\n continue;\n }\n\n // If no name is provided for the index, authentication information must be passed through alternative methods\n if (!name) {\n continue;\n }\n\n const { username, password } = await getUsernamePassword(parsedUrl);\n\n const NAME = name.toUpperCase().replace(/[^A-Z0-9]/g, '_');\n\n if (username) {\n entries.push([`UV_INDEX_${NAME}_USERNAME`, username]);\n }\n\n if (password) {\n entries.push([`UV_INDEX_${NAME}_PASSWORD`, password]);\n }\n }\n\n return Object.fromEntries(entries);\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA+BA,MAAM,cAAc;AACpB,MAAM,UAAU,mBAAmB,CAAC,QAAQ,CAAC;AAE7C,IAAa,cAAb,cAAiC,uBAAuB;CACtD,eAAwB;CAExB,QAAQ,SAAoB,MAAgD;EAC1E,MAAM,KAAK,QAAQ,MAAM;EACzB,IAAI,CAAC,IACH,OAAO;EAGT,MAAM,qBAAqB,GAAG,OAAO,MAClC,UAAU,MAAM,WAAW,MAAM,QACpC;EACA,MAAM,eAAe,GAAG,OAAO,MAC5B,UAAU,MAAM,WAAW,CAAC,MAAM,QACrC;EACA,MAAM,oBAAoB,GAAG,OACzB,QAAQ,UAAU,CAAC,MAAM,YAAY,MAAM,SAAS,cAAc,IAAI,CAAC,EACvE,KAAK,EAAE,UAAU,GAAG;EAExB,MAAM,kBAAkB,GAAG;EAC3B,IAAI,iBACF,KAAK,KAAK,GAAG,eAAe;EAK9B,IAAI,GAAG,WAAW,gBAAgB,mBAChC,KAAK,MAAM,OAAO,MAAM;;GAEtB,IAAI,CAAC,IAAI,aACP;GAGF,IAAI,IAAI,YAAY,mBAClB;GAKF,MAAM,YAAY,GAAG,UAAU,IAAI;GACnC,IAAI,WAAW;IAEb,IAAI,UAAU,SAAS;IACvB,IAAI,WAAW,WAAW;KACxB,MAAM,QAAQ,GAAG,OAAO,MACrB,EAAE,WAAW,SAAS,UAAU,KACnC;KACA,IAAI,OACF,I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UAAU,WAAW;GAEvB,IAAI,UACF,UAAU,WAAW;EAEzB;EAEA,eAAe,KAAK,UAAU,SAAS,CAAC;CAC1C;CAEA,OAAO,EACL,oBAAoB,eAAe,KAAK,GAAG,EAC7C;AACF;AAEA,eAAe,sBACb,SAC4B;CAC5B,MAAM,aAAa,QAAQ,MAAM,IAAI;CAErC,IAAI,CAAC,YACH,OAAO,CAAC;CAGV,MAAM,UAAU,CAAC;CAEjB,KAAK,MAAM,EAAE,MAAM,SAAS,YAAY;EACtC,MAAM,YAAY,SAAS,GAAG;;EAE9B,IAAI,CAAC,WACH;EAIF,IAAI,CAAC,MACH;EAGF,MAAM,EAAE,UAAU,aAAa,MAAM,oBAAoB,SAAS;EAElE,MAAM,OAAO,KAAK,YAAY,CAAC,CAAC,QAAQ,cAAc,GAAG;EAEzD,IAAI,UACF,QAAQ,KAAK,CAAC,YAAY,KAAK,YAAY,QAAQ,CAAC;EAGtD,IAAI,UACF,QAAQ,KAAK,CAAC,YAAY,KAAK,YAAY,QAAQ,CAAC;CAExD;CAEA,OAAO,OAAO,YAAY,OAAO;AACnC"}
|
|
1
|
+
{"version":3,"file":"uv.js","names":[],"sources":["../../../../../lib/modules/manager/pep621/processors/uv.ts"],"sourcesContent":["import { isString } from '@sindresorhus/is';\nimport { quote } from 'shlex';\nimport { TEMPORARY_ERROR } from '../../../../constants/error-messages.ts';\nimport { logger } from '../../../../logger/index.ts';\nimport type { HostRule } from '../../../../types/index.ts';\nimport type {\n ExecOptions,\n ToolConstraint,\n} from '../../../../util/exec/types.ts';\nimport {\n findLocalSiblingOrParent,\n readLocalFile,\n} from '../../../../util/fs/index.ts';\nimport { withGitEnvironment } from '../../../../util/git/exec.ts';\nimport { find } from '../../../../util/host-rules.ts';\nimport { regEx } from '../../../../util/regex.ts';\nimport { Result } from '../../../../util/result.ts';\nimport { parseUrl } from '../../../../util/url.ts';\nimport { PypiDatasource } from '../../../datasource/pypi/index.ts';\nimport { getGoogleAuthHostRule } from '../../../datasource/util.ts';\nimport type {\n PackageDependency,\n UpdateArtifact,\n UpdateArtifactsResult,\n Upgrade,\n} from '../../types.ts';\nimport { applyGitSource } from '../../util.ts';\nimport { type PyProject, UvLockfile } from '../schema.ts';\nimport { depTypes } from '../utils.ts';\nimport { BasePyProjectProcessor } from './abstract.ts';\n\nconst uvUpdateCMD = 'uv lock';\nconst gitExec = withGitEnvironment(['pep621']);\n\nexport class UvProcessor extends BasePyProjectProcessor {\n override lockfileName = 'uv.lock';\n\n process(project: PyProject, deps: PackageDependency[]): PackageDependency[] {\n const uv = project.tool?.uv;\n if (!uv) {\n return deps;\n }\n\n const hasExplicitDefault = uv.index?.some(\n (index) => index.default && index.explicit,\n );\n const defaultIndex = uv.index?.find(\n (index) => index.default && !index.explicit,\n );\n const implicitIndexUrls = uv.index\n ?.filter((index) => !index.explicit && index.name !== defaultIndex?.name)\n ?.map(({ url }) => url);\n\n const devDependencies = uv['dev-dependencies'];\n if (devDependencies) {\n deps.push(...devDependencies);\n }\n\n // https://docs.astral.sh/uv/concepts/dependencies/#dependency-sources\n // Skip sources that do not make sense to handle (e.g. path).\n if (uv.sources || defaultIndex || implicitIndexUrls) {\n for (const dep of deps) {\n /* v8 ignore next 3 -- needs test */\n if (!dep.packageName) {\n continue;\n }\n\n if (dep.depType === 'requires-python') {\n continue;\n }\n\n // Using `packageName` as it applies PEP 508 normalization, which is\n // also applied by uv when matching a source to a dependency.\n const depSource = uv.sources?.[dep.packageName];\n if (depSource) {\n // Dependency is pinned to a specific source.\n dep.depType = depTypes.uvSources;\n if ('index' in depSource) {\n const index = uv.index?.find(\n ({ name }) => name === depSource.index,\n );\n if (index) {\n dep.registryUrls = [index.url];\n }\n } else if ('git' in depSource) {\n applyGitSource(\n dep,\n depSource.git,\n depSource.rev,\n depSource.tag,\n depSource.branch,\n );\n } else if ('url' in depSource) {\n dep.skipReason = 'unsupported-url';\n } else if ('path' in depSource) {\n dep.skipReason = 'path-dependency';\n } else if ('workspace' in depSource) {\n dep.skipReason = 'inherited-dependency';\n } else {\n /* v8 ignore next -- unreachable through schema */\n dep.skipReason = 'unknown-registry';\n }\n } else {\n // Dependency is not pinned to a specific source, so we need to\n // determine the source based on the index configuration.\n if (hasExplicitDefault) {\n // don't fall back to pypi if there is an explicit default index\n dep.registryUrls = [];\n } else if (defaultIndex) {\n // There is a default index configured, so use it.\n dep.registryUrls = [defaultIndex.url];\n }\n\n if (implicitIndexUrls?.length) {\n // If there are implicit indexes, check them first and fall back\n // to the default.\n dep.registryUrls = implicitIndexUrls.concat(\n dep.registryUrls ?? PypiDatasource.defaultURL,\n );\n }\n }\n }\n }\n\n return deps;\n }\n\n async extractLockedVersions(\n project: PyProject,\n deps: PackageDependency[],\n packageFile: string,\n ): Promise<PackageDependency[]> {\n const lockFileName = await findLocalSiblingOrParent(\n packageFile,\n this.lockfileName,\n );\n if (lockFileName === null) {\n logger.debug({ packageFile }, `No uv lock file found`);\n } else {\n const lockFileContent = await readLocalFile(lockFileName, 'utf8');\n if (lockFileContent) {\n const { val: lockFileMapping, err } = Result.parse(\n lockFileContent,\n UvLockfile,\n ).unwrap();\n\n if (err) {\n logger.debug({ packageFile, err }, `Error parsing uv lock file`);\n } else {\n for (const dep of deps) {\n const packageName = dep.packageName;\n if (packageName && packageName in lockFileMapping) {\n dep.lockedVersion = lockFileMapping[packageName];\n }\n }\n }\n }\n }\n\n return Promise.resolve(deps);\n }\n\n async updateArtifacts(\n updateArtifact: UpdateArtifact,\n project: PyProject,\n ): Promise<UpdateArtifactsResult[] | null> {\n const { config, updatedDeps, packageFileName } = updateArtifact;\n\n const { isLockFileMaintenance } = config;\n\n // abort if no lockfile is defined\n const lockFileName = await findLocalSiblingOrParent(\n packageFileName,\n 'uv.lock',\n );\n if (lockFileName === null) {\n logger.debug({ packageFileName }, `No uv lock file found`);\n return null;\n }\n try {\n const existingLockFileContent = await readLocalFile(lockFileName, 'utf8');\n if (!existingLockFileContent) {\n logger.debug('No uv.lock found');\n return null;\n }\n\n const pythonConstraint: ToolConstraint = {\n toolName: 'python',\n constraint:\n config.constraints?.python ?? project.project?.['requires-python'],\n };\n const uvConstraint: ToolConstraint = {\n toolName: 'uv',\n constraint:\n config.constraints?.uv ?? project.tool?.uv?.['required-version'],\n };\n\n const extraEnv = {\n ...(await getUvExtraIndexUrl(project, updateArtifact.updatedDeps)),\n ...(await getUvIndexCredentials(project)),\n };\n const execOptions: ExecOptions = {\n cwdFile: packageFileName,\n extraEnv,\n docker: {},\n toolConstraints: [pythonConstraint, uvConstraint],\n };\n\n // on lockFileMaintenance do not specify any packages and update the complete lock file\n // else only update specific packages\n let cmd: string;\n if (isLockFileMaintenance) {\n cmd = `${uvUpdateCMD} --upgrade`;\n } else {\n cmd = generateCMD(updatedDeps);\n }\n await gitExec(cmd, execOptions);\n\n // check for changes\n const fileChanges: UpdateArtifactsResult[] = [];\n const newLockContent = await readLocalFile(lockFileName, 'utf8');\n const isLockFileChanged = existingLockFileContent !== newLockContent;\n if (isLockFileChanged) {\n fileChanges.push({\n file: {\n type: 'addition',\n path: lockFileName,\n contents: newLockContent,\n },\n });\n } else {\n logger.debug('uv.lock is unchanged');\n }\n\n return fileChanges.length ? fileChanges : null;\n } catch (err) {\n if (err.message === TEMPORARY_ERROR) {\n throw err;\n }\n logger.debug({ err }, 'Failed to update uv lock file');\n return [\n {\n artifactError: {\n fileName: lockFileName,\n stderr: err.message,\n },\n },\n ];\n }\n }\n}\n\nfunction generateCMD(updatedDeps: Upgrade[]): string {\n const deps: string[] = [];\n\n for (const dep of updatedDeps) {\n switch (dep.depType) {\n case depTypes.optionalDependencies: {\n deps.push(dep.depName!);\n break;\n }\n case depTypes.uvDevDependencies:\n case depTypes.uvSources: {\n deps.push(dep.depName!);\n break;\n }\n case depTypes.buildSystemRequires:\n // build requirements are not locked in the lock files, no need to update.\n break;\n default: {\n deps.push(dep.packageName!);\n }\n }\n }\n\n return `${uvUpdateCMD} ${deps.map((dep) => `--upgrade-package ${quote(dep)}`).join(' ')}`;\n}\n\nfunction getMatchingHostRule(url: string | undefined): HostRule {\n return find({ hostType: PypiDatasource.id, url });\n}\n\nasync function getUsernamePassword(\n url: URL,\n): Promise<{ username?: string; password?: string }> {\n const rule = getMatchingHostRule(url.toString());\n if (rule.username || rule.password) {\n return rule;\n }\n\n if (url.hostname.endsWith('.pkg.dev')) {\n const hostRule = await getGoogleAuthHostRule();\n if (hostRule) {\n return hostRule;\n }\n logger.once.debug({ url }, 'Could not get Google access token');\n }\n\n return {};\n}\n\nasync function getUvExtraIndexUrl(\n project: PyProject,\n deps: Upgrade[],\n): Promise<NodeJS.ProcessEnv> {\n const pyPiRegistryUrls = deps\n .filter((dep) => dep.datasource === PypiDatasource.id)\n .filter((dep) => {\n // Remove dependencies that are pinned to a specific index\n const sources = project.tool?.uv?.sources;\n const packageName = dep.packageName!;\n return !sources || !(packageName in sources);\n })\n .flatMap((dep) => dep.registryUrls)\n .filter(isString)\n .filter((registryUrl) => {\n // Check if the registry URL is not the default one and not already configured\n const configuredIndexUrls =\n project.tool?.uv?.index?.map(({ url }) => url) ?? [];\n return (\n registryUrl !== PypiDatasource.defaultURL &&\n !configuredIndexUrls.includes(registryUrl)\n );\n });\n\n const registryUrls = new Set(pyPiRegistryUrls);\n const extraIndexUrls: string[] = [];\n\n for (const registryUrl of registryUrls) {\n const parsedUrl = parseUrl(registryUrl);\n if (!parsedUrl) {\n continue;\n }\n\n const { username, password } = await getUsernamePassword(parsedUrl);\n if (username || password) {\n if (username) {\n parsedUrl.username = username;\n }\n if (password) {\n parsedUrl.password = password;\n }\n }\n\n extraIndexUrls.push(parsedUrl.toString());\n }\n\n return {\n UV_EXTRA_INDEX_URL: extraIndexUrls.join(' '),\n };\n}\n\nasync function getUvIndexCredentials(\n project: PyProject,\n): Promise<NodeJS.ProcessEnv> {\n const uv_indexes = project.tool?.uv?.index;\n\n if (!uv_indexes) {\n return {};\n }\n\n const entries = [];\n\n for (const { name, url } of uv_indexes) {\n const parsedUrl = parseUrl(url);\n /* v8 ignore next 3 -- needs test */\n if (!parsedUrl) {\n continue;\n }\n\n // If no name is provided for the index, authentication information must be passed through alternative methods\n if (!name) {\n continue;\n }\n\n const { username, password } = await getUsernamePassword(parsedUrl);\n\n const NAME = name.toUpperCase().replace(regEx(/[^A-Z0-9]/g), '_');\n\n if (username) {\n entries.push([`UV_INDEX_${NAME}_USERNAME`, username]);\n }\n\n if (password) {\n entries.push([`UV_INDEX_${NAME}_PASSWORD`, password]);\n }\n }\n\n return Object.fromEntries(entries);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA+BA,MAAM,cAAc;AACpB,MAAM,UAAU,mBAAmB,CAAC,QAAQ,CAAC;AAE7C,IAAa,cAAb,cAAiC,uBAAuB;CACtD,eAAwB;CAExB,QAAQ,SAAoB,MAAgD;EAC1E,MAAM,KAAK,QAAQ,MAAM;EACzB,IAAI,CAAC,IACH,OAAO;EAGT,MAAM,qBAAqB,GAAG,OAAO,MAClC,UAAU,MAAM,WAAW,MAAM,QACpC;EACA,MAAM,eAAe,GAAG,OAAO,MAC5B,UAAU,MAAM,WAAW,CAAC,MAAM,QACrC;EACA,MAAM,oBAAoB,GAAG,OACzB,QAAQ,UAAU,CAAC,MAAM,YAAY,MAAM,SAAS,cAAc,IAAI,CAAC,EACvE,KAAK,EAAE,UAAU,GAAG;EAExB,MAAM,kBAAkB,GAAG;EAC3B,IAAI,iBACF,KAAK,KAAK,GAAG,eAAe;EAK9B,IAAI,GAAG,WAAW,gBAAgB,mBAChC,KAAK,MAAM,OAAO,MAAM;;GAEtB,IAAI,CAAC,IAAI,aACP;GAGF,IAAI,IAAI,YAAY,mBAClB;GAKF,MAAM,YAAY,GAAG,UAAU,IAAI;GACnC,IAAI,WAAW;IAEb,IAAI,UAAU,SAAS;IACvB,IAAI,WAAW,WAAW;KACxB,MAAM,QAAQ,GAAG,OAAO,MACrB,EAAE,WAAW,SAAS,UAAU,KACnC;KACA,IAAI,OACF,IAAI,eAAe,CAAC,MAAM,GAAG;IAEjC,OAAO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;EAEzB;EAEA,eAAe,KAAK,UAAU,SAAS,CAAC;CAC1C;CAEA,OAAO,EACL,oBAAoB,eAAe,KAAK,GAAG,EAC7C;AACF;AAEA,eAAe,sBACb,SAC4B;CAC5B,MAAM,aAAa,QAAQ,MAAM,IAAI;CAErC,IAAI,CAAC,YACH,OAAO,CAAC;CAGV,MAAM,UAAU,CAAC;CAEjB,KAAK,MAAM,EAAE,MAAM,SAAS,YAAY;EACtC,MAAM,YAAY,SAAS,GAAG;;EAE9B,IAAI,CAAC,WACH;EAIF,IAAI,CAAC,MACH;EAGF,MAAM,EAAE,UAAU,aAAa,MAAM,oBAAoB,SAAS;EAElE,MAAM,OAAO,KAAK,YAAY,CAAC,CAAC,QAAQ,MAAM,YAAY,GAAG,GAAG;EAEhE,IAAI,UACF,QAAQ,KAAK,CAAC,YAAY,KAAK,YAAY,QAAQ,CAAC;EAGtD,IAAI,UACF,QAAQ,KAAK,CAAC,YAAY,KAAK,YAAY,QAAQ,CAAC;CAExD;CAEA,OAAO,OAAO,YAAY,OAAO;AACnC"}
|
|
@@ -55,7 +55,7 @@ function extractPackageFile(content) {
|
|
|
55
55
|
currentValue,
|
|
56
56
|
datasource: PypiDatasource.id
|
|
57
57
|
};
|
|
58
|
-
if (currentValue?.startsWith("==")) dep.currentVersion = currentValue.replace(/^==\s
|
|
58
|
+
if (currentValue?.startsWith("==")) dep.currentVersion = currentValue.replace(regEx(/^==\s*/), "");
|
|
59
59
|
return dep;
|
|
60
60
|
}).filter(isTruthy);
|
|
61
61
|
const res = extractPackageFileFlags(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/-]+))(\\.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(/^==\\s
|
|
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,sLACF;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,MAAM,WAAW,QAAQ,MAAM,GAAG,CAAC,CAAC,KAAK,SAAS,KAAK,KAAK,CAAC;EACpE,IAAI,cAAc,OAAO,GACvB,IAAI,aAAa;EAEnB,MAAM,CAAC,oBAAoB,KAAK,MAAM,GAAG,CAAC,CAAC,KAA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AACT"}
|
|
@@ -6,7 +6,7 @@ import { lang, query } from "@renovatebot/good-enough-parser";
|
|
|
6
6
|
//#region lib/modules/manager/pip_setup/extract.ts
|
|
7
7
|
const python = lang.createLang("python");
|
|
8
8
|
function cleanupNamedGroups(regexSource) {
|
|
9
|
-
return regexSource.replace(/\(\?<\w+>/g, "(?:");
|
|
9
|
+
return regexSource.replace(regEx(/\(\?<\w+>/g), "(?:");
|
|
10
10
|
}
|
|
11
11
|
const rangePattern = cleanupNamedGroups(RANGE_PATTERN);
|
|
12
12
|
const versionPattern = `(?:${rangePattern}(?:\\s*,\\s*${rangePattern})*)`;
|
|
@@ -46,8 +46,8 @@ function depSkipHandler(ctx) {
|
|
|
46
46
|
deps
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
|
-
const incompleteDepString = query.str(
|
|
50
|
-
const depString = query.str(
|
|
49
|
+
const incompleteDepString = query.str(regEx(cleanupNamedGroups(depPattern))).op(regEx(/^\+|\*$/));
|
|
50
|
+
const depString = query.str(regEx(cleanupNamedGroups(depPattern)), depStringHandler).opt(query.opt(query.op(",")).comment(regEx(/^#\s*renovate\s*:\s*ignore\s*$/), depSkipHandler));
|
|
51
51
|
const query$1 = query.alt(incompleteDepString, depString);
|
|
52
52
|
function extractPackageFile(content, _packageFile, _config) {
|
|
53
53
|
const res = python.query(content, query$1, { deps: [] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract.js","names":["q","query"],"sources":["../../../../lib/modules/manager/pip_setup/extract.ts"],"sourcesContent":["import type { lexer, parser } from '@renovatebot/good-enough-parser';\nimport { lang, query as q } from '@renovatebot/good-enough-parser';\nimport { RANGE_PATTERN } from '@renovatebot/pep440';\nimport { regEx } from '../../../util/regex.ts';\nimport { normalizePythonDepName } from '../../datasource/pypi/common.ts';\nimport { PypiDatasource } from '../../datasource/pypi/index.ts';\nimport type {\n ExtractConfig,\n PackageDependency,\n PackageFileContent,\n} from '../types.ts';\n\ninterface ManagerData {\n lineNumber: number;\n}\n\ntype Context = PackageFileContent<ManagerData>;\n\nconst python = lang.createLang('python');\n\n// Optimize regex memory usage when we don't need named groups\nfunction cleanupNamedGroups(regexSource: string): string {\n return regexSource.replace(/\\(\\?<\\w+>/g, '(?:');\n}\n\nconst rangePattern = cleanupNamedGroups(RANGE_PATTERN);\nconst versionPattern = `(?:${rangePattern}(?:\\\\s*,\\\\s*${rangePattern})*)`;\nconst depNamePattern = '(?:[a-zA-Z][-_a-zA-Z0-9\\\\.]*[a-zA-Z0-9])';\nconst depPattern = [\n '^',\n `(?<depName>${depNamePattern})`,\n `(?<extra>(?:\\\\[\\\\s*(?:${depNamePattern}(?:\\\\s*,\\\\s*${depNamePattern})*\\\\s*)\\\\])?)`,\n `(?<currentValue>${versionPattern})`,\n].join('\\\\s*');\n\nconst extractRegex = regEx(depPattern);\n\n// Extract dependency string\nfunction depStringHandler(\n ctx: Context,\n token: lexer.StringValueToken,\n): Context {\n const depStr = token.value;\n const match = extractRegex.exec(depStr);\n // TODO #22198\n const { depName, currentValue } = match!.groups!;\n\n const dep: PackageDependency<ManagerData> = {\n depName,\n packageName: normalizePythonDepName(depName),\n currentValue,\n managerData: {\n lineNumber: token.line - 1,\n },\n datasource: PypiDatasource.id,\n };\n\n if (currentValue?.startsWith('==')) {\n dep.currentVersion = currentValue.replace(regEx(/^==\\s*/), '');\n }\n\n return { ...ctx, deps: [...ctx.deps, dep] };\n}\n\n// Add `skip-reason` for dependencies annotated\n// with \"# renovate: ignore\" comment\nfunction depSkipHandler(ctx: Context): Context {\n const dep = ctx.deps.at(-1);\n const deps = ctx.deps.slice(0, -1);\n deps.push({ ...dep, skipReason: 'ignored' });\n return { ...ctx, deps };\n}\n\nconst incompleteDepString = q\n .str<Context>(
|
|
1
|
+
{"version":3,"file":"extract.js","names":["q","query"],"sources":["../../../../lib/modules/manager/pip_setup/extract.ts"],"sourcesContent":["import type { lexer, parser } from '@renovatebot/good-enough-parser';\nimport { lang, query as q } from '@renovatebot/good-enough-parser';\nimport { RANGE_PATTERN } from '@renovatebot/pep440';\nimport { regEx } from '../../../util/regex.ts';\nimport { normalizePythonDepName } from '../../datasource/pypi/common.ts';\nimport { PypiDatasource } from '../../datasource/pypi/index.ts';\nimport type {\n ExtractConfig,\n PackageDependency,\n PackageFileContent,\n} from '../types.ts';\n\ninterface ManagerData {\n lineNumber: number;\n}\n\ntype Context = PackageFileContent<ManagerData>;\n\nconst python = lang.createLang('python');\n\n// Optimize regex memory usage when we don't need named groups\nfunction cleanupNamedGroups(regexSource: string): string {\n return regexSource.replace(regEx(/\\(\\?<\\w+>/g), '(?:');\n}\n\nconst rangePattern = cleanupNamedGroups(RANGE_PATTERN);\nconst versionPattern = `(?:${rangePattern}(?:\\\\s*,\\\\s*${rangePattern})*)`;\nconst depNamePattern = '(?:[a-zA-Z][-_a-zA-Z0-9\\\\.]*[a-zA-Z0-9])';\nconst depPattern = [\n '^',\n `(?<depName>${depNamePattern})`,\n `(?<extra>(?:\\\\[\\\\s*(?:${depNamePattern}(?:\\\\s*,\\\\s*${depNamePattern})*\\\\s*)\\\\])?)`,\n `(?<currentValue>${versionPattern})`,\n].join('\\\\s*');\n\nconst extractRegex = regEx(depPattern);\n\n// Extract dependency string\nfunction depStringHandler(\n ctx: Context,\n token: lexer.StringValueToken,\n): Context {\n const depStr = token.value;\n const match = extractRegex.exec(depStr);\n // TODO #22198\n const { depName, currentValue } = match!.groups!;\n\n const dep: PackageDependency<ManagerData> = {\n depName,\n packageName: normalizePythonDepName(depName),\n currentValue,\n managerData: {\n lineNumber: token.line - 1,\n },\n datasource: PypiDatasource.id,\n };\n\n if (currentValue?.startsWith('==')) {\n dep.currentVersion = currentValue.replace(regEx(/^==\\s*/), '');\n }\n\n return { ...ctx, deps: [...ctx.deps, dep] };\n}\n\n// Add `skip-reason` for dependencies annotated\n// with \"# renovate: ignore\" comment\nfunction depSkipHandler(ctx: Context): Context {\n const dep = ctx.deps.at(-1);\n const deps = ctx.deps.slice(0, -1);\n deps.push({ ...dep, skipReason: 'ignored' });\n return { ...ctx, deps };\n}\n\nconst incompleteDepString = q\n .str<Context>(regEx(cleanupNamedGroups(depPattern)))\n .op(regEx(/^\\+|\\*$/));\n\nconst depString = q\n .str<Context>(regEx(cleanupNamedGroups(depPattern)), depStringHandler)\n .opt(\n q\n .opt(q.op<Context>(','))\n .comment(regEx(/^#\\s*renovate\\s*:\\s*ignore\\s*$/), depSkipHandler),\n );\n\nconst query = q.alt(incompleteDepString, depString);\n\nexport function extractPackageFile(\n content: string,\n _packageFile: string,\n _config: ExtractConfig,\n): PackageFileContent | null {\n const res = python.query<Context, parser.Node>(content, query, { deps: [] });\n return res?.deps?.length ? res : null;\n}\n"],"mappings":";;;;;;AAkBA,MAAM,SAAS,KAAK,WAAW,QAAQ;AAGvC,SAAS,mBAAmB,aAA6B;CACvD,OAAO,YAAY,QAAQ,MAAM,YAAY,GAAG,KAAK;AACvD;AAEA,MAAM,eAAe,mBAAmB,aAAa;AACrD,MAAM,iBAAiB,MAAM,aAAa,cAAc,aAAa;AACrE,MAAM,iBAAiB;AACvB,MAAM,aAAa;CACjB;CACA,cAAc,eAAe;CAC7B,yBAAyB,eAAe,cAAc,eAAe;CACrE,mBAAmB,eAAe;AACpC,CAAC,CAAC,KAAK,MAAM;AAEb,MAAM,eAAe,MAAM,UAAU;AAGrC,SAAS,iBACP,KACA,OACS;CACT,MAAM,SAAS,MAAM;CAGrB,MAAM,EAAE,SAAS,iBAFH,aAAa,KAAK,MAEM,CAAC,CAAE;CAEzC,MAAM,MAAsC;EAC1C;EACA,aAAa,uBAAuB,OAAO;EAC3C;EACA,aAAa,EACX,YAAY,MAAM,OAAO,EAC3B;EACA,YAAY,eAAe;CAC7B;CAEA,IAAI,cAAc,WAAW,IAAI,GAC/B,IAAI,iBAAiB,aAAa,QAAQ,MAAM,QAAQ,GAAG,EAAE;CAG/D,OAAO;EAAE,GAAG;EAAK,MAAM,CAAC,GAAG,IAAI,MAAM,GAAG;CAAE;AAC5C;AAIA,SAAS,eAAe,KAAuB;CAC7C,MAAM,MAAM,IAAI,KAAK,GAAG,EAAE;CAC1B,MAAM,OAAO,IAAI,KAAK,MAAM,GAAG,EAAE;CACjC,KAAK,KAAK;EAAE,GAAG;EAAK,YAAY;CAAU,CAAC;CAC3C,OAAO;EAAE,GAAG;EAAK;CAAK;AACxB;AAEA,MAAM,sBAAsBA,MACzB,IAAa,MAAM,mBAAmB,UAAU,CAAC,CAAC,CAAC,CACnD,GAAG,MAAM,SAAS,CAAC;AAEtB,MAAM,YAAYA,MACf,IAAa,MAAM,mBAAmB,UAAU,CAAC,GAAG,gBAAgB,CAAC,CACrE,IACCA,MACG,IAAIA,MAAE,GAAY,GAAG,CAAC,CAAC,CACvB,QAAQ,MAAM,gCAAgC,GAAG,cAAc,CACpE;AAEF,MAAMC,UAAQD,MAAE,IAAI,qBAAqB,SAAS;AAElD,SAAgB,mBACd,SACA,cACA,SAC2B;CAC3B,MAAM,MAAM,OAAO,MAA4B,SAASC,SAAO,EAAE,MAAM,CAAC,EAAE,CAAC;CAC3E,OAAO,KAAK,MAAM,SAAS,MAAM;AACnC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { regEx } from "../../../util/regex.js";
|
|
1
2
|
import { LooseRecord, Toml, Yaml } from "../../../util/schema-utils/index.js";
|
|
2
3
|
import { id } from "../../versioning/pep440/index.js";
|
|
3
4
|
import { id as id$1 } from "../../versioning/conda/index.js";
|
|
@@ -26,7 +27,7 @@ const PypiDependency = z.union([z.string().transform((version) => ({ version }))
|
|
|
26
27
|
versioning: id,
|
|
27
28
|
datasource: PypiDatasource.id
|
|
28
29
|
};
|
|
29
|
-
if (version.startsWith("==")) dep.currentVersion = version.replace(/^==\s
|
|
30
|
+
if (version.startsWith("==")) dep.currentVersion = version.replace(regEx(/^==\s*/), "");
|
|
30
31
|
return dep;
|
|
31
32
|
});
|
|
32
33
|
const PypiGitDependency = z.object({
|