@verdaccio/node-api 6.0.0-6-next.21 → 6.0.0-6-next.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,59 @@
1
1
  # @verdaccio/node-api
2
2
 
3
+ ## 6.0.0-6-next.25
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [a828271d]
8
+ - Updated dependencies [24b9be02]
9
+ - Updated dependencies [e75c0a3b]
10
+ - @verdaccio/server@6.0.0-6-next.24
11
+ - @verdaccio/core@6.0.0-6-next.4
12
+ - @verdaccio/logger@6.0.0-6-next.8
13
+ - @verdaccio/config@6.0.0-6-next.12
14
+
15
+ ## 6.0.0-6-next.24
16
+
17
+ ### Patch Changes
18
+
19
+ - @verdaccio/server@6.0.0-6-next.23
20
+ - @verdaccio/config@6.0.0-6-next.11
21
+
22
+ ## 6.0.0-6-next.23
23
+
24
+ ### Minor Changes
25
+
26
+ - 6c1eb021: feat: use warning codes for deprecation warnings
27
+
28
+ ### Patch Changes
29
+
30
+ - Updated dependencies [6c1eb021]
31
+ - @verdaccio/core@6.0.0-6-next.3
32
+ - @verdaccio/logger@6.0.0-6-next.7
33
+ - @verdaccio/config@6.0.0-6-next.10
34
+ - @verdaccio/server@6.0.0-6-next.22
35
+
36
+ ## 6.0.0-6-next.22
37
+
38
+ ### Major Changes
39
+
40
+ - 794af76c: Remove Node 12 support
41
+
42
+ - We need move to the new `undici` and does not support Node.js 12
43
+
44
+ ### Minor Changes
45
+
46
+ - 154b2ecd: refactor: remove @verdaccio/commons-api in favor @verdaccio/core and remove duplications
47
+
48
+ ### Patch Changes
49
+
50
+ - Updated dependencies [794af76c]
51
+ - Updated dependencies [154b2ecd]
52
+ - @verdaccio/config@6.0.0-6-next.9
53
+ - @verdaccio/core@6.0.0-6-next.2
54
+ - @verdaccio/logger@6.0.0-6-next.6
55
+ - @verdaccio/server@6.0.0-6-next.21
56
+
3
57
  ## 6.0.0-6-next.21
4
58
 
5
59
  ### Patch Changes
@@ -3,9 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.parseAddress = parseAddress;
6
+ exports.DEFAULT_PROTOCOL = exports.DEFAULT_PORT = exports.DEFAULT_DOMAIN = void 0;
7
7
  exports.getListListenAddresses = getListListenAddresses;
8
- exports.DEFAULT_DOMAIN = exports.DEFAULT_PROTOCOL = exports.DEFAULT_PORT = void 0;
8
+ exports.parseAddress = parseAddress;
9
+
10
+ var _core = require("@verdaccio/core");
11
+
9
12
  const DEFAULT_PORT = '4873';
10
13
  exports.DEFAULT_PORT = DEFAULT_PORT;
11
14
  const DEFAULT_PROTOCOL = 'http';
