git-watchtower 1.11.9 → 1.12.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/bin/git-watchtower.js +11 -2
- package/package.json +1 -1
- package/src/git/commands.js +4 -13
- package/src/ui/ansi.js +72 -55
package/bin/git-watchtower.js
CHANGED
|
@@ -448,7 +448,11 @@ function applyConfig(config) {
|
|
|
448
448
|
// Server log management
|
|
449
449
|
function addServerLog(line, isError = false) {
|
|
450
450
|
const entry = { timestamp: new Date().toLocaleTimeString(), line, isError };
|
|
451
|
-
const
|
|
451
|
+
const prev = store.get('serverLogBuffer');
|
|
452
|
+
// Drop the oldest entries to stay within MAX_SERVER_LOG_LINES after push
|
|
453
|
+
const startIdx = Math.max(0, prev.length + 1 - MAX_SERVER_LOG_LINES);
|
|
454
|
+
const serverLogBuffer = prev.slice(startIdx);
|
|
455
|
+
serverLogBuffer.push(entry);
|
|
452
456
|
store.setState({ serverLogBuffer });
|
|
453
457
|
}
|
|
454
458
|
|
|
@@ -976,7 +980,12 @@ function addLog(message, type = 'info') {
|
|
|
976
980
|
icon: icons[type] || '○',
|
|
977
981
|
color: colors[type] || 'white',
|
|
978
982
|
};
|
|
979
|
-
const
|
|
983
|
+
const prev = store.get('activityLog');
|
|
984
|
+
// Drop the oldest entries to stay within MAX_LOG_ENTRIES after prepend
|
|
985
|
+
const keepCount = Math.min(prev.length, MAX_LOG_ENTRIES - 1);
|
|
986
|
+
const activityLog = new Array(keepCount + 1);
|
|
987
|
+
activityLog[0] = entry;
|
|
988
|
+
for (let i = 0; i < keepCount; i++) activityLog[i + 1] = prev[i];
|
|
980
989
|
store.setState({ activityLog });
|
|
981
990
|
}
|
|
982
991
|
|
package/package.json
CHANGED
package/src/git/commands.js
CHANGED
|
@@ -17,8 +17,7 @@ const SHORT_TIMEOUT = 5000;
|
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Execute a git command safely using execFile (no shell).
|
|
20
|
-
* @param {string
|
|
21
|
-
* or a legacy command string (e.g. 'git --version') for backwards compatibility
|
|
20
|
+
* @param {string[]} args - Git arguments as an array (e.g. ['log', '--oneline'])
|
|
22
21
|
* @param {Object} [options] - Execution options
|
|
23
22
|
* @param {number} [options.timeout] - Command timeout in ms
|
|
24
23
|
* @param {string} [options.cwd] - Working directory
|
|
@@ -28,16 +27,8 @@ const SHORT_TIMEOUT = 5000;
|
|
|
28
27
|
async function execGit(args, options = {}) {
|
|
29
28
|
const { timeout = DEFAULT_TIMEOUT, cwd = process.cwd() } = options;
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (typeof args === 'string') {
|
|
34
|
-
const parts = /** @type {string} */ (args).split(/\s+/);
|
|
35
|
-
// Strip leading 'git' if present so callers can pass 'git --version'
|
|
36
|
-
if (parts[0] === 'git') {
|
|
37
|
-
args = parts.slice(1);
|
|
38
|
-
} else {
|
|
39
|
-
args = parts;
|
|
40
|
-
}
|
|
30
|
+
if (!Array.isArray(args)) {
|
|
31
|
+
throw new TypeError('execGit: args must be an array of strings');
|
|
41
32
|
}
|
|
42
33
|
|
|
43
34
|
const command = `git ${args.join(' ')}`;
|
|
@@ -72,7 +63,7 @@ async function execGit(args, options = {}) {
|
|
|
72
63
|
|
|
73
64
|
/**
|
|
74
65
|
* Execute git command silently (suppress errors)
|
|
75
|
-
* @param {string
|
|
66
|
+
* @param {string[]} command - Git arguments
|
|
76
67
|
* @param {Object} [options] - Execution options
|
|
77
68
|
* @returns {Promise<{stdout: string, stderr: string}|null>}
|
|
78
69
|
*/
|
package/src/ui/ansi.js
CHANGED
|
@@ -7,6 +7,22 @@
|
|
|
7
7
|
const ESC = '\x1b';
|
|
8
8
|
const CSI = `${ESC}[`;
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Whether color output is enabled.
|
|
12
|
+
* Honors the NO_COLOR convention (https://no-color.org/) and TERM=dumb.
|
|
13
|
+
* Structural codes (cursor movement, screen control) are still emitted
|
|
14
|
+
* so the TUI layout remains functional — only color/style codes are stripped.
|
|
15
|
+
*/
|
|
16
|
+
const colorsEnabled = !(
|
|
17
|
+
(process.env.NO_COLOR && process.env.NO_COLOR !== '') ||
|
|
18
|
+
process.env.TERM === 'dumb'
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
/** Empty string for disabled color codes, or the given code when enabled. */
|
|
22
|
+
const c = (code) => (colorsEnabled ? code : '');
|
|
23
|
+
/** Empty-returning function for disabled color functions. */
|
|
24
|
+
const cFn = (fn) => (colorsEnabled ? fn : () => '');
|
|
25
|
+
|
|
10
26
|
/**
|
|
11
27
|
* ANSI escape codes for terminal control and styling
|
|
12
28
|
*/
|
|
@@ -44,81 +60,81 @@ const ansi = {
|
|
|
44
60
|
restoreCursor: `${CSI}u`,
|
|
45
61
|
|
|
46
62
|
// Text styles
|
|
47
|
-
reset: `${CSI}0m
|
|
48
|
-
bold: `${CSI}1m
|
|
49
|
-
dim: `${CSI}2m
|
|
50
|
-
italic: `${CSI}3m
|
|
51
|
-
underline: `${CSI}4m
|
|
52
|
-
blink: `${CSI}5m
|
|
53
|
-
inverse: `${CSI}7m
|
|
54
|
-
hidden: `${CSI}8m
|
|
55
|
-
strikethrough: `${CSI}9m
|
|
63
|
+
reset: c(`${CSI}0m`),
|
|
64
|
+
bold: c(`${CSI}1m`),
|
|
65
|
+
dim: c(`${CSI}2m`),
|
|
66
|
+
italic: c(`${CSI}3m`),
|
|
67
|
+
underline: c(`${CSI}4m`),
|
|
68
|
+
blink: c(`${CSI}5m`),
|
|
69
|
+
inverse: c(`${CSI}7m`),
|
|
70
|
+
hidden: c(`${CSI}8m`),
|
|
71
|
+
strikethrough: c(`${CSI}9m`),
|
|
56
72
|
|
|
57
73
|
// Reset specific styles
|
|
58
|
-
resetBold: `${CSI}22m
|
|
59
|
-
resetDim: `${CSI}22m
|
|
60
|
-
resetItalic: `${CSI}23m
|
|
61
|
-
resetUnderline: `${CSI}24m
|
|
62
|
-
resetBlink: `${CSI}25m
|
|
63
|
-
resetInverse: `${CSI}27m
|
|
64
|
-
resetHidden: `${CSI}28m
|
|
65
|
-
resetStrikethrough: `${CSI}29m
|
|
74
|
+
resetBold: c(`${CSI}22m`),
|
|
75
|
+
resetDim: c(`${CSI}22m`),
|
|
76
|
+
resetItalic: c(`${CSI}23m`),
|
|
77
|
+
resetUnderline: c(`${CSI}24m`),
|
|
78
|
+
resetBlink: c(`${CSI}25m`),
|
|
79
|
+
resetInverse: c(`${CSI}27m`),
|
|
80
|
+
resetHidden: c(`${CSI}28m`),
|
|
81
|
+
resetStrikethrough: c(`${CSI}29m`),
|
|
66
82
|
|
|
67
83
|
// Foreground colors (standard)
|
|
68
|
-
black: `${CSI}30m
|
|
69
|
-
red: `${CSI}31m
|
|
70
|
-
green: `${CSI}32m
|
|
71
|
-
yellow: `${CSI}33m
|
|
72
|
-
blue: `${CSI}34m
|
|
73
|
-
magenta: `${CSI}35m
|
|
74
|
-
cyan: `${CSI}36m
|
|
75
|
-
white: `${CSI}37m
|
|
76
|
-
default: `${CSI}39m
|
|
84
|
+
black: c(`${CSI}30m`),
|
|
85
|
+
red: c(`${CSI}31m`),
|
|
86
|
+
green: c(`${CSI}32m`),
|
|
87
|
+
yellow: c(`${CSI}33m`),
|
|
88
|
+
blue: c(`${CSI}34m`),
|
|
89
|
+
magenta: c(`${CSI}35m`),
|
|
90
|
+
cyan: c(`${CSI}36m`),
|
|
91
|
+
white: c(`${CSI}37m`),
|
|
92
|
+
default: c(`${CSI}39m`),
|
|
77
93
|
|
|
78
94
|
// Foreground colors (bright)
|
|
79
|
-
gray: `${CSI}90m
|
|
80
|
-
brightRed: `${CSI}91m
|
|
81
|
-
brightGreen: `${CSI}92m
|
|
82
|
-
brightYellow: `${CSI}93m
|
|
83
|
-
brightBlue: `${CSI}94m
|
|
84
|
-
brightMagenta: `${CSI}95m
|
|
85
|
-
brightCyan: `${CSI}96m
|
|
86
|
-
brightWhite: `${CSI}97m
|
|
95
|
+
gray: c(`${CSI}90m`),
|
|
96
|
+
brightRed: c(`${CSI}91m`),
|
|
97
|
+
brightGreen: c(`${CSI}92m`),
|
|
98
|
+
brightYellow: c(`${CSI}93m`),
|
|
99
|
+
brightBlue: c(`${CSI}94m`),
|
|
100
|
+
brightMagenta: c(`${CSI}95m`),
|
|
101
|
+
brightCyan: c(`${CSI}96m`),
|
|
102
|
+
brightWhite: c(`${CSI}97m`),
|
|
87
103
|
|
|
88
104
|
// Background colors (standard)
|
|
89
|
-
bgBlack: `${CSI}40m
|
|
90
|
-
bgRed: `${CSI}41m
|
|
91
|
-
bgGreen: `${CSI}42m
|
|
92
|
-
bgYellow: `${CSI}43m
|
|
93
|
-
bgBlue: `${CSI}44m
|
|
94
|
-
bgMagenta: `${CSI}45m
|
|
95
|
-
bgCyan: `${CSI}46m
|
|
96
|
-
bgWhite: `${CSI}47m
|
|
97
|
-
bgDefault: `${CSI}49m
|
|
105
|
+
bgBlack: c(`${CSI}40m`),
|
|
106
|
+
bgRed: c(`${CSI}41m`),
|
|
107
|
+
bgGreen: c(`${CSI}42m`),
|
|
108
|
+
bgYellow: c(`${CSI}43m`),
|
|
109
|
+
bgBlue: c(`${CSI}44m`),
|
|
110
|
+
bgMagenta: c(`${CSI}45m`),
|
|
111
|
+
bgCyan: c(`${CSI}46m`),
|
|
112
|
+
bgWhite: c(`${CSI}47m`),
|
|
113
|
+
bgDefault: c(`${CSI}49m`),
|
|
98
114
|
|
|
99
115
|
// Background colors (bright)
|
|
100
|
-
bgGray: `${CSI}100m
|
|
101
|
-
bgBrightRed: `${CSI}101m
|
|
102
|
-
bgBrightGreen: `${CSI}102m
|
|
103
|
-
bgBrightYellow: `${CSI}103m
|
|
104
|
-
bgBrightBlue: `${CSI}104m
|
|
105
|
-
bgBrightMagenta: `${CSI}105m
|
|
106
|
-
bgBrightCyan: `${CSI}106m
|
|
107
|
-
bgBrightWhite: `${CSI}107m
|
|
116
|
+
bgGray: c(`${CSI}100m`),
|
|
117
|
+
bgBrightRed: c(`${CSI}101m`),
|
|
118
|
+
bgBrightGreen: c(`${CSI}102m`),
|
|
119
|
+
bgBrightYellow: c(`${CSI}103m`),
|
|
120
|
+
bgBrightBlue: c(`${CSI}104m`),
|
|
121
|
+
bgBrightMagenta: c(`${CSI}105m`),
|
|
122
|
+
bgBrightCyan: c(`${CSI}106m`),
|
|
123
|
+
bgBrightWhite: c(`${CSI}107m`),
|
|
108
124
|
|
|
109
125
|
/**
|
|
110
126
|
* Set foreground color using 256-color palette
|
|
111
127
|
* @param {number} n - Color number (0-255)
|
|
112
128
|
* @returns {string}
|
|
113
129
|
*/
|
|
114
|
-
fg256: (n) => `${CSI}38;5;${n}m
|
|
130
|
+
fg256: cFn((n) => `${CSI}38;5;${n}m`),
|
|
115
131
|
|
|
116
132
|
/**
|
|
117
133
|
* Set background color using 256-color palette
|
|
118
134
|
* @param {number} n - Color number (0-255)
|
|
119
135
|
* @returns {string}
|
|
120
136
|
*/
|
|
121
|
-
bg256: (n) => `${CSI}48;5;${n}m
|
|
137
|
+
bg256: cFn((n) => `${CSI}48;5;${n}m`),
|
|
122
138
|
|
|
123
139
|
/**
|
|
124
140
|
* Set foreground color using RGB
|
|
@@ -127,7 +143,7 @@ const ansi = {
|
|
|
127
143
|
* @param {number} b - Blue (0-255)
|
|
128
144
|
* @returns {string}
|
|
129
145
|
*/
|
|
130
|
-
fgRgb: (r, g, b) => `${CSI}38;2;${r};${g};${b}m
|
|
146
|
+
fgRgb: cFn((r, g, b) => `${CSI}38;2;${r};${g};${b}m`),
|
|
131
147
|
|
|
132
148
|
/**
|
|
133
149
|
* Set background color using RGB
|
|
@@ -136,7 +152,7 @@ const ansi = {
|
|
|
136
152
|
* @param {number} b - Blue (0-255)
|
|
137
153
|
* @returns {string}
|
|
138
154
|
*/
|
|
139
|
-
bgRgb: (r, g, b) => `${CSI}48;2;${r};${g};${b}m
|
|
155
|
+
bgRgb: cFn((r, g, b) => `${CSI}48;2;${r};${g};${b}m`),
|
|
140
156
|
};
|
|
141
157
|
|
|
142
158
|
/**
|
|
@@ -492,6 +508,7 @@ module.exports = {
|
|
|
492
508
|
wordWrap,
|
|
493
509
|
horizontalLine,
|
|
494
510
|
style,
|
|
511
|
+
colorsEnabled,
|
|
495
512
|
// Export constants for direct use
|
|
496
513
|
ESC,
|
|
497
514
|
CSI,
|