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 🙏

© 2025 – Pkg Stats / Ryan Hefner

ljy-node-cli

v1.0.0

Published

快速搭建本地或远程模板项目的命令行工具

Downloads

97

Readme

Node CLI 项目模板生成器

一个功能强大的 Node.js CLI 工具,用于从本地或远程模板创建项目。

功能特性

  • ✅ 从本地模板创建项目
  • ✅ 从远程模板创建项目(Vue2/Vue3/React)
  • ✅ 交互式模板选择
  • ✅ 目录存在检查和覆盖处理
  • ✅ 模块化、可扩展的架构

项目结构

my-node-cli/
├── bin/
│   └── cli.js              # CLI入口文件
├── lib/
│   ├── index.js            # 主入口文件
│   ├── create.js           # 主创建逻辑
│   ├── http.js             # HTTP请求工具
│   ├── utils/
│   │   └── helpers.js      # 工具函数
│   └── templates/
│       ├── TemplateSelector.js          # 模板选择器
│       ├── LocalTemplateCreator.js      # 本地模板创建器
│       └── RemoteTemplateGenerator.js   # 远程模板生成器
├── local-templates/         # 本地模板目录
│   ├── template-one/
│   │   └── hello.js
│   └── template-two/
│       ├── index.html
│       └── common.css
└── package.json

核心模块说明

1. CLI 入口 (bin/cli.js)

  • 使用 Commander.js 构建命令行界面
  • 配置 create、config、ui 等命令
  • 处理命令行参数和选项

2. 主创建逻辑 (lib/create.js)

  • ProjectCreator类:协调整个创建流程
  • 处理目录检查和模板类型选择
  • 调用相应的模板创建器

3. 模板选择器 (lib/templates/TemplateSelector.js)

  • 提供交互式模板类型选择
  • 动态加载本地模板列表
  • 支持本地和远程模板选择

4. 本地模板创建器 (lib/templates/LocalTemplateCreator.js)

  • 从 local-templates 目录复制模板文件
  • 处理本地模板的创建逻辑

5. 远程模板生成器 (lib/templates/RemoteTemplateGenerator.js)

  • 下载远程 Git 仓库模板
  • 支持 Vue2、Vue3、React 等流行框架
  • 包含加载动画和错误处理

6. 工具函数 (lib/utils/helpers.js)

  • 获取本地模板列表
  • 处理目录存在检查和覆盖逻辑

使用方法

创建新项目

my-node-cli create <project-name>

添加本地模板

local-templates/目录下创建新的模板文件夹:

local-templates/
└── my-template/
    ├── package.json
    ├── src/
    │   └── index.js
    └── README.md

依赖项

  • commander - 命令行界面
  • inquirer - 交互式命令行提示
  • download-git-repo - Git 仓库下载
  • ora - 加载动画
  • fs-extra - 增强的文件系统操作
  • chalk - 终端颜色输出
  • figlet - ASCII 艺术字

开发说明

项目采用模块化设计,易于扩展和维护。每个功能模块都有清晰的职责分离,便于添加新的模板类型或功能。