@t0.labs/daxta 0.4.17 → 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 CHANGED
@@ -168,20 +168,33 @@ Then `daxta build` to refresh `/docs` and export.
168
168
 
169
169
  ## Test titles (docs / Postman names)
170
170
 
171
- Docs and the collection use a **human title**, not the raw path. Put it in `TEST_TITLE` (or the describe string):
171
+ Readable `TEST_TITLE` (path stays after the em dash so DAxTA can still bind the route):
172
172
 
173
173
  ```ts
174
- static TEST_TITLE = () => `Create Mock Tbs /v1/admin/mock-tbs [POST] (integration)`;
174
+ static TEST_TITLE = () => `Create Mock Tbs — POST /v1/admin/mock-tbs`;
175
175
  describe(`${TEST_TITLE()} POSITIVE CASES`, () => { /* … */ });
176
176
  ```
177
177
 
178
- Format: `{Title} {path} [{METHOD}] (integration)`
178
+ Format: `{Title} — {METHOD} {path}`
179
179
 
180
- - Verb comes from the method (`GET` collection → Find All, `GET …/{id}` → Find One, `POST` → Create, …) plus kebab resource (`mock-tbs` → Mock Tbs). Action segments (`validate`, `approve`, …) become the verb.
181
- - Skip the title and docs fall back to the path.
182
- - `it()` example names: `{outcome} when {condition}` — e.g. `creates mock tbs when payload is valid`. No path, no `[POST]`, no status (status comes from the recorded hit).
183
- - `daxta titles` lists file:line for both rules; pick a suggestion, type custom, or skip.
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.
180
+ Suggested titles (method + path, never `:id` as a name):
181
+
182
+ | Call | Title |
183
+ | --- | --- |
184
+ | `GET /…/mock-tbs` | Find All Mock Tbs |
185
+ | `GET /…/mock-tbs/:id` | Find One Mock Tbs By Id |
186
+ | `POST /…/mock-tbs` | Create Mock Tbs |
187
+ | `PATCH /…/mock-tbs/:id` | Update Mock Tbs By Id |
188
+ | `POST /…/products/bulk` | Create Bulk Products |
189
+ | `POST /…/validator/tax-id/validate` | Validate Tax Id |
190
+
191
+ `--yes` / `a` only rewrite **known** patterns (CRUD + bulk + validate/approve/…). Unknown routes are **not skipped**: they stay listed until you type a custom title (`c`).
192
+
193
+ Old `{path} [METHOD] (integration)` still parses. `daxta titles --yes` rewrites to the new form.
194
+
195
+ - `it()`: `{outcome} when {condition}` — e.g. `creates mock tbs when payload is valid`
196
+ - `daxta titles` / `--yes` / `y` / `a` as before
197
+ - **Before tests:** install, `daxta test`, and Jest `globalSetup` (TTY). `--yes` / `CI=1` skip questions.
185
198
 
