@@ -131,45 +131,6 @@ components-static: $(PYBIN) deps
131131components-shinylive-links : $(PYBIN ) deps
132132 . $(PYBIN ) /activate && python components/update-shinylive-links.py
133133
134-
135- SHINYLIVE_DIR ?= shinylive
136-
137- # # Clone shinylive repository (for building from source)
138- .PHONY : clone-shinylive
139- clone-shinylive :
140- @if [ ! -d " $( SHINYLIVE_DIR) " ]; then \
141- echo " 🔵 Cloning shinylive repository..." ; \
142- git clone https://github.com/posit-dev/shinylive.git $(SHINYLIVE_DIR ) ; \
143- else \
144- echo " ✓ shinylive directory already exists" ; \
145- fi
146-
147- # # Build shinylive from source for previewing unreleased features
148- .PHONY : build-shinylive
149- build-shinylive : $(PYBIN ) clone-shinylive
150- @echo " 🔵 Building shinylive from source..."
151- cd $(SHINYLIVE_DIR ) && make submodules
152- cd $(SHINYLIVE_DIR ) && npm install
153- cd $(SHINYLIVE_DIR ) && make all
154- cd $(SHINYLIVE_DIR ) && make dist
155- @echo " 🔵 Installing locally-built shinylive..."
156- . $(PYBIN ) /activate && pip uninstall -y shinylive 2> /dev/null || true
157- . $(PYBIN ) /activate && pip install $(SHINYLIVE_DIR )
158- @echo " ✓ shinylive built and installed from source"
159-
160- # # Update shinylive source and rebuild
161- .PHONY : update-shinylive
162- update-shinylive : clone-shinylive
163- @echo " 🔵 Updating shinylive repository..."
164- cd $(SHINYLIVE_DIR ) && git pull
165- $(MAKE ) build-shinylive
166-
167- # # Clean shinylive build artifacts
168- .PHONY : clean-shinylive
169- clean-shinylive :
170- rm -rf $(SHINYLIVE_DIR )
171-
172-
173134# # Remove Quarto website build files
174135.PHONY : clean
175136clean :
@@ -185,54 +146,50 @@ clean-extensions:
185146clean-venv :
186147 rm -rf $(VENV )
187148
188- # # Remove all build files (Quarto website, quarto extensions, venv, shinylive )
149+ # # Remove all build files (Quarto website, quarto extensions, venv)
189150.PHONY : distclean
190- distclean : clean clean-extensions clean-venv clean-shinylive
151+ distclean : clean clean-extensions clean-venv
191152
192153SHINYLIVE_ARTIFACT_DIR ?= _shinylive-pr-build
154+ SHINYLIVE_BRANCH ?= main
193155
194156# # Download and install shinylive artifact from py-shiny CI/CD (requires gh and jq)
195- .PHONY : use-shinylive-artifact
196- use-shinylive-artifact : $(PYBIN ) deps
157+ # # This is essential the first time you want to use the dev shinylive build, but is not
158+ # # necessary after, as shinylive will use the lastest cached artifact
159+ # # By default searches main branch. Supply SHINYLIVE_BRANCH to test a specific branch.
160+ # # Usage: make use-dev-shinylive [SHINYLIVE_BRANCH=feature-branch]
161+ .PHONY : use-dev-shinylive
162+ use-dev-shinylive : $(PYBIN ) deps
197163 @command -v gh jq > /dev/null || (echo " ❌ Install: brew install gh jq && gh auth login" && exit 1)
198164 @gh auth status > /dev/null 2>&1 || (echo " ❌ Authenticate: gh auth login" && exit 1)
199- @rm -rf $(SHINYLIVE_ARTIFACT_DIR )
200- @. $(PYBIN ) /activate && python -c " import appdirs, shutil; shutil.rmtree(appdirs.user_cache_dir('shinylive'), ignore_errors=True)"
201- @echo " 🔵 Finding shinylive-build artifact in py-shiny workflows..."
202- @FOUND=false; \
203- for RUN_ID in $$ (gh run list --repo posit-dev/py-shiny --workflow build-docs.yaml --limit 20 --json databaseId --jq ' .[].databaseId' ); do \
165+ @echo " 🔵 Finding shinylive-build artifact in py-shiny workflows on branch: $( SHINYLIVE_BRANCH) ..." ; \
166+ RUN_IDS=$$(gh run list --repo posit-dev/py-shiny --workflow build-docs.yaml --branch $(SHINYLIVE_BRANCH ) --limit 20 --json databaseId --jq '.[].databaseId' ) ; \
167+ FOUND=false; \
168+ for RUN_ID in $$ RUN_IDS; do \
204169 if gh api repos/posit-dev/py-shiny/actions/runs/$$ RUN_ID/artifacts --jq ' .artifacts[].name' 2> /dev/null | grep -q ' ^shinylive-build$$' ; then \
205170 echo " 🔹 Found artifact in run $$ RUN_ID" ; \
171+ rm -rf $(SHINYLIVE_ARTIFACT_DIR ) && \
172+ . $(PYBIN ) /activate && python -c " import appdirs, shutil; shutil.rmtree(appdirs.user_cache_dir('shinylive'), ignore_errors=True)" && \
206173 gh run download --repo posit-dev/py-shiny --name shinylive-build --dir $(SHINYLIVE_ARTIFACT_DIR ) $$ RUN_ID && \
207174 . $(PYBIN ) /activate && shinylive assets install-from-local " $( SHINYLIVE_ARTIFACT_DIR) " && \
208- echo " ✓ Shinylive artifact installed" && \
175+ echo " ✓ Shinylive artifact installed from branch $( SHINYLIVE_BRANCH ) " && \
209176 FOUND=true && \
210177 break ; \
211178 fi ; \
212179 done ; \
213180 if [ " $$ FOUND" != " true" ]; then \
214- echo " ❌ No shinylive-build artifact found in recent py-shiny builds" ; \
181+ echo " ❌ No shinylive-build artifact found in recent py-shiny builds on branch $( SHINYLIVE_BRANCH ) " ; \
215182 exit 1; \
216183 fi
217184
218- # # Build documentation with py-shiny shinylive artifact
219- .PHONY : all-with-artifact
220- all-with-artifact : use-shinylive-artifact quartodoc components site
221- @echo " ✓ Documentation built with py-shiny shinylive artifact"
222-
223- # # Serve documentation with py-shiny shinylive artifact
224- .PHONY : serve-with-artifact
225- serve-with-artifact : use-shinylive-artifact quartodoc components
226- . $(PYBIN ) /activate && ${QUARTO_PATH} preview
227185
228186# # Clean shinylive artifact download
229- .PHONY : clean-shinylive-artifact
230- clean-shinylive-artifact :
187+ .PHONY : clean-dev-shinylive
188+ clean-dev-shinylive :
231189 rm -rf $(SHINYLIVE_ARTIFACT_DIR )
232190
233191
234192
235-
236193define PRINT_HELP_PYSCRIPT
237194import re, sys
238195
0 commit comments