build: migrate to pnpm (#772)

This commit is contained in:
Trim21
2024-08-10 04:36:38 +08:00
committed by GitHub
parent a078cfe2b0
commit 61ea0b445a
21 changed files with 14256 additions and 20130 deletions

View File

@@ -9,23 +9,36 @@ on:
- master - master
jobs: jobs:
build: build-real:
runs-on: ubuntu-20.04 runs-on: ubuntu-24.04
strategy: strategy:
matrix: matrix:
node: [18, 20] node: ['20', '22']
fail-fast: false fail-fast: false
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- name: Use Node.js ${{ matrix.node }} - name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: ${{ matrix.node }} node-version: ${{ matrix.node }}
cache: 'npm' cache: 'pnpm'
- run: npm ci - run: pnpm install --frozen-lockfile
- run: npm run build - run: npm run build
- run: npm run start -- --help - run: npm run start -- --help
build:
# so we do not need to update GitHub repo config
needs: build-real
runs-on: ubuntu-latest
strategy:
matrix:
node: ['18', '20']
fail-fast: false
steps:
- run: echo pass

View File

@@ -9,23 +9,36 @@ on:
- master - master
jobs: jobs:
check: check-real:
runs-on: ubuntu-20.04 runs-on: ubuntu-24.04
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
node: [20] node: ['22']
check: [check-source-formatting, check-types, lint] check: [check-source-formatting, check-types, lint]
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- name: Use Node.js ${{ matrix.node }} - name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: ${{ matrix.node }} node-version: ${{ matrix.node }}
cache: npm cache: 'pnpm'
- run: npm ci - run: pnpm install --frozen-lockfile
- run: npm run ${{ matrix.check }} - run: npm run ${{ matrix.check }}
check:
# so we do not need to update GitHub repo config
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node: ['20']
check: [check-source-formatting, check-types, lint]
needs:
- check-real
steps:
- run: echo ok

View File

@@ -13,7 +13,7 @@ on:
jobs: jobs:
analyze: analyze:
name: Analyze name: Analyze
runs-on: ubuntu-20.04 runs-on: ubuntu-24.04
strategy: strategy:
fail-fast: false fail-fast: false
@@ -27,15 +27,6 @@ jobs:
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2
# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}
# Initializes the CodeQL tools for scanning. # Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL - name: Initialize CodeQL

View File

@@ -9,7 +9,7 @@ on:
jobs: jobs:
aur: aur:
runs-on: ubuntu-20.04 runs-on: ubuntu-24.04
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4

View File

@@ -9,21 +9,22 @@ on:
jobs: jobs:
flood-bin: flood-bin:
runs-on: ubuntu-20.04 runs-on: ubuntu-24.04
strategy: strategy:
matrix: matrix:
node: [20] node: ['22']
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- name: Use Node.js ${{ matrix.node }} - name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: ${{ matrix.node }} node-version: ${{ matrix.node }}
registry-url: 'https://registry.npmjs.org' registry-url: 'https://registry.npmjs.org'
cache: npm cache: 'pnpm'
- name: Set up QEMU - name: Set up QEMU
run: | run: |

View File

@@ -7,23 +7,25 @@ on:
jobs: jobs:
npm: npm:
runs-on: ubuntu-20.04 runs-on: ubuntu-24.04
strategy: strategy:
matrix: matrix:
node: [20] node: ['22']
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- name: Use Node.js ${{ matrix.node }} - name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: ${{ matrix.node }} node-version: ${{ matrix.node }}
registry-url: 'https://registry.npmjs.org' registry-url: 'https://registry.npmjs.org'
cache: npm cache: pnpm
- run: npm ci - run: pnpm install --frozen-lockfile
- name: Tag rolling release - name: Tag rolling release
id: tag_release id: tag_release
@@ -64,7 +66,7 @@ jobs:
docker: docker:
needs: npm needs: npm
runs-on: ubuntu-20.04 runs-on: ubuntu-24.04
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
@@ -115,11 +117,11 @@ jobs:
RTORRENT_VERSION=master RTORRENT_VERSION=master
docker-dbg: docker-dbg:
runs-on: ubuntu-20.04 runs-on: ubuntu-24.04
strategy: strategy:
matrix: matrix:
node: [20] node: ['22']
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
@@ -129,7 +131,7 @@ jobs:
with: with:
node-version: ${{ matrix.node }} node-version: ${{ matrix.node }}
registry-url: 'https://registry.npmjs.org' registry-url: 'https://registry.npmjs.org'
cache: npm cache: 'pnpm'
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
@@ -171,11 +173,11 @@ jobs:
pkg: pkg:
needs: npm needs: npm
runs-on: ubuntu-20.04 runs-on: ubuntu-24.04
strategy: strategy:
matrix: matrix:
node: [20] node: ['22']
steps: steps:
- name: Use Node.js ${{ matrix.node }} - name: Use Node.js ${{ matrix.node }}
@@ -256,7 +258,7 @@ jobs:
docker-distroless: docker-distroless:
needs: pkg needs: pkg
runs-on: ubuntu-20.04 runs-on: ubuntu-24.04
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4

View File

@@ -7,7 +7,7 @@ on:
jobs: jobs:
release: release:
runs-on: ubuntu-20.04 runs-on: ubuntu-24.04
strategy: strategy:
matrix: matrix:
@@ -16,15 +16,17 @@ jobs:
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- name: Use Node.js ${{ matrix.node }} - name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: ${{ matrix.node }} node-version: ${{ matrix.node + 2 }}
registry-url: 'https://registry.npmjs.org' registry-url: 'https://registry.npmjs.org'
cache: npm cache: 'pnpm'
- run: sudo npm i -g pkg - run: sudo npm i -g pkg
- run: npm ci - run: pnpm install --frozen-lockfile
- run: npm publish --access public - run: npm publish --access public
env: env:
@@ -70,7 +72,7 @@ jobs:
release-docker: release-docker:
needs: release needs: release
runs-on: ubuntu-20.04 runs-on: ubuntu-24.04
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4

View File

@@ -9,22 +9,23 @@ on:
- master - master
jobs: jobs:
test-backend: test-backend-real:
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
strategy: strategy:
matrix: matrix:
node: ['18', '20'] node: ['20', '22']
fail-fast: false fail-fast: false
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- name: Use Node.js ${{ matrix.node }} - name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: ${{ matrix.node }} node-version: ${{ matrix.node }}
cache: npm cache: 'pnpm'
- run: sudo add-apt-repository -y ppa:qbittorrent-team/qbittorrent-stable - run: sudo add-apt-repository -y ppa:qbittorrent-team/qbittorrent-stable
- run: sudo add-apt-repository -y ppa:transmissionbt/ppa - run: sudo add-apt-repository -y ppa:transmissionbt/ppa
@@ -34,7 +35,7 @@ jobs:
wget https://github.com/jesec/rtorrent/releases/latest/download/rtorrent-linux-amd64.deb wget https://github.com/jesec/rtorrent/releases/latest/download/rtorrent-linux-amd64.deb
sudo dpkg -i rtorrent-linux-amd64.deb sudo dpkg -i rtorrent-linux-amd64.deb
- run: npm ci - run: pnpm install --frozen-lockfile
- run: npm test || npm test || npm test - run: npm test || npm test || npm test
- uses: codecov/codecov-action@v3 - uses: codecov/codecov-action@v3
@@ -46,3 +47,16 @@ jobs:
- run: npm test -- --selectProjects rtorrent || npm test -- --selectProjects rtorrent || npm test -- --selectProjects rtorrent - run: npm test -- --selectProjects rtorrent || npm test -- --selectProjects rtorrent || npm test -- --selectProjects rtorrent
if: matrix['node'] == '20' if: matrix['node'] == '20'
test-backend:
# so we do not need to update GitHub repo config
runs-on: ubuntu-latest
needs:
- test-backend-real
strategy:
matrix:
node: ['18', '20']
fail-fast: false
steps:
- run: echo pass

View File

@@ -10,7 +10,7 @@ on:
jobs: jobs:
synchronize-with-crowdin: synchronize-with-crowdin:
if: github.repository_owner == 'jesec' if: github.repository_owner == 'jesec'
runs-on: ubuntu-20.04 runs-on: ubuntu-24.04
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4

View File

@@ -4,3 +4,4 @@ dist-pkg/
# Coverage reports # Coverage reports
coverage/ coverage/
pnpm-lock.yaml

View File

@@ -21,7 +21,7 @@ WORKDIR /usr/src/app/
COPY . ./ COPY . ./
# Fetch dependencies from npm # Fetch dependencies from npm
RUN npm ci --legacy-peer-deps RUN pnpm install --frozen-lockfile --legacy-peer-deps
# Build assets # Build assets
RUN npm run build RUN npm run build

View File

@@ -1,8 +1,8 @@
import {FC, lazy, Suspense} from 'react'; import {ComponentType, FC, lazy, Suspense} from 'react';
import packageJSON from '../../../../../../package.json'; import packageJSON from '../../../../../../package.json';
const AboutMarkdown = lazy(() => const AboutMarkdown = lazy<ComponentType<{FloodVersion: unknown; CommitBadge: unknown}>>(() =>
import(/* webpackChunkName: 'about' */ '../../../../ABOUT.md').then((module) => ({default: module.react})), import(/* webpackChunkName: 'about' */ '../../../../ABOUT.md').then((module) => ({default: module.react})),
); );

View File

@@ -1,6 +1,7 @@
import {ClassNamesArg, cx} from '@emotion/css'; import {cx} from '@emotion/css';
import {FC} from 'react'; import {FC} from 'react';
import {useLingui} from '@lingui/react'; import {useLingui} from '@lingui/react';
import {ClassNamesArg} from '@emotion/react';
import AuthActions from '@client/actions/AuthActions'; import AuthActions from '@client/actions/AuthActions';
import ConfigStore from '@client/stores/ConfigStore'; import ConfigStore from '@client/stores/ConfigStore';

View File

@@ -1,5 +1,5 @@
# Use node alpine docker image # Use node alpine docker image
FROM docker.io/node:alpine FROM docker.io/node:22-alpine
ARG PACKAGE=flood ARG PACKAGE=flood
ARG VERSION=latest ARG VERSION=latest

20060
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -40,12 +40,12 @@
"dist/geoip-country6.dat" "dist/geoip-country6.dat"
], ],
"targets": [ "targets": [
"node18-linuxstatic-x64", "node20-linuxstatic-x64",
"node18-linuxstatic-arm64", "node20-linuxstatic-arm64",
"node18-macos-x64", "node20-macos-x64",
"node18-macos-arm64", "node20-macos-arm64",
"node18-win-x64", "node20-win-x64",
"node18-win-arm64" "node20-win-arm64"
] ]
}, },
"scripts": { "scripts": {
@@ -82,12 +82,14 @@
"@dnd-kit/core": "^6.0.8", "@dnd-kit/core": "^6.0.8",
"@dnd-kit/modifiers": "^6.0.1", "@dnd-kit/modifiers": "^6.0.1",
"@dnd-kit/sortable": "^7.0.2", "@dnd-kit/sortable": "^7.0.2",
"@dnd-kit/utilities": "^3.2.2",
"@emotion/babel-plugin": "^11.11.0", "@emotion/babel-plugin": "^11.11.0",
"@emotion/css": "^11.11.0", "@emotion/css": "^11.11.0",
"@emotion/react": "^11.11.1", "@emotion/react": "^11.11.1",
"@fastify/compress": "^6.5.0", "@fastify/compress": "^6.5.0",
"@fastify/express": "^2.3.0", "@fastify/express": "^2.3.0",
"@fastify/static": "^6.10.2", "@fastify/static": "^6.10.2",
"@lingui/core": "^3.17.2",
"@lingui/loader": "^3.17.2", "@lingui/loader": "^3.17.2",
"@lingui/react": "^3.17.2", "@lingui/react": "^3.17.2",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.10", "@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
@@ -98,6 +100,9 @@
"@types/cookie-parser": "^1.4.3", "@types/cookie-parser": "^1.4.3",
"@types/create-torrent": "^5.0.0", "@types/create-torrent": "^5.0.0",
"@types/d3": "^7.4.0", "@types/d3": "^7.4.0",
"@types/d3-array": "^3.2.1",
"@types/d3-scale": "^4.0.8",
"@types/d3-shape": "^3.1.6",
"@types/express": "^4.17.17", "@types/express": "^4.17.17",
"@types/fs-extra": "^9.0.13", "@types/fs-extra": "^9.0.13",
"@types/geoip-country": "^4.0.0", "@types/geoip-country": "^4.0.0",
@@ -106,14 +111,13 @@
"@types/jsonwebtoken": "^9.0.2", "@types/jsonwebtoken": "^9.0.2",
"@types/lodash": "^4.14.195", "@types/lodash": "^4.14.195",
"@types/morgan": "^1.9.4", "@types/morgan": "^1.9.4",
"@types/node": "^12.20.55", "@types/node": "^14.0.0",
"@types/parse-torrent": "^5.8.4", "@types/parse-torrent": "^5.8.4",
"@types/passport": "^1.0.12", "@types/passport": "^1.0.12",
"@types/passport-jwt": "^3.0.9", "@types/passport-jwt": "^3.0.9",
"@types/react": "^18.2.11", "@types/react": "^18.3.3",
"@types/react-dom": "^18.2.4", "@types/react-dom": "^18.2.4",
"@types/react-measure": "^2.0.8", "@types/react-measure": "^2.0.8",
"@types/react-router-dom": "^5.3.3",
"@types/react-transition-group": "^4.4.6", "@types/react-transition-group": "^4.4.6",
"@types/react-window": "^1.8.5", "@types/react-window": "^1.8.5",
"@types/supertest": "^2.0.12", "@types/supertest": "^2.0.12",
@@ -169,6 +173,7 @@
"jsonwebtoken": "^9.0.0", "jsonwebtoken": "^9.0.0",
"lint-staged": "^15.2.2", "lint-staged": "^15.2.2",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"make-plural": "^7.4.0",
"mini-css-extract-plugin": "^2.7.6", "mini-css-extract-plugin": "^2.7.6",
"mobx": "^6.9.0", "mobx": "^6.9.0",
"mobx-react": "^7.6.0", "mobx-react": "^7.6.0",
@@ -189,8 +194,8 @@
"react-dropzone": "^14.2.3", "react-dropzone": "^14.2.3",
"react-measure": "^2.5.2", "react-measure": "^2.5.2",
"react-refresh": "^0.14.0", "react-refresh": "^0.14.0",
"react-router": "^6.12.1", "react-router": "^6.26.0",
"react-router-dom": "^6.12.1", "react-router-dom": "^6.26.0",
"react-transition-group": "^4.4.5", "react-transition-group": "^4.4.5",
"react-use": "^17.4.0", "react-use": "^17.4.0",
"react-window": "^1.8.9", "react-window": "^1.8.9",
@@ -210,7 +215,7 @@
"tsconfig-paths": "^4.2.0", "tsconfig-paths": "^4.2.0",
"tsx": "^4.6.2", "tsx": "^4.6.2",
"typed-emitter": "^2.1.0", "typed-emitter": "^2.1.0",
"typescript": "~4.9.5", "typescript": "~5.0.4",
"webpack": "^5.86.0", "webpack": "^5.86.0",
"webpack-dev-server": "^4.15.1", "webpack-dev-server": "^4.15.1",
"webpack-shebang-plugin": "^1.1.8", "webpack-shebang-plugin": "^1.1.8",
@@ -219,8 +224,7 @@
"zod": "^3.21.4" "zod": "^3.21.4"
}, },
"engines": { "engines": {
"node": ">=12.0.0", "node": ">=16.0.0"
"npm": ">=6.0.0"
}, },
"browserslist": [ "browserslist": [
"> 2%", "> 2%",
@@ -235,5 +239,6 @@
], ],
"lint-staged": { "lint-staged": {
"*": "prettier --ignore-unknown -w" "*": "prettier --ignore-unknown -w"
} },
"packageManager": "pnpm@9.7.0"
} }

