From 71f33564089c49c990d5313019b0a0a865db6d7c Mon Sep 17 00:00:00 2001 From: Abhishek Verma <72438220+avas27JTG@users.noreply.github.com> Date: Wed, 4 Jan 2023 16:08:32 +0530 Subject: [PATCH 1/9] [MI-2504][server+webapp]: Generated manifest files and Changed "Hide" to "Close" on filter popover. (#17) (#21) * [MI-2504][webapp]: Changed Hide to Close on filter popover * [MI-2504][server]: Generated manifest files * [MI-2504][server]: Updated version in manifest Co-authored-by: Abhishek Verma Co-authored-by: Abhishek Verma --- Makefile | 5 ++ build/manifest/main.go | 51 +++++++++++++++++++ server/plugin/manifest.go | 11 ++++ .../containers/Rhs/projectDetails/header.tsx | 2 +- 4 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 server/plugin/manifest.go diff --git a/Makefile b/Makefile index f98b74e8..e9d579a0 100644 --- a/Makefile +++ b/Makefile @@ -31,6 +31,11 @@ ifneq ($(wildcard build/custom.mk),) include build/custom.mk endif +## Propagates plugin manifest information into the server/ and webapp/ folders as required. +.PHONY: apply +apply: + ./build/bin/manifest apply + ## Checks the code style, tests, builds and bundles the plugin. .PHONY: all all: check-style test dist diff --git a/build/manifest/main.go b/build/manifest/main.go index 1c6da231..9d744694 100644 --- a/build/manifest/main.go +++ b/build/manifest/main.go @@ -3,12 +3,33 @@ package main import ( "encoding/json" "fmt" + "io/ioutil" "os" "github.com/mattermost/mattermost-server/v5/model" "github.com/pkg/errors" ) +const pluginIDGoFileTemplate = `// This file is automatically generated. Do not modify it manually. + +package plugin + +var manifest = struct { + ID string + Version string +}{ + ID: "%s", + Version: "%s", +} +` + +const pluginIDTSFileTemplate = `import manifest from '../../plugin.json'; + +export default manifest; +export const id = manifest.id; +export const version = manifest.version; +` + func main() { if len(os.Args) <= 1 { panic("no cmd specified") @@ -37,6 +58,11 @@ func main() { fmt.Printf("true") } + case "apply": + if err := applyManifest(manifest); err != nil { + panic("failed to apply manifest: " + err.Error()) + } + default: panic("unrecognized command: " + cmd) } @@ -74,3 +100,28 @@ func dumpPluginID(manifest *model.Manifest) { 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/plugin/manifest.go", + []byte(fmt.Sprintf(pluginIDGoFileTemplate, manifest.Id, manifest.Version)), + 0600, + ); err != nil { + return errors.Wrap(err, "failed to write server/plugin/manifest.go") + } + } + + if manifest.HasWebapp() { + if err := ioutil.WriteFile( + "webapp/src/manifest.ts", + []byte(pluginIDTSFileTemplate), + 0600, + ); err != nil { + return errors.Wrap(err, "failed to write webapp/src/manifest.ts") + } + } + + return nil +} diff --git a/server/plugin/manifest.go b/server/plugin/manifest.go new file mode 100644 index 00000000..27a69ba3 --- /dev/null +++ b/server/plugin/manifest.go @@ -0,0 +1,11 @@ +// This file is automatically generated. Do not modify it manually. + +package plugin + +var manifest = struct { + ID string + Version string +}{ + ID: "mattermost-plugin-azure-devops", + Version: "2.2.1", +} diff --git a/webapp/src/containers/Rhs/projectDetails/header.tsx b/webapp/src/containers/Rhs/projectDetails/header.tsx index 7bb9cbe6..ea7b3abd 100644 --- a/webapp/src/containers/Rhs/projectDetails/header.tsx +++ b/webapp/src/containers/Rhs/projectDetails/header.tsx @@ -234,7 +234,7 @@ const Header = ({projectDetails, showAllSubscriptions, handlePagination, setShow isDisabled={!isFilterApplied()} />