cnagent 2.0.3 → 2.0.5
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/cn +20 -1
- package/package.json +1 -1
package/bin/cn
CHANGED
|
@@ -11,7 +11,7 @@ const { execSync, spawn } = require('child_process');
|
|
|
11
11
|
const path = require('path');
|
|
12
12
|
const fs = require('fs');
|
|
13
13
|
|
|
14
|
-
const VERSION = '2.0.
|
|
14
|
+
const VERSION = '2.0.5';
|
|
15
15
|
|
|
16
16
|
// Colors (respects NO_COLOR)
|
|
17
17
|
const noColor = process.env.NO_COLOR !== undefined;
|
|
@@ -44,6 +44,7 @@ Commands:
|
|
|
44
44
|
flush Execute decisions
|
|
45
45
|
peer Manage peers
|
|
46
46
|
doctor Check system health
|
|
47
|
+
update Update cn to latest version
|
|
47
48
|
|
|
48
49
|
Aliases:
|
|
49
50
|
i = inbox, s = status, d = doctor
|
|
@@ -241,6 +242,24 @@ if (command === 'init') {
|
|
|
241
242
|
process.exit(1);
|
|
242
243
|
}
|
|
243
244
|
|
|
245
|
+
if (command === 'update') {
|
|
246
|
+
// Check if already on latest
|
|
247
|
+
try {
|
|
248
|
+
const latest = execSync('npm view cnagent version', { encoding: 'utf8' }).trim();
|
|
249
|
+
if (VERSION === latest) {
|
|
250
|
+
ok(`Already up to date (v${VERSION})`);
|
|
251
|
+
process.exit(0);
|
|
252
|
+
}
|
|
253
|
+
info(`Updating cnagent v${VERSION} → v${latest}...`);
|
|
254
|
+
execSync('npm install -g cnagent@latest', { stdio: 'inherit' });
|
|
255
|
+
ok(`Updated to v${latest}`);
|
|
256
|
+
} catch (e) {
|
|
257
|
+
fail('Update failed. Try: npm install -g cnagent@latest');
|
|
258
|
+
process.exit(1);
|
|
259
|
+
}
|
|
260
|
+
process.exit(0);
|
|
261
|
+
}
|
|
262
|
+
|
|
244
263
|
// Find hub
|
|
245
264
|
const hubPath = findHubPath();
|
|
246
265
|
if (!hubPath) {
|