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

speike

v1.2.2

Published

Simple CLI for scaffolding Speike projects

Downloads

14

Readme

speike-cli

npm Build Status Coverage Status

简单且通用的脚手架工具

安装

条件:Node.js >= 6.x

$ npm install -g speike

使用

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

例子:

$ speike init speike-template-thinkjs hao-project

上面的例子首先会从 haotech/speike-template-thinkjs 拉取模板,然后根据模板项目中根目录下 metadata.js 文件中 prompts 的配置使用 交互命令 获取一些信息,最后通过这些获取到的信息生成 hao-project 项目。

推荐模板

speike 提供了一些常用的,并且比较推荐的模板,这些模板目前在 haotech 组织下,全部以 speike-template 开头命名,所有推荐模板均可以用 speike init <template-name> <project-name> 这行命令使用并生成项目,你也可以使用 speike list 命令来查看当前有哪些可用的模板。

推荐模板:

自定义模板

推荐的模板并不能覆盖所有需求场景,所以用户可以编写自己的自定义模板,只需要遵循一定的规则即可。

当编写好自定义的模板之后,可以通过下面的命令来使用该模板。

$ speike init username/repo my-project

模板下载功能是基于 download-git-repo 开发,所以可以使用 download-git-repo 的全部语法。

例如拉取模板的指定分支:

$ speike init owner/name#my-branch

如果您想从私有仓库下载模板,请使用 -c--clone,speike将使用 git clone 来下来您的模板。

仓库支持:

  • Github - github:owner/name or simply owner/name
  • GitLab - gitlab:owner/name
  • Bitbucket - bitbucket:owner/name

编写自定义模板

  • 模板仓库根目录必须有一个 template 文件夹
  • 模板仓库根目录下必须有一个 metadata 文件,metadata.js 或者 metadata.json 二选一,metadata 文件必须包含以下字段:
    • prompts:用于配置命令行如何与人进行交互,从而收集一些模板需要的信息

prompts

metadata 文件中的 prompts 字段必须是一个 Object 包含了用户提示信息,prompts 中的每个key会对应生成一个变量,可以在 template 文件夹内的模板中使用,就像 ejs, jade, nunjucks 中传入模板中的变量一样(事实上就是使用模板引擎来实现的),而每个key对应的 value 是一个 Inquirer.js question object,例如:

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

当所有与用户间的询问完成之后,会进行模板渲染,这里使用的模板引擎是 Handlebars,与用户交互完毕后拿到的数据会传入到模板引擎中~

所以在模板引擎中可以使用 Handlebars 的所有语法,例如 {{expression}}, if 等。

question object

question object 是一个hash,包含了一些与问题相关的值

  • type: (String) 提示类型。默认为 input,可用类型:inputconfirmrawlistexpandcheckboxpasswordeditor
  • message: (String) 在命令行中显示的问题
  • default: (String|Number|Array) 问题的默认值
  • choices: (Array) 值可以是string,也可以是ObjectObject 包含namevalueshortname 是显示在终端列表中的名字,value是保存在hash中的值, short是选择后显示的值。

更多信息请查看 Inquirer.js 中的详细说明~

skipCompile

metadata 文件中的 skipCompile 字段可以是 Array 也可以是 String,值为 minimatch 的匹配规则,例如:

{
  "skipCompile": [
    "src/**/*.vue"
  ]
}

被匹配到的文件会跳过 **模板编译**这一步。

所以被跳过的文件并不会读取到 `prompts` 中的值。