build(dev): add convenience script to run frontend/backend branches separately DEV-1304 #6490
+120
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add a helper script for running the backend and frontend independently on 2 different branches.
💭 Notes
With two distinct copies of
kobotoolbox/kpichecked out, this script will make it so that the app served bykpi-backendwill point to the frontend dev server running fromkpi-frontend:./scripts/split-frontend.sh \ -f ~/kobo/kpi-frontend \ -b ~/kobo/kpi-backendThen, you can switch
kpi-frontendandkpi-backendbranches independently from one another.Use case
Day-to-day branch switching
mainduring this while you test the JS changes.Parallel previews
Assumptions for this PR
npm run watchon the host (outside of the kpi container that has your backend running)(these restrictions may be relaxed when the backend and frontend are decoupled further)
Implementation notes
The script is a wrapper for essentially a 1-liner:
To avoid the need to install
watchexecor similar binary separately,split-frontend.shborrows a CLI watcher fromuv(PyPI) ornpx(npm).uvis installed (backend developers), it will useuvxand the[email protected]package.npmis installed (frontend developers), it will usenpxand the[email protected]package.👀 Preview steps
../kobo-install/run.py (…), 🌐 kf.kobo.localnpm run watch, 🌐 localhost:3000./scripts/split-frontend.sh -b ~/kobo/kpi -f ~/kobo/kpi-feanji/dev-1169-select-one-to-mantinedev-1278-data-endpoint-paginationdiagram
--- config: look: neo layout: dagre --- flowchart TB n2["backend"] -- "<span style=background-color:>dev-1304-disjoint-frontend</span>" --> n5@{ label: "ℹ️ bring up your kobo-install dev instance normally<br><br>e.g. 📁<b style=\"color:\">~/kobo/kpi</b>(backend)<br><b style=\"color:\"></b>🌐<b style=\"color:\">kf.kobo.local</b><br>" } n3["frontend"] --> n1["ℹ️ clone another copy of kpi for the frontend<br><br>e.g. 📁<b>~/kobo/kpi-fe</b><br>"] n1 -- "<span style=background-color:>dev-1304-disjoint-frontend</span>" --> n4@{ label: "start a frontend dev server on host<br><br><b>npm install</b><br><b>npm run watch<br><br></b><span style=\"background-color:\">🌐</span><b>localhost:3000</b>" } n4 --> n6["<br>Run the script: <br><br> ~/kobo/kpi/scripts/split-frontend.sh \ <br>-b ~/kobo/kpi \ <br> -f ~/kobo/kpi-fe<br><br><br>"] n5 -- <br> --> n6 n6 --> n8["Switch branch in <br><b>📁~/kobo/kpi<br></b>(backend)"] & n9["Switch frontend branch in <br><b>📁~/kobo/kpi-fe</b><br>(frontend)<br>"] n8 -- "e.g. <a title=kobotoolbox/kpi:dev-1278-data-endpoint-pagination href=https://github.com/kobotoolbox/kpi/tree/dev-1278-data-endpoint-pagination><span class=css-truncate-target>dev-1278-data-endpoint-pagination</span></a>" --> n7["🟢 See that the frontend and backend updates apply independently"] n9 -- "e.g. <a title=kobotoolbox/kpi:anji/dev-1169-select-one-to-mantine href=https://github.com/kobotoolbox/kpi/tree/anji/dev-1169-select-one-to-mantine><span class=css-truncate-target>anji/dev-1169-select-one-to-mantine</span></a>" --> n7 n2@{ shape: terminal} n5@{ shape: tag-proc} n3@{ shape: terminal} n1@{ shape: tag-proc} n4@{ shape: tag-proc} n6@{ shape: tag-proc} n8@{ shape: terminal} n9@{ shape: terminal} n7@{ shape: terminal} n2:::be n5:::be n3:::fe n1:::fe n4:::fe n6:::merge n8:::be n9:::fe n7:::merge classDef be fill:#BBDEFB classDef merge fill:#C8E6C9 classDef fe fill:#FFF9C4 style n6 fill:#C8E6C9