diff --git a/docs/MAINTENANCE.md b/docs/MAINTENANCE.md index 61c190780..3943a17d4 100644 --- a/docs/MAINTENANCE.md +++ b/docs/MAINTENANCE.md @@ -6,7 +6,7 @@ This document describes updating the [examples](../examples) in this repository The [examples](../examples) directory contains examples of the use of Cypress (Current) [Configuration](https://docs.cypress.io/guides/references/configuration) which applies to Cypress 10 and later. These examples test and demonstrate the use of [cypress-io/github-action](https://github.com/cypress-io/github-action). -The examples make use of [npm](https://www.npmjs.com/), [pnpm](https://pnpm.io/), [Yarn 1 (Classic)](https://classic.yarnpkg.com/) and [Yarn Modern](https://yarnpkg.com/) (Yarn 2 and later) to define and install the packages being used. +The examples make use of [npm](https://www.npmjs.com/), [pnpm](https://pnpm.io/), [Yarn 1 (Classic)](https://classic.yarnpkg.com/) and [Yarn Modern](https://yarnpkg.com/) to define and install the packages being used. For [Yarn Modern](https://yarnpkg.com/) the recommended [Corepack](https://yarnpkg.com/corepack) is used as a Yarn version manager. *The previous [examples/v9](https://github.com/cypress-io/github-action/tree/v5/examples/v9) are archived in the [v5](https://github.com/cypress-io/github-action/tree/v5/) branch. This directory contains examples which were set up to use Cypress `9.7.0`, the last version using Legacy Configuration, covering Cypress 9 and below. These `v9` examples are no longer maintained. @@ -18,7 +18,9 @@ The examples make use of [npm](https://www.npmjs.com/), [pnpm](https://pnpm.io/) - [git](https://git-scm.com/) distributed version control system. -- [npm](https://www.npmjs.com/), which is installed with [Node.js](https://nodejs.org/) +- [npm](https://www.npmjs.com/), which is installed with [Node.js](https://nodejs.org/). + +- [corepack](https://github.com/nodejs/corepack), which is installed with [Node.js](https://nodejs.org/). - [pnpm](https://pnpm.io/) installed through: @@ -26,12 +28,6 @@ The examples make use of [npm](https://www.npmjs.com/), [pnpm](https://pnpm.io/) npm install pnpm@latest -g ``` -- [Yarn 1 (Classic)](https://classic.yarnpkg.com/) installed through: - -```bash -npm install yarn@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: @@ -55,3 +51,7 @@ This updates all [examples](../examples) to cypress@latest. [.github/workflows/example-install-only.yml](../.github/workflows/example-install-only.yml) contains a hard-coded Cypress version number. This can be updated by hand. After updating the examples locally, they can be committed with git and a pull request opened on GitHub. + +### 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. diff --git a/scripts/check-package-manager-yarn.sh b/scripts/check-package-manager-yarn.sh deleted file mode 100755 index 1661c579b..000000000 --- a/scripts/check-package-manager-yarn.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -# This script checks that the prerequisite -# yarn is installed - -if ! command -v yarn &> /dev/null -then - echo "**yarn not installed**" - echo "execute the following command:" - echo "npm install yarn -g" - echo -exit 1 # failure -else - echo "yarn is installed" -fi diff --git a/scripts/update-cypress-latest-yarn.sh b/scripts/update-cypress-latest-yarn.sh index a4494bcb9..0814d9e55 100755 --- a/scripts/update-cypress-latest-yarn.sh +++ b/scripts/update-cypress-latest-yarn.sh @@ -1,14 +1,31 @@ #!/bin/bash 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 +exit 1 # failure +else + echo "corepack is installed" +fi +# # Examples using the yarn package manager are # updated to Cypress latest version # -# Make sure that yarn is installed -./scripts/check-package-manager-yarn.sh - +# After running this script, Yarn 1 Classic latest is installed +# corepack is disabled +# echo updating yarn examples to Cypress latest version cd examples +# -------------------------------------------------- +# Yarn 1 Classic section +# No corepack +corepack disable yarn +npm install yarn@latest -g # examples/start-and-yarn-workspaces (yarn) echo @@ -37,6 +54,11 @@ cd yarn-classic yarn add cypress --dev --exact cd .. +# -------------------------------------------------- +# Yarn 4 Modern section +# Use corepack +corepack enable yarn + # examples/yarn-modern echo echo updating examples/yarn-modern to cypress@latest @@ -53,4 +75,10 @@ yarn set version latest yarn add cypress --dev --exact cd .. +corepack disable yarn +echo "corepack is now disabled for Yarn" +npm install yarn@latest -g +# End of Yarn 4 Modern section +# -------------------------------------------------- + cd .. diff --git a/scripts/update-cypress-latest.sh b/scripts/update-cypress-latest.sh index c291c0689..2618d7be1 100755 --- a/scripts/update-cypress-latest.sh +++ b/scripts/update-cypress-latest.sh @@ -4,14 +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 yarn v1 (classic) and pnpm are installed. -# npm install yarn -g +# 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-yarn.sh ./scripts/check-package-manager-pnpm.sh # then proceed to updating the examples echo