From 2b5a15c22b5857d88ce7ca1d9d0a5cdf7d8c491b Mon Sep 17 00:00:00 2001 From: Juan Picado Date: Sun, 24 Sep 2023 12:44:39 +0200 Subject: [PATCH] chore: add e2e npm 10 e2e (#4036) --- .github/workflows/e2e-ci.yml | 2 +- e2e/cli/README.md | 7 +- e2e/cli/e2e-npm10/.babelrc | 3 + e2e/cli/e2e-npm10/.eslintrc | 7 ++ e2e/cli/e2e-npm10/CHANGELOG.md | 62 +++++++++++++++ e2e/cli/e2e-npm10/audit.spec.ts | 44 +++++++++++ e2e/cli/e2e-npm10/deprecate.spec.ts | 115 ++++++++++++++++++++++++++++ e2e/cli/e2e-npm10/dist-tags.spec.ts | 91 ++++++++++++++++++++++ e2e/cli/e2e-npm10/info.spec.ts | 31 ++++++++ e2e/cli/e2e-npm10/install.spec.ts | 38 +++++++++ e2e/cli/e2e-npm10/jest.config.js | 3 + e2e/cli/e2e-npm10/package.json | 12 +++ e2e/cli/e2e-npm10/ping.spec.ts | 24 ++++++ e2e/cli/e2e-npm10/publish.spec.ts | 41 ++++++++++ e2e/cli/e2e-npm10/search.spec.ts | 33 ++++++++ e2e/cli/e2e-npm10/star.spec.ts | 85 ++++++++++++++++++++ e2e/cli/e2e-npm10/tsconfig.json | 8 ++ e2e/cli/e2e-npm10/utils.ts | 41 ++++++++++ pnpm-lock.yaml | 84 ++++++++++++++++++++ 19 files changed, 725 insertions(+), 6 deletions(-) create mode 100644 e2e/cli/e2e-npm10/.babelrc create mode 100644 e2e/cli/e2e-npm10/.eslintrc create mode 100644 e2e/cli/e2e-npm10/CHANGELOG.md create mode 100644 e2e/cli/e2e-npm10/audit.spec.ts create mode 100644 e2e/cli/e2e-npm10/deprecate.spec.ts create mode 100644 e2e/cli/e2e-npm10/dist-tags.spec.ts create mode 100644 e2e/cli/e2e-npm10/info.spec.ts create mode 100644 e2e/cli/e2e-npm10/install.spec.ts create mode 100644 e2e/cli/e2e-npm10/jest.config.js create mode 100644 e2e/cli/e2e-npm10/package.json create mode 100644 e2e/cli/e2e-npm10/ping.spec.ts create mode 100644 e2e/cli/e2e-npm10/publish.spec.ts create mode 100644 e2e/cli/e2e-npm10/search.spec.ts create mode 100644 e2e/cli/e2e-npm10/star.spec.ts create mode 100644 e2e/cli/e2e-npm10/tsconfig.json create mode 100644 e2e/cli/e2e-npm10/utils.ts diff --git a/.github/workflows/e2e-ci.yml b/.github/workflows/e2e-ci.yml index 78e769465..705f0f52f 100644 --- a/.github/workflows/e2e-ci.yml +++ b/.github/workflows/e2e-ci.yml @@ -78,7 +78,7 @@ jobs: strategy: fail-fast: false matrix: - pkg: [npm6, npm7, npm8, npm9, pnpm6, pnpm7, pnpm8, yarn1, yarn2, yarn3, yarn4] + pkg: [npm6, npm7, npm8, npm9, npm10, pnpm6, pnpm7, pnpm8, yarn1, yarn2, yarn3, yarn4] node: [16, 18, 19] name: ${{ matrix.pkg }}/ ubuntu-latest / ${{ matrix.node }} runs-on: ubuntu-latest diff --git a/e2e/cli/README.md b/e2e/cli/README.md index a1da841d0..52abd1305 100644 --- a/e2e/cli/README.md +++ b/e2e/cli/README.md @@ -3,14 +3,11 @@ ## What is included on these test? - Default configuration only -- Test with all popular package managers: -- `yarn classic` and `yarn modern (2, 3, 4 RC)` -- `pnpm 6, 7` -- `npm 6, 7, 8 and 9` +- Test with all popular package managers ### Commands Tested -| cmd | npm6 | npm7 | npm8 | npm9 | pnpm6 | pnpm7 | pnpm8 | yarn1 | yarn2 | yarn3 | yarn4 | +| cmd | npm6 | npm7 | npm8 | npm9 | npm10 | pnpm6 | pnpm7 | yarn1 | yarn2 | yarn3 | yarn4 | | --------- | ---- | ---- | ---- | ---- | ----- | ----- | ----- | ----- | ----- | ----- | ----- | | publish | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | info | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | diff --git a/e2e/cli/e2e-npm10/.babelrc b/e2e/cli/e2e-npm10/.babelrc new file mode 100644 index 000000000..851856e59 --- /dev/null +++ b/e2e/cli/e2e-npm10/.babelrc @@ -0,0 +1,3 @@ +{ + "extends": "../../../.babelrc" +} diff --git a/e2e/cli/e2e-npm10/.eslintrc b/e2e/cli/e2e-npm10/.eslintrc new file mode 100644 index 000000000..eb2ac4c85 --- /dev/null +++ b/e2e/cli/e2e-npm10/.eslintrc @@ -0,0 +1,7 @@ +{ + "rules": { + "no-console": 0, + "@typescript-eslint/no-var-requires": 0, + "@typescript-eslint/explicit-member-accessibility": 0 + } +} diff --git a/e2e/cli/e2e-npm10/CHANGELOG.md b/e2e/cli/e2e-npm10/CHANGELOG.md new file mode 100644 index 000000000..96b99d884 --- /dev/null +++ b/e2e/cli/e2e-npm10/CHANGELOG.md @@ -0,0 +1,62 @@ +# @verdaccio/e2e-cli-npm9 + +## 1.0.1 + +### Patch Changes + +- Updated dependencies [351aeeaa8] +- Updated dependencies [d167f92e1] +- Updated dependencies [c383eb68c] + - @verdaccio/test-cli-commons@1.1.0 + +## 1.0.1-6-next.7 + +### Patch Changes + +- Updated dependencies [c383eb68] + - @verdaccio/test-cli-commons@1.1.0-6-next.7 + +## 1.0.1-6-next.6 + +### Patch Changes + +- Updated dependencies [d167f92e] + - @verdaccio/test-cli-commons@1.1.0-6-next.6 + +## 1.0.1-6-next.5 + +### Patch Changes + +- @verdaccio/test-cli-commons@1.0.1-6-next.5 + +## 1.0.1-6-next.4 + +### Patch Changes + +- @verdaccio/test-cli-commons@1.0.1-6-next.4 + +## 1.0.1-6-next.3 + +### Patch Changes + +- 351aeeaa: fix(deps): @verdaccio/utils should be a prod dep of local-storage +- Updated dependencies [351aeeaa] + - @verdaccio/test-cli-commons@1.0.1-6-next.3 + +## 1.0.1-6-next.2 + +### Patch Changes + +- @verdaccio/test-cli-commons@1.0.1-6-next.2 + +## 1.0.1-6-next.1 + +### Patch Changes + +- @verdaccio/test-cli-commons@1.0.1-6-next.1 + +## 1.0.1-6-next.0 + +### Patch Changes + +- @verdaccio/test-cli-commons@1.0.1-6-next.0 diff --git a/e2e/cli/e2e-npm10/audit.spec.ts b/e2e/cli/e2e-npm10/audit.spec.ts new file mode 100644 index 000000000..b2ecf2d5a --- /dev/null +++ b/e2e/cli/e2e-npm10/audit.spec.ts @@ -0,0 +1,44 @@ +import { addRegistry, initialSetup, prepareGenericEmptyProject } from '@verdaccio/test-cli-commons'; + +import { npm } from './utils'; + +describe('audit a package', () => { + jest.setTimeout(10000); + let registry; + + beforeAll(async () => { + const setup = await initialSetup(); + registry = setup.registry; + await registry.init(); + }); + + test.each([['verdaccio-memory', '@verdaccio/cli']])( + 'should audit a package %s', + async (pkgName) => { + const { tempFolder } = await prepareGenericEmptyProject( + pkgName, + '1.0.0-patch', + registry.port, + registry.getToken(), + registry.getRegistryUrl(), + { jquery: '3.6.1' } + ); + // install is required to create package lock file + await npm({ cwd: tempFolder }, 'install', ...addRegistry(registry.getRegistryUrl())); + const resp = await npm( + { cwd: tempFolder }, + 'audit', + '--json', + ...addRegistry(registry.getRegistryUrl()) + ); + const parsedBody = JSON.parse(resp.stdout as string); + expect(parsedBody.metadata).toBeDefined(); + expect(parsedBody.auditReportVersion).toBeDefined(); + expect(parsedBody.vulnerabilities).toBeDefined(); + } + ); + + afterAll(async () => { + registry.stop(); + }); +}); diff --git a/e2e/cli/e2e-npm10/deprecate.spec.ts b/e2e/cli/e2e-npm10/deprecate.spec.ts new file mode 100644 index 000000000..9855138df --- /dev/null +++ b/e2e/cli/e2e-npm10/deprecate.spec.ts @@ -0,0 +1,115 @@ +import { + addRegistry, + initialSetup, + npmUtils, + prepareGenericEmptyProject, +} from '@verdaccio/test-cli-commons'; + +import { npm } from './utils'; + +describe('deprecate a package', () => { + jest.setTimeout(20000); + let registry; + + async function deprecate(tempFolder, packageVersion, registry, message) { + await npm( + { cwd: tempFolder }, + 'deprecate', + packageVersion, + message, + '--json', + ...addRegistry(registry.getRegistryUrl()) + ); + } + + beforeAll(async () => { + const setup = await initialSetup(); + registry = setup.registry; + await registry.init(); + }); + + test.each([['@verdaccio/deprecated-1']])( + 'should deprecate a single package %s', + async (pkgName) => { + const message = 'some message'; + const { tempFolder } = await prepareGenericEmptyProject( + pkgName, + '1.0.0', + registry.port, + registry.getToken(), + registry.getRegistryUrl() + ); + await npmUtils.publish(npm, tempFolder, pkgName, registry); + // deprecate one version + await deprecate(tempFolder, `${pkgName}@1.0.0`, registry, message); + // verify is deprecated + const infoBody = await npmUtils.getInfoVersions(npm, `${pkgName}`, registry); + expect(infoBody.name).toEqual(pkgName); + expect(infoBody.deprecated).toEqual(message); + } + ); + + test.each([['@verdaccio/deprecated-2']])('should un-deprecate a package %s', async (pkgName) => { + const message = 'some message'; + const { tempFolder } = await prepareGenericEmptyProject( + pkgName, + '1.0.0', + registry.port, + registry.getToken(), + registry.getRegistryUrl() + ); + await npmUtils.publish(npm, tempFolder, pkgName, registry); + // deprecate one version + await deprecate(tempFolder, `${pkgName}@1.0.0`, registry, message); + // verify is deprecated + const infoBody = await npmUtils.getInfoVersions(npm, `${pkgName}`, registry); + expect(infoBody.deprecated).toEqual(message); + // empty string is same as undeprecate + await deprecate(tempFolder, `${pkgName}@1.0.0`, registry, ''); + const infoBody2 = await npmUtils.getInfoVersions(npm, `${pkgName}`, registry); + expect(infoBody2.deprecated).toBeUndefined(); + }); + + test.each([['@verdaccio/deprecated-3']])( + 'should deprecate a multiple packages %s', + async (pkgName) => { + const message = 'some message'; + const { tempFolder } = await prepareGenericEmptyProject( + pkgName, + '1.0.0', + registry.port, + registry.getToken(), + registry.getRegistryUrl() + ); + // publish 1.0.0 + await npmUtils.publish(npm, tempFolder, pkgName, registry); + // publish 1.1.0 + await npmUtils.bumbUp(npm, tempFolder, registry); + await npmUtils.publish(npm, tempFolder, pkgName, registry); + // publish 1.2.0 + await npmUtils.bumbUp(npm, tempFolder, registry); + await npmUtils.publish(npm, tempFolder, pkgName, registry); + // publish 1.3.0 + await npmUtils.bumbUp(npm, tempFolder, registry); + await npmUtils.publish(npm, tempFolder, pkgName, registry); + // // deprecate all version + await deprecate(tempFolder, pkgName, registry, message); + // verify is deprecated + for (let v of ['1.0.0', '1.1.0', '1.2.0', '1.3.0']) { + const infoResp = await npmUtils.getInfoVersions(npm, `${pkgName}@${v}`, registry); + expect(infoResp.deprecated).toEqual(message); + } + // publish normal version + // publish 1.4.0 + await npmUtils.bumbUp(npm, tempFolder, registry); + await npmUtils.publish(npm, tempFolder, pkgName, registry); + const infoResp = await npmUtils.getInfoVersions(npm, `${pkgName}@1.4.0`, registry); + // must be not deprecated + expect(infoResp.deprecated).toBeUndefined(); + } + ); + + afterAll(async () => { + registry.stop(); + }); +}); diff --git a/e2e/cli/e2e-npm10/dist-tags.spec.ts b/e2e/cli/e2e-npm10/dist-tags.spec.ts new file mode 100644 index 000000000..1c9ac76ca --- /dev/null +++ b/e2e/cli/e2e-npm10/dist-tags.spec.ts @@ -0,0 +1,91 @@ +import { + addRegistry, + initialSetup, + npmUtils, + prepareGenericEmptyProject, +} from '@verdaccio/test-cli-commons'; + +import { npm } from './utils'; + +describe('publish a package', () => { + jest.setTimeout(20000); + let registry; + + beforeAll(async () => { + const setup = await initialSetup(); + registry = setup.registry; + await registry.init(); + }); + + test.each([['@foo/foo', 'foo']])('should list dist-tags for %s', async (pkgName) => { + const { tempFolder } = await prepareGenericEmptyProject( + pkgName, + '1.0.0', + registry.port, + registry.getToken(), + registry.getRegistryUrl() + ); + await npmUtils.publish(npm, tempFolder, pkgName, registry); + await npmUtils.bumbUp(npm, tempFolder, registry); + await npmUtils.publish(npm, tempFolder, pkgName, registry, ['--tag', 'beta']); + const resp2 = await npm( + { cwd: tempFolder }, + 'dist-tag', + 'ls', + '--json', + ...addRegistry(registry.getRegistryUrl()) + ); + expect(resp2.stdout).toEqual('beta: 1.1.0latest: 1.0.0'); + }); + + test.each([['@verdaccio/bar']])('should remove tag with dist-tags for %s', async (pkgName) => { + const { tempFolder } = await prepareGenericEmptyProject( + pkgName, + '1.0.0', + registry.port, + registry.getToken(), + registry.getRegistryUrl() + ); + await npmUtils.publish(npm, tempFolder, pkgName, registry); + await npmUtils.bumbUp(npm, tempFolder, registry); + await npmUtils.publish(npm, tempFolder, pkgName, registry, ['--tag', 'beta']); + const resp2 = await npm( + { cwd: tempFolder }, + 'dist-tag', + 'rm', + `${pkgName}@1.1.0`, + 'beta', + ...addRegistry(registry.getRegistryUrl()) + ); + expect(resp2.stdout).toEqual('-beta: @verdaccio/bar@1.1.0'); + }); + + test.each([['@verdaccio/five']])( + 'should add tag to package and version with dist-tags for %s', + async (pkgName) => { + const { tempFolder } = await prepareGenericEmptyProject( + pkgName, + '1.0.0', + registry.port, + registry.getToken(), + registry.getRegistryUrl() + ); + await npmUtils.publish(npm, tempFolder, pkgName, registry); + await npmUtils.bumbUp(npm, tempFolder, registry); + await npmUtils.publish(npm, tempFolder, pkgName, registry); + const resp2 = await npm( + { cwd: tempFolder }, + 'dist-tag', + 'add', + `${pkgName}@1.1.0`, + 'alfa', + ...addRegistry(registry.getRegistryUrl()) + ); + expect(resp2.stdout).toEqual(`+alfa: ${pkgName}@1.1.0`); + } + ); + + afterAll(async () => { + registry.stop(); + }); +}); diff --git a/e2e/cli/e2e-npm10/info.spec.ts b/e2e/cli/e2e-npm10/info.spec.ts new file mode 100644 index 000000000..2b11a113a --- /dev/null +++ b/e2e/cli/e2e-npm10/info.spec.ts @@ -0,0 +1,31 @@ +import { addRegistry, initialSetup } from '@verdaccio/test-cli-commons'; + +import { npm } from './utils'; + +describe('install a package', () => { + jest.setTimeout(10000); + let registry; + + beforeAll(async () => { + const setup = await initialSetup(); + registry = setup.registry; + await registry.init(); + }); + + test('should run npm info json body', async () => { + const resp = await npm( + {}, + 'info', + 'verdaccio', + '--json', + ...addRegistry(registry.getRegistryUrl()) + ); + const parsedBody = JSON.parse(resp.stdout as string); + expect(parsedBody.name).toEqual('verdaccio'); + expect(parsedBody.dependencies).toBeDefined(); + }); + + afterAll(async () => { + registry.stop(); + }); +}); diff --git a/e2e/cli/e2e-npm10/install.spec.ts b/e2e/cli/e2e-npm10/install.spec.ts new file mode 100644 index 000000000..2b15921da --- /dev/null +++ b/e2e/cli/e2e-npm10/install.spec.ts @@ -0,0 +1,38 @@ +import { addRegistry, initialSetup, prepareGenericEmptyProject } from '@verdaccio/test-cli-commons'; + +import { npm } from './utils'; + +describe('install a project packages', () => { + jest.setTimeout(100000); + let registry; + + beforeAll(async () => { + const setup = await initialSetup(); + registry = setup.registry; + await registry.init(); + }); + + test('should run npm install json body', async () => { + const { tempFolder } = await prepareGenericEmptyProject( + 'something', + '1.0.0-patch', + registry.port, + registry.getToken(), + registry.getRegistryUrl(), + { react: '18.2.0' } + ); + const resp = await npm( + { cwd: tempFolder }, + 'install', + '--json', + ...addRegistry(registry.getRegistryUrl()) + ); + const parsedBody = JSON.parse(resp.stdout as string); + expect(parsedBody.added).toBeDefined(); + expect(parsedBody.audit).toBeDefined(); + }); + + afterAll(async () => { + registry.stop(); + }); +}); diff --git a/e2e/cli/e2e-npm10/jest.config.js b/e2e/cli/e2e-npm10/jest.config.js new file mode 100644 index 000000000..cd9759162 --- /dev/null +++ b/e2e/cli/e2e-npm10/jest.config.js @@ -0,0 +1,3 @@ +const config = require('../jest.config'); + +module.exports = { ...config }; diff --git a/e2e/cli/e2e-npm10/package.json b/e2e/cli/e2e-npm10/package.json new file mode 100644 index 000000000..f1a2dcbd8 --- /dev/null +++ b/e2e/cli/e2e-npm10/package.json @@ -0,0 +1,12 @@ +{ + "private": true, + "name": "@verdaccio/e2e-cli-npm9", + "version": "1.0.1", + "dependencies": { + "@verdaccio/test-cli-commons": "workspace:1.1.0", + "npm": "10.1.0" + }, + "scripts": { + "test": "jest" + } +} diff --git a/e2e/cli/e2e-npm10/ping.spec.ts b/e2e/cli/e2e-npm10/ping.spec.ts new file mode 100644 index 000000000..37edf9cbc --- /dev/null +++ b/e2e/cli/e2e-npm10/ping.spec.ts @@ -0,0 +1,24 @@ +import { addRegistry, initialSetup } from '@verdaccio/test-cli-commons'; + +import { npm } from './utils'; + +describe('ping registry', () => { + jest.setTimeout(10000); + let registry; + + beforeAll(async () => { + const setup = await initialSetup(); + registry = setup.registry; + await registry.init(); + }); + + test('should ping registry', async () => { + const resp = await npm({}, 'ping', '--json', ...addRegistry(registry.getRegistryUrl())); + const parsedBody = JSON.parse(resp.stdout as string); + expect(parsedBody.registry).toEqual(registry.getRegistryUrl() + '/'); + }); + + afterAll(async () => { + registry.stop(); + }); +}); diff --git a/e2e/cli/e2e-npm10/publish.spec.ts b/e2e/cli/e2e-npm10/publish.spec.ts new file mode 100644 index 000000000..ed137ecb3 --- /dev/null +++ b/e2e/cli/e2e-npm10/publish.spec.ts @@ -0,0 +1,41 @@ +import { addRegistry, initialSetup, prepareGenericEmptyProject } from '@verdaccio/test-cli-commons'; + +import { npm } from './utils'; + +describe('install a package', () => { + jest.setTimeout(10000); + let registry; + + beforeAll(async () => { + const setup = await initialSetup(); + registry = setup.registry; + await registry.init(); + }); + + test.each([['verdaccio-memory', 'verdaccio', '@verdaccio/foo', '@verdaccio/some-foo']])( + 'should publish a package %s', + async (pkgName) => { + const { tempFolder } = await prepareGenericEmptyProject( + pkgName, + '1.0.0-patch', + registry.port, + registry.getToken(), + registry.getRegistryUrl() + ); + const resp = await npm( + { cwd: tempFolder }, + 'publish', + '--json', + ...addRegistry(registry.getRegistryUrl()) + ); + const parsedBody = JSON.parse(resp.stdout as string); + expect(parsedBody.name).toEqual(pkgName); + expect(parsedBody.files).toBeDefined(); + expect(parsedBody.files).toBeDefined(); + } + ); + + afterAll(async () => { + registry.stop(); + }); +}); diff --git a/e2e/cli/e2e-npm10/search.spec.ts b/e2e/cli/e2e-npm10/search.spec.ts new file mode 100644 index 000000000..c62ba1be6 --- /dev/null +++ b/e2e/cli/e2e-npm10/search.spec.ts @@ -0,0 +1,33 @@ +import { addRegistry, initialSetup } from '@verdaccio/test-cli-commons'; + +import { npm } from './utils'; + +describe('search a package', () => { + jest.setTimeout(10000); + let registry; + + beforeAll(async () => { + const setup = await initialSetup(); + registry = setup.registry; + await registry.init(); + }); + + test('should search a package', async () => { + const resp = await npm( + {}, + 'search', + '@verdaccio/cli', + '--json', + ...addRegistry(registry.getRegistryUrl()) + ); + const parsedBody = JSON.parse(resp.stdout as string); + const pkgFind = parsedBody.find((item) => { + return item.name === '@verdaccio/cli'; + }); + expect(pkgFind.name).toEqual('@verdaccio/cli'); + }); + + afterAll(async () => { + registry.stop(); + }); +}); diff --git a/e2e/cli/e2e-npm10/star.spec.ts b/e2e/cli/e2e-npm10/star.spec.ts new file mode 100644 index 000000000..9f1b75b54 --- /dev/null +++ b/e2e/cli/e2e-npm10/star.spec.ts @@ -0,0 +1,85 @@ +import { + addRegistry, + initialSetup, + npmUtils, + prepareGenericEmptyProject, +} from '@verdaccio/test-cli-commons'; + +import { npm } from './utils'; + +describe('star a package', () => { + jest.setTimeout(20000); + let registry; + + beforeAll(async () => { + const setup = await initialSetup(); + registry = setup.registry; + await registry.init(); + }); + + test.each([['@verdaccio/foo']])('should star a package %s', async (pkgName) => { + const { tempFolder } = await prepareGenericEmptyProject( + pkgName, + '1.0.0-patch', + registry.port, + registry.getToken(), + registry.getRegistryUrl() + ); + + await npmUtils.publish(npm, tempFolder, pkgName, registry); + const resp = await npm( + { cwd: tempFolder }, + 'star', + pkgName, + ...addRegistry(registry.getRegistryUrl()) + ); + expect(resp.stdout).toEqual(`★ ${pkgName}`); + }); + + test.each([['@verdaccio/bar']])('should unstar a package %s', async (pkgName) => { + const { tempFolder } = await prepareGenericEmptyProject( + pkgName, + '1.0.0-patch', + registry.port, + registry.getToken(), + registry.getRegistryUrl() + ); + + await npmUtils.publish(npm, tempFolder, pkgName, registry); + const resp = await npm( + { cwd: tempFolder }, + 'star', + pkgName, + ...addRegistry(registry.getRegistryUrl()) + ); + expect(resp.stdout).toEqual(`★ ${pkgName}`); + + const resp1 = await npm( + { cwd: tempFolder }, + 'unstar', + pkgName, + ...addRegistry(registry.getRegistryUrl()) + ); + expect(resp1.stdout).toEqual(`☆ ${pkgName}`); + }); + + test('should list stars of a user %s', async () => { + const pkgName = '@verdaccio/stars'; + const { tempFolder } = await prepareGenericEmptyProject( + pkgName, + '1.0.0-patch', + registry.port, + registry.getToken(), + registry.getRegistryUrl() + ); + await npmUtils.publish(npm, tempFolder, pkgName, registry); + await npm({ cwd: tempFolder }, 'star', pkgName, ...addRegistry(registry.getRegistryUrl())); + const resp = await npm({ cwd: tempFolder }, 'stars', ...addRegistry(registry.getRegistryUrl())); + // side effects: this result is affected the the package published in the previous step + expect(resp.stdout).toEqual(`@verdaccio/foo@verdaccio/stars`); + }); + + afterAll(async () => { + registry.stop(); + }); +}); diff --git a/e2e/cli/e2e-npm10/tsconfig.json b/e2e/cli/e2e-npm10/tsconfig.json new file mode 100644 index 000000000..85f4ceca6 --- /dev/null +++ b/e2e/cli/e2e-npm10/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../../tsconfig.reference.json", + "references": [ + { + "path": "../cli-commons" + } + ] +} diff --git a/e2e/cli/e2e-npm10/utils.ts b/e2e/cli/e2e-npm10/utils.ts new file mode 100644 index 000000000..4b9da27bb --- /dev/null +++ b/e2e/cli/e2e-npm10/utils.ts @@ -0,0 +1,41 @@ +import { SpawnOptions } from 'child_process'; +import { join } from 'path'; + +import { exec } from '@verdaccio/test-cli-commons'; +import { addRegistry } from '@verdaccio/test-cli-commons'; + +export function getCommand() { + return join(__dirname, './node_modules/.bin/npm'); +} + +export function npm(options: SpawnOptions, ...args: string[]) { + return exec(options, getCommand(), args); +} + +export async function bumbUp(tempFolder, registry) { + await npm({ cwd: tempFolder }, 'version', 'minor', ...addRegistry(registry.getRegistryUrl())); +} + +export async function publish(tempFolder, pkgName, registry, arg: string[] = []) { + const resp = await npm( + { cwd: tempFolder }, + 'publish', + ...arg, + '--json', + ...addRegistry(registry.getRegistryUrl()) + ); + const parsedBody = JSON.parse(resp.stdout as string); + expect(parsedBody.name).toEqual(pkgName); +} + +export async function getInfoVersions(pkgName, registry) { + const infoResp = await npm( + {}, + 'info', + pkgName, + '--json', + ...addRegistry(registry.getRegistryUrl()) + ); + const infoBody = JSON.parse(infoResp.stdout as string); + return infoBody; +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 558c03688..5e5fc4175 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -379,6 +379,15 @@ importers: specifier: workspace:7.0.0-next.2 version: link:../../../packages/verdaccio + e2e/cli/e2e-npm10: + dependencies: + '@verdaccio/test-cli-commons': + specifier: workspace:1.1.0 + version: link:../cli-commons + npm: + specifier: 10.1.0 + version: 10.1.0 + e2e/cli/e2e-npm6: dependencies: '@verdaccio/test-cli-commons': @@ -22340,6 +22349,81 @@ packages: engines: {node: '>=6.0.0'} dev: false + /npm@10.1.0: + resolution: {integrity: sha512-pZ2xybXzNGbJFZEKNbPoEXsE38Xou9VTnxxBk+B3pz0ndsGCs7iWHoUCPSsISU2hjmkWfDkJo3bYKE8RDOg4eg==} + engines: {node: ^18.17.0 || >=20.5.0} + hasBin: true + dev: false + bundledDependencies: + - '@isaacs/string-locale-compare' + - '@npmcli/arborist' + - '@npmcli/config' + - '@npmcli/fs' + - '@npmcli/map-workspaces' + - '@npmcli/package-json' + - '@npmcli/promise-spawn' + - '@npmcli/run-script' + - '@sigstore/tuf' + - abbrev + - archy + - cacache + - chalk + - ci-info + - cli-columns + - cli-table3 + - columnify + - fastest-levenshtein + - fs-minipass + - glob + - graceful-fs + - hosted-git-info + - ini + - init-package-json + - is-cidr + - json-parse-even-better-errors + - libnpmaccess + - libnpmdiff + - libnpmexec + - libnpmfund + - libnpmhook + - libnpmorg + - libnpmpack + - libnpmpublish + - libnpmsearch + - libnpmteam + - libnpmversion + - make-fetch-happen + - minimatch + - minipass + - minipass-pipeline + - ms + - node-gyp + - nopt + - npm-audit-report + - npm-install-checks + - npm-package-arg + - npm-pick-manifest + - npm-profile + - npm-registry-fetch + - npm-user-validate + - npmlog + - p-map + - pacote + - parse-conflict-json + - proc-log + - qrcode-terminal + - read + - semver + - ssri + - supports-color + - tar + - text-table + - tiny-relative-date + - treeverse + - validate-npm-package-name + - which + - write-file-atomic + /npm@9.7.1: resolution: {integrity: sha512-kxMviaiLX4Lfnjy2dt7EWB87v5QdLiGpy04S2ORdKLmPqFhgy8g4cgJjQfnWob4mJIaNHjBO+hk45CvLlsZZ8g==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0}