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

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
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.
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`).
CI (`.gitea/workflows/deploy.yml`) builds two Docker images on every push to `master`, pushes them to
`git.aranroig.com/<user>/dragonroll-{frontend,backend}:latest`, copies `docker-compose.yml` +
CI (`.gitea/workflows/deploy.yml`) builds three Docker images on every push to `master` — always from
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`.
`.gitea/workflows/test.yml` runs the `npm test` suite (frontend + Foundry module tests, no dependencies
installed) on every push to any branch, not just `master`.
`.gitea/workflows/test.yml` runs the `corepack pnpm test` suite (frontend + Foundry module tests, no
dependencies installed) on every push to any branch, not just `master`.
## 2. Root layout
@@ -30,44 +38,49 @@ installed) on every push to any branch, not just `master`.
dragonroll/
├── backend/ Express API (CommonJS, entry: src/index.js)
├── 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
├── 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
├── nginx.conf reverse proxy rules for the compose stack
├── ecosystem.config.js PM2 config (stale: runs `npm start`, which does not exist — see §9)
├── .gitea/workflows/deploy.yml
├── static/media/ README logo images only
├── 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)
```
## 3. Commands
`pnpm` comes from corepack (`packageManager` in `package.json`); `COREPACK_ENABLE_DOWNLOAD_PROMPT=0`
keeps corepack from asking in non-interactive shells.
```bash
npm install # root: installs `concurrently` only
npm install --prefix backend
npm install --prefix frontend # runs `nuxt prepare` via postinstall
pnpm install # the whole workspace, once, from the root
# (frontend's `nuxt prepare` runs as its postinstall)
npm run dev # both apps: backend (nodemon, :5000) + frontend (nuxt dev, :3000)
# also runs the Foundry VTT start script from root .env
pnpm dev # backend (nodemon, :5000) + frontend (nuxt dev, :3000)
# + discord-bot, plus the Foundry VTT start script from root .env
# (FOUNDRY_START_SCRIPT, via scripts/run-foundry.js)
npm --prefix backend run dev # backend only
npm --prefix frontend run dev # frontend only
npm --prefix frontend run build # nuxt build --dotenv .env.production
npm --prefix frontend run preview
pnpm dev:backend # one package, also `pnpm dev:frontend` / `pnpm dev:discord-bot`
pnpm --filter ./frontend run build # nuxt build --dotenv .env.production
pnpm --filter ./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);
`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
| 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.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 |