renovate 44.237.2 → 44.238.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/config/options/index.js +11 -1
  2. package/dist/config/options/index.js.map +1 -1
  3. package/dist/config/presets/internal/security.preset.js +14 -9
  4. package/dist/config/presets/internal/security.preset.js.map +1 -1
  5. package/dist/config/types.d.ts +1 -0
  6. package/dist/config/types.js.map +1 -1
  7. package/dist/global-config-option-defaults.generated.js +1 -1
  8. package/dist/global-config-option-defaults.generated.js.map +1 -1
  9. package/dist/modules/manager/cargo/artifacts.js +39 -10
  10. package/dist/modules/manager/cargo/artifacts.js.map +1 -1
  11. package/dist/modules/manager/cargo/extract.js +45 -28
  12. package/dist/modules/manager/cargo/extract.js.map +1 -1
  13. package/dist/modules/manager/cargo/index.js +10 -1
  14. package/dist/modules/manager/cargo/index.js.map +1 -1
  15. package/dist/modules/manager/cargo/locked-version.js +10 -4
  16. package/dist/modules/manager/cargo/locked-version.js.map +1 -1
  17. package/dist/modules/manager/cargo/minimum-release-age.js +216 -0
  18. package/dist/modules/manager/cargo/minimum-release-age.js.map +1 -0
  19. package/dist/modules/manager/cargo/schema.js +6 -1
  20. package/dist/modules/manager/cargo/schema.js.map +1 -1
  21. package/dist/modules/manager/cargo/utils.js +23 -1
  22. package/dist/modules/manager/cargo/utils.js.map +1 -1
  23. package/dist/modules/manager/fingerprint.generated.js +3 -3
  24. package/dist/modules/manager/fingerprint.generated.js.map +1 -1
  25. package/dist/modules/manager/npm/constants.js +3 -1
  26. package/dist/modules/manager/npm/constants.js.map +1 -1
  27. package/dist/modules/manager/npm/extract/index.js +1 -1
  28. package/dist/modules/manager/npm/extract/index.js.map +1 -1
  29. package/dist/modules/manager/npm/extract/npmrc.js +93 -0
  30. package/dist/modules/manager/npm/extract/npmrc.js.map +1 -0
  31. package/dist/modules/manager/npm/extract/pnpm-minimum-release-age.js +149 -0
  32. package/dist/modules/manager/npm/extract/pnpm-minimum-release-age.js.map +1 -0
  33. package/dist/modules/manager/npm/extract/pnpm.js +88 -2
  34. package/dist/modules/manager/npm/extract/pnpm.js.map +1 -1
  35. package/dist/modules/manager/npm/extract/post/index.js +7 -1
  36. package/dist/modules/manager/npm/extract/post/index.js.map +1 -1
  37. package/dist/modules/manager/npm/extract/utils.js +25 -1
  38. package/dist/modules/manager/npm/extract/utils.js.map +1 -1
  39. package/dist/modules/manager/npm/extract/yarn-minimum-release-age.js +181 -0
  40. package/dist/modules/manager/npm/extract/yarn-minimum-release-age.js.map +1 -0
  41. package/dist/modules/manager/npm/index.js +18 -4
  42. package/dist/modules/manager/npm/index.js.map +1 -1
  43. package/dist/modules/manager/npm/minimum-release-age.js +93 -0
  44. package/dist/modules/manager/npm/minimum-release-age.js.map +1 -0
  45. package/dist/modules/manager/npm/post-update/index.js +12 -3
  46. package/dist/modules/manager/npm/post-update/index.js.map +1 -1
  47. package/dist/modules/manager/npm/post-update/npm.js +89 -57
  48. package/dist/modules/manager/npm/post-update/npm.js.map +1 -1
  49. package/dist/modules/manager/npm/post-update/pnpm.js +132 -90
  50. package/dist/modules/manager/npm/post-update/pnpm.js.map +1 -1
  51. package/dist/modules/manager/npm/post-update/utils.js +7 -1
  52. package/dist/modules/manager/npm/post-update/utils.js.map +1 -1
  53. package/dist/modules/manager/npm/post-update/yarn.js +70 -3
  54. package/dist/modules/manager/npm/post-update/yarn.js.map +1 -1
  55. package/dist/modules/manager/npm/schema.js +21 -2
  56. package/dist/modules/manager/npm/schema.js.map +1 -1
  57. package/dist/modules/manager/types.d.ts +10 -3
  58. package/dist/modules/versioning/common.js +14 -2
  59. package/dist/modules/versioning/common.js.map +1 -1
  60. package/dist/modules/versioning/rust-release-channel/index.js +21 -0
  61. package/dist/modules/versioning/rust-release-channel/index.js.map +1 -1
  62. package/dist/util/minimum-release-age.js +20 -6
  63. package/dist/util/minimum-release-age.js.map +1 -1
  64. package/dist/util/schema-utils/index.js.map +1 -1
  65. package/dist/workers/repository/updates/flatten.js +1 -0
  66. package/dist/workers/repository/updates/flatten.js.map +1 -1
  67. package/package.json +3 -3
  68. package/renovate-schema.json +380 -2
@@ -4,10 +4,11 @@ import { findLocalSiblingOrParent, getSiblingFileName, localPathExists, readLoca
4
4
  import { coerceObject } from "../../../../util/object.js";
5
5
  import { parseSingleYaml, parseYaml } from "../../../../util/yaml.js";
6
6
  import { NpmDatasource } from "../../../datasource/npm/index.js";
7
+ import { resolveToolConstraint } from "../../util.js";
7
8
  import { pnpmWorkspaceOverrides } from "../dep-types.js";
8
9
  import { extractCatalogDeps } from "./common/catalogs.js";
9
10
  import { extractDependency } from "./common/dependency.js";
10
- import { isNonEmptyObject, isNumber, isObject, isPlainObject, isString } from "@sindresorhus/is";
11
+ import { isNonEmptyObject, isNullOrUndefined, isNumber, isNumericString, isObject, isPlainObject, isString } from "@sindresorhus/is";
11
12
  import upath from "upath";
12
13
  import { parsePkgAndParentSelector } from "@pnpm/parse-overrides";
13
14
  import { findPackages } from "find-packages";
@@ -196,6 +197,91 @@ function resolveRegistryUrl(packageName, registries, defaultRegistry) {
196
197
  }
197
198
  return defaultRegistry ?? null;
198
199
  }
199
- export { applyPnpmWorkspaceRegistries, detectPnpmWorkspaces, extractPnpmFilters, extractPnpmWorkspaceFile, findPnpmWorkspace, getPnpmLock, resolveRegistryUrl };
200
+ async function getConstraintFromLockFile(lockFileName) {
201
+ let constraint = null;
202
+ try {
203
+ const lockfileContent = await readLocalFile(lockFileName, "utf8");
204
+ if (!lockfileContent) {
205
+ logger.trace(`Empty pnpm lock file: ${lockFileName}`);
206
+ return null;
207
+ }
208
+ const pnpmLock = parseYaml(lockfileContent).at(-1);
209
+ if (!isNumber(pnpmLock?.lockfileVersion) && !isNumericString(pnpmLock?.lockfileVersion)) {
210
+ logger.trace(`Invalid pnpm lockfile version: ${lockFileName}`);
211
+ return null;
212
+ }
213
+ const { lowerConstraint, upperConstraint } = lockToPnpmVersionMapping.find((m) => m.lockfileVersion === pnpmLock.lockfileVersion) ?? {
214
+ lockfileVersion: 5,
215
+ lowerConstraint: ">=3",
216
+ upperConstraint: "<3.5.0"
217
+ };
218
+ constraint = lowerConstraint;
219
+ if (upperConstraint) constraint += ` ${upperConstraint}`;
220
+ } catch (err) {
221
+ logger.warn({ err }, "Error getting pnpm constraints from lock file");
222
+ }
223
+ return constraint;
224
+ }
225
+ /**
226
+ * Resolves the pnpm constraint of `pnpmLockFile` from the tool constraints config, the pnpm version of the root `package.json` which `getPackageJsonConstraint` returns, or the `lockfileVersion` of the lock file.
227
+ */
228
+ async function resolvePnpmConstraint(config, pnpmLockFile, getPackageJsonConstraint) {
229
+ return await resolveToolConstraint(config, "pnpm", async () => {
230
+ let pnpmVersion = await getPackageJsonConstraint();
231
+ if (isNullOrUndefined(pnpmVersion)) pnpmVersion = await getConstraintFromLockFile(pnpmLockFile);
232
+ return pnpmVersion;
233
+ });
234
+ }
235
+ /**
236
+ * pnpm lockfiles have corresponding version numbers called "lockfileVersion"
237
+ * each lockfileVersion can only be generated by a certain pnpm version range
238
+ * eg. lockfileVersion: 5.4 can only be generated by pnpm version >=7 && <8
239
+ * official list can be found here : https://github.com/pnpm/spec/tree/master/lockfile
240
+ * we use the mapping present below to find the compatible pnpm version range for a given lockfileVersion
241
+ *
242
+ * the various terms used in the mapping are explained below:
243
+ * lowerConstraint : lowest pnpm version that can generate the lockfileVersion
244
+ * upperConstraint : highest pnpm version that can generate the lockfileVersion
245
+ * lowerBound : highest pnpm version that is less than the lowerConstraint
246
+ * upperBound : lowest pnpm version that is greater than the upperConstraint
247
+ *
248
+ * To handle future lockfileVersions, we need to:
249
+ * 1. add a upperBound and upperConstraint to the current latest lockfileVersion
250
+ * 2. add an object for the new lockfileVersion with lowerBound and lowerConstraint
251
+ *
252
+ * lockfileVersion from v6 on are strings
253
+ */
254
+ const lockToPnpmVersionMapping = [
255
+ {
256
+ lockfileVersion: "9.0",
257
+ lowerConstraint: ">=9"
258
+ },
259
+ {
260
+ lockfileVersion: "6.0",
261
+ lowerConstraint: ">=7.24.2",
262
+ upperConstraint: "<9"
263
+ },
264
+ {
265
+ lockfileVersion: 5.4,
266
+ lowerConstraint: ">=7",
267
+ upperConstraint: "<8"
268
+ },
269
+ {
270
+ lockfileVersion: 5.3,
271
+ lowerConstraint: ">=6",
272
+ upperConstraint: "<7"
273
+ },
274
+ {
275
+ lockfileVersion: 5.2,
276
+ lowerConstraint: ">=5.10.0",
277
+ upperConstraint: "<6"
278
+ },
279
+ {
280
+ lockfileVersion: 5.1,
281
+ lowerConstraint: ">=3.5.0",
282
+ upperConstraint: "<5.9.3"
283
+ }
284
+ ];
285
+ export { applyPnpmWorkspaceRegistries, detectPnpmWorkspaces, extractPnpmFilters, extractPnpmWorkspaceFile, findPnpmWorkspace, getConstraintFromLockFile, getPnpmLock, resolvePnpmConstraint, resolveRegistryUrl };
200
286
 
