Skip to content

Commit

Permalink
Replace npm with pnpm
Browse files Browse the repository at this point in the history
  • Loading branch information
menghif committed Dec 7, 2021
1 parent 15a2d61 commit ab699ab
Show file tree
Hide file tree
Showing 27 changed files with 16,705 additions and 152 deletions.
52 changes: 27 additions & 25 deletions .github/workflows/node-js-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,33 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: pnpm/action-setup@v2.0.1
with:
version: 6.23.5
- uses: actions/setup-node@v2.4.1
with:
cache: 'pnpm'
- name: Install dependencies and run prettier-check
run: |
npm install
npm run prettier-check
pnpm install
pnpm prettier-check
# Make sure eslint passes
eslint:
name: ESLint Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: pnpm/action-setup@v2.0.1
with:
version: 6.23.5
- uses: actions/setup-node@v2.4.1
with:
cache: 'pnpm'
- name: Install dependencies and run eslint
run: |
npm install
npm run eslint
pnpm install
pnpm eslint
# Run unit tests on all platforms/versions of node
unit:
Expand All @@ -43,25 +53,19 @@ jobs:
node-version: [14.x, 16.x]
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2.1.6
env:
cache-name: cache-node-modules
- uses: pnpm/action-setup@v2.0.1
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
version: 6.23.5
- uses: actions/setup-node@v2.4.1
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v1
- name: Install dependencies and run tests with default env
run: |
npm install
pnpm install
# pnpm can't handle passing args through to run scripts: https://github.com/pnpm/pnpm/issues/2764
npm run jest --max-workers ${{ steps.cpu-cores.outputs.count }}
# Run end-to-end tests along with the microservices in docker-compose on Linux
Expand All @@ -72,19 +76,17 @@ jobs:
matrix:
node-version: [14.x, 16.x]
steps:
- uses: actions/cache@v2.1.6
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- uses: actions/checkout@v2
- uses: pnpm/action-setup@v2.0.1
with:
version: 6.23.5
- uses: actions/setup-node@v2.4.1
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- uses: microsoft/playwright-github-action@v1
- name: Start microservices and run tests
- name: Start microservices and run e2e tests
run: |
npm install
npm run services:start
npm run jest:e2e
pnpm install
pnpm services:start
pnpm jest:e2e
53 changes: 28 additions & 25 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,33 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: pnpm/action-setup@v2.0.1
with:
version: 6.23.2
- uses: actions/setup-node@v2.4.1
with:
cache: 'pnpm'
- name: Install dependencies and run prettier-check
run: |
npm install
npm run prettier-check
pnpm install
pnpm prettier-check
# Make sure eslint passes
eslint:
name: ESLint Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: pnpm/action-setup@v2.0.1
with:
version: 6.23.2
- uses: actions/setup-node@v2.4.1
with:
cache: 'pnpm'
- name: Install dependencies and run eslint
run: |
npm install
npm run eslint
pnpm install
pnpm eslint
# Run unit tests on all platforms/versions of node
unit:
Expand All @@ -43,25 +53,19 @@ jobs:
node-version: [14.x, 16.x]
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2.1.6
env:
cache-name: cache-node-modules
- uses: pnpm/action-setup@v2.0.1
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
version: 6.23.2
- uses: actions/setup-node@v2.4.1
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v1
- name: Install dependencies and run tests with default env
run: |
npm install
pnpm install
# pnpm can't handle passing args through to run scripts: https://github.com/pnpm/pnpm/issues/2764
npm run jest --max-workers ${{ steps.cpu-cores.outputs.count }}
# Run end-to-end tests along with the microservices in docker-compose on Linux
Expand All @@ -72,22 +76,21 @@ jobs:
matrix:
node-version: [14.x, 16.x]
steps:
- uses: actions/cache@v2.1.6
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- uses: actions/checkout@v2
- uses: pnpm/action-setup@v2.0.1
with:
version: 6.23.2
- uses: actions/setup-node@v2.4.1
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- uses: microsoft/playwright-github-action@v1
- name: Start microservices and run tests
- name: Start microservices and run e2e tests
run: |
npm install
npm run services:start
npm run jest:e2e
pnpm install
pnpm services:start
pnpm jest:e2e
release:
needs: [prettier, eslint, unit, e2e]
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ certs/

