create-idp 0.1.0 → 0.2.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/README.md +88 -127
- package/dist/index.js +86 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/templates/django/README.md +27 -0
- package/templates/django/_gitignore +20 -0
- package/templates/django/_template.json +14 -0
- package/templates/django/manage.py +22 -0
- package/templates/django/project_name/__init__.py +1 -0
- package/templates/django/project_name/asgi.py +11 -0
- package/templates/django/project_name/settings.py +75 -0
- package/templates/django/project_name/urls.py +16 -0
- package/templates/django/project_name/wsgi.py +11 -0
- package/templates/django/pyproject.toml +20 -0
- package/templates/express-ts/README.md +27 -0
- package/templates/express-ts/_gitignore +7 -0
- package/templates/express-ts/_template.json +13 -0
- package/templates/express-ts/package.json +23 -0
- package/templates/express-ts/src/index.ts +17 -0
- package/templates/express-ts/src/middleware/error-handler.ts +14 -0
- package/templates/express-ts/src/routes/index.ts +11 -0
- package/templates/express-ts/tsconfig.json +17 -0
- package/templates/express-ts/tsup.config.ts +9 -0
- package/templates/fastapi/README.md +21 -0
- package/templates/fastapi/_gitignore +16 -0
- package/templates/fastapi/_template.json +14 -0
- package/templates/fastapi/pyproject.toml +21 -0
- package/templates/fastapi/src/project_name/__init__.py +1 -0
- package/templates/fastapi/src/project_name/main.py +20 -0
- package/templates/fastapi/src/project_name/routes/__init__.py +8 -0
- package/templates/flask/README.md +15 -0
- package/templates/flask/_gitignore +17 -0
- package/templates/flask/_template.json +14 -0
- package/templates/flask/pyproject.toml +19 -0
- package/templates/flask/src/project_name/__init__.py +1 -0
- package/templates/flask/src/project_name/app.py +15 -0
- package/templates/flask/src/project_name/routes/__init__.py +8 -0
- package/templates/fullstack-react-node/README.md +35 -0
- package/templates/fullstack-react-node/_gitignore +7 -0
- package/templates/fullstack-react-node/_template.json +14 -0
- package/templates/fullstack-react-node/backend/package.json +22 -0
- package/templates/fullstack-react-node/backend/src/index.ts +20 -0
- package/templates/fullstack-react-node/backend/tsconfig.json +17 -0
- package/templates/fullstack-react-node/backend/tsup.config.ts +9 -0
- package/templates/fullstack-react-node/frontend/index.html +12 -0
- package/templates/fullstack-react-node/frontend/package.json +22 -0
- package/templates/fullstack-react-node/frontend/src/App.css +16 -0
- package/templates/fullstack-react-node/frontend/src/App.tsx +22 -0
- package/templates/fullstack-react-node/frontend/src/main.tsx +9 -0
- package/templates/fullstack-react-node/frontend/tsconfig.json +20 -0
- package/templates/fullstack-react-node/frontend/vite.config.ts +14 -0
- package/templates/fullstack-react-node/package.json +10 -0
- package/templates/fullstack-react-node/pnpm-workspace.yaml +3 -0
- package/templates/fullstack-react-python/Makefile +35 -0
- package/templates/fullstack-react-python/README.md +43 -0
- package/templates/fullstack-react-python/_gitignore +18 -0
- package/templates/fullstack-react-python/_template.json +25 -0
- package/templates/fullstack-react-python/backend/pyproject.toml +21 -0
- package/templates/fullstack-react-python/backend/src/project_name/__init__.py +1 -0
- package/templates/fullstack-react-python/backend/src/project_name/main.py +29 -0
- package/templates/fullstack-react-python/backend/src/project_name/routes/__init__.py +8 -0
- package/templates/fullstack-react-python/frontend/index.html +12 -0
- package/templates/fullstack-react-python/frontend/package.json +22 -0
- package/templates/fullstack-react-python/frontend/src/App.css +16 -0
- package/templates/fullstack-react-python/frontend/src/App.tsx +22 -0
- package/templates/fullstack-react-python/frontend/src/main.tsx +9 -0
- package/templates/fullstack-react-python/frontend/tsconfig.json +20 -0
- package/templates/fullstack-react-python/frontend/vite.config.ts +14 -0
- package/templates/fullstack-vue-node/README.md +35 -0
- package/templates/fullstack-vue-node/_gitignore +7 -0
- package/templates/fullstack-vue-node/_template.json +14 -0
- package/templates/fullstack-vue-node/backend/package.json +22 -0
- package/templates/fullstack-vue-node/backend/src/index.ts +20 -0
- package/templates/fullstack-vue-node/backend/tsconfig.json +17 -0
- package/templates/fullstack-vue-node/backend/tsup.config.ts +9 -0
- package/templates/fullstack-vue-node/frontend/index.html +12 -0
- package/templates/fullstack-vue-node/frontend/package.json +20 -0
- package/templates/fullstack-vue-node/frontend/src/App.vue +41 -0
- package/templates/fullstack-vue-node/frontend/src/main.ts +4 -0
- package/templates/fullstack-vue-node/frontend/src/vite-env.d.ts +1 -0
- package/templates/fullstack-vue-node/frontend/tsconfig.json +20 -0
- package/templates/fullstack-vue-node/frontend/vite.config.ts +14 -0
- package/templates/fullstack-vue-node/package.json +10 -0
- package/templates/fullstack-vue-node/pnpm-workspace.yaml +3 -0
- package/templates/next-ts/README.md +26 -0
- package/templates/next-ts/_gitignore +34 -0
- package/templates/next-ts/_template.json +13 -0
- package/templates/next-ts/next.config.ts +7 -0
- package/templates/next-ts/package.json +22 -0
- package/templates/next-ts/src/app/globals.css +21 -0
- package/templates/next-ts/src/app/layout.tsx +19 -0
- package/templates/next-ts/src/app/page.tsx +10 -0
- package/templates/next-ts/tsconfig.json +27 -0
- package/templates/springboot/.mvn/wrapper/maven-wrapper.properties +2 -0
- package/templates/springboot/README.md +27 -0
- package/templates/springboot/_gitignore +36 -0
- package/templates/springboot/_template.json +14 -0
- package/templates/springboot/mvnw +19 -0
- package/templates/springboot/mvnw.cmd +13 -0
- package/templates/springboot/pom.xml +46 -0
- package/templates/springboot/src/main/java/com/example/project_name/Application.java +12 -0
- package/templates/springboot/src/main/java/com/example/project_name/controller/HelloController.java +25 -0
- package/templates/springboot/src/main/resources/application.yml +6 -0
- package/templates/springboot/src/test/java/com/example/project_name/ApplicationTests.java +12 -0
- package/templates/template.config.json +78 -10
package/README.md
CHANGED
|
@@ -2,110 +2,115 @@
|
|
|
2
2
|
|
|
3
3
|
快速创建项目并自动初始化 GitHub 仓库的 CLI 脚手架工具。
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## 快速开始
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
-
|
|
10
|
-
- 🔐 安全的 Token 管理
|
|
11
|
-
- 📦 多模板支持
|
|
12
|
-
- ⚡ Node.js 18+ 原生支持
|
|
7
|
+
```bash
|
|
8
|
+
# 使用 npx (推荐)
|
|
9
|
+
npx create-idp my-app
|
|
13
10
|
|
|
14
|
-
|
|
11
|
+
# 或使用 npm create
|
|
12
|
+
npm create idp my-app
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
# 或全局安装后使用
|
|
17
15
|
npm install -g create-idp
|
|
16
|
+
create-idp my-app
|
|
18
17
|
```
|
|
19
18
|
|
|
20
|
-
##
|
|
19
|
+
## 用法
|
|
21
20
|
|
|
22
|
-
###
|
|
21
|
+
### 交互式创建
|
|
23
22
|
|
|
24
23
|
```bash
|
|
25
|
-
create-idp
|
|
24
|
+
npx create-idp
|
|
26
25
|
```
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
### 2. 创建项目
|
|
27
|
+
### 指定模板创建
|
|
31
28
|
|
|
32
29
|
```bash
|
|
33
|
-
|
|
34
|
-
create-idp
|
|
35
|
-
|
|
36
|
-
# 或一条命令
|
|
37
|
-
create-idp my-app --github --template node-ts
|
|
30
|
+
npx create-idp my-app --template react-ts
|
|
31
|
+
npx create-idp my-api --template fastapi
|
|
32
|
+
npx create-idp my-fullstack --template fullstack-react-node
|
|
38
33
|
```
|
|
39
34
|
|
|
40
|
-
###
|
|
35
|
+
### 一条命令创建并推送到 GitHub
|
|
41
36
|
|
|
42
37
|
```bash
|
|
43
|
-
|
|
44
|
-
pnpm dev
|
|
38
|
+
npx create-idp my-app --github --template node-ts
|
|
45
39
|
```
|
|
46
40
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
### 配置管理
|
|
41
|
+
### 列出所有可用模板
|
|
50
42
|
|
|
51
43
|
```bash
|
|
52
|
-
create-idp
|
|
53
|
-
create-idp config --show # 显示当前配置
|
|
54
|
-
create-idp config --path # 显示配置文件路径
|
|
44
|
+
npx create-idp list
|
|
55
45
|
```
|
|
56
46
|
|
|
57
|
-
|
|
47
|
+
## 可用模板
|
|
58
48
|
|
|
59
|
-
|
|
60
|
-
create-idp # 交互式创建
|
|
61
|
-
create-idp my-app # 指定项目名
|
|
62
|
-
create-idp my-app --template node-ts # 指定模板
|
|
63
|
-
create-idp my-app --github # 创建 + GitHub 仓库
|
|
64
|
-
create-idp my-app --github --public # 创建公开仓库
|
|
65
|
-
create-idp my-app --no-git # 不初始化 Git
|
|
66
|
-
```
|
|
49
|
+
### 单体项目
|
|
67
50
|
|
|
68
|
-
|
|
51
|
+
| 模板名 | 描述 |
|
|
52
|
+
|--------|------|
|
|
53
|
+
| `node-ts` | Node.js + TypeScript |
|
|
54
|
+
| `express-ts` | Express + TypeScript API |
|
|
55
|
+
| `react-ts` | React 18 + Vite + TypeScript |
|
|
56
|
+
| `vue-ts` | Vue 3 + Vite + TypeScript |
|
|
57
|
+
| `next-ts` | Next.js 14 + App Router |
|
|
58
|
+
| `python-uv` | Python + uv 包管理器 |
|
|
59
|
+
| `fastapi` | FastAPI + uv |
|
|
60
|
+
| `django` | Django + uv |
|
|
61
|
+
| `flask` | Flask + uv |
|
|
62
|
+
| `springboot` | Spring Boot 3.x + Maven |
|
|
63
|
+
| `empty` | 空项目 |
|
|
69
64
|
|
|
70
|
-
###
|
|
65
|
+
### 前后端分离
|
|
71
66
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
pnpm
|
|
76
|
-
|
|
67
|
+
| 模板名 | 描述 |
|
|
68
|
+
|--------|------|
|
|
69
|
+
| `fullstack-react-node` | React + Express (pnpm workspace) |
|
|
70
|
+
| `fullstack-vue-node` | Vue 3 + Express (pnpm workspace) |
|
|
71
|
+
| `fullstack-react-python` | React + FastAPI (Makefile) |
|
|
77
72
|
|
|
78
|
-
|
|
73
|
+
## 命令参考
|
|
79
74
|
|
|
80
|
-
|
|
75
|
+
### 创建项目
|
|
81
76
|
|
|
82
77
|
```bash
|
|
83
|
-
create-idp
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
create-idp my-
|
|
87
|
-
|
|
78
|
+
npx create-idp # 交互式创建
|
|
79
|
+
npx create-idp my-app # 指定项目名
|
|
80
|
+
npx create-idp my-app --template node-ts # 指定模板
|
|
81
|
+
npx create-idp my-app --github # 创建 + GitHub 仓库
|
|
82
|
+
npx create-idp my-app --github --public # 创建公开仓库
|
|
83
|
+
npx create-idp my-app --no-git # 不初始化 Git
|
|
84
|
+
npx create-idp my-app --no-install # 跳过依赖安装
|
|
88
85
|
```
|
|
89
86
|
|
|
90
|
-
###
|
|
87
|
+
### 列出模板
|
|
91
88
|
|
|
92
89
|
```bash
|
|
93
|
-
create-idp
|
|
90
|
+
npx create-idp list
|
|
94
91
|
```
|
|
95
92
|
|
|
96
|
-
|
|
93
|
+
### 配置管理
|
|
97
94
|
|
|
98
|
-
|
|
95
|
+
```bash
|
|
96
|
+
create-idp config --setup-github # 配置 GitHub Token
|
|
97
|
+
create-idp config --show # 显示当前配置
|
|
98
|
+
create-idp config --path # 显示配置文件路径
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## GitHub 集成
|
|
99
102
|
|
|
100
|
-
###
|
|
103
|
+
### 首次使用配置 Token
|
|
101
104
|
|
|
102
105
|
```bash
|
|
103
|
-
create-idp config --
|
|
106
|
+
npx create-idp config --setup-github
|
|
104
107
|
```
|
|
105
108
|
|
|
106
|
-
|
|
109
|
+
按提示获取 Token: https://github.com/settings/tokens/new?scopes=repo
|
|
107
110
|
|
|
108
|
-
|
|
111
|
+
### 配置文件
|
|
112
|
+
|
|
113
|
+
配置文件位置: `~/.create-idp.json`
|
|
109
114
|
|
|
110
115
|
```json
|
|
111
116
|
{
|
|
@@ -121,85 +126,41 @@ create-idp config --show
|
|
|
121
126
|
}
|
|
122
127
|
```
|
|
123
128
|
|
|
124
|
-
##
|
|
125
|
-
|
|
126
|
-
- ✅ Token 验证 (GET /user)
|
|
127
|
-
- ✅ 创建个人仓库 (POST /user/repos)
|
|
128
|
-
- ✅ 创建组织仓库 (POST /orgs/{org}/repos)
|
|
129
|
-
- ✅ 自动配置 git remote
|
|
130
|
-
- ✅ 自动推送初始提交
|
|
131
|
-
|
|
132
|
-
## 安全性
|
|
133
|
-
|
|
134
|
-
- 配置文件权限自动设置为 600 (仅所有者读写)
|
|
135
|
-
- Token 存储在本地,不会上传
|
|
136
|
-
- 使用 HTTPS 连接 GitHub
|
|
137
|
-
- 完善的错误处理
|
|
129
|
+
## 项目结构示例
|
|
138
130
|
|
|
139
|
-
|
|
131
|
+
### 单体项目 (node-ts)
|
|
140
132
|
|
|
141
|
-
### Q: Token 失效了怎么办?
|
|
142
|
-
|
|
143
|
-
```bash
|
|
144
|
-
create-idp config --setup-github
|
|
145
133
|
```
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
### Q: 如何跳过创建 GitHub 仓库?
|
|
154
|
-
|
|
155
|
-
```bash
|
|
156
|
-
create-idp my-app --no-git
|
|
134
|
+
my-app/
|
|
135
|
+
├── src/
|
|
136
|
+
│ └── index.ts
|
|
137
|
+
├── package.json
|
|
138
|
+
├── tsconfig.json
|
|
139
|
+
└── README.md
|
|
157
140
|
```
|
|
158
141
|
|
|
159
|
-
###
|
|
142
|
+
### 全栈项目 (fullstack-react-node)
|
|
160
143
|
|
|
161
|
-
```bash
|
|
162
|
-
create-idp config --setup-github
|
|
163
144
|
```
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
- `node-ts` - Node.js + TypeScript
|
|
176
|
-
- `react-ts` - React + TypeScript
|
|
177
|
-
- `vue-ts` - Vue + TypeScript
|
|
178
|
-
- 更多自定义模板
|
|
145
|
+
my-app/
|
|
146
|
+
├── frontend/
|
|
147
|
+
│ ├── src/
|
|
148
|
+
│ ├── package.json
|
|
149
|
+
│ └── vite.config.ts
|
|
150
|
+
├── backend/
|
|
151
|
+
│ ├── src/
|
|
152
|
+
│ └── package.json
|
|
153
|
+
├── package.json
|
|
154
|
+
└── pnpm-workspace.yaml
|
|
155
|
+
```
|
|
179
156
|
|
|
180
157
|
## 系统要求
|
|
181
158
|
|
|
182
159
|
- Node.js >= 18.0.0
|
|
183
|
-
- npm
|
|
160
|
+
- pnpm (推荐) / npm / yarn
|
|
161
|
+
- uv (Python 模板)
|
|
162
|
+
- Maven (Spring Boot 模板)
|
|
184
163
|
|
|
185
164
|
## 许可证
|
|
186
165
|
|
|
187
166
|
MIT
|
|
188
|
-
|
|
189
|
-
## 相关链接
|
|
190
|
-
|
|
191
|
-
- [GitHub](https://github.com/your-username/create-idp)
|
|
192
|
-
- [npm Package](https://www.npmjs.com/package/create-idp)
|
|
193
|
-
|
|
194
|
-
## 贡献
|
|
195
|
-
|
|
196
|
-
欢迎提交 Issue 和 Pull Request!
|
|
197
|
-
|
|
198
|
-
## 变更日志
|
|
199
|
-
|
|
200
|
-
### v0.1.0
|
|
201
|
-
|
|
202
|
-
- 初始发布
|
|
203
|
-
- GitHub API 集成
|
|
204
|
-
- CLI 命令完整
|
|
205
|
-
- 完整的文档和指南
|
package/dist/index.js
CHANGED
|
@@ -7,16 +7,18 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
7
7
|
});
|
|
8
8
|
|
|
9
9
|
// src/cli.ts
|
|
10
|
+
import path7 from "path";
|
|
11
|
+
import fs5 from "fs";
|
|
10
12
|
import { Command } from "commander";
|
|
11
13
|
import pc6 from "picocolors";
|
|
12
14
|
|
|
13
15
|
// package.json
|
|
14
|
-
var version = "0.
|
|
16
|
+
var version = "0.2.0";
|
|
15
17
|
|
|
16
18
|
// src/prompts.ts
|
|
17
19
|
import path2 from "path";
|
|
18
20
|
import fs from "fs";
|
|
19
|
-
import { input, select, confirm } from "@inquirer/prompts";
|
|
21
|
+
import { input, select, confirm, Separator } from "@inquirer/prompts";
|
|
20
22
|
import pc from "picocolors";
|
|
21
23
|
|
|
22
24
|
// src/utils.ts
|
|
@@ -35,11 +37,11 @@ function toValidPackageName(name) {
|
|
|
35
37
|
return name.trim().toLowerCase().replace(/\s+/g, "-").replace(/^[._]/, "").replace(/[^a-z0-9-~]+/g, "-");
|
|
36
38
|
}
|
|
37
39
|
function isEmpty(dirPath) {
|
|
38
|
-
const
|
|
39
|
-
if (!
|
|
40
|
+
const fs6 = __require("fs");
|
|
41
|
+
if (!fs6.existsSync(dirPath)) {
|
|
40
42
|
return true;
|
|
41
43
|
}
|
|
42
|
-
const files =
|
|
44
|
+
const files = fs6.readdirSync(dirPath);
|
|
43
45
|
return files.length === 0 || files.length === 1 && files[0] === ".git";
|
|
44
46
|
}
|
|
45
47
|
function execAsync(command, args, options = {}) {
|
|
@@ -109,10 +111,25 @@ async function runPrompts(argProjectName, options, userConfig = {}) {
|
|
|
109
111
|
let template = options.template;
|
|
110
112
|
if (!template) {
|
|
111
113
|
const defaultTemplate = defaults.template;
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
const singleTemplates = registry.templates.filter((t) => t.category !== "fullstack");
|
|
115
|
+
const fullstackTemplates = registry.templates.filter((t) => t.category === "fullstack");
|
|
116
|
+
const templateChoices = [];
|
|
117
|
+
templateChoices.push(new Separator("\u2500\u2500 \u5355\u4F53\u9879\u76EE \u2500\u2500"));
|
|
118
|
+
for (const t of singleTemplates) {
|
|
119
|
+
templateChoices.push({
|
|
120
|
+
name: `${t.displayName} ${pc.dim(`- ${t.description}`)}`,
|
|
121
|
+
value: t.name
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
if (fullstackTemplates.length > 0) {
|
|
125
|
+
templateChoices.push(new Separator("\u2500\u2500 \u524D\u540E\u7AEF\u5206\u79BB \u2500\u2500"));
|
|
126
|
+
for (const t of fullstackTemplates) {
|
|
127
|
+
templateChoices.push({
|
|
128
|
+
name: `${t.displayName} ${pc.dim(`- ${t.description}`)}`,
|
|
129
|
+
value: t.name
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
116
133
|
template = await select({
|
|
117
134
|
message: "\u9009\u62E9\u6A21\u677F:",
|
|
118
135
|
choices: templateChoices,
|
|
@@ -430,6 +447,7 @@ async function createGithubRepo(repoName, targetDir, isPublic) {
|
|
|
430
447
|
}
|
|
431
448
|
|
|
432
449
|
// src/post-init.ts
|
|
450
|
+
import path5 from "path";
|
|
433
451
|
import pc3 from "picocolors";
|
|
434
452
|
async function runPostInit(targetDir, commands) {
|
|
435
453
|
for (const cmd of commands) {
|
|
@@ -447,13 +465,27 @@ async function runPostInit(targetDir, commands) {
|
|
|
447
465
|
}
|
|
448
466
|
}
|
|
449
467
|
}
|
|
468
|
+
async function runWorkspacePostInit(targetDir, config) {
|
|
469
|
+
if (config.postInit && config.postInit.length > 0) {
|
|
470
|
+
await runPostInit(targetDir, config.postInit);
|
|
471
|
+
}
|
|
472
|
+
if (config.workspaces) {
|
|
473
|
+
for (const ws of config.workspaces) {
|
|
474
|
+
if (ws.postInit && ws.postInit.length > 0) {
|
|
475
|
+
const wsDir = path5.join(targetDir, ws.name);
|
|
476
|
+
console.log(pc3.dim(` [${ws.name}]`));
|
|
477
|
+
await runPostInit(wsDir, ws.postInit);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}
|
|
450
482
|
|
|
451
483
|
// src/update-check.ts
|
|
452
484
|
import fs4 from "fs";
|
|
453
|
-
import
|
|
485
|
+
import path6 from "path";
|
|
454
486
|
import os2 from "os";
|
|
455
487
|
import pc4 from "picocolors";
|
|
456
|
-
var CACHE_PATH =
|
|
488
|
+
var CACHE_PATH = path6.join(os2.homedir(), ".create-idp-update-check");
|
|
457
489
|
var CACHE_TTL = 24 * 60 * 60 * 1e3;
|
|
458
490
|
var PACKAGE_NAME = "create-idp";
|
|
459
491
|
function readCache() {
|
|
@@ -642,6 +674,28 @@ async function createCli() {
|
|
|
642
674
|
throw err;
|
|
643
675
|
}
|
|
644
676
|
});
|
|
677
|
+
program.command("list").description("\u5217\u51FA\u6240\u6709\u53EF\u7528\u6A21\u677F").action(() => {
|
|
678
|
+
const templatesDir = getTemplatesDir();
|
|
679
|
+
const registryPath = path7.join(templatesDir, "template.config.json");
|
|
680
|
+
const registry = JSON.parse(
|
|
681
|
+
fs5.readFileSync(registryPath, "utf-8")
|
|
682
|
+
);
|
|
683
|
+
const singleTemplates = registry.templates.filter((t) => t.category !== "fullstack");
|
|
684
|
+
const fullstackTemplates = registry.templates.filter((t) => t.category === "fullstack");
|
|
685
|
+
console.log();
|
|
686
|
+
console.log(pc6.cyan(" \u5355\u4F53\u9879\u76EE:"));
|
|
687
|
+
for (const t of singleTemplates) {
|
|
688
|
+
console.log(` ${pc6.green(t.name.padEnd(24))} ${pc6.dim(t.displayName)}`);
|
|
689
|
+
}
|
|
690
|
+
if (fullstackTemplates.length > 0) {
|
|
691
|
+
console.log();
|
|
692
|
+
console.log(pc6.cyan(" \u524D\u540E\u7AEF\u5206\u79BB:"));
|
|
693
|
+
for (const t of fullstackTemplates) {
|
|
694
|
+
console.log(` ${pc6.green(t.name.padEnd(24))} ${pc6.dim(t.displayName)}`);
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
console.log();
|
|
698
|
+
});
|
|
645
699
|
program.command("config").description("\u7BA1\u7406\u914D\u7F6E").option("--setup-github", "\u914D\u7F6E GitHub Token").option("--show", "\u663E\u793A\u5F53\u524D\u914D\u7F6E").option("--path", "\u663E\u793A\u914D\u7F6E\u6587\u4EF6\u8DEF\u5F84").action(async (options) => {
|
|
646
700
|
if (options.setupGithub) {
|
|
647
701
|
const success = await runGitHubSetup();
|
|
@@ -665,9 +719,14 @@ async function createCli() {
|
|
|
665
719
|
async function executeProject(options) {
|
|
666
720
|
const templateConfig = await scaffoldProject(options);
|
|
667
721
|
console.log(pc6.green("\u2714 \u9879\u76EE\u6587\u4EF6\u5DF2\u751F\u6210"));
|
|
668
|
-
if (!options.noInstall && templateConfig
|
|
669
|
-
|
|
670
|
-
|
|
722
|
+
if (!options.noInstall && templateConfig) {
|
|
723
|
+
if (templateConfig.type === "workspace") {
|
|
724
|
+
await runWorkspacePostInit(options.targetDir, templateConfig);
|
|
725
|
+
console.log(pc6.green("\u2714 \u4F9D\u8D56\u5B89\u88C5\u5B8C\u6210"));
|
|
726
|
+
} else if (templateConfig.postInit) {
|
|
727
|
+
await runPostInit(options.targetDir, templateConfig.postInit);
|
|
728
|
+
console.log(pc6.green("\u2714 \u4F9D\u8D56\u5B89\u88C5\u5B8C\u6210"));
|
|
729
|
+
}
|
|
671
730
|
}
|
|
672
731
|
if (options.initGit) {
|
|
673
732
|
await initGit(options.targetDir);
|
|
@@ -686,7 +745,19 @@ async function executeProject(options) {
|
|
|
686
745
|
console.log();
|
|
687
746
|
const pm = templateConfig?.packageManager ?? "pnpm";
|
|
688
747
|
const cdCmd = options.targetDir !== process.cwd() ? `cd ${options.projectName} && ` : "";
|
|
689
|
-
|
|
748
|
+
if (templateConfig?.type === "workspace") {
|
|
749
|
+
if (pm === "pnpm") {
|
|
750
|
+
console.log(pc6.dim(` ${cdCmd}pnpm dev`));
|
|
751
|
+
} else {
|
|
752
|
+
console.log(pc6.dim(` ${cdCmd}make dev`));
|
|
753
|
+
}
|
|
754
|
+
} else if (pm === "maven") {
|
|
755
|
+
console.log(pc6.dim(` ${cdCmd}./mvnw spring-boot:run`));
|
|
756
|
+
} else if (pm === "gradle") {
|
|
757
|
+
console.log(pc6.dim(` ${cdCmd}./gradlew bootRun`));
|
|
758
|
+
} else {
|
|
759
|
+
console.log(pc6.dim(` ${cdCmd}${pm} dev`));
|
|
760
|
+
}
|
|
690
761
|
console.log();
|
|
691
762
|
}
|
|
692
763
|
|