Skip to content

Commit

Permalink
feat: upgrade to yarn v3
Browse files Browse the repository at this point in the history
Upgrades to `yarn` v3. Changes the installation method from `npm` to
`corepack`, which is the recommended way to install yarn[^1].

Migrates `devbase` to use v3 of `yarn`, a follow up PR to stencil-base
will change the `package.json` and `.gitignore`.

[^1]: https://yarnpkg.com/getting-started/install
  • Loading branch information
jaredallard committed Sep 21, 2023
1 parent 5dd66a2 commit e1f36d9
Show file tree
Hide file tree
Showing 8 changed files with 5,231 additions and 3,980 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,5 @@ Pulumi.*.yaml
## <<Stencil::Block(extras)>>
orb.*
.version
.yarn
## <</Stencil::Block>>
3 changes: 3 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-3.6.3.cjs
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
"prettier": "^2.8.8",
"semantic-release": "^21.0.5",
"semver": "^7.5.2"
}
},
"packageManager": "[email protected]"
}
1 change: 0 additions & 1 deletion shell/ci/env/asdf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ init_asdf() {
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.12.0

# langauage specifics
echo -e "yarn" >"$HOME/.default-npm-packages"
echo -e "bundler 2.2.17" >"$HOME/.default-gems"
cat >"$HOME/.default-golang-pkgs" <<EOF
github.com/golang/protobuf/protoc-gen-go@v$(get_tool_version protoc-gen-go)
Expand Down
2 changes: 1 addition & 1 deletion shell/ci/release/dryrun.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ GH_TOKEN="$GH_TOKEN" yarn --frozen-lockfile semantic-release --dry-run

# Handle unstable releasing for CLIs, pre-conditions for this exist
# in the script.
"$DIR/unstable-release.sh" --dry-run
exec "$DIR/unstable-release.sh" --dry-run
12 changes: 5 additions & 7 deletions shell/languages/nodejs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)/../lib/she
yarn_install_if_needed() {
local stateFile="node_modules/devbase.lock"

if ! yarn -v >/dev/null 2>&1; then
npm install -g yarn
fi

if [[ ! -e "node_modules" ]]; then
yarn_install "$stateFile"
return
if ! command -v yarn >/dev/null; then
corepack enable
if command -v asdf >/dev/null; then
asdf reshim
fi
fi

if [[ ! -e $stateFile ]]; then
Expand Down
8 changes: 8 additions & 0 deletions shell/lib/asdf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ asdf_devbase_ensure() {
# Install the language, retrying w/ AMD64 emulation if on macOS or just retrying on failure once.
asdf install "$plugin" "$version" || asdf_install_retry "$plugin" "$version"
fi

if [[ $plugin == "nodejs" ]]; then
# Ensure that yarn is installed.
if ! command -v yarn >/dev/null; then
corepack enable
need_reshim=1
fi
fi
done

if [ "$need_reshim" == 1 ]; then
Expand Down
Loading

0 comments on commit e1f36d9

Please sign in to comment.