fix: install managed monitor from temp clone
This commit is contained in:
@@ -112,6 +112,10 @@ function copyDir(src, dest, { exclude = [] } = {}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function shellEscape(value) {
|
||||||
|
return `'${String(value).replace(/'/g, `'"'"'`)}'`;
|
||||||
|
}
|
||||||
|
|
||||||
function detectEnvironment() {
|
function detectEnvironment() {
|
||||||
const totalSteps = options.installCli ? 6 : 5;
|
const totalSteps = options.installCli ? 6 : 5;
|
||||||
logStep(1, totalSteps, 'Detecting environment...');
|
logStep(1, totalSteps, 'Detecting environment...');
|
||||||
@@ -176,35 +180,26 @@ async function build() {
|
|||||||
logOk('plugin compiled');
|
logOk('plugin compiled');
|
||||||
}
|
}
|
||||||
|
|
||||||
function findMonitorSource(projectRoot) {
|
|
||||||
const candidates = [
|
|
||||||
join(projectRoot, 'HarborForge.Monitor'),
|
|
||||||
resolve(projectRoot, '..', 'HarborForge.Monitor'),
|
|
||||||
];
|
|
||||||
return candidates.find((p) => existsSync(p)) || null;
|
|
||||||
}
|
|
||||||
|
|
||||||
function installManagedMonitor(openclawPath) {
|
function installManagedMonitor(openclawPath) {
|
||||||
if (options.installMonitor !== 'yes') return null;
|
if (options.installMonitor !== 'yes') return null;
|
||||||
const projectRoot = resolve(__dirname, '..');
|
const projectRoot = resolve(__dirname, '..');
|
||||||
const monitorSrc = findMonitorSource(projectRoot);
|
const gitRoot = exec('git config --get remote.origin.url', { cwd: projectRoot, silent: true }).trim();
|
||||||
if (!monitorSrc) {
|
const monitorRepo = gitRoot.replace(/HarborForge\.OpenclawPlugin(\.git)?$/, 'HarborForge.Monitor.git');
|
||||||
logWarn('HarborForge.Monitor source not found; skipping managed monitor install');
|
const tmpDir = join('/tmp', `harborforge-monitor-${Date.now()}`);
|
||||||
return null;
|
const monitorDestDir = join(openclawPath, 'plugins', PLUGIN_NAME, 'bin');
|
||||||
}
|
|
||||||
const monitorDestDir = join(openclawPath, 'managed', 'harborforge-monitor');
|
|
||||||
rmSync(monitorDestDir, { recursive: true, force: true });
|
|
||||||
mkdirSync(monitorDestDir, { recursive: true });
|
|
||||||
copyDir(monitorSrc, monitorDestDir, { exclude: ['.git', 'node_modules', 'bin', 'obj'] });
|
|
||||||
const binaryPath = join(monitorDestDir, 'HarborForge.Monitor');
|
const binaryPath = join(monitorDestDir, 'HarborForge.Monitor');
|
||||||
|
mkdirSync(monitorDestDir, { recursive: true });
|
||||||
try {
|
try {
|
||||||
exec(`go build -o ${binaryPath} .`, { cwd: monitorDestDir, silent: !options.verbose });
|
exec(`git clone --branch ${shellEscape(options.monitorBranch)} ${shellEscape(monitorRepo)} ${shellEscape(tmpDir)}`, { silent: !options.verbose });
|
||||||
|
exec(`go build -o ${shellEscape(binaryPath)} .`, { cwd: tmpDir, silent: !options.verbose });
|
||||||
chmodSync(binaryPath, 0o755);
|
chmodSync(binaryPath, 0o755);
|
||||||
logOk(`Managed monitor installed → ${binaryPath} (branch hint: ${options.monitorBranch})`);
|
logOk(`Managed monitor installed → ${binaryPath} (branch hint: ${options.monitorBranch})`);
|
||||||
return binaryPath;
|
return binaryPath;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logWarn(`Managed monitor build failed: ${err.message}`);
|
logWarn(`Managed monitor build failed: ${err.message}`);
|
||||||
return null;
|
return null;
|
||||||
|
} finally {
|
||||||
|
rmSync(tmpDir, { recursive: true, force: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,7 +283,7 @@ async function install() {
|
|||||||
|
|
||||||
// Copy compiled plugin (no server directory — sidecar removed)
|
// Copy compiled plugin (no server directory — sidecar removed)
|
||||||
mkdirSync(destDir, { recursive: true });
|
mkdirSync(destDir, { recursive: true });
|
||||||
copyDir(PLUGIN_SRC_DIR, destDir, { exclude: ['node_modules', '.git', '*.ts'] });
|
copyDir(PLUGIN_SRC_DIR, destDir, { exclude: ['node_modules', '.git'] });
|
||||||
logOk(`Plugin files → ${destDir}`);
|
logOk(`Plugin files → ${destDir}`);
|
||||||
|
|
||||||
// Copy skills (exclude hf/ unless --install-cli)
|
// Copy skills (exclude hf/ unless --install-cli)
|
||||||
@@ -376,8 +371,7 @@ async function configure() {
|
|||||||
logOk(`plugins.allow includes ${PLUGIN_NAME}`);
|
logOk(`plugins.allow includes ${PLUGIN_NAME}`);
|
||||||
|
|
||||||
if (options.installMonitor === 'yes') {
|
if (options.installMonitor === 'yes') {
|
||||||
const projectRoot = resolve(__dirname, '..');
|
const binaryPath = join(openclawPath, 'plugins', PLUGIN_NAME, 'bin', 'HarborForge.Monitor');
|
||||||
const binaryPath = join(openclawPath, 'managed', 'harborforge-monitor', 'HarborForge.Monitor');
|
|
||||||
const entry = getOpenclawConfig(`plugins.entries.${PLUGIN_NAME}`, {}) || {};
|
const entry = getOpenclawConfig(`plugins.entries.${PLUGIN_NAME}`, {}) || {};
|
||||||
const config = entry.config || {};
|
const config = entry.config || {};
|
||||||
config.managedMonitor = binaryPath;
|
config.managedMonitor = binaryPath;
|
||||||
@@ -448,7 +442,7 @@ async function uninstall() {
|
|||||||
logOk('Removed hf CLI binary');
|
logOk('Removed hf CLI binary');
|
||||||
}
|
}
|
||||||
|
|
||||||
const managedDir = join(openclawPath, 'managed', 'harborforge-monitor');
|
const managedDir = join(openclawPath, 'plugins', PLUGIN_NAME, 'bin');
|
||||||
if (existsSync(managedDir)) {
|
if (existsSync(managedDir)) {
|
||||||
rmSync(managedDir, { recursive: true, force: true });
|
rmSync(managedDir, { recursive: true, force: true });
|
||||||
logOk('Removed managed HarborForge monitor');
|
logOk('Removed managed HarborForge monitor');
|
||||||
|
|||||||
Reference in New Issue
Block a user