14141
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
module.exports = { module.exports = {
transformIgnorePatterns: ['node_modules/(?!(p-queue|p-timeout)/)'], transformIgnorePatterns: ['node_modules/.pnpm/(?!(p-queue|p-timeout).*/)'],
transform: { transform: {
// transform ESM only package to CommonJS // transform ESM only package to CommonJS
'^.+\\.(t|j)sx?$': [ '^.+\\.(t|j)sx?$': [

View File

@@ -27,7 +27,7 @@ export const methodCallXML = (options: net.NetConnectOpts, methodName: string, p
const xmlLength = Buffer.byteLength(xml, 'utf8'); const xmlLength = Buffer.byteLength(xml, 'utf8');
stream.on('error', reject); stream.on('error', reject);
stream.setEncoding('UTF8'); stream.setEncoding('utf8');
const headerItems = [ const headerItems = [
`CONTENT_LENGTH${NULL_CHAR}${xmlLength}${NULL_CHAR}`, `CONTENT_LENGTH${NULL_CHAR}${xmlLength}${NULL_CHAR}`,
@@ -68,7 +68,7 @@ export const methodCallJSON = (options: net.NetConnectOpts, methodName: string,
const jsonLength = Buffer.byteLength(json, 'utf8'); const jsonLength = Buffer.byteLength(json, 'utf8');
stream.on('error', reject); stream.on('error', reject);
stream.setEncoding('UTF8'); stream.setEncoding('utf8');
const headerItems = [ const headerItems = [
`CONTENT_LENGTH${NULL_CHAR}${jsonLength}${NULL_CHAR}`, `CONTENT_LENGTH${NULL_CHAR}${jsonLength}${NULL_CHAR}`,

View File

@@ -1,6 +1,6 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "es2019", "target": "es2020",
"moduleResolution": "node", "moduleResolution": "node",
"allowJs": true, "allowJs": true,
"module": "commonjs", "module": "commonjs",
@@ -9,6 +9,7 @@
"isolatedModules": true, "isolatedModules": true,
"esModuleInterop": true, "esModuleInterop": true,
"resolveJsonModule": true, "resolveJsonModule": true,
"useUnknownInCatchVariables": false,
"baseUrl": "../", "baseUrl": "../",
"paths": { "paths": {
"@shared/*": ["shared/*"] "@shared/*": ["shared/*"]

View File

@@ -15,6 +15,7 @@
"esModuleInterop": true, "esModuleInterop": true,
"experimentalDecorators": true, "experimentalDecorators": true,
"useDefineForClassFields": true, "useDefineForClassFields": true,
"useUnknownInCatchVariables": false,
"baseUrl": "./", "baseUrl": "./",
"paths": { "paths": {
"@client/*": ["client/src/javascript/*"], "@client/*": ["client/src/javascript/*"],