ソースを参照

build frontend bundles before tests

Fred Lefévère-Laoide 1 年間 前
コミット
50ff164131

+ 0 - 1
frontend/taipy-gui/dom/package-lock.json

@@ -14,7 +14,6 @@
       }
     },
     "../packaging": {
-      "name": "taipy-gui",
       "version": "3.1.0"
     },
     "node_modules/js-tokens": {

ファイルの差分が大きいため隠しています
+ 349 - 202
frontend/taipy-gui/package-lock.json


+ 2 - 2
frontend/taipy-gui/webpack.config.js

@@ -63,7 +63,7 @@ module.exports = (env, options) => {
         {
             mode: options.mode, //'development', //'production',
             name: taipyBundleName,
-            entry: ["./extensions/exports.ts"],
+            entry: ["./src/extensions/exports.ts"],
             output: {
                 filename: taipyBundle + ".js",
                 path: webAppPath,
@@ -111,7 +111,7 @@ module.exports = (env, options) => {
         {
             mode: options.mode, //'development', //'production',
             context: resolveApp("dom"),
-            entry: ["./index.tsx"],
+            entry: ["./src/index.tsx"],
             output: {
                 filename: "taipy-gui-dom.js",
                 path: webAppPath,

+ 6 - 2
frontend/taipy/package-lock.json

@@ -21,7 +21,7 @@
         "formik": "^2.2.9",
         "react": "^18.2.0",
         "react-dom": "^18.2.0",
-        "taipy-gui": "file:../../../.virtualenvs/taipy-OW_uNObx/Lib/site-packages/taipy/gui/webapp"
+        "taipy-gui": "file:../../taipy/gui/webapp"
       },
       "devDependencies": {
         "@types/react": "^18.0.15",
@@ -42,6 +42,10 @@
     },
     "../../../.virtualenvs/taipy-OW_uNObx/Lib/site-packages/taipy/gui/webapp": {
       "name": "taipy-gui",
+      "version": "3.1.0",
+      "extraneous": true
+    },
+    "../../taipy/gui/webapp": {
       "version": "3.1.0"
     },
     "node_modules/@aashutoshrathi/word-wrap": {
@@ -4915,7 +4919,7 @@
       }
     },
     "node_modules/taipy-gui": {
-      "resolved": "../../../.virtualenvs/taipy-OW_uNObx/Lib/site-packages/taipy/gui/webapp",
+      "resolved": "../../taipy/gui/webapp",
       "link": true
     },
     "node_modules/tapable": {

+ 39 - 0
tools/frontend/bundle_build.py

@@ -0,0 +1,39 @@
+import os
+import sys
+from pathlib import Path
+
+
+def build_gui(root_path):
+    print(f"Building taipy-gui frontend bundle in {root_path}.")
+    already_exists = (root_path / "taipy" / "gui" / "webapp" / "index.html").exists()
+    if already_exists:
+        print(f'Found taipy-gui frontend bundle in {root_path  / "taipy" / "gui" / "webapp"}.')
+    else:
+        os.system("cd frontend/taipy-gui/dom && npm ci")
+        os.system("cd frontend/taipy-gui && npm ci --omit=optional && npm run build")
+
+
+def build_taipy(root_path):
+    print(f"Building taipy frontend bundle in {root_path}.")
+    already_exists = (root_path / "taipy" / "gui_core" / "lib" / "taipy-gui-core.js").exists()
+    if already_exists:
+        print(f'Found taipy frontend bundle in {root_path / "taipy" / "gui_core" / "lib"}.')
+    else:
+        # Specify the correct path to taipy-gui in gui/.env file
+        env_file_path = root_path / "frontend" / "taipy" / ".env"
+        if not os.path.exists(env_file_path):
+            with open(env_file_path, "w") as env_file:
+                env_file.write(f"TAIPY_GUI_DIR={root_path}\n")
+        os.system("cd frontend/taipy && npm ci && npm run build")
+
+
+if __name__ == "__main__":
+    root_path = Path(__file__).absolute().parent.parent.parent
+    if len(sys.argv) > 1:
+        if sys.argv[1] == "gui":
+            build_gui(root_path)
+        elif sys.argv[1] == "taipy":
+            build_taipy(root_path)
+    else:
+        build_gui(root_path)
+        build_taipy(root_path)

+ 4 - 0
tox.ini

@@ -32,6 +32,7 @@ commands =
 platform = linux
 commands =
     pipenv install --dev
+    pipenv run python tools/frontend/bundle_build.py
     pipenv run ipython kernel install --name "python3" --user
     pipenv run playwright install chromium --with-deps
     pipenv run mypy --config-file mypy.ini taipy
@@ -41,6 +42,7 @@ commands =
 platform = win32
 commands =
     pipenv install --dev
+    pipenv run python tools/frontend/bundle_build.py
     pipenv run ipython kernel install --name "python3" --user
     pipenv run playwright install chromium --with-deps
     pipenv run pytest -s tests
@@ -49,6 +51,7 @@ commands =
 platform = darwin
 commands =
     pipenv install --dev
+    pipenv run python tools/frontend/bundle_build.py
     pipenv run ipython kernel install --name "python3" --user
     pipenv run playwright install chromium --with-deps
     pipenv run pytest -s tests
@@ -71,6 +74,7 @@ commands = coverage erase
 [testenv:tests]
 commands =
     pipenv install --dev
+    pipenv run python tools/frontend/bundle_build.py
     pipenv run pip freeze
     pipenv run pytest -s tests
 

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません