@t0.labs/daxta 0.4.16 → 0.4.17
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 +2 -1
- package/dist/cli/main.js +2 -1
- package/dist/cli/titles.d.ts +1 -0
- package/dist/cli/titles.js +72 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -184,7 +184,8 @@ Format: `{Title} {path} [{METHOD}] (integration)`
|
|
|
184
184
|
- **Before tests:** `daxta install` and `daxta test` ask in the terminal (TTY). `pnpm test:integration` also asks via Jest `globalSetup` when stdin is a TTY. CI only prints. `--yes` / `CI=1` skip the questions.
|
|
185
185
|
|
|
186
186
|
```bash
|
|
187
|
-
daxta titles # interactive
|
|
187
|
+
daxta titles # interactive (y = this recommended, a = all remaining)
|
|
188
|
+
daxta titles --yes # rewrite every hit with the recommended name
|
|
188
189
|
daxta titles --check # report only
|
|
189
190
|
```
|
|
190
191
|
|
package/dist/cli/main.js
CHANGED
|
@@ -19,7 +19,7 @@ Usage:
|
|
|
19
19
|
daxta init (alias of install)
|
|
20
20
|
daxta uninstall [--yes] [--dry-run] [--keep-dep] [--fast]
|
|
21
21
|
daxta migrate [--yes] (force upgrade + sidebar prompts)
|
|
22
|
-
daxta titles [--check] [--strict]
|
|
22
|
+
daxta titles [--check] [--yes] [--strict]
|
|
23
23
|
daxta test [--script <name>] [--config <jest.json>] [--serve] [--port <n>] [--yes] [--strict]
|
|
24
24
|
daxta build
|
|
25
25
|
daxta serve [--port <n>]
|
|
@@ -117,6 +117,7 @@ async function main() {
|
|
|
117
117
|
if (command === 'titles' || command === 'title') {
|
|
118
118
|
const code = await (0, titles_1.runTitleCheck)({
|
|
119
119
|
checkOnly: Boolean(flags.check),
|
|
120
|
+
apply: Boolean(flags.yes) && !flags.check,
|
|
120
121
|
yes: Boolean(flags.yes),
|
|
121
122
|
strict: Boolean(flags.strict),
|
|
122
123
|
});
|
package/dist/cli/titles.d.ts
CHANGED
package/dist/cli/titles.js
CHANGED
|
@@ -26,11 +26,16 @@ async function pickFromSuggestions(finding, extra, validate) {
|
|
|
26
26
|
const mark = index === 0 ? ui_1.c.dim(' (recommended)') : '';
|
|
27
27
|
console.log(` ${ui_1.c.cyan(String(index + 1))} ${name}${mark}`);
|
|
28
28
|
});
|
|
29
|
-
console.log(` ${ui_1.c.cyan('1–3')} pick
|
|
30
|
-
const answer = await prompt(` ${ui_1.c.cyan('›')} `);
|
|
31
|
-
|
|
29
|
+
console.log(` ${ui_1.c.cyan('1–3')} pick ${ui_1.c.cyan('y')} this recommended ${ui_1.c.cyan('a')} all remaining recommended ${ui_1.c.cyan('s')} skip ${ui_1.c.cyan('c')} custom`);
|
|
30
|
+
const answer = (await prompt(` ${ui_1.c.cyan('›')} `)).trim();
|
|
31
|
+
const lower = answer.toLowerCase();
|
|
32
|
+
if (!answer || lower === 's')
|
|
32
33
|
return 'skip';
|
|
33
|
-
if (
|
|
34
|
+
if (lower === 'a' || lower === 'all')
|
|
35
|
+
return 'all';
|
|
36
|
+
if (lower === 'y' || lower === 'yes')
|
|
37
|
+
return suggestions[0] ?? 'skip';
|
|
38
|
+
if (lower === 'c') {
|
|
34
39
|
const custom = await prompt(` ${ui_1.c.dim('text')} ${ui_1.c.cyan('›')} `);
|
|
35
40
|
if (!validate(custom)) {
|
|
36
41
|
console.log(` ${ui_1.c.yellow('!')} does not match the format — skipped`);
|
|
@@ -45,6 +50,40 @@ async function pickFromSuggestions(finding, extra, validate) {
|
|
|
45
50
|
return answer;
|
|
46
51
|
return 'skip';
|
|
47
52
|
}
|
|
53
|
+
function writeTitle(cwd, finding) {
|
|
54
|
+
const name = finding.suggestions[0];
|
|
55
|
+
if (!name || !(0, test_title_1.isHumanOperationTitle)(name))
|
|
56
|
+
return false;
|
|
57
|
+
return (0, scan_1.applyTitle)(cwd, finding, name);
|
|
58
|
+
}
|
|
59
|
+
function writeIt(cwd, finding) {
|
|
60
|
+
const name = finding.suggestions[0];
|
|
61
|
+
if (!name || !(0, it_case_1.isValidItCase)(name))
|
|
62
|
+
return false;
|
|
63
|
+
return (0, scan_1.applyItCase)(cwd, finding, name);
|
|
64
|
+
}
|
|
65
|
+
function applyAllRecommended(cwd, titles, cases, fromTitleIndex, fromCaseIndex) {
|
|
66
|
+
let written = 0;
|
|
67
|
+
let skipped = 0;
|
|
68
|
+
for (let i = fromTitleIndex; i < titles.length; i += 1) {
|
|
69
|
+
if (writeTitle(cwd, titles[i])) {
|
|
70
|
+
console.log(` ${ui_1.c.green('✔')} ${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.green('✔')} ${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 };
|
|
86
|
+
}
|
|
48
87
|
async function runTitleCheck(options) {
|
|
49
88
|
const cwd = options.cwd ?? process.cwd();
|
|
50
89
|
const report = (0, scan_1.scanTestNaming)(cwd);
|
|
@@ -57,6 +96,15 @@ async function runTitleCheck(options) {
|
|
|
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.green('✔')} ${result.written} updated ${ui_1.c.dim(`${result.skipped} skipped`)}`);
|
|
105
|
+
console.log('');
|
|
106
|
+
return options.strict && result.skipped > 0 ? 1 : 0;
|
|
107
|
+
}
|
|
60
108
|
if (options.checkOnly || options.yes || !process.stdin.isTTY) {
|
|
61
109
|
(0, scan_1.printNamingFindings)(report, ui_1.c);
|
|
62
110
|
return options.strict ? 1 : 0;
|
|
@@ -64,11 +112,21 @@ async function runTitleCheck(options) {
|
|
|
64
112
|
(0, ui_1.banner)('Test naming', 'runs before Jest — docs / Postman labels');
|
|
65
113
|
console.log(` ${ui_1.c.dim('Title')} Create Mock Tbs /v1/admin/mock-tbs [POST] (integration)`);
|
|
66
114
|
console.log(` ${ui_1.c.dim('it()')} creates mock tbs when payload is valid`);
|
|
67
|
-
console.log(` ${ui_1.c.yellow(String(total))} to review —
|
|
115
|
+
console.log(` ${ui_1.c.yellow(String(total))} to review — ${ui_1.c.cyan('y')} one recommended, ${ui_1.c.cyan('a')} all remaining, ${ui_1.c.cyan('s')} skip.`);
|
|
68
116
|
let written = 0;
|
|
69
117
|
let skipped = 0;
|
|
70
|
-
for (
|
|
118
|
+
for (let i = 0; i < report.titles.length; i += 1) {
|
|
119
|
+
const finding = report.titles[i];
|
|
71
120
|
const choice = await pickFromSuggestions(finding, `docs would show ${finding.path}`, test_title_1.isHumanOperationTitle);
|
|
121
|
+
if (choice === 'all') {
|
|
122
|
+
const rest = applyAllRecommended(cwd, report.titles, report.cases, i, 0);
|
|
123
|
+
written += rest.written;
|
|
124
|
+
skipped += rest.skipped;
|
|
125
|
+
console.log('');
|
|
126
|
+
console.log(` ${ui_1.c.green('✔')} ${written} updated ${ui_1.c.dim(`${skipped} skipped`)}`);
|
|
127
|
+
console.log('');
|
|
128
|
+
return options.strict && skipped > 0 ? 1 : 0;
|
|
129
|
+
}
|
|
72
130
|
if (!choice || choice === 'skip') {
|
|
73
131
|
skipped += 1;
|
|
74
132
|
continue;
|
|
@@ -82,8 +140,15 @@ async function runTitleCheck(options) {
|
|
|
82
140
|
skipped += 1;
|
|
83
141
|
}
|
|
84
142
|
}
|
|
85
|
-
for (
|
|
143
|
+
for (let i = 0; i < report.cases.length; i += 1) {
|
|
144
|
+
const finding = report.cases[i];
|
|
86
145
|
const choice = await pickFromSuggestions(finding, finding.section ? `section ${finding.section}` : 'it() example name', it_case_1.isValidItCase);
|
|
146
|
+
if (choice === 'all') {
|
|
147
|
+
const rest = applyAllRecommended(cwd, [], report.cases, 0, i);
|
|
148
|
+
written += rest.written;
|
|
149
|
+
skipped += rest.skipped;
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
87
152
|
if (!choice || choice === 'skip') {
|
|
88
153
|
skipped += 1;
|
|
89
154
|
continue;
|