juice-email-cli 2.3.7 → 2.3.8
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/package.json +1 -1
- package/src/init.js +13 -11
package/package.json
CHANGED
package/src/init.js
CHANGED
|
@@ -93,13 +93,13 @@ async function directCopy(srcPath, cwd) {
|
|
|
93
93
|
* Wrap @inquirer/prompts select with back/exit navigation.
|
|
94
94
|
* Returns the chosen value, 'back', or 'exit'.
|
|
95
95
|
*/
|
|
96
|
-
async function selectWithNav(choices, showBack) {
|
|
96
|
+
async function selectWithNav(message, choices, showBack) {
|
|
97
97
|
const { select } = await import('@inquirer/prompts');
|
|
98
98
|
const all = [];
|
|
99
99
|
if (showBack) all.push({ name: '.. 返回上级', value: 'back' });
|
|
100
100
|
all.push(...choices);
|
|
101
101
|
all.push({ name: '✕ 退出', value: 'exit' });
|
|
102
|
-
return select({ message
|
|
102
|
+
return select({ message, choices: all, loop: false });
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
async function interactiveInit(edmDir, cwd) {
|
|
@@ -113,7 +113,7 @@ async function interactiveInit(edmDir, cwd) {
|
|
|
113
113
|
name: formatName(b.meta, b.name) + (b.meta.description ? ' — ' + chalk.dim(b.meta.description) : ''),
|
|
114
114
|
value: b,
|
|
115
115
|
}));
|
|
116
|
-
const result = await selectWithNav(choices, false);
|
|
116
|
+
const result = await selectWithNav('选择品牌:', choices, false);
|
|
117
117
|
if (result === 'exit') { console.log(chalk.gray('已退出。\n')); return; }
|
|
118
118
|
brand = result;
|
|
119
119
|
step = 'version';
|
|
@@ -126,7 +126,7 @@ async function interactiveInit(edmDir, cwd) {
|
|
|
126
126
|
name: formatName(v.meta, v.name) + (v.meta.description ? ' — ' + chalk.dim(v.meta.description) : ''),
|
|
127
127
|
value: v,
|
|
128
128
|
}));
|
|
129
|
-
const result = await selectWithNav(choices, true);
|
|
129
|
+
const result = await selectWithNav('选择模板版本:', choices, true);
|
|
130
130
|
if (result === 'back') { step = 'brand'; continue; }
|
|
131
131
|
if (result === 'exit') { console.log(chalk.gray('已退出。\n')); return; }
|
|
132
132
|
version = result;
|
|
@@ -148,7 +148,7 @@ async function interactiveInit(edmDir, cwd) {
|
|
|
148
148
|
value: s,
|
|
149
149
|
})),
|
|
150
150
|
];
|
|
151
|
-
const result = await selectWithNav(choices, true);
|
|
151
|
+
const result = await selectWithNav('选择片段系列:', choices, true);
|
|
152
152
|
if (result === 'back') { step = 'version'; continue; }
|
|
153
153
|
if (result === 'exit') { console.log(chalk.gray('已退出。\n')); return; }
|
|
154
154
|
series = result;
|
|
@@ -167,7 +167,7 @@ async function interactiveInit(edmDir, cwd) {
|
|
|
167
167
|
name: formatName(v.meta, v.name) + (v.meta.description ? ' — ' + chalk.dim(v.meta.description) : ''),
|
|
168
168
|
value: v,
|
|
169
169
|
}));
|
|
170
|
-
const result = await selectWithNav(choices, true);
|
|
170
|
+
const result = await selectWithNav('选择片段变体:', choices, true);
|
|
171
171
|
if (result === 'back') { step = 'series'; continue; }
|
|
172
172
|
if (result === 'exit') { console.log(chalk.gray('已退出。\n')); return; }
|
|
173
173
|
variant = result;
|
|
@@ -367,11 +367,13 @@ async function runInitMode({ initPath, template, snippet, config, all }) {
|
|
|
367
367
|
|
|
368
368
|
// --all: copy entire EDM directory
|
|
369
369
|
if (all) {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
370
|
+
// Always use package built-in EDM for --all (not CWD's local copy)
|
|
371
|
+
const pkgEdm = path.resolve(__dirname, '..', 'edm');
|
|
372
|
+
const edmDir = fs.existsSync(pkgEdm) ? pkgEdm : (() => {
|
|
373
|
+
try { return resolveEdmDir(); } catch (_) { return null; }
|
|
374
|
+
})();
|
|
375
|
+
if (!edmDir) {
|
|
376
|
+
console.error(chalk.red('\n ✘ EDM 资源库不存在,无法拷贝。\n'));
|
|
375
377
|
process.exit(1);
|
|
376
378
|
}
|
|
377
379
|
const target = all === true ? cwd : path.resolve(all);
|