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

tomato-cli

v1.0.2

Published

Simple CLI for scaffolding web projects

Downloads

20

Readme

tomato-cli Build Status npm package

用命令生成项目脚手架, fork from vue-cli

工程文件模板改用 ejs, 因为大量组件已用了 handebars,会有冲突,因此需注意引用第三方的文件有 ejs 写法的文件

安装

需要: Node.js (>5.x preferred) and Git.

$ npm install -g tomato-cli

用法

$ tomato init <template-name> <project-name>

举例:

$ tomato init java-webapp my-project

模板来自 tomato-templates/java-webapp, 最终生成的文件在 ./my-project/.

线上模板

线上模板只是提供工作上常用的模板

所有线上模板在 tomato-templates organization。 如有新模块被添加,可运行 tomato init <template-name> <project-name> 来运用模板。 你也可以 tomato list 查看线上可用的模板。

目前已有模板:

自定义模板

如果线上模板不能满足你的需求,发现 github 已有模板刚好适合你的需求,这时可以这样做:

tomato init username/repo my-project

Where username/repo is the GitHub repo shorthand for your fork.

The shorthand repo notation is passed to download-git-repo so you can also use things like bitbucket:username/repo for a Bitbucket repo and username/repo#branch for tags or branches.

If you would like to download from a private repository use the --clone flag and the cli will use git clone so your SHH keys are used.

本地模板

你可能需要运用本地的模板,可以这样做:

tomato init ~/fs/path/to-custom-template my-project

怎么写自定义模板

  • 你的模板包必须有一个 template 目录,用来存放模板文件的目录

  • 你的模板包必须有一个 meta.json ,这是提供模板的默认配置文件,它可以包含如下字段:

    • prompts: 用来提示用户操作的信息;

    • filters: 过滤不想被 render 的文件;

    • completeMessage: 当模板生成完成后,要显示给用户的信息;

模板提示信息

meta.json 里有一个用户信息对象 prompts,它的 key 就是变量名,值就是一个 Inquirer.js question object。 例如:

{
  "prompts": {
    "name": {
      "type": "string",
      "required": true,
      "message": "Project name"
    }
  }
}

这些参数值会通过 ejs, 把值 rendertemplate 目录里的模板文件

条件提示信息

添加 when 字段, 可做条件式提示,例如:

{
  "prompts": {
    "lint": {
      "type": "confirm",
      "message": "Use a linter?"
    },
    "lintConfig": {
      "when": "lint",
      "type": "list",
      "message": "Pick a lint config",
      "choices": [
        "standard",
        "airbnb",
        "none"
      ]
    }
  }
}

当用户确认选择 lintlintConfig 才能被触发生效。

文件过滤

meta.json 文件的 filters, 它是一个文件过滤规则对象。 它的 key 是一个 minimatch glob pattern,它的值是一个提示信息作用域下的具体一个值. Example:

{
  "filters": {
    "test/**/*": "needTests"
  }
}

只用用户选择需要 needTests , test 目录下的文件才会被创建