# api-builder-cli

> Generate the front-end API call method according to the swagger.json provided by the back-end

Latest version **0.2.1** (published 2020-05-22) · ISC license · 0 weekly downloads

## Install

```sh
npm install api-builder-cli
pnpm add api-builder-cli
yarn add api-builder-cli
bun add api-builder-cli
```

Provides the command `api`.

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2020-05-22 |
| First published | 2020-05-09 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 14.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | kuangliting |
| Maintainers | kuangliting |

## Links

- npm: https://www.npmjs.com/package/api-builder-cli
- npm.io page: https://npm.io/package/api-builder-cli

## Dependencies (5)

- [chalk](https://npm.io/package/chalk.md) ^4.0.0
- [fs-extra](https://npm.io/package/fs-extra.md) ^9.0.0
- [inquirer](https://npm.io/package/inquirer.md) ^7.1.0
- [commander](https://npm.io/package/commander.md) ^5.1.0
- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.0

## Recent versions

- 0.2.1 (latest) — 2020-05-22
- 0.2.0 — 2020-05-22
- 0.1.1 — 2020-05-09
- 0.1.0 — 2020-05-09

## README

<h1 align="center">api-builder-cli</h1>

## Introduction
## 介绍
api-builder-cli 是一个帮助前端开发提升开发效率的小工具，通过简单的配置，它就能**自动生成**整个项目的**前后端api调用方法**模块，使用它有一个前提，就是后端必须提供生成api对应的swagger.json 文件的服务。

## 使用方式
### 安装
```shell
npm install api-builder-cli -g
```

### 使用
```shell
api-cli --host  hostUrl   //生成api模块命令，hostUrl为服务器swagger.json地址
api-cli  // 生成api模块命令，前提是api.config.js配置了服务器地址

api-cli -h //查看命令参数
api-cli init //生成配置文件

```

### config

首次输入**api-cli**后，如果命令所在工作目录没有api.config.js，会自动生成该文件，也可以用**api-cli init**手动生成。


```javascript
let Path = require("path");
let resolve = (path) => {
    return Path.resolve(__dirname, path);
}

module.exports = {
    apiHost: "",//swagger.json地址"http://10.9.105.13:8889/v2/api-docs"
    includes: [],
    excludes: [],
    swaggerPath: resolve(".swagger/swagger.json"),
    api: {
        path: resolve("src/api-cli"),
        fileName: "{moduleName}/index.js",
        requestPath:"../request.js",
        hasComments: true,
    },
    tsSupport: false,
    typePath: resolve("src/typings/api/smartCity.d.ts"),
}
```

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