@@ -86,9 +89,7 @@ function getListListenAddresses(argListen, configListen) {
86
89
  const parsedAddr = parseAddress(addr);
87
90
 
88
91
  if (!parsedAddr) {
89
- process.emitWarning( // eslint-disable-next-line max-len
90
- `invalid address - ${addr}, we expect a port (e.g. "4873"), host:port (e.g. "localhost:4873") or full url '(e.g. "http://localhost:4873/")`);
91
- process.emitWarning('https://verdaccio.org/docs/en/configuration#listen-port');
92
+ _core.warningUtils.emit(_core.warningUtils.Codes.VERWAR004, addr);
92
93
  }
93
94
 
94
95
  return parsedAddr;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cli-utils.ts"],"names":["DEFAULT_PORT","DEFAULT_PROTOCOL","DEFAULT_DOMAIN","parseAddress","urlAddress","urlPattern","exec","proto","host","port","path","getListListenAddresses","argListen","configListen","addresses","Array","isArray","process","emitWarning","map","addr","parsedAddr","filter","Boolean"],"mappings":";;;;;;;;AAAO,MAAMA,YAAY,GAAG,MAArB;;AACA,MAAMC,gBAAgB,GAAG,MAAzB;;AACA,MAAMC,cAAc,GAAG,WAAvB;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACO,SAASC,YAAT,CAAsBC,UAAtB,EAA4C;AACjD;AACA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Y,CAACiB,IAAD,CAA/B;;AAEA,QAAI,CAACC,UAAL,EAAiB;AACfJ,MAAAA,OAAO,CAACC,WAAR,EACE;AACC,2BAAoBE,IAAK,kHAF5B;AAIAH,MAAAA,OAAO,CAACC,WAAR,CAAoB,yDAApB;AACD;;AAED,WAAOG,UAAP;AACD,GAbS,EAcTC,MAdS,CAcFC,OAdE,CAAZ;AAgBA,SAAOT,SAAP;AACD","sourcesContent":["export const DEFAULT_PORT = '4873';\nexport const DEFAULT_PROTOCOL = 'http';\nexport const DEFAULT_DOMAIN = 'localhost';\n/**\n * Parse an internet address\n * Allow:\n - https:localhost:1234 - protocol + host + port\n - localhost:1234 - host + port\n - 1234 - port\n - http::1234 - protocol + port\n - https://localhost:443/ - full url + https\n - http://[::1]:443/ - ipv6\n - unix:/tmp/http.sock - unix sockets\n - https://unix:/tmp/http.sock - unix sockets (https)\n * @param {*} urlAddress the internet address definition\n * @return {Object|Null} literal object that represent the address parsed\n */\nexport function parseAddress(urlAddress: any): any {\n //\n // TODO: refactor it to something more reasonable?\n //\n // protocol : // ( host )|( ipv6 ): port /\n let urlPattern = /^((https?):(\\/\\/)?)?((([^\\/:]*)|\\[([^\\[\\]]+)\\]):)?(\\d+)\\/?$/.exec(urlAddress);\n\n if (urlPattern) {\n return {\n proto: urlPattern[2] || DEFAULT_PROTOCOL,\n host: urlPattern[6] || urlPattern[7] || DEFAULT_DOMAIN,\n port: urlPattern[8] || DEFAULT_PORT,\n };\n }\n\n urlPattern = /^((https?):(\\/\\/)?)?unix:(.*)$/.exec(urlAddress);\n\n if (urlPattern) {\n return {\n proto: urlPattern[2] || DEFAULT_PROTOCOL,\n path: urlPattern[4],\n };\n }\n\n return null;\n}\n\n/**\n * Retrieve all addresses defined in the config file.\n * Verdaccio is able to listen multiple ports\n * @param {String} argListen\n * @param {String} configListen\n * eg:\n * listen:\n - localhost:5555\n - localhost:5557\n @return {Array}\n */\nexport function getListListenAddresses(argListen: string | void, configListen: any): any {\n // command line || config file || default\n let addresses;\n if (argListen) {\n addresses = [argListen];\n } else if (Array.isArray(configListen)) {\n addresses = configListen;\n process.emitWarning('multiple addresses will be deprecated in the next major, only use one');\n } else if (configListen) {\n addresses = [configListen];\n } else {\n addresses = [DEFAULT_PORT];\n }\n addresses = addresses\n .map(function (addr): string {\n const parsedAddr = parseAddress(addr);\n\n if (!parsedAddr) {\n process.emitWarning(\n // eslint-disable-next-line max-len\n `invalid address - ${addr}, we expect a port (e.g. \"4873\"), host:port (e.g. \"localhost:4873\") or full url '(e.g. \"http://localhost:4873/\")`\n );\n process.emitWarning('https://verdaccio.org/docs/en/configuration#listen-port');\n }\n\n return parsedAddr;\n })\n .filter(Boolean);\n\n return addresses;\n}\n"],"file":"cli-utils.js"}
1
+ {"version":3,"sources":["../src/cli-utils.ts"],"names":["DEFAULT_PORT","DEFAULT_PROTOCOL","DEFAULT_DOMAIN","parseAddress","urlAddress","urlPattern","exec","proto","host","port","path","getListListenAddresses","argListen","configListen","addresses","Array","isArray","process","emitWarning","map","addr","parsedAddr","warningUtils","emit","Codes","VERWAR004","filter","Boolean"],"mappings":";;;;;;;;;AAAA;;AAEO,MAAMA,YAAY,GAAG,MAArB;;AACA,MAAMC,gBAAgB,GAAG,MAAzB;;AACA,MAAMC,cAAc,GAAG,WAAvB;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACO,SAASC,YAAT,CAAsBC,UAAtB,EAA4C;AACjD;AACA;AACA;AACA;AACA,MAAIC,UAAU,GAAG,8DAA8DC,IAA9D,CAAmEF,UAAnE,CAAjB;;AAEA,MAAIC,UAAJ,EAAgB;AACd,WAAO;AACLE,MAAAA,KAAK,EAAEF,UAAU,CAAC,CAAD,CAAV,IAAiBJ,gBADnB;AAELO,MAAAA,IAAI,EAAEH,UAAU,CAAC,CAAD,CAAV,IAAiBA,UAAU,CAAC,CAAD,CAA3B,IAAkCH,cAFnC;AAGLO,MAAAA,IAAI,EAAEJ,UAAU,CAAC,CAAD,CAAV,IAAiBL;AAHlB,KAAP;AAKD;;AAEDK,EAAAA,UAAU,GAAG,iCAAiCC,IAAjC,CAAsCF,UAAtC,CAAb;;AAEA,MAAIC,UAAJ,EAAgB;AACd,WAAO;AACLE,MAAAA,KAAK,EAAEF,UAAU,CAAC,CAAD,CAAV,IAAiBJ,gBADnB;AAELS,MAAAA,IAAI,EAAEL,UAAU,CAAC,CAAD;AAFX,KAAP;AAID;;AAED,SAAO,IAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASM,sBAAT,CAAgCC,SAAhC,EAA0DC,YAA1D,EAAkF;AACvF;AACA,MAAIC,SAAJ;;AACA,MAAIF,SAAJ,EAAe;AACbE,IAAAA,SAAS,GAAG,CAACF,SAAD,CAAZ;AACD,GAFD,MAEO,IAAIG,KAAK,CAACC,OAAN,CAAcH,YAAd,CAAJ,EAAiC;AACtCC,IAAAA,SAAS,GAAGD,YAAZ;AACAI,IAAAA,OAAO,CAACC,WAAR,CAAoB,uEAApB;AACD,GAHM,MAGA,IAAIL,YAAJ,EAAkB;AACvBC,IAAAA,SAAS,GAAG,CAACD,YAAD,CAAZ;AACD,GAFM,MAEA;AACLC,IAAAA,SAAS,GAAG,CAACd,YAAD,CAAZ;AACD;;AACDc,EAAAA,SAAS,GAAGA,SAAS,CAClBK,GADS,CACL,UAAUC,IAAV,EAAwB;AAC3B,UAAMC,UAAU,GAAGlB,YAAY,CAACiB,IAAD,CAA/B;;AAEA,QAAI,CAACC,UAAL,EAAiB;AACfC,yBAAaC,IAAb,CAAkBD,mBAAaE,KAAb,CAAmBC,SAArC,EAAgDL,IAAhD;AACD;;AAED,WAAOC,UAAP;AACD,GATS,EAUTK,MAVS,CAUFC,OAVE,CAAZ;AAYA,SAAOb,SAAP;AACD","sourcesContent":["import { warningUtils } from '@verdaccio/core';\n\nexport const DEFAULT_PORT = '4873';\nexport const DEFAULT_PROTOCOL = 'http';\nexport const DEFAULT_DOMAIN = 'localhost';\n/**\n * Parse an internet address\n * Allow:\n - https:localhost:1234 - protocol + host + port\n - localhost:1234 - host + port\n - 1234 - port\n - http::1234 - protocol + port\n - https://localhost:443/ - full url + https\n - http://[::1]:443/ - ipv6\n - unix:/tmp/http.sock - unix sockets\n - https://unix:/tmp/http.sock - unix sockets (https)\n * @param {*} urlAddress the internet address definition\n * @return {Object|Null} literal object that represent the address parsed\n */\nexport function parseAddress(urlAddress: any): any {\n //\n // TODO: refactor it to something more reasonable?\n //\n // protocol : // ( host )|( ipv6 ): port /\n let urlPattern = /^((https?):(\\/\\/)?)?((([^\\/:]*)|\\[([^\\[\\]]+)\\]):)?(\\d+)\\/?$/.exec(urlAddress);\n\n if (urlPattern) {\n return {\n proto: urlPattern[2] || DEFAULT_PROTOCOL,\n host: urlPattern[6] || urlPattern[7] || DEFAULT_DOMAIN,\n port: urlPattern[8] || DEFAULT_PORT,\n };\n }\n\n urlPattern = /^((https?):(\\/\\/)?)?unix:(.*)$/.exec(urlAddress);\n\n if (urlPattern) {\n return {\n proto: urlPattern[2] || DEFAULT_PROTOCOL,\n path: urlPattern[4],\n };\n }\n\n return null;\n}\n\n/**\n * Retrieve all addresses defined in the config file.\n * Verdaccio is able to listen multiple ports\n * @param {String} argListen\n * @param {String} configListen\n * eg:\n * listen:\n - localhost:5555\n - localhost:5557\n @return {Array}\n */\nexport function getListListenAddresses(argListen: string | void, configListen: any): any {\n // command line || config file || default\n let addresses;\n if (argListen) {\n addresses = [argListen];\n } else if (Array.isArray(configListen)) {\n addresses = configListen;\n process.emitWarning('multiple addresses will be deprecated in the next major, only use one');\n } else if (configListen) {\n addresses = [configListen];\n } else {\n addresses = [DEFAULT_PORT];\n }\n addresses = addresses\n .map(function (addr): string {\n const parsedAddr = parseAddress(addr);\n\n if (!parsedAddr) {\n warningUtils.emit(warningUtils.Codes.VERWAR004, addr);\n }\n\n return parsedAddr;\n })\n .filter(Boolean);\n\n return addresses;\n}\n"],"file":"cli-utils.js"}
package/build/server.js CHANGED
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- require("core-js/modules/esnext.weak-map.delete-all.js");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
@@ -9,23 +7,23 @@ exports.createServerFactory = createServerFactory;
9
7
  exports.initServer = initServer;
10
8
  exports.runServer = runServer;
11
9
 
12
- var _lodash = _interopRequireWildcard(require("lodash"));
13
-
14
- var _http = _interopRequireDefault(require("http"));
15
-
16
- var _https = _interopRequireDefault(require("https"));
17
-
18
10
  var _constants = _interopRequireDefault(require("constants"));
19
11
 
20
12
  var _debug = _interopRequireDefault(require("debug"));
21
13
 
22
14
  var _fs = _interopRequireDefault(require("fs"));
23
15
 
16
+ var _http = _interopRequireDefault(require("http"));
17
+
18
+ var _https = _interopRequireDefault(require("https"));
19
+
20
+ var _lodash = _interopRequireWildcard(require("lodash"));
21
+
24
22
  var _url = _interopRequireDefault(require("url"));
25
23
 
26
24
  var _config = require("@verdaccio/config");
27
25
 
28
- var _commonsApi = require("@verdaccio/commons-api");
26
+ var _core = require("@verdaccio/core");
29
27
 
30
28
  var _logger = require("@verdaccio/logger");
31
29
 
@@ -35,18 +33,13 @@ var _cliUtils = require("./cli-utils");
35
33
 
36
34
  var _experiments = require("./experiments");
37
35
 
38
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
39
-
40
36
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
41
37
 
42
38
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
43
39
 
44
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
45
-
46
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
47
-
48
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
40
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
49
41
 
42
+ /* eslint-disable */
50
43
  const debug = (0, _debug.default)('verdaccio:node-api');
51
44
 
52
45
  function unlinkAddressPath(addr) {
@@ -96,12 +89,13 @@ function createServerFactory(config, addr, app) {
96
89
  cert,
97
90
  ca
98
91
  } = keyCertConfig;
99
- httpsOptions = (0, _lodash.assign)(httpsOptions, _objectSpread({
92
+ httpsOptions = (0, _lodash.assign)(httpsOptions, {
100
93
  key: _fs.default.readFileSync(key),
101
- cert: _fs.default.readFileSync(cert)
102
- }, ca && {
103
- ca: _fs.default.readFileSync(ca)
104
- }));
94
+ cert: _fs.default.readFileSync(cert),
95
+ ...(ca && {
96
+ ca: _fs.default.readFileSync(ca)
97
+ })
98
+ });
105
99
  } // TODO: enable http2 as feature
106
100
  // if (config.server.http2) <-- check if force http2
107
101
 
@@ -176,9 +170,10 @@ async function initServer(config, port, version, pkgName) {
176
170
  });
177
171
  }
