# @liuli-util/cli

> 一个针对于库和 CLI 应用程序打包的零配置 CLI

Latest version **3.22.1** (published 2022-11-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install @liuli-util/cli
pnpm add @liuli-util/cli
yarn add @liuli-util/cli
bun add @liuli-util/cli
```

Provides the command `liuli-cli`.

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.22.1 |
| Published | 2022-11-22 |
| First published | 2021-01-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 22 |
| Unpacked size | 3.6 MB |
| Known vulnerabilities | 0 (+16 in 3 direct dependencies) |
| Install scripts | no |
| GitHub stars | 84 |
| Maintainers | rxliuli |

## Links

- npm: https://www.npmjs.com/package/@liuli-util/cli
- Repository: https://github.com/rxliuli/liuli-tools.git#master
- Homepage: https://github.com/rxliuli/liuli-tools/tree/master#readme
- Issues: https://github.com/rxliuli/liuli-tools/issues
- npm.io page: https://npm.io/package/@liuli-util/cli

## Dependencies (22)

- [ajv](https://npm.io/package/ajv.md) ^8.11.0
- [tar](https://npm.io/package/tar.md) ^6.1.11
- [conf](https://npm.io/package/conf.md) ^10.2.0
- [glob](https://npm.io/package/glob.md) ^8.0.3
- [ssh2](https://npm.io/package/ssh2.md) ^1.11.0
- [json5](https://npm.io/package/json5.md) ^2.2.1
- [esbuild](https://npm.io/package/esbuild.md) 0.14.39
- [ajv-i18n](https://npm.io/package/ajv-i18n.md) ^4.2.0
- [chokidar](https://npm.io/package/chokidar.md) ^3.5.3
- [enquirer](https://npm.io/package/enquirer.md) ^2.3.6
- [fs-extra](https://npm.io/package/fs-extra.md) ^10.1.0
- [spinnies](https://npm.io/package/spinnies.md) ^0.5.1
- [ts-morph](https://npm.io/package/ts-morph.md) ^15.1.0
- [commander](https://npm.io/package/commander.md) ^9.4.0
- [simple-git](https://npm.io/package/simple-git.md) ^3.11.0
- [ajv-formats](https://npm.io/package/ajv-formats.md) ^2.1.1
- [glob-promise](https://npm.io/package/glob-promise.md) ^5.0.0
- [ssh2-sftp-client](https://npm.io/package/ssh2-sftp-client.md) ^9.0.3
- [@liuli-util/eslint-config-ts](https://npm.io/package/@liuli-util/eslint-config-ts.md) 0.4.0
- [@liuli-util/eslint-config-react-ts](https://npm.io/package/@liuli-util/eslint-config-react-ts.md) 0.2.1
- [@liuli-util/prettier-standard-config](https://npm.io/package/@liuli-util/prettier-standard-config.md) 0.3.0
- [@liuli-util/commitlint-standard-config](https://npm.io/package/@liuli-util/commitlint-standard-config.md) 0.1.6

## Recent versions

- 3.22.1 (latest) — 2022-11-22
- 3.22.0 — 2022-09-23
- 3.21.0 — 2022-04-11
- 3.20.2 — 2022-03-31
- 3.20.1 — 2022-03-31
- 3.20.0 — 2022-03-31
- 3.19.2 — 2022-03-07
- 3.19.1 — 2022-03-01
- 3.19.0 — 2022-02-25
- 3.18.0 — 2022-01-14
- 3.17.2 — 2022-01-12
- 3.17.1 — 2022-01-11
- 3.17.0 — 2021-12-28
- 3.16.0 — 2021-12-28
- 3.15.0 — 2021-12-04
- … 34 more at https://npm.io/package/@liuli-util/cli/versions

## README

# @liuli-util/cli

> [中文](https://github.com/rxliuli/liuli-tools/tree/master/apps/liuli-cli/README.zh-CN.md)

A zero-configuration CLI for packaging libraries and CLI applications.

## Getting Started

### Install

```sh
pnpm i -D @liuli-util/cli # Local installation
pnpm i -g @liuli-util/cli # global install
```

### Packages

```sh
liuli-cli build lib # Package the library
liuli-cli build cli # Package cli references
```

> Adding the `-w` option starts the rollup monitoring mode, the dist/ will not be compressed and the dependencies will not be added to the bundle.

![watchdog mode](https://liuli.dev/images/liuli-cli%20%E7%9B%91%E8%A7%86%E6%A8%A1%E5%BC%8F.gif)

### Generate

```sh
liuli-cli generate <name> --template lib # Generate ts-lib project
liuli-cli generate <name> --template cli # generate cli project
```

util also supports interactive project creation

```shell
liuli-cli generate
```

![liuli-cli interactive creation screenshot](https://liuli.dev/images/liuli-cli%20%E4%BA%A4%E4%BA%92%E5%BC%8F%E5%88%9B%E5%BB%BA%E6%88%AA%E5%9B%BE.gif)

### Deployment

Support for deploying front-end resources to a remote location via sftp/gh-pages, with configuration information in the `deploy` field in package.json

```sh
liuli deploy
```

public

| configuration | description                       | defaults |
| ------------- | --------------------------------- | -------- |
| ``type`       | deployment type, ``sftp/gh-pgaes` | none     |
| `dist`        | Static resource directory         | None     |
| `dest`        | deployed remote directory         | none     |

sftp

| configuration        | description       | defaults |
| -------------------- | ----------------- | -------- |
| `sshConfig.host`     | ip address of ssh |          |
| `sshConfig.port`     | ssh's port number | 22       |
| `sshConfig.username` | ssh's username    |          |

gh-pages

| configuration     | description                               | default                                 |
| ----------------- | ----------------------------------------- | --------------------------------------- |
| `repo?: string`   | the git address of the project to push to | the default is the current project      |
| `remote?: string` | push remote                               | defaults to origin                      |
| `branch?: string` | remote branch name                        | defaults to gh-pages                    |
| `add?: boolean`   | whether to push incrementally             | cleans up the dest directory by default |

Example configuration for deploying a vuepress documentation site

```json
{
  "deploy": {
    "type": "gh-pages",
    "dist": "docs/.vuepress/dist"
  }
}
```

### Sync configuration

```shell
liuli-cli sync
```

You need to specify which configuration to sync in package.json

```json
{
  "sync": ["prettier", "workspaces", "commitlint", "simplehooks"]
}
```

Currently supported configuration items

- prettier
- commitlint
- simplehooks
- workspaces
- gitignore
- eslint-ts
- eslint-vue-ts
- jest

Future goals: By default, this will include checking the cli's own sync (if it needs to be used outside of monorepo), eslint/style-lint, and interactive cli when not configured

> Note: Currently, only dependencies are synchronized and no installation is performed

Interactive initialization of synchronized configuration is also supported

```shell
liuli-cli sync init
```

## Design philosophy

- Conventions outweigh configuration and should be left out if possible. VitePress does the same thing, see: https://vitepress.vuejs.org/#lighter-page-weight This leads to a number of constraints, including the following
  - The entry file must be `src/index.ts` when packaging the library, and the exit file must be `dist/index.esm.js` and `dist/index.js`
  - The entry file must be `src/bin.ts` and the exit file is `dist/bin.js` when packaging the CLI.
  - When packaging lib, all dependencies are treated as external dependencies, while when packaging cli, all dependencies are typed into the bundle

## FAQ

### Why not bundle external dependencies

The main reason is that we want to leave the bundling to the final application, to avoid bundling the same dependencies over and over again, and to avoid dealing with the problem of using `worker_threads` directly on the filesystem in nodejs.

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