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(build): add plugin vendor directory management function
Lukin01238d550601
diff --git a/internal/cli/build.go b/internal/cli/build.goindex 46df8741..d8a12644 100644--- a/internal/cli/build.go+++ b/internal/cli/build.go@@ -125,6 +125,7 @@ func BuildNewAnswer(buildDir, outputPath string, plugins []string, originalAnswebuilder := newAnswerBuilder(buildDir, outputPath, plugins, originalAnswerInfo)builder.DoTask(createMainGoFile)builder.DoTask(downloadGoModFile)+ builder.DoTask(movePluginToVendor)builder.DoTask(copyUIFiles)builder.DoTask(buildUI)builder.DoTask(mergeI18nFiles)@@ -221,6 +222,24 @@ func downloadGoModFile(b *buildingMaterial) (err error) {return}+// movePluginToVendor move plugin to vendor dir+// Traverse the plugins, and if the plugin path is not github.com/apache/answer-plugins, move the contents of the current plugin to the vendor/github.com/apache/answer-plugins/ directory.+func movePluginToVendor(b *buildingMaterial) (err error) {+ pluginsDir := filepath.Join(b.tmpDir, "vendor/github.com/apache/answer-plugins/")+ for _, p := range b.plugins {+ pluginDir := filepath.Join(b.tmpDir, "vendor/", p.Name)+ pluginName := filepath.Base(p.Name)+ if !strings.HasPrefix(p.Name, "github.com/apache/answer-plugins/") {+ fmt.Printf("try to copy dir from %s to %s\n", pluginDir, filepath.Join(pluginsDir, pluginName))+ err = copyDirEntries(os.DirFS(pluginDir), ".", filepath.Join(pluginsDir, pluginName), "node_modules")+ if err != nil {+ return err+ }+ }+ }+ return nil+}+// copyUIFiles copy ui files from answer module to tmp dirfunc copyUIFiles(b *buildingMaterial) (err error) {goListCmd := b.newExecCmd("go", "list", "-mod=mod", "-m", "-f", "{{.Dir}}", "github.com/apache/answer")