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

bluestar-model-creater

v1.0.3

Published

BlueStar API创建器

Readme

bluestar-model-creater

BlueStar 模型创建器 - 自动生成 Vue 模型文件模板的命令行工具。

📖 简介

bluestar-model-creater 是一个专为 BlueStar 项目设计的代码生成工具,能够自动创建符合项目规范的模型文件结构,包括:

  • 模型主文件 (index.js)
  • API 接口文件 (api.js)
  • 分页管理模块 (pagement/index.js)

通过交互式命令行或参数传递,快速生成标准化的模型代码模板,提高开发效率。

✨ 特性

  • 🚀 快速生成:一键生成完整的模型文件结构
  • 📝 标准化模板:遵循 BlueStar 项目规范
  • 💬 交互友好:支持交互式输入和命令行参数两种方式
  • 🔧 自动创建目录:智能检测并创建必要的文件夹
  • 🎯 类型安全:提供 TypeScript 类型定义文件

📦 安装

全局安装(推荐)

npm install -g bluestar-model-creater

项目依赖安装

npm install bluestar-model-creater

🚀 使用方法

方式一:命令行参数(推荐)

# 使用 npx 直接执行
npx create-model -name=User

# 全局安装后使用
create-model -name=Product

# 在项目 scripts 中使用
# package.json: { "scripts": { "create": "create-model -name=Order" } }
npm run create

方式二:交互式输入

# 不传参数时,会提示输入模型名称
npx create-model

# 或使用命令别名
npx bluestar-model-creater

执行后会提示:

请输入模块字母名称: User

📁 生成的文件结构

执行 create-model -name=User 后,会在当前项目的 src/model 目录下生成:

src/
├── model/
│   ├── user/              # 模型名称(首字母小写)
│       ├── index.js       # 模型主文件
│       └── api.js         # API 接口定义

文件说明

index.js - 模型主文件

包含模型的完整业务逻辑,包括:

  • 数据状态管理
  • 方法定义
  • 生命周期钩子
  • 与 Vue 组件的集成

api.js - API 接口文件

定义与后端交互的 API 调用方法,包括:

  • HTTP 请求封装
  • 接口路径配置
  • 参数处理

pagement/index.js - 分页管理模块

提供通用的分页功能支持(仅在首次创建模型时生成)。

⚙️ 配置说明

命令行参数

| 参数 | 说明 | 示例 | |------|------|------| | -name=<ModelName> | 模型名称(必填) | -name=User |

命名规则

  • 输入的模型名称会自动生成两种格式:
    • 大驼峰(PascalCase):用于类名、组件名(如 User
    • 小驼峰(camelCase):用于文件名、变量名(如 user

例如:

  • 输入:UserProfile
  • 生成目录:src/model/userProfile/
  • 类名:UserProfile

💡 使用示例

示例 1:创建用户模型

npx create-model -name=User

生成结果:

✓ 创建 src 文件夹成功
✓ 创建 model 文件夹成功
✓ 创建 user 成功

示例 2:创建产品模型

npx create-model -name=Product

示例 3:交互式创建

npx create-model
# 提示:请输入模块字母名称: Order
# ✓ 创建 order 成功

🔍 注意事项

  1. 工作目录:工具会在当前执行命令的目录(process.cwd())下创建 src/model 结构
  2. 覆盖保护:如果模型目录已存在,不会覆盖已有文件
  3. 首次初始化:第一次运行时会同时创建 pagement 分页管理模块
  4. Node.js 版本:需要 Node.js >= 18.0.0

📄 许可证

GPL-3.0-only

👤 作者

awayel

🔗 相关链接


Happy Coding! 🎉