A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.
chore(plugins): Add plugin to index.ts
robin6f71805c3d97
diff --git a/ui/scripts/plugin.js b/ui/scripts/plugin.jsindex 0dad3090..48a37ef5 100644--- a/ui/scripts/plugin.js+++ b/ui/scripts/plugin.js@@ -20,6 +20,11 @@const path = require('path');const fs = require('fs');+function pascalize(str) {+ str = str.replace(/[-_\s]+/g, '');+ return str.charAt(0).toUpperCase() + str.slice(1);+}+const pluginPath = path.join(__dirname, '../src/plugins');const pluginFolders = fs.readdirSync(pluginPath);@@ -42,5 +47,17 @@ pluginFolders.forEach((folder) => {packageJsonPath,JSON.stringify(packageJsonContent, null, 2),);+++ // add plugin to index.ts last line+ const indexTsPath = path.join(pluginPath, 'index.ts');+ const indexTsContent = fs.readFileSync(indexTsPath, 'utf-8');+ const lines = indexTsContent.split('\n');+ const ComponentName = pascalize(packageName);+ const importLine = `export { default as ${ComponentName} } from '${packageName}';`;+ if (!lines.includes(importLine)) {+ lines.push(importLine);+ }+ fs.writeFileSync(indexTsPath, lines.join('\n'));}});