# @qts-mini/cli

> @qts-mini/cli

Latest version **0.0.31-alpha.0** (published 2020-04-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install @qts-mini/cli
pnpm add @qts-mini/cli
yarn add @qts-mini/cli
bun add @qts-mini/cli
```

Provides the command `qts-mini`.

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.31-alpha.0 |
| Published | 2020-04-30 |
| First published | 2019-12-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 17.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | 13 |
| Maintainers | li13 |
| Keywords | mini, wx, alipay, transform, cli |

## Links

- npm: https://www.npmjs.com/package/@qts-mini/cli
- Repository: https://gitee.com/f2ee/qts-mini
- Homepage: https://gitee.com/f2ee/qts-mini/tree/master/packages/cli
- npm.io page: https://npm.io/package/@qts-mini/cli

## Dependencies (6)

- [is-glob](https://npm.io/package/is-glob.md) ^4.0.1
- [commander](https://npm.io/package/commander.md) ^4.0.0
- [@qts-mini/shared](https://npm.io/package/@qts-mini/shared.md) ^0.0.29-alpha.0
- [@qts-mini/compiler](https://npm.io/package/@qts-mini/compiler.md) ^0.0.31-alpha.0
- [@qts-mini/transform](https://npm.io/package/@qts-mini/transform.md) ^0.0.31-alpha.0
- [@qts-mini/mini-plugin](https://npm.io/package/@qts-mini/mini-plugin.md) ^0.0.31-alpha.0

## 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

- 0.0.31-alpha.0 (latest) — 2020-04-30
- 0.0.30-alpha.0 — 2020-04-30
- 0.0.29-alpha.0 — 2020-04-29
- 0.0.28-alpha.0 — 2020-04-28
- 0.0.27-alpha.0 — 2020-04-27
- 0.0.26-alpha.0 — 2020-04-24
- 0.0.25-alpha.0 — 2020-04-24
- 0.0.24-alpha.0 — 2020-04-23
- 0.0.23-alpha.0 — 2020-04-23
- 0.0.22-alpha.0 — 2020-04-22
- 0.0.21-alpha.0 — 2020-04-21
- 0.0.20-alpha.0 — 2020-04-16
- 0.0.19-alpha.0 — 2020-04-16
- 0.0.18-alpha.0 — 2020-04-15
- 0.0.17-alpha.0 — 2020-04-15
- … 12 more at https://npm.io/package/@qts-mini/cli/versions

## README

# @qts-mini/cli

小程序多端同构 & 使用微信小程序或者支付宝小程序进行多端开发

简单，基于小程序语法，无接入成本和逃离成本（依然可以在转换后的代码继续开发）

支持多种同构语法

- 条件注释
- js 多态
- 组件文件多态

## Installing

Using npm:

```bash
$ npm i -g @qts-mini/cli
```

Using yarn:

```bash
$ yarn global add @qts-mini/cli
```

## Use

```bash
qts-mini transform 'target/**'
```

查看命令运行目录有`dist`目录，注意`'target/**'`的引号

## Example

![avatar](https://qiniu-image.qtshe.com/qts-mini/qts-mini-example.gif)

## 配置 和 API

### `qts-mini.config.js`

在项目根目录配置`qts-mini.config.js`

```javascript
module.exports = {
  files: {
    'example/**': {
      out: {
        wx: 'dist/wx',
        alipay: 'dist/alipay'
      }
    }
  }
}
```

### `transform`

#### 简单命令行模式

`qts-mini transform 'target1/**' 'target2/**'` 忽略`qts-mini.config.js`，代码自动转换到当前命令运行目录下的'dist/wx'和'dist/alipay'

`qts-mini transform 'target1/**' 'target2/**' -w`

#### 配置文件模式

`qts-mini transform` 转换代码，根据`qts-mini.config.js`文件输出目录，可配置多个

`qts-mini transform -w` 监听代码，默认不转换监听到改动才转换

`qts-mini transform -w --init-run` 先转换一次后监听

## 同构模式

### 条件注释 [preprocess](https://github.com/jsoverson/preprocess)

js:

```javascript
// @ifdef WX
const text = '专属于微信'
// @endif
```

xml:

```xml
<!-- @ifdef ALIPAY -->
<view>专属于支付宝</view>
<!-- @endif -->
```

在`javascript`、`xml`、`css`、`bash`等文件中使用条件注释，导出到不同端

### js 多态 `interface`语法

`test.interface` 文件

```html
<script type="wx">
  export function show() {
    wx.show()
  }
</script>

<script type="alipay">
  export function show() {
    my.show()
  }
</script>
```

```js
import { show } from './a.interface'
```

### 组件目录条件编译

```
|- component
  |- login.interface
    |- wx
      |- index.wxml
      |- ...
    |- alipay
      |- index.axml
      |- ...
|- pages
  |- index
    |- index.json
```

最终会根据目录编译，例如微信(wx)：

```
|- component
  |- login
    |- index.wxml
    |- ...
|- pages
  |- index
    |- index.json
```

所以直接在 `pages/index/index.json`中使用组件`login: 'component/login/index'`

根据目录的多态组件的格式
`${组件名称}.interface/${wx/alipay}/${原生代码}`

`原生代码`不会经过转换，原样输出

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