Nikhil Rao 2 лет назад
Родитель
Сommit
0bc09dc961
5 измененных файлов с 27 добавлено и 1 удалено
  1. 1 0
      pynecone/.templates/web/pcversion.txt
  2. 5 0
      pynecone/constants.py
  3. 7 0
      pynecone/pc.py
  4. 13 0
      pynecone/utils.py
  5. 1 1
      pyproject.toml

+ 1 - 0
pynecone/.templates/web/pcversion.txt

@@ -0,0 +1 @@
+0.1.11

+ 5 - 0
pynecone/constants.py

@@ -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.

+ 7 - 0
pynecone/pc.py

@@ -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()

+ 13 - 0
pynecone/utils.py

@@ -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 - 1
pyproject.toml

@@ -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 = [