e2e cli npm 6 (#3282)

* chore: add config utility

* improve verdaccio bin location

* add new npm cli e2e tests

* add tests

* rename files
This commit is contained in:
Juan Picado 2022-08-02 22:45:16 +02:00 committed by GitHub
parent a123775f20
commit 1755840cd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
60 changed files with 602 additions and 749 deletions

View File

@ -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'

View File

@ -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",

View File

@ -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);
}

View File

@ -7,3 +7,4 @@ export * from './uplinks';
export * from './security';
export * from './user';
export { default as ConfigBuilder } from './builder';
export { getDefaultConfig } from './conf';

View File

@ -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');

View File

@ -1,3 +1,3 @@
#!/usr/bin/env node
require('@verdaccio/cli');
require('../build/start');

View File

@ -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);

View File

@ -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'}

View File

@ -10,5 +10,5 @@ packages:
- packages/plugins/memory
- packages/plugins/local-storage
- website
- test/e2e-*
- test/cli/*
- test/helpers

View File

@ -0,0 +1,3 @@
{
"extends": "../../../.babelrc"
}

View File

@ -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"
}
}

View File

@ -0,0 +1,4 @@
export { getDefaultConfig } from '@verdaccio/config';
export { initialSetup } from './registry';
export { addNpmPrefix, addYarnPrefix, addRegistry } from './utils';
export { exec, ExecOutput } from './process';

View File

@ -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<ExecOutput> {
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<ExecOutput> {
debug('run silent npm %o', args);
// @ts-ignore
return exec({ silent: true }, 'npm', args);
}

View File

@ -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<Setup> {
const { configPath, tempFolder } = await Registry.fromConfigToPath(getDefaultConfig());
debug(`configPath %o`, configPath);
debug(`tempFolder %o`, tempFolder);
const registry = new Registry(configPath);
return { registry, tempFolder };
}

View File

@ -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];
}

View File

@ -0,0 +1,5 @@
import got from 'got';
export function callRegistry(url: string): Promise<string> {
return got.get(url, { headers: { Accept: 'application/json' } }).json();
}

View File

@ -0,0 +1,9 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./build"
},
"include": ["src/**/*"],
"exclude": ["src/**/*.test.ts"]
}

View File

@ -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"
}
]
}

View File

@ -0,0 +1,3 @@
{
"extends": "../../../.babelrc"
}

View File

@ -0,0 +1,7 @@
{
"rules": {
"no-console": 0,
"@typescript-eslint/no-var-requires": 0,
"@typescript-eslint/explicit-member-accessibility": 0
}
}

View File

@ -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();
});
});

View File

@ -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',
});

View File

@ -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"
}
}

View File

@ -3,5 +3,10 @@
"compilerOptions": {
"rootDir": "./src",
"outDir": "./build"
}
},
"references": [
{
"path": "../cli-commons"
}
]
}

View File

@ -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);
}

View File

@ -1,3 +0,0 @@
{
"extends": "../../.babelrc"
}

View File

@ -1,4 +0,0 @@
require('@babel/register')({
extensions: ['.ts', '.js'],
});
module.exports = require('./setup/test_environment');

View File

@ -1,4 +0,0 @@
require('@babel/register')({
extensions: ['.ts', '.js'],
});
module.exports = require('./setup/setup');

View File

@ -1,4 +0,0 @@
require('@babel/register')({
extensions: ['.ts', '.js'],
});
module.exports = require('./setup/teardown');

View File

@ -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',
});

View File

@ -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"
}
}

View File

@ -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}`
);
};

View File

@ -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();
};

View File

@ -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;

View File

@ -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];
};

View File

@ -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<ExecOutput> {
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<ExecOutput> {
return _exec({}, 'npm', args);
}
export function yarn(...args): Promise<ExecOutput> {
return _exec({}, 'yarn', args);
}
export function pnpm(...args): Promise<ExecOutput> {
return _exec({}, 'pnpm', args);
}
export function pnpmWithCwd(cwd, ...args): Promise<ExecOutput> {
return _exec({ cwd }, 'pnpm', args);
}
export function yarnWithCwd(cwd, ...args): Promise<ExecOutput> {
return _exec({ cwd }, 'yarn', args);
}
export function nodeCwd(cwd, ...args): Promise<ExecOutput> {
return _exec({ cwd }, 'yarn', args);
}
export function silentNpm(...args): Promise<ExecOutput> {
debug('run silent npm %o', args);
return _exec({ silent: true }, 'npm', args);
}

View File

@ -1,7 +0,0 @@
import { addNpmPrefix } from './registry';
describe('registry utils', function () {
test('prefix', () => {
expect([...addNpmPrefix('foo')]).toEqual('');
});
});

View File

@ -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<Setup> {
// 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<ChildProcess> {
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}`);
};

View File

@ -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`;

View File

@ -1,22 +0,0 @@
import { IncomingMessage } from 'http';
import request from 'request';
export function callRegistry(url: string): Promise<string> {
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);
}
});
});
}