201
287
  //# sourceMappingURL=pnpm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pnpm.js","names":[],"sources":["../../../../../lib/modules/manager/npm/extract/pnpm.ts"],"sourcesContent":["import { parsePkgAndParentSelector } from '@pnpm/parse-overrides';\nimport {\n isNonEmptyObject,\n isNumber,\n isObject,\n isPlainObject,\n isString,\n} from '@sindresorhus/is';\nimport { findPackages } from 'find-packages';\nimport upath from 'upath';\nimport { GlobalConfig } from '../../../../config/global.ts';\nimport { logger } from '../../../../logger/index.ts';\nimport {\n findLocalSiblingOrParent,\n getSiblingFileName,\n localPathExists,\n readLocalFile,\n} from '../../../../util/fs/index.ts';\nimport { coerceObject } from '../../../../util/object.ts';\nimport { parseSingleYaml, parseYaml } from '../../../../util/yaml.ts';\nimport { NpmDatasource } from '../../../datasource/npm/index.ts';\nimport type {\n PackageDependency,\n PackageFile,\n PackageFileContent,\n} from '../../types.ts';\nimport { pnpmWorkspaceOverrides } from '../dep-types.ts';\nimport type { PnpmDependency, PnpmLockFile } from '../post-update/types.ts';\nimport type { PnpmCatalogs, PnpmWorkspaceFile } from '../schema.ts';\nimport type { NpmManagerData } from '../types.ts';\nimport { extractCatalogDeps } from './common/catalogs.ts';\nimport { extractDependency } from './common/dependency.ts';\nimport type { Catalog, LockFile } from './types.ts';\n\nfunction isPnpmLockfile(obj: any): obj is PnpmLockFile {\n return isPlainObject(obj) && 'lockfileVersion' in obj;\n}\n\nexport async function extractPnpmFilters(\n fileName: string,\n): Promise<string[] | undefined> {\n try {\n // TODO: use schema (#9610,#22198)\n const contents = parseSingleYaml<PnpmWorkspaceFile>(\n (await readLocalFile(fileName, 'utf8'))!,\n );\n if (\n !Array.isArray(contents.packages) ||\n !contents.packages.every((item) => isString(item))\n ) {\n logger.trace(\n { fileName },\n 'Failed to find required \"packages\" array in pnpm-workspace.yaml',\n );\n return undefined;\n }\n return contents.packages;\n } catch (err) {\n logger.trace({ fileName, err }, 'Failed to parse pnpm-workspace.yaml');\n return undefined;\n }\n}\n\nexport async function findPnpmWorkspace(\n packageFile: string,\n): Promise<{ lockFilePath: string; workspaceYamlPath: string } | null> {\n // search for pnpm-workspace.yaml\n const workspaceYamlPath = await findLocalSiblingOrParent(\n packageFile,\n 'pnpm-workspace.yaml',\n );\n if (!workspaceYamlPath) {\n logger.trace(\n { packageFile },\n 'Failed to locate pnpm-workspace.yaml in a parent directory.',\n );\n return null;\n }\n\n // search for pnpm-lock.yaml next to pnpm-workspace.yaml\n const pnpmLockfilePath = getSiblingFileName(\n workspaceYamlPath,\n 'pnpm-lock.yaml',\n );\n if (!(await localPathExists(pnpmLockfilePath))) {\n logger.trace(\n { workspaceYamlPath, packageFile },\n 'Failed to find a pnpm-lock.yaml sibling for the workspace.',\n );\n return null;\n }\n\n return {\n lockFilePath: pnpmLockfilePath,\n workspaceYamlPath,\n };\n}\n\nexport async function detectPnpmWorkspaces(\n packageFiles: Partial<PackageFile<NpmManagerData>>[],\n): Promise<void> {\n logger.debug(`Detecting pnpm Workspaces`);\n const packagePathCache = new Map<string, string[] | null>();\n\n for (const p of packageFiles) {\n const { packageFile, managerData } = p;\n const pnpmLockFile = managerData?.pnpmLockFile;\n\n // check if pnpmLockFile-file has already been provided\n if (pnpmLockFile) {\n logger.trace(\n { packageFile, pnpmLockFile },\n 'Found an existing pnpm shrinkwrap file; skipping pnpm monorepo check.',\n );\n continue;\n }\n\n // search for corresponding pnpm workspace\n // TODO #22198\n const pnpmWorkspace = await findPnpmWorkspace(packageFile!);\n if (pnpmWorkspace === null) {\n continue;\n }\n const { workspaceYamlPath, lockFilePath } = pnpmWorkspace;\n\n // check if package matches workspace filter\n if (!packagePathCache.has(workspaceYamlPath)) {\n const filters = await extractPnpmFilters(workspaceYamlPath);\n // TODO: types (#22198)\n const localDir = GlobalConfig.get('localDir');\n const packages = await findPackages(\n upath.dirname(upath.join(localDir, workspaceYamlPath)),\n {\n patterns: filters,\n // Match the ignores used in @pnpm/find-workspace-packages\n ignore: ['**/node_modules/**', '**/bower_components/**'],\n },\n );\n const packagePaths = packages.map((pkg) =>\n upath.join(pkg.dir, 'package.json'),\n );\n packagePathCache.set(workspaceYamlPath, packagePaths);\n }\n const packagePaths = packagePathCache.get(workspaceYamlPath);\n\n const isPackageInWorkspace = packagePaths?.some((p) =>\n p.endsWith(packageFile!),\n );\n\n if (isPackageInWorkspace) {\n p.managerData ??= {};\n p.managerData.pnpmLockFile = lockFilePath;\n } else {\n logger.trace(\n { packageFile, workspaceYamlPath },\n `Didn't find the package in the pnpm workspace`,\n );\n }\n }\n}\n\nexport async function getPnpmLock(filePath: string): Promise<LockFile> {\n try {\n const pnpmLockRaw = await readLocalFile(filePath, 'utf8');\n if (!pnpmLockRaw) {\n throw new Error('Unable to read pnpm-lock.yaml');\n }\n\n // pnpm writes a multi-document YAML lockfile when `pnpm-workspace.yaml`\n // declares `configDependencies`; the env document (config-deps + integrity\n // metadata) is unconditionally prepended before the main lockfile, so the\n // main lockfile is always the last document.\n // https://pnpm.io/config-dependencies.\n const parsedDocs = parseYaml(pnpmLockRaw);\n const lockParsed = parsedDocs.at(-1);\n if (!isPnpmLockfile(lockParsed)) {\n throw new Error('Invalid or empty lockfile');\n }\n logger.trace({ lockParsed }, 'pnpm lockfile parsed');\n\n // field lockfileVersion is type string in lockfileVersion = 6 and type number in < 6\n const lockfileVersion: number = isNumber(lockParsed.lockfileVersion)\n ? lockParsed.lockfileVersion\n : parseFloat(lockParsed.lockfileVersion);\n\n const lockedVersions = getLockedVersions(lockParsed);\n const lockedCatalogVersions = getLockedCatalogVersions(lockParsed);\n\n return {\n lockedVersionsWithPath: lockedVersions,\n lockedVersionsWithCatalog: lockedCatalogVersions,\n lockfileVersion,\n };\n } catch (err) {\n logger.debug({ filePath, err }, 'Warning: Exception parsing pnpm lockfile');\n return { lockedVersions: {} };\n }\n}\n\nfunction getLockedCatalogVersions(\n lockParsed: PnpmLockFile,\n): Record<string, Record<string, string>> {\n const lockedVersions: Record<string, Record<string, string>> = {};\n\n if (isNonEmptyObject(lockParsed.catalogs)) {\n for (const [catalog, dependencies] of Object.entries(lockParsed.catalogs)) {\n const versions: Record<string, string> = {};\n\n for (const [dep, versionCarrier] of Object.entries(dependencies)) {\n versions[dep] = versionCarrier.version;\n }\n\n lockedVersions[catalog] = versions;\n }\n }\n\n return lockedVersions;\n}\n\nfunction getLockedVersions(\n lockParsed: PnpmLockFile,\n): Record<string, Record<string, Record<string, string>>> {\n const lockedVersions: Record<\n string,\n Record<string, Record<string, string>>\n > = {};\n\n // monorepo\n if (isNonEmptyObject(lockParsed.importers)) {\n for (const [importer, imports] of Object.entries(lockParsed.importers)) {\n lockedVersions[importer] = getLockedDependencyVersions(imports);\n }\n }\n // normal repo\n else {\n lockedVersions['.'] = getLockedDependencyVersions(lockParsed);\n }\n\n return lockedVersions;\n}\n\nfunction getLockedDependencyVersions(\n obj: PnpmLockFile | Record<string, PnpmDependency>,\n): Record<string, Record<string, string>> {\n const dependencyTypes = [\n 'dependencies',\n 'devDependencies',\n 'optionalDependencies',\n ] as const;\n\n const res: Record<string, Record<string, string>> = {};\n for (const depType of dependencyTypes) {\n res[depType] = {};\n for (const [pkgName, versionCarrier] of Object.entries(\n coerceObject(obj[depType]),\n )) {\n let version: string;\n if (isObject(versionCarrier)) {\n version = versionCarrier.version;\n } else {\n version = versionCarrier;\n }\n\n const pkgVersion = version.split('(')[0].trim();\n res[depType][pkgName] = pkgVersion;\n }\n }\n\n return res;\n}\n\nexport async function extractPnpmWorkspaceFile(\n workspaceFile: PnpmWorkspaceFile,\n packageFile: string,\n): Promise<PackageFileContent<NpmManagerData> | null> {\n logger.trace(`pnpm.extractPnpmWorkspaceFile(${packageFile})`);\n\n const pnpmCatalogs = pnpmCatalogsToArray(workspaceFile);\n\n const deps = extractCatalogDeps(pnpmCatalogs);\n\n if (workspaceFile.overrides) {\n for (const [overridesKey, overridesVal] of Object.entries(\n workspaceFile.overrides,\n )) {\n // flat syntax: `parent>parent>child`\n const packageName =\n parsePkgAndParentSelector(overridesKey).targetPkg.name;\n const depType = pnpmWorkspaceOverrides;\n deps.push({\n depName: overridesKey,\n packageName,\n depType,\n ...extractDependency(depType, packageName, overridesVal),\n });\n }\n }\n\n const { registry, registries } = workspaceFile;\n applyPnpmWorkspaceRegistries(deps, registries, registry);\n\n let pnpmLockFile;\n const filePath = getSiblingFileName(packageFile, 'pnpm-lock.yaml');\n\n if (await readLocalFile(filePath, 'utf8')) {\n pnpmLockFile = filePath;\n }\n\n return {\n deps,\n managerData: {\n pnpmLockFile,\n },\n };\n}\n\nfunction pnpmCatalogsToArray({\n catalog: defaultCatalogDeps,\n catalogs: namedCatalogs,\n}: PnpmCatalogs): Catalog[] {\n const result: Catalog[] = [];\n\n if (defaultCatalogDeps !== undefined) {\n result.push({ name: 'default', dependencies: defaultCatalogDeps });\n }\n\n if (!namedCatalogs) {\n return result;\n }\n\n for (const [name, dependencies] of Object.entries(namedCatalogs)) {\n result.push({\n name,\n dependencies,\n });\n }\n\n return result;\n}\n\nexport function applyPnpmWorkspaceRegistries(\n deps: PackageDependency[],\n registries: Record<string, string> | undefined,\n registry: string | undefined,\n): void {\n if (!(registry ?? registries)) {\n return;\n }\n for (const dep of deps) {\n const lookupName = dep.packageName ?? dep.depName;\n if (lookupName && dep.datasource === NpmDatasource.id) {\n const registryUrl = resolveRegistryUrl(lookupName, registries, registry);\n if (registryUrl) {\n dep.registryUrls = [registryUrl];\n }\n }\n }\n}\n\nexport function resolveRegistryUrl(\n packageName: string,\n registries: Record<string, string> | undefined,\n defaultRegistry: string | undefined,\n): string | null {\n if (registries) {\n for (const scope in registries) {\n // `default` is the fallback registry, not a scope\n if (scope === 'default') {\n continue;\n }\n // pnpm scope keys keep the leading `@`, e.g. `@my-org`\n if (packageName.startsWith(`${scope}/`)) {\n return registries[scope];\n }\n }\n if (registries.default) {\n return registries.default;\n }\n }\n return defaultRegistry ?? null;\n}\n"],"mappings":";;;;;;;;;;;;;;AAkCA,SAAS,eAAe,KAA+B;CACrD,OAAO,cAAc,GAAG,KAAK,qBAAqB;AACpD;AAEA,eAAsB,mBACpB,UAC+B;CAC/B,IAAI;EAEF,MAAM,WAAW,gBACd,MAAM,cAAc,UAAU,MAAM,CACvC;EACA,IACE,CAAC,MAAM,QAAQ,SAAS,QAAQ,KAChC,CAAC,SAAS,SAAS,OAAO,SAAS,SAAS,IAAI,CAAC,GACjD;GACA,OAAO,MACL,EAAE,SAAS,GACX,mEACF;GACA;EACF;EACA,OAAO,SAAS;CAClB,SAAS,KAAK;EACZ,OAAO,MAAM;GAAE;GAAU;EAAI,GAAG,qCAAqC;EACrE;CACF;AACF;AAEA,eAAsB,kBACpB,aACqE;CAErE,MAAM,oBAAoB,MAAM,yBAC9B,aACA,qBACF;CACA,IAAI,CAAC,mBAAmB;EACtB,OAAO,MACL,EAAE,YAAY,GACd,6DACF;EACA,OAAO;CACT;CAGA,MAAM,mBAAmB,mBACvB,mBACA,gBACF;CACA,IAAI,CAAE,MAAM,gBAAgB,gBAAgB,GAAI;EAC9C,OAAO,MACL;GAAE;GAAmB;EAAY,GACjC,4DACF;EACA,OAAO;CACT;CAEA,OAAO;EACL,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BACe;CACf,IAAI,YAAY;EACd,KAAK,MAAM,SAAS,YAAY;GAE9B,IAAI,UAAU,WACZ;GAGF,IAAI,YAAY,WAAW,GAAG,MAAM,EAAE,GACpC,OAAO,WAAW;EAEtB;EACA,IAAI,WAAW,SACb,OAAO,WAAW;CAEtB;CACA,OAAO,mBAAmB;AAC5B"}
