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

devmate-cli-test

v1.0.53

Published

AI脚手架工具 - 支持多种项目模板创建

Readme

AI CLI 脚手架工具

一个功能强大、架构优化的命令行脚手架工具,支持快速创建和管理各种类型的项目。

🚀 功能特性

  • 项目初始化: 支持 Monorepo 和小程序项目创建
  • 开发服务器: 一键启动开发环境,智能配置管理
  • 项目构建: 生成生产就绪的构建版本
  • 子应用管理: 在现有 Monorepo 中快速添加新的子应用
  • 交互式界面: 友好的命令行交互体验
  • 统一错误处理: 智能错误诊断和解决建议
  • 配置管理: 支持多层级配置合并和验证
  • 类型安全: TypeScript 支持,提供完整的类型定义
  • 调试支持: 多级别日志系统,支持调试模式

📦 安装

# 克隆项目
git clone <repository-url>
cd cli

# 安装依赖
npm install

# 全局链接(可选)
npm link

系统要求

  • Node.js: >= 16.0.0
  • npm: >= 7.0.0
  • Git: 用于模板克隆

🎯 使用方法

基本命令

# 显示帮助信息
ai help

# 初始化新项目
ai init <project-name>

# 在现有 Monorepo 中添加子应用
ai add <sub-app-name>

# 启动开发服务器
ai dev [options]

# 构建项目
ai build [options]

高级选项

# 启用调试模式
DEBUG=true ai init my-project

# 指定 CDN 前缀
ai build --cdn-prefix https://cdn.example.com

# 查看详细日志
ai dev --verbose

详细使用说明

1. 初始化项目

ai init myapp

运行后会出现交互式选择:

  1. 项目类型选择:

    • 📦 Monorepo (单体仓库)
    • 📱 小程序
  2. Monorepo 子类型选择:

    • 💻 PC端应用 ✅ (支持)
    • 📱 H5应用 ⚠️ (开发中)
    • 🔧 微前端 ⚠️ (开发中)
    • 🎨 UI库 ⚠️ (开发中)
    • 🛠️ 工具库 ⚠️ (开发中)

注意:目前仅支持 PC端应用 的完整创建流程,其他选项会显示"暂不支持,正在开发中"

2. 开发模式

cd myapp
ai dev

自动检测并安装依赖,启动开发服务器。

3. 构建项目

ai build

生成 dist 目录,包含生产就绪的代码。

4. 添加子应用

在现有的 Monorepo 项目中添加新的子应用:

# 进入 Monorepo 项目目录
cd my-monorepo

# 添加新的子应用
ai add my-new-app

运行后会自动:

  • 验证当前环境是否为有效的 Monorepo
  • 克隆子应用模板
  • 更新项目配置
  • 添加启动脚本

📁 项目结构

Monorepo 项目结构

my-monorepo/
├── packages/
│   ├── app1/             # 子应用1
│   │   ├── src/
│   │   ├── public/
│   │   ├── package.json
│   │   └── vite.config.js
│   └── app2/             # 子应用2
├── package.json          # 根配置文件
├── devmate.config.ts     # 项目配置文件
└── README.md

CLI 工具架构

cli/
├── bin/
│   └── ai.js             # CLI 入口文件
├── commands/
│   ├── init.js           # 初始化命令
│   ├── dev.js            # 开发命令
│   ├── build.js          # 构建命令
│   └── add.js            # 添加命令
├── core/                 # 🆕 核心模块
│   ├── ProjectManager.js # 项目管理器
│   ├── ConfigManager.js  # 配置管理器
│   └── ErrorHandler.js   # 错误处理器
├── constants/
│   └── index.ts          # 🆕 TypeScript 常量定义
├── utils/
│   ├── fileUtils.js      # 文件操作工具
│   ├── gitUtils.js       # Git 操作工具
│   ├── promptUtils.js    # 用户交互工具
│   ├── commandUtils.js   # 🆕 优化的命令工具
│   └── configUtils.js    # 🆕 重构的配置工具
├── validators/
│   └── projectValidator.js # 🆕 优化的验证器
├── docs/                 # 🆕 文档目录
│   ├── CODE_STRUCTURE.md
│   ├── OPTIMIZATION_SUMMARY.md
│   └── BEST_PRACTICES.md
└── package.json