178
172
 
179
- process.on('SIGINT', handleShutdownGracefully);
180
- process.on('SIGTERM', handleShutdownGracefully);
181
- process.on('SIGHUP', handleShutdownGracefully);
173
+ for (const signal of ['SIGINT', 'SIGTERM', 'SIGHUP']) {
174
+ // Use once() so that receiving double signals exit the app.
175
+ process.once(signal, handleShutdownGracefully);
176
+ }
182
177
  });
183
178
  }
184
179
  /**
@@ -203,7 +198,7 @@ async function runServer(config) {
203
198
  } else if (_lodash.default.isObject(config)) {
204
199
  configurationParsed = config;
205
200
  } else {
206
- throw new Error(_commonsApi.API_ERROR.CONFIG_BAD_FORMAT);
201
+ throw new Error(_core.API_ERROR.CONFIG_BAD_FORMAT);
207
202
  }
208
203
 
209
204
  (0, _logger.setup)(configurationParsed.logs);
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/server.ts"],"names":["debug","unlinkAddressPath","addr","path","fs","existsSync","unlinkSync","createServerFactory","config","app","serverFactory","proto","httpsOptions","secureOptions","constants","SSL_OP_NO_SSLv2","SSL_OP_NO_SSLv3","keyCertConfig","https","pfxConfig","key","cert","pfx","Error","passphrase","readFileSync","ca","createServer","err","message","http","server","keepAliveTimeout","initServer","port","version","pkgName","Promise","resolve","reject","listen","logger","logs","flags","host","process","send","verdaccio_started","addressServer","url","format","protocol","pathname","hostname","info","on","exitCode","handleShutdownGracefully","fatal","close","exit","runServer","configurationParsed","undefined","configPathLocation","_","isObject","API_ERROR","CONFIG_BAD_FORMAT"],"mappings":";;;;;;;;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAEA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;AAEA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unction } from 'lodash';\nimport http from 'http';\nimport https from 'https';\nimport constants from 'constants';\nimport buildDebug from 'debug';\nimport fs from 'fs';\nimport url from 'url';\n\nimport { findConfigFile, parseConfigFile } from '@verdaccio/config';\nimport { API_ERROR } from '@verdaccio/commons-api';\nimport { ConfigRuntime, HttpsConfKeyCert, HttpsConfPfx } from '@verdaccio/types';\nimport { setup, logger } from '@verdaccio/logger';\nimport server from '@verdaccio/server';\nimport { getListListenAddresses } from './cli-utils';\nimport { displayExperimentsInfoBox } from './experiments';\n\nconst debug = buildDebug('verdaccio:node-api');\n\nfunction unlinkAddressPath(addr) {\n if (addr.path && fs.existsSync(addr.path)) {\n fs.unlinkSync(addr.path);\n }\n}\n\n/**\n * Return a native HTTP/HTTPS server instance\n * @param config\n * @param addr\n * @param app\n */\nexport function createServerFactory(config: ConfigRuntime, addr, app) {\n let serverFactory;\n if (addr.proto === 'https') {\n debug('https enabled');\n try {\n let httpsOptions = {\n // disable insecure SSLv2 and SSLv3\n secureOptions: constants.SSL_OP_NO_SSLv2 | constants.SSL_OP_NO_SSLv3,\n };\n\n const keyCertConfig = config.https as HttpsConfKeyCert;\n const pfxConfig = config.https as HttpsConfPfx;\n\n // https must either have key and cert or a pfx and (optionally) a passphrase\n if (!((keyCertConfig.key && keyCertConfig.cert) || pfxConfig.pfx)) {\n // logHTTPSError(configPath);\n throw Error('bad format https configuration');\n }\n\n if (pfxConfig.pfx) {\n const { pfx, passphrase } = pfxConfig;\n httpsOptions = assign(httpsOptions, {\n pfx: fs.readFileSync(pfx),\n passphrase: passphrase || '',\n });\n } else {\n const { key, cert, ca } = keyCertConfig;\n httpsOptions = assign(httpsOptions, {\n key: fs.readFileSync(key),\n cert: fs.readFileSync(cert),\n ...(ca && {\n ca: fs.readFileSync(ca),\n }),\n });\n }\n // TODO: enable http2 as feature\n // if (config.server.http2) <-- check if force http2\n serverFactory = https.createServer(httpsOptions, app);\n } catch (err: any) {\n throw new Error(`cannot create https server: ${err.message}`);\n }\n } else {\n // http\n debug('http enabled');\n serverFactory = http.createServer(app);\n }\n\n if (\n config.server &&\n typeof config.server.keepAliveTimeout !== 'undefined' &&\n // @ts-ignore\n config.server.keepAliveTimeout !== 'null'\n ) {\n // library definition for node is not up to date (doesn't contain recent 8.0 changes)\n serverFactory.keepAliveTimeout = config.server.keepAliveTimeout * 1000;\n }\n // FIXE: I could not find the reason of this code.\n unlinkAddressPath(addr);\n\n return serverFactory;\n}\n\n/**\n * Start the server on the port defined\n * @param config\n * @param port\n * @param version\n * @param pkgName\n */\nexport async function initServer(\n config: ConfigRuntime,\n port: string | void,\n version: string,\n pkgName: string\n): Promise<void> {\n return new Promise(async (resolve, reject) => {\n // FIXME: get only the first match, the multiple address will be removed\n const [addr] = getListListenAddresses(port, config.listen);\n const logger = setup((config as ConfigRuntime).logs);\n displayExperimentsInfoBox(config.flags);\n const app = await server(config);\n const serverFactory = createServerFactory(config, addr, app);\n serverFactory\n .listen(addr.port || addr.path, addr.host, (): void => {\n // send a message for test\n if (isFunction(process.send)) {\n process.send({\n verdaccio_started: true,\n });\n }\n const addressServer = `${\n addr.path\n ? url.format({\n protocol: 'unix',\n pathname: addr.path,\n })\n : url.format({\n protocol: addr.proto,\n hostname: addr.host,\n port: addr.port,\n pathname: '/',\n })\n }`;\n logger.info(`http address ${addressServer}`);\n logger.info(`version: ${version}`);\n resolve();\n })\n .on('error', function (err): void {\n reject(err);\n process.exitCode = 1;\n });\n\n function handleShutdownGracefully() {\n logger.fatal('received shutdown signal - closing server gracefully...');\n serverFactory.close(() => {\n logger.info('server closed.');\n process.exit(0);\n });\n }\n\n process.on('SIGINT', handleShutdownGracefully);\n process.on('SIGTERM', handleShutdownGracefully);\n process.on('SIGHUP', handleShutdownGracefully);\n });\n}\n\n/**\n * Exposes a server factory to be instantiated programmatically.\n *\n const app = await runServer(); // default configuration\n const app = await runServer('./config/config.yaml');\n const app = await runServer({ configuration });\n app.listen(4000, (event) => {\n // do something\n });\n * @param config\n */\nexport async function runServer(config?: string | ConfigRuntime): Promise<any> {\n let configurationParsed: ConfigRuntime;\n if (config === undefined || typeof config === 'string') {\n const configPathLocation = findConfigFile(config);\n configurationParsed = parseConfigFile(configPathLocation);\n } else if (_.isObject(config)) {\n configurationParsed = config;\n } else {\n throw new Error(API_ERROR.CONFIG_BAD_FORMAT);\n }\n\n setup(configurationParsed.logs);\n displayExperimentsInfoBox(configurationParsed.flags);\n // FIXME: get only the first match, the multiple address will be removed\n const [addr] = getListListenAddresses(undefined, configurationParsed.listen);\n const app = await server(configurationParsed);\n return createServerFactory(configurationParsed, addr, app);\n}\n"],"file":"server.js"}
1
+ {"version":3,"sources":["../src/server.ts"],"names":["debug","unlinkAddressPath","addr","path","fs","existsSync","unlinkSync","createServerFactory","config","app","serverFactory","proto","httpsOptions","secureOptions","constants","SSL_OP_NO_SSLv2","SSL_OP_NO_SSLv3","keyCertConfig","https","pfxConfig","key","cert","pfx","Error","passphrase","readFileSync","ca","createServer","err","message","http","server","keepAliveTimeout","initServer","port","version","pkgName","Promise","resolve","reject","listen","logger","logs","flags","host","process","send","verdaccio_started","addressServer","url","format","protocol","pathname","hostname","info","on","exitCode","handleShutdownGracefully","fatal","close","exit","signal","once","runServer","configurationParsed","undefined","configPathLocation","_","isObject","API_ERROR","CONFIG_BAD_FORMAT"],"mappings":";;;;;;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAGA;;AACA;;;;;;;;AAhBA;AAkBA,MAAMA,KAAK,GAAG,oBAAW,oBAAX,CAAd;;AAEA,SAASC,iBAAT,CAA2BC,IAA3B,EAAiC;AAC/B,MAAIA,IAAI,CAACC,IAAL,IAAaC,YAAGC,UAAH,CAAcH,IAAI,CAACC,IAAnB,CAAjB,EAA2C;AACzCC,gBAAGE,UAAH,CAAcJ,IAAI,CAACC,IAAnB;AACD;AACF;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASI,mBAAT,CAA6BC,MAA7B,EAAoDN,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AhB,MAAAA,OAAO,CAACiB,IAAR,CAAaD,MAAb,EAAqBJ,wBAArB;AACD;AACF,GAjDM,CAAP;AAkDD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,eAAeM,SAAf,CAAyBvD,MAAzB,EAAwE;AAC7E,MAAIwD,mBAAJ;;AACA,MAAIxD,MAAM,KAAKyD,SAAX,IAAwB,OAAOzD,MAAP,KAAkB,QAA9C,EAAwD;AACtD,UAAM0D,kBAAkB,GAAG,4BAAe1D,MAAf,CAA3B;AACAwD,IAAAA,mBAAmB,GAAG,6BAAgBE,kBAAhB,CAAtB;AACD,GAHD,MAGO,IAAIC,gBAAEC,QAAF,CAAW5D,MAAX,CAAJ,EAAwB;AAC7BwD,IAAAA,mBAAmB,GAAGxD,MAAtB;AACD,GAFM,MAEA;AACL,UAAM,IAAIe,KAAJ,CAAU8C,gBAAUC,iBAApB,CAAN;AACD;;AAED,qBAAMN,mBAAmB,CAACtB,IAA1B;AACA,8CAA0BsB,mBAAmB,CAACrB,KAA9C,EAZ6E,CAa7E;;AACA,QAAM,CAACzC,IAAD,IAAS,sCAAuB+D,SAAvB,EAAkCD,mBAAmB,CAACxB,MAAtD,CAAf;AACA,QAAM/B,GAAG,GAAG,MAAM,qBAAOuD,mBAAP,CAAlB;AACA,SAAOzD,mBAAmB,CAACyD,mBAAD,EAAsB9D,IAAtB,EAA4BO,GAA5B,CAA1B;AACD","sourcesContent":["/* eslint-disable */\nimport constants from 'constants';\nimport buildDebug from 'debug';\nimport fs from 'fs';\nimport http from 'http';\nimport https from 'https';\nimport _, { assign, isFunction } from 'lodash';\nimport url from 'url';\n\nimport { findConfigFile, parseConfigFile } from '@verdaccio/config';\nimport { API_ERROR } from '@verdaccio/core';\nimport { logger, setup } from '@verdaccio/logger';\nimport server from '@verdaccio/server';\nimport { ConfigRuntime, HttpsConfKeyCert, HttpsConfPfx } from '@verdaccio/types';\n\nimport { getListListenAddresses } from './cli-utils';\nimport { displayExperimentsInfoBox } from './experiments';\n\nconst debug = buildDebug('verdaccio:node-api');\n\nfunction unlinkAddressPath(addr) {\n if (addr.path && fs.existsSync(addr.path)) {\n fs.unlinkSync(addr.path);\n }\n}\n\n/**\n * Return a native HTTP/HTTPS server instance\n * @param config\n * @param addr\n * @param app\n */\nexport function createServerFactory(config: ConfigRuntime, addr, app) {\n let serverFactory;\n if (addr.proto === 'https') {\n debug('https enabled');\n try {\n let httpsOptions = {\n // disable insecure SSLv2 and SSLv3\n secureOptions: constants.SSL_OP_NO_SSLv2 | constants.SSL_OP_NO_SSLv3,\n };\n\n const keyCertConfig = config.https as HttpsConfKeyCert;\n const pfxConfig = config.https as HttpsConfPfx;\n\n // https must either have key and cert or a pfx and (optionally) a passphrase\n if (!((keyCertConfig.key && keyCertConfig.cert) || pfxConfig.pfx)) {\n // logHTTPSError(configPath);\n throw Error('bad format https configuration');\n }\n\n if (pfxConfig.pfx) {\n const { pfx, passphrase } = pfxConfig;\n httpsOptions = assign(httpsOptions, {\n pfx: fs.readFileSync(pfx),\n passphrase: passphrase || '',\n });\n } else {\n const { key, cert, ca } = keyCertConfig;\n httpsOptions = assign(httpsOptions, {\n key: fs.readFileSync(key),\n cert: fs.readFileSync(cert),\n ...(ca && {\n ca: fs.readFileSync(ca),\n }),\n });\n }\n // TODO: enable http2 as feature\n // if (config.server.http2) <-- check if force http2\n serverFactory = https.createServer(httpsOptions, app);\n } catch (err: any) {\n throw new Error(`cannot create https server: ${err.message}`);\n }\n } else {\n // http\n debug('http enabled');\n serverFactory = http.createServer(app);\n }\n\n if (\n config.server &&\n typeof config.server.keepAliveTimeout !== 'undefined' &&\n // @ts-ignore\n config.server.keepAliveTimeout !== 'null'\n ) {\n // library definition for node is not up to date (doesn't contain recent 8.0 changes)\n serverFactory.keepAliveTimeout = config.server.keepAliveTimeout * 1000;\n }\n // FIXE: I could not find the reason of this code.\n unlinkAddressPath(addr);\n\n return serverFactory;\n}\n\n/**\n * Start the server on the port defined\n * @param config\n * @param port\n * @param version\n * @param pkgName\n */\nexport async function initServer(\n config: ConfigRuntime,\n port: string | void,\n version: string,\n pkgName: string\n): Promise<void> {\n return new Promise(async (resolve, reject) => {\n // FIXME: get only the first match, the multiple address will be removed\n const [addr] = getListListenAddresses(port, config.listen);\n const logger = setup((config as ConfigRuntime).logs);\n displayExperimentsInfoBox(config.flags);\n const app = await server(config);\n const serverFactory = createServerFactory(config, addr, app);\n serverFactory\n .listen(addr.port || addr.path, addr.host, (): void => {\n // send a message for test\n if (isFunction(process.send)) {\n process.send({\n verdaccio_started: true,\n });\n }\n const addressServer = `${\n addr.path\n ? url.format({\n protocol: 'unix',\n pathname: addr.path,\n })\n : url.format({\n protocol: addr.proto,\n hostname: addr.host,\n port: addr.port,\n pathname: '/',\n })\n }`;\n logger.info(`http address ${addressServer}`);\n logger.info(`version: ${version}`);\n resolve();\n })\n .on('error', function (err): void {\n reject(err);\n process.exitCode = 1;\n });\n\n function handleShutdownGracefully() {\n logger.fatal('received shutdown signal - closing server gracefully...');\n serverFactory.close(() => {\n logger.info('server closed.');\n process.exit(0);\n });\n }\n\n for (const signal of ['SIGINT', 'SIGTERM', 'SIGHUP']) {\n // Use once() so that receiving double signals exit the app.\n process.once(signal, handleShutdownGracefully);\n }\n });\n}\n\n/**\n * Exposes a server factory to be instantiated programmatically.\n *\n const app = await runServer(); // default configuration\n const app = await runServer('./config/config.yaml');\n const app = await runServer({ configuration });\n app.listen(4000, (event) => {\n // do something\n });\n * @param config\n */\nexport async function runServer(config?: string | ConfigRuntime): Promise<any> {\n let configurationParsed: ConfigRuntime;\n if (config === undefined || typeof config === 'string') {\n const configPathLocation = findConfigFile(config);\n configurationParsed = parseConfigFile(configPathLocation);\n } else if (_.isObject(config)) {\n configurationParsed = config;\n } else {\n throw new Error(API_ERROR.CONFIG_BAD_FORMAT);\n }\n\n setup(configurationParsed.logs);\n displayExperimentsInfoBox(configurationParsed.flags);\n // FIXME: get only the first match, the multiple address will be removed\n const [addr] = getListListenAddresses(undefined, configurationParsed.listen);\n const app = await server(configurationParsed);\n return createServerFactory(configurationParsed, addr, app);\n}\n"],"file":"server.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdaccio/node-api",
3
- "version": "6.0.0-6-next.21",
3
+ "version": "6.0.0-6-next.25",
4
4
  "description": "node API",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -25,23 +25,23 @@
25
25
  "verdaccio"
26
26
  ],
27
27
  "engines": {
28
- "node": ">=12",
28
+ "node": ">=14",
29
29
  "npm": ">=6"
30
30
  },
31
31
  "license": "MIT",
32
32
  "dependencies": {
33
- "@verdaccio/commons-api": "11.0.0-6-next.4",
34
- "@verdaccio/config": "6.0.0-6-next.8",
35
- "@verdaccio/logger": "6.0.0-6-next.5",
36
- "@verdaccio/server": "6.0.0-6-next.20",
33
+ "@verdaccio/core": "6.0.0-6-next.4",
34
+ "@verdaccio/config": "6.0.0-6-next.12",
35
+ "@verdaccio/logger": "6.0.0-6-next.8",
36
+ "@verdaccio/server": "6.0.0-6-next.24",
37
37
  "core-js": "3.17.2",
38
- "debug": "4.3.2",
38
+ "debug": "4.3.3",
39
39
  "lodash": "4.17.21"
40
40
  },
41
41
  "devDependencies": {
42
- "@types/node": "16.9.1",
43
- "@verdaccio/mock": "6.0.0-6-next.9",
44
- "@verdaccio/types": "11.0.0-6-next.8",
42
+ "@types/node": "16.11.12",
43
+ "@verdaccio/mock": "6.0.0-6-next.13",
44
+ "@verdaccio/types": "11.0.0-6-next.10",
45
45
  "jest-mock-process": "1.4.1",
46
46
  "selfsigned": "1.10.11",
47
47
  "supertest": "6.1.6"
package/src/cli-utils.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { warningUtils } from '@verdaccio/core';
2
+
1
3
  export const DEFAULT_PORT = '4873';
2
4
  export const DEFAULT_PROTOCOL = 'http';
3
5
  export const DEFAULT_DOMAIN = 'localhost';
@@ -71,11 +73,7 @@ export function getListListenAddresses(argListen: string | void, configListen: a
71
73
  const parsedAddr = parseAddress(addr);
72
74
 
73
75
  if (!parsedAddr) {
74
- process.emitWarning(
75
- // eslint-disable-next-line max-len
76
- `invalid address - ${addr}, we expect a port (e.g. "4873"), host:port (e.g. "localhost:4873") or full url '(e.g. "http://localhost:4873/")`
77
- );
78
- process.emitWarning('https://verdaccio.org/docs/en/configuration#listen-port');
76
+ warningUtils.emit(warningUtils.Codes.VERWAR004, addr);
79
77
  }
80
78
 
81
79
  return parsedAddr;
package/src/server.ts CHANGED
@@ -1,17 +1,18 @@
1
1
  /* eslint-disable */
2
- import _, { assign, isFunction } from 'lodash';
3
- import http from 'http';
4
- import https from 'https';
5
2
  import constants from 'constants';
6
3
  import buildDebug from 'debug';
7
4
  import fs from 'fs';
5
+ import http from 'http';
6
+ import https from 'https';
7
+ import _, { assign, isFunction } from 'lodash';
8
8
  import url from 'url';
9
9
 
10
10
  import { findConfigFile, parseConfigFile } from '@verdaccio/config';
11
- import { API_ERROR } from '@verdaccio/commons-api';
12
- import { ConfigRuntime, HttpsConfKeyCert, HttpsConfPfx } from '@verdaccio/types';
13
- import { setup, logger } from '@verdaccio/logger';
11
+ import { API_ERROR } from '@verdaccio/core';
12
+ import { logger, setup } from '@verdaccio/logger';
14
13
  import server from '@verdaccio/server';
14
+ import { ConfigRuntime, HttpsConfKeyCert, HttpsConfPfx } from '@verdaccio/types';
15
+
15
16
  import { getListListenAddresses } from './cli-utils';
16
17
  import { displayExperimentsInfoBox } from './experiments';
17
18
 
@@ -149,9 +150,10 @@ export async function initServer(
149
150
  });
150
151
  }
151
152
 
152
- process.on('SIGINT', handleShutdownGracefully);
153
- process.on('SIGTERM', handleShutdownGracefully);
154
- process.on('SIGHUP', handleShutdownGracefully);
153
+ for (const signal of ['SIGINT', 'SIGTERM', 'SIGHUP']) {
154
+ // Use once() so that receiving double signals exit the app.
155
+ process.once(signal, handleShutdownGracefully);
156
+ }
155
157
  });
156
158
  }
157
159
 
@@ -1,4 +1,5 @@
1
1
  import _ from 'lodash';
2
+
2
3
  import {
3
4
  DEFAULT_DOMAIN,
4
5
  DEFAULT_PORT,
@@ -1,4 +1,5 @@
1
1
  import _ from 'lodash';
2
+
2
3
  import { DEFAULT_DOMAIN, DEFAULT_PORT, parseAddress } from '../src/cli-utils';
3
4
 
4
5
  describe('Parse listen address', () => {
@@ -1,5 +1,7 @@
1
1
  import request from 'supertest';
2
+
2
3
  import { runServer } from '../src';
4
+
3
5
  describe('startServer via API', () => {
4
6
  test('should provide all HTTP server data', async () => {
5
7
  const webServer = await runServer();