@t0.labs/daxta 0.4.18 → 0.4.19
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/catalog/it-case.js +1 -1
- package/dist/catalog/test-title.d.ts +5 -3
- package/dist/catalog/test-title.js +164 -22
- package/dist/cli/discover-test.js +22 -10
- package/dist/cli/inject-main.js +18 -12
- package/dist/cli/install.js +0 -3
- package/dist/cli/titles.js +8 -4
- package/package.json +1 -1
package/dist/catalog/it-case.js
CHANGED
|
@@ -47,7 +47,7 @@ function resourcePhrase(pathTemplate) {
|
|
|
47
47
|
function suggestItCases(section, method, pathTemplate) {
|
|
48
48
|
const res = resourcePhrase(pathTemplate);
|
|
49
49
|
const m = (method || 'get').toLowerCase();
|
|
50
|
-
const hasParam = Boolean(pathTemplate?.split('/').some((part) =>
|
|
50
|
+
const hasParam = Boolean(pathTemplate?.split('/').some((part) => (0, test_title_1.isPathParam)(part)));
|
|
51
51
|
const out = [];
|
|
52
52
|
const add = (value) => {
|
|
53
53
|
const next = value.replace(/\s+/g, ' ').trim();
|
|
@@ -21,9 +21,11 @@ export type TitleSuggestion = {
|
|
|
21
21
|
};
|
|
22
22
|
/**
|
|
23
23
|
* POST /v1/admin/mock-tbs → Create Mock Tbs
|
|
24
|
-
* GET /v1/
|
|
25
|
-
*
|
|
26
|
-
*
|
|
24
|
+
* GET /v1/me/branches → Find All Branches
|
|
25
|
+
* GET /v1/integrator/merchants/{id}/branches → Find All Branches By Merchant Id
|
|
26
|
+
* GET /v1/admin/addresses/:id → Find One Address By Id
|
|
27
|
+
* POST /v1/me/branches/:id/addresses/billing → Create Billing Address
|
|
28
|
+
* POST /v1/public/external-checkout/:id/complete → Complete External Checkout
|
|
27
29
|
*/
|
|
28
30
|
export declare function suggestOperationTitleResult(method: string, pathTemplate: string): TitleSuggestion;
|
|
29
31
|
export declare function suggestOperationTitles(method: string, pathTemplate: string): string[];
|
|
@@ -18,9 +18,14 @@ const ROLE_WORDS = new Set([
|
|
|
18
18
|
'admin',
|
|
19
19
|
'user',
|
|
20
20
|
'users',
|
|
21
|
+
'me',
|
|
21
22
|
'public',
|
|
22
23
|
'internal',
|
|
24
|
+
'internal-application',
|
|
25
|
+
'internal-service',
|
|
26
|
+
'integrator',
|
|
23
27
|
'partner',
|
|
28
|
+
'device',
|
|
24
29
|
'staff',
|
|
25
30
|
'customer',
|
|
26
31
|
'vendor',
|
|
@@ -29,7 +34,7 @@ const ROLE_WORDS = new Set([
|
|
|
29
34
|
'system',
|
|
30
35
|
'superadmin',
|
|
31
36
|
]);
|
|
32
|
-
const MODULE_WORDS = new Set(['validator', 'validation', 'validators']);
|
|
37
|
+
const MODULE_WORDS = new Set(['validator', 'validation', 'validators', 'business-data']);
|
|
33
38
|
const ACTION_WORDS = new Set([
|
|
34
39
|
'validate',
|
|
35
40
|
'approve',
|
|
@@ -48,14 +53,37 @@ const ACTION_WORDS = new Set([
|
|
|
48
53
|
'restore',
|
|
49
54
|
'verify',
|
|
50
55
|
'confirm',
|
|
56
|
+
'complete',
|
|
51
57
|
'activate',
|
|
52
58
|
'deactivate',
|
|
53
59
|
'check',
|
|
54
60
|
'calculate',
|
|
61
|
+
'retry',
|
|
62
|
+
'send',
|
|
63
|
+
'insert',
|
|
64
|
+
'merge',
|
|
65
|
+
'upsert',
|
|
66
|
+
'onboard',
|
|
67
|
+
'assign',
|
|
55
68
|
]);
|
|
69
|
+
const NOTIFY_WORDS = new Set(['sms', 'email', 'phone', 'push']);
|
|
56
70
|
function isPathParam(part) {
|
|
57
71
|
const value = part.trim();
|
|
58
|
-
|
|
72
|
+
if (!value)
|
|
73
|
+
return false;
|
|
74
|
+
if (value.startsWith('{') || value.startsWith(':') || value.startsWith('${'))
|
|
75
|
+
return true;
|
|
76
|
+
if (/\$\{[^}]+\}/.test(value))
|
|
77
|
+
return true;
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
function paramName(part) {
|
|
81
|
+
return part
|
|
82
|
+
.trim()
|
|
83
|
+
.replace(/^\$\{/, '')
|
|
84
|
+
.replace(/^[:{]+/, '')
|
|
85
|
+
.replace(/[}]+$/, '')
|
|
86
|
+
.replace(/^\$/, '');
|
|
59
87
|
}
|
|
60
88
|
function titleCaseToken(value) {
|
|
61
89
|
return value
|
|
@@ -132,18 +160,86 @@ function lastSegment(pathTemplate) {
|
|
|
132
160
|
const rest = operationSegments(pathTemplate);
|
|
133
161
|
return (rest[rest.length - 1] || '').toLowerCase();
|
|
134
162
|
}
|
|
163
|
+
function singularSimple(raw) {
|
|
164
|
+
const value = raw.toLowerCase();
|
|
165
|
+
if (value.length <= 3)
|
|
166
|
+
return value;
|
|
167
|
+
if (value.endsWith('ies') && value.length > 4)
|
|
168
|
+
return value.slice(0, -3) + 'y';
|
|
169
|
+
if (value.endsWith('ches') || value.endsWith('shes') || value.endsWith('sses'))
|
|
170
|
+
return value.slice(0, -2);
|
|
171
|
+
if (value.endsWith('ses') && value.length > 4)
|
|
172
|
+
return value.slice(0, -2);
|
|
173
|
+
if (value.endsWith('s') && !value.endsWith('ss'))
|
|
174
|
+
return value.slice(0, -1);
|
|
175
|
+
return value;
|
|
176
|
+
}
|
|
177
|
+
function singularStem(token) {
|
|
178
|
+
if (token.includes('-')) {
|
|
179
|
+
const bits = token.split('-');
|
|
180
|
+
bits[bits.length - 1] = singularSimple(bits[bits.length - 1]);
|
|
181
|
+
return bits.join('-');
|
|
182
|
+
}
|
|
183
|
+
return singularSimple(token);
|
|
184
|
+
}
|
|
185
|
+
/** `{id}` after `merchants` (parent) → Merchant Id; trailing `:id` → Id */
|
|
186
|
+
function byClauseFromParam(param, precedingNamed, role) {
|
|
187
|
+
const name = paramName(param);
|
|
188
|
+
if (!name)
|
|
189
|
+
return 'By Id';
|
|
190
|
+
if (/^id$/i.test(name)) {
|
|
191
|
+
if (role === 'parent' && precedingNamed) {
|
|
192
|
+
return `By ${titleCaseToken(singularStem(precedingNamed))} Id`;
|
|
193
|
+
}
|
|
194
|
+
return 'By Id';
|
|
195
|
+
}
|
|
196
|
+
if (/Id$/i.test(name))
|
|
197
|
+
return `By ${titleCaseToken(name.replace(/Id$/i, ''))} Id`;
|
|
198
|
+
return `By ${titleCaseToken(name)}`;
|
|
199
|
+
}
|
|
200
|
+
function pathTokens(pathTemplate) {
|
|
201
|
+
return pathTemplate.split('/').filter(Boolean);
|
|
202
|
+
}
|
|
203
|
+
function trailingParam(pathTemplate) {
|
|
204
|
+
const tokens = pathTokens(pathTemplate);
|
|
205
|
+
const last = tokens[tokens.length - 1];
|
|
206
|
+
return last && isPathParam(last) ? last : undefined;
|
|
207
|
+
}
|
|
208
|
+
function parentParam(pathTemplate) {
|
|
209
|
+
const tokens = pathTokens(pathTemplate);
|
|
210
|
+
for (let i = tokens.length - 1; i >= 1; i -= 1) {
|
|
211
|
+
if (!isPathParam(tokens[i]))
|
|
212
|
+
continue;
|
|
213
|
+
if (i === tokens.length - 1)
|
|
214
|
+
continue;
|
|
215
|
+
let named = '';
|
|
216
|
+
for (let j = i - 1; j >= 0; j -= 1) {
|
|
217
|
+
if (!isPathParam(tokens[j]) && !/^v\d+$/i.test(tokens[j]) && !ROLE_WORDS.has(tokens[j].toLowerCase())) {
|
|
218
|
+
named = tokens[j];
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return { param: tokens[i], named };
|
|
223
|
+
}
|
|
224
|
+
return undefined;
|
|
225
|
+
}
|
|
135
226
|
/**
|
|
136
227
|
* POST /v1/admin/mock-tbs → Create Mock Tbs
|
|
137
|
-
* GET /v1/
|
|
138
|
-
*
|
|
139
|
-
*
|
|
228
|
+
* GET /v1/me/branches → Find All Branches
|
|
229
|
+
* GET /v1/integrator/merchants/{id}/branches → Find All Branches By Merchant Id
|
|
230
|
+
* GET /v1/admin/addresses/:id → Find One Address By Id
|
|
231
|
+
* POST /v1/me/branches/:id/addresses/billing → Create Billing Address
|
|
232
|
+
* POST /v1/public/external-checkout/:id/complete → Complete External Checkout
|
|
140
233
|
*/
|
|
141
234
|
function suggestOperationTitleResult(method, pathTemplate) {
|
|
142
|
-
const resource = resourceLabel(pathTemplate);
|
|
143
235
|
const rest = operationSegments(pathTemplate);
|
|
144
236
|
const last = lastSegment(pathTemplate);
|
|
145
|
-
const
|
|
237
|
+
const prev = rest.length >= 2 ? rest[rest.length - 2] : undefined;
|
|
238
|
+
const leafAll = last ? titleCaseToken(last) : resourceLabel(pathTemplate);
|
|
239
|
+
const leafOne = last ? titleCaseToken(singularStem(last)) : leafAll;
|
|
146
240
|
const m = method.toLowerCase();
|
|
241
|
+
const endParam = trailingParam(pathTemplate);
|
|
242
|
+
const nested = parentParam(pathTemplate);
|
|
147
243
|
const out = [];
|
|
148
244
|
const add = (value) => {
|
|
149
245
|
const next = value.replace(/\s+/g, ' ').trim();
|
|
@@ -151,34 +247,80 @@ function suggestOperationTitleResult(method, pathTemplate) {
|
|
|
151
247
|
out.push(next);
|
|
152
248
|
};
|
|
153
249
|
if (last === 'bulk') {
|
|
250
|
+
const resource = resourceLabel(pathTemplate);
|
|
154
251
|
add(m === 'get' ? `Find Bulk ${resource}` : `Create Bulk ${resource}`);
|
|
155
252
|
return { titles: out.slice(0, 3), auto: out.length > 0 };
|
|
156
253
|
}
|
|
254
|
+
if (last.startsWith('by-')) {
|
|
255
|
+
const target = prev ? titleCaseToken(prev) : resourceLabel(pathTemplate);
|
|
256
|
+
const by = titleCaseToken(last);
|
|
257
|
+
if (m === 'get') {
|
|
258
|
+
add(`Find All ${target} ${by}`);
|
|
259
|
+
add(`Find ${target} ${by}`);
|
|
260
|
+
}
|
|
261
|
+
else if (m === 'post')
|
|
262
|
+
add(`Create ${target} ${by}`);
|
|
263
|
+
else
|
|
264
|
+
add(`${titleCaseToken(m)} ${target} ${by}`);
|
|
265
|
+
return { titles: out.slice(0, 3), auto: out.length > 0 };
|
|
266
|
+
}
|
|
267
|
+
if (NOTIFY_WORDS.has(last) && (prev === 'send' || prev === 'validations' || ACTION_WORDS.has(prev || ''))) {
|
|
268
|
+
if (prev === 'send' || last !== 'phone')
|
|
269
|
+
add(`Send ${titleCaseToken(last)}`);
|
|
270
|
+
if (prev === 'validations' || prev === 'validate')
|
|
271
|
+
add(`Validate ${titleCaseToken(last)}`);
|
|
272
|
+
if (out.length)
|
|
273
|
+
return { titles: out.slice(0, 3), auto: true };
|
|
274
|
+
}
|
|
275
|
+
if (NOTIFY_WORDS.has(last) && m === 'post') {
|
|
276
|
+
add(`Send ${titleCaseToken(last)}`);
|
|
277
|
+
return { titles: out.slice(0, 3), auto: out.length > 0 };
|
|
278
|
+
}
|
|
279
|
+
if (last.endsWith('-retries') || last === 'retries') {
|
|
280
|
+
const subject = prev ? titleCaseToken(prev) : titleCaseToken(last.replace(/-?retries$/, '') || 'operation');
|
|
281
|
+
add(`Retry ${subject}`);
|
|
282
|
+
add('Retry Operation');
|
|
283
|
+
return { titles: out.slice(0, 3), auto: out.length > 0 };
|
|
284
|
+
}
|
|
157
285
|
if (ACTION_WORDS.has(last)) {
|
|
286
|
+
const resource = prev ? titleCaseToken(prev) : resourceLabel(pathTemplate);
|
|
158
287
|
add(`${titleCaseToken(last)} ${resource}`);
|
|
159
288
|
return { titles: out.slice(0, 3), auto: out.length > 0 };
|
|
160
289
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
290
|
+
if (prev && /^(addresses?|items?)$/i.test(prev) && !ACTION_WORDS.has(last) && !endParam) {
|
|
291
|
+
const kind = titleCaseToken(last);
|
|
292
|
+
const noun = titleCaseToken(singularStem(prev));
|
|
293
|
+
if (m === 'post')
|
|
294
|
+
add(`Create ${kind} ${noun}`);
|
|
295
|
+
else if (m === 'get')
|
|
296
|
+
add(`Find ${kind} ${noun}`);
|
|
297
|
+
else
|
|
298
|
+
add(`${titleCaseToken(m)} ${kind} ${noun}`);
|
|
299
|
+
if (out.length)
|
|
300
|
+
return { titles: out.slice(0, 3), auto: true };
|
|
301
|
+
}
|
|
302
|
+
const byEnd = endParam ? byClauseFromParam(endParam, last, 'end') : undefined;
|
|
303
|
+
const byParent = nested ? byClauseFromParam(nested.param, nested.named, 'parent') : undefined;
|
|
304
|
+
if (m === 'get' && endParam)
|
|
305
|
+
add(`Find One ${leafOne} ${byEnd}`);
|
|
306
|
+
else if (m === 'get' && byParent) {
|
|
307
|
+
add(`Find All ${leafAll} ${byParent}`);
|
|
308
|
+
add(`Find All ${leafAll}`);
|
|
165
309
|
}
|
|
166
|
-
if (m === 'get' && byId)
|
|
167
|
-
add(`Find One ${resource} By Id`);
|
|
168
310
|
else if (m === 'get')
|
|
169
|
-
add(`Find All ${
|
|
311
|
+
add(`Find All ${leafAll}`);
|
|
170
312
|
else if (m === 'post')
|
|
171
|
-
add(`Create ${
|
|
172
|
-
else if (m === 'delete' &&
|
|
173
|
-
add(`Delete One ${
|
|
313
|
+
add(`Create ${leafOne}`);
|
|
314
|
+
else if (m === 'delete' && endParam)
|
|
315
|
+
add(`Delete One ${leafOne} ${byEnd}`);
|
|
174
316
|
else if (m === 'delete')
|
|
175
|
-
add(`Delete ${
|
|
176
|
-
else if ((m === 'put' || m === 'patch' || m === 'update') &&
|
|
177
|
-
add(`Update ${
|
|
317
|
+
add(`Delete ${leafAll}`);
|
|
318
|
+
else if ((m === 'put' || m === 'patch' || m === 'update') && endParam)
|
|
319
|
+
add(`Update ${leafOne} ${byEnd}`);
|
|
178
320
|
else if (m === 'put' || m === 'patch' || m === 'update')
|
|
179
|
-
add(`Update ${
|
|
321
|
+
add(`Update ${leafAll}`);
|
|
180
322
|
else
|
|
181
|
-
return { titles:
|
|
323
|
+
return { titles: out.slice(0, 3), auto: false };
|
|
182
324
|
return { titles: out.slice(0, 3), auto: out.length > 0 };
|
|
183
325
|
}
|
|
184
326
|
function suggestOperationTitles(method, pathTemplate) {
|
|
@@ -106,22 +106,34 @@ async function resolveTestScript(options) {
|
|
|
106
106
|
return null;
|
|
107
107
|
return typed;
|
|
108
108
|
}
|
|
109
|
-
const
|
|
109
|
+
const shown = choices.slice(0, 8);
|
|
110
|
+
const def = shown[0];
|
|
110
111
|
if (options.yes || !process.stdin.isTTY)
|
|
111
112
|
return def.name;
|
|
112
|
-
console.log(` ${ui_1.c.dim('
|
|
113
|
-
|
|
114
|
-
const
|
|
115
|
-
const
|
|
116
|
-
const cmd = isDaxtaWrappedScript(choice.command)
|
|
117
|
-
|
|
113
|
+
console.log(` ${ui_1.c.gold('?')} ${ui_1.c.bold('Test script')} ${ui_1.c.dim('— reporter + globalSetup')}`);
|
|
114
|
+
shown.forEach((choice, i) => {
|
|
115
|
+
const n = String(i + 1);
|
|
116
|
+
const rec = i === 0 ? ui_1.c.dim(' recommended') : '';
|
|
117
|
+
const cmd = isDaxtaWrappedScript(choice.command)
|
|
118
|
+
? '(already wired → daxta test)'
|
|
119
|
+
: choice.command.length > 52
|
|
120
|
+
? `${choice.command.slice(0, 52)}…`
|
|
121
|
+
: choice.command;
|
|
122
|
+
console.log(` ${ui_1.c.ice(n)} ${ui_1.c.bold(choice.name)}${rec}`);
|
|
123
|
+
console.log(` ${ui_1.c.dim(cmd)}`);
|
|
118
124
|
});
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
if (!answer
|
|
125
|
+
console.log(` ${ui_1.c.dim('n')} skip`);
|
|
126
|
+
const answer = await (0, ui_1.readlineAsk)(` ${ui_1.c.dim(`Enter = 1 (${def.name})`)} ${ui_1.c.dim('·')} ${ui_1.c.dim('or type a script name')}\n ${ui_1.c.ice('›')} `);
|
|
127
|
+
if (!answer)
|
|
122
128
|
return def.name;
|
|
123
129
|
if (/^n(o)?$/i.test(answer))
|
|
124
130
|
return null;
|
|
131
|
+
if (/^\d+$/.test(answer)) {
|
|
132
|
+
const picked = shown[Number(answer) - 1];
|
|
133
|
+
if (!picked)
|
|
134
|
+
throw new Error(`No script #${answer}`);
|
|
135
|
+
return picked.name;
|
|
136
|
+
}
|
|
125
137
|
return answer;
|
|
126
138
|
}
|
|
127
139
|
function upsertConfigFields(cwd, fields, dryRun = false) {
|
package/dist/cli/inject-main.js
CHANGED
|
@@ -94,21 +94,27 @@ async function resolveMainPath(cwd, candidates) {
|
|
|
94
94
|
return full;
|
|
95
95
|
}
|
|
96
96
|
const rel = path.relative(cwd, def);
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (!answer
|
|
97
|
+
const shown = candidates.slice(0, 8);
|
|
98
|
+
console.log(` ${ui_1.c.gold('?')} ${ui_1.c.bold('Nest entry')} ${ui_1.c.dim('— apiDocs(app)')}`);
|
|
99
|
+
shown.forEach((file, i) => {
|
|
100
|
+
const r = path.relative(cwd, file);
|
|
101
|
+
const rec = i === 0 ? ui_1.c.dim(' recommended') : '';
|
|
102
|
+
console.log(` ${ui_1.c.ice(String(i + 1))} ${ui_1.c.bold(r)}${rec}`);
|
|
103
|
+
});
|
|
104
|
+
if (candidates.length > shown.length)
|
|
105
|
+
console.log(` ${ui_1.c.dim(`… +${candidates.length - shown.length} more`)}`);
|
|
106
|
+
console.log(` ${ui_1.c.dim('n')} skip`);
|
|
107
|
+
const answer = await (0, ui_1.readlineAsk)(` ${ui_1.c.dim(`Enter = 1 (${rel})`)} ${ui_1.c.dim('·')} ${ui_1.c.dim('or type a path')}\n ${ui_1.c.ice('›')} `);
|
|
108
|
+
if (!answer)
|
|
109
109
|
return def;
|
|
110
110
|
if (/^n(o)?$/i.test(answer))
|
|
111
111
|
return null;
|
|
112
|
+
if (/^\d+$/.test(answer)) {
|
|
113
|
+
const picked = shown[Number(answer) - 1];
|
|
114
|
+
if (!picked)
|
|
115
|
+
throw new Error(`No file #${answer}`);
|
|
116
|
+
return picked;
|
|
117
|
+
}
|
|
112
118
|
const full = path.isAbsolute(answer) ? answer : path.join(cwd, answer);
|
|
113
119
|
if (!(0, fs_1.existsSync)(full))
|
|
114
120
|
throw new Error(`File not found: ${full}`);
|
package/dist/cli/install.js
CHANGED
|
@@ -258,8 +258,6 @@ async function installDaxta(options = {}) {
|
|
|
258
258
|
await (0, ui_1.step)('Set DAXTA_DOCS in env', () => ensureEnvDaxtaDocs(cwd, dryRun), { paceMs, n: 2, of });
|
|
259
259
|
(0, ui_1.phase)(3, of, 'Nest', 'apiDocs(app) on the HTTP bootstrap');
|
|
260
260
|
if (!options.skipMain) {
|
|
261
|
-
console.log('');
|
|
262
|
-
console.log(` ${ui_1.c.gold('?')} ${ui_1.c.bold('Nest entry')} ${ui_1.c.dim('— wire apiDocs(app)')}`);
|
|
263
261
|
const target = await (0, inject_main_1.resolveMainTarget)({
|
|
264
262
|
cwd,
|
|
265
263
|
yes: options.yes,
|
|
@@ -286,7 +284,6 @@ async function installDaxta(options = {}) {
|
|
|
286
284
|
await (0, ui_1.step)('Inject apiDocs(app)', () => 'skipped (--skip-main)', { paceMs, n: 3, of });
|
|
287
285
|
}
|
|
288
286
|
(0, ui_1.phase)(4, of, 'Tests', 'Jest plugin — your script stays the parent');
|
|
289
|
-
console.log(` ${ui_1.c.gold('?')} ${ui_1.c.bold('Test script')} ${ui_1.c.dim('— attach reporter + globalSetup')}`);
|
|
290
287
|
const testScript = await (0, discover_test_1.resolveTestScript)({
|
|
291
288
|
cwd,
|
|
292
289
|
scripts: pkg.scripts,
|
package/dist/cli/titles.js
CHANGED
|
@@ -13,16 +13,20 @@ async function pickFromSuggestions(finding, extra, validate) {
|
|
|
13
13
|
if (extra)
|
|
14
14
|
console.log(` ${ui_1.c.dim(extra)}`);
|
|
15
15
|
if (!suggestions.length) {
|
|
16
|
-
console.log(` ${ui_1.c.gold('no auto suggestion')} ${ui_1.c.dim('— type a
|
|
16
|
+
console.log(` ${ui_1.c.gold('no auto suggestion')} ${ui_1.c.dim('— type a title, or s to skip')}`);
|
|
17
17
|
}
|
|
18
18
|
suggestions.forEach((name, index) => {
|
|
19
|
-
const mark = index === 0 ? ui_1.c.dim('
|
|
19
|
+
const mark = index === 0 ? ui_1.c.dim(' recommended') : '';
|
|
20
20
|
console.log(` ${ui_1.c.ice(String(index + 1))} ${name}${mark}`);
|
|
21
21
|
});
|
|
22
|
-
console.log(
|
|
22
|
+
console.log(suggestions.length
|
|
23
|
+
? ` ${ui_1.c.dim('Enter = 1')} ${ui_1.c.dim('·')} ${ui_1.c.ice('a')} remaining auto ${ui_1.c.dim('·')} ${ui_1.c.ice('s')} skip ${ui_1.c.dim('·')} ${ui_1.c.ice('c')} custom`
|
|
24
|
+
: ` ${ui_1.c.ice('c')} custom ${ui_1.c.dim('·')} ${ui_1.c.ice('s')} skip`);
|
|
23
25
|
const answer = (await (0, ui_1.readlineAsk)(` ${ui_1.c.ice('›')} `)).trim();
|
|
24
26
|
const lower = answer.toLowerCase();
|
|
25
|
-
if (!answer
|
|
27
|
+
if (!answer)
|
|
28
|
+
return suggestions[0] ? suggestions[0] : 'skip';
|
|
29
|
+
if (lower === 's')
|
|
26
30
|
return 'skip';
|
|
27
31
|
if (lower === 'a' || lower === 'all')
|
|
28
32
|
return 'all';
|