create-vue3-enterprise 1.0.29 → 1.0.31
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 +23 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -162,16 +162,29 @@ async function main() {
|
|
|
162
162
|
title: "Vue3 + TypeScript + Vite + Pinia + Vue Router",
|
|
163
163
|
value: "vue3-ts-full"
|
|
164
164
|
}
|
|
165
|
-
]
|
|
165
|
+
],
|
|
166
|
+
// 新增:选中模板后立即输出 value 到终端
|
|
167
|
+
onState: (state) => {
|
|
168
|
+
const selectedTemplate = state.value;
|
|
169
|
+
if (selectedTemplate) {
|
|
170
|
+
console.log(green(`✔ 你选择的模板值: ${selectedTemplate}`));
|
|
171
|
+
}
|
|
172
|
+
}
|
|
166
173
|
},
|
|
174
|
+
// 询问 Router:仅当模板不是全量模板时显示
|
|
167
175
|
{
|
|
168
|
-
type: (prev) =>
|
|
176
|
+
type: (prev) => {
|
|
177
|
+
return ["vue3-ts", "vue3-ts-pinia"].includes(prev.template) ? "confirm" : null;
|
|
178
|
+
},
|
|
169
179
|
name: "needsRouter",
|
|
170
180
|
message: "添加 Vue Router?",
|
|
171
181
|
initial: true
|
|
172
182
|
},
|
|
183
|
+
// 询问 Pinia:仅当模板是基础模板(vue3-ts)时显示
|
|
173
184
|
{
|
|
174
|
-
type: (prev) =>
|
|
185
|
+
type: (prev) => {
|
|
186
|
+
return prev.template === "vue3-ts" ? "confirm" : null;
|
|
187
|
+
},
|
|
175
188
|
name: "needsPinia",
|
|
176
189
|
message: "添加 Pinia (状态管理)?",
|
|
177
190
|
initial: true
|
|
@@ -194,9 +207,12 @@ async function main() {
|
|
|
194
207
|
]
|
|
195
208
|
},
|
|
196
209
|
{
|
|
197
|
-
type:
|
|
210
|
+
type: (prev) => {
|
|
211
|
+
// 仅当目录存在且非空时,才显示确认覆盖的选项
|
|
212
|
+
return targetDir && fs.existsSync(targetDir) && fs.readdirSync(targetDir).length > 0 ? "confirm" : null;
|
|
213
|
+
},
|
|
198
214
|
name: "overwrite",
|
|
199
|
-
message:
|
|
215
|
+
message: `目录 "${targetDir}" 已存在且不为空。是否覆盖?`,
|
|
200
216
|
initial: false
|
|
201
217
|
}
|
|
202
218
|
], {
|
|
@@ -205,6 +221,8 @@ async function main() {
|
|
|
205
221
|
process.exit(1);
|
|
206
222
|
}
|
|
207
223
|
});
|
|
224
|
+
// 可选:在所有交互完成后,也可以输出最终选中的模板值(二次确认)
|
|
225
|
+
console.log(green(`\n📌 最终确认:你选择的模板值是: ${promptResult.template}`));
|
|
208
226
|
if (promptResult.overwrite === false) {
|
|
209
227
|
console.log(red("✖ 操作已取消"));
|
|
210
228
|
process.exit(1);
|