Skip to content

Feat: Adding option to specify the package manager version that you want #486

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
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
18 changes: 18 additions & 0 deletions .circleci/test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ workflows:
cypress-cache-key: cypress-cache{{ arch }}-{{ checksum "examples/yarn-install/package.json" }}
post-install: "npx cypress install"
package-manager: "yarn"
- cypress/run:
filters: *filters
name: Yarn Version Example
working-directory: examples/yarn-install
cypress-cache-key: cypress-cache{{ arch }}-{{ checksum "examples/yarn-install/package.json" }}
post-install: "./check-yarn-version.sh 1.22.5"
package-manager: "yarn"
package-manager-version: "1.22.5"
- cypress/run:
filters: *filters
name: Pnpm Example
Expand All @@ -91,6 +99,14 @@ workflows:
cypress-cache-key: cypress-cache{{ arch }}-{{ checksum "examples/pnpm-install/package.json" }}
post-install: "pnpm cypress install"
package-manager: "pnpm"
- cypress/run:
filters: *filters
name: Pnpm Version Example
working-directory: examples/pnpm-install
cypress-cache-key: cypress-cache{{ arch }}-{{ checksum "examples/pnpm-install/package.json" }}
post-install: "./check-pnpm-version.sh 9.7.1"
package-manager: "pnpm"
package-manager-version: "9.7.1"
- cypress/run:
filters: *filters
name: Custom Install Example
Expand Down Expand Up @@ -167,7 +183,9 @@ workflows:
- Standard Npm Example
- Custom Node Version Example
- Yarn Example
- Yarn Version Example
- Pnpm Example
- Pnpm Version Example
- Custom Install Example
- Wait On Example
- Angular Application
Expand Down
14 changes: 14 additions & 0 deletions examples/pnpm-install/check-pnpm-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

# Check if a version parameter is provided
if [ -z "$1" ]; then
echo "Usage: $0 <version>"
exit 1
fi

VERSION=$1

if ! pnpm --version | grep -q "$VERSION"; then
echo "pnpm version $VERSION not found"
exit 1
fi
14 changes: 14 additions & 0 deletions examples/yarn-install/check-yarn-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

# Check if a version parameter is provided
if [ -z "$1" ]; then
echo "Usage: $0 <version>"
exit 1
fi

VERSION=$1

if ! yarn --version | grep -q "$VERSION"; then
echo "yarn version $VERSION not found"
exit 1
fi
19 changes: 19 additions & 0 deletions src/commands/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ parameters:
type: boolean
default: false
description: Allow skipping the `checkout` command
package-manager-version:
type: string
default: ""
description: |
If you need to specify a version of the package manager, you can do so here.
This is useful if you need to use a specific version of Yarn or PNPM.
If you are using Yarn Berry, you can specify the version here.
If you are using NPM, this parameter will be ignored.

steps:
- unless:
Expand All @@ -65,13 +73,24 @@ steps:
- restore_cache:
name: Restore Cypress cache
key: << parameters.cypress-cache-key >>
- when:
condition:
and:
- not:
equal: [ '', << parameters.package-manager-version >> ]
- equal: [ 'yarn', << parameters.package-manager >> ]
steps:
- node/install:
install-yarn: true
yarn-version: << parameters.package-manager-version >>
- when:
condition:
and:
- equal: [ 'pnpm', << parameters.package-manager >> ]
steps:
- node/install:
install-pnpm: true
pnpm-version: << parameters.package-manager-version >>
- node/install-packages:
override-ci-command: << parameters.install-command >>
app-dir: << parameters.working-directory >>
Expand Down
15 changes: 15 additions & 0 deletions src/examples/pnpm-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
description: >
Runs Cypress tests using pnpm.
Installs dependencies and caches NPM modules and the Cypress binary.
usage:
version: 2.1
orbs:
cypress: cypress-io/cypress@3
workflows:
use-my-orb:
jobs:
- cypress/run:
package-manager: "pnpm"
package-manager-version: "9.7.1"
start-command: "pnpm start"
install-command: "pnpm install"
2 changes: 1 addition & 1 deletion src/examples/pnpm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ usage:
- cypress/run:
package-manager: "pnpm"
start-command: "pnpm start"
install-command: "pnpm install --frozen-lockfile"
install-command: "pnpm install"
14 changes: 14 additions & 0 deletions src/examples/yarn-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
description: >
Runs Cypress tests using yarn.
Installs dependencies and caches NPM modules and the Cypress binary.
usage:
version: 2.1
orbs:
cypress: cypress-io/cypress@3
workflows:
use-my-orb:
jobs:
- cypress/run:
package-manager: "yarn"
package-manager-version: "1.22.5"
start-command: "yarn start"
9 changes: 9 additions & 0 deletions src/jobs/run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ parameters:
enum: ["npm", "yarn", "yarn-berry", "pnpm"]
default: "npm"
description: Select the default node package manager to use. NPM v5+ Required.
package-manager-version:
type: string
default: ""
description: |
If you need to specify a version of the package manager, you can do so here.
This is useful if you need to use a specific version of Yarn or PNPM.
If you are using Yarn Berry, you can specify the version here.
If you are using NPM, this parameter will be ignored.
start-command:
description: Command used to start your local dev server for Cypress to tests against
type: string
Expand Down Expand Up @@ -87,6 +95,7 @@ steps:
node-cache-version: << parameters.node-cache-version >>
working-directory: << parameters.working-directory >>
package-manager: << parameters.package-manager >>
package-manager-version: << parameters.package-manager-version >>
include-branch-in-node-cache-key: << parameters.include-branch-in-node-cache-key >>
install-browsers: << parameters.install-browsers >>
skip-checkout: << parameters.skip-checkout >>
Expand Down