Chore: use pnpm

This commit is contained in:
shamoon 2025-03-05 23:06:19 -08:00
parent d73118d226
commit 50e57e2d6a
No known key found for this signature in database
13 changed files with 12342 additions and 33 deletions

View File

@ -149,7 +149,7 @@ RUN --mount=type=cache,target=/root/.cache/uv,id=pip-cache \
&& apt-get install --yes --quiet ${BUILD_PACKAGES} && apt-get install --yes --quiet ${BUILD_PACKAGES}
RUN set -eux \ RUN set -eux \
&& npm update npm -g && npm update -g pnpm
# add users, setup scripts # add users, setup scripts
# Mount the compiled frontend to expected location # Mount the compiled frontend to expected location

View File

@ -33,7 +33,7 @@
"label": "Start: Frontend Angular", "label": "Start: Frontend Angular",
"description": "Start the Frontend Angular Dev Server", "description": "Start the Frontend Angular Dev Server",
"type": "shell", "type": "shell",
"command": "npm start", "command": "pnpm start",
"isBackground": true, "isBackground": true,
"options": { "options": {
"cwd": "${workspaceFolder}/src-ui" "cwd": "${workspaceFolder}/src-ui"
@ -173,8 +173,8 @@
}, },
{ {
"label": "Maintenance: Install Frontend Dependencies", "label": "Maintenance: Install Frontend Dependencies",
"description": "Install frontend (npm) dependencies", "description": "Install frontend (pnpm) dependencies",
"type": "npm", "type": "pnpm",
"script": "install", "script": "install",
"path": "src-ui", "path": "src-ui",
"group": "clean", "group": "clean",
@ -185,7 +185,7 @@
"description": "Clean install frontend dependencies and build the frontend for production", "description": "Clean install frontend dependencies and build the frontend for production",
"label": "Maintenance: Compile frontend for production", "label": "Maintenance: Compile frontend for production",
"type": "shell", "type": "shell",
"command": "npm ci && ./node_modules/.bin/ng build --configuration production", "command": "pnpm install && ./node_modules/.bin/ng build --configuration production",
"group": "none", "group": "none",
"presentation": { "presentation": {
"echo": true, "echo": true,

View File

@ -5,8 +5,8 @@ version: 2
enable-beta-ecosystems: true enable-beta-ecosystems: true
updates: updates:
# Enable version updates for npm # Enable version updates for pnpm
- package-ecosystem: "npm" - package-ecosystem: "pnpm"
target-branch: "dev" target-branch: "dev"
# Look for `package.json` and `lock` files in the `/src-ui` directory # Look for `package.json` and `lock` files in the `/src-ui` directory
directory: "/src-ui" directory: "/src-ui"

View File

@ -186,25 +186,29 @@ jobs:
- pre-commit - pre-commit
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- -
name: Use Node.js 20 name: Use Node.js 20
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: 20.x node-version: 20.x
cache: 'npm' cache: 'pnpm'
cache-dependency-path: 'src-ui/package-lock.json' cache-dependency-path: 'src-ui/pnpm-lock.yaml'
- name: Cache frontend dependencies - name: Cache frontend dependencies
id: cache-frontend-deps id: cache-frontend-deps
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
path: | path: |
~/.npm ~/.pnpm-store
~/.cache ~/.cache
key: ${{ runner.os }}-frontenddeps-${{ hashFiles('src-ui/package-lock.json') }} key: ${{ runner.os }}-frontenddeps-${{ hashFiles('src-ui/pnpm-lock.yaml') }}
- -
name: Install dependencies name: Install dependencies
if: steps.cache-frontend-deps.outputs.cache-hit != 'true' if: steps.cache-frontend-deps.outputs.cache-hit != 'true'
run: cd src-ui && npm ci run: cd src-ui && pnpm install
- -
name: Install Playwright name: Install Playwright
if: steps.cache-frontend-deps.outputs.cache-hit != 'true' if: steps.cache-frontend-deps.outputs.cache-hit != 'true'
@ -223,31 +227,35 @@ jobs:
shard-count: [4] shard-count: [4]
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- -
name: Use Node.js 20 name: Use Node.js 20
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: 20.x node-version: 20.x
cache: 'npm' cache: 'pnpm'
cache-dependency-path: 'src-ui/package-lock.json' cache-dependency-path: 'src-ui/pnpm-lock.yaml'
- name: Cache frontend dependencies - name: Cache frontend dependencies
id: cache-frontend-deps id: cache-frontend-deps
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
path: | path: |
~/.npm ~/.pnpm-store
~/.cache ~/.cache
key: ${{ runner.os }}-frontenddeps-${{ hashFiles('src-ui/package-lock.json') }} key: ${{ runner.os }}-frontenddeps-${{ hashFiles('src-ui/package-lock.json') }}
- name: Re-link Angular cli - name: Re-link Angular cli
run: cd src-ui && npm link @angular/cli run: cd src-ui && pnpm link @angular/cli
- -
name: Linting checks name: Linting checks
run: cd src-ui && npm run lint run: cd src-ui && pnpm run lint
- -
name: Run Jest unit tests name: Run Jest unit tests
env: env:
JEST_JUNIT_OUTPUT_FILE: junit-report-${{ matrix.shard-index }}.xml JEST_JUNIT_OUTPUT_FILE: junit-report-${{ matrix.shard-index }}.xml
run: cd src-ui && npm run test -- --max-workers=2 --shard=${{ matrix.shard-index }}/${{ matrix.shard-count }} run: cd src-ui && pnpm run test --max-workers=2 --shard=${{ matrix.shard-index }}/${{ matrix.shard-count }}
- -
name: Upload Jest coverage name: Upload Jest coverage
if: always() if: always()
@ -350,25 +358,30 @@ jobs:
token: ${{ secrets.CODECOV_TOKEN }} token: ${{ secrets.CODECOV_TOKEN }}
flags: backend flags: backend
directory: src/ directory: src/
-
name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- -
name: Use Node.js 20 name: Use Node.js 20
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: 20.x node-version: 20.x
cache: 'npm' cache: 'pnpm'
cache-dependency-path: 'src-ui/package-lock.json' cache-dependency-path: 'src-ui/pnpm-lock.yaml'
- -
name: Cache frontend dependencies name: Cache frontend dependencies
id: cache-frontend-deps id: cache-frontend-deps
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
path: | path: |
~/.npm ~/.pnpm-store
~/.cache ~/.cache
key: ${{ runner.os }}-frontenddeps-${{ hashFiles('src-ui/package-lock.json') }} key: ${{ runner.os }}-frontenddeps-${{ hashFiles('src-ui/package-lock.json') }}
- -
name: Re-link Angular cli name: Re-link Angular cli
run: cd src-ui && npm link @angular/cli run: cd src-ui && pnpm link @angular/cli
- -
name: Build frontend and upload analysis name: Build frontend and upload analysis
env: env:

View File

@ -32,7 +32,7 @@ repos:
rev: v2.4.0 rev: v2.4.0
hooks: hooks:
- id: codespell - id: codespell
exclude: "(^src-ui/src/locale/)|(^src-ui/e2e/)|(^src/paperless_mail/tests/samples/)" exclude: "(^src-ui/src/locale/)|(^src-ui/pnpm-lock.yaml)|(^src-ui/e2e/)|(^src/paperless_mail/tests/samples/)"
exclude_types: exclude_types:
- pofile - pofile
- json - json

View File

@ -4,15 +4,15 @@
# Stage: compile-frontend # Stage: compile-frontend
# Purpose: Compiles the frontend # Purpose: Compiles the frontend
# Notes: # Notes:
# - Does NPM stuff with Typescript and such # - Does PNPM stuff with Typescript and such
FROM --platform=$BUILDPLATFORM docker.io/node:20-bookworm-slim AS compile-frontend FROM --platform=$BUILDPLATFORM docker.io/node:20-bookworm-slim AS compile-frontend
COPY ./src-ui /src/src-ui COPY ./src-ui /src/src-ui
WORKDIR /src/src-ui WORKDIR /src/src-ui
RUN set -eux \ RUN set -eux \
&& npm update npm -g \ && npm update -g pnpm \
&& npm ci && pnpm install
ARG PNGX_TAG_VERSION= ARG PNGX_TAG_VERSION=
# Add the tag to the environment file if its a tagged dev build # Add the tag to the environment file if its a tagged dev build

View File

@ -140,7 +140,7 @@ To build the front end once use this command:
```bash ```bash
# src-ui/ # src-ui/
$ npm install $ pnpm install
$ ng build --configuration production $ ng build --configuration production
``` ```
@ -176,7 +176,7 @@ To add a new development package `uv add --dev <package>`
## Front end development ## Front end development
The front end is built using AngularJS. In order to get started, you need Node.js (version 14.15+) and The front end is built using AngularJS. In order to get started, you need Node.js (version 14.15+) and
`npm`. `pnpm`.
!!! note !!! note
@ -185,7 +185,7 @@ The front end is built using AngularJS. In order to get started, you need Node.j
1. Install the Angular CLI. You might need sudo privileges to perform this command: 1. Install the Angular CLI. You might need sudo privileges to perform this command:
```bash ```bash
npm install -g @angular/cli pnpm install -g @angular/cli
``` ```
2. Make sure that it's on your path. 2. Make sure that it's on your path.
@ -193,7 +193,7 @@ The front end is built using AngularJS. In order to get started, you need Node.j
3. Install all necessary modules: 3. Install all necessary modules:
```bash ```bash
npm install pnpm install
``` ```
4. You can launch a development server by running: 4. You can launch a development server by running:

1
src-ui/.npmrc Normal file
View File

@ -0,0 +1 @@
shamefully-hoist=true

View File

@ -178,7 +178,8 @@
"schematicCollections": [ "schematicCollections": [
"@angular-eslint/schematics" "@angular-eslint/schematics"
], ],
"analytics": false "analytics": false,
"packageManager": "pnpm"
}, },
"schematics": { "schematics": {
"@angular-eslint/schematics:application": { "@angular-eslint/schematics:application": {

View File

@ -7,7 +7,9 @@ module.exports = {
'abstract-name-filter-service', 'abstract-name-filter-service',
'abstract-paperless-service', 'abstract-paperless-service',
], ],
transformIgnorePatterns: [`<rootDir>/node_modules/(?!.*\\.mjs$|lodash-es)`], transformIgnorePatterns: [
`<rootDir>/node_modules/.pnpm/(?!.*\\.mjs$|lodash-es)`,
],
moduleNameMapper: { moduleNameMapper: {
'^src/(.*)': '<rootDir>/src/$1', '^src/(.*)': '<rootDir>/src/$1',
}, },

View File

@ -2,6 +2,7 @@
"name": "paperless-ui", "name": "paperless-ui",
"version": "0.0.0", "version": "0.0.0",
"scripts": { "scripts": {
"preinstall": "npx only-allow pnpm",
"ng": "ng", "ng": "ng",
"start": "ng serve", "start": "ng serve",
"build": "ng build", "build": "ng build",
@ -71,5 +72,14 @@
"ts-node": "~10.9.1", "ts-node": "~10.9.1",
"typescript": "^5.5.4" "typescript": "^5.5.4"
}, },
"pnpm": {
"onlyBuiltDependencies": [
"@parcel/watcher",
"canvas",
"esbuild",
"lmdb",
"msgpackr-extract"
]
},
"typings": "./src/typings.d.ts" "typings": "./src/typings.d.ts"
} }

View File

@ -21,7 +21,7 @@ export default defineConfig({
/* Run your local dev server before starting the tests */ /* Run your local dev server before starting the tests */
webServer: { webServer: {
port, port,
command: 'npm run start', command: 'pnpm run start',
reuseExistingServer: !process.env.CI, reuseExistingServer: !process.env.CI,
timeout: 2 * 60 * 1000, timeout: 2 * 60 * 1000,
}, },

12282
src-ui/pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff