Skip to content

Commit

Permalink
Update pnpm and use corepack (#4628)
Browse files Browse the repository at this point in the history
* Update pnpm and use corepack

Signed-off-by: Olga Bulat <[email protected]>

* Remove unused PACKAGE_MANAGER arg

Signed-off-by: Olga Bulat <[email protected]>

* Remove comments

Signed-off-by: Olga Bulat <[email protected]>

---------

Signed-off-by: Olga Bulat <[email protected]>
  • Loading branch information
obulat authored Jul 19, 2024
1 parent c321633 commit 9bdc326
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 19 deletions.
5 changes: 2 additions & 3 deletions .github/actions/setup-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ runs:
pip install -U pip
pip install pipenv pdm
# Node.js
- name: Setup pnpm
if: inputs.setup_nodejs == 'true'
uses: pnpm/action-setup@v3
# Automatically reads `packageManager` field from root `package.json`.
shell: bash
run: corepack enable pnpm

- name: Setup Node.js
if: inputs.setup_nodejs == 'true'
Expand Down
5 changes: 1 addition & 4 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@ ARG FRONTEND_NODE_VERSION

FROM docker.io/node:${FRONTEND_NODE_VERSION}-alpine AS builder

# Automatically use the right version of pnpm.
ARG FRONTEND_PNPM_VERSION

# Install system packages needed to build on macOS
RUN apk add --no-cache --virtual .gyp python3 make g++ \
&& npm install -g pnpm@${FRONTEND_PNPM_VERSION}
&& corepack enable pnpm

USER node

Expand Down
7 changes: 4 additions & 3 deletions frontend/Dockerfile.playwright
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ ARG PLAYWRIGHT_VERSION

FROM mcr.microsoft.com/playwright:v${PLAYWRIGHT_VERSION}-jammy

ARG PACKAGE_MANAGER

COPY package.json /

# Ensure the Playwright container's pnpm cache folder exists and is writable
RUN mkdir -p /.cache/node/corepack/ && chmod -R 777 /.cache/node/corepack/

# Requires `packageManager` field to be present in `frontend/package.json`.
RUN npm install -g $PACKAGE_MANAGER
RUN corepack enable pnpm
8 changes: 1 addition & 7 deletions frontend/bin/playwright.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
#! /usr/bin/env sh
set -e

package_manager() {
grep packageManager ../package.json | awk '{print $2}' | sed 's/[",]//g'
}

version() {
pnpm ls --depth=0 | grep -e playwright | awk '{print $2}'
}

PACKAGE_MANAGER=$(package_manager)
export PACKAGE_MANAGER
export USER_ID="${USER_ID:-$(id -u)}"
export PLAYWRIGHT_ARGS="$*"
PLAYWRIGHT_VERSION=$(version)
Expand All @@ -19,7 +13,7 @@ export TEST_COMMAND="${TEST_COMMAND:-test:playwright:local}"

pnpm i18n:get-translations --en-only

echo Running Playwright v"$PLAYWRIGHT_VERSION" as "$USER_ID" with Playwright arguments "$PLAYWRIGHT_ARGS" under package manager "$PACKAGE_MANAGER"
echo Running Playwright v"$PLAYWRIGHT_VERSION" as "$USER_ID" with Playwright arguments "$PLAYWRIGHT_ARGS"

docker compose -f docker-compose.playwright.yml up --build --force-recreate --exit-code-from playwright --remove-orphans

Expand Down
1 change: 0 additions & 1 deletion frontend/docker-compose.playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ services:
context: .
dockerfile: Dockerfile.playwright
args:
- PACKAGE_MANAGER=${PACKAGE_MANAGER}
- PLAYWRIGHT_VERSION=${PLAYWRIGHT_VERSION}
volumes:
- ../node_modules:/node_modules
Expand Down
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"description": "Openverse frontend",
"private": true,
"version": "2.2.1",
"packageManager": "[email protected]",
"scripts": {
"predev": "pnpm install && pnpm i18n:no-get",
"dev": "run-p dev:only 'i18n:en --watch'",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"preeslint": "pnpm --filter '@openverse/eslint-plugin' run build",
"eslint": "eslint --ext .js,.ts,.vue,.json,.json5 --ignore-path .gitignore --ignore-path .eslintignore --max-warnings=0 frontend automations/js packages/js .pnpmfile.cjs .eslintrc.js prettier.config.js tsconfig.base.json"
},
"packageManager": "pnpm@9.2.0",
"packageManager": "pnpm@9.5.0",
"engines": {
"node": ">= 20.0.0 <21"
},
Expand Down

0 comments on commit 9bdc326

Please sign in to comment.