# milady

> Generate the front-end code by parsing the interface document

Latest version **0.0.5** (published 2019-07-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install milady
pnpm add milady
yarn add milady
bun add milady
```

Provides the command `milady`.

## 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.0.5 |
| Published | 2019-07-22 |
| First published | 2019-06-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 10 |
| Unpacked size | 31.5 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 12 |
| Author | xiaohuoni |
| Maintainers | imhele, shawdanon, xiaohuoni |
| Keywords | codegen, umi, alitajs |

## Links

- npm: https://www.npmjs.com/package/milady
- Repository: https://github.com/alitajs/codegen
- Homepage: https://github.com/alitajs/codegen#readme
- Issues: https://github.com/alitajs/codegen/issues
- npm.io page: https://npm.io/package/milady

## Dependencies (10)

- [fs](https://npm.io/package/fs.md) ^0.0.1-security
- [path](https://npm.io/package/path.md) ^0.12.7
- [signale](https://npm.io/package/signale.md) ^1.4.0
- [fs-extra](https://npm.io/package/fs-extra.md) ^8.0.1
- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.0
- [typescript](https://npm.io/package/typescript.md) ^3.5.2
- [umi-request](https://npm.io/package/umi-request.md) ^1.0.8
- [yargs-parser](https://npm.io/package/yargs-parser.md) ^13.1.1
- [@types/signale](https://npm.io/package/@types/signale.md) ^1.2.1
- [@types/node-fetch](https://npm.io/package/@types/node-fetch.md) ^2.3.7

## Recent versions

- 0.0.5 (latest) — 2019-07-22
- 0.0.4 — 2019-07-06
- 0.0.3 — 2019-06-30
- 0.0.2 — 2019-06-30
- 0.0.1 — 2019-06-27

## README

# milady

Generate the front-end code by parsing the interface document

## what

这是一个通过 swagger 的 url 自动化生成代码的项目。

## why

因为使用 umi 途中需要写很多重复的 service 文件和 mock 文件，故建立此项目来自动化这些重复的工作。

## how

### 通过引用使用

安装

```js
npm i milady
```

使用

```js
import milady from 'milady';
const config = {
  swaggerUrl: '', //必填，用于获取数据
  plugins: [
    {
      outPath: '', //输出目录路径
      handelData: params => {
        return [{ fileName: 'api.ts', fileStr: params }];
      }, //传入swagger数据，返回集合fileName是生成的文件名，fileStr是生成的文件内容
    },
  ], //可选的，用于自定义输出文件
};
milady(config); //传入配置参数，调用milady方法生成文件
```

### 通过命令行使用

安装

```js
npm i milady -D
```

使用：

- 执行命令`milady [swaggerUrl]`生成文件
- 可选择设置配置`.miladyrc.js`文件进行高级设置，配置文件如下：

```js
exports.default = {
  swaggerUrl: '', //推荐的，优先加载命令行的url，命令行没有再加载配置的url
  plugins: [
    {
      outPath: '', //输出目录路径
      handelData: params => {
        return [{ fileName: 'api.ts', fileStr: params }];
      }, //传入swagger数据，返回集合fileName是生成的文件名，fileStr是生成的文件内容
    },
  ], //可选的
};
```

当命令和配置文件 swaggerUrl 冲突时使用命令的 swaggerUrl

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