tweak plugin id/version injection
* define BUNDLE_NAME after including build/setup.mk (just for clarity, not correctness) * separate plugin id from version with dash in bundle name to match Mattermost package * fix various js/go idioms (some pre-existing!) * fix error message
This commit is contained in:
parent
a0e9acdbaf
commit
5b2980d1ac
6 changed files with 28 additions and 17 deletions
|
@ -10,15 +10,20 @@ import (
|
|||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
const PluginIdGoFileTemplate = `package main
|
||||
const pluginIdGoFileTemplate = `package main
|
||||
|
||||
const PluginId = "%s"
|
||||
const PluginVersion = "%s"
|
||||
var manifest = struct {
|
||||
Id string
|
||||
Version string
|
||||
}{
|
||||
Id: "%s",
|
||||
Version: "%s",
|
||||
}
|
||||
`
|
||||
|
||||
const PluginIdJsFileTemplate = `export default {
|
||||
PluginId: '%s',
|
||||
PluginVersion: '%s',
|
||||
const pluginIdJsFileTemplate = `export default {
|
||||
id: '%s',
|
||||
version: '%s',
|
||||
};
|
||||
`
|
||||
|
||||
|
@ -98,7 +103,7 @@ func applyManifest(manifest *model.Manifest) error {
|
|||
if manifest.HasServer() {
|
||||
if err := ioutil.WriteFile(
|
||||
"server/manifest.go",
|
||||
[]byte(fmt.Sprintf(PluginIdGoFileTemplate, manifest.Id, manifest.Version)),
|
||||
[]byte(fmt.Sprintf(pluginIdGoFileTemplate, manifest.Id, manifest.Version)),
|
||||
0644,
|
||||
); err != nil {
|
||||
return errors.Wrap(err, "failed to write server/manifest.go")
|
||||
|
@ -108,7 +113,7 @@ func applyManifest(manifest *model.Manifest) error {
|
|||
if manifest.HasWebapp() {
|
||||
if err := ioutil.WriteFile(
|
||||
"webapp/src/manifest.js",
|
||||
[]byte(fmt.Sprintf(PluginIdJsFileTemplate, manifest.Id, manifest.Version)),
|
||||
[]byte(fmt.Sprintf(pluginIdJsFileTemplate, manifest.Id, manifest.Version)),
|
||||
0644,
|
||||
); err != nil {
|
||||
return errors.Wrap(err, "failed to open webapp/src/manifest.js")
|
||||
|
|
Reference in a new issue