186
199
  ```bash
187
200
  daxta titles # interactive (y = this recommended, a = all remaining)
@@ -1,5 +1,5 @@
1
1
  import { type TreeLayout } from '../config';
2
- export { parseOperationLabel, suggestOperationTitles, formatTestTitle } from './test-title';
2
+ export { parseOperationLabel, suggestOperationTitles, suggestOperationTitleResult, formatTestTitle } from './test-title';
3
3
  export { isValidItCase, suggestItCases, parseCaseSection, type CaseSection } from './it-case';
4
4
  export type { TreeLayout };
5
5
  export type FieldDoc = {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.STATUS_TEXT = exports.parseCaseSection = exports.suggestItCases = exports.isValidItCase = exports.formatTestTitle = exports.suggestOperationTitles = exports.parseOperationLabel = void 0;
3
+ exports.STATUS_TEXT = exports.parseCaseSection = exports.suggestItCases = exports.isValidItCase = exports.formatTestTitle = exports.suggestOperationTitleResult = exports.suggestOperationTitles = exports.parseOperationLabel = void 0;
4
4
  exports.declaredMethods = declaredMethods;
5
5
  exports.pathSegments = pathSegments;
6
6
  exports.treePathSegments = treePathSegments;
@@ -18,6 +18,7 @@ const test_title_1 = require("./test-title");
18
18
  var test_title_2 = require("./test-title");
19
19
  Object.defineProperty(exports, "parseOperationLabel", { enumerable: true, get: function () { return test_title_2.parseOperationLabel; } });
20
20
  Object.defineProperty(exports, "suggestOperationTitles", { enumerable: true, get: function () { return test_title_2.suggestOperationTitles; } });
21
+ Object.defineProperty(exports, "suggestOperationTitleResult", { enumerable: true, get: function () { return test_title_2.suggestOperationTitleResult; } });
21
22
  Object.defineProperty(exports, "formatTestTitle", { enumerable: true, get: function () { return test_title_2.formatTestTitle; } });
22
23
  var it_case_1 = require("./it-case");
23
24
  Object.defineProperty(exports, "isValidItCase", { enumerable: true, get: function () { return it_case_1.isValidItCase; } });
@@ -43,6 +44,11 @@ const CASE_SECTION_RE = /^(POSITIVE CASES|SEMANTIC ERROR CASES(?:\s*-\s*AUTH)?|I
43
44
  function declaredMethods(test) {
44
45
  if (!test)
45
46
  return null;
47
+ const fromLabel = (0, test_title_1.parseOperationLabel)(test);
48
+ if (fromLabel?.method) {
49
+ const method = fromLabel.method.toLowerCase();
50
+ return METHOD_ALIASES[method] ?? [method];
51
+ }
46
52
  const declared = test.match(/\[(GET|POST|PUT|PATCH|DELETE|UPDATE|UPSERT)\]/i);
47
53
  if (!declared)
48
54
  return null;
@@ -50,7 +56,7 @@ function declaredMethods(test) {
50
56
  return METHOD_ALIASES[method] ?? [method];
51
57
  }
52
58
  function pathSegments(pathTemplate) {
53
- return pathTemplate.split('/').filter((part) => part && !part.startsWith('{'));
59
+ return pathTemplate.split('/').filter((part) => part && !part.startsWith('{') && !part.startsWith(':'));
54
60
  }
55
61
  function applyLayout(parts, layout) {
56
62
  if (parts.length >= 3 && /^v\d+$/i.test(parts[0]) && layout === 'resource-role') {
@@ -168,6 +174,7 @@ function caseName(test) {
168
174
  if (!test)
169
175
  return 'example';
170
176
  let rest = test
177
+ .replace(/^.+?\s+[—–-]\s+(?:GET|POST|PUT|PATCH|DELETE|UPDATE|UPSERT)\s+\S+\s*/i, '')
171
178
  .replace(/^.*?\[(?:GET|POST|PUT|PATCH|DELETE|UPDATE|UPSERT)\]\s*(?:\(integration\))?\s*/i, '')
172
179
  .replace(CASE_SECTION_RE, '')
173
180
  .trim();
@@ -39,11 +39,7 @@ function isValidItCase(name) {
39
39
  function resourcePhrase(pathTemplate) {
40
40
  if (!pathTemplate)
41
41
  return 'resource';
42
- const named = pathTemplate.split('/').filter((part) => part && !part.startsWith('{') && !/^v\d+$/i.test(part));
43
- const last = named[named.length - 1] || 'resource';
44
- const prev = named[named.length - 2];
45
- const action = /^(validate|approve|reject|sync|search|export|import|lock|unlock)$/i.test(last);
46
- return (0, test_title_1.titleCaseToken)(action && prev ? prev : last).toLowerCase();
42
+ return (0, test_title_1.resourceLabel)(pathTemplate).toLowerCase();
47
43
  }
48
44
  /**
49
45
  * Deterministic it() suggestions: `{outcome} when {condition}`.
@@ -51,7 +47,7 @@ function resourcePhrase(pathTemplate) {
51
47
  function suggestItCases(section, method, pathTemplate) {
52
48
  const res = resourcePhrase(pathTemplate);
53
49
  const m = (method || 'get').toLowerCase();
54
- const hasParam = Boolean(pathTemplate?.split('/').some((part) => part.startsWith('{')));
50
+ const hasParam = Boolean(pathTemplate?.split('/').some((part) => part.startsWith('{') || part.startsWith(':')));
55
51
  const out = [];
56
52
  const add = (value) => {
57
53
  const next = value.replace(/\s+/g, ' ').trim();
@@ -4,16 +4,26 @@ export type ParsedOperationLabel = {
4
4
  method: string;
5
5
  integration: boolean;
6
6
  };
7
+ export declare function isPathParam(part: string): boolean;
7
8
  export declare function titleCaseToken(value: string): string;
8
9
  export declare function isHumanOperationTitle(title: string | undefined): boolean;
9
10
  /**
10
11
  * Pull path / method / optional human title from a TEST_TITLE or Jest name.
11
- * Section suffixes (POSITIVE CASES …) are ignored.
12
12
  */
13
13
  export declare function parseOperationLabel(raw?: string): ParsedOperationLabel | undefined;
14
+ /** Readable TEST_TITLE: `Create Mock Tbs — POST /v1/admin/mock-tbs` */
14
15
  export declare function formatTestTitle(title: string, pathTemplate: string, method: string): string;
16
+ export declare function resourceLabel(pathTemplate: string): string;
17
+ export type TitleSuggestion = {
18
+ titles: string[];
19
+ /** Safe to apply with --yes / `a`. False → user must type a custom name. */
20
+ auto: boolean;
21
+ };
15
22
  /**
16
- * Deterministic title suggestions from HTTP method + path (no AI).
17
- * POST /v1/admin/mock-tbs → ["Create Mock Tbs", "Create Admin Mock Tbs"]
23
+ * POST /v1/admin/mock-tbs → Create Mock Tbs
24
+ * GET /v1/admin/mock-tbs/:id → Find One Mock Tbs By Id
25
+ * POST /v1/admin/products/bulk → Create Bulk Products
26
+ * POST /v1/admin/validator/tax-id/validate → Validate Tax Id
18
27
  */
28
+ export declare function suggestOperationTitleResult(method: string, pathTemplate: string): TitleSuggestion;
19
29
  export declare function suggestOperationTitles(method: string, pathTemplate: string): string[];
@@ -1,13 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isPathParam = isPathParam;
3
4
  exports.titleCaseToken = titleCaseToken;
4
5
  exports.isHumanOperationTitle = isHumanOperationTitle;
5
6
  exports.parseOperationLabel = parseOperationLabel;
6
7
  exports.formatTestTitle = formatTestTitle;
8
+ exports.resourceLabel = resourceLabel;
9
+ exports.suggestOperationTitleResult = suggestOperationTitleResult;
7
10
  exports.suggestOperationTitles = suggestOperationTitles;
8
11
  const METHODS = 'GET|POST|PUT|PATCH|DELETE|UPDATE|UPSERT';
9
- const PATH_ONLY_RE = new RegExp(`^(?<path>\\/\\S+)\\s+\\[(?<method>${METHODS})\\](?:\\s+\\(integration\\))?\\s*$`, 'i');
10
- const WITH_TITLE_RE = new RegExp(`^(?<title>.+?)\\s+(?<path>\\/\\S+)\\s+\\[(?<method>${METHODS})\\](?:\\s+\\(integration\\))?\\s*$`, 'i');
12
+ const PATH_ONLY_BRACKET_RE = new RegExp(`^(?<path>\\/\\S+)\\s+\\[(?<method>${METHODS})\\](?:\\s+\\(integration\\))?\\s*$`, 'i');
13
+ const TITLE_BRACKET_RE = new RegExp(`^(?<title>.+?)\\s+(?<path>\\/\\S+)\\s+\\[(?<method>${METHODS})\\](?:\\s+\\(integration\\))?\\s*$`, 'i');
14
+ /** `Create Mock Tbs — POST /v1/admin/mock-tbs` */
15
+ const TITLE_DASH_RE = new RegExp(`^(?<title>.+?)\\s+[—–-]\\s+(?<method>${METHODS})\\s+(?<path>\\/\\S+)(?:\\s+\\(integration\\))?\\s*$`, 'i');
16
+ const PATH_ONLY_DASH_RE = new RegExp(`^(?<method>${METHODS})\\s+(?<path>\\/\\S+)(?:\\s+\\(integration\\))?\\s*$`, 'i');
11
17
  const ROLE_WORDS = new Set([
12
18
  'admin',
13
19
  'user',
@@ -23,6 +29,7 @@ const ROLE_WORDS = new Set([
23
29
  'system',
24
30
  'superadmin',
25
31
  ]);
32
+ const MODULE_WORDS = new Set(['validator', 'validation', 'validators']);
26
33
  const ACTION_WORDS = new Set([
27
34
  'validate',
28
35
  'approve',
@@ -43,9 +50,16 @@ const ACTION_WORDS = new Set([
43
50
  'confirm',
44
51
  'activate',
45
52
  'deactivate',
53
+ 'check',
54
+ 'calculate',
46
55
  ]);
56
+ function isPathParam(part) {
57
+ const value = part.trim();
58
+ return value.startsWith('{') || value.startsWith(':') || /^:.+/.test(value);
59
+ }
47
60
  function titleCaseToken(value) {
48
61
  return value
62
+ .replace(/^[:]/, '')
49
63
  .replace(/[{}]/g, '')
50
64
  .split(/[-_]/g)
51
65
  .filter(Boolean)
@@ -56,83 +70,117 @@ function isHumanOperationTitle(title) {
56
70
  const value = title?.trim() ?? '';
57
71
  if (value.length < 2 || value.length > 80)
58
72
  return false;
59
- if (value.startsWith('/'))
73
+ if (value.startsWith('/') || value.startsWith(':'))
74
+ return false;
75
+ if (/[{}]/.test(value) || /:[a-zA-Z]/.test(value))
60
76
  return false;
61
77
  if (!/[a-zA-Z]/.test(value))
62
78
  return false;
63
79
  return true;
64
80
  }
81
+ function stripCaseTail(raw) {
82
+ return raw
83
+ .replace(/\s+(POSITIVE CASES|SEMANTIC ERROR CASES(?:\s*-\s*AUTH)?|INVALID CASES|OMITTED(?: FIELD)? CASES)\b[\s\S]*$/i, '')
84
+ .trim();
85
+ }
65
86
  /**
66
87
  * Pull path / method / optional human title from a TEST_TITLE or Jest name.
67
- * Section suffixes (POSITIVE CASES …) are ignored.
68
88
  */
69
89
  function parseOperationLabel(raw) {
70
90
  if (!raw)
71
91
  return undefined;
72
- const cut = raw
73
- .replace(/\s+(POSITIVE CASES|SEMANTIC ERROR CASES(?:\s*-\s*AUTH)?|INVALID CASES|OMITTED(?: FIELD)? CASES)\b[\s\S]*$/i, '')
74
- .trim();
92
+ const cut = stripCaseTail(raw);
75
93
  const integration = /\(integration\)/i.test(cut);
76
- const pathOnly = cut.match(PATH_ONLY_RE);
77
- if (pathOnly?.groups?.path && pathOnly.groups.method) {
78
- return { path: pathOnly.groups.path, method: pathOnly.groups.method.toUpperCase(), integration };
79
- }
80
- const withTitle = cut.match(WITH_TITLE_RE);
81
- if (!withTitle?.groups?.path || !withTitle.groups.method)
82
- return undefined;
83
- const title = withTitle.groups.title?.trim();
84
- return {
85
- title: isHumanOperationTitle(title) ? title : undefined,
86
- path: withTitle.groups.path,
87
- method: withTitle.groups.method.toUpperCase(),
88
- integration,
94
+ const fromGroups = (match) => {
95
+ const path = match?.groups?.path;
96
+ const method = match?.groups?.method;
97
+ if (!path || !method)
98
+ return undefined;
99
+ const title = match.groups?.title?.trim();
100
+ return {
101
+ title: isHumanOperationTitle(title) ? title : undefined,
102
+ path,
103
+ method: method.toUpperCase(),
104
+ integration,
105
+ };
89
106
  };
107
+ return (fromGroups(cut.match(TITLE_DASH_RE)) ||
108
+ fromGroups(cut.match(PATH_ONLY_DASH_RE)) ||
109
+ fromGroups(cut.match(PATH_ONLY_BRACKET_RE)) ||
110
+ fromGroups(cut.match(TITLE_BRACKET_RE)));
90
111
  }
112
+ /** Readable TEST_TITLE: `Create Mock Tbs — POST /v1/admin/mock-tbs` */
91
113
  function formatTestTitle(title, pathTemplate, method) {
92
114
  const clean = title.trim().replace(/\s+/g, ' ');
93
- return `${clean} ${pathTemplate} [${method.toUpperCase()}] (integration)`;
115
+ return `${clean} — ${method.toUpperCase()} ${pathTemplate}`;
94
116
  }
95
- function verbFor(method, pathTemplate, actionLabel) {
96
- if (actionLabel)
97
- return actionLabel;
98
- const hasParam = pathTemplate.split('/').some((part) => part.startsWith('{'));
99
- const m = method.toLowerCase();
100
- if (m === 'get')
101
- return hasParam ? 'Find One' : 'Find All';
102
- if (m === 'post')
103
- return 'Create';
104
- if (m === 'delete')
105
- return 'Delete';
106
- if (m === 'put' || m === 'patch' || m === 'update')
107
- return 'Update';
108
- if (m === 'upsert')
109
- return 'Upsert';
110
- return titleCaseToken(m);
117
+ function namedSegments(pathTemplate) {
118
+ return pathTemplate.split('/').filter((part) => part && !isPathParam(part) && !/^v\d+$/i.test(part));
119
+ }
120
+ function operationSegments(pathTemplate) {
121
+ return namedSegments(pathTemplate).filter((part) => !ROLE_WORDS.has(part.toLowerCase()) && !MODULE_WORDS.has(part.toLowerCase()));
122
+ }
123
+ function resourceLabel(pathTemplate) {
124
+ const rest = operationSegments(pathTemplate);
125
+ const last = rest[rest.length - 1] || namedSegments(pathTemplate)[namedSegments(pathTemplate).length - 1] || 'resource';
126
+ const prev = rest[rest.length - 2];
127
+ if ((ACTION_WORDS.has(last.toLowerCase()) || last.toLowerCase() === 'bulk') && prev)
128
+ return titleCaseToken(prev);
129
+ return titleCaseToken(last);
130
+ }
131
+ function lastSegment(pathTemplate) {
132
+ const rest = operationSegments(pathTemplate);
133
+ return (rest[rest.length - 1] || '').toLowerCase();
111
134
  }
112
135
  /**
113
- * Deterministic title suggestions from HTTP method + path (no AI).
114
- * POST /v1/admin/mock-tbs → ["Create Mock Tbs", "Create Admin Mock Tbs"]
136
+ * POST /v1/admin/mock-tbs → Create Mock Tbs
137
+ * GET /v1/admin/mock-tbs/:id → Find One Mock Tbs By Id
138
+ * POST /v1/admin/products/bulk → Create Bulk Products
139
+ * POST /v1/admin/validator/tax-id/validate → Validate Tax Id
115
140
  */
116
- function suggestOperationTitles(method, pathTemplate) {
117
- const parts = pathTemplate.split('/').filter(Boolean);
118
- const named = parts.filter((part) => !part.startsWith('{') && !/^v\d+$/i.test(part));
119
- const last = named[named.length - 1] || 'resource';
120
- const prev = named[named.length - 2];
121
- const lastIsAction = ACTION_WORDS.has(last.toLowerCase());
122
- const resource = titleCaseToken(lastIsAction && prev ? prev : last);
123
- const actionLabel = lastIsAction ? titleCaseToken(last) : null;
124
- const role = named.find((part) => ROLE_WORDS.has(part.toLowerCase()));
125
- const verb = verbFor(method, pathTemplate, actionLabel);
141
+ function suggestOperationTitleResult(method, pathTemplate) {
142
+ const resource = resourceLabel(pathTemplate);
143
+ const rest = operationSegments(pathTemplate);
144
+ const last = lastSegment(pathTemplate);
145
+ const byId = pathTemplate.split('/').some((part) => isPathParam(part));
146
+ const m = method.toLowerCase();
126
147
  const out = [];
127
148
  const add = (value) => {
128
149
  const next = value.replace(/\s+/g, ' ').trim();
129
- if (next && !out.includes(next))
150
+ if (next && !out.includes(next) && isHumanOperationTitle(next))
130
151
  out.push(next);
131
152
  };
132
- add(`${verb} ${resource}`);
133
- if (role)
134
- add(`${verb} ${titleCaseToken(role)} ${resource}`);
135
- if (actionLabel && verb !== actionLabel)
136
- add(`${actionLabel} ${resource}`);
137
- return out.slice(0, 3);
153
+ if (last === 'bulk') {
154
+ add(m === 'get' ? `Find Bulk ${resource}` : `Create Bulk ${resource}`);
155
+ return { titles: out.slice(0, 3), auto: out.length > 0 };
156
+ }
157
+ if (ACTION_WORDS.has(last)) {
158
+ add(`${titleCaseToken(last)} ${resource}`);
159
+ return { titles: out.slice(0, 3), auto: out.length > 0 };
160
+ }
161
+ const extraTail = rest.length > 1;
162
+ if (extraTail) {
163
+ // e.g. /validator/tax-id/something-unknown — do not invent a CRUD name
164
+ return { titles: [], auto: false };
165
+ }
166
+ if (m === 'get' && byId)
167
+ add(`Find One ${resource} By Id`);
168
+ else if (m === 'get')
169
+ add(`Find All ${resource}`);
170
+ else if (m === 'post')
171
+ add(`Create ${resource}`);
172
+ else if (m === 'delete' && byId)
173
+ add(`Delete One ${resource} By Id`);
174
+ else if (m === 'delete')
175
+ add(`Delete ${resource}`);
176
+ else if ((m === 'put' || m === 'patch' || m === 'update') && byId)
177
+ add(`Update ${resource} By Id`);
178
+ else if (m === 'put' || m === 'patch' || m === 'update')
179
+ add(`Update ${resource}`);
180
+ else
181
+ return { titles: [], auto: false };
182
+ return { titles: out.slice(0, 3), auto: out.length > 0 };
183
+ }
184
+ function suggestOperationTitles(method, pathTemplate) {
185
+ return suggestOperationTitleResult(method, pathTemplate).titles;
138
186
  }
@@ -39,19 +39,9 @@ exports.extractJestConfigFromCommand = extractJestConfigFromCommand;
39
39
  exports.resolveTestScript = resolveTestScript;
40
40
  exports.upsertTestWiringInConfig = upsertTestWiringInConfig;
41
41
  exports.wrapUserTestScript = wrapUserTestScript;
42
- const readline_1 = require("readline");
43
42
  const fs_1 = require("fs");
44
43
  const path = __importStar(require("path"));
45
44
  const ui_1 = require("./ui");
46
- function prompt(question) {
47
- const rl = (0, readline_1.createInterface)({ input: process.stdin, output: process.stdout });
48
- return new Promise((resolve) => {
49
- rl.question(question, (answer) => {
50
- rl.close();
51
- resolve(answer.trim());
52
- });
53
- });
54
- }
55
45
  function scoreScript(name, command) {
56
46
  const n = name.toLowerCase();
57
47
  const cmd = command.toLowerCase();
@@ -111,7 +101,7 @@ async function resolveTestScript(options) {
111
101
  if (!choices.length) {
112
102
  if (options.yes || !process.stdin.isTTY)
113
103
  return null;
114
- const typed = await prompt(` ${ui_1.c.yellow('?')} ${ui_1.c.bold('No test script found.')} Enter script name, or ${ui_1.c.dim('n')} to skip:\n ${ui_1.c.cyan('›')} `);
104
+ const typed = await (0, ui_1.readlineAsk)((0, ui_1.askLine)('No test script found', 'script name, or n to skip'));
115
105
  if (!typed || /^n(o)?$/i.test(typed))
116
106
  return null;
117
107
  return typed;
@@ -121,13 +111,13 @@ async function resolveTestScript(options) {
121
111
  return def.name;
122
112
  console.log(` ${ui_1.c.dim('your scripts')}`);
123
113
  choices.slice(0, 8).forEach((choice, i) => {
124
- const mark = i === 0 ? ui_1.c.cyan('●') : ui_1.c.dim('○');
114
+ const mark = i === 0 ? ui_1.c.ice('●') : ui_1.c.dim('○');
125
115
  const label = i === 0 ? ui_1.c.bold(choice.name) : ui_1.c.dim(choice.name);
126
116
  const cmd = isDaxtaWrappedScript(choice.command) ? '(already wired → daxta test)' : choice.command.slice(0, 56);
127
117
  console.log(` ${mark} ${label} ${ui_1.c.dim(cmd)}`);
128
118
  });
129
- const answer = await prompt(` ${ui_1.c.yellow('?')} Attach DAxTA plugin to ${ui_1.c.cyan(def.name)}?\n` +
130
- ` ${ui_1.c.dim('Y')} yes · ${ui_1.c.dim('n')} skip · or type another script name\n ${ui_1.c.cyan('›')} `);
119
+ const answer = await (0, ui_1.readlineAsk)(` ${ui_1.c.gold('?')} Attach DAxTA plugin to ${ui_1.c.ice(def.name)}?\n` +
120
+ ` ${ui_1.c.dim('Y yes · n skip · or another script name')}\n ${ui_1.c.ice('›')} `);
131
121
  if (!answer || /^y(es)?$/i.test(answer))
132
122
  return def.name;
133
123
  if (/^n(o)?$/i.test(answer))
@@ -38,7 +38,6 @@ exports.resolveMainPath = resolveMainPath;
38
38
  exports.injectApiDocs = injectApiDocs;
39
39
  exports.removeApiDocs = removeApiDocs;
40
40
  exports.resolveMainTarget = resolveMainTarget;
41
- const readline_1 = require("readline");
42
41
  const fs_1 = require("fs");
43
42
  const path = __importStar(require("path"));
44
43
  const ui_1 = require("./ui");
@@ -80,22 +79,13 @@ function findMainCandidates(cwd) {
80
79
  }
81
80
  return preferred;
82
81
  }
83
- function prompt(question) {
84
- const rl = (0, readline_1.createInterface)({ input: process.stdin, output: process.stdout });
85
- return new Promise((resolve) => {
86
- rl.question(question, (answer) => {
87
- rl.close();
88
- resolve(answer.trim());
89
- });
90
- });
91
- }
92
82
  /**
93
83
  * Ask: use detected main, or type another path / n to skip.
94
84
  */
95
85
  async function resolveMainPath(cwd, candidates) {
96
86
  const def = candidates[0];
97
87
  if (!def) {
98
- const typed = await prompt(` ${ui_1.c.yellow('?')} ${ui_1.c.bold('No main.ts found.')} Enter path, or ${ui_1.c.dim('n')} to skip:\n ${ui_1.c.cyan('›')} `);
88
+ const typed = await (0, ui_1.readlineAsk)(`${(0, ui_1.askLine)('No main.ts found', 'path, or n to skip')}`);
99
89
  if (!typed || /^n(o)?$/i.test(typed))
100
90
  return null;
101
91
  const full = path.isAbsolute(typed) ? typed : path.join(cwd, typed);
@@ -113,8 +103,8 @@ async function resolveMainPath(cwd, candidates) {
113
103
  if (candidates.length > 5)
114
104
  console.log(` ${ui_1.c.dim(`… +${candidates.length - 5} more`)}`);
115
105
  }
116
- const answer = await prompt(` ${ui_1.c.yellow('?')} Inject ${ui_1.c.bold('apiDocs(app)')} into ${ui_1.c.cyan(rel)}?\n` +
117
- ` ${ui_1.c.dim('Y')} yes · ${ui_1.c.dim('n')} skip · or type another path\n ${ui_1.c.cyan('›')} `);
106
+ const answer = await (0, ui_1.readlineAsk)(` ${ui_1.c.gold('?')} Inject ${ui_1.c.bold('apiDocs(app)')} into ${ui_1.c.ice(rel)}?\n` +
107
+ ` ${ui_1.c.dim('Y yes · n skip · or another path')}\n ${ui_1.c.ice('›')} `);
118
108
  if (!answer || /^y(es)?$/i.test(answer))
119
109
  return def;
120
110
  if (/^n(o)?$/i.test(answer))
@@ -198,7 +198,7 @@ function runPackageInstall(cwd, pm, version, dryRun) {
198
198
  async function installDaxta(options = {}) {
199
199
  const cwd = options.cwd ?? process.cwd();
200
200
  const dryRun = Boolean(options.dryRun);
201
- const paceMs = options.fast || dryRun || process.env.CI ? 0 : 2200;
201
+ const paceMs = options.fast || dryRun || process.env.CI ? 0 : 380;
202
202
  const pkgPath = path.join(cwd, 'package.json');
203
203
  if (!(0, fs_1.existsSync)(pkgPath))
204
204
  throw new Error(`No package.json in ${cwd}`);
@@ -206,10 +206,12 @@ async function installDaxta(options = {}) {
206
206
  const pm = detectPackageManager(cwd, pkg);
207
207
  const version = selfVersion();
208
208
  const project = pkg.name || path.basename(cwd);
209
- (0, ui_1.banner)('DAxTA install', `v${version} · ${project}`);
209
+ const of = 5;
210
+ (0, ui_1.splash)({ version, project, dryRun });
210
211
  if (paceMs)
211
- await (0, ui_1.sleep)(700);
212
- await (0, ui_1.step)('Detect package manager', () => pm, { paceMs });
212
+ await (0, ui_1.sleep)(220);
213
+ (0, ui_1.phase)(1, of, 'Project', 'package manager and DAxTA package');
214
+ await (0, ui_1.step)('Detect package manager', () => pm, { paceMs, n: 1, of });
213
215
  if (!options.skipDep) {
214
216
  if (!isDaxtaListed(pkg) || !isDaxtaInstalled(cwd)) {
215
217
  await (0, ui_1.step)(`Add @t0.labs/daxta via ${pm}`, () => {
@@ -217,16 +219,17 @@ async function installDaxta(options = {}) {
217
219
  if (!dryRun)
218
220
  pkg = readJson(pkgPath);
219
221
  return { summary: 'devDependency', details: [spec] };
220
- }, { paceMs: paceMs ? 600 : 0 });
222
+ }, { paceMs: paceMs ? 180 : 0, n: 1, of });
221
223
  }
222
224
  else {
223
- await (0, ui_1.step)('Package dependency', () => 'already installed — skip add', { paceMs });
225
+ await (0, ui_1.step)('Package dependency', () => 'already installed — skip add', { paceMs, n: 1, of });
224
226
  }
225
227
  }
228
+ (0, ui_1.phase)(2, of, 'Workspace files', 'config, gitignore, docs env flag');
226
229
  await (0, ui_1.step)('Write daxta.config.ts', () => {
227
230
  const { created, rel } = writeConfig(cwd, dryRun);
228
231
  return created ? `created ${rel}` : `exists · ${rel}`;
229
- }, { paceMs });
232
+ }, { paceMs, n: 2, of });
230
233
  await (0, ui_1.step)('Clean package.json scripts', () => {
231
234
  const stripped = stripRegisterNodeOptions(pkg);
232
235
  const removed = removeDaxtaAliasScripts(pkg);
@@ -240,29 +243,30 @@ async function installDaxta(options = {}) {
240
243
  if (!details.length)
241
244
  return 'no daxta:* aliases';
242
245
  return { summary: `${details.length} cleanup(s)`, details };
243
- }, { paceMs });
246
+ }, { paceMs, n: 2, of });
244
247
  await (0, ui_1.step)('Prepare output dir', () => {
245
248
  if (!dryRun)
246
249
  (0, fs_1.mkdirSync)(path.join(cwd, 'daxta', 'out'), { recursive: true });
247
250
  return 'daxta/out';
248
- }, { paceMs });
251
+ }, { paceMs, n: 2, of });
249
252
  await (0, ui_1.step)('Update .gitignore', () => {
250
253
  const notes = ensureGitignore(cwd, dryRun);
251
254
  if (!notes.length)
252
255
  return 'already ignored';
253
256
  return { summary: `${notes.length} entr${notes.length === 1 ? 'y' : 'ies'}`, details: notes };
254
- }, { paceMs });
255
- await (0, ui_1.step)('Set DAXTA_DOCS in env', () => ensureEnvDaxtaDocs(cwd, dryRun), { paceMs });
257
+ }, { paceMs, n: 2, of });
258
+ await (0, ui_1.step)('Set DAXTA_DOCS in env', () => ensureEnvDaxtaDocs(cwd, dryRun), { paceMs, n: 2, of });
259
+ (0, ui_1.phase)(3, of, 'Nest', 'apiDocs(app) on the HTTP bootstrap');
256
260
  if (!options.skipMain) {
257
261
  console.log('');
258
- console.log(` ${ui_1.c.yellow(ui_1.c.bold('?'))} ${ui_1.c.bold('Nest entry')} ${ui_1.c.dim('— wire apiDocs(app)')}`);
262
+ console.log(` ${ui_1.c.gold('?')} ${ui_1.c.bold('Nest entry')} ${ui_1.c.dim('— wire apiDocs(app)')}`);
259
263
  const target = await (0, inject_main_1.resolveMainTarget)({
260
264
  cwd,
261
265
  yes: options.yes,
262
266
  mainPath: options.mainPath,
263
267
  });
264
268
  if (!target) {
265
- await (0, ui_1.step)('Inject apiDocs(app)', () => 'skipped', { paceMs });
269
+ await (0, ui_1.step)('Inject apiDocs(app)', () => 'skipped', { paceMs, n: 3, of });
266
270
  }
267
271
  else {
268
272
  await (0, ui_1.step)('Inject apiDocs(app)', () => {
@@ -275,11 +279,14 @@ async function installDaxta(options = {}) {
275
279
  `file · ${rel}`,
276
280
  ],
277
281
  };
278
- }, { paceMs });
282
+ }, { paceMs, n: 3, of });
279
283
  }
280
284
  }
281
- console.log('');
282
- console.log(` ${ui_1.c.yellow(ui_1.c.bold('?'))} ${ui_1.c.bold('Test script')} ${ui_1.c.dim('— Jest plugin, your script stays the parent')}`);
285
+ else {
286
+ await (0, ui_1.step)('Inject apiDocs(app)', () => 'skipped (--skip-main)', { paceMs, n: 3, of });
287
+ }
288
+ (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')}`);
283
290
  const testScript = await (0, discover_test_1.resolveTestScript)({
284
291
  cwd,
285
292
  scripts: pkg.scripts,
@@ -325,21 +332,21 @@ async function installDaxta(options = {}) {
325
332
  summary: 'hooks in Jest config',
326
333
  details,
327
334
  };
328
- }, { paceMs });
335
+ }, { paceMs, n: 4, of });
329
336
  }
