From 0a452750dd7978766a7860af72d93bcdd4d07919 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 27 Jul 2023 16:26:15 -0300 Subject: [PATCH 1/6] update make file to make_frontend to remove node_modules before install and avoid binding error --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 79e27833e..c123a9f18 100644 --- a/Makefile +++ b/Makefile @@ -32,10 +32,10 @@ lint: poetry run ruff . --fix install_frontend: - cd src/frontend && npm install + cd src/frontend && m -rf node_modules && npm install run_frontend: - cd src/frontend && npm start + cd src/frontend && rm -rf node_modules && npm start frontend: make install_frontend From fe61d4aa5157b05fe54aa43870ea6b38d244d9d8 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 27 Jul 2023 16:57:43 -0300 Subject: [PATCH 2/6] fix(Makefile): fix typo in 'rm -rf' command to remove node_modules directory in install_frontend target fix(Makefile): remove unnecessary 'rm -rf' command in run_frontend target --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index c123a9f18..d969142f9 100644 --- a/Makefile +++ b/Makefile @@ -32,10 +32,10 @@ lint: poetry run ruff . --fix install_frontend: - cd src/frontend && m -rf node_modules && npm install + cd src/frontend && rm -rf node_modules && npm install run_frontend: - cd src/frontend && rm -rf node_modules && npm start + cd src/frontend && npm start frontend: make install_frontend From b528ae86fd5db0bea193b31d1044eb190c7c100b Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Tue, 15 Aug 2023 15:39:33 -0300 Subject: [PATCH 3/6] chore(Makefile): change npm install command to npm ci for frontend installation to ensure reproducible builds --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4d20de28b..f8603f552 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ lint: poetry run ruff . --fix install_frontend: - cd src/frontend && rm -rf node_modules && npm install + cd src/frontend && npm ci run_frontend: cd src/frontend && npm start From 021380b6f3ec8f5bf17db341dafad4688b6a4bac Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Tue, 15 Aug 2023 15:40:50 -0300 Subject: [PATCH 4/6] format code --- src/frontend/src/modals/formModal/index.tsx | 3 ++- src/frontend/vite.config.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/frontend/src/modals/formModal/index.tsx b/src/frontend/src/modals/formModal/index.tsx index 68137c0da..0e2f9b3c4 100644 --- a/src/frontend/src/modals/formModal/index.tsx +++ b/src/frontend/src/modals/formModal/index.tsx @@ -160,7 +160,8 @@ export default function FormModal({ } function getWebSocketUrl(chatId, isDevelopment = false) { - const isSecureProtocol = window.location.protocol === "https:" || window.location.port === "443"; + const isSecureProtocol = + window.location.protocol === "https:" || window.location.port === "443"; const webSocketProtocol = isSecureProtocol ? "wss" : "ws"; const host = isDevelopment ? "localhost:7860" : window.location.host; const chatEndpoint = `/api/v1/chat/${chatId}`; diff --git a/src/frontend/vite.config.ts b/src/frontend/vite.config.ts index d477ce539..b513e36bb 100644 --- a/src/frontend/vite.config.ts +++ b/src/frontend/vite.config.ts @@ -6,7 +6,7 @@ const apiRoutes = ["^/api/v1/", "/health"]; // Use environment variable to determine the target. const target = process.env.VITE_PROXY_TARGET || "http://127.0.0.1:7860"; -// Use environment variable to determine the UI server port +// Use environment variable to determine the UI server port const port = process.env.VITE_PORT || 3000; const proxyTargets = apiRoutes.reduce((proxyObj, route) => { From 9096fcd1109a4a8562cbad8cc0ad1b829966badb Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Wed, 16 Aug 2023 17:23:24 -0300 Subject: [PATCH 5/6] chore(Makefile): modify install_frontend target to conditionally run npm ci or npm install based on the value of the clean variable --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f8603f552..9e9f876d9 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,11 @@ lint: poetry run ruff . --fix install_frontend: - cd src/frontend && npm ci + @if [ "$(clean)" = "true" ]; then \ + cd src/frontend && npm ci; \ + else \ + cd src/frontend && npm install; \ + fi run_frontend: cd src/frontend && npm start From 16fa3a66b82c3fdb2fbd9f440a0343711a47003c Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Wed, 16 Aug 2023 17:28:35 -0300 Subject: [PATCH 6/6] chore(Makefile): simplify install_frontend target by removing unnecessary conditional statement feat(Makefile): add install_frontendc target to install frontend dependencies using npm ci for clean installs feat(Makefile): add frontendc target to install frontend dependencies using npm ci and run frontend chore(ApiModal/index.tsx): reformat codesArray for better readability --- Makefile | 13 ++++++++----- src/frontend/src/modals/ApiModal/index.tsx | 8 +++++++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 9e9f876d9..f96931a4d 100644 --- a/Makefile +++ b/Makefile @@ -32,11 +32,10 @@ lint: poetry run ruff . --fix install_frontend: - @if [ "$(clean)" = "true" ]; then \ - cd src/frontend && npm ci; \ - else \ - cd src/frontend && npm install; \ - fi + cd src/frontend && npm install; + +install_frontendc: + cd src/frontend && npm ci; run_frontend: cd src/frontend && npm start @@ -44,6 +43,10 @@ run_frontend: frontend: make install_frontend make run_frontend + +frontendc: + make install_frontendc + make run_frontend install_backend: poetry install diff --git a/src/frontend/src/modals/ApiModal/index.tsx b/src/frontend/src/modals/ApiModal/index.tsx index 8410ee7d4..5bd93df45 100644 --- a/src/frontend/src/modals/ApiModal/index.tsx +++ b/src/frontend/src/modals/ApiModal/index.tsx @@ -49,7 +49,13 @@ const ApiModal = forwardRef( const pythonCode = getPythonCode(flow, tweak.current, tabsState); const widgetCode = getWidgetCode(flow, tabsState); const tweaksCode = buildTweaks(flow); - const codesArray = [curl_code, pythonApiCode, pythonCode, widgetCode, pythonCode]; + const codesArray = [ + curl_code, + pythonApiCode, + pythonCode, + widgetCode, + pythonCode, + ]; const [tabs, setTabs] = useState(tabsArray(codesArray, 0)); function startState() {