Skip to content

chore: prepare update scripts for Corepack global install #1425

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions docs/MAINTENANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ _The previous [examples/v9](https://github.com/cypress-io/github-action/tree/v5/

- [corepack](https://github.com/nodejs/corepack). This is currently installed with [Node.js](https://nodejs.org/). Due to plans of Node.js to remove it in versions Node.js `25.x` and later, you may need to install it separately with `npm install -g corepack`.

- [pnpm](https://pnpm.io/) installed through:

```bash
npm install pnpm@latest -g
```

- [Visual Studio Code](https://code.visualstudio.com/) or other editor

Under Microsoft Windows it may be necessary to also execute the following preparatory command:
Expand All @@ -52,6 +46,10 @@ This updates all [examples](../examples) to cypress@latest.

After updating the examples locally, they can be committed with git and a pull request opened on GitHub.

### Updating pnpm examples

The script [/scripts/update-cypress-latest-pnpm.sh](../scripts/update-cypress-latest-pnpm.sh) (which is invoked through `npm run update:cypress` to update the pnpm examples) runs [pnpm](https://pnpm.io/) as an `npm` global install. It leaves pnpm installed and Corepack disabled for pnpm on completion.

### Updating Yarn examples

The script [/scripts/update-cypress-latest-yarn.sh](../scripts/update-cypress-latest-yarn.sh) (which is invoked through `npm run update:cypress` to update the Yarn examples) runs [Yarn 1 (Classic)](https://classic.yarnpkg.com/) as an `npm` global install, runs [Yarn Modern](https://yarnpkg.com/) through Corepack and returns Corepack to its default disabled state on completion.
The script [/scripts/update-cypress-latest-yarn.sh](../scripts/update-cypress-latest-yarn.sh) (which is invoked through `npm run update:cypress` to update the Yarn examples) runs [Yarn 1 (Classic)](https://classic.yarnpkg.com/) as an `npm` global install and runs [Yarn Modern](https://yarnpkg.com/) through Corepack. It leaves Yarn Classic installed and Corepack disabled for Yarn on completion.
15 changes: 15 additions & 0 deletions scripts/check-package-manager-corepack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
# This script checks that the prerequisite
# Corepack is installed

if ! command -v corepack &> /dev/null
then
echo **Corepack not installed**
echo execute the following command:
echo npm install corepack@latest -g
echo if npm install fails then reinstall Node.js and try again
echo
exit 1 # failure
else
echo corepack version $(corepack --version) is installed
fi
9 changes: 4 additions & 5 deletions scripts/check-package-manager-npm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@

if ! command -v npm &> /dev/null
then
echo "**npm is required and not installed**"
echo "install Node.js LTS from:"
echo "https://nodejs.org/en/"
echo "or install and use nvm"
echo **npm is required and not installed**
echo install Node.js LTS from:
echo https://nodejs.org/en/download
echo
exit 1 # failure
else
echo "npm is installed"
echo npm version $(npm --version) is installed
fi
14 changes: 0 additions & 14 deletions scripts/check-package-manager-pnpm.sh

This file was deleted.

15 changes: 14 additions & 1 deletion scripts/update-cypress-latest-pnpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,22 @@ set -e # fail on error
# Examples using the pnpm package manager are
# updated to Cypress latest version
#
# npm must be installed before running this script.
./scripts/check-package-manager-npm.sh

# Make sure that pnpm is installed
./scripts/check-package-manager-pnpm.sh
if command -v corepack &> /dev/null
then
echo disabling Corepack for pnpm
corepack disable pnpm
else
echo Corepack is not needed and not installed
fi
echo install latest pnpm version
npm add pnpm@latest -g
echo pnpm version $(pnpm --version) is installed

echo
echo updating pnpm examples to Cypress latest version
cd examples

Expand Down
18 changes: 12 additions & 6 deletions scripts/update-cypress-latest-yarn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ set -e # fail on error
#
if ! command -v corepack &> /dev/null
then
echo "**corepack is required and not installed**"
echo "Refer to Yarn Modern installation instructions"
echo "https://yarnpkg.com/getting-started/install"
echo "https://yarnpkg.com/corepack"
echo **corepack is required and not installed**
echo Refer to Yarn Modern installation instructions
echo https://yarnpkg.com/getting-started/install
echo https://yarnpkg.com/corepack
echo
exit 1 # failure
else
echo "corepack is installed"
echo corepack version $(corepack --version) is installed
fi
#
# Examples using the yarn package manager are
Expand All @@ -26,6 +26,7 @@ cd examples
# No corepack
corepack disable yarn
npm install yarn@latest -g
echo yarn version $(yarn --version) is installed

# examples/start-and-yarn-workspaces (yarn)
echo
Expand Down Expand Up @@ -64,6 +65,7 @@ echo
echo updating examples/yarn-modern to cypress@latest
cd yarn-modern
yarn set version latest
echo yarn version $(yarn --version) is installed
yarn add cypress --dev --exact
cd ..

Expand All @@ -72,12 +74,16 @@ echo
echo updating examples/yarn-modern-pnp to cypress@latest
cd yarn-modern-pnp
yarn set version latest
echo yarn version $(yarn --version) is installed
yarn add cypress --dev --exact
cd ..

echo
corepack disable yarn
echo "corepack is now disabled for Yarn"
echo corepack is now disabled for Yarn
npm install yarn@latest -g
echo yarn version $(yarn --version) is installed
echo
# End of Yarn 4 Modern section
# --------------------------------------------------

Expand Down
5 changes: 2 additions & 3 deletions scripts/update-cypress-latest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ set -e # fail on error
# All examples are updated to Cypress latest version
#
# Make sure that Node.js LTS from https://nodejs.org/en/ is installed before running.
# Ensure pnpm is installed.
# npm install pnpm -g

# The VScode editor is also used in the last step if available.
#
# First check if the required package managers are installed
./scripts/check-package-manager-npm.sh
./scripts/check-package-manager-pnpm.sh
./scripts/check-package-manager-corepack.sh
# then proceed to updating the examples
echo
./scripts/update-cypress-latest-npm.sh
Expand Down