mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-30 22:34:10 -05:00
feature: Update Build pipeline for Babel transpiler (#349)
feature: Update Build pipeline for Babel transpiler
This commit is contained in:
parent
6a0d539b61
commit
a5e162d475
15 changed files with 261 additions and 212 deletions
12
.babelrc
12
.babelrc
|
@ -1,4 +1,6 @@
|
||||||
{
|
{
|
||||||
|
"env": {
|
||||||
|
"ui": {
|
||||||
"presets": [
|
"presets": [
|
||||||
"react",
|
"react",
|
||||||
["env",{
|
["env",{
|
||||||
|
@ -21,8 +23,16 @@
|
||||||
"transform-runtime",
|
"transform-runtime",
|
||||||
"transform-object-rest-spread",
|
"transform-object-rest-spread",
|
||||||
"transform-decorators-legacy"
|
"transform-decorators-legacy"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"registry": {
|
||||||
|
"presets": [
|
||||||
|
"es2015-node4", "flow"
|
||||||
],
|
],
|
||||||
"env": {
|
"plugins": [
|
||||||
|
"transform-object-rest-spread"
|
||||||
|
]
|
||||||
|
},
|
||||||
"development": {
|
"development": {
|
||||||
"presets": ["flow"],
|
"presets": ["flow"],
|
||||||
"plugins": [
|
"plugins": [
|
||||||
|
|
30
package.json
30
package.json
|
@ -15,8 +15,8 @@
|
||||||
"verdaccio": "./bin/verdaccio"
|
"verdaccio": "./bin/verdaccio"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@verdaccio/file-locking": "0.0.5",
|
"@verdaccio/file-locking": "^0.0.5",
|
||||||
"@verdaccio/local-storage": "^0.0.10",
|
"@verdaccio/local-storage": "^0.0.11",
|
||||||
"@verdaccio/streams": "^0.0.2",
|
"@verdaccio/streams": "^0.0.2",
|
||||||
"@verdaccio/types": "^0.0.7",
|
"@verdaccio/types": "^0.0.7",
|
||||||
"JSONStream": "^1.1.1",
|
"JSONStream": "^1.1.1",
|
||||||
|
@ -50,20 +50,26 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"axios": "0.16.2",
|
"axios": "0.16.2",
|
||||||
"babel-cli": "6.24.1",
|
"babel-cli": "^6.26.0",
|
||||||
"babel-core": "6.25.0",
|
"babel-core": "6.26.0",
|
||||||
"babel-eslint": "7.2.3",
|
"babel-eslint": "8.0.1",
|
||||||
"babel-loader": "7.1.1",
|
"babel-loader": "7.1.2",
|
||||||
"babel-plugin-flow-runtime": "0.11.1",
|
"babel-plugin-flow-runtime": "0.11.1",
|
||||||
"babel-plugin-transform-decorators-legacy": "1.3.4",
|
"babel-plugin-transform-decorators-legacy": "1.3.4",
|
||||||
|
"babel-plugin-transform-es2015-classes": "^6.24.1",
|
||||||
"babel-plugin-transform-runtime": "6.23.0",
|
"babel-plugin-transform-runtime": "6.23.0",
|
||||||
"babel-polyfill": "^6.26.0",
|
"babel-polyfill": "^6.26.0",
|
||||||
"babel-preset-env": "1.5.2",
|
"babel-preset-env": "1.6.0",
|
||||||
|
"babel-preset-es2015": "^6.24.1",
|
||||||
|
"babel-preset-es2015-node4": "2.1.0",
|
||||||
"babel-preset-flow": "6.23.0",
|
"babel-preset-flow": "6.23.0",
|
||||||
"babel-preset-react": "6.24.1",
|
"babel-preset-react": "6.24.1",
|
||||||
"babel-preset-stage-2": "6.24.1",
|
"babel-preset-stage-2": "6.24.1",
|
||||||
"babel-preset-stage-3": "6.24.1",
|
"babel-preset-stage-3": "6.24.1",
|
||||||
"babel-runtime": "6.23.0",
|
"babel-register": "^6.26.0",
|
||||||
|
"babel-runtime": "6.26.0",
|
||||||
|
"babel-jest": "^21.2.0",
|
||||||
|
"babel-plugin-transform-async-to-generator": "^6.24.1",
|
||||||
"codacy-coverage": "2.0.2",
|
"codacy-coverage": "2.0.2",
|
||||||
"codecov": "2.2.0",
|
"codecov": "2.2.0",
|
||||||
"coveralls": "2.13.1",
|
"coveralls": "2.13.1",
|
||||||
|
@ -87,7 +93,7 @@
|
||||||
"html-webpack-plugin": "2.29.0",
|
"html-webpack-plugin": "2.29.0",
|
||||||
"in-publish": "2.0.0",
|
"in-publish": "2.0.0",
|
||||||
"localstorage-memory": "1.0.2",
|
"localstorage-memory": "1.0.2",
|
||||||
"mocha": "3.4.2",
|
"mocha": "3.5.3",
|
||||||
"mocha-lcov-reporter": "1.3.0",
|
"mocha-lcov-reporter": "1.3.0",
|
||||||
"node-sass": "4.5.3",
|
"node-sass": "4.5.3",
|
||||||
"normalize.css": "7.0.0",
|
"normalize.css": "7.0.0",
|
||||||
|
@ -126,7 +132,7 @@
|
||||||
"release": "standard-version -a -s",
|
"release": "standard-version -a -s",
|
||||||
"prepublish": "in-publish && npm run build:webui || not-in-publish",
|
"prepublish": "in-publish && npm run build:webui || not-in-publish",
|
||||||
"flow": "flow",
|
"flow": "flow",
|
||||||
"test": "mocha ./test/functional ./test/unit --reporter=spec --full-trace",
|
"test": "BABEL_ENV=registry mocha --require babel-register ./test/functional ./test/unit --reporter=spec --full-trace",
|
||||||
"pre:ci": "npm run build:webui",
|
"pre:ci": "npm run build:webui",
|
||||||
"test:ci": "npm run test:coverage",
|
"test:ci": "npm run test:coverage",
|
||||||
"test:only": "mocha ./test/functional ./test/unit",
|
"test:only": "mocha ./test/functional ./test/unit",
|
||||||
|
@ -135,9 +141,11 @@
|
||||||
"coverage:publish": "nyc report --reporter=lcov | codecov",
|
"coverage:publish": "nyc report --reporter=lcov | codecov",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"lint:css": "stylelint 'src/**/*.scss' --syntax scss",
|
"lint:css": "stylelint 'src/**/*.scss' --syntax scss",
|
||||||
|
"dev:start": "BABEL_ENV=registry babel-node src/lib/cli",
|
||||||
|
"code:build": "BABEL_ENV=registry babel src/ --out-dir build/ --ignore src/webui/ --copy-files",
|
||||||
"pre:webpack": "npm run lint && rimraf static/*",
|
"pre:webpack": "npm run lint && rimraf static/*",
|
||||||
"dev:webui": "babel-node tools/dev.server.js",
|
"dev:webui": "babel-node tools/dev.server.js",
|
||||||
"build:webui": "npm run pre:webpack && webpack --config tools/webpack.prod.config.babel.js",
|
"build:webui": "npm run pre:webpack && BABEL_ENV=ui webpack --config tools/webpack.prod.config.babel.js",
|
||||||
"build:docker": "docker build -t verdaccio . --no-cache",
|
"build:docker": "docker build -t verdaccio . --no-cache",
|
||||||
"build:docker:rpi": "docker build -f Dockerfile.rpi -t verdaccio:rpi ."
|
"build:docker:rpi": "docker build -f Dockerfile.rpi -t verdaccio:rpi ."
|
||||||
},
|
},
|
||||||
|
|
|
@ -35,7 +35,7 @@ module.exports = function(config, auth, storage) {
|
||||||
|
|
||||||
// Get list of all visible package
|
// Get list of all visible package
|
||||||
route.get('/packages', function(req, res, next) {
|
route.get('/packages', function(req, res, next) {
|
||||||
storage.get_local(function(err, packages) {
|
storage.getLocalDatabase(function(err, packages) {
|
||||||
if (err) {
|
if (err) {
|
||||||
// that function shouldn't produce any
|
// that function shouldn't produce any
|
||||||
throw err;
|
throw err;
|
||||||
|
|
166
src/lib/bootstrap.js
vendored
Normal file
166
src/lib/bootstrap.js
vendored
Normal file
|
@ -0,0 +1,166 @@
|
||||||
|
import isFunction from 'lodash/isFunction';
|
||||||
|
import Path from 'path';
|
||||||
|
import URL from 'url';
|
||||||
|
import fs from 'fs';
|
||||||
|
import http from'http';
|
||||||
|
import https from 'https';
|
||||||
|
|
||||||
|
const server = require('../api/index');
|
||||||
|
const Utils = require('./utils');
|
||||||
|
const logger = require('./logger');
|
||||||
|
const constants = require('constants');
|
||||||
|
// const pkgVersion = module.exports.version;
|
||||||
|
// const pkgName = module.exports.name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve all addresses defined in the config file.
|
||||||
|
* Verdaccio is able to listen multiple ports
|
||||||
|
* @param {String} argListen
|
||||||
|
* @param {String} configListen
|
||||||
|
* eg:
|
||||||
|
* listen:
|
||||||
|
- localhost:5555
|
||||||
|
- localhost:5557
|
||||||
|
@return {Array}
|
||||||
|
*/
|
||||||
|
function get_listen_addresses(argListen, configListen) {
|
||||||
|
// command line || config file || default
|
||||||
|
let addresses;
|
||||||
|
if (argListen) {
|
||||||
|
addresses = [argListen];
|
||||||
|
} else if (Array.isArray(configListen)) {
|
||||||
|
addresses = configListen;
|
||||||
|
} else if (configListen) {
|
||||||
|
addresses = [configListen];
|
||||||
|
} else {
|
||||||
|
addresses = ['4873'];
|
||||||
|
}
|
||||||
|
addresses = addresses.map(function(addr) {
|
||||||
|
let parsed_addr = Utils.parse_address(addr);
|
||||||
|
|
||||||
|
if (!parsed_addr) {
|
||||||
|
logger.logger.warn({addr: addr},
|
||||||
|
'invalid address - @{addr}, we expect a port (e.g. "4873"),'
|
||||||
|
+ ' host:port (e.g. "localhost:4873") or full url'
|
||||||
|
+ ' (e.g. "http://localhost:4873/")');
|
||||||
|
}
|
||||||
|
|
||||||
|
return parsed_addr;
|
||||||
|
}).filter(Boolean);
|
||||||
|
|
||||||
|
return addresses;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trigger the server after configuration has been loaded.
|
||||||
|
* @param {Object} config
|
||||||
|
* @param {Object} cliArguments
|
||||||
|
* @param {String} config_path
|
||||||
|
* @param {String} pkgVersion
|
||||||
|
* @param {String} pkgName
|
||||||
|
*/
|
||||||
|
function afterConfigLoad(config, cliArguments, config_path, pkgVersion, pkgName) {
|
||||||
|
if (!config.self_path) {
|
||||||
|
config.self_path = Path.resolve(config_path);
|
||||||
|
}
|
||||||
|
if (!config.https) {
|
||||||
|
config.https = {enable: false};
|
||||||
|
}
|
||||||
|
const app = server(config);
|
||||||
|
get_listen_addresses(cliArguments.listen, config.listen).forEach(function(addr) {
|
||||||
|
let webServer;
|
||||||
|
if (addr.proto === 'https') { // https must either have key cert and ca or a pfx and (optionally) a passphrase
|
||||||
|
if (!config.https || !config.https.key || !config.https.cert || !config.https.ca) {
|
||||||
|
let conf_path = function(file) {
|
||||||
|
if (!file) {
|
||||||
|
return config_path;
|
||||||
|
}
|
||||||
|
return Path.resolve(Path.dirname(config_path), file);
|
||||||
|
};
|
||||||
|
|
||||||
|
logger.logger.fatal([
|
||||||
|
'You need to specify either ',
|
||||||
|
' "https.key", "https.cert" and "https.ca" or ',
|
||||||
|
' "https.pfx" and optionally "https.passphrase" ',
|
||||||
|
'to run https server',
|
||||||
|
'',
|
||||||
|
// commands are borrowed from node.js docs
|
||||||
|
'To quickly create self-signed certificate, use:',
|
||||||
|
' $ openssl genrsa -out ' + conf_path('verdaccio-key.pem') + ' 2048',
|
||||||
|
' $ openssl req -new -sha256 -key ' + conf_path('verdaccio-key.pem') + ' -out ' + conf_path('verdaccio-csr.pem'),
|
||||||
|
' $ openssl x509 -req -in ' + conf_path('verdaccio-csr.pem') +
|
||||||
|
' -signkey ' + conf_path('verdaccio-key.pem') + ' -out ' + conf_path('verdaccio-cert.pem'),
|
||||||
|
'',
|
||||||
|
'And then add to config file (' + conf_path() + '):',
|
||||||
|
' https:',
|
||||||
|
' key: verdaccio-key.pem',
|
||||||
|
' cert: verdaccio-cert.pem',
|
||||||
|
' ca: verdaccio-cert.pem',
|
||||||
|
].join('\n'));
|
||||||
|
process.exit(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const httpsOptions = {
|
||||||
|
secureProtocol: 'SSLv23_method', // disable insecure SSLv2 and SSLv3
|
||||||
|
secureOptions: constants.SSL_OP_NO_SSLv2 | constants.SSL_OP_NO_SSLv3,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (config.https.pfx) {
|
||||||
|
Object.assign(httpsOptions, {
|
||||||
|
pfx: fs.readFileSync(config.https.pfx),
|
||||||
|
passphrase: config.https.passphrase || '',
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Object.assign(httpsOptions, {
|
||||||
|
key: fs.readFileSync(config.https.key),
|
||||||
|
cert: fs.readFileSync(config.https.cert),
|
||||||
|
ca: fs.readFileSync(config.https.ca),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
webServer = https.createServer(httpsOptions, app);
|
||||||
|
} catch (err) { // catch errors related to certificate loading
|
||||||
|
logger.logger.fatal({err: err}, 'cannot create server: @{err.message}');
|
||||||
|
process.exit(2);
|
||||||
|
}
|
||||||
|
} else { // http
|
||||||
|
webServer = http.createServer(app);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (addr.path && fs.existsSync(addr.path)) {
|
||||||
|
fs.unlinkSync(addr.path);
|
||||||
|
}
|
||||||
|
|
||||||
|
webServer
|
||||||
|
.listen(addr.port || addr.path, addr.host)
|
||||||
|
.on('error', function(err) {
|
||||||
|
logger.logger.fatal({err: err}, 'cannot create server: @{err.message}');
|
||||||
|
process.exit(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
logger.logger.warn({
|
||||||
|
addr: ( addr.path
|
||||||
|
? URL.format({
|
||||||
|
protocol: 'unix',
|
||||||
|
pathname: addr.path,
|
||||||
|
})
|
||||||
|
: URL.format({
|
||||||
|
protocol: addr.proto,
|
||||||
|
hostname: addr.host,
|
||||||
|
port: addr.port,
|
||||||
|
pathname: '/',
|
||||||
|
})
|
||||||
|
),
|
||||||
|
version: pkgName + '/' + pkgVersion,
|
||||||
|
}, 'http address - @{addr} - @{version}');
|
||||||
|
});
|
||||||
|
|
||||||
|
// undocumented stuff for tests
|
||||||
|
if (isFunction(process.send)) {
|
||||||
|
process.send({
|
||||||
|
verdaccio_started: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export {afterConfigLoad};
|
160
src/lib/cli.js
160
src/lib/cli.js
|
@ -2,9 +2,7 @@
|
||||||
|
|
||||||
/* eslint no-sync:0 */
|
/* eslint no-sync:0 */
|
||||||
/* eslint no-empty:0 */
|
/* eslint no-empty:0 */
|
||||||
'use strict';
|
import {afterConfigLoad} from './bootstrap';
|
||||||
|
|
||||||
const _ = require('lodash');
|
|
||||||
|
|
||||||
if (process.getuid && process.getuid() === 0) {
|
if (process.getuid && process.getuid() === 0) {
|
||||||
global.console.error('Verdaccio doesn\'t need superuser privileges. Don\'t run it under root.');
|
global.console.error('Verdaccio doesn\'t need superuser privileges. Don\'t run it under root.');
|
||||||
|
@ -22,13 +20,7 @@ const logger = require('./logger');
|
||||||
logger.setup(); // default setup
|
logger.setup(); // default setup
|
||||||
|
|
||||||
const commander = require('commander');
|
const commander = require('commander');
|
||||||
const constants = require('constants');
|
const path = require('path');
|
||||||
const fs = require('fs');
|
|
||||||
const http = require('http');
|
|
||||||
const https = require('https');
|
|
||||||
const Path = require('path');
|
|
||||||
const URL = require('url');
|
|
||||||
const server = require('../api/index');
|
|
||||||
const Utils = require('./utils');
|
const Utils = require('./utils');
|
||||||
const pkginfo = require('pkginfo')(module); // eslint-disable-line no-unused-vars
|
const pkginfo = require('pkginfo')(module); // eslint-disable-line no-unused-vars
|
||||||
const pkgVersion = module.exports.version;
|
const pkgVersion = module.exports.version;
|
||||||
|
@ -45,7 +37,7 @@ if (commander.args.length == 1 && !commander.config) {
|
||||||
commander.config = commander.args.pop();
|
commander.config = commander.args.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (commander.args.length != 0) {
|
if (commander.args.length !== 0) {
|
||||||
commander.help();
|
commander.help();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +45,7 @@ let config;
|
||||||
let config_path;
|
let config_path;
|
||||||
try {
|
try {
|
||||||
if (commander.config) {
|
if (commander.config) {
|
||||||
config_path = Path.resolve(commander.config);
|
config_path = path.resolve(commander.config);
|
||||||
} else {
|
} else {
|
||||||
config_path = require('./config-path')();
|
config_path = require('./config-path')();
|
||||||
}
|
}
|
||||||
|
@ -66,149 +58,7 @@ try {
|
||||||
|
|
||||||
process.title = config.web && config.web.title || 'verdaccio';
|
process.title = config.web && config.web.title || 'verdaccio';
|
||||||
|
|
||||||
afterConfigLoad();
|
afterConfigLoad(config, commander, config_path, pkgVersion, pkgName);
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve all addresses defined in the config file.
|
|
||||||
* Verdaccio is able to listen multiple ports
|
|
||||||
* eg:
|
|
||||||
* listen:
|
|
||||||
- localhost:5555
|
|
||||||
- localhost:5557
|
|
||||||
@return {Array}
|
|
||||||
*/
|
|
||||||
function get_listen_addresses() {
|
|
||||||
// command line || config file || default
|
|
||||||
let addresses;
|
|
||||||
if (commander.listen) {
|
|
||||||
addresses = [commander.listen];
|
|
||||||
} else if (Array.isArray(config.listen)) {
|
|
||||||
addresses = config.listen;
|
|
||||||
} else if (config.listen) {
|
|
||||||
addresses = [config.listen];
|
|
||||||
} else {
|
|
||||||
addresses = ['4873'];
|
|
||||||
}
|
|
||||||
addresses = addresses.map(function(addr) {
|
|
||||||
let parsed_addr = Utils.parse_address(addr);
|
|
||||||
|
|
||||||
if (!parsed_addr) {
|
|
||||||
logger.logger.warn({addr: addr},
|
|
||||||
'invalid address - @{addr}, we expect a port (e.g. "4873"),'
|
|
||||||
+ ' host:port (e.g. "localhost:4873") or full url'
|
|
||||||
+ ' (e.g. "http://localhost:4873/")');
|
|
||||||
}
|
|
||||||
|
|
||||||
return parsed_addr;
|
|
||||||
}).filter(Boolean);
|
|
||||||
|
|
||||||
return addresses;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Trigger the server after configuration has been loaded.
|
|
||||||
*/
|
|
||||||
function afterConfigLoad() {
|
|
||||||
if (!config.self_path) {
|
|
||||||
config.self_path = Path.resolve(config_path);
|
|
||||||
}
|
|
||||||
if (!config.https) {
|
|
||||||
config.https = {enable: false};
|
|
||||||
}
|
|
||||||
const app = server(config);
|
|
||||||
get_listen_addresses().forEach(function(addr) {
|
|
||||||
let webServer;
|
|
||||||
if (addr.proto === 'https') { // https must either have key cert and ca or a pfx and (optionally) a passphrase
|
|
||||||
if (!config.https || !((config.https.key && config.https.cert && config.https.ca) || config.https.pfx)) {
|
|
||||||
let conf_path = function(file) {
|
|
||||||
if (!file) return config_path;
|
|
||||||
return Path.resolve(Path.dirname(config_path), file);
|
|
||||||
};
|
|
||||||
|
|
||||||
logger.logger.fatal([
|
|
||||||
'You need to specify either ',
|
|
||||||
' "https.key", "https.cert" and "https.ca" or ',
|
|
||||||
' "https.pfx" and optionally "https.passphrase" ',
|
|
||||||
'to run https server',
|
|
||||||
'',
|
|
||||||
// commands are borrowed from node.js docs
|
|
||||||
'To quickly create self-signed certificate, use:',
|
|
||||||
' $ openssl genrsa -out ' + conf_path('verdaccio-key.pem') + ' 2048',
|
|
||||||
' $ openssl req -new -sha256 -key ' + conf_path('verdaccio-key.pem') + ' -out ' + conf_path('verdaccio-csr.pem'),
|
|
||||||
' $ openssl x509 -req -in ' + conf_path('verdaccio-csr.pem') +
|
|
||||||
' -signkey ' + conf_path('verdaccio-key.pem') + ' -out ' + conf_path('verdaccio-cert.pem'),
|
|
||||||
'',
|
|
||||||
'And then add to config file (' + conf_path() + '):',
|
|
||||||
' https:',
|
|
||||||
' key: verdaccio-key.pem',
|
|
||||||
' cert: verdaccio-cert.pem',
|
|
||||||
' ca: verdaccio-cert.pem',
|
|
||||||
].join('\n'));
|
|
||||||
process.exit(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const httpsOptions = {
|
|
||||||
secureProtocol: 'SSLv23_method', // disable insecure SSLv2 and SSLv3
|
|
||||||
secureOptions: constants.SSL_OP_NO_SSLv2 | constants.SSL_OP_NO_SSLv3,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (config.https.pfx) {
|
|
||||||
Object.assign(httpsOptions, {
|
|
||||||
pfx: fs.readFileSync(config.https.pfx),
|
|
||||||
passphrase: config.https.passphrase || '',
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
Object.assign(httpsOptions, {
|
|
||||||
key: fs.readFileSync(config.https.key),
|
|
||||||
cert: fs.readFileSync(config.https.cert),
|
|
||||||
ca: fs.readFileSync(config.https.ca),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
webServer = https.createServer(httpsOptions, app);
|
|
||||||
} catch (err) { // catch errors related to certificate loading
|
|
||||||
logger.logger.fatal({err: err}, 'cannot create server: @{err.message}');
|
|
||||||
process.exit(2);
|
|
||||||
}
|
|
||||||
} else { // http
|
|
||||||
webServer = http.createServer(app);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (addr.path && fs.existsSync(addr.path)) {
|
|
||||||
fs.unlinkSync(addr.path);
|
|
||||||
}
|
|
||||||
|
|
||||||
webServer
|
|
||||||
.listen(addr.port || addr.path, addr.host)
|
|
||||||
.on('error', function(err) {
|
|
||||||
logger.logger.fatal({err: err}, 'cannot create server: @{err.message}');
|
|
||||||
process.exit(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
logger.logger.warn({
|
|
||||||
addr: ( addr.path
|
|
||||||
? URL.format({
|
|
||||||
protocol: 'unix',
|
|
||||||
pathname: addr.path,
|
|
||||||
})
|
|
||||||
: URL.format({
|
|
||||||
protocol: addr.proto,
|
|
||||||
hostname: addr.host,
|
|
||||||
port: addr.port,
|
|
||||||
pathname: '/',
|
|
||||||
})
|
|
||||||
),
|
|
||||||
version: pkgName + '/' + pkgVersion,
|
|
||||||
}, 'http address - @{addr} - @{version}');
|
|
||||||
});
|
|
||||||
|
|
||||||
// undocumented stuff for tests
|
|
||||||
if (_.isFunction(process.send)) {
|
|
||||||
process.send({
|
|
||||||
verdaccio_started: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
process.on('uncaughtException', function(err) {
|
process.on('uncaughtException', function(err) {
|
||||||
logger.logger.fatal( {
|
logger.logger.fatal( {
|
||||||
|
|
|
@ -14,7 +14,8 @@
|
||||||
2,
|
2,
|
||||||
{
|
{
|
||||||
"allow": [
|
"allow": [
|
||||||
"log"
|
"log",
|
||||||
|
"error"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const Server = require('../lib/server');
|
import Server from '../lib/server';
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,8 @@ describe('functional test verdaccio', function() {
|
||||||
require('./lib/startup').start('./store/test-storage3', '/store/config-3.yaml'),
|
require('./lib/startup').start('./store/test-storage3', '/store/config-3.yaml'),
|
||||||
]).then(() => {
|
]).then(() => {
|
||||||
done();
|
done();
|
||||||
|
}).catch(function(error) {
|
||||||
|
console.error("error on start servers", error);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -76,7 +78,7 @@ describe('functional test verdaccio', function() {
|
||||||
require('./plugins/auth.spec')();
|
require('./plugins/auth.spec')();
|
||||||
require('./plugins/middleware.spec')();
|
require('./plugins/middleware.spec')();
|
||||||
require('./notifications/notify')();
|
require('./notifications/notify')();
|
||||||
// requires packages published to server1/server2
|
// // requires packages published to server1/server2
|
||||||
require('./uplink.cache.spec')();
|
require('./uplink.cache.spec')();
|
||||||
require('./uplink.auth.spec')();
|
require('./uplink.auth.spec')();
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const request = require('request');
|
const request = require('request');
|
||||||
const requestData = Symbol('smart_request_data');
|
const requestData = Symbol('smart_request_data');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|
||||||
class PromiseAssert extends Promise {
|
export class PromiseAssert extends Promise {
|
||||||
|
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
super(options);
|
super(options);
|
||||||
|
@ -96,7 +94,6 @@ function smartRequest(options) {
|
||||||
smartObject[requestData] = {};
|
smartObject[requestData] = {};
|
||||||
smartObject[requestData].error = Error();
|
smartObject[requestData].error = Error();
|
||||||
Error.captureStackTrace(smartObject[requestData].error, smartRequest);
|
Error.captureStackTrace(smartObject[requestData].error, smartRequest);
|
||||||
|
|
||||||
const result = new PromiseAssert(function(resolve, reject) {
|
const result = new PromiseAssert(function(resolve, reject) {
|
||||||
smartObject[requestData].request = request(options, function(err, res, body) {
|
smartObject[requestData].request = request(options, function(err, res, body) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -109,8 +106,10 @@ function smartRequest(options) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// console.log("--result->", result);
|
||||||
|
|
||||||
return injectResponse(smartObject, result);
|
return injectResponse(smartObject, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = smartRequest;
|
export default smartRequest;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const assert = require('assert');
|
|
||||||
const request = require('./request');
|
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
import assert from 'assert';
|
||||||
|
import request from './request';
|
||||||
|
|
||||||
const buildAuthHeader = (user, pass) => {
|
const buildAuthHeader = (user, pass) => {
|
||||||
return `Basic ${(new Buffer(`${user}:${pass}`)).toString('base64')}`;
|
return `Basic ${(new Buffer(`${user}:${pass}`)).toString('base64')}`;
|
||||||
|
@ -207,5 +206,4 @@ class Server {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
export default Server;
|
||||||
module.exports = Server;
|
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
import express from 'express';
|
||||||
|
import Server from './server';
|
||||||
|
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const fork = require('child_process').fork;
|
const fork = require('child_process').fork;
|
||||||
const bodyParser = require('body-parser');
|
const bodyParser = require('body-parser');
|
||||||
const express = require('express');
|
|
||||||
const rimRaf = require('rimraf');
|
const rimRaf = require('rimraf');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const Server = require('./server');
|
|
||||||
|
|
||||||
const forks = process.forks = [];
|
const forks = process.forks = [];
|
||||||
process.server = new Server('http://localhost:55551/');
|
process.server = new Server('http://localhost:55551/');
|
||||||
|
@ -24,6 +26,7 @@ module.exports.start = function(dir, conf) {
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
const storageDir = path.join(__dirname, `/../${dir}`);
|
const storageDir = path.join(__dirname, `/../${dir}`);
|
||||||
const configPath = path.join(__dirname, '../', conf);
|
const configPath = path.join(__dirname, '../', conf);
|
||||||
|
|
||||||
rimRaf(storageDir, function(err) {
|
rimRaf(storageDir, function(err) {
|
||||||
if(_.isNil(err) === false) {
|
if(_.isNil(err) === false) {
|
||||||
reject(err);
|
reject(err);
|
||||||
|
@ -32,12 +35,15 @@ module.exports.start = function(dir, conf) {
|
||||||
// filter out --debug-brk and --inspect-brk since Node7
|
// filter out --debug-brk and --inspect-brk since Node7
|
||||||
return (x.indexOf('--debug-brk') === -1 && x.indexOf('--inspect-brk') === -1);
|
return (x.indexOf('--debug-brk') === -1 && x.indexOf('--inspect-brk') === -1);
|
||||||
});
|
});
|
||||||
|
const url = path.join(__dirname, '/../../helper/verdaccio-test');
|
||||||
const childFork = fork(__dirname + '/../../../bin/verdaccio',
|
const childFork = fork(url,
|
||||||
['-c', configPath],
|
['-c', configPath],
|
||||||
{
|
{
|
||||||
silent: !process.env.TRAVIS
|
silent: !process.env.TRAVIS,
|
||||||
// silent: false
|
// silent: false,
|
||||||
|
env: {
|
||||||
|
BABEL_ENV: 'registry'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
6
test/helper/register.js
Normal file
6
test/helper/register.js
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
require("babel-polyfill");
|
||||||
|
require('babel-core/register')({
|
||||||
|
ignore: /node_modules\/(?!ProjectB)/,
|
||||||
|
sourceMap: 'inline',
|
||||||
|
});
|
||||||
|
require('../../src/lib/cli');
|
3
test/helper/verdaccio-test
Executable file
3
test/helper/verdaccio-test
Executable file
|
@ -0,0 +1,3 @@
|
||||||
|
#!/usr/bin/env node
|
||||||
|
require("babel-register");
|
||||||
|
require('../../src/lib/cli');
|
BIN
yarn.lock
BIN
yarn.lock
Binary file not shown.
Loading…
Reference in a new issue