mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-03-11 02:15:57 -05:00
fix: get-port missing dependency (#3677)
This commit is contained in:
parent
7ef599cc4a
commit
c383eb68ce
13 changed files with 115 additions and 454 deletions
7
.changeset/honest-maps-hear.md
Normal file
7
.changeset/honest-maps-hear.md
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
'@verdaccio/test-cli-commons': patch
|
||||||
|
'@verdaccio/e2e-ui': patch
|
||||||
|
'verdaccio': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: get-port missing dep
|
|
@ -12,6 +12,7 @@
|
||||||
"fs-extra": "10.1.0",
|
"fs-extra": "10.1.0",
|
||||||
"got": "11.8.6",
|
"got": "11.8.6",
|
||||||
"js-yaml": "4.1.0",
|
"js-yaml": "4.1.0",
|
||||||
|
"get-port": "5.1.1",
|
||||||
"lodash": "4.17.21",
|
"lodash": "4.17.21",
|
||||||
"verdaccio": "workspace:6.0.0-6-next.65"
|
"verdaccio": "workspace:6.0.0-6-next.65"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/* eslint-disable prefer-promise-reject-errors */
|
/* eslint-disable prefer-promise-reject-errors */
|
||||||
import buildDebug from 'debug';
|
import buildDebug from 'debug';
|
||||||
|
import getPort from 'get-port';
|
||||||
import { merge } from 'lodash';
|
import { merge } from 'lodash';
|
||||||
import { Registry } from 'verdaccio';
|
import { Registry } from 'verdaccio';
|
||||||
|
|
||||||
|
@ -35,6 +36,7 @@ export async function initialSetup(customConfig?: ConfigYaml): Promise<Setup> {
|
||||||
const { configPath, tempFolder } = await getConfigPath(config);
|
const { configPath, tempFolder } = await getConfigPath(config);
|
||||||
debug(`configPath %o`, configPath);
|
debug(`configPath %o`, configPath);
|
||||||
debug(`tempFolder %o`, tempFolder);
|
debug(`tempFolder %o`, tempFolder);
|
||||||
const registry = new Registry(configPath, { createUser: true });
|
const port = await getPort();
|
||||||
|
const registry = new Registry(configPath, { createUser: true, port });
|
||||||
return { registry, tempFolder };
|
return { registry, tempFolder };
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { defineConfig } from 'cypress';
|
import { defineConfig } from 'cypress';
|
||||||
|
import getPort from 'get-port';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { Registry, ServerQuery } from 'verdaccio';
|
import { Registry, ServerQuery } from 'verdaccio';
|
||||||
|
|
||||||
|
@ -17,9 +18,11 @@ export default defineConfig({
|
||||||
...configProtected,
|
...configProtected,
|
||||||
storage: registry1storage,
|
storage: registry1storage,
|
||||||
});
|
});
|
||||||
|
const port = await getPort();
|
||||||
registry1 = new Registry(protectedRegistry.configPath, {
|
registry1 = new Registry(protectedRegistry.configPath, {
|
||||||
createUser: true,
|
createUser: true,
|
||||||
credentials: { user: 'test', password: 'test' },
|
credentials: { user: 'test', password: 'test' },
|
||||||
|
port,
|
||||||
});
|
});
|
||||||
await registry1.init();
|
await registry1.init();
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,7 +8,8 @@
|
||||||
"@verdaccio/config": "workspace:6.0.0-6-next.65",
|
"@verdaccio/config": "workspace:6.0.0-6-next.65",
|
||||||
"@verdaccio/test-helper": "workspace:2.0.0-6-next.8",
|
"@verdaccio/test-helper": "workspace:2.0.0-6-next.8",
|
||||||
"debug": "4.3.4",
|
"debug": "4.3.4",
|
||||||
"cypress": "11.2.0"
|
"cypress": "11.2.0",
|
||||||
|
"get-port": "5.1.1"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"cypress:open": "cypress open",
|
"cypress:open": "cypress open",
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { ChildProcess, fork } from 'child_process';
|
import { ChildProcess, fork } from 'child_process';
|
||||||
import buildDebug from 'debug';
|
import buildDebug from 'debug';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import getPort from 'get-port';
|
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
import { fromJStoYAML } from '@verdaccio/config';
|
import { fromJStoYAML } from '@verdaccio/config';
|
||||||
|
@ -103,78 +102,79 @@ export class Registry {
|
||||||
verdaccioPath: string = path.join(__dirname, '../../bin/verdaccio')
|
verdaccioPath: string = path.join(__dirname, '../../bin/verdaccio')
|
||||||
): Promise<ChildProcess> {
|
): Promise<ChildProcess> {
|
||||||
debug('_start %o', verdaccioPath);
|
debug('_start %o', verdaccioPath);
|
||||||
return getPort().then((port: number) => {
|
debug('port %o', this.port);
|
||||||
this.port = port;
|
return new Promise((resolve, reject) => {
|
||||||
debug('port %o', port);
|
let childOptions = {
|
||||||
return new Promise((resolve, reject) => {
|
silent: false,
|
||||||
let childOptions = {
|
};
|
||||||
silent: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (this.debug) {
|
if (this.debug) {
|
||||||
const debugPort = port + 5;
|
const debugPort = this.port + 5;
|
||||||
debug('debug port %o', debugPort);
|
debug('debug port %o', debugPort);
|
||||||
childOptions = Object.assign({}, childOptions, {
|
childOptions = Object.assign({}, childOptions, {
|
||||||
execArgv: [`--inspect=${debugPort}`],
|
execArgv: [`--inspect=${debugPort}`],
|
||||||
env: {
|
env: {
|
||||||
DEBUG: process.env.DEBUG,
|
DEBUG: process.env.DEBUG,
|
||||||
VERDACCIO_SERVER: process.env.VERDACCIO_SERVER,
|
VERDACCIO_SERVER: process.env.VERDACCIO_SERVER,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
childOptions = Object.assign({}, childOptions, {
|
childOptions = Object.assign({}, childOptions, {
|
||||||
env: {
|
env: {
|
||||||
DEBUG: process.env.DEBUG,
|
DEBUG: process.env.DEBUG,
|
||||||
VERDACCIO_SERVER: process.env.VERDACCIO_SERVER,
|
VERDACCIO_SERVER: process.env.VERDACCIO_SERVER,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const { configPath } = this;
|
const { configPath } = this;
|
||||||
debug('configPath %s', configPath);
|
debug('configPath %s', configPath);
|
||||||
debug('port %s', port);
|
debug('port %s', this.port);
|
||||||
this.childFork = fork(verdaccioPath, ['-c', configPath, '-l', String(port)], childOptions);
|
this.childFork = fork(
|
||||||
|
verdaccioPath,
|
||||||
|
['-c', configPath, '-l', String(this.port)],
|
||||||
|
childOptions
|
||||||
|
);
|
||||||
|
|
||||||
this.childFork.on('message', async (msg: any) => {
|
this.childFork.on('message', async (msg: any) => {
|
||||||
// verdaccio_started is a message that comes from verdaccio in debug mode that
|
// verdaccio_started is a message that comes from verdaccio in debug mode that
|
||||||
// notify has been started
|
// notify has been started
|
||||||
try {
|
try {
|
||||||
if ('verdaccio_started' in msg) {
|
if ('verdaccio_started' in msg) {
|
||||||
const server = new ServerQuery(`http://${this.domain}:` + port);
|
const server = new ServerQuery(`http://${this.domain}:` + this.port);
|
||||||
if (this.createUser) {
|
if (this.createUser) {
|
||||||
const user = await server.createUser(
|
const user = await server.createUser(
|
||||||
this.credentials.user,
|
this.credentials.user,
|
||||||
this.credentials.password
|
this.credentials.password
|
||||||
);
|
);
|
||||||
user.status(HTTP_STATUS.CREATED).body_ok(new RegExp(this.credentials.user));
|
user.status(HTTP_STATUS.CREATED).body_ok(new RegExp(this.credentials.user));
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
this.token = user?.response?.body.token;
|
this.token = user?.response?.body.token;
|
||||||
this.authstr = buildAuthHeader(this.token as string);
|
this.authstr = buildAuthHeader(this.token as string);
|
||||||
}
|
|
||||||
|
|
||||||
return resolve(this.childFork);
|
|
||||||
}
|
}
|
||||||
} catch (e: any) {
|
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.error(e);
|
|
||||||
// eslint-disable-next-line prefer-promise-reject-errors
|
|
||||||
return reject([e, this]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
this.childFork.on('error', (err) => {
|
return resolve(this.childFork);
|
||||||
debug('error %s', err);
|
}
|
||||||
|
} catch (e: any) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.error(e);
|
||||||
// eslint-disable-next-line prefer-promise-reject-errors
|
// eslint-disable-next-line prefer-promise-reject-errors
|
||||||
reject([err, this]);
|
return reject([e, this]);
|
||||||
});
|
}
|
||||||
this.childFork.on('disconnect', (err) => {
|
});
|
||||||
// eslint-disable-next-line prefer-promise-reject-errors
|
|
||||||
reject([err, this]);
|
this.childFork.on('error', (err) => {
|
||||||
});
|
debug('error %s', err);
|
||||||
this.childFork.on('exit', (err) => {
|
// eslint-disable-next-line prefer-promise-reject-errors
|
||||||
// eslint-disable-next-line prefer-promise-reject-errors
|
reject([err, this]);
|
||||||
reject([err, this]);
|
});
|
||||||
});
|
this.childFork.on('disconnect', (err) => {
|
||||||
|
// eslint-disable-next-line prefer-promise-reject-errors
|
||||||
|
reject([err, this]);
|
||||||
|
});
|
||||||
|
this.childFork.on('exit', (err) => {
|
||||||
|
// eslint-disable-next-line prefer-promise-reject-errors
|
||||||
|
reject([err, this]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import getPort from 'get-port';
|
||||||
|
|
||||||
import { ConfigBuilder } from '@verdaccio/config';
|
import { ConfigBuilder } from '@verdaccio/config';
|
||||||
import { API_MESSAGE, HTTP_STATUS, constants, fileUtils } from '@verdaccio/core';
|
import { API_MESSAGE, HTTP_STATUS, constants, fileUtils } from '@verdaccio/core';
|
||||||
|
|
||||||
|
@ -22,7 +24,8 @@ describe('basic test endpoints', () => {
|
||||||
.addLogger({ level: 'debug', type: 'stdout', format: 'pretty' })
|
.addLogger({ level: 'debug', type: 'stdout', format: 'pretty' })
|
||||||
.addUplink('upstream', { url: 'https://registry.verdaccio.org' });
|
.addUplink('upstream', { url: 'https://registry.verdaccio.org' });
|
||||||
const { configPath } = await Registry.fromConfigToPath(configuration.getConfig());
|
const { configPath } = await Registry.fromConfigToPath(configuration.getConfig());
|
||||||
registry = new Registry(configPath);
|
const port = await getPort();
|
||||||
|
registry = new Registry(configPath, { port });
|
||||||
await registry.init();
|
await registry.init();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import getPort from 'get-port';
|
||||||
import got from 'got';
|
import got from 'got';
|
||||||
|
|
||||||
import { ConfigBuilder } from '@verdaccio/config';
|
import { ConfigBuilder } from '@verdaccio/config';
|
||||||
|
@ -24,7 +25,8 @@ describe('html', () => {
|
||||||
.addLogger({ level: 'debug', type: 'stdout', format: 'pretty' })
|
.addLogger({ level: 'debug', type: 'stdout', format: 'pretty' })
|
||||||
.addUplink('upstream', { url: 'https://registry.verdaccio.org' });
|
.addUplink('upstream', { url: 'https://registry.verdaccio.org' });
|
||||||
const { configPath } = await Registry.fromConfigToPath(configuration.getConfig());
|
const { configPath } = await Registry.fromConfigToPath(configuration.getConfig());
|
||||||
registry = new Registry(configPath);
|
const port = await getPort();
|
||||||
|
registry = new Registry(configPath, { port });
|
||||||
await registry.init();
|
await registry.init();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import getPort from 'get-port';
|
||||||
|
|
||||||
import { ConfigBuilder } from '@verdaccio/config';
|
import { ConfigBuilder } from '@verdaccio/config';
|
||||||
import { API_MESSAGE, constants, fileUtils } from '@verdaccio/core';
|
import { API_MESSAGE, constants, fileUtils } from '@verdaccio/core';
|
||||||
|
|
||||||
|
@ -22,7 +24,8 @@ describe('race publishing packages', () => {
|
||||||
.addLogger({ level: 'warn', type: 'stdout', format: 'pretty' })
|
.addLogger({ level: 'warn', type: 'stdout', format: 'pretty' })
|
||||||
.addUplink('upstream', { url: 'https://registry.verdaccio.org' });
|
.addUplink('upstream', { url: 'https://registry.verdaccio.org' });
|
||||||
const { configPath } = await Registry.fromConfigToPath(configuration.getConfig());
|
const { configPath } = await Registry.fromConfigToPath(configuration.getConfig());
|
||||||
registry = new Registry(configPath);
|
const port = await getPort();
|
||||||
|
registry = new Registry(configPath, { port });
|
||||||
await registry.init();
|
await registry.init();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import getPort from 'get-port';
|
||||||
|
|
||||||
import { ConfigBuilder } from '@verdaccio/config';
|
import { ConfigBuilder } from '@verdaccio/config';
|
||||||
import { HTTP_STATUS, constants, fileUtils } from '@verdaccio/core';
|
import { HTTP_STATUS, constants, fileUtils } from '@verdaccio/core';
|
||||||
|
|
||||||
|
@ -43,7 +45,8 @@ describe('multiple proxy registries configuration', () => {
|
||||||
.addUplink('npmjs', { url: 'https://registry.npmjs.com' });
|
.addUplink('npmjs', { url: 'https://registry.npmjs.com' });
|
||||||
|
|
||||||
const confRegistry = await Registry.fromConfigToPath(configuration.getConfig());
|
const confRegistry = await Registry.fromConfigToPath(configuration.getConfig());
|
||||||
registry = new Registry(confRegistry.configPath);
|
const port = await getPort({ port: 3001 });
|
||||||
|
registry = new Registry(confRegistry.configPath, { port });
|
||||||
await registry.init();
|
await registry.init();
|
||||||
|
|
||||||
// server 3 configuration
|
// server 3 configuration
|
||||||
|
@ -67,7 +70,8 @@ describe('multiple proxy registries configuration', () => {
|
||||||
.addLogger({ level: 'debug', type: 'stdout', format: 'pretty' })
|
.addLogger({ level: 'debug', type: 'stdout', format: 'pretty' })
|
||||||
.addUplink('npmjs', { url: 'https://registry.npmjs.com' });
|
.addUplink('npmjs', { url: 'https://registry.npmjs.com' });
|
||||||
const confRegistry3 = await Registry.fromConfigToPath(configuration3.getConfig());
|
const confRegistry3 = await Registry.fromConfigToPath(configuration3.getConfig());
|
||||||
registry3 = new Registry(confRegistry3.configPath);
|
const port3 = await getPort({ port: 3002 });
|
||||||
|
registry3 = new Registry(confRegistry3.configPath, { port: port3 });
|
||||||
await registry3.init();
|
await registry3.init();
|
||||||
|
|
||||||
// server 2 configuration
|
// server 2 configuration
|
||||||
|
@ -107,7 +111,8 @@ describe('multiple proxy registries configuration', () => {
|
||||||
.addUplink('no-retry', { url: `http://no-retry.local`, max_fails: 0 })
|
.addUplink('no-retry', { url: `http://no-retry.local`, max_fails: 0 })
|
||||||
.addUplink('timeout', { url: `http://timeout.local`, max_fails: 0, timeout: '1s' });
|
.addUplink('timeout', { url: `http://timeout.local`, max_fails: 0, timeout: '1s' });
|
||||||
const confRegistry2 = await Registry.fromConfigToPath(configuration2.getConfig());
|
const confRegistry2 = await Registry.fromConfigToPath(configuration2.getConfig());
|
||||||
registry2 = new Registry(confRegistry2.configPath);
|
const port2 = await getPort({ port: 3004 });
|
||||||
|
registry2 = new Registry(confRegistry2.configPath, { port: port2 });
|
||||||
await registry2.init();
|
await registry2.init();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import getPort from 'get-port';
|
||||||
|
|
||||||
import { ConfigBuilder } from '@verdaccio/config';
|
import { ConfigBuilder } from '@verdaccio/config';
|
||||||
import { constants, fileUtils } from '@verdaccio/core';
|
import { constants, fileUtils } from '@verdaccio/core';
|
||||||
|
|
||||||
|
@ -25,7 +27,8 @@ describe('race publishing packages', () => {
|
||||||
.addLogger({ level: 'debug', type: 'stdout', format: 'pretty' })
|
.addLogger({ level: 'debug', type: 'stdout', format: 'pretty' })
|
||||||
.addUplink('upstream', { url: 'https://registry.verdaccio.org' });
|
.addUplink('upstream', { url: 'https://registry.verdaccio.org' });
|
||||||
const { configPath } = await Registry.fromConfigToPath(configuration.getConfig());
|
const { configPath } = await Registry.fromConfigToPath(configuration.getConfig());
|
||||||
registry = new Registry(configPath);
|
const port = await getPort();
|
||||||
|
registry = new Registry(configPath, { port });
|
||||||
await registry.init();
|
await registry.init();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import getPort from 'get-port';
|
||||||
import nock from 'nock';
|
import nock from 'nock';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
|
@ -9,7 +10,8 @@ const configFile = path.join(__dirname, './config.yaml');
|
||||||
|
|
||||||
describe('server query', () => {
|
describe('server query', () => {
|
||||||
test('server run', async () => {
|
test('server run', async () => {
|
||||||
const registry = new Registry(configFile);
|
const port = await getPort({ port: 4001 });
|
||||||
|
const registry = new Registry(configFile, { port });
|
||||||
const vPath = path.join(__dirname, '../bin/verdaccio');
|
const vPath = path.join(__dirname, '../bin/verdaccio');
|
||||||
const d = await registry.init(vPath);
|
const d = await registry.init(vPath);
|
||||||
expect(d.pid).toBeDefined();
|
expect(d.pid).toBeDefined();
|
||||||
|
@ -20,7 +22,8 @@ describe('server query', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('server create user', async () => {
|
test('server create user', async () => {
|
||||||
const registry = new Registry(configFile, { createUser: true });
|
const port = await getPort({ port: 4002 });
|
||||||
|
const registry = new Registry(configFile, { createUser: true, port });
|
||||||
const vPath = path.join(__dirname, '../bin/verdaccio');
|
const vPath = path.join(__dirname, '../bin/verdaccio');
|
||||||
const d = await registry.init(vPath);
|
const d = await registry.init(vPath);
|
||||||
expect(d.pid).toBeDefined();
|
expect(d.pid).toBeDefined();
|
||||||
|
|
380
pnpm-lock.yaml
generated
380
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue