mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-03-04 02:02:39 -05:00
Merge pull request #1624 from verdaccio/e2e-pkg-poc
test: E2E with Verdaccio for our own CLI
This commit is contained in:
commit
5189254fbb
33 changed files with 683 additions and 7 deletions
|
@ -110,6 +110,14 @@ jobs:
|
|||
- run:
|
||||
name: Test End-to-End
|
||||
command: yarn run test:e2e
|
||||
test_e2e_cli:
|
||||
<<: *defaults
|
||||
executor: node_latest
|
||||
steps:
|
||||
- restore_repo
|
||||
- run:
|
||||
name: Test End-to-End ClI
|
||||
command: yarn run test:e2e:cli
|
||||
|
||||
coverage:
|
||||
<<: *defaults
|
||||
|
@ -149,7 +157,15 @@ workflows:
|
|||
- test_node_lts_10
|
||||
- test_node_lts_12
|
||||
<<: *ignore_non_dev_branches
|
||||
- test_e2e_cli:
|
||||
requires:
|
||||
- prepare
|
||||
- test_node_latest
|
||||
- test_node_lts_10
|
||||
- test_node_lts_12
|
||||
<<: *ignore_non_dev_branches
|
||||
- coverage:
|
||||
requires:
|
||||
- test_e2e
|
||||
- test_e2e_cli
|
||||
<<: *ignore_non_dev_branches
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
"@verdaccio"
|
||||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/no-var-requires": ["warn"],
|
||||
"@typescript-eslint/no-var-requires": 0,
|
||||
"@typescript-eslint/ban-ts-ignore": 0,
|
||||
"@typescript-eslint/no-inferrable-types": ["warn"],
|
||||
"@typescript-eslint/no-empty-function": ["warn"],
|
||||
"@typescript-eslint/no-inferrable-types": 0,
|
||||
"@typescript-eslint/no-empty-function": 0,
|
||||
"@typescript-eslint/no-this-alias": ["warn"],
|
||||
"@typescript-eslint/no-use-before-define": 0,
|
||||
"@typescript-eslint/array-type": ["warn"],
|
||||
|
|
|
@ -78,6 +78,7 @@
|
|||
"cross-env": "6.0.3",
|
||||
"detect-secrets": "1.0.5",
|
||||
"eslint": "5.16.0",
|
||||
"fs-extra": "8.1.0",
|
||||
"get-stdin": "7.0.0",
|
||||
"husky": "2.7.0",
|
||||
"in-publish": "2.0.0",
|
||||
|
@ -92,6 +93,7 @@
|
|||
"standard-version": "7.0.0",
|
||||
"supertest": "4.0.2",
|
||||
"typescript": "3.7.1-rc",
|
||||
"verdaccio": "latest",
|
||||
"verdaccio-auth-memory": "8.3.0",
|
||||
"verdaccio-memory": "8.2.0"
|
||||
},
|
||||
|
@ -116,8 +118,9 @@
|
|||
"test:clean": "npx jest --clearCache",
|
||||
"test:unit": "cross-env NODE_ENV=test BABEL_ENV=test TZ=UTC FORCE_COLOR=1 jest --config ./jest.config.js --maxWorkers 2 --passWithNoTests",
|
||||
"test:functional": "cross-env NODE_ENV=test jest --config ./test/jest.config.functional.js --testPathPattern ./test/functional/index* --passWithNoTests",
|
||||
"test:e2e:cli": "cross-env NODE_ENV=test jest --config ./test/e2e-cli/jest.config.e2e.cli.js --passWithNoTests",
|
||||
"test:e2e": "cross-env BABEL_ENV=test jest --config ./test/jest.config.e2e.js",
|
||||
"test:all": "npm run test && npm run test:functional && npm run test:e2e",
|
||||
"test:all": "npm run test && npm run test:functional && npm run test:e2e & npm run test:e2e:pkg",
|
||||
"pre:ci": "npm run lint",
|
||||
"coverage:publish": "codecov",
|
||||
"lint": "npm run type-check && npm run lint:ts && npm run lint:lockfile",
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
}
|
||||
],
|
||||
"no-useless-escape": 0,
|
||||
"@typescript-eslint/explicit-function-return-type": 0
|
||||
"@typescript-eslint/explicit-function-return-type": 0,
|
||||
"@typescript-eslint/no-empty-function": 0
|
||||
}
|
||||
}
|
||||
|
|
6
test/e2e-cli/.eslintrc
Normal file
6
test/e2e-cli/.eslintrc
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"rules": {
|
||||
"@typescript-eslint/no-var-requires": 0,
|
||||
"@typescript-eslint/explicit-member-accessibility": 0
|
||||
}
|
||||
}
|
37
test/e2e-cli/config/_bootstrap_verdaccio.yaml
Normal file
37
test/e2e-cli/config/_bootstrap_verdaccio.yaml
Normal file
|
@ -0,0 +1,37 @@
|
|||
storage: ./storage
|
||||
|
||||
#store:
|
||||
# memory:
|
||||
# limit: 1000
|
||||
|
||||
auth:
|
||||
htpasswd:
|
||||
file: ./htpasswd
|
||||
max_users: -1
|
||||
|
||||
web:
|
||||
enable: true
|
||||
title: verdaccio-e2e-pkg
|
||||
|
||||
uplinks:
|
||||
npmjs:
|
||||
url: https://registry.npmjs.org/
|
||||
|
||||
logs:
|
||||
- { type: stdout, format: pretty, level: warn }
|
||||
|
||||
packages:
|
||||
'@*/*':
|
||||
access: $all
|
||||
publish: $anonymous
|
||||
unpublish: $authenticated
|
||||
proxy: npmjs
|
||||
'verdaccio':
|
||||
access: $all
|
||||
publish: $anonymous
|
||||
'**':
|
||||
access: $all
|
||||
publish: $anonymous
|
||||
unpublish: $authenticated
|
||||
proxy: npmjs
|
||||
_debug: true
|
35
test/e2e-cli/config/default.yaml
Normal file
35
test/e2e-cli/config/default.yaml
Normal file
|
@ -0,0 +1,35 @@
|
|||
storage: ./storage
|
||||
|
||||
#store:
|
||||
# memory:
|
||||
# limit: 1000
|
||||
|
||||
auth:
|
||||
htpasswd:
|
||||
file: ./htpasswd
|
||||
max_users: -1
|
||||
|
||||
web:
|
||||
enable: true
|
||||
title: verdaccio-default
|
||||
|
||||
uplinks:
|
||||
local:
|
||||
url: http://localhost:4873
|
||||
|
||||
logs:
|
||||
- { type: stdout, format: pretty, level: warn }
|
||||
|
||||
packages:
|
||||
'@*/*':
|
||||
access: $all
|
||||
publish: $anonymous
|
||||
unpublish: $authenticated
|
||||
proxy: local
|
||||
'**':
|
||||
access: $all
|
||||
publish: $all
|
||||
unpublish: $authenticated
|
||||
proxy: local
|
||||
|
||||
_debug: true
|
4
test/e2e-cli/env_babel.js
Normal file
4
test/e2e-cli/env_babel.js
Normal file
|
@ -0,0 +1,4 @@
|
|||
require('@babel/register')({
|
||||
extensions: [".ts", ".js"]
|
||||
});
|
||||
module.exports = require('./setup/test_environment');
|
4
test/e2e-cli/env_setup.js
Normal file
4
test/e2e-cli/env_setup.js
Normal file
|
@ -0,0 +1,4 @@
|
|||
require('@babel/register')({
|
||||
extensions: [".ts", ".js"]
|
||||
});
|
||||
module.exports = require('./setup/setup');
|
4
test/e2e-cli/env_teardown.js
Normal file
4
test/e2e-cli/env_teardown.js
Normal file
|
@ -0,0 +1,4 @@
|
|||
require('@babel/register')({
|
||||
extensions: [".ts", ".js"]
|
||||
});
|
||||
module.exports = require('./setup/teardown');
|
12
test/e2e-cli/jest.config.e2e.cli.js
Normal file
12
test/e2e-cli/jest.config.e2e.cli.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
const { defaults } = require('jest-config');
|
||||
|
||||
module.exports = {
|
||||
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'
|
||||
};
|
0
test/e2e-cli/projects/basic/.npmignore
Normal file
0
test/e2e-cli/projects/basic/.npmignore
Normal file
3
test/e2e-cli/projects/basic/README.md
Normal file
3
test/e2e-cli/projects/basic/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Simple project
|
||||
|
||||
This is a normal readme
|
6
test/e2e-cli/projects/basic/index.js
Normal file
6
test/e2e-cli/projects/basic/index.js
Normal file
|
@ -0,0 +1,6 @@
|
|||
module.exports = function() {
|
||||
const message = "this is a basic project";
|
||||
console.log(message);
|
||||
|
||||
return message;
|
||||
};
|
18
test/e2e-cli/projects/basic/package.json
Normal file
18
test/e2e-cli/projects/basic/package.json
Normal file
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"name": "basic-verdaccio",
|
||||
"version": "1.0.0",
|
||||
"description": "this is a basic project",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [
|
||||
"verdaccio",
|
||||
"sample"
|
||||
],
|
||||
"dependencies": {
|
||||
"verdaccio": "latest"
|
||||
},
|
||||
"author": "Juan Picado <juanpicado19@gmail.com>",
|
||||
"license": "MIT"
|
||||
}
|
0
test/e2e-cli/projects/scoped_basic/.npmignore
Normal file
0
test/e2e-cli/projects/scoped_basic/.npmignore
Normal file
3
test/e2e-cli/projects/scoped_basic/README.md
Normal file
3
test/e2e-cli/projects/scoped_basic/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Simple project
|
||||
|
||||
This is a normal readme
|
6
test/e2e-cli/projects/scoped_basic/index.js
Normal file
6
test/e2e-cli/projects/scoped_basic/index.js
Normal file
|
@ -0,0 +1,6 @@
|
|||
module.exports = function() {
|
||||
const message = "this is a scoped basic project";
|
||||
console.log(message);
|
||||
|
||||
return message;
|
||||
};
|
15
test/e2e-cli/projects/scoped_basic/package.json
Normal file
15
test/e2e-cli/projects/scoped_basic/package.json
Normal file
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"name": "@e2e-verdaccio/basic",
|
||||
"version": "1.0.0",
|
||||
"description": "this is a scoped basic project",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": ["verdaccio", "sample", "scoped"],
|
||||
"dependencies": {
|
||||
"verdaccio": "latest"
|
||||
},
|
||||
"author": "Juan Picado <juanpicado19@gmail.com>",
|
||||
"license": "MIT"
|
||||
}
|
30
test/e2e-cli/setup/setup.ts
Normal file
30
test/e2e-cli/setup/setup.ts
Normal file
|
@ -0,0 +1,30 @@
|
|||
import fs from "fs";
|
||||
import path from "path";
|
||||
import os from "os";
|
||||
import {yellow} from "kleur";
|
||||
import {spawn} from "child_process";
|
||||
import { npm } from '../utils/process';
|
||||
import * as __global from '../utils/global.js';
|
||||
|
||||
module.exports = async () => {
|
||||
const tempRoot = fs.mkdtempSync(path.join(fs.realpathSync(os.tmpdir()), 'verdaccio-cli-e2e-'));
|
||||
__global.addItem('dir-root', tempRoot);
|
||||
console.log(yellow(`Add temp root folder: ${tempRoot}`));
|
||||
fs.copyFileSync(
|
||||
path.join(__dirname, '../config/_bootstrap_verdaccio.yaml'),
|
||||
path.join(tempRoot, 'verdaccio.yaml'),
|
||||
);
|
||||
// @ts-ignore
|
||||
global.__namespace = __global;
|
||||
console.log(`current directory: ${process.cwd()}`);
|
||||
// @ts-ignore
|
||||
global.registryProcess = spawn(
|
||||
'node',
|
||||
[require.resolve('verdaccio/bin/verdaccio'), '-c', './verdaccio.yaml'],
|
||||
// @ts-ignore
|
||||
{ cwd: tempRoot, silence: true },
|
||||
);
|
||||
|
||||
// publish current build version on local registry
|
||||
await npm('publish', '--registry' ,'http://localhost:4873');
|
||||
}
|
4
test/e2e-cli/setup/teardown.ts
Normal file
4
test/e2e-cli/setup/teardown.ts
Normal file
|
@ -0,0 +1,4 @@
|
|||
module.exports = async function() {
|
||||
// @ts-ignore
|
||||
global.registryProcess.kill();
|
||||
};
|
28
test/e2e-cli/setup/test_environment.ts
Normal file
28
test/e2e-cli/setup/test_environment.ts
Normal file
|
@ -0,0 +1,28 @@
|
|||
const fs = require('fs');
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
import NodeEnvironment from 'jest-environment-node';
|
||||
const __global = require('../utils/global');
|
||||
// import { npm } from '../utils/process';
|
||||
|
||||
|
||||
class E2ECliTestEnvironment extends NodeEnvironment {
|
||||
constructor(config) {
|
||||
super(config)
|
||||
}
|
||||
|
||||
async setup() {
|
||||
const tempRoot = fs.mkdtempSync(path.join(fs.realpathSync(os.tmpdir()), 'verdaccio-suite-test-'));
|
||||
__global.addItem('dir-root', tempRoot);
|
||||
this.global.__namespace = __global;
|
||||
console.log(`current directory: ${process.cwd()}`);
|
||||
}
|
||||
|
||||
async teardown() {}
|
||||
|
||||
runScript(script) {
|
||||
return super.runScript(script);
|
||||
}
|
||||
}
|
||||
|
||||
export default E2ECliTestEnvironment;
|
5
test/e2e-cli/test/__partials/npm_commands.ts
Normal file
5
test/e2e-cli/test/__partials/npm_commands.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
import { silentNpm } from '../../utils/process';
|
||||
|
||||
export function installVerdaccio(verdaccioInstall) {
|
||||
return silentNpm('install', '--prefix', verdaccioInstall, 'verdaccio', '--registry' ,'http://localhost:4873', '--no-package-lock');
|
||||
}
|
29
test/e2e-cli/test/core/info.spec.ts
Normal file
29
test/e2e-cli/test/core/info.spec.ts
Normal file
|
@ -0,0 +1,29 @@
|
|||
import path from 'path';
|
||||
import {runVerdaccio} from '../../utils/process';
|
||||
import {installVerdaccio} from "../__partials/npm_commands";
|
||||
|
||||
describe('verdaccio info', ()=> {
|
||||
jest.setTimeout(90000);
|
||||
// @ts-ignore
|
||||
const tempRootFolder = global.__namespace.getItem('dir-root');
|
||||
const verdaccioInstall = path.join(tempRootFolder, 'verdaccio-root-info');
|
||||
let registryProcess;
|
||||
|
||||
beforeAll(async () => {
|
||||
await installVerdaccio(verdaccioInstall);
|
||||
});
|
||||
|
||||
|
||||
test('should run verdaccio info command', async () => {
|
||||
const pathVerdaccioModule = require.resolve('verdaccio/bin/verdaccio', {
|
||||
paths: [verdaccioInstall]
|
||||
});
|
||||
const hasMatch = await runVerdaccio(pathVerdaccioModule, verdaccioInstall, ['--info'], /Environment/);
|
||||
|
||||
expect(hasMatch.ok).toBeTruthy();
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
registryProcess.kill();
|
||||
});
|
||||
});
|
41
test/e2e-cli/test/core/listen.spec.ts
Normal file
41
test/e2e-cli/test/core/listen.spec.ts
Normal file
|
@ -0,0 +1,41 @@
|
|||
import path from 'path';
|
||||
import fs from "fs";
|
||||
import {installVerdaccio} from "../__partials/npm_commands";
|
||||
import {spawnRegistry} from "../../utils/registry";
|
||||
import {callRegistry} from "../../utils/web";
|
||||
|
||||
describe('npm install', ()=> {
|
||||
jest.setTimeout(90000);
|
||||
const port = '9012';
|
||||
|
||||
// @ts-ignore
|
||||
const tempRootFolder = global.__namespace.getItem('dir-root');
|
||||
const verdaccioInstall = path.join(tempRootFolder, 'verdaccio-root-install');
|
||||
let registryProcess;
|
||||
const configPath = path.join(tempRootFolder, 'verdaccio.yaml');
|
||||
|
||||
beforeAll(async () => {
|
||||
await installVerdaccio(verdaccioInstall);
|
||||
fs.copyFileSync(path.join(__dirname, '../../config/default.yaml'), configPath);
|
||||
});
|
||||
|
||||
test('should match the listing port and load metadata', async () => {
|
||||
const pathVerdaccioModule = require.resolve('verdaccio/bin/verdaccio', {
|
||||
paths: [verdaccioInstall]
|
||||
});
|
||||
|
||||
registryProcess = await spawnRegistry(pathVerdaccioModule,
|
||||
['-c', configPath, '-l', port],
|
||||
{ cwd: verdaccioInstall, silent: true }
|
||||
);
|
||||
|
||||
const body = await callRegistry(`http://localhost:${port}/verdaccio`);
|
||||
const parsedBody = JSON.parse(body);
|
||||
|
||||
expect(parsedBody.name).toEqual('verdaccio');
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
registryProcess.kill();
|
||||
});
|
||||
});
|
54
test/e2e-cli/test/install/install.spec.ts
Normal file
54
test/e2e-cli/test/install/install.spec.ts
Normal file
|
@ -0,0 +1,54 @@
|
|||
import path from 'path';
|
||||
import fs from "fs";
|
||||
import * as __global from "../../utils/global";
|
||||
import {spawnRegistry} from "../../utils/registry";
|
||||
import {execAndWaitForOutputToMatch} from '../../utils/process';
|
||||
import {installVerdaccio} from "../__partials/npm_commands";
|
||||
import {expectFileToExist} from "../../utils/expect";
|
||||
|
||||
describe('npm install', ()=> {
|
||||
jest.setTimeout(90000);
|
||||
const port = '9011';
|
||||
|
||||
// @ts-ignore
|
||||
const tempRootFolder = global.__namespace.getItem('dir-root');
|
||||
const verdaccioInstall = path.join(tempRootFolder, 'verdaccio-root-install');
|
||||
let registryProcess;
|
||||
|
||||
beforeAll(async () => {
|
||||
await installVerdaccio(verdaccioInstall);
|
||||
|
||||
const configPath = path.join(tempRootFolder, 'verdaccio.yaml');
|
||||
fs.copyFileSync(path.join(__dirname, '../../config/default.yaml'), configPath);
|
||||
// @ts-ignore
|
||||
global.__namespace = __global;
|
||||
const pathVerdaccioModule = require.resolve('verdaccio/bin/verdaccio', {
|
||||
paths: [verdaccioInstall]
|
||||
});
|
||||
registryProcess = await spawnRegistry(pathVerdaccioModule,
|
||||
['-c', configPath, '-l', port],
|
||||
{ cwd: verdaccioInstall, silent: true }
|
||||
);
|
||||
});
|
||||
|
||||
test('should match on npm info verdaccio', async () => {
|
||||
// FIXME: not the best match, looking for a better way to match the terminal output
|
||||
const output = await execAndWaitForOutputToMatch('npm', ['info', 'verdaccio', '--registry'], /A lightweight private npm proxy registry/);
|
||||
|
||||
expect(output.ok).toBeTruthy();
|
||||
});
|
||||
|
||||
test('should install jquery', async () => {
|
||||
const testCwd = path.join(tempRootFolder, '_jquery_');
|
||||
await execAndWaitForOutputToMatch('npm', ['install', '--prefix', testCwd, 'jquery', '--registry' ,`http://localhost:${port}`], /''/, {
|
||||
cwd: verdaccioInstall
|
||||
});
|
||||
|
||||
const exist = await expectFileToExist(path.join(testCwd, 'node_modules', 'jquery', 'package.json'));
|
||||
expect(exist).toBeTruthy();
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
registryProcess.kill();
|
||||
});
|
||||
});
|
13
test/e2e-cli/utils/expect.ts
Normal file
13
test/e2e-cli/utils/expect.ts
Normal file
|
@ -0,0 +1,13 @@
|
|||
import * as fs from 'fs-extra';
|
||||
|
||||
export function expectFileToExist(fileName: string) {
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.exists(fileName, (exist) => {
|
||||
if (exist) {
|
||||
resolve(exist);
|
||||
} else {
|
||||
reject(new Error(`File ${fileName} was expected to exist but not found...`));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
14
test/e2e-cli/utils/global.js
Normal file
14
test/e2e-cli/utils/global.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
const namespace = Object.create(null);
|
||||
|
||||
exports.addItem = function(name, value) {
|
||||
namespace[name] = value;
|
||||
}
|
||||
|
||||
exports.getItem = function(name) {
|
||||
console.log("get-item", name, namespace);
|
||||
if (!(name in namespace)) {
|
||||
throw new Error("The item ".concat(name, " does exist in the namespace"));
|
||||
}
|
||||
|
||||
return namespace[name];
|
||||
}
|
97
test/e2e-cli/utils/process.ts
Normal file
97
test/e2e-cli/utils/process.ts
Normal file
|
@ -0,0 +1,97 @@
|
|||
import * as child_process from 'child_process';
|
||||
import {SpawnOptions} from "child_process";
|
||||
|
||||
export async function _exec(options, cmd, args) {
|
||||
let stdout = '';
|
||||
let stderr = '';
|
||||
const flags = [];
|
||||
const cwd = process.cwd();
|
||||
const env = options.env;
|
||||
console.log(`Running \`${cmd} ${args.map(x => `"${x}"`).join(' ')}\`${flags}...`);
|
||||
console.log(`CWD: ${cwd}`);
|
||||
console.log(`ENV: ${JSON.stringify(env)}`);
|
||||
const spawnOptions = {
|
||||
cwd,
|
||||
...env ? { env } : {},
|
||||
};
|
||||
|
||||
if (process.platform.startsWith('win')) {
|
||||
args.unshift('/c', cmd);
|
||||
cmd = 'cmd.exe';
|
||||
spawnOptions['stdio'] = 'pipe';
|
||||
}
|
||||
|
||||
|
||||
const childProcess = child_process.spawn(cmd, args, spawnOptions);
|
||||
childProcess.stdout.on('data', (data) => {
|
||||
stdout += data.toString('utf-8');
|
||||
if (options.silent) {
|
||||
return;
|
||||
}
|
||||
|
||||
data.toString('utf-8')
|
||||
.split(/[\n\r]+/)
|
||||
.filter(line => line !== '')
|
||||
.forEach(line => console.log(' ' + line));
|
||||
});
|
||||
|
||||
childProcess.stderr.on('data', (data) => {
|
||||
stderr += data.toString('utf-8');
|
||||
if (options.silent) {
|
||||
return;
|
||||
}
|
||||
|
||||
data.toString('utf-8')
|
||||
.split(/[\n\r]+/)
|
||||
.filter(line => line !== '')
|
||||
.forEach(line => console.error((' ' + 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(err);
|
||||
}
|
||||
});
|
||||
|
||||
if (options.waitForMatch) {
|
||||
const match = options.waitForMatch;
|
||||
childProcess.stdout.on('data', (data) => {
|
||||
// console.log("-->data==>", data.toString(), data.toString().match(match));
|
||||
if (data.toString().match(match)) {
|
||||
resolve({ok: true, stdout, stderr });
|
||||
}
|
||||
});
|
||||
childProcess.stderr.on('data', (data) => {
|
||||
if (data.toString().match(match)) {
|
||||
resolve({ stdout, stderr });
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function execAndWaitForOutputToMatch(
|
||||
cmd: string,
|
||||
args: string[],
|
||||
match: RegExp,
|
||||
spawnOptions: SpawnOptions = {}): any {
|
||||
return _exec({ waitForMatch: match, ...spawnOptions, silence: true }, cmd, args);
|
||||
}
|
||||
|
||||
|
||||
export function npm(...args) {
|
||||
return _exec({}, 'npm', args);
|
||||
}
|
||||
|
||||
export function runVerdaccio(cmd, installation, args, match: RegExp): any {
|
||||
return _exec({ cwd: installation, silent: true, waitForMatch: match }, cmd, args);
|
||||
}
|
||||
|
||||
export function silentNpm(...args) {
|
||||
return _exec({silent: true}, 'npm', args);
|
||||
}
|
26
test/e2e-cli/utils/registry.ts
Normal file
26
test/e2e-cli/utils/registry.ts
Normal file
|
@ -0,0 +1,26 @@
|
|||
import {fork} from "child_process";
|
||||
|
||||
export function prepareEnvironment(rootFolder: string, folderName: string) {
|
||||
|
||||
}
|
||||
|
||||
export function spawnRegistry(
|
||||
verdaccioPath: string,
|
||||
args: string[],
|
||||
childOptions) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let _childOptions = {silent: true, ...childOptions};
|
||||
|
||||
const childFork = fork(verdaccioPath, args, _childOptions);
|
||||
|
||||
childFork.on('message', (msg) => {
|
||||
if ('verdaccio_started' in msg) {
|
||||
resolve(childFork);
|
||||
}
|
||||
});
|
||||
|
||||
childFork.on('error', (err) => reject([err]));
|
||||
childFork.on('disconnect', (err) => reject([err]));
|
||||
childFork.on('exit', (err) => reject([err]));
|
||||
});
|
||||
}
|
9
test/e2e-cli/utils/utils.ts
Normal file
9
test/e2e-cli/utils/utils.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
import path from "path";
|
||||
import fs from "fs";
|
||||
|
||||
export function copyConfigFile(rootFolder, configTemplate): string {
|
||||
const configPath = path.join(rootFolder, 'verdaccio.yaml');
|
||||
fs.copyFileSync(path.join(__dirname, configTemplate), configPath);
|
||||
|
||||
return configPath;
|
||||
}
|
23
test/e2e-cli/utils/web.ts
Normal file
23
test/e2e-cli/utils/web.ts
Normal file
|
@ -0,0 +1,23 @@
|
|||
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);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
134
yarn.lock
134
yarn.lock
|
@ -1705,13 +1705,26 @@
|
|||
dependencies:
|
||||
lockfile "1.0.4"
|
||||
|
||||
"@verdaccio/file-locking@^8.4.2":
|
||||
"@verdaccio/file-locking@^8.2.0", "@verdaccio/file-locking@^8.4.2":
|
||||
version "8.4.2"
|
||||
resolved "https://registry.verdaccio.org/@verdaccio%2ffile-locking/-/file-locking-8.4.2.tgz#007b15a4f131d9e6bd482c8e631e03b4df9fe647"
|
||||
integrity sha512-XsniyZl2YzbDGf7wsemM97RG/sqtX4/3dfy2quwULKd5WnNtSbX/ewm8EJyL8Ajsfx3y3xtzX9+jj6+7TBGE8g==
|
||||
dependencies:
|
||||
lockfile "1.0.4"
|
||||
|
||||
"@verdaccio/local-storage@8.2.0":
|
||||
version "8.2.0"
|
||||
resolved "https://registry.verdaccio.org/@verdaccio%2flocal-storage/-/local-storage-8.2.0.tgz#d09406b8738e949ff247fef71386de0e8a1de0f1"
|
||||
integrity sha512-gIamhfr7TwXAmOv/2NNr/Cisr9UextH/8w3qPnzdAMuZWAyquiZK9/z/DLDZm04H9A6pP9oaSfjXydUVeD4ZYg==
|
||||
dependencies:
|
||||
"@verdaccio/commons-api" "^8.2.0"
|
||||
"@verdaccio/file-locking" "^8.2.0"
|
||||
"@verdaccio/streams" "^8.2.0"
|
||||
async "3.1.0"
|
||||
level "5.0.1"
|
||||
lodash "4.17.15"
|
||||
mkdirp "0.5.1"
|
||||
|
||||
"@verdaccio/local-storage@8.4.2":
|
||||
version "8.4.2"
|
||||
resolved "https://registry.verdaccio.org/@verdaccio%2flocal-storage/-/local-storage-8.4.2.tgz#b05653eefc7d721fc283a1dd3bfb0436606f1a70"
|
||||
|
@ -1725,6 +1738,15 @@
|
|||
lodash "4.17.15"
|
||||
mkdirp "0.5.1"
|
||||
|
||||
"@verdaccio/readme@8.2.0":
|
||||
version "8.2.0"
|
||||
resolved "https://registry.verdaccio.org/@verdaccio%2freadme/-/readme-8.2.0.tgz#a1628f633c46fe86e8b5d55fbba44aba11d23e33"
|
||||
integrity sha512-fII0jdixadOkQFtFktZw3EMyYGvTs2nzhlkGM9WZfv4QH2pVVmrfx1E9sqBrKLHUvwgrO8sDfcC8wHJQ6tsNVw==
|
||||
dependencies:
|
||||
dompurify "2.0.7"
|
||||
jsdom "15.2.0"
|
||||
marked "0.7.0"
|
||||
|
||||
"@verdaccio/readme@8.4.2":
|
||||
version "8.4.2"
|
||||
resolved "https://registry.verdaccio.org/@verdaccio%2freadme/-/readme-8.4.2.tgz#6c3535ae88f66c0adffd29f79257504c1a77f1bb"
|
||||
|
@ -1749,6 +1771,11 @@
|
|||
resolved "https://registry.verdaccio.org/@verdaccio%2ftypes/-/types-8.1.0.tgz#298baa1c0bffd340022537a1d9b064b82b4ae497"
|
||||
integrity sha512-wc0SaH25ioT6xt4HtlFzvmNSjZXQOddJLDuI1VN4/8nHAIlrUdlQ0sGnmky4+bJOuTL3eqbaqx4nHMKep5+lDg==
|
||||
|
||||
"@verdaccio/ui-theme@0.3.2":
|
||||
version "0.3.2"
|
||||
resolved "https://registry.verdaccio.org/@verdaccio%2fui-theme/-/ui-theme-0.3.2.tgz#6f4a27abb3781a9741473e55bff7af650dce118c"
|
||||
integrity sha512-bxICDb2dgHXp6DOEx8f1IfU7PsgF1AuuDxa87MbvXqfE3CfMGB2TEwlPWNlX+VSScgWNh/yYSDrOIQ2SqwgAGg==
|
||||
|
||||
"@verdaccio/ui-theme@0.3.9":
|
||||
version "0.3.9"
|
||||
resolved "https://registry.verdaccio.org/@verdaccio%2fui-theme/-/ui-theme-0.3.9.tgz#6ff0f05315912b4ba39e29eb589ecc8833640990"
|
||||
|
@ -3307,6 +3334,11 @@ end-of-stream@^1.1.0:
|
|||
dependencies:
|
||||
once "^1.4.0"
|
||||
|
||||
envinfo@7.4.0:
|
||||
version "7.4.0"
|
||||
resolved "https://registry.verdaccio.org/envinfo/-/envinfo-7.4.0.tgz#bef4ece9e717423aaf0c3584651430b735ad6630"
|
||||
integrity sha512-FdDfnWnCVjxTTpWE3d6Jgh5JDIA3Cw7LCgpM/pI7kK1ORkjaqI2r6NqQ+ln2j0dfpgxY00AWieSvtkiZQKIItA==
|
||||
|
||||
envinfo@7.5.0:
|
||||
version "7.5.0"
|
||||
resolved "https://registry.verdaccio.org/envinfo/-/envinfo-7.5.0.tgz#91410bb6db262fb4f1409bd506e9ff57e91023f4"
|
||||
|
@ -3944,6 +3976,15 @@ fs-access@1.0.1:
|
|||
dependencies:
|
||||
null-check "^1.0.0"
|
||||
|
||||
fs-extra@8.1.0:
|
||||
version "8.1.0"
|
||||
resolved "https://registry.verdaccio.org/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0"
|
||||
integrity sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==
|
||||
dependencies:
|
||||
graceful-fs "^4.2.0"
|
||||
jsonfile "^4.0.0"
|
||||
universalify "^0.1.0"
|
||||
|
||||
fs-minipass@^1.2.5:
|
||||
version "1.2.6"
|
||||
resolved "https://registry.verdaccio.org/fs-minipass/-/fs-minipass-1.2.6.tgz#2c5cc30ded81282bfe8a0d7c7c1853ddeb102c07"
|
||||
|
@ -4186,6 +4227,11 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.3
|
|||
resolved "https://registry.verdaccio.org/graceful-fs/-/graceful-fs-4.2.0.tgz#8d8fdc73977cb04104721cb53666c1ca64cd328b"
|
||||
integrity sha512-jpSvDPV4Cq/bgtpndIWbI5hmYxhQGHPC4d4cqBPb4DLniCfhJokdXhwhaDuLBGLQdvvRum/UiX6ECVIPvDXqdg==
|
||||
|
||||
graceful-fs@^4.1.6, graceful-fs@^4.2.0:
|
||||
version "4.2.3"
|
||||
resolved "https://registry.verdaccio.org/graceful-fs/-/graceful-fs-4.2.3.tgz#4a12ff1b60376ef09862c2093edd908328be8423"
|
||||
integrity sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ==
|
||||
|
||||
growly@^1.3.0:
|
||||
version "1.3.0"
|
||||
resolved "https://registry.verdaccio.org/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081"
|
||||
|
@ -5245,6 +5291,38 @@ jsbn@~0.1.0:
|
|||
resolved "https://registry.verdaccio.org/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513"
|
||||
integrity sha1-peZUwuWi3rXyAdls77yoDA7y9RM=
|
||||
|
||||
jsdom@15.2.0:
|
||||
version "15.2.0"
|
||||
resolved "https://registry.verdaccio.org/jsdom/-/jsdom-15.2.0.tgz#4baead4f464e733533ed6ac607ce440918cf5cbb"
|
||||
integrity sha512-+hRyEfjRPFwTYMmSQ3/f7U9nP8ZNZmbkmUek760ZpxnCPWJIhaaLRuUSvpJ36fZKCGENxLwxClzwpOpnXNfChQ==
|
||||
dependencies:
|
||||
abab "^2.0.0"
|
||||
acorn "^7.1.0"
|
||||
acorn-globals "^4.3.2"
|
||||
array-equal "^1.0.0"
|
||||
cssom "^0.4.1"
|
||||
cssstyle "^2.0.0"
|
||||
data-urls "^1.1.0"
|
||||
domexception "^1.0.1"
|
||||
escodegen "^1.11.1"
|
||||
html-encoding-sniffer "^1.0.2"
|
||||
nwsapi "^2.1.4"
|
||||
parse5 "5.1.0"
|
||||
pn "^1.1.0"
|
||||
request "^2.88.0"
|
||||
request-promise-native "^1.0.7"
|
||||
saxes "^3.1.9"
|
||||
symbol-tree "^3.2.2"
|
||||
tough-cookie "^3.0.1"
|
||||
w3c-hr-time "^1.0.1"
|
||||
w3c-xmlserializer "^1.1.2"
|
||||
webidl-conversions "^4.0.2"
|
||||
whatwg-encoding "^1.0.5"
|
||||
whatwg-mimetype "^2.3.0"
|
||||
whatwg-url "^7.0.0"
|
||||
ws "^7.0.0"
|
||||
xml-name-validator "^3.0.0"
|
||||
|
||||
jsdom@15.2.1:
|
||||
version "15.2.1"
|
||||
resolved "https://registry.verdaccio.org/jsdom/-/jsdom-15.2.1.tgz#d2feb1aef7183f86be521b8c6833ff5296d07ec5"
|
||||
|
@ -5356,6 +5434,13 @@ json5@^2.1.0:
|
|||
dependencies:
|
||||
minimist "^1.2.0"
|
||||
|
||||
jsonfile@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.verdaccio.org/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb"
|
||||
integrity sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=
|
||||
optionalDependencies:
|
||||
graceful-fs "^4.1.6"
|
||||
|
||||
jsonparse@^1.2.0:
|
||||
version "1.3.1"
|
||||
resolved "https://registry.verdaccio.org/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280"
|
||||
|
@ -6348,7 +6433,7 @@ nwsapi@^2.0.7:
|
|||
resolved "https://registry.verdaccio.org/nwsapi/-/nwsapi-2.1.4.tgz#e006a878db23636f8e8a67d33ca0e4edf61a842f"
|
||||
integrity sha512-iGfd9Y6SFdTNldEy2L0GUhcarIutFmk+MPWIn9dmj8NMIup03G08uUF2KGbbmv/Ux4RT0VZJoP/sVbWA6d/VIw==
|
||||
|
||||
nwsapi@^2.2.0:
|
||||
nwsapi@^2.1.4, nwsapi@^2.2.0:
|
||||
version "2.2.0"
|
||||
resolved "https://registry.verdaccio.org/nwsapi/-/nwsapi-2.2.0.tgz#204879a9e3d068ff2a55139c2c772780681a38b7"
|
||||
integrity sha512-h2AatdwYH+JHiZpv7pt/gSX1XoRGb7L/qSIeuqA6GwYoF9w1vP1cw42TO0aI2pNyshRK5893hNSl+1//vHK7hQ==
|
||||
|
@ -8276,6 +8361,11 @@ universal-user-agent@^4.0.0:
|
|||
dependencies:
|
||||
os-name "^3.1.0"
|
||||
|
||||
universalify@^0.1.0:
|
||||
version "0.1.2"
|
||||
resolved "https://registry.verdaccio.org/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66"
|
||||
integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==
|
||||
|
||||
unix-crypt-td-js@1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.verdaccio.org/unix-crypt-td-js/-/unix-crypt-td-js-1.0.0.tgz#1c0824150481bc7a01d49e98f1ec668d82412f3b"
|
||||
|
@ -8405,6 +8495,46 @@ verdaccio-memory@8.2.0:
|
|||
http-errors "1.7.3"
|
||||
memory-fs "0.5.0"
|
||||
|
||||
verdaccio@latest:
|
||||
version "4.3.5"
|
||||
resolved "https://registry.verdaccio.org/verdaccio/-/verdaccio-4.3.5.tgz#7e7dea476c0d41f6ac8923d4cdcec31217ab462b"
|
||||
integrity sha512-184myBmaBc7nVpTYJCTLjhaBV+1dCw/do8clAmwUgxC5immDBf44YXJ/CtbJURgq532SLTrdlI4e4xnRl74RTg==
|
||||
dependencies:
|
||||
"@verdaccio/commons-api" "8.3.0"
|
||||
"@verdaccio/local-storage" "8.2.0"
|
||||
"@verdaccio/readme" "8.2.0"
|
||||
"@verdaccio/streams" "8.2.0"
|
||||
"@verdaccio/ui-theme" "0.3.2"
|
||||
JSONStream "1.3.5"
|
||||
async "3.1.0"
|
||||
body-parser "1.19.0"
|
||||
bunyan "1.8.12"
|
||||
commander "3.0.2"
|
||||
compression "1.7.4"
|
||||
cookies "0.7.3"
|
||||
cors "2.8.5"
|
||||
dayjs "1.8.17"
|
||||
envinfo "7.4.0"
|
||||
express "4.17.1"
|
||||
handlebars "4.5.3"
|
||||
http-errors "1.7.3"
|
||||
js-yaml "3.13.1"
|
||||
jsonwebtoken "8.5.1"
|
||||
kleur "3.0.3"
|
||||
lockfile-lint "2.0.1"
|
||||
lodash "4.17.15"
|
||||
lunr-mutable-indexes "2.3.2"
|
||||
marked "0.7.0"
|
||||
mime "2.4.4"
|
||||
minimatch "3.0.4"
|
||||
mkdirp "0.5.1"
|
||||
mv "2.1.1"
|
||||
pkginfo "0.4.1"
|
||||
request "2.87.0"
|
||||
semver "6.3.0"
|
||||
verdaccio-audit "8.1.4"
|
||||
verdaccio-htpasswd "8.2.0"
|
||||
|
||||
verror@1.10.0:
|
||||
version "1.10.0"
|
||||
resolved "https://registry.verdaccio.org/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400"
|
||||
|
|
Loading…
Add table
Reference in a new issue