Skip to content

Commit 7f33fe0

Browse files
committed
Stop packaging node_modules in release tarballs
- Don't package node_modules in tarballs, they are not cross-platform anymore and npm cache should not be messed with directly. Instead, require an internet connection to rebuild the UI, which is not necessary in the general use case because prebuilt UI files are shipped in the public directory. - Simplify the fomantic build and make the target phony. We don't need anything more for something that is rarely ran. - Use regular tar again to build tarballs and add variable for excludes - Disable annoying npm update notifications Fixes: go-gitea#14578 Fixes: go-gitea#15256 Fixes: go-gitea#15262
1 parent e8693eb commit 7f33fe0

File tree

8 files changed

+30
-60
lines changed

8 files changed

+30
-60
lines changed

.drone.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ steps:
501501
pull: always
502502
image: techknowlogick/xgo:go-1.16.x
503503
commands:
504-
- curl -sL https://deb.nodesource.com/setup_14.x | bash - && apt -y install nodejs bsdtar\|libarchive-tools
504+
- curl -sL https://deb.nodesource.com/setup_14.x | bash - && apt-get install -y nodejs
505505
- export PATH=$PATH:$GOPATH/bin
506506
- make release
507507
environment:
@@ -597,7 +597,7 @@ steps:
597597
pull: always
598598
image: techknowlogick/xgo:go-1.16.x
599599
commands:
600-
- curl -sL https://deb.nodesource.com/setup_14.x | bash - && apt-get install -y nodejs bsdtar\|libarchive-tools
600+
- curl -sL https://deb.nodesource.com/setup_14.x | bash - && apt-get install -y nodejs
601601
- export PATH=$PATH:$GOPATH/bin
602602
- make release
603603
environment:

.gitignore

