Fix sitemap output dir (#1382)

This commit is contained in:
Nikhil Rao 2023-07-19 17:55:52 -07:00 committed by GitHub
parent 23fa6d5ec4
commit d1924bb4a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 16 deletions

View File

@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "reflex" name = "reflex"
version = "0.2.0" version = "0.2.1"
description = "Web apps in pure Python." description = "Web apps in pure Python."
license = "Apache-2.0" license = "Apache-2.0"
authors = [ authors = [

View File

@ -3,6 +3,7 @@
"scripts": { "scripts": {
"dev": "next dev", "dev": "next dev",
"export": "next build && next export -o _static", "export": "next build && next export -o _static",
"export-sitemap": "next build && next-sitemap && next export -o _static",
"prod": "next start" "prod": "next start"
}, },
"dependencies": { "dependencies": {

View File

@ -69,6 +69,8 @@ JINJA_TEMPLATE_DIR = os.path.join(TEMPLATE_DIR, "jinja")
WEB_DIR = ".web" WEB_DIR = ".web"
# The name of the utils file. # The name of the utils file.
UTILS_DIR = "utils" UTILS_DIR = "utils"
# The name of the output static directory.
STATIC_DIR = "_static"
# The name of the state file. # The name of the state file.
STATE_PATH = "/".join([UTILS_DIR, "state"]) STATE_PATH = "/".join([UTILS_DIR, "state"])
# The name of the components file. # 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. # The directory where the app pages are compiled to.
WEB_PAGES_DIR = os.path.join(WEB_DIR, "pages") WEB_PAGES_DIR = os.path.join(WEB_DIR, "pages")
# The directory where the static build is located. # 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. # The directory where the utils file is located.
WEB_UTILS_DIR = os.path.join(WEB_DIR, UTILS_DIR) WEB_UTILS_DIR = os.path.join(WEB_DIR, UTILS_DIR)
# The directory where the assets are located. # The directory where the assets are located.

View File

@ -86,15 +86,6 @@ def generate_sitemap_config(deploy_url: str):
f.write(templates.SITEMAP_CONFIG(config=config)) 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( def export_app(
backend: bool = True, backend: bool = True,
frontend: bool = True, frontend: bool = True,
@ -115,8 +106,10 @@ def export_app(
path_ops.rm(constants.WEB_STATIC_DIR) path_ops.rm(constants.WEB_STATIC_DIR)
# Generate the sitemap file. # Generate the sitemap file.
command = "export"
if deploy_url is not None: if deploy_url is not None:
generate_sitemap_config(deploy_url) generate_sitemap_config(deploy_url)
command = "export-sitemap"
# Create a progress object # Create a progress object
progress = Progress( progress = Progress(
@ -143,7 +136,7 @@ def export_app(
# Start the subprocess with the progress bar. # Start the subprocess with the progress bar.
try: try:
with progress, new_process( with progress, new_process(
[prerequisites.get_package_manager(), "run", "export"], [prerequisites.get_package_manager(), "run", command],
cwd=constants.WEB_DIR, cwd=constants.WEB_DIR,
) as export_process: ) as export_process:
assert export_process.stdout is not None, "No stdout for export process." assert export_process.stdout is not None, "No stdout for export process."
@ -168,10 +161,6 @@ def export_app(
) )
os._exit(1) os._exit(1)
# Generate the actual sitemap.
if deploy_url is not None:
generate_sitemap()
# Zip up the app. # Zip up the app.
if zip: if zip:
if os.name == "posix": if os.name == "posix":