reflex.py 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742
  1. """Reflex CLI to create, run, and deploy apps."""
  2. from __future__ import annotations
  3. # WARNING: do not import any modules that contain rx.State subclasses here
  4. import atexit
  5. import os
  6. from pathlib import Path
  7. from typing import List, Optional
  8. import typer
  9. import typer.core
  10. from reflex_cli.deployments import deployments_cli
  11. from reflex_cli.utils import dependency
  12. from reflex_cli.v2.deployments import check_version, hosting_cli
  13. from reflex import constants
  14. from reflex.config import environment, get_config
  15. from reflex.custom_components.custom_components import custom_components_cli
  16. from reflex.utils import console, telemetry
  17. from reflex.utils.exec import set_env_mode
  18. # Disable typer+rich integration for help panels
  19. typer.core.rich = None # type: ignore
  20. # Create the app.
  21. try:
  22. cli = typer.Typer(add_completion=False, pretty_exceptions_enable=False)
  23. except TypeError:
  24. # Fallback for older typer versions.
  25. cli = typer.Typer(add_completion=False)
  26. # Get the config.
  27. config = get_config()
  28. def version(value: bool):
  29. """Get the Reflex version.
  30. Args:
  31. value: Whether the version flag was passed.
  32. Raises:
  33. typer.Exit: If the version flag was passed.
  34. """
  35. if value:
  36. console.print(constants.Reflex.VERSION)
  37. raise typer.Exit()
  38. @cli.callback()
  39. def main(
  40. version: bool = typer.Option(
  41. None,
  42. "-v",
  43. "--version",
  44. callback=version,
  45. help="Get the Reflex version.",
  46. is_eager=True,
  47. ),
  48. ):
  49. """Reflex CLI to create, run, and deploy apps."""
  50. pass
  51. def _init(
  52. name: str,
  53. template: str | None = None,
  54. loglevel: constants.LogLevel = config.loglevel,
  55. ai: bool = False,
  56. ):
  57. """Initialize a new Reflex app in the given directory."""
  58. from reflex.utils import exec, prerequisites
  59. # Set the log level.
  60. console.set_log_level(loglevel)
  61. # Show system info
  62. exec.output_system_info()
  63. # Validate the app name.
  64. app_name = prerequisites.validate_app_name(name)
  65. console.rule(f"[bold]Initializing {app_name}")
  66. # Check prerequisites.
  67. prerequisites.check_latest_package_version(constants.Reflex.MODULE_NAME)
  68. prerequisites.initialize_reflex_user_directory()
  69. prerequisites.ensure_reflex_installation_id()
  70. # Set up the web project.
  71. prerequisites.initialize_frontend_dependencies()
  72. # Initialize the app.
  73. template = prerequisites.initialize_app(app_name, template, ai)
  74. # Initialize the .gitignore.
  75. prerequisites.initialize_gitignore()
  76. # Initialize the requirements.txt.
  77. prerequisites.initialize_requirements_txt()
  78. template_msg = f" using the {template} template" if template else ""
  79. # Finish initializing the app.
  80. console.success(f"Initialized {app_name}{template_msg}")
  81. @cli.command()
  82. def init(
  83. name: str = typer.Option(
  84. None, metavar="APP_NAME", help="The name of the app to initialize."
  85. ),
  86. template: str = typer.Option(
  87. None,
  88. help="The template to initialize the app with.",
  89. ),
  90. loglevel: constants.LogLevel = typer.Option(
  91. config.loglevel, help="The log level to use."
  92. ),
  93. ai: bool = typer.Option(
  94. False,
  95. help="Use AI to create the initial template. Cannot be used with existing app or `--template` option.",
  96. ),
  97. ):
  98. """Initialize a new Reflex app in the current directory."""
  99. _init(name, template, loglevel, ai)
  100. def _run(
  101. env: constants.Env = constants.Env.DEV,
  102. frontend: bool = True,
  103. backend: bool = True,
  104. frontend_port: str = str(config.frontend_port),
  105. backend_port: str = str(config.backend_port),
  106. backend_host: str = config.backend_host,
  107. loglevel: constants.LogLevel = config.loglevel,
  108. ):
  109. """Run the app in the given directory."""
  110. # Set env mode in the environment
  111. # This must be set before importing modules that contain rx.State subclasses
  112. set_env_mode(env)
  113. from reflex.state import reset_disk_state_manager
  114. from reflex.utils import build, exec, prerequisites, processes
  115. # Set the log level.
  116. console.set_log_level(loglevel)
  117. # Show system info
  118. exec.output_system_info()
  119. # If no --frontend-only and no --backend-only, then turn on frontend and backend both
  120. if not frontend and not backend:
  121. frontend = True
  122. backend = True
  123. if not frontend and backend:
  124. _skip_compile()
  125. # Check that the app is initialized.
  126. if prerequisites.needs_reinit(frontend=frontend):
  127. _init(name=config.app_name, loglevel=loglevel)
  128. # Delete the states folder if it exists.
  129. reset_disk_state_manager()
  130. # Find the next available open port if applicable.
  131. if frontend:
  132. frontend_port = processes.handle_port(
  133. "frontend", frontend_port, str(constants.DefaultPorts.FRONTEND_PORT)
  134. )
  135. if backend:
  136. backend_port = processes.handle_port(
  137. "backend", backend_port, str(constants.DefaultPorts.BACKEND_PORT)
  138. )
  139. # Apply the new ports to the config.
  140. if frontend_port != str(config.frontend_port):
  141. config._set_persistent(frontend_port=frontend_port)
  142. if backend_port != str(config.backend_port):
  143. config._set_persistent(backend_port=backend_port)
  144. # Reload the config to make sure the env vars are persistent.
  145. get_config(reload=True)
  146. console.rule("[bold]Starting Reflex App")
  147. prerequisites.check_latest_package_version(constants.Reflex.MODULE_NAME)
  148. if frontend:
  149. # Get the app module.
  150. prerequisites.get_compiled_app()
  151. # Warn if schema is not up to date.
  152. prerequisites.check_schema_up_to_date()
  153. # Get the frontend and backend commands, based on the environment.
  154. setup_frontend = frontend_cmd = backend_cmd = None
  155. if env == constants.Env.DEV:
  156. setup_frontend, frontend_cmd, backend_cmd = (
  157. build.setup_frontend,
  158. exec.run_frontend,
  159. exec.run_backend,
  160. )
  161. if env == constants.Env.PROD:
  162. setup_frontend, frontend_cmd, backend_cmd = (
  163. build.setup_frontend_prod,
  164. exec.run_frontend_prod,
  165. exec.run_backend_prod,
  166. )
  167. if not setup_frontend or not frontend_cmd or not backend_cmd:
  168. raise ValueError("Invalid env")
  169. # Post a telemetry event.
  170. telemetry.send(f"run-{env.value}")
  171. # Display custom message when there is a keyboard interrupt.
  172. atexit.register(processes.atexit_handler)
  173. # Run the frontend and backend together.
  174. commands = []
  175. # Run the frontend on a separate thread.
  176. if frontend:
  177. setup_frontend(Path.cwd())
  178. commands.append((frontend_cmd, Path.cwd(), frontend_port, backend))
  179. # In prod mode, run the backend on a separate thread.
  180. if backend and env == constants.Env.PROD:
  181. commands.append(
  182. (
  183. backend_cmd,
  184. backend_host,
  185. backend_port,
  186. loglevel.subprocess_level(),
  187. frontend,
  188. )
  189. )
  190. # Start the frontend and backend.
  191. with processes.run_concurrently_context(*commands):
  192. # In dev mode, run the backend on the main thread.
  193. if backend and env == constants.Env.DEV:
  194. backend_cmd(
  195. backend_host, int(backend_port), loglevel.subprocess_level(), frontend
  196. )
  197. # The windows uvicorn bug workaround
  198. # https://github.com/reflex-dev/reflex/issues/2335
  199. if constants.IS_WINDOWS and exec.frontend_process:
  200. # Sends SIGTERM in windows
  201. exec.kill(exec.frontend_process.pid)
  202. @cli.command()
  203. def run(
  204. env: constants.Env = typer.Option(
  205. constants.Env.DEV, help="The environment to run the app in."
  206. ),
  207. frontend: bool = typer.Option(
  208. False,
  209. "--frontend-only",
  210. help="Execute only frontend.",
  211. envvar=environment.REFLEX_FRONTEND_ONLY.name,
  212. ),
  213. backend: bool = typer.Option(
  214. False,
  215. "--backend-only",
  216. help="Execute only backend.",
  217. envvar=environment.REFLEX_BACKEND_ONLY.name,
  218. ),
  219. frontend_port: str = typer.Option(
  220. config.frontend_port, help="Specify a different frontend port."
  221. ),
  222. backend_port: str = typer.Option(
  223. config.backend_port, help="Specify a different backend port."
  224. ),
  225. backend_host: str = typer.Option(
  226. config.backend_host, help="Specify the backend host."
  227. ),
  228. loglevel: constants.LogLevel = typer.Option(
  229. config.loglevel, help="The log level to use."
  230. ),
  231. ):
  232. """Run the app in the current directory."""
  233. if frontend and backend:
  234. console.error("Cannot use both --frontend-only and --backend-only options.")
  235. raise typer.Exit(1)
  236. environment.REFLEX_BACKEND_ONLY.set(backend)
  237. environment.REFLEX_FRONTEND_ONLY.set(frontend)
  238. _run(env, frontend, backend, frontend_port, backend_port, backend_host, loglevel)
  239. @cli.command()
  240. def export(
  241. zipping: bool = typer.Option(
  242. True, "--no-zip", help="Disable zip for backend and frontend exports."
  243. ),
  244. frontend: bool = typer.Option(
  245. True, "--backend-only", help="Export only backend.", show_default=False
  246. ),
  247. backend: bool = typer.Option(
  248. True, "--frontend-only", help="Export only frontend.", show_default=False
  249. ),
  250. zip_dest_dir: str = typer.Option(
  251. os.getcwd(),
  252. help="The directory to export the zip files to.",
  253. show_default=False,
  254. ),
  255. upload_db_file: bool = typer.Option(
  256. False,
  257. help="Whether to exclude sqlite db files when exporting backend.",
  258. hidden=True,
  259. ),
  260. loglevel: constants.LogLevel = typer.Option(
  261. config.loglevel, help="The log level to use."
  262. ),
  263. ):
  264. """Export the app to a zip file."""
  265. # Set env mode in the environment
  266. # This must be set before importing modules that contain rx.State subclasses
  267. set_env_mode(constants.Env.PROD)
  268. from reflex.utils import export as export_utils
  269. from reflex.utils import prerequisites
  270. if prerequisites.needs_reinit(frontend=True):
  271. _init(name=config.app_name, loglevel=loglevel)
  272. export_utils.export(
  273. zipping=zipping,
  274. frontend=frontend,
  275. backend=backend,
  276. zip_dest_dir=zip_dest_dir,
  277. upload_db_file=upload_db_file,
  278. loglevel=loglevel.subprocess_level(),
  279. )
  280. def _login() -> str:
  281. """Helper function to authenticate with Reflex hosting service."""
  282. from reflex_cli.utils import hosting
  283. access_token, invitation_code = hosting.authenticated_token()
  284. if access_token:
  285. console.print("You already logged in.")
  286. return access_token
  287. # If not already logged in, open a browser window/tab to the login page.
  288. access_token = hosting.authenticate_on_browser(invitation_code)
  289. if not access_token:
  290. console.error("Unable to authenticate. Please try again or contact support.")
  291. raise typer.Exit(1)
  292. console.print("Successfully logged in.")
  293. return access_token
  294. @cli.command()
  295. def login(
  296. loglevel: constants.LogLevel = typer.Option(
  297. config.loglevel, help="The log level to use."
  298. ),
  299. ):
  300. """Authenticate with Reflex hosting service."""
  301. # Set the log level.
  302. console.set_log_level(loglevel)
  303. _login()
  304. @cli.command()
  305. def loginv2(loglevel: constants.LogLevel = typer.Option(config.loglevel)):
  306. """Authenicate with experimental Reflex hosting service."""
  307. from reflex_cli.v2 import cli as hosting_cli
  308. check_version()
  309. hosting_cli.login()
  310. @cli.command()
  311. def logout(
  312. loglevel: constants.LogLevel = typer.Option(
  313. config.loglevel, help="The log level to use."
  314. ),
  315. ):
  316. """Log out of access to Reflex hosting service."""
  317. from reflex_cli.utils import hosting
  318. console.set_log_level(loglevel)
  319. hosting.log_out_on_browser()
  320. console.debug("Deleting access token from config locally")
  321. hosting.delete_token_from_config(include_invitation_code=True)
  322. @cli.command()
  323. def logoutv2(
  324. loglevel: constants.LogLevel = typer.Option(
  325. config.loglevel, help="The log level to use."
  326. ),
  327. ):
  328. """Log out of access to Reflex hosting service."""
  329. from reflex_cli.v2.utils import hosting
  330. check_version()
  331. console.set_log_level(loglevel)
  332. hosting.log_out_on_browser()
  333. console.debug("Deleting access token from config locally")
  334. hosting.delete_token_from_config(include_invitation_code=True)
  335. db_cli = typer.Typer()
  336. script_cli = typer.Typer()
  337. def _skip_compile():
  338. """Skip the compile step."""
  339. environment.REFLEX_SKIP_COMPILE.set(True)
  340. @db_cli.command(name="init")
  341. def db_init():
  342. """Create database schema and migration configuration."""
  343. from reflex import model
  344. from reflex.utils import prerequisites
  345. # Check the database url.
  346. if config.db_url is None:
  347. console.error("db_url is not configured, cannot initialize.")
  348. return
  349. # Check the alembic config.
  350. if environment.ALEMBIC_CONFIG.get().exists():
  351. console.error(
  352. "Database is already initialized. Use "
  353. "[bold]reflex db makemigrations[/bold] to create schema change "
  354. "scripts and [bold]reflex db migrate[/bold] to apply migrations "
  355. "to a new or existing database.",
  356. )
  357. return
  358. # Initialize the database.
  359. _skip_compile()
  360. prerequisites.get_compiled_app()
  361. model.Model.alembic_init()
  362. model.Model.migrate(autogenerate=True)
  363. @db_cli.command()
  364. def migrate():
  365. """Create or update database schema from migration scripts."""
  366. from reflex import model
  367. from reflex.utils import prerequisites
  368. # TODO see if we can use `get_app()` instead (no compile). Would _skip_compile still be needed then?
  369. _skip_compile()
  370. prerequisites.get_compiled_app()
  371. if not prerequisites.check_db_initialized():
  372. return
  373. model.Model.migrate()
  374. prerequisites.check_schema_up_to_date()
  375. @db_cli.command()
  376. def makemigrations(
  377. message: str = typer.Option(
  378. None, help="Human readable identifier for the generated revision."
  379. ),
  380. ):
  381. """Create autogenerated alembic migration scripts."""
  382. from alembic.util.exc import CommandError
  383. from reflex import model
  384. from reflex.utils import prerequisites
  385. # TODO see if we can use `get_app()` instead (no compile). Would _skip_compile still be needed then?
  386. _skip_compile()
  387. prerequisites.get_compiled_app()
  388. if not prerequisites.check_db_initialized():
  389. return
  390. with model.Model.get_db_engine().connect() as connection:
  391. try:
  392. model.Model.alembic_autogenerate(connection=connection, message=message)
  393. except CommandError as command_error:
  394. if "Target database is not up to date." not in str(command_error):
  395. raise
  396. console.error(
  397. f"{command_error} Run [bold]reflex db migrate[/bold] to update database."
  398. )
  399. @cli.command()
  400. def deploy(
  401. key: Optional[str] = typer.Option(
  402. None,
  403. "-k",
  404. "--deployment-key",
  405. help="The name of the deployment. Domain name safe characters only.",
  406. ),
  407. app_name: str = typer.Option(
  408. config.app_name,
  409. "--app-name",
  410. help="The name of the App to deploy under.",
  411. hidden=True,
  412. ),
  413. regions: List[str] = typer.Option(
  414. list(),
  415. "-r",
  416. "--region",
  417. help="The regions to deploy to.",
  418. ),
  419. envs: List[str] = typer.Option(
  420. list(),
  421. "--env",
  422. help="The environment variables to set: <key>=<value>. For multiple envs, repeat this option, e.g. --env k1=v2 --env k2=v2.",
  423. ),
  424. cpus: Optional[int] = typer.Option(
  425. None, help="The number of CPUs to allocate.", hidden=True
  426. ),
  427. memory_mb: Optional[int] = typer.Option(
  428. None, help="The amount of memory to allocate.", hidden=True
  429. ),
  430. auto_start: Optional[bool] = typer.Option(
  431. None,
  432. help="Whether to auto start the instance.",
  433. hidden=True,
  434. ),
  435. auto_stop: Optional[bool] = typer.Option(
  436. None,
  437. help="Whether to auto stop the instance.",
  438. hidden=True,
  439. ),
  440. frontend_hostname: Optional[str] = typer.Option(
  441. None,
  442. "--frontend-hostname",
  443. help="The hostname of the frontend.",
  444. hidden=True,
  445. ),
  446. interactive: bool = typer.Option(
  447. True,
  448. help="Whether to list configuration options and ask for confirmation.",
  449. ),
  450. with_metrics: Optional[str] = typer.Option(
  451. None,
  452. help="Setting for metrics scraping for the deployment. Setup required in user code.",
  453. hidden=True,
  454. ),
  455. with_tracing: Optional[str] = typer.Option(
  456. None,
  457. help="Setting to export tracing for the deployment. Setup required in user code.",
  458. hidden=True,
  459. ),
  460. upload_db_file: bool = typer.Option(
  461. False,
  462. help="Whether to include local sqlite db files when uploading to hosting service.",
  463. hidden=True,
  464. ),
  465. loglevel: constants.LogLevel = typer.Option(
  466. config.loglevel, help="The log level to use."
  467. ),
  468. ):
  469. """Deploy the app to the Reflex hosting service."""
  470. from reflex_cli import cli as hosting_cli
  471. from reflex.utils import export as export_utils
  472. from reflex.utils import prerequisites
  473. # Set the log level.
  474. console.set_log_level(loglevel)
  475. # Only check requirements if interactive. There is user interaction for requirements update.
  476. if interactive:
  477. dependency.check_requirements()
  478. # Check if we are set up.
  479. if prerequisites.needs_reinit(frontend=True):
  480. _init(name=config.app_name, loglevel=loglevel)
  481. prerequisites.check_latest_package_version(constants.ReflexHostingCLI.MODULE_NAME)
  482. hosting_cli.deploy(
  483. app_name=app_name,
  484. export_fn=lambda zip_dest_dir,
  485. api_url,
  486. deploy_url,
  487. frontend,
  488. backend,
  489. zipping: export_utils.export(
  490. zip_dest_dir=zip_dest_dir,
  491. api_url=api_url,
  492. deploy_url=deploy_url,
  493. frontend=frontend,
  494. backend=backend,
  495. zipping=zipping,
  496. loglevel=loglevel.subprocess_level(),
  497. upload_db_file=upload_db_file,
  498. ),
  499. key=key,
  500. regions=regions,
  501. envs=envs,
  502. cpus=cpus,
  503. memory_mb=memory_mb,
  504. auto_start=auto_start,
  505. auto_stop=auto_stop,
  506. frontend_hostname=frontend_hostname,
  507. interactive=interactive,
  508. with_metrics=with_metrics,
  509. with_tracing=with_tracing,
  510. loglevel=loglevel.subprocess_level(),
  511. )
  512. @cli.command()
  513. def deployv2(
  514. app_name: str = typer.Option(
  515. config.app_name,
  516. "--app-name",
  517. help="The name of the App to deploy under.",
  518. hidden=True,
  519. ),
  520. regions: List[str] = typer.Option(
  521. list(),
  522. "-r",
  523. "--region",
  524. help="The regions to deploy to. `reflex apps regions` For multiple envs, repeat this option, e.g. --region sjc --region iad",
  525. ),
  526. envs: List[str] = typer.Option(
  527. list(),
  528. "--env",
  529. help="The environment variables to set: <key>=<value>. For multiple envs, repeat this option, e.g. --env k1=v2 --env k2=v2.",
  530. ),
  531. vmtype: Optional[str] = typer.Option(
  532. None,
  533. "--vmtype",
  534. help="Vm type id. Run `reflex apps vmtypes` to get options.",
  535. ),
  536. hostname: Optional[str] = typer.Option(
  537. None,
  538. "--hostname",
  539. help="The hostname of the frontend.",
  540. ),
  541. interactive: bool = typer.Option(
  542. True,
  543. help="Whether to list configuration options and ask for confirmation.",
  544. ),
  545. envfile: Optional[str] = typer.Option(
  546. None,
  547. "--envfile",
  548. help="The path to an env file to use. Will override any envs set manually.",
  549. ),
  550. loglevel: constants.LogLevel = typer.Option(
  551. config.loglevel, help="The log level to use."
  552. ),
  553. project: Optional[str] = typer.Option(
  554. None,
  555. "--project",
  556. help="project id to deploy to",
  557. ),
  558. token: Optional[str] = typer.Option(
  559. None,
  560. "--token",
  561. help="token to use for auth",
  562. ),
  563. ):
  564. """Deploy the app to the Reflex hosting service."""
  565. # Set env mode in the environment
  566. # This must be set before importing modules that contain rx.State subclasses
  567. set_env_mode(constants.Env.PROD)
  568. from reflex_cli.v2 import cli as hosting_cli
  569. from reflex_cli.v2.utils import dependency
  570. from reflex.utils import export as export_utils
  571. from reflex.utils import prerequisites
  572. check_version()
  573. # Set the log level.
  574. console.set_log_level(loglevel)
  575. # Only check requirements if interactive.
  576. # There is user interaction for requirements update.
  577. if interactive:
  578. dependency.check_requirements()
  579. # Check if we are set up.
  580. if prerequisites.needs_reinit(frontend=True):
  581. _init(name=config.app_name, loglevel=loglevel)
  582. prerequisites.check_latest_package_version(constants.ReflexHostingCLI.MODULE_NAME)
  583. hosting_cli.deploy(
  584. app_name=app_name,
  585. export_fn=lambda zip_dest_dir,
  586. api_url,
  587. deploy_url,
  588. frontend,
  589. backend,
  590. zipping: export_utils.export(
  591. zip_dest_dir=zip_dest_dir,
  592. api_url=api_url,
  593. deploy_url=deploy_url,
  594. frontend=frontend,
  595. backend=backend,
  596. zipping=zipping,
  597. loglevel=loglevel.subprocess_level(),
  598. ),
  599. regions=regions,
  600. envs=envs,
  601. vmtype=vmtype,
  602. envfile=envfile,
  603. hostname=hostname,
  604. interactive=interactive,
  605. loglevel=loglevel.subprocess_level(),
  606. token=token,
  607. project=project,
  608. )
  609. cli.add_typer(db_cli, name="db", help="Subcommands for managing the database schema.")
  610. cli.add_typer(script_cli, name="script", help="Subcommands running helper scripts.")
  611. cli.add_typer(
  612. deployments_cli,
  613. name="deployments",
  614. help="Subcommands for managing the Deployments.",
  615. )
  616. cli.add_typer(
  617. hosting_cli,
  618. name="apps",
  619. help="Subcommands for managing the Deployments.",
  620. )
  621. cli.add_typer(
  622. custom_components_cli,
  623. name="component",
  624. help="Subcommands for creating and publishing Custom Components.",
  625. )
  626. if __name__ == "__main__":
  627. cli()