Skip to content

chore(previews): make dev-mobile ports configurable and tighten SST env types#651

Draft
Barnabas A Nsoh (ayinloya) wants to merge 4 commits into
mainfrom
chore/previews-dev-mobile-port-config
Draft

chore(previews): make dev-mobile ports configurable and tighten SST env types#651
Barnabas A Nsoh (ayinloya) wants to merge 4 commits into
mainfrom
chore/previews-dev-mobile-port-config

Conversation

@ayinloya

Copy link
Copy Markdown
Collaborator

Summary

Internal dev-tooling improvements to the previews/ workspace. Split out of #650 so the 11.4.5 release PR only contains the user-facing Selfie fix and version bumps.

Changes

previews/scripts/dev-mobile.sh

  • Optionally source previews/.env so contributors can persist their port choices.
  • Add EMBED_PORT (default 8000) and APP_PORT (default 5173) overrides.
  • Validate that both values are numeric and that neither port is already bound (via lsof) before launching tunnels — fail fast with a clear message instead of getting a half-running tunnel.
  • Serve the embed sidecar from a fresh npm run build + npx serve instead of npm start, so the tunneled origin matches what mobile devices actually load.
  • Thread APP_PORT through to sst dev … vite:dev -- --port "$APP_PORT".

previews/sst-env.d.ts

  • Type EmbedUrl as sst.sst.Secret (was sst.sst.Linkable) to match how it's wired in sst.config.ts.
  • Declare WafWebAclArn (also sst.sst.Secret) so TS stops complaining when the WAF link is referenced.

Scope

  • Touches only previews/ (private workspace; not published).
  • No runtime or shipped-code behaviour changes.
  • No new dependencies.

Notes / follow-ups

A couple of nits worth knowing about (not blockers, can be addressed in review or a follow-up):

  • The header comment at the top of dev-mobile.sh still references the old hard-coded ports — worth updating.
  • is_port_in_use silently returns false if lsof isn't installed; consider a command -v lsof guard with a warning.
  • The serve binary is fetched on demand via npx; adding --yes would avoid the interactive prompt on first run.

Testing

Manual:

  • EMBED_PORT=9000 APP_PORT=5180 ./previews/scripts/dev-mobile.sh — both tunnels come up on the chosen ports.
  • Re-running with a port already in use — script exits with the port-in-use error before starting any tunnels.
  • Running with defaults — unchanged behaviour from main.

…ability

Allow overriding the embed and previews app ports via EMBED_PORT and
APP_PORT (with optional .env support), validate that the chosen ports
are numeric and free before starting tunnels, and switch the embed
sidecar to a built bundle served by 'serve' so the tunneled origin
matches what mobile devices will hit.
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

🔍 Semgrep Security Scan Results

✅ No security findings detected by p/security-audit ruleset.

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

This branch has been deployed to s3 / cloudfront.

✅ Preview URL for Smart Camera Web:

https://cdn.smileidentity.com/js/preview-chore/previews-dev-mobile-port-config/smart-camera-web.js

✅ Preview URL for Embed:

https://cdn.smileidentity.com/inline/preview-chore/previews-dev-mobile-port-config/js/script.min.js

✅ Preview URL for Web Client (Sandbox):

https://d2lwo0rysx3tp6.cloudfront.net

✅ Preview URL for Web Client (Production):

https://dxn0vlga3aiaw.cloudfront.net

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