Files
snippets/yarn2.sh

24 lines
824 B
Bash
Executable File

#!/usr/bin/env sh
dir=$(pwd)
# shellcheck disable=SC2129
printf "\n" >> "$dir/.gitignore"
printf "\n###Yarn 2" >> "$dir/.gitignore"
printf "\n.yarn/*" >> "$dir/.gitignore"
printf "\n!.yarn/releases" >> "$dir/.gitignore"
printf "\n!.yarn/plugins" >> "$dir/.gitignore"
# Upgrade Yarn to Berry (latest Yarn 2 version known to Yarn 1)
yarn set version berry
# Upgrade Yarn Berry to latest version now that Yarn knows where to download it from
yarn set version latest
# (optional) Set nodeLinker to node-modules - this 100% guarantees backwards compatibility
yarn config set nodeLinker node-modules
# (optional) Adds `yarn upgrade-interactive` command back
yarn plugin import interactive-tools
# Reinstalls project using Yarn 2. This will also update your yarn.lock file, but will NOT sneakily upgrade the dependencies
yarn