@verdaccio/loaders 8.1.1 → 8.1.3

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.
@@ -132,5 +132,6 @@ function executePlugin(plugin, pluginConfig, pluginOptions, legacyMergeConfigs =
132
132
  }
133
133
  //#endregion
134
134
  exports.asyncLoadPlugin = asyncLoadPlugin;
135
+ exports.executePlugin = executePlugin;
135
136
 
136
137
  //# sourceMappingURL=plugin-async-loader.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-async-loader.js","names":[],"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, tryLoadAsync } 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 = await tryLoadAsync<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 = await tryLoadAsync<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(pluginConfig, pluginOptions) as PluginType<T>;\n }\n}\n"],"mappings":";;;;;;;;;;AAWA,IAAM,WAAA,GAAA,MAAA,SAAmB,+BAA+B;AAExD,eAAe,YAAY,YAAoB;CAE7C,QAAO,OAAA,GAAA,iBAAA,OADkB,UAAU,GACvB,YAAY;AAC1B;AAEA,SAAS,YAAY,WAAoB,cAAuB;CAC9D,OAAO,OAAA,QAAE,MAAM,CAAC,GAAG,WAAW,YAAY;AAC5C;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,eAAsB,gBACpB,gBAAqB,CAAC,GACtB,eACA,aACA,qBAA8B,OAC9B,SAAiB,gBAAA,eACjB,iBAAyB,WACC;CAC1B,MAAM,SAAS,eAAe;CAC9B,MAAM,aAAa,OAAO,KAAK,iBAAiB,CAAC,CAAC;CAClD,MAAM,EAAE,WAAW;CACnB,MAAM,UAA2B,CAAC;CAClC,KAAK,MAAM,YAAY,YAAY;EACjC,QAAM,6BAA6B,QAAQ;EAE3C,MAAM,WAAoB,SAAS,WAAW,GAAG,KAAK,SAAS,SAAS,GAAG;EAC3E,QAAM,wBAAwB,QAAQ;EACtC,MAAM,aAAa,WAAW,WAAW,GAAG,OAAO,GAAG;EACtD,QAAM,0BAA0B,UAAU;EAG1C,IAAI,OAAO,OAAO,YAAY,UAAU;GACtC,IAAI,cAAc,OAAO;GACzB,QAAM,kBAAkB,WAAW;GACnC,IAAI,EAAA,GAAA,UAAA,YAAY,WAAW,GAAG;IAC5B,IAAI,OAAO,OAAO,gBAAgB,YAAY,CAAC,OAAO,YACpD,OAAO,MACL,8FACF;IAGF,IAAI,CAAC,OAAO,YAAY;KACtB,OAAO,MAAM,sDAAsD;KACnE;IACF;IACA,eAAA,GAAA,UAAA,UAAA,GAAA,UAAA,OAAA,GAAA,UAAA,SAAmC,OAAO,UAAU,GAAG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A,qBAA8B,OACf;CAEf,IAAI,oBAAoB;EACtB,QAAM,iCAAiC;EACvC,MAAM,iBAAiB,cAAc;EACrC,eAAe,YAAY,gBAAgB,YAAY;CACzD;CACA,IAAI,cAAA,MAAM,MAAM,GAAG;EACjB,QAAM,eAAe;EAGrB,OAAO,IAAI,OAAO,QAAQ,cAAc,aAAa;CACvD,OAAO;EACL,QAAM,oBAAoB;EAE1B,OAAO,OAAO,cAAc,aAAa;CAC3C;AACF"}
1
+ {"version":3,"file":"plugin-async-loader.js","names":[],"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, tryLoadAsync } 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 = await tryLoadAsync<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 = await tryLoadAsync<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(pluginConfig, pluginOptions) as PluginType<T>;\n }\n}\n"],"mappings":";;;;;;;;;;AAWA,IAAM,WAAA,GAAA,MAAA,QAAA,CAAmB,+BAA+B;AAExD,eAAe,YAAY,YAAoB;CAE7C,QAAO,OAAA,GAAA,iBAAA,MAAA,CADkB,UAAU,EAAA,CACvB,YAAY;AAC1B;AAEA,SAAS,YAAY,WAAoB,cAAuB;CAC9D,OAAO,OAAA,QAAE,MAAM,CAAC,GAAG,WAAW,YAAY;AAC5C;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,eAAsB,gBACpB,gBAAqB,CAAC,GACtB,eACA,aACA,qBAA8B,OAC9B,SAAiB,gBAAA,eACjB,iBAAyB,WACC;CAC1B,MAAM,SAAS,eAAe;CAC9B,MAAM,aAAa,OAAO,KAAK,iBAAiB,CAAC,CAAC;CAClD,MAAM,EAAE,WAAW;CACnB,MAAM,UAA2B,CAAC;CAClC,KAAK,MAAM,YAAY,YAAY;EACjC,QAAM,6BAA6B,QAAQ;EAE3C,MAAM,WAAoB,SAAS,WAAW,GAAG,KAAK,SAAS,SAAS,GAAG;EAC3E,QAAM,wBAAwB,QAAQ;EACtC,MAAM,aAAa,WAAW,WAAW,GAAG,OAAO,GAAG;EACtD,QAAM,0BAA0B,UAAU;EAG1C,IAAI,OAAO,OAAO,YAAY,UAAU;GACtC,IAAI,cAAc,OAAO;GACzB,QAAM,kBAAkB,WAAW;GACnC,IAAI,EAAA,GAAA,UAAA,WAAA,CAAY,WAAW,GAAG;IAC5B,IAAI,OAAO,OAAO,gBAAgB,YAAY,CAAC,OAAO,YACpD,OAAO,MACL,8FACF;IAGF,IAAI,CAAC,OAAO,YAAY;KACtB,OAAO,MAAM,sDAAsD;KACnE;IACF;IACA,eAAA,GAAA,UAAA,QAAA,EAAA,GAAA,UAAA,KAAA,EAAA,GAAA,UAAA,QAAA,C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AEA,SAAgB,cACd,QACA,cACA,eACA,qBAA8B,OACf;CAEf,IAAI,oBAAoB;EACtB,QAAM,iCAAiC;EACvC,MAAM,iBAAiB,cAAc;EACrC,eAAe,YAAY,gBAAgB,YAAY;CACzD;CACA,IAAI,cAAA,MAAM,MAAM,GAAG;EACjB,QAAM,eAAe;EAGrB,OAAO,IAAI,OAAO,QAAQ,cAAc,aAAa;CACvD,OAAO;EACL,QAAM,oBAAoB;EAE1B,OAAO,OAAO,cAAc,aAAa;CAC3C;AACF"}
@@ -128,6 +128,6 @@ function executePlugin(plugin, pluginConfig, pluginOptions, legacyMergeConfigs =
128
128
  }
