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

@aoviz/code-gen

v1.0.7-alpha.1

Published

使用代码生成工具生成的代码。提供了通过终端命令和 VsCode 集成两种使用方式。

Downloads

71

Readme

@aoviz/code-gen

使用代码生成工具生成的代码。提供了通过终端命令和 VsCode 集成两种使用方式。

Installation

yarn global add @aoviz/cli
yarn add @aoviz/code-gen

Concept

代码生成依据模板文件和元数据组合生成代码,一个模版可以对应多个组合元数组,根据所需生成的页面选择适合自己的元数据。在项目或产品目录新增 .aoviz-tmp 目录,用来放置和之相关的模版文件内容。模版文件的目录结构如下:

--- .aoviz-tmp
    --- list
        --- index.js
        --- metadata
            --- example.json
            --- complexity.json
    --- detail
        --- index.js
        --- metadata
            --- example.json
            --- complexity.json
    --- modal
        --- index.js
        --- metadata
            --- example.json
            --- complexity.json

模板文件的定义如下:

const { Template } = require('@aoviz/code-gen');
module.exports = [
  {
    template: Template`
      function Aoviz() {
        return 'aoviz'
      }
    `,
  }
]

元数据的定义为 .json 文件,与选中的模版进行组合生成代码。

Generation

通过终端生成

选用终端生成时执行以下命令:

aoviz code-gen file-name -t list -m example

默认将文件生成在当前执行命令的目录下,也可以通过 -o 参数指定生成的目录。-t-m 参数分别指定模版和元数据,如果不指定终端会弹出选择交互功能,通过终端交互选择所需配置。

建议在每个模块的 pages 目录下生成。

通过 VsCode 生成

在 VsCode 中安装 Create tempalte file for datagrand 插件,通过右键菜单选择目录,选择模版和元数据,输入文件名称,即可生成代码。