UNPKG

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