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

@cjsound/nestjs-cli

v0.1.8

Published

NestJS 通用脚手架 CLI - 支持 drizzle / typeorm / sequelize 三套 ORM

Downloads

1,005

Readme

@cjsound/nestjs-cli

全栈项目脚手架 CLI,按需创建:

  • service:NestJS 后端项目(drizzle / typeorm / sequelize 三选一)
  • frontend:前端项目,可选 vue3(Element Plus 后台管理)或 uniapp(多端)
  • fullstack:同时创建上述两者

安装

npm i -g @cjsound/nestjs-cli
# 或免安装
npx @cjsound/nestjs-cli init

要求:Node.js >= 18


快速开始

交互式

nestjs-cli init

CLI 会按以下顺序询问:

  1. 创建类型service / frontend / fullstack
  2. 后端配置(仅 service / fullstack):项目名 → ORM → 数据库 host/port/user/password
  3. 前端类型 + 项目名(仅 frontend / fullstack

一行命令

# 只要后端
nestjs-cli init my-app --type service --orm drizzle --db-host 127.0.0.1

# 只要 vue3 后台前端
nestjs-cli init my-web --type frontend --frontend vue3

# 只要 uni-app 多端前端
nestjs-cli init my-app --type frontend --frontend uniapp

# 全栈 vue3:自动 my-app/ + my-app-web/
nestjs-cli init my-app --type fullstack --frontend vue3 --orm drizzle --db-host 127.0.0.1

# 全栈 uni-app:自动 my-app/ + my-app-app/
nestjs-cli init my-app --type fullstack --frontend uniapp --orm drizzle --db-host 127.0.0.1

# 全栈 + 自定义前端目录名
nestjs-cli init my-app --type fullstack --frontend vue3 --web-name admin-ui --orm drizzle

创建后

# 后端
cd my-app
yarn db                 # 同步表 + seed
yarn dev                # http://localhost:6010

# vue3 前端
cd ../my-app-web
yarn dev                # http://localhost:5173
yarn api                # 后端起来后从 Swagger 拉 TS 类型

# uni-app 前端
cd ../my-app-app
yarn page               # 生成 pages.json
yarn dev                # H5 模式
yarn dev:wx             # 微信小程序
yarn api                # 拉 cjsound-kit 风格的接口代码

命令参考

init [project-name]

| 参数 | 说明 | 默认 | |---|---|---| | [project-name] | service/fullstack 时是后端名,frontend 时是前端名 | 交互询问 | | --type <service\|frontend\|fullstack> | 创建类型 | 交互询问 | | --frontend <vue3\|uniapp> | 前端类型(frontend / fullstack 时生效) | 交互询问 | | --web-name <name> | 前端项目目录名 | vue3: <项目名>-web;uniapp: <项目名>-app | | --orm <drizzle\|typeorm\|sequelize> | ORM(service / fullstack) | 交互询问 | | --db-host / --db-port / --db-user / --db-password / --db-name | 数据库连接 | 任一传入即非交互,其余取默认 | | --jwt-secret <secret> | JWT 签名密钥 | 随机 32 字节 hex | | --skip-install | 跳过 yarn install | false |

sync [project-dir]

把脚手架最新模板(_base + _orm/<orm>)增量同步到一个已存在的项目。 适合 CLI 升级后,把新增模块 / Bug 修复带回自己的项目。

# 默认在当前目录执行, ORM 从 package.json 自动检测
cd my-app
nestjs-cli sync

# 显式指定目标目录 + ORM
nestjs-cli sync ./my-app --orm drizzle

# 只看会改哪些文件, 不实际写入
nestjs-cli sync --dry-run

# 同时合并模板里的 package.partial.json 到目标 package.json (新增依赖)
nestjs-cli sync --merge-pkg

| 参数 | 说明 | 默认 | |---|---|---| | [project-dir] | 目标项目目录 | 当前目录 (.) | | --orm <drizzle\|typeorm\|sequelize> | 强制指定 ORM | 自动检测 (package.json / 目录特征) | | --merge-pkg | 合并 package.partial.jsonpackage.json | false | | --include-env | 同时同步 _env.* / _gitignore | false (避免覆盖本地配置) | | --dry-run | 只展示会改哪些文件, 不写入 | false |

默认跳过node_modules / dist / yarn.lock / package.json / .env*(保护用户态); 模板里的 _env.* / _gitignore / package.partial.json 也默认跳过; 内容相同的文件不会写入(避免触发 nest dev 热重载)。

同步后若提示 package.json 有变化,记得到目标项目跑一次 yarn install

生成的目录布局

所有目录都在 当前工作目录 下生成:

# --type service
my-app/

# --type frontend --frontend vue3
my-web/

# --type frontend --frontend uniapp
my-app/

# --type fullstack --frontend vue3
my-app/         # 后端
my-app-web/     # 前端

# --type fullstack --frontend uniapp
my-app/         # 后端
my-app-app/     # 前端 (uni-app)

# --type fullstack --web-name admin-ui
my-app/         # 后端
admin-ui/       # 前端

模板说明

后端 my-app/

src/
├── modules/admin/          # auth / user / role / permission / dict / log / file
├── db/                     # 表定义 + 数据库 module
├── sdk/sqlSdk/             # 跨 ORM 裸 SQL 抽象
├── common/                 # 异常/拦截器/响应封装
├── guards/                 # JWT / 权限守卫
└── main.ts                 # Swagger + 全局 Pipe/Filter/Interceptor

vue3 前端

src/
├── apiService/             # @umijs/openapi 自动生成 (按 _admin_ tag)
├── layout/                 # 侧边栏 + tag 页 + 头部
├── views/system/           # 用户/角色/权限/字典/日志
├── views/help-doc/         # Markdown 帮助文档
└── ...

uniapp 前端

src/
├── apiService/modules/     # 自定义生成脚本 (按 _app_ tag, cjsound-kit 风格)
├── pinia/                  # Pinia + uni.storage 持久化
├── pages/                  # index / login / tabbar/center
├── components/             # c-* 通用组件
└── ...

ORM 选择建议

| ORM | 适用场景 | 特点 | |---|---|---| | drizzle | 追求性能 / 类型完备 / 接近原生 SQL | 轻量、TS 优先、SQL 风格 API | | typeorm | 已有 TypeORM 经验 / 需要装饰器风格 | 成熟、生态广 | | sequelize | 旧项目迁移 / 偏好传统 ORM 风格 | 老牌稳定、文档全 |

三套 ORM 由统一的 SqlSdk 包装,业务层(service / controller)写法基本一致。


开发 / 贡献

yarn install
yarn build

# 本地试用
yarn cli init test-app --type fullstack --frontend vue3 --orm drizzle --skip-install

License

MIT