# @fe-hl/cli-shared

> cli脚手架工具库

Latest version **2.0.0** (published 2025-07-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install @fe-hl/cli-shared
pnpm add @fe-hl/cli-shared
yarn add @fe-hl/cli-shared
bun add @fe-hl/cli-shared
```

## Health

**Score 30/100 (F)** — status: maintenance-mode.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2025-07-25 |
| First published | 2023-04-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 15 |
| Unpacked size | 29.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | hl |
| Maintainers | huleiit |

## Links

- npm: https://www.npmjs.com/package/@fe-hl/cli-shared
- Repository: git@gitee.com:fe-hl/cli
- npm.io page: https://npm.io/package/@fe-hl/cli-shared

## Dependencies (15)

- [ora](https://npm.io/package/ora.md) ^6.1.2
- [axios](https://npm.io/package/axios.md) ^1.2.1
- [chalk](https://npm.io/package/chalk.md) ^5.2.0
- [execa](https://npm.io/package/execa.md) ^6.1.0
- [cfonts](https://npm.io/package/cfonts.md) ^3.1.1
- [npmlog](https://npm.io/package/npmlog.md) ^7.0.1
- [semver](https://npm.io/package/semver.md) ^7.3.8
- [fs-extra](https://npm.io/package/fs-extra.md) ^11.1.0
- [inquirer](https://npm.io/package/inquirer.md) ^9.1.4
- [url-join](https://npm.io/package/url-join.md) ^5.0.0
- [commander](https://npm.io/package/commander.md) ^14.0.0
- [root-check](https://npm.io/package/root-check.md) ^2.0.0
- [path-exists](https://npm.io/package/path-exists.md) ^5.0.0
- [import-local](https://npm.io/package/import-local.md) ^3.1.0
- [dirname-filename-esm](https://npm.io/package/dirname-filename-esm.md) ^1.1.1

## Recent versions

- 2.0.0 (latest) — 2025-07-25
- 1.0.4 — 2024-04-13
- 1.0.2 — 2023-04-26

## README

# cli 脚手架工具库

## 引用

```js
import {
  fse,
  pathExists,
  chalk,
  rootCheck,
  semver,
  logs,
  isDebug,
  request,
  spinnerLoading,
  makeList,
  makeInput,
  makeConfirm,
  makePassword,
  getLatestVersion,
  checkGlobalUpdate,
  welcome,
  checkNodeVersion,
  getPkgInfo,
  getDirname,
  getFilename,
  exception,
  printErrorLog,
  createCli
  saveToken,
  homedir,
  importLocal
} from "@fe-hl/cli-shared";
```

## fse 等同 fs-extra 库

```js
import fse from "fs-extra";
```

## pathExists 等同 pathExists 库

```js
import { pathExists } from "path-exists";
```

## chalk 等同 chalk 库

```js
import chalk from "chalk";
```

## rootCheck 等同 rootCheck 库

```js
import rootCheck from "root-check";
```

## semver 等同 semver 库

```js
import semver from "semver";
```

## logs 日志输出

```js
logs.silly(prefix, message);
logs.verbose(prefix, message);
logs.info(prefix, message);
logs.http(prefix, message);
logs.warn(prefix, message);
logs.error(prefix, message);
```

## isDebug 模式判断

```js
// hl-cli init createApp -- --debug
isDebug();
```

## request http 请求

```js
await request.get(url);
await request.post(url);
```

## spinnerLoading

```js
const { spinnerSucceed, spinnerFail } = spinnerLoading("开始创建远程仓库");
spinnerSucceed(message?);
spinnerFail(message?);
```

## makeList,makeInput,makeConfirm,makePassword

```js
await makeList({
  choices: [
    {
      name: "项目",
      value: "project",
    },
  ],
  message: "请选择初始化类型",
  defaultValue: "project",
});

await makeInput({
  message: "请输入开发语言",
});

await makeConfirm({
  message: `检测到新版本【${latestVersion}】,是否使用最新版本模版?`,
});

await makePassword({
  message: "请输入token信息",
});
```

## getLatestVersion 获取 npm 最新的版本号

```js
const lastVersion = await getLatestVersion(npmName);
```

## checkGlobalUpdate 检测 npm 包是否有新版本

```js
const importMeta = import.meta;
checkGlobalUpdate(importMeta);
```

## welcome 欢迎语

```js
const importMeta = import.meta;
welcome(importMeta);
```

## checkNodeVersion 检测 Node 版本

```js
checkNodeVersion("14.0.0");
```

## getPkgInfo package.json 转 JSON

```js
const importMeta = import.meta;
const pkg = getPkgInfo(importMeta);
```

## getDirname 获取执行文件的目录路径

```js
const importMeta = import.meta;
const dirname = getDirname(importMeta);
```

## getFilename 获取执行文件的路径

```js
const importMeta = import.meta;
const filename = getFilename(importMeta);
```

## exception

- node 全局异常、promise 异常打印控制台

```js
exception();
```

## createCli

- 创建 cli 命令行工具

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