Skip to content

fix: make dev up, dev server, and dev docs work - #956

Merged
kdaviduik merged 1 commit into
mainfrom
kd-fix-dev-up-and-server
Aug 27, 2026
Merged

kdaviduik merged 1 commit into
mainfrom
kd-fix-dev-up-and-server

Conversation

@kdaviduik

@kdaviduik kdaviduik commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Why

dev up was broken (the node task used a pnpm: key that current dev rejects), dev server failed to bind port 8080 (devns conflict), and dev docs had no Ruby/Jekyll toolchain provisioned. This PR fixes all three so the standard dev workflow works out of the box — no manual setup steps.

What

dev up — fixed node task + provisioned Jekyll

  • dev.yml node task: pnpm: 10.16.1package_manager: pnpm@10.16.1 + packages: [.] (the old pnpm: key was rejected by dev's validator)
  • Added ruby + bundler to up: — provisions Ruby 3.3.6 and Jekyll 4.4.1 so dev docs works without manually installing Jekyll
  • New files: .ruby-version (3.3.6), Gemfile (gem 'jekyll', '~> 4.4'), Gemfile.lock (generated by dev up)

dev server — renamed command, fixed port binding, removed manual setup

  • Renamed startserver in dev.yml (matches the convention across Shopify repos)

  • server now runs pnpm run build && pnpm run start — a restart picks up source changes cleanly

  • Renamed open: exampleopen: app — Ctrl-T during dev server is hardcoded to look for a link named app

  • Fixed EADDRINUSE on port 8080: changed serve script from http-server to http-server -a 127.0.0.1 -p 8080

    devns (dev's networking daemon) holds 0.0.0.0:8080 in a CLOSED socket state to proxy *.shop.dev traffic. http-server defaults to binding 0.0.0.0:8080, which conflicts. Binding to 127.0.0.1 avoids the conflict. -p 8080 is also needed — without it, http-server uses portfinder which checks 0.0.0.0 (still blocked by devns) and auto-increments to 8081+.

    Evidence: http-server README documents that -a defaults to 0.0.0.0 and -p defaults to 8080. You can reproduce the conflict by running node -e "require('http').createServer().listen(8080, '0.0.0.0')" — it throws EADDRINUSE, while listen(8080, '127.0.0.1') succeeds.

    Why not -p 0 (auto-find open port)? The http-server docs suggest -p 0 to let portfinder find an open port starting at 8080. However, portfinder checks availability on 0.0.0.0 (where devns holds the CLOSED socket), not on the -a 127.0.0.1 address — so it sees 8080 as taken and skips to 8081, which breaks dev open app (hardcoded to http://localhost:8080/). Using an explicit -p 8080 bypasses portfinder entirely and binds directly to 127.0.0.1:8080.

  • Renamed index.example.htmlindex.html and hardcoded the hydrogen-preview demo store credentials (same public credentials already used in test-manual/index.html). Removed /index.html from .gitignore so it's committed. This eliminates the manual cp + credential-filling step — dev server just works.

    Why this is safe: index.html was originally gitignored in 2016 because it contained a real Storefront API key. The example/template pattern was the 2016 solution to "don't commit API keys." This concern no longer applies: storefront access tokens are public-by-design (they're embedded in browser-side JS on merchant websites — that's literally what buy-button-js does), they only grant read access to products/collections, and the specific credentials used here are already committed in test-manual/index.html in this same repo.

dev docs — fixed docs command + stale docs

  • docs script: jekyll servebundle exec jekyll serve (uses the Jekyll provisioned by dev up)
  • docs/readme.md: was copy-pasted from the js-buy-sdk repo (wrong title, wrong URL, referenced non-existent doc-build/doc-serve scripts) — rewritten to accurately describe this repo's docs setup
  • readme.md: Documentation section no longer says to manually gem install jekyll (dev up handles it); corrected "gh-pages from main" to "Pages builds /docs from main" (no gh-pages branch); removed manual cp index.example.html index.html step

Ignore files

  • .gitignore: removed /index.html (now committed); added .jekyll-cache (Jekyll 4 cache dir)
  • .npmignore: excluded /Gemfile, /Gemfile.lock, /.ruby-version so Ruby tooling doesn't ship to npm consumers (index.html was already excluded)

How to verify

dev up          # should converge cleanly (Ruby + Jekyll installed)
dev server      # should build, then serve at http://localhost:8080/ (demo page with hydrogen-preview store)
dev docs        # should serve docs at http://localhost:4000/buy-button-js/

@kdaviduik
kdaviduik force-pushed the kd-fix-dev-up-and-server branch 3 times, most recently from 6890ab8 to eba4c2c Compare August 22, 2026 03:39
@kdaviduik
kdaviduik marked this pull request as ready for review August 22, 2026 03:51
@kdaviduik
kdaviduik requested a review from a team as a code owner August 22, 2026 03:51
Comment thread Gemfile.lock
@@ -0,0 +1,106 @@
GEM
remote: https://rubygems.org/

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this file behere?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - jekyll only exists as a Ruby gem. Before, the instructions were to manually install it. But it's a smoother developer experience to just have it installed automatically as part of dev up, so this PR wires that up, which also requires adding the ruby version file and the Gemfile.lock since those didn't exist before.

image

Comment thread index.html
domain: '', // ex 'storename.myshopify.com'
storefrontAccessToken: '' // previously 'apiKey', now deprecated
domain: 'hydrogen-preview.myshopify.com',
storefrontAccessToken: '79921ccabf3be126fbd83c8fa0e04a3c'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume it's fine having this as a public thing?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep! I had a comment about this in the PR description
image

@EvilGenius13

Copy link
Copy Markdown

Forgot to say I 🎩 and everything booted up and worked.

@kdaviduik
kdaviduik marked this pull request as draft August 27, 2026 19:13
dev up was broken: the node task used a pnpm: key that current dev
rejects (requires package_manager:), and docs had no Ruby/Jekyll
toolchain provisioned. dev server used the non-standard 'start'
command name and failed to bind port 8080 due to a devns conflict.

Changes to dev.yml:
- Fix node task: pnpm: -> package_manager: + packages: [.]
  (the old pnpm: key was rejected by dev's validator)
- Add ruby + bundler to up: provisions Jekyll for the docs preview
- Rename 'start' command to 'server' (matches dev convention across
  Shopify repos; Ctrl-T during dev server opens 'app' link)
- server now runs 'pnpm build && pnpm start' so a restart picks up
  source changes (the watch-based start script handles incremental
  recompiles, but build ensures dist/lib are current for test-manual)
- Rename open: example -> open: app (Ctrl-T is hardcoded to look for
  a link named 'app')

Changes to package.json:
- serve script: http-server -> http-server -a 127.0.0.1 -p 8080
  devns (dev's networking daemon) holds 0.0.0.0:8080 in a CLOSED
  socket state to proxy *.shop.dev traffic. http-server defaults to
  binding 0.0.0.0:8080, which conflicts (EADDRINUSE). Binding to
  127.0.0.1 avoids the conflict. -p 8080 is needed because without
  it, http-server uses portfinder which checks 0.0.0.0 (still
  blocked by devns) and auto-increments to 8081+.
  See: https://github.com/http-party/http-server#readme (-a defaults
  to 0.0.0.0, -p defaults to 8080)
- docs script: jekyll serve -> bundle exec jekyll serve
  Uses the Jekyll provisioned by dev up instead of relying on a
  system-installed jekyll

New files:
- .ruby-version: 3.3.6 (required by dev's ruby task; Jekyll 4.4
  compatible)
- Gemfile: gem 'jekyll', '~> 4.4' for the docs preview server
- Gemfile.lock: generated by dev up, ensures reproducible installs

Doc fixes:
- docs/readme.md: was copy-pasted from js-buy-sdk repo (wrong title,
  wrong URL, referenced non-existent doc-build/doc-serve scripts).
  Rewritten to describe this repo's docs setup accurately.
- readme.md: Documentation section no longer says to manually
  'gem install jekyll' (dev up handles it). Corrected 'gh-pages from
  main' to 'Pages builds /docs from main' (no gh-pages branch).
  Added note about http-server binding to 127.0.0.1.

Ignore files:
- .gitignore: add .jekyll-cache (Jekyll 4 cache dir)
- .npmignore: exclude /Gemfile, /Gemfile.lock, /.ruby-version so
  the Ruby tooling doesn't ship to npm consumers

Co-authored-by: AI (Pi/GLM 5.2 Fast (Fireworks) [1m]) <noreply@pi.dev>
@kdaviduik
kdaviduik force-pushed the kd-fix-dev-up-and-server branch from eba4c2c to c3154a4 Compare August 27, 2026 19:13
@kdaviduik
kdaviduik marked this pull request as ready for review August 27, 2026 19:17
@kdaviduik
kdaviduik merged commit 24d7e34 into main Aug 27, 2026
5 checks passed
@kdaviduik
kdaviduik deleted the kd-fix-dev-up-and-server branch August 27, 2026 19:17
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.

3 participants