From 3a63fba339cb0d2a5ad8c7a8655629e6d8b570b6 Mon Sep 17 00:00:00 2001 From: "Juan Picado @jotadeveloper" Date: Sat, 6 Apr 2019 17:51:26 +0200 Subject: [PATCH] chore: add verdaccio and webpack dev server script --- package.json | 7 +++++-- tools/verdaccio.js | 8 +++++++- yarn.lock | 42 ++++++++++++++++++++++++++++++++++++++---- 3 files changed, 50 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index e8b7245..21a10e2 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "autosuggest-highlight": "3.1.1", "bundlesize": "0.17.1", "codecov": "3.2.0", + "concurrently": "4.1.0", "cross-env": "5.2.0", "css-loader": "0.28.10", "date-fns": "1.30.1", @@ -113,8 +114,10 @@ "coverage:publish": "codecov", "lint:css": "stylelint 'src/webui/**/styles.js'", "pre:webpack": "rimraf static/*", - "dev": "cross-env BABEL_ENV=ui babel-node tools/dev.server.js", - "build": "npm run pre:webpack && cross-env BABEL_ENV=ui webpack --config tools/webpack.prod.config.babel.js" + "dev:web": "cross-env BABEL_ENV=ui babel-node tools/dev.server.js", + "verdaccio:server": "node tools/verdaccio.js", + "build": "npm run pre:webpack && cross-env BABEL_ENV=ui webpack --config tools/webpack.prod.config.babel.js", + "dev": "concurrently --kill-others \"npm run dev:web\" \"npm run verdaccio:server\"" }, "engines": { "node": ">=8", diff --git a/tools/verdaccio.js b/tools/verdaccio.js index 7da6fd6..9ae7698 100644 --- a/tools/verdaccio.js +++ b/tools/verdaccio.js @@ -2,12 +2,18 @@ const fs = require('fs'); const startServer = require('verdaccio').default; const yalm = require('js-yaml'); -const configJsonFormat = yalm.safeLoad(fs.readFileSync('./_config.yaml', 'utf8')); +const configJsonFormat = yalm.safeLoad(fs.readFileSync('./tools/_config.yaml', 'utf8')); const handler = 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('Process terminated') + }) + }) }; startServer(configJsonFormat, 8080, '', '1.0.0', 'verdaccio', handler); diff --git a/yarn.lock b/yarn.lock index 4272053..2d1bf89 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3519,6 +3519,21 @@ concat-stream@1.6.2, concat-stream@^1.4.10, concat-stream@^1.5.0: readable-stream "^2.2.2" typedarray "^0.0.6" +concurrently@4.1.0: + version "4.1.0" + resolved "https://registry.verdaccio.org/concurrently/-/concurrently-4.1.0.tgz#17fdf067da71210685d9ea554423ef239da30d33" + integrity sha512-pwzXCE7qtOB346LyO9eFWpkFJVO3JQZ/qU/feGeaAHiX1M3Rw3zgXKc5cZ8vSH5DGygkjzLFDzA/pwoQDkRNGg== + dependencies: + chalk "^2.4.1" + date-fns "^1.23.0" + lodash "^4.17.10" + read-pkg "^4.0.1" + rxjs "^6.3.3" + spawn-command "^0.0.2-1" + supports-color "^4.5.0" + tree-kill "^1.1.0" + yargs "^12.0.1" + connect-history-api-fallback@^1.3.0: version "1.6.0" resolved "https://registry.yarnpkg.com/connect-history-api-fallback/-/connect-history-api-fallback-1.6.0.tgz#8b32089359308d111115d81cad3fceab888f97bc" @@ -4226,7 +4241,7 @@ data-urls@^1.0.0: whatwg-mimetype "^2.2.0" whatwg-url "^7.0.0" -date-fns@1.30.1: +date-fns@1.30.1, date-fns@^1.23.0: version "1.30.1" resolved "https://registry.verdaccio.org/date-fns/-/date-fns-1.30.1.tgz#2e71bf0b119153dbb4cc4e88d9ea5acfb50dc05c" integrity sha512-hBSVCvSmWC+QypYObzwGOd9wqdDpOt+0wl0KbU+R+uuZBS1jN8VsD1ss3irQDknRj5NvxiTF6oj/nDRnN/UQNw== @@ -10972,6 +10987,15 @@ read-pkg@^3.0.0: normalize-package-data "^2.3.2" path-type "^3.0.0" +read-pkg@^4.0.1: + version "4.0.1" + resolved "https://registry.verdaccio.org/read-pkg/-/read-pkg-4.0.1.tgz#963625378f3e1c4d48c85872b5a6ec7d5d093237" + integrity sha1-ljYlN48+HE1IyFhytabsfV0JMjc= + dependencies: + normalize-package-data "^2.3.2" + parse-json "^4.0.0" + pify "^3.0.0" + "readable-stream@1 || 2", readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.4, readable-stream@^2.0.6, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.3.0, readable-stream@^2.3.3, readable-stream@^2.3.5, readable-stream@^2.3.6, readable-stream@~2.3.6: version "2.3.6" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf" @@ -11501,7 +11525,7 @@ run-queue@^1.0.0, run-queue@^1.0.3: dependencies: aproba "^1.1.1" -rxjs@^6.4.0: +rxjs@^6.3.3, rxjs@^6.4.0: version "6.4.0" resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.4.0.tgz#f3bb0fe7bda7fb69deac0c16f17b50b0b8790504" integrity sha512-Z9Yfa11F6B9Sg/BK9MnqnQ+aQYicPLtilXBp2yUtDt2JRCE0h26d33EnfO3ZxoNxG0T92OUucP3Ct7cpfkdFfw== @@ -11949,6 +11973,11 @@ source-map@^0.7.2, source-map@^0.7.3: resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383" integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ== +spawn-command@^0.0.2-1: + version "0.0.2-1" + resolved "https://registry.verdaccio.org/spawn-command/-/spawn-command-0.0.2-1.tgz#62f5e9466981c1b796dc5929937e11c9c6921bd0" + integrity sha1-YvXpRmmBwbeW3Fkpk34RycaSG9A= + spdx-correct@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.0.tgz#fb83e504445268f154b074e218c87c003cd31df4" @@ -12461,7 +12490,7 @@ supports-color@^3.2.3: dependencies: has-flag "^1.0.0" -supports-color@^4.0.0: +supports-color@^4.0.0, supports-color@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-4.5.0.tgz#be7a0de484dec5c5cddf8b3d59125044912f635b" integrity sha1-vnoN5ITexcXN34s9WRJQRJEvY1s= @@ -12781,6 +12810,11 @@ tr46@^1.0.1: dependencies: punycode "^2.1.0" +tree-kill@^1.1.0: + version "1.2.1" + resolved "https://registry.verdaccio.org/tree-kill/-/tree-kill-1.2.1.tgz#5398f374e2f292b9dcc7b2e71e30a5c3bb6c743a" + integrity sha512-4hjqbObwlh2dLyW4tcz0Ymw0ggoaVDMveUB9w8kFSQScdRLo0gxO9J7WFcUBo+W3C1TLdFIEwNOWebgZZ0RH9Q== + trim-newlines@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613" @@ -13715,7 +13749,7 @@ yargs@12.0.2: y18n "^3.2.1 || ^4.0.0" yargs-parser "^10.1.0" -yargs@^12.0.2, yargs@^12.0.4, yargs@^12.0.5: +yargs@^12.0.1, yargs@^12.0.2, yargs@^12.0.4, yargs@^12.0.5: version "12.0.5" resolved "https://registry.yarnpkg.com/yargs/-/yargs-12.0.5.tgz#05f5997b609647b64f66b81e3b4b10a368e7ad13" integrity sha512-Lhz8TLaYnxq/2ObqHDql8dX8CJi97oHxrjUcYtzKbbykPtVW9WB+poxI+NM2UIzsMgNCZTIf0AQwsjK5yMAqZw==