129
129
  }
130
130
  //#endregion
131
- export { asyncLoadPlugin };
131
+ export { asyncLoadPlugin, executePlugin };
132
132
 
133
133
  //# sourceMappingURL=plugin-async-loader.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-async-loader.mjs","names":[],"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, tryLoadAsync } 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 = await tryLoadAsync<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 = await tryLoadAsync<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(pluginConfig, pluginOptions) as PluginType<T>;\n }\n}\n"],"mappings":";;;;;;;AAWA,IAAM,QAAQ,WAAW,+BAA+B;AAExD,eAAe,YAAY,YAAoB;CAE7C,QAAO,MADY,MAAM,UAAU,GACvB,YAAY;AAC1B;AAEA,SAAS,YAAY,WAAoB,cAAuB;CAC9D,OAAO,EAAE,MAAM,CAAC,GAAG,WAAW,YAAY;AAC5C;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,eAAsB,gBACpB,gBAAqB,CAAC,GACtB,eACA,aACA,qBAA8B,OAC9B,SAAiB,eACjB,iBAAyB,WACC;CAC1B,MAAM,SAAS,eAAe;CAC9B,MAAM,aAAa,OAAO,KAAK,iBAAiB,CAAC,CAAC;CAClD,MAAM,EAAE,WAAW;CACnB,MAAM,UAA2B,CAAC;CAClC,KAAK,MAAM,YAAY,YAAY;EACjC,MAAM,6BAA6B,QAAQ;EAE3C,MAAM,WAAoB,SAAS,WAAW,GAAG,KAAK,SAAS,SAAS,GAAG;EAC3E,MAAM,wBAAwB,QAAQ;EACtC,MAAM,aAAa,WAAW,WAAW,GAAG,OAAO,GAAG;EACtD,MAAM,0BAA0B,UAAU;EAG1C,IAAI,OAAO,OAAO,YAAY,UAAU;GACtC,IAAI,cAAc,OAAO;GACzB,MAAM,kBAAkB,WAAW;GACnC,IAAI,CAAC,WAAW,WAAW,GAAG;IAC5B,IAAI,OAAO,OAAO,gBAAgB,YAAY,CAAC,OAAO,YACpD,OAAO,MACL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ACA,MAAM,wBAAwB,gBAAgB,QAAQ,MAAM;CAC5D,OAAO;AACT;AAEA,SAAgB,cACd,QACA,cACA,eACA,qBAA8B,OACf;CAEf,IAAI,oBAAoB;EACtB,MAAM,iCAAiC;EACvC,MAAM,iBAAiB,cAAc;EACrC,eAAe,YAAY,gBAAgB,YAAY;CACzD;CACA,IAAI,MAAM,MAAM,GAAG;EACjB,MAAM,eAAe;EAGrB,OAAO,IAAI,OAAO,QAAQ,cAAc,aAAa;CACvD,OAAO;EACL,MAAM,oBAAoB;EAE1B,OAAO,OAAO,cAAc,aAAa;CAC3C;AACF"}
