UNPKG

10.4 kBMarkdownView Raw
1# @oclif/plugin-plugins
2
3plugins plugin for oclif
4
5[![Version](https://img.shields.io/npm/v/@oclif/plugin-plugins.svg)](https://npmjs.org/package/@oclif/plugin-plugins)
6[![Downloads/week](https://img.shields.io/npm/dw/@oclif/plugin-plugins.svg)](https://npmjs.org/package/@oclif/plugin-plugins)
7[![License](https://img.shields.io/npm/l/@oclif/plugin-plugins.svg)](https://github.com/oclif/plugin-plugins/blob/main/package.json)
8
9<!-- toc -->
10* [@oclif/plugin-plugins](#oclifplugin-plugins)
11* [What is this?](#what-is-this)
12* [Usage](#usage)
13* [Friendly names](#friendly-names)
14* [Aliases](#aliases)
15* [Environment Variables](#environment-variables)
16* [Commands](#commands)
17* [Contributing](#contributing)
18<!-- tocstop -->
19
20# What is this?
21
22This plugin is used to allow users to install plugins into your oclif CLI at runtime. For example, in the Heroku CLI this is used to allow people to install plugins such as the Heroku Kafka plugin:
23
24```sh-session
25$ heroku plugins:install heroku-kafka
26$ heroku kafka
27```
28
29This is useful to allow users to create their own plugins to work in your CLI or to allow you to build functionality that users can optionally install.
30
31One particular way this is useful is for building functionality you aren't ready to include in a public repository. Build your plugin separately as a plugin, then include it as a core plugin later into your CLI.
32
33# Usage
34
35First add the plugin to your project with `yarn add @oclif/plugin-plugins`, then add it to the `package.json` of the oclif CLI:
36
37```js
38{
39 "name": "mycli",
40 "version": "0.0.0",
41 // ...
42 "oclif": {
43 "plugins": ["@oclif/plugin-help", "@oclif/plugin-plugins"]
44 }
45}
46```
47
48Now the user can run any of the commands below to manage plugins at runtime.
49
50# Friendly names
51
52To make it simpler for users to install plugins, we have "friendly name" functionality. With this, you can run `mycli plugins:install myplugin` and it will first check if `@mynpmorg/plugin-myplugin` exists on npm before trying to install `myplugin`. This is useful if you want to use a generic name that's already taken in npm.
53
54To set this up, simply set the `oclif.scope` to the name of your npm org. In the example above, this would be `mynpmorg`.
55
56# Aliases
57
58Over time in the Heroku CLI we've changed plugin names, brought plugins into the core of the CLI, or sunset old plugins that no longer function. There is support in this plugin for dealing with these situations.
59
60For renaming plugins, add an alias section to `oclif.aliases` in `package.json`:
61
62```json
63"aliases": {
64 "old-name-plugin": "new-name-plugin"
65}
66```
67
68If a user had `old-name-plugin` installed, the next time the CLI is updated it will remove `old-name-plugin` and install `new-name-plugin`. If a user types `mycli plugins:install old-name-plugin` it will actually install `new-name-plugin` instead.
69
70For removing plugins that are no longer needed (either because they're sunset or because they've been moved into core), set the alias to null:
71
72```json
73"aliases": {
74 "old-name-plugin": null
75}
76```
77
78`old-name-plugin` will be autoremoved on the next update and will not be able to be installed with `mycli plugins:install old-name-plugin`.
79
80# Environment Variables
81
82`<CLI>_USE_NETWORK_MUTEX` if true, use the `--mutex=network` option on yarn operations
83`<CLI>_NETWORK_MUTEX_PORT` specify the port for the `mutex=network` option, depends on `<CLI>_USE_NETWORK_MUTEX`
84`<CLI>_NETWORK_TIMEOUT` specify the `--network-timeout` option on yarn operation (set in milliseconds)
85
86# Commands
87
88<!-- commands -->
89* [`mycli plugins`](#mycli-plugins)
90* [`mycli plugins add PLUGIN`](#mycli-plugins-add-plugin)
91* [`mycli plugins:inspect PLUGIN...`](#mycli-pluginsinspect-plugin)
92* [`mycli plugins install PLUGIN`](#mycli-plugins-install-plugin)
93* [`mycli plugins link PATH`](#mycli-plugins-link-path)
94* [`mycli plugins remove [PLUGIN]`](#mycli-plugins-remove-plugin)
95* [`mycli plugins reset`](#mycli-plugins-reset)
96* [`mycli plugins uninstall [PLUGIN]`](#mycli-plugins-uninstall-plugin)
97* [`mycli plugins unlink [PLUGIN]`](#mycli-plugins-unlink-plugin)
98* [`mycli plugins update`](#mycli-plugins-update)
99
100## `mycli plugins`
101
102List installed plugins.
103
104```
105USAGE
106 $ mycli plugins [--json] [--core]
107
108FLAGS
109 --core Show core plugins.
110
111GLOBAL FLAGS
112 --json Format output as json.
113
114DESCRIPTION
115 List installed plugins.
116
117EXAMPLES
118 $ mycli plugins
119```
120
121_See code: [src/commands/plugins/index.ts](https://github.com/oclif/plugin-plugins/blob/v5.0.14/src/commands/plugins/index.ts)_
122
123## `mycli plugins add PLUGIN`
124
125Installs a plugin into mycli.
126
127```
128USAGE
129 $ mycli plugins add PLUGIN... [--json] [-f] [-h] [-s | -v]
130
131ARGUMENTS
132 PLUGIN... Plugin to install.
133
134FLAGS
135 -f, --force Force npm to fetch remote resources even if a local copy exists on disk.
136 -h, --help Show CLI help.
137 -s, --silent Silences npm output.
138 -v, --verbose Show verbose npm output.
139
140GLOBAL FLAGS
141 --json Format output as json.
142
143DESCRIPTION
144 Installs a plugin into mycli.
145
146 Uses bundled npm executable to install plugins into /home/runner/.local/share/@oclif/plugin-plugins
147
148 Installation of a user-installed plugin will override a core plugin.
149
150 Use the MYCLI_NPM_LOG_LEVEL environment variable to set the npm loglevel.
151 Use the MYCLI_NPM_REGISTRY environment variable to set the npm registry.
152
153ALIASES
154 $ mycli plugins add
155
156EXAMPLES
157 Install a plugin from npm registry.
158
159 $ mycli plugins add myplugin
160
161 Install a plugin from a github url.
162
163 $ mycli plugins add https://github.com/someuser/someplugin
164
165 Install a plugin from a github slug.
166
167 $ mycli plugins add someuser/someplugin
168```
169
170## `mycli plugins:inspect PLUGIN...`
171
172Displays installation properties of a plugin.
173
174```
175USAGE
176 $ mycli plugins inspect PLUGIN...
177
178ARGUMENTS
179 PLUGIN... [default: .] Plugin to inspect.
180
181FLAGS
182 -h, --help Show CLI help.
183 -v, --verbose
184
185GLOBAL FLAGS
186 --json Format output as json.
187
188DESCRIPTION
189 Displays installation properties of a plugin.
190
191EXAMPLES
192 $ mycli plugins inspect myplugin
193```
194
195_See code: [src/commands/plugins/inspect.ts](https://github.com/oclif/plugin-plugins/blob/v5.0.14/src/commands/plugins/inspect.ts)_
196
197## `mycli plugins install PLUGIN`
198
199Installs a plugin into mycli.
200
201```
202USAGE
203 $ mycli plugins install PLUGIN... [--json] [-f] [-h] [-s | -v]
204
205ARGUMENTS
206 PLUGIN... Plugin to install.
207
208FLAGS
209 -f, --force Force npm to fetch remote resources even if a local copy exists on disk.
210 -h, --help Show CLI help.
211 -s, --silent Silences npm output.
212 -v, --verbose Show verbose npm output.
213
214GLOBAL FLAGS
215 --json Format output as json.
216
217DESCRIPTION
218 Installs a plugin into mycli.
219
220 Uses bundled npm executable to install plugins into /home/runner/.local/share/@oclif/plugin-plugins
221
222 Installation of a user-installed plugin will override a core plugin.
223
224 Use the MYCLI_NPM_LOG_LEVEL environment variable to set the npm loglevel.
225 Use the MYCLI_NPM_REGISTRY environment variable to set the npm registry.
226
227ALIASES
228 $ mycli plugins add
229
230EXAMPLES
231 Install a plugin from npm registry.
232
233 $ mycli plugins install myplugin
234
235 Install a plugin from a github url.
236
237 $ mycli plugins install https://github.com/someuser/someplugin
238
239 Install a plugin from a github slug.
240
241 $ mycli plugins install someuser/someplugin
242```
243
244_See code: [src/commands/plugins/install.ts](https://github.com/oclif/plugin-plugins/blob/v5.0.14/src/commands/plugins/install.ts)_
245
246## `mycli plugins link PATH`
247
248Links a plugin into the CLI for development.
249
250```
251USAGE
252 $ mycli plugins link PATH [-h] [--install] [-v]
253
254ARGUMENTS
255 PATH [default: .] path to plugin
256
257FLAGS
258 -h, --help Show CLI help.
259 -v, --verbose
260 --[no-]install Install dependencies after linking the plugin.
261
262DESCRIPTION
263 Links a plugin into the CLI for development.
264 Installation of a linked plugin will override a user-installed or core plugin.
265
266 e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello'
267 command will override the user-installed or core plugin implementation. This is useful for development work.
268
269
270EXAMPLES
271 $ mycli plugins link myplugin
272```
273
274_See code: [src/commands/plugins/link.ts](https://github.com/oclif/plugin-plugins/blob/v5.0.14/src/commands/plugins/link.ts)_
275
276## `mycli plugins remove [PLUGIN]`
277
278Removes a plugin from the CLI.
279
280```
281USAGE
282 $ mycli plugins remove [PLUGIN...] [-h] [-v]
283
284ARGUMENTS
285 PLUGIN... plugin to uninstall
286
287FLAGS
288 -h, --help Show CLI help.
289 -v, --verbose
290
291DESCRIPTION
292 Removes a plugin from the CLI.
293
294ALIASES
295 $ mycli plugins unlink
296 $ mycli plugins remove
297
298EXAMPLES
299 $ mycli plugins remove myplugin
300```
301
302## `mycli plugins reset`
303
304Remove all user-installed and linked plugins.
305
306```
307USAGE
308 $ mycli plugins reset [--hard] [--reinstall]
309
310FLAGS
311 --hard Delete node_modules and package manager related files in addition to uninstalling plugins.
312 --reinstall Reinstall all plugins after uninstalling.
313```
314
315_See code: [src/commands/plugins/reset.ts](https://github.com/oclif/plugin-plugins/blob/v5.0.14/src/commands/plugins/reset.ts)_
316
317## `mycli plugins uninstall [PLUGIN]`
318
319Removes a plugin from the CLI.
320
321```
322USAGE
323 $ mycli plugins uninstall [PLUGIN...] [-h] [-v]
324
325ARGUMENTS
326 PLUGIN... plugin to uninstall
327
328FLAGS
329 -h, --help Show CLI help.
330 -v, --verbose
331
332DESCRIPTION
333 Removes a plugin from the CLI.
334
335ALIASES
336 $ mycli plugins unlink
337 $ mycli plugins remove
338
339EXAMPLES
340 $ mycli plugins uninstall myplugin
341```
342
343_See code: [src/commands/plugins/uninstall.ts](https://github.com/oclif/plugin-plugins/blob/v5.0.14/src/commands/plugins/uninstall.ts)_
344
345## `mycli plugins unlink [PLUGIN]`
346
347Removes a plugin from the CLI.
348
349```
350USAGE
351 $ mycli plugins unlink [PLUGIN...] [-h] [-v]
352
353ARGUMENTS
354 PLUGIN... plugin to uninstall
355
356FLAGS
357 -h, --help Show CLI help.
358 -v, --verbose
359
360DESCRIPTION
361 Removes a plugin from the CLI.
362
363ALIASES
364 $ mycli plugins unlink
365 $ mycli plugins remove
366
367EXAMPLES
368 $ mycli plugins unlink myplugin
369```
370
371## `mycli plugins update`
372
373Update installed plugins.
374
375```
376USAGE
377 $ mycli plugins update [-h] [-v]
378
379FLAGS
380 -h, --help Show CLI help.
381 -v, --verbose
382
383DESCRIPTION
384 Update installed plugins.
385```
386
387_See code: [src/commands/plugins/update.ts](https://github.com/oclif/plugin-plugins/blob/v5.0.14/src/commands/plugins/update.ts)_
388<!-- commandsstop -->
389
390# Contributing
391
392See [contributing guide](./CONRTIBUTING.md)