git-watchtower 2.2.0 → 2.2.2
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 +2 -2
- package/bin/git-watchtower.js +1 -1
- package/package.json +1 -1
- package/src/cli/args.js +4 -4
- package/src/config/schema.js +5 -5
- package/src/server/static.js +13 -5
- package/src/utils/errors.js +0 -27
- package/src/utils/install-source.js +1 -1
package/README.md
CHANGED
|
@@ -95,9 +95,9 @@ Real-time branch monitoring, PR workflows, CI status, and session statistics —
|
|
|
95
95
|
|
|
96
96
|
| Mode | Flag | Description |
|
|
97
97
|
|------|------|-------------|
|
|
98
|
-
| **
|
|
98
|
+
| **No Server** | `--no-server` | Branch monitoring only (default) |
|
|
99
|
+
| **Static Site** | `--mode static` | Built-in server with live reload for HTML/CSS/JS |
|
|
99
100
|
| **Custom Command** | `--mode command -c "npm run dev"` | Run your own dev server (Next.js, Vite, Nuxt, etc.) |
|
|
100
|
-
| **No Server** | `--no-server` | Branch monitoring only |
|
|
101
101
|
|
|
102
102
|
## 🎰 Casino Mode
|
|
103
103
|
|
package/bin/git-watchtower.js
CHANGED
|
@@ -862,7 +862,7 @@ let pollIntervalId = null;
|
|
|
862
862
|
const { ansi, box, truncate, sparkline: uiSparkline, visibleLength, stripAnsi, padRight, padLeft, getMaxBranchesForScreen: calcMaxBranches, drawBox: renderBox, clearArea: renderClearArea } = require('../src/ui/ansi');
|
|
863
863
|
|
|
864
864
|
// Error detection utilities imported from src/utils/errors.js
|
|
865
|
-
const {
|
|
865
|
+
const { isAuthError, isMergeConflict, isNetworkError } = require('../src/utils/errors');
|
|
866
866
|
const { Mutex, sleep } = require('../src/utils/async');
|
|
867
867
|
|
|
868
868
|
// Keyboard handling utilities imported from src/ui/keybindings.js
|
package/package.json
CHANGED
package/src/cli/args.js
CHANGED
|
@@ -255,9 +255,9 @@ Usage:
|
|
|
255
255
|
git-watchtower [options]
|
|
256
256
|
|
|
257
257
|
Server Options:
|
|
258
|
-
-m, --mode <mode> Server mode: static, command, or none
|
|
258
|
+
-m, --mode <mode> Server mode: static, command, or none (default: none)
|
|
259
259
|
-p, --port <port> Server port (default: 3000)
|
|
260
|
-
-n, --no-server Shorthand for --mode none
|
|
260
|
+
-n, --no-server Shorthand for --mode none (default)
|
|
261
261
|
--static-dir <dir> Directory for static file serving (default: public)
|
|
262
262
|
-c, --command <cmd> Command to run in command mode (e.g., "npm run dev")
|
|
263
263
|
--restart-on-switch Restart server on branch switch (default)
|
|
@@ -287,9 +287,9 @@ General:
|
|
|
287
287
|
-h, --help Show this help message
|
|
288
288
|
|
|
289
289
|
Server Modes:
|
|
290
|
-
|
|
290
|
+
none Branch monitoring only (default)
|
|
291
|
+
static Serve static files with live reload
|
|
291
292
|
command Run your own dev server (Next.js, Vite, Nuxt, etc.)
|
|
292
|
-
none Branch monitoring only
|
|
293
293
|
|
|
294
294
|
Configuration:
|
|
295
295
|
On first run, Git Watchtower will prompt you to configure settings.
|
package/src/config/schema.js
CHANGED
|
@@ -48,7 +48,7 @@ const SERVER_MODES = ['static', 'command', 'none'];
|
|
|
48
48
|
*/
|
|
49
49
|
const DEFAULTS = {
|
|
50
50
|
server: {
|
|
51
|
-
mode: /** @type {ServerMode} */ ('
|
|
51
|
+
mode: /** @type {ServerMode} */ ('none'),
|
|
52
52
|
staticDir: 'public',
|
|
53
53
|
command: '',
|
|
54
54
|
port: 3000,
|
|
@@ -291,12 +291,12 @@ function migrateConfig(config) {
|
|
|
291
291
|
return validateConfig(config);
|
|
292
292
|
}
|
|
293
293
|
|
|
294
|
-
// Convert old format to new
|
|
294
|
+
// Convert old format to new. Legacy configs predate the 'none' default,
|
|
295
|
+
// so preserve the old behavior: noServer maps to 'none', anything else
|
|
296
|
+
// implies the user wanted the static server that used to be the default.
|
|
295
297
|
const newConfig = getDefaultConfig();
|
|
296
298
|
|
|
297
|
-
|
|
298
|
-
newConfig.server.mode = 'none';
|
|
299
|
-
}
|
|
299
|
+
newConfig.server.mode = config.noServer ? 'none' : 'static';
|
|
300
300
|
if (config.port !== undefined) {
|
|
301
301
|
newConfig.server.port = validatePort(config.port);
|
|
302
302
|
}
|
package/src/server/static.js
CHANGED
|
@@ -56,14 +56,22 @@ const LIVE_RELOAD_SCRIPT = `
|
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
58
|
* Inject live reload script into HTML content.
|
|
59
|
+
*
|
|
60
|
+
* Splits on the LAST `</body>` rather than the first. String.prototype.replace
|
|
61
|
+
* with a string argument only replaces the first match, which mis-injects
|
|
62
|
+
* the script when the page has a literal `</body>` earlier in the document —
|
|
63
|
+
* e.g. inside a `<pre>` or `<code>` block on a docs site rendering HTML
|
|
64
|
+
* samples. The browser only honours the last `</body>` as the actual close,
|
|
65
|
+
* so that's where the script needs to land.
|
|
66
|
+
*
|
|
59
67
|
* @param {string} html - HTML content
|
|
60
|
-
* @returns {string} HTML with live reload script injected before </body>
|
|
68
|
+
* @returns {string} HTML with live reload script injected before the closing </body>
|
|
61
69
|
*/
|
|
62
70
|
function injectLiveReload(html) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return html;
|
|
71
|
+
const closeTag = '</body>';
|
|
72
|
+
const idx = html.lastIndexOf(closeTag);
|
|
73
|
+
if (idx === -1) return html;
|
|
74
|
+
return html.slice(0, idx) + LIVE_RELOAD_SCRIPT + html.slice(idx + closeTag.length);
|
|
67
75
|
}
|
|
68
76
|
|
|
69
77
|
/**
|
package/src/utils/errors.js
CHANGED
|
@@ -252,33 +252,6 @@ class ServerError extends AppError {
|
|
|
252
252
|
this.name = 'ServerError';
|
|
253
253
|
}
|
|
254
254
|
|
|
255
|
-
/**
|
|
256
|
-
* Create ServerError for port in use
|
|
257
|
-
* @param {number} port - The port that's in use
|
|
258
|
-
* @returns {ServerError}
|
|
259
|
-
*/
|
|
260
|
-
static portInUse(port) {
|
|
261
|
-
return new ServerError(
|
|
262
|
-
`Port ${port} is already in use`,
|
|
263
|
-
'PORT_IN_USE',
|
|
264
|
-
{ port }
|
|
265
|
-
);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* Create ServerError for process crash
|
|
270
|
-
* @param {string} command - The command that crashed
|
|
271
|
-
* @param {number} exitCode - Exit code
|
|
272
|
-
* @returns {ServerError}
|
|
273
|
-
*/
|
|
274
|
-
static processCrashed(command, exitCode) {
|
|
275
|
-
return new ServerError(
|
|
276
|
-
`Server process crashed with exit code ${exitCode}`,
|
|
277
|
-
'PROCESS_CRASHED',
|
|
278
|
-
{ command, exitCode }
|
|
279
|
-
);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
255
|
/**
|
|
283
256
|
* Create ServerError for start failure
|
|
284
257
|
* @param {string} command - The command that failed to start
|
|
@@ -63,7 +63,7 @@ function detectInstallSource() {
|
|
|
63
63
|
*/
|
|
64
64
|
function getUpdateCommand(source) {
|
|
65
65
|
switch (source) {
|
|
66
|
-
case 'homebrew': return 'brew upgrade git-watchtower';
|
|
66
|
+
case 'homebrew': return 'brew update && brew upgrade git-watchtower';
|
|
67
67
|
case 'npm': return 'npm i -g git-watchtower';
|
|
68
68
|
case 'source': return 'git pull && npm install';
|
|
69
69
|
default: return 'npm i -g git-watchtower';
|