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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@wlwastone/generate-file

v0.0.7

Published

generate file by db(mysql or oracle) and tpl file

Readme

@wastone/generate

中文文档

Generate files from template files and database tables

Often used for development requirements with a large number of repetitive files. For example, the background management system has a large part of the list page structure is similar, only add, delete, change and check related functions, you can take this library to solve this repetitive work.

Install

$ npm install -D @wlwastone/generate-file

Features

Usage

Create a generate folder with the following directory structure
-- generate
  +-- tpl
  | +-- api.art
  | +-- showview.art
  --- index.js

The tpl directory is used to store template files. The template uses art-template

template example

When database information is used, the returned information includes the infos below, which can be directly used in the template file.

// returned table info
{
  tableName: string,
  tableComment?: string,
  column: [{
    name: string,
    nullable: boolean,
    type: string,
    comment?: string,
    dataDefault?: any
  }]
}

// api.art exmaple
import * as http from '@/api'

export const add = (data) => {
  return http.postJson('/{{ tableName }}/add', data)
}

export const update = (data) => {
  return http.putJson('/{{ tableName }}/update', data)
}

export const del = (id) => {
  return http.delete(`/{{ tableName }}/updDel/${id}`)
}

export const getOne = (id) => {
  return http.get(`/{{ tableName }}/one/${id}`)
}
index.js complete example
// gennerate/index.js

const path = require('path')
const Generate = require('@wastone/generate')


// instantiation (You can call directly without instantiation)
const generate = new Generate()

// Database configuration (Here is the oracle database configuration)
const databaseConfig = {
  user: 'test',           // database username (string)
  password: 'test',       // database password  (string)
  host: '127.0.0.1',      // database host/ip  (string)
  port: 21,               // database port (number)
  serviceID: 'test',     // oracle database SID(mysql database do not need configuration)
  database: ''           // mysql database name(oracle database do not need configuration)
}

// setDatabase(databaseType, databaseConfig)  databaseType: 'mysql' | 'oracle' | null
generate.setDatabase('oracle', databaseConfig)

// the first configuration
const apiConfig = {
  tplPath: path.resolve(__dirname, './tpl/api.art'),
  outPath: path.resolve(__dirname, './dist/api.js'),
  databaseType: 'oracle',
  databaseConfig,
  // templateData: { name: '1' } // support custom data (format: Object|string)
}

// the second configuration
const showViewConfig = {
  tplPath: path.resolve(__dirname, './tpl/showview.art'),
  outPath: path.resolve(__dirname, './dist/show.vue'),
  databaseType: 'oracle',
  databaseConfig
}

// custom function, support promise, createFile can be called multiple times to accommodate generating multiple files at once
async function run () {
  console.log('======start======')
  try {
    await generate.createFile(apiConfig)
    await generate.createFile(showViewConfig)
  } catch (error) {
    console.log(error)
    return Promise.reject('create failed')
  }
}

run().then(() => {
  console.log('======end======')
})
run
// Run commands in the generate root directory
node index

TODO

  • Vscode plugin support
  • Support visual operation

LICENSE

MIT @ wastone