yarn.plugin.zsh 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. _upgrade=(
  25. '(--exact)--exact[Install exact version]'
  26. '(--tilde)--tilde[Install most recent release with the same minor version]'
  27. )
  28. _1st_arguments=(
  29. 'help:Display help information about yarn' \
  30. 'init:Initialize for the development of a package' \
  31. 'add:Add a package to use in your current package' \
  32. 'install:Install all the dependencies listed within package.json in the local node_modules folder' \
  33. 'publish:Publish a package to a package manager' \
  34. 'remove:Remove a package that will no longer be used in your current package' \
  35. 'cache:Clear the local cache. It will be populated again the next time yarn or yarn install is run' \
  36. 'clean:Frees up space by removing unnecessary files and folders from dependencies' \
  37. 'check:Verifies that versions of the package dependencies in the current project’s package.json matches that of yarn’s lock file' \
  38. 'ls:List all installed packages' \
  39. 'global:Makes binaries available to use on your operating system' \
  40. 'info:<package> [<field>] - fetch information about a package and return it in a tree format' \
  41. 'outdated:Checks for outdated package dependencies' \
  42. 'run:Runs a defined package script' \
  43. 'self-update:Updates Yarn to the latest version' \
  44. 'upgrade:Upgrades packages to their latest version based on the specified range' \
  45. 'upgrade-interactive:Selectively upgrades specific packages in a simple way' \
  46. 'why:<query> - Show information about why a package is installed'
  47. )
  48. _arguments \
  49. '*:: :->subcmds' && return 0
  50. if (( CURRENT == 1 )); then
  51. _describe -t commands "yarn subcommand" _1st_arguments
  52. return
  53. fi
  54. case "$words[1]" in
  55. add)
  56. _arguments \
  57. $_dopts \
  58. $_dev \
  59. $_production
  60. ;;
  61. install)
  62. _arguments \
  63. $_installopts \
  64. $_dopts \
  65. $_dev \
  66. $_no_color \
  67. $_production
  68. ;;
  69. update)
  70. _arguments \
  71. $_dopts
  72. ;;
  73. remove)
  74. _arguments \
  75. $_dopts
  76. ;;
  77. upgrade-interactive)
  78. _arguments \
  79. $_upgrade
  80. ;;
  81. *)
  82. _arguments \
  83. ;;
  84. esac
  85. }
  86. compdef _yarn yarn