@verdaccio/node-api 6.0.0-6-next.51 → 6.0.0-6-next.52
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 +10 -0
- package/build/cli-utils.js +1 -14
- package/build/cli-utils.js.map +1 -1
- package/build/experiments.js +2 -6
- package/build/experiments.js.map +1 -1
- package/build/index.js +0 -1
- package/build/index.js.map +1 -1
- package/build/server.js +14 -45
- package/build/server.js.map +1 -1
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @verdaccio/node-api
|
|
2
2
|
|
|
3
|
+
## 6.0.0-6-next.52
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @verdaccio/core@6.0.0-6-next.52
|
|
8
|
+
- @verdaccio/config@6.0.0-6-next.52
|
|
9
|
+
- @verdaccio/logger@6.0.0-6-next.20
|
|
10
|
+
- @verdaccio/server@6.0.0-6-next.41
|
|
11
|
+
- @verdaccio/server-fastify@6.0.0-6-next.33
|
|
12
|
+
|
|
3
13
|
## 6.0.0-6-next.51
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
package/build/cli-utils.js
CHANGED
|
@@ -6,9 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.DEFAULT_PROTOCOL = exports.DEFAULT_PORT = exports.DEFAULT_DOMAIN = void 0;
|
|
7
7
|
exports.getListListenAddresses = getListListenAddresses;
|
|
8
8
|
exports.parseAddress = parseAddress;
|
|
9
|
-
|
|
10
9
|
var _core = require("@verdaccio/core");
|
|
11
|
-
|
|
12
10
|
const DEFAULT_PORT = '4873';
|
|
13
11
|
exports.DEFAULT_PORT = DEFAULT_PORT;
|
|
14
12
|
const DEFAULT_PROTOCOL = 'http';
|
|
@@ -28,16 +26,13 @@ const DEFAULT_DOMAIN = 'localhost';
|
|
|
28
26
|
* @param {*} urlAddress the internet address definition
|
|
29
27
|
* @return {Object|Null} literal object that represent the address parsed
|
|
30
28
|
*/
|
|
31
|
-
|
|
32
29
|
exports.DEFAULT_DOMAIN = DEFAULT_DOMAIN;
|
|
33
|
-
|
|
34
30
|
function parseAddress(urlAddress) {
|
|
35
31
|
//
|
|
36
32
|
// TODO: refactor it to something more reasonable?
|
|
37
33
|
//
|
|
38
34
|
// protocol : // ( host )|( ipv6 ): port /
|
|
39
35
|
let urlPattern = /^((https?):(\/\/)?)?((([^\/:]*)|\[([^\[\]]+)\]):)?(\d+)\/?$/.exec(urlAddress);
|
|
40
|
-
|
|
41
36
|
if (urlPattern) {
|
|
42
37
|
return {
|
|
43
38
|
proto: urlPattern[2] || DEFAULT_PROTOCOL,
|
|
@@ -45,18 +40,16 @@ function parseAddress(urlAddress) {
|
|
|
45
40
|
port: urlPattern[8] || DEFAULT_PORT
|
|
46
41
|
};
|
|
47
42
|
}
|
|
48
|
-
|
|
49
43
|
urlPattern = /^((https?):(\/\/)?)?unix:(.*)$/.exec(urlAddress);
|
|
50
|
-
|
|
51
44
|
if (urlPattern) {
|
|
52
45
|
return {
|
|
53
46
|
proto: urlPattern[2] || DEFAULT_PROTOCOL,
|
|
54
47
|
path: urlPattern[4]
|
|
55
48
|
};
|
|
56
49
|
}
|
|
57
|
-
|
|
58
50
|
return null;
|
|
59
51
|
}
|
|
52
|
+
|
|
60
53
|
/**
|
|
61
54
|
* Retrieve all addresses defined in the config file.
|
|
62
55
|
* Verdaccio is able to listen multiple ports
|
|
@@ -68,12 +61,9 @@ function parseAddress(urlAddress) {
|
|
|
68
61
|
- localhost:5557
|
|
69
62
|
@return {Array}
|
|
70
63
|
*/
|
|
71
|
-
|
|
72
|
-
|
|
73
64
|
function getListListenAddresses(argListen, configListen) {
|
|
74
65
|
// command line || config file || default
|
|
75
66
|
let addresses;
|
|
76
|
-
|
|
77
67
|
if (argListen) {
|
|
78
68
|
addresses = [argListen];
|
|
79
69
|
} else if (Array.isArray(configListen)) {
|
|
@@ -84,14 +74,11 @@ function getListListenAddresses(argListen, configListen) {
|
|
|
84
74
|
} else {
|
|
85
75
|
addresses = [DEFAULT_PORT];
|
|
86
76
|
}
|
|
87
|
-
|
|
88
77
|
addresses = addresses.map(function (addr) {
|
|
89
78
|
const parsedAddr = parseAddress(addr);
|
|
90
|
-
|
|
91
79
|
if (!parsedAddr) {
|
|
92
80
|
_core.warningUtils.emit(_core.warningUtils.Codes.VERWAR004, addr);
|
|
93
81
|
}
|
|
94
|
-
|
|
95
82
|
return parsedAddr;
|
|
96
83
|
}).filter(Boolean);
|
|
97
84
|
return addresses;
|
package/build/cli-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-utils.js","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"],"sources":["../src/cli-utils.ts"],"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"],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli-utils.js","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"],"sources":["../src/cli-utils.ts"],"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"],"mappings":";;;;;;;;AAAA;AAEO,MAAMA,YAAY,GAAG,MAAM;AAAC;AAC5B,MAAMC,gBAAgB,GAAG,MAAM;AAAC;AAChC,MAAMC,cAAc,GAAG,WAAW;AACzC;AACA;AACA;AACA;AACA;AACA;A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I,CAAC;IAErC,IAAI,CAACC,UAAU,EAAE;MACfC,kBAAY,CAACC,IAAI,CAACD,kBAAY,CAACE,KAAK,CAACC,SAAS,EAAEL,IAAI,CAAC;IACvD;IAEA,OAAOC,UAAU;EACnB,CAAC,CAAC,CACDK,MAAM,CAACC,OAAO,CAAC;EAElB,OAAOb,SAAS;AAClB"}
|
package/build/experiments.js
CHANGED
|
@@ -4,20 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.displayExperimentsInfoBox = displayExperimentsInfoBox;
|
|
7
|
-
|
|
8
7
|
var _logger = require("@verdaccio/logger");
|
|
9
|
-
|
|
10
8
|
function displayExperimentsInfoBox(flags) {
|
|
11
9
|
if (!flags) {
|
|
12
10
|
return;
|
|
13
11
|
}
|
|
14
|
-
|
|
15
12
|
const experimentList = Object.keys(flags);
|
|
16
|
-
|
|
17
13
|
if (experimentList.length >= 1) {
|
|
18
|
-
_logger.logger.warn(
|
|
14
|
+
_logger.logger.warn(
|
|
15
|
+
// eslint-disable-next-line max-len
|
|
19
16
|
`experiments are enabled, it is recommended do not use experiments in production comment out this section to disable it`);
|
|
20
|
-
|
|
21
17
|
experimentList.forEach(experiment => {
|
|
22
18
|
// eslint-disable-next-line max-len
|
|
23
19
|
_logger.logger.info(`support for experiment [${experiment}] ${flags[experiment] ? 'is enabled' : ' is disabled'}`);
|
package/build/experiments.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"experiments.js","names":["displayExperimentsInfoBox","flags","experimentList","Object","keys","length","logger","warn","forEach","experiment","info"],"sources":["../src/experiments.ts"],"sourcesContent":["import { logger } from '@verdaccio/logger';\n\nexport function displayExperimentsInfoBox(flags) {\n if (!flags) {\n return;\n }\n\n const experimentList = Object.keys(flags);\n if (experimentList.length >= 1) {\n logger.warn(\n // eslint-disable-next-line max-len\n `experiments are enabled, it is recommended do not use experiments in production comment out this section to disable it`\n );\n experimentList.forEach((experiment) => {\n // eslint-disable-next-line max-len\n logger.info(\n `support for experiment [${experiment}] ${\n flags[experiment] ? 'is enabled' : ' is disabled'\n }`\n );\n });\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"experiments.js","names":["displayExperimentsInfoBox","flags","experimentList","Object","keys","length","logger","warn","forEach","experiment","info"],"sources":["../src/experiments.ts"],"sourcesContent":["import { logger } from '@verdaccio/logger';\n\nexport function displayExperimentsInfoBox(flags) {\n if (!flags) {\n return;\n }\n\n const experimentList = Object.keys(flags);\n if (experimentList.length >= 1) {\n logger.warn(\n // eslint-disable-next-line max-len\n `experiments are enabled, it is recommended do not use experiments in production comment out this section to disable it`\n );\n experimentList.forEach((experiment) => {\n // eslint-disable-next-line max-len\n logger.info(\n `support for experiment [${experiment}] ${\n flags[experiment] ? 'is enabled' : ' is disabled'\n }`\n );\n });\n }\n}\n"],"mappings":";;;;;;AAAA;AAEO,SAASA,yBAAyB,CAACC,KAAK,EAAE;EAC/C,IAAI,CAACA,KAAK,EAAE;IACV;EACF;EAEA,MAAMC,cAAc,GAAGC,MAAM,CAACC,IAAI,CAACH,KAAK,CAAC;EACzC,IAAIC,cAAc,CAACG,MAAM,IAAI,CAAC,EAAE;IAC9BC,cAAM,CAACC,IAAI;IACT;IACC,wHAAuH,CACzH;IACDL,cAAc,CAACM,OAAO,CAAEC,UAAU,IAAK;MACrC;MACAH,cAAM,CAACI,IAAI,CACR,2BAA0BD,UAAW,KACpCR,KAAK,CAACQ,UAAU,CAAC,GAAG,YAAY,GAAG,cACpC,EAAC,CACH;IACH,CAAC,CAAC;EACJ;AACF"}
|
package/build/index.js
CHANGED
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export { initServer, runServer } from './server';\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export { initServer, runServer } from './server';\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA"}
|
package/build/server.js
CHANGED
|
@@ -6,76 +6,55 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.createServerFactory = createServerFactory;
|
|
7
7
|
exports.initServer = initServer;
|
|
8
8
|
exports.runServer = runServer;
|
|
9
|
-
|
|
10
9
|
var _constants = _interopRequireDefault(require("constants"));
|
|
11
|
-
|
|
12
10
|
var _debug = _interopRequireDefault(require("debug"));
|
|
13
|
-
|
|
14
11
|
var _fs = _interopRequireDefault(require("fs"));
|
|
15
|
-
|
|
16
12
|
var _http = _interopRequireDefault(require("http"));
|
|
17
|
-
|
|
18
13
|
var _https = _interopRequireDefault(require("https"));
|
|
19
|
-
|
|
20
14
|
var _lodash = _interopRequireWildcard(require("lodash"));
|
|
21
|
-
|
|
22
15
|
var _url = _interopRequireDefault(require("url"));
|
|
23
|
-
|
|
24
16
|
var _config = require("@verdaccio/config");
|
|
25
|
-
|
|
26
17
|
var _core = require("@verdaccio/core");
|
|
27
|
-
|
|
28
18
|
var _logger = require("@verdaccio/logger");
|
|
29
|
-
|
|
30
19
|
var _server = _interopRequireDefault(require("@verdaccio/server"));
|
|
31
|
-
|
|
32
20
|
var _serverFastify = _interopRequireDefault(require("@verdaccio/server-fastify"));
|
|
33
|
-
|
|
34
21
|
var _cliUtils = require("./cli-utils");
|
|
35
|
-
|
|
36
22
|
var _experiments = require("./experiments");
|
|
37
|
-
|
|
38
23
|
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); }
|
|
39
|
-
|
|
40
24
|
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; }
|
|
41
|
-
|
|
42
25
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
43
|
-
|
|
44
26
|
/* eslint-disable */
|
|
45
|
-
const debug = (0, _debug.default)('verdaccio:node-api');
|
|
46
27
|
|
|
28
|
+
const debug = (0, _debug.default)('verdaccio:node-api');
|
|
47
29
|
function unlinkAddressPath(addr) {
|
|
48
30
|
if (addr.path && _fs.default.existsSync(addr.path)) {
|
|
49
31
|
_fs.default.unlinkSync(addr.path);
|
|
50
32
|
}
|
|
51
33
|
}
|
|
34
|
+
|
|
52
35
|
/**
|
|
53
36
|
* Return a native HTTP/HTTPS server instance
|
|
54
37
|
* @param config
|
|
55
38
|
* @param addr
|
|
56
39
|
* @param app
|
|
57
40
|
*/
|
|
58
|
-
|
|
59
|
-
|
|
60
41
|
function createServerFactory(config, addr, app) {
|
|
61
42
|
let serverFactory;
|
|
62
|
-
|
|
63
43
|
if (addr.proto === 'https') {
|
|
64
44
|
debug('https enabled');
|
|
65
|
-
|
|
66
45
|
try {
|
|
67
46
|
let httpsOptions = {
|
|
68
47
|
// disable insecure SSLv2 and SSLv3
|
|
69
48
|
secureOptions: _constants.default.SSL_OP_NO_SSLv2 | _constants.default.SSL_OP_NO_SSLv3
|
|
70
49
|
};
|
|
71
50
|
const keyCertConfig = config.https;
|
|
72
|
-
const pfxConfig = config.https;
|
|
51
|
+
const pfxConfig = config.https;
|
|
73
52
|
|
|
53
|
+
// https must either have key and cert or a pfx and (optionally) a passphrase
|
|
74
54
|
if (!(keyCertConfig.key && keyCertConfig.cert || pfxConfig.pfx)) {
|
|
75
55
|
// logHTTPSError(configPath);
|
|
76
56
|
throw Error('bad format https configuration');
|
|
77
57
|
}
|
|
78
|
-
|
|
79
58
|
if (pfxConfig.pfx) {
|
|
80
59
|
const {
|
|
81
60
|
pfx,
|
|
@@ -98,10 +77,9 @@ function createServerFactory(config, addr, app) {
|
|
|
98
77
|
ca: _fs.default.readFileSync(ca)
|
|
99
78
|
})
|
|
100
79
|
});
|
|
101
|
-
}
|
|
80
|
+
}
|
|
81
|
+
// TODO: enable http2 as feature
|
|
102
82
|
// if (config.server.http2) <-- check if force http2
|
|
103
|
-
|
|
104
|
-
|
|
105
83
|
serverFactory = _https.default.createServer(httpsOptions, app);
|
|
106
84
|
} catch (err) {
|
|
107
85
|
throw new Error(`cannot create https server: ${err.message}`);
|
|
@@ -111,17 +89,17 @@ function createServerFactory(config, addr, app) {
|
|
|
111
89
|
debug('http enabled');
|
|
112
90
|
serverFactory = _http.default.createServer(app);
|
|
113
91
|
}
|
|
114
|
-
|
|
115
|
-
|
|
92
|
+
if (config.server && typeof config.server.keepAliveTimeout !== 'undefined' &&
|
|
93
|
+
// @ts-ignore
|
|
116
94
|
config.server.keepAliveTimeout !== 'null') {
|
|
117
95
|
// library definition for node is not up to date (doesn't contain recent 8.0 changes)
|
|
118
96
|
serverFactory.keepAliveTimeout = config.server.keepAliveTimeout * 1000;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
97
|
+
}
|
|
98
|
+
// FIXE: I could not find the reason of this code.
|
|
122
99
|
unlinkAddressPath(addr);
|
|
123
100
|
return serverFactory;
|
|
124
101
|
}
|
|
102
|
+
|
|
125
103
|
/**
|
|
126
104
|
* Start the server on the port defined
|
|
127
105
|
* @param config
|
|
@@ -129,8 +107,6 @@ function createServerFactory(config, addr, app) {
|
|
|
129
107
|
* @param version
|
|
130
108
|
* @param pkgName
|
|
131
109
|
*/
|
|
132
|
-
|
|
133
|
-
|
|
134
110
|
async function initServer(config, port, version, pkgName) {
|
|
135
111
|
return new Promise(async (resolve, reject) => {
|
|
136
112
|
// FIXME: get only the first match, the multiple address will be removed
|
|
@@ -138,7 +114,6 @@ async function initServer(config, port, version, pkgName) {
|
|
|
138
114
|
const logger = (0, _logger.setup)(config === null || config === void 0 ? void 0 : config.log);
|
|
139
115
|
(0, _experiments.displayExperimentsInfoBox)(config.flags);
|
|
140
116
|
let app;
|
|
141
|
-
|
|
142
117
|
if (process.env.VERDACCIO_SERVER === 'fastify') {
|
|
143
118
|
app = await (0, _serverFastify.default)(config);
|
|
144
119
|
app.listen({
|
|
@@ -161,7 +136,6 @@ async function initServer(config, port, version, pkgName) {
|
|
|
161
136
|
verdaccio_started: true
|
|
162
137
|
});
|
|
163
138
|
}
|
|
164
|
-
|
|
165
139
|
const addressServer = `${addr.path ? _url.default.format({
|
|
166
140
|
protocol: 'unix',
|
|
167
141
|
pathname: addr.path
|
|
@@ -178,7 +152,6 @@ async function initServer(config, port, version, pkgName) {
|
|
|
178
152
|
reject(err);
|
|
179
153
|
process.exitCode = 1;
|
|
180
154
|
});
|
|
181
|
-
|
|
182
155
|
function handleShutdownGracefully() {
|
|
183
156
|
logger.info('received shutdown signal - closing server gracefully...');
|
|
184
157
|
serverFactory.close(() => {
|
|
@@ -186,7 +159,6 @@ async function initServer(config, port, version, pkgName) {
|
|
|
186
159
|
process.exit(0);
|
|
187
160
|
});
|
|
188
161
|
}
|
|
189
|
-
|
|
190
162
|
for (const signal of ['SIGINT', 'SIGTERM', 'SIGHUP']) {
|
|
191
163
|
// Use once() so that receiving double signals exit the app.
|
|
192
164
|
process.once(signal, handleShutdownGracefully);
|
|
@@ -194,6 +166,7 @@ async function initServer(config, port, version, pkgName) {
|
|
|
194
166
|
}
|
|
195
167
|
});
|
|
196
168
|
}
|
|
169
|
+
|
|
197
170
|
/**
|
|
198
171
|
* Exposes a server factory to be instantiated programmatically.
|
|
199
172
|
*
|
|
@@ -207,11 +180,8 @@ async function initServer(config, port, version, pkgName) {
|
|
|
207
180
|
```
|
|
208
181
|
* @param config
|
|
209
182
|
*/
|
|
210
|
-
|
|
211
|
-
|
|
212
183
|
async function runServer(config) {
|
|
213
184
|
let configurationParsed;
|
|
214
|
-
|
|
215
185
|
if (config === undefined || typeof config === 'string') {
|
|
216
186
|
const configPathLocation = (0, _config.findConfigFile)(config);
|
|
217
187
|
configurationParsed = (0, _config.parseConfigFile)(configPathLocation);
|
|
@@ -220,10 +190,9 @@ async function runServer(config) {
|
|
|
220
190
|
} else {
|
|
221
191
|
throw new Error(_core.API_ERROR.CONFIG_BAD_FORMAT);
|
|
222
192
|
}
|
|
223
|
-
|
|
224
193
|
(0, _logger.setup)(configurationParsed.log);
|
|
225
|
-
(0, _experiments.displayExperimentsInfoBox)(configurationParsed.flags);
|
|
226
|
-
|
|
194
|
+
(0, _experiments.displayExperimentsInfoBox)(configurationParsed.flags);
|
|
195
|
+
// FIXME: get only the first match, the multiple address will be removed
|
|
227
196
|
const [addr] = (0, _cliUtils.getListListenAddresses)(undefined, configurationParsed.listen);
|
|
228
197
|
const app = await (0, _server.default)(configurationParsed);
|
|
229
198
|
return createServerFactory(configurationParsed, addr, app);
|
package/build/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","names":["debug","buildDebug","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","assign","readFileSync","ca","createServer","err","message","http","server","keepAliveTimeout","initServer","port","version","pkgName","Promise","resolve","reject","getListListenAddresses","listen","logger","setup","log","displayExperimentsInfoBox","flags","process","env","VERDACCIO_SERVER","fastifyServer","host","expressServer","isFunction","send","verdaccio_started","addressServer","url","format","protocol","pathname","hostname","info","on","exitCode","handleShutdownGracefully","close","exit","signal","once","runServer","configurationParsed","undefined","configPathLocation","findConfigFile","parseConfigFile","_","isObject","API_ERROR","CONFIG_BAD_FORMAT"],"sources":["../src/server.ts"],"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 { setup } from '@verdaccio/logger';\nimport expressServer from '@verdaccio/server';\nimport fastifyServer from '@verdaccio/server-fastify';\nimport { ConfigYaml, 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: ConfigYaml, 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: ConfigYaml,\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?.log as any);\n displayExperimentsInfoBox(config.flags);\n\n let app;\n if (process.env.VERDACCIO_SERVER === 'fastify') {\n app = await fastifyServer(config);\n app.listen({ port: addr.port, host: addr.host }, (err) => {\n if (err) {\n reject(err);\n } else {\n resolve();\n }\n });\n } else {\n app = await expressServer(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 function handleShutdownGracefully() {\n logger.info('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/**\n * Exposes a server factory to be instantiated programmatically.\n *\n ```ts\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 ```\n * @param config\n */\nexport async function runServer(config?: string | ConfigYaml): Promise<any> {\n let configurationParsed: ConfigYaml;\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.log as any);\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 expressServer(configurationParsed);\n return createServerFactory(configurationParsed, addr, app);\n}\n"],"mappings":";;;;;;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAGA;;AACA;;;;;;;;AAjBA;AAmBA,MAAMA,KAAK,GAAG,IAAAC,cAAA,EAAW,oBAAX,CAAd;;AAEA,SAASC,iBAAT,CAA2BC,IAA3B,EAAiC;EAC/B,IAAIA,IAAI,CAACC,IAAL,IAAaC,WAAA,CAAGC,UAAH,CAAcH,IAAI,CAACC,IAAnB,CAAjB,EAA2C;IACzCC,WAAA,CAAGE,UAAH,CAAcJ,IAAI,CAACC,IAAnB;EACD;AACF;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASI,mBAAT,CAA6BC,MAA7B,EAAiDN,IAAjD,EAAuDO,GAAvD,EAA4D;EACjE,IAAIC,aAAJ;;EACA,IAAIR,IAAI,CAACS,KAAL,KAAe,OAAn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":"server.js","names":["debug","buildDebug","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","assign","readFileSync","ca","createServer","err","message","http","server","keepAliveTimeout","initServer","port","version","pkgName","Promise","resolve","reject","getListListenAddresses","listen","logger","setup","log","displayExperimentsInfoBox","flags","process","env","VERDACCIO_SERVER","fastifyServer","host","expressServer","isFunction","send","verdaccio_started","addressServer","url","format","protocol","pathname","hostname","info","on","exitCode","handleShutdownGracefully","close","exit","signal","once","runServer","configurationParsed","undefined","configPathLocation","findConfigFile","parseConfigFile","_","isObject","API_ERROR","CONFIG_BAD_FORMAT"],"sources":["../src/server.ts"],"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 { setup } from '@verdaccio/logger';\nimport expressServer from '@verdaccio/server';\nimport fastifyServer from '@verdaccio/server-fastify';\nimport { ConfigYaml, 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: ConfigYaml, 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: ConfigYaml,\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?.log as any);\n displayExperimentsInfoBox(config.flags);\n\n let app;\n if (process.env.VERDACCIO_SERVER === 'fastify') {\n app = await fastifyServer(config);\n app.listen({ port: addr.port, host: addr.host }, (err) => {\n if (err) {\n reject(err);\n } else {\n resolve();\n }\n });\n } else {\n app = await expressServer(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 function handleShutdownGracefully() {\n logger.info('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/**\n * Exposes a server factory to be instantiated programmatically.\n *\n ```ts\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 ```\n * @param config\n */\nexport async function runServer(config?: string | ConfigYaml): Promise<any> {\n let configurationParsed: ConfigYaml;\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.log as any);\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 expressServer(configurationParsed);\n return createServerFactory(configurationParsed, addr, app);\n}\n"],"mappings":";;;;;;;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAGA;AACA;AAA0D;AAAA;AAAA;AAjB1D;;AAmBA,MAAMA,KAAK,GAAG,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,mBAAmB,CAAC3B,GAAG,CAAQ;EACrC,IAAAC,sCAAyB,EAAC0B,mBAAmB,CAACzB,KAAK,CAAC;EACpD;EACA,MAAM,CAAC7C,IAAI,CAAC,GAAG,IAAAuC,gCAAsB,EAACgC,SAAS,EAAED,mBAAmB,CAAC9B,MAAM,CAAC;EAC5E,MAAMjC,GAAG,GAAG,MAAM,IAAA4C,eAAa,EAACmB,mBAAmB,CAAC;EACpD,OAAOjE,mBAAmB,CAACiE,mBAAmB,EAAEtE,IAAI,EAAEO,GAAG,CAAC;AAC5D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdaccio/node-api",
|
|
3
|
-
"version": "6.0.0-6-next.
|
|
3
|
+
"version": "6.0.0-6-next.52",
|
|
4
4
|
"description": "node API",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -30,21 +30,21 @@
|
|
|
30
30
|
},
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@verdaccio/core": "6.0.0-6-next.
|
|
34
|
-
"@verdaccio/config": "6.0.0-6-next.
|
|
35
|
-
"@verdaccio/logger": "6.0.0-6-next.
|
|
36
|
-
"@verdaccio/server": "6.0.0-6-next.
|
|
37
|
-
"@verdaccio/server-fastify": "6.0.0-6-next.
|
|
38
|
-
"core-js": "3.
|
|
33
|
+
"@verdaccio/core": "6.0.0-6-next.52",
|
|
34
|
+
"@verdaccio/config": "6.0.0-6-next.52",
|
|
35
|
+
"@verdaccio/logger": "6.0.0-6-next.20",
|
|
36
|
+
"@verdaccio/server": "6.0.0-6-next.41",
|
|
37
|
+
"@verdaccio/server-fastify": "6.0.0-6-next.33",
|
|
38
|
+
"core-js": "3.26.1",
|
|
39
39
|
"debug": "4.3.4",
|
|
40
40
|
"lodash": "4.17.21"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@types/node": "16.
|
|
43
|
+
"@types/node": "16.18.3",
|
|
44
44
|
"@verdaccio/types": "11.0.0-6-next.17",
|
|
45
45
|
"jest-mock-process": "1.5.1",
|
|
46
46
|
"selfsigned": "1.10.14",
|
|
47
|
-
"supertest": "6.3.
|
|
47
|
+
"supertest": "6.3.1"
|
|
48
48
|
},
|
|
49
49
|
"publishConfig": {
|
|
50
50
|
"access": "public"
|