{"id":21158254,"url":"https://github.com/simbo/auto-plug","last_synced_at":"2025-08-02T10:33:06.569Z","repository":{"id":24850150,"uuid":"28265196","full_name":"simbo/auto-plug","owner":"simbo","description":"Auto-require plugin packages by prefix. (for i.e. Gulp, Grunt or other heavy plugin-dependent packages)","archived":false,"fork":false,"pushed_at":"2015-09-16T13:54:35.000Z","size":290,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-09T12:50:54.735Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/auto-plug","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/simbo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-12-20T11:23:38.000Z","updated_at":"2016-10-08T11:22:52.000Z","dependencies_parsed_at":"2022-09-16T12:12:25.601Z","dependency_job_id":null,"html_url":"https://github.com/simbo/auto-plug","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/simbo/auto-plug","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simbo%2Fauto-plug","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simbo%2Fauto-plug/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simbo%2Fauto-plug/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simbo%2Fauto-plug/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simbo","download_url":"https://codeload.github.com/simbo/auto-plug/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simbo%2Fauto-plug/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268370969,"owners_count":24239781,"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-20T12:19:04.106Z","updated_at":"2025-08-02T10:33:06.539Z","avatar_url":"https://github.com/simbo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"auto-plug\n=========\n\n  \u003e Auto-require plugin packages by prefix. (for i.e. [Gulp](https://github.com/gulpjs/gulp), [Grunt](https://github.com/gruntjs/grunt) or other\n  \u003e heavy plugin-dependent packages)\n\n[![npm Package Version](https://img.shields.io/npm/v/auto-plug.svg?style=flat-square)](https://www.npmjs.com/package/auto-plug)\n[![MIT License](http://img.shields.io/:license-mit-blue.svg?style=flat-square)](http://simbo.mit-license.org)\n[![Travis Build Status](https://img.shields.io/travis/simbo/auto-plug/master.svg?style=flat-square)](https://travis-ci.org/simbo/auto-plug)\n[![Code Climate GPA](https://img.shields.io/codeclimate/github/simbo/auto-plug.svg?style=flat-square)](https://codeclimate.com/github/simbo/auto-plug)\n[![Code Climate Test Coverage](https://img.shields.io/codeclimate/coverage/github/simbo/auto-plug.svg?style=flat-square)](https://codeclimate.com/github/simbo/auto-plug)\n\n[![Dependencies Status](https://img.shields.io/david/simbo/auto-plug.svg?style=flat-square)](https://david-dm.org/simbo/auto-plug)\n[![devDependencies Status](https://img.shields.io/david/dev/simbo/auto-plug.svg?style=flat-square)](https://david-dm.org/simbo/auto-plug#info=devDependencies)\n\n---\n\n\n\u003c!-- MarkdownTOC --\u003e\n\n- [Install](#install)\n- [Usage](#usage)\n    - [with Gulp](#with-gulp)\n    - [with Grunt](#with-grunt)\n    - [with any other thing](#with-any-other-thing)\n    - [Tip](#tip)\n- [Options](#options)\n    - [Default options](#default-options)\n- [API Usage](#api-usage)\n- [License](#license)\n\n\u003c!-- /MarkdownTOC --\u003e\n\n\n## Install\n\n``` bash\n$ npm install auto-plug\n```\n\n\n## Usage\n\n***auto-plug*** will return an object containing the required module exports. \nIf your config data (package.json) contains package names like `foo-this` and\n`foo-that`, they can be autoloaded by\n\n``` javascript\nvar plugins = require('auto-plug')('foo')`\n```\n\nand then accessed by `plugins.this()`or `plugins.that()`.\n\nInstead of a simple prefix string you can also set [custom options](#options):\n\n``` javascript\nvar plugins = require('auto-plug')({ prefix: 'foo', lazy: false });\n```\n\n\n### with Gulp\n\nJust set the prefix option to `gulp`:\n\n``` javascript\n// Gulpfile.js\nvar gulp = require('gulp'),\n    gulpPlugins = require('auto-plug')('gulp');\ngulp.task('default', function() {\n    return gulp\n        .src('some/glob')\n        .pipe(gulpPlugins.someGulpThing())\n        .pipe(gulpPlugins.someOtherGulpThing())\n        // ...\n    }\n});\n```\n\n\n### with Grunt\n\nGrunt needs it's own require function:\n\n``` javascript\n// Gruntfile.js\nmodule.exports = function (grunt) {\n    require('auto-plug')({ prefix: 'grunt', require: grunt.loadNpmTasks });\n    // do grunt things as usual\n}\n```\n\n\n### with any other thing\n\n… i.e. with [Metalsmith](https://github.com/segmentio/metalsmith):\n\n``` javascript\nvar metalsmith = require('metalsmith')\n    metalsmithPlugins = require('auto-plug')('metalsmith');\n\n    Metalsmith\n        .source('.')\n        .use(metalsmithPlugins.someMetalsmithThing())\n        .use(metalsmithPlugins.someOtherMetalsmithThing())\n        .build();\n```\n\n\n### Tip\n\nIf you already loaded your package.json's data, pass it as config option to speed up things:\n\n``` javascript\nvar pkg = require(process.cwd() + '/package.json'),\n    plugins = require('auo-plug')({ prefix: 'foo', config: pkg });\n```\n\n\n## Options\n\nYou either have to define a `prefix` or a `pattern` and `replaceExp`. All other options are optional.\n\n  - `prefix`  \n    can be used to quickly define `pattern` and `replaceExpr` at once (see [default options](#default-options))\n\n  - `pattern`  \n    (default: `[prefix + '-*', prefix + '.*']`)  \n    a globbing pattern to find packages in config for require\n\n  - `replaceExpr`  \n    (default: `new RegExp('^' + prefix + '([\\.-])')`)  \n    a regular expression for what shall be removed from a package name when adding to container object\n\n  - `scope`  \n    (default: `['dependencies', 'devDependencies']`)  \n    which keys in config object contain packages to require\n\n  - `module`\n    (default: the module that executed `require('auto-plug')`)\n    The module used to find the default `config` and `requireFn` options\n    \n  - `config`  \n    (default: `module` option's package.json data)  \n    the config where auto-plug will look for packages to require; can be a plain object or a string containing a path to require\n\n  - `requireFn`  \n    (default: `module` option's `require` property)  \n    the function to be used for requiring packages\n\n  - `camelize`  \n    (default: `true`)  \n    whether package names should be converted to camelcase when adding to container object or not\n\n  - `lazy`  \n    (default: `true`)  \n    whether packages should be lazy-loaded (loaded when called for the first time) or directly when calling auto-plug\n\n  - `rename`  \n    (default: `{}`)  \n    a plain object for custom renaming; keys are original package names and values the respective rename string\n\n\n### Default options\n\n``` javascript\n{\n    prefix: undefined,\n    pattern: [prefix + '-*', prefix + '.*'],\n    replaceExpr: new RegExp('^' + prefix + '([\\.-])'),\n    scope: ['dependencies', 'devDependencies'],\n    module: module.parent, // the module that require()'d auto-plug\n    config: findup('package.json', {cwd: path.dirname(this.options.module.filename)}),\n    requireFn: this.options.module.require.bind(this.options.module),\n    camelize: true,\n    lazy: true,\n    rename: {}\n}\n```\n\n\n## API Usage\n\n``` javascript\n// get your AutoPlug instance\nvar AutoPlug = require('auto-plug').AutoPlug,\n    autoPlug = new AutoPlug('gulp');\n// find matching packages, require them and add them to container\nautoPlug.plug();\n// manually add a package to container\nautoPlug.addPackageToContainer('runSequence');\n// get the container\nvar g = autoPlug.getContainer();\n```\n\n\n## License\n\n[MIT \u0026copy; 2014 Simon Lepel](http://simbo.mit-license.org/)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimbo%2Fauto-plug","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimbo%2Fauto-plug","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimbo%2Fauto-plug/lists"}