diff --git a/custom-completions/yarn/yarn-v4-completions.nu b/custom-completions/yarn/yarn-v4-completions.nu index 912974e2..6d820e85 100644 --- a/custom-completions/yarn/yarn-v4-completions.nu +++ b/custom-completions/yarn/yarn-v4-completions.nu @@ -2,7 +2,93 @@ # This is for yarn v2(berry) and higher, which is not installed by default. see https://yarnpkg.com/getting-started/migration for a migration guide # Before running any command after this is installed, please run `refresh-cache` to update the NPM registry and yarn plugin cache +def "nu-complete yarn run" [] { + + let userScripts = try { + open ./package.json + | get scripts + | transpose + | rename value description + } catch {[]} + + let binaries = try { + yarn bin --json + | lines + | each { |it| $it | from json } + | select name source + | rename value description + } catch {[]} + + $userScripts | append $binaries +} + +def 'nu-complete yarn' [] { + let commands = [ + {value:'add', description:'Add dependencies to the project'} + {value:'bin', description:'Get the path to a binary script'} + {value: 'cache clean', description: 'Remove the shared cache files'} + {value: 'config get', description: 'Read a configuration settings'} + {value: 'config set', description: 'Change a configuration settings'} + {value: 'config unset', description: 'Unset a configuration setting'} + {value: 'config', description: 'Display the current configuration'} + {value: 'constraints query', description: 'Query the constraints fact database'} + {value: 'constraints source', description: 'Print the source code for the constraints'} + {value: 'yarn constraints', description: 'Check that the project constraints are met'} + {value: 'dedupe', description: 'Deduplicate dependencies with overlapping ranges'} + {value: 'dlx', description: 'Run a package in a temporary environment'} + {value: 'exec', description: 'Execute a shell script'} + {value: 'explain peer-requirements', description: 'Explain a set of peer requirements'} + {value: 'explain', description: 'Explain an error code'} + {value: 'info', description: 'See information related to packages'} + {value: 'install', description: 'Install the project dependencies'} + {value: 'link', description: 'Connect the local project to another one'} + {value: 'node', description: 'Run node with the hook already setup'} + {value: 'npm audit', description: 'Perform a vulnerability audit against the installed packages'} + {value: 'npm info', description: 'Show information about a package'} + {value: 'npm login', description: 'Store new login info to access the npm registry'} + {value: 'npm logout', description: 'Logout of the npm registry'} + {value: 'npm publish', description: 'Publish the active workspace to the npm registry'} + {value: 'npm tag add', description: 'Add a tag for a specific version of a package'} + {value: 'npm tag list', description: 'List all dist-tags of a package'} + {value: 'npm tag remove', description: 'Remove a tag from a package'} + {value: 'npm whoami', description: 'Display the name of the authenticated user'} + {value: 'pack', description: 'Generate a tarball from the active workspace'} + {value: 'patch-commit', description: 'Generate a patch out of a directory'} + {value: 'patch', description: 'Prepare a package for patching'} + {value: 'plugin import from sources', description: 'Build a plugin from sources'} + {value: 'plugin import', description: 'Download a plugin'} + {value: 'plugin list', description: 'List the available official plugins'} + {value: 'plugin remove', description: 'Remove a plugin'} + {value: 'plugin runtime', description: 'List the active plugins'} + {value: 'rebuild', description: "Rebuild the project's native packages"} + {value: 'remove', description: 'Remove dependencies from the project'} + {value: 'run', description: 'Run a script defined in the package.json'} + {value: 'search', description: 'Open the search interface'} + {value: 'set resolution', description: 'Enforce a package resolution'} + {value: 'set version from sources', description: 'Build Yarn from master'} + {value: 'set version', description: 'Lock the Yarn version used by the project'} + {value: 'stage', description: 'Add all yarn files to your vcs'} + {value: 'unlink', description: 'Disconnect the local project from another one'} + {value: 'unplug', description: 'Force the unpacking of a list of packages'} + {value: 'up', description: 'Upgrade dependencies across the project'} + {value: 'upgrade-interactive', description: 'Open the upgrade interface'} + {value: 'version', description: 'Apply a new version to the current package'} + {value: 'version apply', description: 'Apply all the deferred version bumps at once'} + {value: 'version check', description: 'Check that all the relevant packages have been bumped'} + {value: 'why', description: 'Display the reason why a package is needed'} + {value: 'workspace', description: 'Run a command within the specified workspace'} + {value: 'workspaces focus', description: 'Install a single workspace and its dependencies'} + {value: 'workspaces foreach', description: 'Run a command on all workspaces'} + {value: 'workspaces list', description: 'List all available workspaces'} + ] + + let runnables = try {(nu-complete yarn run)} catch {[]} + + $commands | append $runnables +} + export extern "yarn" [ + command?: string@"nu-complete yarn" ] def 'nu-complete yarn mode' [] { @@ -24,7 +110,7 @@ def "nu-complete yarn add" [] { open $cacheFilePath | $in.package } -# Add dependencies to the project. +# Add dependencies to the project export extern "yarn add" [ --json # Format the output as an NDJSON stream --exact(-E) # Don't use any semver modifier on the resolved range @@ -47,14 +133,14 @@ def 'nu-complete yarn bin' [] { |$in.name } -# Get the path to a binary script. +# Get the path to a binary script export extern "yarn bin" [ --json # Format the output as an NDJSON stream --verbose(-v) # Print both the binary name and the locator of the package that provides the binary binary?: string@"nu-complete yarn bin" ] -# Remove the shared cache files. +# Remove the shared cache files export extern "yarn cache clean" [ --mirror # Remove the global cache files instead of the local cache files --all # Remove both the global cache files and the local cache files of the current project @@ -67,14 +153,14 @@ def "nu-complete yarn config" [] { |$in.key } -# Read a configuration settings. +# Read a configuration settings export extern "yarn config get" [ --json # Format the output as an NDJSON stream --no-redacted # Don't redact secrets (such as tokens) from the output name: string@"nu-complete yarn config" ] -# Change a configuration settings. +# Change a configuration settings export extern "yarn config set" [ --json # Set complex configuration settings to JSON values --home(-H) # Update the home configuration instead of the project configuration @@ -82,31 +168,31 @@ export extern "yarn config set" [ value: string ] -# Unset a configuration settings. +# Unset a configuration setting export extern "yarn config unset" [ --home(-H) # Update the home configuration instead of the project configuration name: string@"nu-complete yarn config" ] -# Display the current configuration. +# Display the current configuration export extern "yarn config" [ --verbose(-v) # Print the setting description on top of the regular key/value information --json # Format the output as an NDJSON stream --why # Print the reason why a setting is set a particular way ] -# Query the constraints fact database. This requires the constraints plugin to be installed +# Query the constraints fact database export extern "yarn constraints query" [ --json # Format the output as NDJSON stream query: string ] -# Print the source code for the constraints. This requires the constraints plugin to be installed +# Print the source code for the constraints export extern "yarn constraints source" [ --verbose(-v) # Also print the fact database automatically compiled from the workspace manifests ] -# Check that the project constraints are met. +# Check that the project constraints are met export extern "yarn constraints" [ --fix # Attempt to automatically fix unambiguous issues, following a multi-pass process ] @@ -115,11 +201,10 @@ def 'nu-complete yarn dedupe strategy' [] { ["highest"] } - -# Deduplicate dependencies with overlapping ranges. - export extern "yarn dedupe" [ - --strategy(-s): string@"nu-complete yarn dedupe strategy" # The strategy to use when deduping dependencies - --check(-c) # Exit with exit code 1 when duplicates are found, without persisting the dependency tree +# Deduplicate dependencies with overlapping ranges +export extern "yarn dedupe" [ + --strategy(-s): string@"nu-complete yarn dedupe strategy" # The strategy to use when deduping dependencies + --check(-c) # Exit with exit code 1 when duplicates are found, without persisting the dependency tree --json # Format the output as an NDJSON stream --mode: string@"nu-complete yarn mode" # Change what artifacts installs generate package: string @@ -131,7 +216,7 @@ def "nu-complete yarn dlx" [] { open $cacheFilePath | $in.package } -# Run a package in a temporary environment. +# Run a package in a temporary environment export extern "yarn dlx" [ --package(-p) # The package(s) to install before running the command --quiet(-q) # Only report critical errors instead of printing the full install logs @@ -139,7 +224,7 @@ export extern "yarn dlx" [ ...args: string ] -# Execute a shell script. +# Execute a shell script export extern "yarn exec" [ ...command: string ] @@ -172,12 +257,12 @@ def "nu-complete yarn explain peer-requirements" [] { } } -# Explain a set of peer requirements. +# Explain a set of peer requirements export extern "yarn explain peer-requirements" [ hash?: string@"nu-complete yarn explain peer-requirements" ] -# Explain an error code. +# Explain an error code export extern "yarn explain" [ --json # Format the output as an NDJSON stream code: string @@ -192,7 +277,7 @@ def "nu-complete yarn info" [] { $deps | append $devDeps } -# See information related to packages. +# See information related to packages export extern "yarn info" [ --all(-A) # Print versions of a package from the whole project --recursive(-R) # Print information for all packages, including transitive dependencies @@ -206,7 +291,7 @@ export extern "yarn info" [ package: string@"nu-complete yarn info" ] -# Install the project dependencies. +# Install the project dependencies export extern "yarn install" [ --json # Format the output as an NDJSON stream --immutable # Abort with an error exit code if the lockfile was to be modified @@ -216,7 +301,7 @@ export extern "yarn install" [ --mode: string@"nu-complete yarn mode" # Change what artifacts installs generate ] -# Connect the local project to another one. +# Connect the local project to another one export extern "yarn link" [ --all(-A) # Link all workspaces belonging to the target project to the current one --private(-p) # Also link private workspaces belonging to the target project to the current one @@ -224,7 +309,7 @@ export extern "yarn link" [ path: string ] -# Run node with the hook already setup. +# Run node with the hook already setup export extern "yarn node" [ ...command: string ] @@ -249,7 +334,7 @@ export extern "yarn npm info" [ package: string ] -# Store new login info to access the npm registry. +# Store new login info to access the npm registry export extern "yarn npm login" [ --scope(-s) # Login to the registry configured for a given scope --publish # Login to the publish registry @@ -262,7 +347,7 @@ export extern "yarn npm logout" [ --all(-A) # Logout of all registries ] -# Publish the active workspace to the npm registry. +# Publish the active workspace to the npm registry export extern "yarn npm publish" [ --access: string # The access level of the published package (public or restricted) --tag: string # The tag on the registry that the package should be attached to @@ -270,7 +355,7 @@ export extern "yarn npm publish" [ --opt: string # The OTP token to use with the command ] -# Add a tag for a specific version of a package. +# Add a tag for a specific version of a package export extern "yarn npm tag add" [ package: string tag: string @@ -288,13 +373,13 @@ export extern "yarn npm tag remove" [ tag: string ] -# Display the name of the authenticated user. +# Display the name of the authenticated user export extern "yarn npm whoami" [ --scope(-s) # Print username for the registry configured for a given scope --publish # Print username for the publish registry ] -# Generate a tarball from the active workspace. +# Generate a tarball from the active workspace export extern "yarn pack" [ --install-if-needed # Run a priliminary yarn install if the package contains build scripts --dry-run(-n) # Print the file paths without actually generating the package archive @@ -302,7 +387,7 @@ export extern "yarn pack" [ --out(-o): string # Create the archive at the specified path ] -# Generate a patch out of a directory. +# Generate a patch out of a directory export extern "yarn patch-commit" [ --save(-s) # Add the patch to your resolution entries ] @@ -315,7 +400,7 @@ def "nu-complete yarn patch" [] { $deps | append $devDeps } -# Prepare a package for patching. +# Prepare a package for patching export extern "yarn patch" [ --json # Format the output as an NDJSON stream package: string@"nu-complete yarn patch" @@ -338,12 +423,12 @@ def "nu-complete yarn plugin import" [] { open $yarnPluginCacheFilePath | get name } -# Download a plugin. +# Download a plugin export extern "yarn plugin import" [ plugin: string@"nu-complete yarn plugin import" ] -# List the available official plugins. +# List the available official plugins export extern "yarn plugin list" [ --json # Format the output as an NDJSON stream ] @@ -352,12 +437,12 @@ def "nu-complete yarn plugin remove" [] { open ./.yarnrc.yml | get plugins | get spec } -# Remove a plugin. +# Remove a plugin export extern "yarn plugin remove" [ plugin: string@"nu-complete yarn plugin remove" ] -# List the active plugins. +# List the active plugins export extern "yarn plugin runtime" [ --json # Format the output as an NDJSON stream ] @@ -375,28 +460,13 @@ export extern "yarn rebuild" [ ...packages: string@"nu-complete yarn rebuild" ] -# Remove a dependency from the project. +# Remove a dependency from the project export extern "yarn remove" [ --all(-A) # Apply the operation to all workspaces from the current project --mode: string@"nu-complete yarn mode" # The mode to use when removing the dependency ] -def "nu-complete yarn run" [] { - let userScripts = open ./package.json - | get scripts - | transpose - | rename value description - - let binaries = yarn bin --json - | lines - | each { |it| $it | from json } - | select name source - | rename value description - - $userScripts | append $binaries -} - -# Run a script defined in the package.json. +# Run a script defined in the package.json export extern "yarn run" [ --inspect # forwarded to the underlying node process --inspect-brk # forwarded to the underlying node process @@ -417,7 +487,7 @@ export extern "yarn set resolution" [ resolution: string ] -# Build yarn from master. +# Build yarn from master export extern "yarn set version from sources" [ --path: string # The path where the repository should be cloned to --repository: string # The repository that should be cloned @@ -427,7 +497,7 @@ export extern "yarn set version from sources" [ --skip-plugins # Skip updating the contrib plugins ] -# Lock the Yarn version used by the project. +# Lock the Yarn version used by the project export extern "yarn set version" [ --only-if-needed # Only lock the yarn version if it isn't already locked version: string @@ -440,7 +510,7 @@ export extern "yarn stage" [ --dry-run(-n) # Print the commit message and the list of modified files without staging / committing ] -# Disconnect the local project from another one. +# Disconnect the local project from another one export extern "yarn unlink" [ --all(-A) # Unlink all workspaces belonging to the target project from the current one ...packages: string @@ -454,7 +524,7 @@ export extern "yarn unplug" [ ...packages: string ] -# Upgrade dependencies across the project. +# Upgrade dependencies across the project export extern "yarn up" [ --interactive(-i) # Offer various choices, depending on the detected upgrade paths --exact(-E) # Don't use any semver modifier on the resolved range @@ -506,7 +576,7 @@ def "nu-complete yarn why" [] { $deps | append $devDeps } -# Display the reason why a package is needed. +# Display the reason why a package is needed export extern "yarn why" [ --recursive(-R) # List, for each workspace, what are all the paths that lead to the dependency --json # Format the output as an NDJSON stream