quiesco 0.2.0 → 0.3.0

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.
Files changed (42) hide show
  1. package/README.md +3 -1
  2. package/dist/cli.d.ts +1 -1
  3. package/dist/cli.d.ts.map +1 -1
  4. package/dist/cli.js +10 -0
  5. package/dist/cli.js.map +1 -1
  6. package/dist/commands/list.d.ts +16 -0
  7. package/dist/commands/list.d.ts.map +1 -0
  8. package/dist/commands/list.js +56 -0
  9. package/dist/commands/list.js.map +1 -0
  10. package/dist/commands/test.d.ts +20 -1
  11. package/dist/commands/test.d.ts.map +1 -1
  12. package/dist/commands/test.js +14 -6
  13. package/dist/commands/test.js.map +1 -1
  14. package/dist/commands/ui.d.ts +43 -0
  15. package/dist/commands/ui.d.ts.map +1 -0
  16. package/dist/commands/ui.js +121 -0
  17. package/dist/commands/ui.js.map +1 -0
  18. package/dist/context.d.ts +20 -0
  19. package/dist/context.d.ts.map +1 -1
  20. package/dist/context.js +30 -0
  21. package/dist/context.js.map +1 -1
  22. package/dist/progress/render.d.ts +31 -0
  23. package/dist/progress/render.d.ts.map +1 -0
  24. package/dist/progress/render.js +89 -0
  25. package/dist/progress/render.js.map +1 -0
  26. package/dist/progress/run.d.ts +24 -0
  27. package/dist/progress/run.d.ts.map +1 -0
  28. package/dist/progress/run.js +95 -0
  29. package/dist/progress/run.js.map +1 -0
  30. package/dist/progress/sticky.d.ts +25 -0
  31. package/dist/progress/sticky.d.ts.map +1 -0
  32. package/dist/progress/sticky.js +90 -0
  33. package/dist/progress/sticky.js.map +1 -0
  34. package/package.json +3 -3
  35. package/src/cli.ts +10 -0
  36. package/src/commands/list.ts +65 -0
  37. package/src/commands/test.ts +17 -7
  38. package/src/commands/ui.ts +152 -0
  39. package/src/context.ts +47 -0
  40. package/src/progress/render.ts +117 -0
  41. package/src/progress/run.ts +105 -0
  42. package/src/progress/sticky.ts +95 -0
@@ -0,0 +1,31 @@
1
+ /**
2
+ * The progress bar line of `quiesco test`, from a RunState. Pure (no terminal access) so it can be
3
+ * unit-tested:
4
+ *
5
+ * ▕██████████░░░░░░░░░░▏ 12/30 ✓10 ✗1 ↷1 2m13s ▶ adds a todo
6
+ *
7
+ * - `~30`: the total is an estimate (Vitest) or still growing (Jest).
8
+ * - Several workers: `▶ 1:adds a todo · 2:edits a todo` (worker numbers from 1).
9
+ * - Fits in `width` columns (CJK characters count as two).
10
+ */
11
+ import type { RunState } from '@quiesco/core';
12
+ export interface RenderOptions {
13
+ width: number;
14
+ color: boolean;
15
+ /** Bar cells (default 20). */
16
+ barWidth?: number;
17
+ /**
18
+ * When the runner was started (epoch ms): the time shown counts from there, so it includes starting the
19
+ * device and the app. Default: from the first test.
20
+ */
21
+ since?: number;
22
+ now?: () => number;
23
+ }
24
+ export declare function stripAnsi(text: string): string;
25
+ /** Terminal columns taken by `text` (ANSI escapes take none). */
26
+ export declare function textWidth(text: string): number;
27
+ /** Cut plain text (no ANSI) to `width` columns, ending with … when cut. */
28
+ export declare function truncate(text: string, width: number): string;
29
+ export declare function formatDuration(ms: number): string;
30
+ export declare function renderBar(state: RunState, options: RenderOptions): string;
31
+ //# sourceMappingURL=render.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/progress/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,8BAA8B;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAKD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9C;AAiBD,iEAAiE;AACjE,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQ9C;AAED,2EAA2E;AAC3E,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAY5D;AAED,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAMjD;AAID,wBAAgB,SAAS,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,CAiCzE"}
@@ -0,0 +1,89 @@
1
+ // eslint-disable-next-line no-control-regex -- ANSI escape sequences start with ESC
2
+ const ANSI = /\u001b\[[0-9;?]*[ -/]*[@-~]/g;
3
+ export function stripAnsi(text) {
4
+ return text.replace(ANSI, '');
5
+ }
6
+ /** East Asian wide and fullwidth characters, and emoji, take two columns. */
7
+ function isWide(code) {
8
+ return ((code >= 0x1100 && code <= 0x115f) ||
9
+ (code >= 0x2e80 && code <= 0xa4cf && code !== 0x303f) ||
10
+ (code >= 0xac00 && code <= 0xd7a3) ||
11
+ (code >= 0xf900 && code <= 0xfaff) ||
12
+ (code >= 0xfe30 && code <= 0xfe4f) ||
13
+ (code >= 0xff00 && code <= 0xff60) ||
14
+ (code >= 0xffe0 && code <= 0xffe6) ||
15
+ (code >= 0x1f300 && code <= 0x1faff) ||
16
+ (code >= 0x20000 && code <= 0x3fffd));
17
+ }
18
+ /** Terminal columns taken by `text` (ANSI escapes take none). */
19
+ export function textWidth(text) {
20
+ let w = 0;
21
+ for (const ch of stripAnsi(text)) {
22
+ const code = ch.codePointAt(0) ?? 0;
23
+ if (code < 0x20 || (code >= 0x7f && code < 0xa0) || (code >= 0x300 && code <= 0x36f) || code === 0x200d || (code >= 0xfe00 && code <= 0xfe0f))
24
+ continue;
25
+ w += isWide(code) ? 2 : 1;
26
+ }
27
+ return w;
28
+ }
29
+ /** Cut plain text (no ANSI) to `width` columns, ending with … when cut. */
30
+ export function truncate(text, width) {
31
+ if (width <= 0)
32
+ return '';
33
+ if (textWidth(text) <= width)
34
+ return text;
35
+ let out = '';
36
+ let w = 0;
37
+ for (const ch of text) {
38
+ const cw = textWidth(ch);
39
+ if (w + cw > width - 1)
40
+ break;
41
+ out += ch;
42
+ w += cw;
43
+ }
44
+ return `${out}…`;
45
+ }
46
+ export function formatDuration(ms) {
47
+ const s = Math.floor(ms / 1000);
48
+ if (s < 60)
49
+ return `${s}s`;
50
+ const m = Math.floor(s / 60);
51
+ if (m < 60)
52
+ return `${m}m${String(s % 60).padStart(2, '0')}s`;
53
+ return `${Math.floor(m / 60)}h${String(m % 60).padStart(2, '0')}m`;
54
+ }
55
+ const paint = (on, code, text) => (on ? `\u001b[${code}m${text}\u001b[0m` : text);
56
+ export function renderBar(state, options) {
57
+ const { width, color } = options;
58
+ const cells = options.barWidth ?? 20;
59
+ if (state.phase === 'idle')
60
+ return truncate('quiesco: waiting for the test runner…', width - 1);
61
+ const total = state.total;
62
+ const done = state.done;
63
+ const ratio = total > 0 ? Math.min(1, done / total) : 0;
64
+ const filled = Math.round(ratio * cells);
65
+ const failed = state.counts.failed > 0 || state.fileErrors.size > 0 || state.runErrors.length > 0;
66
+ const bar = `▕${paint(color, failed ? '31' : '32', '█'.repeat(filled))}${paint(color, '2', '░'.repeat(cells - filled))}▏`;
67
+ const totalText = `${state.totalIsApproximate ? '~' : ''}${total}`;
68
+ const c = state.counts;
69
+ const skipped = c.skipped + c.pending + c.todo + c.undefined + c.notRun;
70
+ const parts = [
71
+ `${bar} ${done}/${totalText}`,
72
+ [paint(color, '32', `✓${c.passed}`), ...(c.failed > 0 ? [paint(color, '31', `✗${c.failed}`)] : []), ...(skipped > 0 ? [paint(color, '33', `↷${skipped}`)] : [])].join(' '),
73
+ formatDuration(options.since !== undefined ? Math.max(0, (state.endedAt ?? (options.now ?? Date.now)()) - options.since) : state.elapsedMs),
74
+ ];
75
+ let line = parts.join(' ');
76
+ // What is running now, in the space left.
77
+ const room = width - 1 - textWidth(line) - 4;
78
+ if (state.phase === 'running' && state.running.size > 0 && room > 8) {
79
+ const running = [...state.running.values()].sort((a, b) => (a.worker ?? 0) - (b.worker ?? 0));
80
+ const many = running.length > 1;
81
+ const text = running.map((r) => `${many && r.worker !== undefined ? `${r.worker + 1}:` : ''}${r.test.name}`).join(' · ');
82
+ line += ` ${paint(color, '36', '▶')} ${truncate(text, room)}`;
83
+ }
84
+ else if (state.phase === 'ended') {
85
+ line += ` ${state.interrupted ? paint(color, '33', 'interrupted') : state.success === true ? paint(color, '32', 'passed') : paint(color, '31', 'failed')}`;
86
+ }
87
+ return textWidth(line) <= width - 1 ? line : truncate(stripAnsi(line), width - 1);
88
+ }
89
+ //# sourceMappingURL=render.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.js","sourceRoot":"","sources":["../../src/progress/render.ts"],"names":[],"mappings":"AAyBA,oFAAoF;AACpF,MAAM,IAAI,GAAG,8BAA8B,CAAC;AAE5C,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AAChC,CAAC;AAED,6EAA6E;AAC7E,SAAS,MAAM,CAAC,IAAY;IAC1B,OAAO,CACL,CAAC,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,CAAC;QAClC,CAAC,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,KAAK,MAAM,CAAC;QACrD,CAAC,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,CAAC;QAClC,CAAC,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,CAAC;QAClC,CAAC,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,CAAC;QAClC,CAAC,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,CAAC;QAClC,CAAC,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,CAAC;QAClC,CAAC,IAAI,IAAI,OAAO,IAAI,IAAI,IAAI,OAA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CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzH,IAAI,IAAI,KAAK,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;IACjE,CAAC;SAAM,IAAI,KAAK,CAAC,KAAK,KAAK,OAAO,EAAE,CAAC;QACnC,IAAI,IAAI,KAAK,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,CAAC;IAC9J,CAAC;IACD,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;AACpF,CAAC"}
@@ -0,0 +1,24 @@
1
+ import type { CliContext, Terminal } from '../context.js';
2
+ export type RunnerName = 'cucumber' | 'jest' | 'vitest';
3
+ /**
4
+ * Whether to show the bar: a terminal, not CI, not turned off (`--no-progress`, QUIESCO_PROGRESS=0).
5
+ */
6
+ export declare function progressWanted(ctx: CliContext, noProgressFlag: boolean): ctx is CliContext & {
7
+ terminal: Terminal;
8
+ };
9
+ /**
10
+ * The cucumber-js arguments that add Quiesco's events formatter, from the project's own
11
+ * @quiesco/cucumber; [] when it is not installed. The file target keeps the user's stdout formatter
12
+ * (a format without one would replace it).
13
+ */
14
+ export declare function cucumberFormatArgs(ctx: CliContext): string[];
15
+ export interface ProgressRun {
16
+ command: string;
17
+ args: readonly string[];
18
+ env: NodeJS.ProcessEnv;
19
+ runner: RunnerName;
20
+ }
21
+ export declare function runWithProgress(ctx: CliContext & {
22
+ terminal: Terminal;
23
+ }, run: ProgressRun): Promise<number>;
24
+ //# sourceMappingURL=run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/progress/run.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAI1D,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,MAAM,GAAG,QAAQ,CAAC;AAKxD;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,UAAU,EAAE,cAAc,EAAE,OAAO,GAAG,GAAG,IAAI,UAAU,GAAG;IAAE,QAAQ,EAAE,QAAQ,CAAA;CAAE,CAMnH;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,UAAU,GAAG,MAAM,EAAE,CAS5D;AAQD,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACxB,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IACvB,MAAM,EAAE,UAAU,CAAC;CACpB;AAED,wBAAsB,eAAe,CAAC,GAAG,EAAE,UAAU,GAAG;IAAE,QAAQ,EAAE,QAAQ,CAAA;CAAE,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CA6CjH"}
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Run the test runner with the progress bar (P3): a run-events socket the runner's Quiesco reporter
3
+ * connects to (QUIESCO_EVENTS), the runner's output piped through so the bar stays on the last line.
4
+ */
5
+ import os from 'node:os';
6
+ import path from 'node:path';
7
+ import { pathToFileURL } from 'node:url';
8
+ import { RunEventServer, RunState } from '@quiesco/core';
9
+ import { renderBar } from './render.js';
10
+ import { StickyTerminal } from './sticky.js';
11
+ /** Redraw at most this often for events; the clock ticks once a second. */
12
+ const FRAME_MS = 80;
13
+ /**
14
+ * Whether to show the bar: a terminal, not CI, not turned off (`--no-progress`, QUIESCO_PROGRESS=0).
15
+ */
16
+ export function progressWanted(ctx, noProgressFlag) {
17
+ if (noProgressFlag || ctx.terminal === null)
18
+ return false;
19
+ const env = ctx.env;
20
+ if (env['QUIESCO_PROGRESS'] === '0' || env['QUIESCO_PROGRESS'] === 'false')
21
+ return false;
22
+ const ci = env['CI'];
23
+ return ci === undefined || ci === '' || ci === '0' || ci === 'false';
24
+ }
25
+ /**
26
+ * The cucumber-js arguments that add Quiesco's events formatter, from the project's own
27
+ * @quiesco/cucumber; [] when it is not installed. The file target keeps the user's stdout formatter
28
+ * (a format without one would replace it).
29
+ */
30
+ export function cucumberFormatArgs(ctx) {
31
+ const file = ctx.resolveFrom(ctx.cwd, '@quiesco/cucumber/events');
32
+ if (file === null)
33
+ return [];
34
+ const url = pathToFileURL(file).href;
35
+ // Windows: a temp file (cucumber creates the target's directory, which fails for the null device).
36
+ const target = ctx.platform === 'win32' ? path.join(os.tmpdir(), `quiesco-events-${process.pid}.out`) : '/dev/null';
37
+ const descriptor = `"${url}":"${target}"`;
38
+ // Through cmd.exe (Windows runs npx with a shell) the quotes must survive the argument parsing.
39
+ return ['--format', ctx.platform === 'win32' ? `"${descriptor.replaceAll('"', '\\"')}"` : descriptor];
40
+ }
41
+ const HINTS = {
42
+ cucumber: "quiesco: no test progress was received. Install @quiesco/cucumber in this project (quiesco test adds its formatter by itself).",
43
+ vitest: "quiesco: no test progress was received. Add quiescoPlugin() to your Vitest config: `import { quiesco, quiescoPlugin } from '@quiesco/vitest/config'` and `plugins: [quiescoPlugin()]`.",
44
+ jest: "quiesco: no test progress was received. Your Jest config replaces the preset's reporters: add '@quiesco/jest/reporter' to `reporters` (next to 'default').",
45
+ };
46
+ export async function runWithProgress(ctx, run) {
47
+ const term = ctx.terminal;
48
+ const state = new RunState();
49
+ const since = Date.now();
50
+ const sticky = new StickyTerminal({ write: term.stdout, columns: term.columns });
51
+ const draw = () => sticky.setBar(renderBar(state, { width: term.columns(), color: term.color, since }));
52
+ let frame = null;
53
+ const schedule = () => {
54
+ frame ??= setTimeout(() => {
55
+ frame = null;
56
+ draw();
57
+ }, FRAME_MS);
58
+ };
59
+ const server = new RunEventServer({
60
+ onEvent: (event) => {
61
+ state.apply(event);
62
+ schedule();
63
+ },
64
+ });
65
+ await server.listen();
66
+ const clock = setInterval(draw, 1000);
67
+ clock.unref();
68
+ const offInterrupt = term.onInterrupt(() => sticky.stop());
69
+ draw();
70
+ const env = { ...run.env, ...server.env() };
71
+ // The runner's output is a pipe now: keep its colors and width as on the terminal.
72
+ if (term.color && env['FORCE_COLOR'] === undefined && env['NO_COLOR'] === undefined)
73
+ env['FORCE_COLOR'] = '1';
74
+ if (env['COLUMNS'] === undefined)
75
+ env['COLUMNS'] = String(term.columns());
76
+ let code;
77
+ try {
78
+ code = await ctx.runPiped(run.command, run.args, { cwd: ctx.cwd, env, onStdout: (c) => sticky.output(c, term.stdout), onStderr: (c) => sticky.output(c, term.stderr) });
79
+ await server.drain();
80
+ }
81
+ finally {
82
+ clearInterval(clock);
83
+ if (frame !== null)
84
+ clearTimeout(frame);
85
+ offInterrupt();
86
+ await server.close();
87
+ }
88
+ state.runnerExited(code);
89
+ const received = server.hellos.length > 0;
90
+ sticky.stop(received ? renderBar(state, { width: term.columns(), color: term.color, since }) : undefined);
91
+ if (!received)
92
+ ctx.err(HINTS[run.runner]);
93
+ return code;
94
+ }
95
+ //# sourceMappingURL=run.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/progress/run.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CA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M,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;YAAS,CAAC;QACT,aAAa,CAAC,KAAK,CAAC,CAAC;QACrB,IAAI,KAAK,KAAK,IAAI;YAAE,YAAY,CAAC,KAAK,CAAC,CAAC;QACxC,YAAY,EAAE,CAAC;QACf,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;IACD,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IACzB,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IAC1C,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAC1G,IAAI,CAAC,QAAQ;QAAE,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IAC1C,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,25 @@
1
+ export interface StickyOutput {
2
+ /** Writes escape sequences and the bottom region (stdout). */
3
+ write(text: string): void;
4
+ /** Current terminal width. */
5
+ columns(): number;
6
+ }
7
+ export declare class StickyTerminal {
8
+ private readonly out;
9
+ private partial;
10
+ private bar;
11
+ private drawnRows;
12
+ private stopped;
13
+ constructor(out: StickyOutput);
14
+ /** The child wrote `chunk` (to stdout or stderr: `write` is that stream). */
15
+ output(chunk: string, write: (text: string) => void): void;
16
+ /** Show `line` as the status line (no wider than the terminal). */
17
+ setBar(line: string): void;
18
+ /** Remove the region; write the unfinished line back, then `finalLine` (if any) as plain output. */
19
+ stop(finalLine?: string): void;
20
+ private visiblePartial;
21
+ private rows;
22
+ private draw;
23
+ private erase;
24
+ }
25
+ //# sourceMappingURL=sticky.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sticky.d.ts","sourceRoot":"","sources":["../../src/progress/sticky.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,YAAY;IAC3B,8DAA8D;IAC9D,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,8BAA8B;IAC9B,OAAO,IAAI,MAAM,CAAC;CACnB;AAED,qBAAa,cAAc;IAMb,OAAO,CAAC,QAAQ,CAAC,GAAG;IALhC,OAAO,CAAC,OAAO,CAAM;IACrB,OAAO,CAAC,GAAG,CAAM;IACjB,OAAO,CAAC,SAAS,CAAK;IACtB,OAAO,CAAC,OAAO,CAAS;gBAEK,GAAG,EAAE,YAAY;IAE9C,6EAA6E;IAC7E,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI;IAiB1D,mEAAmE;IACnE,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAO1B,oGAAoG;IACpG,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI;IAU9B,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,IAAI;IAKZ,OAAO,CAAC,IAAI;IAeZ,OAAO,CAAC,KAAK;CAMd"}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Keeps one status line at the bottom of the terminal while a child's output scrolls above it.
3
+ *
4
+ * The bottom region is [the child's current unfinished line, if any] + [the status line]. Before the
5
+ * child's output is written the region is erased (cursor up, clear to the end of the screen); complete
6
+ * lines are written; the region is drawn again. An unfinished line (cucumber's progress dots
7
+ * `....F..`) stays visible above the bar and is completed in place by later output.
8
+ */
9
+ import { textWidth } from './render.js';
10
+ export class StickyTerminal {
11
+ out;
12
+ partial = '';
13
+ bar = '';
14
+ drawnRows = 0;
15
+ stopped = false;
16
+ constructor(out) {
17
+ this.out = out;
18
+ }
19
+ /** The child wrote `chunk` (to stdout or stderr: `write` is that stream). */
20
+ output(chunk, write) {
21
+ if (this.stopped) {
22
+ write(chunk);
23
+ return;
24
+ }
25
+ this.erase();
26
+ const text = this.partial + chunk;
27
+ const nl = text.lastIndexOf('\n');
28
+ if (nl === -1) {
29
+ this.partial = text;
30
+ }
31
+ else {
32
+ write(text.slice(0, nl + 1));
33
+ this.partial = text.slice(nl + 1);
34
+ }
35
+ this.draw();
36
+ }
37
+ /** Show `line` as the status line (no wider than the terminal). */
38
+ setBar(line) {
39
+ if (this.stopped || line === this.bar)
40
+ return;
41
+ this.erase();
42
+ this.bar = line;
43
+ this.draw();
44
+ }
45
+ /** Remove the region; write the unfinished line back, then `finalLine` (if any) as plain output. */
46
+ stop(finalLine) {
47
+ if (this.stopped)
48
+ return;
49
+ this.erase();
50
+ this.stopped = true;
51
+ let tail = this.partial;
52
+ this.partial = '';
53
+ if (finalLine !== undefined)
54
+ tail += `${tail === '' ? '' : '\n'}${finalLine}\n`;
55
+ if (tail !== '')
56
+ this.out.write(tail);
57
+ }
58
+ visiblePartial() {
59
+ // A carriage return inside the unfinished line rewrites it from the start, as a terminal would.
60
+ const cr = this.partial.lastIndexOf('\r');
61
+ return cr === -1 ? this.partial : this.partial.slice(cr + 1);
62
+ }
63
+ rows(text) {
64
+ const cols = Math.max(1, this.out.columns());
65
+ return Math.max(1, Math.ceil(textWidth(text) / cols));
66
+ }
67
+ draw() {
68
+ const partial = this.visiblePartial();
69
+ if (partial === '' && this.bar === '')
70
+ return;
71
+ let text = '';
72
+ let rows = 0;
73
+ if (partial !== '') {
74
+ text += `${partial}\n`;
75
+ rows += this.rows(partial);
76
+ }
77
+ text += this.bar;
78
+ rows += 1;
79
+ this.out.write(text);
80
+ this.drawnRows = rows;
81
+ }
82
+ erase() {
83
+ if (this.drawnRows === 0)
84
+ return;
85
+ const up = this.drawnRows - 1;
86
+ this.out.write(`\r${up > 0 ? `\u001b[${up}A` : ''}\u001b[0J`);
87
+ this.drawnRows = 0;
88
+ }
89
+ }
90
+ //# sourceMappingURL=sticky.js.map
@@ -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AAG,EAAE,CAAC;QACd,IAAI,IAAI,GAAG,CAAC,CAAC;QACb,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC;YACnB,IAAI,IAAI,GAAG,OAAO,IAAI,CAAC;YACvB,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC7B,CAAC;QACD,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC;QACjB,IAAI,IAAI,CAAC,CAAC;QACV,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;IAEO,KAAK;QACX,IAAI,IAAI,CAAC,SAAS,KAAK,CAAC;YAAE,OAAO;QACjC,MAAM,EAAE,GAAG,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;QAC9B,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;QAC9D,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;IACrB,CAAC;CACF"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "quiesco",
3
- "version": "0.2.0",
4
- "description": "Quiesco command line: init, test, doctor, tree",
3
+ "version": "0.3.0",
4
+ "description": "Quiesco command line: init, test (with a progress bar), ui, list, doctor, tree",
5
5
  "license": "MIT",
6
6
  "author": "h2nology",
7
7
  "keywords": [
@@ -44,7 +44,7 @@
44
44
  "src"
45
45
  ],
46
46
  "dependencies": {
47
- "@quiesco/core": "0.2.0"
47
+ "@quiesco/core": "0.3.0"
48
48
  },
49
49
  "scripts": {
50
50
  "build": "tsc -b",
package/src/cli.ts CHANGED
@@ -5,8 +5,10 @@ import { buildCommand } from './commands/build.js';
5
5
  import { devicesCommand } from './commands/devices.js';
6
6
  import { doctorCommand } from './commands/doctor.js';
7
7
  import { initCommand } from './commands/init.js';
8
+ import { listCommand } from './commands/list.js';
8
9
  import { testCommand } from './commands/test.js';
9
10
  import { treeCommand } from './commands/tree.js';
11
+ import { uiCommand } from './commands/ui.js';
10
12
  import type { CliContext } from './context.js';
11
13
  import { defaultContext } from './context.js';
12
14
 
@@ -19,6 +21,10 @@ Commands:
19
21
  ios|android --force (also when the native inputs did not change)
20
22
  test Run the tests with cucumber-js (or --runner jest|vitest); other arguments go to the runner unchanged
21
23
  --platform ios|android|web --workers N (N devices in parallel) (quiesco test --help for more)
24
+ ui Open the test UI: run tests from the browser and watch them live (needs @quiesco/ui)
25
+ --platform ios|android|web --runner … --port N --no-open
26
+ list List the tests the runner would run, without running them
27
+ --runner cucumber|jest|vitest --json
22
28
  doctor Check the tools and the project setup
23
29
  --platform ios|android|web
24
30
  tree Print the element tree of the running app (to find testIDs)
@@ -45,6 +51,10 @@ export async function main(argv: readonly string[], ctx: CliContext = defaultCon
45
51
  return await buildCommand(args, ctx);
46
52
  case 'test':
47
53
  return await testCommand(args, ctx);
54
+ case 'ui':
55
+ return await uiCommand(args, ctx);
56
+ case 'list':
57
+ return await listCommand(args, ctx);
48
58
  case 'doctor':
49
59
  return await doctorCommand(args, ctx);
50
60
  case 'tree':
@@ -0,0 +1,65 @@
1
+ /**
2
+ * `quiesco list [--runner cucumber|jest|vitest] [--json] [runner arguments…]` (P4): the tests the runner
3
+ * would run, without running them or starting a device. Grouped by file; `--json` prints the TestList
4
+ * (the ids the run events use). Runner arguments: `--config <file>`, paths / filters (cucumber also
5
+ * `--profile`).
6
+ */
7
+ import type { TestList } from '@quiesco/core';
8
+ import { listTests } from '@quiesco/core';
9
+
10
+ import type { CliContext } from '../context.js';
11
+ import { takeFlag, takeOption } from '../context.js';
12
+
13
+ export const LIST_HELP = `Usage: quiesco list [options] [runner arguments…]
14
+
15
+ Lists the tests the runner would run, without running them (no device is started).
16
+
17
+ Options:
18
+ --runner cucumber|jest|vitest Test runner (default: cucumber)
19
+ --json Print the list as JSON (ids as in the run events)
20
+ -h, --help Show this help
21
+
22
+ Runner arguments: --config <file>, paths or filters (cucumber: also --profile <name>).
23
+
24
+ Examples:
25
+ quiesco list
26
+ quiesco list features/login.feature
27
+ quiesco list --runner vitest --config vitest.e2e.config.mts`;
28
+
29
+ export interface ListDeps {
30
+ listTests: typeof listTests;
31
+ }
32
+
33
+ const RUNNERS = ['cucumber', 'jest', 'vitest'] as const;
34
+
35
+ export function formatList(list: TestList): string[] {
36
+ const lines: string[] = [];
37
+ const byFile = new Map<string, TestList['tests'][number][]>();
38
+ for (const f of list.files) byFile.set(f, []);
39
+ for (const t of list.tests) byFile.set(t.file, [...(byFile.get(t.file) ?? []), t]);
40
+ for (const [file, tests] of byFile) {
41
+ lines.push(file);
42
+ for (const t of tests) lines.push(` ${t.path.join(' › ')}${t.line !== undefined ? ` :${t.line}` : ''}`);
43
+ }
44
+ for (const e of list.errors) lines.push(`✗ ${e.file !== undefined ? `${e.file}: ` : ''}${e.message}`);
45
+ lines.push(`${list.tests.length} test${list.tests.length === 1 ? '' : 's'} in ${list.files.length} file${list.files.length === 1 ? '' : 's'}`);
46
+ return lines;
47
+ }
48
+
49
+ export async function listCommand(args: readonly string[], ctx: CliContext, deps: ListDeps = { listTests }): Promise<number> {
50
+ if (args.includes('-h') || args.includes('--help')) {
51
+ ctx.out(LIST_HELP);
52
+ return 0;
53
+ }
54
+ const r = takeOption(args, '--runner');
55
+ const json = takeFlag(r.rest, '--json');
56
+ const runner = r.value ?? 'cucumber';
57
+ if (!(RUNNERS as readonly string[]).includes(runner)) {
58
+ ctx.err(`quiesco list: unknown runner "${runner}" (cucumber, jest or vitest).`);
59
+ return 2;
60
+ }
61
+ const list = await deps.listTests({ runner: runner as (typeof RUNNERS)[number], cwd: ctx.cwd, args: json.rest, env: ctx.env });
62
+ if (json.present) ctx.out(JSON.stringify(list, null, 2));
63
+ else for (const line of formatList(list)) ctx.out(line);
64
+ return list.errors.length > 0 && list.tests.length === 0 ? 1 : 0;
65
+ }
@@ -5,20 +5,23 @@
5
5
  * each on its own device, with the runner's own flags; those flags can also be passed directly.
6
6
  * Everything after a `--` goes to the runner as-is, and the `--` itself is dropped (issue #7): cucumber-js
7
7
  * would read every argument after it as a path.
8
+ * On a terminal a progress bar stays on the last line (P3, `--no-progress` turns it off): the runner's
9
+ * Quiesco reporter sends run events over a local socket (QUIESCO_EVENTS).
8
10
  */
9
11
  import type { QuiescoConfig } from '@quiesco/core';
10
12
  import { loadConfig } from '@quiesco/core';
11
13
 
12
14
  import type { CliContext } from '../context.js';
13
- import { parsePlatform, takeOption } from '../context.js';
15
+ import { parsePlatform, takeFlag, takeOption } from '../context.js';
14
16
  import { ensureDevServer } from '../dev-server.js';
17
+ import { cucumberFormatArgs, progressWanted, runWithProgress } from '../progress/run.js';
15
18
 
16
19
  export interface TestDeps {
17
20
  /** The project's quiesco.config (null when there is none: the runner reports that itself). */
18
21
  loadConfig: (cwd: string, env: NodeJS.ProcessEnv) => Promise<QuiescoConfig | null>;
19
22
  }
20
23
 
21
- const defaultTestDeps: TestDeps = {
24
+ export const defaultTestDeps: TestDeps = {
22
25
  loadConfig: async (cwd, env) => {
23
26
  try {
24
27
  return (await loadConfig({ cwd, ...(env['QUIESCO_CONFIG'] !== undefined ? { file: env['QUIESCO_CONFIG'] } : {}), worker: { workerIndex: 0, workerCount: 1 } })).config;
@@ -28,13 +31,13 @@ const defaultTestDeps: TestDeps = {
28
31
  },
29
32
  };
30
33
 
31
- const RUNNERS = {
34
+ export const RUNNERS = {
32
35
  cucumber: { command: ['cucumber-js'], workers: (n: number) => (n > 1 ? ['--parallel', String(n)] : []) },
33
36
  // `jest` reads jest.config.*.
34
37
  jest: { command: ['jest'], workers: (n: number) => ['--maxWorkers', String(n)] },
35
38
  vitest: { command: ['vitest', 'run'], workers: (n: number) => (n > 1 ? ['--fileParallelism', '--maxWorkers', String(n)] : ['--no-file-parallelism', '--maxWorkers', '1']) },
36
39
  } as const;
37
- type Runner = keyof typeof RUNNERS;
40
+ export type Runner = keyof typeof RUNNERS;
38
41
 
39
42
  export const TEST_HELP = `Usage: quiesco test [options] [runner arguments…]
40
43
 
@@ -48,6 +51,7 @@ Options:
48
51
  --platform ios|android|web Platform to test (or set QUIESCO_PLATFORM)
49
52
  --runner cucumber|jest|vitest Test runner (default: cucumber, i.e. cucumber-js)
50
53
  --workers N Run N workers, each on a device of its own
54
+ --no-progress No progress bar (it shows on a terminal, not in CI; or QUIESCO_PROGRESS=0)
51
55
  -h, --help Show this help (\`quiesco test -- --help\` shows the runner's)
52
56
 
53
57
  Examples:
@@ -57,7 +61,7 @@ Examples:
57
61
  quiesco test --platform web -- --tags @debug
58
62
  quiesco test --platform ios --runner vitest --config vitest.e2e.config.mts`;
59
63
 
60
- function isRunner(v: string | undefined): v is Runner {
64
+ export function isRunner(v: string | undefined): v is Runner {
61
65
  return v !== undefined && Object.hasOwn(RUNNERS, v);
62
66
  }
63
67
 
@@ -73,7 +77,8 @@ export async function testCommand(args: readonly string[], ctx: CliContext, deps
73
77
  const p = takeOption(own, '--platform');
74
78
  const r = takeOption(p.rest, '--runner');
75
79
  const w = takeOption(r.rest, '--workers');
76
- const rest = [...w.rest, ...passThrough];
80
+ const np = takeFlag(w.rest, '--no-progress');
81
+ const rest = [...np.rest, ...passThrough];
77
82
  const platform = parsePlatform(p.value) ?? parsePlatform(ctx.env['QUIESCO_PLATFORM']);
78
83
  if (platform === undefined) {
79
84
  ctx.err('quiesco test: choose a platform with --platform ios|android|web (or set QUIESCO_PLATFORM). See quiesco test --help.');
@@ -105,7 +110,12 @@ export async function testCommand(args: readonly string[], ctx: CliContext, deps
105
110
  }
106
111
  try {
107
112
  // npx runs the project's own runner (node_modules/.bin), the one the tests import.
108
- return await ctx.run('npx', [...spec.command, ...workerArgs, ...rest], { cwd: ctx.cwd, env: { ...ctx.env, QUIESCO_PLATFORM: platform } });
113
+ const env = { ...ctx.env, QUIESCO_PLATFORM: platform };
114
+ if (progressWanted(ctx, np.present)) {
115
+ const formatArgs = runner === 'cucumber' ? cucumberFormatArgs(ctx) : [];
116
+ return await runWithProgress(ctx, { command: 'npx', args: [...spec.command, ...workerArgs, ...formatArgs, ...rest], env, runner });
117
+ }
118
+ return await ctx.run('npx', [...spec.command, ...workerArgs, ...rest], { cwd: ctx.cwd, env });
109
119
  } finally {
110
120
  await devServer?.stop();
111
121
  }