@@ -7,7 +7,7 @@ import makeCLI from "yargs";
7
7
import { version as wranglerVersion } from "../package.json" ;
8
8
import { ai } from "./ai" ;
9
9
import { cloudchamber } from "./cloudchamber" ;
10
- import { loadDotEnv , readConfig } from "./config" ;
10
+ import { loadDotEnv } from "./config" ;
11
11
import { createCommandRegister } from "./core/register-commands" ;
12
12
import { d1 } from "./d1" ;
13
13
import { deleteHandler , deleteOptions } from "./delete" ;
@@ -48,9 +48,9 @@ import { hyperdrive } from "./hyperdrive/index";
48
48
import { initHandler , initOptions } from "./init" ;
49
49
import "./kv" ;
50
50
import "./workflows" ;
51
+ import "./user/commands" ;
51
52
import { demandSingleValue } from "./core" ;
52
53
import { logBuildFailure , logger , LOGGER_LEVELS } from "./logger" ;
53
- import * as metrics from "./metrics" ;
54
54
import { mTlsCertificateCommands } from "./mtls-certificate/cli" ;
55
55
import { writeOutput } from "./output" ;
56
56
import { pages } from "./pages" ;
@@ -70,19 +70,13 @@ import { tailHandler, tailOptions } from "./tail";
70
70
import registerTriggersSubcommands from "./triggers" ;
71
71
import { typesHandler , typesOptions } from "./type-generation" ;
72
72
import { printWranglerBanner , updateCheck } from "./update-check" ;
73
- import {
74
- getAuthFromEnv ,
75
- listScopes ,
76
- login ,
77
- logout ,
78
- validateScopeKeys ,
79
- } from "./user" ;
73
+ import { getAuthFromEnv } from "./user" ;
74
+ import { whoami } from "./user/whoami" ;
80
75
import { debugLogFilepath } from "./utils/log-file" ;
81
76
import { vectorize } from "./vectorize/index" ;
82
77
import registerVersionsSubcommands from "./versions" ;
83
78
import registerVersionsDeploymentsSubcommands from "./versions/deployments" ;
84
79
import registerVersionsRollbackCommand from "./versions/rollback" ;
85
- import { whoami } from "./whoami" ;
86
80
import { asJson } from "./yargs-types" ;
87
81
import type { Config } from "./config" ;
88
82
import type { LoggerLevel } from "./logger" ;
@@ -596,99 +590,10 @@ export function createCLIParser(argv: string[]) {
596
590
} ) ;
597
591
598
592
/******************** CMD GROUP ***********************/
599
- // login
600
- wrangler . command (
601
- // this needs scopes as an option?
602
- "login" ,
603
- "🔓 Login to Cloudflare" ,
604
- ( yargs ) => {
605
- // TODO: This needs some copy editing
606
- // I mean, this entire app does, but this too.
607
- return yargs
608
- . option ( "scopes-list" , {
609
- describe : "List all the available OAuth scopes with descriptions" ,
610
- } )
611
- . option ( "browser" , {
612
- default : true ,
613
- type : "boolean" ,
614
- describe : "Automatically open the OAuth link in a browser" ,
615
- } )
616
- . option ( "scopes" , {
617
- describe : "Pick the set of applicable OAuth scopes when logging in" ,
618
- array : true ,
619
- type : "string" ,
620
- requiresArg : true ,
621
- } ) ;
622
- // TODO: scopes
623
- } ,
624
- async ( args ) => {
625
- await printWranglerBanner ( ) ;
626
- if ( args [ "scopes-list" ] ) {
627
- listScopes ( ) ;
628
- return ;
629
- }
630
- if ( args . scopes ) {
631
- if ( args . scopes . length === 0 ) {
632
- // don't allow no scopes to be passed, that would be weird
633
- listScopes ( ) ;
634
- return ;
635
- }
636
- if ( ! validateScopeKeys ( args . scopes ) ) {
637
- throw new CommandLineArgsError (
638
- `One of ${ args . scopes } is not a valid authentication scope. Run "wrangler login --scopes-list" to see the valid scopes.`
639
- ) ;
640
- }
641
- await login ( { scopes : args . scopes , browser : args . browser } ) ;
642
- return ;
643
- }
644
- await login ( { browser : args . browser } ) ;
645
- const config = readConfig ( args . config , args , undefined , true ) ;
646
- await metrics . sendMetricsEvent ( "login user" , {
647
- sendMetrics : config . send_metrics ,
648
- } ) ;
649
-
650
- // TODO: would be nice if it optionally saved login
651
- // credentials inside node_modules/.cache or something
652
- // this way you could have multiple users on a single machine
653
- }
654
- ) ;
655
593
656
- // logout
657
- wrangler . command (
658
- // this needs scopes as an option?
659
- "logout" ,
660
- "🚪 Logout from Cloudflare" ,
661
- ( ) => { } ,
662
- async ( args ) => {
663
- await printWranglerBanner ( ) ;
664
- await logout ( ) ;
665
- const config = readConfig ( undefined , args , undefined , true ) ;
666
- await metrics . sendMetricsEvent ( "logout user" , {
667
- sendMetrics : config . send_metrics ,
668
- } ) ;
669
- }
670
- ) ;
671
-
672
- // whoami
673
- wrangler . command (
674
- "whoami" ,
675
- "🕵️ Retrieve your user information" ,
676
- ( yargs ) => {
677
- return yargs . option ( "account" , {
678
- type : "string" ,
679
- describe :
680
- "Show membership information for the given account (id or name)." ,
681
- } ) ;
682
- } ,
683
- async ( args ) => {
684
- await printWranglerBanner ( ) ;
685
- await whoami ( args . account ) ;
686
- const config = readConfig ( undefined , args ) ;
687
- await metrics . sendMetricsEvent ( "view accounts" , {
688
- sendMetrics : config . send_metrics ,
689
- } ) ;
690
- }
691
- ) ;
594
+ register . registerNamespace ( "login" ) ;
595
+ register . registerNamespace ( "logout" ) ;
596
+ register . registerNamespace ( "whoami" ) ;
692
597
693
598
/******************************************************/
694
599
/* DEPRECATED COMMANDS */
0 commit comments