189774c5d0d989ab45c0765f646803926e08e013
- Author
- Jeroen Claassens <jeroen.claassens@live.nl>
- Committer
- GitHub <noreply@github.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/plugins/yarn/README.md b/plugins/yarn/README.md
2index 5c7c7f3238ccb21862225cac03a2cb42cac2456f..f1d089b1fd638b45156597559df647fa427872a7 100644
3--- a/plugins/yarn/README.md
4+++ b/plugins/yarn/README.md
5@@ -1,7 +1,7 @@
6 # Yarn plugin
7
8-This plugin adds completion for the [Yarn package manager](https://yarnpkg.com/en/),
9-as well as some aliases for common Yarn commands.
10+This plugin adds completion for the [Yarn package manager](https://yarnpkg.com/en/), as well as some aliases
11+for common Yarn commands.
12
13 To use it, add `yarn` to the plugins array in your zshrc file:
14
15@@ -11,48 +11,64 @@ plugins=(... yarn)
16
17 ## Global scripts directory
18
19-It also adds `yarn` global scripts dir (commonly `~/.yarn/bin`) to the `$PATH`.
20-To disable this feature, set the following style in your `.zshrc`:
21+It also adds `yarn` global scripts dir (commonly `~/.yarn/bin`) to the `$PATH`. To disable this feature, set
22+the following style in your `.zshrc`:
23
24 ```zsh
25 zstyle ':omz:plugins:yarn' global-path no
26 ```
27
28+## Yarn Berry
29+
30+If you are using Yarn berry (a.k.a. Yarn version 2 or higher) as your global Yarn version you should configure
31+this plugin to configure its aliases accordingly, set the following style in your `.zshrc`:
32+
33+```zsh
34+zstyle ':omz:plugins:yarn' berry yes
35+```
36+
37 ## Aliases
38
39-| Alias | Command | Description |
40-| ----- | ----------------------------------------- | ----------------------------------------------------------------------------- |
41-| y | `yarn` | The Yarn command |
42-| ya | `yarn add` | Install a package in dependencies (`package.json`) |
43-| yad | `yarn add --dev` | Install a package in devDependencies (`package.json`) |
44-| yap | `yarn add --peer` | Install a package in peerDependencies (`package.json`) |
45-| yb | `yarn build` | Run the build script defined in `package.json` |
46-| ycc | `yarn cache clean` | Clean yarn's global cache of packages |
47-| yd | `yarn dev` | Run the dev script defined in `package.json` |
48-| yf | `yarn format` | Run the dev script defined in `package.json` |
49-| yga | `yarn global add` | Install packages globally on your operating system |
50-| ygls | `yarn global list` | Lists global installed packages |
51-| ygrm | `yarn global remove` | Remove global installed packages from your OS |
52-| ygu | `yarn global upgrade` | Upgrade packages installed globally to their latest version |
53-| yh | `yarn help` | Show help for a yarn command |
54-| yi | `yarn init` | Interactively creates or updates a package.json file |
55-| yin | `yarn install` | Install dependencies defined in `package.json` |
56-| yln | `yarn lint` | Run the lint script defined in `package.json` |
57-| ylnf | `yarn lint --fix` | Run the lint script defined in `package.json`to automatically fix problems |
58-| yls | `yarn list` | List installed packages |
59-| yout | `yarn outdated` | Check for outdated package dependencies |
60-| yp | `yarn pack` | Create a compressed gzip archive of package dependencies |
61-| yrm | `yarn remove` | Remove installed packages |
62-| yrun | `yarn run` | Run a defined package script |
63-| ys | `yarn serve` | Start the dev server |
64-| yst | `yarn start` | Run the start script defined in `package.json` |
65-| yt | `yarn test` | Run the test script defined in `package.json` |
66-| ytc | `yarn test --coverage` | Run the test script defined in `package.json` with coverage |
67-| yuc | `yarn global upgrade && yarn cache clean` | Upgrade global packages and clean yarn's global cache |
68-| yui | `yarn upgrade-interactive` | Prompt for which outdated packages to upgrade |
69-| yuil | `yarn upgrade-interactive --latest` | Prompt for which outdated packages to upgrade to the latest available version |
70-| yup | `yarn upgrade` | Upgrade packages to their latest version |
71-| yv | `yarn version` | Update the version of your package |
72-| yw | `yarn workspace` | Run a command within a single workspace. |
73-| yws | `yarn workspaces` | Run a command within all defined workspaces. |
74-| yy | `yarn why` | Show why a package has been installed, detailing which other packages depend on it |
75+- Aliases marked with <sup>`*`</sup> are only available when using Yarn v1 (non-berry)
76+- Aliases marked with <sup>`b`</sup> are only available when using Yarn berry
77+
78+| Alias | Command | Description |
79+| ------------------ | ----------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
80+| y | `yarn` | The Yarn command |
81+| ya | `yarn add` | Install a package in dependencies (`package.json`) |
82+| yad | `yarn add --dev` | Install a package in devDependencies (`package.json`) |
83+| yap | `yarn add --peer` | Install a package in peerDependencies (`package.json`) |
84+| yb | `yarn build` | Run the build script defined in `package.json` |
85+| ycc | `yarn cache clean` | Clean yarn's global cache of packages |
86+| yd | `yarn dev` | Run the dev script defined in `package.json` |
87+| yf | `yarn format` | Run the dev script defined in `package.json` |
88+| yh | `yarn help` | Show help for a yarn command |
89+| yi | `yarn init` | Interactively creates or updates a package.json file |
90+| yin | `yarn install` | Install dependencies defined in `package.json` |
91+| yln | `yarn lint` | Run the lint script defined in `package.json` |
92+| ylnf | `yarn lint --fix` | Run the lint script defined in `package.json`to automatically fix problems |
93+| yp | `yarn pack` | Create a compressed gzip archive of package dependencies |
94+| yrm | `yarn remove` | Remove installed packages |
95+| yrun | `yarn run` | Run a defined package script |
96+| ys | `yarn serve` | Start the dev server |
97+| yst | `yarn start` | Run the start script defined in `package.json` |
98+| yt | `yarn test` | Run the test script defined in `package.json` |
99+| ytc | `yarn test --coverage` | Run the test script defined in `package.json` with coverage |
100+| yui | `yarn upgrade-interactive` | Prompt for which outdated packages to upgrade |
101+| yuil | `yarn upgrade-interactive --latest` (or see `yui` when using [yarn berry](#yarn-berry)) | Prompt for which outdated packages to upgrade to the latest available version |
102+| yii | `yarn install --frozen-lockfile` (or `yarn install --immutable` when using [yarn berry](#yarn-berry)) | Install dependencies and abort if the lockfile was to be modified |
103+| yifl | `yii` | Install dependencies and abort if the lockfile was to be modified |
104+| yup | `yarn upgrade` | Upgrade packages to their latest version |
105diff --git a/plugins/yarn/yarn.plugin.zsh b/plugins/yarn/yarn.plugin.zsh
106index 157044d7138a5a51f08a8aff6cc8ffeed262ede0..b7d64770d5ab21bf7673df01c6c00ef3465661bc 100644
107--- a/plugins/yarn/yarn.plugin.zsh
108+++ b/plugins/yarn/yarn.plugin.zsh
109@@ -18,17 +18,11 @@ alias yb="yarn build"
110 alias ycc="yarn cache clean"
111 alias yd="yarn dev"
112 alias yf="yarn format"
113-alias yga="yarn global add"
114-alias ygls="yarn global list"
115-alias ygrm="yarn global remove"
116-alias ygu="yarn global upgrade"
117 alias yh="yarn help"
118 alias yi="yarn init"
119 alias yin="yarn install"
120 alias yln="yarn lint"
121 alias ylnf="yarn lint --fix"
122-alias yls="yarn list"
123-alias yout="yarn outdated"
124 alias yp="yarn pack"
125 alias yrm="yarn remove"
126 alias yrun="yarn run"
127@@ -36,11 +30,37 @@ alias ys="yarn serve"
128 alias yst="yarn start"
129 alias yt="yarn test"
130 alias ytc="yarn test --coverage"
131-alias yuc="yarn global upgrade && yarn cache clean"
132 alias yui="yarn upgrade-interactive"
133-alias yuil="yarn upgrade-interactive --latest"
134 alias yup="yarn upgrade"
135 alias yv="yarn version"
136 alias yw="yarn workspace"
137 alias yws="yarn workspaces"
138 alias yy="yarn why"
139+
140+# Commands that are specific to the yarn version being used
141+if zstyle -t ':omz:plugins:yarn' berry; then
142+ # aliases that differ
143+ alias yuil='yui' # --latest flag was removed in yarn berry
144+ alias yii='yarn install --immutable'
145+ alias yifl='yarn install --immutable'
146+
147+ # unique aliases
148+ alias ydlx="yarn dlx"
149+ alias yn="yarn node"
150+else
151+ # aliases that differ
152+ alias yuil='yarn upgrade-interactive --latest'
153+ alias yii='yarn install --frozen-lockfile'
154+ alias yifl='yarn install --frozen-lockfile'
155+
156+ # unique aliases
157+ alias yga="yarn global add"
158+ alias ygls="yarn global list"
159+ alias ygrm="yarn global remove"
160+ alias ygu="yarn global upgrade"
161+ alias yls="yarn list"
162+ alias yout="yarn outdated"
163+ alias yuca="yarn global upgrade && yarn cache clean"
164+fi
165+
166+unset is_yarn_berry