create-vue3-enterprise 1.0.32 → 1.0.33
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/dist/index.js +10 -26
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -141,6 +141,7 @@ async function main() {
|
|
|
141
141
|
return;
|
|
142
142
|
}
|
|
143
143
|
let targetDir = argv._[0];
|
|
144
|
+
let selectedTemplate = "";
|
|
144
145
|
const promptResult = await prompts([
|
|
145
146
|
{
|
|
146
147
|
type: targetDir ? null : "text",
|
|
@@ -162,31 +163,21 @@ async function main() {
|
|
|
162
163
|
title: "Vue3 + TypeScript + Vite + Pinia + Vue Router",
|
|
163
164
|
value: "vue3-ts-full"
|
|
164
165
|
}
|
|
165
|
-
]
|
|
166
|
-
onState: (state) => {
|
|
167
|
-
const selectedTemplate = state.value;
|
|
168
|
-
if (selectedTemplate) {
|
|
169
|
-
console.log(green(`✔ 你选择的模板值: ${selectedTemplate}`));
|
|
170
|
-
}
|
|
171
|
-
}
|
|
166
|
+
]
|
|
172
167
|
},
|
|
173
|
-
// 询问 Router:输出 prev.template 并判断显示
|
|
174
168
|
{
|
|
175
|
-
type: (
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
return ["vue3-ts", "vue3-ts-pinia"].includes(prev.template) ? "confirm" : null;
|
|
169
|
+
type: () => {
|
|
170
|
+
console.log(yellow(`\n[调试] needsRouter 阶段 模板值 = ${selectedTemplate}`));
|
|
171
|
+
return ["vue3-ts", "vue3-ts-pinia"].includes(selectedTemplate) ? "confirm" : null;
|
|
179
172
|
},
|
|
180
173
|
name: "needsRouter",
|
|
181
174
|
message: "添加 Vue Router?",
|
|
182
175
|
initial: true
|
|
183
176
|
},
|
|
184
|
-
// 询问 Pinia:输出 prev.template 并判断显示
|
|
185
177
|
{
|
|
186
|
-
type: (
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
return prev.template === "vue3-ts" ? "confirm" : null;
|
|
178
|
+
type: () => {
|
|
179
|
+
console.log(yellow(`\n[调试] needsPinia 阶段 模板值 = ${selectedTemplate}`));
|
|
180
|
+
return selectedTemplate === "vue3-ts" ? "confirm" : null;
|
|
190
181
|
},
|
|
191
182
|
name: "needsPinia",
|
|
192
183
|
message: "添加 Pinia (状态管理)?",
|
|
@@ -210,14 +201,9 @@ async function main() {
|
|
|
210
201
|
]
|
|
211
202
|
},
|
|
212
203
|
{
|
|
213
|
-
type:
|
|
214
|
-
// 调试输出:打印 prev.template 的值
|
|
215
|
-
console.log(yellow(`\n[调试] overwrite 阶段 prev.template = ${prev.template}`));
|
|
216
|
-
// 仅当目录存在且非空时,才显示确认覆盖的选项
|
|
217
|
-
return targetDir && fs.existsSync(targetDir) && fs.readdirSync(targetDir).length > 0 ? "confirm" : null;
|
|
218
|
-
},
|
|
204
|
+
type: "confirm",
|
|
219
205
|
name: "overwrite",
|
|
220
|
-
message: `目录 "${targetDir}"
|
|
206
|
+
message: targetDir && fs.existsSync(targetDir) && fs.readdirSync(targetDir).length > 0 ? `目录 "${targetDir}" 已存在且不为空。是否覆盖?` : "",
|
|
221
207
|
initial: false
|
|
222
208
|
}
|
|
223
209
|
], {
|
|
@@ -226,8 +212,6 @@ async function main() {
|
|
|
226
212
|
process.exit(1);
|
|
227
213
|
}
|
|
228
214
|
});
|
|
229
|
-
// 最终输出:确认所有交互完成后的 prev.template 最终值(即 promptResult.template)
|
|
230
|
-
console.log(green(`\n📌 最终确认:prev.template 的最终值是: ${promptResult.template}`));
|
|
231
215
|
if (promptResult.overwrite === false) {
|
|
232
216
|
console.log(red("✖ 操作已取消"));
|
|
233
217
|
process.exit(1);
|