1414
1515# This is the "normal" part of the Makefile
1616
17- TAR := $(shell hash bsdtar > /dev/null 2>&1 && echo "bsdtar --no-xattrs" || echo "tar" )
18-
1917DIST := dist
2018DIST_DIRS := $(DIST ) /binaries $(DIST ) /release
2119IMPORT := code.gitea.io/gitea
@@ -28,7 +26,7 @@ COMMA := ,
2826
2927XGO_VERSION := go-1.16.x
3028MIN_GO_VERSION := 001014000
31- MIN_NODE_VERSION := 010013000
29+ MIN_NODE_VERSION := 012017000
3230
3331DOCKER_IMAGE ?= gitea/gitea
3432DOCKER_TAG ?= latest
@@ -93,8 +91,6 @@ LINUX_ARCHS ?= linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64
9391
9492GO_PACKAGES ?= $(filter-out code.gitea.io/gitea/models/migrations code.gitea.io/gitea/integrations/migration-test code.gitea.io/gitea/integrations,$(shell $(GO ) list -mod=vendor ./... | grep -v /vendor/) )
9593
96- FOMANTIC_CONFIGS := semantic.json web_src/fomantic/theme.config.less web_src/fomantic/_site/globals/site.variables
97- FOMANTIC_DEST := web_src/fomantic/build/semantic.js web_src/fomantic/build/semantic.css
9894FOMANTIC_WORK_DIR := web_src/fomantic
9995
10096WEBPACK_SOURCES := $(shell find web_src/js web_src/less -type f)
@@ -115,6 +111,8 @@ TAGS_EVIDENCE := $(MAKE_EVIDENCE_DIR)/tags
115111
116112TEST_TAGS ?= sqlite sqlite_unlock_notify
117113
114+ TAR_EXCLUDES := .git data indexers queues log node_modules $(EXECUTABLE ) $(FOMANTIC_WORK_DIR ) /node_modules $(DIST ) $(MAKE_EVIDENCE_DIR ) $(AIR_TMP_DIR )
115+
118116GO_DIRS := cmd integrations models modules routers build services vendor tools
119117
120118GO_SOURCES := $(wildcard * .go)
@@ -173,6 +171,9 @@ help:
173171 @echo " - checks run various consistency checks"
174172 @echo " - checks-frontend check frontend files"
175173 @echo " - checks-backend check backend files"
174+ @echo " - test test everything"
175+ @echo " - test-frontend test frontend files"
176+ @echo " - test-backend test backend files"
176177 @echo " - webpack build webpack files"
177178 @echo " - svg build svg files"
178179 @echo " - fomantic build fomantic files"
@@ -322,8 +323,9 @@ lint: lint-frontend lint-backend
322323
323324.PHONY : lint-frontend
324325lint-frontend : node_modules
325- npx eslint --color --max-warnings=0 web_src/js build templates webpack .config.js
326+ npx eslint --color --max-warnings=0 web_src/js build templates * .config.js
326327 npx stylelint --color --max-warnings=0 web_src/less
328+ npx editorconfig-checker templates
327329
328330.PHONY : lint-backend
329331lint-backend : golangci-lint revive vet
@@ -345,16 +347,23 @@ watch-backend: go-check
345347 air -c .air.conf
346348
347349.PHONY : test
348- test :
350+ test : test-frontend test-backend
351+
352+ .PHONY : test-backend
353+ test-backend :
349354 @echo " Running go test with -tags '$( TEST_TAGS) '..."
350355 @$(GO ) test $(GOTESTFLAGS ) -mod=vendor -tags=' $(TEST_TAGS)' $(GO_PACKAGES )
351356
357+ .PHONY : test-frontend
358+ test-frontend :
359+ @NODE_OPTIONS=" --experimental-vm-modules --no-warnings" npx jest --color
360+
352361.PHONY : test-check
353362test-check :
354363 @echo " Running test-check..." ;
355364 @diff=$$(git status -s ) ; \
356365 if [ -n " $$ diff" ]; then \
357- echo " make test has changed files in the source tree:" ; \
366+ echo " make test-backend has changed files in the source tree:" ; \
358367 echo " $$ {diff}" ; \
359368 echo " You should change the tests to create these files in a temporary directory." ; \
360369 echo " Do not simply add these files to .gitignore" ; \
@@ -579,7 +588,7 @@ install: $(wildcard *.go)
579588build : frontend backend
580589
581590.PHONY : frontend
582- frontend : node-check $(WEBPACK_DEST )
591+ frontend : $(WEBPACK_DEST )
583592
584593.PHONY : backend
585594backend : go-check generate $(EXECUTABLE )
@@ -644,16 +653,16 @@ release-compress: | $(DIST_DIRS)
644653 cd $(DIST ) /release/; for file in ` find . -type f -name " *" ` ; do echo " compressing $$ {file}" && gxz -k -9 $$ {file}; done ;
645654
646655.PHONY : release-sources
647- release-sources : | $(DIST_DIRS ) npm-cache
656+ release-sources : | $(DIST_DIRS )
648657 echo $(VERSION ) > $(STORED_VERSION_FILE )
649- $( eval EXCL := --exclude= $( shell [ ! " $( TAR ) " = "tar" ] && echo "^" ) ./)
650- $(eval EXCL_RECURSIVE := --exclude=)
651- $( TAR ) $(EXCL )$( DIST ) $(EXCL ) .git $( EXCL )$( MAKE_EVIDENCE_DIR ) $( EXCL_RECURSIVE ) node_modules $( EXCL )$( AIR_TMP_DIR ) -czf $(DIST ) /release/gitea-src-$(VERSION ) .tar.gz .
658+ # bsdtar needs a ^ to prevent matching subdirectories
659+ $(eval EXCL := --exclude=$(shell tar --help | grep -q bsdtar && echo "^")./ )
660+ tar $(addprefix $(EXCL),$(TAR_EXCLUDES) ) -czf $(DIST)/release/gitea-src-$(VERSION).tar.gz .
652661 rm -f $(STORED_VERSION_FILE)
653662
654663.PHONY : release-docs
655664release-docs : | $(DIST_DIRS ) docs
656- $( TAR ) -czf $(DIST ) /release/gitea-docs-$(VERSION ) .tar.gz -C ./docs/public .
665+ tar -czf $(DIST ) /release/gitea-docs-$(VERSION ) .tar.gz -C ./docs/public .
657666
658667.PHONY : docs
659668docs :
@@ -666,25 +675,6 @@ node_modules: package-lock.json
666675 npm install --no-save
667676 @touch node_modules
668677
669- .PHONY : npm-cache
670- npm-cache : .npm-cache $(FOMANTIC_WORK_DIR ) /node_modules/fomantic-ui
671-
672- .npm-cache : package-lock.json
673- rm -rf .npm-cache
674- $(eval ESBUILD_VERSION := $(shell node -p "require('./package-lock.json') .dependencies.esbuild.version") )
675- npm config --userconfig=.npmrc set cache=.npm-cache
676- rm -rf node_modules && npm install --no-save
677- npm config --userconfig=$(FOMANTIC_WORK_DIR ) /.npmrc set cache=../../.npm-cache
678- echo $(foreach build, darwin-64 $(foreach arch,arm arm64 32 64,linux-${arch}) $(foreach arch,32 64,windows-${arch}) , esbuild-${build}@$(ESBUILD_VERSION ) ) | tr " " " \n" | xargs -n 1 -P 4 npm cache add
679- rm -rf $(FOMANTIC_WORK_DIR ) /node_modules
680- @touch .npm-cache
681-
682- .PHONY : npm-uncache
683- npm-uncache :
684- rm -rf .npm-cache
685- npm config --userconfig=$(FOMANTIC_WORK_DIR ) /.npmrc rm cache
686- npm config --userconfig=.npmrc rm cache
687-
688678.PHONY : npm-update
689679npm-update : node-check | node_modules
690680 npx updates -cu
@@ -693,30 +683,18 @@ npm-update: node-check | node_modules
693683 @touch node_modules
694684
695685.PHONY : fomantic
696- fomantic : $(FOMANTIC_DEST )
697-
698- $(FOMANTIC_WORK_DIR ) /node_modules/fomantic-ui :
699- ln -sf ../../semantic.json $(FOMANTIC_WORK_DIR )
700- cd $(FOMANTIC_WORK_DIR ) ; \
701- rm -rf node_modules && mkdir node_modules && \
702- npm install fomantic-ui; \
703- rm -f semantic.json
704- @touch $(FOMANTIC_WORK_DIR ) /node_modules
705-
706- $(FOMANTIC_DEST ) : $(FOMANTIC_CONFIGS ) $(FOMANTIC_WORK_DIR ) /node_modules/fomantic-ui
707- ln -sf ../../semantic.json $(FOMANTIC_WORK_DIR )
686+ fomantic :
708687 rm -rf $(FOMANTIC_WORK_DIR ) /build
709- cd $(FOMANTIC_WORK_DIR ) ; \
710- cp -f theme.config.less node_modules/fomantic-ui/src/theme.config; \
711- cp -rf _site node_modules/fomantic-ui/src/; \
712- npx gulp -f node_modules/fomantic-ui/gulpfile.js build; \
713- rm -f semantic.json
714- @touch $(FOMANTIC_DEST )
688+ cd $(FOMANTIC_WORK_DIR ) && npm install --no-save
689+ cp -f $(FOMANTIC_WORK_DIR ) /theme.config.less $(FOMANTIC_WORK_DIR ) /node_modules/fomantic-ui/src/theme.config
690+ cp -rf $(FOMANTIC_WORK_DIR ) /_site $(FOMANTIC_WORK_DIR ) /node_modules/fomantic-ui/src/
691+ cd $(FOMANTIC_WORK_DIR ) && npx gulp -f node_modules/fomantic-ui/gulpfile.js build
715692
716693.PHONY : webpack
717694webpack : $(WEBPACK_DEST )
718695
719- $(WEBPACK_DEST ) : $(WEBPACK_SOURCES ) $(WEBPACK_CONFIGS ) package-lock.json | node_modules
696+ $(WEBPACK_DEST ) : $(WEBPACK_SOURCES ) $(WEBPACK_CONFIGS ) package-lock.json
697+ @$(MAKE ) -s node-check node_modules
720698 rm -rf $(WEBPACK_DEST_ENTRIES )
721699 npx webpack
722700 @touch $(WEBPACK_DEST )
0 commit comments