Skip to content

Commit

Permalink
Fix: yarn berry install packages (#226)
Browse files Browse the repository at this point in the history
* Add commands to ensure usage of yarn-berry

* add sudo to corepack enable

* add sudo to corepack enable

* Add package manager to package.json

* fix linter errors

* Add a second package for testing

* Fix package files location

* Update cache

* Remove lock

* Set immutable installation

* Use migration command

* Add yarn install in test

* Add corepack enable

* Update yarn version

* Add env manually

* Use custom command

* use a different version
  • Loading branch information
marboledacci authored Aug 30, 2024
1 parent 4ec8467 commit 0d7935c
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 5 deletions.
7 changes: 6 additions & 1 deletion .circleci/test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,16 +176,21 @@ jobs:
pkg-manager: yarn
cache-version: yarn-v3
app-dir: "~/project/sample"
- run: yarn --version
- run: cd ~/project/sample && yarn test
integration-test-yarn-berry:
environment:
YARN_ENABLE_IMMUTABLE_INSTALLS: false
executor:
name: node/default
steps:
- checkout
- run: mv ~/project/sample/package-berry.json ~/project/sample/package.json
- node/install-packages:
pkg-manager: yarn-berry
cache-version: yarn-berry-v1
cache-version: yarn-berry-v2
app-dir: "~/project/sample"
override-ci-command: yarn install
- run: cd ~/project/sample && yarn test

workflows:
Expand Down
42 changes: 42 additions & 0 deletions sample/package-berry.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "opd-server",
"packageManager": "[email protected]",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "nodemon --watch 'src/**/*.ts' --exec 'ts-node --require dotenv/config' src/index.ts",
"build": "tsc -h",
"start": "node dist/index.js",
"test": "jest jest-tests",
"testmocha": "mocha mocha-tests",
"test:coverage": "jest --coverage jest-tests"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@types/cors": "^2.8.12",
"@types/dotenv": "^8.2.0",
"@types/express": "^4.17.13",
"@types/node": "^17.0.0",
"@types/node-fetch": "^3.0.2",
"jest": "^27.4.5",
"jest-junit": "^13.0.0",
"mocha-junit-reporter": "2.0.2",
"mocha-multi": "1.1.5",
"nodemon": "^2.0.20",
"ts-node": "^10.4.0",
"tslint": "^6.1.1",
"typescript": "^4.5.4"
},
"dependencies": {
"axios": "^0.28.0",
"axios-logger": "^2.6.0",
"cors": "^2.8.5",
"dotenv": "^10.0.0",
"express": "^4.19.2",
"mocha": "^9.1.3",
"node-fetch": "^3.2.10",
"yaml": "^1.10.2"
}
}
4 changes: 3 additions & 1 deletion src/commands/install-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ parameters:
type: enum
enum: ['npm', 'yarn', 'yarn-berry', 'pnpm']
default: 'npm'
description: Select the default node package manager to use. NPM v5+ Required.
description: |
Select the default node package manager to use. NPM v5+ Required.
To use yarn-berry your package.json must have packageManager set to a yarn berry version, otherwise it will use old yarn.
with-cache:
type: boolean
default: true
Expand Down
6 changes: 3 additions & 3 deletions src/scripts/packages/yarn-berry-install.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash

corepack enable --install-directory ~/bin
# Run override ci command if provided, otherwise run default yarn install
# See: https://yarnpkg.com/configuration/yarnrc/#cacheFolder
if [[ -n "$PARAM_CACHE_PATH" ]]; then
Expand Down Expand Up @@ -33,12 +33,12 @@ else
set -- "$@" --check-cache
fi

yarn install --immutable --immutable-cache "$@"
echo y | yarn install --immutable --immutable-cache "$@"

if [[ "$PARAM_CHECK_CACHE" == "detect" && -n "$ENABLE_CHECK_CACHE" ]]; then
cp yarn.lock "$YARN_LOCKFILE_PATH"
fi
else
yarn install --immutable
echo y | yarn install --immutable
fi
fi

0 comments on commit 0d7935c

Please sign in to comment.