claude-mission-control 1.9.0 → 1.9.1
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/lib/update.js +17 -7
- package/package.json +1 -1
- package/server.js +1 -1
package/lib/update.js
CHANGED
|
@@ -68,7 +68,17 @@ function readPkgVersion(appDir) {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
// Pure: did the update leave a different version on disk than the one this
|
|
72
|
+
// process is running? The before/after-on-disk comparison is wrong when the
|
|
73
|
+
// tree was already updated (a manual git pull, a previous click that didn't
|
|
74
|
+
// restart): disk == disk, but the running process is still old and needs
|
|
75
|
+
// the restart.
|
|
76
|
+
function updateOutcome(runningVersion, diskVersion, managed) {
|
|
77
|
+
const unchanged = !diskVersion || diskVersion === runningVersion;
|
|
78
|
+
return { unchanged, willRestart: !unchanged && managed };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function runSelfUpdate(appDir, runningVersion) {
|
|
72
82
|
const kind = detectInstallKind(appDir, fs.existsSync(path.join(appDir, '.git')));
|
|
73
83
|
const plan = updatePlan(kind, PKG_NAME);
|
|
74
84
|
if (plan.type === 'manual') {
|
|
@@ -83,7 +93,6 @@ function runSelfUpdate(appDir) {
|
|
|
83
93
|
args = [cli, ...plan.args];
|
|
84
94
|
}
|
|
85
95
|
}
|
|
86
|
-
const before = readPkgVersion(appDir);
|
|
87
96
|
return new Promise((resolve) => {
|
|
88
97
|
execFile(cmd, args, { cwd: appDir, timeout: 120_000 }, (err, stdout, stderr) => {
|
|
89
98
|
if (err) {
|
|
@@ -92,19 +101,20 @@ function runSelfUpdate(appDir) {
|
|
|
92
101
|
}
|
|
93
102
|
// The command exiting 0 isn't proof anything changed: npm can re-fetch
|
|
94
103
|
// the same version while a release is still publishing, and git can
|
|
95
|
-
// pull nothing. Only a version
|
|
104
|
+
// pull nothing. Only a version on disk that differs from the one we're
|
|
105
|
+
// running earns a restart.
|
|
96
106
|
const after = readPkgVersion(appDir);
|
|
97
|
-
const
|
|
107
|
+
const { unchanged, willRestart } = updateOutcome(runningVersion, after, serviceManaged());
|
|
98
108
|
resolve({
|
|
99
109
|
ok: true,
|
|
100
110
|
kind,
|
|
101
111
|
version: after || undefined,
|
|
102
|
-
unchanged
|
|
103
|
-
willRestart
|
|
112
|
+
unchanged,
|
|
113
|
+
willRestart,
|
|
104
114
|
output: String(stdout).slice(0, 300),
|
|
105
115
|
});
|
|
106
116
|
});
|
|
107
117
|
});
|
|
108
118
|
}
|
|
109
119
|
|
|
110
|
-
module.exports = { detectInstallKind, updatePlan, npmCliCandidates, runSelfUpdate };
|
|
120
|
+
module.exports = { detectInstallKind, updatePlan, npmCliCandidates, updateOutcome, runSelfUpdate };
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -186,7 +186,7 @@ const server = http.createServer((req, res) => {
|
|
|
186
186
|
// relaunch it on the new code.
|
|
187
187
|
if (url === '/api/update' && req.method === 'POST') {
|
|
188
188
|
if (!sameOrigin(req)) return json(res, 403, { ok: false, error: 'forbidden' });
|
|
189
|
-
runSelfUpdate(__dirname).then((result) => {
|
|
189
|
+
runSelfUpdate(__dirname, VERSION).then((result) => {
|
|
190
190
|
json(res, result.ok || result.manual ? 200 : 500, result);
|
|
191
191
|
if (result.ok && result.willRestart) {
|
|
192
192
|
setTimeout(() => {
|