99
1010import typer
1111import typer .core
12- from reflex_cli .deployments import deployments_cli
13- from reflex_cli .utils import dependency
1412from reflex_cli .v2 .deployments import check_version , hosting_cli
1513
1614from reflex import constants
@@ -330,41 +328,8 @@ def export(
330328 )
331329
332330
333- def _login () -> str :
334- """Helper function to authenticate with Reflex hosting service."""
335- from reflex_cli .utils import hosting
336-
337- access_token , invitation_code = hosting .authenticated_token ()
338- if access_token :
339- console .print ("You already logged in." )
340- return access_token
341-
342- # If not already logged in, open a browser window/tab to the login page.
343- access_token = hosting .authenticate_on_browser (invitation_code )
344-
345- if not access_token :
346- console .error ("Unable to authenticate. Please try again or contact support." )
347- raise typer .Exit (1 )
348-
349- console .print ("Successfully logged in." )
350- return access_token
351-
352-
353- @cli .command ()
354- def login (
355- loglevel : constants .LogLevel = typer .Option (
356- config .loglevel , help = "The log level to use."
357- ),
358- ):
359- """Authenticate with Reflex hosting service."""
360- # Set the log level.
361- console .set_log_level (loglevel )
362-
363- _login ()
364-
365-
366331@cli .command ()
367- def loginv2 (loglevel : constants .LogLevel = typer .Option (config .loglevel )):
332+ def login (loglevel : constants .LogLevel = typer .Option (config .loglevel )):
368333 """Authenicate with experimental Reflex hosting service."""
369334 from reflex_cli .v2 import cli as hosting_cli
370335
@@ -382,26 +347,11 @@ def logout(
382347 ),
383348):
384349 """Log out of access to Reflex hosting service."""
385- from reflex_cli .utils import hosting
386-
387- console .set_log_level (loglevel )
388-
389- hosting .log_out_on_browser ()
390- console .debug ("Deleting access token from config locally" )
391- hosting .delete_token_from_config (include_invitation_code = True )
392-
393-
394- @cli .command ()
395- def logoutv2 (
396- loglevel : constants .LogLevel = typer .Option (
397- config .loglevel , help = "The log level to use."
398- ),
399- ):
400- """Log out of access to Reflex hosting service."""
401- from reflex_cli .v2 import cli
350+ from reflex_cli .v2 .cli import logout
402351
403352 check_version ()
404- cli .logout ()
353+
354+ logout (loglevel ) # type: ignore
405355
406356
407357db_cli = typer .Typer ()
@@ -486,126 +436,6 @@ def makemigrations(
486436
487437@cli .command ()
488438def deploy (
489- key : Optional [str ] = typer .Option (
490- None ,
491- "-k" ,
492- "--deployment-key" ,
493- help = "The name of the deployment. Domain name safe characters only." ,
494- ),
495- app_name : str = typer .Option (
496- config .app_name ,
497- "--app-name" ,
498- help = "The name of the App to deploy under." ,
499- hidden = True ,
500- ),
501- regions : List [str ] = typer .Option (
502- list (),
503- "-r" ,
504- "--region" ,
505- help = "The regions to deploy to." ,
506- ),
507- envs : List [str ] = typer .Option (
508- list (),
509- "--env" ,
510- help = "The environment variables to set: <key>=<value>. For multiple envs, repeat this option, e.g. --env k1=v2 --env k2=v2." ,
511- ),
512- cpus : Optional [int ] = typer .Option (
513- None , help = "The number of CPUs to allocate." , hidden = True
514- ),
515- memory_mb : Optional [int ] = typer .Option (
516- None , help = "The amount of memory to allocate." , hidden = True
517- ),
518- auto_start : Optional [bool ] = typer .Option (
519- None ,
520- help = "Whether to auto start the instance." ,
521- hidden = True ,
522- ),
523- auto_stop : Optional [bool ] = typer .Option (
524- None ,
525- help = "Whether to auto stop the instance." ,
526- hidden = True ,
527- ),
528- frontend_hostname : Optional [str ] = typer .Option (
529- None ,
530- "--frontend-hostname" ,
531- help = "The hostname of the frontend." ,
532- hidden = True ,
533- ),
534- interactive : bool = typer .Option (
535- True ,
536- help = "Whether to list configuration options and ask for confirmation." ,
537- ),
538- with_metrics : Optional [str ] = typer .Option (
539- None ,
540- help = "Setting for metrics scraping for the deployment. Setup required in user code." ,
541- hidden = True ,
542- ),
543- with_tracing : Optional [str ] = typer .Option (
544- None ,
545- help = "Setting to export tracing for the deployment. Setup required in user code." ,
546- hidden = True ,
547- ),
548- upload_db_file : bool = typer .Option (
549- False ,
550- help = "Whether to include local sqlite db files when uploading to hosting service." ,
551- hidden = True ,
552- ),
553- loglevel : constants .LogLevel = typer .Option (
554- config .loglevel , help = "The log level to use."
555- ),
556- ):
557- """Deploy the app to the Reflex hosting service."""
558- from reflex_cli import cli as hosting_cli
559-
560- from reflex .utils import export as export_utils
561- from reflex .utils import prerequisites
562-
563- # Set the log level.
564- console .set_log_level (loglevel )
565-
566- # Only check requirements if interactive. There is user interaction for requirements update.
567- if interactive :
568- dependency .check_requirements ()
569-
570- # Check if we are set up.
571- if prerequisites .needs_reinit (frontend = True ):
572- _init (name = config .app_name , loglevel = loglevel )
573- prerequisites .check_latest_package_version (constants .ReflexHostingCLI .MODULE_NAME )
574-
575- hosting_cli .deploy (
576- app_name = app_name ,
577- export_fn = lambda zip_dest_dir ,
578- api_url ,
579- deploy_url ,
580- frontend ,
581- backend ,
582- zipping : export_utils .export (
583- zip_dest_dir = zip_dest_dir ,
584- api_url = api_url ,
585- deploy_url = deploy_url ,
586- frontend = frontend ,
587- backend = backend ,
588- zipping = zipping ,
589- loglevel = loglevel .subprocess_level (),
590- upload_db_file = upload_db_file ,
591- ),
592- key = key ,
593- regions = regions ,
594- envs = envs ,
595- cpus = cpus ,
596- memory_mb = memory_mb ,
597- auto_start = auto_start ,
598- auto_stop = auto_stop ,
599- frontend_hostname = frontend_hostname ,
600- interactive = interactive ,
601- with_metrics = with_metrics ,
602- with_tracing = with_tracing ,
603- loglevel = loglevel .subprocess_level (),
604- )
605-
606-
607- @cli .command ()
608- def deployv2 (
609439 app_name : str = typer .Option (
610440 config .app_name ,
611441 "--app-name" ,
@@ -657,8 +487,8 @@ def deployv2(
657487 ),
658488):
659489 """Deploy the app to the Reflex hosting service."""
490+ from reflex_cli .utils import dependency
660491 from reflex_cli .v2 import cli as hosting_cli
661- from reflex_cli .v2 .utils import dependency
662492
663493 from reflex .utils import export as export_utils
664494 from reflex .utils import prerequisites
@@ -702,23 +532,18 @@ def deployv2(
702532 envfile = envfile ,
703533 hostname = hostname ,
704534 interactive = interactive ,
705- loglevel = loglevel . subprocess_level (),
535+ loglevel = type ( loglevel ). INFO , # type: ignore
706536 token = token ,
707537 project = project ,
708538 )
709539
710540
711541cli .add_typer (db_cli , name = "db" , help = "Subcommands for managing the database schema." )
712542cli .add_typer (script_cli , name = "script" , help = "Subcommands running helper scripts." )
713- cli .add_typer (
714- deployments_cli ,
715- name = "deployments" ,
716- help = "Subcommands for managing the Deployments." ,
717- )
718543cli .add_typer (
719544 hosting_cli ,
720- name = "apps " ,
721- help = "Subcommands for managing the Deployments ." ,
545+ name = "cloud " ,
546+ help = "Subcommands for managing the reflex cloud ." ,
722547)
723548cli .add_typer (
724549 custom_components_cli ,
0 commit comments