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.
feat: Update plugin.js to use humps for pascalizing package names
robin2ff6e7eab453
diff --git a/ui/scripts/plugin.js b/ui/scripts/plugin.jsindex cdd84d17..a0d31e0c 100644--- a/ui/scripts/plugin.js+++ b/ui/scripts/plugin.js@@ -19,15 +19,11 @@const path = require('path');const fs = require('fs');+const humps = require('humps');const pluginPath = path.join(__dirname, '../src/plugins');const pluginFolders = fs.readdirSync(pluginPath);-function pascalize(str) {- return str.replace(/\b\w/g, (match) => match.toUpperCase())- .replace(/[-_\s]+/g, '');-}-function resetPackageJson() {const packageJsonPath = path.join(__dirname, '..', 'package.json');const packageJsonContent = require(packageJsonPath);@@ -63,7 +59,7 @@ function addPluginToIndexTs(packageName) {const indexTsPath = path.join(pluginPath, 'index.ts');const indexTsContent = fs.readFileSync(indexTsPath, 'utf-8');const lines = indexTsContent.split('\n');- const ComponentName = pascalize(packageName);+ const ComponentName = humps.pascalize(packageName);const importLine = `export { default as ${ComponentName} } from '${packageName}';`;if (!lines.includes(importLine)) {lines.push(importLine);@@ -94,7 +90,6 @@ pluginFolders.forEach((folder) => {const packageJson = require(path.join(pluginFolder, 'package.json'));const packageName = packageJson.name;-addPluginToPackageJson(packageName);addPluginToIndexTs(packageName);}