0.1.18 • Published 3 years ago

ys-codegen v0.1.18

Weekly downloads
113
License
ISC
Repository
-
Last release
3 years ago

codegen

代码生成工具,根据模板和模板参数生成文件

安装

使用 npm:

$ npm install -D ys-codegen

使用 yarn:

$ yarn add -D ys-codegen

更新:

$ yarn upgrade ys-codegen --latest

使用

使用方法生成

import { codegen } from "ys-codegen"

let config = __dirname+"/../src/template/AntDVProEdit/default.json" //模板配置文件路径
let template = __dirname+"/../src/template/AntDVProEdit/EditModal.vue" //模板文件路径
const content = codegen(template,config) // 传入参数生成 返回字符串

let file = "/template/Edit.vue" //输出路径
codegenVueFile(template,config,file)  // 生成Vue文件
codegenFile(template,config,file)  // 生成文件 无美化

命令行生成文件

vue美化输出,可能不符合项目的美化规则

node ./bin/codegen.js vue <模板文件路径> <模板数据文件路径> [-o 输出路径] [-f prettier美化参数json路径]

直接输出,不美化

node ./bin/codegen.js file <模板文件路径> <模板数据文件路径> [-o 输出路径] 
// 包目录下
node ./bin/codegen.js vue D:\www\html\vue\ys-codegen\packages\codegen\src\template\AntDVProEdit\EditModal.vue D:\www\html\vue\ys-codegen\packages\codegen\src\template\AntDVProEdit\default.json -o 输出路径

// 项目目录下 
yarn codegen vue D:\www\html\vue\ys-codegen\packages\codegen\src\template\AntDVProEdit\EditModal.vue D:\www\html\vue\ys-codegen\packages\codegen\src\template\AntDVProEdit\default.json -o 输出路径

-o 输出路径 可选参数,不填,默认输出在命令行目录下

模板数据

  • AntDVProEdit 点击链接查看模态框编辑页模板参数详细文档
  • AntDVProList 点击链接查看模态框列表页模板参数详细文档
  • AntDVProPageEdit 点击链接查看路由编辑页模板参数详细文档
  • AntDVProPageList 点击链接查看路由编辑页模板参数详细文档
  • AntDVProItemModalEdit 模态框方式的列表页,点击编辑再弹出的编辑页
  • AntDVProItemModalList 模态框方式的列表页

database

import { database } from "ys-codegen"
console.log('database', database)

数据示例

 [
    {
        "title":"AntDVProEdit", // 模板名称
        "file":'/template/AntDVProEdit/EditModal.vue"', // 模板路径
        "config": "/template/AntDVProEdit/default.config.js", // 配置路径
        "type": "form", // 模板数据类型
        "category": "AntDvProModal" // 模板分组
        "remark": "模态框编辑页模板" // 备注
    }
 ]

注意

每个模板都有对应的配置文件,配置文件JSON结构会有所不同。 js后缀的配置带有注释解释

0.1.18

3 years ago

0.1.17

3 years ago

0.1.15

3 years ago

0.1.16

3 years ago

0.1.13

3 years ago

0.1.14

3 years ago

0.1.12

3 years ago

0.1.11

3 years ago

0.1.10

3 years ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.0.23

3 years ago

0.0.21

3 years ago

0.0.22

3 years ago

0.0.20

3 years ago

0.0.18

3 years ago

0.0.19

3 years ago

0.0.17

3 years ago

0.0.16

3 years ago

0.0.15

3 years ago

0.0.14

3 years ago

0.0.12

3 years ago

0.0.13

3 years ago

0.0.10

3 years ago

0.0.11

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago