From 1755840cd3bfef0634f561767decbb8c5546606b Mon Sep 17 00:00:00 2001 From: Juan Picado Date: Tue, 2 Aug 2022 22:45:16 +0200 Subject: [PATCH] e2e cli npm 6 (#3282) * chore: add config utility * improve verdaccio bin location * add new npm cli e2e tests * add tests * rename files --- .github/workflows/ci.yml | 52 +- package.json | 3 +- packages/config/src/conf/index.ts | 8 + packages/config/src/index.ts | 1 + packages/config/test/config.spec.ts | 5 +- packages/verdaccio/bin/verdaccio | 2 +- packages/verdaccio/src/server/registry.ts | 25 +- pnpm-lock.yaml | 478 ++++++++++-------- pnpm-workspace.yaml | 2 +- test/cli/cli-commons/.babelrc | 3 + test/{e2e-cli => cli/cli-commons}/.eslintrc | 0 test/cli/cli-commons/package.json | 27 + .../utils => cli/cli-commons/src}/expect.ts | 0 test/cli/cli-commons/src/index.ts | 4 + test/cli/cli-commons/src/process.ts | 58 +++ test/cli/cli-commons/src/registry.ts | 20 + test/cli/cli-commons/src/utils.ts | 45 ++ test/cli/cli-commons/src/web.ts | 5 + .../old_tests}/__partials/npm_commands.ts | 0 .../cli-commons/tests/old_tests/info.__.ts} | 0 .../tests/old_tests/install.__.ts} | 0 .../cli-commons/tests/old_tests/listen.__.ts} | 0 .../cli-commons/tests/old_tests/search.__.ts} | 0 .../tests}/projects/basic/.npmignore | 0 .../tests}/projects/basic/README.md | 0 .../tests}/projects/basic/index.js | 0 .../tests}/projects/basic/package.json | 0 .../tests}/projects/scoped_basic/.npmignore | 0 .../tests}/projects/scoped_basic/README.md | 0 .../tests}/projects/scoped_basic/index.js | 0 .../tests}/projects/scoped_basic/package.json | 0 test/cli/cli-commons/tsconfig.build.json | 9 + test/cli/cli-commons/tsconfig.json | 21 + test/cli/e2e-npm6/.babelrc | 3 + test/cli/e2e-npm6/.eslintrc | 7 + test/{e2e-cli => cli/e2e-npm6}/CHANGELOG.md | 0 test/{e2e-cli => cli/e2e-npm6}/LICENSE | 0 test/{e2e-cli => cli/e2e-npm6}/README.md | 0 .../config/_bootstrap_verdaccio.yaml | 0 .../e2e-npm6}/config/default.yaml | 0 test/cli/e2e-npm6/info.spec.ts | 30 ++ test/cli/e2e-npm6/jest.config.js | 14 + test/cli/e2e-npm6/package.json | 12 + test/{e2e-cli => cli/e2e-npm6}/tsconfig.json | 7 +- test/cli/e2e-npm6/utils.ts | 12 + test/e2e-cli/.babelrc | 3 - test/e2e-cli/env_babel.js | 4 - test/e2e-cli/env_setup.js | 4 - test/e2e-cli/env_teardown.js | 4 - test/e2e-cli/jest.config.e2e.cli.js | 14 - test/e2e-cli/package.json | 21 - test/e2e-cli/setup/setup.ts | 68 --- test/e2e-cli/setup/teardown.ts | 9 - test/e2e-cli/setup/test_environment.ts | 38 -- test/e2e-cli/utils/global.js | 18 - test/e2e-cli/utils/process.ts | 102 ---- test/e2e-cli/utils/registry.spec.ts | 7 - test/e2e-cli/utils/registry.ts | 149 ------ test/e2e-cli/utils/utils.ts | 35 -- test/e2e-cli/utils/web.ts | 22 - 60 files changed, 602 insertions(+), 749 deletions(-) create mode 100644 packages/config/src/conf/index.ts create mode 100644 test/cli/cli-commons/.babelrc rename test/{e2e-cli => cli/cli-commons}/.eslintrc (100%) create mode 100644 test/cli/cli-commons/package.json rename test/{e2e-cli/utils => cli/cli-commons/src}/expect.ts (100%) create mode 100644 test/cli/cli-commons/src/index.ts create mode 100644 test/cli/cli-commons/src/process.ts create mode 100644 test/cli/cli-commons/src/registry.ts create mode 100644 test/cli/cli-commons/src/utils.ts create mode 100644 test/cli/cli-commons/src/web.ts rename test/{e2e-cli/test_bk => cli/cli-commons/tests/old_tests}/__partials/npm_commands.ts (100%) rename test/{e2e-cli/test_bk/info.spec.ts => cli/cli-commons/tests/old_tests/info.__.ts} (100%) rename test/{e2e-cli/test_bk/install.spec.ts => cli/cli-commons/tests/old_tests/install.__.ts} (100%) rename test/{e2e-cli/test_bk/listen.spec.ts => cli/cli-commons/tests/old_tests/listen.__.ts} (100%) rename test/{e2e-cli/test_bk/search.spec.ts => cli/cli-commons/tests/old_tests/search.__.ts} (100%) rename test/{e2e-cli => cli/cli-commons/tests}/projects/basic/.npmignore (100%) rename test/{e2e-cli => cli/cli-commons/tests}/projects/basic/README.md (100%) rename test/{e2e-cli => cli/cli-commons/tests}/projects/basic/index.js (100%) rename test/{e2e-cli => cli/cli-commons/tests}/projects/basic/package.json (100%) rename test/{e2e-cli => cli/cli-commons/tests}/projects/scoped_basic/.npmignore (100%) rename test/{e2e-cli => cli/cli-commons/tests}/projects/scoped_basic/README.md (100%) rename test/{e2e-cli => cli/cli-commons/tests}/projects/scoped_basic/index.js (100%) rename test/{e2e-cli => cli/cli-commons/tests}/projects/scoped_basic/package.json (100%) create mode 100644 test/cli/cli-commons/tsconfig.build.json create mode 100644 test/cli/cli-commons/tsconfig.json create mode 100644 test/cli/e2e-npm6/.babelrc create mode 100644 test/cli/e2e-npm6/.eslintrc rename test/{e2e-cli => cli/e2e-npm6}/CHANGELOG.md (100%) rename test/{e2e-cli => cli/e2e-npm6}/LICENSE (100%) rename test/{e2e-cli => cli/e2e-npm6}/README.md (100%) rename test/{e2e-cli => cli/e2e-npm6}/config/_bootstrap_verdaccio.yaml (100%) rename test/{e2e-cli => cli/e2e-npm6}/config/default.yaml (100%) create mode 100644 test/cli/e2e-npm6/info.spec.ts create mode 100644 test/cli/e2e-npm6/jest.config.js create mode 100644 test/cli/e2e-npm6/package.json rename test/{e2e-cli => cli/e2e-npm6}/tsconfig.json (63%) create mode 100644 test/cli/e2e-npm6/utils.ts delete mode 100644 test/e2e-cli/.babelrc delete mode 100644 test/e2e-cli/env_babel.js delete mode 100644 test/e2e-cli/env_setup.js delete mode 100644 test/e2e-cli/env_teardown.js delete mode 100644 test/e2e-cli/jest.config.e2e.cli.js delete mode 100644 test/e2e-cli/package.json delete mode 100644 test/e2e-cli/setup/setup.ts delete mode 100644 test/e2e-cli/setup/teardown.ts delete mode 100644 test/e2e-cli/setup/test_environment.ts delete mode 100644 test/e2e-cli/utils/global.js delete mode 100644 test/e2e-cli/utils/process.ts delete mode 100644 test/e2e-cli/utils/registry.spec.ts delete mode 100644 test/e2e-cli/utils/registry.ts delete mode 100644 test/e2e-cli/utils/utils.ts delete mode 100644 test/e2e-cli/utils/web.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 262849265..160aa2721 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -139,34 +139,32 @@ jobs: # env: # DEBUG: verdaccio:e2e* # FIXME verify why fails on Node 16 (locally works fine) - # ci-e2e-cli: - # needs: [format, lint] - # runs-on: ubuntu-latest - # # TODO: fails on migrate to node 16, we need to check why - # name: CLI Test E2E Node 16 - # steps: - # - uses: actions/checkout@v3 - # - uses: actions/setup-node@v3 - # with: - # node-version: 16 - # - name: Install pnpm - # run: npm i pnpm@latest -g - # - uses: actions/cache@v3 - # with: - # path: ~/.pnpm-store - # key: pnpm-${{ hashFiles('pnpm-lock.yaml') }} - # - name: Install - # ## we need scripts, pupetter downloads aditional content - # run: pnpm recursive install --frozen-lockfile - # - name: build - # run: pnpm build - # - name: Test CLI - # run: pnpm test:e2e:cli - # env: - # DEBUG: verdaccio* + ci-e2e-cli: + needs: [format, lint] + runs-on: ubuntu-latest + name: CLI Test E2E Node 16 + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16 + - name: Install pnpm + run: npm i pnpm@6.32.15 -g + - uses: actions/cache@v3 + with: + path: ~/.pnpm-store + key: pnpm-${{ hashFiles('pnpm-lock.yaml') }} + - name: Install + ## we need scripts, pupetter downloads aditional content + run: pnpm recursive install --frozen-lockfile + - name: build + run: pnpm build + - name: Test CLI + run: pnpm test:e2e:cli + # env: + # DEBUG: verdaccio* sync-translations: - # needs: [ci-e2e-cli, ci-e2e-ui] - needs: [ci-e2e-ui] + needs: [ci-e2e-cli, ci-e2e-ui] runs-on: ubuntu-latest name: synchronize translations if: (github.event_name == 'push' && github.ref == 'refs/heads/master') || github.event_name == 'workflow_dispatch' diff --git a/package.json b/package.json index 8262b87d7..baf114da0 100644 --- a/package.json +++ b/package.json @@ -110,6 +110,7 @@ "verdaccio-memory": "workspace:*" }, "scripts": { + "prepare": "husky install", "husky:pre-commit": "lint-staged", "clean": "pnpm recursive run clean", "build": "pnpm recursive run build --filter=!@verdaccio/website", @@ -118,7 +119,7 @@ "format:check": "prettier --check \"**/*.{js,jsx,ts,tsx,json,yml,yaml,md}\"", "lint": "eslint --max-warnings 100 \"**/*.{js,jsx,ts,tsx}\"", "test": "pnpm recursive test --filter ./packages", - "test:e2e:cli": "pnpm test --filter ...@verdaccio/e2e-cli", + "test:e2e:cli": "pnpm test --filter ...@verdaccio/e2e-*", "test:e2e:ui": "pnpm test --filter ...@verdaccio/e2e-ui", "start": "concurrently --kill-others \"pnpm _start:server\" \"pnpm _start:web\"", "benchmark:hyper": "verdaccio-benchmark hyper -r ./hyper-results.json", diff --git a/packages/config/src/conf/index.ts b/packages/config/src/conf/index.ts new file mode 100644 index 000000000..5ba7ff44f --- /dev/null +++ b/packages/config/src/conf/index.ts @@ -0,0 +1,8 @@ +import { join } from 'path'; + +import { parseConfigFile } from '../parse'; + +export function getDefaultConfig(fileName = 'default.yaml') { + const file = join(__dirname, `./${fileName}`); + return parseConfigFile(file); +} diff --git a/packages/config/src/index.ts b/packages/config/src/index.ts index aacb84e8b..21f68d20e 100644 --- a/packages/config/src/index.ts +++ b/packages/config/src/index.ts @@ -7,3 +7,4 @@ export * from './uplinks'; export * from './security'; export * from './user'; export { default as ConfigBuilder } from './builder'; +export { getDefaultConfig } from './conf'; diff --git a/packages/config/test/config.spec.ts b/packages/config/test/config.spec.ts index 5f59ff4fe..94b36c6a9 100644 --- a/packages/config/test/config.spec.ts +++ b/packages/config/test/config.spec.ts @@ -8,6 +8,7 @@ import { ROLES, WEB_TITLE, defaultSecurity, + getDefaultConfig, parseConfigFile, } from '../src'; import { parseConfigurationFile } from './utils'; @@ -74,7 +75,7 @@ describe('check basic content parsed file', () => { }; test('parse default.yaml', () => { - const config = new Config(parseConfigFile(resolveConf('default'))); + const config = new Config(getDefaultConfig()); checkDefaultUplink(config); expect(config.storage).toBe('./storage'); expect(config.auth.htpasswd.file).toBe('./htpasswd'); @@ -82,7 +83,7 @@ describe('check basic content parsed file', () => { }); test('parse docker.yaml', () => { - const config = new Config(parseConfigFile(resolveConf('docker'))); + const config = new Config(getDefaultConfig('docker.yaml')); checkDefaultUplink(config); expect(config.storage).toBe('/verdaccio/storage/data'); expect(config.auth.htpasswd.file).toBe('/verdaccio/storage/htpasswd'); diff --git a/packages/verdaccio/bin/verdaccio b/packages/verdaccio/bin/verdaccio index 11ee67277..9c5d2d2b5 100755 --- a/packages/verdaccio/bin/verdaccio +++ b/packages/verdaccio/bin/verdaccio @@ -1,3 +1,3 @@ #!/usr/bin/env node -require('@verdaccio/cli'); +require('../build/start'); diff --git a/packages/verdaccio/src/server/registry.ts b/packages/verdaccio/src/server/registry.ts index 4a2d624fe..eaeba06c6 100644 --- a/packages/verdaccio/src/server/registry.ts +++ b/packages/verdaccio/src/server/registry.ts @@ -96,15 +96,22 @@ export class Registry { silent: false, }; - // @ts-ignore - const debugPort = parseInt(port, 10) + 5; - - childOptions = Object.assign({}, childOptions, { - execArgv: [`--inspect=${debugPort}`], - env: { - DEBUG: process.env.DEBUG, - }, - }); + if (this.debug) { + const debugPort = port + 5; + debug('debug port %o', debugPort); + childOptions = Object.assign({}, childOptions, { + execArgv: [`--inspect=${debugPort}`], + env: { + DEBUG: process.env.DEBUG, + }, + }); + } else { + childOptions = Object.assign({}, childOptions, { + env: { + DEBUG: process.env.DEBUG, + }, + }); + } const { configPath } = this; debug('configPath %s', configPath); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8096b441e..f54007323 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1245,50 +1245,39 @@ importers: verdaccio-auth-memory: link:../plugins/auth-memory verdaccio-memory: link:../plugins/memory - test/e2e-cli: - specifiers: - debug: 4.3.3 - fs-extra: 10.0.0 - get-port: 5.1.1 - npm: 7.24.2 - pnpm: 6.27.1 - request: 2.88.0 - semver: 7.3.5 - wait-on: ^6.0.0 - yarn: 1.22.17 - dependencies: - debug: 4.3.3 - npm: 7.24.2 - pnpm: 6.27.1 - request: 2.88.0 - yarn: 1.22.17 - devDependencies: - fs-extra: 10.0.0 - get-port: 5.1.1 - semver: 7.3.5 - wait-on: 6.0.0 - - test/e2e-ui: + test/cli/cli-commons: specifiers: '@verdaccio/config': workspace:6.0.0-6-next.14 '@verdaccio/core': workspace:6.0.0-6-next.5 '@verdaccio/test-helper': workspace:1.1.0-6-next.1 - debug: 4.3.4 - kleur: ^3.0.3 - lodash: ^4.17.21 - puppeteer: 10.4.0 - rimraf: 3.0.2 + debug: 4.3.3 + fs-extra: 10.0.0 + get-port: 5.1.1 + got: 11.8.3 + npm: 6.14.5 + semver: 7.3.5 verdaccio: workspace:6.0.0-6-next.41 - devDependencies: - '@verdaccio/config': link:../../packages/config - '@verdaccio/core': link:../../packages/core/core - '@verdaccio/test-helper': link:../../packages/tools/helpers - debug: 4.3.4 - kleur: 3.0.3 - lodash: 4.17.21 - puppeteer: 10.4.0 - rimraf: 3.0.2 - verdaccio: link:../../packages/verdaccio + wait-on: ^6.0.0 + dependencies: + '@verdaccio/config': link:../../../packages/config + '@verdaccio/core': link:../../../packages/core/core + '@verdaccio/test-helper': link:../../../packages/tools/helpers + debug: 4.3.3 + fs-extra: 10.0.0 + get-port: 5.1.1 + got: 11.8.3 + npm: 6.14.5 + semver: 7.3.5 + verdaccio: link:../../../packages/verdaccio + wait-on: 6.0.1_debug@4.3.3 + + test/cli/e2e-npm6: + specifiers: + '@verdaccio/test-cli-commons': workspace:1.0.0 + npm: latest-6 + dependencies: + '@verdaccio/test-cli-commons': link:../cli-commons + npm: 6.14.17 website: specifiers: @@ -9486,11 +9475,6 @@ packages: resolution: {integrity: sha512-e6ZowgGJmTuXa3GyaPbTGxX17tnThl2aSSizrFthQ7m9uLGZBXiGhgE55cjRZTF5kjZvYn9EOPOMljdjwbflxw==} dev: true - /@types/node/16.11.17: - resolution: {integrity: sha512-C1vTZME8cFo8uxY2ui41xcynEotVkczIVI5AjLmy5pkpBv/FtG+jhtOlfcPysI8VRVwoOMv6NJm44LGnoMSWkw==} - dev: true - optional: true - /@types/node/16.11.19: resolution: {integrity: sha512-BPAcfDPoHlRQNKktbsbnpACGdypPFBuX4xQlsWDE7B8XXcfII+SpOLay3/qZmCLb39kV5S1RTYwXdkx2lwLYng==} @@ -9780,14 +9764,6 @@ packages: dependencies: '@types/yargs-parser': 20.2.0 - /@types/yauzl/2.9.1: - resolution: {integrity: sha512-A1b8SU4D10uoPjwb0lnHmmu8wZhR9d+9o2PKBQT2jU5YPTKsxac6M2qGAdY7VcL+dHHhARVUDmeg0rOrcd9EjA==} - requiresBuild: true - dependencies: - '@types/node': 16.11.17 - dev: true - optional: true - /@types/yup/0.29.13: resolution: {integrity: sha512-qRyuv+P/1t1JK1rA+elmK1MmCL1BapEzKKfbEhDBV/LMMse4lmhZ/XbgETI39JveDJRpLjmToOI6uFtMW/WR2g==} dev: true @@ -10960,6 +10936,14 @@ packages: dependencies: follow-redirects: 1.13.0 + /axios/0.25.0_debug@4.3.3: + resolution: {integrity: sha512-cD8FOb0tRH3uuEe6+evtAbgJtfxr7ly3fQjYcMcuPlgkwVS9xboaVIpcDV+cYQe+yGykgwZCs1pzjntcGa6l5g==} + dependencies: + follow-redirects: 1.14.9_debug@4.3.3 + transitivePeerDependencies: + - debug + dev: false + /axios/0.25.0_debug@4.3.4: resolution: {integrity: sha512-cD8FOb0tRH3uuEe6+evtAbgJtfxr7ly3fQjYcMcuPlgkwVS9xboaVIpcDV+cYQe+yGykgwZCs1pzjntcGa6l5g==} dependencies: @@ -11685,10 +11669,6 @@ packages: resolution: {integrity: sha1-M3dm2hWAEhD92VbCLpxokaudAzc=} dev: true - /buffer-crc32/0.2.13: - resolution: {integrity: sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=} - dev: true - /buffer-equal-constant-time/1.0.1: resolution: {integrity: sha1-+OcRMvf/5uAaXJaXpMbz5I1cyBk=} @@ -13755,10 +13735,6 @@ packages: - supports-color dev: true - /devtools-protocol/0.0.901419: - resolution: {integrity: sha512-4INMPwNm9XRpBukhNbF7OB6fNTTCaI8pzy/fXg0xQzAy5h3zL1P8xT3QazgKqBrb/hAYwIBizqDBZ7GtJE74QQ==} - dev: true - /dezalgo/1.0.3: resolution: {integrity: sha1-f3Qt4Gb8dIvI24IFad3c5Jvw1FY=} dependencies: @@ -15425,20 +15401,6 @@ packages: transitivePeerDependencies: - supports-color - /extract-zip/2.0.1: - resolution: {integrity: sha512-GDhU9ntwuKyGXdZBUgTIe+vXnWj0fppUEtMDL0+idd5Sta8TGpHssn/eusA9mrPr9qNDym6SxAYZjNvCn/9RBg==} - engines: {node: '>= 10.17.0'} - hasBin: true - dependencies: - debug: 4.3.4 - get-stream: 5.2.0 - yauzl: 2.10.0 - optionalDependencies: - '@types/yauzl': 2.9.1 - transitivePeerDependencies: - - supports-color - dev: true - /extsprintf/1.3.0: resolution: {integrity: sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=} engines: {'0': node >=0.6.0} @@ -15630,12 +15592,6 @@ packages: transitivePeerDependencies: - encoding - /fd-slicer/1.1.0: - resolution: {integrity: sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4=} - dependencies: - pend: 1.2.0 - dev: true - /feed/4.2.2: resolution: {integrity: sha512-u5/sxGfiMfZNtJ3OvQpXcvotFpYkL0n9u9mM2vkui2nGo8b4wvDkJ8gAkYqbA8QpGyFCv3RK0Z+Iv+9veCS9bQ==} engines: {node: '>=0.4.0'} @@ -15855,6 +15811,18 @@ packages: resolution: {integrity: sha512-aq6gF1BEKje4a9i9+5jimNFIpq4Q1WiwBToeRK5NvZBd/TRsmW8BsJfOEGkr76TbOyPVD3OVDN910EcUNtRYEA==} engines: {node: '>=4.0'} + /follow-redirects/1.14.9_debug@4.3.3: + resolution: {integrity: sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==} + engines: {node: '>=4.0'} + peerDependencies: + debug: '*' + peerDependenciesMeta: + debug: + optional: true + dependencies: + debug: 4.3.3 + dev: false + /follow-redirects/1.14.9_debug@4.3.4: resolution: {integrity: sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==} engines: {node: '>=4.0'} @@ -16015,7 +15983,7 @@ packages: resolution: {integrity: sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ==} engines: {node: '>=12'} dependencies: - graceful-fs: 4.2.6 + graceful-fs: 4.2.9 jsonfile: 6.1.0 universalify: 2.0.0 @@ -18276,16 +18244,6 @@ packages: - ts-node - utf-8-validate - /joi/17.4.1: - resolution: {integrity: sha512-gDPOwQ5sr+BUxXuPDGrC1pSNcVR/yGGcTI0aCnjYxZEa3za60K/iCQ+OFIkEHWZGVCUcUlXlFKvMmrlmxrG6UQ==} - dependencies: - '@hapi/hoek': 9.1.0 - '@hapi/topo': 5.0.0 - '@sideway/address': 4.1.0 - '@sideway/formula': 3.0.0 - '@sideway/pinpoint': 2.0.0 - dev: true - /joi/17.4.2: resolution: {integrity: sha512-Lm56PP+n0+Z2A2rfRvsfWVDXGEWjXxatPopkQ8qQ5mxCEhwHG+Ettgg5o98FFaxilOxozoa14cFhrE/hOzh/Nw==} dependencies: @@ -20279,11 +20237,6 @@ packages: semver: 5.7.1 dev: true - /node-fetch/2.6.1: - resolution: {integrity: sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==} - engines: {node: 4.x || >=6.0.0} - dev: true - /node-fetch/2.6.7: resolution: {integrity: sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==} engines: {node: 4.x || >=6.0.0} @@ -20454,81 +20407,264 @@ packages: engines: {node: '>=6.0.0'} dev: false - /npm/7.24.2: - resolution: {integrity: sha512-120p116CE8VMMZ+hk8IAb1inCPk4Dj3VZw29/n2g6UI77urJKVYb7FZUDW8hY+EBnfsjI/2yrobBgFyzo7YpVQ==} - engines: {node: '>=10'} + /npm/6.14.17: + resolution: {integrity: sha512-CxEDn1ydVRPDl4tHrlnq+WevYAhv4GF2AEHzJKQ4prZDZ96IS3Uo6t0Sy6O9kB6XzqkI+J00WfYCqqk0p6IJ1Q==} + engines: {node: 6 >=6.2.0 || 8 || >=9.3.0} hasBin: true dev: false bundledDependencies: - - '@isaacs/string-locale-compare' - - '@npmcli/arborist' - - '@npmcli/ci-detect' - - '@npmcli/config' - - '@npmcli/map-workspaces' - - '@npmcli/package-json' - - '@npmcli/run-script' - abbrev - ansicolors - ansistyles + - aproba - archy + - bin-links + - bluebird + - byte-size - cacache - - chalk + - call-limit - chownr + - ci-info - cli-columns - cli-table3 + - cmd-shim - columnify - - fastest-levenshtein + - config-chain + - debuglog + - detect-indent + - detect-newline + - dezalgo + - editor + - figgy-pudding + - find-npm-prefix + - fs-vacuum + - fs-write-stream-atomic + - gentle-fs - glob - graceful-fs + - has-unicode - hosted-git-info + - iferr + - imurmurhash + - infer-owner + - inflight + - inherits - ini - init-package-json - is-cidr - - json-parse-even-better-errors + - json-parse-better-errors + - JSONStream + - lazy-property + - libcipm + - libnpm - libnpmaccess - - libnpmdiff - - libnpmexec - - libnpmfund - libnpmhook - libnpmorg - - libnpmpack - - libnpmpublish - libnpmsearch - libnpmteam - - libnpmversion - - make-fetch-happen - - minipass - - minipass-pipeline + - libnpx + - lock-verify + - lockfile + - lodash._baseindexof + - lodash._baseuniq + - lodash._bindcallback + - lodash._cacheindexof + - lodash._createcache + - lodash._getnative + - lodash.clonedeep + - lodash.restparam + - lodash.union + - lodash.uniq + - lodash.without + - lru-cache + - meant + - mississippi - mkdirp - - mkdirp-infer-owner - - ms + - move-concurrently - node-gyp - nopt + - normalize-package-data - npm-audit-report + - npm-cache-filename - npm-install-checks + - npm-lifecycle - npm-package-arg + - npm-packlist - npm-pick-manifest - npm-profile - npm-registry-fetch - npm-user-validate - npmlog + - once - opener + - osenv - pacote - - parse-conflict-json + - path-is-inside + - promise-inflight - qrcode-terminal - - read + - query-string + - qw + - read-cmd-shim + - read-installed - read-package-json - - read-package-json-fast + - read-package-tree + - read + - readable-stream - readdir-scoped-modules + - request + - retry - rimraf + - safe-buffer - semver + - sha + - slide + - sorted-object + - sorted-union-stream - ssri + - stringify-package - tar - text-table - tiny-relative-date - - treeverse + - uid-number + - umask + - unique-filename + - unpipe + - update-notifier + - uuid + - validate-npm-package-license - validate-npm-package-name - which + - worker-farm + - write-file-atomic + + /npm/6.14.5: + resolution: {integrity: sha512-CDwa3FJd0XJpKDbWCST484H+mCNjF26dPrU+xnREW+upR0UODjMEfXPl3bxWuAwZIX6c2ASg1plLO7jP8ehWeA==} + engines: {node: 6 >=6.2.0 || 8 || >=9.3.0} + hasBin: true + dev: false + bundledDependencies: + - abbrev + - ansicolors + - ansistyles + - aproba + - archy + - bin-links + - bluebird + - byte-size + - cacache + - call-limit + - chownr + - ci-info + - cli-columns + - cli-table3 + - cmd-shim + - columnify + - config-chain + - debuglog + - detect-indent + - detect-newline + - dezalgo + - editor + - figgy-pudding + - find-npm-prefix + - fs-vacuum + - fs-write-stream-atomic + - gentle-fs + - glob + - graceful-fs + - has-unicode + - hosted-git-info + - iferr + - imurmurhash + - infer-owner + - inflight + - inherits + - ini + - init-package-json + - is-cidr + - json-parse-better-errors + - JSONStream + - lazy-property + - libcipm + - libnpm + - libnpmaccess + - libnpmhook + - libnpmorg + - libnpmsearch + - libnpmteam + - libnpx + - lock-verify + - lockfile + - lodash._baseindexof + - lodash._baseuniq + - lodash._bindcallback + - lodash._cacheindexof + - lodash._createcache + - lodash._getnative + - lodash.clonedeep + - lodash.restparam + - lodash.union + - lodash.uniq + - lodash.without + - lru-cache + - meant + - mississippi + - mkdirp + - move-concurrently + - node-gyp + - nopt + - normalize-package-data + - npm-audit-report + - npm-cache-filename + - npm-install-checks + - npm-lifecycle + - npm-package-arg + - npm-packlist + - npm-pick-manifest + - npm-profile + - npm-registry-fetch + - npm-user-validate + - npmlog + - once + - opener + - osenv + - pacote + - path-is-inside + - promise-inflight + - qrcode-terminal + - query-string + - qw + - read-cmd-shim + - read-installed + - read-package-json + - read-package-tree + - read + - readable-stream + - readdir-scoped-modules + - request + - retry + - rimraf + - safe-buffer + - semver + - sha + - slide + - sorted-object + - sorted-union-stream + - ssri + - stringify-package + - tar + - text-table + - tiny-relative-date + - uid-number + - umask + - unique-filename + - unpipe + - update-notifier + - uuid + - validate-npm-package-license + - validate-npm-package-name + - which + - worker-farm - write-file-atomic /npmlog/4.1.2: @@ -21071,10 +21207,6 @@ packages: resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} engines: {node: '>=8'} - /pend/1.2.0: - resolution: {integrity: sha1-elfrVQpng/kRUzH89GY9XI4AelA=} - dev: true - /performance-now/2.1.0: resolution: {integrity: sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=} dev: false @@ -21267,12 +21399,6 @@ packages: resolution: {integrity: sha512-2qHaIQr2VLRFoxe2nASzsV6ef4yOOH+Fi9FBOVH6cqeSgUnoyySPZkxzLuzd+RYOQTRpROA0ztTMqxROKSb/nA==} dev: false - /pnpm/6.27.1: - resolution: {integrity: sha512-aW+oDXiMk9mzInmIaRv9v9+FSNkXBs60rVUO6QBpalPja0eO3J5ePSyBxAbLsuhGGbEOpwRq0aNywFq8yIi9HQ==} - engines: {node: '>=12.17'} - hasBin: true - dev: false - /popper.js/1.16.1-lts: resolution: {integrity: sha512-Kjw8nKRl1m+VrSFCoVGPph93W/qrSO7ZkqPpTf7F4bk/sqcfWK019dWBUpE/fBOsOQY1dks/Bmcbfn1heM/IsA==} dev: false @@ -22300,11 +22426,6 @@ packages: engines: {node: '>= 0.6.0'} dev: true - /progress/2.0.1: - resolution: {integrity: sha512-OE+a6vzqazc+K6LxJrX5UPyKFvGnL5CYmq2jFGNIBWHpc4QyE49/YOumcrpQFJpfejmvRtbJzgO1zPmMCqlbBg==} - engines: {node: '>=0.4.0'} - dev: true - /progress/2.0.3: resolution: {integrity: sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==} engines: {node: '>=0.4.0'} @@ -22376,10 +22497,6 @@ packages: forwarded: 0.2.0 ipaddr.js: 1.9.1 - /proxy-from-env/1.1.0: - resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==} - dev: true - /prr/1.0.1: resolution: {integrity: sha1-0/wRS6BplaRexok/SEzrHXj19HY=} @@ -22416,29 +22533,6 @@ packages: dependencies: escape-goat: 2.1.1 - /puppeteer/10.4.0: - resolution: {integrity: sha512-2cP8mBoqnu5gzAVpbZ0fRaobBWZM8GEUF4I1F6WbgHrKV/rz7SX8PG2wMymZgD0wo0UBlg2FBPNxlF/xlqW6+w==} - engines: {node: '>=10.18.1'} - requiresBuild: true - dependencies: - debug: 4.3.1 - devtools-protocol: 0.0.901419 - extract-zip: 2.0.1 - https-proxy-agent: 5.0.0 - node-fetch: 2.6.1 - pkg-dir: 4.2.0 - progress: 2.0.1 - proxy-from-env: 1.1.0 - rimraf: 3.0.2 - tar-fs: 2.0.0 - unbzip2-stream: 1.3.3 - ws: 7.4.6 - transitivePeerDependencies: - - bufferutil - - supports-color - - utf-8-validate - dev: true - /pure-color/1.3.0: resolution: {integrity: sha1-H+Bk+wrIUfDeYTIKi/eWg2Qi8z4=} @@ -23640,12 +23734,6 @@ packages: dependencies: tslib: 1.14.1 - /rxjs/7.3.0: - resolution: {integrity: sha512-p2yuGIg9S1epc3vrjKf6iVb3RCaAYjYskkO+jHIaV0IjOPlJop4UnodOoFb2xeNwlguqLYvGw1b1McillYb5Gw==} - dependencies: - tslib: 2.1.0 - dev: true - /rxjs/7.4.0: resolution: {integrity: sha512-7SQDi7xeTMCJpqViXh8gL/lebcwlp3d831F05+9B44A4B0WfsEwUQHR64gsH1kvJ+Ep/J9K2+n1hVl1CsGN23w==} dependencies: @@ -25121,15 +25209,6 @@ packages: resolution: {integrity: sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==} engines: {node: '>=6'} - /tar-fs/2.0.0: - resolution: {integrity: sha512-vaY0obB6Om/fso8a8vakQBzwholQ7v5+uy+tF3Ozvxv1KNezmVQAiWtcNmMHFSFPqL3dJA8ha6gdtFbfX9mcxA==} - dependencies: - chownr: 1.1.4 - mkdirp: 0.5.5 - pump: 3.0.0 - tar-stream: 2.1.4 - dev: true - /tar-fs/2.1.0: resolution: {integrity: sha512-9uW5iDvrIMCVpvasdFHW0wJPez0K4JnMZtsuIeDI7HyMGJNxmDZDOCQROr7lXyS+iL/QMpj07qcjGYTSdRFXUg==} dependencies: @@ -25776,13 +25855,6 @@ packages: which-boxed-primitive: 1.0.2 dev: false - /unbzip2-stream/1.3.3: - resolution: {integrity: sha512-fUlAF7U9Ah1Q6EieQ4x4zLNejrRvDWUYmxXUpN3uziFYCHapjWFaCAnreY9bGgxzaMCFAPPpYNng57CypwJVhg==} - dependencies: - buffer: 5.7.1 - through: 2.3.8 - dev: true - /undefsafe/2.0.5: resolution: {integrity: sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==} dev: true @@ -26538,17 +26610,19 @@ packages: rxjs: 6.6.7 dev: false - /wait-on/6.0.0: - resolution: {integrity: sha512-tnUJr9p5r+bEYXPUdRseolmz5XqJTTj98JgOsfBn7Oz2dxfE2g3zw1jE+Mo8lopM3j3et/Mq1yW7kKX6qw7RVw==} + /wait-on/6.0.1_debug@4.3.3: + resolution: {integrity: sha512-zht+KASY3usTY5u2LgaNqn/Cd8MukxLGjdcZxT2ns5QzDmTFc4XoWBgC+C/na+sMRZTuVygQoMYwdcVjHnYIVw==} engines: {node: '>=10.0.0'} hasBin: true dependencies: - axios: 0.21.1 - joi: 17.4.1 + axios: 0.25.0_debug@4.3.3 + joi: 17.6.0 lodash: 4.17.21 - minimist: 1.2.5 - rxjs: 7.3.0 - dev: true + minimist: 1.2.6 + rxjs: 7.5.4 + transitivePeerDependencies: + - debug + dev: false /wait-on/6.0.1_debug@4.3.4: resolution: {integrity: sha512-zht+KASY3usTY5u2LgaNqn/Cd8MukxLGjdcZxT2ns5QzDmTFc4XoWBgC+C/na+sMRZTuVygQoMYwdcVjHnYIVw==} @@ -27666,20 +27740,6 @@ packages: yargs-parser: 21.0.0 dev: true - /yarn/1.22.17: - resolution: {integrity: sha512-H0p241BXaH0UN9IeH//RT82tl5PfNraVpSpEoW+ET7lmopNC61eZ+A+IDvU8FM6Go5vx162SncDL8J1ZjRBriQ==} - engines: {node: '>=4.0.0'} - hasBin: true - requiresBuild: true - dev: false - - /yauzl/2.10.0: - resolution: {integrity: sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=} - dependencies: - buffer-crc32: 0.2.13 - fd-slicer: 1.1.0 - dev: true - /yn/3.1.1: resolution: {integrity: sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==} engines: {node: '>=6'} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index e68896cf3..4c8c7898b 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -10,5 +10,5 @@ packages: - packages/plugins/memory - packages/plugins/local-storage - website - - test/e2e-* + - test/cli/* - test/helpers diff --git a/test/cli/cli-commons/.babelrc b/test/cli/cli-commons/.babelrc new file mode 100644 index 000000000..851856e59 --- /dev/null +++ b/test/cli/cli-commons/.babelrc @@ -0,0 +1,3 @@ +{ + "extends": "../../../.babelrc" +} diff --git a/test/e2e-cli/.eslintrc b/test/cli/cli-commons/.eslintrc similarity index 100% rename from test/e2e-cli/.eslintrc rename to test/cli/cli-commons/.eslintrc diff --git a/test/cli/cli-commons/package.json b/test/cli/cli-commons/package.json new file mode 100644 index 000000000..8570ca54d --- /dev/null +++ b/test/cli/cli-commons/package.json @@ -0,0 +1,27 @@ +{ + "private": true, + "name": "@verdaccio/test-cli-commons", + "version": "1.0.0", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "dependencies": { + "debug": "4.3.3", + "npm": "6.14.5", + "get-port": "5.1.1", + "wait-on": "^6.0.0", + "fs-extra": "10.0.0", + "semver": "7.3.5", + "got": "11.8.3", + "verdaccio": "workspace:6.0.0-6-next.41", + "@verdaccio/core": "workspace:6.0.0-6-next.5", + "@verdaccio/config": "workspace:6.0.0-6-next.14", + "@verdaccio/test-helper": "workspace:1.1.0-6-next.1" + }, + "scripts": { + "test": "jest", + "type-check": "tsc --noEmit -p tsconfig.build.json", + "build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json", + "build:js": "babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\" --source-maps", + "build": "pnpm run build:js && pnpm run build:types" + } +} diff --git a/test/e2e-cli/utils/expect.ts b/test/cli/cli-commons/src/expect.ts similarity index 100% rename from test/e2e-cli/utils/expect.ts rename to test/cli/cli-commons/src/expect.ts diff --git a/test/cli/cli-commons/src/index.ts b/test/cli/cli-commons/src/index.ts new file mode 100644 index 000000000..91ebc0c92 --- /dev/null +++ b/test/cli/cli-commons/src/index.ts @@ -0,0 +1,4 @@ +export { getDefaultConfig } from '@verdaccio/config'; +export { initialSetup } from './registry'; +export { addNpmPrefix, addYarnPrefix, addRegistry } from './utils'; +export { exec, ExecOutput } from './process'; diff --git a/test/cli/cli-commons/src/process.ts b/test/cli/cli-commons/src/process.ts new file mode 100644 index 000000000..b6d5adee7 --- /dev/null +++ b/test/cli/cli-commons/src/process.ts @@ -0,0 +1,58 @@ +import { spawn } from 'child_process'; +import { SpawnOptions } from 'child_process'; +import buildDebug from 'debug'; +import { createInterface } from 'readline'; + +const debug = buildDebug('verdaccio:e2e:process'); + +export type ExecOutput = { + stdout: string; + stderr: string; +}; + +export async function exec(options: SpawnOptions, cmd, args): Promise { + debug('start _exec %o %o %o', options, cmd, args); + let stdout = ''; + let stderr; + const env = options.env; + debug(`Running \`${cmd} ${args.join(' ')}`); + debug(`CWD: %o`, options.cwd); + debug(`ENV: ${JSON.stringify(env)}`); + const spawnOptions = { + cwd: options.cwd, + stdio: options.stdio || 'pipe', + ...(env ? { env } : {}), + }; + + if (process.platform.startsWith('win')) { + args.unshift('/c', cmd); + cmd = 'cmd.exe'; + spawnOptions['stdio'] = 'pipe'; + } + + const childProcess = spawn(cmd, args, spawnOptions); + // @ts-ignore + const rl = createInterface({ input: childProcess.stdout }); + + rl.on('line', function (line) { + stdout += line; + }); + + const err = new Error(`Running "${cmd} ${args.join(' ')}" returned error code `); + return new Promise((resolve, reject) => { + childProcess.on('exit', (error) => { + if (!error) { + resolve({ stdout, stderr }); + } else { + err.message += `${error}...\n\nSTDOUT:\n${stdout}\n\nSTDERR:\n${stderr}\n`; + return reject({ stdout, stderr: err }); + } + }); + }); +} + +export function silentNpm(...args): Promise { + debug('run silent npm %o', args); + // @ts-ignore + return exec({ silent: true }, 'npm', args); +} diff --git a/test/cli/cli-commons/src/registry.ts b/test/cli/cli-commons/src/registry.ts new file mode 100644 index 000000000..f85843381 --- /dev/null +++ b/test/cli/cli-commons/src/registry.ts @@ -0,0 +1,20 @@ +/* eslint-disable prefer-promise-reject-errors */ +import buildDebug from 'debug'; +import { Registry } from 'verdaccio'; + +import { getDefaultConfig } from '@verdaccio/config'; + +const debug = buildDebug('verdaccio:e2e:registry-utils'); + +export type Setup = { + registry: Registry; + tempFolder: string; +}; + +export async function initialSetup(): Promise { + const { configPath, tempFolder } = await Registry.fromConfigToPath(getDefaultConfig()); + debug(`configPath %o`, configPath); + debug(`tempFolder %o`, tempFolder); + const registry = new Registry(configPath); + return { registry, tempFolder }; +} diff --git a/test/cli/cli-commons/src/utils.ts b/test/cli/cli-commons/src/utils.ts new file mode 100644 index 000000000..9ae2a503d --- /dev/null +++ b/test/cli/cli-commons/src/utils.ts @@ -0,0 +1,45 @@ +import fs from 'fs-extra'; +import { join } from 'path'; + +import { fileUtils } from '@verdaccio/core'; + +export function createProject(projectName: string) { + // @ts-ignore + const tempRootFolder = global.__namespace.getItem('dir-suite-root'); + const verdaccioInstall = join(tempRootFolder, projectName); + fs.mkdirSync(verdaccioInstall); + + return verdaccioInstall; +} +export function copyConfigFile(rootFolder, configTemplate): string { + const configPath = join(rootFolder, 'config.yaml'); + copyTo(join(__dirname, configTemplate), configPath); + + return configPath; +} + +export async function createTempFolder(prefix: string) { + return fileUtils.createTempFolder(prefix); +} + +export function copyTo(from, to) { + fs.copyFileSync(from, to); +} + +export function cleanUpTemp(tmpFolder) { + fs.rmdirSync(tmpFolder, { recursive: true }); +} + +export function addRegistry(registryUrl) { + return ['--registry', registryUrl]; +} + +export function addNpmPrefix(installFolder) { + return ['--prefix', installFolder]; +} + +export function addYarnPrefix(installFolder) { + // info regarding cwd flag + // https://github.com/yarnpkg/yarn/pull/4174 + return ['--cwd', installFolder]; +} diff --git a/test/cli/cli-commons/src/web.ts b/test/cli/cli-commons/src/web.ts new file mode 100644 index 000000000..97733e922 --- /dev/null +++ b/test/cli/cli-commons/src/web.ts @@ -0,0 +1,5 @@ +import got from 'got'; + +export function callRegistry(url: string): Promise { + return got.get(url, { headers: { Accept: 'application/json' } }).json(); +} diff --git a/test/e2e-cli/test_bk/__partials/npm_commands.ts b/test/cli/cli-commons/tests/old_tests/__partials/npm_commands.ts similarity index 100% rename from test/e2e-cli/test_bk/__partials/npm_commands.ts rename to test/cli/cli-commons/tests/old_tests/__partials/npm_commands.ts diff --git a/test/e2e-cli/test_bk/info.spec.ts b/test/cli/cli-commons/tests/old_tests/info.__.ts similarity index 100% rename from test/e2e-cli/test_bk/info.spec.ts rename to test/cli/cli-commons/tests/old_tests/info.__.ts diff --git a/test/e2e-cli/test_bk/install.spec.ts b/test/cli/cli-commons/tests/old_tests/install.__.ts similarity index 100% rename from test/e2e-cli/test_bk/install.spec.ts rename to test/cli/cli-commons/tests/old_tests/install.__.ts diff --git a/test/e2e-cli/test_bk/listen.spec.ts b/test/cli/cli-commons/tests/old_tests/listen.__.ts similarity index 100% rename from test/e2e-cli/test_bk/listen.spec.ts rename to test/cli/cli-commons/tests/old_tests/listen.__.ts diff --git a/test/e2e-cli/test_bk/search.spec.ts b/test/cli/cli-commons/tests/old_tests/search.__.ts similarity index 100% rename from test/e2e-cli/test_bk/search.spec.ts rename to test/cli/cli-commons/tests/old_tests/search.__.ts diff --git a/test/e2e-cli/projects/basic/.npmignore b/test/cli/cli-commons/tests/projects/basic/.npmignore similarity index 100% rename from test/e2e-cli/projects/basic/.npmignore rename to test/cli/cli-commons/tests/projects/basic/.npmignore diff --git a/test/e2e-cli/projects/basic/README.md b/test/cli/cli-commons/tests/projects/basic/README.md similarity index 100% rename from test/e2e-cli/projects/basic/README.md rename to test/cli/cli-commons/tests/projects/basic/README.md diff --git a/test/e2e-cli/projects/basic/index.js b/test/cli/cli-commons/tests/projects/basic/index.js similarity index 100% rename from test/e2e-cli/projects/basic/index.js rename to test/cli/cli-commons/tests/projects/basic/index.js diff --git a/test/e2e-cli/projects/basic/package.json b/test/cli/cli-commons/tests/projects/basic/package.json similarity index 100% rename from test/e2e-cli/projects/basic/package.json rename to test/cli/cli-commons/tests/projects/basic/package.json diff --git a/test/e2e-cli/projects/scoped_basic/.npmignore b/test/cli/cli-commons/tests/projects/scoped_basic/.npmignore similarity index 100% rename from test/e2e-cli/projects/scoped_basic/.npmignore rename to test/cli/cli-commons/tests/projects/scoped_basic/.npmignore diff --git a/test/e2e-cli/projects/scoped_basic/README.md b/test/cli/cli-commons/tests/projects/scoped_basic/README.md similarity index 100% rename from test/e2e-cli/projects/scoped_basic/README.md rename to test/cli/cli-commons/tests/projects/scoped_basic/README.md diff --git a/test/e2e-cli/projects/scoped_basic/index.js b/test/cli/cli-commons/tests/projects/scoped_basic/index.js similarity index 100% rename from test/e2e-cli/projects/scoped_basic/index.js rename to test/cli/cli-commons/tests/projects/scoped_basic/index.js diff --git a/test/e2e-cli/projects/scoped_basic/package.json b/test/cli/cli-commons/tests/projects/scoped_basic/package.json similarity index 100% rename from test/e2e-cli/projects/scoped_basic/package.json rename to test/cli/cli-commons/tests/projects/scoped_basic/package.json diff --git a/test/cli/cli-commons/tsconfig.build.json b/test/cli/cli-commons/tsconfig.build.json new file mode 100644 index 000000000..79f1f81e0 --- /dev/null +++ b/test/cli/cli-commons/tsconfig.build.json @@ -0,0 +1,9 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "rootDir": "./src", + "outDir": "./build" + }, + "include": ["src/**/*"], + "exclude": ["src/**/*.test.ts"] +} diff --git a/test/cli/cli-commons/tsconfig.json b/test/cli/cli-commons/tsconfig.json new file mode 100644 index 000000000..3ebcbdddd --- /dev/null +++ b/test/cli/cli-commons/tsconfig.json @@ -0,0 +1,21 @@ +{ + "extends": "../../../tsconfig.reference.json", + "compilerOptions": { + "rootDir": "./src", + "outDir": "./build" + }, + "references": [ + { + "path": "../../../packages/core/core" + }, + { + "path": "../../../packages/verdaccio" + }, + { + "path": "../../../packages/config" + }, + { + "path": "../../../packages/tools/helpers" + } + ] +} diff --git a/test/cli/e2e-npm6/.babelrc b/test/cli/e2e-npm6/.babelrc new file mode 100644 index 000000000..851856e59 --- /dev/null +++ b/test/cli/e2e-npm6/.babelrc @@ -0,0 +1,3 @@ +{ + "extends": "../../../.babelrc" +} diff --git a/test/cli/e2e-npm6/.eslintrc b/test/cli/e2e-npm6/.eslintrc new file mode 100644 index 000000000..eb2ac4c85 --- /dev/null +++ b/test/cli/e2e-npm6/.eslintrc @@ -0,0 +1,7 @@ +{ + "rules": { + "no-console": 0, + "@typescript-eslint/no-var-requires": 0, + "@typescript-eslint/explicit-member-accessibility": 0 + } +} diff --git a/test/e2e-cli/CHANGELOG.md b/test/cli/e2e-npm6/CHANGELOG.md similarity index 100% rename from test/e2e-cli/CHANGELOG.md rename to test/cli/e2e-npm6/CHANGELOG.md diff --git a/test/e2e-cli/LICENSE b/test/cli/e2e-npm6/LICENSE similarity index 100% rename from test/e2e-cli/LICENSE rename to test/cli/e2e-npm6/LICENSE diff --git a/test/e2e-cli/README.md b/test/cli/e2e-npm6/README.md similarity index 100% rename from test/e2e-cli/README.md rename to test/cli/e2e-npm6/README.md diff --git a/test/e2e-cli/config/_bootstrap_verdaccio.yaml b/test/cli/e2e-npm6/config/_bootstrap_verdaccio.yaml similarity index 100% rename from test/e2e-cli/config/_bootstrap_verdaccio.yaml rename to test/cli/e2e-npm6/config/_bootstrap_verdaccio.yaml diff --git a/test/e2e-cli/config/default.yaml b/test/cli/e2e-npm6/config/default.yaml similarity index 100% rename from test/e2e-cli/config/default.yaml rename to test/cli/e2e-npm6/config/default.yaml diff --git a/test/cli/e2e-npm6/info.spec.ts b/test/cli/e2e-npm6/info.spec.ts new file mode 100644 index 000000000..13245890e --- /dev/null +++ b/test/cli/e2e-npm6/info.spec.ts @@ -0,0 +1,30 @@ +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/test/cli/e2e-npm6/jest.config.js b/test/cli/e2e-npm6/jest.config.js new file mode 100644 index 000000000..757434d39 --- /dev/null +++ b/test/cli/e2e-npm6/jest.config.js @@ -0,0 +1,14 @@ +const { defaults } = require('jest-config'); +const config = require('../../../jest/config'); + +module.exports = Object.assign({}, config, { + name: 'verdaccio-e2e-cli-jest', + // verbose: true, + // collectCoverage: false, + moduleFileExtensions: [...defaults.moduleFileExtensions, 'ts'], + // testEnvironment: './env_babel.js', + // globalSetup: './env_setup.js', + // globalTeardown: './env_teardown.js', + // testRegex: '(/test/e2e.*\\.spec)\\.ts', + testRegex: '(/test/*.*.spec)\\.ts', +}); diff --git a/test/cli/e2e-npm6/package.json b/test/cli/e2e-npm6/package.json new file mode 100644 index 000000000..94295fd58 --- /dev/null +++ b/test/cli/e2e-npm6/package.json @@ -0,0 +1,12 @@ +{ + "private": true, + "name": "@verdaccio/e2e-cli-npm6", + "version": "2.0.0-6-next.1", + "dependencies": { + "@verdaccio/test-cli-commons": "workspace:1.0.0", + "npm": "latest-6" + }, + "scripts": { + "test": "jest" + } +} diff --git a/test/e2e-cli/tsconfig.json b/test/cli/e2e-npm6/tsconfig.json similarity index 63% rename from test/e2e-cli/tsconfig.json rename to test/cli/e2e-npm6/tsconfig.json index 385a6f173..08e267c67 100644 --- a/test/e2e-cli/tsconfig.json +++ b/test/cli/e2e-npm6/tsconfig.json @@ -3,5 +3,10 @@ "compilerOptions": { "rootDir": "./src", "outDir": "./build" - } + }, + "references": [ + { + "path": "../cli-commons" + } + ] } diff --git a/test/cli/e2e-npm6/utils.ts b/test/cli/e2e-npm6/utils.ts new file mode 100644 index 000000000..12a867dd3 --- /dev/null +++ b/test/cli/e2e-npm6/utils.ts @@ -0,0 +1,12 @@ +import { join } from 'path'; + +import { exec } from '@verdaccio/test-cli-commons'; + +export function getCommand() { + return join(__dirname, './node_modules/.bin/npm'); +} + +export function npm(...args: string[]) { + console.log('-getCommand()', getCommand()); + return exec({}, getCommand(), args); +} diff --git a/test/e2e-cli/.babelrc b/test/e2e-cli/.babelrc deleted file mode 100644 index 633f93f42..000000000 --- a/test/e2e-cli/.babelrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "../../.babelrc" -} diff --git a/test/e2e-cli/env_babel.js b/test/e2e-cli/env_babel.js deleted file mode 100644 index 93ed7b81a..000000000 --- a/test/e2e-cli/env_babel.js +++ /dev/null @@ -1,4 +0,0 @@ -require('@babel/register')({ - extensions: ['.ts', '.js'], -}); -module.exports = require('./setup/test_environment'); diff --git a/test/e2e-cli/env_setup.js b/test/e2e-cli/env_setup.js deleted file mode 100644 index dc96b42dc..000000000 --- a/test/e2e-cli/env_setup.js +++ /dev/null @@ -1,4 +0,0 @@ -require('@babel/register')({ - extensions: ['.ts', '.js'], -}); -module.exports = require('./setup/setup'); diff --git a/test/e2e-cli/env_teardown.js b/test/e2e-cli/env_teardown.js deleted file mode 100644 index 07f353212..000000000 --- a/test/e2e-cli/env_teardown.js +++ /dev/null @@ -1,4 +0,0 @@ -require('@babel/register')({ - extensions: ['.ts', '.js'], -}); -module.exports = require('./setup/teardown'); diff --git a/test/e2e-cli/jest.config.e2e.cli.js b/test/e2e-cli/jest.config.e2e.cli.js deleted file mode 100644 index 083703fa4..000000000 --- a/test/e2e-cli/jest.config.e2e.cli.js +++ /dev/null @@ -1,14 +0,0 @@ -const { defaults } = require('jest-config'); -const config = require('../../jest/config'); - -module.exports = Object.assign({}, config, { - name: 'verdaccio-e2e-cli-jest', - verbose: true, - collectCoverage: false, - moduleFileExtensions: [...defaults.moduleFileExtensions, 'ts'], - testEnvironment: './env_babel.js', - globalSetup: './env_setup.js', - globalTeardown: './env_teardown.js', - // testRegex: '(/test/e2e.*\\.spec)\\.ts', - testRegex: '(/test_bk/*.*.spec)\\.ts', -}); diff --git a/test/e2e-cli/package.json b/test/e2e-cli/package.json deleted file mode 100644 index d91e92f3b..000000000 --- a/test/e2e-cli/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "private": true, - "name": "@verdaccio/e2e-cli", - "version": "2.0.0-6-next.1", - "dependencies": { - "debug": "4.3.3", - "npm": "7.24.2", - "pnpm": "6.27.1", - "request": "2.88.0", - "yarn": "1.22.17" - }, - "devDependencies": { - "get-port": "5.1.1", - "wait-on": "^6.0.0", - "fs-extra": "10.0.0", - "semver": "7.3.5" - }, - "scripts": { - "test": "jest --config jest.config.e2e.cli.js" - } -} diff --git a/test/e2e-cli/setup/setup.ts b/test/e2e-cli/setup/setup.ts deleted file mode 100644 index 561d8b850..000000000 --- a/test/e2e-cli/setup/setup.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { spawn } from 'child_process'; -import buildDebug from 'debug'; -import fs from 'fs'; -import { yellow } from 'kleur'; -import os from 'os'; -import path from 'path'; - -import * as __global from '../utils/global.js'; -import { pnpmGlobal } from '../utils/process'; -import { SETUP_VERDACCIO_PORT } from '../utils/utils'; - -// import { waitOnRegistry } from '../utils/registry'; - -const debug = buildDebug('verdaccio:e2e:setup'); - -module.exports = async () => { - const tempRoot = fs.mkdtempSync(path.join(fs.realpathSync(os.tmpdir()), 'verdaccio-cli-e2e-')); - debug('dirname folder %o', __dirname); - debug('temporary folder %o', tempRoot); - // @ts-ignore - __global.addItem('dir-root', tempRoot); - debug(yellow(`Add temp root folder: ${tempRoot}`)); - const destinationConfigFile = path.join(tempRoot, 'verdaccio.yaml'); - debug('destination config file %o', destinationConfigFile); - fs.copyFileSync( - path.join(__dirname, '../config/_bootstrap_verdaccio.yaml'), - destinationConfigFile - ); - // @ts-ignore - global.__namespace = __global; - debug(`current directory %o`, process.cwd()); - const verdaccioPath = path.normalize( - path.join(process.cwd(), '../../packages/verdaccio/debug/bootstrap.js') - ); - debug(process.env.DEBUG); - debug('verdaccio path %o', verdaccioPath); - const childProcess = spawn( - 'node', - [verdaccioPath, '-c', './verdaccio.yaml', '-l', SETUP_VERDACCIO_PORT], - // @ts-ignore - { - cwd: tempRoot, - env: { - ...process.env, - }, - stdio: 'ignore', - } - ); - // @ts-ignore - global.registryProcess = childProcess; - // await waitOnRegistry(SETUP_VERDACCIO_PORT); - // publish current build version on local registry - const rootFolder = path.normalize(path.join(process.cwd(), '../../')); - // install the local changes to verdaccio - // the published package will be installed from every suite - await pnpmGlobal( - rootFolder, - 'publish', - '--filter', - ' ./packages', - '--access', - 'public', - '--git-checks', - 'false', - '--registry', - `http://localhost:${SETUP_VERDACCIO_PORT}` - ); -}; diff --git a/test/e2e-cli/setup/teardown.ts b/test/e2e-cli/setup/teardown.ts deleted file mode 100644 index 11a4e41ef..000000000 --- a/test/e2e-cli/setup/teardown.ts +++ /dev/null @@ -1,9 +0,0 @@ -import buildDebug from 'debug'; - -const debug = buildDebug('verdaccio:e2e:teardown'); - -module.exports = async function () { - debug('e2e teardown kill server'); - // @ts-ignore - global.registryProcess.kill(); -}; diff --git a/test/e2e-cli/setup/test_environment.ts b/test/e2e-cli/setup/test_environment.ts deleted file mode 100644 index dbc5f9e01..000000000 --- a/test/e2e-cli/setup/test_environment.ts +++ /dev/null @@ -1,38 +0,0 @@ -import buildDebug from 'debug'; -import NodeEnvironment from 'jest-environment-node'; -import os from 'os'; -import path from 'path'; - -const fs = require('fs'); - -const __global = require('../utils/global'); - -const debug = buildDebug('verdaccio:e2e:env'); - -class E2ECliTestEnvironment extends NodeEnvironment { - constructor(config) { - super(config); - } - - public async setup() { - // create an unique suite location peer test to avoid conflicts - const tempRoot = fs.mkdtempSync( - path.join(fs.realpathSync(os.tmpdir()), 'verdaccio-suite-test-') - ); - debug('suite temporary folder %o', tempRoot); - __global.addItem('dir-suite-root', tempRoot); - // @ts-ignore - this.global.__namespace = __global; - debug(`current directory: ${process.cwd()}`); - } - - async teardown() { - // TODO: clean folder - } - - public runScript(script): any { - return super.runScript(script); - } -} - -export default E2ECliTestEnvironment; diff --git a/test/e2e-cli/utils/global.js b/test/e2e-cli/utils/global.js deleted file mode 100644 index 3e2e04d34..000000000 --- a/test/e2e-cli/utils/global.js +++ /dev/null @@ -1,18 +0,0 @@ -import buildDebug from 'debug'; - -const namespace = Object.create(null); - -const debug = buildDebug('verdaccio:e2e:global'); - -exports.addItem = function (name, value) { - namespace[name] = value; -}; - -exports.getItem = function (name) { - debug('get-item %o:%o', name, namespace); - if (!(name in namespace)) { - throw new Error('The item '.concat(name, ' does exist in the namespace')); - } - - return namespace[name]; -}; diff --git a/test/e2e-cli/utils/process.ts b/test/e2e-cli/utils/process.ts deleted file mode 100644 index 9760c4d4c..000000000 --- a/test/e2e-cli/utils/process.ts +++ /dev/null @@ -1,102 +0,0 @@ -import { spawn } from 'child_process'; -import { SpawnOptions } from 'child_process'; -import buildDebug from 'debug'; -import readline from 'readline'; - -const debug = buildDebug('verdaccio:e2e:process'); - -export type ExecOutput = { - stdout: string; - stderr: string; -}; - -export async function _exec(options: SpawnOptions, cmd, args): Promise { - debug('start _exec %o %o %o', options, cmd, args); - let stdout = ''; - let stderr; - const env = options.env; - debug(`Running \`${cmd} ${args.join(' ')}`); - debug(`CWD: %o`, options.cwd); - debug(`ENV: ${JSON.stringify(env)}`); - const spawnOptions = { - cwd: options.cwd, - stdio: options.stdio || 'pipe', - ...(env ? { env } : {}), - }; - - if (process.platform.startsWith('win')) { - args.unshift('/c', cmd); - cmd = 'cmd.exe'; - spawnOptions['stdio'] = 'pipe'; - } - - const childProcess = spawn(cmd, args, spawnOptions); - const rl = readline.createInterface({ input: childProcess.stdout }); - - rl.on('line', function (line) { - stdout += line; - }); - - const err = new Error(`Running "${cmd} ${args.join(' ')}" returned error code `); - return new Promise((resolve, reject) => { - childProcess.on('exit', (error) => { - if (!error) { - resolve({ stdout, stderr }); - } else { - err.message += `${error}...\n\nSTDOUT:\n${stdout}\n\nSTDERR:\n${stderr}\n`; - reject({ stdout, stderr: err }); - } - }); - }); -} - -// export function execAndWaitForOutputToMatch( -// cmd: string, -// args: string[], -// match: RegExp, -// spawnOptions: SpawnOptions = {} -// ): any { -// return _exec({ waitForMatch: match, ...spawnOptions, silence: true }, cmd, args); -// } - -export function pnpmGlobal(rootFolder, ...args) { - const pnpmCmd = require.resolve('pnpm'); - debug('pnpmCommand %o', pnpmCmd); - debug('run pnpm on %o', rootFolder); - return _exec( - { - cwd: rootFolder, - }, - process.execPath, - [pnpmCmd, ...args] - ); -} - -export function npm(...args): Promise { - return _exec({}, 'npm', args); -} - -export function yarn(...args): Promise { - return _exec({}, 'yarn', args); -} - -export function pnpm(...args): Promise { - return _exec({}, 'pnpm', args); -} - -export function pnpmWithCwd(cwd, ...args): Promise { - return _exec({ cwd }, 'pnpm', args); -} - -export function yarnWithCwd(cwd, ...args): Promise { - return _exec({ cwd }, 'yarn', args); -} - -export function nodeCwd(cwd, ...args): Promise { - return _exec({ cwd }, 'yarn', args); -} - -export function silentNpm(...args): Promise { - debug('run silent npm %o', args); - return _exec({ silent: true }, 'npm', args); -} diff --git a/test/e2e-cli/utils/registry.spec.ts b/test/e2e-cli/utils/registry.spec.ts deleted file mode 100644 index a4667447d..000000000 --- a/test/e2e-cli/utils/registry.spec.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { addNpmPrefix } from './registry'; - -describe('registry utils', function () { - test('prefix', () => { - expect([...addNpmPrefix('foo')]).toEqual(''); - }); -}); diff --git a/test/e2e-cli/utils/registry.ts b/test/e2e-cli/utils/registry.ts deleted file mode 100644 index b4732db7b..000000000 --- a/test/e2e-cli/utils/registry.ts +++ /dev/null @@ -1,149 +0,0 @@ -/* eslint-disable prefer-promise-reject-errors */ -import { ChildProcess, fork } from 'child_process'; -import buildDebug from 'debug'; -import fs from 'fs'; -import path from 'path'; -import waitOn from 'wait-on'; - -import { silentNpm } from './process'; - -const debug = buildDebug('verdaccio:e2e:registry-utils'); - -export function createInstallationFolder(tempRootFolder) { - const verdaccioInstall = path.join(tempRootFolder, 'verdaccio-root-install'); - fs.mkdirSync(verdaccioInstall); - return verdaccioInstall; -} - -export function addNpmPrefix(installFolder) { - return ['--prefix', installFolder]; -} - -export function addYarnPrefix(installFolder) { - // info regarding cwd flag - // https://github.com/yarnpkg/yarn/pull/4174 - return ['--cwd', installFolder]; -} - -export function addRegistry(port) { - return ['--registry', `http://localhost:${port}`]; -} - -export function installVerdaccio(verdaccioInstall) { - debug('installing verdaccio from internal registry'); - return silentNpm( - 'install', - ...addNpmPrefix(verdaccioInstall), - 'verdaccio', - ...addRegistry('6001'), - // lock file is not useful for this purpose - '--no-package-lock', - '-no-shrinkwrap', - // reduce external calls and potential test failures - '--no-audit' - ); -} - -export type Setup = { - child: ChildProcess; - install: string; -}; - -export async function initialSetup(port: string | number): Promise { - // temp folder created on test_environment.ts - // @ts-ignore - const tempRootFolder = global.__namespace.getItem('dir-suite-root'); - debug('initial setup on %o and port %o', tempRootFolder, port); - // create temporary installation folder - const verdaccioInstall = createInstallationFolder(tempRootFolder); - debug('install folder %o', verdaccioInstall); - // create a file path for the future the configuration file - const verdaccioConfigPathOnInstallLocation = path.join(tempRootFolder, 'verdaccio.yaml'); - debug('config file location %o', verdaccioConfigPathOnInstallLocation); - // install a global verdaccio - debug('install verdaccio start'); - await installVerdaccio(verdaccioInstall); - debug('install verdaccio finish'); - // copy the original config verdaccio file - fs.copyFileSync( - path.join(__dirname, '../../../packages/config/src/conf/default.yaml'), - verdaccioConfigPathOnInstallLocation - ); - // location of verdaccio binary installed in the previous step - const pathVerdaccioModule = require.resolve('verdaccio/bin/verdaccio', { - paths: [verdaccioInstall], - }); - debug('path verdaccio module %o', pathVerdaccioModule); - // spawn the registry - const processChild = await forkRegistry( - pathVerdaccioModule, - ['-c', verdaccioConfigPathOnInstallLocation, '-l', port], - { - cwd: verdaccioInstall, - silent: false, - }, - port - ); - - return { - child: processChild, - install: verdaccioInstall, - }; -} - -export function getVerdaccioPath() { - const verdaccioPath = path.normalize( - path.join(process.cwd(), '../../packages/verdaccio/debug/bootstrap.js') - ); - - return verdaccioPath; -} - -export function forkRegistry( - verdaccioPath: string, - args: string[], - childOptions, - port -): Promise { - debug('spawning registry for %o in port %o', verdaccioPath, port); - return new Promise((resolve, reject) => { - let _childOptions = { silent: true, ...childOptions }; - debug('options %o', _childOptions); - debug('fork path %o', verdaccioPath); - debug('args %o', args); - const childFork = fork(verdaccioPath, args, _childOptions); - - childFork.on('message', (msg) => { - if ('verdaccio_started' in msg) { - debug('spawning registry [started] in port %o', port); - resolve(childFork); - } - }); - - childFork.on('error', (err) => { - debug('error %o', err); - reject([err]); - }); - childFork.on('disconnect', (err) => { - debug('disconnect %o', err); - reject([err]); - }); - childFork.on('exit', (err) => { - debug('exit %o', err); - reject([err]); - }); - }); -} - -export const waitOnRegistry = async (port, timeout = 5000) => { - debug('waiting on registry ...'); - await waitOn({ - timeout, - resources: [`http://localhost:${port}/-/ping`], - validateStatus: function (status) { - debug('wating status %s', status); - return status >= 200 && status < 300; // default if not provided - }, - }); - debug(`registry detected on por ${port}`); -}; diff --git a/test/e2e-cli/utils/utils.ts b/test/e2e-cli/utils/utils.ts deleted file mode 100644 index 966ab5fd7..000000000 --- a/test/e2e-cli/utils/utils.ts +++ /dev/null @@ -1,35 +0,0 @@ -import fs from 'fs-extra'; -import os from 'os'; -import path from 'path'; - -export function createProject(projectName: string) { - // @ts-ignore - const tempRootFolder = global.__namespace.getItem('dir-suite-root'); - const verdaccioInstall = path.join(tempRootFolder, projectName); - fs.mkdirSync(verdaccioInstall); - - return verdaccioInstall; -} -export function copyConfigFile(rootFolder, configTemplate): string { - const configPath = path.join(rootFolder, 'verdaccio.yaml'); - copyTo(path.join(__dirname, configTemplate), configPath); - - return configPath; -} - -/** - * @deprecated use @verdaccio/core:createTempFolder async function instead - */ -export function createTempFolder(prefix: string) { - return fs.mkdtempSync(path.join(fs.realpathSync(os.tmpdir()), prefix)); -} - -export function copyTo(from, to) { - fs.copyFileSync(from, to); -} - -export function cleanUpTemp(tmpFolder) { - fs.rmdirSync(tmpFolder, { recursive: true }); -} - -export const SETUP_VERDACCIO_PORT = `6001`; diff --git a/test/e2e-cli/utils/web.ts b/test/e2e-cli/utils/web.ts deleted file mode 100644 index 272e0cc46..000000000 --- a/test/e2e-cli/utils/web.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { IncomingMessage } from 'http'; -import request from 'request'; - -export function callRegistry(url: string): Promise { - return new Promise((resolve, reject) => { - let options = { - url: url, - headers: { Accept: 'application/json' }, - }; - // @ts-ignore - request(options, (error: any, response: IncomingMessage, body: string) => { - if (error) { - reject(error); - // @ts-ignore - } else if (response.statusCode >= 400) { - reject(new Error(`Requesting "${url}" returned status code ${response.statusCode}.`)); - } else { - resolve(body); - } - }); - }); -}