@justin0713/opspilot 1.0.6 → 1.0.7
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/opspilot.js +122 -12
- package/package.json +1 -1
package/bin/opspilot.js
CHANGED
|
@@ -56,11 +56,75 @@ function tryRun(cmd) {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
function checkDocker() {
|
|
59
|
-
if (
|
|
59
|
+
if (tryRun('docker --version')) return; // already installed
|
|
60
|
+
|
|
61
|
+
const platform = os.platform();
|
|
62
|
+
warn('Docker is not installed. Attempting auto-install...');
|
|
63
|
+
|
|
64
|
+
if (platform === 'darwin') {
|
|
65
|
+
// macOS — prefer Colima (lightweight, no GUI, works on managed Macs)
|
|
66
|
+
if (tryRun('brew --version')) {
|
|
67
|
+
log('Installing Colima + Docker CLI via Homebrew (no Docker Desktop needed)...');
|
|
68
|
+
try {
|
|
69
|
+
run('brew install colima docker');
|
|
70
|
+
log('Starting Colima...');
|
|
71
|
+
run('colima start');
|
|
72
|
+
ok('Docker is ready via Colima.');
|
|
73
|
+
return;
|
|
74
|
+
} catch (e) {
|
|
75
|
+
warn('Colima install failed. Trying Docker Desktop...');
|
|
76
|
+
try {
|
|
77
|
+
run('brew install --cask docker');
|
|
78
|
+
warn('Docker Desktop installed. Please open Docker Desktop from Applications,');
|
|
79
|
+
warn('wait for the whale icon in the menu bar, then run: opspilot start again.');
|
|
80
|
+
process.exit(0);
|
|
81
|
+
} catch (_) {}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// No Homebrew
|
|
60
85
|
die(
|
|
61
|
-
'Docker is
|
|
62
|
-
' Install
|
|
86
|
+
'Docker is required but could not be auto-installed.\n\n' +
|
|
87
|
+
' Option 1 — Install Homebrew first, then retry:\n' +
|
|
88
|
+
' /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"\n\n' +
|
|
89
|
+
' Option 2 — Install OrbStack (lightweight Docker Desktop alternative):\n' +
|
|
90
|
+
' https://orbstack.dev\n\n' +
|
|
91
|
+
' Option 3 — Run without Docker (Python only):\n' +
|
|
92
|
+
' opspilot install-guide'
|
|
63
93
|
);
|
|
94
|
+
|
|
95
|
+
} else if (platform === 'linux') {
|
|
96
|
+
log('Installing Docker via get.docker.com...');
|
|
97
|
+
try {
|
|
98
|
+
run('curl -fsSL https://get.docker.com | sh');
|
|
99
|
+
const user = tryRun('whoami');
|
|
100
|
+
if (user && user !== 'root') {
|
|
101
|
+
try { run(`sudo usermod -aG docker ${user}`); } catch (_) {}
|
|
102
|
+
warn(`Added ${user} to docker group. You may need to log out and back in.`);
|
|
103
|
+
}
|
|
104
|
+
ok('Docker installed. Starting Docker service...');
|
|
105
|
+
try { run('sudo systemctl enable --now docker'); } catch (_) {}
|
|
106
|
+
return;
|
|
107
|
+
} catch (e) {
|
|
108
|
+
die(
|
|
109
|
+
'Auto-install failed. Install Docker manually:\n' +
|
|
110
|
+
' https://docs.docker.com/engine/install/'
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
} else {
|
|
115
|
+
// Windows or unknown
|
|
116
|
+
die(
|
|
117
|
+
'Docker is required.\n\n' +
|
|
118
|
+
' Download Docker Desktop for Windows:\n' +
|
|
119
|
+
' https://docs.docker.com/desktop/install/windows-install/\n\n' +
|
|
120
|
+
' After installing, open Docker Desktop and wait for it to start,\n' +
|
|
121
|
+
' then run: opspilot start'
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Final check after auto-install
|
|
126
|
+
if (!tryRun('docker --version')) {
|
|
127
|
+
die('Docker still not available after install. Please reopen your terminal and try again.');
|
|
64
128
|
}
|
|
65
129
|
}
|
|
66
130
|
|
|
@@ -276,6 +340,50 @@ function cmdConfig() {
|
|
|
276
340
|
console.log(JSON.stringify(safe, null, 2));
|
|
277
341
|
}
|
|
278
342
|
|
|
343
|
+
function cmdInstallGuide() {
|
|
344
|
+
const platform = os.platform();
|
|
345
|
+
console.log(`
|
|
346
|
+
${BOLD}${CYAN}OpsPilot Local — Docker Install Guide${RESET}
|
|
347
|
+
|
|
348
|
+
Docker is required to run OpsPilot Local.
|
|
349
|
+
The CLI will auto-install Docker when you run ${CYAN}opspilot start${RESET}.
|
|
350
|
+
|
|
351
|
+
${BOLD}Auto-install behaviour by platform:${RESET}
|
|
352
|
+
|
|
353
|
+
${BOLD}macOS${RESET}
|
|
354
|
+
• If Homebrew is installed → installs ${CYAN}Colima + Docker CLI${RESET} automatically
|
|
355
|
+
(lightweight, no Docker Desktop, works on managed/corporate Macs)
|
|
356
|
+
• If Homebrew is missing → installs Homebrew first:
|
|
357
|
+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
|
358
|
+
Then retry: ${CYAN}opspilot start --token <token>${RESET}
|
|
359
|
+
|
|
360
|
+
${BOLD}Linux${RESET}
|
|
361
|
+
• Runs the official Docker install script automatically:
|
|
362
|
+
curl -fsSL https://get.docker.com | sh
|
|
363
|
+
|
|
364
|
+
${BOLD}Windows${RESET}
|
|
365
|
+
• Cannot auto-install. Download Docker Desktop:
|
|
366
|
+
https://docs.docker.com/desktop/install/windows-install/
|
|
367
|
+
|
|
368
|
+
${BOLD}Manual install options (macOS):${RESET}
|
|
369
|
+
|
|
370
|
+
1. ${CYAN}Colima${RESET} — lightweight, CLI-only, free (recommended for managed Macs)
|
|
371
|
+
brew install colima docker
|
|
372
|
+
colima start
|
|
373
|
+
|
|
374
|
+
2. ${CYAN}OrbStack${RESET} — lightweight Docker Desktop alternative
|
|
375
|
+
brew install orbstack
|
|
376
|
+
# or: https://orbstack.dev
|
|
377
|
+
|
|
378
|
+
3. ${CYAN}Docker Desktop${RESET} — official GUI app
|
|
379
|
+
brew install --cask docker
|
|
380
|
+
# or: https://www.docker.com/products/docker-desktop/
|
|
381
|
+
|
|
382
|
+
${BOLD}Current platform:${RESET} ${platform}
|
|
383
|
+
${BOLD}Docker status :${RESET} ${tryRun('docker --version') || RED + 'not found' + RESET}
|
|
384
|
+
`);
|
|
385
|
+
}
|
|
386
|
+
|
|
279
387
|
function printHelp() {
|
|
280
388
|
console.log(`
|
|
281
389
|
${BOLD}${CYAN}OpsPilot Local${RESET} — CLI v${PKG_VERSION}
|
|
@@ -284,13 +392,14 @@ ${BOLD}Usage:${RESET}
|
|
|
284
392
|
opspilot <command> [options]
|
|
285
393
|
|
|
286
394
|
${BOLD}Commands:${RESET}
|
|
287
|
-
${CYAN}start${RESET}
|
|
288
|
-
${CYAN}stop${RESET}
|
|
289
|
-
${CYAN}logs${RESET}
|
|
290
|
-
${CYAN}update${RESET}
|
|
291
|
-
${CYAN}status${RESET}
|
|
292
|
-
${CYAN}config${RESET}
|
|
293
|
-
${CYAN}password${RESET}
|
|
395
|
+
${CYAN}start${RESET} Pull image and start the container ${YELLOW}(auto-installs Docker if missing)${RESET}
|
|
396
|
+
${CYAN}stop${RESET} Stop and remove the container
|
|
397
|
+
${CYAN}logs${RESET} Show container logs (-f to follow)
|
|
398
|
+
${CYAN}update${RESET} Pull latest image and restart
|
|
399
|
+
${CYAN}status${RESET} Show container status
|
|
400
|
+
${CYAN}config${RESET} Show saved local config
|
|
401
|
+
${CYAN}password${RESET} Show first-run admin password (--clear to delete after reading)
|
|
402
|
+
${CYAN}install-guide${RESET} Show Docker installation instructions for your platform
|
|
294
403
|
|
|
295
404
|
${BOLD}Start options:${RESET}
|
|
296
405
|
--token <token> License token from OpsPilot Cloud ${YELLOW}(required)${RESET}
|
|
@@ -329,8 +438,9 @@ switch (cmd) {
|
|
|
329
438
|
cmdStart(Object.assign({}, cfg, parsed.flags));
|
|
330
439
|
})();
|
|
331
440
|
break;
|
|
332
|
-
case 'status':
|
|
333
|
-
case 'config':
|
|
441
|
+
case 'status': cmdStatus(); break;
|
|
442
|
+
case 'config': cmdConfig(); break;
|
|
443
|
+
case 'install-guide': cmdInstallGuide(); break;
|
|
334
444
|
case 'password':
|
|
335
445
|
if (parsed.flags.clear) {
|
|
336
446
|
try { fs.unlinkSync(CREDENTIALS_FILE); ok('Credentials file cleared.'); }
|
package/package.json
CHANGED