@synmux/claude-commit 1.0.3 → 1.1.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.
package/src/ui/spinner.ts DELETED
@@ -1,79 +0,0 @@
1
- /**
2
- * The progress spinner for non-interactive runs, rendered by `ora`.
3
- *
4
- * It writes to stderr (so stdout stays clean for piping) and only animates when
5
- * explicitly enabled: callers gate on `process.stderr.isTTY` and `--no-spinner`,
6
- * and ora's own TTY/CI detection is bypassed so that decision lives in one
7
- * place. When disabled, `start`/`update` are silent no-ops but final status
8
- * lines (`succeed`/`fail`) still print. This keeps the progress indicator out
9
- * of the way of `cco --dry-run | git commit -F -`.
10
- *
11
- * The animation is chosen by the `spinner` config key: any name from the
12
- * cli-spinners set bundled with ora, defaulting to {@link DEFAULT_SPINNER}.
13
- */
14
- import ora, { type Ora } from "ora";
15
- import spinners, { type Spinner as SpinnerAnimation } from "cli-spinners";
16
- import { color } from "./colors";
17
-
18
- /** The spinner used when none (or an unknown one) is configured. */
19
- export const DEFAULT_SPINNER = "material";
20
-
21
- /** Whether `name` is one of the cli-spinners animations bundled with ora. */
22
- export function isSpinnerName(name: string): boolean {
23
- return Object.hasOwn(spinners, name);
24
- }
25
-
26
- /**
27
- * Look up a spinner animation by name, falling back to {@link DEFAULT_SPINNER}
28
- * for unknown names (ora itself throws on those, and a cosmetic option must
29
- * never be able to break a commit).
30
- */
31
- export function resolveSpinner(name: string): SpinnerAnimation {
32
- const known = (spinners as Record<string, SpinnerAnimation | undefined>)[
33
- name
34
- ];
35
- return known ?? spinners[DEFAULT_SPINNER];
36
- }
37
-
38
- export class Spinner {
39
- private instance: Ora | null = null;
40
- private readonly enabled: boolean;
41
- private readonly animation: SpinnerAnimation;
42
-
43
- constructor(enabled = process.stderr.isTTY, spinnerName = DEFAULT_SPINNER) {
44
- this.enabled = Boolean(enabled);
45
- this.animation = resolveSpinner(spinnerName);
46
- }
47
-
48
- start(label: string): void {
49
- if (!this.enabled) return;
50
- this.instance?.stop();
51
- this.instance = ora({
52
- text: label,
53
- spinner: this.animation,
54
- stream: process.stderr,
55
- // The caller already decided (TTY check + --no-spinner); don't let ora's
56
- // own TTY/CI detection silently disagree.
57
- isEnabled: true,
58
- }).start();
59
- }
60
-
61
- update(label: string): void {
62
- if (this.instance) this.instance.text = label;
63
- }
64
-
65
- /** Stop and clear the spinner line, optionally printing a final status line. */
66
- stop(finalLine?: string): void {
67
- this.instance?.stop();
68
- this.instance = null;
69
- if (finalLine !== undefined) process.stderr.write(finalLine + "\n");
70
- }
71
-
72
- succeed(label: string): void {
73
- this.stop(`${color("32", "✔")} ${label}`);
74
- }
75
-
76
- fail(label: string): void {
77
- this.stop(`${color("31", "✖")} ${label}`);
78
- }
79
- }
package/src/utils.ts DELETED
@@ -1,5 +0,0 @@
1
- import packageJson from "../package.json";
2
-
3
- export const getVersion = () => {
4
- return packageJson.version;
5
- };