From d1924bb4a61354b58bb223727de64d37ea6f4cfb Mon Sep 17 00:00:00 2001 From: Nikhil Rao <nikhil@pynecone.io> Date: Wed, 19 Jul 2023 17:55:52 -0700 Subject: [PATCH] Fix sitemap output dir (#1382) --- pyproject.toml | 2 +- reflex/.templates/web/package.json | 1 + reflex/constants.py | 4 +++- reflex/utils/build.py | 17 +++-------------- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f26a7348f..89241a975 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "reflex" -version = "0.2.0" +version = "0.2.1" description = "Web apps in pure Python." license = "Apache-2.0" authors = [ diff --git a/reflex/.templates/web/package.json b/reflex/.templates/web/package.json index 80d466822..b1ab8b666 100644 --- a/reflex/.templates/web/package.json +++ b/reflex/.templates/web/package.json @@ -3,6 +3,7 @@ "scripts": { "dev": "next dev", "export": "next build && next export -o _static", + "export-sitemap": "next build && next-sitemap && next export -o _static", "prod": "next start" }, "dependencies": { diff --git a/reflex/constants.py b/reflex/constants.py index 51210fdce..d64138dfa 100644 --- a/reflex/constants.py +++ b/reflex/constants.py @@ -69,6 +69,8 @@ JINJA_TEMPLATE_DIR = os.path.join(TEMPLATE_DIR, "jinja") WEB_DIR = ".web" # The name of the utils file. UTILS_DIR = "utils" +# The name of the output static directory. +STATIC_DIR = "_static" # The name of the state file. STATE_PATH = "/".join([UTILS_DIR, "state"]) # The name of the components file. @@ -76,7 +78,7 @@ COMPONENTS_PATH = "/".join([UTILS_DIR, "components"]) # The directory where the app pages are compiled to. WEB_PAGES_DIR = os.path.join(WEB_DIR, "pages") # The directory where the static build is located. -WEB_STATIC_DIR = os.path.join(WEB_DIR, "_static") +WEB_STATIC_DIR = os.path.join(WEB_DIR, STATIC_DIR) # The directory where the utils file is located. WEB_UTILS_DIR = os.path.join(WEB_DIR, UTILS_DIR) # The directory where the assets are located. diff --git a/reflex/utils/build.py b/reflex/utils/build.py index bf36f858f..d2d9d0110 100644 --- a/reflex/utils/build.py +++ b/reflex/utils/build.py @@ -86,15 +86,6 @@ def generate_sitemap_config(deploy_url: str): f.write(templates.SITEMAP_CONFIG(config=config)) -def generate_sitemap(): - """Generate the actual sitemap.""" - subprocess.run( - [prerequisites.get_package_manager(), "run", "next-sitemap"], - cwd=constants.WEB_DIR, - stdout=subprocess.PIPE, - ) - - def export_app( backend: bool = True, frontend: bool = True, @@ -115,8 +106,10 @@ def export_app( path_ops.rm(constants.WEB_STATIC_DIR) # Generate the sitemap file. + command = "export" if deploy_url is not None: generate_sitemap_config(deploy_url) + command = "export-sitemap" # Create a progress object progress = Progress( @@ -143,7 +136,7 @@ def export_app( # Start the subprocess with the progress bar. try: with progress, new_process( - [prerequisites.get_package_manager(), "run", "export"], + [prerequisites.get_package_manager(), "run", command], cwd=constants.WEB_DIR, ) as export_process: assert export_process.stdout is not None, "No stdout for export process." @@ -168,10 +161,6 @@ def export_app( ) os._exit(1) - # Generate the actual sitemap. - if deploy_url is not None: - generate_sitemap() - # Zip up the app. if zip: if os.name == "posix":