# `@cloudbase/addon-cli`

[@cloudbase/cli](https://github.com/TencentCloudBase/cloudbase-cli.git) 中 `tcb addon` 命令行的功能实现

## 发布

请前往[流水线](https://zhiyan.woa.com/qci/6389/pipeline/#/pipeline/detail/566445/build/current)发布

## 开发

- 方式一：单元测试开发

  > 需要自行提供相关 mock 数据。具体请参考 `test/fixtures` 的相关代码

  ```sh
  $ yarn test [path/to/testFile]
  ```

  举例：通过单元测试开发调试 `pull` 命令

  ```sh
  $ yarn test test/tests/pull.test.ts
  ```

- 方式二：使用 tcb 开发调试

  1. 将 addon-cli 链接到本地模块并开启修改监听

  ```sh
  $ yarn run link
  $ yarn run dev
  ```

  2. 将 tcb 链接到本地并开启修改监听（可选，适用于运行本地 cloud-base-cli 的情况）

  ```sh
  $ cd path/to/cloud-base-cli
  $ npm link
  $ yarn run dev
  ```

  3. 运行 tcb addon \<command\> 命令

  ```sh
  tcb addon <command>
  ```

  **示例 1：运行 pull 命令**

  pull 插件

  ```sh
  $ tcb addon pull wx_custom --envId lowcode-1gk9y5ik310a94df
  ```

  pull 资源

  ```sh
  $ tcb addon pull block1 --resource block --envId lowcode-1gk9y5ik310a94df
  ```

  **示例 2：运行 push 命令**

  push 插件

  ```sh
  $ tcb addon push
  ```

  push 资源

  ```sh
  $ tcb addon push --resource block
  ```

## 代码生成

> 需要提前安装 ncgen: `npm i ncgen -g`

- 新增一个命令

> 比如 pull, push 这种命令

```sh
$ yarn code:add-command
```

- 为命令新增一种资源处理

> 比如为 pull 命令增加 block 资源处理

```sh
$ yarn code:add-resource
```
