@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 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
  });
@@ -2,5 +2,6 @@ export declare function runTitleCheck(options: {
2
2
  cwd?: string;
3
3
  checkOnly?: boolean;
4
4
  yes?: boolean;
5
+ apply?: boolean;
5
6
  strict?: boolean;
6
7
  }): Promise<number>;
@@ -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 suggestion ${ui_1.c.cyan('s')} skip ${ui_1.c.cyan('c')} type your own`);
30
- const answer = await prompt(` ${ui_1.c.cyan('›')} `);
31
- if (!answer || answer.toLowerCase() === 's')
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 (answer.toLowerCase() === 'c') {
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 — pick a suggestion, custom, or skip.`);
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 (const finding of report.titles) {
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 (const finding of report.cases) {
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t0.labs/daxta",
3
- "version": "0.4.16",
3
+ "version": "0.4.17",
4
4
  "description": "DAxTA \u2014 docs from Nest integration traffic + DTO field CLI / Try-it",
5
5
  "license": "MIT",
6
6
  "repository": {