@@ -31,7 +31,7 @@ XGO_VERSION := go-1.25.x
3131
3232AIR_PACKAGE ?= github.com/air-verse/air@v1
3333EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/v3/cmd/editorconfig-checker@v3
34- GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.8.0
34+ GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.9.1
3535GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/
[email protected] 3636GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/
[email protected] 3737MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/
[email protected] @@ -100,6 +100,15 @@ STORED_VERSION_FILE := VERSION
100100GITHUB_REF_TYPE ?= branch
101101GITHUB_REF_NAME ?= $(shell git rev-parse --abbrev-ref HEAD)
102102
103+ # Enable typescript support in Node.js before 22.18
104+ # TODO: Remove this once we can raise the minimum Node.js version to 22.18 (alpine >= 3.23)
105+ NODE_VERSION := $(shell printf "% 03d% 03d% 03d" $(shell node -v 2>/dev/null | cut -c2- | tr '.' ' ') )
106+ ifeq ($(shell test "$(NODE_VERSION ) " -lt "022018000"; echo $$? ) ,0)
107+ NODE_VARS := NODE_OPTIONS="--experimental-strip-types"
108+ else
109+ NODE_VARS :=
110+ endif
111+
103112ifneq ($(GITHUB_REF_TYPE ) ,branch)
104113 VERSION ?= $(subst v,,$(GITHUB_REF_NAME))
105114 GITEA_VERSION ?= $(VERSION)
@@ -131,7 +140,7 @@ GO_TEST_PACKAGES ?= $(filter-out $(shell $(GO) list code.gitea.io/gitea/models/m
131140MIGRATE_TEST_PACKAGES ?= $(shell $(GO ) list code.gitea.io/gitea/models/migrations/...)
132141
133142WEBPACK_SOURCES := $(shell find web_src/js web_src/css -type f)
134- WEBPACK_CONFIGS := webpack.config.js tailwind.config.js
143+ WEBPACK_CONFIGS := webpack.config.ts tailwind.config.ts
135144WEBPACK_DEST := public/assets/js/index.js public/assets/css/index.css
136145WEBPACK_DEST_ENTRIES := public/assets/js public/assets/css public/assets/fonts
137146
@@ -157,9 +166,9 @@ TAR_EXCLUDES := .git data indexers queues log node_modules $(EXECUTABLE) $(DIST)
157166GO_DIRS := build cmd models modules routers services tests
158167WEB_DIRS := web_src/js web_src/css
159168
160- ESLINT_FILES := web_src/js tools *.js *. ts *.cjs tests/e2e
169+ ESLINT_FILES := web_src/js tools *.ts *.cjs tests/e2e
161170STYLELINT_FILES := web_src/css web_src/js/components/*.vue
162- SPELLCHECK_FILES := $(GO_DIRS ) $(WEB_DIRS ) templates options/locale/locale_en-US.ini .github $(filter-out CHANGELOG.md, $(wildcard * .go * .js * . md * .yml * .yaml * .toml) ) $(filter-out tools/misspellings.csv, $(wildcard tools/* ) )
171+ SPELLCHECK_FILES := $(GO_DIRS ) $(WEB_DIRS ) templates options/locale/locale_en-US.ini .github $(filter-out CHANGELOG.md, $(wildcard * .go * .md * .yml * .yaml * .toml) ) $(filter-out tools/misspellings.csv, $(wildcard tools/* ) )
163172EDITORCONFIG_FILES := templates .github/workflows options/locale/locale_en-US.ini
164173
165174GO_SOURCES := $(wildcard * .go)
@@ -221,7 +230,6 @@ git-check:
221230node-check :
222231 $(eval MIN_NODE_VERSION_STR := $(shell grep -Eo '"node":.* [0-9.]+"' package.json | sed -n 's/.* [^0-9.]\([0-9.]* \) "/\1/p') )
223232 $(eval MIN_NODE_VERSION := $(shell printf "% 03d% 03d% 03d" $(shell echo '$(MIN_NODE_VERSION_STR ) ' | tr '.' ' ') ) )
224- $(eval NODE_VERSION := $(shell printf "% 03d% 03d% 03d" $(shell node -v | cut -c2- | tr '.' ' ') ;) )
225233 $(eval PNPM_MISSING := $(shell hash pnpm > /dev/null 2>&1 || echo 1) )
226234 @if [ " $( NODE_VERSION) " -lt " $( MIN_NODE_VERSION) " ]; then \
227235 echo " Gitea requires Node.js $( MIN_NODE_VERSION_STR) or greater to build. You can get it at https://nodejs.org/en/download/" ; \
@@ -234,7 +242,7 @@ node-check:
234242
235243.PHONY : clean-all
236244clean-all : clean # # delete backend, frontend and integration files
237- rm -rf $(WEBPACK_DEST_ENTRIES ) node_modules tools/node_modules
245+ rm -rf $(WEBPACK_DEST_ENTRIES ) node_modules
238246
239247.PHONY : clean
240248clean : # # delete backend and integration files
@@ -342,29 +350,29 @@ lint-backend-fix: lint-go-fix lint-go-gitea-vet lint-editorconfig ## lint backen
342350
343351.PHONY : lint-js
344352lint-js : node_modules # # lint js files
345- pnpm exec eslint --color --max-warnings=0 --ext js,ts,vue $(ESLINT_FILES )
346- pnpm exec vue-tsc
353+ $( NODE_VARS ) pnpm exec eslint --color --max-warnings=0 --ext js,ts,vue $(ESLINT_FILES )
354+ $( NODE_VARS ) pnpm exec vue-tsc
347355
348356.PHONY : lint-js-fix
349357lint-js-fix : node_modules # # lint js files and fix issues
350- pnpm exec eslint --color --max-warnings=0 --ext js,ts,vue $(ESLINT_FILES ) --fix
351- pnpm exec vue-tsc
358+ $( NODE_VARS ) pnpm exec eslint --color --max-warnings=0 --ext js,ts,vue $(ESLINT_FILES ) --fix
359+ $( NODE_VARS ) pnpm exec vue-tsc
352360
353361.PHONY : lint-css
354362lint-css : node_modules # # lint css files
355- pnpm exec stylelint --color --max-warnings=0 $(STYLELINT_FILES )
363+ $( NODE_VARS ) pnpm exec stylelint --color --max-warnings=0 $(STYLELINT_FILES )
356364
357365.PHONY : lint-css-fix
358366lint-css-fix : node_modules # # lint css files and fix issues
359- pnpm exec stylelint --color --max-warnings=0 $(STYLELINT_FILES ) --fix
367+ $( NODE_VARS ) pnpm exec stylelint --color --max-warnings=0 $(STYLELINT_FILES ) --fix
360368
361369.PHONY : lint-swagger
362370lint-swagger : node_modules # # lint swagger files
363- pnpm exec spectral lint -q -F hint $(SWAGGER_SPEC )
371+ $( NODE_VARS ) pnpm exec spectral lint -q -F hint $(SWAGGER_SPEC )
364372
365373.PHONY : lint-md
366374lint-md : node_modules # # lint markdown files
367- pnpm exec markdownlint * .md
375+ $( NODE_VARS ) pnpm exec markdownlint * .md
368376
369377.PHONY : lint-spell
370378lint-spell : # # lint spelling
@@ -411,7 +419,7 @@ lint-actions: ## lint action workflow files
411419
412420.PHONY : lint-templates
413421lint-templates : .venv node_modules # # lint template files
414- @node tools/lint-templates-svg.js
422+ @node tools/lint-templates-svg.ts
415423 @uv run --frozen djlint $(shell find templates -type f -iname '* .tmpl')
416424
417425.PHONY : lint-yaml
@@ -425,7 +433,7 @@ watch: ## watch everything and continuously rebuild
425433.PHONY : watch-frontend
426434watch-frontend : node-check node_modules # # watch frontend files and continuously rebuild
427435 @rm -rf $(WEBPACK_DEST_ENTRIES )
428- NODE_ENV=development pnpm exec webpack --watch --progress
436+ NODE_ENV=development $( NODE_VARS ) pnpm exec webpack --watch --progress --disable-interpret
429437
430438.PHONY : watch-backend
431439watch-backend : go-check # # watch backend files and continuously rebuild
@@ -441,7 +449,7 @@ test-backend: ## test backend files
441449
442450.PHONY : test-frontend
443451test-frontend : node_modules # # test frontend files
444- pnpm exec vitest
452+ $( NODE_VARS ) pnpm exec vitest
445453
446454.PHONY : test-check
447455test-check :
@@ -584,7 +592,7 @@ test-mssql-migration: migrations.mssql.test migrations.individual.mssql.test
584592
585593.PHONY : playwright
586594playwright : deps-frontend
587- pnpm exec playwright install $(PLAYWRIGHT_FLAGS )
595+ $( NODE_VARS ) pnpm exec playwright install $(PLAYWRIGHT_FLAGS )
588596
589597.PHONY : test-e2e%
590598test-e2e% : TEST_TYPE ?= e2e
@@ -848,13 +856,9 @@ deps-tools: ## install tool dependencies
848856 wait
849857
850858node_modules : pnpm-lock.yaml
851- pnpm install --frozen-lockfile
859+ $( NODE_VARS ) pnpm install --frozen-lockfile
852860 @touch node_modules
853861
854- tools/node_modules : tools/package.json
855- cd tools && pnpm install
856- @touch tools/node_modules
857-
858862.venv : uv.lock
859863 uv sync
860864 @touch .venv
@@ -864,16 +868,16 @@ update: update-js update-py ## update js and py dependencies
864868
865869.PHONY : update-js
866870update-js : node-check | node_modules # # update js dependencies
867- pnpm exec updates -u -f package.json
871+ $( NODE_VARS ) pnpm exec updates -u -f package.json
868872 rm -rf node_modules pnpm-lock.yaml
869- pnpm install
870- pnpm exec nolyfill install
871- pnpm install
873+ $( NODE_VARS ) pnpm install
874+ $( NODE_VARS ) pnpm exec nolyfill install
875+ $( NODE_VARS ) pnpm install
872876 @touch node_modules
873877
874878.PHONY : update-py
875879update-py : node-check | node_modules # # update py dependencies
876- pnpm exec updates -u -f pyproject.toml
880+ $( NODE_VARS ) pnpm exec updates -u -f pyproject.toml
877881 rm -rf .venv uv.lock
878882 uv sync
879883 @touch .venv
@@ -885,13 +889,13 @@ $(WEBPACK_DEST): $(WEBPACK_SOURCES) $(WEBPACK_CONFIGS) pnpm-lock.yaml
885889 @$(MAKE ) -s node-check node_modules
886890 @rm -rf $(WEBPACK_DEST_ENTRIES )
887891 @echo " Running webpack..."
888- @BROWSERSLIST_IGNORE_OLD_DATA=true pnpm exec webpack
892+ @BROWSERSLIST_IGNORE_OLD_DATA=true $( NODE_VARS ) pnpm exec webpack --disable-interpret
889893 @touch $(WEBPACK_DEST )
890894
891895.PHONY : svg
892896svg : node-check | node_modules # # build svg files
893897 rm -rf $(SVG_DEST_DIR )
894- node tools/generate-svg.js
898+ node tools/generate-svg.ts
895899
896900.PHONY : svg-check
897901svg-check : svg
@@ -905,7 +909,7 @@ svg-check: svg
905909
906910.PHONY : lockfile-check
907911lockfile-check :
908- pnpm install --frozen-lockfile
912+ $( NODE_VARS ) pnpm install --frozen-lockfile
909913 @diff=$$(git diff --color=always pnpm-lock.yaml ) ; \
910914 if [ -n " $$ diff" ]; then \
911915 echo " pnpm-lock.yaml is inconsistent with package.json" ; \
@@ -929,8 +933,8 @@ generate-gitignore: ## update gitignore files
929933 $(GO ) run build/generate-gitignores.go
930934
931935.PHONY : generate-images
932- generate-images : | node_modules tools/node_modules # # generate images (requires cairo development packages)
933- cd tools && node generate-images.js $(TAGS )
936+ generate-images : | node_modules # # generate images
937+ cd tools && node generate-images.ts $(TAGS )
934938
935939.PHONY : generate-manpage
936940generate-manpage : # # generate manpage
0 commit comments