(deps: AuthDeps = {})
| 268 | } |
| 269 | |
| 270 | export function createAuthCommand(deps: AuthDeps = {}): Command { |
| 271 | const auth = new Command('auth').description('Manage TestSprite credentials'); |
| 272 | |
| 273 | // `status` (primary; formerly `whoami`). Credential WRITES no longer live |
| 274 | // here — `auth configure` is a hidden, deprecated alias for `setup` (attached |
| 275 | // in index.ts), and `setup` is the only command that writes credentials. |
| 276 | |
| 277 | auth |
| 278 | .command('status') |
| 279 | .description('Show the user, API key, env, and scopes bound to the active profile') |
| 280 | .addHelpText('after', GLOBAL_OPTS_HINT) |
| 281 | .action(async (_cmdOpts, command: Command) => { |
| 282 | await runWhoami(resolveCommonOptions(command), deps); |
| 283 | }); |
| 284 | |
| 285 | // `whoami` — hidden, deprecated alias for `status` (kept so scripts/agents |
| 286 | // on the old name keep working; invisible to --help). |
| 287 | auth |
| 288 | .command('whoami', { hidden: true }) |
| 289 | .addHelpText('after', GLOBAL_OPTS_HINT) |
| 290 | .action(async (_cmdOpts, command: Command) => { |
| 291 | emitDeprecationNotice('auth whoami', 'auth status', deps.stderr); |
| 292 | await runWhoami(resolveCommonOptions(command), deps); |
| 293 | }); |
| 294 | |
| 295 | auth |
| 296 | .command('remove') |
| 297 | .description('Remove credentials for the active profile') |
| 298 | .addHelpText('after', GLOBAL_OPTS_HINT) |
| 299 | .action(async (_cmdOpts, command: Command) => { |
| 300 | await runLogout(resolveCommonOptions(command), deps); |
| 301 | }); |
| 302 | |
| 303 | // `logout` — hidden, deprecated alias for `remove`. |
| 304 | auth |
| 305 | .command('logout', { hidden: true }) |
| 306 | .addHelpText('after', GLOBAL_OPTS_HINT) |
| 307 | .action(async (_cmdOpts, command: Command) => { |
| 308 | emitDeprecationNotice('auth logout', 'auth remove', deps.stderr); |
| 309 | await runLogout(resolveCommonOptions(command), deps); |
| 310 | }); |
| 311 | |
| 312 | return auth; |
| 313 | } |
| 314 | |
| 315 | function resolveCommonOptions(command: Command): CommonOptions { |
| 316 | const globals = command.optsWithGlobals() as Partial<CommonOptions> & { |
no test coverage detected