88import click
99from os .path import abspath , dirname , exists , isdir , join
1010from functools import wraps
11+ from typing import Optional
1112
1213from rsconnect .certificates import read_certificate_file
1314
6566from .log import logger , LogOutputFormat
6667from .metadata import ServerStore , AppStore
6768from .models import (
69+ AppMode ,
6870 AppModes ,
6971 BuildStatus ,
7072 ContentGuidWithBundleParamType ,
@@ -1274,18 +1276,22 @@ def deploy_html(
12741276 ce .verify_deployment ()
12751277
12761278
1277- def generate_deploy_python (app_mode , alias , min_version ):
1279+ def generate_deploy_python (app_mode : AppMode , alias : str , min_version : str , desc : Optional [str ] = None ):
1280+
1281+ if desc is None :
1282+ desc = app_mode .desc ()
1283+
12781284 # noinspection SpellCheckingInspection
12791285 @deploy .command (
12801286 name = alias ,
12811287 short_help = "Deploy a {desc} to Posit Connect [v{version}+], Posit Cloud, or shinyapps.io." .format (
1282- desc = app_mode . desc () ,
1288+ desc = desc ,
12831289 version = min_version ,
12841290 ),
12851291 help = (
12861292 "Deploy a {desc} module to Posit Connect, Posit Cloud, or shinyapps.io (if supported by the platform). "
12871293 'The "directory" argument must refer to an existing directory that contains the application code.'
1288- ).format (desc = app_mode . desc () ),
1294+ ).format (desc = desc ),
12891295 no_args_is_help = True ,
12901296 )
12911297 @server_args
@@ -1297,7 +1303,7 @@ def generate_deploy_python(app_mode, alias, min_version):
12971303 "-e" ,
12981304 help = (
12991305 "The module and executable object which serves as the entry point for the {desc} (defaults to app)"
1300- ).format (desc = app_mode . desc () ),
1306+ ).format (desc = desc ),
13011307 )
13021308 @click .option (
13031309 "--exclude" ,
@@ -1395,14 +1401,13 @@ def deploy_app(
13951401 return deploy_app
13961402
13971403
1398- deploy_api = generate_deploy_python (app_mode = AppModes .PYTHON_API , alias = "api" , min_version = "1.8.2" )
1399- # TODO: set fastapi min_version correctly
1400- # deploy_fastapi = generate_deploy_python(app_mode=AppModes.PYTHON_FASTAPI, alias="fastapi", min_version="2021.08.0")
1401- deploy_fastapi = generate_deploy_python (app_mode = AppModes .PYTHON_FASTAPI , alias = "fastapi" , min_version = "2021.08.0" )
1402- deploy_dash_app = generate_deploy_python (app_mode = AppModes .DASH_APP , alias = "dash" , min_version = "1.8.2" )
1403- deploy_streamlit_app = generate_deploy_python (app_mode = AppModes .STREAMLIT_APP , alias = "streamlit" , min_version = "1.8.4" )
1404- deploy_bokeh_app = generate_deploy_python (app_mode = AppModes .BOKEH_APP , alias = "bokeh" , min_version = "1.8.4" )
1405- deploy_shiny = generate_deploy_python (app_mode = AppModes .PYTHON_SHINY , alias = "shiny" , min_version = "2022.07.0" )
1404+ generate_deploy_python (app_mode = AppModes .PYTHON_API , alias = "api" , min_version = "1.8.2" )
1405+ generate_deploy_python (app_mode = AppModes .PYTHON_API , alias = "flask" , min_version = "1.8.2" , desc = "Flask API" )
1406+ generate_deploy_python (app_mode = AppModes .PYTHON_FASTAPI , alias = "fastapi" , min_version = "2021.08.0" )
1407+ generate_deploy_python (app_mode = AppModes .DASH_APP , alias = "dash" , min_version = "1.8.2" )
1408+ generate_deploy_python (app_mode = AppModes .STREAMLIT_APP , alias = "streamlit" , min_version = "1.8.4" )
1409+ generate_deploy_python (app_mode = AppModes .BOKEH_APP , alias = "bokeh" , min_version = "1.8.4" )
1410+ generate_deploy_python (app_mode = AppModes .PYTHON_SHINY , alias = "shiny" , min_version = "2022.07.0" )
14061411
14071412
14081413@deploy .command (
@@ -1734,24 +1739,27 @@ def write_manifest_quarto(
17341739 )
17351740
17361741
1737- def generate_write_manifest_python (app_mode , alias ):
1742+ def generate_write_manifest_python (app_mode , alias , desc : Optional [str ] = None ):
1743+ if desc is None :
1744+ desc = app_mode .desc ()
1745+
17381746 # noinspection SpellCheckingInspection
17391747 @write_manifest .command (
17401748 name = alias ,
1741- short_help = "Create a manifest.json file for a {desc}." .format (desc = app_mode . desc () ),
1749+ short_help = "Create a manifest.json file for a {desc}." .format (desc = desc ),
17421750 help = (
17431751 "Create a manifest.json file for a {desc} for later deployment. This will create an "
17441752 'environment file ("requirements.txt") if one does not exist. All files '
17451753 "are created in the same directory as the API code."
1746- ).format (desc = app_mode . desc () ),
1754+ ).format (desc = desc ),
17471755 )
17481756 @click .option ("--overwrite" , "-o" , is_flag = True , help = "Overwrite manifest.json, if it exists." )
17491757 @click .option (
17501758 "--entrypoint" ,
17511759 "-e" ,
17521760 help = (
17531761 "The module and executable object which serves as the entry point for the {desc} (defaults to app)"
1754- ).format (desc = app_mode . desc () ),
1762+ ).format (desc = desc ),
17551763 )
17561764 @click .option (
17571765 "--exclude" ,
@@ -1816,12 +1824,13 @@ def manifest_writer(
18161824 return manifest_writer
18171825
18181826
1819- write_manifest_api = generate_write_manifest_python (AppModes .PYTHON_API , alias = "api" )
1820- write_manifest_fastapi = generate_write_manifest_python (AppModes .PYTHON_FASTAPI , alias = "fastapi" )
1821- write_manifest_dash = generate_write_manifest_python (AppModes .DASH_APP , alias = "dash" )
1822- write_manifest_streamlit = generate_write_manifest_python (AppModes .STREAMLIT_APP , alias = "streamlit" )
1823- write_manifest_bokeh = generate_write_manifest_python (AppModes .BOKEH_APP , alias = "bokeh" )
1824- write_manifest_shiny = generate_write_manifest_python (AppModes .PYTHON_SHINY , alias = "shiny" )
1827+ generate_write_manifest_python (AppModes .BOKEH_APP , alias = "bokeh" )
1828+ generate_write_manifest_python (AppModes .DASH_APP , alias = "dash" )
1829+ generate_write_manifest_python (AppModes .PYTHON_API , alias = "api" )
1830+ generate_write_manifest_python (AppModes .PYTHON_API , alias = "flask" , desc = "Flask API" )
1831+ generate_write_manifest_python (AppModes .PYTHON_FASTAPI , alias = "fastapi" )
1832+ generate_write_manifest_python (AppModes .PYTHON_SHINY , alias = "shiny" )
1833+ generate_write_manifest_python (AppModes .STREAMLIT_APP , alias = "streamlit" )
18251834
18261835
18271836# noinspection SpellCheckingInspection
0 commit comments