1
+ {"version":3,"file":"plugin-async-loader.mjs","names":[],"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, tryLoadAsync } 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 = await tryLoadAsync<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 = await tryLoadAsync<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(pluginConfig, pluginOptions) as PluginType<T>;\n }\n}\n"],"mappings":";;;;;;;AAWA,IAAM,QAAQ,WAAW,+BAA+B;AAExD,eAAe,YAAY,YAAoB;CAE7C,QAAO,MADY,MAAM,UAAU,EAAA,CACvB,YAAY;AAC1B;AAEA,SAAS,YAAY,WAAoB,cAAuB;CAC9D,OAAO,EAAE,MAAM,CAAC,GAAG,WAAW,YAAY;AAC5C;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,eAAsB,gBACpB,gBAAqB,CAAC,GACtB,eACA,aACA,qBAA8B,OAC9B,SAAiB,eACjB,iBAAyB,WACC;CAC1B,MAAM,SAAS,eAAe;CAC9B,MAAM,aAAa,OAAO,KAAK,iBAAiB,CAAC,CAAC;CAClD,MAAM,EAAE,WAAW;CACnB,MAAM,UAA2B,CAAC;CAClC,KAAK,MAAM,YAAY,YAAY;EACjC,MAAM,6BAA6B,QAAQ;EAE3C,MAAM,WAAoB,SAAS,WAAW,GAAG,KAAK,SAAS,SAAS,GAAG;EAC3E,MAAM,wBAAwB,QAAQ;EACtC,MAAM,aAAa,WAAW,WAAW,GAAG,OAAO,GAAG;EACtD,MAAM,0BAA0B,UAAU;EAG1C,IAAI,OAAO,OAAO,YAAY,UAAU;GACtC,IAAI,cAAc,OAAO;GACzB,MAAM,kBAAkB,WAAW;GACnC,IAAI,CAAC,WAAW,WAAW,GAAG;IAC5B,IAAI,OAAO,OAAO,gBAAgB,YAAY,CAAC,OAAO,YACpD,OAAO,MACL,8FACF;IAGF,IAAI,CAAC,OAAO,YAAY;KACtB,OAAO,MAAM,sDAAsD;KACnE;IACF;IACA,cAAc,QAAQ,KAAK,QAAQ,OAAO,UAAU,GAAG,WAAW,CAAC;GACrE;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C;EACvC,MAAM,iBAAiB,cAAc;EACrC,eAAe,YAAY,gBAAgB,YAAY;CACzD;CACA,IAAI,MAAM,MAAM,GAAG;EACjB,MAAM,eAAe;EAGrB,OAAO,IAAI,OAAO,QAAQ,cAAc,aAAa;CACvD,OAAO;EACL,MAAM,oBAAoB;EAE1B,OAAO,OAAO,cAAc,aAAa;CAC3C;AACF"}
package/build/utils.js CHANGED
@@ -115,6 +115,7 @@ async function tryLoadAsync(path, onError) {
115
115
  //#endregion
116
116
  exports.isES6 = isES6;
117
117
  exports.isValid = isValid;
118
+ exports.tryLoad = tryLoad;
118
119
  exports.tryLoadAsync = tryLoadAsync;
119
120
 
120
121
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport _ from 'lodash';\nimport { existsSync, readFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { isAbsolute, join } from 'node:path';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\n\nimport type { pluginUtils } from '@verdaccio/core';\n\nconst debug = buildDebug('verdaccio:plugin:loader:utils');\nconst MODULE_NOT_FOUND = 'MODULE_NOT_FOUND';\nconst ERR_REQUIRE_ESM = 'ERR_REQUIRE_ESM';\n// thrown by require(esm) when the module uses top-level await\nconst ERR_REQUIRE_ASYNC_MODULE = 'ERR_REQUIRE_ASYNC_MODULE';\n\n// the ESM build has no ambient require; create one so CJS plugins keep loading.\n// rolldown rewrites bare `require` to a throwing stub in the ESM output and\n// lowers `import.meta` to `{}` in the CJS output, so `import.meta.url` is only\n// truthy in the ESM build; module-scoped __filename covers the CJS build\n// (checking `typeof __filename`/`typeof require` instead is unsafe: node -e and\n// the REPL leak both as globals into ESM modules)\nconst requireModule = import.meta.url ? createRequire(import.meta.url) : createRequire(__filename);\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 requireModule(path) as PluginType<T>;\n } catch (err: any) {\n if (err.code === MODULE_NOT_FOUND) {\n debug('\"require\" failed for plugin %s', path);\n const message = err.message.replace(/\\\\\\\\/g, '\\\\').split('\\n');\n if (!message[0].includes(path)) {\n // the plugin itself was found but one of its own dependencies is\n // missing: that is a real load error — reporting \"not found\" (and\n // re-evaluating the plugin through the import() fallback) would mask\n // the actual cause and run its side effects twice\n debug('%o', message[0]); // error message\n debug('%o', message.slice(1)); // stack trace\n onError({ err: err.message }, 'error loading plugin @{err}');\n throw err;\n }\n return null;\n }\n if (err.code === ERR_REQUIRE_ESM || err.code === ERR_REQUIRE_ASYNC_MODULE) {\n debug('\"require\" failed for ESM plugin %s, will try dynamic import', path);\n return null;\n }\n onError({ err: err.message }, 'error loading plugin @{err}');\n throw err;\n }\n}\n\n/**\n * Resolve the entry point for a directory-based plugin.\n * dynamic import() does not support directory imports, so we need to\n * find the actual file to import (via package.json \"main\"/\"exports\" or index.js).\n */\nfunction resolveEntryPoint(dirPath: string): string {\n const pkgPath = join(dirPath, 'package.json');\n if (existsSync(pkgPath)) {\n try {\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));\n // Check exports first, then module, then main; only string entries are\n // usable paths — condition objects without them fall through to the\n // next field (otherwise we would return the directory itself, which\n // dynamic import() rejects)\n if (pkg.exports) {\n // exports may use the sugar form with conditions at the top level\n // instead of a '.' subpath map\n const dotExport = pkg.exports['.'] ?? pkg.exports;\n if (typeof dotExport === 'string') {\n return join(dirPath, dotExport);\n }\n if (typeof dotExport?.import === 'string') {\n return join(dirPath, dotExport.import);\n }\n if (typeof dotExport?.import?.default === 'string') {\n return join(dirPath, dotExport.import.default);\n }\n if (typeof dotExport?.default === 'string') {\n return join(dirPath, dotExport.default);\n }\n }\n if (pkg.module) {\n return join(dirPath, pkg.module);\n }\n if (pkg.main) {\n return join(dirPath, pkg.main);\n }\n } catch {\n // fall through to index.js\n }\n }\n return join(dirPath, 'index.js');\n}\n\n/**\n * Dynamically imports a module (supports ESM plugins).\n * Falls back from require() to import() for ESM compatibility.\n * @param {*} path the module's path\n * @return {Object}\n */\nexport async function tryLoadAsync<T>(path: string, onError: any): Promise<PluginType<T> | null> {\n // Try require first (handles CJS and will be fast)\n try {\n const cjsResult = tryLoad<T>(path, onError);\n if (cjsResult !== null) {\n return cjsResult;\n }\n } catch (err: any) {\n // tryLoad() returns null for the not-found / ESM cases and only throws on\n // a real load error (the plugin itself failed to evaluate); retrying via\n // import() would run the plugin's side effects twice and mask the error\n debug('require() threw a real load error for %s: %s', path, err.message);\n throw err;\n }\n\n // Fallback to dynamic import for ESM modules\n // import() doesn't support directory imports — resolve the entry point,\n // also for manifest-less directory plugins that only ship an index.js\n let importPath = path;\n try {\n if (\n isAbsolute(path) &&\n (existsSync(join(path, 'package.json')) || existsSync(join(path, 'index.js')))\n ) {\n importPath = resolveEntryPoint(path);\n debug('resolved ESM entry point: %s', importPath);\n }\n\n // Convert to file URL for import() compatibility (isAbsolute also covers\n // Windows paths like C:\\..., which startsWith('/') would miss)\n const importUrl = isAbsolute(importPath) ? pathToFileURL(importPath).href : importPath;\n debug('trying dynamic import for plugin %s', importUrl);\n const module = await import(importUrl);\n debug('dynamic import succeeded for plugin %s', importUrl);\n return module as PluginType<T>;\n } catch (err: any) {\n if (err.code === 'ERR_UNSUPPORTED_DIR_IMPORT') {\n // only the plugin path itself is ever imported as a directory\n debug('\"import\" failed for plugin %s', path);\n return null;\n }\n if (err.code === MODULE_NOT_FOUND || err.code === 'ERR_MODULE_NOT_FOUND') {\n // \"not found\" may refer to the plugin itself (plugin not installed:\n // return null) or to a missing dependency inside an existing plugin —\n // a real load error that must surface, mirroring the require() path\n // the missing specifier may be reported as a file:// URL\n const missingRaw = /Cannot find (?:module|package) '([^']+)'/.exec(err.message)?.[1];\n const missing = missingRaw?.startsWith('file://') ? fileURLToPath(missingRaw) : missingRaw;\n const refersToPlugin =\n missing === undefined ||\n missing === path ||\n missing === importPath ||\n missing.startsWith(path);\n if (refersToPlugin) {\n debug('\"import\" failed for plugin %s', path);\n return null;\n }\n debug('plugin %s exists but its dependency %s is missing', path, missing);\n }\n onError({ err: err.message }, 'error loading plugin @{err}');\n throw err;\n }\n}\n"],"mappings":";;;;;;;;;;AASA,IAAM,WAAA,GAAA,MAAA,SAAmB,+BAA+B;AACxD,IAAM,mBAAmB;AACzB,IAAM,kBAAkB;AAExB,IAAM,2BAA2B;AAQjC,IAAM,gBAAA,CAAA,EAA4B,OAAA,GAAA,YAAA,eAAA,CAAA,EAAgC,GAAG,KAAA,GAAA,YAAA,eAAkB,UAAU;AAIjG,SAAgB,QAAW,QAAgC;CAEzD,OAAO,OAAA,QAAE,WAAW,MAAM,KAAK,OAAA,QAAE,WAAW,OAAO,OAAO;AAC5D;AAEA,SAAgB,MAAS,QAAgC;CACvD,OAAO,OAAO,KAAK,MAAM,EAAE,SAAS,SAAS;AAC/C;;;;;;AAOA,SAAgB,QAAW,MAAc,SAAoC;CAC3E,IAAI;EACF,QAAM,qBAAqB,IAAI;EAC/B,OAAO,cAAc,IAAI;CAC3B,SAAS,KAAU;EACjB,IAAI,IAAI,SAAS,kBAAkB;GACjC,QAAM,oCAAkC,IAAI;GAC5C,MAAM,UAAU,IAAI,QAAQ,QAAQ,SAAS,IAAI,EAAE,MAAM,IAAI;GAC7D,IAAI,CAAC,QAAQ,GAAG,SAAS,IAAI,GAAG;IAK9B,QAAM,MAAM,QAAQ,EAAE;IACtB,QAAM,MAAM,QAAQ,MAAM,CAAC,CAAC;IAC5B,QAAQ,EAAE,KAAK,IAAI,QAAQ,GAAG,6BAA6B;IAC3D,MAAM;GACR;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AI,OAAA,GAAA,QAAA,aAAA,GAAA,UAAA,MACE,MAAM,cAAc,CAAC,MAAA,GAAA,QAAA,aAAA,GAAA,UAAA,MAAqB,MAAM,UAAU,CAAC,IAC5E;GACA,aAAa,kBAAkB,IAAI;GACnC,QAAM,gCAAgC,UAAU;EAClD;EAIA,MAAM,aAAA,GAAA,UAAA,YAAuB,UAAU,KAAA,GAAA,SAAA,eAAkB,UAAU,EAAE,OAAO;EAC5E,QAAM,uCAAuC,SAAS;EACtD,MAAM,SAAS,MAAM,OAAO;EAC5B,QAAM,0CAA0C,SAAS;EACzD,OAAO;CACT,SAAS,KAAU;EACjB,IAAI,IAAI,SAAS,8BAA8B;GAE7C,QAAM,mCAAiC,IAAI;GAC3C,OAAO;EACT;EACA,IAAI,IAAI,SAAS,oBAAoB,IAAI,SAAS,wBAAwB;GAKxE,MAAM,aAAa,2CAA2C,KAAK,IAAI,OAAO,IAAI;GAClF,MAAM,UAAU,YAAY,WAAW,SAAS,KAAA,GAAA,SAAA,eAAkB,UAAU,IAAI;GAMhF,IAJE,YAAY,KAAA,KACZ,YAAY,QACZ,YAAY,cACZ,QAAQ,WAAW,IAAI,GACL;IAClB,QAAM,mCAAiC,IAAI;IAC3C,OAAO;GACT;GACA,QAAM,qDAAqD,MAAM,OAAO;EAC1E;EACA,QAAQ,EAAE,KAAK,IAAI,QAAQ,GAAG,6BAA6B;EAC3D,MAAM;CACR;AACF"}
1
+ {"version":3,"file":"utils.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport _ from 'lodash';\nimport { existsSync, readFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { isAbsolute, join } from 'node:path';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\n\nimport type { pluginUtils } from '@verdaccio/core';\n\nconst debug = buildDebug('verdaccio:plugin:loader:utils');\nconst MODULE_NOT_FOUND = 'MODULE_NOT_FOUND';\nconst ERR_REQUIRE_ESM = 'ERR_REQUIRE_ESM';\n// thrown by require(esm) when the module uses top-level await\nconst ERR_REQUIRE_ASYNC_MODULE = 'ERR_REQUIRE_ASYNC_MODULE';\n\n// the ESM build has no ambient require; create one so CJS plugins keep loading.\n// rolldown rewrites bare `require` to a throwing stub in the ESM output and\n// lowers `import.meta` to `{}` in the CJS output, so `import.meta.url` is only\n// truthy in the ESM build; module-scoped __filename covers the CJS build\n// (checking `typeof __filename`/`typeof require` instead is unsafe: node -e and\n// the REPL leak both as globals into ESM modules)\nconst requireModule = import.meta.url ? createRequire(import.meta.url) : createRequire(__filename);\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 requireModule(path) as PluginType<T>;\n } catch (err: any) {\n if (err.code === MODULE_NOT_FOUND) {\n debug('\"require\" failed for plugin %s', path);\n const message = err.message.replace(/\\\\\\\\/g, '\\\\').split('\\n');\n if (!message[0].includes(path)) {\n // the plugin itself was found but one of its own dependencies is\n // missing: that is a real load error — reporting \"not found\" (and\n // re-evaluating the plugin through the import() fallback) would mask\n // the actual cause and run its side effects twice\n debug('%o', message[0]); // error message\n debug('%o', message.slice(1)); // stack trace\n onError({ err: err.message }, 'error loading plugin @{err}');\n throw err;\n }\n return null;\n }\n if (err.code === ERR_REQUIRE_ESM || err.code === ERR_REQUIRE_ASYNC_MODULE) {\n debug('\"require\" failed for ESM plugin %s, will try dynamic import', path);\n return null;\n }\n onError({ err: err.message }, 'error loading plugin @{err}');\n throw err;\n }\n}\n\n/**\n * Resolve the entry point for a directory-based plugin.\n * dynamic import() does not support directory imports, so we need to\n * find the actual file to import (via package.json \"main\"/\"exports\" or index.js).\n */\nfunction resolveEntryPoint(dirPath: string): string {\n const pkgPath = join(dirPath, 'package.json');\n if (existsSync(pkgPath)) {\n try {\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));\n // Check exports first, then module, then main; only string entries are\n // usable paths — condition objects without them fall through to the\n // next field (otherwise we would return the directory itself, which\n // dynamic import() rejects)\n if (pkg.exports) {\n // exports may use the sugar form with conditions at the top level\n // instead of a '.' subpath map\n const dotExport = pkg.exports['.'] ?? pkg.exports;\n if (typeof dotExport === 'string') {\n return join(dirPath, dotExport);\n }\n if (typeof dotExport?.import === 'string') {\n return join(dirPath, dotExport.import);\n }\n if (typeof dotExport?.import?.default === 'string') {\n return join(dirPath, dotExport.import.default);\n }\n if (typeof dotExport?.default === 'string') {\n return join(dirPath, dotExport.default);\n }\n }\n if (pkg.module) {\n return join(dirPath, pkg.module);\n }\n if (pkg.main) {\n return join(dirPath, pkg.main);\n }\n } catch {\n // fall through to index.js\n }\n }\n return join(dirPath, 'index.js');\n}\n\n/**\n * Dynamically imports a module (supports ESM plugins).\n * Falls back from require() to import() for ESM compatibility.\n * @param {*} path the module's path\n * @return {Object}\n */\nexport async function tryLoadAsync<T>(path: string, onError: any): Promise<PluginType<T> | null> {\n // Try require first (handles CJS and will be fast)\n try {\n const cjsResult = tryLoad<T>(path, onError);\n if (cjsResult !== null) {\n return cjsResult;\n }\n } catch (err: any) {\n // tryLoad() returns null for the not-found / ESM cases and only throws on\n // a real load error (the plugin itself failed to evaluate); retrying via\n // import() would run the plugin's side effects twice and mask the error\n debug('require() threw a real load error for %s: %s', path, err.message);\n throw err;\n }\n\n // Fallback to dynamic import for ESM modules\n // import() doesn't support directory imports — resolve the entry point,\n // also for manifest-less directory plugins that only ship an index.js\n let importPath = path;\n try {\n if (\n isAbsolute(path) &&\n (existsSync(join(path, 'package.json')) || existsSync(join(path, 'index.js')))\n ) {\n importPath = resolveEntryPoint(path);\n debug('resolved ESM entry point: %s', importPath);\n }\n\n // Convert to file URL for import() compatibility (isAbsolute also covers\n // Windows paths like C:\\..., which startsWith('/') would miss)\n const importUrl = isAbsolute(importPath) ? pathToFileURL(importPath).href : importPath;\n debug('trying dynamic import for plugin %s', importUrl);\n const module = await import(importUrl);\n debug('dynamic import succeeded for plugin %s', importUrl);\n return module as PluginType<T>;\n } catch (err: any) {\n if (err.code === 'ERR_UNSUPPORTED_DIR_IMPORT') {\n // only the plugin path itself is ever imported as a directory\n debug('\"import\" failed for plugin %s', path);\n return null;\n }\n if (err.code === MODULE_NOT_FOUND || err.code === 'ERR_MODULE_NOT_FOUND') {\n // \"not found\" may refer to the plugin itself (plugin not installed:\n // return null) or to a missing dependency inside an existing plugin —\n // a real load error that must surface, mirroring the require() path\n // the missing specifier may be reported as a file:// URL\n const missingRaw = /Cannot find (?:module|package) '([^']+)'/.exec(err.message)?.[1];\n const missing = missingRaw?.startsWith('file://') ? fileURLToPath(missingRaw) : missingRaw;\n const refersToPlugin =\n missing === undefined ||\n missing === path ||\n missing === importPath ||\n missing.startsWith(path);\n if (refersToPlugin) {\n debug('\"import\" failed for plugin %s', path);\n return null;\n }\n debug('plugin %s exists but its dependency %s is missing', path, missing);\n }\n onError({ err: err.message }, 'error loading plugin @{err}');\n throw err;\n }\n}\n"],"mappings":";;;;;;;;;;AASA,IAAM,WAAA,GAAA,MAAA,QAAA,CAAmB,+BAA+B;AACxD,IAAM,mBAAmB;AACzB,IAAM,kBAAkB;AAExB,IAAM,2BAA2B;AAQjC,IAAM,gBAAA,CAAA,EAA4B,OAAA,GAAA,YAAA,cAAA,CAAA,CAAA,EAAgC,GAAG,KAAA,GAAA,YAAA,cAAA,CAAkB,UAAU;AAIjG,SAAgB,QAAW,QAAgC;CAEzD,OAAO,OAAA,QAAE,WAAW,MAAM,KAAK,OAAA,QAAE,WAAW,OAAO,OAAO;AAC5D;AAEA,SAAgB,MAAS,QAAgC;CACvD,OAAO,OAAO,KAAK,MAAM,CAAC,CAAC,SAAS,SAAS;A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GAMhF,IAJE,YAAY,KAAA,KACZ,YAAY,QACZ,YAAY,cACZ,QAAQ,WAAW,IAAI,GACL;IAClB,QAAM,mCAAiC,IAAI;IAC3C,OAAO;GACT;GACA,QAAM,qDAAqD,MAAM,OAAO;EAC1E;EACA,QAAQ,EAAE,KAAK,IAAI,QAAQ,GAAG,6BAA6B;EAC3D,MAAM;CACR;AACF"}
package/build/utils.mjs CHANGED
@@ -110,6 +110,6 @@ async function tryLoadAsync(path, onError) {
110
110
  }
111
111
  }