1
+ {"version":3,"file":"pnpm.js","names":[],"sources":["../../../../../lib/modules/manager/npm/extract/pnpm.ts"],"sourcesContent":["import { parsePkgAndParentSelector } from '@pnpm/parse-overrides';\nimport {\n isNonEmptyObject,\n isNullOrUndefined,\n isNumber,\n isNumericString,\n isObject,\n isPlainObject,\n isString,\n} from '@sindresorhus/is';\nimport { findPackages } from 'find-packages';\nimport upath from 'upath';\nimport { GlobalConfig } from '../../../../config/global.ts';\nimport { logger } from '../../../../logger/index.ts';\nimport type { MaybePromise } from '../../../../types/index.ts';\nimport {\n findLocalSiblingOrParent,\n getSiblingFileName,\n localPathExists,\n readLocalFile,\n} from '../../../../util/fs/index.ts';\nimport { coerceObject } from '../../../../util/object.ts';\nimport { parseSingleYaml, parseYaml } from '../../../../util/yaml.ts';\nimport { NpmDatasource } from '../../../datasource/npm/index.ts';\nimport type {\n PackageDependency,\n PackageFile,\n PackageFileContent,\n ToolConstraintsConfig,\n} from '../../types.ts';\nimport { resolveToolConstraint } from '../../util.ts';\nimport { pnpmWorkspaceOverrides } from '../dep-types.ts';\nimport type { PnpmDependency, PnpmLockFile } from '../post-update/types.ts';\nimport type { PnpmCatalogs, PnpmWorkspaceFile } from '../schema.ts';\nimport type { NpmManagerData } from '../types.ts';\nimport { extractCatalogDeps } from './common/catalogs.ts';\nimport { extractDependency } from './common/dependency.ts';\nimport type { Catalog, LockFile } from './types.ts';\n\nfunction isPnpmLockfile(obj: any): obj is PnpmLockFile {\n return isPlainObject(obj) && 'lockfileVersion' in obj;\n}\n\nexport async function extractPnpmFilters(\n fileName: string,\n): Promise<string[] | undefined> {\n try {\n // TODO: use schema (#9610,#22198)\n const contents = parseSingleYaml<PnpmWorkspaceFile>(\n (await readLocalFile(fileName, 'utf8'))!,\n );\n if (\n !Array.isArray(contents.packages) ||\n !contents.packages.every((item) => isString(item))\n ) {\n logger.trace(\n { fileName },\n 'Failed to find required \"packages\" array in pnpm-workspace.yaml',\n );\n return undefined;\n }\n return contents.packages;\n } catch (err) {\n logger.trace({ fileName, err }, 'Failed to parse pnpm-workspace.yaml');\n return undefined;\n }\n}\n\nexport async function findPnpmWorkspace(\n packageFile: string,\n): Promise<{ lockFilePath: string; workspaceYamlPath: string } | null> {\n // search for pnpm-workspace.yaml\n const workspaceYamlPath = await findLocalSiblingOrParent(\n packageFile,\n 'pnpm-workspace.yaml',\n );\n if (!workspaceYamlPath) {\n logger.trace(\n { packageFile },\n 'Failed to locate pnpm-workspace.yaml in a parent directory.',\n );\n return null;\n }\n\n // search for pnpm-lock.yaml next to pnpm-workspace.yaml\n const pnpmLockfilePath = getSiblingFileName(\n workspaceYamlPath,\n 'pnpm-lock.yaml',\n );\n if (!(await localPathExists(pnpmLockfilePath))) {\n logger.trace(\n { workspaceYamlPath, packageFile },\n 'Failed to find a pnpm-lock.yaml sibling for the workspace.',\n );\n return null;\n }\n\n return {\n lockFilePath: pnpmLockfilePath,\n workspaceYamlPath,\n };\n}\n\nexport async function detectPnpmWorkspaces(\n packageFiles: Partial<PackageFile<NpmManagerData>>[],\n): Promise<void> {\n logger.debug(`Detecting pnpm Workspaces`);\n const packagePathCache = new Map<string, string[] | null>();\n\n for (const p of packageFiles) {\n const { packageFile, managerData } = p;\n const pnpmLockFile = managerData?.pnpmLockFile;\n\n // check if pnpmLockFile-file has already been provided\n if (pnpmLockFile) {\n logger.trace(\n { packageFile, pnpmLockFile },\n 'Found an existing pnpm shrinkwrap file; skipping pnpm monorepo check.',\n );\n continue;\n }\n\n // search for corresponding pnpm workspace\n // TODO #22198\n const pnpmWorkspace = await findPnpmWorkspace(packageFile!);\n if (pnpmWorkspace === null) {\n continue;\n }\n const { workspaceYamlPath, lockFilePath } = pnpmWorkspace;\n\n // check if package matches workspace filter\n if (!packagePathCache.has(workspaceYamlPath)) {\n const filters = await extractPnpmFilters(workspaceYamlPath);\n // TODO: types (#22198)\n const localDir = GlobalConfig.get('localDir');\n const packages = await findPackages(\n upath.dirname(upath.join(localDir, workspaceYamlPath)),\n {\n patterns: filters,\n // Match the ignores used in @pnpm/find-workspace-packages\n ignore: ['**/node_modules/**', '**/bower_components/**'],\n },\n );\n const packagePaths = packages.map((pkg) =>\n upath.join(pkg.dir, 'package.json'),\n );\n packagePathCache.set(workspaceYamlPath, packagePaths);\n }\n const packagePaths = packagePathCache.get(workspaceYamlPath);\n\n const isPackageInWorkspace = packagePaths?.some((p) =>\n p.endsWith(packageFile!),\n );\n\n if (isPackageInWorkspace) {\n p.managerData ??= {};\n p.managerData.pnpmLockFile = lockFilePath;\n } else {\n logger.trace(\n { packageFile, workspaceYamlPath },\n `Didn't find the package in the pnpm workspace`,\n );\n }\n }\n}\n\nexport async function getPnpmLock(filePath: string): Promise<LockFile> {\n try {\n const pnpmLockRaw = await readLocalFile(filePath, 'utf8');\n if (!pnpmLockRaw) {\n throw new Error('Unable to read pnpm-lock.yaml');\n }\n\n // pnpm writes a multi-document YAML lockfile when `pnpm-workspace.yaml`\n // declares `configDependencies`; the env document (config-deps + integrity\n // metadata) is unconditionally prepended before the main lockfile, so the\n // main lockfile is always the last document.\n // https://pnpm.io/config-dependencies.\n const parsedDocs = parseYaml(pnpmLockRaw);\n const lockParsed = parsedDocs.at(-1);\n if (!isPnpmLockfile(lockParsed)) {\n throw new Error('Invalid or empty lockfile');\n }\n logger.trace({ lockParsed }, 'pnpm lockfile parsed');\n\n // field lockfileVersion is type string in lockfileVersion = 6 and type number in < 6\n const lockfileVersion: number = isNumber(lockParsed.lockfileVersion)\n ? lockParsed.lockfileVersion\n : parseFloat(lockParsed.lockfileVersion);\n\n const lockedVersions = getLockedVersions(lockParsed);\n const lockedCatalogVersions = getLockedCatalogVersions(lockParsed);\n\n return {\n lockedVersionsWithPath: lockedVersions,\n lockedVersionsWithCatalog: lockedCatalogVersions,\n lockfileVersion,\n };\n } catch (err) {\n logger.debug({ filePath, err }, 'Warning: Exception parsing pnpm lockfile');\n return { lockedVersions: {} };\n }\n}\n\nfunction getLockedCatalogVersions(\n lockParsed: PnpmLockFile,\n): Record<string, Record<string, string>> {\n const lockedVersions: Record<string, Record<string, string>> = {};\n\n if (isNonEmptyObject(lockParsed.catalogs)) {\n for (const [catalog, dependencies] of Object.entries(lockParsed.catalogs)) {\n const versions: Record<string, string> = {};\n\n for (const [dep, versionCarrier] of Object.entries(dependencies)) {\n versions[dep] = versionCarrier.version;\n }\n\n lockedVersions[catalog] = versions;\n }\n }\n\n return lockedVersions;\n}\n\nfunction getLockedVersions(\n lockParsed: PnpmLockFile,\n): Record<string, Record<string, Record<string, string>>> {\n const lockedVersions: Record<\n string,\n Record<string, Record<string, string>>\n > = {};\n\n // monorepo\n if (isNonEmptyObject(lockParsed.importers)) {\n for (const [importer, imports] of Object.entries(lockParsed.importers)) {\n lockedVersions[importer] = getLockedDependencyVersions(imports);\n }\n }\n // normal repo\n else {\n lockedVersions['.'] = getLockedDependencyVersions(lockParsed);\n }\n\n return lockedVersions;\n}\n\nfunction getLockedDependencyVersions(\n obj: PnpmLockFile | Record<string, PnpmDependency>,\n): Record<string, Record<string, string>> {\n const dependencyTypes = [\n 'dependencies',\n 'devDependencies',\n 'optionalDependencies',\n ] as const;\n\n const res: Record<string, Record<string, string>> = {};\n for (const depType of dependencyTypes) {\n res[depType] = {};\n for (const [pkgName, versionCarrier] of Object.entries(\n coerceObject(obj[depType]),\n )) {\n let version: string;\n if (isObject(versionCarrier)) {\n version = versionCarrier.version;\n } else {\n version = versionCarrier;\n }\n\n const pkgVersion = version.split('(')[0].trim();\n res[depType][pkgName] = pkgVersion;\n }\n }\n\n return res;\n}\n\nexport async function extractPnpmWorkspaceFile(\n workspaceFile: PnpmWorkspaceFile,\n packageFile: string,\n): Promise<PackageFileContent<NpmManagerData> | null> {\n logger.trace(`pnpm.extractPnpmWorkspaceFile(${packageFile})`);\n\n const pnpmCatalogs = pnpmCatalogsToArray(workspaceFile);\n\n const deps = extractCatalogDeps(pnpmCatalogs);\n\n if (workspaceFile.overrides) {\n for (const [overridesKey, overridesVal] of Object.entries(\n workspaceFile.overrides,\n )) {\n // flat syntax: `parent>parent>child`\n const packageName =\n parsePkgAndParentSelector(overridesKey).targetPkg.name;\n const depType = pnpmWorkspaceOverrides;\n deps.push({\n depName: overridesKey,\n packageName,\n depType,\n ...extractDependency(depType, packageName, overridesVal),\n });\n }\n }\n\n const { registry, registries } = workspaceFile;\n applyPnpmWorkspaceRegistries(deps, registries, registry);\n\n let pnpmLockFile;\n const filePath = getSiblingFileName(packageFile, 'pnpm-lock.yaml');\n\n if (await readLocalFile(filePath, 'utf8')) {\n pnpmLockFile = filePath;\n }\n\n return {\n deps,\n managerData: {\n pnpmLockFile,\n },\n };\n}\n\nfunction pnpmCatalogsToArray({\n catalog: defaultCatalogDeps,\n catalogs: namedCatalogs,\n}: PnpmCatalogs): Catalog[] {\n const result: Catalog[] = [];\n\n if (defaultCatalogDeps !== undefined) {\n result.push({ name: 'default', dependencies: defaultCatalogDeps });\n }\n\n if (!namedCatalogs) {\n return result;\n }\n\n for (const [name, dependencies] of Object.entries(namedCatalogs)) {\n result.push({\n name,\n dependencies,\n });\n }\n\n return result;\n}\n\nexport function applyPnpmWorkspaceRegistries(\n deps: PackageDependency[],\n registries: Record<string, string> | undefined,\n registry: string | undefined,\n): void {\n if (!(registry ?? registries)) {\n return;\n }\n for (const dep of deps) {\n const lookupName = dep.packageName ?? dep.depName;\n if (lookupName && dep.datasource === NpmDatasource.id) {\n const registryUrl = resolveRegistryUrl(lookupName, registries, registry);\n if (registryUrl) {\n dep.registryUrls = [registryUrl];\n }\n }\n }\n}\n\nexport function resolveRegistryUrl(\n packageName: string,\n registries: Record<string, string> | undefined,\n defaultRegistry: string | undefined,\n): string | null {\n if (registries) {\n for (const scope in registries) {\n // `default` is the fallback registry, not a scope\n if (scope === 'default') {\n continue;\n }\n // pnpm scope keys keep the leading `@`, e.g. `@my-org`\n if (packageName.startsWith(`${scope}/`)) {\n return registries[scope];\n }\n }\n if (registries.default) {\n return registries.default;\n }\n }\n return defaultRegistry ?? null;\n}\n\nexport async function getConstraintFromLockFile(\n lockFileName: string,\n): Promise<string | null> {\n let constraint: string | null = null;\n try {\n const lockfileContent = await readLocalFile(lockFileName, 'utf8');\n if (!lockfileContent) {\n logger.trace(`Empty pnpm lock file: ${lockFileName}`);\n return null;\n }\n // the main lockfile is the last document, see `getPnpmLock`\n const pnpmLock = parseYaml(lockfileContent).at(-1) as\n PnpmLockFile | undefined;\n if (\n !isNumber(pnpmLock?.lockfileVersion) &&\n !isNumericString(pnpmLock?.lockfileVersion)\n ) {\n logger.trace(`Invalid pnpm lockfile version: ${lockFileName}`);\n return null;\n }\n // find matching lockfileVersion and use its constraints\n // if no match found use lockfileVersion 5\n // lockfileVersion 5 is the minimum version required to generate the pnpm-lock.yaml file\n const { lowerConstraint, upperConstraint } = lockToPnpmVersionMapping.find(\n (m) => m.lockfileVersion === pnpmLock.lockfileVersion,\n ) ?? {\n lockfileVersion: 5.0,\n lowerConstraint: '>=3',\n upperConstraint: '<3.5.0',\n };\n constraint = lowerConstraint;\n if (upperConstraint) {\n constraint += ` ${upperConstraint}`;\n }\n } catch (err) {\n logger.warn({ err }, 'Error getting pnpm constraints from lock file');\n }\n return constraint;\n}\n\n/**\n * Resolves the pnpm constraint of `pnpmLockFile` from the tool constraints config, the pnpm version of the root `package.json` which `getPackageJsonConstraint` returns, or the `lockfileVersion` of the lock file.\n */\nexport async function resolvePnpmConstraint(\n config: ToolConstraintsConfig,\n pnpmLockFile: string,\n getPackageJsonConstraint: () => MaybePromise<string | null | undefined>,\n): Promise<string | undefined> {\n return await resolveToolConstraint(config, 'pnpm', async () => {\n let pnpmVersion = await getPackageJsonConstraint();\n if (isNullOrUndefined(pnpmVersion)) {\n pnpmVersion = await getConstraintFromLockFile(pnpmLockFile);\n }\n return pnpmVersion;\n });\n}\n\n/**\n * pnpm lockfiles have corresponding version numbers called \"lockfileVersion\"\n * each lockfileVersion can only be generated by a certain pnpm version range\n * eg. lockfileVersion: 5.4 can only be generated by pnpm version >=7 && <8\n * official list can be found here : https://github.com/pnpm/spec/tree/master/lockfile\n * we use the mapping present below to find the compatible pnpm version range for a given lockfileVersion\n *\n * the various terms used in the mapping are explained below:\n * lowerConstraint : lowest pnpm version that can generate the lockfileVersion\n * upperConstraint : highest pnpm version that can generate the lockfileVersion\n * lowerBound : highest pnpm version that is less than the lowerConstraint\n * upperBound : lowest pnpm version that is greater than the upperConstraint\n *\n * To handle future lockfileVersions, we need to:\n * 1. add a upperBound and upperConstraint to the current latest lockfileVersion\n * 2. add an object for the new lockfileVersion with lowerBound and lowerConstraint\n *\n * lockfileVersion from v6 on are strings\n */\nconst lockToPnpmVersionMapping: LockToPnpmVersionMapping[] = [\n { lockfileVersion: '9.0', lowerConstraint: '>=9' },\n {\n lockfileVersion: '6.0',\n lowerConstraint: '>=7.24.2',\n upperConstraint: '<9',\n },\n {\n lockfileVersion: 5.4,\n lowerConstraint: '>=7',\n upperConstraint: '<8',\n },\n {\n lockfileVersion: 5.3,\n lowerConstraint: '>=6',\n upperConstraint: '<7',\n },\n {\n lockfileVersion: 5.2,\n lowerConstraint: '>=5.10.0',\n upperConstraint: '<6',\n },\n {\n lockfileVersion: 5.1,\n lowerConstraint: '>=3.5.0',\n upperConstraint: '<5.9.3',\n },\n];\n\ninterface LockToPnpmVersionMapping {\n lockfileVersion: string | number;\n lowerConstraint: string;\n upperConstraint?: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAuCA,SAAS,eAAe,KAA+B;CACrD,OAAO,cAAc,GAAG,KAAK,qBAAqB;AACpD;AAEA,eAAsB,mBACpB,UAC+B;CAC/B,IAAI;EAEF,MAAM,WAAW,gBACd,MAAM,cAAc,UAAU,MAAM,CACv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,iBAAiB;GACjB,iBAAiB;GACjB,iBAAiB;EACnB;EACA,aAAa;EACb,IAAI,iBACF,cAAc,IAAI;CAEtB,SAAS,KAAK;EACZ,OAAO,KAAK,EAAE,IAAI,GAAG,+CAA+C;CACtE;CACA,OAAO;AACT;;;;AAKA,eAAsB,sBACpB,QACA,cACA,0BAC6B;CAC7B,OAAO,MAAM,sBAAsB,QAAQ,QAAQ,YAAY;EAC7D,IAAI,cAAc,MAAM,yBAAyB;EACjD,IAAI,kBAAkB,WAAW,GAC/B,cAAc,MAAM,0BAA0B,YAAY;EAE5D,OAAO;CACT,CAAC;AACH;;;;;;;;;;;;;;;;;;;;AAqBA,MAAM,2BAAuD;CAC3D;EAAE,iBAAiB;EAAO,iBAAiB;CAAM;CACjD;EACE,iBAAiB;EACjB,iBAAiB;EACjB,iBAAiB;CACnB;CACA;EACE,iBAAiB;EACjB,iBAAiB;EACjB,iBAAiB;CACnB;CACA;EACE,iBAAiB;EACjB,iBAAiB;EACjB,iBAAiB;CACnB;CACA;EACE,iBAAiB;EACjB,iBAAiB;EACjB,iBAAiB;CACnB;CACA;EACE,iBAAiB;EACjB,iBAAiB;EACjB,iBAAiB;CACnB;AACF"}
@@ -1,9 +1,15 @@
1
+ import { setNpmrcMinimumReleaseAge } from "../npmrc.js";
2
+ import { setPnpmMinimumReleaseAge } from "../pnpm-minimum-release-age.js";
3
+ import { setYarnMinimumReleaseAge } from "../yarn-minimum-release-age.js";
1
4
  import { getLockedVersions } from "./locked-versions.js";
2
5
  import { detectMonorepos } from "./monorepo.js";
3
6
  // lib/modules/manager/npm/extract/post/index.ts
4
- async function postExtract(packageFiles) {
7
+ async function postExtract(packageFiles, config) {
5
8
  await detectMonorepos(packageFiles);
6
9
  await getLockedVersions(packageFiles);
10
+ setNpmrcMinimumReleaseAge(packageFiles);
11
+ await setPnpmMinimumReleaseAge(packageFiles, config);
12
+ await setYarnMinimumReleaseAge(packageFiles, config);
7
13
  }
8
14
  export { postExtract };
9
15
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../../../../lib/modules/manager/npm/extract/post/index.ts"],"sourcesContent":["import type { PackageFile } from '../../../types.ts';\nimport type { NpmManagerData } from '../../types.ts';\nimport { getLockedVersions } from './locked-versions.ts';\nimport { detectMonorepos } from './monorepo.ts';\n\nexport async function postExtract(\n packageFiles: PackageFile<NpmManagerData>[],\n): Promise<void> {\n await detectMonorepos(packageFiles);\n await getLockedVersions(packageFiles);\n}\n"],"mappings":";;;AAKA,eAAsB,YACpB,cACe;CACf,MAAM,gBAAgB,YAAY;CAClC,MAAM,kBAAkB,YAAY;AACtC"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../../../lib/modules/manager/npm/extract/post/index.ts"],"sourcesContent":["import type { ExtractConfig, PackageFile } from '../../../types.ts';\nimport type { NpmManagerData } from '../../types.ts';\nimport { setNpmrcMinimumReleaseAge } from '../npmrc.ts';\nimport { setPnpmMinimumReleaseAge } from '../pnpm-minimum-release-age.ts';\nimport { setYarnMinimumReleaseAge } from '../yarn-minimum-release-age.ts';\nimport { getLockedVersions } from './locked-versions.ts';\nimport { detectMonorepos } from './monorepo.ts';\n\nexport async function postExtract(\n packageFiles: PackageFile<NpmManagerData>[],\n config: ExtractConfig,\n): Promise<void> {\n await detectMonorepos(packageFiles);\n await getLockedVersions(packageFiles);\n setNpmrcMinimumReleaseAge(packageFiles);\n await setPnpmMinimumReleaseAge(packageFiles, config);\n await setYarnMinimumReleaseAge(packageFiles, config);\n}\n"],"mappings":";;;;;;AAQA,eAAsB,YACpB,cACA,QACe;CACf,MAAM,gBAAgB,YAAY;CAClC,MAAM,kBAAkB,YAAY;CACpC,0BAA0B,YAAY;CACtC,MAAM,yBAAyB,cAAc,MAAM;CACnD,MAAM,yBAAyB,cAAc,MAAM;AACrD"}
@@ -1,5 +1,7 @@
1
1
  import { logger } from "../../../../logger/index.js";
