Add template version check (#164)
This commit is contained in:
parent
974d2b4cbb
commit
0bc09dc961
1
pynecone/.templates/web/pcversion.txt
Normal file
1
pynecone/.templates/web/pcversion.txt
Normal file
@ -0,0 +1 @@
|
||||
0.1.11
|
@ -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.
|
||||
|
@ -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()
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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 = [
|
||||
|
Loading…
Reference in New Issue
Block a user