# @yocdev/tarocodegen

> > 用于自动生成项目里那些逻辑重复的中间层代码

Latest version **1.1.14** (published 2021-09-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install @yocdev/tarocodegen
pnpm add @yocdev/tarocodegen
yarn add @yocdev/tarocodegen
bun add @yocdev/tarocodegen
```

Provides the command `tarocodegen`.

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.14 |
| Published | 2021-09-06 |
| First published | 2021-06-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=10 |
| Dependencies | 19 |
| Unpacked size | 30.2 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | npm@youchai.me |
| Maintainers | yocdev |

## Links

- npm: https://www.npmjs.com/package/@yocdev/tarocodegen
- Repository: https://github.com/yocdev/tarocodegen
- Homepage: https://github.com/yocdev/tarocodegen#readme
- Issues: https://github.com/yocdev/tarocodegen/issues
- npm.io page: https://npm.io/package/@yocdev/tarocodegen

## Dependencies (19)

- [rd](https://npm.io/package/rd.md) ^2.0.1
- [ajv](https://npm.io/package/ajv.md) ^7.2.3
- [ink](https://npm.io/package/ink.md) ^3.0.8
- [glob](https://npm.io/package/glob.md) ^7.1.7
- [meow](https://npm.io/package/meow.md) ^9.0.0
- [react](https://npm.io/package/react.md) ^17.0.2
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [prettier](https://npm.io/package/prettier.md) ^2.2.1
- [@svgr/core](https://npm.io/package/@svgr/core.md) ^5.5.0
- [handlebars](https://npm.io/package/handlebars.md) ^4.7.7
- [ink-spinner](https://npm.io/package/ink-spinner.md) ^4.0.1
- [string-hash](https://npm.io/package/string-hash.md) ^1.1.3
- [glob-promise](https://npm.io/package/glob-promise.md) ^4.2.0
- [@types/lodash](https://npm.io/package/@types/lodash.md) ^4.14.168
- [@svgr/plugin-jsx](https://npm.io/package/@svgr/plugin-jsx.md) ^5.5.0
- [ink-select-input](https://npm.io/package/ink-select-input.md) ^4.2.0
- [@svgr/plugin-svgo](https://npm.io/package/@svgr/plugin-svgo.md) ^5.5.0
- [@types/string-hash](https://npm.io/package/@types/string-hash.md) ^1.1.1
- [@svgr/plugin-prettier](https://npm.io/package/@svgr/plugin-prettier.md) ^5.5.0

## Recent versions

- 1.1.14 (latest) — 2021-09-06
- 1.1.11 — 2021-08-09
- 1.1.10 — 2021-08-09
- 1.1.9 — 2021-08-05
- 1.1.8 — 2021-07-16
- 1.1.6 — 2021-07-12
- 1.1.5 — 2021-07-12
- 1.1.4 — 2021-07-12
- 1.1.3 — 2021-07-12
- 1.1.2 — 2021-07-12
- 1.1.0 — 2021-07-12
- 1.0.7 — 2021-07-07
- 1.0.6 — 2021-07-06
- 1.0.5 — 2021-07-06
- 1.0.4 — 2021-06-17
- … 3 more at https://npm.io/package/@yocdev/tarocodegen/versions

## README

# tarocodegen

> 用于自动生成项目里那些逻辑重复的中间层代码

## Install

```bash
$ yarn add @yocdev/tarocodegen
```

## CLI

```
$ tarocodegen --help

  Usage
    $ tarocodegen

  Options
    --type  生成类型[router]

  Examples
    $ tarocodegen --type=router
```

## 类型
### router - 自动生成微信小程序路由配置文件
**问题:**
- 小程序路由配置需要手动在 `app.config.json` 里填写路由名和对应的路由文件路径。
- 实际业务代码中又需要在跳转时使用路由文件路径，但这样硬编码路由文件路径的形式并不好维护。

**原理:**

路由文件路径在新建路由文件时就确定了，故可以根据 `pages/` 目录下的所有路由文件自动生成带路由名的配置文件。

**使用:**
- 生成的 `routes.json` 包含符合 `app.config.json` 规则的路由信息，可直接用于 `app.config.json` 里注册路由
- 生成的 `routes.json` 同时为路由添加了完备的类型描述，可以在实际业务代码中使用路由名来实现跳转。

**符合要求的路由文件路径：**
1. pages/[routerName]/index.tsx
2. pages/packages/[packageName]/[routerName]/index.tsx
3. pages/tabs/[routerName]/index.tsx

**TODO:**
- [ ] 支持分包预下载配置


### icon - 自动生成独立文件的 icon 组件
**问题：**
- 项目里的图标文件一般以 image 或 background 的形式使用，一般引入图标文件及设置尺寸和颜色等存在重复的代码，这部分代码适合自动生成
- 图标组件在增加删除时都需要修改代码，这部分代码也可以自动生成
- 使用图标组件时需要有枚举值描述项目已有哪些图标可供使用

**原理:**

读取图标目录下所有有效的图标文件，自动生成对应的独立 IconXxx 组件文件。增删图标只需重新运行工具即可。

**使用:**

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