refactor(installer): detect existing install via plugins.entries.dirigent registration
This commit is contained in:
@@ -232,14 +232,21 @@ function clone(v) {
|
||||
return JSON.parse(JSON.stringify(v));
|
||||
}
|
||||
|
||||
function isDirigentRegistered() {
|
||||
const entry = getJson(PATH_PLUGIN_ENTRY);
|
||||
return !!(entry && typeof entry === "object");
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
// INSTALL
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
if (mode === "install") {
|
||||
// Check if already installed - if so, uninstall first
|
||||
// Check if plugin is already registered in config.
|
||||
// Prefer record-based uninstall when record exists; otherwise continue with in-place overwrite.
|
||||
const registered = isDirigentRegistered();
|
||||
const existingRecord = findLatestInstallRecord();
|
||||
if (existingRecord) {
|
||||
console.log("[dirigent] existing installation detected, uninstalling first...");
|
||||
if (registered && existingRecord) {
|
||||
console.log("[dirigent] existing plugin registration detected (with install record), uninstalling first...");
|
||||
process.env.RECORD_FILE = existingRecord;
|
||||
const result = spawnSync(process.execPath, [import.meta.filename, "--uninstall"], {
|
||||
env: { ...process.env, OPENCLAW_DIR },
|
||||
@@ -250,6 +257,8 @@ if (mode === "install") {
|
||||
process.exit(1);
|
||||
}
|
||||
console.log("[dirigent] previous installation removed, proceeding with fresh install...");
|
||||
} else if (registered) {
|
||||
console.log("[dirigent] existing plugin registration detected (no install record). Proceeding with in-place reinstall...");
|
||||
}
|
||||
|
||||
// 1. Build dist
|
||||
|
||||
Reference in New Issue
Block a user