pluginctl/assets/build/utils.mk
Felipe Martin 2e2a95d7d6
Add GoModule support to template context and update gitignore
- Add GoModule struct with Module and Version fields
- Parse go.mod file to extract module name and Go version
- Expose GoModule in template context as {{.GoModule}}
- Update asset templates to use {{.GoModule}} instead of hardcoded values
- Add gitignore pattern for testdata directories (keep only plugin.json files)
- All templates now have access to both manifest and Go module information

Templates can now use:
- {{.GoModule.Module}} for module name
- {{.GoModule.Version}} for Go version
- {{if .GoModule}}...{{end}} for conditional logic

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-14 22:16:41 +02:00

42 lines
No EOL
1.4 KiB
Makefile

# ====================================================================================
# Utilities
# ====================================================================================
## Clean removes all build artifacts.
.PHONY: clean
clean:
rm -fr dist/
ifneq ($(HAS_SERVER),)
rm -fr server/coverage.txt
rm -fr server/dist
endif
ifneq ($(HAS_WEBAPP),)
rm -fr webapp/junit.xml
rm -fr webapp/dist
rm -fr webapp/node_modules
endif
rm -fr build/bin/
## Extract strings for translation from the source code.
.PHONY: i18n-extract
i18n-extract:
ifneq ($(HAS_WEBAPP),)
ifeq ($(HAS_MM_UTILITIES),)
@echo "You must clone github.com/mattermost/mattermost-utilities repo in .. to use this command"
else
cd $(MM_UTILITIES_DIR) && npm install && npm run babel && node mmjstool/build/index.js i18n extract-webapp --webapp-dir $(PWD)/webapp
endif
endif
## Generate mocks for testing.
.PHONY: mock
mock:
ifneq ($(HAS_SERVER),)
go install github.com/golang/mock/mockgen@v1.6.0
mockgen -destination=server/command/mocks/mock_commands.go -package=mocks {{.GoModule}}/server/command Command
endif
## Show help documentation.
.PHONY: help
help:
@cat Makefile build/*.mk | grep -v '\.PHONY' | grep -v '\help:' | grep -B1 -E '^[a-zA-Z0-9_.-]+:.*' | sed -e "s/:.*//g" | sed -e "s/^## //g" | grep -v '\-\-' | sed '1!G;h;$$!d' | awk 'NR%2{printf "\033[36m%-30s\033[0m",$$0;next;}1' | sort