This is an automated email from the ASF dual-hosted git repository.

linkinstar pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/answer.git


The following commit(s) were added to refs/heads/dev by this push:
     new 01238d55 feat(build): add plugin vendor directory management function
01238d55 is described below

commit 01238d5506015566cfede8d76ce698fb7cef59d5
Author: Lukin <[email protected]>
AuthorDate: Thu Feb 20 15:24:45 2025 +0800

    feat(build): add plugin vendor directory management function
    
    Implement movePluginToVendor to handle plugin directory organization during 
build process
---
 internal/cli/build.go | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/internal/cli/build.go b/internal/cli/build.go
index 46df8741..d8a12644 100644
--- a/internal/cli/build.go
+++ b/internal/cli/build.go
@@ -125,6 +125,7 @@ func BuildNewAnswer(buildDir, outputPath string, plugins 
[]string, originalAnswe
        builder := 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 dir
 func copyUIFiles(b *buildingMaterial) (err error) {
        goListCmd := b.newExecCmd("go", "list", "-mod=mod", "-m", "-f", 
"{{.Dir}}", "github.com/apache/answer")

Reply via email to