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

@ttjl/template-cli

v1.0.0

Published

Create a new project from bundled templates

Readme

create-myapp

从 npm 包内置模板创建项目的脚手架工具,无需运行 git clone 或访问远程模板仓库。

特性

  • 🚀 快速创建 - 直接复制随 CLI 发布的项目模板
  • 🎨 交互式配置 - 友好的命令行交互界面
  • 📝 模板引擎 - 支持 Handlebars 语法,包含条件、循环等功能
  • 🔧 灵活配置 - 支持自定义变量和多种输入类型
  • 📦 模板管理 - 支持扩展 templates/ 下的内置模板

安装

# 全局安装
npm install -g @ttjl/template-cli

# 或使用 pnpm
pnpm add -g @ttjl/template-cli

# 或直接使用 npx (无需安装)
npx @ttjl/template-cli

使用

交互式创建

create-myapp

指定项目名称

create-myapp my-project

使用指定模板

create-myapp my-project --template react

当前内置模板包括 react、react-shadcn、react-tauri 和 vue。原有的 vite-react、vite-react-shadcn、vite-react-tauri 和 vite-vue 名称仍可作为兼容别名使用。

传入变量值

create-myapp my-project --var author=张三 --var typescript=true

完整选项

create-myapp [project-name] [options]

选项:
  -t, --template <name>      模板名称
  --target-dir <path>        目标目录
  --var <variables>          变量值 (格式: key=value)
  -h, --help                 显示帮助信息

模板配置

templates/ 下的内置模板目录可以包含 template.config.json 文件来定义模板配置:

{
  "name": "vue-template",
  "description": "Vue 3 项目模板",
  "variables": [
    {
      "name": "projectName",
      "description": "项目名称",
      "default": "my-app"
    },
    {
      "name": "author",
      "description": "作者",
      "default": ""
    },
    {
      "name": "typescript",
      "description": "使用 TypeScript",
      "type": "confirm",
      "default": true
    },
    {
      "name": "features",
      "description": "选择功能",
      "type": "multiselect",
      "options": ["router", "pinia", "vitest"],
      "default": ["router"]
    }
  ]
}

新增模板时,将完整项目放入 templates/<template-name>/,再在 src/templates/config.ts 的 builtInTemplates 中注册名称、说明和目录。模板中的 .gitignore 应另存为 _gitignore,生成时会自动还原文件名。

变量类型

  • text - 文本输入(默认)
  • confirm - 确认(是/否)
  • select - 单选
  • multiselect - 多选

模板语法

模板文件支持 Handlebars 语法:

package.json 示例

{
  "name": "{{kebab-case projectName}}",
  "version": "1.0.0",
  "author": "{{author}}",
  {{#if typescript}}
  "type": "module",
  {{/if}}
  "scripts": {
    {{#if typescript}}
    "build": "tsc && vite build"
    {{else}}
    "build": "vite build"
    {{/if}}
  }
}

内置 Helpers

  • {{kebab-case value}} - 转换为 kebab-case
  • {{camelCase value}} - 转换为 camelCase
  • {{upper value}} - 转大写
  • {{lower value}} - 转小写
  • {{#if condition}}...{{/if}} - 条件判断
  • {{#each array}}...{{/each}} - 循环

开发

# 克隆仓库
git clone <repo-url>
cd create-myapp

# 安装依赖
pnpm install

# 构建
pnpm build

# 本地测试
node dist/index.js test-project --template react

# 或使用 link
pnpm link --global
create-myapp test-project

发布

# 更新版本
pnpm version patch/minor/major

# 发布到 npm
pnpm publish

License

MIT