Refactoring (#43)

* Cleanup .gitignore

* Document minimum server version

* Become golint compliant

* Use pre defined http method

* Update dependencies

* Add i18n-extract target

* Add golint target

* Run check-style against all go files

Co-Authored-By: Jesse Hallam <jesse.hallam@gmail.com>
This commit is contained in:
Hanzei 2019-06-22 16:15:48 +02:00 committed by GitHub
parent 2f14f54b59
commit 43af4d9cfe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 351 additions and 83 deletions

View file

View file

@ -10,18 +10,18 @@ import (
"github.com/pkg/errors"
)
const pluginIdGoFileTemplate = `package main
const pluginIDGoFileTemplate = `package main
var manifest = struct {
Id string
ID string
Version string
}{
Id: "%s",
ID: "%s",
Version: "%s",
}
`
const pluginIdJsFileTemplate = `export const id = '%s';
const pluginIDJSFileTemplate = `export const id = '%s';
export const version = '%s';
`
@ -38,7 +38,7 @@ func main() {
cmd := os.Args[1]
switch cmd {
case "id":
dumpPluginId(manifest)
dumpPluginID(manifest)
case "version":
dumpPluginVersion(manifest)
@ -87,7 +87,7 @@ func findManifest() (*model.Manifest, error) {
}
// dumpPluginId writes the plugin id from the given manifest to standard out
func dumpPluginId(manifest *model.Manifest) {
func dumpPluginID(manifest *model.Manifest) {
fmt.Printf("%s", manifest.Id)
}
@ -101,7 +101,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")
@ -111,7 +111,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")

View file

@ -28,6 +28,12 @@ HAS_WEBAPP ?= $(shell build/bin/manifest has_webapp)
# Determine if a /public folder is in use
HAS_PUBLIC ?= $(wildcard public/.)
# Determine if the mattermost-utilities repo is present
HAS_MM_UTILITIES ?= $(wildcard $(MM_UTILITIES_DIR)/.)
# Store the current path for later use
PWD ?= $(shell pwd)
# Ensure that npm (and thus node) is installed.
ifneq ($(HAS_WEBAPP),)
ifeq ($(NPM),)