Fix issue #29: Migrate from npm to pnpm workspace
All checks were successful
Test / test (push) Successful in 2s

This commit is contained in:
Gitea OpenCode Agent
2026-10-14 17:01:02 +00:00
parent b02ecca7d4
commit 9820a375dc
17 changed files with 10053 additions and 15178 deletions

9
.dockerignore Normal file
View File

@@ -0,0 +1,9 @@
# Images are built from the repository root (see .gitea/workflows/deploy.yml:
# `docker build -f <package>/Dockerfile .`), so this is the ignore file that counts.
.git
**/node_modules
**/*.log
**/.env
frontend/.nuxt
frontend/.output
frontend/dist

View File

@@ -32,24 +32,28 @@ jobs:
run: | run: |
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login git.aranroig.com -u "${{ secrets.REGISTRY_USER }}" --password-stdin echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login git.aranroig.com -u "${{ secrets.REGISTRY_USER }}" --password-stdin
# pnpm workspace: every image is built from the repository root so the
# Dockerfiles can read pnpm-workspace.yaml, pnpm-lock.yaml and the other
# package.json files of the workspace.
- name: Build frontend - name: Build frontend
run: | run: |
docker build -t git.aranroig.com/${{ secrets.REGISTRY_USER }}/dragonroll-frontend:latest \ docker build -t git.aranroig.com/${{ secrets.REGISTRY_USER }}/dragonroll-frontend:latest \
--build-arg NUXT_PUBLIC_GIT_COMMIT=$(git rev-parse --short HEAD) \ --build-arg NUXT_PUBLIC_GIT_COMMIT=$(git rev-parse --short HEAD) \
--build-arg NUXT_PUBLIC_GIT_TAG=$(git describe --tags --abbrev=0) \ --build-arg NUXT_PUBLIC_GIT_TAG=$(git describe --tags --abbrev=0) \
--build-arg NUXT_PUBLIC_GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD) \ --build-arg NUXT_PUBLIC_GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD) \
./frontend -f ./frontend/Dockerfile .
docker push git.aranroig.com/${{ secrets.REGISTRY_USER }}/dragonroll-frontend:latest docker push git.aranroig.com/${{ secrets.REGISTRY_USER }}/dragonroll-frontend:latest
- name: Build backend - name: Build backend
run: | run: |
docker build -t git.aranroig.com/${{ secrets.REGISTRY_USER }}/dragonroll-backend:latest ./backend docker build -t git.aranroig.com/${{ secrets.REGISTRY_USER }}/dragonroll-backend:latest \
-f ./backend/Dockerfile .
docker push git.aranroig.com/${{ secrets.REGISTRY_USER }}/dragonroll-backend:latest docker push git.aranroig.com/${{ secrets.REGISTRY_USER }}/dragonroll-backend:latest
- name: Build discord bot - name: Build discord bot
run: | run: |
docker build -t git.aranroig.com/${{ secrets.REGISTRY_USER }}/dragonroll-discord-bot:latest \ docker build -t git.aranroig.com/${{ secrets.REGISTRY_USER }}/dragonroll-discord-bot:latest \
./discord-bot -f ./discord-bot/Dockerfile .
docker push git.aranroig.com/${{ secrets.REGISTRY_USER }}/dragonroll-discord-bot:latest docker push git.aranroig.com/${{ secrets.REGISTRY_USER }}/dragonroll-discord-bot:latest
- name: Copy files - name: Copy files

View File

@@ -28,4 +28,8 @@ jobs:
fi fi
- name: Run tests - name: Run tests
run: npm test # The repository is a pnpm workspace: run the root script through corepack,
# which picks the pnpm version pinned by "packageManager" in package.json.
run: corepack pnpm test
env:
COREPACK_ENABLE_DOWNLOAD_PROMPT: '0'

View File

