{"id":21401444,"url":"https://github.com/spoonx/plugin-discovery","last_synced_at":"2025-08-02T05:40:21.343Z","repository":{"id":57326071,"uuid":"85915555","full_name":"SpoonX/plugin-discovery","owner":"SpoonX","description":"Discover plugins for your CLI tool based on a prefix.","archived":false,"fork":false,"pushed_at":"2018-02-01T15:15:35.000Z","size":13,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-10T20:14:38.518Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SpoonX.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-23T06:37:20.000Z","updated_at":"2019-04-05T02:10:56.000Z","dependencies_parsed_at":"2022-09-21T01:52:46.170Z","dependency_job_id":null,"html_url":"https://github.com/SpoonX/plugin-discovery","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/SpoonX/plugin-discovery","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpoonX%2Fplugin-discovery","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpoonX%2Fplugin-discovery/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpoonX%2Fplugin-discovery/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpoonX%2Fplugin-discovery/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SpoonX","download_url":"https://codeload.github.com/SpoonX/plugin-discovery/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpoonX%2Fplugin-discovery/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268339418,"owners_count":24234545,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-22T15:27:46.546Z","updated_at":"2025-08-02T05:40:21.318Z","avatar_url":"https://github.com/SpoonX.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# plugin-discovery\n\nDiscover plugins for your (CLI) tool.\n\nThis module will scan locations on the file system in an optimal manner, in search of your plugins.\n\n## Installation\n\n`npm i --save plugin-discovery`\n\n## Usage\n\nThis plugin can be used in instance form, or statically, both async (recommended) and sync.\nThere's an example in the `example` directory of this project.\n\n```js\nconst {PluginDiscovery} = require('plugin-discovery');\n\n// Sync\nlet plugins = PluginDiscovery.discoverSync(config);\n\n// Async\nPluginDiscovery.discover(discoveryConfig).then(plugins =\u003e {\n  // Go nuts! :)\n})\n```\n\n### Config\n\nThese options are available to configure.\n\n```js\nconst configOptions = {\n\n  // Prefix of your plugins, e.g. my-prefix-foo\n  prefix: 'my-prefix',\n\n  // Strategy to use for the plugin's key. Read on for the options.\n  dictionaryKeyStrategy: PluginDiscovery.constants.STRATEGY_PROPERTY,\n\n  // Name of the property for strategies PROPERTY and METHOD.\n  dictionaryKeyProperty: 'name',\n\n  // Additional paths to look for plugins\n  searchPaths: [__dirname + '/custom_path'],\n\n  // Discover plugins in the global node_modules directory? (useful for CLI tools!)\n  discoverGlobal: true,\n\n  // Discover plugins in the current working directory?\n  discoverCwd: true,\n\n  // Import plugin based on named export? (e.g. module.exports.MyPlugin)\n  importNamed: 'MyPlugin',\n\n  // Import plugin based on named fallback export when not found after regular checks?\n  namedFallback: 'MyPluginFallback',\n\n  // Custom configurers. The key is used to allow for multiple configurers. \n  configurers: {\n    myPlugin: (key, plugin, rootImport) =\u003e {\n      // Configure for your own project here...\n    }\n  },\n\n  // Internal method used to configure. Only override when you really know what you're doing.\n  configure: (dictionaryKey, imported, root) =\u003e this.configure(dictionaryKey, imported, root)\n};\n```\n\n### Strategies\n\nThere are a couple of strategies available for determining what the key of your plugin will be in the produced plugin-dictionary.\n\nAll constants are available through: `PluginDiscovery.constants.${constant}`\n\n#### STRATEGY_MODULE_NAME\n\nUsing this strategy, the key will simply be the entire module name, including the prefix.\n\n#### STRATEGY_STRIP_PREFIX\n\nUsing this strategy, the key will simply be the entire module name, minus the prefix.\n\n#### STRATEGY_PROPERTY\n\nThis strategy allows you to export the key of the plugin, in the plugin.\n\n```js\nmodule.exports = {\n  name  : 'my_plugin',\n  plugin: MyPlugin\n};\n```\n\n_**Note:** this option requires you to also configure the `dictionaryKeyProperty`._\n\n#### STRATEGY_METHOD\n\nThis strategy allows you to export the key of the plugin, using a method on the plugin export.\n\n```js\nmodule.exports = {\n  name  : () =\u003e 'my_plugin',\n  plugin: MyPlugin\n};\n```\n\n_**Note:** this option requires you to also configure the `dictionaryKeyProperty`._\n\n#### STRATEGY_CUSTOM\n\nThis strategy means that PluginDiscovery won't index your plugins at all. Instead, you are expected to do so yourself in the configure phase. \n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspoonx%2Fplugin-discovery","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspoonx%2Fplugin-discovery","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspoonx%2Fplugin-discovery/lists"}