You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@answer.apache.org by ro...@apache.org on 2024/07/04 08:56:38 UTC
(incubator-answer) branch chore/update-plugin-script created (now 9272e354)
This is an automated email from the ASF dual-hosted git repository.
robin0716 pushed a change to branch chore/update-plugin-script
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git
at 9272e354 feat: Update plugin.js to use humps for pascalizing package names
This branch includes the following new commits:
new 9272e354 feat: Update plugin.js to use humps for pascalizing package names
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(incubator-answer) 01/01: feat: Update plugin.js to use humps for pascalizing package names
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
robin0716 pushed a commit to branch chore/update-plugin-script
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git
commit 9272e3544d208f4d22f052e0c45db57def8cf9e1
Author: robin <ro...@rnode.me>
AuthorDate: Thu Jul 4 16:56:24 2024 +0800
feat: Update plugin.js to use humps for pascalizing package names
---
ui/scripts/plugin.js | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/ui/scripts/plugin.js b/ui/scripts/plugin.js
index 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);
}