Skip to content

Commit 0fb6d41

Browse files
authored
feat(tools): use pnpm (#2136)
* fix: use pnpm instead of yarn and add mise * fix: remove client host * fix: update some things * fix: update workflow * fix: add db doc generation * fix: test
1 parent 24c916f commit 0fb6d41

14 files changed

Lines changed: 14114 additions & 154 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,10 @@ RUN apt-get update \
3333

3434
USER node
3535

36+
# install mise
37+
RUN curl https://mise.run | sh
38+
39+
ENV PATH="/home/node/.local/bin:$PATH"
40+
RUN echo 'eval "$(mise activate bash)"' >> ~/.bashrc
41+
3642
RUN echo "source /usr/share/bash-completion/completions/git" >> ~/.bashrc

.github/workflows/deploy-db-doc.yml

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,10 @@ jobs:
1919
runs-on: ubuntu-latest
2020
steps:
2121
- name: Checkout
22-
uses: actions/checkout@v4
22+
uses: actions/checkout@v6
2323

24-
- name: Setup Node
25-
uses: actions/setup-node@v4
26-
with:
27-
node-version: 24
28-
29-
- name: Get yarn cache directory
30-
id: yarn-cache-dir-path
31-
run: |
32-
echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
33-
34-
- uses: actions/cache@v4
35-
with:
36-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
37-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
38-
restore-keys: |
39-
${{ runner.os }}-yarn-
40-
41-
- name: yarn install and generate docs
42-
run: |
43-
yarn
44-
yarn db-doc:generate
24+
- name: generate DB docs
25+
run: mise run generate-db-docs
4526

4627
- name: Upload artifact
4728
uses: actions/upload-pages-artifact@v3

.github/workflows/test.yml

Lines changed: 13 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ env:
1919
APPS_PUBLISHER_ID: 9c9cea73-f3b7-48a3-aa6e-ead82c0685e7 # mock uuid
2020
GRAASPER_CREATOR_ID: bbbf7cac-6139-45e4-8fbf-4cf767b50b29 # mock uuid
2121
COOKIE_DOMAIN: localhost
22-
CLIENT_HOST: http://localhost:3114
2322
DB_PASSWORD: docker
2423
DB_USERNAME: docker
2524
DB_NAME: docker
@@ -92,41 +91,25 @@ jobs:
9291
--health-retries 5
9392
9493
steps:
95-
- uses: actions/checkout@v4
94+
- uses: actions/checkout@v6
9695

97-
- name: Setup Node
98-
uses: actions/setup-node@v4
99-
with:
100-
node-version: 24
101-
102-
- name: Get yarn cache directory
103-
id: yarn-cache-dir-path
104-
run: |
105-
echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
106-
107-
- uses: actions/cache@v4
108-
with:
109-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
110-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
111-
restore-keys: |
112-
${{ runner.os }}-yarn-
96+
- name: Install Mise
97+
uses: jdx/mise-action@v3
11398

11499
- name: yarn install and build
115-
run: |
116-
yarn
117-
yarn build
100+
run: mise run build
118101

119102
- name: yarn check
120-
run: yarn check
103+
run: mise run check
121104

122105
- name: apply migrations on empty database
123-
run: yarn migration:run
106+
run: mise run migrate
124107

125108
- name: check migrations are up to date
126-
run: yarn migration:check
109+
run: mise run migration-check
127110

128111
- name: vitest tests
129-
run: yarn vitest
112+
run: mise run vitest
130113

131114
test-node:
132115
strategy:
@@ -171,24 +154,10 @@ jobs:
171154
--health-retries 5
172155
173156
steps:
174-
- uses: actions/checkout@v4
157+
- uses: actions/checkout@v6
175158

176-
- name: Setup Node
177-
uses: actions/setup-node@v4
178-
with:
179-
node-version: 24
180-
181-
- name: Get yarn cache directory
182-
id: yarn-cache-dir-path
183-
run: |
184-
echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
185-
186-
- uses: actions/cache@v4
187-
with:
188-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
189-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
190-
restore-keys: |
191-
${{ runner.os }}-yarn-
159+
- name: Install Mise
160+
uses: jdx/mise-action@v3
192161

193162
- uses: actions/cache@v4
194163
with:
@@ -197,12 +166,8 @@ jobs:
197166
restore-keys: |
198167
${{ runner.os }}-jest-
199168
200-
- name: yarn install
201-
run: |
202-
yarn
203-
204169
- name: apply migrations on empty database
205-
run: yarn migration:run
170+
run: mise run migrate
206171

207172
- name: yarn test
208-
run: yarn test:ci --shard=${{ matrix.shard }}
173+
run: mise run e2e --shard=${{ matrix.shard }}

.yarnrc.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ GRAASPER_CREATOR_ID=<id>
201201
# REDIS_CONNECTION=
202202

203203
# Client hosts
204-
CLIENT_HOST=http://localhost:3114
205204
LIBRARY_CLIENT_HOST=http://localhost:3005
206205

207206
# Base url used to redirect shortlink aliases

docker/Dockerfile

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,42 @@
11
FROM node:24.12-bookworm AS base
2+
RUN apt-get update \
3+
&& apt-get -y --no-install-recommends install \
4+
sudo curl git ca-certificates build-essential dumb-init \
5+
&& rm -rf /var/lib/apt/lists/*
6+
7+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
8+
ENV MISE_INSTALL_PATH="/usr/local/bin/mise"
9+
10+
# Install mise
11+
RUN curl https://mise.run | sh
212

313

414
##############################
515
### Build Application Step ###
616
##############################
717
# This step will build the application
8-
FROM base AS tools
9-
10-
# update packages and install the minimal init system "dumb-init"
11-
RUN apt-get update && apt-get install -y --no-install-recommends dumb-init
18+
# FROM base AS tools
1219

20+
# # update packages and install the minimal init system "dumb-init"
21+
# RUN apt-get update \
22+
# && apt-get install -y --no-install-recommends dumb-init \
23+
# && rm -rf /var/lib/apt/lists/*
1324

1425
# -------------------------------------------------------
1526
FROM base AS build
1627

1728
WORKDIR /app
18-
COPY package.json yarn.lock .yarnrc.yml ./
19-
# We need a specific command because we need to copy the folder with it, not just the content.
20-
COPY .yarn/releases ./.yarn/releases/
21-
RUN yarn set version berry && yarn install --immutable
29+
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml mise.toml ./
30+
31+
ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0
32+
RUN mise trust && mise install && corepack enable && pnpm install --frozen-lockfile
2233

2334
ENV NODE_ENV=production
2435
COPY . .
25-
RUN yarn build-ts
36+
RUN pnpm build-ts
2637

27-
# -------------------------------------------------------
28-
FROM base AS deps
29-
30-
WORKDIR /app
31-
COPY package.json yarn.lock .yarnrc.yml ./
32-
# We need a specific command because we need to copy the folder with it, not just the content.
33-
COPY .yarn/releases ./.yarn/releases/
34-
RUN yarn set version berry && yarn workspaces focus --all --production
38+
# removes non prod dependencies
39+
RUN pnpm install --prod --frozen-lockfile
3540

3641
############################
3742
### Run Application Step ###
@@ -54,10 +59,10 @@ EXPOSE 3000
5459
WORKDIR /app
5560

5661
# Copy the installed dumb-init system from build image
57-
COPY --from=tools /usr/bin/dumb-init /usr/bin/dumb-init
62+
COPY --from=base /usr/bin/dumb-init /usr/bin/dumb-init
5863

5964
# Copy the dependencies and compiled server code
60-
COPY --chown=node:node --from=deps ./app/node_modules ./node_modules
65+
COPY --chown=node:node --from=build ./app/node_modules ./node_modules
6166
COPY --chown=node:node --from=build ./app/dist ./dist
6267

6368
# Set user to be non-root node

mise.toml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
[tools]
2+
node = "24"
3+
4+
[hooks]
5+
# Enabling corepack will install the `pnpm` package manager specified in your package.json
6+
# alternatively, you can also install `pnpm` with mise
7+
postinstall = 'npx corepack enable'
8+
9+
[settings]
10+
# This must be enabled to make the hooks work
11+
experimental = true
12+
13+
[env]
14+
_.path = ['{{config_root}}/node_modules/.bin']
15+
16+
[tasks.pnpm-install]
17+
description = 'Installs dependencies with pnpm'
18+
run = 'pnpm install'
19+
sources = ['package.json', 'pnpm-lock.yaml', 'mise.toml']
20+
outputs = ['node_modules/.pnpm/lock.yaml']
21+
22+
[tasks.dev]
23+
depends = ["pnpm-install"]
24+
description = "Run the development server"
25+
run = "pnpm watch"
26+
27+
[tasks.lint]
28+
depends = ["pnpm-install"]
29+
description = "Lint the files with eslint"
30+
run = "eslint '**/*.{js,ts}'"
31+
32+
[tasks.prettier-check]
33+
depends = ["pnpm-install"]
34+
description = "Check formatting with prettier"
35+
run = "prettier --check \"{src,test}/**/*.ts\""
36+
37+
[tasks.type-check]
38+
depends = ["pnpm-install"]
39+
description = "Run typescript checking"
40+
run = "tsc --noEmit"
41+
42+
[tasks.check]
43+
depends = ["prettier-check", "lint", "type-check"]
44+
45+
[tasks.build]
46+
depends = ["lint"]
47+
description = "Build the application"
48+
run = "tsc -p tsconfig.build.json"
49+
50+
[tasks.migrate]
51+
depends = ["pnpm-install"]
52+
run = "drizzle-kit migrate"
53+
env = { _.file = '.env.development' }
54+
55+
[tasks.migration-check]
56+
env = { _.file = '.env.development' }
57+
depends = ["pnpm-install"]
58+
run = "drizzle-kit generate --name=migrationtest --out=./src/drizzle --schema=./src/drizzle/schema.ts --dialect=postgresql && [ -f '$(find ./src/drizzle | grep migrationtest)' ] && exit 1 || exit 0"
59+
60+
[tasks.vitest]
61+
depends = "pnpm-install"
62+
run = "vitest"
63+
64+
[tasks.e2e]
65+
depends = ["pnpm-install"]
66+
env = { _.file = '.env.test'}
67+
run = "jest --forceExit --verbose --coverage --silent --detectOpenHandles --maxWorkers=2"
68+
69+
[tasks.test]
70+
depends = ["vitest", "e2e"]
71+
72+
[tasks.generate-db-docs]
73+
depends = ["pnpm-install"]
74+
description = "Generate documentation for the database schemas"
75+
run = "drizzle-kit export > schema.sql && npx @liam-hq/cli erd build --input schema.sql --format postgres --output-dir db-documentation"

package.json

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@
1212
"license": "AGPL-3.0-only",
1313
"author": "Graasp",
1414
"type": "commonjs",
15+
"packageManager": "pnpm@11.2.1",
1516
"scripts": {
16-
"start": "yarn serve",
17-
"build": "yarn lint && yarn build-ts",
18-
"serve": "NODE_PATH=./dist node dist/server.js",
17+
"start": "NODE_PATH=./dist node dist/server.js",
18+
"build": "pnpm lint && pnpm build-ts",
1919
"watch-node": "NODE_PATH=./dist nodemon dist/server.js",
2020
"watch-node:worker": "NODE_PATH=./dist nodemon dist/workers/entrypoint.js",
21-
"dev": "yarn run watch",
22-
"watch": "concurrently -k -p \"[{name}]\" -n \"TypeScript,Server,Worker\" -c \"cyan.bold,green.bold,magenta.bold\" \"yarn watch-ts\" \"yarn watch-node\" \"yarn watch-node:worker\"",
21+
"watch": "concurrently -k -p \"[{name}]\" -n \"TypeScript,Server\" -c \"cyan.bold,green.bold\" \"pnpm watch-ts\" \"pnpm watch-node\"",
2322
"seed": "ts-node -e 'import seed from \"./test/mocks/index\";seed();'",
2423
"test": "jest --forceExit --verbose --runInBand --detectOpenHandles",
2524
"test:ci": "jest --forceExit --verbose --coverage --silent --detectOpenHandles --maxWorkers=2",
@@ -43,7 +42,7 @@
4342
"openapi:report": "vacuum html-report ./openapi.json vacuum-report.html",
4443
"migration:apply-test": "DB_CONNECTION=postgres://test:test@db:5432/test yarn migration:run",
4544
"migration:generate": "yarn drizzle-kit generate",
46-
"migration:run": "yarn drizzle-kit migrate",
45+
"migrate": "drizzle-kit migrate",
4746
"migration:check": "yarn drizzle-kit generate --name=migrationtest --out=./src/drizzle --schema=./src/drizzle/schema.ts --dialect=postgresql && [ -f '$(find ./src/drizzle | grep migrationtest)' ] && exit 1 || exit 0",
4847
"db-doc:generate": "npx drizzle-kit export > schema.sql && npx @liam-hq/cli erd build --input schema.sql --format postgres --output-dir db-documentation"
4948
},
@@ -183,6 +182,5 @@
183182
"sodium-native": "4.2.0",
184183
"fastify": "5.8.5",
185184
"@sinclair/typebox": "0.34.49"
186-
},
187-
"packageManager": "yarn@4.14.1"
185+
}
188186
}

0 commit comments

Comments
 (0)