2
+ import { coerceArray } from "../../../../util/array.js";
2
3
  import { minimatch } from "../../../../util/minimatch.js";
4
+ import upath from "upath";
3
5
  // lib/modules/manager/npm/extract/utils.ts
4
6
  function matchesAnyPattern(val, patterns) {
5
7
  const res = patterns.some((pattern) => pattern === `${val}/` || minimatch(pattern, { dot: true }).match(val));
@@ -10,6 +12,28 @@ function matchesAnyPattern(val, patterns) {
10
12
  }, `matchesAnyPattern`);
11
13
  return res;
12
14
  }
13
- export { matchesAnyPattern };
15
+ /**
16
+ * Groups `packageFiles` by the lock file in `managerData[lockFileKey]`, with the root `package.json` of each lock file.
17
+ */
18
+ function groupByLockFile(packageFiles, lockFileKey) {
19
+ const groups = /* @__PURE__ */ new Map();
20
+ for (const packageFile of packageFiles) {
21
+ const lockFile = packageFile.managerData?.[lockFileKey];
22
+ if (lockFile) {
23
+ const group = coerceArray(groups.get(lockFile));
24
+ group.push(packageFile);
25
+ groups.set(lockFile, group);
26
+ }
27
+ }
28
+ return [...groups].map(([lockFile, lockFilePackageFiles]) => {
29
+ const rootPackageFile = upath.join(upath.dirname(lockFile), "package.json");
30
+ return {
31
+ lockFile,
32
+ packageFiles: lockFilePackageFiles,
33
+ root: lockFilePackageFiles.find((packageFile) => packageFile.packageFile === rootPackageFile) ?? lockFilePackageFiles.find((packageFile) => packageFile.packageFile?.endsWith("package.json"))
34
+ };
35
+ });
36
+ }
37
+ export { groupByLockFile, matchesAnyPattern };
14
38
 