112
112
  //#endregion
113
- export { isES6, isValid, tryLoadAsync };
113
+ export { isES6, isValid, tryLoad, tryLoadAsync };
114
114
 
115
115
  //# sourceMappingURL=utils.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.mjs","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport _ from 'lodash';\nimport { existsSync, readFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { isAbsolute, join } from 'node:path';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\n\nimport type { pluginUtils } from '@verdaccio/core';\n\nconst debug = buildDebug('verdaccio:plugin:loader:utils');\nconst MODULE_NOT_FOUND = 'MODULE_NOT_FOUND';\nconst ERR_REQUIRE_ESM = 'ERR_REQUIRE_ESM';\n// thrown by require(esm) when the module uses top-level await\nconst ERR_REQUIRE_ASYNC_MODULE = 'ERR_REQUIRE_ASYNC_MODULE';\n\n// the ESM build has no ambient require; create one so CJS plugins keep loading.\n// rolldown rewrites bare `require` to a throwing stub in the ESM output and\n// lowers `import.meta` to `{}` in the CJS output, so `import.meta.url` is only\n// truthy in the ESM build; module-scoped __filename covers the CJS build\n// (checking `typeof __filename`/`typeof require` instead is unsafe: node -e and\n// the REPL leak both as globals into ESM modules)\nconst requireModule = import.meta.url ? createRequire(import.meta.url) : createRequire(__filename);\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 requireModule(path) as PluginType<T>;\n } catch (err: any) {\n if (err.code === MODULE_NOT_FOUND) {\n debug('\"require\" failed for plugin %s', path);\n const message = err.message.replace(/\\\\\\\\/g, '\\\\').split('\\n');\n if (!message[0].includes(path)) {\n // the plugin itself was found but one of its own dependencies is\n // missing: that is a real load error — reporting \"not found\" (and\n // re-evaluating the plugin through the import() fallback) would mask\n // the actual cause and run its side effects twice\n debug('%o', message[0]); // error message\n debug('%o', message.slice(1)); // stack trace\n onError({ err: err.message }, 'error loading plugin @{err}');\n throw err;\n }\n return null;\n }\n if (err.code === ERR_REQUIRE_ESM || err.code === ERR_REQUIRE_ASYNC_MODULE) {\n debug('\"require\" failed for ESM plugin %s, will try dynamic import', path);\n return null;\n }\n onError({ err: err.message }, 'error loading plugin @{err}');\n throw err;\n }\n}\n\n/**\n * Resolve the entry point for a directory-based plugin.\n * dynamic import() does not support directory imports, so we need to\n * find the actual file to import (via package.json \"main\"/\"exports\" or index.js).\n */\nfunction resolveEntryPoint(dirPath: string): string {\n const pkgPath = join(dirPath, 'package.json');\n if (existsSync(pkgPath)) {\n try {\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));\n // Check exports first, then module, then main; only string entries are\n // usable paths — condition objects without them fall through to the\n // next field (otherwise we would return the directory itself, which\n // dynamic import() rejects)\n if (pkg.exports) {\n // exports may use the sugar form with conditions at the top level\n // instead of a '.' subpath map\n const dotExport = pkg.exports['.'] ?? pkg.exports;\n if (typeof dotExport === 'string') {\n return join(dirPath, dotExport);\n }\n if (typeof dotExport?.import === 'string') {\n return join(dirPath, dotExport.import);\n }\n if (typeof dotExport?.import?.default === 'string') {\n return join(dirPath, dotExport.import.default);\n }\n if (typeof dotExport?.default === 'string') {\n return join(dirPath, dotExport.default);\n }\n }\n if (pkg.module) {\n return join(dirPath, pkg.module);\n }\n if (pkg.main) {\n return join(dirPath, pkg.main);\n }\n } catch {\n // fall through to index.js\n }\n }\n return join(dirPath, 'index.js');\n}\n\n/**\n * Dynamically imports a module (supports ESM plugins).\n * Falls back from require() to import() for ESM compatibility.\n * @param {*} path the module's path\n * @return {Object}\n */\nexport async function tryLoadAsync<T>(path: string, onError: any): Promise<PluginType<T> | null> {\n // Try require first (handles CJS and will be fast)\n try {\n const cjsResult = tryLoad<T>(path, onError);\n if (cjsResult !== null) {\n return cjsResult;\n }\n } catch (err: any) {\n // tryLoad() returns null for the not-found / ESM cases and only throws on\n // a real load error (the plugin itself failed to evaluate); retrying via\n // import() would run the plugin's side effects twice and mask the error\n debug('require() threw a real load error for %s: %s', path, err.message);\n throw err;\n }\n\n // Fallback to dynamic import for ESM modules\n // import() doesn't support directory imports — resolve the entry point,\n // also for manifest-less directory plugins that only ship an index.js\n let importPath = path;\n try {\n if (\n isAbsolute(path) &&\n (existsSync(join(path, 'package.json')) || existsSync(join(path, 'index.js')))\n ) {\n importPath = resolveEntryPoint(path);\n debug('resolved ESM entry point: %s', importPath);\n }\n\n // Convert to file URL for import() compatibility (isAbsolute also covers\n // Windows paths like C:\\..., which startsWith('/') would miss)\n const importUrl = isAbsolute(importPath) ? pathToFileURL(importPath).href : importPath;\n debug('trying dynamic import for plugin %s', importUrl);\n const module = await import(importUrl);\n debug('dynamic import succeeded for plugin %s', importUrl);\n return module as PluginType<T>;\n } catch (err: any) {\n if (err.code === 'ERR_UNSUPPORTED_DIR_IMPORT') {\n // only the plugin path itself is ever imported as a directory\n debug('\"import\" failed for plugin %s', path);\n return null;\n }\n if (err.code === MODULE_NOT_FOUND || err.code === 'ERR_MODULE_NOT_FOUND') {\n // \"not found\" may refer to the plugin itself (plugin not installed:\n // return null) or to a missing dependency inside an existing plugin —\n // a real load error that must surface, mirroring the require() path\n // the missing specifier may be reported as a file:// URL\n const missingRaw = /Cannot find (?:module|package) '([^']+)'/.exec(err.message)?.[1];\n const missing = missingRaw?.startsWith('file://') ? fileURLToPath(missingRaw) : missingRaw;\n const refersToPlugin =\n missing === undefined ||\n missing === path ||\n missing === importPath ||\n missing.startsWith(path);\n if (refersToPlugin) {\n debug('\"import\" failed for plugin %s', path);\n return null;\n }\n debug('plugin %s exists but its dependency %s is missing', path, missing);\n }\n onError({ err: err.message }, 'error loading plugin @{err}');\n throw err;\n }\n}\n"],"mappings":";;;;;;;AASA,IAAM,QAAQ,WAAW,+BAA+B;AACxD,IAAM,mBAAmB;AACzB,IAAM,kBAAkB;AAExB,IAAM,2BAA2B;AAQjC,IAAM,gBAAgB,OAAO,KAAK,MAAM,cAAc,OAAO,KAAK,GAAG,IAAI,cAAc,UAAU;AAIjG,SAAgB,QAAW,QAAgC;CAEzD,OAAO,EAAE,WAAW,MAAM,KAAK,EAAE,WAAW,OAAO,OAAO;AAC5D;AAEA,SAAgB,MAAS,QAAgC;CACvD,OAAO,OAAO,KAAK,MAAM,EAAE,SAAS,SAAS;AAC/C;;;;;;AAOA,SAAgB,QAAW,MAAc,SAAoC;CAC3E,IAAI;EACF,MAAM,qBAAqB,IAAI;EAC/B,OAAO,cAAc,IAAI;CAC3B,SAAS,KAAU;EACjB,IAAI,IAAI,SAAS,kBAAkB;GACjC,MAAM,oCAAkC,IAAI;GAC5C,MAAM,UAAU,IAAI,QAAQ,QAAQ,SAAS,IAAI,EAAE,MAAM,IAAI;GAC7D,IAAI,CAAC,QAAQ,GAAG,SAAS,IAAI,GAAG;IAK9B,MAAM,MAAM,QAAQ,EAAE;IACtB,MAAM,MAAM,QAAQ,MAAM,CAAC,CAAC;IAC5B,QAAQ,EAAE,KAAK,IAAI,QAAQ,GAAG,6BAA6B;IAC3D,MAAM;GACR;GACA,OAAO;EACT;EACA,IAAI,IAAI,SAAS,mBAAmB,IAAI,SAAS,0B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AAO;EAC5E,MAAM,uCAAuC,SAAS;EACtD,MAAM,SAAS,MAAM,OAAO;EAC5B,MAAM,0CAA0C,SAAS;EACzD,OAAO;CACT,SAAS,KAAU;EACjB,IAAI,IAAI,SAAS,8BAA8B;GAE7C,MAAM,mCAAiC,IAAI;GAC3C,OAAO;EACT;EACA,IAAI,IAAI,SAAS,oBAAoB,IAAI,SAAS,wBAAwB;GAKxE,MAAM,aAAa,2CAA2C,KAAK,IAAI,OAAO,IAAI;GAClF,MAAM,UAAU,YAAY,WAAW,SAAS,IAAI,cAAc,UAAU,IAAI;GAMhF,IAJE,YAAY,KAAA,KACZ,YAAY,QACZ,YAAY,cACZ,QAAQ,WAAW,IAAI,GACL;IAClB,MAAM,mCAAiC,IAAI;IAC3C,OAAO;GACT;GACA,MAAM,qDAAqD,MAAM,OAAO;EAC1E;EACA,QAAQ,EAAE,KAAK,IAAI,QAAQ,GAAG,6BAA6B;EAC3D,MAAM;CACR;AACF"}
