From 6b24707c8d453345a9c262e0b951857c6aa68849 Mon Sep 17 00:00:00 2001 From: Zsolt Tasnadi Date: Sun, 16 Aug 2026 23:12:12 +0200 Subject: [PATCH] Build bundled Phaser projects with their own toolchain MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The step assumed one project shape: plain sources concatenated with cat and Phaser pulled from a CDN. trickster-tiles is the other shape — Vite plus TypeScript, built with `tsc && vite build` — so `cat src/*.js` found nothing to bundle and the build failed. The earlier guard on the syntax check fixed only the first symptom of that mismatch. A project with a build script now runs npm ci && npm run build and is packaged from its own dist/, which already contains index.html and the hashed assets. Plain projects keep the existing path untouched. The bundler's base has to be relative, since games are served out of /file/-/; the step fails loudly if the build leaves no dist/index.html rather than shipping an empty zip. Verified in the phaser-builder image against trickster-tiles: a 344 kB package with index.html at the root and ./assets/ references. Co-Authored-By: Claude Opus 5 (1M context) --- .../platforms/phaser/pipeline.yaml.erb | 49 ++++++++++++++----- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/libs/ruby/warp_engine/app/services/warp_engine/platforms/phaser/pipeline.yaml.erb b/libs/ruby/warp_engine/app/services/warp_engine/platforms/phaser/pipeline.yaml.erb index 7d8f7b8..3cb625f 100644 --- a/libs/ruby/warp_engine/app/services/warp_engine/platforms/phaser/pipeline.yaml.erb +++ b/libs/ruby/warp_engine/app/services/warp_engine/platforms/phaser/pipeline.yaml.erb @@ -22,19 +22,42 @@ steps: commands: - | VERSION=$(cat .version) - echo "==> Checking JS syntax" - for f in src/*.js; do [ -e "$f" ] || continue; node --check "$f"; done - mkdir -p dist/web - echo "==> Downloading Phaser 3.90.0" - curl -sSL https://cdn.jsdelivr.net/npm/phaser@3.90.0/dist/phaser.min.js -o dist/web/phaser.min.js - echo "==> Downloading index.html" - curl -sSL https://git.teletypegames.org/tools/phaser-tools/raw/branch/master/web/index.html -o dist/web/index.html - echo "==> Bundling game sources" - cat src/*.js > dist/web/game.js - echo "==> Packaging web build for $VERSION" - (cd dist/web && zip -r "../../<%= name %>-$VERSION.html.zip" .) - echo "==> Cleaning temporary files" - rm -rf dist/web + # Ketfele projektforma el egymas mellett: a sima JS (a forrasok + # osszefuzve, a Phaser CDN-rol) es a bundleres (Vite + TypeScript), + # ami maga allitja elo a kesz webes csomagot. + if [ -f package.json ] && grep -q '"build"' package.json; then + echo "==> Bundled project — npm ci && npm run build" + npm ci + npm run build + # A Vite kimenete onmagaban teljes: index.html + a beforgatott + # assetek. A vite.config base-enek relativnak kell lennie, mert a + # jatek a /file/-/ alkonyvtarbol szolgal ki. + if [ ! -f dist/index.html ]; then + echo "ERROR: a build nem hagyott dist/index.html-t" >&2 + exit 1 + fi + echo "==> Packaging web build for $VERSION" + (cd dist && zip -r "../<%= name %>-$VERSION.html.zip" .) + echo "==> Cleaning temporary files" + rm -rf dist + else + echo "==> Checking JS syntax" + # A bundleres projektben nincs src/*.js, es a shell ilyenkor a + # mintat adja tovabb literalkent — a node MODULE_NOT_FOUND-dal + # szall el rajta. + for f in src/*.js; do [ -e "$f" ] || continue; node --check "$f"; done + mkdir -p dist/web + echo "==> Downloading Phaser 3.90.0" + curl -sSL https://cdn.jsdelivr.net/npm/phaser@3.90.0/dist/phaser.min.js -o dist/web/phaser.min.js + echo "==> Downloading index.html" + curl -sSL https://git.teletypegames.org/build/phaser-tools/raw/branch/master/web/index.html -o dist/web/index.html + echo "==> Bundling game sources" + cat src/*.js > dist/web/game.js + echo "==> Packaging web build for $VERSION" + (cd dist/web && zip -r "../../<%= name %>-$VERSION.html.zip" .) + echo "==> Cleaning temporary files" + rm -rf dist/web + fi - name: upload image: alpine