# @carrotwu/wcli

> A global cli tool that supports custom development, packaging and pushing

Latest version **1.2.0** (published 2021-12-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @carrotwu/wcli
pnpm add @carrotwu/wcli
yarn add @carrotwu/wcli
bun add @carrotwu/wcli
```

Provides the command `wcli`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2021-12-24 |
| First published | 2020-05-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 12 |
| Unpacked size | 111.2 KB |
| Known vulnerabilities | 0 (+31 in 2 direct dependencies) |
| Install scripts | no |
| Author | carrotWu |
| Maintainers | carrotwu |
| Keywords | ts, cli, node, typescript |

## Links

- npm: https://www.npmjs.com/package/@carrotwu/wcli
- npm.io page: https://npm.io/package/@carrotwu/wcli

## Dependencies (12)

- [ora](https://npm.io/package/ora.md) ^5.2.0
- [axios](https://npm.io/package/axios.md) ^0.21.1
- [colors](https://npm.io/package/colors.md) ^1.4.0
- [enquirer](https://npm.io/package/enquirer.md) ^2.3.6
- [fs-extra](https://npm.io/package/fs-extra.md) ^9.0.1
- [commander](https://npm.io/package/commander.md) ^7.0.0
- [simple-git](https://npm.io/package/simple-git.md) ^2.31.0
- [compressing](https://npm.io/package/compressing.md) ^1.5.1
- [module-alias](https://npm.io/package/module-alias.md) ^2.2.2
- [git-url-parse](https://npm.io/package/git-url-parse.md) ^11.4.4
- [update-notifier](https://npm.io/package/update-notifier.md) ^5.0.1
- [download-git-repo](https://npm.io/package/download-git-repo.md) ^3.0.2

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 1.2.0 (latest) — 2021-12-24
- 1.1.1 — 2021-12-21
- 1.1.0 — 2021-12-21
- 1.0.8 — 2021-03-01
- 1.0.7 — 2021-03-01
- 1.0.6 — 2021-02-27
- 1.0.5 — 2021-02-03
- 1.0.4 — 2021-01-18
- 1.0.3 — 2020-09-02
- 1.0.2 — 2020-09-02
- 1.0.1 — 2020-06-19
- 1.0.0 — 2020-05-28

## README

# wcli
<p align="center">
  <a href="https://www.npmjs.com/package/@carrotwu/wcli">
    <img src="https://img.shields.io/npm/v/@carrotwu/wcli.svg?style=flat-square&colorB=51C838"
         alt="NPM Version"/>
  </a>
  <a href="https://www.npmjs.com/package/@carrotwu/wcli">
    <img src="https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square" alt="License"/>
  </a>
  <br />
</p>

一个通过插件化的形式支持自定义开发打包推送的全局cli工具

## 安装

```sh
npm install @carrotwu/wcli --global
or
yarn global add @carrotwu/wcli
```

## 使用

1. 请先确保项目根目录已经有wcliconfig.json文件，wcli命令的执行依托于该配置。
2. 通过`wcli plugin install XXX`安装相应的plugin插件。
3. 执行wcli提供的`dev`,`publish`,`build`等指令。

## init命令

初始化模命令，适用于生成新的wcliconfig.json文件或者创建新的react后者vue项目模板。

### wcli init (wj or wcliconfig)

在当前目录下新创建一个wcliconfig.json文件或者重置初始化当前目录逇wcliconfig.json文件

## plugin指令

### wcli plugin install

插件的安装支持两种方式，一种是`github`或者`gitlab`的ur地址，一种是通过npm包名的形式进行安装。插件会自动安装在项目根目录的`plugins`目录下，插件安装完成之后会自动执行`install`命令

```sh
// 通过npm的方式安装插件
wcli plugin install XXX-plugin -n

// 通过github或者gitlab的ssh或者https克隆地址下载插件(连接上带.git的)
wcli plugin install git@gitlab.xxx.com:xxx.git
// 或者
wcli plugin install https://gitlab.xxx.com:xxx.git
```

### wcli plugin init

当你需要编写一个插件时，可以通过`wcli plugin init`初始化一个插件目录模板。插件目录下会默认初始化四个文件。

1. **dev.js**: 执行`wcli dev`命令时执行的文件。
2. **build.js**: 执行`wcli build`命令时执行的文件。
3. **publish.js**: 执行`wcli publish`命令时执行的文件。
3. **custom.js**: 执行`wcli custom`命令时执行的文件。
4. **package.json**: 初始化的插件package.json文件。

对于前三个文件的导出函数，会把一些可能使用到的参数变量或者wcli提供的一些通用方法通过`context`参数注入。具体`context`类型定义如下：

```ts
interface Context {
  config: {
    // 是否处于debug模式
    isDebug: boolean;
    // 项目根目录下的wcliconfig.json文件
    wcliConfigJson: WCliConfigJson;
    // 初始化publish命令时 用户所填的推送项目ssh token
    token?: string;
    // publish命令时 用户输入的commitMessage
    publishCommitMsg: string;
  };
  paths: {
      // 当前用户执行wcli命令的路径
    currentBinPath: string;
  };
  utils: {
      // 获取项目目录文件的通用方法
    getCurrentBinFilePath: (...paths: string[]) => string;
    // 默认提供的使用axios推送文件到gitlab的方法（只支持gitlab）
    publishFileWithGitlabCommit: typeof publishFileWithGitlabCommit;
    // 使用git命令推送文件的方法（支持github gitlab）
    publishFileWithGit: typeof publishFileWithGit;
    // 一些输出控制台新的方法(success warn loading error 等)
    logTools: typeof logTools;
  };
  toolsModules: {
      // 交互性的工具库 具体用法可以参考 https://github.com/SBoudrias/Inquirer.js/
    prompt: PromptModule;
    // axios
    axios: AxiosStatic;
    // fs-extra
    fse: typeof fse;
  };
}
```

### 一些额外的命令
1. `wcli plugin list`: 表格展示已安装过得plugin列表。
2. `wcli plugin remove XXX`: 删除具体某个插件。
3. `wcli plugin upgrade`: 更新插件(todo 暂时是通过插件重新安装的方法更新)
4. `wcli plugin link XXX`: 跟npm link相似，用于本地插件开发时的索引指向。用于本地插件的开发以及本地插件的使用

## wcli dev
执行插件目录下的`dev.js`文件，在当前目录下可以手动启动一个webpack server服务。可以通过`Inquirer`让用户选择一些前置性的参数如（开发环境，代理地址，需要开发的路由模块等）个性化的启动开发模式。

在`dev.js`中您可以使用一些框架库如`vue-cli` `create-react-app`字典的script命令，也可以在`dev.js`中自搭建一个webapck的server进行开发。

## wcli build

跟wcli dev同理。可以自由定制项目打包时的环境以及参数等。

## wcli custom [commands]...

允许插件编写者自定义`wcli custom xxx`命令的编写.

---
_Source: https://npm.io/package/@carrotwu/wcli · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
