Skip to content

Commit

Permalink
Removed build folder from gitignore
Browse files Browse the repository at this point in the history
  • Loading branch information
Billy Ernest committed Mar 12, 2019
1 parent cb0feea commit e3f5066
Show file tree
Hide file tree
Showing 324 changed files with 57,947 additions and 2 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
node_modules
build
dist

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ git clone https://github.com/wbernest/mattermost-plugin-rssfeed

Build your plugin:
```
make
make dist
```

This will produce a single plugin file (with support for multiple architectures) for upload to your Mattermost server:
Expand Down
1 change: 1 addition & 0 deletions build/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bin
Empty file added build/manifest/.gitignore
Empty file.
136 changes: 136 additions & 0 deletions build/manifest/Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions build/manifest/Gopkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[prune]
go-tests = true
unused-packages = true

[[constraint]]
name = "github.com/mattermost/mattermost-server"
version = "~5.6.0"

[[constraint]]
name = "github.com/pkg/errors"
version = "0.8.0"
122 changes: 122 additions & 0 deletions build/manifest/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
package main

import (
"encoding/json"
"fmt"
"io/ioutil"
"os"

"github.com/mattermost/mattermost-server/model"
"github.com/pkg/errors"
)

const pluginIdGoFileTemplate = `package main
var manifest = struct {
Id string
Version string
}{
Id: "%s",
Version: "%s",
}
`

const pluginIdJsFileTemplate = `export const id = '%s';
export const version = '%s';
`

func main() {
if len(os.Args) <= 1 {
panic("no cmd specified")
}

manifest, err := findManifest()
if err != nil {
panic("failed to find manifest: " + err.Error())
}

cmd := os.Args[1]
switch cmd {
case "id":
dumpPluginId(manifest)

case "version":
dumpPluginVersion(manifest)

case "has_server":
if manifest.HasServer() {
fmt.Printf("true")
}

case "has_webapp":
if manifest.HasWebapp() {
fmt.Printf("true")
}

case "apply":
if err := applyManifest(manifest); err != nil {
panic("failed to apply manifest: " + err.Error())
}

default:
panic("unrecognized command: " + cmd)
}
}

func findManifest() (*model.Manifest, error) {
_, manifestFilePath, err := model.FindManifest(".")
if err != nil {
return nil, errors.Wrap(err, "failed to find manifest in current working directory")
}
manifestFile, err := os.Open(manifestFilePath)
if err != nil {
return nil, errors.Wrapf(err, "failed to open %s", manifestFilePath)
}
defer manifestFile.Close()

// Re-decode the manifest, disallowing unknown fields. When we write the manifest back out,
// we don't want to accidentally clobber anything we won't preserve.
var manifest model.Manifest
decoder := json.NewDecoder(manifestFile)
decoder.DisallowUnknownFields()
if err = decoder.Decode(&manifest); err != nil {
return nil, errors.Wrap(err, "failed to parse manifest")
}

return &manifest, nil
}

// dumpPluginId writes the plugin id from the given manifest to standard out
func dumpPluginId(manifest *model.Manifest) {
fmt.Printf("%s", manifest.Id)
}

// dumpPluginVersion writes the plugin version from the given manifest to standard out
func dumpPluginVersion(manifest *model.Manifest) {
fmt.Printf("%s", manifest.Version)
}

// applyManifest propagates the plugin_id into the server and webapp folders, as necessary
func applyManifest(manifest *model.Manifest) error {
if manifest.HasServer() {
if err := ioutil.WriteFile(
"server/manifest.go",
[]byte(fmt.Sprintf(pluginIdGoFileTemplate, manifest.Id, manifest.Version)),
0644,
); err != nil {
return errors.Wrap(err, "failed to write server/manifest.go")
}
}

if manifest.HasWebapp() {
if err := ioutil.WriteFile(
"webapp/src/manifest.js",
[]byte(fmt.Sprintf(pluginIdJsFileTemplate, manifest.Id, manifest.Version)),
0644,
); err != nil {
return errors.Wrap(err, "failed to open webapp/src/manifest.js")
}
}

return nil
}
21 changes: 21 additions & 0 deletions build/manifest/vendor/github.com/blang/semver/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions build/manifest/vendor/github.com/blang/semver/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e3f5066

Please sign in to comment.