Merge pull request 'feat/uninstall-config-cleanup' (#4) from feat/uninstall-config-cleanup into main
Reviewed-on: #4
This commit was merged in pull request #4.
This commit is contained in:
72
install.mjs
72
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() {
|
||||
@@ -120,6 +158,32 @@ function uninstall() {
|
||||
logWarn(`${destDir} not found, nothing to remove`);
|
||||
}
|
||||
|
||||
// Clean OpenClaw config
|
||||
log('Cleaning OpenClaw config...', 'cyan');
|
||||
try {
|
||||
const allow = ensureArray(getConfigValue('plugins.allow')).filter((id) => id !== PLUGIN_NAME);
|
||||
const loadPaths = ensureArray(getConfigValue('plugins.load.paths')).filter((p) => p !== destDir);
|
||||
|
||||
if (allow.length > 0) {
|
||||
execSync(`openclaw config set plugins.allow '${JSON.stringify(allow)}'`);
|
||||
} else {
|
||||
execSync('openclaw config unset plugins.allow');
|
||||
}
|
||||
|
||||
if (loadPaths.length > 0) {
|
||||
execSync(`openclaw config set plugins.load.paths '${JSON.stringify(loadPaths)}'`);
|
||||
} else {
|
||||
execSync('openclaw config unset plugins.load.paths');
|
||||
}
|
||||
|
||||
execSync(`openclaw config unset plugins.entries.${PLUGIN_NAME}`);
|
||||
|
||||
logOk('OpenClaw config cleaned');
|
||||
} catch (err) {
|
||||
logErr('Failed to clean OpenClaw config via `openclaw config`');
|
||||
throw err;
|
||||
}
|
||||
|
||||
console.log('');
|
||||
log('✓ Yonexus uninstalled.', 'green');
|
||||
log('\nNext: openclaw gateway restart', 'yellow');
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"main": "dist/yonexus/index.js",
|
||||
"types": "dist/yonexus/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "tsc -p tsconfig.json && cp plugin.json dist/yonexus/plugin.json",
|
||||
"build": "tsc -p tsconfig.json && cp plugin.json dist/yonexus/plugin.json && cp plugin/openclaw.plugin.json dist/yonexus/openclaw.plugin.json",
|
||||
"clean": "rm -rf dist",
|
||||
"prepare": "npm run clean && npm run build",
|
||||
"test:smoke": "tsx tests/smoke.ts",
|
||||
|
||||
13
plugin/openclaw.plugin.json
Normal file
13
plugin/openclaw.plugin.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"id": "yonexus",
|
||||
"name": "Yonexus",
|
||||
"version": "0.2.0",
|
||||
"description": "Organization hierarchy, agent identity management, query DSL, and scope memory for OpenClaw",
|
||||
"configSchema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true,
|
||||
"properties": {
|
||||
"enabled": { "type": "boolean", "default": true }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user