@verdaccio/loaders 8.0.0-next-8.4 → 8.0.0-next-8.5

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.
Files changed (40) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +30 -25
  3. package/build/plugin-async-loader.js +4 -2
  4. package/build/plugin-async-loader.js.map +1 -1
  5. package/build/utils.js +9 -1
  6. package/build/utils.js.map +1 -1
  7. package/package.json +13 -9
  8. package/.babelrc +0 -3
  9. package/CHANGELOG.md +0 -906
  10. package/src/index.ts +0 -1
  11. package/src/plugin-async-loader.ts +0 -156
  12. package/src/utils.ts +0 -37
  13. package/test/partials/config/custom-prefix-auth.yaml +0 -3
  14. package/test/partials/config/npm-plugin-auth.yaml +0 -3
  15. package/test/partials/config/npm-plugin-not-found.yaml +0 -3
  16. package/test/partials/config/plugins-folder-fake.yaml +0 -4
  17. package/test/partials/config/relative-plugins.yaml +0 -4
  18. package/test/partials/config/scope-auth.yaml +0 -3
  19. package/test/partials/config/valid-plugin-store.yaml +0 -3
  20. package/test/partials/config/valid-plugin.yaml +0 -3
  21. package/test/partials/plugin/authenticate.fail.js +0 -11
  22. package/test/partials/plugin/authenticate.passthroug.js +0 -9
  23. package/test/partials/plugin/authenticate.success.js +0 -9
  24. package/test/partials/test-plugin-storage/.eslintrc +0 -6
  25. package/test/partials/test-plugin-storage/invalid-package/package.json +0 -11
  26. package/test/partials/test-plugin-storage/invalid-plugin/index.js +0 -1
  27. package/test/partials/test-plugin-storage/invalid-plugin/package.json +0 -11
  28. package/test/partials/test-plugin-storage/invalid-plugin-sanity/index.js +0 -9
  29. package/test/partials/test-plugin-storage/invalid-plugin-sanity/package.json +0 -11
  30. package/test/partials/test-plugin-storage/verdaccio-es6-plugin/dummy.js +0 -51
  31. package/test/partials/test-plugin-storage/verdaccio-es6-plugin/index.js +0 -18
  32. package/test/partials/test-plugin-storage/verdaccio-plugin/index.js +0 -7
  33. package/test/partials/test-plugin-storage/verdaccio-plugin/package.json +0 -11
  34. package/test/partials/test-plugin-storage/verdaccio-plugin-store/index.js +0 -7
  35. package/test/partials/test-plugin-storage/verdaccio-plugin-store/package.json +0 -11
  36. package/test/partials/test-plugin-storage/verdaccio-scope/index.js +0 -7
  37. package/test/partials/test-plugin-storage/verdaccio-scope/package.json +0 -11
  38. package/test/plugin_loader_async.spec.ts +0 -175
  39. package/tsconfig.build.json +0 -10
  40. package/tsconfig.json +0 -21
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 Verdaccio contributors
3
+ Copyright (c) 2025 Verdaccio contributors
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,13 +1,19 @@
1
- # @verdaccio/loaders
1
+ # @verdaccio/loaders - Verdaccio Loader Logic
2
2
 
