2020-04-25 07:21:05 +00:00
# Yarn 1.22.4
2020-03-01 16:22:10 +00:00
source $__fish_data_dir /functions /__fish_npm_helper.fish
2019-01-11 05:10:21 +00:00
set -l yarn_add "yarn global add"
2018-03-05 14:28:19 +00:00
2018-10-19 22:45:02 +00:00
# Typically there is no need to check if (commandline -ct) begins with `--`
# because it won't be matched. But we can prevent the slowdown from getting
# a list of all packages and filtering through it if we only do that when
# completing what seems to be a package name.
complete -f -c yarn -n '__fish_seen_subcommand_from remove; and not __fish_is_switch' -xa '(__yarn_installed_packages)'
2019-01-11 05:10:21 +00:00
complete -f -c yarn -n '__fish_seen_subcommand_from add; and not __fish_is_switch' -xa " (__yarn_filtered_list_packages \" $yarn_add \") "
2018-03-05 14:28:19 +00:00
2020-04-25 07:21:05 +00:00
complete -f -c yarn -n __fish_use_subcommand -a help -d 'Show available commands and flags'
2017-02-09 16:24:38 +00:00
2020-04-25 07:21:05 +00:00
complete -f -c yarn -n __fish_use_subcommand -a access -d 'Not implemented'
2017-02-09 16:24:38 +00:00
complete -f -c yarn -n '__fish_seen_subcommand_from access' -a 'public restricted grant revoke ls-packages ls-collaborators edit'
2020-04-25 07:21:05 +00:00
complete -f -c yarn -n __fish_use_subcommand -a add -d 'Add packages'
2017-02-09 16:24:38 +00:00
complete -f -c yarn -n '__fish_seen_subcommand_from add' -l dev -s D
complete -f -c yarn -n '__fish_seen_subcommand_from add' -l peer -s P
complete -f -c yarn -n '__fish_seen_subcommand_from add' -l O -s O
complete -f -c yarn -n '__fish_seen_subcommand_from add' -l exact -s E
complete -f -c yarn -n '__fish_seen_subcommand_from add' -l tilde -s T
2020-04-25 07:21:05 +00:00
complete -f -c yarn -n __fish_use_subcommand -a audit -d 'Perform vulnerability audit'
complete -f -c yarn -n __fish_use_subcommand -a autoclean -d 'Clean unnecessary files from dependencies'
2017-02-09 16:24:38 +00:00
2020-04-25 07:21:05 +00:00
complete -f -c yarn -n __fish_use_subcommand -a bin -d 'Show location of Yarn `bin` folder'
complete -f -c yarn -n __fish_use_subcommand -a cache -d 'Manage Yarn cache'
2017-12-15 04:09:53 +00:00
complete -f -c yarn -n '__fish_seen_subcommand_from cache' -a 'ls dir clean'
2017-02-09 16:24:38 +00:00
2020-04-25 07:21:05 +00:00
complete -f -c yarn -n __fish_use_subcommand -a check -d 'Check dependencies integrity'
2017-02-09 16:24:38 +00:00
2020-04-25 07:21:05 +00:00
complete -f -c yarn -n __fish_use_subcommand -a config -d 'Manage Yarn configuration'
2017-12-15 04:09:53 +00:00
complete -f -c yarn -n '__fish_seen_subcommand_from config' -a 'set get delete list'
2017-02-09 16:24:38 +00:00
2020-04-25 07:21:05 +00:00
complete -f -c yarn -n __fish_use_subcommand -a create -d 'Create new project'
complete -f -c yarn -n __fish_use_subcommand -a exec -d 'Run binaries'
2017-02-09 16:24:38 +00:00
2020-04-25 07:21:05 +00:00
complete -f -c yarn -n __fish_use_subcommand -a generate-lock-entry -d 'Generate lockfile entry'
2017-02-09 16:24:38 +00:00
2020-04-25 07:21:05 +00:00
complete -f -c yarn -n __fish_use_subcommand -a global -d 'Manage global packages'
complete -f -c yarn -n '__fish_seen_subcommand_from global' -a 'add bin dir ls list remove upgrade upgrade-interactive'
complete -f -c yarn -n __fish_use_subcommand -a import -d 'Generate lockfile from existing installation'
complete -f -c yarn -n __fish_use_subcommand -a info -d 'Show information about a package'
complete -f -c yarn -n __fish_use_subcommand -a init -d 'Interactively create or update `package.json`'
2017-02-09 16:24:38 +00:00
complete -f -c yarn -n '__fish_seen_subcommand_from init' -s y -l yes
2020-04-25 07:21:05 +00:00
complete -f -c yarn -n __fish_use_subcommand -a install -d 'Install packages'
2017-02-09 16:24:38 +00:00
2020-04-25 07:21:05 +00:00
complete -f -c yarn -n __fish_use_subcommand -a licenses -d 'List licenses for installed packages'
2017-02-09 16:24:38 +00:00
complete -f -c yarn -n '__fish_seen_subcommand_from licenses' -a 'ls generate-disclaimer'
2020-04-25 07:21:05 +00:00
complete -f -c yarn -n __fish_use_subcommand -a link -d 'Symlink a package'
2017-02-09 16:24:38 +00:00
2020-04-25 07:21:05 +00:00
complete -f -c yarn -n __fish_use_subcommand -a list -d 'List installed packages'
2017-12-15 04:09:53 +00:00
complete -f -c yarn -n '__fish_seen_subcommand_from list' -l depth
2017-02-09 16:24:38 +00:00
2020-04-25 07:21:05 +00:00
complete -f -c yarn -n __fish_use_subcommand -a login -d 'Store registry username and email'
complete -f -c yarn -n __fish_use_subcommand -a logout -d 'Clear registry username and email'
complete -f -c yarn -n __fish_use_subcommand -a node -d 'Run Node with the hook already setup'
complete -f -c yarn -n __fish_use_subcommand -a outdated -d 'Check for outdated packages'
2017-02-09 16:24:38 +00:00
2020-04-25 07:21:05 +00:00
complete -f -c yarn -n __fish_use_subcommand -a owner -d 'Manage package owners'
2017-02-09 16:24:38 +00:00
complete -f -c yarn -n '__fish_seen_subcommand_from owner' -a 'add rm ls'
2020-04-25 07:21:05 +00:00
complete -f -c yarn -n __fish_use_subcommand -a pack -d 'Create compressed archive of packages'
complete -f -c yarn -n __fish_use_subcommand -a policies -d 'Defines project-wide policies'
2017-02-09 16:24:38 +00:00
2020-04-25 07:21:05 +00:00
complete -f -c yarn -n __fish_use_subcommand -a publish -d 'Publish package to npm registry'
2017-12-15 04:09:53 +00:00
complete -f -c yarn -n '__fish_seen_subcommand_from publish' -l access -a 'public restricted'
complete -f -c yarn -n '__fish_seen_subcommand_from publish' -l tag
complete -f -c yarn -n '__fish_seen_subcommand_from publish' -l new-version
complete -f -c yarn -n '__fish_seen_subcommand_from publish' -l message
complete -f -c yarn -n '__fish_seen_subcommand_from publish' -l no-git-tag-version
complete -f -c yarn -n '__fish_seen_subcommand_from publish' -l access
2017-02-09 16:24:38 +00:00
complete -f -c yarn -n '__fish_seen_subcommand_from publish' -l tag
2020-04-25 07:21:05 +00:00
complete -f -c yarn -n __fish_use_subcommand -a remove -d 'Remove packages'
complete -f -c yarn -n __fish_use_subcommand -a run -d 'Run a defined package script'
2017-02-09 16:24:38 +00:00
2017-12-15 04:13:09 +00:00
function __fish_yarn_run
2019-03-09 17:00:52 +00:00
if test -e package.json; and set -l python ( __fish_anypython )
# Warning: That weird indentation is necessary, because python.
2020-02-27 12:48:42 +00:00
$python -S -c 'import json, sys; data = json.load( sys .stdin) ;
2019-03-09 17:00:52 +00:00
for k,v in data[ "scripts" ] .items( ) : print( k + "\t" + v[ :18 ] ) ' < package.json 2 > /dev/null
else if test -e package.json; and type -q jq
jq -r '.scripts | to_entries | map("\(.key)\t\(.value | tostring | .[0:20])") | .[]' package.json
else if type -q jq
# Yarn is quite slow and still requires `jq` because the normal format is unusable.
2019-05-05 10:53:09 +00:00
command yarn run --json 2 > /dev/null | jq -r '.data.hints? | to_entries | map("\(.key)\t\(.value | tostring |.[0:20])") | .[]'
2019-03-09 17:00:52 +00:00
end
2017-12-15 04:13:09 +00:00
end
2019-02-19 13:23:18 +00:00
# Scripts can be used like normal subcommands, or with `yarn run SCRIPT`.
2019-03-09 17:03:19 +00:00
complete -c yarn -n '__fish_use_subcommand; or __fish_seen_subcommand_from run' -xa "(__fish_yarn_run)"
2017-12-15 04:13:09 +00:00
2020-04-25 07:21:05 +00:00
complete -f -c yarn -n __fish_use_subcommand -a tag -d 'Manage package tags'
2017-12-15 04:09:53 +00:00
complete -f -c yarn -n '__fish_seen_subcommand_from tag' -a 'add rm ls'
2017-02-09 16:24:38 +00:00
2020-04-25 07:21:05 +00:00
complete -f -c yarn -n __fish_use_subcommand -a team -d 'Maintain team memberships'
2017-12-15 04:09:53 +00:00
complete -f -c yarn -n '__fish_seen_subcommand_from team' -a 'create destroy add rm ls'
2017-02-09 16:24:38 +00:00
2020-04-25 07:21:05 +00:00
complete -f -c yarn -n __fish_use_subcommand -a unlink -d 'Unlink a previously created symlink'
complete -f -c yarn -n __fish_use_subcommand -a unplug -d 'Force unpack packages'
complete -f -c yarn -n __fish_use_subcommand -a upgrade -d 'Upgrade packages'
complete -f -c yarn -n __fish_use_subcommand -a upgrade-interactive -d 'Upgrade packages interactively'
2017-02-09 16:24:38 +00:00
2020-04-25 07:21:05 +00:00
complete -f -c yarn -n __fish_use_subcommand -a version -d 'Update the package version'
2017-02-09 16:24:38 +00:00
complete -f -c yarn -n '__fish_seen_subcommand_from version' -l new-version
complete -f -c yarn -n '__fish_seen_subcommand_from version' -l message
complete -f -c yarn -n '__fish_seen_subcommand_from version' -l no-git-tag-version
2020-04-25 07:21:05 +00:00
complete -f -c yarn -n __fish_use_subcommand -a versions -d 'Show Yarn and Node version'
complete -f -c yarn -n __fish_use_subcommand -a why -d 'Show why a package is installed'
complete -f -c yarn -n __fish_use_subcommand -a workspace -d 'Manage workspace packages'
complete -f -c yarn -n __fish_use_subcommand -a workspaces -d 'Show workspaces information'
2017-02-09 16:24:38 +00:00
# These are the yarn commands all of them use the same options
2020-04-25 07:21:05 +00:00
set -g yarn_cmds access add audit autoclean bin cache check config create exec generate-lock-entry global import info init install licenses link list login logout node outdated owner pack policies publish remove run tag team unlink unplug upgrade upgrade-interactive version versions why workspace workspaces
2017-02-09 16:24:38 +00:00
# Common short, long options
2019-01-11 04:20:17 +00:00
complete -c yarn -n '__fish_seen_subcommand_from $yarn_cmds' -l help -s h -d 'output usage information'
complete -c yarn -n '__fish_seen_subcommand_from $yarn_cmds' -l version -s V -d 'output the version number'
2017-02-09 16:24:38 +00:00
# The rest of common options are all of them long
2019-01-11 04:20:17 +00:00
complete -c yarn -n '__fish_seen_subcommand_from $yarn_cmds' -l verbose -d 'output verbose messages on internal operations'
complete -c yarn -n '__fish_seen_subcommand_from $yarn_cmds' -l offline -d 'trigger an error if any required dependencies are not available in local cache'
complete -c yarn -n '__fish_seen_subcommand_from $yarn_cmds' -l prefer-offline -d 'use network only if dependencies are not available in local cache'
complete -c yarn -n '__fish_seen_subcommand_from $yarn_cmds' -l strict-semver
complete -c yarn -n '__fish_seen_subcommand_from $yarn_cmds' -l json
complete -c yarn -n '__fish_seen_subcommand_from $yarn_cmds' -l ignore-scripts -d 'don\' t run lifecycle scripts'
complete -c yarn -n '__fish_seen_subcommand_from $yarn_cmds' -l har -d 'save HAR output of network traffic'
complete -c yarn -n '__fish_seen_subcommand_from $yarn_cmds' -l ignore-platform -d 'ignore platform checks'
complete -c yarn -n '__fish_seen_subcommand_from $yarn_cmds' -l ignore-engines -d 'ignore engines check'
complete -c yarn -n '__fish_seen_subcommand_from $yarn_cmds' -l ignore-optional -d 'ignore optional dependencies'
complete -c yarn -n '__fish_seen_subcommand_from $yarn_cmds' -l force -d 'ignore all caches'
complete -c yarn -n '__fish_seen_subcommand_from $yarn_cmds' -l no-bin-links -d 'don\' t generate bin links when setting up packages'
complete -c yarn -n '__fish_seen_subcommand_from $yarn_cmds' -l flat -d 'only allow one version of a package'
complete -c yarn -n '__fish_seen_subcommand_from $yarn_cmds' -l 'prod production'
complete -c yarn -n '__fish_seen_subcommand_from $yarn_cmds' -l no-lockfile -d 'don\' t read or generate a lockfile'
complete -c yarn -n '__fish_seen_subcommand_from $yarn_cmds' -l pure-lockfile -d 'don\' t generate a lockfile'
complete -c yarn -n '__fish_seen_subcommand_from $yarn_cmds' -l frozen-lockfile -d 'don\' t generate a lockfile and fail if an update is needed'
complete -c yarn -n '__fish_seen_subcommand_from $yarn_cmds' -l global-folder
complete -c yarn -n '__fish_seen_subcommand_from $yarn_cmds' -l modules-folder -d 'rather than installing modules into the node_modules folder relative to the cwd, output them here'
complete -c yarn -n '__fish_seen_subcommand_from $yarn_cmds' -l cache-folder -d 'specify a custom folder to store the yarn cache'
complete -c yarn -n '__fish_seen_subcommand_from $yarn_cmds' -l mutex -d 'use a mutex to ensure only one yarn instance is executing'
complete -c yarn -n '__fish_seen_subcommand_from $yarn_cmds' -l mutex -a 'file network'
complete -c yarn -n '__fish_seen_subcommand_from $yarn_cmds' -l no-emoji -d 'disable emoji in output'
complete -c yarn -n '__fish_seen_subcommand_from $yarn_cmds' -l proxy
complete -c yarn -n '__fish_seen_subcommand_from $yarn_cmds' -l https-proxy
complete -c yarn -n '__fish_seen_subcommand_from $yarn_cmds' -l no-progress -d 'disable progress bar'
complete -c yarn -n '__fish_seen_subcommand_from $yarn_cmds' -l network-concurrency -d 'maximum number of concurrent network requests'