@t0.labs/daxta 0.4.16 → 0.4.18
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/README.md +23 -9
- package/dist/catalog/index.d.ts +1 -1
- package/dist/catalog/index.js +9 -2
- package/dist/catalog/it-case.js +2 -6
- package/dist/catalog/test-title.d.ts +13 -3
- package/dist/catalog/test-title.js +104 -56
- package/dist/cli/discover-test.js +4 -14
- package/dist/cli/inject-main.js +3 -13
- package/dist/cli/install.js +31 -24
- package/dist/cli/main.js +25 -28
- package/dist/cli/titles.d.ts +1 -0
- package/dist/cli/titles.js +115 -28
- package/dist/cli/tree.js +30 -40
- package/dist/cli/ui.d.ts +23 -3
- package/dist/cli/ui.js +107 -23
- package/dist/cli/uninstall.js +4 -14
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/dist/titles/scan.d.ts +1 -0
- package/dist/titles/scan.js +8 -3
- package/package.json +1 -1
package/dist/cli/main.js
CHANGED
|
@@ -11,35 +11,31 @@ const test_1 = require("./test");
|
|
|
11
11
|
const tree_1 = require("./tree");
|
|
12
12
|
const titles_1 = require("./titles");
|
|
13
13
|
const uninstall_1 = require("./uninstall");
|
|
14
|
+
const ui_1 = require("./ui");
|
|
14
15
|
function usage() {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
pnpm dlx @t0.labs/daxta
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
daxta titles = check TEST_TITLE + it() format before tests; suggests names from method/path/section
|
|
40
|
-
daxta test = forwards to your package script (Jest stays parent; DAxTA is a plugin)
|
|
41
|
-
daxta tree = choose how paths appear in the /docs sidebar
|
|
42
|
-
`);
|
|
16
|
+
const cmd = (name) => ui_1.c.bold(ui_1.c.ice(name));
|
|
17
|
+
console.log('');
|
|
18
|
+
console.log(` ${ui_1.c.bold(ui_1.c.ice('DAxTA'))} ${ui_1.c.dim('docs from Nest traffic · @t0.labs/daxta')}`);
|
|
19
|
+
console.log('');
|
|
20
|
+
console.log(` ${ui_1.c.gold('Setup')}`);
|
|
21
|
+
console.log(` ${cmd('daxta install')} ${ui_1.c.dim('[--yes] [--dry-run] [--skip-dep] [--skip-main] [--fast]')}`);
|
|
22
|
+
console.log(` ${cmd('daxta init')} ${ui_1.c.dim('alias of install')}`);
|
|
23
|
+
console.log(` ${cmd('daxta uninstall')} ${ui_1.c.dim('[--yes] [--dry-run] [--keep-dep]')}`);
|
|
24
|
+
console.log(` ${cmd('daxta migrate')} ${ui_1.c.dim('[--yes]')}`);
|
|
25
|
+
console.log('');
|
|
26
|
+
console.log(` ${ui_1.c.gold('Docs & tests')}`);
|
|
27
|
+
console.log(` ${cmd('daxta titles')} ${ui_1.c.dim('[--check] [--yes] [--strict]')}`);
|
|
28
|
+
console.log(` ${cmd('daxta test')} ${ui_1.c.dim('your Jest script + plugin')}`);
|
|
29
|
+
console.log(` ${cmd('daxta build')} ${ui_1.c.dim('OpenAPI + viewer from hits')}`);
|
|
30
|
+
console.log(` ${cmd('daxta serve')} ${ui_1.c.dim('[--port]')}`);
|
|
31
|
+
console.log(` ${cmd('daxta tree')} ${ui_1.c.dim('sidebar layout')}`);
|
|
32
|
+
console.log('');
|
|
33
|
+
console.log(` ${ui_1.c.gold('Try-it')}`);
|
|
34
|
+
console.log(` ${cmd('daxta fields')} ${ui_1.c.dim('[METHOD] [PATH]')}`);
|
|
35
|
+
console.log(` ${cmd('daxta call')} ${ui_1.c.dim('[METHOD] [PATH] | --file')}`);
|
|
36
|
+
console.log('');
|
|
37
|
+
console.log(` ${ui_1.c.mint('First time')} ${ui_1.c.ice('pnpm dlx @t0.labs/daxta install')}`);
|
|
38
|
+
console.log('');
|
|
43
39
|
}
|
|
44
40
|
function parseArgs(argv) {
|
|
45
41
|
const args = argv.slice(2);
|
|
@@ -117,6 +113,7 @@ async function main() {
|
|
|
117
113
|
if (command === 'titles' || command === 'title') {
|
|
118
114
|
const code = await (0, titles_1.runTitleCheck)({
|
|
119
115
|
checkOnly: Boolean(flags.check),
|
|
116
|
+
apply: Boolean(flags.yes) && !flags.check,
|
|
120
117
|
yes: Boolean(flags.yes),
|
|
121
118
|
strict: Boolean(flags.strict),
|
|
122
119
|
});
|
package/dist/cli/titles.d.ts
CHANGED
package/dist/cli/titles.js
CHANGED
|
@@ -1,39 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runTitleCheck = runTitleCheck;
|
|
4
|
-
const readline_1 = require("readline");
|
|
5
4
|
const test_title_1 = require("../catalog/test-title");
|
|
6
5
|
const it_case_1 = require("../catalog/it-case");
|
|
7
6
|
const scan_1 = require("../titles/scan");
|
|
8
7
|
const ui_1 = require("./ui");
|
|
9
|
-
function prompt(question) {
|
|
10
|
-
const rl = (0, readline_1.createInterface)({ input: process.stdin, output: process.stdout });
|
|
11
|
-
return new Promise((resolve) => {
|
|
12
|
-
rl.question(question, (answer) => {
|
|
13
|
-
rl.close();
|
|
14
|
-
resolve(answer.trim());
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
8
|
async function pickFromSuggestions(finding, extra, validate) {
|
|
19
9
|
const suggestions = finding.suggestions;
|
|
20
10
|
console.log('');
|
|
21
|
-
console.log(` ${ui_1.c.
|
|
11
|
+
console.log(` ${ui_1.c.ice(finding.file)}${ui_1.c.dim(`:${finding.line}:${finding.column}`)}`);
|
|
22
12
|
console.log(` ${ui_1.c.dim(finding.raw)}`);
|
|
23
13
|
if (extra)
|
|
24
14
|
console.log(` ${ui_1.c.dim(extra)}`);
|
|
15
|
+
if (!suggestions.length) {
|
|
16
|
+
console.log(` ${ui_1.c.gold('no auto suggestion')} ${ui_1.c.dim('— type a custom title (c). --yes will not skip this.')}`);
|
|
17
|
+
}
|
|
25
18
|
suggestions.forEach((name, index) => {
|
|
26
19
|
const mark = index === 0 ? ui_1.c.dim(' (recommended)') : '';
|
|
27
|
-
console.log(` ${ui_1.c.
|
|
20
|
+
console.log(` ${ui_1.c.ice(String(index + 1))} ${name}${mark}`);
|
|
28
21
|
});
|
|
29
|
-
console.log(` ${ui_1.c.
|
|
30
|
-
const answer = await
|
|
31
|
-
|
|
22
|
+
console.log(` ${ui_1.c.ice('1–3')} pick ${ui_1.c.ice('y')} this recommended ${ui_1.c.ice('a')} all remaining recommended ${ui_1.c.ice('s')} skip ${ui_1.c.ice('c')} custom`);
|
|
23
|
+
const answer = (await (0, ui_1.readlineAsk)(` ${ui_1.c.ice('›')} `)).trim();
|
|
24
|
+
const lower = answer.toLowerCase();
|
|
25
|
+
if (!answer || lower === 's')
|
|
32
26
|
return 'skip';
|
|
33
|
-
if (
|
|
34
|
-
|
|
27
|
+
if (lower === 'a' || lower === 'all')
|
|
28
|
+
return 'all';
|
|
29
|
+
if (lower === 'y' || lower === 'yes')
|
|
30
|
+
return suggestions[0] ? suggestions[0] : 'skip';
|
|
31
|
+
if (lower === 'c') {
|
|
32
|
+
const custom = await (0, ui_1.readlineAsk)(` ${ui_1.c.dim('text')} ${ui_1.c.ice('›')} `);
|
|
35
33
|
if (!validate(custom)) {
|
|
36
|
-
console.log(` ${ui_1.c.
|
|
34
|
+
console.log(` ${ui_1.c.gold('!')} does not match the format — skipped`);
|
|
37
35
|
return 'skip';
|
|
38
36
|
}
|
|
39
37
|
return custom;
|
|
@@ -45,6 +43,47 @@ async function pickFromSuggestions(finding, extra, validate) {
|
|
|
45
43
|
return answer;
|
|
46
44
|
return 'skip';
|
|
47
45
|
}
|
|
46
|
+
function writeTitle(cwd, finding) {
|
|
47
|
+
if (!finding.auto)
|
|
48
|
+
return false;
|
|
49
|
+
const name = finding.suggestions[0];
|
|
50
|
+
if (!name || !(0, test_title_1.isHumanOperationTitle)(name))
|
|
51
|
+
return false;
|
|
52
|
+
return (0, scan_1.applyTitle)(cwd, finding, name);
|
|
53
|
+
}
|
|
54
|
+
function writeIt(cwd, finding) {
|
|
55
|
+
const name = finding.suggestions[0];
|
|
56
|
+
if (!name || !(0, it_case_1.isValidItCase)(name))
|
|
57
|
+
return false;
|
|
58
|
+
return (0, scan_1.applyItCase)(cwd, finding, name);
|
|
59
|
+
}
|
|
60
|
+
function applyAllRecommended(cwd, titles, cases, fromTitleIndex, fromCaseIndex) {
|
|
61
|
+
let written = 0;
|
|
62
|
+
let skipped = 0;
|
|
63
|
+
const pending = [];
|
|
64
|
+
for (let i = fromTitleIndex; i < titles.length; i += 1) {
|
|
65
|
+
if (!titles[i].auto || !titles[i].suggestions[0]) {
|
|
66
|
+
pending.push(titles[i]);
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (writeTitle(cwd, titles[i])) {
|
|
70
|
+
console.log(` ${ui_1.c.mint('✔')} ${titles[i].suggestions[0]} ${ui_1.c.dim(titles[i].file + ':' + titles[i].line)}`);
|
|
71
|
+
written += 1;
|
|
72
|
+
}
|
|
73
|
+
else
|
|
74
|
+
skipped += 1;
|
|
75
|
+
}
|
|
76
|
+
const caseStart = fromTitleIndex < titles.length ? 0 : fromCaseIndex;
|
|
77
|
+
for (let i = caseStart; i < cases.length; i += 1) {
|
|
78
|
+
if (writeIt(cwd, cases[i])) {
|
|
79
|
+
console.log(` ${ui_1.c.mint('✔')} ${cases[i].suggestions[0]} ${ui_1.c.dim(cases[i].file + ':' + cases[i].line)}`);
|
|
80
|
+
written += 1;
|
|
81
|
+
}
|
|
82
|
+
else
|
|
83
|
+
skipped += 1;
|
|
84
|
+
}
|
|
85
|
+
return { written, skipped, pending };
|
|
86
|
+
}
|
|
48
87
|
async function runTitleCheck(options) {
|
|
49
88
|
const cwd = options.cwd ?? process.cwd();
|
|
50
89
|
const report = (0, scan_1.scanTestNaming)(cwd);
|
|
@@ -52,53 +91,101 @@ async function runTitleCheck(options) {
|
|
|
52
91
|
if (!total) {
|
|
53
92
|
if (!options.checkOnly) {
|
|
54
93
|
(0, ui_1.banner)('Test naming', 'titles + it() cases');
|
|
55
|
-
console.log(` ${ui_1.c.
|
|
94
|
+
console.log(` ${ui_1.c.mint('✔')} nothing to fix`);
|
|
56
95
|
console.log('');
|
|
57
96
|
}
|
|
58
97
|
return 0;
|
|
59
98
|
}
|
|
99
|
+
const applyAll = Boolean(options.apply);
|
|
100
|
+
if (applyAll) {
|
|
101
|
+
(0, ui_1.banner)('Test naming', 'applying recommended titles + it() names');
|
|
102
|
+
const result = applyAllRecommended(cwd, report.titles, report.cases, 0, 0);
|
|
103
|
+
console.log('');
|
|
104
|
+
console.log(` ${ui_1.c.mint('✔')} ${result.written} updated ${ui_1.c.dim(`${result.skipped} skipped`)}`);
|
|
105
|
+
if (result.pending.length) {
|
|
106
|
+
console.log('');
|
|
107
|
+
console.log(` ${ui_1.c.gold('!')} ${ui_1.c.bold(`${result.pending.length} title(s) have no auto suggestion`)} ${ui_1.c.dim('--yes does not invent names')}`);
|
|
108
|
+
for (const item of result.pending) {
|
|
109
|
+
console.log(` ${ui_1.c.ice(item.file)}${ui_1.c.dim(`:${item.line}`)} ${ui_1.c.dim(item.path + ' [' + item.method + ']')}`);
|
|
110
|
+
}
|
|
111
|
+
console.log(` ${ui_1.c.dim('Set those with')} ${ui_1.c.ice('daxta titles')} ${ui_1.c.dim('→ c (custom)')}`);
|
|
112
|
+
console.log('');
|
|
113
|
+
}
|
|
114
|
+
const leftover = result.skipped + result.pending.length;
|
|
115
|
+
return leftover > 0 && options.strict ? 1 : leftover > 0 ? 1 : 0;
|
|
116
|
+
}
|
|
60
117
|
if (options.checkOnly || options.yes || !process.stdin.isTTY) {
|
|
61
118
|
(0, scan_1.printNamingFindings)(report, ui_1.c);
|
|
62
119
|
return options.strict ? 1 : 0;
|
|
63
120
|
}
|
|
64
121
|
(0, ui_1.banner)('Test naming', 'runs before Jest — docs / Postman labels');
|
|
65
|
-
console.log(` ${ui_1.c.dim('Title')} Create Mock Tbs /v1/admin/mock-tbs
|
|
122
|
+
console.log(` ${ui_1.c.dim('Title')} Create Mock Tbs — POST /v1/admin/mock-tbs`);
|
|
66
123
|
console.log(` ${ui_1.c.dim('it()')} creates mock tbs when payload is valid`);
|
|
67
|
-
console.log(` ${ui_1.c.
|
|
124
|
+
console.log(` ${ui_1.c.gold(String(total))} to review — ${ui_1.c.ice('y')} one recommended, ${ui_1.c.ice('a')} all remaining, ${ui_1.c.ice('s')} skip.`);
|
|
68
125
|
let written = 0;
|
|
69
126
|
let skipped = 0;
|
|
70
|
-
for (
|
|
127
|
+
for (let i = 0; i < report.titles.length; i += 1) {
|
|
128
|
+
const finding = report.titles[i];
|
|
71
129
|
const choice = await pickFromSuggestions(finding, `docs would show ${finding.path}`, test_title_1.isHumanOperationTitle);
|
|
130
|
+
if (choice === 'all') {
|
|
131
|
+
const rest = applyAllRecommended(cwd, report.titles, report.cases, i, 0);
|
|
132
|
+
written += rest.written;
|
|
133
|
+
skipped += rest.skipped;
|
|
134
|
+
for (const pending of rest.pending) {
|
|
135
|
+
const customChoice = await pickFromSuggestions(pending, `docs would show ${pending.path} — custom title required`, test_title_1.isHumanOperationTitle);
|
|
136
|
+
if (!customChoice || customChoice === 'skip' || customChoice === 'all') {
|
|
137
|
+
skipped += 1;
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
if ((0, scan_1.applyTitle)(cwd, pending, customChoice)) {
|
|
141
|
+
console.log(` ${ui_1.c.mint('✔')} ${customChoice}`);
|
|
142
|
+
written += 1;
|
|
143
|
+
}
|
|
144
|
+
else
|
|
145
|
+
skipped += 1;
|
|
146
|
+
}
|
|
147
|
+
console.log('');
|
|
148
|
+
console.log(` ${ui_1.c.mint('✔')} ${written} updated ${ui_1.c.dim(`${skipped} skipped`)}`);
|
|
149
|
+
console.log('');
|
|
150
|
+
return options.strict && skipped > 0 ? 1 : 0;
|
|
151
|
+
}
|
|
72
152
|
if (!choice || choice === 'skip') {
|
|
73
153
|
skipped += 1;
|
|
74
154
|
continue;
|
|
75
155
|
}
|
|
76
156
|
if ((0, scan_1.applyTitle)(cwd, finding, choice)) {
|
|
77
|
-
console.log(` ${ui_1.c.
|
|
157
|
+
console.log(` ${ui_1.c.mint('✔')} ${choice}`);
|
|
78
158
|
written += 1;
|
|
79
159
|
}
|
|
80
160
|
else {
|
|
81
|
-
console.log(` ${ui_1.c.
|
|
161
|
+
console.log(` ${ui_1.c.gold('!')} could not rewrite that line — skipped`);
|
|
82
162
|
skipped += 1;
|
|
83
163
|
}
|
|
84
164
|
}
|
|
85
|
-
for (
|
|
165
|
+
for (let i = 0; i < report.cases.length; i += 1) {
|
|
166
|
+
const finding = report.cases[i];
|
|
86
167
|
const choice = await pickFromSuggestions(finding, finding.section ? `section ${finding.section}` : 'it() example name', it_case_1.isValidItCase);
|
|
168
|
+
if (choice === 'all') {
|
|
169
|
+
const rest = applyAllRecommended(cwd, [], report.cases, 0, i);
|
|
170
|
+
written += rest.written;
|
|
171
|
+
skipped += rest.skipped;
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
87
174
|
if (!choice || choice === 'skip') {
|
|
88
175
|
skipped += 1;
|
|
89
176
|
continue;
|
|
90
177
|
}
|
|
91
178
|
if ((0, scan_1.applyItCase)(cwd, finding, choice)) {
|
|
92
|
-
console.log(` ${ui_1.c.
|
|
179
|
+
console.log(` ${ui_1.c.mint('✔')} ${choice}`);
|
|
93
180
|
written += 1;
|
|
94
181
|
}
|
|
95
182
|
else {
|
|
96
|
-
console.log(` ${ui_1.c.
|
|
183
|
+
console.log(` ${ui_1.c.gold('!')} could not rewrite that line — skipped`);
|
|
97
184
|
skipped += 1;
|
|
98
185
|
}
|
|
99
186
|
}
|
|
100
187
|
console.log('');
|
|
101
|
-
console.log(` ${ui_1.c.
|
|
188
|
+
console.log(` ${ui_1.c.mint('✔')} ${written} updated ${ui_1.c.dim(`${skipped} skipped`)}`);
|
|
102
189
|
console.log('');
|
|
103
190
|
return options.strict && skipped > 0 ? 1 : 0;
|
|
104
191
|
}
|
package/dist/cli/tree.js
CHANGED
|
@@ -1,22 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runTreeWizard = runTreeWizard;
|
|
4
|
-
const readline_1 = require("readline");
|
|
5
4
|
const fs_1 = require("fs");
|
|
6
5
|
const config_1 = require("../config");
|
|
7
6
|
const dto_fields_1 = require("../fields/dto-fields");
|
|
8
7
|
const paths_1 = require("../serve/paths");
|
|
9
8
|
const config_edit_1 = require("./config-edit");
|
|
10
9
|
const ui_1 = require("./ui");
|
|
11
|
-
function prompt(question) {
|
|
12
|
-
const rl = (0, readline_1.createInterface)({ input: process.stdin, output: process.stdout });
|
|
13
|
-
return new Promise((resolve) => {
|
|
14
|
-
rl.question(question, (answer) => {
|
|
15
|
-
rl.close();
|
|
16
|
-
resolve(answer.trim());
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
10
|
function normalizePathInput(raw) {
|
|
21
11
|
const trimmed = raw.trim();
|
|
22
12
|
if (!trimmed)
|
|
@@ -59,12 +49,12 @@ function listKnownPaths() {
|
|
|
59
49
|
}
|
|
60
50
|
function printPathChoices(paths, limit = 12) {
|
|
61
51
|
if (!paths.length) {
|
|
62
|
-
console.log(` ${ui_1.c.dim('tip')} type a path like ${ui_1.c.
|
|
52
|
+
console.log(` ${ui_1.c.dim('tip')} type a path like ${ui_1.c.ice('/v1/admin/baskets')}`);
|
|
63
53
|
return;
|
|
64
54
|
}
|
|
65
55
|
console.log(` ${ui_1.c.dim('known paths')}`);
|
|
66
56
|
paths.slice(0, limit).forEach((item, index) => {
|
|
67
|
-
console.log(` ${ui_1.c.dim(String(index + 1).padStart(2, ' '))} ${ui_1.c.
|
|
57
|
+
console.log(` ${ui_1.c.dim(String(index + 1).padStart(2, ' '))} ${ui_1.c.ice(item)}`);
|
|
68
58
|
});
|
|
69
59
|
if (paths.length > limit)
|
|
70
60
|
console.log(` ${ui_1.c.dim(`… +${paths.length - limit} more`)}`);
|
|
@@ -74,7 +64,7 @@ async function pickPath(flagPath) {
|
|
|
74
64
|
return normalizePathInput(flagPath);
|
|
75
65
|
const known = listKnownPaths();
|
|
76
66
|
printPathChoices(known);
|
|
77
|
-
const answer = await
|
|
67
|
+
const answer = await (0, ui_1.readlineAsk)(` ${ui_1.c.gold('?')} ${ui_1.c.bold('Path')} override ${ui_1.c.dim('(number · path · n skip)')}\n ${ui_1.c.ice('›')} `);
|
|
78
68
|
if (!answer || /^n(o)?$/i.test(answer))
|
|
79
69
|
return null;
|
|
80
70
|
if (/^\d+$/.test(answer)) {
|
|
@@ -89,18 +79,18 @@ async function pickLayout(current) {
|
|
|
89
79
|
const sample = '/v1/admin/baskets/{id}/lock';
|
|
90
80
|
console.log('');
|
|
91
81
|
console.log(` ${ui_1.c.bold('Folder order')} ${ui_1.c.dim('(company default)')}`);
|
|
92
|
-
console.log(` ${ui_1.c.dim('sample')} ${ui_1.c.
|
|
82
|
+
console.log(` ${ui_1.c.dim('sample')} ${ui_1.c.ice(sample)}`);
|
|
93
83
|
console.log('');
|
|
94
|
-
console.log(` ${ui_1.c.
|
|
84
|
+
console.log(` ${ui_1.c.ice('1')} role → resource ${ui_1.c.dim('recommended')}`);
|
|
95
85
|
console.log(` ${(0, config_edit_1.previewTree)(layoutSegments(sample, 'role-resource', true))}`);
|
|
96
86
|
console.log(` ${ui_1.c.dim('v1 › admin › baskets (ops under baskets, not under {id})')}`);
|
|
97
87
|
console.log('');
|
|
98
|
-
console.log(` ${ui_1.c.
|
|
88
|
+
console.log(` ${ui_1.c.ice('2')} resource → role`);
|
|
99
89
|
console.log(` ${(0, config_edit_1.previewTree)(layoutSegments(sample, 'resource-role', true))}`);
|
|
100
90
|
console.log(` ${ui_1.c.dim('v1 › baskets › admin')}`);
|
|
101
91
|
console.log('');
|
|
102
|
-
console.log(` ${ui_1.c.
|
|
103
|
-
const answer = await
|
|
92
|
+
console.log(` ${ui_1.c.ice('3')} keep ${ui_1.c.dim(`(${current})`)}`);
|
|
93
|
+
const answer = await (0, ui_1.readlineAsk)(` ${ui_1.c.gold('?')} Choose\n ${ui_1.c.ice('›')} `);
|
|
104
94
|
if (!answer || answer === '3' || /^k(eep)?$/i.test(answer))
|
|
105
95
|
return current;
|
|
106
96
|
if (answer === '1' || /^role/i.test(answer))
|
|
@@ -112,11 +102,11 @@ async function pickLayout(current) {
|
|
|
112
102
|
async function pickSkipParams(current) {
|
|
113
103
|
console.log('');
|
|
114
104
|
console.log(` ${ui_1.c.bold('Stop folders at path params')}`);
|
|
115
|
-
console.log(` ${ui_1.c.dim('Avoid')} ${ui_1.c.
|
|
116
|
-
console.log(` ${ui_1.c.
|
|
117
|
-
console.log(` ${ui_1.c.
|
|
118
|
-
console.log(` ${ui_1.c.
|
|
119
|
-
const answer = await
|
|
105
|
+
console.log(` ${ui_1.c.dim('Avoid')} ${ui_1.c.ice('{id}')} ${ui_1.c.dim('→ complete / lock / pay as nested folders')}`);
|
|
106
|
+
console.log(` ${ui_1.c.ice('1')} yes — fold under resource ${ui_1.c.dim('(recommended)')}`);
|
|
107
|
+
console.log(` ${ui_1.c.ice('2')} no — nest full path`);
|
|
108
|
+
console.log(` ${ui_1.c.ice('3')} keep ${ui_1.c.dim(`(${current ? 'yes' : 'no'})`)}`);
|
|
109
|
+
const answer = await (0, ui_1.readlineAsk)(` ${ui_1.c.gold('?')} Choose\n ${ui_1.c.ice('›')} `);
|
|
120
110
|
if (!answer || answer === '3' || /^k(eep)?$/i.test(answer))
|
|
121
111
|
return current;
|
|
122
112
|
if (answer === '1' || /^y/i.test(answer))
|
|
@@ -128,14 +118,14 @@ async function pickSkipParams(current) {
|
|
|
128
118
|
async function pickExampleStyle(current) {
|
|
129
119
|
console.log('');
|
|
130
120
|
console.log(` ${ui_1.c.bold('Example / scenario labels')}`);
|
|
131
|
-
console.log(` ${ui_1.c.
|
|
121
|
+
console.log(` ${ui_1.c.ice('1')} status-title-case`);
|
|
132
122
|
console.log(` ${ui_1.c.dim('200 — Admin Find One Basket By Id API — returns basket when found')}`);
|
|
133
|
-
console.log(` ${ui_1.c.
|
|
123
|
+
console.log(` ${ui_1.c.ice('2')} status-case`);
|
|
134
124
|
console.log(` ${ui_1.c.dim('200 — returns basket when found')}`);
|
|
135
|
-
console.log(` ${ui_1.c.
|
|
125
|
+
console.log(` ${ui_1.c.ice('3')} full`);
|
|
136
126
|
console.log(` ${ui_1.c.dim('200 — Admin Find… API - GET /v1/admin/baskets/{id} POSITIVE CASES returns…')}`);
|
|
137
|
-
console.log(` ${ui_1.c.
|
|
138
|
-
const answer = await
|
|
127
|
+
console.log(` ${ui_1.c.ice('4')} keep ${ui_1.c.dim(`(${current})`)}`);
|
|
128
|
+
const answer = await (0, ui_1.readlineAsk)(` ${ui_1.c.gold('?')} Choose\n ${ui_1.c.ice('›')} `);
|
|
139
129
|
if (!answer || answer === '4' || /^k(eep)?$/i.test(answer))
|
|
140
130
|
return current;
|
|
141
131
|
if (answer === '1' || /title/i.test(answer))
|
|
@@ -159,12 +149,12 @@ function layoutChoicesFor(pathTemplate, layout, skipParams) {
|
|
|
159
149
|
async function pickSegments(pathTemplate, layout, skipParams) {
|
|
160
150
|
const choices = layoutChoicesFor(pathTemplate, layout, skipParams);
|
|
161
151
|
console.log('');
|
|
162
|
-
console.log(` ${ui_1.c.bold('Override')} ${ui_1.c.
|
|
152
|
+
console.log(` ${ui_1.c.bold('Override')} ${ui_1.c.ice(pathTemplate)}`);
|
|
163
153
|
choices.forEach((choice, index) => {
|
|
164
|
-
console.log(` ${ui_1.c.
|
|
154
|
+
console.log(` ${ui_1.c.ice(String(index + 1))} ${ui_1.c.bold(choice.label)}`);
|
|
165
155
|
console.log(` ${(0, config_edit_1.previewTree)(choice.segments)}`);
|
|
166
156
|
});
|
|
167
|
-
const answer = await
|
|
157
|
+
const answer = await (0, ui_1.readlineAsk)(` ${ui_1.c.gold('?')} Choose\n ${ui_1.c.ice('›')} `);
|
|
168
158
|
if (!answer || /^n(o)?$/i.test(answer))
|
|
169
159
|
return null;
|
|
170
160
|
const index = /^\d+$/.test(answer) ? Number(answer) - 1 : -1;
|
|
@@ -173,7 +163,7 @@ async function pickSegments(pathTemplate, layout, skipParams) {
|
|
|
173
163
|
throw new Error(`Unknown choice: ${answer}`);
|
|
174
164
|
if (selected.id !== 'custom')
|
|
175
165
|
return selected.segments;
|
|
176
|
-
const typed = await
|
|
166
|
+
const typed = await (0, ui_1.readlineAsk)(` ${ui_1.c.gold('?')} Segments ${ui_1.c.dim('(space separated)')}\n ${ui_1.c.ice('›')} `);
|
|
177
167
|
if (!typed)
|
|
178
168
|
return null;
|
|
179
169
|
return typed.split(/›|>|,|\s+/).map((part) => part.trim()).filter(Boolean);
|
|
@@ -195,7 +185,7 @@ async function runTreeWizard(options = {}) {
|
|
|
195
185
|
(0, config_1.resetConfig)();
|
|
196
186
|
const config = (0, config_1.getConfig)(true);
|
|
197
187
|
console.log('');
|
|
198
|
-
console.log(` ${ui_1.c.
|
|
188
|
+
console.log(` ${ui_1.c.gold(ui_1.c.bold('?'))} ${ui_1.c.bold('Docs presentation')} ${ui_1.c.dim('— sidebar + OpenAPI export')}`);
|
|
199
189
|
let layout = (0, config_1.normalizeTreeLayout)(options.layout === 'resource-first' || options.layout === 'resource-role'
|
|
200
190
|
? 'resource-role'
|
|
201
191
|
: options.layout === 'url-order' || options.layout === 'role-resource'
|
|
@@ -204,17 +194,17 @@ async function runTreeWizard(options = {}) {
|
|
|
204
194
|
if (!options.layout)
|
|
205
195
|
layout = await pickLayout(layout);
|
|
206
196
|
(0, config_edit_1.upsertConfigValue)(configPath, 'treeLayout', (0, config_edit_1.formatTsString)(layout));
|
|
207
|
-
console.log(` ${ui_1.c.
|
|
197
|
+
console.log(` ${ui_1.c.mint('✔')} treeLayout → ${ui_1.c.ice(layout)}`);
|
|
208
198
|
const skipParams = await pickSkipParams(config.treeSkipParams !== false);
|
|
209
199
|
(0, config_edit_1.upsertConfigValue)(configPath, 'treeSkipParams', skipParams ? 'true' : 'false');
|
|
210
|
-
console.log(` ${ui_1.c.
|
|
200
|
+
console.log(` ${ui_1.c.mint('✔')} treeSkipParams → ${ui_1.c.ice(String(skipParams))}`);
|
|
211
201
|
const exampleStyle = await pickExampleStyle(config.exampleLabelStyle ?? 'status-title-case');
|
|
212
202
|
(0, config_edit_1.upsertConfigValue)(configPath, 'exampleLabelStyle', (0, config_edit_1.formatTsString)(exampleStyle));
|
|
213
|
-
console.log(` ${ui_1.c.
|
|
203
|
+
console.log(` ${ui_1.c.mint('✔')} exampleLabelStyle → ${ui_1.c.ice(exampleStyle)}`);
|
|
214
204
|
const customize = options.path
|
|
215
205
|
? 'y'
|
|
216
|
-
: await
|
|
217
|
-
` ${ui_1.c.dim('Y')} yes · ${ui_1.c.dim('n')} later\n ${ui_1.c.
|
|
206
|
+
: await (0, ui_1.readlineAsk)(` ${ui_1.c.gold('?')} Per-path override now?\n` +
|
|
207
|
+
` ${ui_1.c.dim('Y')} yes · ${ui_1.c.dim('n')} later\n ${ui_1.c.ice('›')} `);
|
|
218
208
|
if (customize && !/^n(o)?$/i.test(customize)) {
|
|
219
209
|
const pathTemplate = await pickPath(options.path);
|
|
220
210
|
if (pathTemplate) {
|
|
@@ -223,13 +213,13 @@ async function runTreeWizard(options = {}) {
|
|
|
223
213
|
const overrides = (0, config_edit_1.readTreePathOverrides)();
|
|
224
214
|
overrides[pathTemplate] = segments;
|
|
225
215
|
(0, config_edit_1.upsertConfigValue)(configPath, 'treePathOverrides', (0, config_edit_1.formatTsStringRecord)(overrides));
|
|
226
|
-
console.log(` ${ui_1.c.
|
|
216
|
+
console.log(` ${ui_1.c.mint('✔')} ${ui_1.c.ice(pathTemplate)} → ${(0, config_edit_1.previewTree)(segments)}`);
|
|
227
217
|
}
|
|
228
218
|
}
|
|
229
219
|
}
|
|
230
220
|
if (!options.embedded) {
|
|
231
221
|
console.log(` ${ui_1.c.dim('saved')} ${configPath}`);
|
|
232
|
-
console.log(` ${ui_1.c.dim('refresh')} ${ui_1.c.
|
|
222
|
+
console.log(` ${ui_1.c.dim('refresh')} ${ui_1.c.ice('daxta build')}`);
|
|
233
223
|
console.log('');
|
|
234
224
|
}
|
|
235
225
|
}
|
package/dist/cli/ui.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/** Viewer-adjacent palette: ice, gold, mint, stone. */
|
|
2
|
+
export declare const tone: {
|
|
3
|
+
ice: (t: string) => string;
|
|
4
|
+
gold: (t: string) => string;
|
|
5
|
+
mint: (t: string) => string;
|
|
6
|
+
rose: (t: string) => string;
|
|
7
|
+
mist: (t: string) => string;
|
|
8
|
+
paper: (t: string) => string;
|
|
9
|
+
};
|
|
1
10
|
export declare const c: {
|
|
2
11
|
bold: (t: string) => string;
|
|
3
12
|
dim: (t: string) => string;
|
|
@@ -6,19 +15,30 @@ export declare const c: {
|
|
|
6
15
|
yellow: (t: string) => string;
|
|
7
16
|
magenta: (t: string) => string;
|
|
8
17
|
red: (t: string) => string;
|
|
18
|
+
ice: (t: string) => string;
|
|
19
|
+
gold: (t: string) => string;
|
|
20
|
+
mint: (t: string) => string;
|
|
9
21
|
};
|
|
10
22
|
export declare function sleep(ms: number): Promise<void>;
|
|
23
|
+
export declare function divider(width?: number): void;
|
|
24
|
+
export declare function splash(options: {
|
|
25
|
+
version: string;
|
|
26
|
+
project: string;
|
|
27
|
+
dryRun?: boolean;
|
|
28
|
+
}): void;
|
|
11
29
|
export declare function banner(title: string, subtitle?: string): void;
|
|
30
|
+
export declare function phase(index: number, total: number, label: string, hint?: string): void;
|
|
31
|
+
export declare function askLine(label: string, hint?: string): string;
|
|
32
|
+
export declare function readlineAsk(question: string): Promise<string>;
|
|
12
33
|
export type StepResult = string | {
|
|
13
34
|
summary: string;
|
|
14
35
|
details?: string[];
|
|
15
36
|
} | void;
|
|
16
|
-
/**
|
|
17
|
-
* Spinner while work runs → ✔ / ✖, optional detail lines, then a short pause to read.
|
|
18
|
-
*/
|
|
19
37
|
export declare function step(label: string, work: () => StepResult | Promise<StepResult>, options?: {
|
|
20
38
|
paceMs?: number;
|
|
21
39
|
spinner?: boolean;
|
|
40
|
+
n?: number;
|
|
41
|
+
of?: number;
|
|
22
42
|
}): Promise<void>;
|
|
23
43
|
export declare function box(title: string, lines: string[]): void;
|
|
24
44
|
export declare function nextSteps(lines: Array<{
|