@commandgarden/cli 1.0.2 → 1.1.0
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/dist/main.js +31 -5
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -8,6 +8,8 @@ var __export = (target, all) => {
|
|
|
8
8
|
// src/main.ts
|
|
9
9
|
import { Command } from "commander";
|
|
10
10
|
import { join as join3, dirname } from "path";
|
|
11
|
+
import { existsSync as existsSync4 } from "fs";
|
|
12
|
+
import { createRequire } from "module";
|
|
11
13
|
import { homedir } from "os";
|
|
12
14
|
import { fileURLToPath } from "url";
|
|
13
15
|
|
|
@@ -5009,8 +5011,32 @@ async function executeDown(cgHome) {
|
|
|
5009
5011
|
// src/main.ts
|
|
5010
5012
|
var __filename = fileURLToPath(import.meta.url);
|
|
5011
5013
|
var __dirname = dirname(__filename);
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
+
function resolveScript(relativePath, packageName, entryPoint) {
|
|
5015
|
+
const relative = join3(__dirname, relativePath);
|
|
5016
|
+
if (existsSync4(relative)) return relative;
|
|
5017
|
+
try {
|
|
5018
|
+
const require2 = createRequire(import.meta.url);
|
|
5019
|
+
const pkgJsonPath = require2.resolve(`${packageName}/package.json`);
|
|
5020
|
+
const resolved = join3(dirname(pkgJsonPath), entryPoint);
|
|
5021
|
+
if (existsSync4(resolved)) return resolved;
|
|
5022
|
+
} catch {
|
|
5023
|
+
}
|
|
5024
|
+
console.error(`Cannot find ${packageName} entry point.`);
|
|
5025
|
+
console.error(`Looked at:
|
|
5026
|
+
- ${relative}`);
|
|
5027
|
+
console.error(`
|
|
5028
|
+
If @commandgarden/cli is installed globally, also run:`);
|
|
5029
|
+
console.error(` cd <monorepo>/commandGarden/${packageName.split("/").pop()} && npm link`);
|
|
5030
|
+
process.exit(1);
|
|
5031
|
+
}
|
|
5032
|
+
var _daemonScript;
|
|
5033
|
+
function getDaemonScript() {
|
|
5034
|
+
return _daemonScript ??= resolveScript("../../daemon/dist/main.js", "@commandgarden/daemon", "dist/main.js");
|
|
5035
|
+
}
|
|
5036
|
+
var _appScript;
|
|
5037
|
+
function getAppScript() {
|
|
5038
|
+
return _appScript ??= resolveScript("../../app/dist/server/main.js", "@commandgarden/app", "dist/server/main.js");
|
|
5039
|
+
}
|
|
5014
5040
|
var CG_HOME = join3(homedir(), ".commandgarden");
|
|
5015
5041
|
var TOKEN_PATH = join3(CG_HOME, "session-token");
|
|
5016
5042
|
var CONFIG_PATH = join3(CG_HOME, "config.yaml");
|
|
@@ -5047,7 +5073,7 @@ daemon.command("status").description("Check daemon status").action(async () => {
|
|
|
5047
5073
|
console.log(await executeDaemonStatus(BASE_URL));
|
|
5048
5074
|
});
|
|
5049
5075
|
daemon.command("start").description("Start the daemon in background").action(async () => {
|
|
5050
|
-
console.log(await executeDaemonStart(BASE_URL, CG_HOME,
|
|
5076
|
+
console.log(await executeDaemonStart(BASE_URL, CG_HOME, getDaemonScript()));
|
|
5051
5077
|
});
|
|
5052
5078
|
daemon.command("stop").description("Stop the daemon").action(async () => {
|
|
5053
5079
|
console.log(await executeDaemonStop(CG_HOME));
|
|
@@ -5084,7 +5110,7 @@ config.command("set <key> <value>").description("Set a configuration value (e.g.
|
|
|
5084
5110
|
});
|
|
5085
5111
|
var gui = program.command("gui").description("Manage the GUI app server");
|
|
5086
5112
|
gui.command("start", { isDefault: true }).description("Start the GUI (foreground by default)").option("-b, --background", "Run in background").option("--no-open", "Do not open browser").action(async (opts) => {
|
|
5087
|
-
console.log(await executeGuiStart(BASE_URL, CG_HOME,
|
|
5113
|
+
console.log(await executeGuiStart(BASE_URL, CG_HOME, getAppScript(), {
|
|
5088
5114
|
background: opts.background,
|
|
5089
5115
|
noOpen: opts.open === false,
|
|
5090
5116
|
configPath: CONFIG_PATH
|
|
@@ -5097,7 +5123,7 @@ gui.command("status").description("Check GUI status").action(() => {
|
|
|
5097
5123
|
console.log(executeGuiStatus(CG_HOME));
|
|
5098
5124
|
});
|
|
5099
5125
|
program.command("up").description("Start daemon + GUI, open browser").action(async () => {
|
|
5100
|
-
console.log(await executeUp(BASE_URL, CG_HOME,
|
|
5126
|
+
console.log(await executeUp(BASE_URL, CG_HOME, getDaemonScript(), getAppScript(), CONFIG_PATH));
|
|
5101
5127
|
});
|
|
5102
5128
|
program.command("down").description("Stop GUI + daemon").action(async () => {
|
|
5103
5129
|
console.log(await executeDown(CG_HOME));
|