Files
worldwideview/scripts/watch-local-plugins.mjs
Antigravity AI ab80dad42b refactor(plugins): migrate legacy plugins to local-plugins architecture
- Migrated wwv-plugin-gps-jamming to local-plugins and fixed WebSocket payload handling (Patch)

- Migrated wwv-plugin-fortiguard to local-plugins and refactored API proxy fetch logic (Patch)

- Migrated wwv-plugin-nz-traffic-cameras to local-plugins (Patch)

- Cleaned up tutorial plugin wwv-plugin-iss from tree (Patch)

- Added scripts/migrate-plugin.mjs for automation (Patch)
2026-05-11 19:24:19 +12:00

42 lines
1.3 KiB
JavaScript

// scripts/watch-local-plugins.mjs
import fs from "fs";
import path from "path";
import { fileURLToPath } from "url";
import { syncAll } from "./sync-local-plugins.mjs";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const ROOT = path.resolve(__dirname, "..");
const LOCAL_PLUGINS_DIR = path.join(ROOT, "local-plugins");
if (!fs.existsSync(LOCAL_PLUGINS_DIR)) {
fs.mkdirSync(LOCAL_PLUGINS_DIR, { recursive: true });
}
let debounceTimeout = null;
function handleFileChange(eventType, filename) {
if (filename && (filename.includes("dist") || filename.includes("node_modules") || filename.endsWith(".map"))) return; // ignore build artifacts
if (debounceTimeout) {
clearTimeout(debounceTimeout);
}
debounceTimeout = setTimeout(async () => {
console.log(`\n[watch] Change detected in local plugins (file: ${filename}). Syncing...`);
try {
await syncAll();
} catch (err) {
console.error(`[watch] Sync failed:`, err);
}
}, 500);
}
// Initial sync
console.log(`[watch] Starting initial sync...`);
syncAll().then(() => {
console.log(`[watch] Watching ${LOCAL_PLUGINS_DIR} for changes...`);
fs.watch(LOCAL_PLUGINS_DIR, { recursive: true }, handleFileChange);
}).catch(err => {
console.error(`[watch] Initial sync failed:`, err);
});