@web-auto/camo 0.1.16 → 0.1.18
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/package.json +1 -1
- package/src/cli.mjs +19 -0
- package/src/utils/help.mjs +1 -0
package/package.json
CHANGED
package/src/cli.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
+
import { readFileSync } from 'node:fs';
|
|
4
5
|
import { listProfiles, getDefaultProfile, loadConfig, hasStartScript, setRepoRoot } from './utils/config.mjs';
|
|
5
6
|
import { printHelp, printProfilesAndHint } from './utils/help.mjs';
|
|
6
7
|
import { handleProfileCommand } from './commands/profile.mjs';
|
|
@@ -34,6 +35,19 @@ import { ensureProgressEventDaemon } from './events/daemon.mjs';
|
|
|
34
35
|
|
|
35
36
|
const CURRENT_DIR = path.dirname(fileURLToPath(import.meta.url));
|
|
36
37
|
const START_SCRIPT_REL = path.join('runtime', 'infra', 'utils', 'scripts', 'service', 'start-browser-service.mjs');
|
|
38
|
+
const PACKAGE_JSON_PATH = path.resolve(CURRENT_DIR, '..', 'package.json');
|
|
39
|
+
|
|
40
|
+
function readCliVersion() {
|
|
41
|
+
try {
|
|
42
|
+
const raw = JSON.parse(readFileSync(PACKAGE_JSON_PATH, 'utf8'));
|
|
43
|
+
const version = String(raw?.version || '').trim();
|
|
44
|
+
return version || '0.0.0';
|
|
45
|
+
} catch {
|
|
46
|
+
return '0.0.0';
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const CLI_VERSION = readCliVersion();
|
|
37
51
|
|
|
38
52
|
function readFlagValue(args, names) {
|
|
39
53
|
for (let i = 0; i < args.length; i += 1) {
|
|
@@ -177,6 +191,11 @@ async function main() {
|
|
|
177
191
|
return;
|
|
178
192
|
}
|
|
179
193
|
|
|
194
|
+
if (cmd === 'version' || cmd === '--version' || cmd === '-v') {
|
|
195
|
+
console.log(CLI_VERSION);
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
|
|
180
199
|
if (cmd === '__session-watchdog') {
|
|
181
200
|
await handleSessionWatchdogCommand(args);
|
|
182
201
|
return;
|