[英]Install Local Plugin
I generated a multi-command CLI using npx oclif multi mynewcli
.我使用
npx oclif multi mynewcli
生成了一个多命令 CLI。 I'm trying to install the default plugin created using npx oclif plugin mynewplugin
as referenced here .我正在尝试安装使用此处引用的
npx oclif plugin mynewplugin
创建的默认插件。 I don't know see any documentation on how to actually do that though.我不知道看到任何有关如何实际执行此操作的文档。 Is there documentation I'm missing?
有没有我遗漏的文件? How does the CLI know where to look for included plugins?
CLI 如何知道在哪里寻找包含的插件?
After you have executed the two commands npx oclif multi mynewcli
and npx oclif plugin mynewplugin
is some directory for example in this case the projects
directory, your directories will be structured like this执行完这两个命令后
npx oclif multi mynewcli
和npx oclif plugin mynewplugin
是某个目录,例如在这种情况下是projects
目录,您的目录结构如下
projects
|--- mynewcli
|--- mynewplugin
cd
into the mynewcli
project and cd
进入mynewcli
项目和
install the plugins installer with npm i @oclif/plugin-plugins --save
使用
npm i @oclif/plugin-plugins --save
安装插件安装程序
add this plugin into package.json
in oclif.plugins
array将此插件添加到
package.json
数组中的oclif.plugins
中
{ "name": "mynewcli", "version": "0.0.0", //... "oclif": { "plugins": [ "@oclif/plugin-help", "@oclif/plugin-plugins" // <== in here ] } }
run ./bin/run plugins:link../mynewplugin
to link the plugin into your main project运行
./bin/run plugins:link../mynewplugin
将插件链接到您的主项目
run ./bin/run plugins
you will see your mynewplugin
was added into your project运行
./bin/run plugins
你会看到你的mynewplugin
被添加到你的项目中
In the link you supplied, it says where it knows where to look:在您提供的链接中,它说它知道在哪里看:
Plugins can have commands or hooks just like a CLI.
插件可以像 CLI 一样具有命令或挂钩。 To add a plugin such as the not-found plugin plugin, first add it to your CLI with yarn add @oclif/plugin-not-found, then add the following to your package.json:
要添加诸如 not-found 插件之类的插件,首先使用 yarn add @oclif/plugin-not-found 将其添加到 CLI,然后将以下内容添加到 package.json 中:
{ "name": "mycli", "version": "0.0.0", //... "oclif": { "plugins": [ "@oclif/plugin-help", "@oclif/plugin-not-found" ] } }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.