22default : help
33JSONNET_VENDOR_DIR := vendor_jsonnet
44
5+ GRAFANA_PLUGIN_ID := $(shell jq -r '.id' src/plugin.json)
6+ GRAFANA_PLUGIN_VERSION := $(shell jq -r '.version' package.json)
7+ GRAFANA_PLUGIN_ARTIFACT := $(GRAFANA_PLUGIN_ID ) -$(GRAFANA_PLUGIN_VERSION ) .zip
8+ GRAFANA_PLUGIN_ARTIFACT_CHECKSUM := $(GRAFANA_PLUGIN_ARTIFACT ) .md5
9+
510
611# #@ Dependencies
712
8- $(JSONNET_VENDOR_DIR ) : jsonnetfile.json
13+ $(JSONNET_VENDOR_DIR ) : jsonnetfile.json jsonnetfile.lock.json
914 jb --jsonnetpkg-home=" $( JSONNET_VENDOR_DIR) " install
1015
1116deps-dashboards : $(JSONNET_VENDOR_DIR ) # # Install jsonnet dependencies
1217
13- node_modules : package.json
18+ node_modules : package.json yarn.lock
1419 yarn install
1520
1621deps-frontend : node_modules # # Install Node.js dependencies
@@ -26,7 +31,7 @@ deps: deps-dashboards deps-frontend deps-backend ## Install all dependencies
2631dev-frontend : deps-frontend # # Build frontend datasources (development)
2732 yarn run dev
2833
29- watch-frontend : deps-frontend dist -dashboards # # Auto rebuilt frontend on file changes
34+ watch-frontend : deps-frontend build -dashboards # # Auto rebuilt frontend on file changes
3035 yarn run watch
3136
3237dev-backend : deps-backend
@@ -43,21 +48,28 @@ dist/%.json: src/%.jsonnet $(JSONNET_VENDOR_DIR)
4348 mkdir -p $(dir $@ )
4449 jsonnet -J " $( JSONNET_VENDOR_DIR) " -o $@ $<
4550
46- dist -dashboards : $(shell find src -name '* .jsonnet' | sed -E 's@src/(.* ) \.jsonnet@dist/\1.json@g') # # Build Grafana dashboards from jsonnet
51+ build -dashboards : $(shell find src -name '* .jsonnet' | sed -E 's@src/(.+ ) \.jsonnet@dist/\1.json@g') # # Build Grafana dashboards from jsonnet
4752
48- dist -frontend : deps-frontend # # Build frontend datasources
53+ build -frontend : deps-frontend # # Build frontend datasources
4954 yarn run build
5055
5156GO_LD_FLAGS := -w -s -extldflags "-static"
52- dist -backend : deps-backend # # Build backend datasource
57+ build -backend : deps-backend # # Build backend datasource
5358 # mage buildAll
5459 for arch in amd64 arm arm64 s390x ppc64le 386; do \
5560 CGO_ENABLED=0 GOOS=linux GOARCH=$$ {arch} go build -o dist/datasources/redis/pcp_redis_datasource_linux_$$ {arch} -ldflags ' $(GO_LD_FLAGS)' ./pkg; \
5661 done
5762 CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o dist/datasources/redis/pcp_redis_datasource_darwin_amd64 -ldflags ' $(GO_LD_FLAGS)' ./pkg
5863 CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o dist/datasources/redis/pcp_redis_datasource_windows_amd64.exe -ldflags ' $(GO_LD_FLAGS)' ./pkg
5964
60- dist : dist-dashboards dist-frontend dist-backend # # Build everything
65+ build : build-dashboards build-frontend build-backend # # Build everything
66+
67+ zip :
68+ rm -rf build && mkdir build
69+ cp -a dist " build/$( GRAFANA_PLUGIN_ID) "
70+ cd build && zip -r " $( GRAFANA_PLUGIN_ARTIFACT) " " $( GRAFANA_PLUGIN_ID) "
71+ cd build && md5sum " $( GRAFANA_PLUGIN_ARTIFACT) " > " $( GRAFANA_PLUGIN_ARTIFACT_CHECKSUM) "
72+ rm -r " build/$( GRAFANA_PLUGIN_ID) "
6173
6274
6375# #@ Test
@@ -105,8 +117,11 @@ sign: ## Sign the plugin
105117jsonnetfmt : # # Run jsonnetfmt on all jsonnet files
106118 jsonnetfmt -i $$(find . -name '*.jsonnet' )
107119
120+ lint : # # Run Grafana plugincheck on the plugin zip file
121+ plugincheck build/* .zip
122+
108123clean : # # Clean all artifacts
109- rm -rf node_modules " $( JSONNET_VENDOR_DIR) " dist
124+ rm -rf node_modules " $( JSONNET_VENDOR_DIR) " dist build
110125
111126help : # # Display this help
112127 @awk ' BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-16s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST )
0 commit comments