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: Update plugin script
robin7f1186b01322
diff --git a/ui/.env.development b/ui/.env.developmentindex c78ae289..a634cee2 100644--- a/ui/.env.development+++ b/ui/.env.development@@ -1,2 +1,2 @@PUBLIC_URL-REACT_APP_API_URL = http://127.0.0.1+REACT_APP_API_URL = http://10.0.20.84:8080/diff --git a/ui/scripts/plugin.js b/ui/scripts/plugin.jsindex 873b19c5..823b6b6b 100644--- a/ui/scripts/plugin.js+++ b/ui/scripts/plugin.js@@ -1,29 +1,5 @@const path = require('path');const fs = require('fs');-const humps = require('humps');--const template = `-package {{slugName}}--import "github.com/answerdev/answer/plugin"--type {{pluginName}} struct {-}--func init() {- plugin.Register(&{{pluginName}}{})-}--func (d {{pluginName}}) Info() plugin.Info {- return plugin.Info{- Name: plugin.MakeTranslator("i18n.{{slugName}}.name"),- SlugName: "{{slugName}}",- Description: plugin.MakeTranslator("i18n.{{slugName}}.description"),- Author: "{{author}}",- Version: "{{version}}",- }-}-`;const pluginPath = path.join(__dirname, '../src/plugins');const pluginFolders = fs.readdirSync(pluginPath);@@ -36,28 +12,13 @@ pluginFolders.forEach((folder) => {return;}- const tsFile = fs.readFileSync(- path.join(pluginFolder, 'index.ts'),- 'utf-8',- );- const slugName = tsFile.match(/slug_name: '(.*)'/)[1];- const pluginName = humps.pascalize(slugName) + 'Plugin';+ // add plugin to package.jsonconst packageJson = require(path.join(pluginFolder, 'package.json'));-- const author = packageJson.author;- const version = packageJson.version;- const content = template- .replace(/{{slugName}}/g, slugName)- .replace(/{{pluginName}}/g, pluginName)- .replace(/{{author}}/g, author)- .replace(/{{version}}/g, version);- fs.writeFileSync(path.join(pluginFolder, `${slugName}.go`), content);-const packageName = packageJson.name;- // update package.json dependenciesconst packageJsonPath = path.join(__dirname, 'package.json');const packageJsonContent = require(packageJsonPath);packageJsonContent.dependencies[packageName] = 'workspace:*';+fs.writeFileSync(packageJsonPath,JSON.stringify(packageJsonContent, null, 2),