respect plugin manifest webapp bundle_path (#8393)
Этот коммит содержится в:
коммит произвёл
Christopher Brown
родитель
e4ddad16bf
Коммит
98e1231fcc
@@ -173,6 +173,11 @@ func (m *Manifest) ClientManifest() *Manifest {
|
|||||||
cm.Name = ""
|
cm.Name = ""
|
||||||
cm.Description = ""
|
cm.Description = ""
|
||||||
cm.Backend = nil
|
cm.Backend = nil
|
||||||
|
if cm.Webapp != nil {
|
||||||
|
cm.Webapp = new(ManifestWebapp)
|
||||||
|
*cm.Webapp = *m.Webapp
|
||||||
|
cm.Webapp.BundlePath = "/static/" + m.Id + "_bundle.js"
|
||||||
|
}
|
||||||
return cm
|
return cm
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"path/filepath"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
@@ -163,12 +164,24 @@ func (env *Environment) ActivatePlugin(id string) error {
|
|||||||
return fmt.Errorf("env missing webapp path, cannot activate plugin: %v", id)
|
return fmt.Errorf("env missing webapp path, cannot activate plugin: %v", id)
|
||||||
}
|
}
|
||||||
|
|
||||||
webappBundle, err := ioutil.ReadFile(fmt.Sprintf("%s/%s/webapp/%s_bundle.js", env.searchPath, id, id))
|
bundlePath := filepath.Clean(bundle.Manifest.Webapp.BundlePath)
|
||||||
|
if bundlePath == "" || bundlePath[0] == '.' {
|
||||||
|
return fmt.Errorf("invalid webapp bundle path")
|
||||||
|
}
|
||||||
|
bundlePath = filepath.Join(env.searchPath, id, bundlePath)
|
||||||
|
|
||||||
|
webappBundle, err := ioutil.ReadFile(bundlePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if supervisor != nil {
|
// Backwards compatibility for plugins where webapp.bundle_path was ignored. This should
|
||||||
supervisor.Stop()
|
// be removed eventually.
|
||||||
|
if webappBundle2, err2 := ioutil.ReadFile(fmt.Sprintf("%s/%s/webapp/%s_bundle.js", env.searchPath, id, id)); err2 == nil {
|
||||||
|
webappBundle = webappBundle2
|
||||||
|
} else {
|
||||||
|
if supervisor != nil {
|
||||||
|
supervisor.Stop()
|
||||||
|
}
|
||||||
|
return errors.Wrapf(err, "unable to read webapp bundle: %v", id)
|
||||||
}
|
}
|
||||||
return errors.Wrapf(err, "unable to read webapp bundle: %v", id)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ioutil.WriteFile(fmt.Sprintf("%s/%s_bundle.js", env.webappPath, id), webappBundle, 0644)
|
err = ioutil.WriteFile(fmt.Sprintf("%s/%s_bundle.js", env.webappPath, id), webappBundle, 0644)
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user