@t0.labs/daxta 0.4.17 → 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/README.md +21 -8
- 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 +15 -3
- package/dist/catalog/test-title.js +246 -56
- package/dist/cli/discover-test.js +23 -21
- package/dist/cli/inject-main.js +19 -23
- package/dist/cli/install.js +29 -25
- package/dist/cli/main.js +24 -28
- package/dist/cli/titles.js +60 -34
- 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/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<{
|
package/dist/cli/ui.js
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.c = void 0;
|
|
3
|
+
exports.c = exports.tone = void 0;
|
|
4
4
|
exports.sleep = sleep;
|
|
5
|
+
exports.divider = divider;
|
|
6
|
+
exports.splash = splash;
|
|
5
7
|
exports.banner = banner;
|
|
8
|
+
exports.phase = phase;
|
|
9
|
+
exports.askLine = askLine;
|
|
10
|
+
exports.readlineAsk = readlineAsk;
|
|
6
11
|
exports.step = step;
|
|
7
12
|
exports.box = box;
|
|
8
13
|
exports.nextSteps = nextSteps;
|
|
14
|
+
const readline_1 = require("readline");
|
|
9
15
|
const isTTY = Boolean(process.stdout.isTTY);
|
|
10
16
|
const useColor = isTTY && !process.env.NO_COLOR && process.env.FORCE_COLOR !== '0';
|
|
17
|
+
const truecolor = useColor && Boolean(process.env.COLORTERM || process.env.TERM_PROGRAM);
|
|
11
18
|
const ansi = {
|
|
12
19
|
reset: '\x1b[0m',
|
|
13
20
|
bold: '\x1b[1m',
|
|
@@ -17,12 +24,29 @@ const ansi = {
|
|
|
17
24
|
yellow: '\x1b[33m',
|
|
18
25
|
magenta: '\x1b[35m',
|
|
19
26
|
red: '\x1b[31m',
|
|
27
|
+
white: '\x1b[37m',
|
|
20
28
|
};
|
|
21
29
|
function paint(code, text) {
|
|
22
30
|
if (!useColor)
|
|
23
31
|
return text;
|
|
24
32
|
return `${code}${text}${ansi.reset}`;
|
|
25
33
|
}
|
|
34
|
+
function rgb(r, g, b, text) {
|
|
35
|
+
if (!useColor)
|
|
36
|
+
return text;
|
|
37
|
+
if (!truecolor)
|
|
38
|
+
return paint(ansi.cyan, text);
|
|
39
|
+
return `\x1b[38;2;${r};${g};${b}m${text}${ansi.reset}`;
|
|
40
|
+
}
|
|
41
|
+
/** Viewer-adjacent palette: ice, gold, mint, stone. */
|
|
42
|
+
exports.tone = {
|
|
43
|
+
ice: (t) => rgb(125, 211, 252, t),
|
|
44
|
+
gold: (t) => rgb(232, 192, 122, t),
|
|
45
|
+
mint: (t) => rgb(52, 211, 153, t),
|
|
46
|
+
rose: (t) => rgb(251, 113, 133, t),
|
|
47
|
+
mist: (t) => rgb(148, 163, 184, t),
|
|
48
|
+
paper: (t) => rgb(248, 250, 252, t),
|
|
49
|
+
};
|
|
26
50
|
exports.c = {
|
|
27
51
|
bold: (t) => paint(ansi.bold, t),
|
|
28
52
|
dim: (t) => paint(ansi.dim, t),
|
|
@@ -31,33 +55,84 @@ exports.c = {
|
|
|
31
55
|
yellow: (t) => paint(ansi.yellow, t),
|
|
32
56
|
magenta: (t) => paint(ansi.magenta, t),
|
|
33
57
|
red: (t) => paint(ansi.red, t),
|
|
58
|
+
ice: exports.tone.ice,
|
|
59
|
+
gold: exports.tone.gold,
|
|
60
|
+
mint: exports.tone.mint,
|
|
34
61
|
};
|
|
35
62
|
function sleep(ms) {
|
|
36
63
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
37
64
|
}
|
|
65
|
+
function bar(done, total, width = 16) {
|
|
66
|
+
const n = Math.max(1, total);
|
|
67
|
+
const filled = Math.round((done / n) * width);
|
|
68
|
+
const on = '━'.repeat(Math.max(0, filled));
|
|
69
|
+
const off = '─'.repeat(Math.max(0, width - filled));
|
|
70
|
+
return `${exports.tone.ice(on)}${exports.c.dim(off)}`;
|
|
71
|
+
}
|
|
72
|
+
function divider(width = 52) {
|
|
73
|
+
console.log(` ${exports.c.dim('─'.repeat(width))}`);
|
|
74
|
+
}
|
|
75
|
+
function splash(options) {
|
|
76
|
+
const title = 'DAxTA';
|
|
77
|
+
const tag = 'Document API × Test API';
|
|
78
|
+
const meta = `v${options.version} · ${options.project}${options.dryRun ? ' · dry-run' : ''}`;
|
|
79
|
+
const inner = 50;
|
|
80
|
+
const pad = (s) => s + ' '.repeat(Math.max(0, inner - s.length));
|
|
81
|
+
const top = ` ${exports.c.dim('╭' + '─'.repeat(inner + 2) + '╮')}`;
|
|
82
|
+
const bot = ` ${exports.c.dim('╰' + '─'.repeat(inner + 2) + '╯')}`;
|
|
83
|
+
const row = (body) => ` ${exports.c.dim('│')} ${body}${exports.c.dim(' │')}`;
|
|
84
|
+
console.log('');
|
|
85
|
+
console.log(top);
|
|
86
|
+
console.log(row(exports.c.bold(exports.tone.ice(pad(title)))));
|
|
87
|
+
console.log(row(exports.tone.mist(pad(tag))));
|
|
88
|
+
console.log(row(exports.c.dim(pad(meta))));
|
|
89
|
+
console.log(bot);
|
|
90
|
+
console.log('');
|
|
91
|
+
}
|
|
38
92
|
function banner(title, subtitle) {
|
|
39
93
|
console.log('');
|
|
40
|
-
console.log(
|
|
41
|
-
|
|
94
|
+
console.log(` ${exports.tone.ice('◆')} ${exports.c.bold(title)}${subtitle ? exports.tone.mist(` ${subtitle}`) : ''}`);
|
|
95
|
+
divider(Math.min(52, Math.max(32, title.length + 12)));
|
|
96
|
+
}
|
|
97
|
+
function phase(index, total, label, hint) {
|
|
98
|
+
console.log('');
|
|
99
|
+
const mark = String(index).padStart(2, '0');
|
|
100
|
+
console.log(` ${exports.tone.gold(mark)}${exports.c.dim(`/${String(total).padStart(2, '0')}`)} ${bar(index, total)} ${exports.c.bold(label)}`);
|
|
101
|
+
if (hint)
|
|
102
|
+
console.log(` ${exports.tone.mist(hint)}`);
|
|
103
|
+
console.log('');
|
|
104
|
+
}
|
|
105
|
+
function askLine(label, hint) {
|
|
106
|
+
const q = `${exports.tone.gold('?')} ${exports.c.bold(label)}${hint ? exports.tone.mist(` — ${hint}`) : ''}`;
|
|
107
|
+
return ` ${q}\n ${exports.tone.ice('›')} `;
|
|
108
|
+
}
|
|
109
|
+
function readlineAsk(question) {
|
|
110
|
+
const rl = (0, readline_1.createInterface)({ input: process.stdin, output: process.stdout });
|
|
111
|
+
return new Promise((resolve) => {
|
|
112
|
+
rl.question(question, (answer) => {
|
|
113
|
+
rl.close();
|
|
114
|
+
resolve(answer.trim());
|
|
115
|
+
});
|
|
116
|
+
});
|
|
42
117
|
}
|
|
43
|
-
/**
|
|
44
|
-
* Spinner while work runs → ✔ / ✖, optional detail lines, then a short pause to read.
|
|
45
|
-
*/
|
|
46
118
|
async function step(label, work, options = {}) {
|
|
47
119
|
const paceMs = options.paceMs ?? 0;
|
|
48
120
|
const useSpinner = options.spinner !== false && isTTY;
|
|
49
121
|
const frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
50
122
|
let i = 0;
|
|
51
123
|
let timer;
|
|
124
|
+
const prefix = options.n != null && options.of != null
|
|
125
|
+
? `${exports.c.dim(String(options.n).padStart(2, ' ') + '/' + options.of)} `
|
|
126
|
+
: ' ';
|
|
52
127
|
if (useSpinner) {
|
|
53
|
-
process.stdout.write(` ${exports.
|
|
128
|
+
process.stdout.write(` ${prefix}${exports.tone.ice(frames[0])} ${label}`);
|
|
54
129
|
timer = setInterval(() => {
|
|
55
130
|
i = (i + 1) % frames.length;
|
|
56
|
-
process.stdout.write(`\r ${exports.
|
|
57
|
-
},
|
|
131
|
+
process.stdout.write(`\r ${prefix}${exports.tone.ice(frames[i])} ${label}`);
|
|
132
|
+
}, 70);
|
|
58
133
|
}
|
|
59
134
|
else {
|
|
60
|
-
console.log(` ${exports.
|
|
135
|
+
console.log(` ${prefix}${exports.tone.ice('▸')} ${label}`);
|
|
61
136
|
}
|
|
62
137
|
try {
|
|
63
138
|
const result = await work();
|
|
@@ -71,13 +146,14 @@ async function step(label, work, options = {}) {
|
|
|
71
146
|
summary = result.summary;
|
|
72
147
|
details = result.details ?? [];
|
|
73
148
|
}
|
|
74
|
-
const line = summary ? `${label} ${exports.
|
|
149
|
+
const line = summary ? `${label} ${exports.tone.mist(summary)}` : label;
|
|
150
|
+
const ok = `${prefix}${exports.tone.mint('✔')} ${line}`;
|
|
75
151
|
if (useSpinner)
|
|
76
|
-
process.stdout.write(`\r ${
|
|
152
|
+
process.stdout.write(`\r ${ok}${' '.repeat(16)}\n`);
|
|
77
153
|
else
|
|
78
|
-
console.log(` ${
|
|
154
|
+
console.log(` ${ok}`);
|
|
79
155
|
for (const d of details) {
|
|
80
|
-
console.log(`
|
|
156
|
+
console.log(` ${exports.c.dim('·')} ${d}`);
|
|
81
157
|
}
|
|
82
158
|
if (paceMs > 0)
|
|
83
159
|
await sleep(paceMs);
|
|
@@ -86,26 +162,34 @@ async function step(label, work, options = {}) {
|
|
|
86
162
|
if (timer)
|
|
87
163
|
clearInterval(timer);
|
|
88
164
|
const msg = error instanceof Error ? error.message : String(error);
|
|
165
|
+
const fail = `${prefix}${exports.tone.rose('✖')} ${label} ${exports.c.red(msg)}`;
|
|
89
166
|
if (useSpinner)
|
|
90
|
-
process.stdout.write(`\r ${
|
|
167
|
+
process.stdout.write(`\r ${fail}${' '.repeat(8)}\n`);
|
|
91
168
|
else
|
|
92
|
-
console.log(` ${
|
|
169
|
+
console.log(` ${fail}`);
|
|
93
170
|
throw error;
|
|
94
171
|
}
|
|
95
172
|
}
|
|
96
173
|
function box(title, lines) {
|
|
174
|
+
const width = 58;
|
|
97
175
|
console.log('');
|
|
98
|
-
console.log(` ${exports.c.
|
|
176
|
+
console.log(` ${exports.c.dim('╭' + '─'.repeat(width) + '╮')}`);
|
|
177
|
+
console.log(` ${exports.c.dim('│')} ${exports.c.bold(exports.tone.mint(title.padEnd(width - 1)))}${exports.c.dim('│')}`);
|
|
178
|
+
console.log(` ${exports.c.dim('│' + ' '.repeat(width) + '│')}`);
|
|
99
179
|
for (const line of lines) {
|
|
100
|
-
|
|
180
|
+
const visible = line.replace(/\x1b\[[0-9;]*m/g, '');
|
|
181
|
+
const pad = Math.max(0, width - 1 - visible.length);
|
|
182
|
+
console.log(` ${exports.c.dim('│')} ${line}${' '.repeat(pad)}${exports.c.dim('│')}`);
|
|
101
183
|
}
|
|
184
|
+
console.log(` ${exports.c.dim('╰' + '─'.repeat(width) + '╯')}`);
|
|
102
185
|
console.log('');
|
|
103
186
|
}
|
|
104
187
|
function nextSteps(lines) {
|
|
105
|
-
console.log(` ${exports.c.bold('Next')}`);
|
|
106
|
-
for (const { cmd, why } of lines) {
|
|
107
|
-
console.log(` ${exports.c.cyan('$')} ${exports.c.bold(cmd)}`);
|
|
108
|
-
console.log(` ${exports.c.dim(why)}`);
|
|
109
|
-
}
|
|
188
|
+
console.log(` ${exports.c.bold(exports.tone.ice('Next'))}`);
|
|
110
189
|
console.log('');
|
|
190
|
+
lines.forEach((item, index) => {
|
|
191
|
+
console.log(` ${exports.tone.gold(String(index + 1) + '.')} ${exports.c.bold('$')} ${exports.c.bold(item.cmd)}`);
|
|
192
|
+
console.log(` ${exports.tone.mist(item.why)}`);
|
|
193
|
+
console.log('');
|
|
194
|
+
});
|
|
111
195
|
}
|
package/dist/cli/uninstall.js
CHANGED
|
@@ -34,7 +34,6 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.uninstallDaxta = uninstallDaxta;
|
|
37
|
-
const readline_1 = require("readline");
|
|
38
37
|
const fs_1 = require("fs");
|
|
39
38
|
const path = __importStar(require("path"));
|
|
40
39
|
const child_process_1 = require("child_process");
|
|
@@ -48,15 +47,6 @@ function readJson(filePath) {
|
|
|
48
47
|
function writeJson(filePath, value) {
|
|
49
48
|
(0, fs_1.writeFileSync)(filePath, `${JSON.stringify(value, null, 2)}\n`);
|
|
50
49
|
}
|
|
51
|
-
function prompt(question) {
|
|
52
|
-
const rl = (0, readline_1.createInterface)({ input: process.stdin, output: process.stdout });
|
|
53
|
-
return new Promise((resolve) => {
|
|
54
|
-
rl.question(question, (answer) => {
|
|
55
|
-
rl.close();
|
|
56
|
-
resolve(answer.trim());
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
50
|
function detectPackageManager(cwd, pkg) {
|
|
61
51
|
if ((0, fs_1.existsSync)(path.join(cwd, 'pnpm-lock.yaml')) || pkg.packageManager?.startsWith('pnpm'))
|
|
62
52
|
return 'pnpm';
|
|
@@ -146,8 +136,8 @@ async function uninstallDaxta(options = {}) {
|
|
|
146
136
|
const pm = detectPackageManager(cwd, pkg);
|
|
147
137
|
(0, ui_1.banner)('DAxTA uninstall', project);
|
|
148
138
|
if (!options.yes && process.stdin.isTTY) {
|
|
149
|
-
const answer = await
|
|
150
|
-
`
|
|
139
|
+
const answer = await (0, ui_1.readlineAsk)(` ${ui_1.c.gold('?')} Remove DAxTA from ${ui_1.c.bold(project)}?\n` +
|
|
140
|
+
` ${ui_1.c.dim('Y yes · n cancel')}\n ${ui_1.c.ice('›')} `);
|
|
151
141
|
if (answer && !/^y(es)?$/i.test(answer)) {
|
|
152
142
|
console.log(` ${ui_1.c.dim('cancelled')}`);
|
|
153
143
|
return;
|
|
@@ -274,8 +264,8 @@ async function uninstallDaxta(options = {}) {
|
|
|
274
264
|
await (0, ui_1.step)('Package dependency', () => 'not listed — skip', { paceMs });
|
|
275
265
|
}
|
|
276
266
|
}
|
|
277
|
-
(0, ui_1.box)('
|
|
278
|
-
`${ui_1.c.
|
|
267
|
+
(0, ui_1.box)('Removed', [
|
|
268
|
+
`${ui_1.c.mint('✔')} DAxTA unwound from ${ui_1.c.bold(project)}`,
|
|
279
269
|
`${ui_1.c.dim('check')} Nest main + Jest config if anything custom remained`,
|
|
280
270
|
]);
|
|
281
271
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,5 +6,5 @@ export { dtoRequired, type FieldLocation } from './fields/dto-fields';
|
|
|
6
6
|
export { buildFieldsFile, writeFieldsFile, readFieldsFile, type FieldsFile } from './fields/export-fields';
|
|
7
7
|
export { apiDocs, apiDocsHandler, serveApiDocs, getDocsBasePath, getHtmlPath, getOutDir, getSpecJsonPath, type ApiDocsHandler, type ApiDocsOptions, } from './serve';
|
|
8
8
|
export { runInteractiveCall, runFileCall, executeCall, type CallValues } from './call';
|
|
9
|
-
export { apiTitle, parseOperationLabel, suggestOperationTitles, formatTestTitle, isValidItCase, suggestItCases, type FieldDoc, type OperationDoc, } from './catalog';
|
|
9
|
+
export { apiTitle, parseOperationLabel, suggestOperationTitles, suggestOperationTitleResult, formatTestTitle, isValidItCase, suggestItCases, type FieldDoc, type OperationDoc, } from './catalog';
|
|
10
10
|
export { installDaxta, type InstallOptions } from './cli/install';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.installDaxta = exports.suggestItCases = exports.isValidItCase = exports.formatTestTitle = exports.suggestOperationTitles = exports.parseOperationLabel = exports.apiTitle = exports.executeCall = exports.runFileCall = exports.runInteractiveCall = exports.getSpecJsonPath = exports.getOutDir = exports.getHtmlPath = exports.getDocsBasePath = exports.serveApiDocs = exports.apiDocsHandler = exports.apiDocs = exports.readFieldsFile = exports.writeFieldsFile = exports.buildFieldsFile = exports.dtoRequired = exports.getHits = exports.clearWorkerHits = exports.flush = exports.install = exports.touchPartialMarker = exports.clearPartialMarker = exports.flushAndRebuild = exports.rebuildFromDisk = exports.loadHits = exports.buildOpenApi = exports.buildDaxtaSpec = exports.normalizeTreeLayout = exports.resolveConfig = exports.getConfig = exports.defineConfig = void 0;
|
|
3
|
+
exports.installDaxta = exports.suggestItCases = exports.isValidItCase = exports.formatTestTitle = exports.suggestOperationTitleResult = exports.suggestOperationTitles = exports.parseOperationLabel = exports.apiTitle = exports.executeCall = exports.runFileCall = exports.runInteractiveCall = exports.getSpecJsonPath = exports.getOutDir = exports.getHtmlPath = exports.getDocsBasePath = exports.serveApiDocs = exports.apiDocsHandler = exports.apiDocs = exports.readFieldsFile = exports.writeFieldsFile = exports.buildFieldsFile = exports.dtoRequired = exports.getHits = exports.clearWorkerHits = exports.flush = exports.install = exports.touchPartialMarker = exports.clearPartialMarker = exports.flushAndRebuild = exports.rebuildFromDisk = exports.loadHits = exports.buildOpenApi = exports.buildDaxtaSpec = exports.normalizeTreeLayout = exports.resolveConfig = exports.getConfig = exports.defineConfig = void 0;
|
|
4
4
|
var config_1 = require("./config");
|
|
5
5
|
Object.defineProperty(exports, "defineConfig", { enumerable: true, get: function () { return config_1.defineConfig; } });
|
|
6
6
|
Object.defineProperty(exports, "getConfig", { enumerable: true, get: function () { return config_1.getConfig; } });
|
|
@@ -42,6 +42,7 @@ var catalog_1 = require("./catalog");
|
|
|
42
42
|
Object.defineProperty(exports, "apiTitle", { enumerable: true, get: function () { return catalog_1.apiTitle; } });
|
|
43
43
|
Object.defineProperty(exports, "parseOperationLabel", { enumerable: true, get: function () { return catalog_1.parseOperationLabel; } });
|
|
44
44
|
Object.defineProperty(exports, "suggestOperationTitles", { enumerable: true, get: function () { return catalog_1.suggestOperationTitles; } });
|
|
45
|
+
Object.defineProperty(exports, "suggestOperationTitleResult", { enumerable: true, get: function () { return catalog_1.suggestOperationTitleResult; } });
|
|
45
46
|
Object.defineProperty(exports, "formatTestTitle", { enumerable: true, get: function () { return catalog_1.formatTestTitle; } });
|
|
46
47
|
Object.defineProperty(exports, "isValidItCase", { enumerable: true, get: function () { return catalog_1.isValidItCase; } });
|
|
47
48
|
Object.defineProperty(exports, "suggestItCases", { enumerable: true, get: function () { return catalog_1.suggestItCases; } });
|
package/dist/titles/scan.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export type TitleFinding = {
|
|
|
8
8
|
path: string;
|
|
9
9
|
method: string;
|
|
10
10
|
suggestions: string[];
|
|
11
|
+
auto: boolean;
|
|
11
12
|
};
|
|
12
13
|
export declare function scanMissingTitles(cwd?: string): TitleFinding[];
|
|
13
14
|
export declare function applyTitle(cwd: string, finding: TitleFinding, title: string): boolean;
|
package/dist/titles/scan.js
CHANGED
|
@@ -126,6 +126,7 @@ function scanMissingTitles(cwd = process.cwd()) {
|
|
|
126
126
|
const parsed = (0, test_title_1.parseOperationLabel)(body);
|
|
127
127
|
if (!parsed || parsed.title)
|
|
128
128
|
continue;
|
|
129
|
+
const suggestion = (0, test_title_1.suggestOperationTitleResult)(parsed.method, parsed.path);
|
|
129
130
|
findings.push({
|
|
130
131
|
file: rel,
|
|
131
132
|
line: index + 1,
|
|
@@ -134,7 +135,8 @@ function scanMissingTitles(cwd = process.cwd()) {
|
|
|
134
135
|
quote,
|
|
135
136
|
path: parsed.path,
|
|
136
137
|
method: parsed.method,
|
|
137
|
-
suggestions:
|
|
138
|
+
suggestions: suggestion.titles,
|
|
139
|
+
auto: suggestion.auto,
|
|
138
140
|
});
|
|
139
141
|
}
|
|
140
142
|
});
|
|
@@ -165,14 +167,17 @@ function printTitleFindings(findings, paint) {
|
|
|
165
167
|
return;
|
|
166
168
|
console.log('');
|
|
167
169
|
console.log(` ${paint.yellow('!')} ${paint.bold(`${findings.length} test title(s) missing a human name`)} ${paint.dim('(docs would show the path)')}`);
|
|
168
|
-
console.log(` ${paint.dim('Format:')} ${paint.cyan('Create Mock Tbs /v1/admin/mock-tbs
|
|
170
|
+
console.log(` ${paint.dim('Format:')} ${paint.cyan('Create Mock Tbs — POST /v1/admin/mock-tbs')}`);
|
|
169
171
|
for (const item of findings) {
|
|
170
172
|
console.log('');
|
|
171
173
|
console.log(` ${paint.cyan(item.file)}${paint.dim(`:${item.line}:${item.column}`)}`);
|
|
172
174
|
console.log(` ${paint.dim(item.raw)}`);
|
|
173
|
-
if (item.suggestions.length) {
|
|
175
|
+
if (item.suggestions.length && item.auto) {
|
|
174
176
|
console.log(` ${paint.dim('suggest')} ${item.suggestions.map((name, i) => `${i + 1}:${name}`).join(' ')}`);
|
|
175
177
|
}
|
|
178
|
+
else {
|
|
179
|
+
console.log(` ${paint.yellow('custom title required')} ${paint.dim('(Create Bulk / Validate … — not applied by --yes)')}`);
|
|
180
|
+
}
|
|
176
181
|
}
|
|
177
182
|
console.log('');
|
|
178
183
|
console.log(` ${paint.dim('Fix interactively:')} ${paint.cyan('daxta titles')}`);
|