3
- [![backers](https://opencollective.com/verdaccio/tiers/backer/badge.svg?label=Backer&color=brightgreen)](https://opencollective.com/verdaccio)
4
- [![stackshare](https://img.shields.io/badge/Follow%20on-StackShare-blue.svg?logo=stackshare&style=flat)](https://stackshare.io/verdaccio)
5
- [![MIT](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/verdaccio/verdaccio/blob/master/LICENSE)
6
- [![Crowdin](https://d322cqt584bo4o.cloudfront.net/verdaccio/localized.svg)](https://crowdin.com/project/verdaccio)
7
- [![TODOs](https://badgen.net/https/api.tickgit.com/badgen/github.com/verdaccio/verdaccio)](https://www.tickgit.com/browse?repo=github.com/verdaccio/verdaccio)
3
+ [![Verdaccio Home](https://img.shields.io/badge/Homepage-Verdaccio-405236?style=flat)](https://verdaccio.org)
4
+ [![MIT License](https://img.shields.io/github/license/verdaccio/verdaccio?label=License&color=405236)](https://github.com/verdaccio/verdaccio/blob/master/LICENSE)
5
+ [![Verdaccio Latest](https://img.shields.io/npm/v/verdaccio?label=Latest%20Version&color=405236)](https://github.com/verdaccio/verdaccio)
6
+ [![This Package Latest](https://img.shields.io/npm/v/@verdaccio/loaders?label=@verdaccio/loaders&color=405236)](https://npmjs.com/package/@verdaccio/loaders)
8
7
 
9
- [![Twitter followers](https://img.shields.io/twitter/follow/verdaccio_npm.svg?style=social&label=Follow)](https://twitter.com/verdaccio_npm)
10
- [![Github](https://img.shields.io/github/stars/verdaccio/verdaccio.svg?style=social&label=Stars)](https://github.com/verdaccio/verdaccio/stargazers)
8
+ [![Documentation](https://img.shields.io/badge/Help-Verdaccio?style=flat&logo=Verdaccio&label=Verdaccio&color=cd4000)](https://verdaccio.org/docs)
9
+ [![Discord](https://img.shields.io/badge/Chat-Discord?style=flat&logo=Discord&label=Discord&color=cd4000)](https://discord.com/channels/388674437219745793)
10
+ [![Bluesky](https://img.shields.io/badge/Follow-Bluesky?style=flat&logo=Bluesky&label=Bluesky&color=cd4000)](https://bsky.app/profile/verdaccio.org)
11
+ [![Backers](https://img.shields.io/opencollective/backers/verdaccio?style=flat&logo=opencollective&label=Join%20Backers&color=cd4000)](https://opencollective.com/verdaccio/contribute)
12
+ [![Sponsors](https://img.shields.io/opencollective/sponsors/verdaccio?style=flat&logo=opencollective&label=Sponsor%20Us&color=cd4000)](https://opencollective.com/verdaccio/contribute)
13
+
14
+ [![Verdaccio Downloads](https://img.shields.io/npm/dm/verdaccio?style=flat&logo=npm&label=Npm%20Downloads&color=lightgrey)](https://www.npmjs.com/package/verdaccio)
15
+ [![Docker Pulls](https://img.shields.io/docker/pulls/verdaccio/verdaccio?style=flat&logo=docker&label=Docker%20Pulls&color=lightgrey)](https://hub.docker.com/r/verdaccio/verdaccio)
16
+ [![GitHub Stars](https://img.shields.io/github/stars/verdaccio?style=flat&logo=github&label=GitHub%20Stars%20%E2%AD%90&color=lightgrey)](https://github.com/verdaccio/verdaccio/stargazers)
11
17
 
12
18
  ## Donations
13
19
 
@@ -21,7 +27,7 @@ If you want to report a security vulnerability, please follow the steps which we
21
27
 
22
28
  ## Open Collective Sponsors
23
29
 
24
- Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/verdaccio#sponsor)]
30
+ Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/verdaccio/contribute)]
25
31
 
26
32
  [![sponsor](https://opencollective.com/verdaccio/sponsor/0/avatar.svg)](https://opencollective.com/verdaccio/sponsor/0/website)
27
33
  [![sponsor](https://opencollective.com/verdaccio/sponsor/1/avatar.svg)](https://opencollective.com/verdaccio/sponsor/1/website)
@@ -36,40 +42,39 @@ Support this project by becoming a sponsor. Your logo will show up here with a l
36
42
 
37
43
  ## Open Collective Backers
38
44
 
39
- Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/verdaccio#backer)]
45
+ Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/verdaccio/contribute)]
40
46
 
41
- [![backers](https://opencollective.com/verdaccio/backers.svg?width=890)](https://opencollective.com/verdaccio#backers)
47
+ [![backers](https://opencollective.com/verdaccio/backers.svg?width=890)](https://opencollective.com/verdaccio/contributes)
42
48
 
43
49
  ## Special Thanks
44
50
 
45
51
  Thanks to the following companies to help us to achieve our goals providing free open source licenses.
46
52
 
47
- [![jetbrain](assets/thanks/jetbrains/logo.png)](https://www.jetbrains.com/)
48
- [![crowdin](assets/thanks/crowdin/logo.png)](https://crowdin.com/)
49
- [![balsamiq](assets/thanks/balsamiq/logo.jpg)](https://balsamiq.com/)
53
+ [![jetbrains](https://github.com/verdaccio/verdaccio/blob/master/assets/thanks/jetbrains/logo.jpg?raw=true)](https://www.jetbrains.com/)
54
+ [![crowdin](https://github.com/verdaccio/verdaccio/blob/master/assets/thanks/crowdin/logo.png?raw=true)](https://crowdin.com/)
50
55
 
51
56
  ## Contributors
52
57
 
53
- This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].
58
+ This project exists thanks to all the people who contribute. [[Contribute](https://github.com/verdaccio/verdaccio/blob/master/CONTRIBUTING.md)].
54
59
 
55
- [![contributors](https://opencollective.com/verdaccio/contributors.svg?width=890&button=true)](../../graphs/contributors)
60
+ [![contributors](https://opencollective.com/verdaccio/contributors.svg?width=890&button=true)](https://github.com/verdaccio/verdaccio/graphs/contributors)
56
61
 
57
- ### FAQ / Contact / Troubleshoot
62
+ ## FAQ / Contact / Troubleshoot
58
63
 
59
- If you have any issue you can try the following options, do no desist to ask or check our issues database, perhaps someone has asked already what you are looking for.
64
+ If you have any issue you can try the following options. Do not hesitate to ask or check our issues database. Perhaps someone has asked already what you are looking for.
60
65
 
61
66
  - [Blog](https://verdaccio.org/blog/)
62
67
  - [Donations](https://opencollective.com/verdaccio)
63
68
  - [Reporting an issue](https://github.com/verdaccio/verdaccio/blob/master/CONTRIBUTING.md#reporting-a-bug)
64
- - [Running discussions](https://github.com/verdaccio/verdaccio/issues?q=is%3Aissue+is%3Aopen+label%3Adiscuss)
65
- - [Chat](http://chat.verdaccio.org/)
66
- - [Logos](https://verdaccio.org/docs/en/logo)
67
- - [Docker Examples](https://github.com/verdaccio/docker-examples)
69
+ - [Running discussions](https://github.com/orgs/verdaccio/discussions)
70
+ - [Chat](https://discord.com/channels/388674437219745793)
71
+ - [Logos](https://verdaccio.org/docs/logo)
72
+ - [Docker Examples](https://github.com/verdaccio/verdaccio/tree/master/docker-examples)
68
73
  - [FAQ](https://github.com/verdaccio/verdaccio/issues?utf8=%E2%9C%93&q=is%3Aissue%20label%3Aquestion%20)
69
74
 
70
- ### License
75
+ ## License
71
76
 
72
77
  Verdaccio is [MIT licensed](https://github.com/verdaccio/verdaccio/blob/master/LICENSE)
73
78
 
74
- The Verdaccio documentation and logos (excluding /thanks, e.g., .md, .png, .sketch) files within the /assets folder) is
75
- [Creative Commons licensed](https://github.com/verdaccio/verdaccio/blob/master/LICENSE-docs).
79
+ The Verdaccio documentation and logos (excluding /thanks, e.g., .md, .png, .sketch files within the /assets folder) are
80
+ [Creative Commons licensed](https://creativecommons.org/licenses/by/4.0/).
@@ -55,7 +55,7 @@ async function asyncLoadPlugin(pluginConfigs = {}, pluginOptions, sanityCheck, p
55
55
  } = pluginOptions;
56
56
  let plugins = [];
57
57
  for (let pluginId of pluginsIds) {
58
- debug('looking for plugin %o', pluginId);
58
+ debug('>>> looking for plugin %o', pluginId);
59
59
  if (typeof config.plugins === 'string') {
60
60
  let pluginsPath = config.plugins;
61
61
  debug('plugin path %s', pluginsPath);
@@ -88,6 +88,7 @@ async function asyncLoadPlugin(pluginConfigs = {}, pluginOptions, sanityCheck, p
88
88
  }, "@{content} doesn't look like a valid plugin");
89
89
  continue;
90
90
  }
91
+ debug('>>> plugin is running and passed sanity check');
91
92
  plugins.push(plugin);
92
93
  logger.info({
93
94
  prefix,
@@ -120,6 +121,7 @@ async function asyncLoadPlugin(pluginConfigs = {}, pluginOptions, sanityCheck, p
120
121
  }, "@{content} doesn't look like a valid plugin");
121
122
  continue;
122
123
  }
124
+ debug('>>> plugin is running and passed sanity check');
123
125
  plugins.push(plugin);
124
126
  logger.info({
125
127
  prefix,
@@ -135,7 +137,7 @@ async function asyncLoadPlugin(pluginConfigs = {}, pluginOptions, sanityCheck, p
135
137
  }
136
138
  }
137
139
  }
138
- debug('%s plugins found: %s', pluginCategory, plugins.length);
140
+ debug('%o plugins found: %o', pluginCategory, plugins.length);
139
141
  return plugins;
140
142
  }
141
143
  function executePlugin(plugin, pluginConfig, pluginOptions) {
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-async-loader.js","names":["_debug","_interopRequireDefault","require","_fs","_path","_utils","e","__esModule","default","debug","buildDebug","lstat","fs","promises","isDirectory","pathFolder","stat","asyncLoadPlugin","pluginConfigs","pluginOptions","sanityCheck","prefix","pluginCategory","logger","pluginsIds","Object","keys","config","plugins","pluginId","pluginsPath","isAbsolute","config_path","configPath","error","resolve","join","dirname","path","pluginDir","externalFilePlugin","plugin","tryLoad","a","b","isValid","executePlugin","content","push","info","err","warn","message","isScoped","startsWith","includes","pluginName","length","pluginConfig","isES6"],"sources":["../src/plugin-async-loader.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport fs from 'fs';\nimport { dirname, isAbsolute, join, resolve } from 'path';\n\nimport { pluginUtils } from '@verdaccio/core';\n\nimport { PluginType, isES6, isValid, tryLoad } from './utils';\n\nconst debug = buildDebug('verdaccio:plugin:loader:async');\n\nconst { lstat } = fs.promises ? fs.promises : require('fs/promises');\n\nasync function isDirectory(pathFolder: string) {\n const stat = await lstat(pathFolder);\n return stat.isDirectory();\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.\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 prefix: string = 'verdaccio',\n pluginCategory: string = ''\n): Promise<PluginType<T>[]> {\n const logger = pluginOptions?.logger;\n const pluginsIds = Object.keys(pluginConfigs);\n const { config } = pluginOptions;\n let plugins: PluginType<T>[] = [];\n for (let pluginId of pluginsIds) {\n debug('looking for plugin %o', pluginId);\n 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, `${prefix}-${pluginId}`);\n let plugin = tryLoad<T>(externalFilePlugin, (a: any, b: any) => {\n logger.error(a, b);\n });\n if (plugin && isValid(plugin)) {\n plugin = executePlugin(plugin, pluginConfigs[pluginId], pluginOptions);\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 logger.info(\n { prefix, pluginId, pluginCategory },\n 'plugin @{prefix}-@{pluginId} successfully loaded (@{pluginCategory})'\n );\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 package name %s', pluginName);\n let plugin = tryLoad<T>(pluginName, (a: any, b: any) => {\n logger.error(a, b);\n });\n if (plugin && isValid(plugin)) {\n plugin = executePlugin(plugin, pluginConfigs[pluginId], pluginOptions);\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 logger.info(\n { prefix, pluginId, pluginCategory },\n 'plugin @{prefix}-@{pluginId} 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('%s plugins found: %s', pluginCategory, plugins.length);\n return plugins;\n}\n\nexport function executePlugin<T>(\n plugin: PluginType<T>,\n pluginConfig: unknown,\n pluginOptions: pluginUtils.PluginOptions\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, pluginOptions) as Plugin;\n } else {\n debug('plugin is commonJS');\n // @ts-expect-error improve this type\n return plugin(pluginConfig, pluginOptions) as PluginType<T>;\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,GAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAIA,IAAAG,MAAA,GAAAH,OAAA;AAA8D,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE9D,MAAMG,KAAK,GAAG,IAAAC,cAAU,EAAC,+BAA+B,CAAC;AAEzD,MAAM;EAAEC;AAAM,CAAC,GAAGC,WAAE,CAACC,QAAQ,GAAGD,WAAE,CAACC,QAAQ,GAAGX,OAAO,CAAC,aAAa,CAAC;AAEpE,eAAeY,WAAWA,CAACC,UAAkB,EAAE;EAC7C,MAAMC,IAAI,GAAG,MAAML,KAAK,CAACI,UAAU,CAAC;EACpC,OAAOC,IAAI,CAACF,WAAW,CAAC,CAAC;AAC3B;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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debug","_interopRequireDefault","require","_fs","_path","_utils","e","__esModule","default","debug","buildDebug","lstat","fs","promises","isDirectory","pathFolder","stat","asyncLoadPlugin","pluginConfigs","pluginOptions","sanityCheck","prefix","pluginCategory","logger","pluginsIds","Object","keys","config","plugins","pluginId","pluginsPath","isAbsolute","config_path","configPath","error","resolve","join","dirname","path","pluginDir","externalFilePlugin","plugin","tryLoad","a","b","isValid","executePlugin","content","push","info","err","warn","message","isScoped","startsWith","includes","pluginName","length","pluginConfig","isES6"],"sources":["../src/plugin-async-loader.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport fs from 'fs';\nimport { dirname, isAbsolute, join, resolve } from 'path';\n\nimport { pluginUtils } from '@verdaccio/core';\n\nimport { PluginType, isES6, isValid, tryLoad } from './utils';\n\nconst debug = buildDebug('verdaccio:plugin:loader:async');\n\nconst { lstat } = fs.promises ? fs.promises : require('fs/promises');\n\nasync function isDirectory(pathFolder: string) {\n const stat = await lstat(pathFolder);\n return stat.isDirectory();\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.\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 prefix: string = 'verdaccio',\n pluginCategory: string = ''\n): Promise<PluginType<T>[]> {\n const logger = pluginOptions?.logger;\n const pluginsIds = Object.keys(pluginConfigs);\n const { config } = pluginOptions;\n let plugins: PluginType<T>[] = [];\n for (let pluginId of pluginsIds) {\n debug('>>> looking for plugin %o', pluginId);\n 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, `${prefix}-${pluginId}`);\n let plugin = tryLoad<T>(externalFilePlugin, (a: any, b: any) => {\n logger.error(a, b);\n });\n if (plugin && isValid(plugin)) {\n plugin = executePlugin(plugin, pluginConfigs[pluginId], pluginOptions);\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 { prefix, pluginId, pluginCategory },\n 'plugin @{prefix}-@{pluginId} successfully loaded (@{pluginCategory})'\n );\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 package name %s', pluginName);\n let plugin = tryLoad<T>(pluginName, (a: any, b: any) => {\n logger.error(a, b);\n });\n if (plugin && isValid(plugin)) {\n plugin = executePlugin(plugin, pluginConfigs[pluginId], pluginOptions);\n if (!sanityCheck(plugin)) {\n logger.error({ content: pluginName }, \"@{content} 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 { prefix, pluginId, pluginCategory },\n 'plugin @{prefix}-@{pluginId} 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): 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, pluginOptions) as Plugin;\n } else {\n debug('plugin is commonJS');\n // @ts-expect-error improve this type\n return plugin(pluginConfig, pluginOptions) as PluginType<T>;\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,GAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAIA,IAAAG,MAAA,GAAAH,OAAA;AAA8D,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE9D,MAAMG,KAA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EM,OAAO,CAAC6B,MAAM,CAAC;EAC7D,OAAO7B,OAAO;AAChB;AAEO,SAASkB,aAAaA,CAC3BL,MAAqB,EACrBiB,YAAqB,EACrBvC,aAAwC,EACzB;EACf,IAAI,IAAAwC,YAAK,EAAClB,MAAM,CAAC,EAAE;IACjBhC,KAAK,CAAC,eAAe,CAAC;IACtB;IACA;IACA,OAAO,IAAIgC,MAAM,CAACjC,OAAO,CAACkD,YAAY,EAAEvC,aAAa,CAAC;EACxD,CAAC,MAAM;IACLV,KAAK,CAAC,oBAAoB,CAAC;IAC3B;IACA,OAAOgC,MAAM,CAACiB,YAAY,EAAEvC,aAAa,CAAC;EAC5C;AACF","ignoreList":[]}
package/build/utils.js CHANGED
@@ -30,7 +30,15 @@ function tryLoad(path, onError) {
30
30
  return require(path);
31
31
  } catch (err) {
32
32
  if (err.code === MODULE_NOT_FOUND) {
33
- debug('plugin %s not found', path);
33
+ debug('"require" failed for plugin %s', path);
34
+ // If loading fails, because a dependency is missing,
35
+ // we want to log the error message and require stack
36
+ // to see where the missing dependency is.
37
+ const message = err.message.replace(/\\\\/g, '\\').split('\n');
38
+ if (!message[0].includes(path)) {
39
+ debug('%o', message[0]); // error message
40
+ debug('%o', message.slice(1)); // stack trace
41
+ }
34
42
  return null;
35
43
  }
36
44
  onError({
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":["_debug","_interopRequireDefault","require","_lodash","e","__esModule","default","debug","buildDebug","MODULE_NOT_FOUND","isValid","plugin","_","isFunction","isES6","Object","keys","includes","tryLoad","path","onError","err","code","msg"],"sources":["../src/utils.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport _ from 'lodash';\n\nimport { pluginUtils } from '@verdaccio/core';\n\nconst debug = buildDebug('verdaccio:plugin:loader:utils');\nconst MODULE_NOT_FOUND = 'MODULE_NOT_FOUND';\n\nexport type PluginType<T> = T extends pluginUtils.Plugin<T> ? T : never;\n\nexport function isValid<T>(plugin: PluginType<T>): boolean {\n // @ts-expect-error default not relevant\n return _.isFunction(plugin) || _.isFunction(plugin.default);\n}\n\nexport function isES6<T>(plugin: PluginType<T>): boolean {\n return Object.keys(plugin).includes('default');\n}\n\n/**\n * Requires a module.\n * @param {*} path the module's path\n * @return {Object}\n */\nexport function tryLoad<T>(path: string, onError: any): PluginType<T> | null {\n try {\n debug('loading plugin %s', path);\n return require(path) as PluginType<T>;\n } catch (err: any) {\n if (err.code === MODULE_NOT_FOUND) {\n debug('plugin %s not found', path);\n return null;\n }\n onError({ err: err.msg }, 'error loading plugin @{err}');\n throw err;\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AAAuB,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAIvB,MAAMG,KAAK,GAAG,IAAAC,cAAU,EAAC,+BAA+B,CAAC;AACzD,MAAMC,gBAAgB,GAAG,kBAAkB;AAIpC,SAASC,OAAOA,CAAIC,MAAqB,EAAW;EACzD;EACA,OAAOC,eAAC,CAACC,UAAU,CAACF,MAAM,CAAC,IAAIC,eAAC,CAACC,UAAU,CAACF,MAAM,CAACL,OAAO,CAAC;AAC7D;AAEO,SAASQ,KAAKA,CAAIH,MAAqB,EAAW;EACvD,OAAOI,MAAM,CAACC,IAAI,CAACL,MAAM,CAAC,CAACM,QAAQ,CAAC,SAAS,CAAC;AAChD;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,OAAOA,CAAIC,IAAY,EAAEC,OAAY,EAAwB;EAC3E,IAAI;IACFb,KAAK,CAAC,mBAAmB,EAAEY,IAAI,CAAC;IAChC,OAAOjB,OAAO,CAACiB,IAAI,CAAC;EACtB,CAAC,CAAC,OAAOE,GAAQ,EAAE;IACjB,IAAIA,GAAG,CAACC,IAAI,KAAKb,gBAAgB,EAAE;MACjCF,KAAK,CAAC,qBAAqB,EAAEY,IAAI,CAAC;MAClC,OAAO,IAAI;IACb;IACAC,OAAO,CAAC;MAAEC,GAAG,EAAEA,GAAG,CAACE;IAAI,CAAC,EAAE,6BAA6B,CAAC;IACxD,MAAMF,GAAG;EACX;AACF","ignoreList":[]}
1
+ {"version":3,"file":"utils.js","names":["_debug","_interopRequireDefault","require","_lodash","e","__esModule","default","debug","buildDebug","MODULE_NOT_FOUND","isValid","plugin","_","isFunction","isES6","Object","keys","includes","tryLoad","path","onError","err","code","message","replace","split","slice","msg"],"sources":["../src/utils.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport _ from 'lodash';\n\nimport { pluginUtils } from '@verdaccio/core';\n\nconst debug = buildDebug('verdaccio:plugin:loader:utils');\nconst MODULE_NOT_FOUND = 'MODULE_NOT_FOUND';\n\nexport type PluginType<T> = T extends pluginUtils.Plugin<T> ? T : never;\n\nexport function isValid<T>(plugin: PluginType<T>): boolean {\n // @ts-expect-error default not relevant\n return _.isFunction(plugin) || _.isFunction(plugin.default);\n}\n\nexport function isES6<T>(plugin: PluginType<T>): boolean {\n return Object.keys(plugin).includes('default');\n}\n\n/**\n * Requires a module.\n * @param {*} path the module's path\n * @return {Object}\n */\nexport function tryLoad<T>(path: string, onError: any): PluginType<T> | null {\n try {\n debug('loading plugin %s', path);\n return require(path) as PluginType<T>;\n } catch (err: any) {\n if (err.code === MODULE_NOT_FOUND) {\n debug('\"require\" failed for plugin %s', path);\n // If loading fails, because a dependency is missing,\n // we want to log the error message and require stack\n // to see where the missing dependency is.\n const message = err.message.replace(/\\\\\\\\/g, '\\\\').split('\\n');\n if (!message[0].includes(path)) {\n debug('%o', message[0]); // error message\n debug('%o', message.slice(1)); // stack trace\n }\n return null;\n }\n onError({ err: err.msg }, 'error loading plugin @{err}');\n throw err;\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAA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,CAAC;MAAEC,GAAG,EAAEA,GAAG,CAACM;IAAI,CAAC,EAAE,6BAA6B,CAAC;IACxD,MAAMN,GAAG;EACX;AACF","ignoreList":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@verdaccio/loaders",
3
- "version": "8.0.0-next-8.4",
4
- "description": "loaders logic",
3
+ "version": "8.0.0-next-8.5",
4
+ "description": "Verdaccio Loader Logic",
5
5
  "main": "./build/index.js",
6
6
  "types": "build/index.d.ts",
7
7
  "author": {
@@ -10,20 +10,24 @@
10
10
  },
11
11
  "repository": {
12
12
  "type": "https",
13
- "url": "https://github.com/verdaccio/verdaccio"
13
+ "url": "https://github.com/verdaccio/verdaccio",
14
+ "directory": "packages/loaders"
15
+ },
16
+ "bugs": {
17
+ "url": "https://github.com/verdaccio/verdaccio/issues"
14
18
  },
15
19
  "dependencies": {
16
- "debug": "4.3.7",
20
+ "debug": "4.4.0",
17
21
  "lodash": "4.17.21"
18
22
  },
19
23
  "devDependencies": {
20
- "@verdaccio/logger": "8.0.0-next-8.5",
21
- "@verdaccio/core": "8.0.0-next-8.5",
22
- "@verdaccio/config": "8.0.0-next-8.5",
23
- "@verdaccio/types": "13.0.0-next-8.2",
24
+ "@verdaccio/logger": "8.0.0-next-8.13",
25
+ "@verdaccio/core": "8.0.0-next-8.13",
26
+ "@verdaccio/config": "8.0.0-next-8.13",
27
+ "@verdaccio/types": "13.0.0-next-8.4",
24
28
  "@verdaccio-scope/verdaccio-auth-foo": "0.0.2",
25
29
  "customprefix-auth": "2.0.0",
26
- "verdaccio-auth-memory": "13.0.0-next-8.5"
30
+ "verdaccio-auth-memory": "13.0.0-next-8.13"
27
31
  },
28
32
  "homepage": "https://verdaccio.org",
29
33
  "keywords": [
package/.babelrc DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "../../.babelrc"
3
- }