31
31
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/
[email protected]
32
32
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/
[email protected]
33
33
MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/
[email protected]
34
- SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.32.3
34
+ SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@717e3cb29becaaf00e56953556c6d80f8a01b286
35
35
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
36
36
GO_LICENSES_PACKAGE ?= github.com/google/go-licenses@v1
37
37
GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/govulncheck@v1
@@ -96,6 +96,15 @@ STORED_VERSION_FILE := VERSION
96
96
GITHUB_REF_TYPE ?= branch
97
97
GITHUB_REF_NAME ?= $(shell git rev-parse --abbrev-ref HEAD)
98
98
99
+ # Enable typescript support in Node.js before 22.18
100
+ # TODO: Remove this once we can raise the minimum Node.js version to 22.18 (alpine >= 3.23)
101
+ NODE_VERSION := $(shell printf "% 03d% 03d% 03d" $(shell node -v 2>/dev/null | cut -c2- | tr '.' ' ') )
102
+ ifeq ($(shell test "$(NODE_VERSION ) " -lt "022018000"; echo $$? ) ,0)
103
+ NODE_VARS := NODE_OPTIONS="--experimental-strip-types"
104
+ else
105
+ NODE_VARS :=
106
+ endif
107
+
99
108
ifneq ($(GITHUB_REF_TYPE ) ,branch)
100
109
VERSION ?= $(subst v,,$(GITHUB_REF_NAME))
101
110
GITEA_VERSION ?= $(VERSION)
@@ -127,7 +136,7 @@ GO_TEST_PACKAGES ?= $(filter-out $(shell $(GO) list code.gitea.io/gitea/models/m
127
136
MIGRATE_TEST_PACKAGES ?= $(shell $(GO ) list code.gitea.io/gitea/models/migrations/...)
128
137
129
138
WEBPACK_SOURCES := $(shell find web_src/js web_src/css -type f)
130
- WEBPACK_CONFIGS := webpack.config.js tailwind.config.js
139
+ WEBPACK_CONFIGS := webpack.config.ts tailwind.config.ts
131
140
WEBPACK_DEST := public/assets/js/index.js public/assets/css/index.css
132
141
WEBPACK_DEST_ENTRIES := public/assets/js public/assets/css public/assets/fonts
133
142
@@ -153,9 +162,9 @@ TAR_EXCLUDES := .git data indexers queues log node_modules $(EXECUTABLE) $(DIST)
153
162
GO_DIRS := build cmd models modules routers services tests
154
163
WEB_DIRS := web_src/js web_src/css
155
164
156
- ESLINT_FILES := web_src/js tools *.js *. ts *.cjs tests/e2e
165
+ ESLINT_FILES := web_src/js tools *.ts *.cjs tests/e2e
157
166
STYLELINT_FILES := web_src/css web_src/js/components/*.vue
158
- 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/* ) )
167
+ 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/* ) )
159
168
EDITORCONFIG_FILES := templates .github/workflows options/locale/locale_en-US.ini
160
169
161
170
GO_SOURCES := $(wildcard * .go)
@@ -217,7 +226,6 @@ git-check:
217
226
node-check :
218
227
$(eval MIN_NODE_VERSION_STR := $(shell grep -Eo '"node":.* [0-9.]+"' package.json | sed -n 's/.* [^0-9.]\([0-9.]* \) "/\1/p') )
219
228
$(eval MIN_NODE_VERSION := $(shell printf "% 03d% 03d% 03d" $(shell echo '$(MIN_NODE_VERSION_STR ) ' | tr '.' ' ') ) )
220
- $(eval NODE_VERSION := $(shell printf "% 03d% 03d% 03d" $(shell node -v | cut -c2- | tr '.' ' ') ;) )
221
229
$(eval PNPM_MISSING := $(shell hash pnpm > /dev/null 2>&1 || echo 1) )
222
230
@if [ " $( NODE_VERSION) " -lt " $( MIN_NODE_VERSION) " ]; then \
223
231
echo " Gitea requires Node.js $( MIN_NODE_VERSION_STR) or greater to build. You can get it at https://nodejs.org/en/download/" ; \
@@ -230,7 +238,7 @@ node-check:
230
238
231
239
.PHONY : clean-all
232
240
clean-all : clean # # delete backend, frontend and integration files
233
- rm -rf $(WEBPACK_DEST_ENTRIES ) node_modules tools/node_modules
241
+ rm -rf $(WEBPACK_DEST_ENTRIES ) node_modules
234
242
235
243
.PHONY : clean
236
244
clean : # # delete backend and integration files
@@ -338,29 +346,29 @@ lint-backend-fix: lint-go-fix lint-go-gitea-vet lint-editorconfig ## lint backen
338
346
339
347
.PHONY : lint-js
340
348
lint-js : node_modules # # lint js files
341
- pnpm exec eslint --color --max-warnings=0 --ext js,ts,vue $(ESLINT_FILES )
342
- pnpm exec vue-tsc
349
+ $( NODE_VARS ) pnpm exec eslint --color --max-warnings=0 --ext js,ts,vue $(ESLINT_FILES )
350
+ $( NODE_VARS ) pnpm exec vue-tsc
343
351
344
352
.PHONY : lint-js-fix
345
353
lint-js-fix : node_modules # # lint js files and fix issues
346
- pnpm exec eslint --color --max-warnings=0 --ext js,ts,vue $(ESLINT_FILES ) --fix
347
- pnpm exec vue-tsc
354
+ $( NODE_VARS ) pnpm exec eslint --color --max-warnings=0 --ext js,ts,vue $(ESLINT_FILES ) --fix
355
+ $( NODE_VARS ) pnpm exec vue-tsc
348
356
349
357
.PHONY : lint-css
350
358
lint-css : node_modules # # lint css files
351
- pnpm exec stylelint --color --max-warnings=0 $(STYLELINT_FILES )
359
+ $( NODE_VARS ) pnpm exec stylelint --color --max-warnings=0 $(STYLELINT_FILES )
352
360
353
361
.PHONY : lint-css-fix
354
362
lint-css-fix : node_modules # # lint css files and fix issues
355
- pnpm exec stylelint --color --max-warnings=0 $(STYLELINT_FILES ) --fix
363
+ $( NODE_VARS ) pnpm exec stylelint --color --max-warnings=0 $(STYLELINT_FILES ) --fix
356
364
357
365
.PHONY : lint-swagger
358
366
lint-swagger : node_modules # # lint swagger files
359
- pnpm exec spectral lint -q -F hint $(SWAGGER_SPEC )
367
+ $( NODE_VARS ) pnpm exec spectral lint -q -F hint $(SWAGGER_SPEC )
360
368
361
369
.PHONY : lint-md
362
370
lint-md : node_modules # # lint markdown files
363
- pnpm exec markdownlint * .md
371
+ $( NODE_VARS ) pnpm exec markdownlint * .md
364
372
365
373
.PHONY : lint-spell
366
374
lint-spell : # # lint spelling
@@ -407,7 +415,7 @@ lint-actions: ## lint action workflow files
407
415
408
416
.PHONY : lint-templates
409
417
lint-templates : .venv node_modules # # lint template files
410
- @node tools/lint-templates-svg.js
418
+ @node tools/lint-templates-svg.ts
411
419
@uv run --frozen djlint $(shell find templates -type f -iname '* .tmpl')
412
420
413
421
.PHONY : lint-yaml
@@ -421,7 +429,7 @@ watch: ## watch everything and continuously rebuild
421
429
.PHONY : watch-frontend
422
430
watch-frontend : node-check node_modules # # watch frontend files and continuously rebuild
423
431
@rm -rf $(WEBPACK_DEST_ENTRIES )
424
- NODE_ENV=development pnpm exec webpack --watch --progress
432
+ NODE_ENV=development $( NODE_VARS ) pnpm exec webpack --watch --progress --disable-interpret
425
433
426
434
.PHONY : watch-backend
427
435
watch-backend : go-check # # watch backend files and continuously rebuild
@@ -437,7 +445,7 @@ test-backend: ## test backend files
437
445
438
446
.PHONY : test-frontend
439
447
test-frontend : node_modules # # test frontend files
440
- pnpm exec vitest
448
+ $( NODE_VARS ) pnpm exec vitest
441
449
442
450
.PHONY : test-check
443
451
test-check :
@@ -580,7 +588,7 @@ test-mssql-migration: migrations.mssql.test migrations.individual.mssql.test
580
588
581
589
.PHONY : playwright
582
590
playwright : deps-frontend
583
- pnpm exec playwright install $(PLAYWRIGHT_FLAGS )
591
+ $( NODE_VARS ) pnpm exec playwright install $(PLAYWRIGHT_FLAGS )
584
592
585
593
.PHONY : test-e2e%
586
594
test-e2e% : TEST_TYPE ?= e2e
@@ -844,13 +852,9 @@ deps-tools: ## install tool dependencies
844
852
wait
845
853
846
854
node_modules : pnpm-lock.yaml
847
- pnpm install --frozen-lockfile
855
+ $( NODE_VARS ) pnpm install --frozen-lockfile
848
856
@touch node_modules
849
857
850
- tools/node_modules : tools/package.json
851
- cd tools && pnpm install
852
- @touch tools/node_modules
853
-
854
858
.venv : uv.lock
855
859
uv sync
856
860
@touch .venv
@@ -860,16 +864,16 @@ update: update-js update-py ## update js and py dependencies
860
864
861
865
.PHONY : update-js
862
866
update-js : node-check | node_modules # # update js dependencies
863
- pnpm exec updates -u -f package.json
867
+ $( NODE_VARS ) pnpm exec updates -u -f package.json
864
868
rm -rf node_modules pnpm-lock.yaml
865
- pnpm install
866
- pnpm exec nolyfill install
867
- pnpm install
869
+ $( NODE_VARS ) pnpm install
870
+ $( NODE_VARS ) pnpm exec nolyfill install
871
+ $( NODE_VARS ) pnpm install
868
872
@touch node_modules
869
873
870
874
.PHONY : update-py
871
875
update-py : node-check | node_modules # # update py dependencies
872
- pnpm exec updates -u -f pyproject.toml
876
+ $( NODE_VARS ) pnpm exec updates -u -f pyproject.toml
873
877
rm -rf .venv uv.lock
874
878
uv sync
875
879
@touch .venv
@@ -881,13 +885,13 @@ $(WEBPACK_DEST): $(WEBPACK_SOURCES) $(WEBPACK_CONFIGS) pnpm-lock.yaml
881
885
@$(MAKE ) -s node-check node_modules
882
886
@rm -rf $(WEBPACK_DEST_ENTRIES )
883
887
@echo " Running webpack..."
884
- @BROWSERSLIST_IGNORE_OLD_DATA=true pnpm exec webpack
888
+ @BROWSERSLIST_IGNORE_OLD_DATA=true $( NODE_VARS ) pnpm exec webpack --disable-interpret
885
889
@touch $(WEBPACK_DEST )
886
890
887
891
.PHONY : svg
888
892
svg : node-check | node_modules # # build svg files
889
893
rm -rf $(SVG_DEST_DIR )
890
- node tools/generate-svg.js
894
+ node tools/generate-svg.ts
891
895
892
896
.PHONY : svg-check
893
897
svg-check : svg
@@ -901,7 +905,7 @@ svg-check: svg
901
905
902
906
.PHONY : lockfile-check
903
907
lockfile-check :
904
- pnpm install --frozen-lockfile
908
+ $( NODE_VARS ) pnpm install --frozen-lockfile
905
909
@diff=$$(git diff --color=always pnpm-lock.yaml ) ; \
906
910
if [ -n " $$ diff" ]; then \
907
911
echo " pnpm-lock.yaml is inconsistent with package.json" ; \
@@ -925,8 +929,8 @@ generate-gitignore: ## update gitignore files
925
929
$(GO ) run build/generate-gitignores.go
926
930
927
931
.PHONY : generate-images
928
- generate-images : | node_modules tools/node_modules # # generate images (requires cairo development packages)
929
- cd tools && node generate-images.js $(TAGS )
932
+ generate-images : | node_modules # # generate images
933
+ cd tools && node generate-images.ts $(TAGS )
930
934
931
935
.PHONY : generate-manpage
932
936
generate-manpage : # # generate manpage
0 commit comments