Add --no-zip pc CLI Parameter (#479)

This commit is contained in:
Robert Neumann 2023-02-08 23:39:38 +01:00 committed by GitHub
parent 60949e24e6
commit fdf0e9ea6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 8 deletions

View File

@ -150,7 +150,11 @@ def deploy(dry_run: bool = typer.Option(False, help="Whether to run a dry run.")
@cli.command()
def export():
def export(
zipping: bool = typer.Option(
True, "--no-zip", help="Disable zip for backend and frontend exports."
)
):
"""Export the app to a zip file."""
# Get the app config.
config = utils.get_config()
@ -159,10 +163,17 @@ def export():
# Compile the app in production mode and export it.
utils.console.rule("[bold]Compiling production app and preparing for export.")
app = utils.get_app().app
utils.export_app(app, zip=True)
utils.console.rule(
"Backend & Frontend compiled. See [green bold]backend.zip[/green bold] and [green bold]frontend.zip[/green bold]."
)
utils.export_app(app, zip=zipping)
if zipping:
utils.console.rule(
"""Backend & Frontend compiled. See [green bold]backend.zip[/green bold]
and [green bold]frontend.zip[/green bold]."""
)
else:
utils.console.rule(
"""Backend & Frontend compiled. See [green bold]app[/green bold]
and [green bold].web/_static[/green bold] directories."""
)
main = cli

View File

@ -500,7 +500,10 @@ def export_app(app: App, zip: bool = False):
# Zip up the app.
if zip:
cmd = r"cd .web/_static && zip -r ../../frontend.zip ./* && cd ../.. && zip -r backend.zip ./* -x .web/\* ./assets\* ./frontend.zip\* ./backend.zip\*"
if os.name == "posix":
cmd = r"cd .web/_static && zip -r ../../frontend.zip ./* && cd ../.. && zip -r backend.zip ./* -x .web/\* ./assets\* ./frontend.zip\* ./backend.zip\*"
if os.name == "nt":
cmd = r'powershell -Command "Set-Location .web/_static; Compress-Archive -Path .\* -DestinationPath ..\..\frontend.zip; Set-Location ..\..; Compress-Archive -Path .\* -DestinationPath backend.zip -Exclude .web\*, assets\*, frontend.zip, backend.zip"'
os.system(cmd)

View File

@ -27,7 +27,6 @@ def component1() -> Type[Component]:
"""
class TestComponent1(Component):
# A test string prop.
text: Var[str]
@ -52,7 +51,6 @@ def component2() -> Type[Component]:
"""
class TestComponent2(Component):
# A test list prop.
arr: Var[List[str]]