1
+ {"version":3,"file":"utils.mjs","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport _ from 'lodash';\nimport { existsSync, readFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { isAbsolute, join } from 'node:path';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\n\nimport type { pluginUtils } from '@verdaccio/core';\n\nconst debug = buildDebug('verdaccio:plugin:loader:utils');\nconst MODULE_NOT_FOUND = 'MODULE_NOT_FOUND';\nconst ERR_REQUIRE_ESM = 'ERR_REQUIRE_ESM';\n// thrown by require(esm) when the module uses top-level await\nconst ERR_REQUIRE_ASYNC_MODULE = 'ERR_REQUIRE_ASYNC_MODULE';\n\n// the ESM build has no ambient require; create one so CJS plugins keep loading.\n// rolldown rewrites bare `require` to a throwing stub in the ESM output and\n// lowers `import.meta` to `{}` in the CJS output, so `import.meta.url` is only\n// truthy in the ESM build; module-scoped __filename covers the CJS build\n// (checking `typeof __filename`/`typeof require` instead is unsafe: node -e and\n// the REPL leak both as globals into ESM modules)\nconst requireModule = import.meta.url ? createRequire(import.meta.url) : createRequire(__filename);\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 requireModule(path) as PluginType<T>;\n } catch (err: any) {\n if (err.code === MODULE_NOT_FOUND) {\n debug('\"require\" failed for plugin %s', path);\n const message = err.message.replace(/\\\\\\\\/g, '\\\\').split('\\n');\n if (!message[0].includes(path)) {\n // the plugin itself was found but one of its own dependencies is\n // missing: that is a real load error — reporting \"not found\" (and\n // re-evaluating the plugin through the import() fallback) would mask\n // the actual cause and run its side effects twice\n debug('%o', message[0]); // error message\n debug('%o', message.slice(1)); // stack trace\n onError({ err: err.message }, 'error loading plugin @{err}');\n throw err;\n }\n return null;\n }\n if (err.code === ERR_REQUIRE_ESM || err.code === ERR_REQUIRE_ASYNC_MODULE) {\n debug('\"require\" failed for ESM plugin %s, will try dynamic import', path);\n return null;\n }\n onError({ err: err.message }, 'error loading plugin @{err}');\n throw err;\n }\n}\n\n/**\n * Resolve the entry point for a directory-based plugin.\n * dynamic import() does not support directory imports, so we need to\n * find the actual file to import (via package.json \"main\"/\"exports\" or index.js).\n */\nfunction resolveEntryPoint(dirPath: string): string {\n const pkgPath = join(dirPath, 'package.json');\n if (existsSync(pkgPath)) {\n try {\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));\n // Check exports first, then module, then main; only string entries are\n // usable paths — condition objects without them fall through to the\n // next field (otherwise we would return the directory itself, which\n // dynamic import() rejects)\n if (pkg.exports) {\n // exports may use the sugar form with conditions at the top level\n // instead of a '.' subpath map\n const dotExport = pkg.exports['.'] ?? pkg.exports;\n if (typeof dotExport === 'string') {\n return join(dirPath, dotExport);\n }\n if (typeof dotExport?.import === 'string') {\n return join(dirPath, dotExport.import);\n }\n if (typeof dotExport?.import?.default === 'string') {\n return join(dirPath, dotExport.import.default);\n }\n if (typeof dotExport?.default === 'string') {\n return join(dirPath, dotExport.default);\n }\n }\n if (pkg.module) {\n return join(dirPath, pkg.module);\n }\n if (pkg.main) {\n return join(dirPath, pkg.main);\n }\n } catch {\n // fall through to index.js\n }\n }\n return join(dirPath, 'index.js');\n}\n\n/**\n * Dynamically imports a module (supports ESM plugins).\n * Falls back from require() to import() for ESM compatibility.\n * @param {*} path the module's path\n * @return {Object}\n */\nexport async function tryLoadAsync<T>(path: string, onError: any): Promise<PluginType<T> | null> {\n // Try require first (handles CJS and will be fast)\n try {\n const cjsResult = tryLoad<T>(path, onError);\n if (cjsResult !== null) {\n return cjsResult;\n }\n } catch (err: any) {\n // tryLoad() returns null for the not-found / ESM cases and only throws on\n // a real load error (the plugin itself failed to evaluate); retrying via\n // import() would run the plugin's side effects twice and mask the error\n debug('require() threw a real load error for %s: %s', path, err.message);\n throw err;\n }\n\n // Fallback to dynamic import for ESM modules\n // import() doesn't support directory imports — resolve the entry point,\n // also for manifest-less directory plugins that only ship an index.js\n let importPath = path;\n try {\n if (\n isAbsolute(path) &&\n (existsSync(join(path, 'package.json')) || existsSync(join(path, 'index.js')))\n ) {\n importPath = resolveEntryPoint(path);\n debug('resolved ESM entry point: %s', importPath);\n }\n\n // Convert to file URL for import() compatibility (isAbsolute also covers\n // Windows paths like C:\\..., which startsWith('/') would miss)\n const importUrl = isAbsolute(importPath) ? pathToFileURL(importPath).href : importPath;\n debug('trying dynamic import for plugin %s', importUrl);\n const module = await import(importUrl);\n debug('dynamic import succeeded for plugin %s', importUrl);\n return module as PluginType<T>;\n } catch (err: any) {\n if (err.code === 'ERR_UNSUPPORTED_DIR_IMPORT') {\n // only the plugin path itself is ever imported as a directory\n debug('\"import\" failed for plugin %s', path);\n return null;\n }\n if (err.code === MODULE_NOT_FOUND || err.code === 'ERR_MODULE_NOT_FOUND') {\n // \"not found\" may refer to the plugin itself (plugin not installed:\n // return null) or to a missing dependency inside an existing plugin —\n // a real load error that must surface, mirroring the require() path\n // the missing specifier may be reported as a file:// URL\n const missingRaw = /Cannot find (?:module|package) '([^']+)'/.exec(err.message)?.[1];\n const missing = missingRaw?.startsWith('file://') ? fileURLToPath(missingRaw) : missingRaw;\n const refersToPlugin =\n missing === undefined ||\n missing === path ||\n missing === importPath ||\n missing.startsWith(path);\n if (refersToPlugin) {\n debug('\"import\" failed for plugin %s', path);\n return null;\n }\n debug('plugin %s exists but its dependency %s is missing', path, missing);\n }\n onError({ err: err.message }, 'error loading plugin @{err}');\n throw err;\n }\n}\n"],"mappings":";;;;;;;AASA,IAAM,QAAQ,WAAW,+BAA+B;AACxD,IAAM,mBAAmB;AACzB,IAAM,kBAAkB;AAExB,IAAM,2BAA2B;AAQjC,IAAM,gBAAgB,OAAO,KAAK,MAAM,cAAc,OAAO,KAAK,GAAG,IAAI,cAAc,UAAU;AAIjG,SAAgB,QAAW,QAAgC;CAEzD,OAAO,EAAE,WAAW,MAAM,KAAK,EAAE,WAAW,OAAO,OAAO;AAC5D;AAEA,SAAgB,MAAS,QAAgC;CACvD,OAAO,OAAO,KAAK,MAAM,CAAC,CAAC,SAAS,SAAS;AAC/C;;;;;;AAOA,SAAgB,QAAW,MAAc,SAAoC;CAC3E,IAAI;EACF,MAAM,qBAAqB,IAAI;EAC/B,OAAO,cAAc,IAAI;CAC3B,SAAS,KAAU;EACjB,IAAI,IAAI,SAAS,kBAAkB;GACjC,MAAM,oCAAkC,IAAI;GAC5C,MAAM,UAAU,IAAI,QAAQ,QAAQ,SAAS,IAAI,CAAC,CAAC,MAAM,IAAI;GAC7D,IAAI,CAAC,QAAQ,EAAE,CAAC,SAAS,IAAI,GAAG;IAK9B,MAAM,MAAM,QAAQ,EAAE;IAC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MAAM,cAAc,CAAC,KAAK,WAAW,KAAK,MAAM,UAAU,CAAC,IAC5E;GACA,aAAa,kBAAkB,IAAI;GACnC,MAAM,gCAAgC,UAAU;EAClD;EAIA,MAAM,YAAY,WAAW,UAAU,IAAI,cAAc,UAAU,CAAC,CAAC,OAAO;EAC5E,MAAM,uCAAuC,SAAS;EACtD,MAAM,SAAS,MAAM,OAAO;EAC5B,MAAM,0CAA0C,SAAS;EACzD,OAAO;CACT,SAAS,KAAU;EACjB,IAAI,IAAI,SAAS,8BAA8B;GAE7C,MAAM,mCAAiC,IAAI;GAC3C,OAAO;EACT;EACA,IAAI,IAAI,SAAS,oBAAoB,IAAI,SAAS,wBAAwB;GAKxE,MAAM,aAAa,2CAA2C,KAAK,IAAI,OAAO,CAAC,GAAG;GAClF,MAAM,UAAU,YAAY,WAAW,SAAS,IAAI,cAAc,UAAU,IAAI;GAMhF,IAJE,YAAY,KAAA,KACZ,YAAY,QACZ,YAAY,cACZ,QAAQ,WAAW,IAAI,GACL;IAClB,MAAM,mCAAiC,IAAI;IAC3C,OAAO;GACT;GACA,MAAM,qDAAqD,MAAM,OAAO;EAC1E;EACA,QAAQ,EAAE,KAAK,IAAI,QAAQ,GAAG,6BAA6B;EAC3D,MAAM;CACR;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdaccio/loaders",
3
- "version": "8.1.1",
3
+ "version": "8.1.3",
4
4
  "description": "Verdaccio Loader Logic",
5
5
  "keywords": [
6
6
  "enterprise",
@@ -48,18 +48,18 @@
48
48
  "./build/*": "./build/*"
49
49
  },
50
50
  "dependencies": {
51
- "@verdaccio/core": "8.2.1",
51
+ "@verdaccio/core": "8.3.0",
52
52
  "debug": "4.4.3",
53
53
  "lodash": "4.18.1"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@verdaccio-scope/verdaccio-auth-foo": "0.0.2",
57
- "@verdaccio/config": "8.2.1",
58
- "@verdaccio/core": "8.2.1",
59
- "@verdaccio/logger": "8.1.1",
60
- "vite": "8.0.16",
61
- "vitest": "4.1.2",
62
- "verdaccio-auth-memory": "13.1.1"
57
+ "@verdaccio/config": "8.3.0",
58
+ "@verdaccio/core": "8.3.0",
59
+ "@verdaccio/logger": "8.1.3",
60
+ "vite": "8.1.5",
61
+ "vitest": "4.1.10",
62
+ "verdaccio-auth-memory": "13.1.3"
63
63
  },
64
64
  "engines": {
65
65
  "node": ">=22"