15
39
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":[],"sources":["../../../../../lib/modules/manager/npm/extract/utils.ts"],"sourcesContent":["import { logger } from '../../../../logger/index.ts';\nimport { minimatch } from '../../../../util/minimatch.ts';\n\nexport function matchesAnyPattern(val: string, patterns: string[]): boolean {\n const res = patterns.some(\n (pattern) =>\n pattern === `${val}/` || minimatch(pattern, { dot: true }).match(val),\n );\n logger.trace({ val, patterns, res }, `matchesAnyPattern`);\n return res;\n}\n"],"mappings":";;;AAGA,SAAgB,kBAAkB,KAAa,UAA6B;CAC1E,MAAM,MAAM,SAAS,MAClB,YACC,YAAY,GAAG,IAAI,MAAM,UAAU,SAAS,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,MAAM,GAAG,CACxE;CACA,OAAO,MAAM;EAAE;EAAK;EAAU;CAAI,GAAG,mBAAmB;CACxD,OAAO;AACT"}
1
+ {"version":3,"file":"utils.js","names":[],"sources":["../../../../../lib/modules/manager/npm/extract/utils.ts"],"sourcesContent":["import upath from 'upath';\nimport { logger } from '../../../../logger/index.ts';\nimport { coerceArray } from '../../../../util/array.ts';\nimport { minimatch } from '../../../../util/minimatch.ts';\nimport type { PackageFile } from '../../types.ts';\nimport type { NpmManagerData } from '../types.ts';\nimport type { LockFilePackageFiles } from './types.ts';\n\nexport function matchesAnyPattern(val: string, patterns: string[]): boolean {\n const res = patterns.some(\n (pattern) =>\n pattern === `${val}/` || minimatch(pattern, { dot: true }).match(val),\n );\n logger.trace({ val, patterns, res }, `matchesAnyPattern`);\n return res;\n}\n\n/**\n * Groups `packageFiles` by the lock file in `managerData[lockFileKey]`, with the root `package.json` of each lock file.\n */\nexport function groupByLockFile<T extends Partial<PackageFile<NpmManagerData>>>(\n packageFiles: T[],\n lockFileKey: 'pnpmLockFile' | 'yarnLock',\n): LockFilePackageFiles<T>[] {\n const groups = new Map<string, T[]>();\n for (const packageFile of packageFiles) {\n const lockFile = packageFile.managerData?.[lockFileKey];\n if (lockFile) {\n const group = coerceArray(groups.get(lockFile));\n group.push(packageFile);\n groups.set(lockFile, group);\n }\n }\n return [...groups].map(([lockFile, lockFilePackageFiles]) => {\n const rootPackageFile = upath.join(upath.dirname(lockFile), 'package.json');\n const root =\n lockFilePackageFiles.find(\n (packageFile) => packageFile.packageFile === rootPackageFile,\n ) ??\n lockFilePackageFiles.find((packageFile) =>\n packageFile.packageFile?.endsWith('package.json'),\n );\n return { lockFile, packageFiles: lockFilePackageFiles, root };\n });\n}\n"],"mappings":";;;;;AAQA,SAAgB,kBAAkB,KAAa,UAA6B;CAC1E,MAAM,MAAM,SAAS,MAClB,YACC,YAAY,GAAG,IAAI,MAAM,UAAU,SAAS,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,MAAM,GAAG,CACxE;CACA,OAAO,MAAM;EAAE;EAAK;EAAU;CAAI,GAAG,mBAAmB;CACxD,OAAO;AACT;;;;AAKA,SAAgB,gBACd,cACA,aAC2B;CAC3B,MAAM,yBAAS,IAAI,IAAiB;CACpC,KAAK,MAAM,eAAe,cAAc;EACtC,MAAM,WAAW,YAAY,cAAc;EAC3C,IAAI,UAAU;GACZ,MAAM,QAAQ,YAAY,OAAO,IAAI,QAAQ,CAAC;GAC9C,MAAM,KAAK,WAAW;GACtB,OAAO,IAAI,UAAU,KAAK;EAC5B;CACF;CACA,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC,KAAK,CAAC,UAAU,0BAA0B;EAC3D,MAAM,kBAAkB,MAAM,KAAK,MAAM,QAAQ,QAAQ,GAAG,cAAc;EAQ1E,OAAO;GAAE;GAAU,cAAc;GAAsB,MANrD,qBAAqB,MAClB,gBAAgB,YAAY,gBAAgB,eAC/C,KACA,qBAAqB,MAAM,gBACzB,YAAY,aAAa,SAAS,cAAc,CAClD;EAC0D;CAC9D,CAAC;AACH"}
@@ -0,0 +1,181 @@
1
+ import { logger } from "../../../../logger/index.js";
2
+ import { coerceArray } from "../../../../util/array.js";
3
+ import { findLocalSiblingOrParent, readLocalFile } from "../../../../util/fs/index.js";
4
+ import { coerceObject } from "../../../../util/object.js";
5
+ import { regEx } from "../../../../util/regex.js";
6
+ import { matchRegexOrGlobList } from "../../../../util/string-match.js";
7
+ import { NpmDatasource } from "../../../datasource/npm/index.js";
8
+ import { intersectsWith } from "../../../versioning/common.js";
9
+ import { api } from "../../../versioning/npm/index.js";
10
+ import { resolveToolConstraint } from "../../util.js";
11
+ import { DAY_MS, MINUTE_MS } from "../constants.js";
12
+ import { YarnrcMinimalAgeGate } from "../schema.js";
13
+ import { groupByLockFile } from "./utils.js";
14
+ import { isNumber, isString } from "@sindresorhus/is";
15
+ import semver from "semver";
16
+ // lib/modules/manager/npm/extract/yarn-minimum-release-age.ts
17
+ const yarnDefaultMinimalAgeGateRange = ">=4.15.0";
18
+ const yarnDefaultMinimalAgeGateMinutes = 1440;
19
+ const yarnScopeMinimalAgeGateRange = ">=4.17.0";
20
+ const durationUnitMs = {
21
+ ms: 1,
22
+ s: 1e3,
23
+ m: MINUTE_MS,
24
+ h: 60 * MINUTE_MS,
25
+ d: DAY_MS,
26
+ w: 7 * DAY_MS
27
+ };
28
+ const durationRegex = regEx(/^(?<num>\d*\.?\d+)(?<unit>ms|s|m|h|d|w)?$/);
29
+ const descriptorRegex = regEx(/^(?:@(?<scope>[^/]+?)\/)?(?<name>[^@/]+?)(?:@(?<range>.+))?$/);
30
+ /**
31
+ * Parses a Yarn duration like `3d` to minutes like Yarn, where a number without a unit is in minutes, or returns `null` for a value which Yarn rejects.
32
+ */
33
+ function parseYarnDurationMinutes(value) {
34
+ const text = isNumber(value) ? String(value) : value;
35
+ if (!isString(text)) return null;
36
+ const match = durationRegex.exec(text)?.groups;
37
+ if (!match) return null;
38
+ const num = parseFloat(match.num);
39
+ if (!match.unit) return num;
40
+ return num * durationUnitMs[match.unit] / MINUTE_MS;
41
+ }
42
+ function getMinutes(value, setting, yarnrcFile) {
43
+ if (value === void 0) return null;
44
+ const minutes = parseYarnDurationMinutes(value);
45
+ if (minutes === null) logger.debug(`Invalid ${setting} ${JSON.stringify(value)} in ${yarnrcFile}, ignoring`);
46
+ return minutes;
47
+ }
48
+ /**
49
+ * Reads the minimum release age settings of the nearest `.yarnrc.yml` in the directory of a Yarn lock file or a parent directory, and ignores invalid ages.
50
+ */
51
+ async function readYarnrcMinimalAgeGate(yarnLock) {
52
+ const yarnrcFile = await findLocalSiblingOrParent(yarnLock, ".yarnrc.yml");
53
+ if (!yarnrcFile) return {};
54
+ const content = await readLocalFile(yarnrcFile, "utf8");
55
+ if (!content) return {};
56
+ const parsed = YarnrcMinimalAgeGate.safeParse(content);
57
+ if (!parsed.success) {
58
+ logger.debug({
59
+ yarnrcFile,
60
+ err: parsed.error
61
+ }, "Failed to parse the minimum release age of .yarnrc.yml");
62
+ return {};
63
+ }
64
+ const { npmMinimalAgeGate, npmPreapprovedPackages, npmScopes } = parsed.data;
65
+ const settings = {};
66
+ const minutes = getMinutes(npmMinimalAgeGate, "npmMinimalAgeGate", yarnrcFile);
67
+ if (minutes !== null) settings.npmMinimalAgeGate = minutes;
68
+ if (npmScopes) {
69
+ settings.npmScopes = {};
70
+ for (const [scope, scopeConfig] of Object.entries(npmScopes)) settings.npmScopes[scope] = getMinutes(scopeConfig.npmMinimalAgeGate, `npmScopes.${scope}.npmMinimalAgeGate`, yarnrcFile);
71
+ }
72
+ if (npmPreapprovedPackages) settings.npmPreapprovedPackages = npmPreapprovedPackages;
73
+ return settings;
74
+ }
75
+ /**
76
+ * Whether Renovate runs Yarn 1 for the Yarn constraint, which is the case for a missing constraint, a constraint which is no valid range, or one which allows Yarn 1.
77
+ */
78
+ function isYarn1Constraint(yarnConstraint) {
79
+ const range = semver.validRange(yarnConstraint);
80
+ const minVersion = range && semver.minVersion(range);
81
+ return !minVersion || minVersion.major === 1;
82
+ }
83
+ /**
84
+ * The global `npmMinimalAgeGate` in minutes which Yarn configures itself, or with `includeDefault` the Yarn default if the `.yarnrc.yml` does not set it.
85
+ */
86
+ function getYarnMinimalAgeGateMinutes(settings, includeDefault) {
87
+ if (settings.npmMinimalAgeGate !== void 0) return settings.npmMinimalAgeGate;
88
+ return includeDefault ? yarnDefaultMinimalAgeGateMinutes : void 0;
89
+ }
90
+ /**
91
+ * Returns the `npmMinimalAgeGate` in minutes of each scope of `npmScopes`, which Yarn applies to the packages of that scope instead of the global value, with the Yarn default for a scope without its own value if `includeDefault` is set.
92
+ */
93
+ function getYarnScopeMinimalAgeGateMinutes(settings, includeDefault) {
94
+ const result = {};
95
+ for (const [scope, minutes] of Object.entries(coerceObject(settings.npmScopes))) if (minutes !== null) result[scope] = minutes;
96
+ else if (includeDefault) result[scope] = yarnDefaultMinimalAgeGateMinutes;
97
+ return result;
98
+ }
99
+ /**
100
+ * Parses the `npmPreapprovedPackages` entries of a `.yarnrc.yml` like Yarn, which accepts a package name or glob, where `*` does not match `/` as in `matchPackageNames`, optionally with a semver range like `foo@^1.0.0`.
101
+ */
102
+ function parseYarnPreapprovedPackages(entries) {
103
+ const result = [];
104
+ for (const entry of coerceArray(entries)) {
105
+ const match = descriptorRegex.exec(entry)?.groups;
106
+ if (!match) {
107
+ logger.debug(`Invalid npmPreapprovedPackages entry ${entry}, ignoring`);
108
+ continue;
109
+ }
110
+ const packageName = match.scope ? `@${match.scope}/${match.name}` : match.name;
111
+ result.push(match.range ? {
112
+ packageName,
113
+ range: match.range
114
+ } : { packageName });
115
+ }
116
+ return result;
117
+ }
118
+ function isPreapprovedBy(entry, packageName, version) {
119
+ if (!matchRegexOrGlobList(packageName, [entry.packageName])) return false;
120
+ if (!entry.range) return true;
121
+ return !!version && semver.satisfies(version, entry.range);
122
+ }
123
+ /**
124
+ * Whether `npmPreapprovedPackages` exempts `version` of `packageName` from the Yarn minimum release age.
125
+ */
126
+ function isYarnPreapproved(preapproved, packageName, version) {
127
+ return preapproved.some((entry) => isPreapprovedBy(entry, packageName, version));
128
+ }
129
+ /**
130
+ * Returns the `packageRules` for a Yarn minimum release age of npm packages, with the age of `npmScopes` for the packages of a scope, and with `npmPreapprovedPackages` entries without a range lifting it for the packages they name.
131
+ */
132
+ function getYarnMinimumReleaseAgeRules(minutes, scopeMinutes, preapproved) {
133
+ const scopes = Object.entries(scopeMinutes);
134
+ if (!minutes && !scopes.some(([, scopeAge]) => scopeAge)) return [];
135
+ const rules = [];
136
+ if (minutes) rules.push({
137
+ matchDatasources: [NpmDatasource.id],
138
+ minimumReleaseAgeExtracted: `${minutes} minutes`
139
+ });
140
+ for (const [scope, scopeAge] of scopes) rules.push({
141
+ matchDatasources: [NpmDatasource.id],
142
+ matchPackageNames: [`@${scope}/**`],
143
+ minimumReleaseAgeExtracted: scopeAge ? `${scopeAge} minutes` : null
144
+ });
145
+ for (const entry of preapproved) if (!entry.range) rules.push({
146
+ matchDatasources: [NpmDatasource.id],
147
+ matchPackageNames: [entry.packageName],
148
+ minimumReleaseAgeExtracted: null
149
+ });
150
+ return rules;
151
+ }
152
+ /**
153
+ * Adds `packageRules` with the Yarn minimum release age to the package files of each Yarn lock file, from the nearest `.yarnrc.yml` in its directory or a parent directory or the Yarn default, and keeps the settings of the lock file in the `managerData` of each of its package files, except for Yarn 1, which has no minimum release age.
154
+ */
155
+ async function setYarnMinimumReleaseAge(packageFiles, config) {
156
+ for (const { lockFile: yarnLock, packageFiles: lockFilePackageFiles, root } of groupByLockFile(packageFiles, "yarnLock")) {
157
+ const yarnConstraint = await resolveToolConstraint(config, "yarn", () => root?.extractedConstraints?.yarn);
158
+ if (isYarn1Constraint(yarnConstraint)) continue;
159
+ const settings = await readYarnrcMinimalAgeGate(yarnLock);
160
+ const { npmMinimalAgeGate, npmScopes } = settings;
161
+ const hasNpmPreapprovedPackages = !!settings.npmPreapprovedPackages?.length;
162
+ for (const packageFile of lockFilePackageFiles) packageFile.managerData.yarnMinimalAgeGate = {
163
+ npmMinimalAgeGate,
164
+ npmScopes,
165
+ ...hasNpmPreapprovedPackages && { hasNpmPreapprovedPackages },
166
+ yarnConstraint
167
+ };
168
+ const minutes = getYarnMinimalAgeGateMinutes(settings, intersectsWith(api, yarnConstraint, yarnDefaultMinimalAgeGateRange));
169
+ const scopeMinutes = getYarnScopeMinimalAgeGateMinutes(settings, intersectsWith(api, yarnConstraint, yarnScopeMinimalAgeGateRange));
170
+ const rules = getYarnMinimumReleaseAgeRules(minutes, scopeMinutes, parseYarnPreapprovedPackages(settings.npmPreapprovedPackages));
171
+ if (!rules.length) continue;
172
+ const globalAge = minutes ? `${minutes} minutes` : "none";
173
+ const scopeAges = Object.entries(scopeMinutes).map(([scope, scopeAge]) => `@${scope} ${scopeAge} minutes`);
174
+ const scopeAgesText = scopeAges.length ? `, scopes ${scopeAges.join(", ")}` : "";
175
+ logger.debug(`Found Yarn minimum release age for ${yarnLock}: global ${globalAge}${scopeAgesText}`);
176
+ for (const packageFile of lockFilePackageFiles) packageFile.packageRules = [...coerceArray(packageFile.packageRules), ...rules];
177
+ }
178
+ }
179
+ export { getYarnMinimalAgeGateMinutes, getYarnMinimumReleaseAgeRules, getYarnScopeMinimalAgeGateMinutes, isYarn1Constraint, isYarnPreapproved, parseYarnDurationMinutes, parseYarnPreapprovedPackages, readYarnrcMinimalAgeGate, setYarnMinimumReleaseAge, yarnDefaultMinimalAgeGateMinutes, yarnDefaultMinimalAgeGateRange, yarnScopeMinimalAgeGateRange };
180
+
181
+ //# sourceMappingURL=yarn-minimum-release-age.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yarn-minimum-release-age.js","names":["npmVersioning"],"sources":["../../../../../lib/modules/manager/npm/extract/yarn-minimum-release-age.ts"],"sourcesContent":["import { isNumber, isString } from '@sindresorhus/is';\nimport semver from 'semver';\nimport { logger } from '../../../../logger/index.ts';\nimport { coerceArray } from '../../../../util/array.ts';\nimport {\n findLocalSiblingOrParent,\n readLocalFile,\n} from '../../../../util/fs/index.ts';\nimport { coerceObject } from '../../../../util/object.ts';\nimport { regEx } from '../../../../util/regex.ts';\nimport { matchRegexOrGlobList } from '../../../../util/string-match.ts';\nimport { NpmDatasource } from '../../../datasource/npm/index.ts';\nimport { intersectsWith } from '../../../versioning/common.ts';\nimport { api as npmVersioning } from '../../../versioning/npm/index.ts';\nimport type {\n ExtractConfig,\n ExtractedPackageRule,\n PackageFile,\n} from '../../types.ts';\nimport { resolveToolConstraint } from '../../util.ts';\nimport { DAY_MS, MINUTE_MS } from '../constants.ts';\nimport { YarnrcMinimalAgeGate } from '../schema.ts';\nimport type { NpmManagerData } from '../types.ts';\nimport type {\n YarnMinimalAgeGateSettings,\n YarnPreapprovedPackage,\n YarnrcMinimalAgeGateSettings,\n} from './types.ts';\nimport { groupByLockFile } from './utils.ts';\n\n// Yarn defaults `npmMinimalAgeGate` to 1 day since v4.15.0\nexport const yarnDefaultMinimalAgeGateRange = '>=4.15.0';\nexport const yarnDefaultMinimalAgeGateMinutes = 1440;\n\n// Yarn reads `npmMinimalAgeGate` per scope of `npmScopes` since v4.17.0, and\n// applies the default of 1 day to each listed scope without its own value\nexport const yarnScopeMinimalAgeGateRange = '>=4.17.0';\n\nconst durationUnitMs: Record<string, number> = {\n ms: 1,\n s: 1000,\n m: MINUTE_MS,\n h: 60 * MINUTE_MS,\n d: DAY_MS,\n w: 7 * DAY_MS,\n};\nconst durationRegex = regEx(/^(?<num>\\d*\\.?\\d+)(?<unit>ms|s|m|h|d|w)?$/);\n\n// the descriptor syntax of Yarn, like `foo`, `@scope/*` or `foo@^1.0.0`\nconst descriptorRegex = regEx(\n /^(?:@(?<scope>[^/]+?)\\/)?(?<name>[^@/]+?)(?:@(?<range>.+))?$/,\n);\n\n/**\n * Parses a Yarn duration like `3d` to minutes like Yarn, where a number without a unit is in minutes, or returns `null` for a value which Yarn rejects.\n */\nexport function parseYarnDurationMinutes(value: unknown): number | null {\n // Yarn reads every value of the `.yarnrc.yml` as a string\n const text = isNumber(value) ? String(value) : value;\n if (!isString(text)) {\n return null;\n }\n const match = durationRegex.exec(text)?.groups;\n if (!match) {\n return null;\n }\n const num = parseFloat(match.num);\n if (!match.unit) {\n return num;\n }\n return (num * durationUnitMs[match.unit]) / MINUTE_MS;\n}\n\nfunction getMinutes(\n value: unknown,\n setting: string,\n yarnrcFile: string,\n): number | null {\n if (value === undefined) {\n return null;\n }\n const minutes = parseYarnDurationMinutes(value);\n if (minutes === null) {\n logger.debug(\n `Invalid ${setting} ${JSON.stringify(value)} in ${yarnrcFile}, ignoring`,\n );\n }\n return minutes;\n}\n\n/**\n * Reads the minimum release age settings of the nearest `.yarnrc.yml` in the directory of a Yarn lock file or a parent directory, and ignores invalid ages.\n */\nexport async function readYarnrcMinimalAgeGate(\n yarnLock: string,\n): Promise<YarnrcMinimalAgeGateSettings> {\n const yarnrcFile = await findLocalSiblingOrParent(yarnLock, '.yarnrc.yml');\n if (!yarnrcFile) {\n return {};\n }\n const content = await readLocalFile(yarnrcFile, 'utf8');\n if (!content) {\n return {};\n }\n const parsed = YarnrcMinimalAgeGate.safeParse(content);\n if (!parsed.success) {\n logger.debug(\n { yarnrcFile, err: parsed.error },\n 'Failed to parse the minimum release age of .yarnrc.yml',\n );\n return {};\n }\n const { npmMinimalAgeGate, npmPreapprovedPackages, npmScopes } = parsed.data;\n const settings: YarnrcMinimalAgeGateSettings = {};\n const minutes = getMinutes(\n npmMinimalAgeGate,\n 'npmMinimalAgeGate',\n yarnrcFile,\n );\n if (minutes !== null) {\n settings.npmMinimalAgeGate = minutes;\n }\n if (npmScopes) {\n settings.npmScopes = {};\n for (const [scope, scopeConfig] of Object.entries(npmScopes)) {\n settings.npmScopes[scope] = getMinutes(\n scopeConfig.npmMinimalAgeGate,\n `npmScopes.${scope}.npmMinimalAgeGate`,\n yarnrcFile,\n );\n }\n }\n if (npmPreapprovedPackages) {\n settings.npmPreapprovedPackages = npmPreapprovedPackages;\n }\n return settings;\n}\n\n/**\n * Whether Renovate runs Yarn 1 for the Yarn constraint, which is the case for a missing constraint, a constraint which is no valid range, or one which allows Yarn 1.\n */\nexport function isYarn1Constraint(\n yarnConstraint: string | null | undefined,\n): boolean {\n const range = semver.validRange(yarnConstraint);\n const minVersion = range && semver.minVersion(range);\n return !minVersion || minVersion.major === 1;\n}\n\n/**\n * The global `npmMinimalAgeGate` in minutes which Yarn configures itself, or with `includeDefault` the Yarn default if the `.yarnrc.yml` does not set it.\n */\nexport function getYarnMinimalAgeGateMinutes(\n settings: YarnMinimalAgeGateSettings,\n includeDefault: boolean,\n): number | undefined {\n if (settings.npmMinimalAgeGate !== undefined) {\n return settings.npmMinimalAgeGate;\n }\n return includeDefault ? yarnDefaultMinimalAgeGateMinutes : undefined;\n}\n\n/**\n * Returns the `npmMinimalAgeGate` in minutes of each scope of `npmScopes`, which Yarn applies to the packages of that scope instead of the global value, with the Yarn default for a scope without its own value if `includeDefault` is set.\n */\nexport function getYarnScopeMinimalAgeGateMinutes(\n settings: YarnMinimalAgeGateSettings,\n includeDefault: boolean,\n): Record<string, number> {\n const result: Record<string, number> = {};\n for (const [scope, minutes] of Object.entries(\n coerceObject(settings.npmScopes),\n )) {\n if (minutes !== null) {\n result[scope] = minutes;\n } else if (includeDefault) {\n result[scope] = yarnDefaultMinimalAgeGateMinutes;\n }\n }\n return result;\n}\n\n/**\n * Parses the `npmPreapprovedPackages` entries of a `.yarnrc.yml` like Yarn, which accepts a package name or glob, where `*` does not match `/` as in `matchPackageNames`, optionally with a semver range like `foo@^1.0.0`.\n */\nexport function parseYarnPreapprovedPackages(\n entries: string[] | undefined,\n): YarnPreapprovedPackage[] {\n const result: YarnPreapprovedPackage[] = [];\n for (const entry of coerceArray(entries)) {\n const match = descriptorRegex.exec(entry)?.groups;\n if (!match) {\n logger.debug(`Invalid npmPreapprovedPackages entry ${entry}, ignoring`);\n continue;\n }\n const packageName = match.scope\n ? `@${match.scope}/${match.name}`\n : match.name;\n result.push(\n match.range ? { packageName, range: match.range } : { packageName },\n );\n }\n return result;\n}\n\nfunction isPreapprovedBy(\n entry: YarnPreapprovedPackage,\n packageName: string,\n version: string | undefined,\n): boolean {\n if (!matchRegexOrGlobList(packageName, [entry.packageName])) {\n return false;\n }\n if (!entry.range) {\n return true;\n }\n return !!version && semver.satisfies(version, entry.range);\n}\n\n/**\n * Whether `npmPreapprovedPackages` exempts `version` of `packageName` from the Yarn minimum release age.\n */\nexport function isYarnPreapproved(\n preapproved: YarnPreapprovedPackage[],\n packageName: string,\n version: string | undefined,\n): boolean {\n return preapproved.some((entry) =>\n isPreapprovedBy(entry, packageName, version),\n );\n}\n\n/**\n * Returns the `packageRules` for a Yarn minimum release age of npm packages, with the age of `npmScopes` for the packages of a scope, and with `npmPreapprovedPackages` entries without a range lifting it for the packages they name.\n */\nexport function getYarnMinimumReleaseAgeRules(\n minutes: number | undefined,\n scopeMinutes: Record<string, number>,\n preapproved: YarnPreapprovedPackage[],\n): ExtractedPackageRule[] {\n const scopes = Object.entries(scopeMinutes);\n if (!minutes && !scopes.some(([, scopeAge]) => scopeAge)) {\n return [];\n }\n const rules: ExtractedPackageRule[] = [];\n if (minutes) {\n rules.push({\n matchDatasources: [NpmDatasource.id],\n minimumReleaseAgeExtracted: `${minutes} minutes`,\n });\n }\n for (const [scope, scopeAge] of scopes) {\n rules.push({\n matchDatasources: [NpmDatasource.id],\n matchPackageNames: [`@${scope}/**`],\n minimumReleaseAgeExtracted: scopeAge ? `${scopeAge} minutes` : null,\n });\n }\n for (const entry of preapproved) {\n if (!entry.range) {\n rules.push({\n matchDatasources: [NpmDatasource.id],\n matchPackageNames: [entry.packageName],\n minimumReleaseAgeExtracted: null,\n });\n }\n }\n return rules;\n}\n\n/**\n * Adds `packageRules` with the Yarn minimum release age to the package files of each Yarn lock file, from the nearest `.yarnrc.yml` in its directory or a parent directory or the Yarn default, and keeps the settings of the lock file in the `managerData` of each of its package files, except for Yarn 1, which has no minimum release age.\n */\nexport async function setYarnMinimumReleaseAge(\n packageFiles: Partial<PackageFile<NpmManagerData>>[],\n config: ExtractConfig,\n): Promise<void> {\n for (const {\n lockFile: yarnLock,\n packageFiles: lockFilePackageFiles,\n root,\n } of groupByLockFile(packageFiles, 'yarnLock')) {\n const yarnConstraint = await resolveToolConstraint(\n config,\n 'yarn',\n () => root?.extractedConstraints?.yarn,\n );\n if (isYarn1Constraint(yarnConstraint)) {\n continue;\n }\n const settings = await readYarnrcMinimalAgeGate(yarnLock);\n const { npmMinimalAgeGate, npmScopes } = settings;\n const hasNpmPreapprovedPackages = !!settings.npmPreapprovedPackages?.length;\n // the .yarnrc.yml has no Yarn constraint of its own, so the root\n // package.json sets it for every package file of the lock file\n for (const packageFile of lockFilePackageFiles) {\n packageFile.managerData!.yarnMinimalAgeGate = {\n npmMinimalAgeGate,\n npmScopes,\n ...(hasNpmPreapprovedPackages && { hasNpmPreapprovedPackages }),\n yarnConstraint,\n };\n }\n // a Yarn range which allows a version with a default gets it, as Renovate\n // may install that version\n const minutes = getYarnMinimalAgeGateMinutes(\n settings,\n intersectsWith(\n npmVersioning,\n yarnConstraint,\n yarnDefaultMinimalAgeGateRange,\n ),\n );\n const scopeMinutes = getYarnScopeMinimalAgeGateMinutes(\n settings,\n intersectsWith(\n npmVersioning,\n yarnConstraint,\n yarnScopeMinimalAgeGateRange,\n ),\n );\n const rules = getYarnMinimumReleaseAgeRules(\n minutes,\n scopeMinutes,\n parseYarnPreapprovedPackages(settings.npmPreapprovedPackages),\n );\n if (!rules.length) {\n continue;\n }\n const globalAge = minutes ? `${minutes} minutes` : 'none';\n const scopeAges = Object.entries(scopeMinutes).map(\n ([scope, scopeAge]) => `@${scope} ${scopeAge} minutes`,\n );\n const scopeAgesText = scopeAges.length\n ? `, scopes ${scopeAges.join(', ')}`\n : '';\n logger.debug(\n `Found Yarn minimum release age for ${yarnLock}: global ${globalAge}${scopeAgesText}`,\n );\n for (const packageFile of lockFilePackageFiles) {\n packageFile.packageRules = [\n ...coerceArray(packageFile.packageRules),\n ...rules,\n ];\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA+BA,MAAa,iCAAiC;AAC9C,MAAa,mCAAmC;AAIhD,MAAa,+BAA+B;AAE5C,MAAM,iBAAyC;CAC7C,IAAI;CACJ,GAAG;CACH,GAAG;CACH,GAAG,KAAK;CACR,GAAG;CACH,GAAG,IAAI;AACT;AACA,MAAM,gBAAgB,MAAM,2CAA2C;AAGvE,MAAM,kBAAkB,MACtB,8DACF;;;;AAKA,SAAgB,yBAAyB,OAA+B;CAEtE,MAAM,OAAO,SAAS,KAAK,IAAI,OAAO,KAAK,IAAI;CAC/C,IAAI,CAAC,SAAS,IAAI,GAChB,OAAO;CAET,MAAM,QAAQ,cAAc,KAAK,IAAI,CAAC,EAAE;CACxC,IAAI,CAAC,OACH,OAAO;CAET,MAAM,MAAM,WAAW,MAAM,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,MACL,sCAAsC,SAAS,WAAW,YAAY,eACxE;EACA,KAAK,MAAM,eAAe,sBACxB,YAAY,eAAe,CACzB,GAAG,YAAY,YAAY,YAAY,GACvC,GAAG,KACL;CAEJ;AACF"}
@@ -2,6 +2,7 @@ import { __exportAll } from "../../../_virtual/_rolldown/runtime.js";
2
2
  import { GithubTagsDatasource } from "../../datasource/github-tags/index.js";
