From 5b0d77a445f348151e0a5985cf7da3ad8dda7a80 Mon Sep 17 00:00:00 2001 From: Mateusz Russak Date: Tue, 15 Oct 2024 19:34:03 +0200 Subject: [PATCH 1/3] feat: add deploy alias --- src/writer/command_line.py | 19 ++++++++++++++++++- src/writer/deploy.py | 5 +++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/writer/command_line.py b/src/writer/command_line.py index 6bf8962f6..e28e2e58b 100644 --- a/src/writer/command_line.py +++ b/src/writer/command_line.py @@ -7,7 +7,7 @@ import click import writer.serve -from writer.deploy import cloud +from writer.deploy import cloud, deploy_app CONTEXT_SETTINGS = {'help_option_names': ['-h', '--help']} @click.group( @@ -73,6 +73,23 @@ def hello(port: Optional[int], host: str, enable_remote_edit): enable_server_setup=False) +@main.command() +@click.option('--api-key', + default=lambda: os.environ.get("WRITER_API_KEY", None), + allow_from_autoenv=True, + show_envvar=True, + envvar='WRITER_API_KEY', + prompt="Enter your API key", + hide_input=True, help="Writer API key" +) +@click.option('--env', '-e', multiple=True, default=[], help="Environment to deploy the app to") +@click.option('--force', '-f', default=False, is_flag=True, help="Ignores warnings and overwrites the app") +@click.option('--verbose', '-v', default=False, is_flag=True, help="Enable verbose mode") +@click.argument('path') +def deploy(path, api_key, env, verbose, force): + """Deploy the app from PATH folder.""" + deploy_app(path, api_key, env, verbose, force) + main.add_command(cloud) def create_app(app_path: str, template_name: Optional[str], overwrite=False): diff --git a/src/writer/deploy.py b/src/writer/deploy.py index dfba5ba57..96803004c 100644 --- a/src/writer/deploy.py +++ b/src/writer/deploy.py @@ -37,6 +37,11 @@ def cloud(): def deploy(path, api_key, env, verbose, force): """Deploy the app from PATH folder.""" + deploy_app(path, api_key, env, verbose, force) + +def deploy_app(path, api_key, env, verbose, force): + """Deploy the app from PATH folder.""" + deploy_url = os.getenv("WRITER_DEPLOY_URL", "https://api.writer.com/v1/deployment/apps") sleep_interval = int(os.getenv("WRITER_DEPLOY_SLEEP_INTERVAL", '5')) From a318f2fda79ead916a04b9e0aebdd654ca0bbfb8 Mon Sep 17 00:00:00 2001 From: Mateusz Russak Date: Mon, 21 Oct 2024 18:08:43 +0200 Subject: [PATCH 2/3] fix: deploy alias --- src/writer/command_line.py | 20 ++------------------ src/writer/deploy.py | 7 +------ 2 files changed, 3 insertions(+), 24 deletions(-) diff --git a/src/writer/command_line.py b/src/writer/command_line.py index e28e2e58b..1255f5240 100644 --- a/src/writer/command_line.py +++ b/src/writer/command_line.py @@ -7,7 +7,7 @@ import click import writer.serve -from writer.deploy import cloud, deploy_app +from writer.deploy import cloud, deploy CONTEXT_SETTINGS = {'help_option_names': ['-h', '--help']} @click.group( @@ -73,23 +73,7 @@ def hello(port: Optional[int], host: str, enable_remote_edit): enable_server_setup=False) -@main.command() -@click.option('--api-key', - default=lambda: os.environ.get("WRITER_API_KEY", None), - allow_from_autoenv=True, - show_envvar=True, - envvar='WRITER_API_KEY', - prompt="Enter your API key", - hide_input=True, help="Writer API key" -) -@click.option('--env', '-e', multiple=True, default=[], help="Environment to deploy the app to") -@click.option('--force', '-f', default=False, is_flag=True, help="Ignores warnings and overwrites the app") -@click.option('--verbose', '-v', default=False, is_flag=True, help="Enable verbose mode") -@click.argument('path') -def deploy(path, api_key, env, verbose, force): - """Deploy the app from PATH folder.""" - deploy_app(path, api_key, env, verbose, force) - +main.add_command(deploy, name="deploy") main.add_command(cloud) def create_app(app_path: str, template_name: Optional[str], overwrite=False): diff --git a/src/writer/deploy.py b/src/writer/deploy.py index 96803004c..b733134ef 100644 --- a/src/writer/deploy.py +++ b/src/writer/deploy.py @@ -30,18 +30,13 @@ def cloud(): prompt="Enter your API key", hide_input=True, help="Writer API key" ) -@click.option('--env', '-e', multiple=True, default=[], help="Environment to deploy the app to") +@click.option('--env', '-e', multiple=True, default=[], help="Environment variable to deploy the app to") @click.option('--force', '-f', default=False, is_flag=True, help="Ignores warnings and overwrites the app") @click.option('--verbose', '-v', default=False, is_flag=True, help="Enable verbose mode") @click.argument('path') def deploy(path, api_key, env, verbose, force): """Deploy the app from PATH folder.""" - deploy_app(path, api_key, env, verbose, force) - -def deploy_app(path, api_key, env, verbose, force): - """Deploy the app from PATH folder.""" - deploy_url = os.getenv("WRITER_DEPLOY_URL", "https://api.writer.com/v1/deployment/apps") sleep_interval = int(os.getenv("WRITER_DEPLOY_SLEEP_INTERVAL", '5')) From ea0807d539bce25520d6d1a790369d270e9a9e88 Mon Sep 17 00:00:00 2001 From: Mateusz Russak Date: Tue, 22 Oct 2024 14:37:59 +0200 Subject: [PATCH 3/3] Update src/writer/deploy.py Co-authored-by: Ramiro Medina <64783088+ramedina86@users.noreply.github.com> --- src/writer/deploy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/writer/deploy.py b/src/writer/deploy.py index b733134ef..6fc479e4e 100644 --- a/src/writer/deploy.py +++ b/src/writer/deploy.py @@ -30,7 +30,7 @@ def cloud(): prompt="Enter your API key", hide_input=True, help="Writer API key" ) -@click.option('--env', '-e', multiple=True, default=[], help="Environment variable to deploy the app to") +@click.option('--env', '-e', multiple=True, default=[], help="Set environment variables for the app (e.g., --env KEY=VALUE)") @click.option('--force', '-f', default=False, is_flag=True, help="Ignores warnings and overwrites the app") @click.option('--verbose', '-v', default=False, is_flag=True, help="Enable verbose mode") @click.argument('path')