@verdaccio/e2e-cli 3.4.0 → 4.0.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.
@@ -8,18 +8,7 @@ let path = require("path");
8
8
  let fs_promises = require("fs/promises");
9
9
  //#region src/adapters/pnpm.ts
10
10
  var debug$1 = (0, debug.default)("verdaccio:e2e-cli:pnpm");
11
- var PNPM_V10_COMMANDS = /* @__PURE__ */ new Set([
12
- "publish",
13
- "unpublish",
14
- "install",
15
- "info",
16
- "audit",
17
- "deprecate",
18
- "dist-tag",
19
- "ping",
20
- "search"
21
- ]);
22
- var PNPM_V11_COMMANDS = /* @__PURE__ */ new Set([
11
+ var PNPM_COMMANDS = /* @__PURE__ */ new Set([
23
12
  "publish",
24
13
  "unpublish",
25
14
  "install",
@@ -27,15 +16,7 @@ var PNPM_V11_COMMANDS = /* @__PURE__ */ new Set([
27
16
  "audit",
28
17
  "deprecate"
29
18
  ]);
30
- function getSupportedCommands(version) {
31
- const major = parseInt(version.split(".")[0], 10);
32
- if (major >= 11) {
33
- debug$1("pnpm v%d detected, using v11 command set", major);
34
- return PNPM_V11_COMMANDS;
35
- }
36
- return PNPM_V10_COMMANDS;
37
- }
38
- var PNPM_MIN_SUPPORTED_MAJOR = 10;
19
+ var PNPM_MIN_SUPPORTED_MAJOR = 11;
39
20
  function detectVersion(bin) {
40
21
  try {
41
22
  return (0, child_process.execSync)(`${bin} --version`, {
@@ -78,7 +59,7 @@ function createPnpmAdapter(binPath, version) {
78
59
  name: `pnpm@${resolved}`,
79
60
  type: "pnpm",
80
61
  bin,
81
- supports: getSupportedCommands(resolved),
62
+ supports: PNPM_COMMANDS,
82
63
  registryArg(url) {
83
64
  return ["--registry", url];
84
65
  },
@@ -1 +1 @@
1
- {"version":3,"file":"pnpm.cjs","names":[],"sources":["../../../src/adapters/pnpm.ts"],"sourcesContent":["import { SpawnOptions, execSync } from 'child_process';\nimport buildDebug from 'debug';\nimport { writeFile } from 'fs/promises';\nimport { join } from 'path';\n\nimport { ExecOutput, PackageManagerAdapter } from '../types';\nimport { exec } from '../utils/process';\nimport { prepareGenericEmptyProject } from '../utils/project';\n\nconst debug = buildDebug('verdaccio:e2e-cli:pnpm');\n\nconst PNPM_V10_COMMANDS = new Set([\n 'publish',\n 'unpublish',\n 'install',\n 'info',\n 'audit',\n 'deprecate',\n 'dist-tag',\n 'ping',\n 'search',\n]);\n\n// pnpm v11 removed ping and search\n// dist-tag output format changed (no --json), needs adapted assertions\nconst PNPM_V11_COMMANDS = new Set([\n 'publish',\n 'unpublish',\n 'install',\n 'info',\n 'audit',\n 'deprecate',\n]);\n\nfunction getSupportedCommands(version: string): Set<string> {\n const major = parseInt(version.split('.')[0], 10);\n if (major >= 11) {\n debug('pnpm v%d detected, using v11 command set', major);\n return PNPM_V11_COMMANDS;\n }\n return PNPM_V10_COMMANDS;\n}\n\n// pnpm 8 and 9 are end-of-life and no longer supported by the suite.\nconst PNPM_MIN_SUPPORTED_MAJOR = 10;\n\nfunction detectVersion(bin: string): string {\n try {\n return execSync(`${bin} --version`, { encoding: 'utf8', timeout: 5000 }).trim();\n } catch {\n return 'unknown';\n }\n}\n\nfunction assertSupportedVersion(resolved: string): void {\n const major = parseInt(resolved.split('.')[0], 10);\n if (!Number.isNaN(major) && major < PNPM_MIN_SUPPORTED_MAJOR) {\n throw new Error(\n `pnpm@${resolved} is not supported. Minimum supported major: ${PNPM_MIN_SUPPORTED_MAJOR}`\n );\n }\n}\n\nfunction installPnpm(version: string): string {\n const pkg = `pnpm@${version}`;\n debug('installing %s into temp dir', pkg);\n const tmpDir = execSync('mktemp -d', { encoding: 'utf8' }).trim();\n execSync(`npm install --prefix \"${tmpDir}\" ${pkg} --loglevel=error`, {\n encoding: 'utf8',\n timeout: 30000,\n });\n const bin = `${tmpDir}/node_modules/.bin/pnpm`;\n const installed = detectVersion(bin);\n debug('installed pnpm %s at %s', installed, bin);\n console.log(` Auto-installed pnpm ${installed}`);\n return bin;\n}\n\nfunction resolvePnpmBin(binPath?: string, version?: string): string {\n if (binPath) return binPath;\n if (version) return installPnpm(version);\n return 'pnpm';\n}\n\nexport function createPnpmAdapter(binPath?: string, version?: string): PackageManagerAdapter {\n const bin = resolvePnpmBin(binPath, version);\n const resolved = detectVersion(bin);\n assertSupportedVersion(resolved);\n debug('creating pnpm adapter with bin: %s (%s)', bin, resolved);\n\n const adapter: PackageManagerAdapter = {\n name: `pnpm@${resolved}`,\n type: 'pnpm',\n bin,\n supports: getSupportedCommands(resolved),\n\n registryArg(url: string): string[] {\n return ['--registry', url];\n },\n\n prefixArg(folder: string): string[] {\n return ['--prefix', folder];\n },\n\n exec(options: SpawnOptions, ...args: string[]): Promise<ExecOutput> {\n const major = parseInt(resolved.split('.')[0], 10);\n if (major >= 11) {\n // pnpm v11: native deprecate/unpublish don't support --json\n const cmd = args[0];\n if (cmd === 'deprecate' || cmd === 'unpublish' || cmd === 'publish' || cmd === 'dist-tag') {\n args = args.filter((a) => a !== '--json' && !a.startsWith('--loglevel'));\n }\n // pnpm v11: un-deprecate uses `undeprecate` command instead of `deprecate pkg \"\"`\n if (cmd === 'deprecate') {\n // Check if message arg is empty string (un-deprecate)\n // args: ['deprecate', 'pkg@version', '', ...flags]\n const msgIdx = 2; // message is the third arg\n if (args.length > msgIdx && args[msgIdx] === '') {\n args = ['undeprecate', args[1], ...args.slice(3)];\n }\n }\n // pnpm v11: native version command doesn't accept --registry, --loglevel, or --no--git-tag-version\n if (cmd === 'version') {\n args = args.filter(\n (a) =>\n !a.startsWith('--registry') &&\n !a.startsWith('--loglevel') &&\n !a.startsWith('--no--git-tag-version')\n );\n }\n }\n return exec(options, bin, args);\n },\n\n async prepareProject(\n packageName: string,\n version: string,\n registryUrl: string,\n port: number,\n token: string,\n dependencies: Record<string, string> = {},\n devDependencies: Record<string, string> = {}\n ): Promise<{ tempFolder: string }> {\n const project = await prepareGenericEmptyProject(\n packageName,\n version,\n port,\n token,\n registryUrl,\n dependencies,\n devDependencies\n );\n // pnpm 11.24+ enforces a minimumReleaseAge cooldown by default, which\n // rejects the just-published packages these tests install\n // (ERR_PNPM_NO_MATURE_MATCHING_VERSION). Disable it per project via\n // pnpm-workspace.yaml — the file also marks the temp folder as its own\n // workspace root, isolating it from any parent workspace. Tests that\n // exercise the cooldown itself overwrite this file with their own config.\n await writeFile(join(project.tempFolder, 'pnpm-workspace.yaml'), 'minimumReleaseAge: 0\\n');\n return project;\n },\n };\n\n return adapter;\n}\n"],"mappings":";;;;;;;;;AASA,IAAM,WAAA,GAAQ,MAAA,QAAA,CAAW,wBAAwB;AAEjD,IAAM,oCAAoB,IAAI,IAAI;CAChC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAID,IAAM,oCAAoB,IAAI,IAAI;CAChC;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,qBAAqB,SAA8B;CAC1D,MAAM,QAAQ,SAAS,QAAQ,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE;CAChD,IAAI,SAAS,IAAI;EACf,QAAM,4CAA4C,KAAK;EACvD,OAAO;CACT;CACA,OAAO;AACT;AAGA,IAAM,2BAA2B;AAEjC,SAAS,cAAc,KAAqB;CAC1C,IAAI;EACF,QAAA,GAAO,cAAA,SAAA,CAAS,GAAG,IAAI,aAAa;GAAE,UAAU;GAAQ,SAAS;EAAK,CAAC,CAAC,CAAC,KAAK;CAChF,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAS,uBAAuB,UAAwB;CACtD,MAAM,QAAQ,SAAS,SAAS,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE;CACjD,IAAI,CAAC,OAAO,MAAM,KAAK,KAAK,QAAQ,0BAClC,MAAM,IAAI,MACR,QAAQ,SAAS,8CAA8C,0BACjE;AAEJ;AAEA,SAAS,YAAY,SAAyB;CAC5C,MAAM,MAAM,QAAQ;CACpB,QAAM,+BAA+B,GAAG;CACxC,MAAM,UAAA,GAAS,cAAA,SAAA,CAAS,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,EAAE,WAAW,YAAY,KAC1B,CAAC,EAAE,WAAW,YAAY,KAC1B,CAAC,EAAE,WAAW,uBAAuB,CACzC;GAEJ;GACA,OAAO,gBAAA,KAAK,SAAS,KAAK,IAAI;EAChC;EAEA,MAAM,eACJ,aACA,SACA,aACA,MACA,OACA,eAAuC,CAAC,GACxC,kBAA0C,CAAC,GACV;GACjC,MAAM,UAAU,MAAM,gBAAA,2BACpB,aACA,SACA,MACA,OACA,aACA,cACA,eACF;GAOA,OAAA,GAAM,YAAA,UAAA,EAAA,GAAU,KAAA,KAAA,CAAK,QAAQ,YAAY,qBAAqB,GAAG,wBAAwB;GACzF,OAAO;EACT;CAGK;AACT"}
1
+ {"version":3,"file":"pnpm.cjs","names":[],"sources":["../../../src/adapters/pnpm.ts"],"sourcesContent":["import { SpawnOptions, execSync } from 'child_process';\nimport buildDebug from 'debug';\nimport { writeFile } from 'fs/promises';\nimport { join } from 'path';\n\nimport { ExecOutput, PackageManagerAdapter } from '../types';\nimport { exec } from '../utils/process';\nimport { prepareGenericEmptyProject } from '../utils/project';\n\nconst debug = buildDebug('verdaccio:e2e-cli:pnpm');\n\n// pnpm removed ping and search; the dist-tag output changed (no --json) and needs adapted assertions\nconst PNPM_COMMANDS = new Set(['publish', 'unpublish', 'install', 'info', 'audit', 'deprecate']);\n\n// pnpm 8, 9 and 10 are no longer supported by the suite.\nconst PNPM_MIN_SUPPORTED_MAJOR = 11;\n\nfunction detectVersion(bin: string): string {\n try {\n return execSync(`${bin} --version`, { encoding: 'utf8', timeout: 5000 }).trim();\n } catch {\n return 'unknown';\n }\n}\n\nfunction assertSupportedVersion(resolved: string): void {\n const major = parseInt(resolved.split('.')[0], 10);\n if (!Number.isNaN(major) && major < PNPM_MIN_SUPPORTED_MAJOR) {\n throw new Error(\n `pnpm@${resolved} is not supported. Minimum supported major: ${PNPM_MIN_SUPPORTED_MAJOR}`\n );\n }\n}\n\nfunction installPnpm(version: string): string {\n const pkg = `pnpm@${version}`;\n debug('installing %s into temp dir', pkg);\n const tmpDir = execSync('mktemp -d', { encoding: 'utf8' }).trim();\n execSync(`npm install --prefix \"${tmpDir}\" ${pkg} --loglevel=error`, {\n encoding: 'utf8',\n timeout: 30000,\n });\n const bin = `${tmpDir}/node_modules/.bin/pnpm`;\n const installed = detectVersion(bin);\n debug('installed pnpm %s at %s', installed, bin);\n console.log(` Auto-installed pnpm ${installed}`);\n return bin;\n}\n\nfunction resolvePnpmBin(binPath?: string, version?: string): string {\n if (binPath) return binPath;\n if (version) return installPnpm(version);\n return 'pnpm';\n}\n\nexport function createPnpmAdapter(binPath?: string, version?: string): PackageManagerAdapter {\n const bin = resolvePnpmBin(binPath, version);\n const resolved = detectVersion(bin);\n assertSupportedVersion(resolved);\n debug('creating pnpm adapter with bin: %s (%s)', bin, resolved);\n\n const adapter: PackageManagerAdapter = {\n name: `pnpm@${resolved}`,\n type: 'pnpm',\n bin,\n supports: PNPM_COMMANDS,\n\n registryArg(url: string): string[] {\n return ['--registry', url];\n },\n\n prefixArg(folder: string): string[] {\n return ['--prefix', folder];\n },\n\n exec(options: SpawnOptions, ...args: string[]): Promise<ExecOutput> {\n const major = parseInt(resolved.split('.')[0], 10);\n if (major >= 11) {\n // pnpm v11: native deprecate/unpublish don't support --json\n const cmd = args[0];\n if (cmd === 'deprecate' || cmd === 'unpublish' || cmd === 'publish' || cmd === 'dist-tag') {\n args = args.filter((a) => a !== '--json' && !a.startsWith('--loglevel'));\n }\n // pnpm v11: un-deprecate uses `undeprecate` command instead of `deprecate pkg \"\"`\n if (cmd === 'deprecate') {\n // Check if message arg is empty string (un-deprecate)\n // args: ['deprecate', 'pkg@version', '', ...flags]\n const msgIdx = 2; // message is the third arg\n if (args.length > msgIdx && args[msgIdx] === '') {\n args = ['undeprecate', args[1], ...args.slice(3)];\n }\n }\n // pnpm v11: native version command doesn't accept --registry, --loglevel, or --no--git-tag-version\n if (cmd === 'version') {\n args = args.filter(\n (a) =>\n !a.startsWith('--registry') &&\n !a.startsWith('--loglevel') &&\n !a.startsWith('--no--git-tag-version')\n );\n }\n }\n return exec(options, bin, args);\n },\n\n async prepareProject(\n packageName: string,\n version: string,\n registryUrl: string,\n port: number,\n token: string,\n dependencies: Record<string, string> = {},\n devDependencies: Record<string, string> = {}\n ): Promise<{ tempFolder: string }> {\n const project = await prepareGenericEmptyProject(\n packageName,\n version,\n port,\n token,\n registryUrl,\n dependencies,\n devDependencies\n );\n // pnpm 11.24+ enforces a minimumReleaseAge cooldown by default, which\n // rejects the just-published packages these tests install\n // (ERR_PNPM_NO_MATURE_MATCHING_VERSION). Disable it per project via\n // pnpm-workspace.yaml — the file also marks the temp folder as its own\n // workspace root, isolating it from any parent workspace. Tests that\n // exercise the cooldown itself overwrite this file with their own config.\n await writeFile(join(project.tempFolder, 'pnpm-workspace.yaml'), 'minimumReleaseAge: 0\\n');\n return project;\n },\n };\n\n return adapter;\n}\n"],"mappings":";;;;;;;;;AASA,IAAM,WAAA,GAAQ,MAAA,QAAA,CAAW,wBAAwB;AAGjD,IAAM,gCAAgB,IAAI,IAAI;CAAC;CAAW;CAAa;CAAW;CAAQ;CAAS;AAAW,CAAC;AAG/F,IAAM,2BAA2B;AAEjC,SAAS,cAAc,KAAqB;CAC1C,IAAI;EACF,QAAA,GAAO,cAAA,SAAA,CAAS,GAAG,IAAI,aAAa;GAAE,UAAU;GAAQ,SAAS;EAAK,CAAC,CAAC,CAAC,KAAK;CAChF,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAS,uBAAuB,UAAwB;CACtD,MAAM,QAAQ,SAAS,SAAS,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE;CACjD,IAAI,CAAC,OAAO,MAAM,KAAK,KAAK,QAAQ,0BAClC,MAAM,IAAI,MACR,QAAQ,SAAS,8CAA8C,0BACjE;AAEJ;AAEA,SAAS,YAAY,SAAyB;CAC5C,MAAM,MAAM,QAAQ;CACpB,QAAM,+BAA+B,GAAG;CACxC,MAAM,UAAA,GAAS,cAAA,SAAA,CAA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AAY,KAC1B,CAAC,EAAE,WAAW,YAAY,KAC1B,CAAC,EAAE,WAAW,uBAAuB,CACzC;GAEJ;GACA,OAAO,gBAAA,KAAK,SAAS,KAAK,IAAI;EAChC;EAEA,MAAM,eACJ,aACA,SACA,aACA,MACA,OACA,eAAuC,CAAC,GACxC,kBAA0C,CAAC,GACV;GACjC,MAAM,UAAU,MAAM,gBAAA,2BACpB,aACA,SACA,MACA,OACA,aACA,cACA,eACF;GAOA,OAAA,GAAM,YAAA,UAAA,EAAA,GAAU,KAAA,KAAA,CAAK,QAAQ,YAAY,qBAAqB,GAAG,wBAAwB;GACzF,OAAO;EACT;CAGK;AACT"}
@@ -10,8 +10,8 @@ const require_yarn_modern = require("./adapters/yarn-modern.cjs");
10
10
  require("./adapters/index.cjs");
11
11
  const require_runner = require("./runner.cjs");
12
12
  const require_index$1 = require("./scenarios/index.cjs");
13
- const require_index$2 = require("./tests/index.cjs");
14
13
  const require_registry_client = require("./utils/registry-client.cjs");
14
+ const require_index$2 = require("./tests/index.cjs");
15
15
  let debug = require("debug");
16
16
  debug = require_runtime.__toESM(debug, 1);
17
17
  //#region src/index.ts
@@ -1 +1 @@
1
- {"version":3,"file":"minimum-release-age.cjs","names":[],"sources":["../../../src/scenarios/minimum-release-age.ts"],"sourcesContent":["import assert from 'assert';\nimport { writeFile } from 'fs/promises';\nimport { join } from 'path';\n\nimport { PackageManagerAdapter, TestContext, TestDefinition } from '../types';\nimport { trace } from '../utils/process';\n\n/**\n * Scenario: minimum-release-age (pnpm 11.1+ only)\n *\n * Exercises pnpm's `minimumReleaseAge` cooldown together with\n * `minimumReleaseAgeExclude`. With a 7-day (10080 minute) cooldown, freshly\n * published versions are normally not installable until they age past the\n * threshold — but packages matching the exclude globs bypass the check.\n *\n * minimumReleaseAge: 10080\n * minimumReleaseAgeStrict: true\n * minimumReleaseAgeExclude:\n * - '@verdaccio/*'\n * - 'verdaccio-*'\n *\n * minimumReleaseAgeStrict is required on pnpm 12: without it, pnpm 12\n * auto-adds new direct dependencies to minimumReleaseAgeExclude instead of\n * failing. pnpm 11 enforces the cooldown unconditionally and ignores the key.\n *\n * The scenario publishes brand-new (age ~0) packages and asserts:\n * - an excluded scoped package (@verdaccio/*) installs despite the cooldown\n * - an excluded unscoped package (verdaccio-*) installs despite the cooldown\n * - a non-excluded package is blocked by the cooldown (proving it is active)\n *\n * pnpm reads these settings from `pnpm-workspace.yaml`, mirroring the\n * configuration used by the repo root. The cooldown is only enforced from\n * pnpm 11.1.0 onward (11.0.x silently ignores it), so the scenario is gated to\n * that version range — see {@link isPnpm11Plus}.\n */\n\nconst MINIMUM_RELEASE_AGE = 10080; // 7 days, in minutes\nconst MINIMUM_RELEASE_AGE_EXCLUDE = ['@verdaccio/*', 'verdaccio-*'];\n\nconst PNPM_WORKSPACE_YAML = [\n `minimumReleaseAge: ${MINIMUM_RELEASE_AGE}`,\n // pnpm 12 no longer blocks new direct dependencies by default: it auto-adds\n // them to minimumReleaseAgeExclude in pnpm-workspace.yaml and proceeds.\n // minimumReleaseAgeStrict restores the blocking behavior this scenario\n // asserts (ERR_PNPM_NO_MATURE_MATCHING_VERSION); pnpm 11 ignores the key.\n 'minimumReleaseAgeStrict: true',\n 'minimumReleaseAgeExclude:',\n ...MINIMUM_RELEASE_AGE_EXCLUDE.map((glob) => ` - '${glob}'`),\n '',\n].join('\\n');\n\n/**\n * True only for pnpm versions that actually enforce minimumReleaseAge.\n *\n * The cooldown is honored in pnpm 11.1.0+, but it is silently ignored in\n * 11.0.0 / 11.0.1 (and the 11.0.0 release candidates) — those versions install\n * brand-new packages regardless of the configured cooldown. We scope this\n * scenario to pnpm 11.1.0 and newer so it doesn't false-fail on that regression.\n */\nexport function isPnpm11Plus(adapter: PackageManagerAdapter): boolean {\n if (adapter.type !== 'pnpm') {\n return false;\n }\n const match = adapter.name.match(/pnpm@(\\d+)\\.(\\d+)/);\n if (!match) {\n return false;\n }\n const major = parseInt(match[1], 10);\n const minor = parseInt(match[2], 10);\n return major > 11 || (major === 11 && minor >= 1);\n}\n\nasync function publishPackage(ctx: TestContext, pkgName: string, version: string): Promise<void> {\n trace('publishing %s@%s', pkgName, version);\n const { tempFolder } = await ctx.adapter.prepareProject(\n pkgName,\n version,\n ctx.registryUrl,\n ctx.port,\n ctx.token\n );\n await ctx.adapter.exec(\n { cwd: tempFolder },\n 'publish',\n ...ctx.adapter.registryArg(ctx.registryUrl)\n );\n trace('published %s@%s', pkgName, version);\n}\n\n/**\n * Build a consumer project with the minimumReleaseAge cooldown configured in\n * pnpm-workspace.yaml, depending on the given packages.\n */\nasync function prepareCooldownConsumer(\n ctx: TestContext,\n consumerName: string,\n dependencies: Record<string, string>\n): Promise<string> {\n const { tempFolder } = await ctx.adapter.prepareProject(\n consumerName,\n '1.0.0',\n ctx.registryUrl,\n ctx.port,\n ctx.token,\n dependencies\n );\n await writeFile(join(tempFolder, 'pnpm-workspace.yaml'), PNPM_WORKSPACE_YAML);\n trace('prepared cooldown consumer %s at %s', consumerName, tempFolder);\n return tempFolder;\n}\n\nasync function testMinimumReleaseAge(ctx: TestContext): Promise<void> {\n const id = ctx.runId;\n\n const excludedScoped = `@verdaccio/release-age-${id}`;\n const excludedUnscoped = `verdaccio-release-age-${id}`;\n const blocked = `e2e-release-age-blocked-${id}`;\n\n // --- Phase 1: Publish brand-new (age ~0) packages ---\n await ctx.subTest('publish fresh packages', async () => {\n await publishPackage(ctx, excludedScoped, '1.0.0');\n await publishPackage(ctx, excludedUnscoped, '1.0.0');\n await publishPackage(ctx, blocked, '1.0.0');\n });\n\n // --- Phase 2: Excluded packages install despite the cooldown ---\n await ctx.subTest('excluded packages bypass the cooldown', async () => {\n const tempFolder = await prepareCooldownConsumer(ctx, `@verdaccio/consumer-excluded-${id}`, {\n [excludedScoped]: '1.0.0',\n [excludedUnscoped]: '1.0.0',\n });\n\n // Should succeed: both deps match the exclude globs.\n await ctx.adapter.exec(\n { cwd: tempFolder },\n 'install',\n ...ctx.adapter.registryArg(ctx.registryUrl)\n );\n\n trace('excluded packages installed successfully under cooldown');\n });\n\n // --- Phase 3: Non-excluded fresh package is blocked by the cooldown ---\n await ctx.subTest('non-excluded fresh package is blocked', async () => {\n const tempFolder = await prepareCooldownConsumer(ctx, `e2e-consumer-blocked-${id}`, {\n [blocked]: '1.0.0',\n });\n\n let errorMessage = '';\n try {\n await ctx.adapter.exec(\n { cwd: tempFolder },\n 'install',\n // pnpm 12's parser rejects the `--flag=false` form; --no-frozen-lockfile\n // is accepted by pnpm 10, 11 and 12 alike\n '--no-frozen-lockfile',\n ...ctx.adapter.registryArg(ctx.registryUrl)\n );\n } catch (err) {\n errorMessage = err instanceof Error ? err.message : String(err);\n trace('install correctly rejected by cooldown: %s', errorMessage.split('\\n')[0]);\n }\n\n assert.ok(\n errorMessage,\n `Expected install of fresh non-excluded package \"${blocked}\" to be blocked by ` +\n `minimumReleaseAge (${MINIMUM_RELEASE_AGE} min), but it succeeded`\n );\n // pnpm reports ERR_PNPM_NO_MATURE_MATCHING_VERSION / \"minimumReleaseAge\" when a\n // version is too new. Assert the failure is the cooldown, not an unrelated error.\n assert.ok(\n /minimumReleaseAge|NO_MATURE_MATCHING_VERSION/i.test(errorMessage),\n `Install of \"${blocked}\" failed for an unexpected reason (expected a minimumReleaseAge ` +\n `cooldown error):\\n${errorMessage}`\n );\n });\n}\n\nexport const minimumReleaseAgeScenario: TestDefinition = {\n name: 'scenario:minimum-release-age',\n requires: ['publish', 'install'],\n appliesTo: isPnpm11Plus,\n run: testMinimumReleaseAge,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,IAAM,sBAAsB;AAG5B,IAAM,sBAAsB;CAC1B,sBAAsB;CAKtB;CACA;CACA,GAAG,CAVgC,gBAAgB,aAUhD,CAAA,CAA4B,KAAK,SAAS,QAAQ,KAAK,EAAE;CAC5D;AACF,CAAC,CAAC,KAAK,IAAI;;;;;;;;;AAUX,SAAgB,aAAa,SAAyC;CACpE,IAAI,QAAQ,S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ACzF,iBAAiB;IACjB,mBAAmB;EACtB,CAAC;EAGD,MAAM,IAAI,QAAQ,KAChB,EAAE,KAAK,WAAW,GAClB,WACA,GAAG,IAAI,QAAQ,YAAY,IAAI,WAAW,CAC5C;EAEA,gBAAA,MAAM,yDAAyD;CACjE,CAAC;CAGD,MAAM,IAAI,QAAQ,yCAAyC,YAAY;EACrE,MAAM,aAAa,MAAM,wBAAwB,KAAK,wBAAwB,MAAM,GACjF,UAAU,QACb,CAAC;EAED,IAAI,eAAe;EACnB,IAAI;GACF,MAAM,IAAI,QAAQ,KAChB,EAAE,KAAK,WAAW,GAClB,WAGA,wBACA,GAAG,IAAI,QAAQ,YAAY,IAAI,WAAW,CAC5C;EACF,SAAS,KAAK;GACZ,eAAe,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;GAC9D,gBAAA,MAAM,8CAA8C,aAAa,MAAM,IAAI,CAAC,CAAC,EAAE;EACjF;EAEA,OAAA,QAAO,GACL,cACA,mDAAmD,QAAQ,wCACnC,oBAAoB,wBAC9C;EAGA,OAAA,QAAO,GACL,gDAAgD,KAAK,YAAY,GACjE,eAAe,QAAQ,oFACA,cACzB;CACF,CAAC;AACH;AAEA,IAAa,4BAA4C;CACvD,MAAM;CACN,UAAU,CAAC,WAAW,SAAS;CAC/B,WAAW;CACX,KAAK;AACP"}
1
+ {"version":3,"file":"minimum-release-age.cjs","names":[],"sources":["../../../src/scenarios/minimum-release-age.ts"],"sourcesContent":["import assert from 'assert';\nimport { writeFile } from 'fs/promises';\nimport { join } from 'path';\n\nimport { PackageManagerAdapter, TestContext, TestDefinition } from '../types';\nimport { trace } from '../utils/process';\n\n/**\n * Scenario: minimum-release-age (pnpm 11.1+ only)\n *\n * Exercises pnpm's `minimumReleaseAge` cooldown together with\n * `minimumReleaseAgeExclude`. With a 7-day (10080 minute) cooldown, freshly\n * published versions are normally not installable until they age past the\n * threshold — but packages matching the exclude globs bypass the check.\n *\n * minimumReleaseAge: 10080\n * minimumReleaseAgeStrict: true\n * minimumReleaseAgeExclude:\n * - '@verdaccio/*'\n * - 'verdaccio-*'\n *\n * minimumReleaseAgeStrict is required on pnpm 12: without it, pnpm 12\n * auto-adds new direct dependencies to minimumReleaseAgeExclude instead of\n * failing. pnpm 11 enforces the cooldown unconditionally and ignores the key.\n *\n * The scenario publishes brand-new (age ~0) packages and asserts:\n * - an excluded scoped package (@verdaccio/*) installs despite the cooldown\n * - an excluded unscoped package (verdaccio-*) installs despite the cooldown\n * - a non-excluded package is blocked by the cooldown (proving it is active)\n *\n * pnpm reads these settings from `pnpm-workspace.yaml`, mirroring the\n * configuration used by the repo root. The cooldown is only enforced from\n * pnpm 11.1.0 onward (11.0.x silently ignores it), so the scenario is gated to\n * that version range — see {@link isPnpm11Plus}.\n */\n\nconst MINIMUM_RELEASE_AGE = 10080; // 7 days, in minutes\nconst MINIMUM_RELEASE_AGE_EXCLUDE = ['@verdaccio/*', 'verdaccio-*'];\n\nconst PNPM_WORKSPACE_YAML = [\n `minimumReleaseAge: ${MINIMUM_RELEASE_AGE}`,\n // pnpm 12 no longer blocks new direct dependencies by default: it auto-adds\n // them to minimumReleaseAgeExclude in pnpm-workspace.yaml and proceeds.\n // minimumReleaseAgeStrict restores the blocking behavior this scenario\n // asserts (ERR_PNPM_NO_MATURE_MATCHING_VERSION); pnpm 11 ignores the key.\n 'minimumReleaseAgeStrict: true',\n 'minimumReleaseAgeExclude:',\n ...MINIMUM_RELEASE_AGE_EXCLUDE.map((glob) => ` - '${glob}'`),\n '',\n].join('\\n');\n\n/**\n * True only for pnpm versions that actually enforce minimumReleaseAge.\n *\n * The cooldown is honored in pnpm 11.1.0+, but it is silently ignored in\n * 11.0.0 / 11.0.1 (and the 11.0.0 release candidates) — those versions install\n * brand-new packages regardless of the configured cooldown. We scope this\n * scenario to pnpm 11.1.0 and newer so it doesn't false-fail on that regression.\n */\nexport function isPnpm11Plus(adapter: PackageManagerAdapter): boolean {\n if (adapter.type !== 'pnpm') {\n return false;\n }\n const match = adapter.name.match(/pnpm@(\\d+)\\.(\\d+)/);\n if (!match) {\n return false;\n }\n const major = parseInt(match[1], 10);\n const minor = parseInt(match[2], 10);\n return major > 11 || (major === 11 && minor >= 1);\n}\n\nasync function publishPackage(ctx: TestContext, pkgName: string, version: string): Promise<void> {\n trace('publishing %s@%s', pkgName, version);\n const { tempFolder } = await ctx.adapter.prepareProject(\n pkgName,\n version,\n ctx.registryUrl,\n ctx.port,\n ctx.token\n );\n await ctx.adapter.exec(\n { cwd: tempFolder },\n 'publish',\n ...ctx.adapter.registryArg(ctx.registryUrl)\n );\n trace('published %s@%s', pkgName, version);\n}\n\n/**\n * Build a consumer project with the minimumReleaseAge cooldown configured in\n * pnpm-workspace.yaml, depending on the given packages.\n */\nasync function prepareCooldownConsumer(\n ctx: TestContext,\n consumerName: string,\n dependencies: Record<string, string>\n): Promise<string> {\n const { tempFolder } = await ctx.adapter.prepareProject(\n consumerName,\n '1.0.0',\n ctx.registryUrl,\n ctx.port,\n ctx.token,\n dependencies\n );\n await writeFile(join(tempFolder, 'pnpm-workspace.yaml'), PNPM_WORKSPACE_YAML);\n trace('prepared cooldown consumer %s at %s', consumerName, tempFolder);\n return tempFolder;\n}\n\nasync function testMinimumReleaseAge(ctx: TestContext): Promise<void> {\n const id = ctx.runId;\n\n const excludedScoped = `@verdaccio/release-age-${id}`;\n const excludedUnscoped = `verdaccio-release-age-${id}`;\n const blocked = `e2e-release-age-blocked-${id}`;\n\n // --- Phase 1: Publish brand-new (age ~0) packages ---\n await ctx.subTest('publish fresh packages', async () => {\n await publishPackage(ctx, excludedScoped, '1.0.0');\n await publishPackage(ctx, excludedUnscoped, '1.0.0');\n await publishPackage(ctx, blocked, '1.0.0');\n });\n\n // --- Phase 2: Excluded packages install despite the cooldown ---\n await ctx.subTest('excluded packages bypass the cooldown', async () => {\n const tempFolder = await prepareCooldownConsumer(ctx, `@verdaccio/consumer-excluded-${id}`, {\n [excludedScoped]: '1.0.0',\n [excludedUnscoped]: '1.0.0',\n });\n\n // Should succeed: both deps match the exclude globs.\n await ctx.adapter.exec(\n { cwd: tempFolder },\n 'install',\n ...ctx.adapter.registryArg(ctx.registryUrl)\n );\n\n trace('excluded packages installed successfully under cooldown');\n });\n\n // --- Phase 3: Non-excluded fresh package is blocked by the cooldown ---\n await ctx.subTest('non-excluded fresh package is blocked', async () => {\n const tempFolder = await prepareCooldownConsumer(ctx, `e2e-consumer-blocked-${id}`, {\n [blocked]: '1.0.0',\n });\n\n let errorMessage = '';\n try {\n await ctx.adapter.exec(\n { cwd: tempFolder },\n 'install',\n // pnpm 12's parser rejects the `--flag=false` form; --no-frozen-lockfile\n // is accepted by pnpm 11 and 12 alike\n '--no-frozen-lockfile',\n ...ctx.adapter.registryArg(ctx.registryUrl)\n );\n } catch (err) {\n errorMessage = err instanceof Error ? err.message : String(err);\n trace('install correctly rejected by cooldown: %s', errorMessage.split('\\n')[0]);\n }\n\n assert.ok(\n errorMessage,\n `Expected install of fresh non-excluded package \"${blocked}\" to be blocked by ` +\n `minimumReleaseAge (${MINIMUM_RELEASE_AGE} min), but it succeeded`\n );\n // pnpm reports ERR_PNPM_NO_MATURE_MATCHING_VERSION / \"minimumReleaseAge\" when a\n // version is too new. Assert the failure is the cooldown, not an unrelated error.\n assert.ok(\n /minimumReleaseAge|NO_MATURE_MATCHING_VERSION/i.test(errorMessage),\n `Install of \"${blocked}\" failed for an unexpected reason (expected a minimumReleaseAge ` +\n `cooldown error):\\n${errorMessage}`\n );\n });\n}\n\nexport const minimumReleaseAgeScenario: TestDefinition = {\n name: 'scenario:minimum-release-age',\n requires: ['publish', 'install'],\n appliesTo: isPnpm11Plus,\n run: testMinimumReleaseAge,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,IAAM,sBAAsB;AAG5B,IAAM,sBAAsB;CAC1B,sBAAsB;CAKtB;CACA;CACA,GAAG,CAVgC,gBAAgB,aAUhD,CAAA,CAA4B,KAAK,SAAS,QAAQ,KAA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,CAAC;CAGD,MAAM,IAAI,QAAQ,yCAAyC,YAAY;EACrE,MAAM,aAAa,MAAM,wBAAwB,KAAK,gCAAgC,MAAM;IACzF,iBAAiB;IACjB,mBAAmB;EACtB,CAAC;EAGD,MAAM,IAAI,QAAQ,KAChB,EAAE,KAAK,WAAW,GAClB,WACA,GAAG,IAAI,QAAQ,YAAY,IAAI,WAAW,CAC5C;EAEA,gBAAA,MAAM,yDAAyD;CACjE,CAAC;CAGD,MAAM,IAAI,QAAQ,yCAAyC,YAAY;EACrE,MAAM,aAAa,MAAM,wBAAwB,KAAK,wBAAwB,MAAM,GACjF,UAAU,QACb,CAAC;EAED,IAAI,eAAe;EACnB,IAAI;GACF,MAAM,IAAI,QAAQ,KAChB,EAAE,KAAK,WAAW,GAClB,WAGA,wBACA,GAAG,IAAI,QAAQ,YAAY,IAAI,WAAW,CAC5C;EACF,SAAS,KAAK;GACZ,eAAe,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;GAC9D,gBAAA,MAAM,8CAA8C,aAAa,MAAM,IAAI,CAAC,CAAC,EAAE;EACjF;EAEA,OAAA,QAAO,GACL,cACA,mDAAmD,QAAQ,wCACnC,oBAAoB,wBAC9C;EAGA,OAAA,QAAO,GACL,gDAAgD,KAAK,YAAY,GACjE,eAAe,QAAQ,oFACA,cACzB;CACF,CAAC;AACH;AAEA,IAAa,4BAA4C;CACvD,MAAM;CACN,UAAU,CAAC,WAAW,SAAS;CAC/B,WAAW;CACX,KAAK;AACP"}
@@ -1,5 +1,6 @@
1
1
  const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
2
2
  const require_project = require("../utils/project.cjs");
3
+ const require_registry_client = require("../utils/registry-client.cjs");
3
4
  let debug = require("debug");
4
5
  debug = require_runtime.__toESM(debug, 1);
5
6
  let path = require("path");
@@ -114,6 +115,29 @@ async function testLogin(ctx) {
114
115
  const who2 = await yarnWhoami(ctx, tf);
115
116
  assert.default.ok(who2.includes(user2), `Expected "${user2}" after switch but got "${who2}"`);
116
117
  });
118
+ for (const client of [
119
+ "npm",
120
+ "yarn",
121
+ "pnpm"
122
+ ]) {
123
+ await ctx.subTest(`${client} logs an existing user in with the Basic retry`, async () => {
124
+ const user = `login-retry-${client}-${id}`;
125
+ const password = "retry-password-123";
126
+ await require_registry_client.createUser(ctx.registryUrl, user, password);
127
+ const token = await require_registry_client.legacyLogin(ctx.registryUrl, user, password, client);
128
+ assert.default.strictEqual(await require_registry_client.whoami(ctx.registryUrl, token), user);
129
+ });
130
+ await ctx.subTest(`${client} registers a new user`, async () => {
131
+ const user = `login-new-${client}-${id}`;
132
+ const token = await require_registry_client.legacyLogin(ctx.registryUrl, user, "retry-password-123", client);
133
+ assert.default.strictEqual(await require_registry_client.whoami(ctx.registryUrl, token), user);
134
+ });
135
+ await ctx.subTest(`${client} cannot log an existing user in with a wrong password`, async () => {
136
+ const user = `login-wrong-${client}-${id}`;
137
+ await require_registry_client.createUser(ctx.registryUrl, user, "retry-password-123");
138
+ await assert.default.rejects(require_registry_client.legacyLogin(ctx.registryUrl, user, "wrong-password", client), (error) => error instanceof require_registry_client.LegacyLoginError && error.status === 401);
139
+ });
140
+ }
117
141
  }
118
142
  var loginTest = {
119
143
  name: "login",
@@ -1 +1 @@
1
- {"version":3,"file":"login.cjs","names":[],"sources":["../../../src/tests/login.ts"],"sourcesContent":["import assert from 'assert';\nimport buildDebug from 'debug';\nimport { writeFile } from 'fs/promises';\nimport * as YAML from 'js-yaml';\nimport { join } from 'path';\n\nimport { TestContext, TestDefinition } from '../types';\nimport { createTempFolder, getPackageJSON, getREADME } from '../utils/project';\n\nconst debug = buildDebug('verdaccio:e2e-cli:test:login');\n\n/**\n * Creates a project with registry config but WITHOUT auth token,\n * so whoami will use the token saved by login to ~/.yarnrc.yml.\n */\nasync function prepareLoginProject(ctx: TestContext, name: string): Promise<string> {\n debug('preparing project for %s (no auth token)', name);\n const tempFolder = await createTempFolder(name);\n const yamlContent = YAML.dump({\n npmRegistryServer: ctx.registryUrl,\n enableImmutableInstalls: false,\n unsafeHttpWhitelist: ['localhost'],\n });\n await writeFile(join(tempFolder, '.yarnrc.yml'), yamlContent);\n await writeFile(join(tempFolder, 'package.json'), JSON.stringify({ name, version: '1.0.0' }));\n if (ctx.adapter.importPlugin) {\n debug('importing npm-login plugin into %s', tempFolder);\n await ctx.adapter.importPlugin(tempFolder, 'npm-login');\n }\n return tempFolder;\n}\n\nasync function yarnLogin(\n ctx: TestContext,\n cwd: string,\n user: string,\n password: string,\n email: string\n) {\n debug('yarn npm login as %s', user);\n return ctx.adapter.exec(\n { cwd },\n 'login',\n '--auth-type=legacy',\n `--user=${user}`,\n `--password=${password}`,\n `--email=${email}`\n );\n}\n\nasync function yarnWhoami(ctx: TestContext, cwd: string): Promise<string> {\n const resp = await ctx.adapter.exec({ cwd }, 'whoami');\n debug('yarn npm whoami: %s', resp.stdout);\n return resp.stdout;\n}\n\nasync function testLogin(ctx: TestContext): Promise<void> {\n const type = ctx.adapter.type;\n const id = ctx.runId;\n\n if (type !== 'yarn-modern') {\n debug('login test only supported for yarn-modern, skipping %s', type);\n return;\n }\n\n const user1 = `login-a-${id}`;\n const password1 = 'test-password-123';\n const email1 = `${user1}@test.example.com`;\n\n await ctx.subTest('create new user + whoami', async () => {\n const tf = await prepareLoginProject(ctx, `verdaccio-login1-${id}`);\n const loginResp = await yarnLogin(ctx, tf, user1, password1, email1);\n assert.ok(\n loginResp.stdout.includes('Logged in') || loginResp.stdout.includes('token saved'),\n `Expected login success message but got \"${loginResp.stdout}\"`\n );\n const who = await yarnWhoami(ctx, tf);\n assert.ok(who.includes(user1), `Expected whoami \"${user1}\" but got \"${who}\"`);\n });\n\n await ctx.subTest('legacy re-login is rejected without basic auth', async () => {\n const tf = await prepareLoginProject(ctx, `verdaccio-login2-${id}`);\n let loginFailed = false;\n try {\n await yarnLogin(ctx, tf, user1, password1, email1);\n } catch {\n loginFailed = true;\n }\n assert.ok(loginFailed, 'Legacy re-login for an existing user should fail without Basic auth');\n });\n\n await ctx.subTest('wrong password fails', async () => {\n const tf = await prepareLoginProject(ctx, `verdaccio-login3-${id}`);\n let loginFailed = false;\n try {\n await yarnLogin(ctx, tf, user1, 'wrong-password', email1);\n } catch {\n loginFailed = true;\n }\n assert.ok(loginFailed, 'Login with wrong password should have failed');\n });\n\n await ctx.subTest('login then publish', async () => {\n const pkgName = `@verdaccio/login-pub-${id}`;\n const publishUser = `login-pub-${id}`;\n const publishPassword = 'publish-password-123';\n const publishEmail = `${publishUser}@test.example.com`;\n const tf = await createTempFolder(`login-pub-${id}`);\n const yamlContent = YAML.dump({\n npmRegistryServer: ctx.registryUrl,\n enableImmutableInstalls: false,\n unsafeHttpWhitelist: ['localhost'],\n });\n await writeFile(join(tf, '.yarnrc.yml'), yamlContent);\n await writeFile(join(tf, 'package.json'), getPackageJSON(pkgName, '1.0.0'));\n await writeFile(join(tf, 'README.md'), getREADME(pkgName));\n if (ctx.adapter.importPlugin) {\n await ctx.adapter.importPlugin(tf, 'npm-login');\n }\n await yarnLogin(ctx, tf, publishUser, publishPassword, publishEmail);\n await ctx.adapter.exec({ cwd: tf }, 'install');\n const pubResp = await ctx.adapter.exec({ cwd: tf }, 'publish');\n assert.ok(\n pubResp.stdout.includes('Package archive published'),\n `Expected publish success but got \"${pubResp.stdout}\"`\n );\n });\n\n await ctx.subTest('switch users', async () => {\n const switchUser1 = `login-switch-a-${id}`;\n const switchPassword1 = 'switch-password-123';\n const switchEmail1 = `${switchUser1}@test.example.com`;\n const user2 = `login-b-${id}`;\n const password2 = 'other-password-456';\n const email2 = `${user2}@test.example.com`;\n const tf = await prepareLoginProject(ctx, `verdaccio-login5-${id}`);\n\n await yarnLogin(ctx, tf, switchUser1, switchPassword1, switchEmail1);\n const who1 = await yarnWhoami(ctx, tf);\n assert.ok(who1.includes(switchUser1), `Expected \"${switchUser1}\" but got \"${who1}\"`);\n\n await yarnLogin(ctx, tf, user2, password2, email2);\n const who2 = await yarnWhoami(ctx, tf);\n assert.ok(who2.includes(user2), `Expected \"${user2}\" after switch but got \"${who2}\"`);\n });\n}\n\nexport const loginTest: TestDefinition = {\n name: 'login',\n requires: ['login'],\n run: testLogin,\n};\n"],"mappings":";;;;;;;;;;;AASA,IAAM,WAAA,GAAQ,MAAA,QAAA,CAAW,8BAA8B;;;;;AAMvD,eAAe,oBAAoB,KAAkB,MAA+B;CAClF,QAAM,4CAA4C,IAAI;CACtD,MAAM,aAAa,MAAM,gBAAA,iBAAiB,IAAI;CAC9C,MAAM,cAAc,QAAK,KAAK;EAC5B,mBAAmB,IAAI;EACvB,yBAAyB;EACzB,qBAAqB,CAAC,WAAW;CACnC,CAAC;CACD,OAAA,GAAM,YAAA,UAAA,EAAA,GAAU,KAAA,KAAA,CAAK,YAAY,aAAa,GAAG,WAAW;CAC5D,OAAA,GAAM,YAAA,UAAA,EAAA,GAAU,KAAA,KAAA,CAAK,YAAY,cAAc,GAAG,KAAK,UAAU;EAAE;EAAM,SAAS;CAAQ,CAAC,CAAC;CAC5F,IAAI,IAAI,QAAQ,cAAc;EAC5B,QAAM,sCAAsC,UAAU;EACtD,MAAM,IAAI,QAAQ,aAAa,YAAY,WAAW;CACxD;CACA,OAAO;AACT;AAEA,eAAe,UACb,KACA,KACA,MACA,UACA,OACA;CACA,QAAM,wBAAwB,IAAI;CAClC,OAAO,IAAI,QAAQ,KACjB,EAAE,IAAI,GACN,SACA,sBACA,UAAU,QACV,cAAc,YACd,WAAW,OACb;AACF;AAEA,eAAe,WAAW,KAAkB,KAA8B;CACxE,MAAM,OAAO,MAAM,IAAI,QAAQ,KAAK,EAAE,IAAI,GAAG,QAAQ;CACrD,QAAM,uBAAuB,KAAK,MAAM;CACxC,OAAO,KAAK;AACd;AAEA,eAAe,UAAU,KAAiC;CACxD,MAAM,OAAO,IAAI,QAAQ;CACzB,MAAM,KAAK,IAAI;CAEf,IAAI,SAAS,eAAe;EAC1B,QAAM,0DAA0D,IAAI;EACpE;CACF;CAEA,MAAM,QAAQ,WAAW;CACzB,MAAM,Y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;CACtF,CAAC;AACH;AAEA,IAAa,YAA4B;CACvC,MAAM;CACN,UAAU,CAAC,OAAO;CAClB,KAAK;AACP"}
1
+ {"version":3,"file":"login.cjs","names":[],"sources":["../../../src/tests/login.ts"],"sourcesContent":["import assert from 'assert';\nimport buildDebug from 'debug';\nimport { writeFile } from 'fs/promises';\nimport * as YAML from 'js-yaml';\nimport { join } from 'path';\n\nimport { TestContext, TestDefinition } from '../types';\nimport { createTempFolder, getPackageJSON, getREADME } from '../utils/project';\nimport { LegacyLoginError, createUser, legacyLogin, whoami } from '../utils/registry-client';\n\nconst debug = buildDebug('verdaccio:e2e-cli:test:login');\n\n/**\n * Creates a project with registry config but WITHOUT auth token,\n * so whoami will use the token saved by login to ~/.yarnrc.yml.\n */\nasync function prepareLoginProject(ctx: TestContext, name: string): Promise<string> {\n debug('preparing project for %s (no auth token)', name);\n const tempFolder = await createTempFolder(name);\n const yamlContent = YAML.dump({\n npmRegistryServer: ctx.registryUrl,\n enableImmutableInstalls: false,\n unsafeHttpWhitelist: ['localhost'],\n });\n await writeFile(join(tempFolder, '.yarnrc.yml'), yamlContent);\n await writeFile(join(tempFolder, 'package.json'), JSON.stringify({ name, version: '1.0.0' }));\n if (ctx.adapter.importPlugin) {\n debug('importing npm-login plugin into %s', tempFolder);\n await ctx.adapter.importPlugin(tempFolder, 'npm-login');\n }\n return tempFolder;\n}\n\nasync function yarnLogin(\n ctx: TestContext,\n cwd: string,\n user: string,\n password: string,\n email: string\n) {\n debug('yarn npm login as %s', user);\n return ctx.adapter.exec(\n { cwd },\n 'login',\n '--auth-type=legacy',\n `--user=${user}`,\n `--password=${password}`,\n `--email=${email}`\n );\n}\n\nasync function yarnWhoami(ctx: TestContext, cwd: string): Promise<string> {\n const resp = await ctx.adapter.exec({ cwd }, 'whoami');\n debug('yarn npm whoami: %s', resp.stdout);\n return resp.stdout;\n}\n\nasync function testLogin(ctx: TestContext): Promise<void> {\n const type = ctx.adapter.type;\n const id = ctx.runId;\n\n if (type !== 'yarn-modern') {\n debug('login test only supported for yarn-modern, skipping %s', type);\n return;\n }\n\n const user1 = `login-a-${id}`;\n const password1 = 'test-password-123';\n const email1 = `${user1}@test.example.com`;\n\n await ctx.subTest('create new user + whoami', async () => {\n const tf = await prepareLoginProject(ctx, `verdaccio-login1-${id}`);\n const loginResp = await yarnLogin(ctx, tf, user1, password1, email1);\n assert.ok(\n loginResp.stdout.includes('Logged in') || loginResp.stdout.includes('token saved'),\n `Expected login success message but got \"${loginResp.stdout}\"`\n );\n const who = await yarnWhoami(ctx, tf);\n assert.ok(who.includes(user1), `Expected whoami \"${user1}\" but got \"${who}\"`);\n });\n\n await ctx.subTest('legacy re-login is rejected without basic auth', async () => {\n const tf = await prepareLoginProject(ctx, `verdaccio-login2-${id}`);\n let loginFailed = false;\n try {\n await yarnLogin(ctx, tf, user1, password1, email1);\n } catch {\n loginFailed = true;\n }\n assert.ok(loginFailed, 'Legacy re-login for an existing user should fail without Basic auth');\n });\n\n await ctx.subTest('wrong password fails', async () => {\n const tf = await prepareLoginProject(ctx, `verdaccio-login3-${id}`);\n let loginFailed = false;\n try {\n await yarnLogin(ctx, tf, user1, 'wrong-password', email1);\n } catch {\n loginFailed = true;\n }\n assert.ok(loginFailed, 'Login with wrong password should have failed');\n });\n\n await ctx.subTest('login then publish', async () => {\n const pkgName = `@verdaccio/login-pub-${id}`;\n const publishUser = `login-pub-${id}`;\n const publishPassword = 'publish-password-123';\n const publishEmail = `${publishUser}@test.example.com`;\n const tf = await createTempFolder(`login-pub-${id}`);\n const yamlContent = YAML.dump({\n npmRegistryServer: ctx.registryUrl,\n enableImmutableInstalls: false,\n unsafeHttpWhitelist: ['localhost'],\n });\n await writeFile(join(tf, '.yarnrc.yml'), yamlContent);\n await writeFile(join(tf, 'package.json'), getPackageJSON(pkgName, '1.0.0'));\n await writeFile(join(tf, 'README.md'), getREADME(pkgName));\n if (ctx.adapter.importPlugin) {\n await ctx.adapter.importPlugin(tf, 'npm-login');\n }\n await yarnLogin(ctx, tf, publishUser, publishPassword, publishEmail);\n await ctx.adapter.exec({ cwd: tf }, 'install');\n const pubResp = await ctx.adapter.exec({ cwd: tf }, 'publish');\n assert.ok(\n pubResp.stdout.includes('Package archive published'),\n `Expected publish success but got \"${pubResp.stdout}\"`\n );\n });\n\n await ctx.subTest('switch users', async () => {\n const switchUser1 = `login-switch-a-${id}`;\n const switchPassword1 = 'switch-password-123';\n const switchEmail1 = `${switchUser1}@test.example.com`;\n const user2 = `login-b-${id}`;\n const password2 = 'other-password-456';\n const email2 = `${user2}@test.example.com`;\n const tf = await prepareLoginProject(ctx, `verdaccio-login5-${id}`);\n\n await yarnLogin(ctx, tf, switchUser1, switchPassword1, switchEmail1);\n const who1 = await yarnWhoami(ctx, tf);\n assert.ok(who1.includes(switchUser1), `Expected \"${switchUser1}\" but got \"${who1}\"`);\n\n await yarnLogin(ctx, tf, user2, password2, email2);\n const who2 = await yarnWhoami(ctx, tf);\n assert.ok(who2.includes(user2), `Expected \"${user2}\" after switch but got \"${who2}\"`);\n });\n\n // replayed over HTTP: what `npm login`, native `yarn npm login` and `pnpm login` send\n for (const client of ['npm', 'yarn', 'pnpm'] as const) {\n await ctx.subTest(`${client} logs an existing user in with the Basic retry`, async () => {\n const user = `login-retry-${client}-${id}`;\n const password = 'retry-password-123';\n await createUser(ctx.registryUrl, user, password);\n\n const token = await legacyLogin(ctx.registryUrl, user, password, client);\n assert.strictEqual(await whoami(ctx.registryUrl, token), user);\n });\n\n await ctx.subTest(`${client} registers a new user`, async () => {\n const user = `login-new-${client}-${id}`;\n\n const token = await legacyLogin(ctx.registryUrl, user, 'retry-password-123', client);\n assert.strictEqual(await whoami(ctx.registryUrl, token), user);\n });\n\n await ctx.subTest(\n `${client} cannot log an existing user in with a wrong password`,\n async () => {\n const user = `login-wrong-${client}-${id}`;\n await createUser(ctx.registryUrl, user, 'retry-password-123');\n\n await assert.rejects(\n legacyLogin(ctx.registryUrl, user, 'wrong-password', client),\n (error: unknown) => error instanceof LegacyLoginError && error.status === 401\n );\n }\n );\n }\n}\n\nexport const loginTest: TestDefinition = {\n name: 'login',\n requires: ['login'],\n run: testLogin,\n};\n"],"mappings":";;;;;;;;;;;;AAUA,IAAM,WAAA,GAAQ,MAAA,QAAA,CAAW,8BAA8B;;;;;AAMvD,eAAe,oBAAoB,KAAkB,MAA+B;CAClF,QAAM,4CAA4C,IAAI;CACtD,MAAM,aAAa,MAAM,gBAAA,iBAAiB,IAAI;CAC9C,MAAM,cAAc,QAAK,KAAK;EAC5B,mBAAmB,IAAI;EACvB,yBAAyB;EACzB,qBAAqB,CAAC,WAAW;CACnC,CAAC;CACD,OAAA,GAAM,YAAA,UAAA,EAAA,GAAU,KAAA,KAAA,CAAK,YAAY,aAAa,GAAG,WAAW;CAC5D,OAAA,GAAM,YAAA,UAAA,EAAA,GAAU,KAAA,KAAA,CAAK,YAAY,cAAc,GAAG,KAAK,UAAU;EAAE;EAAM,SAAS;CAAQ,CAAC,CAAC;CAC5F,IAAI,IAAI,QAAQ,cAAc;EAC5B,QAAM,sCAAsC,UAAU;EACtD,MAAM,IAAI,QAAQ,aAAa,YAAY,WAAW;CACxD;CACA,OAAO;AACT;AAEA,eAAe,UACb,KACA,KACA,MACA,UACA,OACA;CACA,QAAM,wBAAwB,IAAI;CAClC,OAAO,IAAI,QAAQ,KACjB,EAAE,IAAI,GACN,SACA,sBACA,UAAU,QACV,cAAc,YACd,WAAW,OACb;AACF;AAEA,eAAe,WAAW,KAAkB,KAA8B;CACxE,MAAM,OAAO,MAAM,IAAI,QAAQ,KAAK,EAAE,IAAI,GAAG,QAAQ;CACrD,QAAM,uBAAuB,KAAK,MAAM;CACxC,OAAO,KAAK;AACd;AAEA,eAAe,UAAU,KAAiC;CACxD,MAAM,OAAO,IAAI,QAAQ;CACzB,MAAM,KAAK,IAAI;CAEf,IAAI,SAAS,eAAe;EAC1B,QAAM,0DAA0D,IAAI;EACpE;CACF;CAEA,MAAM,QAAQ,WAAW;CACzB,MAAM,YAA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ACtF,CAAC;CAGD,KAAK,MAAM,UAAU;EAAC;EAAO;EAAQ;CAAM,GAAY;EACrD,MAAM,IAAI,QAAQ,GAAG,OAAO,iDAAiD,YAAY;GACvF,MAAM,OAAO,eAAe,OAAO,GAAG;GACtC,MAAM,WAAW;GACjB,MAAM,wBAAA,WAAW,IAAI,aAAa,MAAM,QAAQ;GAEhD,MAAM,QAAQ,MAAM,wBAAA,YAAY,IAAI,aAAa,MAAM,UAAU,MAAM;GACvE,OAAA,QAAO,YAAY,MAAM,wBAAA,OAAO,IAAI,aAAa,KAAK,GAAG,IAAI;EAC/D,CAAC;EAED,MAAM,IAAI,QAAQ,GAAG,OAAO,wBAAwB,YAAY;GAC9D,MAAM,OAAO,aAAa,OAAO,GAAG;GAEpC,MAAM,QAAQ,MAAM,wBAAA,YAAY,IAAI,aAAa,MAAM,sBAAsB,MAAM;GACnF,OAAA,QAAO,YAAY,MAAM,wBAAA,OAAO,IAAI,aAAa,KAAK,GAAG,IAAI;EAC/D,CAAC;EAED,MAAM,IAAI,QACR,GAAG,OAAO,wDACV,YAAY;GACV,MAAM,OAAO,eAAe,OAAO,GAAG;GACtC,MAAM,wBAAA,WAAW,IAAI,aAAa,MAAM,oBAAoB;GAE5D,MAAM,OAAA,QAAO,QACX,wBAAA,YAAY,IAAI,aAAa,MAAM,kBAAkB,MAAM,IAC1D,UAAmB,iBAAiB,wBAAA,oBAAoB,MAAM,WAAW,GAC5E;EACF,CACF;CACF;AACF;AAEA,IAAa,YAA4B;CACvC,MAAM;CACN,UAAU,CAAC,OAAO;CAClB,KAAK;AACP"}
@@ -49,8 +49,67 @@ async function pingRegistry(registryUrl) {
49
49
  return false;
50
50
  }
51
51
  }
52
+ var LegacyLoginError = class extends Error {
53
+ status;
54
+ constructor(message, status) {
55
+ super(message);
56
+ this.status = status;
57
+ }
58
+ };
59
+ /**
60
+ * Replays the legacy login the way each client sends it. npm and Yarn retry a
61
+ * 409 with Basic (Yarn on the GET too); pnpm sends Basic on a single PUT. A
62
+ * registry that authenticates the first PUT is accepted too.
63
+ */
64
+ async function legacyLogin(registryUrl, user, password, client) {
65
+ const userUrl = `${registryUrl}/-/user/org.couchdb.user:${encodeURIComponent(user)}`;
66
+ const basic = `Basic ${Buffer.from(`${user}:${password}`).toString("base64")}`;
67
+ const jsonHeaders = { "Content-Type": "application/json" };
68
+ const body = {
69
+ _id: `org.couchdb.user:${user}`,
70
+ name: user,
71
+ password,
72
+ type: "user",
73
+ roles: [],
74
+ date: (/* @__PURE__ */ new Date()).toISOString()
75
+ };
76
+ const put = (url, headers) => fetch(url, {
77
+ method: "PUT",
78
+ headers,
79
+ body: JSON.stringify(body)
80
+ });
81
+ const first = await put(userUrl, client === "pnpm" ? {
82
+ ...jsonHeaders,
83
+ Authorization: basic,
84
+ "npm-auth-type": "web"
85
+ } : jsonHeaders);
86
+ const firstBody = await first.json();
87
+ if (first.ok && firstBody.token) {
88
+ debug$1("%s: first PUT authenticated %s", client, user);
89
+ return firstBody.token;
90
+ }
91
+ if (first.status !== 409) throw new LegacyLoginError(`first PUT answered ${first.status}`, first.status);
92
+ const current = await fetch(`${userUrl}?write=true`, { headers: client === "yarn" ? { Authorization: basic } : {} });
93
+ if (!current.ok) throw new LegacyLoginError(`GET answered ${current.status}`, current.status);
94
+ const currentBody = await current.json();
95
+ for (const [key, value] of Object.entries(currentBody)) if (!body[key] || key === "roles") body[key] = value;
96
+ const second = await put(`${userUrl}/-rev/${body._rev}`, {
97
+ ...jsonHeaders,
98
+ Authorization: basic
99
+ });
100
+ const secondBody = await second.json();
101
+ if (!second.ok || !secondBody.token) throw new LegacyLoginError(`PUT with revision answered ${second.status}`, second.status);
102
+ return secondBody.token;
103
+ }
104
+ async function whoami(registryUrl, token) {
105
+ const response = await fetch(`${registryUrl}/-/whoami`, { headers: { Authorization: `Bearer ${token}` } });
106
+ return response.ok ? (await response.json()).username : void 0;
107
+ }
52
108
  //#endregion
109
+ exports.LegacyLoginError = LegacyLoginError;
53
110
  exports.createUser = createUser;
111
+ exports.legacyLogin = legacyLogin;
54
112
  exports.pingRegistry = pingRegistry;
113
+ exports.whoami = whoami;
55
114
 
56
115
  //# sourceMappingURL=registry-client.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry-client.cjs","names":[],"sources":["../../../src/utils/registry-client.ts"],"sourcesContent":["import buildDebug from 'debug';\n\nimport { ping } from '@verdaccio/registry-cli';\n\nconst debug = buildDebug('verdaccio:e2e-cli:registry-client');\n\nexport type RegistryAuth = {\n token: string;\n user: string;\n};\n\n/**\n * Creates a user on the registry and returns the auth token.\n * Uses a unique username per run to avoid 409 conflicts.\n * Works against any running Verdaccio instance with htpasswd auth.\n */\nexport async function createUser(\n registryUrl: string,\n user = `e2e-user-${Date.now()}`,\n password = 'e2e-test-password'\n): Promise<RegistryAuth> {\n debug('creating user %s on %s', user, registryUrl);\n const url = `${registryUrl}/-/user/org.couchdb.user:${encodeURIComponent(user)}`;\n const response = await fetch(url, {\n method: 'PUT',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n name: user,\n password,\n _id: `org.couchdb.user:${user}`,\n type: 'user',\n roles: [],\n date: new Date().toISOString(),\n }),\n });\n\n const body = (await response.json()) as any;\n\n if (response.status === 201 || response.status === 200 || response.status === 409) {\n const token = body.token;\n if (token) {\n debug('user %s authenticated, token obtained', user);\n return { token, user };\n }\n }\n\n throw new Error(\n `Failed to create/login user \"${user}\" on ${registryUrl}: ${response.status} ${JSON.stringify(body)}`\n );\n}\n\n/**\n * Ping the registry to check it's alive.\n * Uses @verdaccio/registry-cli ping.\n */\nexport async function pingRegistry(registryUrl: string): Promise<boolean> {\n debug('pinging %s', registryUrl);\n try {\n const result = await ping(registryUrl);\n return result.ok;\n } catch {\n return false;\n }\n}\n"],"mappings":";;;;;AAIA,IAAM,WAAA,GAAQ,MAAA,QAAA,CAAW,mCAAmC;;;;;;AAY5D,eAAsB,WACpB,aACA,OAAO,YAAY,KAAK,IAAI,KAC5B,WAAW,qBACY;CACvB,QAAM,0BAA0B,MAAM,WAAW;CACjD,MAAM,MAAM,GAAG,YAAY,2BAA2B,mBAAmB,IAAI;CAC7E,MAAM,WAAW,MAAM,MAAM,KAAK;EAChC,QAAQ;EACR,SAAS,EAAE,gBAAgB,mBAAmB;EAC9C,MAAM,KAAK,UAAU;GACnB,MAAM;GACN;GACA,KAAK,oBAAoB;GACzB,MAAM;GACN,OAAO,CAAC;GACR,uBAAM,IAAI,KAAK,EAAA,CAAE,YAAY;EAC/B,CAAC;CACH,CAAC;CAED,MAAM,OAAQ,MAAM,SAAS,KAAK;CAElC,IAAI,SAAS,WAAW,OAAO,SAAS,WAAW,OAAO,SAAS,WAAW,KAAK;EACjF,MAAM,QAAQ,KAAK;EACnB,IAAI,OAAO;GACT,QAAM,yCAAyC,IAAI;GACnD,OAAO;IAAE;IAAO;GAAK;EACvB;CACF;CAEA,MAAM,IAAI,MACR,gCAAgC,KAAK,OAAO,YAAY,IAAI,SAAS,OAAO,GAAG,KAAK,UAAU,IAAI,GACpG;AACF;;;;;AAMA,eAAsB,aAAa,aAAuC;CACxE,QAAM,cAAc,WAAW;CAC/B,IAAI;EAEF,QAAO,OAAA,GADc,wBAAA,KAAA,CAAK,WAAW,EAAA,CACvB;CAChB,QAAQ;EACN,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"registry-client.cjs","names":[],"sources":["../../../src/utils/registry-client.ts"],"sourcesContent":["import buildDebug from 'debug';\n\nimport { ping } from '@verdaccio/registry-cli';\n\nconst debug = buildDebug('verdaccio:e2e-cli:registry-client');\n\nexport type RegistryAuth = {\n token: string;\n user: string;\n};\n\n/**\n * Creates a user on the registry and returns the auth token.\n * Uses a unique username per run to avoid 409 conflicts.\n * Works against any running Verdaccio instance with htpasswd auth.\n */\nexport async function createUser(\n registryUrl: string,\n user = `e2e-user-${Date.now()}`,\n password = 'e2e-test-password'\n): Promise<RegistryAuth> {\n debug('creating user %s on %s', user, registryUrl);\n const url = `${registryUrl}/-/user/org.couchdb.user:${encodeURIComponent(user)}`;\n const response = await fetch(url, {\n method: 'PUT',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n name: user,\n password,\n _id: `org.couchdb.user:${user}`,\n type: 'user',\n roles: [],\n date: new Date().toISOString(),\n }),\n });\n\n const body = (await response.json()) as any;\n\n if (response.status === 201 || response.status === 200 || response.status === 409) {\n const token = body.token;\n if (token) {\n debug('user %s authenticated, token obtained', user);\n return { token, user };\n }\n }\n\n throw new Error(\n `Failed to create/login user \"${user}\" on ${registryUrl}: ${response.status} ${JSON.stringify(body)}`\n );\n}\n\n/**\n * Ping the registry to check it's alive.\n * Uses @verdaccio/registry-cli ping.\n */\nexport async function pingRegistry(registryUrl: string): Promise<boolean> {\n debug('pinging %s', registryUrl);\n try {\n const result = await ping(registryUrl);\n return result.ok;\n } catch {\n return false;\n }\n}\n\nexport class LegacyLoginError extends Error {\n constructor(\n message: string,\n readonly status: number\n ) {\n super(message);\n }\n}\n\n/**\n * Replays the legacy login the way each client sends it. npm and Yarn retry a\n * 409 with Basic (Yarn on the GET too); pnpm sends Basic on a single PUT. A\n * registry that authenticates the first PUT is accepted too.\n */\nexport async function legacyLogin(\n registryUrl: string,\n user: string,\n password: string,\n client: 'npm' | 'yarn' | 'pnpm'\n): Promise<string> {\n const userUrl = `${registryUrl}/-/user/org.couchdb.user:${encodeURIComponent(user)}`;\n const basic = `Basic ${Buffer.from(`${user}:${password}`).toString('base64')}`;\n const jsonHeaders = { 'Content-Type': 'application/json' };\n const body: Record<string, unknown> = {\n _id: `org.couchdb.user:${user}`,\n name: user,\n password,\n type: 'user',\n roles: [],\n date: new Date().toISOString(),\n };\n\n const put = (url: string, headers: Record<string, string>) =>\n fetch(url, { method: 'PUT', headers, body: JSON.stringify(body) });\n\n const first = await put(\n userUrl,\n client === 'pnpm'\n ? { ...jsonHeaders, Authorization: basic, 'npm-auth-type': 'web' }\n : jsonHeaders\n );\n const firstBody = (await first.json()) as any;\n if (first.ok && firstBody.token) {\n debug('%s: first PUT authenticated %s', client, user);\n return firstBody.token;\n }\n if (first.status !== 409) {\n throw new LegacyLoginError(`first PUT answered ${first.status}`, first.status);\n }\n\n const current = await fetch(`${userUrl}?write=true`, {\n headers: client === 'yarn' ? { Authorization: basic } : {},\n });\n if (!current.ok) {\n throw new LegacyLoginError(`GET answered ${current.status}`, current.status);\n }\n const currentBody = (await current.json()) as Record<string, unknown>;\n for (const [key, value] of Object.entries(currentBody)) {\n if (!body[key] || key === 'roles') {\n body[key] = value;\n }\n }\n\n const second = await put(`${userUrl}/-rev/${body._rev}`, {\n ...jsonHeaders,\n Authorization: basic,\n });\n const secondBody = (await second.json()) as any;\n if (!second.ok || !secondBody.token) {\n throw new LegacyLoginError(`PUT with revision answered ${second.status}`, second.status);\n }\n return secondBody.token;\n}\n\nexport async function whoami(registryUrl: string, token: string): Promise<string | undefined> {\n const response = await fetch(`${registryUrl}/-/whoami`, {\n headers: { Authorization: `Bearer ${token}` },\n });\n return response.ok ? ((await response.json()) as any).username : undefined;\n}\n"],"mappings":";;;;;AAIA,IAAM,WAAA,GAAQ,MAAA,QAAA,CAAW,mCAAmC;;;;;;AAY5D,eAAsB,WACpB,aACA,OAAO,YAAY,KAAK,IAAI,KAC5B,WAAW,qBACY;CACvB,QAAM,0BAA0B,MAAM,WAAW;CACjD,MAAM,MAAM,GAAG,YAAY,2BAA2B,mBAAmB,IAAI;CAC7E,MAAM,WAAW,MAAM,MAAM,KAAK;EAChC,QAAQ;EACR,SAAS,EAAE,gBAAgB,mBAAmB;EAC9C,MAAM,KAAK,UAAU;GACnB,MAAM;GACN;GACA,KAAK,oBAAoB;GACzB,MAAM;GACN,OAAO,CAAC;GACR,uBAAM,IAAI,KAAK,EAAA,CAAE,YAAY;EAC/B,CAAC;CACH,CAAC;CAED,MAAM,OAAQ,MAAM,SAAS,KAAK;CAElC,IAAI,SAAS,WAAW,OAAO,SAAS,WAAW,OAAO,SAAS,WAAW,KAAK;EACjF,MAAM,QAAQ,KAAK;EACnB,IAA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E,MAAM,UAAU,MAAM,MAAM,GAAG,QAAQ,cAAc,EACnD,SAAS,WAAW,SAAS,EAAE,eAAe,MAAM,IAAI,CAAC,EAC3D,CAAC;CACD,IAAI,CAAC,QAAQ,IACX,MAAM,IAAI,iBAAiB,gBAAgB,QAAQ,UAAU,QAAQ,MAAM;CAE7E,MAAM,cAAe,MAAM,QAAQ,KAAK;CACxC,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,WAAW,GACnD,IAAI,CAAC,KAAK,QAAQ,QAAQ,SACxB,KAAK,OAAO;CAIhB,MAAM,SAAS,MAAM,IAAI,GAAG,QAAQ,QAAQ,KAAK,QAAQ;EACvD,GAAG;EACH,eAAe;CACjB,CAAC;CACD,MAAM,aAAc,MAAM,OAAO,KAAK;CACtC,IAAI,CAAC,OAAO,MAAM,CAAC,WAAW,OAC5B,MAAM,IAAI,iBAAiB,8BAA8B,OAAO,UAAU,OAAO,MAAM;CAEzF,OAAO,WAAW;AACpB;AAEA,eAAsB,OAAO,aAAqB,OAA4C;CAC5F,MAAM,WAAW,MAAM,MAAM,GAAG,YAAY,YAAY,EACtD,SAAS,EAAE,eAAe,UAAU,QAAQ,EAC9C,CAAC;CACD,OAAO,SAAS,MAAO,MAAM,SAAS,KAAK,EAAA,CAAW,WAAW,KAAA;AACnE"}
@@ -6,18 +6,7 @@ import { join } from "path";
6
6
  import { writeFile } from "fs/promises";
7
7
  //#region src/adapters/pnpm.ts
8
8
  var debug = buildDebug("verdaccio:e2e-cli:pnpm");
9
- var PNPM_V10_COMMANDS = /* @__PURE__ */ new Set([
10
- "publish",
11
- "unpublish",
12
- "install",
13
- "info",
14
- "audit",
15
- "deprecate",
16
- "dist-tag",
17
- "ping",
18
- "search"
19
- ]);
20
- var PNPM_V11_COMMANDS = /* @__PURE__ */ new Set([
9
+ var PNPM_COMMANDS = /* @__PURE__ */ new Set([
21
10
  "publish",
22
11
  "unpublish",
23
12
  "install",
@@ -25,15 +14,7 @@ var PNPM_V11_COMMANDS = /* @__PURE__ */ new Set([
25
14
  "audit",
26
15
  "deprecate"
27
16
  ]);
28
- function getSupportedCommands(version) {
29
- const major = parseInt(version.split(".")[0], 10);
30
- if (major >= 11) {
31
- debug("pnpm v%d detected, using v11 command set", major);
32
- return PNPM_V11_COMMANDS;
33
- }
34
- return PNPM_V10_COMMANDS;
35
- }
36
- var PNPM_MIN_SUPPORTED_MAJOR = 10;
17
+ var PNPM_MIN_SUPPORTED_MAJOR = 11;
37
18
  function detectVersion(bin) {
38
19
  try {
39
20
  return execSync(`${bin} --version`, {
@@ -76,7 +57,7 @@ function createPnpmAdapter(binPath, version) {
76
57
  name: `pnpm@${resolved}`,
77
58
  type: "pnpm",
78
59
  bin,
79
- supports: getSupportedCommands(resolved),
60
+ supports: PNPM_COMMANDS,
80
61
  registryArg(url) {
81
62
  return ["--registry", url];
82
63
  },
@@ -1 +1 @@
1
- {"version":3,"file":"pnpm.js","names":[],"sources":["../../../src/adapters/pnpm.ts"],"sourcesContent":["import { SpawnOptions, execSync } from 'child_process';\nimport buildDebug from 'debug';\nimport { writeFile } from 'fs/promises';\nimport { join } from 'path';\n\nimport { ExecOutput, PackageManagerAdapter } from '../types';\nimport { exec } from '../utils/process';\nimport { prepareGenericEmptyProject } from '../utils/project';\n\nconst debug = buildDebug('verdaccio:e2e-cli:pnpm');\n\nconst PNPM_V10_COMMANDS = new Set([\n 'publish',\n 'unpublish',\n 'install',\n 'info',\n 'audit',\n 'deprecate',\n 'dist-tag',\n 'ping',\n 'search',\n]);\n\n// pnpm v11 removed ping and search\n// dist-tag output format changed (no --json), needs adapted assertions\nconst PNPM_V11_COMMANDS = new Set([\n 'publish',\n 'unpublish',\n 'install',\n 'info',\n 'audit',\n 'deprecate',\n]);\n\nfunction getSupportedCommands(version: string): Set<string> {\n const major = parseInt(version.split('.')[0], 10);\n if (major >= 11) {\n debug('pnpm v%d detected, using v11 command set', major);\n return PNPM_V11_COMMANDS;\n }\n return PNPM_V10_COMMANDS;\n}\n\n// pnpm 8 and 9 are end-of-life and no longer supported by the suite.\nconst PNPM_MIN_SUPPORTED_MAJOR = 10;\n\nfunction detectVersion(bin: string): string {\n try {\n return execSync(`${bin} --version`, { encoding: 'utf8', timeout: 5000 }).trim();\n } catch {\n return 'unknown';\n }\n}\n\nfunction assertSupportedVersion(resolved: string): void {\n const major = parseInt(resolved.split('.')[0], 10);\n if (!Number.isNaN(major) && major < PNPM_MIN_SUPPORTED_MAJOR) {\n throw new Error(\n `pnpm@${resolved} is not supported. Minimum supported major: ${PNPM_MIN_SUPPORTED_MAJOR}`\n );\n }\n}\n\nfunction installPnpm(version: string): string {\n const pkg = `pnpm@${version}`;\n debug('installing %s into temp dir', pkg);\n const tmpDir = execSync('mktemp -d', { encoding: 'utf8' }).trim();\n execSync(`npm install --prefix \"${tmpDir}\" ${pkg} --loglevel=error`, {\n encoding: 'utf8',\n timeout: 30000,\n });\n const bin = `${tmpDir}/node_modules/.bin/pnpm`;\n const installed = detectVersion(bin);\n debug('installed pnpm %s at %s', installed, bin);\n console.log(` Auto-installed pnpm ${installed}`);\n return bin;\n}\n\nfunction resolvePnpmBin(binPath?: string, version?: string): string {\n if (binPath) return binPath;\n if (version) return installPnpm(version);\n return 'pnpm';\n}\n\nexport function createPnpmAdapter(binPath?: string, version?: string): PackageManagerAdapter {\n const bin = resolvePnpmBin(binPath, version);\n const resolved = detectVersion(bin);\n assertSupportedVersion(resolved);\n debug('creating pnpm adapter with bin: %s (%s)', bin, resolved);\n\n const adapter: PackageManagerAdapter = {\n name: `pnpm@${resolved}`,\n type: 'pnpm',\n bin,\n supports: getSupportedCommands(resolved),\n\n registryArg(url: string): string[] {\n return ['--registry', url];\n },\n\n prefixArg(folder: string): string[] {\n return ['--prefix', folder];\n },\n\n exec(options: SpawnOptions, ...args: string[]): Promise<ExecOutput> {\n const major = parseInt(resolved.split('.')[0], 10);\n if (major >= 11) {\n // pnpm v11: native deprecate/unpublish don't support --json\n const cmd = args[0];\n if (cmd === 'deprecate' || cmd === 'unpublish' || cmd === 'publish' || cmd === 'dist-tag') {\n args = args.filter((a) => a !== '--json' && !a.startsWith('--loglevel'));\n }\n // pnpm v11: un-deprecate uses `undeprecate` command instead of `deprecate pkg \"\"`\n if (cmd === 'deprecate') {\n // Check if message arg is empty string (un-deprecate)\n // args: ['deprecate', 'pkg@version', '', ...flags]\n const msgIdx = 2; // message is the third arg\n if (args.length > msgIdx && args[msgIdx] === '') {\n args = ['undeprecate', args[1], ...args.slice(3)];\n }\n }\n // pnpm v11: native version command doesn't accept --registry, --loglevel, or --no--git-tag-version\n if (cmd === 'version') {\n args = args.filter(\n (a) =>\n !a.startsWith('--registry') &&\n !a.startsWith('--loglevel') &&\n !a.startsWith('--no--git-tag-version')\n );\n }\n }\n return exec(options, bin, args);\n },\n\n async prepareProject(\n packageName: string,\n version: string,\n registryUrl: string,\n port: number,\n token: string,\n dependencies: Record<string, string> = {},\n devDependencies: Record<string, string> = {}\n ): Promise<{ tempFolder: string }> {\n const project = await prepareGenericEmptyProject(\n packageName,\n version,\n port,\n token,\n registryUrl,\n dependencies,\n devDependencies\n );\n // pnpm 11.24+ enforces a minimumReleaseAge cooldown by default, which\n // rejects the just-published packages these tests install\n // (ERR_PNPM_NO_MATURE_MATCHING_VERSION). Disable it per project via\n // pnpm-workspace.yaml — the file also marks the temp folder as its own\n // workspace root, isolating it from any parent workspace. Tests that\n // exercise the cooldown itself overwrite this file with their own config.\n await writeFile(join(project.tempFolder, 'pnpm-workspace.yaml'), 'minimumReleaseAge: 0\\n');\n return project;\n },\n };\n\n return adapter;\n}\n"],"mappings":";;;;;;;AASA,IAAM,QAAQ,WAAW,wBAAwB;AAEjD,IAAM,oCAAoB,IAAI,IAAI;CAChC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAID,IAAM,oCAAoB,IAAI,IAAI;CAChC;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,qBAAqB,SAA8B;CAC1D,MAAM,QAAQ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qB,QAAQ;EAEvC,YAAY,KAAuB;GACjC,OAAO,CAAC,cAAc,GAAG;EAC3B;EAEA,UAAU,QAA0B;GAClC,OAAO,CAAC,YAAY,MAAM;EAC5B;EAEA,KAAK,SAAuB,GAAG,MAAqC;GAElE,IADc,SAAS,SAAS,MAAM,GAAG,CAAC,CAAC,IAAI,EAC3C,KAAS,IAAI;IAEf,MAAM,MAAM,KAAK;IACjB,IAAI,QAAQ,eAAe,QAAQ,eAAe,QAAQ,aAAa,QAAQ,YAC7E,OAAO,KAAK,QAAQ,MAAM,MAAM,YAAY,CAAC,EAAE,WAAW,YAAY,CAAC;IAGzE,IAAI,QAAQ,aAAa;KAGvB,MAAM,SAAS;KACf,IAAI,KAAK,SAAS,UAAU,KAAK,YAAY,IAC3C,OAAO;MAAC;MAAe,KAAK;MAAI,GAAG,KAAK,MAAM,CAAC;KAAC;IAEpD;IAEA,IAAI,QAAQ,WACV,OAAO,KAAK,QACT,MACC,CAAC,EAAE,WAAW,YAAY,KAC1B,CAAC,EAAE,WAAW,YAAY,KAC1B,CAAC,EAAE,WAAW,uBAAuB,CACzC;GAEJ;GACA,OAAO,KAAK,SAAS,KAAK,IAAI;EAChC;EAEA,MAAM,eACJ,aACA,SACA,aACA,MACA,OACA,eAAuC,CAAC,GACxC,kBAA0C,CAAC,GACV;GACjC,MAAM,UAAU,MAAM,2BACpB,aACA,SACA,MACA,OACA,aACA,cACA,eACF;GAOA,MAAM,UAAU,KAAK,QAAQ,YAAY,qBAAqB,GAAG,wBAAwB;GACzF,OAAO;EACT;CAGK;AACT"}
1
+ {"version":3,"file":"pnpm.js","names":[],"sources":["../../../src/adapters/pnpm.ts"],"sourcesContent":["import { SpawnOptions, execSync } from 'child_process';\nimport buildDebug from 'debug';\nimport { writeFile } from 'fs/promises';\nimport { join } from 'path';\n\nimport { ExecOutput, PackageManagerAdapter } from '../types';\nimport { exec } from '../utils/process';\nimport { prepareGenericEmptyProject } from '../utils/project';\n\nconst debug = buildDebug('verdaccio:e2e-cli:pnpm');\n\n// pnpm removed ping and search; the dist-tag output changed (no --json) and needs adapted assertions\nconst PNPM_COMMANDS = new Set(['publish', 'unpublish', 'install', 'info', 'audit', 'deprecate']);\n\n// pnpm 8, 9 and 10 are no longer supported by the suite.\nconst PNPM_MIN_SUPPORTED_MAJOR = 11;\n\nfunction detectVersion(bin: string): string {\n try {\n return execSync(`${bin} --version`, { encoding: 'utf8', timeout: 5000 }).trim();\n } catch {\n return 'unknown';\n }\n}\n\nfunction assertSupportedVersion(resolved: string): void {\n const major = parseInt(resolved.split('.')[0], 10);\n if (!Number.isNaN(major) && major < PNPM_MIN_SUPPORTED_MAJOR) {\n throw new Error(\n `pnpm@${resolved} is not supported. Minimum supported major: ${PNPM_MIN_SUPPORTED_MAJOR}`\n );\n }\n}\n\nfunction installPnpm(version: string): string {\n const pkg = `pnpm@${version}`;\n debug('installing %s into temp dir', pkg);\n const tmpDir = execSync('mktemp -d', { encoding: 'utf8' }).trim();\n execSync(`npm install --prefix \"${tmpDir}\" ${pkg} --loglevel=error`, {\n encoding: 'utf8',\n timeout: 30000,\n });\n const bin = `${tmpDir}/node_modules/.bin/pnpm`;\n const installed = detectVersion(bin);\n debug('installed pnpm %s at %s', installed, bin);\n console.log(` Auto-installed pnpm ${installed}`);\n return bin;\n}\n\nfunction resolvePnpmBin(binPath?: string, version?: string): string {\n if (binPath) return binPath;\n if (version) return installPnpm(version);\n return 'pnpm';\n}\n\nexport function createPnpmAdapter(binPath?: string, version?: string): PackageManagerAdapter {\n const bin = resolvePnpmBin(binPath, version);\n const resolved = detectVersion(bin);\n assertSupportedVersion(resolved);\n debug('creating pnpm adapter with bin: %s (%s)', bin, resolved);\n\n const adapter: PackageManagerAdapter = {\n name: `pnpm@${resolved}`,\n type: 'pnpm',\n bin,\n supports: PNPM_COMMANDS,\n\n registryArg(url: string): string[] {\n return ['--registry', url];\n },\n\n prefixArg(folder: string): string[] {\n return ['--prefix', folder];\n },\n\n exec(options: SpawnOptions, ...args: string[]): Promise<ExecOutput> {\n const major = parseInt(resolved.split('.')[0], 10);\n if (major >= 11) {\n // pnpm v11: native deprecate/unpublish don't support --json\n const cmd = args[0];\n if (cmd === 'deprecate' || cmd === 'unpublish' || cmd === 'publish' || cmd === 'dist-tag') {\n args = args.filter((a) => a !== '--json' && !a.startsWith('--loglevel'));\n }\n // pnpm v11: un-deprecate uses `undeprecate` command instead of `deprecate pkg \"\"`\n if (cmd === 'deprecate') {\n // Check if message arg is empty string (un-deprecate)\n // args: ['deprecate', 'pkg@version', '', ...flags]\n const msgIdx = 2; // message is the third arg\n if (args.length > msgIdx && args[msgIdx] === '') {\n args = ['undeprecate', args[1], ...args.slice(3)];\n }\n }\n // pnpm v11: native version command doesn't accept --registry, --loglevel, or --no--git-tag-version\n if (cmd === 'version') {\n args = args.filter(\n (a) =>\n !a.startsWith('--registry') &&\n !a.startsWith('--loglevel') &&\n !a.startsWith('--no--git-tag-version')\n );\n }\n }\n return exec(options, bin, args);\n },\n\n async prepareProject(\n packageName: string,\n version: string,\n registryUrl: string,\n port: number,\n token: string,\n dependencies: Record<string, string> = {},\n devDependencies: Record<string, string> = {}\n ): Promise<{ tempFolder: string }> {\n const project = await prepareGenericEmptyProject(\n packageName,\n version,\n port,\n token,\n registryUrl,\n dependencies,\n devDependencies\n );\n // pnpm 11.24+ enforces a minimumReleaseAge cooldown by default, which\n // rejects the just-published packages these tests install\n // (ERR_PNPM_NO_MATURE_MATCHING_VERSION). Disable it per project via\n // pnpm-workspace.yaml — the file also marks the temp folder as its own\n // workspace root, isolating it from any parent workspace. Tests that\n // exercise the cooldown itself overwrite this file with their own config.\n await writeFile(join(project.tempFolder, 'pnpm-workspace.yaml'), 'minimumReleaseAge: 0\\n');\n return project;\n },\n };\n\n return adapter;\n}\n"],"mappings":";;;;;;;AASA,IAAM,QAAQ,WAAW,wBAAwB;AAGjD,IAAM,gCAAgB,IAAI,IAAI;CAAC;CAAW;CAAa;CAAW;CAAQ;CAAS;AAAW,CAAC;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G,MAAqC;GAElE,IADc,SAAS,SAAS,MAAM,GAAG,CAAC,CAAC,IAAI,EAC3C,KAAS,IAAI;IAEf,MAAM,MAAM,KAAK;IACjB,IAAI,QAAQ,eAAe,QAAQ,eAAe,QAAQ,aAAa,QAAQ,YAC7E,OAAO,KAAK,QAAQ,MAAM,MAAM,YAAY,CAAC,EAAE,WAAW,YAAY,CAAC;IAGzE,IAAI,QAAQ,aAAa;KAGvB,MAAM,SAAS;KACf,IAAI,KAAK,SAAS,UAAU,KAAK,YAAY,IAC3C,OAAO;MAAC;MAAe,KAAK;MAAI,GAAG,KAAK,MAAM,CAAC;KAAC;IAEpD;IAEA,IAAI,QAAQ,WACV,OAAO,KAAK,QACT,MACC,CAAC,EAAE,WAAW,YAAY,KAC1B,CAAC,EAAE,WAAW,YAAY,KAC1B,CAAC,EAAE,WAAW,uBAAuB,CACzC;GAEJ;GACA,OAAO,KAAK,SAAS,KAAK,IAAI;EAChC;EAEA,MAAM,eACJ,aACA,SACA,aACA,MACA,OACA,eAAuC,CAAC,GACxC,kBAA0C,CAAC,GACV;GACjC,MAAM,UAAU,MAAM,2BACpB,aACA,SACA,MACA,OACA,aACA,cACA,eACF;GAOA,MAAM,UAAU,KAAK,QAAQ,YAAY,qBAAqB,GAAG,wBAAwB;GACzF,OAAO;EACT;CAGK;AACT"}
@@ -8,8 +8,8 @@ import { createYarnModernAdapter } from "./adapters/yarn-modern.js";
8
8
  import "./adapters/index.js";
9
9
  import { runAll, runSuite } from "./runner.js";
10
10
  import { allScenarios } from "./scenarios/index.js";
11
- import { allTests } from "./tests/index.js";
12
11
  import { createUser, pingRegistry } from "./utils/registry-client.js";
12
+ import { allTests } from "./tests/index.js";
13
13
  import buildDebug from "debug";
14
14
  //#region src/index.ts
15
15
  buildDebug("verdaccio:e2e-cli");
@@ -1 +1 @@
1
- {"version":3,"file":"minimum-release-age.js","names":[],"sources":["../../../src/scenarios/minimum-release-age.ts"],"sourcesContent":["import assert from 'assert';\nimport { writeFile } from 'fs/promises';\nimport { join } from 'path';\n\nimport { PackageManagerAdapter, TestContext, TestDefinition } from '../types';\nimport { trace } from '../utils/process';\n\n/**\n * Scenario: minimum-release-age (pnpm 11.1+ only)\n *\n * Exercises pnpm's `minimumReleaseAge` cooldown together with\n * `minimumReleaseAgeExclude`. With a 7-day (10080 minute) cooldown, freshly\n * published versions are normally not installable until they age past the\n * threshold — but packages matching the exclude globs bypass the check.\n *\n * minimumReleaseAge: 10080\n * minimumReleaseAgeStrict: true\n * minimumReleaseAgeExclude:\n * - '@verdaccio/*'\n * - 'verdaccio-*'\n *\n * minimumReleaseAgeStrict is required on pnpm 12: without it, pnpm 12\n * auto-adds new direct dependencies to minimumReleaseAgeExclude instead of\n * failing. pnpm 11 enforces the cooldown unconditionally and ignores the key.\n *\n * The scenario publishes brand-new (age ~0) packages and asserts:\n * - an excluded scoped package (@verdaccio/*) installs despite the cooldown\n * - an excluded unscoped package (verdaccio-*) installs despite the cooldown\n * - a non-excluded package is blocked by the cooldown (proving it is active)\n *\n * pnpm reads these settings from `pnpm-workspace.yaml`, mirroring the\n * configuration used by the repo root. The cooldown is only enforced from\n * pnpm 11.1.0 onward (11.0.x silently ignores it), so the scenario is gated to\n * that version range — see {@link isPnpm11Plus}.\n */\n\nconst MINIMUM_RELEASE_AGE = 10080; // 7 days, in minutes\nconst MINIMUM_RELEASE_AGE_EXCLUDE = ['@verdaccio/*', 'verdaccio-*'];\n\nconst PNPM_WORKSPACE_YAML = [\n `minimumReleaseAge: ${MINIMUM_RELEASE_AGE}`,\n // pnpm 12 no longer blocks new direct dependencies by default: it auto-adds\n // them to minimumReleaseAgeExclude in pnpm-workspace.yaml and proceeds.\n // minimumReleaseAgeStrict restores the blocking behavior this scenario\n // asserts (ERR_PNPM_NO_MATURE_MATCHING_VERSION); pnpm 11 ignores the key.\n 'minimumReleaseAgeStrict: true',\n 'minimumReleaseAgeExclude:',\n ...MINIMUM_RELEASE_AGE_EXCLUDE.map((glob) => ` - '${glob}'`),\n '',\n].join('\\n');\n\n/**\n * True only for pnpm versions that actually enforce minimumReleaseAge.\n *\n * The cooldown is honored in pnpm 11.1.0+, but it is silently ignored in\n * 11.0.0 / 11.0.1 (and the 11.0.0 release candidates) — those versions install\n * brand-new packages regardless of the configured cooldown. We scope this\n * scenario to pnpm 11.1.0 and newer so it doesn't false-fail on that regression.\n */\nexport function isPnpm11Plus(adapter: PackageManagerAdapter): boolean {\n if (adapter.type !== 'pnpm') {\n return false;\n }\n const match = adapter.name.match(/pnpm@(\\d+)\\.(\\d+)/);\n if (!match) {\n return false;\n }\n const major = parseInt(match[1], 10);\n const minor = parseInt(match[2], 10);\n return major > 11 || (major === 11 && minor >= 1);\n}\n\nasync function publishPackage(ctx: TestContext, pkgName: string, version: string): Promise<void> {\n trace('publishing %s@%s', pkgName, version);\n const { tempFolder } = await ctx.adapter.prepareProject(\n pkgName,\n version,\n ctx.registryUrl,\n ctx.port,\n ctx.token\n );\n await ctx.adapter.exec(\n { cwd: tempFolder },\n 'publish',\n ...ctx.adapter.registryArg(ctx.registryUrl)\n );\n trace('published %s@%s', pkgName, version);\n}\n\n/**\n * Build a consumer project with the minimumReleaseAge cooldown configured in\n * pnpm-workspace.yaml, depending on the given packages.\n */\nasync function prepareCooldownConsumer(\n ctx: TestContext,\n consumerName: string,\n dependencies: Record<string, string>\n): Promise<string> {\n const { tempFolder } = await ctx.adapter.prepareProject(\n consumerName,\n '1.0.0',\n ctx.registryUrl,\n ctx.port,\n ctx.token,\n dependencies\n );\n await writeFile(join(tempFolder, 'pnpm-workspace.yaml'), PNPM_WORKSPACE_YAML);\n trace('prepared cooldown consumer %s at %s', consumerName, tempFolder);\n return tempFolder;\n}\n\nasync function testMinimumReleaseAge(ctx: TestContext): Promise<void> {\n const id = ctx.runId;\n\n const excludedScoped = `@verdaccio/release-age-${id}`;\n const excludedUnscoped = `verdaccio-release-age-${id}`;\n const blocked = `e2e-release-age-blocked-${id}`;\n\n // --- Phase 1: Publish brand-new (age ~0) packages ---\n await ctx.subTest('publish fresh packages', async () => {\n await publishPackage(ctx, excludedScoped, '1.0.0');\n await publishPackage(ctx, excludedUnscoped, '1.0.0');\n await publishPackage(ctx, blocked, '1.0.0');\n });\n\n // --- Phase 2: Excluded packages install despite the cooldown ---\n await ctx.subTest('excluded packages bypass the cooldown', async () => {\n const tempFolder = await prepareCooldownConsumer(ctx, `@verdaccio/consumer-excluded-${id}`, {\n [excludedScoped]: '1.0.0',\n [excludedUnscoped]: '1.0.0',\n });\n\n // Should succeed: both deps match the exclude globs.\n await ctx.adapter.exec(\n { cwd: tempFolder },\n 'install',\n ...ctx.adapter.registryArg(ctx.registryUrl)\n );\n\n trace('excluded packages installed successfully under cooldown');\n });\n\n // --- Phase 3: Non-excluded fresh package is blocked by the cooldown ---\n await ctx.subTest('non-excluded fresh package is blocked', async () => {\n const tempFolder = await prepareCooldownConsumer(ctx, `e2e-consumer-blocked-${id}`, {\n [blocked]: '1.0.0',\n });\n\n let errorMessage = '';\n try {\n await ctx.adapter.exec(\n { cwd: tempFolder },\n 'install',\n // pnpm 12's parser rejects the `--flag=false` form; --no-frozen-lockfile\n // is accepted by pnpm 10, 11 and 12 alike\n '--no-frozen-lockfile',\n ...ctx.adapter.registryArg(ctx.registryUrl)\n );\n } catch (err) {\n errorMessage = err instanceof Error ? err.message : String(err);\n trace('install correctly rejected by cooldown: %s', errorMessage.split('\\n')[0]);\n }\n\n assert.ok(\n errorMessage,\n `Expected install of fresh non-excluded package \"${blocked}\" to be blocked by ` +\n `minimumReleaseAge (${MINIMUM_RELEASE_AGE} min), but it succeeded`\n );\n // pnpm reports ERR_PNPM_NO_MATURE_MATCHING_VERSION / \"minimumReleaseAge\" when a\n // version is too new. Assert the failure is the cooldown, not an unrelated error.\n assert.ok(\n /minimumReleaseAge|NO_MATURE_MATCHING_VERSION/i.test(errorMessage),\n `Install of \"${blocked}\" failed for an unexpected reason (expected a minimumReleaseAge ` +\n `cooldown error):\\n${errorMessage}`\n );\n });\n}\n\nexport const minimumReleaseAgeScenario: TestDefinition = {\n name: 'scenario:minimum-release-age',\n requires: ['publish', 'install'],\n appliesTo: isPnpm11Plus,\n run: testMinimumReleaseAge,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,IAAM,sBAAsB;AAG5B,IAAM,sBAAsB;CAC1B,sBAAsB;CAKtB;CACA;CACA,GAAG,CAVgC,gBAAgB,aAUhD,CAAA,CAA4B,KAAK,SAAS,QAAQ,KAAK,EAAE;CAC5D;AACF,CAAC,CAAC,KAAK,IAAI;;;;;;;;;AAUX,SAAgB,aAAa,SAAyC;CACpE,IAAI,QAAQ,SAAS,QACnB,OAAO;CAET,MAAM,QAAQ,QAAQ,KAAK,MAAM,mBAAmB;CACpD,IAAI,CAAC,OACH,OAAO;CAET,MAAM,QAAQ,SAAS,MAAM,IAAI,EAAE;CACnC,MAAM,QAAQ,SAAS,MAAM,IAAI,EAAE;CACnC,OAAO,QAAQ,MAAO,UAAU,MAAM,SAAS;AACjD;AAEA,eAAe,eAAe,KAAkB,SAAiB,SAAgC;CAC/F,MAAM,oBAAoB,SAAS,OAAO;CAC1C,MAAM,EAAE,eAAe,MAAM,IAAI,QAAQ,eACvC,SACA,SACA,IAAI,aACJ,IAAI,MACJ,IAAI,KACN;CACA,MAAM,IAAI,QAAQ,KAChB,EAAE,KAAK,WAAW,GAClB,WACA,GAAG,IAAI,QAAQ,YAAY,IAAI,WAAW,CAC5C;CACA,MAAM,mBAAmB,SAAS,OAAO;AAC3C;;;;;AAMA,eAAe,wBACb,KACA,cACA,cACiB;CACjB,MAAM,EAAE,eAAe,MAAM,IAAI,QAAQ,eACvC,cACA,SACA,IAAI,aACJ,IAAI,MACJ,IAAI,OACJ,YACF;CACA,MAAM,UAAU,KAAK,YAAY,qBAAqB,GAAG,mBAAmB;CAC5E,MAAM,uCAAuC,cAAc,UAAU;CACrE,OAAO;AACT;AAEA,eAAe,sBAAsB,KAAiC;CACpE,MAAM,KAAK,IAAI;CAEf,MAAM,iBAAiB,0BAA0B;CACjD,MAAM,mBAAmB,yBAAyB;CAClD,MAAM,UAAU,2BAA2B;CAG3C,MAAM,IAAI,QAAQ,0BAA0B,YAAY;EACtD,MAAM,eAAe,KAAK,gBAAgB,OAAO;EACjD,MAAM,eAAe,KAAK,kBAAkB,OAAO;EACnD,MAAM,eAAe,KAAK,SAAS,OAAO;CAC5C,CAAC;CAGD,MAAM,IAAI,QAAQ,yCAAyC,YAAY;EACrE,MAAM,aAAa,MAAM,wBAAwB,KAAK,gCAAgC,MAAM;IACzF,iBAAiB;IACjB,mBAAmB;EACtB,CAAC;EAGD,MAAM,IAAI,QAAQ,KAChB,EAAE,KAAK,WAAW,GAClB,WACA,GAAG,IAAI,QAAQ,YAAY,IAAI,WAAW,CAC5C;EAEA,MAAM,yDAAyD;CACjE,CAAC;CAGD,MAAM,IAAI,QAAQ,yCAAyC,YAAY;EACrE,MAAM,aAAa,MAAM,wBAAwB,KAAK,wBAAwB,MAAM,GACjF,UAAU,QACb,CAAC;EAED,IAAI,eAAe;EACnB,IAAI;GACF,MAAM,IAAI,QAAQ,KAChB,EAAE,KAAK,WAAW,GAClB,WAGA,wBACA,GAAG,IAAI,QAAQ,YAAY,IAAI,WAAW,CAC5C;EACF,SAAS,KAAK;GACZ,eAAe,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;GAC9D,MAAM,8CAA8C,aAAa,MAAM,IAAI,CAAC,CAAC,EAAE;EACjF;EAEA,OAAO,GACL,cACA,mDAAmD,QAAQ,wCACnC,oBAAoB,wBAC9C;EAGA,OAAO,GACL,gDAAgD,KAAK,YAAY,GACjE,eAAe,QAAQ,oFACA,cACzB;CACF,CAAC;AACH;AAEA,IAAa,4BAA4C;CACvD,MAAM;CACN,UAAU,CAAC,WAAW,SAAS;CAC/B,WAAW;CACX,KAAK;AACP"}
1
+ {"version":3,"file":"minimum-release-age.js","names":[],"sources":["../../../src/scenarios/minimum-release-age.ts"],"sourcesContent":["import assert from 'assert';\nimport { writeFile } from 'fs/promises';\nimport { join } from 'path';\n\nimport { PackageManagerAdapter, TestContext, TestDefinition } from '../types';\nimport { trace } from '../utils/process';\n\n/**\n * Scenario: minimum-release-age (pnpm 11.1+ only)\n *\n * Exercises pnpm's `minimumReleaseAge` cooldown together with\n * `minimumReleaseAgeExclude`. With a 7-day (10080 minute) cooldown, freshly\n * published versions are normally not installable until they age past the\n * threshold — but packages matching the exclude globs bypass the check.\n *\n * minimumReleaseAge: 10080\n * minimumReleaseAgeStrict: true\n * minimumReleaseAgeExclude:\n * - '@verdaccio/*'\n * - 'verdaccio-*'\n *\n * minimumReleaseAgeStrict is required on pnpm 12: without it, pnpm 12\n * auto-adds new direct dependencies to minimumReleaseAgeExclude instead of\n * failing. pnpm 11 enforces the cooldown unconditionally and ignores the key.\n *\n * The scenario publishes brand-new (age ~0) packages and asserts:\n * - an excluded scoped package (@verdaccio/*) installs despite the cooldown\n * - an excluded unscoped package (verdaccio-*) installs despite the cooldown\n * - a non-excluded package is blocked by the cooldown (proving it is active)\n *\n * pnpm reads these settings from `pnpm-workspace.yaml`, mirroring the\n * configuration used by the repo root. The cooldown is only enforced from\n * pnpm 11.1.0 onward (11.0.x silently ignores it), so the scenario is gated to\n * that version range — see {@link isPnpm11Plus}.\n */\n\nconst MINIMUM_RELEASE_AGE = 10080; // 7 days, in minutes\nconst MINIMUM_RELEASE_AGE_EXCLUDE = ['@verdaccio/*', 'verdaccio-*'];\n\nconst PNPM_WORKSPACE_YAML = [\n `minimumReleaseAge: ${MINIMUM_RELEASE_AGE}`,\n // pnpm 12 no longer blocks new direct dependencies by default: it auto-adds\n // them to minimumReleaseAgeExclude in pnpm-workspace.yaml and proceeds.\n // minimumReleaseAgeStrict restores the blocking behavior this scenario\n // asserts (ERR_PNPM_NO_MATURE_MATCHING_VERSION); pnpm 11 ignores the key.\n 'minimumReleaseAgeStrict: true',\n 'minimumReleaseAgeExclude:',\n ...MINIMUM_RELEASE_AGE_EXCLUDE.map((glob) => ` - '${glob}'`),\n '',\n].join('\\n');\n\n/**\n * True only for pnpm versions that actually enforce minimumReleaseAge.\n *\n * The cooldown is honored in pnpm 11.1.0+, but it is silently ignored in\n * 11.0.0 / 11.0.1 (and the 11.0.0 release candidates) — those versions install\n * brand-new packages regardless of the configured cooldown. We scope this\n * scenario to pnpm 11.1.0 and newer so it doesn't false-fail on that regression.\n */\nexport function isPnpm11Plus(adapter: PackageManagerAdapter): boolean {\n if (adapter.type !== 'pnpm') {\n return false;\n }\n const match = adapter.name.match(/pnpm@(\\d+)\\.(\\d+)/);\n if (!match) {\n return false;\n }\n const major = parseInt(match[1], 10);\n const minor = parseInt(match[2], 10);\n return major > 11 || (major === 11 && minor >= 1);\n}\n\nasync function publishPackage(ctx: TestContext, pkgName: string, version: string): Promise<void> {\n trace('publishing %s@%s', pkgName, version);\n const { tempFolder } = await ctx.adapter.prepareProject(\n pkgName,\n version,\n ctx.registryUrl,\n ctx.port,\n ctx.token\n );\n await ctx.adapter.exec(\n { cwd: tempFolder },\n 'publish',\n ...ctx.adapter.registryArg(ctx.registryUrl)\n );\n trace('published %s@%s', pkgName, version);\n}\n\n/**\n * Build a consumer project with the minimumReleaseAge cooldown configured in\n * pnpm-workspace.yaml, depending on the given packages.\n */\nasync function prepareCooldownConsumer(\n ctx: TestContext,\n consumerName: string,\n dependencies: Record<string, string>\n): Promise<string> {\n const { tempFolder } = await ctx.adapter.prepareProject(\n consumerName,\n '1.0.0',\n ctx.registryUrl,\n ctx.port,\n ctx.token,\n dependencies\n );\n await writeFile(join(tempFolder, 'pnpm-workspace.yaml'), PNPM_WORKSPACE_YAML);\n trace('prepared cooldown consumer %s at %s', consumerName, tempFolder);\n return tempFolder;\n}\n\nasync function testMinimumReleaseAge(ctx: TestContext): Promise<void> {\n const id = ctx.runId;\n\n const excludedScoped = `@verdaccio/release-age-${id}`;\n const excludedUnscoped = `verdaccio-release-age-${id}`;\n const blocked = `e2e-release-age-blocked-${id}`;\n\n // --- Phase 1: Publish brand-new (age ~0) packages ---\n await ctx.subTest('publish fresh packages', async () => {\n await publishPackage(ctx, excludedScoped, '1.0.0');\n await publishPackage(ctx, excludedUnscoped, '1.0.0');\n await publishPackage(ctx, blocked, '1.0.0');\n });\n\n // --- Phase 2: Excluded packages install despite the cooldown ---\n await ctx.subTest('excluded packages bypass the cooldown', async () => {\n const tempFolder = await prepareCooldownConsumer(ctx, `@verdaccio/consumer-excluded-${id}`, {\n [excludedScoped]: '1.0.0',\n [excludedUnscoped]: '1.0.0',\n });\n\n // Should succeed: both deps match the exclude globs.\n await ctx.adapter.exec(\n { cwd: tempFolder },\n 'install',\n ...ctx.adapter.registryArg(ctx.registryUrl)\n );\n\n trace('excluded packages installed successfully under cooldown');\n });\n\n // --- Phase 3: Non-excluded fresh package is blocked by the cooldown ---\n await ctx.subTest('non-excluded fresh package is blocked', async () => {\n const tempFolder = await prepareCooldownConsumer(ctx, `e2e-consumer-blocked-${id}`, {\n [blocked]: '1.0.0',\n });\n\n let errorMessage = '';\n try {\n await ctx.adapter.exec(\n { cwd: tempFolder },\n 'install',\n // pnpm 12's parser rejects the `--flag=false` form; --no-frozen-lockfile\n // is accepted by pnpm 11 and 12 alike\n '--no-frozen-lockfile',\n ...ctx.adapter.registryArg(ctx.registryUrl)\n );\n } catch (err) {\n errorMessage = err instanceof Error ? err.message : String(err);\n trace('install correctly rejected by cooldown: %s', errorMessage.split('\\n')[0]);\n }\n\n assert.ok(\n errorMessage,\n `Expected install of fresh non-excluded package \"${blocked}\" to be blocked by ` +\n `minimumReleaseAge (${MINIMUM_RELEASE_AGE} min), but it succeeded`\n );\n // pnpm reports ERR_PNPM_NO_MATURE_MATCHING_VERSION / \"minimumReleaseAge\" when a\n // version is too new. Assert the failure is the cooldown, not an unrelated error.\n assert.ok(\n /minimumReleaseAge|NO_MATURE_MATCHING_VERSION/i.test(errorMessage),\n `Install of \"${blocked}\" failed for an unexpected reason (expected a minimumReleaseAge ` +\n `cooldown error):\\n${errorMessage}`\n );\n });\n}\n\nexport const minimumReleaseAgeScenario: TestDefinition = {\n name: 'scenario:minimum-release-age',\n requires: ['publish', 'install'],\n appliesTo: isPnpm11Plus,\n run: testMinimumReleaseAge,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,IAAM,sBAAsB;AAG5B,IAAM,sBAAsB;CAC1B,sBAAsB;CAKtB;CACA;CACA,GAAG,CAVgC,gBAAgB,aAUhD,CAAA,CAA4B,KAAK,SAAS,QAAQ,KAAK,EAAE;CAC5D;AACF,CAAC,CAAC,KAAK,IAAI;;;;;;;;;AAUX,SAAgB,aAAa,SAAyC;CACpE,IAAI,QAAQ,SAAS,QACnB,OAAO;CAET,MAAM,QAAQ,QAAQ,KAAK,MAAM,mBAAmB;CACpD,IAAI,CAAC,OACH,OAAO;CAET,MAAM,QAAQ,SAAS,MAAM,IAAI,EAAE;CACnC,MAAM,QAAQ,SAAS,MAAM,IAAI,EAAE;CACnC,OAAO,QAAQ,MAAO,UAAU,MAAM,SAAS;AACjD;AAEA,eAAe,eAAe,KAAkB,SAAiB,SAAgC;CAC/F,MAAM,oBAAoB,SAAS,OAAO;CAC1C,MAAM,EAAE,eAAe,MAAM,IAAI,QAAQ,eACvC,SACA,SACA,IAAI,aACJ,IAAI,MACJ,IAAI,KACN;CACA,MAAM,IAAI,QAAQ,KAChB,EAAE,KAAK,WAAW,GAClB,WACA,GAAG,IAAI,QAAQ,YAAY,IAAI,WAAW,CAC5C;CACA,MAAM,mBAAmB,SAAS,OAAO;AAC3C;;;;;AAMA,eAAe,wBACb,KACA,cACA,cACiB;CACjB,MAAM,EAAE,eAAe,MAAM,IAAI,QAAQ,eACvC,cACA,SACA,IAAI,aACJ,IAAI,MACJ,IAAI,OACJ,YACF;CACA,MAAM,UAAU,KAAK,YAAY,qBAAqB,GAAG,mBAAmB;CAC5E,MAAM,uCAAuC,cAAc,UAAU;CACrE,OAAO;AACT;AAEA,eAAe,sBAAsB,KAAiC;CACpE,MAA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LegacyLoginError, createUser, legacyLogin, whoami } from "../utils/registry-client.js";
2
3
  import buildDebug from "debug";
3
4
  import { join } from "path";
4
5
  import { writeFile } from "fs/promises";
@@ -110,6 +111,29 @@ async function testLogin(ctx) {
110
111
  const who2 = await yarnWhoami(ctx, tf);
111
112
  assert.ok(who2.includes(user2), `Expected "${user2}" after switch but got "${who2}"`);
112
113
  });
114
+ for (const client of [
115
+ "npm",
116
+ "yarn",
117
+ "pnpm"
118
+ ]) {
119
+ await ctx.subTest(`${client} logs an existing user in with the Basic retry`, async () => {
120
+ const user = `login-retry-${client}-${id}`;
121
+ const password = "retry-password-123";
122
+ await createUser(ctx.registryUrl, user, password);
123
+ const token = await legacyLogin(ctx.registryUrl, user, password, client);
124
+ assert.strictEqual(await whoami(ctx.registryUrl, token), user);
125
+ });
126
+ await ctx.subTest(`${client} registers a new user`, async () => {
127
+ const user = `login-new-${client}-${id}`;
128
+ const token = await legacyLogin(ctx.registryUrl, user, "retry-password-123", client);
129
+ assert.strictEqual(await whoami(ctx.registryUrl, token), user);
130
+ });
131
+ await ctx.subTest(`${client} cannot log an existing user in with a wrong password`, async () => {
132
+ const user = `login-wrong-${client}-${id}`;
133
+ await createUser(ctx.registryUrl, user, "retry-password-123");
134
+ await assert.rejects(legacyLogin(ctx.registryUrl, user, "wrong-password", client), (error) => error instanceof LegacyLoginError && error.status === 401);
135
+ });
136
+ }
113
137
  }
114
138
  var loginTest = {
115
139
  name: "login",
@@ -1 +1 @@
1
- {"version":3,"file":"login.js","names":[],"sources":["../../../src/tests/login.ts"],"sourcesContent":["import assert from 'assert';\nimport buildDebug from 'debug';\nimport { writeFile } from 'fs/promises';\nimport * as YAML from 'js-yaml';\nimport { join } from 'path';\n\nimport { TestContext, TestDefinition } from '../types';\nimport { createTempFolder, getPackageJSON, getREADME } from '../utils/project';\n\nconst debug = buildDebug('verdaccio:e2e-cli:test:login');\n\n/**\n * Creates a project with registry config but WITHOUT auth token,\n * so whoami will use the token saved by login to ~/.yarnrc.yml.\n */\nasync function prepareLoginProject(ctx: TestContext, name: string): Promise<string> {\n debug('preparing project for %s (no auth token)', name);\n const tempFolder = await createTempFolder(name);\n const yamlContent = YAML.dump({\n npmRegistryServer: ctx.registryUrl,\n enableImmutableInstalls: false,\n unsafeHttpWhitelist: ['localhost'],\n });\n await writeFile(join(tempFolder, '.yarnrc.yml'), yamlContent);\n await writeFile(join(tempFolder, 'package.json'), JSON.stringify({ name, version: '1.0.0' }));\n if (ctx.adapter.importPlugin) {\n debug('importing npm-login plugin into %s', tempFolder);\n await ctx.adapter.importPlugin(tempFolder, 'npm-login');\n }\n return tempFolder;\n}\n\nasync function yarnLogin(\n ctx: TestContext,\n cwd: string,\n user: string,\n password: string,\n email: string\n) {\n debug('yarn npm login as %s', user);\n return ctx.adapter.exec(\n { cwd },\n 'login',\n '--auth-type=legacy',\n `--user=${user}`,\n `--password=${password}`,\n `--email=${email}`\n );\n}\n\nasync function yarnWhoami(ctx: TestContext, cwd: string): Promise<string> {\n const resp = await ctx.adapter.exec({ cwd }, 'whoami');\n debug('yarn npm whoami: %s', resp.stdout);\n return resp.stdout;\n}\n\nasync function testLogin(ctx: TestContext): Promise<void> {\n const type = ctx.adapter.type;\n const id = ctx.runId;\n\n if (type !== 'yarn-modern') {\n debug('login test only supported for yarn-modern, skipping %s', type);\n return;\n }\n\n const user1 = `login-a-${id}`;\n const password1 = 'test-password-123';\n const email1 = `${user1}@test.example.com`;\n\n await ctx.subTest('create new user + whoami', async () => {\n const tf = await prepareLoginProject(ctx, `verdaccio-login1-${id}`);\n const loginResp = await yarnLogin(ctx, tf, user1, password1, email1);\n assert.ok(\n loginResp.stdout.includes('Logged in') || loginResp.stdout.includes('token saved'),\n `Expected login success message but got \"${loginResp.stdout}\"`\n );\n const who = await yarnWhoami(ctx, tf);\n assert.ok(who.includes(user1), `Expected whoami \"${user1}\" but got \"${who}\"`);\n });\n\n await ctx.subTest('legacy re-login is rejected without basic auth', async () => {\n const tf = await prepareLoginProject(ctx, `verdaccio-login2-${id}`);\n let loginFailed = false;\n try {\n await yarnLogin(ctx, tf, user1, password1, email1);\n } catch {\n loginFailed = true;\n }\n assert.ok(loginFailed, 'Legacy re-login for an existing user should fail without Basic auth');\n });\n\n await ctx.subTest('wrong password fails', async () => {\n const tf = await prepareLoginProject(ctx, `verdaccio-login3-${id}`);\n let loginFailed = false;\n try {\n await yarnLogin(ctx, tf, user1, 'wrong-password', email1);\n } catch {\n loginFailed = true;\n }\n assert.ok(loginFailed, 'Login with wrong password should have failed');\n });\n\n await ctx.subTest('login then publish', async () => {\n const pkgName = `@verdaccio/login-pub-${id}`;\n const publishUser = `login-pub-${id}`;\n const publishPassword = 'publish-password-123';\n const publishEmail = `${publishUser}@test.example.com`;\n const tf = await createTempFolder(`login-pub-${id}`);\n const yamlContent = YAML.dump({\n npmRegistryServer: ctx.registryUrl,\n enableImmutableInstalls: false,\n unsafeHttpWhitelist: ['localhost'],\n });\n await writeFile(join(tf, '.yarnrc.yml'), yamlContent);\n await writeFile(join(tf, 'package.json'), getPackageJSON(pkgName, '1.0.0'));\n await writeFile(join(tf, 'README.md'), getREADME(pkgName));\n if (ctx.adapter.importPlugin) {\n await ctx.adapter.importPlugin(tf, 'npm-login');\n }\n await yarnLogin(ctx, tf, publishUser, publishPassword, publishEmail);\n await ctx.adapter.exec({ cwd: tf }, 'install');\n const pubResp = await ctx.adapter.exec({ cwd: tf }, 'publish');\n assert.ok(\n pubResp.stdout.includes('Package archive published'),\n `Expected publish success but got \"${pubResp.stdout}\"`\n );\n });\n\n await ctx.subTest('switch users', async () => {\n const switchUser1 = `login-switch-a-${id}`;\n const switchPassword1 = 'switch-password-123';\n const switchEmail1 = `${switchUser1}@test.example.com`;\n const user2 = `login-b-${id}`;\n const password2 = 'other-password-456';\n const email2 = `${user2}@test.example.com`;\n const tf = await prepareLoginProject(ctx, `verdaccio-login5-${id}`);\n\n await yarnLogin(ctx, tf, switchUser1, switchPassword1, switchEmail1);\n const who1 = await yarnWhoami(ctx, tf);\n assert.ok(who1.includes(switchUser1), `Expected \"${switchUser1}\" but got \"${who1}\"`);\n\n await yarnLogin(ctx, tf, user2, password2, email2);\n const who2 = await yarnWhoami(ctx, tf);\n assert.ok(who2.includes(user2), `Expected \"${user2}\" after switch but got \"${who2}\"`);\n });\n}\n\nexport const loginTest: TestDefinition = {\n name: 'login',\n requires: ['login'],\n run: testLogin,\n};\n"],"mappings":";;;;;;;AASA,IAAM,QAAQ,WAAW,8BAA8B;;;;;AAMvD,eAAe,oBAAoB,KAAkB,MAA+B;CAClF,MAAM,4CAA4C,IAAI;CACtD,MAAM,aAAa,MAAM,iBAAiB,IAAI;CAC9C,MAAM,cAAc,KAAK,KAAK;EAC5B,mBAAmB,IAAI;EACvB,yBAAyB;EACzB,qBAAqB,CAAC,WAAW;CACnC,CAAC;CACD,MAAM,UAAU,KAAK,YAAY,aAAa,GAAG,WAAW;CAC5D,MAAM,UAAU,KAAK,YAAY,cAAc,GAAG,KAAK,UAAU;EAAE;EAAM,SAAS;CAAQ,CAAC,CAAC;CAC5F,IAAI,IAAI,QAAQ,cAAc;EAC5B,MAAM,sCAAsC,UAAU;EACtD,MAAM,IAAI,QAAQ,aAAa,YAAY,WAAW;CACxD;CACA,OAAO;AACT;AAEA,eAAe,UACb,KACA,KACA,MACA,UACA,OACA;CACA,MAAM,wBAAwB,IAAI;CAClC,OAAO,IAAI,QAAQ,KACjB,EAAE,IAAI,GACN,SACA,sBACA,UAAU,QACV,cAAc,YACd,WAAW,OACb;AACF;AAEA,eAAe,WAAW,KAAkB,KAA8B;CACxE,MAAM,OAAO,MAAM,IAAI,QAAQ,KAAK,EAAE,IAAI,GAAG,QAAQ;CACrD,MAAM,uBAAuB,KAAK,MAAM;CACxC,OAAO,KAAK;AACd;AAEA,eAAe,UAAU,KAAiC;CACxD,MAAM,OAAO,IAAI,QAAQ;CACzB,MAAM,KAAK,IAAI;CAEf,IAAI,SAAS,eAAe;EAC1B,MAAM,0DAA0D,IAAI;EACpE;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/tests/login.ts"],"sourcesContent":["import assert from 'assert';\nimport buildDebug from 'debug';\nimport { writeFile } from 'fs/promises';\nimport * as YAML from 'js-yaml';\nimport { join } from 'path';\n\nimport { TestContext, TestDefinition } from '../types';\nimport { createTempFolder, getPackageJSON, getREADME } from '../utils/project';\nimport { LegacyLoginError, createUser, legacyLogin, whoami } from '../utils/registry-client';\n\nconst debug = buildDebug('verdaccio:e2e-cli:test:login');\n\n/**\n * Creates a project with registry config but WITHOUT auth token,\n * so whoami will use the token saved by login to ~/.yarnrc.yml.\n */\nasync function prepareLoginProject(ctx: TestContext, name: string): Promise<string> {\n debug('preparing project for %s (no auth token)', name);\n const tempFolder = await createTempFolder(name);\n const yamlContent = YAML.dump({\n npmRegistryServer: ctx.registryUrl,\n enableImmutableInstalls: false,\n unsafeHttpWhitelist: ['localhost'],\n });\n await writeFile(join(tempFolder, '.yarnrc.yml'), yamlContent);\n await writeFile(join(tempFolder, 'package.json'), JSON.stringify({ name, version: '1.0.0' }));\n if (ctx.adapter.importPlugin) {\n debug('importing npm-login plugin into %s', tempFolder);\n await ctx.adapter.importPlugin(tempFolder, 'npm-login');\n }\n return tempFolder;\n}\n\nasync function yarnLogin(\n ctx: TestContext,\n cwd: string,\n user: string,\n password: string,\n email: string\n) {\n debug('yarn npm login as %s', user);\n return ctx.adapter.exec(\n { cwd },\n 'login',\n '--auth-type=legacy',\n `--user=${user}`,\n `--password=${password}`,\n `--email=${email}`\n );\n}\n\nasync function yarnWhoami(ctx: TestContext, cwd: string): Promise<string> {\n const resp = await ctx.adapter.exec({ cwd }, 'whoami');\n debug('yarn npm whoami: %s', resp.stdout);\n return resp.stdout;\n}\n\nasync function testLogin(ctx: TestContext): Promise<void> {\n const type = ctx.adapter.type;\n const id = ctx.runId;\n\n if (type !== 'yarn-modern') {\n debug('login test only supported for yarn-modern, skipping %s', type);\n return;\n }\n\n const user1 = `login-a-${id}`;\n const password1 = 'test-password-123';\n const email1 = `${user1}@test.example.com`;\n\n await ctx.subTest('create new user + whoami', async () => {\n const tf = await prepareLoginProject(ctx, `verdaccio-login1-${id}`);\n const loginResp = await yarnLogin(ctx, tf, user1, password1, email1);\n assert.ok(\n loginResp.stdout.includes('Logged in') || loginResp.stdout.includes('token saved'),\n `Expected login success message but got \"${loginResp.stdout}\"`\n );\n const who = await yarnWhoami(ctx, tf);\n assert.ok(who.includes(user1), `Expected whoami \"${user1}\" but got \"${who}\"`);\n });\n\n await ctx.subTest('legacy re-login is rejected without basic auth', async () => {\n const tf = await prepareLoginProject(ctx, `verdaccio-login2-${id}`);\n let loginFailed = false;\n try {\n await yarnLogin(ctx, tf, user1, password1, email1);\n } catch {\n loginFailed = true;\n }\n assert.ok(loginFailed, 'Legacy re-login for an existing user should fail without Basic auth');\n });\n\n await ctx.subTest('wrong password fails', async () => {\n const tf = await prepareLoginProject(ctx, `verdaccio-login3-${id}`);\n let loginFailed = false;\n try {\n await yarnLogin(ctx, tf, user1, 'wrong-password', email1);\n } catch {\n loginFailed = true;\n }\n assert.ok(loginFailed, 'Login with wrong password should have failed');\n });\n\n await ctx.subTest('login then publish', async () => {\n const pkgName = `@verdaccio/login-pub-${id}`;\n const publishUser = `login-pub-${id}`;\n const publishPassword = 'publish-password-123';\n const publishEmail = `${publishUser}@test.example.com`;\n const tf = await createTempFolder(`login-pub-${id}`);\n const yamlContent = YAML.dump({\n npmRegistryServer: ctx.registryUrl,\n enableImmutableInstalls: false,\n unsafeHttpWhitelist: ['localhost'],\n });\n await writeFile(join(tf, '.yarnrc.yml'), yamlContent);\n await writeFile(join(tf, 'package.json'), getPackageJSON(pkgName, '1.0.0'));\n await writeFile(join(tf, 'README.md'), getREADME(pkgName));\n if (ctx.adapter.importPlugin) {\n await ctx.adapter.importPlugin(tf, 'npm-login');\n }\n await yarnLogin(ctx, tf, publishUser, publishPassword, publishEmail);\n await ctx.adapter.exec({ cwd: tf }, 'install');\n const pubResp = await ctx.adapter.exec({ cwd: tf }, 'publish');\n assert.ok(\n pubResp.stdout.includes('Package archive published'),\n `Expected publish success but got \"${pubResp.stdout}\"`\n );\n });\n\n await ctx.subTest('switch users', async () => {\n const switchUser1 = `login-switch-a-${id}`;\n const switchPassword1 = 'switch-password-123';\n const switchEmail1 = `${switchUser1}@test.example.com`;\n const user2 = `login-b-${id}`;\n const password2 = 'other-password-456';\n const email2 = `${user2}@test.example.com`;\n const tf = await prepareLoginProject(ctx, `verdaccio-login5-${id}`);\n\n await yarnLogin(ctx, tf, switchUser1, switchPassword1, switchEmail1);\n const who1 = await yarnWhoami(ctx, tf);\n assert.ok(who1.includes(switchUser1), `Expected \"${switchUser1}\" but got \"${who1}\"`);\n\n await yarnLogin(ctx, tf, user2, password2, email2);\n const who2 = await yarnWhoami(ctx, tf);\n assert.ok(who2.includes(user2), `Expected \"${user2}\" after switch but got \"${who2}\"`);\n });\n\n // replayed over HTTP: what `npm login`, native `yarn npm login` and `pnpm login` send\n for (const client of ['npm', 'yarn', 'pnpm'] as const) {\n await ctx.subTest(`${client} logs an existing user in with the Basic retry`, async () => {\n const user = `login-retry-${client}-${id}`;\n const password = 'retry-password-123';\n await createUser(ctx.registryUrl, user, password);\n\n const token = await legacyLogin(ctx.registryUrl, user, password, client);\n assert.strictEqual(await whoami(ctx.registryUrl, token), user);\n });\n\n await ctx.subTest(`${client} registers a new user`, async () => {\n const user = `login-new-${client}-${id}`;\n\n const token = await legacyLogin(ctx.registryUrl, user, 'retry-password-123', client);\n assert.strictEqual(await whoami(ctx.registryUrl, token), user);\n });\n\n await ctx.subTest(\n `${client} cannot log an existing user in with a wrong password`,\n async () => {\n const user = `login-wrong-${client}-${id}`;\n await createUser(ctx.registryUrl, user, 'retry-password-123');\n\n await assert.rejects(\n legacyLogin(ctx.registryUrl, user, 'wrong-password', client),\n (error: unknown) => error instanceof LegacyLoginError && error.status === 401\n );\n }\n );\n }\n}\n\nexport const loginTest: TestDefinition = {\n name: 'login',\n requires: ['login'],\n run: testLogin,\n};\n"],"mappings":";;;;;;;;AAUA,IAAM,QA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9D,MAAM,OAAO,aAAa,OAAO,GAAG;GAEpC,MAAM,QAAQ,MAAM,YAAY,IAAI,aAAa,MAAM,sBAAsB,MAAM;GACnF,OAAO,YAAY,MAAM,OAAO,IAAI,aAAa,KAAK,GAAG,IAAI;EAC/D,CAAC;EAED,MAAM,IAAI,QACR,GAAG,OAAO,wDACV,YAAY;GACV,MAAM,OAAO,eAAe,OAAO,GAAG;GACtC,MAAM,WAAW,IAAI,aAAa,MAAM,oBAAoB;GAE5D,MAAM,OAAO,QACX,YAAY,IAAI,aAAa,MAAM,kBAAkB,MAAM,IAC1D,UAAmB,iBAAiB,oBAAoB,MAAM,WAAW,GAC5E;EACF,CACF;CACF;AACF;AAEA,IAAa,YAA4B;CACvC,MAAM;CACN,UAAU,CAAC,OAAO;CAClB,KAAK;AACP"}
@@ -47,7 +47,63 @@ async function pingRegistry(registryUrl) {
47
47
  return false;
48
48
  }
49
49
  }
50
+ var LegacyLoginError = class extends Error {
51
+ status;
52
+ constructor(message, status) {
53
+ super(message);
54
+ this.status = status;
55
+ }
56
+ };
57
+ /**
58
+ * Replays the legacy login the way each client sends it. npm and Yarn retry a
59
+ * 409 with Basic (Yarn on the GET too); pnpm sends Basic on a single PUT. A
60
+ * registry that authenticates the first PUT is accepted too.
61
+ */
62
+ async function legacyLogin(registryUrl, user, password, client) {
63
+ const userUrl = `${registryUrl}/-/user/org.couchdb.user:${encodeURIComponent(user)}`;
64
+ const basic = `Basic ${Buffer.from(`${user}:${password}`).toString("base64")}`;
65
+ const jsonHeaders = { "Content-Type": "application/json" };
66
+ const body = {
67
+ _id: `org.couchdb.user:${user}`,
68
+ name: user,
69
+ password,
70
+ type: "user",
71
+ roles: [],
72
+ date: (/* @__PURE__ */ new Date()).toISOString()
73
+ };
74
+ const put = (url, headers) => fetch(url, {
75
+ method: "PUT",
76
+ headers,
77
+ body: JSON.stringify(body)
78
+ });
79
+ const first = await put(userUrl, client === "pnpm" ? {
80
+ ...jsonHeaders,
81
+ Authorization: basic,
82
+ "npm-auth-type": "web"
83
+ } : jsonHeaders);
84
+ const firstBody = await first.json();
85
+ if (first.ok && firstBody.token) {
86
+ debug("%s: first PUT authenticated %s", client, user);
87
+ return firstBody.token;
88
+ }
89
+ if (first.status !== 409) throw new LegacyLoginError(`first PUT answered ${first.status}`, first.status);
90
+ const current = await fetch(`${userUrl}?write=true`, { headers: client === "yarn" ? { Authorization: basic } : {} });
91
+ if (!current.ok) throw new LegacyLoginError(`GET answered ${current.status}`, current.status);
92
+ const currentBody = await current.json();
93
+ for (const [key, value] of Object.entries(currentBody)) if (!body[key] || key === "roles") body[key] = value;
94
+ const second = await put(`${userUrl}/-rev/${body._rev}`, {
95
+ ...jsonHeaders,
96
+ Authorization: basic
97
+ });
98
+ const secondBody = await second.json();
99
+ if (!second.ok || !secondBody.token) throw new LegacyLoginError(`PUT with revision answered ${second.status}`, second.status);
100
+ return secondBody.token;
101
+ }
102
+ async function whoami(registryUrl, token) {
103
+ const response = await fetch(`${registryUrl}/-/whoami`, { headers: { Authorization: `Bearer ${token}` } });
104
+ return response.ok ? (await response.json()).username : void 0;
105
+ }
50
106
  //#endregion
51
- export { createUser, pingRegistry };
107
+ export { LegacyLoginError, createUser, legacyLogin, pingRegistry, whoami };
52
108
 
53
109
  //# sourceMappingURL=registry-client.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry-client.js","names":[],"sources":["../../../src/utils/registry-client.ts"],"sourcesContent":["import buildDebug from 'debug';\n\nimport { ping } from '@verdaccio/registry-cli';\n\nconst debug = buildDebug('verdaccio:e2e-cli:registry-client');\n\nexport type RegistryAuth = {\n token: string;\n user: string;\n};\n\n/**\n * Creates a user on the registry and returns the auth token.\n * Uses a unique username per run to avoid 409 conflicts.\n * Works against any running Verdaccio instance with htpasswd auth.\n */\nexport async function createUser(\n registryUrl: string,\n user = `e2e-user-${Date.now()}`,\n password = 'e2e-test-password'\n): Promise<RegistryAuth> {\n debug('creating user %s on %s', user, registryUrl);\n const url = `${registryUrl}/-/user/org.couchdb.user:${encodeURIComponent(user)}`;\n const response = await fetch(url, {\n method: 'PUT',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n name: user,\n password,\n _id: `org.couchdb.user:${user}`,\n type: 'user',\n roles: [],\n date: new Date().toISOString(),\n }),\n });\n\n const body = (await response.json()) as any;\n\n if (response.status === 201 || response.status === 200 || response.status === 409) {\n const token = body.token;\n if (token) {\n debug('user %s authenticated, token obtained', user);\n return { token, user };\n }\n }\n\n throw new Error(\n `Failed to create/login user \"${user}\" on ${registryUrl}: ${response.status} ${JSON.stringify(body)}`\n );\n}\n\n/**\n * Ping the registry to check it's alive.\n * Uses @verdaccio/registry-cli ping.\n */\nexport async function pingRegistry(registryUrl: string): Promise<boolean> {\n debug('pinging %s', registryUrl);\n try {\n const result = await ping(registryUrl);\n return result.ok;\n } catch {\n return false;\n }\n}\n"],"mappings":";;;AAIA,IAAM,QAAQ,WAAW,mCAAmC;;;;;;AAY5D,eAAsB,WACpB,aACA,OAAO,YAAY,KAAK,IAAI,KAC5B,WAAW,qBACY;CACvB,MAAM,0BAA0B,MAAM,WAAW;CACjD,MAAM,MAAM,GAAG,YAAY,2BAA2B,mBAAmB,IAAI;CAC7E,MAAM,WAAW,MAAM,MAAM,KAAK;EAChC,QAAQ;EACR,SAAS,EAAE,gBAAgB,mBAAmB;EAC9C,MAAM,KAAK,UAAU;GACnB,MAAM;GACN;GACA,KAAK,oBAAoB;GACzB,MAAM;GACN,OAAO,CAAC;GACR,uBAAM,IAAI,KAAK,EAAA,CAAE,YAAY;EAC/B,CAAC;CACH,CAAC;CAED,MAAM,OAAQ,MAAM,SAAS,KAAK;CAElC,IAAI,SAAS,WAAW,OAAO,SAAS,WAAW,OAAO,SAAS,WAAW,KAAK;EACjF,MAAM,QAAQ,KAAK;EACnB,IAAI,OAAO;GACT,MAAM,yCAAyC,IAAI;GACnD,OAAO;IAAE;IAAO;GAAK;EACvB;CACF;CAEA,MAAM,IAAI,MACR,gCAAgC,KAAK,OAAO,YAAY,IAAI,SAAS,OAAO,GAAG,KAAK,UAAU,IAAI,GACpG;AACF;;;;;AAMA,eAAsB,aAAa,aAAuC;CACxE,MAAM,cAAc,WAAW;CAC/B,IAAI;EAEF,QAAO,MADc,KAAK,WAAW,EAAA,CACvB;CAChB,QAAQ;EACN,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"registry-client.js","names":[],"sources":["../../../src/utils/registry-client.ts"],"sourcesContent":["import buildDebug from 'debug';\n\nimport { ping } from '@verdaccio/registry-cli';\n\nconst debug = buildDebug('verdaccio:e2e-cli:registry-client');\n\nexport type RegistryAuth = {\n token: string;\n user: string;\n};\n\n/**\n * Creates a user on the registry and returns the auth token.\n * Uses a unique username per run to avoid 409 conflicts.\n * Works against any running Verdaccio instance with htpasswd auth.\n */\nexport async function createUser(\n registryUrl: string,\n user = `e2e-user-${Date.now()}`,\n password = 'e2e-test-password'\n): Promise<RegistryAuth> {\n debug('creating user %s on %s', user, registryUrl);\n const url = `${registryUrl}/-/user/org.couchdb.user:${encodeURIComponent(user)}`;\n const response = await fetch(url, {\n method: 'PUT',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n name: user,\n password,\n _id: `org.couchdb.user:${user}`,\n type: 'user',\n roles: [],\n date: new Date().toISOString(),\n }),\n });\n\n const body = (await response.json()) as any;\n\n if (response.status === 201 || response.status === 200 || response.status === 409) {\n const token = body.token;\n if (token) {\n debug('user %s authenticated, token obtained', user);\n return { token, user };\n }\n }\n\n throw new Error(\n `Failed to create/login user \"${user}\" on ${registryUrl}: ${response.status} ${JSON.stringify(body)}`\n );\n}\n\n/**\n * Ping the registry to check it's alive.\n * Uses @verdaccio/registry-cli ping.\n */\nexport async function pingRegistry(registryUrl: string): Promise<boolean> {\n debug('pinging %s', registryUrl);\n try {\n const result = await ping(registryUrl);\n return result.ok;\n } catch {\n return false;\n }\n}\n\nexport class LegacyLoginError extends Error {\n constructor(\n message: string,\n readonly status: number\n ) {\n super(message);\n }\n}\n\n/**\n * Replays the legacy login the way each client sends it. npm and Yarn retry a\n * 409 with Basic (Yarn on the GET too); pnpm sends Basic on a single PUT. A\n * registry that authenticates the first PUT is accepted too.\n */\nexport async function legacyLogin(\n registryUrl: string,\n user: string,\n password: string,\n client: 'npm' | 'yarn' | 'pnpm'\n): Promise<string> {\n const userUrl = `${registryUrl}/-/user/org.couchdb.user:${encodeURIComponent(user)}`;\n const basic = `Basic ${Buffer.from(`${user}:${password}`).toString('base64')}`;\n const jsonHeaders = { 'Content-Type': 'application/json' };\n const body: Record<string, unknown> = {\n _id: `org.couchdb.user:${user}`,\n name: user,\n password,\n type: 'user',\n roles: [],\n date: new Date().toISOString(),\n };\n\n const put = (url: string, headers: Record<string, string>) =>\n fetch(url, { method: 'PUT', headers, body: JSON.stringify(body) });\n\n const first = await put(\n userUrl,\n client === 'pnpm'\n ? { ...jsonHeaders, Authorization: basic, 'npm-auth-type': 'web' }\n : jsonHeaders\n );\n const firstBody = (await first.json()) as any;\n if (first.ok && firstBody.token) {\n debug('%s: first PUT authenticated %s', client, user);\n return firstBody.token;\n }\n if (first.status !== 409) {\n throw new LegacyLoginError(`first PUT answered ${first.status}`, first.status);\n }\n\n const current = await fetch(`${userUrl}?write=true`, {\n headers: client === 'yarn' ? { Authorization: basic } : {},\n });\n if (!current.ok) {\n throw new LegacyLoginError(`GET answered ${current.status}`, current.status);\n }\n const currentBody = (await current.json()) as Record<string, unknown>;\n for (const [key, value] of Object.entries(currentBody)) {\n if (!body[key] || key === 'roles') {\n body[key] = value;\n }\n }\n\n const second = await put(`${userUrl}/-rev/${body._rev}`, {\n ...jsonHeaders,\n Authorization: basic,\n });\n const secondBody = (await second.json()) as any;\n if (!second.ok || !secondBody.token) {\n throw new LegacyLoginError(`PUT with revision answered ${second.status}`, second.status);\n }\n return secondBody.token;\n}\n\nexport async function whoami(registryUrl: string, token: string): Promise<string | undefined> {\n const response = await fetch(`${registryUrl}/-/whoami`, {\n headers: { Authorization: `Bearer ${token}` },\n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aAAqB,OAA4C;CAC5F,MAAM,WAAW,MAAM,MAAM,GAAG,YAAY,YAAY,EACtD,SAAS,EAAE,eAAe,UAAU,QAAQ,EAC9C,CAAC;CACD,OAAO,SAAS,MAAO,MAAM,SAAS,KAAK,EAAA,CAAW,WAAW,KAAA;AACnE"}
@@ -13,3 +13,14 @@ export declare function createUser(registryUrl: string, user?: string, password?
13
13
  * Uses @verdaccio/registry-cli ping.
14
14
  */
15
15
  export declare function pingRegistry(registryUrl: string): Promise<boolean>;
16
+ export declare class LegacyLoginError extends Error {
17
+ readonly status: number;
18
+ constructor(message: string, status: number);
19
+ }
20
+ /**
21
+ * Replays the legacy login the way each client sends it. npm and Yarn retry a
22
+ * 409 with Basic (Yarn on the GET too); pnpm sends Basic on a single PUT. A
23
+ * registry that authenticates the first PUT is accepted too.
24
+ */
25
+ export declare function legacyLogin(registryUrl: string, user: string, password: string, client: 'npm' | 'yarn' | 'pnpm'): Promise<string>;
26
+ export declare function whoami(registryUrl: string, token: string): Promise<string | undefined>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdaccio/e2e-cli",
3
- "version": "3.4.0",
3
+ "version": "4.0.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "CLI tool to run Verdaccio e2e tests against any running registry",
@@ -30,7 +30,7 @@
30
30
  "@verdaccio/registry-cli": "^1.1.0",
31
31
  "debug": "4.4.3",
32
32
  "get-port": "7.2.0",
33
- "js-yaml": "5.2.3"
33
+ "js-yaml": "5.4.1"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/debug": "4.1.13",