@verdaccio/loaders 6.0.0-6-next.19 → 6.0.0-6-next.21
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 +12 -0
- package/build/index.js +0 -1
- package/build/index.js.map +1 -1
- package/build/plugin-async-loader.d.ts +1 -1
- package/build/plugin-async-loader.js +6 -35
- package/build/plugin-async-loader.js.map +1 -1
- package/build/utils.d.ts +1 -1
- package/build/utils.js +1 -11
- package/build/utils.js.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
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 { asyncLoadPlugin } from './plugin-async-loader';\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export { asyncLoadPlugin } from './plugin-async-loader';\n"],"mappings":";;;;;;;;;;;AAAA"}
|
|
@@ -5,26 +5,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.asyncLoadPlugin = asyncLoadPlugin;
|
|
7
7
|
exports.executePlugin = executePlugin;
|
|
8
|
-
|
|
9
8
|
var _debug = _interopRequireDefault(require("debug"));
|
|
10
|
-
|
|
11
9
|
var _promises = require("fs/promises");
|
|
12
|
-
|
|
13
10
|
var _path = require("path");
|
|
14
|
-
|
|
15
11
|
var _logger = require("@verdaccio/logger");
|
|
16
|
-
|
|
17
12
|
var _utils = require("./utils");
|
|
18
|
-
|
|
19
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
|
-
|
|
21
14
|
const debug = (0, _debug.default)('verdaccio:plugin:loader:async');
|
|
22
|
-
|
|
23
15
|
async function isDirectory(pathFolder) {
|
|
24
16
|
const stat = await (0, _promises.lstat)(pathFolder);
|
|
25
17
|
return stat.isDirectory();
|
|
26
18
|
}
|
|
27
|
-
|
|
28
19
|
// type Plugins<T> =
|
|
29
20
|
// | pluginUtils.Auth<T>
|
|
30
21
|
// | pluginUtils.Storage<T>
|
|
@@ -58,50 +49,38 @@ async function asyncLoadPlugin(pluginConfigs = {}, params, sanityCheck, prefix =
|
|
|
58
49
|
config
|
|
59
50
|
} = params;
|
|
60
51
|
let plugins = [];
|
|
61
|
-
|
|
62
52
|
for (let pluginId of pluginsIds) {
|
|
63
53
|
debug('plugin %s', pluginId);
|
|
64
|
-
|
|
65
54
|
if (typeof config.plugins === 'string') {
|
|
66
55
|
let pluginsPath = config.plugins;
|
|
67
56
|
debug('plugin path %s', pluginsPath);
|
|
68
|
-
|
|
69
57
|
if (!(0, _path.isAbsolute)(pluginsPath)) {
|
|
70
58
|
if (typeof config.config_path === 'string' && !config.configPath) {
|
|
71
59
|
_logger.logger.error('configPath is missing and the legacy config.config_path is not available for loading plugins');
|
|
72
60
|
}
|
|
73
|
-
|
|
74
61
|
if (!config.configPath) {
|
|
75
62
|
_logger.logger.error('config path property is required for loading plugins');
|
|
76
|
-
|
|
77
63
|
continue;
|
|
78
64
|
}
|
|
79
|
-
|
|
80
65
|
pluginsPath = (0, _path.resolve)((0, _path.join)((0, _path.dirname)(config.configPath), pluginsPath));
|
|
81
66
|
}
|
|
82
|
-
|
|
83
67
|
_logger.logger.debug({
|
|
84
68
|
path: pluginsPath
|
|
85
|
-
}, 'plugins folder defined, loading plugins from @{path} ');
|
|
86
|
-
|
|
87
|
-
|
|
69
|
+
}, 'plugins folder defined, loading plugins from @{path} ');
|
|
70
|
+
// throws if is nto a directory
|
|
88
71
|
try {
|
|
89
72
|
await isDirectory(pluginsPath);
|
|
90
73
|
const pluginDir = pluginsPath;
|
|
91
74
|
const externalFilePlugin = (0, _path.resolve)(pluginDir, `${prefix}-${pluginId}`);
|
|
92
75
|
let plugin = (0, _utils.tryLoad)(externalFilePlugin);
|
|
93
|
-
|
|
94
76
|
if (plugin && (0, _utils.isValid)(plugin)) {
|
|
95
77
|
plugin = executePlugin(plugin, pluginConfigs[pluginId], params);
|
|
96
|
-
|
|
97
78
|
if (!sanityCheck(plugin)) {
|
|
98
79
|
_logger.logger.error({
|
|
99
80
|
content: externalFilePlugin
|
|
100
81
|
}, "@{content} doesn't look like a valid plugin");
|
|
101
|
-
|
|
102
82
|
continue;
|
|
103
83
|
}
|
|
104
|
-
|
|
105
84
|
plugins.push(plugin);
|
|
106
85
|
continue;
|
|
107
86
|
}
|
|
@@ -113,50 +92,42 @@ async function asyncLoadPlugin(pluginConfigs = {}, params, sanityCheck, prefix =
|
|
|
113
92
|
}, '@{err} on loading plugins at @{pluginsPath} for @{pluginId}');
|
|
114
93
|
}
|
|
115
94
|
}
|
|
116
|
-
|
|
117
95
|
if (typeof pluginId === 'string') {
|
|
118
96
|
const isScoped = pluginId.startsWith('@') && pluginId.includes('/');
|
|
119
97
|
debug('is scoped plugin %s', isScoped);
|
|
120
98
|
const pluginName = isScoped ? pluginId : `${prefix}-${pluginId}`;
|
|
121
99
|
debug('plugin pkg name %s', pluginName);
|
|
122
100
|
let plugin = (0, _utils.tryLoad)(pluginName);
|
|
123
|
-
|
|
124
101
|
if (plugin && (0, _utils.isValid)(plugin)) {
|
|
125
102
|
plugin = executePlugin(plugin, pluginConfigs[pluginId], params);
|
|
126
|
-
|
|
127
103
|
if (!sanityCheck(plugin)) {
|
|
128
104
|
_logger.logger.error({
|
|
129
105
|
content: pluginName
|
|
130
106
|
}, "@{content} doesn't look like a valid plugin");
|
|
131
|
-
|
|
132
107
|
continue;
|
|
133
108
|
}
|
|
134
|
-
|
|
135
109
|
plugins.push(plugin);
|
|
136
110
|
continue;
|
|
137
111
|
} else {
|
|
138
112
|
_logger.logger.error({
|
|
139
113
|
pluginName
|
|
140
114
|
}, 'package not found, try to install @{pluginName} with a package manager');
|
|
141
|
-
|
|
142
115
|
continue;
|
|
143
116
|
}
|
|
144
117
|
}
|
|
145
118
|
}
|
|
146
|
-
|
|
147
119
|
debug('plugin found %s', plugins.length);
|
|
148
120
|
return plugins;
|
|
149
121
|
}
|
|
150
|
-
|
|
151
122
|
function executePlugin(plugin, pluginConfig, params) {
|
|
152
123
|
if ((0, _utils.isES6)(plugin)) {
|
|
153
|
-
debug('plugin is ES6');
|
|
124
|
+
debug('plugin is ES6');
|
|
125
|
+
// @ts-expect-error no relevant for the code
|
|
154
126
|
// eslint-disable-next-line new-cap
|
|
155
|
-
|
|
156
127
|
return new plugin.default(pluginConfig, params);
|
|
157
128
|
} else {
|
|
158
|
-
debug('plugin is commonJS');
|
|
159
|
-
|
|
129
|
+
debug('plugin is commonJS');
|
|
130
|
+
// @ts-expect-error improve this type
|
|
160
131
|
return plugin(pluginConfig, params);
|
|
161
132
|
}
|
|
162
133
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-async-loader.js","names":["debug","buildDebug","isDirectory","pathFolder","stat","lstat","asyncLoadPlugin","pluginConfigs","params","sanityCheck","prefix","pluginsIds","Object","keys","config","plugins","pluginId","pluginsPath","isAbsolute","config_path","configPath","logger","error","resolve","join","dirname","path","pluginDir","externalFilePlugin","plugin","tryLoad","isValid","executePlugin","content","push","err","warn","message","isScoped","startsWith","includes","pluginName","length","pluginConfig","isES6","default"],"sources":["../src/plugin-async-loader.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { lstat } from 'fs/promises';\nimport { dirname, isAbsolute, join, resolve } from 'path';\n\nimport { pluginUtils } from '@verdaccio/core';\nimport { logger } from '@verdaccio/logger';\nimport { Config, Logger } from '@verdaccio/types';\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\nexport type Params = { config: Config; logger: Logger };\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.\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 {*} params a set of params 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 * @return {Array} list of plugins\n */\nexport async function asyncLoadPlugin<T extends pluginUtils.Plugin<T>>(\n pluginConfigs: any = {},\n params: Params,\n sanityCheck: (plugin: PluginType<T>) => boolean,\n prefix: string = 'verdaccio'\n): Promise<PluginType<T>[]> {\n const pluginsIds = Object.keys(pluginConfigs);\n const { config } = params;\n let plugins: PluginType<T>[] = [];\n for (let pluginId of pluginsIds) {\n debug('plugin %s', pluginId);\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\n logger.debug({ path: pluginsPath }, 'plugins folder defined, loading plugins from @{path} ');\n // throws if is nto a directory\n try {\n await isDirectory(pluginsPath);\n const pluginDir = pluginsPath;\n const externalFilePlugin = resolve(pluginDir, `${prefix}-${pluginId}`);\n let plugin = tryLoad<T>(externalFilePlugin);\n if (plugin && isValid(plugin)) {\n plugin = executePlugin(plugin, pluginConfigs[pluginId], params);\n if (!sanityCheck(plugin)) {\n logger.error(\n { content: externalFilePlugin },\n \"@{content} doesn't look like a valid plugin\"\n );\n continue;\n }\n plugins.push(plugin);\n continue;\n }\n } catch (err: any) {\n logger.warn(\n { err: err.message, pluginsPath, pluginId },\n '@{err} on loading plugins at @{pluginsPath} for @{pluginId}'\n );\n }\n }\n\n if (typeof pluginId === 'string') {\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 pkg name %s', pluginName);\n let plugin = tryLoad<T>(pluginName);\n if (plugin && isValid(plugin)) {\n plugin = executePlugin(plugin, pluginConfigs[pluginId], params);\n if (!sanityCheck(plugin)) {\n logger.error({ content: pluginName }, \"@{content} doesn't look like a valid plugin\");\n continue;\n }\n plugins.push(plugin);\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('plugin found %s', plugins.length);\n return plugins;\n}\n\nexport function executePlugin<T>(\n plugin: PluginType<T>,\n pluginConfig: unknown,\n params: Params\n): PluginType<T> {\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, params) as Plugin;\n } else {\n debug('plugin is commonJS');\n // @ts-expect-error improve this type\n return plugin(pluginConfig, params) as PluginType<T>;\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin-async-loader.js","names":["debug","buildDebug","isDirectory","pathFolder","stat","lstat","asyncLoadPlugin","pluginConfigs","params","sanityCheck","prefix","pluginsIds","Object","keys","config","plugins","pluginId","pluginsPath","isAbsolute","config_path","configPath","logger","error","resolve","join","dirname","path","pluginDir","externalFilePlugin","plugin","tryLoad","isValid","executePlugin","content","push","err","warn","message","isScoped","startsWith","includes","pluginName","length","pluginConfig","isES6","default"],"sources":["../src/plugin-async-loader.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { lstat } from 'fs/promises';\nimport { dirname, isAbsolute, join, resolve } from 'path';\n\nimport { pluginUtils } from '@verdaccio/core';\nimport { logger } from '@verdaccio/logger';\nimport { Config, Logger } from '@verdaccio/types';\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\nexport type Params = { config: Config; logger: Logger };\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.\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 {*} params a set of params 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 * @return {Array} list of plugins\n */\nexport async function asyncLoadPlugin<T extends pluginUtils.Plugin<T>>(\n pluginConfigs: any = {},\n params: Params,\n sanityCheck: (plugin: PluginType<T>) => boolean,\n prefix: string = 'verdaccio'\n): Promise<PluginType<T>[]> {\n const pluginsIds = Object.keys(pluginConfigs);\n const { config } = params;\n let plugins: PluginType<T>[] = [];\n for (let pluginId of pluginsIds) {\n debug('plugin %s', pluginId);\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\n logger.debug({ path: pluginsPath }, 'plugins folder defined, loading plugins from @{path} ');\n // throws if is nto a directory\n try {\n await isDirectory(pluginsPath);\n const pluginDir = pluginsPath;\n const externalFilePlugin = resolve(pluginDir, `${prefix}-${pluginId}`);\n let plugin = tryLoad<T>(externalFilePlugin);\n if (plugin && isValid(plugin)) {\n plugin = executePlugin(plugin, pluginConfigs[pluginId], params);\n if (!sanityCheck(plugin)) {\n logger.error(\n { content: externalFilePlugin },\n \"@{content} doesn't look like a valid plugin\"\n );\n continue;\n }\n plugins.push(plugin);\n continue;\n }\n } catch (err: any) {\n logger.warn(\n { err: err.message, pluginsPath, pluginId },\n '@{err} on loading plugins at @{pluginsPath} for @{pluginId}'\n );\n }\n }\n\n if (typeof pluginId === 'string') {\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 pkg name %s', pluginName);\n let plugin = tryLoad<T>(pluginName);\n if (plugin && isValid(plugin)) {\n plugin = executePlugin(plugin, pluginConfigs[pluginId], params);\n if (!sanityCheck(plugin)) {\n logger.error({ content: pluginName }, \"@{content} doesn't look like a valid plugin\");\n continue;\n }\n plugins.push(plugin);\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('plugin found %s', plugins.length);\n return plugins;\n}\n\nexport function executePlugin<T>(\n plugin: PluginType<T>,\n pluginConfig: unknown,\n params: Params\n): PluginType<T> {\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, params) as Plugin;\n } else {\n debug('plugin is commonJS');\n // @ts-expect-error improve this type\n return plugin(pluginConfig, params) as PluginType<T>;\n }\n}\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AAGA;AAGA;AAA8D;AAE9D,MAAMA,KAAK,GAAG,IAAAC,cAAU,EAAC,+BAA+B,CAAC;AAEzD,eAAeC,WAAW,CAACC,UAAkB,EAAE;EAC7C,MAAMC,IAAI,GAAG,MAAM,IAAAC,eAAK,EAACF,UAAU,CAAC;EACpC,OAAOC,IAAI,CAACF,WAAW,EAAE;AAC3B;AAIA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeI,eAAe,CACnCC,aAAkB,GAAG,CAAC,CAAC,EACvBC,MAAc,EACdC,WAA+C,EAC/CC,MAAc,GAAG,WAAW,EACF;EAC1B,MAAMC,UAAU,GAAGC,MAAM,CAACC,IAAI,CAACN,aAAa,CAAC;EAC7C,MAAM;IAAEO;EAAO,CAAC,GAAGN,MAAM;EACzB,IAAIO,OAAwB,GAAG,EAAE;EACjC,KAAK,IAAIC,QAAQ,IAAIL,UAAU,EAAE;IAC/BX,KAAK,CAAC,WAAW,EAAEgB,QAAQ,CAAC;IAC5B,IAAI,OAAOF,MAAM,CAACC,OAAO,KAAK,QAAQ,EAAE;MACtC,IAAIE,WAAW,GAAGH,MAAM,CAACC,OAAO;MAChCf,KAAK,CAAC,gBAAgB,EAAEiB,WAAW,CAAC;MACpC,IAAI,CAAC,IAAAC,gBAAU,EAACD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CAAC,oBAAoB,CAAC;IAC3B;IACA,OAAO6B,MAAM,CAACc,YAAY,EAAEnC,MAAM,CAAC;EACrC;AACF"}
|
package/build/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { pluginUtils } from '@verdaccio/core';
|
|
2
|
-
export
|
|
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;
|
|
5
5
|
/**
|
package/build/utils.js
CHANGED
|
@@ -6,33 +6,25 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.isES6 = isES6;
|
|
7
7
|
exports.isValid = isValid;
|
|
8
8
|
exports.tryLoad = tryLoad;
|
|
9
|
-
|
|
10
9
|
var _debug = _interopRequireDefault(require("debug"));
|
|
11
|
-
|
|
12
10
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
13
|
-
|
|
14
11
|
var _logger = require("@verdaccio/logger");
|
|
15
|
-
|
|
16
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
13
|
const debug = (0, _debug.default)('verdaccio:plugin:loader:utils');
|
|
19
14
|
const MODULE_NOT_FOUND = 'MODULE_NOT_FOUND';
|
|
20
|
-
|
|
21
15
|
function isValid(plugin) {
|
|
22
16
|
// @ts-expect-error default not relevant
|
|
23
17
|
return _lodash.default.isFunction(plugin) || _lodash.default.isFunction(plugin.default);
|
|
24
18
|
}
|
|
25
|
-
|
|
26
19
|
function isES6(plugin) {
|
|
27
20
|
return Object.keys(plugin).includes('default');
|
|
28
21
|
}
|
|
22
|
+
|
|
29
23
|
/**
|
|
30
24
|
* Requires a module.
|
|
31
25
|
* @param {*} path the module's path
|
|
32
26
|
* @return {Object}
|
|
33
27
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
28
|
function tryLoad(path) {
|
|
37
29
|
try {
|
|
38
30
|
debug('loading plugin %s', path);
|
|
@@ -42,11 +34,9 @@ function tryLoad(path) {
|
|
|
42
34
|
debug('plugin %s not found', path);
|
|
43
35
|
return null;
|
|
44
36
|
}
|
|
45
|
-
|
|
46
37
|
_logger.logger.error({
|
|
47
38
|
err: err.msg
|
|
48
39
|
}, 'error loading plugin @{err}');
|
|
49
|
-
|
|
50
40
|
throw err;
|
|
51
41
|
}
|
|
52
42
|
}
|
package/build/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["debug","buildDebug","MODULE_NOT_FOUND","isValid","plugin","_","isFunction","default","isES6","Object","keys","includes","tryLoad","path","require","err","code","logger","error","msg"],"sources":["../src/utils.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport _ from 'lodash';\n\nimport { pluginUtils } from '@verdaccio/core';\nimport { logger } from '@verdaccio/logger';\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): 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('plugin %s not found', path);\n return null;\n }\n logger.error({ err: err.msg }, 'error loading plugin @{err}');\n throw err;\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","names":["debug","buildDebug","MODULE_NOT_FOUND","isValid","plugin","_","isFunction","default","isES6","Object","keys","includes","tryLoad","path","require","err","code","logger","error","msg"],"sources":["../src/utils.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport _ from 'lodash';\n\nimport { pluginUtils } from '@verdaccio/core';\nimport { logger } from '@verdaccio/logger';\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): 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('plugin %s not found', path);\n return null;\n }\n logger.error({ err: err.msg }, 'error loading plugin @{err}');\n throw err;\n }\n}\n"],"mappings":";;;;;;;;AAAA;AACA;AAGA;AAA2C;AAE3C,MAAMA,KAAK,GAAG,IAAAC,cAAU,EAAC,+BAA+B,CAAC;AACzD,MAAMC,gBAAgB,GAAG,kBAAkB;AAIpC,SAASC,OAAO,CAAIC,MAAqB,EAAW;EACzD;EACA,OAAOC,eAAC,CAACC,UAAU,CAACF,MAAM,CAAC,IAAIC,eAAC,CAACC,UAAU,CAACF,MAAM,CAACG,OAAO,CAAC;AAC7D;AAEO,SAASC,KAAK,CAAIJ,MAAqB,EAAW;EACvD,OAAOK,MAAM,CAACC,IAAI,CAACN,MAAM,CAAC,CAACO,QAAQ,CAAC,SAAS,CAAC;AAChD;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,OAAO,CAAIC,IAAY,EAAwB;EAC7D,IAAI;IACFb,KAAK,CAAC,mBAAmB,EAAEa,IAAI,CAAC;IAChC,OAAOC,OAAO,CAACD,IAAI,CAAC;EACtB,CAAC,CAAC,OAAOE,GAAQ,EAAE;IACjB,IAAIA,GAAG,CAACC,IAAI,KAAKd,gBAAgB,EAAE;MACjCF,KAAK,CAAC,qBAAqB,EAAEa,IAAI,CAAC;MAClC,OAAO,IAAI;IACb;IACAI,cAAM,CAACC,KAAK,CAAC;MAAEH,GAAG,EAAEA,GAAG,CAACI;IAAI,CAAC,EAAE,6BAA6B,CAAC;IAC7D,MAAMJ,GAAG;EACX;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdaccio/loaders",
|
|
3
|
-
"version": "6.0.0-6-next.
|
|
3
|
+
"version": "6.0.0-6-next.21",
|
|
4
4
|
"description": "loaders logic",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -13,16 +13,16 @@
|
|
|
13
13
|
"url": "https://github.com/verdaccio/verdaccio"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@verdaccio/logger": "6.0.0-6-next.
|
|
16
|
+
"@verdaccio/logger": "6.0.0-6-next.20",
|
|
17
17
|
"debug": "4.3.4",
|
|
18
18
|
"lodash": "4.17.21"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@verdaccio/core": "6.0.0-6-next.
|
|
22
|
-
"@verdaccio/config": "6.0.0-6-next.
|
|
21
|
+
"@verdaccio/core": "6.0.0-6-next.52",
|
|
22
|
+
"@verdaccio/config": "6.0.0-6-next.52",
|
|
23
23
|
"@verdaccio/types": "11.0.0-6-next.17",
|
|
24
24
|
"@verdaccio-scope/verdaccio-auth-foo": "0.0.2",
|
|
25
|
-
"verdaccio-auth-memory": "11.0.0-6-next.
|
|
25
|
+
"verdaccio-auth-memory": "11.0.0-6-next.17",
|
|
26
26
|
"customprefix-auth": "1.0.0-6-next.0"
|
|
27
27
|
},
|
|
28
28
|
"homepage": "https://verdaccio.org",
|