330
337
  else {
331
- await (0, ui_1.step)('Attach test hooks', () => 'skipped', { paceMs });
338
+ await (0, ui_1.step)('Attach test hooks', () => 'skipped', { paceMs, n: 4, of });
332
339
  }
340
+ (0, ui_1.phase)(5, of, 'Docs taste', 'sidebar folders + test titles for the viewer');
333
341
  if (!dryRun) {
334
342
  await (0, tree_1.runTreeWizard)({ embedded: true, yes: Boolean(options.yes) });
335
343
  await (0, titles_1.runTitleCheck)({ cwd, yes: Boolean(options.yes) });
336
344
  }
337
- (0, ui_1.box)('Done', [
338
- `${ui_1.c.green('✔')} DAxTA wired for ${ui_1.c.bold(project)}`,
339
- `${ui_1.c.dim('env')} ${ui_1.c.cyan('DAXTA_DOCS=true')} written (set ${ui_1.c.cyan('false')} to disable /docs)`,
340
- `${ui_1.c.dim('tests')} run your usual script — naming prompts run first, Docs ready at the end`,
341
- `${ui_1.c.dim('names')} ${ui_1.c.cyan('daxta titles')} to re-label TEST_TITLE / it() cases`,
342
- `${ui_1.c.dim('sidebar')} ${ui_1.c.cyan('daxta tree')} anytime to re-arrange folders`,
345
+ (0, ui_1.box)('Ready', [
346
+ `${ui_1.c.mint('✔')} ${ui_1.c.bold(project)} · DAxTA ${ui_1.c.gold(`v${version}`)}`,
347
+ `${ui_1.c.dim('docs')} ${ui_1.c.ice('/docs')} · ${ui_1.c.ice('DAXTA_DOCS=true')}`,
348
+ `${ui_1.c.dim('tests')} same script — titles first, spec after`,
349
+ `${ui_1.c.dim('retune')} ${ui_1.c.ice('daxta tree')} · ${ui_1.c.ice('daxta titles')}`,
343
350
  ]);
344
351
  const wired = testScript && pkg.scripts?.[testScript] ? testScript : null;
345
352
  (0, ui_1.nextSteps)([