Don't generate manifest.ts (#127)

This commit is contained in:
Ben Schumacher 2020-09-23 01:14:00 +02:00 committed by GitHub
parent eae9f9826a
commit 18d30b50bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 1 additions and 63 deletions

View file

@ -5,7 +5,6 @@ import (
"fmt"
"io/ioutil"
"os"
"strings"
"github.com/mattermost/mattermost-server/v5/model"
"github.com/pkg/errors"
@ -32,17 +31,6 @@ func init() {
}
`
const pluginIDJSFileTemplate = `// This file is automatically generated. Do not modify it manually.
const manifest = JSON.parse(` + "`" + `
%s
` + "`" + `);
export default manifest;
export const id = manifest.id;
export const version = manifest.version;
`
func main() {
if len(os.Args) <= 1 {
panic("no cmd specified")
@ -134,28 +122,5 @@ func applyManifest(manifest *model.Manifest) error {
}
}
if manifest.HasWebapp() {
// generate JSON representation of Manifest.
// JSON is very similar and compatible with JS's object literals. so, what we do here
// is actually JS code generation.
manifestBytes, err := json.MarshalIndent(manifest, "", " ")
if err != nil {
return err
}
manifestStr := string(manifestBytes)
// Escape newlines
manifestStr = strings.ReplaceAll(manifestStr, `\n`, `\\n`)
// write generated code to file by using JS file template.
if err := ioutil.WriteFile(
"webapp/src/manifest.ts",
[]byte(fmt.Sprintf(pluginIDJSFileTemplate, manifestStr)),
0600,
); err != nil {
return errors.Wrap(err, "failed to open webapp/src/manifest.js")
}
}
return nil
}