@@ -14,15 +14,23 @@ dice widgets, shared markdown, sounds). It is a two-app monorepo:
There is **no** database seeding, no ORM migrations, no linter/formatter config, no Pinia/Vuex, and no There is **no** database seeding, no ORM migrations, no linter/formatter config, no Pinia/Vuex, and no
Vue Router pages (see §5.1 — the UI is a window manager, not routed pages). The only automated tests Vue Router pages (see §5.1 — the UI is a window manager, not routed pages). The only automated tests
are `tests/*.test.js` (`npm test`, Node's built-in runner), which exercise the Foundry module's sync are `tests/*.test.js` (`pnpm test`, Node's built-in runner), which exercise the Foundry module's sync
logic against stubbed Foundry globals. logic against stubbed Foundry globals.
Package management is a **pnpm workspace** (`pnpm-workspace.yaml` lists `backend`, `frontend` and
`discord-bot`). One `pnpm-lock.yaml` at the root, no `package-lock.json` anywhere; `packageManager` in
the root `package.json` pins pnpm for corepack. The three packages do not depend on each other, so
nothing uses the `workspace:` protocol yet, and `dragonroll-foundry/bridge` stays outside the workspace
(it needs nothing but Node built-ins).
Git: default branch `master`, hosted on a self-hosted Gitea (`git.aranroig.com/BinarySandia04/Dragonroll`). Git: default branch `master`, hosted on a self-hosted Gitea (`git.aranroig.com/BinarySandia04/Dragonroll`).
CI (`.gitea/workflows/deploy.yml`) builds two Docker images on every push to `master`, pushes them to CI (`.gitea/workflows/deploy.yml`) builds three Docker images on every push to `master` — always from
`git.aranroig.com/<user>/dragonroll-{frontend,backend}:latest`, copies `docker-compose.yml` + the **repository root as build context** (`docker build -f <package>/Dockerfile .`, the Dockerfiles read
the workspace manifests) — pushes them to
`git.aranroig.com/<user>/dragonroll-{frontend,backend,discord-bot}:latest`, copies `docker-compose.yml` +
`nginx.conf` to the deploy host and runs `docker compose pull && up -d`. `nginx.conf` to the deploy host and runs `docker compose pull && up -d`.
`.gitea/workflows/test.yml` runs the `npm test` suite (frontend + Foundry module tests, no dependencies `.gitea/workflows/test.yml` runs the `corepack pnpm test` suite (frontend + Foundry module tests, no
installed) on every push to any branch, not just `master`. dependencies installed) on every push to any branch, not just `master`.
## 2. Root layout ## 2. Root layout
@@ -30,44 +38,49 @@ installed) on every push to any branch, not just `master`.
dragonroll/ dragonroll/
├── backend/ Express API (CommonJS, entry: src/index.js) ├── backend/ Express API (CommonJS, entry: src/index.js)
├── frontend/ Nuxt 4 app (entry: app/app.vue) ├── frontend/ Nuxt 4 app (entry: app/app.vue)
├── discord-bot/ discord.js slash commands reading the API
├── obsidian-plugin/ Plain JavaScript Obsidian plugin for campaign note import/push ├── obsidian-plugin/ Plain JavaScript Obsidian plugin for campaign note import/push
├── pnpm-workspace.yaml workspace packages + the dependencies allowed to run install scripts
├── pnpm-lock.yaml the only lockfile (root of the workspace)
├── docker-compose.yml nginx :3000 -> frontend :3000, /api -> backend :5000 ├── docker-compose.yml nginx :3000 -> frontend :3000, /api -> backend :5000
├── nginx.conf reverse proxy rules for the compose stack ├── nginx.conf reverse proxy rules for the compose stack
├── ecosystem.config.js PM2 config (stale: runs `npm start`, which does not exist — see §9) ├── ecosystem.config.js PM2 config (stale: runs `npm start`, which does not exist — see §9)
├── .gitea/workflows/deploy.yml ├── .gitea/workflows/deploy.yml
├── static/media/ README logo images only ├── static/media/ README logo images only
├── tests/ `node --test` tests (Foundry module sync toggle) ├── tests/ `node --test` tests (Foundry module sync toggle)
├── package.json root: only `concurrently`, used by `npm run dev` ├── package.json root workspace: `concurrently`, the `dev` scripts and `test`
└── README.md install/run instructions are STALE (see §9) └── README.md install/run instructions are STALE (see §9)
``` ```
## 3. Commands ## 3. Commands
`pnpm` comes from corepack (`packageManager` in `package.json`); `COREPACK_ENABLE_DOWNLOAD_PROMPT=0`
keeps corepack from asking in non-interactive shells.
```bash ```bash
npm install # root: installs `concurrently` only pnpm install # the whole workspace, once, from the root
npm install --prefix backend # (frontend's `nuxt prepare` runs as its postinstall)
npm install --prefix frontend # runs `nuxt prepare` via postinstall
npm run dev # both apps: backend (nodemon, :5000) + frontend (nuxt dev, :3000) pnpm dev # backend (nodemon, :5000) + frontend (nuxt dev, :3000)
# also runs the Foundry VTT start script from root .env # + discord-bot, plus the Foundry VTT start script from root .env
# (FOUNDRY_START_SCRIPT, via scripts/run-foundry.js) # (FOUNDRY_START_SCRIPT, via scripts/run-foundry.js)
npm --prefix backend run dev # backend only pnpm dev:backend # one package, also `pnpm dev:frontend` / `pnpm dev:discord-bot`
npm --prefix frontend run dev # frontend only pnpm --filter ./frontend run build # nuxt build --dotenv .env.production
npm --prefix frontend run build # nuxt build --dotenv .env.production pnpm --filter ./frontend run preview
npm --prefix frontend run preview cd frontend && pnpm run build # --filter and `cd` are equivalent inside the workspace
npm test # node --test tests/ (Foundry module sync logic, no dependencies) pnpm test # node --test tests/ (Foundry module sync logic, no dependencies)
``` ```
There is no `start` script in either package and no lint command. There is no `start` script in either app package and no lint command (`discord-bot` has `start`).
Verification = run the dev server and exercise the flow (`/api/test` returns a JSON hello); Verification = run the dev server and exercise the flow (`/api/test` returns a JSON hello);
`npm test` covers the Foundry character/item sync toggle and per-actor force sync. `pnpm test` covers the Foundry character/item sync toggle and per-actor force sync.
### Environment files ### Environment files
| File | Contents | Notes | | File | Contents | Notes |
|---|---|---| |---|---|---|
| `.env` (root) | `FOUNDRY_START_SCRIPT=<path to Foundry VTT start.sh>` | gitignored; consumed by `scripts/run-foundry.js` during `npm run dev` | | `.env` (root) | `FOUNDRY_START_SCRIPT=<path to Foundry VTT start.sh>` | gitignored; consumed by `scripts/run-foundry.js` during `pnpm dev` |
| `backend/.env` | `PORT=5000`, `DB_URI=mongodb://localhost:27017/dragonroll`, `NODE_ENV=development` | gitignored | | `backend/.env` | `PORT=5000`, `DB_URI=mongodb://localhost:27017/dragonroll`, `NODE_ENV=development` | gitignored |
| `backend/.env.production` | same shape, `DB_URI=mongodb://192.168.1.7:27017/dragonroll` | **committed** | | `backend/.env.production` | same shape, `DB_URI=mongodb://192.168.1.7:27017/dragonroll` | **committed** |
| `frontend/.env` | `NUXT_PUBLIC_API_BASE_URL=http://localhost:5000/api` | gitignored | | `frontend/.env` | `NUXT_PUBLIC_API_BASE_URL=http://localhost:5000/api` | gitignored |

View File

@@ -1,23 +1,29 @@
# Use official Node.js runtime # Use official Node.js runtime
FROM node:20-alpine FROM node:20-alpine
# pnpm is served by corepack and pinned by "packageManager" in the root package.json
RUN corepack enable
# Create app directory # Create app directory
WORKDIR /usr/src/app WORKDIR /usr/src/app
# Copy package files first (better caching) # Copy the workspace manifests first (better caching)
COPY package*.json ./ COPY pnpm-workspace.yaml pnpm-lock.yaml package.json ./
COPY backend/package.json ./backend/
COPY frontend/package.json ./frontend/
COPY discord-bot/package.json ./discord-bot/
# Install dependencies # Install the production dependencies of the backend package
RUN npm ci --only=production RUN pnpm install --frozen-lockfile --prod --filter ./backend...
# Copy application source # Copy application source
COPY . . COPY backend ./backend
# Expose the app port
# EXPOSE 3000
# Environment variable # Environment variable
ENV NODE_ENV=production ENV NODE_ENV=production
# The app reads .env.production from its working directory
WORKDIR /usr/src/app/backend
# Start the application # Start the application
CMD ["node", "src/index.js"] CMD ["node", "src/index.js"]

1770
backend/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,21 +1,30 @@
# Use official Node.js runtime # Use official Node.js runtime
FROM node:20-alpine FROM node:20-alpine
# pnpm is served by corepack and pinned by "packageManager" in the root package.json
RUN corepack enable
# Create app directory # Create app directory
WORKDIR /usr/src/app WORKDIR /usr/src/app
# Copy package files first (better caching) # Copy the workspace manifests first (better caching)
COPY package*.json ./ COPY pnpm-workspace.yaml pnpm-lock.yaml package.json ./
COPY backend/package.json ./backend/
COPY frontend/package.json ./frontend/
COPY discord-bot/package.json ./discord-bot/
# Install dependencies # Install the production dependencies of the bot package
RUN npm ci --only=production RUN pnpm install --frozen-lockfile --prod --filter ./discord-bot...
# Copy application source # Copy application source
COPY . . COPY discord-bot ./discord-bot
# Environment variable # Environment variable
ENV NODE_ENV=production ENV NODE_ENV=production
# The bot reads .env from its working directory
WORKDIR /usr/src/app/discord-bot
# The bot only makes outbound connections (Discord gateway + Dragonroll API), # The bot only makes outbound connections (Discord gateway + Dragonroll API),
# it does not listen on a port. # it does not listen on a port.
# Start the application # Start the application

View File

@@ -1,327 +0,0 @@
{
"name": "dragonroll-discord-bot",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "dragonroll-discord-bot",
"version": "1.0.0",
"dependencies": {
"discord.js": "^14.27.0",
"dotenv": "^17.2.3"
},
"engines": {
"node": ">=20"
}
},
"node_modules/@discordjs/builders": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-1.14.1.tgz",
"integrity": "sha512-gSKkhXLqs96TCzk66VZuHHl8z2bQMJFGwrXC0f33ngK+FLNau4hU1PYny3DNJfNdSH+gVMzE85/d5FQ2BpcNwQ==",
"license": "Apache-2.0",
"dependencies": {
"@discordjs/formatters": "^0.6.2",
"@discordjs/util": "^1.2.0",
"@sapphire/shapeshift": "^4.0.0",
"discord-api-types": "^0.38.40",
"fast-deep-equal": "^3.1.3",
"ts-mixer": "^6.0.4",
"tslib": "^2.6.3"
},
"engines": {
"node": ">=16.11.0"
},
"funding": {
"url": "https://github.com/discordjs/discord.js?sponsor"
}
},
"node_modules/@discordjs/collection": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-1.5.3.tgz",
"integrity": "sha512-SVb428OMd3WO1paV3rm6tSjM4wC+Kecaa1EUGX7vc6/fddvw/6lg90z4QtCqm21zvVe92vMMDt9+DkIvjXImQQ==",
"license": "Apache-2.0",
"engines": {
"node": ">=16.11.0"
}
},
"node_modules/@discordjs/formatters": {
"version": "0.6.2",
"resolved": "https://registry.npmjs.org/@discordjs/formatters/-/formatters-0.6.2.tgz",
"integrity": "sha512-y4UPwWhH6vChKRkGdMB4odasUbHOUwy7KL+OVwF86PvT6QVOwElx+TiI1/6kcmcEe+g5YRXJFiXSXUdabqZOvQ==",
"license": "Apache-2.0",
"dependencies": {
"discord-api-types": "^0.38.33"
},
"engines": {
"node": ">=16.11.0"
},
"funding": {
"url": "https://github.com/discordjs/discord.js?sponsor"
}
},
"node_modules/@discordjs/rest": {
"version": "2.6.3",
"resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-2.6.3.tgz",
"integrity": "sha512-wvOylxNYJkwKjctS/Mn5GP1w9r3/rzyH+ThD1JlAca6zEdlHs8QWBBUQJpU5Q+W6DoIj/Ljh1IPlZs7hTU+UAg==",
"license": "Apache-2.0",
"dependencies": {
"@discordjs/collection": "^2.1.1",
"@discordjs/util": "^1.2.0",
"@sapphire/async-queue": "^1.5.3",
"@sapphire/snowflake": "^3.5.5",
"@vladfrangu/async_event_emitter": "^2.4.6",
"discord-api-types": "^0.38.50",
"magic-bytes.js": "^1.13.0",
"tslib": "^2.6.3",
"undici": "^6.27.0"
},
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/discordjs/discord.js?sponsor"
}
},
"node_modules/@discordjs/rest/node_modules/@discordjs/collection": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-2.1.1.tgz",
"integrity": "sha512-LiSusze9Tc7qF03sLCujF5iZp7K+vRNEDBZ86FT9aQAv3vxMLihUvKvpsCWiQ2DJq1tVckopKm1rxomgNUc9hg==",
"license": "Apache-2.0",
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/discordjs/discord.js?sponsor"
}
},
"node_modules/@discordjs/util": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@discordjs/util/-/util-1.2.0.tgz",
"integrity": "sha512-3LKP7F2+atl9vJFhaBjn4nOaSWahZ/yWjOvA4e5pnXkt2qyXRCHLxoBQy81GFtLGCq7K9lPm9R517M1U+/90Qg==",
"license": "Apache-2.0",
"dependencies": {
"discord-api-types": "^0.38.33"
},
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/discordjs/discord.js?sponsor"
}
},
"node_modules/@discordjs/ws": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/@discordjs/ws/-/ws-1.2.3.tgz",
"integrity": "sha512-wPlQDxEmlDg5IxhJPuxXr3Vy9AjYq5xCvFWGJyD7w7Np8ZGu+Mc+97LCoEc/+AYCo2IDpKioiH0/c/mj5ZR9Uw==",
"license": "Apache-2.0",
"dependencies": {
"@discordjs/collection": "^2.1.0",
"@discordjs/rest": "^2.5.1",
"@discordjs/util": "^1.1.0",
"@sapphire/async-queue": "^1.5.2",
"@types/ws": "^8.5.10",
"@vladfrangu/async_event_emitter": "^2.2.4",
"discord-api-types": "^0.38.1",
"tslib": "^2.6.2",
"ws": "^8.17.0"
},
"engines": {
"node": ">=16.11.0"
},
"funding": {
"url": "https://github.com/discordjs/discord.js?sponsor"
}
},
"node_modules/@discordjs/ws/node_modules/@discordjs/collection": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-2.1.1.tgz",
"integrity": "sha512-LiSusze9Tc7qF03sLCujF5iZp7K+vRNEDBZ86FT9aQAv3vxMLihUvKvpsCWiQ2DJq1tVckopKm1rxomgNUc9hg==",
"license": "Apache-2.0",
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/discordjs/discord.js?sponsor"
}
},
"node_modules/@sapphire/async-queue": {
"version": "1.5.5",
"resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.5.5.tgz",
"integrity": "sha512-cvGzxbba6sav2zZkH8GPf2oGk9yYoD5qrNWdu9fRehifgnFZJMV+nuy2nON2roRO4yQQ+v7MK/Pktl/HgfsUXg==",
"license": "MIT",
"engines": {
"node": ">=v14.0.0",
"npm": ">=7.0.0"
}
},
"node_modules/@sapphire/shapeshift": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/@sapphire/shapeshift/-/shapeshift-4.0.0.tgz",
"integrity": "sha512-d9dUmWVA7MMiKobL3VpLF8P2aeanRTu6ypG2OIaEv/ZHH/SUQ2iHOVyi5wAPjQ+HmnMuL0whK9ez8I/raWbtIg==",
"license": "MIT",
"dependencies": {
"fast-deep-equal": "^3.1.3",
"lodash": "^4.17.21"
},
"engines": {
"node": ">=v16"
}
},
"node_modules/@sapphire/snowflake": {
"version": "3.5.5",
"resolved": "https://registry.npmjs.org/@sapphire/snowflake/-/snowflake-3.5.5.tgz",
"integrity": "sha512-xzvBr1Q1c4lCe7i6sRnrofxeO1QTP/LKQ6A6qy0iB4x5yfiSfARMEQEghojzTNALDTcv8En04qYNIco9/K9eZQ==",
"license": "MIT",
"engines": {
"node": ">=v14.0.0",
"npm": ">=7.0.0"
}
},
"node_modules/@types/node": {
"version": "26.6.5",
"resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.5.tgz",
"integrity": "sha512-uMzsv9stDdofIZBx4UGh4Z9ZgXnGC9seRDscilBcTHAeOFk67MZg/k9bWVfO+bk4qZmG+l52hRnLwUiH2LnJTg==",
"license": "MIT",
"dependencies": {
"undici-types": "~8.9.0"
}
},
"node_modules/@types/ws": {
"version": "8.18.2",
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.18.2.tgz",
"integrity": "sha512-67MQl+fpWKVTT1NYdnmo3U4sc/xPo/zQBncVnI74qmQa0z/b+1g6iYqNmGCPbxO+zz2aklb08a0oHfegiVd0/w==",
"license": "MIT",
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@vladfrangu/async_event_emitter": {
"version": "2.4.7",
"resolved": "https://registry.npmjs.org/@vladfrangu/async_event_emitter/-/async_event_emitter-2.4.7.tgz",
"integrity": "sha512-Xfe6rpCTxSxfbswi/W/Pz7zp1WWSNn4A0eW4mLkQUewCrXXtMj31lCg+iQyTkh/CkusZSq9eDflu7tjEDXUY6g==",
"license": "MIT",
"engines": {
"node": ">=v14.0.0",
"npm": ">=7.0.0"
}
},
"node_modules/discord-api-types": {
"version": "0.38.56",
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.38.56.tgz",
"integrity": "sha512-Hti4RZsGvF5C7SM8rF2MDHtIm0Hyfrlk84GpEA29nj91tvVVMvX+oQSCodu10t2ZcjFGofq8TX0YyC04B2E69Q==",
"license": "MIT"
},
"node_modules/discord.js": {
"version": "14.27.0",
"resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.27.0.tgz",
"integrity": "sha512-qHbFlFG2N7y3LjPySYsL6A1+BnX6bkTVgo842EX0CqVPk/KTMwZkojPHEXKsQUpWZNyz5BISNHK1cPpQw0+m4A==",
"license": "Apache-2.0",
"dependencies": {
"@discordjs/builders": "^1.14.1",
"@discordjs/collection": "1.5.3",
"@discordjs/formatters": "^0.6.2",
"@discordjs/rest": "^2.6.2",
"@discordjs/util": "^1.2.0",
"@discordjs/ws": "^1.2.3",
"@sapphire/snowflake": "3.5.5",
"discord-api-types": "^0.38.49",
"fast-deep-equal": "3.1.3",
"lodash.snakecase": "4.1.1",
"magic-bytes.js": "^1.13.0",
"tslib": "^2.6.3",
"undici": "^6.27.0"
},
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/discordjs/discord.js?sponsor"
}
},
"node_modules/dotenv": {
"version": "17.4.2",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.4.2.tgz",
"integrity": "sha512-nI4U3TottKAcAD9LLud4Cb7b2QztQMUEfHbvhTH09bqXTxnSie8WnjPALV/WMCrJZ6UV/qHJ6L03OqO3LcdYZw==",
"license": "BSD-2-Clause",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://dotenvx.com"
}
},
"node_modules/fast-deep-equal": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
"license": "MIT"
},
"node_modules/lodash": {
"version": "4.18.1",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.18.1.tgz",
"integrity": "sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==",
"license": "MIT"
},
"node_modules/lodash.snakecase": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/lodash.snakecase/-/lodash.snakecase-4.1.1.tgz",
"integrity": "sha512-QZ1d4xoBHYUeuouhEq3lk3Uq7ldgyFXGBhg04+oRLnIz8o9T65Eh+8YdroUwn846zchkA9yDsDl5CVVaV2nqYw==",
"license": "MIT"
},
"node_modules/magic-bytes.js": {
"version": "1.13.1",
"resolved": "https://registry.npmjs.org/magic-bytes.js/-/magic-bytes.js-1.13.1.tgz",
"integrity": "sha512-x5sn4UX2k5gCWlcfmoFwG4TPie8+dctESyqOBdhB5p6MsgWXdBKGmt9nXPObj/JI50TTL928lc5Yt1WntMn1bw==",
"license": "MIT"
},
"node_modules/ts-mixer": {
"version": "6.0.4",
"resolved": "https://registry.npmjs.org/ts-mixer/-/ts-mixer-6.0.4.tgz",
"integrity": "sha512-ufKpbmrugz5Aou4wcr5Wc1UUFWOLhq+Fm6qa6P0w0K5Qw2yhaUoiWszhCVuNQyNwrlGiscHOmqYoAox1PtvgjA==",
"license": "MIT"
},
"node_modules/tslib": {
"version": "2.8.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
"license": "0BSD"
},
"node_modules/undici": {
"version": "6.29.0",
"resolved": "https://registry.npmjs.org/undici/-/undici-6.29.0.tgz",
"integrity": "sha512-R+RODBqp6i2pPflGdq+xIOUkl+RNfGgHwoinecKu/JCuf2uO06cOKoDbI2P7Dn6KcswdKwrczbU6IYJ6K8X+wg==",
"license": "MIT",
"engines": {
"node": ">=18.17"
}
},
"node_modules/undici-types": {
"version": "8.9.0",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.9.0.tgz",
"integrity": "sha512-KTDyRTYX8sWmKXAikPHHSyc63CRPETMctyjKFupcC6OBLXT3xsN0e9aF7m+mIXutFWpUXuedtowG7iLOzp0kQg==",
"license": "MIT"
},
"node_modules/ws": {
"version": "8.22.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.22.0.tgz",
"integrity": "sha512-Ydggc987+RO0AnWtZ/7Wq9FtNvcrL1b/RO0ud9mWjUPgDrsAAwQSF51sm2hm1XofbU/4jkpGEsLFsZZxU+1DOg==",
"license": "MIT",
"engines": {
"node": ">=10.0.0"
},
"peerDependencies": {
"bufferutil": "^4.0.1",
"utf-8-validate": ">=5.0.2"
},
"peerDependenciesMeta": {
"bufferutil": {
"optional": true
},
"utf-8-validate": {
"optional": true
}
}
}
}
}

View File

@@ -1,6 +1,9 @@
# ---------- Build Stage ---------- # ---------- Build Stage ----------
FROM node:20-alpine AS builder FROM node:20-alpine AS builder
# pnpm is served by corepack and pinned by "packageManager" in the root package.json
RUN corepack enable
ARG NUXT_PUBLIC_GIT_COMMIT ARG NUXT_PUBLIC_GIT_COMMIT
ARG NUXT_PUBLIC_GIT_TAG ARG NUXT_PUBLIC_GIT_TAG
ARG NUXT_PUBLIC_GIT_BRANCH ARG NUXT_PUBLIC_GIT_BRANCH
@@ -11,18 +14,21 @@ ENV NUXT_PUBLIC_GIT_BRANCH=$NUXT_PUBLIC_GIT_BRANCH
WORKDIR /app WORKDIR /app
# Copy package files # Copy the workspace manifests (pnpm needs every package.json of the workspace)
COPY package*.json ./ COPY pnpm-workspace.yaml pnpm-lock.yaml package.json ./
COPY backend/package.json ./backend/
COPY frontend/package.json ./frontend/
COPY discord-bot/package.json ./discord-bot/
# Install dependencies # Install the dependencies of the frontend package
RUN npm install RUN pnpm install --frozen-lockfile --filter ./frontend...
# Copy project files # Copy project files
ARG CACHEBUST=1 ARG CACHEBUST=1
COPY . . COPY frontend ./frontend
# Build the Nuxt app # Build the Nuxt app
RUN npm run build RUN pnpm --filter ./frontend run build
# ---------- Production Stage ---------- # ---------- Production Stage ----------
FROM node:20-alpine FROM node:20-alpine
@@ -30,7 +36,7 @@ FROM node:20-alpine
WORKDIR /app WORKDIR /app
# Copy built output # Copy built output
COPY --from=builder /app/.output ./.output COPY --from=builder /app/frontend/.output ./.output
# Expose Nuxt port # Expose Nuxt port
EXPOSE 3000 EXPOSE 3000

View File

@@ -89,9 +89,11 @@ onMounted(() => {
.steps { .steps {
margin-left: 8px; margin-left: 8px;
height: 22px; height: 22px;
> {
font-size: 12px;
} }
/* No nested `> {}` here: the scoped style transform turns it into a dangling
combinator, which the current CSS minifier rejects. */
.steps > * {
font-size: 12px;
} }
.steps :deep(.roll-val){ .steps :deep(.roll-val){
display: inline-flex; display: inline-flex;

12707
frontend/package-lock.json generated

File diff suppressed because it is too large Load Diff

326
package-lock.json generated
View File

@@ -1,326 +0,0 @@
{
"name": "dragonroll",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"devDependencies": {
"concurrently": "^9.2.1"
}
},
"node_modules/ansi-regex": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dev": true,
"license": "MIT",
"dependencies": {
"color-convert": "^2.0.1"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/chalk": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
"dev": true,
"license": "MIT",
"dependencies": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/chalk/chalk?sponsor=1"
}
},
"node_modules/chalk/node_modules/supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dev": true,
"license": "MIT",
"dependencies": {
"has-flag": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/cliui": {
"version": "8.0.1",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz",
"integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==",
"dev": true,
"license": "ISC",
"dependencies": {
"string-width": "^4.2.0",
"strip-ansi": "^6.0.1",
"wrap-ansi": "^7.0.0"
},
"engines": {
"node": ">=12"
}
},
"node_modules/color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"color-name": "~1.1.4"
},
"engines": {
"node": ">=7.0.0"
}
},
"node_modules/color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true,
"license": "MIT"
},
"node_modules/concurrently": {
"version": "9.2.1",
"resolved": "https://registry.npmjs.org/concurrently/-/concurrently-9.2.1.tgz",
"integrity": "sha512-fsfrO0MxV64Znoy8/l1vVIjjHa29SZyyqPgQBwhiDcaW8wJc2W3XWVOGx4M3oJBnv/zdUZIIp1gDeS98GzP8Ng==",
"dev": true,
"license": "MIT",
"dependencies": {
"chalk": "4.1.2",
"rxjs": "7.8.2",
"shell-quote": "1.8.3",
"supports-color": "8.1.1",
"tree-kill": "1.2.2",
"yargs": "17.7.2"
},
"bin": {
"conc": "dist/bin/concurrently.js",
"concurrently": "dist/bin/concurrently.js"
},
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/open-cli-tools/concurrently?sponsor=1"
}
},
"node_modules/emoji-regex": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
"dev": true,
"license": "MIT"
},
"node_modules/escalade": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz",
"integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/get-caller-file": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
"integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
"dev": true,
"license": "ISC",
"engines": {
"node": "6.* || 8.* || >= 10.*"
}
},
"node_modules/has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/is-fullwidth-code-point": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
"integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/require-directory": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
"integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/rxjs": {
"version": "7.8.2",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.2.tgz",
"integrity": "sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"tslib": "^2.1.0"
}
},
"node_modules/shell-quote": {
"version": "1.8.3",
"resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.3.tgz",
"integrity": "sha512-ObmnIF4hXNg1BqhnHmgbDETF8dLPCggZWBjkQfhZpbszZnYur5DUljTcCHii5LC3J5E0yeO/1LIMyH+UvHQgyw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/string-width": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
"dev": true,
"license": "MIT",
"dependencies": {
"emoji-regex": "^8.0.0",
"is-fullwidth-code-point": "^3.0.0",
"strip-ansi": "^6.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/strip-ansi": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
"dev": true,
"license": "MIT",
"dependencies": {
"ansi-regex": "^5.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/supports-color": {
"version": "8.1.1",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz",
"integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==",
"dev": true,
"license": "MIT",
"dependencies": {
"has-flag": "^4.0.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/chalk/supports-color?sponsor=1"
}
},
"node_modules/tree-kill": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz",
"integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==",
"dev": true,
"license": "MIT",
"bin": {
"tree-kill": "cli.js"
}
},
"node_modules/tslib": {
"version": "2.8.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
"dev": true,
"license": "0BSD"
},
"node_modules/wrap-ansi": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
"integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==",
"dev": true,
"license": "MIT",
"dependencies": {
"ansi-styles": "^4.0.0",
"string-width": "^4.1.0",
"strip-ansi": "^6.0.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/chalk/wrap-ansi?sponsor=1"
}
},
"node_modules/y18n": {
"version": "5.0.8",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
"integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==",
"dev": true,
"license": "ISC",
"engines": {
"node": ">=10"
}
},
"node_modules/yargs": {
"version": "17.7.2",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz",
"integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==",
"dev": true,
"license": "MIT",
"dependencies": {
"cliui": "^8.0.1",
"escalade": "^3.1.1",
"get-caller-file": "^2.0.5",
"require-directory": "^2.1.1",
"string-width": "^4.2.3",
"y18n": "^5.0.5",
"yargs-parser": "^21.1.1"
},
"engines": {
"node": ">=12"
}
},
"node_modules/yargs-parser": {
"version": "21.1.1",
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz",
"integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==",
"dev": true,
"license": "ISC",
"engines": {
"node": ">=12"
}
}
}
}

