From 50baf5b263ccdba55e59535835f8ff253a64b957 Mon Sep 17 00:00:00 2001 From: Chetanya Kandhari Date: Mon, 11 Feb 2019 13:05:21 +0530 Subject: [PATCH] MI-321: Update the plugin boilerplate --- .circleci/config.yml | 5 +- Makefile | 89 +++++++++++++------------------- server/glide.lock | 6 +-- server/glide.yaml | 2 +- webapp/package-lock.json | 109 ++++++++++++++++++--------------------- webapp/package.json | 14 ++--- 6 files changed, 98 insertions(+), 127 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index fed9736..b5b6443 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -16,13 +16,10 @@ jobs: name: Restore NPM dependencies cache key: dependency-cache-{{ checksum "./webapp/package-lock.json" }} - type: shell - name: 'Build artifacts' + name: 'Check for style guide compliance, run test cases and build artifacts' command: make dist environment: TERM: dumb - - run: - name: Test - command: make test - save_cache: name: Save Golang dependencies cache key: dependency-cache-{{ checksum "./server/glide.lock" }} diff --git a/Makefile b/Makefile index edd5e8a..ced8c09 100644 --- a/Makefile +++ b/Makefile @@ -14,45 +14,39 @@ HAS_SERVER=$(shell if [ "$(shell grep -E '[\^"]server["][ ]*[:]' $(MANIFEST_FILE TMPFILEGOLINT=golint.tmp -BLACK=`tput setaf 0` -RED=`tput setaf 1` -GREEN=`tput setaf 2` -YELLOW=`tput setaf 3` -BLUE=`tput setaf 4` -MAGENTA=`tput setaf 5` -CYAN=`tput setaf 6` -WHITE=`tput setaf 7` +BLACK=`tput -Txterm setaf 0` +RED=`tput -Txterm setaf 1` +GREEN=`tput -Txterm setaf 2` +YELLOW=`tput -Txterm setaf 3` +BLUE=`tput -Txterm setaf 4` +MAGENTA=`tput -Txterm setaf 5` +CYAN=`tput -Txterm setaf 6` +WHITE=`tput -Txterm setaf 7` -BOLD=`tput bold` -INVERSE=`tput rev` -RESET=`tput sgr0` +BOLD=`tput -Txterm bold` +INVERSE=`tput -Txterm rev` +RESET=`tput -Txterm sgr0` -.PHONY: default pre-run test clean check-style check-js check-go govet golint gofmt .distclean dist fix format fix-js fix-go github-release +.PHONY: default setup-plugin build test clean check-style check-js check-go govet golint gofmt .distclean dist format fix-js fix-go trigger-release install-dependencies -default: check-style test dist +default: dist -pre-run: +setup-plugin: ifneq ($(HAS_WEBAPP),) - @echo "export const PLUGIN_NAME = '`echo $(PLUGINNAME)`';\ - " > webapp/src/constants/manifest.js + @echo "export const PLUGIN_NAME = '`echo $(PLUGINNAME)`';" > webapp/src/constants/manifest.js endif ifneq ($(HAS_SERVER),) - @echo "package config\n\nconst (\n\ - PluginName = \""`echo $(PLUGINNAME)`"\"\n)" > server/config/manifest.go - + @echo "package config\n\nconst (\n\tPluginName = \""`echo $(PLUGINNAME)`"\"\n)" > server/config/manifest.go endif -github-release: +trigger-release: @if [ $$(git status --porcelain | wc -l) != "0" -o $$(git rev-list HEAD@{upstream}..HEAD | wc -l) != "0" ]; \ then echo ${RED}"local repo is not clean"${RESET}; exit 1; fi; @echo ${BOLD}"Creating a tag to trigger circleci build-and-release job\n"${RESET} git tag $(PLUGINVERSION) git push origin $(PLUGINVERSION) -check-style: .npminstall vendor - @echo ${BOLD}"Checking for style guide compliance\n"${RESET} - @make check-js - @make check-go +check-style: check-js check-go check-js: ifneq ($(HAS_WEBAPP),) @@ -65,11 +59,7 @@ check-go: server govet golint gofmt govet: ifneq ($(HAS_SERVER),) - @go tool vet 2>/dev/null ; if [ $$? -eq 3 ]; then \ - echo "--> installing govet"; \ - go get golang.org/x/tools/cmd/vet; \ - fi - @echo ${BOLD}Running GOVET${RESET}${RED} + @echo ${BOLD}Running GOVET${RESET} @cd server $(eval PKGS := $(shell go list ./... | grep -v /vendor/)) @$(GO) vet $(PKGS) @@ -78,11 +68,7 @@ endif golint: ifneq ($(HAS_SERVER),) - @command -v golint >/dev/null ; if [ $$? -ne 0 ]; then \ - echo "--> installing golint"; \ - go get -u golang.org/x/lint/golint; \ - fi - @echo ${BOLD}Running GOLINT${RESET}${RED} + @echo ${BOLD}Running GOLINT${RESET} @cd server $(eval PKGS := $(shell go list ./... | grep -v /vendor/)) @touch $(TMPFILEGOLINT) @@ -91,14 +77,12 @@ ifneq ($(HAS_SERVER),) done @grep -Ev "^$$" $(TMPFILEGOLINT) || true @if [ "$$(grep -Ev "^$$" $(TMPFILEGOLINT) | wc -l)" -gt "0" ]; then \ - rm -f $(TMPFILEGOLINT); echo "golint failure\n"${RESET}; exit 1; else \ + rm -f $(TMPFILEGOLINT); echo ${RED}"golint failure\n"${RESET}; exit 1; else \ rm -f $(TMPFILEGOLINT); echo ${GREEN}"golint success\n"${RESET}; \ fi endif -format: fix - -fix: fix-js fix-go +format: fix-js fix-go fix-js: ifneq ($(HAS_WEBAPP),) @@ -109,10 +93,6 @@ endif fix-go: ifneq ($(HAS_SERVER),) - @command -v goimports >/dev/null ; if [ $$? -ne 0 ]; then \ - echo "--> installing goimports"; \ - go get golang.org/x/tools/cmd/goimports; \ - fi @echo ${BOLD}Formatting go giles${RESET} @cd server @find ./ -type f -name "*.go" -not -path "./server/vendor/*" -exec goimports -w {} \; @@ -121,14 +101,14 @@ endif gofmt: ifneq ($(HAS_SERVER),) - @echo ${BOLD}Running GOFMT${RESET}${RED} + @echo ${BOLD}Running GOFMT${RESET} @for package in $$(go list ./server/...); do \ files=$$(go list -f '{{range .GoFiles}}{{$$.Dir}}/{{.}} {{end}}' $$package); \ if [ "$$files" ]; then \ gofmt_output=$$(gofmt -d -s $$files 2>&1); \ if [ "$$gofmt_output" ]; then \ echo "$$gofmt_output"; \ - echo "gofmt failure\n"; \ + echo ${RED}"gofmt failure\n"${RESET}; \ exit 1; \ fi; \ fi; \ @@ -156,31 +136,32 @@ ifneq ($(HAS_SERVER),) @echo "\n" endif -dist: .distclean check-style $(MANIFEST_FILE) +install-dependencies: .npminstall vendor + +dist: install-dependencies check-style test build + +build: .distclean $(MANIFEST_FILE) @echo ${BOLD}"Building plugin\n"${RESET} + mkdir -p dist/$(PLUGINNAME)/ + cp $(MANIFEST_FILE) dist/$(PLUGINNAME)/ ifneq ($(HAS_WEBAPP),) # Build and copy files from webapp cd webapp && npm run build mkdir -p dist/$(PLUGINNAME)/webapp cp -r webapp/dist/* dist/$(PLUGINNAME)/webapp/ -else ifneq ($(HAS_SERVER),) - mkdir -p dist/$(PLUGINNAME)/ endif ifneq ($(HAS_SERVER),) - # Build files from server + # Build files from server and copy server executables cd server && go get github.com/mitchellh/gox $(shell go env GOPATH)/bin/gox -osarch='darwin/amd64 linux/amd64 windows/amd64' -output 'dist/intermediate/plugin_{{.OS}}_{{.Arch}}' ./server -endif + mkdir -p dist/$(PLUGINNAME)/server - # Copy plugin files - cp $(MANIFEST_FILE) dist/$(PLUGINNAME)/ +endif + # Compress plugin ifneq ($(HAS_SERVER),) - # Copy server executables & compress plugin - mkdir -p dist/$(PLUGINNAME)/server - mv dist/intermediate/plugin_darwin_amd64 dist/$(PLUGINNAME)/server/plugin.exe cd dist && tar -zcvf $(PACKAGENAME)-darwin-amd64.tar.gz $(PLUGINNAME)/* diff --git a/server/glide.lock b/server/glide.lock index 53b0caa..4e61c0d 100644 --- a/server/glide.lock +++ b/server/glide.lock @@ -1,5 +1,5 @@ -hash: 655ccb87e0d8a7030cfc905828ff7c8d673ac5531bb348c8f16e6d9ead9a8737 -updated: 2018-12-17T18:19:12.182226461+05:30 +hash: 81fcbe42732487b9325093fa8ad818ccd71502cffd5b21ea26011243a24c332a +updated: 2019-02-11T12:37:12.987426999+05:30 imports: - name: github.com/blang/semver version: 3c1074078d32d767e08ab2c8564867292da86926 @@ -40,7 +40,7 @@ imports: - name: github.com/magiconair/properties version: c2353362d570a7bfa228149c62842019201cfb71 - name: github.com/mattermost/mattermost-server - version: 0c1207215852a8726c3f09dea157d597fec368df + version: ad3ddac9b935fb842ca4301f69266ffb87ec8c86 subpackages: - einterfaces - mlog diff --git a/server/glide.yaml b/server/glide.yaml index f2c4008..b6327c1 100644 --- a/server/glide.yaml +++ b/server/glide.yaml @@ -1,7 +1,7 @@ package: github.com/Brightscout/mattermost-plugin-boilerplate/server import: - package: github.com/mattermost/mattermost-server - version: ~5.6.0 + version: ~5.7.1 subpackages: - plugin - package: golang.org/x/tools/cmd/vet diff --git a/webapp/package-lock.json b/webapp/package-lock.json index 54586eb..9806df8 100644 --- a/webapp/package-lock.json +++ b/webapp/package-lock.json @@ -632,11 +632,6 @@ "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", "dev": true }, - "asap": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", - "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=" - }, "asn1.js": { "version": "4.10.1", "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz", @@ -2291,11 +2286,6 @@ "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", "dev": true }, - "core-js": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-1.2.7.tgz", - "integrity": "sha1-ZSKUwUZR2yj6k70tX/KYOk8IxjY=" - }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", @@ -3169,20 +3159,6 @@ "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", "dev": true }, - "fbjs": { - "version": "0.8.17", - "resolved": "https://registry.npmjs.org/fbjs/-/fbjs-0.8.17.tgz", - "integrity": "sha1-xNWY6taUkRJlPWWIsBpc3Nn5D90=", - "requires": { - "core-js": "^1.0.0", - "isomorphic-fetch": "^2.1.1", - "loose-envify": "^1.0.0", - "object-assign": "^4.1.0", - "promise": "^7.1.1", - "setimmediate": "^1.0.5", - "ua-parser-js": "^0.7.18" - } - }, "figures": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", @@ -4066,9 +4042,19 @@ } }, "hoist-non-react-statics": { - "version": "2.5.5", - "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-2.5.5.tgz", - "integrity": "sha512-rqcy4pJo55FTTLWt+bU8ukscqHeE/e9KWvsOW2b/a3afxQZhwkQdT1rPPCJ0rYXdj4vNcasY8zHTH+jF/qStxw==" + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.0.tgz", + "integrity": "sha512-0XsbTXxgiaCDYDIWFcwkmerZPSwywfUqYmwT4jzewKTQSWoE6FCMoUVOeBJWK3E/CrWbxRG3m5GzY4lnIwGRBA==", + "requires": { + "react-is": "^16.7.0" + }, + "dependencies": { + "react-is": { + "version": "16.8.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.8.1.tgz", + "integrity": "sha512-ioMCzVDWvCvKD8eeT+iukyWrBGrA3DiFYkXfBsVYIRdaREZuBjENG+KjrikavCLasozqRWTwFUagU/O4vPpRMA==" + } + } }, "home-or-tmp": { "version": "2.0.0", @@ -4739,6 +4725,15 @@ "combined-stream": "1.0.6", "mime-types": "^2.1.12" } + }, + "redux": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/redux/-/redux-4.0.0.tgz", + "integrity": "sha512-NnnHF0h0WVE/hXyrB6OlX67LYRuaf/rJcbWvnHHEPCF/Xa/AZpwhs/20WyqzQae5x4SD2F9nPObgBh2rxAgLiA==", + "requires": { + "loose-envify": "^1.1.0", + "symbol-observable": "^1.2.0" + } } } }, @@ -5402,14 +5397,6 @@ "integrity": "sha1-ihvjZr+Pwj2yvSPxDG/pILQ4nR8=", "dev": true }, - "promise": { - "version": "7.3.1", - "resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz", - "integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==", - "requires": { - "asap": "~2.0.3" - } - }, "promise-inflight": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz", @@ -5523,14 +5510,14 @@ } }, "react": { - "version": "16.4.1", - "resolved": "https://registry.npmjs.org/react/-/react-16.4.1.tgz", - "integrity": "sha512-3GEs0giKp6E0Oh/Y9ZC60CmYgUPnp7voH9fbjWsvXtYFb4EWtgQub0ADSq0sJR0BbHc4FThLLtzlcFaFXIorwg==", + "version": "16.7.0", + "resolved": "https://registry.npmjs.org/react/-/react-16.7.0.tgz", + "integrity": "sha512-StCz3QY8lxTb5cl2HJxjwLFOXPIFQp+p+hxQfc8WE0QiLfCtIlKj8/+5tjjKm8uSTlAW+fCPaavGFS06V9Ar3A==", "requires": { - "fbjs": "^0.8.16", "loose-envify": "^1.1.0", "object-assign": "^4.1.1", - "prop-types": "^15.6.0" + "prop-types": "^15.6.2", + "scheduler": "^0.12.0" } }, "react-bootstrap": { @@ -5584,16 +5571,17 @@ } }, "react-redux": { - "version": "5.0.7", - "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-5.0.7.tgz", - "integrity": "sha512-5VI8EV5hdgNgyjfmWzBbdrqUkrVRKlyTKk1sGH3jzM2M2Mhj/seQgPXaz6gVAj2lz/nz688AdTqMO18Lr24Zhg==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-5.1.1.tgz", + "integrity": "sha512-LE7Ned+cv5qe7tMV5BPYkGQ5Lpg8gzgItK07c67yHvJ8t0iaD9kPFPAli/mYkiyJYrs2pJgExR2ZgsGqlrOApg==", "requires": { - "hoist-non-react-statics": "^2.5.0", - "invariant": "^2.0.0", - "lodash": "^4.17.5", - "lodash-es": "^4.17.5", + "@babel/runtime": "^7.1.2", + "hoist-non-react-statics": "^3.1.0", + "invariant": "^2.2.4", "loose-envify": "^1.1.0", - "prop-types": "^15.6.0" + "prop-types": "^15.6.1", + "react-is": "^16.6.0", + "react-lifecycles-compat": "^3.0.0" } }, "react-transition-group": { @@ -5655,11 +5643,11 @@ } }, "redux": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/redux/-/redux-4.0.0.tgz", - "integrity": "sha512-NnnHF0h0WVE/hXyrB6OlX67LYRuaf/rJcbWvnHHEPCF/Xa/AZpwhs/20WyqzQae5x4SD2F9nPObgBh2rxAgLiA==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/redux/-/redux-4.0.1.tgz", + "integrity": "sha512-R7bAtSkk7nY6O/OYMVR9RiBI+XghjF9rlbl5806HJbQph0LJVHZrU5oaO4q70eUKiqMRqm4y07KLTlMZ2BlVmg==", "requires": { - "loose-envify": "^1.1.0", + "loose-envify": "^1.4.0", "symbol-observable": "^1.2.0" } }, @@ -5948,6 +5936,15 @@ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, + "scheduler": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.12.0.tgz", + "integrity": "sha512-t7MBR28Akcp4Jm+QoR63XgAi9YgCUmgvDHqf5otgAj4QvdoBE4ImCX0ffehefePPG+aitiYHp0g/mW6s4Tp+dw==", + "requires": { + "loose-envify": "^1.1.0", + "object-assign": "^4.1.1" + } + }, "schema-utils": { "version": "0.4.7", "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-0.4.7.tgz", @@ -6013,7 +6010,8 @@ "setimmediate": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", - "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=" + "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=", + "dev": true }, "sha.js": { "version": "2.4.11", @@ -6612,11 +6610,6 @@ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", "dev": true }, - "ua-parser-js": { - "version": "0.7.18", - "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.18.tgz", - "integrity": "sha512-LtzwHlVHwFGTptfNSgezHp7WUlwiqb0gA9AALRbKaERfxwJoiX0A73QbTToxteIAuIaFshhgIZfqK8s7clqgnA==" - }, "uglify-es": { "version": "3.3.9", "resolved": "https://registry.npmjs.org/uglify-es/-/uglify-es-3.3.9.tgz", diff --git a/webapp/package.json b/webapp/package.json index ad093a6..c68d2be 100644 --- a/webapp/package.json +++ b/webapp/package.json @@ -1,7 +1,7 @@ { "name": "webapp", "version": "0.0.1", - "description": "This plugin demonstrates the capabilities of a Mattermost plugin.", + "description": "", "main": "src/index.js", "scripts": { "build": "webpack --mode=production", @@ -29,11 +29,11 @@ "webpack-cli": "^3.0.8" }, "dependencies": { - "mattermost-redux": "^5.6.0", - "react": "16.4.1", - "react-bootstrap": "^0.32.3", - "react-redux": "5.0.7", - "redux": "4.0.0", - "superagent": "^3.8.3" + "mattermost-redux": "5.6.0", + "react": "16.7.0", + "react-bootstrap": "0.32.4", + "react-redux": "5.1.1", + "redux": "4.0.1", + "superagent": "3.8.3" } }