Skip to content

Commit

Permalink
feat: migrate to pnpm for better workspace DX (freeCodeCamp#49293)
Browse files Browse the repository at this point in the history
* feat: npm -> pnpm 

This resolves the issues with the gatsby client (gatsby-plugin-pnpm
deals with the fact that gatsby is relying on its own dependencies
being de-duped)
and challenge-editor (which doesn't seem to want to automatically install
codemirror and needed its own eslint config)

* fix: correct mocha path for curriculum tests

* fix: use select workspace with -F not -w

* fix: reorganise packages and restrict hoisting

pnpm works best if the workspaces keep their own dependencies, since
dependencies are not flattened and then what node resolves from a
require is predictable.

@types seem to be a special case and more care is required to prevent
them getting smushed together in the root (hence the .npmrc)

* fix: add types for tools + root

* fix: decouple challenge-auditor from client

* fix: add ui-components types

* fix(client): use the latest types for react 16

* fix: prettify

* fix: prettierignore pnpm-lock

* fix: relax hoisting

Turns out pnpm works just fine with types. I don't know what was going
wrong before, but there are no-longer any type conflicts.

* fix: add @redux-saga/core to fix eslint issue

It seems to only be redux-saga that import/named can't cope with, so it
is probably okay to work around this one.

* chore: add chai to tools/scripts/build

* fix: add store to root for cypress

* fix: allow cypress to download binaries

If we want to keep preventing cypress from downloading binaries, we can
figure out a workaround, but I'm allowing it to ease the transition to
pnpm.

My guess about why this is happening is that npm triggers Cypress's
postinstall script, but pnpm does not (because pnpm install only
installs if necessary, perferring to link)

* chore: re-enable pre/post scripts

* fix: update build scripts for client

Co-authored-by: Shaun Hamilton <[email protected]>

* chore: update engines to use pnpm


* fix: enable choice of (super)block for tests

Only 'nix machines for now.

* chore: pin pnpm to version 7

* chore: remove last npms

Except web + curriculum-server. I'll update them when I start work on
them again.

* fix: lockfile check to catch any package-locks

* fix(action): install pnpm for upcoming tests

* chore: add nodemon to new api

Co-authored-by: Shaun Hamilton <[email protected]>
  • Loading branch information
ojeytonwilliams and ShaunSHamilton authored Mar 2, 2023
1 parent 66438c2 commit d7848ae
Show file tree
Hide file tree
Showing 81 changed files with 30,413 additions and 55,330 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": [
"./client/tsconfig.json",
"./tsconfig.json",
"./api/tsconfig.json",
"./config/tsconfig.json",
Expand Down
16 changes: 10 additions & 6 deletions .github/workflows/crowdin-download.curriculum.yml
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@ jobs:

# Validate the Download #
# All languages should go ABOVE this. #
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 7

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
Expand All @@ -290,15 +294,15 @@ jobs:
- name: Build Source Files
run: |
echo npm version $(npm -v)
npm ci
npm run create:config
npm run build:curriculum
npm run build:server
echo pnpm version $(pnpm -v)
pnpm install
pnpm run create:config
pnpm run build:curriculum
pnpm run build:server
- name: Lint and Format Files
run: |
npm run format:curriculum
pnpm run format:curriculum
# We do not need to run tests because they are run after the PR is created.

Expand Down
11 changes: 8 additions & 3 deletions .github/workflows/e2e-mobile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ jobs:
repository: freeCodeCamp/mobile
path: mobile

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 7

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with:
Expand All @@ -50,9 +55,9 @@ jobs:

- name: Install and Build
run: |
npm ci
npm run create:config
npm run build:curriculum
pnpm install
pnpm run create:config
pnpm run build:curriculum
- name: Generate mobile test files
run: |
Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/e2e-third-party.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ jobs:
repository: freeCodeCamp/client-config
path: client-config

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 7

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with:
Expand All @@ -52,18 +57,18 @@ jobs:
- name: Install and Build
run: |
npm ci
npm run build
pnpm install
pnpm run build
- name: Seed Database
run: npm run seed
run: pnpm run seed
- name: Move serve.json to Public Folder
run: cp client-config/serve.json client/public/serve.json

- name: Cypress run
uses: cypress-io/github-action@v4
with:
record: ${{ env.CYPRESS_RECORD_KEY != 0 }}
start: npm run start-ci
start: pnpm run start-ci
wait-on: http://localhost:8000
wait-on-timeout: 1200
config: baseUrl=http://localhost:8000
Expand Down
26 changes: 18 additions & 8 deletions .github/workflows/e2e-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ jobs:
repository: freeCodeCamp/client-config
path: client-config

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 7

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with:
Expand All @@ -40,8 +45,8 @@ jobs:

- name: Install and Build
run: |
npm ci
npm run build
pnpm install
pnpm run build
- name: Move serve.json to Public Folder
run: cp client-config/serve.json client/public/serve.json
Expand Down Expand Up @@ -115,6 +120,11 @@ jobs:
sudo mv /usr/bin/firefox /usr/bin/firefox_old
sudo ln -s /opt/firefox/firefox /usr/bin/firefox
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 7

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with:
Expand All @@ -125,19 +135,19 @@ jobs:

- name: Install and Build
run: |
npm ci
npm run create:config
npm run build:curriculum
npm run build:server
pnpm install
pnpm run create:config
pnpm run build:curriculum
pnpm run build:server
- name: Seed Database
run: npm run seed
run: pnpm run seed

- name: Cypress run
uses: cypress-io/github-action@v4
with:
record: ${{ env.CYPRESS_RECORD_KEY != 0 }}
start: npm run start-ci
start: pnpm run start-ci
wait-on: http://localhost:8000
wait-on-timeout: 1200
config: baseUrl=http://localhost:8000
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/i18n-validate-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,20 @@ jobs:
steps:
- name: Checkout Source Files
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 7
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Set freeCodeCamp Environment Variables
run: cp sample.env .env

- name: Install Dependencies
run: npm ci
run: pnpm install

- name: Validate Challenge Files
run: npm run audit-challenges
run: pnpm run audit-challenges
10 changes: 6 additions & 4 deletions .github/workflows/i18n-validate-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,24 @@ jobs:
steps:
- name: Checkout Source Files
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 7
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Set freeCodeCamp Environment Variables
run: cp sample.env .env

- name: Install Dependencies
run: npm ci
run: pnpm install

- name: Validate Challenge Files
id: validate
run: npm run audit-challenges
run: pnpm run audit-challenges

- name: Create Comment
# Run if the validate challenge files step fails, specifically. Note that we need the failure() call for this step to trigger if the action fails.
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/node.js-find-unused.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ jobs:
steps:
- name: Checkout Source Files
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 7
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with:
Expand All @@ -35,6 +38,6 @@ jobs:
- name: Run Checks
run: |
echo npm version $(npm -v)
npm ci
npm run knip
echo pnpm version $(pnpm -v)
pnpm install
pnpm run knip
26 changes: 16 additions & 10 deletions .github/workflows/node.js-tests-upcoming.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ jobs:
steps:
- name: Checkout Source Files
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 7
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with:
Expand All @@ -48,12 +51,12 @@ jobs:
- name: Lint Source Files
run: |
npm ci
npm run create:config
pnpm install
pnpm run create:config
npm i --prefix=curriculum-server
npm i --prefix=web
npm run build:curriculum
npm run lint
pnpm run build:curriculum
pnpm run lint
test:
name: Test
Expand All @@ -68,7 +71,10 @@ jobs:
steps:
- name: Checkout Source Files
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 7
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with:
Expand All @@ -83,9 +89,9 @@ jobs:
- name: Install Dependencies
run: |
npm ci
npm run create:config
npm run build:curriculum
pnpm install
pnpm run create:config
pnpm run build:curriculum
- name: Run Tests
run: npm test
run: pnpm test
Loading

0 comments on commit d7848ae

Please sign in to comment.