2020-12-22 10:25:07 +01:00
|
|
|
const fs = require('fs');
|
|
|
|
const path = require('path');
|
|
|
|
|
|
|
|
const yalm = require('js-yaml');
|
2021-04-15 21:10:28 +02:00
|
|
|
const startServer = require('verdaccio').default;
|
2020-12-22 10:25:07 +01: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,
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
const serverHandler = function (webServer, addr, pkgName, pkgVersion) {
|
|
|
|
webServer.listen(addr.port || addr.path, addr.host, () => {
|
|
|
|
console.log(`${pkgName}:${pkgVersion} running ${addr.proto}://${addr.host}:${addr.port}`);
|
|
|
|
});
|
|
|
|
|
|
|
|
process.on('SIGTERM', () => {
|
|
|
|
webServer.close(() => {
|
|
|
|
console.log('verdaccio server has been shutdown');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
// https://verdaccio.org/docs/en/node-api
|
2021-04-15 21:10:28 +02:00
|
|
|
startServer(configJsonFormat, 8080, '', '1.0.0', 'verdaccio', serverHandler);
|