prior-cli 1.3.6 → 1.3.8

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.
Files changed (2) hide show
  1. package/bin/prior.js +47 -0
  2. package/package.json +1 -1
package/bin/prior.js CHANGED
@@ -1259,6 +1259,53 @@ program
1259
1259
  } catch (err) { console.error(c.err(` ✗ ${err.message}`)); }
1260
1260
  });
1261
1261
 
1262
+ // ── UPDATE ─────────────────────────────────────────────────────
1263
+ program
1264
+ .command('update')
1265
+ .description('Check for updates and install if available')
1266
+ .action(async () => {
1267
+ const { execSync } = require('child_process');
1268
+ console.log('');
1269
+ process.stdout.write(c.dim(' Checking for updates…'));
1270
+
1271
+ const fetch = require('node-fetch');
1272
+ let latest;
1273
+ try {
1274
+ const res = await fetch('https://registry.npmjs.org/prior-cli/latest', { timeout: 8000 });
1275
+ if (!res.ok) throw new Error(`Registry error: HTTP ${res.status}`);
1276
+ const data = await res.json();
1277
+ latest = data.version;
1278
+ } catch (err) {
1279
+ clearLine();
1280
+ console.error(c.err(` ✗ Could not reach npm registry: ${err.message}\n`));
1281
+ return;
1282
+ }
1283
+
1284
+ clearLine();
1285
+
1286
+ if (latest === version) {
1287
+ console.log(c.ok(' ✓ Already up to date ') + c.muted(`v${version}`));
1288
+ console.log('');
1289
+ return;
1290
+ }
1291
+
1292
+ console.log(` ${c.muted('Current :')} ${c.white(`v${version}`)}`);
1293
+ console.log(` ${c.muted('Latest :')} ${c.bold(`v${latest}`)}`);
1294
+ console.log('');
1295
+ process.stdout.write(c.dim(' Installing update…'));
1296
+
1297
+ try {
1298
+ execSync('npm install -g prior-cli@latest', { stdio: 'ignore' });
1299
+ clearLine();
1300
+ console.log(c.ok(` ✓ Updated to v${latest} `) + c.muted('restart prior to apply'));
1301
+ } catch (err) {
1302
+ clearLine();
1303
+ console.error(c.err(` ✗ Install failed: ${err.message}`));
1304
+ console.error(c.muted(' Try manually: npm install -g prior-cli@latest'));
1305
+ }
1306
+ console.log('');
1307
+ });
1308
+
1262
1309
  // ── Entry point ────────────────────────────────────────────────
1263
1310
  program
1264
1311
  .name('prior')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prior-cli",
3
- "version": "1.3.6",
3
+ "version": "1.3.8",
4
4
  "description": "Prior Network AI — command-line interface",
5
5
  "bin": {
6
6
  "prior": "bin/prior.js"