yarn.plugin.zsh 3.0 KB

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