Skip to content

chore: migrate from yarn to npm and resolve security advisories#29

Merged
DibranMulder merged 6 commits into
masterfrom
chore/migrate-yarn-to-npm
Jun 9, 2026
Merged

chore: migrate from yarn to npm and resolve security advisories#29
DibranMulder merged 6 commits into
masterfrom
chore/migrate-yarn-to-npm

Conversation

@DibranMulder

Copy link
Copy Markdown

Summary

Migrates all three packages (root, server, client) from yarn to npm and reduces security vulnerabilities by upgrading dependencies.

Vulnerability counts

Package Before (yarn) After (npm)
server 36 (18 high) 0
client 491 (40 critical) 66 (0 critical)
root 0

Dependency fixes

  • server: drop unused uuid; bump http-proxy-middleware v2→v3 (and fix the import to the named export), nodemon v2→v3; convert yarn resolutions→npm overrides and add transitive pins.
  • client: bump axios 0.21→1.x (high-severity CSRF, production-facing); override trim to fix the react-markdownremark-parse ReDoS without a risky v4→v10 rewrite; pin styled-components to v5 (the open >=4.4.1 range otherwise resolved to a breaking v6 under npm).
  • root: remove the vestigial server: file:server dependency that pulled server's dev tooling (and its advisories) into the root install.

Code changes required by the bumps

  • server/src/loaders/session.ts — narrow the cookie type for the newer @types/express-session (now a union with a function).
  • client/.../Demo5.tsx — remove the dead tap option (removed in Leaflet 1.9).
  • Regenerated client snapshots — benign churn: styled-components 5.3.11 stops emitting empty @media blocks.

Tooling conversion

  • Root scripts, husky hooks (pre-commit/pre-push), Dockerfile.prod, server/Dockerfile, client/Dockerfile, README and .dockerignore converted to npm.
  • .gitignore now tracks package-lock.json and ignores yarn.lock.
  • Added client/.npmrc (legacy-peer-deps=true).
  • Bumped the Dockerfile.prod client builder off node:14.4 (npm 6 can't read modern lockfiles/overrides).

Verification

  • server build (tsc + tscpaths) and client build (webpack prod).
  • ✅ Client tests at baseline parity (the Map/Demo5 suite crashes are pre-existing on the original yarn setup — a jest 26 / Node worker issue, not introduced here).
  • ✅ Full Dockerfile.prod Docker build end-to-end; final image contains /server/app.js, production node_modules, and the built /client.

Remaining work

The remaining 66 client advisories are all dev-only build tooling (webpack 4, webpack-dev-server 3, jest 26, stylelint 13) that don't ship in the production bundle. Clearing them requires a major build-chain migration (webpack 5 / jest 30 / stylelint 17), which is out of scope here to keep the app building and tests green.

Dibran Mulder added 2 commits June 8, 2026 20:56
Convert all three packages (root, server, client) from yarn to npm and
reduce vulnerabilities by upgrading dependencies.

Vulnerability counts:
- server: 36 -> 0
- client: 491 (incl. 40 critical) -> 66 (0 critical)
- root: -> 0

Dependency fixes:
- server: drop unused uuid; bump http-proxy-middleware v2->v3 (named
  export import), nodemon v2->v3; convert resolutions to overrides and
  add transitive pins.
- client: bump axios 0.21->1.x (CSRF); override trim to fix the
  react-markdown/remark-parse ReDoS; pin styled-components to v5 (open
  >=4.4.1 range otherwise resolved to a breaking v6).
- root: remove vestigial server file dependency that pulled server's
  dev tooling (and its advisories) into the root install.

Code changes required by the bumps:
- session.ts: narrow cookie type for newer @types/express-session.
- Demo5.tsx: remove dead tap option (removed in Leaflet 1.9).
- regenerate client snapshots (styled-components 5.3.11 drops empty
  @media blocks).

Tooling: convert root scripts, husky hooks, Dockerfiles, README and
.dockerignore to npm; track package-lock.json and ignore yarn.lock; add
client/.npmrc (legacy-peer-deps); bump Dockerfile.prod client builder
off node:14.4 so npm understands modern lockfiles and overrides.

Remaining 66 client advisories are dev-only build tooling (webpack 4,
jest 26, stylelint 13) that require a major build-chain migration.
ts-node 9 crashes against the typescript 4.9.x that npm resolves
(the resolveTypeReferenceDirective signature changed in TS 4.7),
breaking the dev server (npm start / docker-compose). ts-node 10
supports modern TypeScript. Production is unaffected (it compiles
with tsc and runs the emitted JS).
@DibranMulder DibranMulder marked this pull request as ready for review June 8, 2026 19:06
The backend's IRMA_SERVER_URL was unset in docker-compose, so config.ts
fell back to http://localhost:8080 — which inside the be container is
the container itself, not the irma service (ECONNREFUSED).

Set IRMA_SERVER_URL=http://irma:8080 on the be service for the
server-to-server API calls. The URL the Yivi app/browser scans stays on
the irma service's --url flag (defaults to localhost:8080, overridable
to a LAN IP via the shell IRMA_SERVER_URL), so the two roles no longer
collide.

@dobby-coder dobby-coder Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review

Stage 1's findings describe a different PR (yarn-to-npm migration touching Dockerfile.prod, client/.npmrc, Map.spec.tsx) — none of those files appear in this diff, which extracts styled-components into client/src/components/LocalAsc/LocalAsc.tsx. Stage 1 findings are not applicable here.

One real bug in client/src/components/Demo2/Demo2.tsx at the merge-resolved branch around the !isOver18 && isPostcodeInArea case: the first <AscLocal.RedAlert is unclosed (followed immediately by );) and the same else if branch is duplicated right below with the actual props. The first stub branch needs to be deleted — as-is the file won't compile.

Rule compliance

No rules available to check (~/dobby-memory/ not present).

Dibran Mulder and others added 3 commits June 9, 2026 09:07
v3 emits a deprecation warning and is scheduled for removal in December
2026. v4 runs on the Node.js 24 runtime.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bump anchore/scan-action to v7.4.0 and fail the build on fixable critical
vulnerabilities. Pin both scan and upload-sarif actions to commit SHAs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@DibranMulder DibranMulder merged commit d57ecc3 into master Jun 9, 2026
2 checks passed
@rubenhensen rubenhensen deleted the chore/migrate-yarn-to-npm branch June 9, 2026 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants