Files
lnreader-plugins/scripts/generate-plugin-index.js
T
Rajarshee Chatterjee 20c2b75b01 refactor: Overhaul Plugin Architecture & Playground UI (#1846)
* refactor: Move Plugins Out and Consolidate with Multisrc

* feat: Overhaul Playground UI

* feat: Add Filters to New UI

* feat: Persist Selected Plugin

* feat: Add Direct Parse Novel/Chapter Options and Feedback Toasts

[skip ci]

* feat: UX Improvements

* chore: Update Plugin Path in Publish Workflow

* fix: Add Backward Compatibility

* chore: Update Plugin Publishing Script
2025-10-20 22:54:08 +05:30

29 lines
969 B
JavaScript

import fs from 'fs';
import { execSync } from 'child_process';
let content = `import { Plugin } from '@/types/plugin';\n`;
let pluginCounter = 0;
const PLUGIN_DIR = 'plugins';
fs.readdirSync(PLUGIN_DIR)
.filter(f => !f.includes('index') && f !== 'multisrc')
.forEach(langName => {
const LANG_DIR = PLUGIN_DIR + '/' + langName;
fs.readdirSync(LANG_DIR)
.filter(f => !f.includes('broken') && !f.startsWith('.'))
.forEach(pluginName => {
content += `import p_${pluginCounter} from '@plugins/${langName}/${pluginName.replace(/\.ts$/, '')}';\n`;
pluginCounter += 1;
});
});
content += `\nconst PLUGINS: Plugin.PluginBase[] = [${Array(pluginCounter)
.fill()
.map((v, index) => 'p_' + index.toString())
.join(', ')}];\nexport default PLUGINS`;
const outputPath = './plugins/index.ts';
fs.writeFileSync(outputPath, content, { encoding: 'utf-8' });
execSync(`npx prettier --write ${outputPath}`, { stdio: 'inherit' });