check_initialized: skip REFLEX_DIR check for backend only (#1478)

This commit is contained in:
Masen Furer 2023-08-02 06:33:56 -07:00 committed by GitHub
parent deef553e82
commit 919f239168
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 42 additions and 24 deletions

View File

@ -59,10 +59,21 @@ jobs:
working-directory: ./reflex-examples/counter
run: |
poetry run pip install -r requirements.txt
- name: Check export --backend-only before init for counter example
working-directory: ./reflex-examples/counter
run: |
poetry run reflex export --backend-only
- name: Check run --backend-only before init for counter example
run: |
poetry run bash scripts/integration.sh ./reflex-examples/counter dev 8001 --backend-only --backend-port 8001
- name: Init Website for counter example
working-directory: ./reflex-examples/counter
run: |
poetry run reflex init --loglevel debug
- name: Check export for counter example
working-directory: ./reflex-examples/counter
run: |
poetry run reflex export
- name: Run Website and Check for errors
run: |
# Check that npm is home

View File

@ -11,4 +11,4 @@ echo "Installing reflex from local repo code"
cd /reflex-repo
poetry install
echo "Running reflex init in test project dir"
poetry run /bin/bash -c "cd ~/hello && reflex init"
poetry run /bin/bash -c "cd ~/hello && reflex init && rm -rf ~/.reflex .web && reflex export --backend-only"

View File

@ -108,24 +108,24 @@ def export(
generate_sitemap_config(deploy_url)
command = "export-sitemap"
checkpoints = [
"Linting and checking ",
"Compiled successfully",
"Route (pages)",
"Collecting page data",
"automatically rendered as static HTML",
'Copying "static build" directory',
'Copying "public" directory',
"Finalizing page optimization",
"Export successful",
]
# Start the subprocess with the progress bar.
process = processes.new_process(
[prerequisites.get_package_manager(), "run", command],
cwd=constants.WEB_DIR,
)
processes.show_progress("Creating Production Build", process, checkpoints)
if frontend:
checkpoints = [
"Linting and checking ",
"Compiled successfully",
"Route (pages)",
"Collecting page data",
"automatically rendered as static HTML",
'Copying "static build" directory',
'Copying "public" directory',
"Finalizing page optimization",
"Export successful",
]
# Start the subprocess with the progress bar.
process = processes.new_process(
[prerequisites.get_package_manager(), "run", command],
cwd=constants.WEB_DIR,
)
processes.show_progress("Creating Production Build", process, checkpoints)
# Zip up the app.
if zip:

View File

@ -398,7 +398,7 @@ def check_initialized(frontend: bool = True):
Exit: If the app is not initialized.
"""
has_config = os.path.exists(constants.CONFIG_FILE)
has_reflex_dir = IS_WINDOWS or os.path.exists(constants.REFLEX_DIR)
has_reflex_dir = not frontend or IS_WINDOWS or os.path.exists(constants.REFLEX_DIR)
has_web_dir = not frontend or os.path.exists(constants.WEB_DIR)
# Check if the app is initialized.

View File

@ -1,14 +1,21 @@
#!/bin/bash
# Change directory to the first argument passed to the script
pushd "$1" || exit 1
echo "Changed directory to $1"
project_dir=$1
shift
pushd "$project_dir" || exit 1
echo "Changed directory to $project_dir"
# So we get stdout / stderr from Python ASAP. Without this, delays can be very long (e.g. on Windows, Github Actions)
export PYTHONUNBUFFERED=1
env_mode=$1
shift
check_ports=${1:-3000 8000}
shift
# Start the server in the background
reflex run --loglevel debug --env "$2" & pid=$!
reflex run --loglevel debug --env "$env_mode" "$@" & pid=$!
# Within the context of this bash, $pid_in_bash is what we need to pass to "kill" on exit
# This is true on all platforms.
@ -26,4 +33,4 @@ if [ -f /proc/$pid/winpid ]; then
echo "Windows detected, passing winpid $pid to port waiter"
fi
python scripts/wait_for_listening_port.py 3000 8000 --timeout=600 --server-pid "$pid"
python scripts/wait_for_listening_port.py 3000 8000 --timeout=600 --server-pid "$pid"