Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Update pnpm and use corepack (#4628)
Olga Bulat9bdc32649f04
diff --git a/.github/actions/setup-env/action.yml b/.github/actions/setup-env/action.ymlindex ee8034623..bdd74252f 100644--- a/.github/actions/setup-env/action.yml+++ b/.github/actions/setup-env/action.yml@@ -41,11 +41,10 @@ runs:pip install -U pippip install pipenv pdm- # Node.js- name: Setup pnpmif: 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.jsif: inputs.setup_nodejs == 'true'diff --git a/frontend/Dockerfile b/frontend/Dockerfileindex 5516ff018..592e2ef15 100644--- a/frontend/Dockerfile+++ b/frontend/Dockerfile@@ -9,12 +9,9 @@ ARG FRONTEND_NODE_VERSIONFROM 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 macOSRUN apk add --no-cache --virtual .gyp python3 make g++ \- && npm install -g pnpm@${FRONTEND_PNPM_VERSION}+ && corepack enable pnpmUSER nodediff --git a/frontend/Dockerfile.playwright b/frontend/Dockerfile.playwrightindex 4142abf83..2ec05a033 100644--- a/frontend/Dockerfile.playwright+++ b/frontend/Dockerfile.playwright@@ -4,9 +4,10 @@ ARG PLAYWRIGHT_VERSIONFROM 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 pnpmdiff --git a/frontend/bin/playwright.sh b/frontend/bin/playwright.shindex c47f75ecf..8a69edda3 100755--- a/frontend/bin/playwright.sh+++ b/frontend/bin/playwright.sh@@ -1,16 +1,10 @@#! /usr/bin/env shset -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_MANAGERexport USER_ID="${USER_ID:-$(id -u)}"export PLAYWRIGHT_ARGS="$*"PLAYWRIGHT_VERSION=$(version)@@ -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-orphansdiff --git a/frontend/docker-compose.playwright.yml b/frontend/docker-compose.playwright.ymlindex e26780e12..7de7814a1 100644--- a/frontend/docker-compose.playwright.yml+++ b/frontend/docker-compose.playwright.yml@@ -4,7 +4,6 @@ services:context: .dockerfile: Dockerfile.playwrightargs:- - PACKAGE_MANAGER=${PACKAGE_MANAGER}- PLAYWRIGHT_VERSION=${PLAYWRIGHT_VERSION}volumes:- ../node_modules:/node_modulesdiff --git a/frontend/package.json b/frontend/package.jsonindex e4af94264..bae1ab02d 100644--- a/frontend/package.json+++ b/frontend/package.json@@ -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'",diff --git a/package.json b/package.jsonindex 9e2c5bff3..0a5be2e66 100644--- a/package.json+++ b/package.json@@ -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": "[email protected]",+ "packageManager": "[email protected]","engines": {"node": ">= 20.0.0 <21"},