@verdaccio/loaders 8.0.0-next-8.20 → 8.0.0-next-8.22
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/build/index.js +1 -1
- package/build/plugin-async-loader.d.ts +2 -2
- package/build/plugin-async-loader.js +186 -94
- package/build/plugin-async-loader.js.map +1 -1
- package/build/utils.d.ts +1 -1
- package/build/utils.js +5 -5
- package/build/utils.js.map +1 -1
- package/package.json +6 -6
package/build/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { pluginUtils } from '@verdaccio/core';
|
|
2
|
-
import { PluginType } from './utils';
|
|
1
|
+
import type { pluginUtils } from '@verdaccio/core';
|
|
2
|
+
import type { PluginType } from './utils';
|
|
3
3
|
/**
|
|
4
4
|
* The plugin loader find recursively plugins, if one plugin fails is ignored and report the error to the logger.
|
|
5
5
|
*
|
|
@@ -11,14 +11,33 @@ var _promises = require("node:fs/promises");
|
|
|
11
11
|
var _nodePath = require("node:path");
|
|
12
12
|
var _core = require("@verdaccio/core");
|
|
13
13
|
var _utils = require("./utils");
|
|
14
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
15
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
16
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
17
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
18
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
19
|
+
var debug = (0, _debug["default"])('verdaccio:plugin:loader:async');
|
|
20
|
+
function isDirectory(_x) {
|
|
21
|
+
return _isDirectory.apply(this, arguments);
|
|
22
|
+
}
|
|
23
|
+
function _isDirectory() {
|
|
24
|
+
_isDirectory = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(pathFolder) {
|
|
25
|
+
var stat;
|
|
26
|
+
return _regenerator().w(function (_context) {
|
|
27
|
+
while (1) switch (_context.n) {
|
|
28
|
+
case 0:
|
|
29
|
+
_context.n = 1;
|
|
30
|
+
return (0, _promises.lstat)(pathFolder);
|
|
31
|
+
case 1:
|
|
32
|
+
stat = _context.v;
|
|
33
|
+
return _context.a(2, stat.isDirectory());
|
|
34
|
+
}
|
|
35
|
+
}, _callee);
|
|
36
|
+
}));
|
|
37
|
+
return _isDirectory.apply(this, arguments);
|
|
19
38
|
}
|
|
20
39
|
function mergeConfig(appConfig, pluginConfig) {
|
|
21
|
-
return _lodash
|
|
40
|
+
return _lodash["default"].merge({}, appConfig, pluginConfig);
|
|
22
41
|
}
|
|
23
42
|
|
|
24
43
|
// type Plugins<T> =
|
|
@@ -49,114 +68,187 @@ function mergeConfig(appConfig, pluginConfig) {
|
|
|
49
68
|
* @param {*} pluginCategory the category of the plugin, eg: auth, storage, middleware
|
|
50
69
|
* @return {Array} list of plugins
|
|
51
70
|
*/
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
71
|
+
function asyncLoadPlugin() {
|
|
72
|
+
return _asyncLoadPlugin.apply(this, arguments);
|
|
73
|
+
}
|
|
74
|
+
function _asyncLoadPlugin() {
|
|
75
|
+
_asyncLoadPlugin = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
76
|
+
var pluginConfigs,
|
|
77
|
+
pluginOptions,
|
|
78
|
+
sanityCheck,
|
|
79
|
+
legacyMergeConfigs,
|
|
80
|
+
prefix,
|
|
81
|
+
pluginCategory,
|
|
82
|
+
logger,
|
|
83
|
+
pluginsIds,
|
|
84
|
+
config,
|
|
85
|
+
plugins,
|
|
86
|
+
_i,
|
|
87
|
+
_pluginsIds,
|
|
88
|
+
pluginId,
|
|
89
|
+
isScoped,
|
|
90
|
+
pluginName,
|
|
91
|
+
pluginsPath,
|
|
92
|
+
pluginDir,
|
|
93
|
+
externalFilePlugin,
|
|
94
|
+
plugin,
|
|
95
|
+
_plugin,
|
|
96
|
+
_args2 = arguments,
|
|
97
|
+
_t;
|
|
98
|
+
return _regenerator().w(function (_context2) {
|
|
99
|
+
while (1) switch (_context2.p = _context2.n) {
|
|
100
|
+
case 0:
|
|
101
|
+
pluginConfigs = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
|
|
102
|
+
pluginOptions = _args2.length > 1 ? _args2[1] : undefined;
|
|
103
|
+
sanityCheck = _args2.length > 2 ? _args2[2] : undefined;
|
|
104
|
+
legacyMergeConfigs = _args2.length > 3 && _args2[3] !== undefined ? _args2[3] : false;
|
|
105
|
+
prefix = _args2.length > 4 && _args2[4] !== undefined ? _args2[4] : _core.PLUGIN_PREFIX;
|
|
106
|
+
pluginCategory = _args2.length > 5 && _args2[5] !== undefined ? _args2[5] : 'unknown';
|
|
107
|
+
logger = pluginOptions === null || pluginOptions === void 0 ? void 0 : pluginOptions.logger;
|
|
108
|
+
pluginsIds = Object.keys(pluginConfigs || {});
|
|
109
|
+
config = pluginOptions.config;
|
|
110
|
+
plugins = [];
|
|
111
|
+
_i = 0, _pluginsIds = pluginsIds;
|
|
112
|
+
case 1:
|
|
113
|
+
if (!(_i < _pluginsIds.length)) {
|
|
114
|
+
_context2.n = 13;
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
pluginId = _pluginsIds[_i];
|
|
118
|
+
debug('>>> looking for plugin %o', pluginId);
|
|
119
|
+
isScoped = pluginId.startsWith('@') && pluginId.includes('/');
|
|
120
|
+
debug('is scoped plugin: %s', isScoped);
|
|
121
|
+
pluginName = isScoped ? pluginId : "".concat(prefix, "-").concat(pluginId);
|
|
122
|
+
debug('plugin package name %s', pluginName);
|
|
65
123
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
124
|
+
// Try to load the plugin from the config.plugins path
|
|
125
|
+
if (!(typeof config.plugins === 'string')) {
|
|
126
|
+
_context2.n = 9;
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
pluginsPath = config.plugins;
|
|
130
|
+
debug('plugin path %s', pluginsPath);
|
|
131
|
+
if ((0, _nodePath.isAbsolute)(pluginsPath)) {
|
|
132
|
+
_context2.n = 3;
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
if (typeof config.config_path === 'string' && !config.configPath) {
|
|
136
|
+
logger.error('configPath is missing and the legacy config.config_path is not available for loading plugins');
|
|
137
|
+
}
|
|
138
|
+
if (config.configPath) {
|
|
139
|
+
_context2.n = 2;
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
75
142
|
logger.error('config path property is required for loading plugins');
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
143
|
+
return _context2.a(3, 12);
|
|
144
|
+
case 2:
|
|
145
|
+
pluginsPath = (0, _nodePath.resolve)((0, _nodePath.join)((0, _nodePath.dirname)(config.configPath), pluginsPath));
|
|
146
|
+
case 3:
|
|
147
|
+
logger.debug({
|
|
148
|
+
path: pluginsPath
|
|
149
|
+
}, 'plugins folder defined, loading plugins from @{path} ');
|
|
150
|
+
// throws if is not a directory
|
|
151
|
+
_context2.p = 4;
|
|
152
|
+
_context2.n = 5;
|
|
153
|
+
return isDirectory(pluginsPath);
|
|
154
|
+
case 5:
|
|
155
|
+
pluginDir = pluginsPath;
|
|
156
|
+
externalFilePlugin = (0, _nodePath.resolve)(pluginDir, pluginName);
|
|
157
|
+
plugin = (0, _utils.tryLoad)(externalFilePlugin, function (a, b) {
|
|
158
|
+
logger.error(a, b);
|
|
159
|
+
});
|
|
160
|
+
debug('external plugin %o', plugin);
|
|
161
|
+
if (!(plugin && (0, _utils.isValid)(plugin))) {
|
|
162
|
+
_context2.n = 7;
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
93
165
|
plugin = executePlugin(plugin, pluginConfigs[pluginId], pluginOptions, legacyMergeConfigs);
|
|
94
|
-
if (
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}, "@{content} doesn't look like a valid plugin");
|
|
98
|
-
continue;
|
|
166
|
+
if (sanityCheck(plugin)) {
|
|
167
|
+
_context2.n = 6;
|
|
168
|
+
break;
|
|
99
169
|
}
|
|
170
|
+
logger.error({
|
|
171
|
+
content: externalFilePlugin
|
|
172
|
+
}, "@{content} doesn't look like a valid plugin");
|
|
173
|
+
return _context2.a(3, 12);
|
|
174
|
+
case 6:
|
|
100
175
|
debug('>>> plugin is running and passed sanity check');
|
|
101
176
|
plugins.push(plugin);
|
|
102
177
|
logger.info({
|
|
103
|
-
pluginName,
|
|
104
|
-
pluginCategory
|
|
178
|
+
pluginName: pluginName,
|
|
179
|
+
pluginCategory: pluginCategory
|
|
105
180
|
}, 'plugin @{pluginName} successfully loaded (@{pluginCategory})');
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
181
|
+
return _context2.a(3, 12);
|
|
182
|
+
case 7:
|
|
183
|
+
_context2.n = 9;
|
|
184
|
+
break;
|
|
185
|
+
case 8:
|
|
186
|
+
_context2.p = 8;
|
|
187
|
+
_t = _context2.v;
|
|
188
|
+
logger.warn({
|
|
189
|
+
err: _t.message,
|
|
190
|
+
pluginsPath: pluginsPath,
|
|
191
|
+
pluginName: pluginName
|
|
192
|
+
}, '@{err} on loading plugins at @{pluginsPath} for @{pluginName}');
|
|
193
|
+
case 9:
|
|
194
|
+
if (!(typeof pluginId === 'string')) {
|
|
195
|
+
_context2.n = 12;
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
_plugin = (0, _utils.tryLoad)(pluginName, function (a, b) {
|
|
199
|
+
logger.error(a, b);
|
|
200
|
+
});
|
|
201
|
+
if (!(_plugin && (0, _utils.isValid)(_plugin))) {
|
|
202
|
+
_context2.n = 11;
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
_plugin = executePlugin(_plugin, pluginConfigs[pluginId], pluginOptions, legacyMergeConfigs);
|
|
206
|
+
if (sanityCheck(_plugin)) {
|
|
207
|
+
_context2.n = 10;
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
125
210
|
logger.error({
|
|
126
|
-
pluginName
|
|
211
|
+
pluginName: pluginName
|
|
127
212
|
}, "@{pluginName} doesn't look like a valid plugin");
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
213
|
+
return _context2.a(3, 12);
|
|
214
|
+
case 10:
|
|
215
|
+
debug('>>> plugin is running and passed sanity check');
|
|
216
|
+
plugins.push(_plugin);
|
|
217
|
+
logger.info({
|
|
218
|
+
pluginName: pluginName,
|
|
219
|
+
pluginCategory: pluginCategory
|
|
220
|
+
}, 'plugin @{pluginName} successfully loaded (@{pluginCategory})');
|
|
221
|
+
return _context2.a(3, 12);
|
|
222
|
+
case 11:
|
|
223
|
+
logger.error({
|
|
224
|
+
pluginName: pluginName
|
|
225
|
+
}, 'package not found, try to install @{pluginName} with a package manager');
|
|
226
|
+
return _context2.a(3, 12);
|
|
227
|
+
case 12:
|
|
228
|
+
_i++;
|
|
229
|
+
_context2.n = 1;
|
|
230
|
+
break;
|
|
231
|
+
case 13:
|
|
232
|
+
debug('%o plugins found: %o', pluginCategory, plugins.length);
|
|
233
|
+
return _context2.a(2, plugins);
|
|
142
234
|
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return plugins;
|
|
235
|
+
}, _callee2, null, [[4, 8]]);
|
|
236
|
+
}));
|
|
237
|
+
return _asyncLoadPlugin.apply(this, arguments);
|
|
147
238
|
}
|
|
148
|
-
function executePlugin(plugin, pluginConfig, pluginOptions
|
|
239
|
+
function executePlugin(plugin, pluginConfig, pluginOptions) {
|
|
240
|
+
var legacyMergeConfigs = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
149
241
|
// this is a legacy support for plugins that are not using the new API
|
|
150
242
|
if (legacyMergeConfigs) {
|
|
151
243
|
debug('>>> plugin merge config enabled');
|
|
152
|
-
|
|
244
|
+
var originalConfig = pluginOptions.config;
|
|
153
245
|
pluginConfig = mergeConfig(originalConfig, pluginConfig);
|
|
154
246
|
}
|
|
155
247
|
if ((0, _utils.isES6)(plugin)) {
|
|
156
248
|
debug('plugin is ES6');
|
|
157
249
|
// @ts-expect-error no relevant for the code
|
|
158
|
-
|
|
159
|
-
return new plugin
|
|
250
|
+
|
|
251
|
+
return new plugin["default"](pluginConfig, pluginOptions);
|
|
160
252
|
} else {
|
|
161
253
|
debug('plugin is commonJS');
|
|
162
254
|
// @ts-expect-error improve this type
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-async-loader.js","names":["_debug","_interopRequireDefault","require","_lodash","_promises","_nodePath","_core","_utils","e","__esModule","default","debug","buildDebug","isDirectory","pathFolder","stat","lstat","mergeConfig","appConfig","pluginConfig","_","merge","asyncLoadPlugin","pluginConfigs","pluginOptions","sanityCheck","legacyMergeConfigs","prefix","PLUGIN_PREFIX","pluginCategory","logger","pluginsIds","Object","keys","config","plugins","pluginId","isScoped","startsWith","includes","pluginName","pluginsPath","isAbsolute","config_path","configPath","error","resolve","join","dirname","path","pluginDir","externalFilePlugin","plugin","tryLoad","a","b","isValid","executePlugin","content","push","info","err","warn","message","length","originalConfig","isES6"],"sources":["../src/plugin-async-loader.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport _ from 'lodash';\nimport { lstat } from 'node:fs/promises';\nimport { dirname, isAbsolute, join, resolve } from 'node:path';\n\nimport { PLUGIN_PREFIX, pluginUtils } from '@verdaccio/core';\n\nimport { PluginType, isES6, isValid, tryLoad } from './utils';\n\nconst debug = buildDebug('verdaccio:plugin:loader:async');\n\nasync function isDirectory(pathFolder: string) {\n const stat = await lstat(pathFolder);\n return stat.isDirectory();\n}\n\nfunction mergeConfig(appConfig: unknown, pluginConfig: unknown) {\n return _.merge({}, appConfig, pluginConfig);\n}\n\n// type Plugins<T> =\n// | pluginUtils.Auth<T>\n// | pluginUtils.Storage<T>\n// | pluginUtils.ExpressMiddleware<T, unknown, unknown>;\n\n/**\n * The plugin loader find recursively plugins, if one plugin fails is ignored and report the error to the logger.\n *\n * The loader follows the order:\n * - If the at the `config.yaml` file the `plugins: ./plugins` is defined\n * - If is absolute will use the provided path\n * - If is relative, will use the base path of the config file. eg: /root/config.yaml the plugins folder should be\n * hosted at /root/plugins\n * - The next step is find at the node_modules or global based on the `require` native algorithm.\n * - If the package is scoped eg: @scope/foo, try to load the package `@scope/foo`\n * - If the package is not scoped, will use the default prefix: verdaccio-foo (\"verdaccio-theme-\" prefix for theme ui plugins).\n * - If a custom prefix is provided, the verdaccio- is replaced by the config.server.pluginPrefix.\n *\n * The `sanityCheck` is the validation for the required methods to load the plugin, if the validation fails the plugin won't be loaded.\n * The `params` is an object that contains the global configuration and the logger.\n *\n * @param {*} pluginConfigs the custom plugin section\n * @param {*} pluginOptions a set of options to initialize the plugin\n * @param {*} sanityCheck callback that check the shape that should fulfill the plugin\n * @param {*} prefix by default is verdaccio but can be override with config.server.pluginPrefix\n * @param {*} pluginCategory the category of the plugin, eg: auth, storage, middleware\n * @return {Array} list of plugins\n */\nexport async function asyncLoadPlugin<T extends pluginUtils.Plugin<T>>(\n pluginConfigs: any = {},\n pluginOptions: pluginUtils.PluginOptions,\n sanityCheck: (plugin: PluginType<T>) => boolean,\n legacyMergeConfigs: boolean = false,\n prefix: string = PLUGIN_PREFIX,\n pluginCategory: string = 'unknown'\n): Promise<PluginType<T>[]> {\n const logger = pluginOptions?.logger;\n const pluginsIds = Object.keys(pluginConfigs || {});\n const { config } = pluginOptions;\n let plugins: PluginType<T>[] = [];\n for (let pluginId of pluginsIds) {\n debug('>>> looking for plugin %o', pluginId);\n\n const isScoped: boolean = pluginId.startsWith('@') && pluginId.includes('/');\n debug('is scoped plugin: %s', isScoped);\n const pluginName = isScoped ? pluginId : `${prefix}-${pluginId}`;\n debug('plugin package name %s', pluginName);\n\n // Try to load the plugin from the config.plugins path\n if (typeof config.plugins === 'string') {\n let pluginsPath = config.plugins;\n debug('plugin path %s', pluginsPath);\n if (!isAbsolute(pluginsPath)) {\n if (typeof config.config_path === 'string' && !config.configPath) {\n logger.error(\n 'configPath is missing and the legacy config.config_path is not available for loading plugins'\n );\n }\n\n if (!config.configPath) {\n logger.error('config path property is required for loading plugins');\n continue;\n }\n pluginsPath = resolve(join(dirname(config.configPath), pluginsPath));\n }\n logger.debug({ path: pluginsPath }, 'plugins folder defined, loading plugins from @{path} ');\n // throws if is not a directory\n try {\n await isDirectory(pluginsPath);\n const pluginDir = pluginsPath;\n const externalFilePlugin = resolve(pluginDir, pluginName);\n let plugin = tryLoad<T>(externalFilePlugin, (a: any, b: any) => {\n logger.error(a, b);\n });\n debug('external plugin %o', plugin);\n if (plugin && isValid(plugin)) {\n plugin = executePlugin(\n plugin,\n pluginConfigs[pluginId],\n pluginOptions,\n legacyMergeConfigs\n );\n if (!sanityCheck(plugin)) {\n logger.error(\n { content: externalFilePlugin },\n \"@{content} doesn't look like a valid plugin\"\n );\n continue;\n }\n debug('>>> plugin is running and passed sanity check');\n plugins.push(plugin);\n logger.info(\n { pluginName, pluginCategory },\n 'plugin @{pluginName} successfully loaded (@{pluginCategory})'\n );\n continue;\n }\n } catch (err: any) {\n logger.warn(\n { err: err.message, pluginsPath, pluginName },\n '@{err} on loading plugins at @{pluginsPath} for @{pluginName}'\n );\n }\n }\n\n // Try to load the plugin from the node_modules or global based on the `require` native algorithm\n if (typeof pluginId === 'string') {\n let plugin = tryLoad<T>(pluginName, (a: any, b: any) => {\n logger.error(a, b);\n });\n if (plugin && isValid(plugin)) {\n plugin = executePlugin(plugin, pluginConfigs[pluginId], pluginOptions, legacyMergeConfigs);\n if (!sanityCheck(plugin)) {\n logger.error({ pluginName }, \"@{pluginName} doesn't look like a valid plugin\");\n continue;\n }\n debug('>>> plugin is running and passed sanity check');\n plugins.push(plugin);\n logger.info(\n { pluginName, pluginCategory },\n 'plugin @{pluginName} successfully loaded (@{pluginCategory})'\n );\n continue;\n } else {\n logger.error(\n { pluginName },\n 'package not found, try to install @{pluginName} with a package manager'\n );\n continue;\n }\n }\n }\n debug('%o plugins found: %o', pluginCategory, plugins.length);\n return plugins;\n}\n\nexport function executePlugin<T>(\n plugin: PluginType<T>,\n pluginConfig: unknown,\n pluginOptions: pluginUtils.PluginOptions,\n legacyMergeConfigs: boolean = false\n): PluginType<T> {\n // this is a legacy support for plugins that are not using the new API\n if (legacyMergeConfigs) {\n debug('>>> plugin merge config enabled');\n let originalConfig = pluginOptions.config;\n pluginConfig = mergeConfig(originalConfig, pluginConfig);\n }\n if (isES6(plugin)) {\n debug('plugin is ES6');\n // @ts-expect-error no relevant for the code\n // eslint-disable-next-line new-cap\n return new plugin.default(pluginConfig, pluginOptions) as Plugin;\n } else {\n debug('plugin is commonJS');\n // @ts-expect-error improve this type\n return plugin(pluginConfig, pluginOptions) as PluginType<T>;\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AAEA,IAAAI,KAAA,GAAAJ,OAAA;AAEA,IAAAK,MAAA,GAAAL,OAAA;AAA8D,SAAAD,uBAAAO,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE9D,MAAMG,K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ACV;UAAEL;QAAW,CAAC,EACd,wEACF,CAAC;QACD;MACF;IACF;EACF;EACA7B,KAAK,CAAC,sBAAsB,EAAEkB,cAAc,EAAEM,OAAO,CAAC6B,MAAM,CAAC;EAC7D,OAAO7B,OAAO;AAChB;AAEO,SAASsB,aAAaA,CAC3BL,MAAqB,EACrBjC,YAAqB,EACrBK,aAAwC,EACxCE,kBAA2B,GAAG,KAAK,EACpB;EACf;EACA,IAAIA,kBAAkB,EAAE;IACtBf,KAAK,CAAC,iCAAiC,CAAC;IACxC,IAAIsD,cAAc,GAAGzC,aAAa,CAACU,MAAM;IACzCf,YAAY,GAAGF,WAAW,CAACgD,cAAc,EAAE9C,YAAY,CAAC;EAC1D;EACA,IAAI,IAAA+C,YAAK,EAACd,MAAM,CAAC,EAAE;IACjBzC,KAAK,CAAC,eAAe,CAAC;IACtB;IACA;IACA,OAAO,IAAIyC,MAAM,CAAC1C,OAAO,CAACS,YAAY,EAAEK,aAAa,CAAC;EACxD,CAAC,MAAM;IACLb,KAAK,CAAC,oBAAoB,CAAC;IAC3B;IACA,OAAOyC,MAAM,CAACjC,YAAY,EAAEK,aAAa,CAAC;EAC5C;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"plugin-async-loader.js","names":["_debug","_interopRequireDefault","require","_lodash","_promises","_nodePath","_core","_utils","e","__esModule","_regenerator","t","r","Symbol","n","iterator","o","toStringTag","i","c","prototype","Generator","u","Object","create","_regeneratorDefine2","f","p","y","G","v","a","d","bind","length","l","TypeError","call","done","value","GeneratorFunction","GeneratorFunctionPrototype","getPrototypeOf","setPrototypeOf","__proto__","displayName","w","m","defineProperty","_regeneratorDefine","_invoke","enumerable","configurable","writable","asyncGeneratorStep","Promise","resolve","then","_asyncToGenerator","arguments","apply","_next","_throw","debug","buildDebug","isDirectory","_x","_isDirectory","_callee","pathFolder","stat","_context","lstat","mergeConfig","appConfig","pluginConfig","_","merge","asyncLoadPlugin","_asyncLoadPlugin","_callee2","pluginConfigs","pluginOptions","sanityCheck","legacyMergeConfigs","prefix","pluginCategory","logger","pluginsIds","config","plugins","_i","_pluginsIds","pluginId","isScoped","pluginName","pluginsPath","pluginDir","externalFilePlugin","plugin","_plugin","_args2","_t","_context2","undefined","PLUGIN_PREFIX","keys","startsWith","includes","concat","isAbsolute","config_path","configPath","error","join","dirname","path","tryLoad","b","isValid","executePlugin","content","push","info","warn","err","message","originalConfig","isES6"],"sources":["../src/plugin-async-loader.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport _ from 'lodash';\nimport { lstat } from 'node:fs/promises';\nimport { dirname, isAbsolute, join, resolve } from 'node:path';\n\nimport type { pluginUtils } from '@verdaccio/core';\nimport { PLUGIN_PREFIX } from '@verdaccio/core';\n\nimport type { PluginType } from './utils';\nimport { isES6, isValid, tryLoad } from './utils';\n\nconst debug = buildDebug('verdaccio:plugin:loader:async');\n\nasync function isDirectory(pathFolder: string) {\n const stat = await lstat(pathFolder);\n return stat.isDirectory();\n}\n\nfunction mergeConfig(appConfig: unknown, pluginConfig: unknown) {\n return _.merge({}, appConfig, pluginConfig);\n}\n\n// type Plugins<T> =\n// | pluginUtils.Auth<T>\n// | pluginUtils.Storage<T>\n// | pluginUtils.ExpressMiddleware<T, unknown, unknown>;\n\n/**\n * The plugin loader find recursively plugins, if one plugin fails is ignored and report the error to the logger.\n *\n * The loader follows the order:\n * - If the at the `config.yaml` file the `plugins: ./plugins` is defined\n * - If is absolute will use the provided path\n * - If is relative, will use the base path of the config file. eg: /root/config.yaml the plugins folder should be\n * hosted at /root/plugins\n * - The next step is find at the node_modules or global based on the `require` native algorithm.\n * - If the package is scoped eg: @scope/foo, try to load the package `@scope/foo`\n * - If the package is not scoped, will use the default prefix: verdaccio-foo (\"verdaccio-theme-\" prefix for theme ui plugins).\n * - If a custom prefix is provided, the verdaccio- is replaced by the config.server.pluginPrefix.\n *\n * The `sanityCheck` is the validation for the required methods to load the plugin, if the validation fails the plugin won't be loaded.\n * The `params` is an object that contains the global configuration and the logger.\n *\n * @param {*} pluginConfigs the custom plugin section\n * @param {*} pluginOptions a set of options to initialize the plugin\n * @param {*} sanityCheck callback that check the shape that should fulfill the plugin\n * @param {*} prefix by default is verdaccio but can be override with config.server.pluginPrefix\n * @param {*} pluginCategory the category of the plugin, eg: auth, storage, middleware\n * @return {Array} list of plugins\n */\nexport async function asyncLoadPlugin<T extends pluginUtils.Plugin<T>>(\n pluginConfigs: any = {},\n pluginOptions: pluginUtils.PluginOptions,\n sanityCheck: (plugin: PluginType<T>) => boolean,\n legacyMergeConfigs: boolean = false,\n prefix: string = PLUGIN_PREFIX,\n pluginCategory: string = 'unknown'\n): Promise<PluginType<T>[]> {\n const logger = pluginOptions?.logger;\n const pluginsIds = Object.keys(pluginConfigs || {});\n const { config } = pluginOptions;\n const plugins: PluginType<T>[] = [];\n for (const pluginId of pluginsIds) {\n debug('>>> looking for plugin %o', pluginId);\n\n const isScoped: boolean = pluginId.startsWith('@') && pluginId.includes('/');\n debug('is scoped plugin: %s', isScoped);\n const pluginName = isScoped ? pluginId : `${prefix}-${pluginId}`;\n debug('plugin package name %s', pluginName);\n\n // Try to load the plugin from the config.plugins path\n if (typeof config.plugins === 'string') {\n let pluginsPath = config.plugins;\n debug('plugin path %s', pluginsPath);\n if (!isAbsolute(pluginsPath)) {\n if (typeof config.config_path === 'string' && !config.configPath) {\n logger.error(\n 'configPath is missing and the legacy config.config_path is not available for loading plugins'\n );\n }\n\n if (!config.configPath) {\n logger.error('config path property is required for loading plugins');\n continue;\n }\n pluginsPath = resolve(join(dirname(config.configPath), pluginsPath));\n }\n logger.debug({ path: pluginsPath }, 'plugins folder defined, loading plugins from @{path} ');\n // throws if is not a directory\n try {\n await isDirectory(pluginsPath);\n const pluginDir = pluginsPath;\n const externalFilePlugin = resolve(pluginDir, pluginName);\n let plugin = tryLoad<T>(externalFilePlugin, (a: any, b: any) => {\n logger.error(a, b);\n });\n debug('external plugin %o', plugin);\n if (plugin && isValid(plugin)) {\n plugin = executePlugin(\n plugin,\n pluginConfigs[pluginId],\n pluginOptions,\n legacyMergeConfigs\n );\n if (!sanityCheck(plugin)) {\n logger.error(\n { content: externalFilePlugin },\n \"@{content} doesn't look like a valid plugin\"\n );\n continue;\n }\n debug('>>> plugin is running and passed sanity check');\n plugins.push(plugin);\n logger.info(\n { pluginName, pluginCategory },\n 'plugin @{pluginName} successfully loaded (@{pluginCategory})'\n );\n continue;\n }\n } catch (err: any) {\n logger.warn(\n { err: err.message, pluginsPath, pluginName },\n '@{err} on loading plugins at @{pluginsPath} for @{pluginName}'\n );\n }\n }\n\n // Try to load the plugin from the node_modules or global based on the `require` native algorithm\n if (typeof pluginId === 'string') {\n let plugin = tryLoad<T>(pluginName, (a: any, b: any) => {\n logger.error(a, b);\n });\n if (plugin && isValid(plugin)) {\n plugin = executePlugin(plugin, pluginConfigs[pluginId], pluginOptions, legacyMergeConfigs);\n if (!sanityCheck(plugin)) {\n logger.error({ pluginName }, \"@{pluginName} doesn't look like a valid plugin\");\n continue;\n }\n debug('>>> plugin is running and passed sanity check');\n plugins.push(plugin);\n logger.info(\n { pluginName, pluginCategory },\n 'plugin @{pluginName} successfully loaded (@{pluginCategory})'\n );\n continue;\n } else {\n logger.error(\n { pluginName },\n 'package not found, try to install @{pluginName} with a package manager'\n );\n continue;\n }\n }\n }\n debug('%o plugins found: %o', pluginCategory, plugins.length);\n return plugins;\n}\n\nexport function executePlugin<T>(\n plugin: PluginType<T>,\n pluginConfig: unknown,\n pluginOptions: pluginUtils.PluginOptions,\n legacyMergeConfigs: boolean = false\n): PluginType<T> {\n // this is a legacy support for plugins that are not using the new API\n if (legacyMergeConfigs) {\n debug('>>> plugin merge config enabled');\n const originalConfig = pluginOptions.config;\n pluginConfig = mergeConfig(originalConfig, pluginConfig);\n }\n if (isES6(plugin)) {\n debug('plugin is ES6');\n // @ts-expect-error no relevant for the code\n\n return new plugin.default(pluginConfig, pluginOptions) as Plugin;\n } else {\n debug('plugin is commonJS');\n // @ts-expect-error improve this type\n return plugin(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OAAAD,SAAA;AAAA;AAEM,SAAS6D,aAAaA,CAC3BrB,MAAqB,EACrBxB,YAAqB,EACrBO,aAAwC,EAEzB;EAAA,IADfE,kBAA2B,GAAAzB,SAAA,CAAAzB,MAAA,QAAAyB,SAAA,QAAA6C,SAAA,GAAA7C,SAAA,MAAG,KAAK;EAEnC;EACA,IAAIyB,kBAAkB,EAAE;IACtBrB,KAAK,CAAC,iCAAiC,CAAC;IACxC,IAAMgE,cAAc,GAAG7C,aAAa,CAACO,MAAM;IAC3Cd,YAAY,GAAGF,WAAW,CAACsD,cAAc,EAAEpD,YAAY,CAAC;EAC1D;EACA,IAAI,IAAAqD,YAAK,EAAC7B,MAAM,CAAC,EAAE;IACjBpC,KAAK,CAAC,eAAe,CAAC;IACtB;;IAEA,OAAO,IAAIoC,MAAM,WAAQ,CAACxB,YAAY,EAAEO,aAAa,CAAC;EACxD,CAAC,MAAM;IACLnB,KAAK,CAAC,oBAAoB,CAAC;IAC3B;IACA,OAAOoC,MAAM,CAACxB,YAAY,EAAEO,aAAa,CAAC;EAC5C;AACF","ignoreList":[]}
|
package/build/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { pluginUtils } from '@verdaccio/core';
|
|
1
|
+
import type { pluginUtils } from '@verdaccio/core';
|
|
2
2
|
export type PluginType<T> = T extends pluginUtils.Plugin<T> ? T : never;
|
|
3
3
|
export declare function isValid<T>(plugin: PluginType<T>): boolean;
|
|
4
4
|
export declare function isES6<T>(plugin: PluginType<T>): boolean;
|
package/build/utils.js
CHANGED
|
@@ -8,12 +8,12 @@ exports.isValid = isValid;
|
|
|
8
8
|
exports.tryLoad = tryLoad;
|
|
9
9
|
var _debug = _interopRequireDefault(require("debug"));
|
|
10
10
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
12
|
+
var debug = (0, _debug["default"])('verdaccio:plugin:loader:utils');
|
|
13
|
+
var MODULE_NOT_FOUND = 'MODULE_NOT_FOUND';
|
|
14
14
|
function isValid(plugin) {
|
|
15
15
|
// @ts-expect-error default not relevant
|
|
16
|
-
return _lodash
|
|
16
|
+
return _lodash["default"].isFunction(plugin) || _lodash["default"].isFunction(plugin["default"]);
|
|
17
17
|
}
|
|
18
18
|
function isES6(plugin) {
|
|
19
19
|
return Object.keys(plugin).includes('default');
|
|
@@ -34,7 +34,7 @@ function tryLoad(path, onError) {
|
|
|
34
34
|
// If loading fails, because a dependency is missing,
|
|
35
35
|
// we want to log the error message and require stack
|
|
36
36
|
// to see where the missing dependency is.
|
|
37
|
-
|
|
37
|
+
var message = err.message.replace(/\\\\/g, '\\').split('\n');
|
|
38
38
|
if (!message[0].includes(path)) {
|
|
39
39
|
debug('%o', message[0]); // error message
|
|
40
40
|
debug('%o', message.slice(1)); // stack trace
|
package/build/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["_debug","_interopRequireDefault","require","_lodash","e","__esModule","
|
|
1
|
+
{"version":3,"file":"utils.js","names":["_debug","_interopRequireDefault","require","_lodash","e","__esModule","debug","buildDebug","MODULE_NOT_FOUND","isValid","plugin","_","isFunction","isES6","Object","keys","includes","tryLoad","path","onError","err","code","message","replace","split","slice","msg"],"sources":["../src/utils.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport _ from 'lodash';\n\nimport type { pluginUtils } from '@verdaccio/core';\n\nconst debug = buildDebug('verdaccio:plugin:loader:utils');\nconst MODULE_NOT_FOUND = 'MODULE_NOT_FOUND';\n\nexport type PluginType<T> = T extends pluginUtils.Plugin<T> ? T : never;\n\nexport function isValid<T>(plugin: PluginType<T>): boolean {\n // @ts-expect-error default not relevant\n return _.isFunction(plugin) || _.isFunction(plugin.default);\n}\n\nexport function isES6<T>(plugin: PluginType<T>): boolean {\n return Object.keys(plugin).includes('default');\n}\n\n/**\n * Requires a module.\n * @param {*} path the module's path\n * @return {Object}\n */\nexport function tryLoad<T>(path: string, onError: any): PluginType<T> | null {\n try {\n debug('loading plugin %s', path);\n return require(path) as PluginType<T>;\n } catch (err: any) {\n if (err.code === MODULE_NOT_FOUND) {\n debug('\"require\" failed for plugin %s', path);\n // If loading fails, because a dependency is missing,\n // we want to log the error message and require stack\n // to see where the missing dependency is.\n const message = err.message.replace(/\\\\\\\\/g, '\\\\').split('\\n');\n if (!message[0].includes(path)) {\n debug('%o', message[0]); // error message\n debug('%o', message.slice(1)); // stack trace\n }\n return null;\n }\n onError({ err: err.msg }, 'error loading plugin @{err}');\n throw err;\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AAAuB,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,gBAAAA,CAAA;AAIvB,IAAME,KAAK,GAAG,IAAAC,iBAAU,EAAC,+BAA+B,CAAC;AACzD,IAAMC,gBAAgB,GAAG,kBAAkB;AAIpC,SAASC,OAAOA,CAAIC,MAAqB,EAAW;EACzD;EACA,OAAOC,kBAAC,CAACC,UAAU,CAACF,MAAM,CAAC,IAAIC,kBAAC,CAACC,UAAU,CAACF,MAAM,WAAQ,CAAC;AAC7D;AAEO,SAASG,KAAKA,CAAIH,MAAqB,EAAW;EACvD,OAAOI,MAAM,CAACC,IAAI,CAACL,MAAM,CAAC,CAACM,QAAQ,CAAC,SAAS,CAAC;AAChD;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,OAAOA,CAAIC,IAAY,EAAEC,OAAY,EAAwB;EAC3E,IAAI;IACFb,KAAK,CAAC,mBAAmB,EAAEY,IAAI,CAAC;IAChC,OAAOhB,OAAO,CAACgB,IAAI,CAAC;EACtB,CAAC,CAAC,OAAOE,GAAQ,EAAE;IACjB,IAAIA,GAAG,CAACC,IAAI,KAAKb,gBAAgB,EAAE;MACjCF,KAAK,CAAC,gCAAgC,EAAEY,IAAI,CAAC;MAC7C;MACA;MACA;MACA,IAAMI,OAAO,GAAGF,GAAG,CAACE,OAAO,CAACC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAACC,KAAK,CAAC,IAAI,CAAC;MAC9D,IAAI,CAACF,OAAO,CAAC,CAAC,CAAC,CAACN,QAAQ,CAACE,IAAI,CAAC,EAAE;QAC9BZ,KAAK,CAAC,IAAI,EAAEgB,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACzBhB,KAAK,CAAC,IAAI,EAAEgB,OAAO,CAACG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;MACjC;MACA,OAAO,IAAI;IACb;IACAN,OAAO,CAAC;MAAEC,GAAG,EAAEA,GAAG,CAACM;IAAI,CAAC,EAAE,6BAA6B,CAAC;IACxD,MAAMN,GAAG;EACX;AACF","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdaccio/loaders",
|
|
3
|
-
"version": "8.0.0-next-8.
|
|
3
|
+
"version": "8.0.0-next-8.22",
|
|
4
4
|
"description": "Verdaccio Loader Logic",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -17,18 +17,18 @@
|
|
|
17
17
|
"url": "https://github.com/verdaccio/verdaccio/issues"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@verdaccio/core": "8.0.0-next-8.
|
|
20
|
+
"@verdaccio/core": "8.0.0-next-8.32",
|
|
21
21
|
"debug": "4.4.3",
|
|
22
22
|
"lodash": "4.17.23"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@verdaccio/logger": "8.0.0-next-8.
|
|
26
|
-
"@verdaccio/config": "8.0.0-next-8.
|
|
27
|
-
"@verdaccio/core": "8.0.0-next-8.
|
|
25
|
+
"@verdaccio/logger": "8.0.0-next-8.32",
|
|
26
|
+
"@verdaccio/config": "8.0.0-next-8.32",
|
|
27
|
+
"@verdaccio/core": "8.0.0-next-8.32",
|
|
28
28
|
"@verdaccio-scope/verdaccio-auth-foo": "0.0.2",
|
|
29
29
|
"customprefix-auth": "2.0.0",
|
|
30
30
|
"vitest": "3.2.4",
|
|
31
|
-
"verdaccio-auth-memory": "13.0.0-next-8.
|
|
31
|
+
"verdaccio-auth-memory": "13.0.0-next-8.32"
|
|
32
32
|
},
|
|
33
33
|
"homepage": "https://verdaccio.org",
|
|
34
34
|
"keywords": [
|