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

project-create

v1.0.2

Published

create project by template

Downloads

10

Readme

project-create

通过模板创建工程

安装

推荐全局安装project-create

$ npm i project-create -g
$ project-create -h

创建内置的miot工程

$ project-create [dir]

通过模板创建工程

$ project-create [dir] -t path/to/template

命令参数

Options:
  --type          内置模板,目前仅支持miot                         [字符串] [默认值: "miot"]
  --template, -t  创建工程的模板路径,相对路径                       [字符串]
  --dir, -d       创建工程的目标文件夹,相对路径                     [字符串]
  --force, -f     如果目标文件夹存在,是否覆盖                       [布尔]
  --silent, -s    非交互式创建工程                                 [布尔]
  -v, --version   显示版本号                                      [布尔]
  -h, --help      显示帮助信息                                     [布尔]

不询问,使用默认值创建:

$ project-create [dir] -s

如果目标文件夹存在,则覆盖:

$ project-create [dir] -f

模板结构

模板可以参考lib/miot

.
├── index.js
└── template
    ├── build
    ├── index.ios.js
    ├── index.js
    ├── package.json
    ├── project.json
    └── res

每个模板工程由根目录下的index.js文件和里面的template文件夹构成。 index.js中导出需要替换的变量和父模板名,这些可替换变量可以被template中的文件所使用。 template中存放模板工程所需要的文件。

例如:

// index.js
module.exports = {
  repalce: {
    models: {
      description: 'model of device',
      default: 'zhimi.demo.model',
    },
    name: {
      desc: 'project name',
    },
    pwd: {
      type: 'password',
    }
  },
  base: null,
}

这里导出了models的变量,在文件中可以这样使用:

// template/project.json
{
  "models": "{{ models }}",
}

所有使用了"{{ modles }}"的地方,都会替换成通过交互输入的modles,如果不指定,则会替换为默认的zhimi.demo.model。当然也可以通过转义来取消替换,\{{ models }}将会按照原样输出,不会替换变量。

base指定了模板工程的父模板工程,如果存在父模板工程,则会先拷贝父模板工程的项目到目标文件夹,子模板中的文件将会对父模板中同名的文件进行覆盖。

模板工程导出变量可选项

  • type:(String),默认为input,可选参数为input、password、number、list
  • desc:(String|Function),提示语,交互输入时候的提示
  • default:(String|Number|Boolean|Function),变量值的默认值
  • validate:(Function),校验函数,校验输入值是否合法
  • filter:(Function),过滤函数,过滤输入