1
1
mirror of https://github.com/go-gitea/gitea synced 2025-09-10 02:38:28 +00:00

Switch to pnpm (#35274)

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
techknowlogick
2025-09-03 21:17:14 -04:00
committed by GitHub
parent ca6c0dee2e
commit 361e59fd53
22 changed files with 13197 additions and 14451 deletions

View File

@@ -65,6 +65,7 @@ cpu.out
/yarn.lock /yarn.lock
/yarn-error.log /yarn-error.log
/npm-debug.log* /npm-debug.log*
/pnpm-debug.log*
/public/assets/js /public/assets/js
/public/assets/css /public/assets/css
/public/assets/fonts /public/assets/fonts

2
.github/labeler.yml vendored
View File

@@ -59,7 +59,7 @@ modifies/dependencies:
- changed-files: - changed-files:
- any-glob-to-any-file: - any-glob-to-any-file:
- "package.json" - "package.json"
- "package-lock.json" - "pnpm-lock.yaml"
- "pyproject.toml" - "pyproject.toml"
- "uv.lock" - "uv.lock"
- "go.mod" - "go.mod"

View File

@@ -58,7 +58,7 @@ jobs:
- "tools/*.ts" - "tools/*.ts"
- "assets/emoji.json" - "assets/emoji.json"
- "package.json" - "package.json"
- "package-lock.json" - "pnpm-lock.yaml"
- "Makefile" - "Makefile"
- ".eslintrc.cjs" - ".eslintrc.cjs"
- ".npmrc" - ".npmrc"
@@ -67,7 +67,7 @@ jobs:
- "**/*.md" - "**/*.md"
- ".markdownlint.yaml" - ".markdownlint.yaml"
- "package.json" - "package.json"
- "package-lock.json" - "pnpm-lock.yaml"
actions: actions:
- ".github/workflows/*" - ".github/workflows/*"
@@ -90,7 +90,7 @@ jobs:
- "templates/swagger/v1_input.json" - "templates/swagger/v1_input.json"
- "Makefile" - "Makefile"
- "package.json" - "package.json"
- "package-lock.json" - "pnpm-lock.yaml"
- ".spectral.yaml" - ".spectral.yaml"
yaml: yaml:

View File

@@ -34,11 +34,12 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v6 - uses: astral-sh/setup-uv@v6
- run: uv python install 3.12 - run: uv python install 3.12
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
node-version: 24 node-version: 24
cache: npm cache: pnpm
cache-dependency-path: package-lock.json cache-dependency-path: pnpm-lock.yaml
- run: make deps-py - run: make deps-py
- run: make deps-frontend - run: make deps-frontend
- run: make lint-templates - run: make lint-templates
@@ -60,11 +61,12 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
node-version: 24 node-version: 24
cache: npm cache: pnpm
cache-dependency-path: package-lock.json cache-dependency-path: pnpm-lock.yaml
- run: make deps-frontend - run: make deps-frontend
- run: make lint-swagger - run: make lint-swagger
@@ -131,11 +133,12 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
node-version: 24 node-version: 24
cache: npm cache: pnpm
cache-dependency-path: package-lock.json cache-dependency-path: pnpm-lock.yaml
- run: make deps-frontend - run: make deps-frontend
- run: make lint-frontend - run: make lint-frontend
- run: make checks-frontend - run: make checks-frontend
@@ -180,11 +183,12 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
node-version: 24 node-version: 24
cache: npm cache: pnpm
cache-dependency-path: package-lock.json cache-dependency-path: pnpm-lock.yaml
- run: make deps-frontend - run: make deps-frontend
- run: make lint-md - run: make lint-md

View File

@@ -23,13 +23,14 @@ jobs:
with: with:
go-version-file: go.mod go-version-file: go.mod
check-latest: true check-latest: true
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
node-version: 24 node-version: 24
cache: npm cache: pnpm
cache-dependency-path: package-lock.json cache-dependency-path: pnpm-lock.yaml
- run: make deps-frontend frontend deps-backend - run: make deps-frontend frontend deps-backend
- run: npx playwright install --with-deps - run: pnpm exec playwright install --with-deps
- run: make test-e2e-sqlite - run: make test-e2e-sqlite
timeout-minutes: 40 timeout-minutes: 40
env: env:

View File

@@ -20,11 +20,12 @@ jobs:
with: with:
go-version-file: go.mod go-version-file: go.mod
check-latest: true check-latest: true
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
node-version: 24 node-version: 24
cache: npm cache: pnpm
cache-dependency-path: package-lock.json cache-dependency-path: pnpm-lock.yaml
- run: make deps-frontend deps-backend - run: make deps-frontend deps-backend
# xgo build # xgo build
- run: make release - run: make release

View File

@@ -21,11 +21,12 @@ jobs:
with: with:
go-version-file: go.mod go-version-file: go.mod
check-latest: true check-latest: true
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
node-version: 24 node-version: 24
cache: npm cache: pnpm
cache-dependency-path: package-lock.json cache-dependency-path: pnpm-lock.yaml
- run: make deps-frontend deps-backend - run: make deps-frontend deps-backend
# xgo build # xgo build
- run: make release - run: make release

View File

@@ -25,11 +25,12 @@ jobs:
with: with:
go-version-file: go.mod go-version-file: go.mod
check-latest: true check-latest: true
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
node-version: 24 node-version: 24
cache: npm cache: pnpm
cache-dependency-path: package-lock.json cache-dependency-path: pnpm-lock.yaml
- run: make deps-frontend deps-backend - run: make deps-frontend deps-backend
# xgo build # xgo build
- run: make release - run: make release

1
.gitignore vendored
View File

@@ -74,6 +74,7 @@ cpu.out
/tests/*.ini /tests/*.ini
/tests/**/*.git/**/*.sample /tests/**/*.git/**/*.sample
/node_modules /node_modules
/tools/node_modules
/.venv /.venv
/yarn.lock /yarn.lock
/yarn-error.log /yarn-error.log

5
.npmrc
View File

@@ -1,6 +1,7 @@
audit=false audit=false
fund=false fund=false
update-notifier=false update-notifier=false
package-lock=true
save-exact=true save-exact=true
lockfile-version=3 auto-install-peers=true
dedupe-peer-dependents=false
enable-pre-post-scripts=true

View File

@@ -15,6 +15,7 @@ RUN apk --no-cache add \
git \ git \
nodejs \ nodejs \
npm \ npm \
&& npm install -g pnpm@10 \
&& rm -rf /var/cache/apk/* && rm -rf /var/cache/apk/*
# Setup repo # Setup repo

View File

@@ -15,6 +15,7 @@ RUN apk --no-cache add \
git \ git \
nodejs \ nodejs \
npm \ npm \
&& npm install -g pnpm@10 \
&& rm -rf /var/cache/apk/* && rm -rf /var/cache/apk/*
# Setup repo # Setup repo

View File

@@ -218,15 +218,19 @@ node-check:
$(eval MIN_NODE_VERSION_STR := $(shell grep -Eo '"node":.*[0-9.]+"' package.json | sed -n 's/.*[^0-9.]\([0-9.]*\)"/\1/p')) $(eval MIN_NODE_VERSION_STR := $(shell grep -Eo '"node":.*[0-9.]+"' package.json | sed -n 's/.*[^0-9.]\([0-9.]*\)"/\1/p'))
$(eval MIN_NODE_VERSION := $(shell printf "%03d%03d%03d" $(shell echo '$(MIN_NODE_VERSION_STR)' | tr '.' ' '))) $(eval MIN_NODE_VERSION := $(shell printf "%03d%03d%03d" $(shell echo '$(MIN_NODE_VERSION_STR)' | tr '.' ' ')))
$(eval NODE_VERSION := $(shell printf "%03d%03d%03d" $(shell node -v | cut -c2- | tr '.' ' ');)) $(eval NODE_VERSION := $(shell printf "%03d%03d%03d" $(shell node -v | cut -c2- | tr '.' ' ');))
$(eval NPM_MISSING := $(shell hash npm > /dev/null 2>&1 || echo 1)) $(eval PNPM_MISSING := $(shell hash pnpm > /dev/null 2>&1 || echo 1))
@if [ "$(NODE_VERSION)" -lt "$(MIN_NODE_VERSION)" -o "$(NPM_MISSING)" = "1" ]; then \ @if [ "$(NODE_VERSION)" -lt "$(MIN_NODE_VERSION)" ]; then \
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/"; \ echo "Gitea requires Node.js $(MIN_NODE_VERSION_STR) or greater to build. You can get it at https://nodejs.org/en/download/"; \
exit 1; \
fi
@if [ "$(PNPM_MISSING)" = "1" ]; then \
echo "Gitea requires pnpm to build. You can install it at https://pnpm.io/installation"; \
exit 1; \ exit 1; \
fi fi
.PHONY: clean-all .PHONY: clean-all
clean-all: clean ## delete backend, frontend and integration files clean-all: clean ## delete backend, frontend and integration files
rm -rf $(WEBPACK_DEST_ENTRIES) node_modules rm -rf $(WEBPACK_DEST_ENTRIES) node_modules tools/node_modules
.PHONY: clean .PHONY: clean
clean: ## delete backend and integration files clean: ## delete backend and integration files
@@ -334,29 +338,29 @@ lint-backend-fix: lint-go-fix lint-go-gitea-vet lint-editorconfig ## lint backen
.PHONY: lint-js .PHONY: lint-js
lint-js: node_modules ## lint js files lint-js: node_modules ## lint js files
npx eslint --color --max-warnings=0 --ext js,ts,vue $(ESLINT_FILES) pnpm exec eslint --color --max-warnings=0 --ext js,ts,vue $(ESLINT_FILES)
npx vue-tsc pnpm exec vue-tsc
.PHONY: lint-js-fix .PHONY: lint-js-fix
lint-js-fix: node_modules ## lint js files and fix issues lint-js-fix: node_modules ## lint js files and fix issues
npx eslint --color --max-warnings=0 --ext js,ts,vue $(ESLINT_FILES) --fix pnpm exec eslint --color --max-warnings=0 --ext js,ts,vue $(ESLINT_FILES) --fix
npx vue-tsc pnpm exec vue-tsc
.PHONY: lint-css .PHONY: lint-css
lint-css: node_modules ## lint css files lint-css: node_modules ## lint css files
npx stylelint --color --max-warnings=0 $(STYLELINT_FILES) pnpm exec stylelint --color --max-warnings=0 $(STYLELINT_FILES)
.PHONY: lint-css-fix .PHONY: lint-css-fix
lint-css-fix: node_modules ## lint css files and fix issues lint-css-fix: node_modules ## lint css files and fix issues
npx stylelint --color --max-warnings=0 $(STYLELINT_FILES) --fix pnpm exec stylelint --color --max-warnings=0 $(STYLELINT_FILES) --fix
.PHONY: lint-swagger .PHONY: lint-swagger
lint-swagger: node_modules ## lint swagger files lint-swagger: node_modules ## lint swagger files
npx spectral lint -q -F hint $(SWAGGER_SPEC) pnpm exec spectral lint -q -F hint $(SWAGGER_SPEC)
.PHONY: lint-md .PHONY: lint-md
lint-md: node_modules ## lint markdown files lint-md: node_modules ## lint markdown files
npx markdownlint *.md pnpm exec markdownlint *.md
.PHONY: lint-spell .PHONY: lint-spell
lint-spell: ## lint spelling lint-spell: ## lint spelling
@@ -417,7 +421,7 @@ watch: ## watch everything and continuously rebuild
.PHONY: watch-frontend .PHONY: watch-frontend
watch-frontend: node-check node_modules ## watch frontend files and continuously rebuild watch-frontend: node-check node_modules ## watch frontend files and continuously rebuild
@rm -rf $(WEBPACK_DEST_ENTRIES) @rm -rf $(WEBPACK_DEST_ENTRIES)
NODE_ENV=development npx webpack --watch --progress NODE_ENV=development pnpm exec webpack --watch --progress
.PHONY: watch-backend .PHONY: watch-backend
watch-backend: go-check ## watch backend files and continuously rebuild watch-backend: go-check ## watch backend files and continuously rebuild
@@ -433,7 +437,7 @@ test-backend: ## test backend files
.PHONY: test-frontend .PHONY: test-frontend
test-frontend: node_modules ## test frontend files test-frontend: node_modules ## test frontend files
npx vitest pnpm exec vitest
.PHONY: test-check .PHONY: test-check
test-check: test-check:
@@ -576,7 +580,7 @@ test-mssql-migration: migrations.mssql.test migrations.individual.mssql.test
.PHONY: playwright .PHONY: playwright
playwright: deps-frontend playwright: deps-frontend
npx playwright install $(PLAYWRIGHT_FLAGS) pnpm exec playwright install $(PLAYWRIGHT_FLAGS)
.PHONY: test-e2e% .PHONY: test-e2e%
test-e2e%: TEST_TYPE ?= e2e test-e2e%: TEST_TYPE ?= e2e
@@ -839,10 +843,14 @@ deps-tools: ## install tool dependencies
$(GO) install $(GOPLS_MODERNIZE_PACKAGE) & \ $(GO) install $(GOPLS_MODERNIZE_PACKAGE) & \
wait wait
node_modules: package-lock.json node_modules: pnpm-lock.yaml
npm install --no-save pnpm install --frozen-lockfile
@touch node_modules @touch node_modules
tools/node_modules: tools/package.json
cd tools && pnpm install
@touch tools/node_modules
.venv: uv.lock .venv: uv.lock
uv sync uv sync
@touch .venv @touch .venv
@@ -852,16 +860,16 @@ update: update-js update-py ## update js and py dependencies
.PHONY: update-js .PHONY: update-js
update-js: node-check | node_modules ## update js dependencies update-js: node-check | node_modules ## update js dependencies
npx updates -u -f package.json pnpm exec updates -u -f package.json
rm -rf node_modules package-lock.json rm -rf node_modules pnpm-lock.yaml
npm install --package-lock pnpm install
npx nolyfill install pnpm exec nolyfill install
npm install --package-lock pnpm install
@touch node_modules @touch node_modules
.PHONY: update-py .PHONY: update-py
update-py: node-check | node_modules ## update py dependencies update-py: node-check | node_modules ## update py dependencies
npx updates -u -f pyproject.toml pnpm exec updates -u -f pyproject.toml
rm -rf .venv uv.lock rm -rf .venv uv.lock
uv sync uv sync
@touch .venv @touch .venv
@@ -869,11 +877,11 @@ update-py: node-check | node_modules ## update py dependencies
.PHONY: webpack .PHONY: webpack
webpack: $(WEBPACK_DEST) ## build webpack files webpack: $(WEBPACK_DEST) ## build webpack files
$(WEBPACK_DEST): $(WEBPACK_SOURCES) $(WEBPACK_CONFIGS) package-lock.json $(WEBPACK_DEST): $(WEBPACK_SOURCES) $(WEBPACK_CONFIGS) pnpm-lock.yaml
@$(MAKE) -s node-check node_modules @$(MAKE) -s node-check node_modules
@rm -rf $(WEBPACK_DEST_ENTRIES) @rm -rf $(WEBPACK_DEST_ENTRIES)
@echo "Running webpack..." @echo "Running webpack..."
@BROWSERSLIST_IGNORE_OLD_DATA=true npx webpack @BROWSERSLIST_IGNORE_OLD_DATA=true pnpm exec webpack
@touch $(WEBPACK_DEST) @touch $(WEBPACK_DEST)
.PHONY: svg .PHONY: svg
@@ -893,11 +901,11 @@ svg-check: svg
.PHONY: lockfile-check .PHONY: lockfile-check
lockfile-check: lockfile-check:
npm install --package-lock-only pnpm install --frozen-lockfile
@diff=$$(git diff --color=always package-lock.json); \ @diff=$$(git diff --color=always pnpm-lock.yaml); \
if [ -n "$$diff" ]; then \ if [ -n "$$diff" ]; then \
echo "package-lock.json is inconsistent with package.json"; \ echo "pnpm-lock.yaml is inconsistent with package.json"; \
echo "Please run 'npm install --package-lock-only' and commit the result:"; \ echo "Please run 'pnpm install --frozen-lockfile' and commit the result:"; \
printf "%s" "$${diff}"; \ printf "%s" "$${diff}"; \
exit 1; \ exit 1; \
fi fi
@@ -917,9 +925,8 @@ generate-gitignore: ## update gitignore files
$(GO) run build/generate-gitignores.go $(GO) run build/generate-gitignores.go
.PHONY: generate-images .PHONY: generate-images
generate-images: | node_modules generate-images: | node_modules tools/node_modules ## generate images (requires cairo development packages)
npm install --no-save fabric@6 imagemin-zopfli@7 cd tools && node generate-images.js $(TAGS)
node tools/generate-images.js $(TAGS)
.PHONY: generate-manpage .PHONY: generate-manpage
generate-manpage: ## generate manpage generate-manpage: ## generate manpage

View File

@@ -52,7 +52,7 @@ or if SQLite support is required:
The `build` target is split into two sub-targets: The `build` target is split into two sub-targets:
- `make backend` which requires [Go Stable](https://go.dev/dl/), the required version is defined in [go.mod](/go.mod). - `make backend` which requires [Go Stable](https://go.dev/dl/), the required version is defined in [go.mod](/go.mod).
- `make frontend` which requires [Node.js LTS](https://nodejs.org/en/download/) or greater. - `make frontend` which requires [Node.js LTS](https://nodejs.org/en/download/) or greater and [pnpm](https://pnpm.io/installation).
Internet connectivity is required to download the go and npm modules. 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. Internet connectivity is required to download the go and npm modules. 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.

View File

@@ -18,6 +18,7 @@
go = go_1_25; go = go_1_25;
nodejs = nodejs_24; nodejs = nodejs_24;
python3 = python312; python3 = python312;
pnpm = pnpm_10;
# Platform-specific dependencies # Platform-specific dependencies
linuxOnlyInputs = lib.optionals pkgs.stdenv.isLinux [ linuxOnlyInputs = lib.optionals pkgs.stdenv.isLinux [
@@ -43,6 +44,10 @@
# frontend # frontend
nodejs nodejs
pnpm
cairo
pixman
pkg-config
# linting # linting
python3 python3

14391
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,9 @@
{ {
"type": "module", "type": "module",
"packageManager": "pnpm@10.0.0",
"engines": { "engines": {
"node": ">= 20.0.0" "node": ">= 20.0.0",
"pnpm": ">=10.0.0"
}, },
"dependencies": { "dependencies": {
"@citation-js/core": "0.7.18", "@citation-js/core": "0.7.18",
@@ -14,6 +16,7 @@
"@mcaptcha/vanilla-glue": "0.1.0-alpha-3", "@mcaptcha/vanilla-glue": "0.1.0-alpha-3",
"@primer/octicons": "19.15.5", "@primer/octicons": "19.15.5",
"@silverwind/vue3-calendar-heatmap": "2.0.6", "@silverwind/vue3-calendar-heatmap": "2.0.6",
"@techknowlogick/license-checker-webpack-plugin": "0.3.0",
"add-asset-webpack-plugin": "3.0.0", "add-asset-webpack-plugin": "3.0.0",
"ansi_up": "6.0.6", "ansi_up": "6.0.6",
"asciinema-player": "3.10.0", "asciinema-player": "3.10.0",
@@ -32,7 +35,6 @@
"idiomorph": "0.7.3", "idiomorph": "0.7.3",
"jquery": "3.7.1", "jquery": "3.7.1",
"katex": "0.16.22", "katex": "0.16.22",
"license-checker-webpack-plugin": "0.2.1",
"mermaid": "11.10.0", "mermaid": "11.10.0",
"mini-css-extract-plugin": "2.9.2", "mini-css-extract-plugin": "2.9.2",
"minimatch": "10.0.3", "minimatch": "10.0.3",
@@ -69,6 +71,7 @@
"@stoplight/spectral-cli": "6.15.0", "@stoplight/spectral-cli": "6.15.0",
"@stylistic/eslint-plugin-js": "3.1.0", "@stylistic/eslint-plugin-js": "3.1.0",
"@stylistic/stylelint-plugin": "4.0.0", "@stylistic/stylelint-plugin": "4.0.0",
"@types/codemirror": "5.60.16",
"@types/dropzone": "5.7.9", "@types/dropzone": "5.7.9",
"@types/jquery": "3.5.32", "@types/jquery": "3.5.32",
"@types/katex": "0.16.7", "@types/katex": "0.16.7",

10440
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

2
tools/.pnpmrc Normal file
View File

@@ -0,0 +1,2 @@
enable-pre-post-scripts=true
ignored-build-dependencies=[]

22
tools/package.json Normal file
View File

@@ -0,0 +1,22 @@
{
"name": "gitea-tools",
"version": "1.0.0",
"description": "Build tools for Gitea",
"type": "module",
"private": true,
"dependencies": {
"fabric": "^6.0.0",
"imagemin-zopfli": "^7.0.0",
"svgo": "^3.0.0",
"fast-glob": "^3.0.0"
},
"optionalDependencies": {
"canvas": "^3.2.0"
},
"pnpm": {
"onlyBuiltDependencies": ["canvas", "zopflipng-bin"],
"overrides": {
"canvas": "3.2.0"
}
}
}

2644
tools/pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
import fastGlob from 'fast-glob'; import fastGlob from 'fast-glob';
import wrapAnsi from 'wrap-ansi'; import wrapAnsi from 'wrap-ansi';
import AddAssetPlugin from 'add-asset-webpack-plugin'; import AddAssetPlugin from 'add-asset-webpack-plugin';
import LicenseCheckerWebpackPlugin from 'license-checker-webpack-plugin'; import LicenseCheckerWebpackPlugin from '@techknowlogick/license-checker-webpack-plugin';
import MiniCssExtractPlugin from 'mini-css-extract-plugin'; import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import MonacoWebpackPlugin from 'monaco-editor-webpack-plugin'; import MonacoWebpackPlugin from 'monaco-editor-webpack-plugin';
import {VueLoaderPlugin} from 'vue-loader'; import {VueLoaderPlugin} from 'vue-loader';
@@ -254,7 +254,8 @@ export default {
maxAssetSize: Infinity, maxAssetSize: Infinity,
}, },
resolve: { resolve: {
symlinks: false, symlinks: true,
modules: ['node_modules'],
}, },
watchOptions: { watchOptions: {
ignored: [ ignored: [