1
0
mirror of https://github.com/mattermost/focalboard.git synced 2025-01-11 18:13:52 +02:00

Live Watch make target for improve the development experience (#1389)

* Live Watch make target for improve the development experience

* Fixing the pluginctl enable/disable code

* Addressing PR review comments
This commit is contained in:
Jesús Espino 2021-10-04 10:06:54 +02:00 committed by GitHub
parent ee721c89f1
commit 17991b9161
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 57 additions and 8 deletions

View File

@ -111,6 +111,9 @@ webapp: ## Build webapp.
watch-plugin: modd-precheck ## Run and upload the plugin to a development server
modd -f modd-watchplugin.conf
live-watch-plugin: modd-precheck ## Run and update locally the plugin in the development server
cd mattermost-plugin; make live-watch
mac-app: server-mac webapp ## Build Mac application.
rm -rf mac/temp
rm -rf mac/dist

View File

@ -8,6 +8,12 @@ ifeq ($(BUILD_NUMBER),)
BUILD_DATE := n/a
endif
MM_SERVER_PATH ?= $(MM_SERVER_PATH:)
ifeq ($(MM_SERVER_PATH),)
MM_SERVER_PATH := ../../mattermost-server
endif
LDFLAGS += -X "github.com/mattermost/focalboard/server/model.BuildNumber=$(BUILD_NUMBER)"
LDFLAGS += -X "github.com/mattermost/focalboard/server/model.BuildDate=$(BUILD_DATE)"
LDFLAGS += -X "github.com/mattermost/focalboard/server/model.BuildHash=$(BUILD_HASH)"
@ -23,6 +29,8 @@ GO_TEST_FLAGS ?= -race
GO_BUILD_FLAGS ?= -ldflags '$(LDFLAGS)'
MM_UTILITIES_DIR ?= ../mattermost-utilities
DLV_DEBUG_PORT := 2346
MATTERMOST_PLUGINS_PATH=$(MM_SERVER_PATH)/plugins
FOCALBOARD_PLUGIN_PATH=$(MATTERMOST_PLUGINS_PATH)/focalboard
export GO111MODULE=on
@ -277,6 +285,36 @@ ifndef STARTERTEMPLATE_PATH
endif
cd ${STARTERTEMPLATE_PATH} && go run ./build/sync/main.go ./build/sync/plan.yml $(PWD)
## Watch webapp and server changes and redeploy locally using local filesystem (MM_SERVER_PATH)
.PHONY: live-watch
live-watch:
make -j2 live-watch-server live-watch-webapp
## Watch server changes and redeploy locally using local filesystem (MM_SERVER_PATH)
.PHONY: live-watch-server
live-watch-server: apply
cd ../ && modd -f mattermost-plugin/modd.conf
## Watch webapp changes and redeploy locally using local filesystem (MM_SERVER_PATH)
.PHONY: live-watch-webapp
live-watch-webapp: apply
cd webapp && $(NPM) run live-watch
.PHONY: deploy-to-mattermost-directory
deploy-to-mattermost-directory:
./build/bin/pluginctl disable $(PLUGIN_ID)
mkdir -p $(FOCALBOARD_PLUGIN_PATH)
cp $(MANIFEST_FILE) $(FOCALBOARD_PLUGIN_PATH)/
cp -r ../webapp/pack $(FOCALBOARD_PLUGIN_PATH)/
cp -r $(ASSETS_DIR) $(FOCALBOARD_PLUGIN_PATH)/
cp -r public $(FOCALBOARD_PLUGIN_PATH)/
mkdir -p $(FOCALBOARD_PLUGIN_PATH)/server
cp -r server/dist $(FOCALBOARD_PLUGIN_PATH)/server/
mkdir -p $(FOCALBOARD_PLUGIN_PATH)/webapp
cp -r webapp/dist $(FOCALBOARD_PLUGIN_PATH)/webapp/
./build/bin/pluginctl enable $(PLUGIN_ID)
@echo plugin built at: $(FOCALBOARD_PLUGIN_PATH)
# Help documentation à la https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
help:
@cat Makefile build/*.mk | grep -v '\.PHONY' | grep -v '\help:' | grep -B1 -E '^[a-zA-Z0-9_.-]+:.*' | sed -e "s/:.*//" | sed -e "s/^## //" | grep -v '\-\-' | sed '1!G;h;$$!d' | awk 'NR%2{printf "\033[36m%-30s\033[0m",$$0;next;}1' | sort

View File

@ -137,9 +137,9 @@ func deploy(client *model.Client4, pluginID, bundlePath string) error {
// disablePlugin attempts to disable the plugin via the Client4 API.
func disablePlugin(client *model.Client4, pluginID string) error {
log.Print("Disabling plugin.")
_, resp := client.DisablePlugin(pluginID)
if resp.Error != nil {
return fmt.Errorf("failed to disable plugin: %w", resp.Error)
_, err := client.DisablePlugin(pluginID)
if err != nil {
return fmt.Errorf("failed to disable plugin: %w", err)
}
return nil
@ -148,9 +148,9 @@ func disablePlugin(client *model.Client4, pluginID string) error {
// enablePlugin attempts to enable the plugin via the Client4 API.
func enablePlugin(client *model.Client4, pluginID string) error {
log.Print("Enabling plugin.")
_, resp := client.EnablePlugin(pluginID)
if resp.Error != nil {
return fmt.Errorf("failed to enable plugin: %w", resp.Error)
_, err := client.EnablePlugin(pluginID)
if err != nil {
return fmt.Errorf("failed to enable plugin: %w", err)
}
return nil

View File

@ -0,0 +1,3 @@
server/**/*.go !server/**/*_test.go mattermost-plugin/server/**/*.go !mattermost-plugin/server/**/*_test.go {
prep: cd mattermost-plugin; make server deploy-to-mattermost-directory
}

View File

@ -5,6 +5,7 @@
"build:watch": "webpack --mode=production --watch",
"debug": "webpack --mode=none",
"debug:watch": "webpack --mode=development --watch",
"live-watch": "webpack --mode=development --watch",
"lint": "eslint --ignore-pattern node_modules --ignore-pattern dist --ext .js --ext .jsx --ext tsx --ext ts . --quiet --cache",
"fix": "eslint --ignore-pattern node_modules --ignore-pattern dist --ext .js --ext .jsx --ext tsx --ext ts . --quiet --fix --cache",
"test": "jest --forceExit --detectOpenHandles --verbose",

View File

@ -24,7 +24,7 @@ if (NPM_TARGET === 'debug' || NPM_TARGET === 'debug:watch') {
);
}
if (NPM_TARGET === 'build:watch' || NPM_TARGET === 'debug:watch') {
if (NPM_TARGET === 'build:watch' || NPM_TARGET === 'debug:watch' || NPM_TARGET === 'live-watch') {
plugins.push({
apply: (compiler) => {
compiler.hooks.watchRun.tap('WatchStartPlugin', () => {
@ -32,7 +32,11 @@ if (NPM_TARGET === 'build:watch' || NPM_TARGET === 'debug:watch') {
console.log('Change detected. Rebuilding webapp.');
});
compiler.hooks.afterEmit.tap('AfterEmitPlugin', () => {
exec('cd .. && make deploy-from-watch', (err, stdout, stderr) => {
let command = 'cd .. && make deploy-from-watch';
if (NPM_TARGET === 'live-watch') {
command = 'cd .. && make deploy-to-mattermost-directory';
}
exec(command, (err, stdout, stderr) => {
if (stdout) {
process.stdout.write(stdout);
}