View File

@@ -1,9 +1,15 @@
{ {
"name": "dragonroll-workspace",
"private": true,
"packageManager": "pnpm@10.28.2",
"devDependencies": { "devDependencies": {
"concurrently": "^9.2.1" "concurrently": "^9.2.1"
}, },
"scripts": { "scripts": {
"dev": "concurrently -k -n BACKEND,FRONTEND,DISCORD-BOT,FOUNDRY -c blue,green,yellow,magenta \"DEBUG=* npm --prefix backend run dev\" \"npm --prefix frontend run dev\" \"npm --prefix discord-bot start\" \"node scripts/run-foundry.js\"", "dev": "concurrently -k -n BACKEND,FRONTEND,DISCORD-BOT,FOUNDRY -c blue,green,yellow,magenta \"DEBUG=* pnpm --filter ./backend run dev\" \"pnpm --filter ./frontend run dev\" \"pnpm --filter ./discord-bot run start\" \"node scripts/run-foundry.js\"",
"dev:backend": "DEBUG=* pnpm --filter ./backend run dev",
"dev:frontend": "pnpm --filter ./frontend run dev",
"dev:discord-bot": "pnpm --filter ./discord-bot run start",
"test": "node --test tests/" "test": "node --test tests/"
} }
} }

9814
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