🔧 支持的项目类型

Monorepo 项目

| 子类型 | 状态 | 描述 | |--------|------|------| | PC端应用 | ✅ 支持 | 基于 Vite + React 的现代 Web 应用 | | H5应用 | ⚠️ 开发中 | 移动端 H5 应用模板 | | 微前端 | ⚠️ 开发中 | 微前端架构支持 | | UI库 | ⚠️ 开发中 | 组件库开发模板 | | 工具库 | ⚠️ 开发中 | 工具函数库模板 |

小程序项目

  • 📱 微信小程序 (⚠️ 开发中)
  • 📱 支付宝小程序 (⚠️ 开发中)

🆕 新增功能

配置管理

  • 多层级配置: 支持基础配置 + 项目配置 + 命令行选项
  • 深度合并: 智能配置对象合并
  • 配置验证: 自动验证配置完整性
  • 环境变量: 支持环境变量配置

错误处理

  • 统一错误处理: 集中的错误管理系统
  • 错误分类: 验证、文件系统、网络、配置等错误类型
  • 智能建议: 根据错误类型提供解决方案
  • 错误历史: 记录错误历史便于调试

日志系统

  • 多级别日志: ERROR、WARN、INFO、SUCCESS、DEBUG
  • 时间戳: 所有日志包含时间戳
  • 调试模式: DEBUG 环境变量支持
  • 结构化日志: 支持附加数据显示

🛠️ 开发说明

架构优化

本项目经过全面的架构重构,采用了现代化的设计模式:

  • 分层架构: commands → core → utils 清晰的分层设计
  • 管理器模式: 核心业务逻辑集中管理
  • 单一职责: 每个模块职责明确
  • 依赖注入: 便于测试和扩展

技术栈

核心依赖

  • Node.js: >= 16.0.0 运行环境
  • Commander.js: 命令行框架
  • Inquirer.js: 交互式命令行界面
  • fs-extra: 增强的文件系统操作
  • simple-git: Git 操作库

开发工具

  • TypeScript: 类型定义支持
  • Chalk: 终端字符串样式
  • Ora: 优雅的终端加载器
  • @types/: TypeScript 类型定义

配置文件

项目支持 devmate.config.ts 配置文件:

export default {
  // 开发服务器配置
  server: {
    port: 3000,
    host: 'localhost'
  },
  // 构建配置
  build: {
    outDir: 'dist',
    sourcemap: true
  },
  // 自定义配置
  plugins: []
};

📋 开发计划

已完成 ✅

  • [x] 架构重构和代码优化
  • [x] 统一错误处理系统
  • [x] 配置管理优化
  • [x] TypeScript 支持
  • [x] 多级别日志系统
  • [x] 项目文档完善
  • [x] 最佳实践指南

进行中 🚧

  • [ ] 支持 H5 应用模板
  • [ ] 支持微前端架构
  • [ ] 支持 UI 库模板
  • [ ] 支持工具库模板

计划中 📅

  • [ ] 支持小程序模板
  • [ ] 插件系统
  • [ ] 自定义模板支持
  • [ ] 单元测试框架
  • [ ] 性能监控
  • [ ] 配置 UI 界面
  • [ ] 云端集成
  • [ ] AI 辅助代码生成

🤝 贡献指南

开发流程

  1. Fork 本仓库
  2. 创建特性分支 (git checkout -b feature/AmazingFeature)
  3. 遵循 最佳实践指南
  4. 提交更改 (git commit -m 'Add some AmazingFeature')
  5. 推送到分支 (git push origin feature/AmazingFeature)
  6. 打开 Pull Request

代码规范

  • 遵循项目的编码风格
  • 添加适当的 JSDoc 注释
  • 确保类型安全(TypeScript)
  • 编写单元测试
  • 更新相关文档

文档

📄 许可证

本项目采用 MIT 许可证 - 查看 LICENSE 文件了解详情。

🆘 问题反馈

如果您遇到任何问题或有功能建议,请在 Issues 页面提交。


AI CLI - 让项目创建变得简单高效! 🚀