Add OpenClaw manifest and configure install
This commit is contained in:
46
install.mjs
46
install.mjs
@@ -73,7 +73,7 @@ function install() {
|
||||
console.log('');
|
||||
|
||||
// 1. Build
|
||||
log('[1/3] Building...', 'cyan');
|
||||
log('[1/4] Building...', 'cyan');
|
||||
execSync('npm install', { cwd: __dirname, stdio: 'inherit' });
|
||||
execSync('npm run build', { cwd: __dirname, stdio: 'inherit' });
|
||||
|
||||
@@ -84,7 +84,7 @@ function install() {
|
||||
logOk('Build complete');
|
||||
|
||||
// 2. Copy to plugins dir
|
||||
log('[2/3] Installing...', 'cyan');
|
||||
log('[2/4] Installing...', 'cyan');
|
||||
const openclawPath = resolveOpenclawPath();
|
||||
const destDir = join(openclawPath, 'plugins', PLUGIN_NAME);
|
||||
|
||||
@@ -94,8 +94,29 @@ function install() {
|
||||
copyDir(SRC_DIST_DIR, destDir);
|
||||
logOk(`Plugin files → ${destDir}`);
|
||||
|
||||
// 3. Summary
|
||||
log('[3/3] Done!', 'cyan');
|
||||
// 3. Configure OpenClaw
|
||||
log('[3/4] Configuring OpenClaw...', 'cyan');
|
||||
try {
|
||||
const pluginPath = destDir;
|
||||
const allow = ensureArray(getConfigValue('plugins.allow'));
|
||||
const loadPaths = ensureArray(getConfigValue('plugins.load.paths'));
|
||||
|
||||
if (!allow.includes(PLUGIN_NAME)) allow.push(PLUGIN_NAME);
|
||||
if (!loadPaths.includes(pluginPath)) loadPaths.push(pluginPath);
|
||||
|
||||
execSync(`openclaw config set plugins.allow '${JSON.stringify(allow)}'`);
|
||||
execSync(`openclaw config set plugins.load.paths '${JSON.stringify(loadPaths)}'`);
|
||||
execSync(`openclaw config set plugins.entries.${PLUGIN_NAME}.enabled true`);
|
||||
execSync(`openclaw config set plugins.entries.${PLUGIN_NAME}.config '{"enabled": true}'`);
|
||||
|
||||
logOk('OpenClaw config updated');
|
||||
} catch (err) {
|
||||
logErr('Failed to update OpenClaw config via `openclaw config set`');
|
||||
throw err;
|
||||
}
|
||||
|
||||
// 4. Summary
|
||||
log('[4/4] Done!', 'cyan');
|
||||
console.log('');
|
||||
log('✓ Yonexus installed successfully!', 'green');
|
||||
console.log('');
|
||||
@@ -104,6 +125,23 @@ function install() {
|
||||
console.log('');
|
||||
}
|
||||
|
||||
function getConfigValue(path) {
|
||||
try {
|
||||
const out = execSync(`openclaw config get ${path}`, { encoding: 'utf8' }).trim();
|
||||
if (!out || out === 'undefined' || out === 'null') return undefined;
|
||||
try { return JSON.parse(out); } catch { return out; }
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function ensureArray(value) {
|
||||
if (Array.isArray(value)) return value;
|
||||
if (value === undefined || value === null || value === '') return [];
|
||||
return [value];
|
||||
}
|
||||
|
||||
|
||||
// ── Uninstall ───────────────────────────────────────────────────────────
|
||||
|
||||
function uninstall() {
|
||||
|
||||
Reference in New Issue
Block a user