@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/inject-main.js
CHANGED
|
@@ -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
|
|
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);
|
|
@@ -104,21 +94,27 @@ async function resolveMainPath(cwd, candidates) {
|
|
|
104
94
|
return full;
|
|
105
95
|
}
|
|
106
96
|
const rel = path.relative(cwd, def);
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
if (!answer
|
|
97
|
+
const shown = candidates.slice(0, 8);
|
|
98
|
+
console.log(` ${ui_1.c.gold('?')} ${ui_1.c.bold('Nest entry')} ${ui_1.c.dim('— apiDocs(app)')}`);
|
|
99
|
+
shown.forEach((file, i) => {
|
|
100
|
+
const r = path.relative(cwd, file);
|
|
101
|
+
const rec = i === 0 ? ui_1.c.dim(' recommended') : '';
|
|
102
|
+
console.log(` ${ui_1.c.ice(String(i + 1))} ${ui_1.c.bold(r)}${rec}`);
|
|
103
|
+
});
|
|
104
|
+
if (candidates.length > shown.length)
|
|
105
|
+
console.log(` ${ui_1.c.dim(`… +${candidates.length - shown.length} more`)}`);
|
|
106
|
+
console.log(` ${ui_1.c.dim('n')} skip`);
|
|
107
|
+
const answer = await (0, ui_1.readlineAsk)(` ${ui_1.c.dim(`Enter = 1 (${rel})`)} ${ui_1.c.dim('·')} ${ui_1.c.dim('or type a path')}\n ${ui_1.c.ice('›')} `);
|
|
108
|
+
if (!answer)
|
|
119
109
|
return def;
|
|
120
110
|
if (/^n(o)?$/i.test(answer))
|
|
121
111
|
return null;
|
|
112
|
+
if (/^\d+$/.test(answer)) {
|
|
113
|
+
const picked = shown[Number(answer) - 1];
|
|
114
|
+
if (!picked)
|
|
115
|
+
throw new Error(`No file #${answer}`);
|
|
116
|
+
return picked;
|
|
117
|
+
}
|
|
122
118
|
const full = path.isAbsolute(answer) ? answer : path.join(cwd, answer);
|
|
123
119
|
if (!(0, fs_1.existsSync)(full))
|
|
124
120
|
throw new Error(`File not found: ${full}`);
|
package/dist/cli/install.js
CHANGED
|
@@ -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 :
|
|
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
|
-
|
|
209
|
+
const of = 5;
|
|
210
|
+
(0, ui_1.splash)({ version, project, dryRun });
|
|
210
211
|
if (paceMs)
|
|
211
|
-
await (0, ui_1.sleep)(
|
|
212
|
-
|
|
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 ?
|
|
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,28 @@ 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
|
-
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)')}`);
|
|
259
261
|
const target = await (0, inject_main_1.resolveMainTarget)({
|
|
260
262
|
cwd,
|
|
261
263
|
yes: options.yes,
|
|
262
264
|
mainPath: options.mainPath,
|
|
263
265
|
});
|
|
264
266
|
if (!target) {
|
|
265
|
-
await (0, ui_1.step)('Inject apiDocs(app)', () => 'skipped', { paceMs });
|
|
267
|
+
await (0, ui_1.step)('Inject apiDocs(app)', () => 'skipped', { paceMs, n: 3, of });
|
|
266
268
|
}
|
|
267
269
|
else {
|
|
268
270
|
await (0, ui_1.step)('Inject apiDocs(app)', () => {
|
|
@@ -275,11 +277,13 @@ async function installDaxta(options = {}) {
|
|
|
275
277
|
`file · ${rel}`,
|
|
276
278
|
],
|
|
277
279
|
};
|
|
278
|
-
}, { paceMs });
|
|
280
|
+
}, { paceMs, n: 3, of });
|
|
279
281
|
}
|
|
280
282
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
+
else {
|
|
284
|
+
await (0, ui_1.step)('Inject apiDocs(app)', () => 'skipped (--skip-main)', { paceMs, n: 3, of });
|
|
285
|
+
}
|
|
286
|
+
(0, ui_1.phase)(4, of, 'Tests', 'Jest plugin — your script stays the parent');
|
|
283
287
|
const testScript = await (0, discover_test_1.resolveTestScript)({
|
|
284
288
|
cwd,
|
|
285
289
|
scripts: pkg.scripts,
|
|
@@ -325,21 +329,21 @@ async function installDaxta(options = {}) {
|
|
|
325
329
|
summary: 'hooks in Jest config',
|
|
326
330
|
details,
|
|
327
331
|
};
|
|
328
|
-
}, { paceMs });
|
|
332
|
+
}, { paceMs, n: 4, of });
|
|
329
333
|
}
|
|
330
334
|
else {
|
|
331
|
-
await (0, ui_1.step)('Attach test hooks', () => 'skipped', { paceMs });
|
|
335
|
+
await (0, ui_1.step)('Attach test hooks', () => 'skipped', { paceMs, n: 4, of });
|
|
332
336
|
}
|
|
337
|
+
(0, ui_1.phase)(5, of, 'Docs taste', 'sidebar folders + test titles for the viewer');
|
|
333
338
|
if (!dryRun) {
|
|
334
339
|
await (0, tree_1.runTreeWizard)({ embedded: true, yes: Boolean(options.yes) });
|
|
335
340
|
await (0, titles_1.runTitleCheck)({ cwd, yes: Boolean(options.yes) });
|
|
336
341
|
}
|
|
337
|
-
(0, ui_1.box)('
|
|
338
|
-
`${ui_1.c.
|
|
339
|
-
`${ui_1.c.dim('
|
|
340
|
-
`${ui_1.c.dim('tests')}
|
|
341
|
-
`${ui_1.c.dim('
|
|
342
|
-
`${ui_1.c.dim('sidebar')} ${ui_1.c.cyan('daxta tree')} anytime to re-arrange folders`,
|
|
342
|
+
(0, ui_1.box)('Ready', [
|
|
343
|
+
`${ui_1.c.mint('✔')} ${ui_1.c.bold(project)} · DAxTA ${ui_1.c.gold(`v${version}`)}`,
|
|
344
|
+
`${ui_1.c.dim('docs')} ${ui_1.c.ice('/docs')} · ${ui_1.c.ice('DAXTA_DOCS=true')}`,
|
|
345
|
+
`${ui_1.c.dim('tests')} same script — titles first, spec after`,
|
|
346
|
+
`${ui_1.c.dim('retune')} ${ui_1.c.ice('daxta tree')} · ${ui_1.c.ice('daxta titles')}`,
|
|
343
347
|
]);
|
|
344
348
|
const wired = testScript && pkg.scripts?.[testScript] ? testScript : null;
|
|
345
349
|
(0, ui_1.nextSteps)([
|
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);
|
package/dist/cli/titles.js
CHANGED
|
@@ -1,44 +1,41 @@
|
|
|
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 title, or s to skip')}`);
|
|
17
|
+
}
|
|
25
18
|
suggestions.forEach((name, index) => {
|
|
26
|
-
const mark = index === 0 ? ui_1.c.dim('
|
|
27
|
-
console.log(` ${ui_1.c.
|
|
19
|
+
const mark = index === 0 ? ui_1.c.dim(' recommended') : '';
|
|
20
|
+
console.log(` ${ui_1.c.ice(String(index + 1))} ${name}${mark}`);
|
|
28
21
|
});
|
|
29
|
-
console.log(
|
|
30
|
-
|
|
22
|
+
console.log(suggestions.length
|
|
23
|
+
? ` ${ui_1.c.dim('Enter = 1')} ${ui_1.c.dim('·')} ${ui_1.c.ice('a')} remaining auto ${ui_1.c.dim('·')} ${ui_1.c.ice('s')} skip ${ui_1.c.dim('·')} ${ui_1.c.ice('c')} custom`
|
|
24
|
+
: ` ${ui_1.c.ice('c')} custom ${ui_1.c.dim('·')} ${ui_1.c.ice('s')} skip`);
|
|
25
|
+
const answer = (await (0, ui_1.readlineAsk)(` ${ui_1.c.ice('›')} `)).trim();
|
|
31
26
|
const lower = answer.toLowerCase();
|
|
32
|
-
if (!answer
|
|
27
|
+
if (!answer)
|
|
28
|
+
return suggestions[0] ? suggestions[0] : 'skip';
|
|
29
|
+
if (lower === 's')
|
|
33
30
|
return 'skip';
|
|
34
31
|
if (lower === 'a' || lower === 'all')
|
|
35
32
|
return 'all';
|
|
36
33
|
if (lower === 'y' || lower === 'yes')
|
|
37
|
-
return suggestions[0]
|
|
34
|
+
return suggestions[0] ? suggestions[0] : 'skip';
|
|
38
35
|
if (lower === 'c') {
|
|
39
|
-
const custom = await
|
|
36
|
+
const custom = await (0, ui_1.readlineAsk)(` ${ui_1.c.dim('text')} ${ui_1.c.ice('›')} `);
|
|
40
37
|
if (!validate(custom)) {
|
|
41
|
-
console.log(` ${ui_1.c.
|
|
38
|
+
console.log(` ${ui_1.c.gold('!')} does not match the format — skipped`);
|
|
42
39
|
return 'skip';
|
|
43
40
|
}
|
|
44
41
|
return custom;
|
|
@@ -51,6 +48,8 @@ async function pickFromSuggestions(finding, extra, validate) {
|
|
|
51
48
|
return 'skip';
|
|
52
49
|
}
|
|
53
50
|
function writeTitle(cwd, finding) {
|
|
51
|
+
if (!finding.auto)
|
|
52
|
+
return false;
|
|
54
53
|
const name = finding.suggestions[0];
|
|
55
54
|
if (!name || !(0, test_title_1.isHumanOperationTitle)(name))
|
|
56
55
|
return false;
|
|
@@ -65,9 +64,14 @@ function writeIt(cwd, finding) {
|
|
|
65
64
|
function applyAllRecommended(cwd, titles, cases, fromTitleIndex, fromCaseIndex) {
|
|
66
65
|
let written = 0;
|
|
67
66
|
let skipped = 0;
|
|
67
|
+
const pending = [];
|
|
68
68
|
for (let i = fromTitleIndex; i < titles.length; i += 1) {
|
|
69
|
+
if (!titles[i].auto || !titles[i].suggestions[0]) {
|
|
70
|
+
pending.push(titles[i]);
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
69
73
|
if (writeTitle(cwd, titles[i])) {
|
|
70
|
-
console.log(` ${ui_1.c.
|
|
74
|
+
console.log(` ${ui_1.c.mint('✔')} ${titles[i].suggestions[0]} ${ui_1.c.dim(titles[i].file + ':' + titles[i].line)}`);
|
|
71
75
|
written += 1;
|
|
72
76
|
}
|
|
73
77
|
else
|
|
@@ -76,13 +80,13 @@ function applyAllRecommended(cwd, titles, cases, fromTitleIndex, fromCaseIndex)
|
|
|
76
80
|
const caseStart = fromTitleIndex < titles.length ? 0 : fromCaseIndex;
|
|
77
81
|
for (let i = caseStart; i < cases.length; i += 1) {
|
|
78
82
|
if (writeIt(cwd, cases[i])) {
|
|
79
|
-
console.log(` ${ui_1.c.
|
|
83
|
+
console.log(` ${ui_1.c.mint('✔')} ${cases[i].suggestions[0]} ${ui_1.c.dim(cases[i].file + ':' + cases[i].line)}`);
|
|
80
84
|
written += 1;
|
|
81
85
|
}
|
|
82
86
|
else
|
|
83
87
|
skipped += 1;
|
|
84
88
|
}
|
|
85
|
-
return { written, skipped };
|
|
89
|
+
return { written, skipped, pending };
|
|
86
90
|
}
|
|
87
91
|
async function runTitleCheck(options) {
|
|
88
92
|
const cwd = options.cwd ?? process.cwd();
|
|
@@ -91,7 +95,7 @@ async function runTitleCheck(options) {
|
|
|
91
95
|
if (!total) {
|
|
92
96
|
if (!options.checkOnly) {
|
|
93
97
|
(0, ui_1.banner)('Test naming', 'titles + it() cases');
|
|
94
|
-
console.log(` ${ui_1.c.
|
|
98
|
+
console.log(` ${ui_1.c.mint('✔')} nothing to fix`);
|
|
95
99
|
console.log('');
|
|
96
100
|
}
|
|
97
101
|
return 0;
|
|
@@ -101,18 +105,27 @@ async function runTitleCheck(options) {
|
|
|
101
105
|
(0, ui_1.banner)('Test naming', 'applying recommended titles + it() names');
|
|
102
106
|
const result = applyAllRecommended(cwd, report.titles, report.cases, 0, 0);
|
|
103
107
|
console.log('');
|
|
104
|
-
console.log(` ${ui_1.c.
|
|
105
|
-
|
|
106
|
-
|
|
108
|
+
console.log(` ${ui_1.c.mint('✔')} ${result.written} updated ${ui_1.c.dim(`${result.skipped} skipped`)}`);
|
|
109
|
+
if (result.pending.length) {
|
|
110
|
+
console.log('');
|
|
111
|
+
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')}`);
|
|
112
|
+
for (const item of result.pending) {
|
|
113
|
+
console.log(` ${ui_1.c.ice(item.file)}${ui_1.c.dim(`:${item.line}`)} ${ui_1.c.dim(item.path + ' [' + item.method + ']')}`);
|
|
114
|
+
}
|
|
115
|
+
console.log(` ${ui_1.c.dim('Set those with')} ${ui_1.c.ice('daxta titles')} ${ui_1.c.dim('→ c (custom)')}`);
|
|
116
|
+
console.log('');
|
|
117
|
+
}
|
|
118
|
+
const leftover = result.skipped + result.pending.length;
|
|
119
|
+
return leftover > 0 && options.strict ? 1 : leftover > 0 ? 1 : 0;
|
|
107
120
|
}
|
|
108
121
|
if (options.checkOnly || options.yes || !process.stdin.isTTY) {
|
|
109
122
|
(0, scan_1.printNamingFindings)(report, ui_1.c);
|
|
110
123
|
return options.strict ? 1 : 0;
|
|
111
124
|
}
|
|
112
125
|
(0, ui_1.banner)('Test naming', 'runs before Jest — docs / Postman labels');
|
|
113
|
-
console.log(` ${ui_1.c.dim('Title')} Create Mock Tbs /v1/admin/mock-tbs
|
|
126
|
+
console.log(` ${ui_1.c.dim('Title')} Create Mock Tbs — POST /v1/admin/mock-tbs`);
|
|
114
127
|
console.log(` ${ui_1.c.dim('it()')} creates mock tbs when payload is valid`);
|
|
115
|
-
console.log(` ${ui_1.c.
|
|
128
|
+
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.`);
|
|
116
129
|
let written = 0;
|
|
117
130
|
let skipped = 0;
|
|
118
131
|
for (let i = 0; i < report.titles.length; i += 1) {
|
|
@@ -122,8 +135,21 @@ async function runTitleCheck(options) {
|
|
|
122
135
|
const rest = applyAllRecommended(cwd, report.titles, report.cases, i, 0);
|
|
123
136
|
written += rest.written;
|
|
124
137
|
skipped += rest.skipped;
|
|
138
|
+
for (const pending of rest.pending) {
|
|
139
|
+
const customChoice = await pickFromSuggestions(pending, `docs would show ${pending.path} — custom title required`, test_title_1.isHumanOperationTitle);
|
|
140
|
+
if (!customChoice || customChoice === 'skip' || customChoice === 'all') {
|
|
141
|
+
skipped += 1;
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
if ((0, scan_1.applyTitle)(cwd, pending, customChoice)) {
|
|
145
|
+
console.log(` ${ui_1.c.mint('✔')} ${customChoice}`);
|
|
146
|
+
written += 1;
|
|
147
|
+
}
|
|
148
|
+
else
|
|
149
|
+
skipped += 1;
|
|
150
|
+
}
|
|
125
151
|
console.log('');
|
|
126
|
-
console.log(` ${ui_1.c.
|
|
152
|
+
console.log(` ${ui_1.c.mint('✔')} ${written} updated ${ui_1.c.dim(`${skipped} skipped`)}`);
|
|
127
153
|
console.log('');
|
|
128
154
|
return options.strict && skipped > 0 ? 1 : 0;
|
|
129
155
|
}
|
|
@@ -132,11 +158,11 @@ async function runTitleCheck(options) {
|
|
|
132
158
|
continue;
|
|
133
159
|
}
|
|
134
160
|
if ((0, scan_1.applyTitle)(cwd, finding, choice)) {
|
|
135
|
-
console.log(` ${ui_1.c.
|
|
161
|
+
console.log(` ${ui_1.c.mint('✔')} ${choice}`);
|
|
136
162
|
written += 1;
|
|
137
163
|
}
|
|
138
164
|
else {
|
|
139
|
-
console.log(` ${ui_1.c.
|
|
165
|
+
console.log(` ${ui_1.c.gold('!')} could not rewrite that line — skipped`);
|
|
140
166
|
skipped += 1;
|
|
141
167
|
}
|
|
142
168
|
}
|
|
@@ -154,16 +180,16 @@ async function runTitleCheck(options) {
|
|
|
154
180
|
continue;
|
|
155
181
|
}
|
|
156
182
|
if ((0, scan_1.applyItCase)(cwd, finding, choice)) {
|
|
157
|
-
console.log(` ${ui_1.c.
|
|
183
|
+
console.log(` ${ui_1.c.mint('✔')} ${choice}`);
|
|
158
184
|
written += 1;
|
|
159
185
|
}
|
|
160
186
|
else {
|
|
161
|
-
console.log(` ${ui_1.c.
|
|
187
|
+
console.log(` ${ui_1.c.gold('!')} could not rewrite that line — skipped`);
|
|
162
188
|
skipped += 1;
|
|
163
189
|
}
|
|
164
190
|
}
|
|
165
191
|
console.log('');
|
|
166
|
-
console.log(` ${ui_1.c.
|
|
192
|
+
console.log(` ${ui_1.c.mint('✔')} ${written} updated ${ui_1.c.dim(`${skipped} skipped`)}`);
|
|
167
193
|
console.log('');
|
|
168
194
|
return options.strict && skipped > 0 ? 1 : 0;
|
|
169
195
|
}
|