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

zk-chaos

v1.0.1

Published

chaos - boilerplate generator

Downloads

5

Readme

Chaos

项目脚手架生成器

用CLI的方式快速构建项目脚手架

chaos node-api scadmin # 在当前目录下建立名为"scadmin"的Node.js API服务项目
chaos node-api --version 1.2 ssadmin # 在当前目录下以1.2版本的模板建立名为"ssadmin"的项目
chaos node-api ssadmin -a port=8000 # 以默认监听8000端口建立项目

用法

首先全局安装

npm install -g zk-chaos

如果要在 projects 目录下建立 node.js API 项目 coconut :

cd projects
chaos node-api coconut

主要命令

chaos -l # 列出所有模板和版本
chaos <template> -v <version> <name> # 按指定版本的模板创建项目
chaos <template> <name> -a <args> # 传递参数给模板

模板参数

模板参数用以,分隔的querystring格式传给chaos,例如:

要传递以下参数:

  • port = 3000
  • css = less

则需要这么写:

chaos <template> <name> -a port=3000,css=less

所有参数均解析为string,类型转换可以在模板中做。

帮助

程序帮助如下,可以用chaos -hchaos --help查看:


Usage: chaos <template> [options] <name>

  Options:

    -h, --help                        output usage information
    -V, --version                     output the version number
    -v, --template-version <version>  specify template version (defaults to newest)
    -a, --template-args <args>        args pass to template (example: --args port=3000,css=less)
    -l, --list                        list all templates

  Examples:

    $ chaos node-api myapp
    $ chaos node-api -v 1.1 myapp
    $ chaos node-api -v 1.1 myapp -a port=3000,css=less

  Template Arguments:

    port        the port for the template

模板

现有模板

  • node-api
    • 1.0 (default)

制作模板

首先准备好脚手架。

将需要模板化的文件加上后缀 .template:

package.json -> package.json.template

然后在模板中使用ejs编写模板逻辑。如下:

// package.json
{
  "name": "boilerplate",
  "version": "1.0.0",
  ...
}

// package.json.template
{
  "name": "<?= name ?>",
  "version": "1.0.0",
  ...
}

// render with project name = coconut
{
  "name": "coconut",
  "version": "1.0.0",
  ...
}

为了防止和模板项目中可能存在的ejs文件冲突,我们使用 <? ?> 作为模板符号。

准备好模板后,起一个模板名(如:palm),将其放入chaos的templates文件夹中:

.../new_boilerplate/ -> chaos/templates/palm/1.0/

之后每更新版本,便添加一个以版本命名的文件夹放新版本的文件。