10
pnpm-workspace.yaml Normal file
View File

@@ -0,0 +1,10 @@
packages:
- backend
- frontend
- discord-bot
# pnpm blocks install scripts of dependencies by default; these two place their
# native binaries through theirs and have to be allowed to run them.
onlyBuiltDependencies:
- '@parcel/watcher'
- esbuild

View File

@@ -1,5 +1,5 @@
// Runs the Foundry Virtual Tabletop start script defined by FOUNDRY_START_SCRIPT // Runs the Foundry Virtual Tabletop start script defined by FOUNDRY_START_SCRIPT
// in the root .env file. Used by `npm run dev` via concurrently. // in the root .env file. Used by `pnpm dev` via concurrently.
const { spawn } = require('node:child_process'); const { spawn } = require('node:child_process');
const fs = require('node:fs'); const fs = require('node:fs');
const path = require('node:path'); const path = require('node:path');

View File

@@ -0,0 +1,122 @@
// Tests for Syndria98/dragonroll#29: the monorepo is a pnpm workspace, so running or installing it
// goes through pnpm (`pnpm install`, `pnpm dev`, `pnpm test`) and the images are built with the
// workspace manifests instead of one npm lockfile per package.
//
// These checks only read the manifests, the Dockerfiles and the workflows, so they need no installed
// dependencies. They fail when a package is added to the repository without joining the workspace, or
// when a build step slips back to npm and its deleted `package-lock.json`.
//
// Run with `pnpm test` from the repository root, or `node --test tests/`.
const { test } = require("node:test");
const assert = require("node:assert/strict");
const fs = require("node:fs");
const path = require("node:path");
const root = path.join(__dirname, "..");
const read = (...parts) => fs.readFileSync(path.join(root, ...parts), "utf8");
const workspace = read("pnpm-workspace.yaml");
const rootManifest = JSON.parse(read("package.json"));
// `dragonroll-foundry/bridge` is deliberately left out: it depends on nothing but Node built-ins, it
// is not part of `pnpm dev`, and its README runs it with `npm start --prefix foundry/bridge`.
const apps = ["backend", "frontend", "discord-bot"];
function packageJsonOf(pkg) {
return JSON.parse(read(pkg, "package.json"));
}
// The items of a top-level `key:` list of pnpm-workspace.yaml, quotes dropped.
function yamlList(key) {
const block = new RegExp(`${key}\\n((?:\\s+-.*\\n?)+)`).exec(workspace)?.[1] ?? "";
return [...block.matchAll(/^\s+-\s+'?([^'\s]+)'?\s*$/gm)].map((match) => match[1]);
}
test("every app package of the monorepo belongs to the pnpm workspace", () => {
const listed = yamlList("packages:");
for (const pkg of apps) {
assert.ok(listed.includes(pkg), `${pkg} must be listed in pnpm-workspace.yaml`);
assert.ok(fs.existsSync(path.join(root, pkg, "package.json")), `${pkg} must have a package.json`);
}
});
test("the workspace root is private and pins one pnpm version for corepack", () => {
assert.equal(rootManifest.private, true, "the workspace root must not be publishable");
assert.match(rootManifest.packageManager, /^pnpm@\d+\.\d+\.\d+$/, "packageManager must pin pnpm");
});
test("npm lockfiles stay gone and pnpm-lock.yaml is the only lockfile", () => {
const lockfiles = ["", ...apps].flatMap((pkg) => [
path.join(root, pkg, "package-lock.json"),
path.join(root, pkg, "yarn.lock"),
]);
const present = lockfiles.filter((lockfile) => fs.existsSync(lockfile));
assert.deepEqual(present, [], `only pnpm-lock.yaml may exist, found ${present.join(", ")}`);
assert.ok(fs.existsSync(path.join(root, "pnpm-lock.yaml")), "pnpm-lock.yaml must be committed");
});
test("`pnpm dev` runs the whole monorepo through the workspace instead of npm --prefix", () => {
const dev = rootManifest.scripts.dev;
assert.match(dev, /^concurrently -k/, "the dev script keeps running every app together");
assert.ok(!/\bnpm\b/.test(dev), "the dev script must not call npm");
for (const pkg of apps) {
assert.ok(
dev.includes(`pnpm --filter ./${pkg}`),
`the dev script must run ${pkg} through the workspace: ${dev}`
);
}
// The Foundry launcher is not a package, so concurrently keeps driving it.
assert.match(dev, /node scripts\/run-foundry\.js/);
});
test("every app package can be started on its own", () => {
// `pnpm dev:<package>`; building stays `pnpm --filter ./frontend run build`.
for (const pkg of apps) {
const script = rootManifest.scripts[`dev:${pkg}`];
assert.ok(script, `the root needs a dev:${pkg} script`);
assert.match(script, new RegExp(`pnpm --filter ./${pkg} run \\w+`));
const packageScript = packageJsonOf(pkg).scripts[/run (\w+)$/.exec(script)[1]];
assert.ok(packageScript, `${pkg} must define the script dev:${pkg} runs`);
}
});
test("the Dockerfiles install with pnpm from the workspace root", () => {
for (const pkg of apps) {
const dockerfile = read(pkg, "Dockerfile");
assert.match(dockerfile, /corepack enable/, `${pkg}: pnpm must come from corepack`);
assert.match(
dockerfile,
/COPY pnpm-workspace\.yaml pnpm-lock\.yaml package.json/,
`${pkg}: the workspace manifests must be copied before installing`
);
assert.match(
dockerfile,
new RegExp(`pnpm install --frozen-lockfile[^\\n]*--filter \\./${pkg}`),
`${pkg}: dependencies must be installed from the lockfile, filtered to this package`
);
assert.ok(!/\bnpm (ci|install)\b/.test(dockerfile), `${pkg}: must not fall back to npm install`);
}
// The images are built from the repository root, so the manifests are in the context.
const deploy = read(".gitea", "workflows", "deploy.yml");
for (const pkg of apps) {
assert.ok(
deploy.includes(`-f ./${pkg}/Dockerfile .`),
`${pkg} must be built with the repository root as build context`
);
}
});
test("the test workflow runs the suite through pnpm", () => {
assert.match(read(".gitea", "workflows", "test.yml"), /corepack pnpm test/);
});
test("the workspace allows the dependencies that build native binaries to run their scripts", () => {
// pnpm skips install scripts of dependencies by default; the frontend build needs these two to
// place their native binary.
const allowed = yamlList("onlyBuiltDependencies:");
for (const dependency of ["esbuild", "@parcel/watcher"]) {
assert.ok(allowed.includes(dependency), `${dependency} must be listed in onlyBuiltDependencies`);
}
});