npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ys-codegen

v0.1.18

Published

code template and data

Downloads

12

Readme

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后缀的配置带有注释解释