Skip to content

Commit 8d653b1

Browse files
Check go and nodejs version by go.mod and package.json (#19197) (#19254)
* Check go and nodejs version by go.mod and package.json * Update Go official site URL Co-authored-by: wxiaoguang <[email protected]> Co-authored-by: gesangtome <[email protected]>
1 parent b702f2d commit 8d653b1

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Makefile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ HAS_GO = $(shell hash $(GO) > /dev/null 2>&1 && echo "GO" || echo "NOGO" )
2525
COMMA := ,
2626

2727
XGO_VERSION := go-1.18.x
28-
MIN_GO_VERSION := 001017000
29-
MIN_NODE_VERSION := 012017000
3028

3129
AIR_PACKAGE ?= github.com/cosmtrek/[email protected]
3230
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/cmd/[email protected]
@@ -203,9 +201,11 @@ help:
203201

204202
.PHONY: go-check
205203
go-check:
204+
$(eval MIN_GO_VERSION_STR := $(shell grep -Eo '^go\s+[0-9]+\.[0-9.]+' go.mod | cut -d' ' -f2))
205+
$(eval MIN_GO_VERSION := $(shell printf "%03d%03d%03d" $(shell echo '$(MIN_GO_VERSION_STR)' | tr '.' ' ')))
206206
$(eval GO_VERSION := $(shell printf "%03d%03d%03d" $(shell $(GO) version | grep -Eo '[0-9]+\.[0-9.]+' | tr '.' ' ');))
207207
@if [ "$(GO_VERSION)" -lt "$(MIN_GO_VERSION)" ]; then \
208-
echo "Gitea requires Go 1.16 or greater to build. You can get it at https://golang.org/dl/"; \
208+
echo "Gitea requires Go $(MIN_GO_VERSION_STR) or greater to build. You can get it at https://go.dev/dl/"; \
209209
exit 1; \
210210
fi
211211

@@ -218,11 +218,12 @@ git-check:
218218

219219
.PHONY: node-check
220220
node-check:
221+
$(eval MIN_NODE_VERSION_STR := $(shell grep -Eo '"node":.*[0-9.]+"' package.json | sed -n 's/.*[^0-9.]\([0-9.]*\)"/\1/p'))
222+
$(eval MIN_NODE_VERSION := $(shell printf "%03d%03d%03d" $(shell echo '$(MIN_NODE_VERSION_STR)' | tr '.' ' ')))
221223
$(eval NODE_VERSION := $(shell printf "%03d%03d%03d" $(shell node -v | cut -c2- | tr '.' ' ');))
222-
$(eval MIN_NODE_VER_FMT := $(shell printf "%g.%g.%g" $(shell echo $(MIN_NODE_VERSION) | grep -o ...)))
223224
$(eval NPM_MISSING := $(shell hash npm > /dev/null 2>&1 || echo 1))
224225
@if [ "$(NODE_VERSION)" -lt "$(MIN_NODE_VERSION)" -o "$(NPM_MISSING)" = "1" ]; then \
225-
echo "Gitea requires Node.js $(MIN_NODE_VER_FMT) or greater and npm to build. You can get it at https://nodejs.org/en/download/"; \
226+
echo "Gitea requires Node.js $(MIN_NODE_VERSION_STR) or greater and npm to build. You can get it at https://nodejs.org/en/download/"; \
226227
exit 1; \
227228
fi
228229

0 commit comments

Comments
 (0)