# Redis data storage
redis-data/

.pnpm-debug.log
4 changes: 4 additions & 0 deletions .gitpod.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM gitpod/workspace-full

# Install pnpm
RUN npm install -g pnpm
12 changes: 7 additions & 5 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Learn more about this file at https://www.gitpod.io/docs/references/gitpod-yml
image:
file: .gitpod.Dockerfile
tasks:
- name: Service Server
openMode: split-left
Expand All @@ -16,11 +18,11 @@ tasks:
-e "s@development\.yml@gitpod\.yml@" \
config/env.development > .env
init: |
npm install
pnpm install
docker-compose --env-file .env build $SERVICES
command: |
docker-compose --env-file .env up -d $SERVICES
npm run start
pnpm start
- name: Frontend Server
openMode: split-right
Expand All @@ -29,14 +31,14 @@ tasks:
eval $(gp env -e)
# Start the dev server after all services are running
# Instead of rebuilding the nginx-base frontend when environment variables change
# We build the frontend directly through 'npm run dev' to use the latest urls
# We build the frontend directly through 'pnpm dev' to use the latest urls
command: |
gp await-port 3000 && npm run dev
gp await-port 3000 && pnpm dev
- name: Terminal
openMode: tab-after
command: |
echo -e "\n\n\033[94m ======================================================" && echo -e "\n\033[33m💪 Services are built and run automatically in the first terminal, the second one is free" && echo -e "\033[33m💡 If you are only developing on the frontend:" && echo -e "\033[33m 1. Switch to the first terminal and terminate the prebuilds: \e[91mCTRL/CMD + c" && echo -e "\033[33m 2. Install dependencies: $ \033[92mnpm run install:next" && echo -e "\033[33m 3. Copy staging env: $ \033[92mcp config/env.staging > .env" && echo -e "\033[33m 4. Start the dev server: $ \033[92mnpm run dev" && echo -e "\033[33m💡 If you need to test the backend:" && echo -e "\033[33m 1. Go grab a coffee and wait, the build is only done once for each commit" && echo -e "\n\033[94m ======================================================\n\n"
echo -e "\n\n\033[94m ======================================================" && echo -e "\n\033[33m💪 Services are built and run automatically in the first terminal, the second one is free" && echo -e "\033[33m💡 If you are only developing on the frontend:" && echo -e "\033[33m 1. Switch to the first terminal and terminate the prebuilds: \e[91mCTRL/CMD + c" && echo -e "\033[33m 2. Install dependencies: $ \033[92mpnpm install" && echo -e "\033[33m 3. Copy staging env: $ \033[92mcp config/env.staging > .env" && echo -e "\033[33m 4. Start the dev server: $ \033[92mpnpm dev" && echo -e "\033[33m💡 If you need to test the backend:" && echo -e "\033[33m 1. Go grab a coffee and wait, the build is only done once for each commit" && echo -e "\n\033[94m ======================================================\n\n"
# Exposing service ports
# Overriding the default notification popup when a port is open
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run pre-commit
pnpm pre-commit
6 changes: 0 additions & 6 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
# Don't create or read package-lock.json
package-lock=false
# Use exact versions of dependencies vs. semver minor updates
save-exact=true

# Allow running postinstall script in Docker
unsafe-perm=true

# Set empty tag version prefix
tag-version-prefix=""

#Set legacy peer dependencies to 'true', (needed for npm7.x compatibility for now)
legacy-peer-deps=true
4 changes: 2 additions & 2 deletions config/env.development
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ API_URL=http://localhost:3000
# To run:
#
# 1. set PROXY_FRONTEND=1 in the .env
# 2. run the web server: `npm start`
# 3. run the Next dev server: `npm run develop`
# 2. run the web server: `pnpm start`
# 3. run the Next dev server: `pnpm develop`
# 4. open http://localhost:3000/ and you'll get content from http://localhost:8000
PROXY_FRONTEND=

Expand Down
Loading

0 comments on commit ab699ab

Please sign in to comment.