Yarn (https://yarnpkg.com) completion support (#5542)
* yarn completion
Diff
1diff --git a/plugins/yarn/yarn.plugin.zsh b/plugins/yarn/yarn.plugin.zsh
2new file mode 100644
3index 0000000000000000000000000000000000000000..47c503acb0551ef632fcc97bb871654f02bed8b0
4--- /dev/null
5+++ b/plugins/yarn/yarn.plugin.zsh
6@@ -0,0 +1,81 @@
7+alias yi="yarn install"
8+
9+_yarn ()
10+{
11+ local -a _1st_arguments _dopts _dev _production
12+ local expl
13+ typeset -A opt_args
14+
15+ _dopts=(
16+ '(--force)--force[This refetches all packages, even ones that were previously installed.]'
17+ )
18+
19+ _installopts=(
20+ '(--flat)--flat[Only allow one version of a package. On the first run this will prompt you to choose a single version for each package that is depended on at multiple version ranges.]'
21+ '(--har)--har[Outputs an HTTP archive from all the network requests performed during the installation.]'
22+ '(--no-lockfile)--no-lockfile[Don’t read or generate a yarn.lock lockfile.]'
23+ '(--pure-lockfile)--pure-lockfile[Don’t generate a yarn.lock lockfile.]'
24+ )
25+
26+ _dev=('(--dev)--dev[Save installed packages into the project"s package.json devDependencies]')
27+
28+ _production=('(--production)--production[Do not install project devDependencies]')
29+
30+ _1st_arguments=(
31+ 'help:Display help information about yarn' \
32+ 'init:Initialize for the development of a package.' \
33+ 'add:Add a package to use in your current package.' \
34+ 'install:Install all the dependencies listed within package.json in the local node_modules folder.' \
35+ 'publish:Publish a package to a package manager.' \
36+ 'remove:Remove a package that will no longer be used in your current package.' \
37+ 'cache:Clear the local cache. It will be populated again the next time yarn or yarn install is run.' \
38+ 'clean:Frees up space by removing unnecessary files and folders from dependencies.' \
39+ 'check:Verifies that versions of the package dependencies in the current project’s package.json matches that of yarn’s lock file.' \
40+ 'ls:List all installed packages.' \
41+ 'global:Makes binaries available to use on your operating system.' \
42+ 'info:<package> [<field>] - fetch information about a package and return it in a tree format.' \
43+ 'outdated:Checks for outdated package dependencies.' \
44+ 'run:Runs a defined package script.' \
45+ 'self-update:Updates Yarn to the latest version.' \
46+ 'upgrade:Upgrades packages to their latest version based on the specified range.' \
47+ 'why:<query> - Show information about why a package is installed.'
48+ )
49+ _arguments \
50+ '*:: :->subcmds' && return 0
51+
52+ if (( CURRENT == 1 )); then
53+ _describe -t commands "yarn subcommand" _1st_arguments
54+ return
55+ fi
56+
57+ case "$words[1]" in
58+ add)
59+ _arguments \
60+ $_dopts \
61+ $_dev \
62+ $_production
63+ ;;
64+ install)
65+ _arguments \
66+ $_installopts \
67+ $_dopts \
68+ $_dev \
69+ $_no_color \
70+ $_production
71+ ;;
72+ update)
73+ _arguments \
74+ $_dopts
75+ ;;
76+ remove)
77+ _arguments \
78+ $_dopts
79+ ;;
80+ *)
81+ _arguments \
82+ ;;
83+ esac
84+
85+}
86+
87+compdef _yarn yarn