2019-04-06 22:42:52 +07:00
|
|
|
const fs = require('fs');
|
2019-10-08 03:19:18 +07:00
|
|
|
const path = require('path');
|
|
|
|
|
2019-04-06 22:42:52 +07:00
|
|
|
const startServer = require('verdaccio').default;
|
|
|
|
const yalm = require('js-yaml');
|
|
|
|
|
2019-08-04 15:17:43 +07:00
|
|
|
const storageLocation = path.join(__dirname, '../partials/storage');
|
|
|
|
const pluginsLocation = path.join(__dirname, '../partials/plugins');
|
|
|
|
const configJsonFormat = Object.assign({}, yalm.safeLoad(fs.readFileSync('./tools/_verdaccio.config.yaml', 'utf8')), {
|
|
|
|
storage: storageLocation,
|
|
|
|
plugins: pluginsLocation,
|
|
|
|
});
|
2019-04-06 22:42:52 +07:00
|
|
|
|
2019-08-04 15:17:43 +07:00
|
|
|
const serverHandler = function(webServer, addr, pkgName, pkgVersion) {
|
2019-04-06 22:42:52 +07:00
|
|
|
webServer.listen(addr.port || addr.path, addr.host, () => {
|
|
|
|
console.log(`${pkgName}:${pkgVersion} running ${addr.proto}://${addr.host}:${addr.port}`);
|
|
|
|
});
|
2019-04-06 22:51:26 +07:00
|
|
|
|
|
|
|
process.on('SIGTERM', () => {
|
|
|
|
webServer.close(() => {
|
2019-08-04 15:17:43 +07:00
|
|
|
console.log('verdaccio server has been shutdown');
|
2019-04-09 03:29:20 +07:00
|
|
|
});
|
|
|
|
});
|
2019-04-06 22:42:52 +07:00
|
|
|
};
|
|
|
|
|
2019-08-04 15:17:43 +07:00
|
|
|
// https://verdaccio.org/docs/en/node-api
|
|
|
|
startServer(configJsonFormat, 8080, '', '1.0.0', 'verdaccio', serverHandler);
|