Add template version check (#164)

This commit is contained in:
Nikhil Rao 2022-12-21 20:05:02 -08:00 committed by GitHub
parent 974d2b4cbb
commit 0bc09dc961
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 1 deletions

View File

@ -0,0 +1 @@
0.1.11

View File

@ -50,6 +50,11 @@ WEB_ASSETS_DIR = os.path.join(WEB_DIR, "public")
NODE_MODULES = "node_modules"
# The package lock file.
PACKAGE_LOCK = "package-lock.json"
# The pcversion template file.
PCVERSION_TEMPLATE_FILE = os.path.join(WEB_TEMPLATE_DIR, "pcversion.txt")
# The pcversion app file.
PCVERSION_APP_FILE = os.path.join(WEB_DIR, "pcversion.txt")
# Commands to run the app.
# The backend api url.

View File

@ -70,6 +70,13 @@ def run(
)
raise typer.Exit()
# Check that the template is up to date.
if not utils.is_latest_template():
utils.console.print(
"[red]The base app template has updated. Run [bold]pc init[/bold] again."
)
raise typer.Exit()
# Get the app module.
utils.console.rule("[bold]Starting Pynecone App")
app = utils.get_app()

View File

@ -437,6 +437,19 @@ def is_initialized() -> bool:
return os.path.exists(constants.CONFIG_FILE) and os.path.exists(constants.WEB_DIR)
def is_latest_template() -> bool:
"""Whether the app is using the latest template.
Returns:
Whether the app is using the latest template.
"""
template_version = open(constants.PCVERSION_TEMPLATE_FILE).read()
if not os.path.exists(constants.PCVERSION_APP_FILE):
return False
app_version = open(constants.PCVERSION_APP_FILE).read()
return app_version >= template_version
def export_app(app: App, zip: bool = False):
"""Zip up the app for deployment.

View File

@ -1,6 +1,6 @@
[tool.poetry]
name = "pynecone-io"
version = "0.1.10"
version = "0.1.11"
description = "The easiest way to build web apps."
license = "Apache-2.0"
authors = [