Skip to content

fetch the starter template at build time - #432

Merged
mhkeller merged 3 commits into
mainfrom
chore/remove-svelteapp
Sep 6, 2026
Merged

mhkeller merged 3 commits into
mainfrom
chore/remove-svelteapp

Conversation

@mhkeller

@mhkeller mhkeller commented Sep 6, 2026

Copy link
Copy Markdown
Owner

The example pages' Download button builds its zip from layercake-template. Until now a prebuild script degit-ed that repo into src/scripts/svelte-app, wrote static/svelte-app.json and static/deps.json, and all of it was committed. The site builds on gh actions now, so none of that needs to live in the repo.

  • src/_modules/getTemplateFiles.js downloads the template tarball and reads it in memory with node-tar
  • /svelte-app.json and /deps.json are endpoints, prerendered into docs/. listed in prerender.entries since nothing links to them
  • binary files go through as base64. the favicon in the zip was corrupt before
  • example files no longer land in the zip as src/routes/./_data/...
  • drops the vendored folder, the shell script, the generated files, prebuild, update_template and degit
  • the download test checks what's in the zip instead of its size. the old 65kb threshold only passed because the template used to ship a lockfile
  • screenshot tests allow up to 10 differing pixels. the landing page snapshot on linux has been off by one pixel since the v10 notice went in, on main too

Builds need network to reach codeload.github.com.

The Download button on the example pages builds its zip from
mhkeller/layercake-template. Until now a pre-build shell script degit-ed
that repo into src/scripts/svelte-app, turned it into static/svelte-app.json
and static/deps.json, and all of that was committed, so every build left a
diff behind and the checked-in copy was never what deployed.

getTemplateFiles.js downloads the template's tarball from GitHub and reads
it in memory with node-tar. /svelte-app.json and /deps.json are endpoints
that serve the same JSON the script wrote and are prerendered into docs/.
They're listed in prerender.entries because no page links to them.

Binary template files travel as base64 and are decoded when the zip is
built, so the favicon in the zip is a real PNG. Before, it went through a
text decode and came out corrupt. The example's files now land in the zip
without a `./` in their paths.

The vendored folder, the shell script, the generated files, the prebuild
and update_template scripts, the degit dependency and the prettier and
jsconfig exclusions for the folder are gone.
The download test required a zip over 65 kB. That only held because the
template used to ship a package-lock.json, which the template repo has since
removed. The test now checks that the template files, the example's page
and components, a valid favicon and the layercake pin are in the archive.
@mhkeller
mhkeller marked this pull request as ready for review September 6, 2026 15:57
@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

🎭 Playwright tests failed

The Playwright tests failed on this PR. Please check the test results and fix any issues.

📊 View full test report

The landing page's SSR gallery screenshot on Linux differs from its baseline
by one pixel since the v10 notice was added above it, on main too. The blur
in screenshot.css is meant to absorb that kind of noise. A ten pixel
allowance covers what slips through it.
@mhkeller
mhkeller merged commit da4d5b6 into main Sep 6, 2026
5 checks passed
@mhkeller
mhkeller deleted the chore/remove-svelteapp branch September 6, 2026 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant