Skip to content

Commit 0d7935c

Browse files
authored
Fix: yarn berry install packages (#226)
* 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
1 parent 4ec8467 commit 0d7935c

File tree

4 files changed

+54
-5
lines changed

4 files changed

+54
-5
lines changed

.circleci/test-deploy.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,16 +176,21 @@ jobs:
176176
pkg-manager: yarn
177177
cache-version: yarn-v3
178178
app-dir: "~/project/sample"
179+
- run: yarn --version
179180
- run: cd ~/project/sample && yarn test
180181
integration-test-yarn-berry:
182+
environment:
183+
YARN_ENABLE_IMMUTABLE_INSTALLS: false
181184
executor:
182185
name: node/default
183186
steps:
184187
- checkout
188+
- run: mv ~/project/sample/package-berry.json ~/project/sample/package.json
185189
- node/install-packages:
186190
pkg-manager: yarn-berry
187-
cache-version: yarn-berry-v1
191+
cache-version: yarn-berry-v2
188192
app-dir: "~/project/sample"
193+
override-ci-command: yarn install
189194
- run: cd ~/project/sample && yarn test
190195

191196
workflows:

sample/package-berry.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "opd-server",
3+
"packageManager": "[email protected]",
4+
"version": "1.0.0",
5+
"description": "",
6+
"main": "index.js",
7+
"scripts": {
8+
"dev": "nodemon --watch 'src/**/*.ts' --exec 'ts-node --require dotenv/config' src/index.ts",
9+
"build": "tsc -h",
10+
"start": "node dist/index.js",
11+
"test": "jest jest-tests",
12+
"testmocha": "mocha mocha-tests",
13+
"test:coverage": "jest --coverage jest-tests"
14+
},
15+
"author": "",
16+
"license": "ISC",
17+
"devDependencies": {
18+
"@types/cors": "^2.8.12",
19+
"@types/dotenv": "^8.2.0",
20+
"@types/express": "^4.17.13",
21+
"@types/node": "^17.0.0",
22+
"@types/node-fetch": "^3.0.2",
23+
"jest": "^27.4.5",
24+
"jest-junit": "^13.0.0",
25+
"mocha-junit-reporter": "2.0.2",
26+
"mocha-multi": "1.1.5",
27+
"nodemon": "^2.0.20",
28+
"ts-node": "^10.4.0",
29+
"tslint": "^6.1.1",
30+
"typescript": "^4.5.4"
31+
},
32+
"dependencies": {
33+
"axios": "^0.28.0",
34+
"axios-logger": "^2.6.0",
35+
"cors": "^2.8.5",
36+
"dotenv": "^10.0.0",
37+
"express": "^4.19.2",
38+
"mocha": "^9.1.3",
39+
"node-fetch": "^3.2.10",
40+
"yaml": "^1.10.2"
41+
}
42+
}

src/commands/install-packages.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ parameters:
77
type: enum
88
enum: ['npm', 'yarn', 'yarn-berry', 'pnpm']
99
default: 'npm'
10-
description: Select the default node package manager to use. NPM v5+ Required.
10+
description: |
11+
Select the default node package manager to use. NPM v5+ Required.
12+
To use yarn-berry your package.json must have packageManager set to a yarn berry version, otherwise it will use old yarn.
1113
with-cache:
1214
type: boolean
1315
default: true

src/scripts/packages/yarn-berry-install.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
2+
corepack enable --install-directory ~/bin
33
# Run override ci command if provided, otherwise run default yarn install
44
# See: https://yarnpkg.com/configuration/yarnrc/#cacheFolder
55
if [[ -n "$PARAM_CACHE_PATH" ]]; then
@@ -33,12 +33,12 @@ else
3333
set -- "$@" --check-cache
3434
fi
3535

36-
yarn install --immutable --immutable-cache "$@"
36+
echo y | yarn install --immutable --immutable-cache "$@"
3737

3838
if [[ "$PARAM_CHECK_CACHE" == "detect" && -n "$ENABLE_CHECK_CACHE" ]]; then
3939
cp yarn.lock "$YARN_LOCKFILE_PATH"
4040
fi
4141
else
42-
yarn install --immutable
42+
echo y | yarn install --immutable
4343
fi
4444
fi

0 commit comments

Comments
 (0)