commands.d.cts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { c as AgentCommands, A as Agent, C as Command, R as ResolvedCommand, b as AgentCommandValue } from './shared/package-manager-detector.257741fc.cjs';
  2. declare const COMMANDS: {
  3. npm: AgentCommands;
  4. yarn: AgentCommands;
  5. 'yarn@berry': AgentCommands;
  6. pnpm: AgentCommands;
  7. 'pnpm@6': AgentCommands;
  8. bun: AgentCommands;
  9. deno: AgentCommands;
  10. };
  11. /**
  12. * Resolve the command for the agent merging the command arguments with the provided arguments.
  13. *
  14. * For example, to show how to install `@antfu/ni` globally using `pnpm`:
  15. * ```js
  16. * import { resolveCommand } from 'package-manager-detector/commands'
  17. * const { command, args } = resolveCommand('pnpm', 'global', ['@antfu/ni'])
  18. * console.log(`${command} ${args.join(' ')}`) // 'pnpm add -g @antfu/ni'
  19. * ```
  20. *
  21. * @param agent The agent to use.
  22. * @param command the command to resolve.
  23. * @param args The arguments to pass to the command.
  24. * @returns {ResolvedCommand} The resolved command or `null` if the agent command is not found.
  25. */
  26. declare function resolveCommand(agent: Agent, command: Command, args: string[]): ResolvedCommand | null;
  27. /**
  28. * Construct the command from the agent command merging the command arguments with the provided arguments.
  29. * @param value {AgentCommandValue} The agent command to use.
  30. * @param args The arguments to pass to the command.
  31. * @returns {ResolvedCommand} The resolved command or `null` if the command is `null`.
  32. */
  33. declare function constructCommand(value: AgentCommandValue, args: string[]): ResolvedCommand | null;
  34. export { COMMANDS, constructCommand, resolveCommand };