yarn.plugin.zsh 2.9 KB

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