简体   繁体   English

安装本地插件

[英]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 mynewclinpx oclif plugin mynewplugin是某个目录,例如在这种情况下是projects目录,您的目录结构如下

projects
|--- mynewcli
|--- mynewplugin

cd into the mynewcli project and cd进入mynewcli项目和

  1. install the plugins installer with npm i @oclif/plugin-plugins --save使用npm i @oclif/plugin-plugins --save安装插件安装程序

  2. 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 ] } }
  3. run ./bin/run plugins:link../mynewplugin to link the plugin into your main project运行./bin/run plugins:link../mynewplugin将插件链接到您的主项目

  4. 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM