@grafema/cli 0.2.3-beta → 0.2.5-beta
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 +73 -0
- package/dist/cli.js +1 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/analyze.d.ts +9 -0
- package/dist/commands/analyze.d.ts.map +1 -1
- package/dist/commands/analyze.js +136 -52
- package/dist/commands/analyze.js.map +1 -0
- package/dist/commands/check.d.ts +2 -6
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +32 -46
- package/dist/commands/check.js.map +1 -0
- package/dist/commands/coverage.js +1 -0
- package/dist/commands/coverage.js.map +1 -0
- package/dist/commands/doctor/checks.d.ts.map +1 -1
- package/dist/commands/doctor/checks.js +9 -5
- package/dist/commands/doctor/checks.js.map +1 -0
- package/dist/commands/doctor/output.js +1 -0
- package/dist/commands/doctor/output.js.map +1 -0
- package/dist/commands/doctor/types.js +1 -0
- package/dist/commands/doctor/types.js.map +1 -0
- package/dist/commands/doctor.js +1 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/explain.js +1 -0
- package/dist/commands/explain.js.map +1 -0
- package/dist/commands/explore.d.ts.map +1 -1
- package/dist/commands/explore.js +9 -4
- package/dist/commands/explore.js.map +1 -0
- package/dist/commands/get.d.ts.map +1 -1
- package/dist/commands/get.js +7 -0
- package/dist/commands/get.js.map +1 -0
- package/dist/commands/impact.js +1 -0
- package/dist/commands/impact.js.map +1 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +7 -1
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/ls.d.ts.map +1 -1
- package/dist/commands/ls.js +7 -0
- package/dist/commands/ls.js.map +1 -0
- package/dist/commands/overview.d.ts.map +1 -1
- package/dist/commands/overview.js +1 -0
- package/dist/commands/overview.js.map +1 -0
- package/dist/commands/query.d.ts.map +1 -1
- package/dist/commands/query.js +68 -1
- package/dist/commands/query.js.map +1 -0
- package/dist/commands/schema.js +1 -0
- package/dist/commands/schema.js.map +1 -0
- package/dist/commands/server.d.ts +2 -1
- package/dist/commands/server.d.ts.map +1 -1
- package/dist/commands/server.js +50 -3
- package/dist/commands/server.js.map +1 -0
- package/dist/commands/stats.js +1 -0
- package/dist/commands/stats.js.map +1 -0
- package/dist/commands/trace.js +1 -0
- package/dist/commands/trace.js.map +1 -0
- package/dist/commands/types.js +1 -0
- package/dist/commands/types.js.map +1 -0
- package/dist/utils/codePreview.js +1 -0
- package/dist/utils/codePreview.js.map +1 -0
- package/dist/utils/errorFormatter.js +1 -0
- package/dist/utils/errorFormatter.js.map +1 -0
- package/dist/utils/formatNode.js +1 -0
- package/dist/utils/formatNode.js.map +1 -0
- package/dist/utils/progressRenderer.d.ts +119 -0
- package/dist/utils/progressRenderer.d.ts.map +1 -0
- package/dist/utils/progressRenderer.js +245 -0
- package/dist/utils/progressRenderer.js.map +1 -0
- package/dist/utils/spinner.d.ts +39 -0
- package/dist/utils/spinner.d.ts.map +1 -0
- package/dist/utils/spinner.js +84 -0
- package/dist/utils/spinner.js.map +1 -0
- package/package.json +5 -4
- package/src/commands/analyze.ts +150 -55
- package/src/commands/check.ts +36 -68
- package/src/commands/doctor/checks.ts +8 -5
- package/src/commands/explore.tsx +8 -4
- package/src/commands/get.ts +8 -0
- package/src/commands/impact.ts +1 -1
- package/src/commands/init.ts +6 -2
- package/src/commands/ls.ts +8 -0
- package/src/commands/overview.ts +0 -4
- package/src/commands/query.ts +77 -1
- package/src/commands/server.ts +57 -3
- package/src/utils/progressRenderer.ts +288 -0
- package/src/utils/spinner.ts +94 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple terminal spinner for slow operations.
|
|
3
|
+
*
|
|
4
|
+
* Features:
|
|
5
|
+
* - TTY detection: silent in non-TTY environments (CI, pipes)
|
|
6
|
+
* - Delayed display: spinner only appears after 100ms to avoid flicker
|
|
7
|
+
* - Elapsed time: shows seconds for long operations
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* const spinner = new Spinner('Querying graph...');
|
|
11
|
+
* spinner.start();
|
|
12
|
+
* await slowOperation();
|
|
13
|
+
* spinner.stop();
|
|
14
|
+
*
|
|
15
|
+
* IMPORTANT: Always call stop() BEFORE any console.log output.
|
|
16
|
+
*/
|
|
17
|
+
export class Spinner {
|
|
18
|
+
private message: string;
|
|
19
|
+
private frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
20
|
+
private interval: ReturnType<typeof setInterval> | null = null;
|
|
21
|
+
private displayTimer: ReturnType<typeof setTimeout> | null = null;
|
|
22
|
+
private frameIndex = 0;
|
|
23
|
+
private startTime = 0;
|
|
24
|
+
private displayDelay: number;
|
|
25
|
+
private isSpinning = false;
|
|
26
|
+
|
|
27
|
+
constructor(message: string, displayDelay = 100) {
|
|
28
|
+
this.message = message;
|
|
29
|
+
this.displayDelay = displayDelay;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Start the spinner. Spinner appears only after displayDelay ms.
|
|
34
|
+
* In non-TTY environments (CI, pipes), this is a no-op.
|
|
35
|
+
*/
|
|
36
|
+
start(): void {
|
|
37
|
+
// TTY check - ora pattern
|
|
38
|
+
if (!process.stdout.isTTY) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
this.startTime = Date.now();
|
|
43
|
+
|
|
44
|
+
// Defer display to avoid flicker on fast queries
|
|
45
|
+
this.displayTimer = setTimeout(() => {
|
|
46
|
+
this.isSpinning = true;
|
|
47
|
+
this.render();
|
|
48
|
+
|
|
49
|
+
// Animate frames at 80ms interval
|
|
50
|
+
this.interval = setInterval(() => {
|
|
51
|
+
this.frameIndex = (this.frameIndex + 1) % this.frames.length;
|
|
52
|
+
this.render();
|
|
53
|
+
}, 80);
|
|
54
|
+
}, this.displayDelay);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private render(): void {
|
|
58
|
+
if (!this.isSpinning) return;
|
|
59
|
+
|
|
60
|
+
const frame = this.frames[this.frameIndex];
|
|
61
|
+
const elapsed = Math.floor((Date.now() - this.startTime) / 1000);
|
|
62
|
+
const timeStr = elapsed > 0 ? ` (${elapsed}s)` : '';
|
|
63
|
+
|
|
64
|
+
process.stdout.clearLine(0);
|
|
65
|
+
process.stdout.cursorTo(0);
|
|
66
|
+
process.stdout.write(`${frame} ${this.message}${timeStr}`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Stop the spinner and clear the line.
|
|
71
|
+
* Safe to call multiple times or if spinner never started.
|
|
72
|
+
*/
|
|
73
|
+
stop(): void {
|
|
74
|
+
// Clear deferred display timer
|
|
75
|
+
if (this.displayTimer) {
|
|
76
|
+
clearTimeout(this.displayTimer);
|
|
77
|
+
this.displayTimer = null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Stop animation
|
|
81
|
+
if (this.interval) {
|
|
82
|
+
clearInterval(this.interval);
|
|
83
|
+
this.interval = null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Clear line if we were displaying
|
|
87
|
+
if (this.isSpinning && process.stdout.isTTY) {
|
|
88
|
+
process.stdout.clearLine(0);
|
|
89
|
+
process.stdout.cursorTo(0);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
this.isSpinning = false;
|
|
93
|
+
}
|
|
94
|
+
}
|