3
3
  import { NodeVersionDatasource } from "../../datasource/node-version/index.js";
4
4
  import { NpmDatasource } from "../../datasource/npm/index.js";
5
+ import { enforcesMinimumReleaseAge, minReleaseAgeNpmRange, minimumReleaseAgeEnforcedPnpmRange, minimumReleaseAgePnpmRange, minimumReleaseAgeYarnRange } from "./minimum-release-age.js";
5
6
  import { updateArtifacts } from "./artifacts.js";
6
7
  import { updateDependency } from "./update/dependency/index.js";
7
8
  import { detectGlobalConfig } from "./detect.js";
@@ -18,6 +19,7 @@ var npm_exports = /* @__PURE__ */ __exportAll({
18
19
  defaultConfig: () => defaultConfig,
19
20
  detectGlobalConfig: () => detectGlobalConfig,
20
21
  displayName: () => "npm",
22
+ enforcesMinimumReleaseAge: () => enforcesMinimumReleaseAge,
21
23
  extractAllPackageFiles: () => extractAllPackageFiles,
22
24
  getRangeStrategy: () => getRangeStrategy,
23
25
  knownDepTypes: () => knownDepTypes,
@@ -44,10 +46,22 @@ const categories = ["js"];
44
46
  const minimumReleaseAgeSupport = {
45
47
  npm: {
46
48
  passesMinimumReleaseAge: true,
47
- note: "Passes `--before`. Uses the older date if the repository `.npmrc` has a `before` setting. Skipped if the `.npmrc` has `min-release-age`."
49
+ readsConfiguredAge: minReleaseAgeNpmRange,
50
+ enforcedInLockFile: true,
51
+ note: "Passes `--before`, unless `.npmrc` sets `min-release-age`. If `minimumReleaseAgePackageManagerSync` is enabled, reads `.npmrc`, see [npm](#npm)."
48
52
  },
49
- pnpm: {},
50
- yarn: {}
53
+ pnpm: {
54
+ passesMinimumReleaseAge: minimumReleaseAgePnpmRange,
55
+ readsConfiguredAge: minimumReleaseAgePnpmRange,
56
+ enforcedInLockFile: minimumReleaseAgeEnforcedPnpmRange,
57
+ note: "If `minimumReleaseAgePackageManagerSync` is enabled, passes `--config.minimum-release-age` and reads `pnpm-workspace.yaml`, see [pnpm](#pnpm)."
58
+ },
59
+ yarn: {
60
+ passesMinimumReleaseAge: minimumReleaseAgeYarnRange,
61
+ readsConfiguredAge: minimumReleaseAgeYarnRange,
62
+ enforcedInLockFile: minimumReleaseAgeYarnRange,
63
+ note: "If `minimumReleaseAgePackageManagerSync` is enabled, passes `YARN_NPM_MINIMAL_AGE_GATE` and reads `.yarnrc.yml`, see [Yarn](#yarn)."
64
+ }
51
65
  };
52
66
  const defaultConfig = {
53
67
  managerFilePatterns: [
@@ -63,6 +77,6 @@ const supportedDatasources = [
63
77
  NpmDatasource.id,
64
78
  NodeVersionDatasource.id
65
79
  ];
66
- export { bumpPackageVersion, categories, defaultConfig, detectGlobalConfig, extractAllPackageFiles, getRangeStrategy, knownDepTypes, lockFileMaintenanceIsDelegatedToPackageManager, lockFileNames, minimumReleaseAgeSupport, npm_exports, supportedDatasources, supportsDynamicDepTypesNote, updateArtifacts, updateDependency, updateLockedDependency, url };
80
+ export { bumpPackageVersion, categories, defaultConfig, detectGlobalConfig, enforcesMinimumReleaseAge, extractAllPackageFiles, getRangeStrategy, knownDepTypes, lockFileMaintenanceIsDelegatedToPackageManager, lockFileNames, minimumReleaseAgeSupport, npm_exports, supportedDatasources, supportsDynamicDepTypesNote, updateArtifacts, updateDependency, updateLockedDependency, url };
67
81
 
68
82
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../../lib/modules/manager/npm/index.ts"],"sourcesContent":["import type { Category } from '../../../constants/index.ts';\nimport { GithubTagsDatasource } from '../../datasource/github-tags/index.ts';\nimport { NodeVersionDatasource } from '../../datasource/node-version/index.ts';\nimport { NpmDatasource } from '../../datasource/npm/index.ts';\nimport type { MinimumReleaseAgeSupport } from '../types.ts';\n\nexport { updateArtifacts } from './artifacts.ts';\nexport { detectGlobalConfig } from './detect.ts';\nexport { extractAllPackageFiles } from './extract/index.ts';\nexport { getRangeStrategy } from './range.ts';\nexport {\n bumpPackageVersion,\n updateDependency,\n updateLockedDependency,\n} from './update/index.ts';\n\nexport const supportsLockFileMaintenance = true;\nexport const supportsNpmrc = true;\nexport const lockFileNames = [\n 'package-lock.json',\n 'pnpm-lock.yaml',\n 'yarn.lock',\n];\nexport const lockFileMaintenanceIsDelegatedToPackageManager =\n 'Delegated to the underlying package manager CLI - `npm`, `pnpm`, or Yarn - depending on which lock file is present.';\n\nexport const displayName = 'npm';\nexport const url = 'https://docs.npmjs.com';\nexport const categories: Category[] = ['js'];\n\nexport const minimumReleaseAgeSupport: MinimumReleaseAgeSupport = {\n npm: {\n passesMinimumReleaseAge: true,\n note: 'Passes `--before`. Uses the older date if the repository `.npmrc` has a `before` setting. Skipped if the `.npmrc` has `min-release-age`.',\n },\n pnpm: {},\n yarn: {},\n};\n\nexport const defaultConfig = {\n managerFilePatterns: [\n '/(^|/)package\\\\.json$/',\n '/(^|/)pnpm-workspace\\\\.yaml$/',\n '/(^|/)\\\\.yarnrc\\\\.yml$/',\n ],\n digest: {\n prBodyDefinitions: {\n Change:\n '{{#if displayFrom}}`{{{displayFrom}}}` → {{else}}{{#if currentValue}}`{{{currentValue}}}` → {{/if}}{{/if}}{{#if displayTo}}`{{{displayTo}}}`{{else}}`{{{newValue}}}`{{/if}}',\n },\n },\n prBodyDefinitions: {\n Change:\n \"[{{#if displayFrom}}`{{{displayFrom}}}` → {{else}}{{#if currentValue}}`{{{currentValue}}}` → {{/if}}{{/if}}{{#if displayTo}}`{{{displayTo}}}`{{else}}`{{{newValue}}}`{{/if}}]({{#if packageName}}https://renovatebot.com/diffs/npm/{{replace '/' '%2f' packageName}}/{{{currentVersion}}}/{{{newVersion}}}{{/if}})\",\n },\n};\n\nexport const supportedDatasources = [\n GithubTagsDatasource.id,\n NpmDatasource.id,\n NodeVersionDatasource.id,\n];\n\nexport { knownDepTypes, supportsDynamicDepTypesNote } from './dep-types.ts';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,MAAa,gBAAgB;CAC3B;CACA;CACA;AACF;AACA,MAAa,iDACX;AAGF,MAAa,MAAM;AACnB,MAAa,aAAyB,CAAC,IAAI;AAE3C,MAAa,2BAAqD;CAChE,KAAK;EACH,yBAAyB;EACzB,MAAM;CACR;CACA,MAAM,CAAC;CACP,MAAM,CAAC;AACT;AAEA,MAAa,gBAAgB;CAC3B,qBAAqB;EACnB;EACA;EACA;CACF;CACA,QAAQ,EACN,mBAAmB,EACjB,QACE,8KACJ,EACF;CACA,mBAAmB,EACjB,QACE,qTACJ;AACF;AAEA,MAAa,uBAAuB;CAClC,qBAAqB;CACrB,cAAc;CACd,sBAAsB;AACxB"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../lib/modules/manager/npm/index.ts"],"sourcesContent":["import type { Category } from '../../../constants/index.ts';\nimport { GithubTagsDatasource } from '../../datasource/github-tags/index.ts';\nimport { NodeVersionDatasource } from '../../datasource/node-version/index.ts';\nimport { NpmDatasource } from '../../datasource/npm/index.ts';\nimport type { MinimumReleaseAgeSupport } from '../types.ts';\nimport {\n minReleaseAgeNpmRange,\n minimumReleaseAgeEnforcedPnpmRange,\n minimumReleaseAgePnpmRange,\n minimumReleaseAgeYarnRange,\n} from './minimum-release-age.ts';\n\nexport { updateArtifacts } from './artifacts.ts';\nexport { detectGlobalConfig } from './detect.ts';\nexport { extractAllPackageFiles } from './extract/index.ts';\nexport { enforcesMinimumReleaseAge } from './minimum-release-age.ts';\nexport { getRangeStrategy } from './range.ts';\nexport {\n bumpPackageVersion,\n updateDependency,\n updateLockedDependency,\n} from './update/index.ts';\n\nexport const supportsLockFileMaintenance = true;\nexport const supportsNpmrc = true;\nexport const lockFileNames = [\n 'package-lock.json',\n 'pnpm-lock.yaml',\n 'yarn.lock',\n];\nexport const lockFileMaintenanceIsDelegatedToPackageManager =\n 'Delegated to the underlying package manager CLI - `npm`, `pnpm`, or Yarn - depending on which lock file is present.';\n\nexport const displayName = 'npm';\nexport const url = 'https://docs.npmjs.com';\nexport const categories: Category[] = ['js'];\n\nexport const minimumReleaseAgeSupport: MinimumReleaseAgeSupport = {\n npm: {\n passesMinimumReleaseAge: true,\n readsConfiguredAge: minReleaseAgeNpmRange,\n enforcedInLockFile: true,\n note: 'Passes `--before`, unless `.npmrc` sets `min-release-age`. If `minimumReleaseAgePackageManagerSync` is enabled, reads `.npmrc`, see [npm](#npm).',\n },\n pnpm: {\n passesMinimumReleaseAge: minimumReleaseAgePnpmRange,\n readsConfiguredAge: minimumReleaseAgePnpmRange,\n enforcedInLockFile: minimumReleaseAgeEnforcedPnpmRange,\n note: 'If `minimumReleaseAgePackageManagerSync` is enabled, passes `--config.minimum-release-age` and reads `pnpm-workspace.yaml`, see [pnpm](#pnpm).',\n },\n yarn: {\n passesMinimumReleaseAge: minimumReleaseAgeYarnRange,\n readsConfiguredAge: minimumReleaseAgeYarnRange,\n enforcedInLockFile: minimumReleaseAgeYarnRange,\n note: 'If `minimumReleaseAgePackageManagerSync` is enabled, passes `YARN_NPM_MINIMAL_AGE_GATE` and reads `.yarnrc.yml`, see [Yarn](#yarn).',\n },\n};\n\nexport const defaultConfig = {\n managerFilePatterns: [\n '/(^|/)package\\\\.json$/',\n '/(^|/)pnpm-workspace\\\\.yaml$/',\n '/(^|/)\\\\.yarnrc\\\\.yml$/',\n ],\n digest: {\n prBodyDefinitions: {\n Change:\n '{{#if displayFrom}}`{{{displayFrom}}}` → {{else}}{{#if currentValue}}`{{{currentValue}}}` → {{/if}}{{/if}}{{#if displayTo}}`{{{displayTo}}}`{{else}}`{{{newValue}}}`{{/if}}',\n },\n },\n prBodyDefinitions: {\n Change:\n \"[{{#if displayFrom}}`{{{displayFrom}}}` → {{else}}{{#if currentValue}}`{{{currentValue}}}` → {{/if}}{{/if}}{{#if displayTo}}`{{{displayTo}}}`{{else}}`{{{newValue}}}`{{/if}}]({{#if packageName}}https://renovatebot.com/diffs/npm/{{replace '/' '%2f' packageName}}/{{{currentVersion}}}/{{{newVersion}}}{{/if}})\",\n },\n};\n\nexport const supportedDatasources = [\n GithubTagsDatasource.id,\n NpmDatasource.id,\n NodeVersionDatasource.id,\n];\n\nexport { knownDepTypes, supportsDynamicDepTypesNote } from './dep-types.ts';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAa,gBAAgB;CAC3B;CACA;CACA;AACF;AACA,MAAa,iDACX;AAGF,MAAa,MAAM;AACnB,MAAa,aAAyB,CAAC,IAAI;AAE3C,MAAa,2BAAqD;CAChE,KAAK;EACH,yBAAyB;EACzB,oBAAoB;EACpB,oBAAoB;EACpB,MAAM;CACR;CACA,MAAM;EACJ,yBAAyB;EACzB,oBAAoB;EACpB,oBAAoB;EACpB,MAAM;CACR;CACA,MAAM;EACJ,yBAAyB;EACzB,oBAAoB;EACpB,oBAAoB;EACpB,MAAM;CACR;AACF;AAEA,MAAa,gBAAgB;CAC3B,qBAAqB;EACnB;EACA;EACA;CACF;CACA,QAAQ,EACN,mBAAmB,EACjB,QACE,8KACJ,EACF;CACA,mBAAmB,EACjB,QACE,qTACJ;AACF;AAEA,MAAa,uBAAuB;CAClC,qBAAqB;CACrB,cAAc;CACd,sBAAsB;AACxB"}