@svton/cli 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 SVTON Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,138 @@
1
+ # @svton/cli
2
+
3
+ > Svton CLI - 使用 NestJS、Next.js 和 Taro 创建全栈应用
4
+
5
+ [![npm version](https://badge.fury.io/js/@svton/cli.svg)](https://badge.fury.io/js/@svton/cli)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ ## 特性
9
+
10
+ - 🚀 **全栈模板** - 后端 (NestJS)、管理后台 (Next.js)、移动端 (Taro)
11
+ - 📦 **Monorepo 架构** - Turbo + pnpm workspace 预配置
12
+ - 🎯 **多种模板** - 按需选择:全栈、仅后端、仅管理后台、仅移动端
13
+ - 🛠️ **开发体验** - ESLint、Prettier、TypeScript 预配置
14
+ - 🐳 **Docker 支持** - 内置 MySQL 和 Redis 容器配置
15
+ - 📚 **类型安全** - 共享类型定义和 API 接口
16
+
17
+ ## 快速开始
18
+
19
+ ```bash
20
+ # 推荐方式 (npx)
21
+ npx @svton/cli create my-app
22
+
23
+ # 全局安装后使用
24
+ npm install -g @svton/cli
25
+ svton create my-app
26
+ ```
27
+
28
+ ## 使用方法
29
+
30
+ ```bash
31
+ svton create <project-name> [options]
32
+ svton init <project-name> [options] # 别名
33
+ svton new <project-name> [options] # 别名
34
+ ```
35
+
36
+ ### 选项
37
+
38
+ - `-o, --org <name>` - 组织名称(默认:项目名)
39
+ - `--skip-install` - 跳过依赖安装
40
+ - `--skip-git` - 跳过 Git 初始化
41
+ - `-t, --template <template>` - 使用的模板(full-stack、backend-only、admin-only、mobile-only)
42
+ - `-p, --package-manager <pm>` - 包管理器(npm、yarn、pnpm)
43
+
44
+ ### 示例
45
+
46
+ ```bash
47
+ # 创建全栈应用
48
+ svton create my-app
49
+
50
+ # 使用自定义组织名
51
+ svton create my-app --org my-company
52
+
53
+ # 创建仅后端项目
54
+ svton create my-api --template backend-only
55
+
56
+ # 跳过依赖安装
57
+ svton create my-app --skip-install
58
+ ```
59
+
60
+ ## 模板
61
+
62
+ ### 全栈模板 (`full-stack`)
63
+ 完整应用包含:
64
+ - **后端**: NestJS + Prisma + MySQL + Redis
65
+ - **管理后台**: Next.js + TailwindCSS + shadcn/ui
66
+ - **移动端**: Taro + React (微信小程序)
67
+ - **共享类型**: TypeScript 类型定义
68
+
69
+ ### 仅后端 (`backend-only`)
70
+ - NestJS API 服务器
71
+ - Prisma ORM + MySQL
72
+ - JWT 认证
73
+ - Redis 缓存
74
+ - Swagger 文档
75
+
76
+ ### 仅管理后台 (`admin-only`)
77
+ - Next.js 15 + App Router
78
+ - TailwindCSS + shadcn/ui
79
+ - TypeScript + ESLint
80
+ - API 客户端集成
81
+
82
+ ### 仅移动端 (`mobile-only`)
83
+ - Taro 3.6 框架
84
+ - React 18
85
+ - 微信小程序支持
86
+ - TypeScript + ESLint
87
+
88
+ ## 项目架构
89
+
90
+ 使用 `svton` 创建的项目遵循以下架构:
91
+
92
+ ```
93
+ my-app/
94
+ ├── apps/
95
+ │ ├── backend/ # @my-org/backend
96
+ │ ├── admin/ # @my-org/admin
97
+ │ └── mobile/ # @my-org/mobile
98
+ ├── packages/
99
+ │ └── types/ # @my-org/types
100
+ ├── package.json
101
+ ├── pnpm-workspace.yaml
102
+ ├── turbo.json
103
+ └── docker-compose.yml
104
+ ```
105
+
106
+ ## 创建后的步骤
107
+
108
+ 1. **启动数据库**(全栈/后端模板):
109
+ ```bash
110
+ docker-compose up -d
111
+ ```
112
+
113
+ 2. **配置环境变量**:
114
+ ```bash
115
+ cp apps/backend/.env.example apps/backend/.env
116
+ # 编辑 .env 文件配置你的设置
117
+ ```
118
+
119
+ 3. **运行数据库迁移**(后端模板):
120
+ ```bash
121
+ pnpm --filter @my-org/backend prisma:generate
122
+ pnpm --filter @my-org/backend prisma:migrate
123
+ ```
124
+
125
+ 4. **启动开发服务器**:
126
+ ```bash
127
+ pnpm dev
128
+ ```
129
+
130
+ ## 环境要求
131
+
132
+ - Node.js >= 18.0.0
133
+ - npm、yarn 或 pnpm(推荐 pnpm)
134
+ - Docker(用于数据库服务)
135
+
136
+ ## 许可证
137
+
138
+ MIT © [SVTON Team](https://github.com/svton)
package/bin/svton.js ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+
3
+ // 直接使用 CommonJS 格式
4
+ const { cli } = require('../dist/index.js');
5
+
6
+ cli().catch((error) => {
7
+ console.error('Error starting CLI:', error);
8
+ process.exit(1);
9
+ });
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ declare function cli(): void;
3
+
4
+ export { cli };
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ declare function cli(): void;
3
+
4
+ export { cli };