support exporting to zip archives to a dir that is not cwd (to be used by hosting cli) (#2005)

This commit is contained in:
jackie-pc 2023-10-20 09:40:30 -07:00 committed by GitHub
parent 7b8b64668d
commit c653f95435
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -113,6 +113,7 @@ def export(
backend: bool = True, backend: bool = True,
frontend: bool = True, frontend: bool = True,
zip: bool = False, zip: bool = False,
zip_dest_dir: str = os.getcwd(),
deploy_url: str | None = None, deploy_url: str | None = None,
): ):
"""Export the app for deployment. """Export the app for deployment.
@ -121,6 +122,7 @@ def export(
backend: Whether to zip up the backend app. backend: Whether to zip up the backend app.
frontend: Whether to zip up the frontend app. frontend: Whether to zip up the frontend app.
zip: Whether to zip the app. zip: Whether to zip the app.
zip_dest_dir: The destination directory for created zip files (if any)
deploy_url: The URL of the deployed app. deploy_url: The URL of the deployed app.
""" """
# Remove the static folder. # Remove the static folder.
@ -163,14 +165,18 @@ def export(
if frontend: if frontend:
_zip( _zip(
component_name=constants.ComponentName.FRONTEND, component_name=constants.ComponentName.FRONTEND,
target=constants.ComponentName.FRONTEND.zip(), target=os.path.join(
zip_dest_dir, constants.ComponentName.FRONTEND.zip()
),
root_dir=".web/_static", root_dir=".web/_static",
files_to_exclude=files_to_exclude, files_to_exclude=files_to_exclude,
) )
if backend: if backend:
_zip( _zip(
component_name=constants.ComponentName.BACKEND, component_name=constants.ComponentName.BACKEND,
target=constants.ComponentName.BACKEND.zip(), target=os.path.join(
zip_dest_dir, constants.ComponentName.BACKEND.zip()
),
root_dir=".", root_dir=".",
dirs_to_exclude={"assets", "__pycache__"}, dirs_to_exclude={"assets", "__pycache__"},
files_to_exclude=files_to_exclude, files_to_exclude=files_to_exclude,