-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ coverage.all
8181
/public/fonts
8282
/public/img/webpack
8383
/web_src/fomantic/node_modules
84-
/web_src/fomantic/semantic.json
8584
/web_src/fomantic/build/*
8685
!/web_src/fomantic/build/semantic.js
8786
!/web_src/fomantic/build/semantic.css
@@ -95,7 +94,6 @@ coverage.all
9594
!/web_src/fomantic/build/themes/default/assets/fonts/outline-icons.woff2
9695
/VERSION
9796
/.air
98-
/.npm-cache
9997

10098
# Snapcraft
10199
snap/.snapcraft/

.npmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
audit=false
22
fund=false
3+
update-notifier=false
34
package-lock=true
45
save-exact=true
5-
cache=.npm-cache

Makefile

+15-48
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ else
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-
1917
DIST := dist
2018
DIST_DIRS := $(DIST)/binaries $(DIST)/release
2119
IMPORT := code.gitea.io/gitea
@@ -93,8 +91,6 @@ LINUX_ARCHS ?= linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64
9391

9492
GO_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
9894
FOMANTIC_WORK_DIR := web_src/fomantic
9995

10096
WEBPACK_SOURCES := $(shell find web_src/js web_src/less -type f)
@@ -115,6 +111,8 @@ TAGS_EVIDENCE := $(MAKE_EVIDENCE_DIR)/tags
115111

116112
TEST_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+
118116
GO_DIRS := cmd integrations models modules routers build services vendor tools
119117

120118
GO_SOURCES := $(wildcard *.go)
@@ -589,7 +587,7 @@ install: $(wildcard *.go)
589587
build: frontend backend
590588

591589
.PHONY: frontend
592-
frontend: node-check $(WEBPACK_DEST)
590+
frontend: $(WEBPACK_DEST)
593591

594592
.PHONY: backend
595593
backend: go-check generate $(EXECUTABLE)
@@ -654,16 +652,16 @@ release-compress: | $(DIST_DIRS)
654652
cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "compressing $${file}" && gxz -k -9 $${file}; done;
655653

656654
.PHONY: release-sources
657-
release-sources: | $(DIST_DIRS) npm-cache
655+
release-sources: | $(DIST_DIRS)
658656
echo $(VERSION) > $(STORED_VERSION_FILE)
659-
$(eval EXCL := --exclude=$(shell [ ! "$(TAR)" = "tar" ] && echo "^" )./)
660-
$(eval EXCL_RECURSIVE := --exclude=)
661-
$(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 .
657+
# bsdtar needs a ^ to prevent matching subdirectories
658+
$(eval EXCL := --exclude=$(shell tar --help | grep -q bsdtar && echo "^")./)
659+
tar $(addprefix $(EXCL),$(TAR_EXCLUDES)) -czf $(DIST)/release/gitea-src-$(VERSION).tar.gz .
662660
rm -f $(STORED_VERSION_FILE)
663661

664662
.PHONY: release-docs
665663
release-docs: | $(DIST_DIRS) docs
666-
$(TAR) -czf $(DIST)/release/gitea-docs-$(VERSION).tar.gz -C ./docs/public .
664+
tar -czf $(DIST)/release/gitea-docs-$(VERSION).tar.gz -C ./docs/public .
667665

668666
.PHONY: docs
669667
docs:
@@ -676,25 +674,6 @@ node_modules: package-lock.json
676674
npm install --no-save
677675
@touch node_modules
678676

679-
.PHONY: npm-cache
680-
npm-cache: .npm-cache $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui
681-
682-
.npm-cache: package-lock.json
683-
rm -rf .npm-cache
684-
$(eval ESBUILD_VERSION := $(shell node -p "require('./package-lock.json').dependencies.esbuild.version"))
685-
npm config --userconfig=.npmrc set cache=.npm-cache
686-
rm -rf node_modules && npm install --no-save
687-
npm config --userconfig=$(FOMANTIC_WORK_DIR)/.npmrc set cache=../../.npm-cache
688-
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
689-
rm -rf $(FOMANTIC_WORK_DIR)/node_modules
690-
@touch .npm-cache
691-
692-
.PHONY: npm-uncache
693-
npm-uncache:
694-
rm -rf .npm-cache
695-
npm config --userconfig=$(FOMANTIC_WORK_DIR)/.npmrc rm cache
696-
npm config --userconfig=.npmrc rm cache
697-
698677
.PHONY: npm-update
699678
npm-update: node-check | node_modules
700679
npx updates -cu
@@ -703,30 +682,18 @@ npm-update: node-check | node_modules
703682
@touch node_modules
704683

705684
.PHONY: fomantic
706-
fomantic: $(FOMANTIC_DEST)
707-
708-
$(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui:
709-
ln -sf ../../semantic.json $(FOMANTIC_WORK_DIR)
710-
cd $(FOMANTIC_WORK_DIR); \
711-
rm -rf node_modules && mkdir node_modules && \
712-
npm install fomantic-ui; \
713-
rm -f semantic.json
714-
@touch $(FOMANTIC_WORK_DIR)/node_modules
715-
716-
$(FOMANTIC_DEST): $(FOMANTIC_CONFIGS) $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui
717-
ln -sf ../../semantic.json $(FOMANTIC_WORK_DIR)
685+
fomantic:
718686
rm -rf $(FOMANTIC_WORK_DIR)/build
719-
cd $(FOMANTIC_WORK_DIR); \
720-
cp -f theme.config.less node_modules/fomantic-ui/src/theme.config; \
721-
cp -rf _site node_modules/fomantic-ui/src/; \
722-
npx gulp -f node_modules/fomantic-ui/gulpfile.js build; \
723-
rm -f semantic.json
724-
@touch $(FOMANTIC_DEST)
687+
cd $(FOMANTIC_WORK_DIR) && npm install --no-save
688+
cp -f $(FOMANTIC_WORK_DIR)/theme.config.less $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/src/theme.config
689+
cp -rf $(FOMANTIC_WORK_DIR)/_site $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/src/
690+
cd $(FOMANTIC_WORK_DIR) && npx gulp -f node_modules/fomantic-ui/gulpfile.js build
725691

726692
.PHONY: webpack
727693
webpack: $(WEBPACK_DEST)
728694

729-
$(WEBPACK_DEST): $(WEBPACK_SOURCES) $(WEBPACK_CONFIGS) package-lock.json | node_modules
695+
$(WEBPACK_DEST): $(WEBPACK_SOURCES) $(WEBPACK_CONFIGS) package-lock.json
696+
@$(MAKE) -s node-check node_modules
730697
rm -rf $(WEBPACK_DEST_ENTRIES)
731698
npx webpack
732699
@touch $(WEBPACK_DEST)

README.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,11 @@ or if sqlite support is required:
7777
The `build` target is split into two sub-targets:
7878

7979
- `make backend` which requires [Go 1.13](https://golang.org/dl/) or greater.
80-
- `make frontend` which requires [Node.js 12.17](https://nodejs.org/en/download/) or greater.
80+
- `make frontend` which requires [Node.js 12.17](https://nodejs.org/en/download/) or greater and Internet connectivity to download npm dependencies.
8181

82-
If pre-built frontend files are present it is possible to only build the backend:
82+
When building from the official source tarballs which include pre-built frontend files, the `frontend` target will not be triggered, making it possible to build without Node.js and Internet connectivity.
8383

84-
TAGS="bindata" make backend
85-
86-
Parallelism is not supported for these targets, so please don't include `-j <num>`.
84+
Parallelism (`make -j <num>`) is not supported.
8785

8886
More info: https://docs.gitea.io/en-us/install-from-source/
8987

web_src/fomantic/.npmrc

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
optional=false
1+
audit=false
2+
fund=false
3+
update-notifier=false
24
package-lock=false
3-
cache=../../.npm-cache
5+
optional=false

web_src/fomantic/package.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"dependencies": {
3+
"fomantic-ui": "2.8.7"
4+
}
5+
}
File renamed without changes.

0 commit comments

Comments
 (0)