@justin0713/opspilot 1.0.7 → 1.0.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/opspilot.js +61 -1
  2. package/package.json +1 -1
package/bin/opspilot.js CHANGED
@@ -340,6 +340,64 @@ function cmdConfig() {
340
340
  console.log(JSON.stringify(safe, null, 2));
341
341
  }
342
342
 
343
+ function cmdUninstall(flags) {
344
+ const keepData = flags['keep-data'] || false;
345
+ const cfg = loadConfig();
346
+ const data = cfg.dataDir || 'opspilot-data';
347
+
348
+ console.log('');
349
+ log('Uninstalling OpsPilot Local...');
350
+
351
+ // 1. Stop + remove container
352
+ if (tryRun('docker --version')) {
353
+ const status = tryRun(`docker inspect -f "{{.State.Status}}" ${CONTAINER} 2>/dev/null`);
354
+ if (status) {
355
+ log('Stopping container...');
356
+ try { run(`docker stop ${CONTAINER}`, { silent: true }); } catch (_) {}
357
+ try { run(`docker rm -f ${CONTAINER}`, { silent: true }); } catch (_) {}
358
+ ok('Container removed.');
359
+ }
360
+
361
+ // 2. Remove data volume (unless --keep-data)
362
+ if (!keepData) {
363
+ const volExists = tryRun(`docker volume inspect ${data} 2>/dev/null`);
364
+ if (volExists) {
365
+ log(`Removing data volume '${data}'...`);
366
+ try { run(`docker volume rm ${data}`, { silent: true }); ok('Data volume removed.'); }
367
+ catch (_) { warn(`Could not remove volume '${data}' — remove manually: docker volume rm ${data}`); }
368
+ }
369
+ } else {
370
+ warn(`Data volume '${data}' kept (--keep-data). Remove manually later: docker volume rm ${data}`);
371
+ }
372
+
373
+ // 3. Remove Docker image
374
+ const imgExists = tryRun(`docker image inspect ${IMAGE} 2>/dev/null`);
375
+ if (imgExists) {
376
+ log(`Removing image ${IMAGE}...`);
377
+ try { run(`docker rmi ${IMAGE}`, { silent: true }); ok('Image removed.'); } catch (_) {}
378
+ }
379
+ } else {
380
+ warn('Docker not available — skipping container/volume cleanup.');
381
+ }
382
+
383
+ // 4. Remove local CLI config + credentials
384
+ const toDelete = [CONFIG_FILE, CREDENTIALS_FILE, SETUP_TOKEN_FILE];
385
+ toDelete.forEach(f => {
386
+ try { if (fs.existsSync(f)) { fs.unlinkSync(f); } } catch (_) {}
387
+ });
388
+ // Remove config dir if empty
389
+ try {
390
+ const remaining = fs.readdirSync(CONFIG_DIR);
391
+ if (remaining.length === 0) fs.rmdirSync(CONFIG_DIR);
392
+ } catch (_) {}
393
+
394
+ ok('OpsPilot Local uninstalled.');
395
+ console.log('');
396
+ console.log(`To reinstall: ${CYAN}opspilot start --token <license-token>${RESET}`);
397
+ console.log(`To remove CLI: ${CYAN}npm uninstall -g @justin0713/opspilot${RESET}`);
398
+ console.log('');
399
+ }
400
+
343
401
  function cmdInstallGuide() {
344
402
  const platform = os.platform();
345
403
  console.log(`
@@ -399,6 +457,7 @@ ${BOLD}Commands:${RESET}
399
457
  ${CYAN}status${RESET} Show container status
400
458
  ${CYAN}config${RESET} Show saved local config
401
459
  ${CYAN}password${RESET} Show first-run admin password (--clear to delete after reading)
460
+ ${CYAN}uninstall${RESET} Remove container, image, data volume and local config
402
461
  ${CYAN}install-guide${RESET} Show Docker installation instructions for your platform
403
462
 
404
463
  ${BOLD}Start options:${RESET}
@@ -440,7 +499,8 @@ switch (cmd) {
440
499
  break;
441
500
  case 'status': cmdStatus(); break;
442
501
  case 'config': cmdConfig(); break;
443
- case 'install-guide': cmdInstallGuide(); break;
502
+ case 'uninstall': cmdUninstall(parsed.flags); break;
503
+ case 'install-guide': cmdInstallGuide(); break;
444
504
  case 'password':
445
505
  if (parsed.flags.clear) {
446
506
  try { fs.unlinkSync(CREDENTIALS_FILE); ok('Credentials file cleared.'); }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@justin0713/opspilot",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "CLI installer for OpsPilot Local — self-hosted SSH operations platform",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/Albert0977/ShellShare#readme",