Skip to content

Commit 0d56649

Browse files
authored
chore: prepare update scripts for Corepack global install (#1425)
1 parent e97537d commit 0d56649

7 files changed

+52
-36
lines changed

Diff for: docs/MAINTENANCE.md

+5-7
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@ _The previous [examples/v9](https://github.com/cypress-io/github-action/tree/v5/
2222

2323
- [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`.
2424

25-
- [pnpm](https://pnpm.io/) installed through:
26-
27-
```bash
28-
npm install pnpm@latest -g
29-
```
30-
3125
- [Visual Studio Code](https://code.visualstudio.com/) or other editor
3226

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

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

49+
### Updating pnpm examples
50+
51+
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.
52+
5553
### Updating Yarn examples
5654

57-
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.
55+
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.

Diff for: scripts/check-package-manager-corepack.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
# This script checks that the prerequisite
3+
# Corepack is installed
4+
5+
if ! command -v corepack &> /dev/null
6+
then
7+
echo **Corepack not installed**
8+
echo execute the following command:
9+
echo npm install corepack@latest -g
10+
echo if npm install fails then reinstall Node.js and try again
11+
echo
12+
exit 1 # failure
13+
else
14+
echo corepack version $(corepack --version) is installed
15+
fi

Diff for: scripts/check-package-manager-npm.sh

+4-5
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44

55
if ! command -v npm &> /dev/null
66
then
7-
echo "**npm is required and not installed**"
8-
echo "install Node.js LTS from:"
9-
echo "https://nodejs.org/en/"
10-
echo "or install and use nvm"
7+
echo **npm is required and not installed**
8+
echo install Node.js LTS from:
9+
echo https://nodejs.org/en/download
1110
echo
1211
exit 1 # failure
1312
else
14-
echo "npm is installed"
13+
echo npm version $(npm --version) is installed
1514
fi

Diff for: scripts/check-package-manager-pnpm.sh

-14
This file was deleted.

Diff for: scripts/update-cypress-latest-pnpm.sh

+14-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,22 @@ set -e # fail on error
44
# Examples using the pnpm package manager are
55
# updated to Cypress latest version
66
#
7+
# npm must be installed before running this script.
8+
./scripts/check-package-manager-npm.sh
9+
710
# Make sure that pnpm is installed
8-
./scripts/check-package-manager-pnpm.sh
11+
if command -v corepack &> /dev/null
12+
then
13+
echo disabling Corepack for pnpm
14+
corepack disable pnpm
15+
else
16+
echo Corepack is not needed and not installed
17+
fi
18+
echo install latest pnpm version
19+
npm add pnpm@latest -g
20+
echo pnpm version $(pnpm --version) is installed
921

22+
echo
1023
echo updating pnpm examples to Cypress latest version
1124
cd examples
1225

Diff for: scripts/update-cypress-latest-yarn.sh

+12-6
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ set -e # fail on error
33
#
44
if ! command -v corepack &> /dev/null
55
then
6-
echo "**corepack is required and not installed**"
7-
echo "Refer to Yarn Modern installation instructions"
8-
echo "https://yarnpkg.com/getting-started/install"
9-
echo "https://yarnpkg.com/corepack"
6+
echo **corepack is required and not installed**
7+
echo Refer to Yarn Modern installation instructions
8+
echo https://yarnpkg.com/getting-started/install
9+
echo https://yarnpkg.com/corepack
1010
echo
1111
exit 1 # failure
1212
else
13-
echo "corepack is installed"
13+
echo corepack version $(corepack --version) is installed
1414
fi
1515
#
1616
# Examples using the yarn package manager are
@@ -26,6 +26,7 @@ cd examples
2626
# No corepack
2727
corepack disable yarn
2828
npm install yarn@latest -g
29+
echo yarn version $(yarn --version) is installed
2930

3031
# examples/start-and-yarn-workspaces (yarn)
3132
echo
@@ -64,6 +65,7 @@ echo
6465
echo updating examples/yarn-modern to cypress@latest
6566
cd yarn-modern
6667
yarn set version latest
68+
echo yarn version $(yarn --version) is installed
6769
yarn add cypress --dev --exact
6870
cd ..
6971

@@ -72,12 +74,16 @@ echo
7274
echo updating examples/yarn-modern-pnp to cypress@latest
7375
cd yarn-modern-pnp
7476
yarn set version latest
77+
echo yarn version $(yarn --version) is installed
7578
yarn add cypress --dev --exact
7679
cd ..
7780

81+
echo
7882
corepack disable yarn
79-
echo "corepack is now disabled for Yarn"
83+
echo corepack is now disabled for Yarn
8084
npm install yarn@latest -g
85+
echo yarn version $(yarn --version) is installed
86+
echo
8187
# End of Yarn 4 Modern section
8288
# --------------------------------------------------
8389

Diff for: scripts/update-cypress-latest.sh

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ set -e # fail on error
44
# All examples are updated to Cypress latest version
55
#
66
# Make sure that Node.js LTS from https://nodejs.org/en/ is installed before running.
7-
# Ensure pnpm is installed.
8-
# npm install pnpm -g
7+
98
# The VScode editor is also used in the last step if available.
109
#
1110
# First check if the required package managers are installed
1211
./scripts/check-package-manager-npm.sh
13-
./scripts/check-package-manager-pnpm.sh
12+
./scripts/check-package-manager-corepack.sh
1413
# then proceed to updating the examples
1514
echo
1615
./scripts/update-cypress-latest-npm.sh

0 commit comments

Comments
 (0)