From de41aa04fd8f1d4abb7d7bba276e9439da737c2c Mon Sep 17 00:00:00 2001 From: Technomancer702 Date: Thu, 5 Feb 2026 01:42:58 -0800 Subject: [PATCH] feat: enhance plugin system with async support and lifecycle hooks & reverted PR #79 due to Node.js v24 stream compatibility issues --- test-plugin-system.js | 72 ------------------------------------------- 1 file changed, 72 deletions(-) delete mode 100644 test-plugin-system.js diff --git a/test-plugin-system.js b/test-plugin-system.js deleted file mode 100644 index a82cf99..0000000 --- a/test-plugin-system.js +++ /dev/null @@ -1,72 +0,0 @@ -// Test script to verify plugin system improvements -const path = require('path'); -const fs = require('fs'); - -console.log('๐Ÿงช Testing Plugin System Improvements\n'); - -// Test 1: Services freezing -console.log('Test 1: Services Object Freezing'); -const services = { - testService: { name: 'test' }, - anotherService: { value: 123 } -}; -Object.freeze(services); - -try { - services.newService = { bad: 'should fail' }; - console.log('โŒ FAIL: Services object is mutable'); -} catch (e) { - console.log('โœ“ PASS: Cannot add new services (frozen)'); -} - -// In strict mode, this would throw. In non-strict, it silently fails -if (!services.newService) { - console.log('โœ“ PASS: Services object is frozen\n'); -} - -// Test 2: Sorted loading -console.log('Test 2: Sorted Plugin Loading'); -const pluginsDir = path.join(__dirname, 'server', 'plugins'); -if (fs.existsSync(pluginsDir)) { - const pluginFiles = fs.readdirSync(pluginsDir) - .filter(f => f.endsWith('.js')) - .sort(); - console.log('Plugin load order:', pluginFiles); - console.log('โœ“ PASS: Plugins sorted alphabetically\n'); -} - -// Test 3: Async function support -console.log('Test 3: Async Plugin Support'); -const asyncPlugin = async (app, services) => { - await new Promise(resolve => setTimeout(resolve, 10)); - return 'async complete'; -}; - -(async () => { - const result = await asyncPlugin({}, services); - console.log('โœ“ PASS: Async plugin executed:', result, '\n'); - - // Test 4: Lifecycle hooks - console.log('Test 4: Lifecycle Hooks Support'); - const lifecyclePlugin = { - init: async (app, services) => { - console.log(' - init() called'); - return 'initialized'; - }, - shutdown: async () => { - console.log(' - shutdown() called'); - } - }; - - if (typeof lifecyclePlugin.init === 'function') { - await lifecyclePlugin.init({}, services); - console.log('โœ“ PASS: Lifecycle init works'); - } - - if (typeof lifecyclePlugin.shutdown === 'function') { - await lifecyclePlugin.shutdown(); - console.log('โœ“ PASS: Lifecycle shutdown works\n'); - } - - console.log('โœ… All tests passed!'); -})();