create-vue3-enterprise 1.0.32 → 1.0.34
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 -20
- 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",
|
|
@@ -164,29 +165,25 @@ async function main() {
|
|
|
164
165
|
}
|
|
165
166
|
],
|
|
166
167
|
onState: (state) => {
|
|
167
|
-
|
|
168
|
+
selectedTemplate = state.value;
|
|
168
169
|
if (selectedTemplate) {
|
|
169
170
|
console.log(green(`✔ 你选择的模板值: ${selectedTemplate}`));
|
|
170
171
|
}
|
|
171
172
|
}
|
|
172
173
|
},
|
|
173
|
-
// 询问 Router:输出 prev.template 并判断显示
|
|
174
174
|
{
|
|
175
|
-
type: (
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
return ["vue3-ts", "vue3-ts-pinia"].includes(prev.template) ? "confirm" : null;
|
|
175
|
+
type: () => {
|
|
176
|
+
console.log(yellow(`\n[调试] needsRouter 阶段 模板值 = ${selectedTemplate}`));
|
|
177
|
+
return ["vue3-ts", "vue3-ts-pinia"].includes(selectedTemplate) ? "confirm" : null;
|
|
179
178
|
},
|
|
180
179
|
name: "needsRouter",
|
|
181
180
|
message: "添加 Vue Router?",
|
|
182
181
|
initial: true
|
|
183
182
|
},
|
|
184
|
-
// 询问 Pinia:输出 prev.template 并判断显示
|
|
185
183
|
{
|
|
186
|
-
type: (
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
return prev.template === "vue3-ts" ? "confirm" : null;
|
|
184
|
+
type: () => {
|
|
185
|
+
console.log(yellow(`\n[调试] needsPinia 阶段 模板值 = ${selectedTemplate}`));
|
|
186
|
+
return selectedTemplate === "vue3-ts" ? "confirm" : null;
|
|
190
187
|
},
|
|
191
188
|
name: "needsPinia",
|
|
192
189
|
message: "添加 Pinia (状态管理)?",
|
|
@@ -210,14 +207,9 @@ async function main() {
|
|
|
210
207
|
]
|
|
211
208
|
},
|
|
212
209
|
{
|
|
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
|
-
},
|
|
210
|
+
type: "confirm",
|
|
219
211
|
name: "overwrite",
|
|
220
|
-
message: `目录 "${targetDir}"
|
|
212
|
+
message: targetDir && fs.existsSync(targetDir) && fs.readdirSync(targetDir).length > 0 ? `目录 "${targetDir}" 已存在且不为空。是否覆盖?` : "",
|
|
221
213
|
initial: false
|
|
222
214
|
}
|
|
223
215
|
], {
|
|
@@ -226,8 +218,6 @@ async function main() {
|
|
|
226
218
|
process.exit(1);
|
|
227
219
|
}
|
|
228
220
|
});
|
|
229
|
-
// 最终输出:确认所有交互完成后的 prev.template 最终值(即 promptResult.template)
|
|
230
|
-
console.log(green(`\n📌 最终确认:prev.template 的最终值是: ${promptResult.template}`));
|
|
231
221
|
if (promptResult.overwrite === false) {
|
|
232
222
|
console.log(red("✖ 操作已取消"));
|
|
233
223
|
process.exit(1);
|