Skip to content
This repository was archived by the owner on Nov 17, 2026. It is now read-only.

♻️ Restore pages deploy as a shell script and harden the shell commands - #860

Merged
usagizmo merged 2 commits into
mainfrom
refactor/pages-deploy-sh
Jul 28, 2026
Merged

usagizmo merged 2 commits into
mainfrom
refactor/pages-deploy-sh

Conversation

@usagizmo

Copy link
Copy Markdown
Owner

Reverts the apps/pages deploy command from .js back to .sh. The .js rewrite was motivated by cross-platform support, but deploy orchestrates rsync and ssh — POSIX binaries that are absent on Windows — so wrapping them in JS added code without adding portability. Script bodies go from 80 lines to 23.

Which extension is right follows from what a command depends on, not from uniformity:

Depends on Right form
POSIX binaries (rsync / ssh) .sh
File walking, path normalization, string processing .js (clean-images, add-size-to-img stay as-is)
Just passing an env var one line in package.json

Deploy

  • Replace commands/deploy.js with commands/deploy.sh
  • Restore rsync -ahvu — the u (--update) flag was silently dropped in the JS rewrite
  • Create parent directories with ssh mkdir -p before rsync, which only creates the last path segment
  • Split DEPLOY_TARGET into DEPLOY_HOST / DEPLOY_DIR so the mkdir and rsync targets share one source

Snapshot update

  • Delete commands/update-snapshots.js (33 lines) in favor of "test:update": "UPDATE_SNAPSHOTS=1 bun test"
  • bun run executes package.json scripts through Bun Shell on Windows, so the env prefix is already cross-platform

Fixes found along the way

  • The command list in public/index.html was not runnable: it had no cd apps/pages, and bare bun build / bun test launch Bun's built-in bundler and test runner instead of the package scripts
  • commands/*.sh had no shebangs, so execution relied on the shell's ENOEXEC fallback. Also quoted "$0", guarded cd with || exit 1, and dropped the literal brackets in tr '[A-Z]' '[a-z]'
  • The rsync requirement in the README pointed at the target server; what actually matters is rsync / ssh on the local machine. Also documented that --delete mirrors public/
  • Docs now point at commands/deploy.sh instead of enumerating its variables — the DEPLOY_TARGET rename rippling through four places was the cost of that duplication

Verification

bun run lint (5/5), pages tests (7 pass), shellcheck clean.

usagizmo added 2 commits July 28, 2026 13:06
- Add `#!/bin/sh` shebangs; without them execution relies on the shell's ENOEXEC fallback
- Quote "$0" in `dirname` so paths containing spaces resolve correctly
- Guard `cd` with `|| exit 1` so a failed chdir cannot run the script against the wrong directory
- Drop the brackets in `tr '[A-Z]' '[a-z]'`; tr treats them as literal characters, not class delimiters
- Replace `commands/deploy.js` with `commands/deploy.sh`: rsync and ssh are POSIX binaries, so the JS wrapper added code without adding portability
- Restore `rsync -ahvu`; the `u` (`--update`) flag was silently dropped in the JS rewrite
- Create parent directories with `ssh mkdir -p` before rsync, which only creates the last path segment
- Split `DEPLOY_TARGET` into `DEPLOY_HOST` / `DEPLOY_DIR` so the mkdir and rsync targets share one source
- Delete `commands/update-snapshots.js`; `"test:update": "UPDATE_SNAPSHOTS=1 bun test"` is already cross-platform because `bun run` executes scripts through Bun Shell on Windows
- Point the docs at `commands/deploy.sh` instead of enumerating its variables, and note that `--delete` mirrors `public/`
- Fix the command list in `public/index.html`: add `cd apps/pages` and use `bun run`, since bare `bun build`/`bun test` launch Bun's bundler and test runner
@vercel

vercel Bot commented Jul 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
webapp-template-pages Ready Ready Preview, Comment Jul 28, 2026 4:21am
webapp-template-web Ready Ready Preview, Comment Jul 28, 2026 4:21am

Request Review

@usagizmo
usagizmo merged commit f922729 into main Jul 28, 2026
2 checks passed
@usagizmo
usagizmo deleted the refactor/pages-deploy-sh branch July 28, 2026 04:24

This branch was successfully deployed

2 active deployments
Preview – webapp-template-web — 07c2bebe Deployed Jul 28, 2026 by vercel[bot]
Preview – webapp-template-pages — 07c2bebe Deployed Jul 28, 2026 by vercel[bot]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant