-
Notifications
You must be signed in to change notification settings - Fork 16
[DASH-1732] [templates] add build step to create javascript templates #75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
syd-shields
merged 26 commits into
dev
from
sydshields/dash-1732-turn-existing-templates-in-js-files
May 13, 2026
Merged
Changes from 18 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
3cdb1e7
init
syd-shields 2985f0f
add a build step that turns new ts templates into js in CI
syd-shields 2942385
add file filter to build script
syd-shields 6cc2dd6
add built js templates
syd-shields 969f904
add exclude flag
syd-shields f3f7984
add comments to explain build filters
syd-shields ae17bb9
add build step to run on dev branch in CI
syd-shields 48fc473
regen templats on each pr merge
syd-shields 8ea723d
include all readme, package json and env examples in build
syd-shields c7dbcce
get paths to build js files first so that the entire repo isn't delet…
syd-shields fc8fd04
remove built js files
syd-shields 3173ce4
only build js files to production branch
syd-shields ac53074
remove build javascript workflow
syd-shields 541e995
before recursing, skip directories whose basename is in DEFAULT_EXCLU…
syd-shields b17759b
before recursing, skip directories whose basename is in DEFAULT_EXCLU…
syd-shields ed33a0c
if there are zero playground compatible templates, do not call build-…
syd-shields 5b91a7e
add test-production branch support
syd-shields 5d56277
build js templates
syd-shields 0070df7
remove built js files
syd-shields 009a835
add pkg.type = module to adaptPackageJsonForJavaScript so it's uncond…
syd-shields a240b02
consolidate workflows to one plauground.yml file to remove need to ma…
syd-shields a143d03
write contents to test-production and production branches
syd-shields 1ba6a37
use hardcoded branch names instead of unused var
syd-shields 3e85383
add --no-verify flag to build
syd-shields 912d149
add stripLeadingTscBuildCommand to handle when multiple commands exis…
syd-shields 2a862c0
add parseBuildOptions to parse CLI flags at once instead of in multip…
syd-shields File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # When merging changes under these paths to `production`, require review from the | ||
| # Dashboard team. | ||
| /javascript/ @browserbase/dashboard | ||
| /scripts/fetch-playground-typescript-dirs.mjs @browserbase/dashboard | ||
| /scripts/validate-playground-templates.mjs @browserbase/dashboard | ||
| /scripts/playground-ci.mjs @browserbase/dashboard | ||
| /scripts/lib/playground-checks.mjs @browserbase/dashboard | ||
| /.github/workflows/playground-production.yml @browserbase/dashboard |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| # Validates TypeScript → JavaScript builds for templates exposed by the public | ||
| # templates API (playgroundRunnable). Intended for the `production` branch workflow | ||
| # described in https://github.com/browserbase/templates (branch protection: require | ||
| # this check + Dashboard team review before merge). | ||
| # | ||
| # Set TEMPLATES_API_URL to override the default public endpoint (e.g. staging). | ||
|
|
||
| name: Playground templates (production) | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - production | ||
| push: | ||
| branches: | ||
| - production | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| jobs: | ||
| playground-templates: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Clean javascript output directory | ||
| run: rm -rf javascript && mkdir -p javascript | ||
|
|
||
| - name: Setup pnpm | ||
| uses: pnpm/action-setup@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
| cache: pnpm | ||
|
|
||
| - name: Install dependencies | ||
| run: pnpm install --frozen-lockfile | ||
|
|
||
| - name: Build and validate playground TypeScript templates | ||
| env: | ||
| TEMPLATES_API_URL: ${{ vars.TEMPLATES_API_URL }} | ||
| run: pnpm run ci:playground | ||
|
|
||
| - name: Commit and push playground javascript (push to production only) | ||
| if: github.event_name == 'push' | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
| git add -A javascript/ | ||
| if git diff --staged --quiet; then | ||
| echo "No javascript changes to commit." | ||
| else | ||
| git commit -m "chore: regenerate playground javascript templates" | ||
| git push | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| # Validates TypeScript → JavaScript builds for templates exposed by the public | ||
| # templates API (playgroundRunnable). Intended for the `test-production` branch workflow | ||
| # described in https://github.com/browserbase/templates (branch protection: require | ||
| # this check + Dashboard team review before merge). | ||
| # | ||
| # Set TEMPLATES_API_URL to override the default public endpoint (e.g. staging). | ||
|
|
||
| name: Playground templates (test production) | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - test-production | ||
| push: | ||
| branches: | ||
| - test-production | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| jobs: | ||
| playground-templates: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Clean javascript output directory | ||
| run: rm -rf javascript && mkdir -p javascript | ||
|
|
||
| - name: Setup pnpm | ||
| uses: pnpm/action-setup@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
| cache: pnpm | ||
|
|
||
| - name: Install dependencies | ||
| run: pnpm install --frozen-lockfile | ||
|
|
||
| - name: Build and validate playground TypeScript templates | ||
| env: | ||
| TEMPLATES_API_URL: ${{ vars.TEMPLATES_API_URL }} | ||
| run: pnpm run ci:playground | ||
|
|
||
| - name: Commit and push playground javascript (push to test-production only) | ||
| if: github.event_name == 'push' | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
| git add -A javascript/ | ||
| if git diff --staged --quiet; then | ||
| echo "No javascript changes to commit." | ||
| else | ||
| git commit -m "chore: regenerate playground javascript templates" | ||
| git push | ||
| fi | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| # Browserbase credentials - get these from https://www.browserbase.com/settings | ||
| BROWSERBASE_API_KEY=your_browserbase_api_key |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| # Amazon Global Price Comparison | ||
|
|
||
| ## AT A GLANCE | ||
|
|
||
| - Goal: compare Amazon product prices across multiple countries using geolocation proxies. | ||
| - Uses Browserbase's managed proxy infrastructure to route traffic through different geographic locations (US, UK, Germany, France, Italy, Spain). | ||
| - Extracts structured product data (name, price, rating, reviews) using Stagehand's extraction capabilities with Zod schema validation. | ||
| - Sequential processing shows how different proxy locations return different pricing from the same Amazon search. | ||
| - Docs → https://docs.browserbase.com/features/proxies | ||
|
|
||
| ## GLOSSARY | ||
|
|
||
| - geolocation proxies: route traffic through specific geographic locations (city, country) to access location-specific content and pricing | ||
| Docs → https://docs.browserbase.com/features/proxies#set-proxy-geolocation | ||
| - extract: extract structured data from web pages using natural language instructions and Zod schemas | ||
| Docs → https://docs.stagehand.dev/basics/extract | ||
| - proxies: Browserbase's managed proxy infrastructure supporting 201+ countries for geolocation-based routing | ||
| Docs → https://docs.browserbase.com/features/proxies | ||
|
|
||
| ## QUICKSTART | ||
|
|
||
| 1. cd amazon-global-price-comparison | ||
| 2. pnpm install | ||
| 3. cp .env.example .env | ||
| 4. Add your Browserbase API key to .env | ||
| 5. pnpm start | ||
|
|
||
| ## EXPECTED OUTPUT | ||
|
|
||
| - Creates Browserbase sessions with geolocation proxies for each country (US, UK, DE, FR, IT, ES) | ||
| - Navigates to Amazon search results through location-specific proxies | ||
| - Extracts product name, price, rating, and review count for each location | ||
| - Displays formatted comparison table showing price differences across countries | ||
| - Outputs JSON results for programmatic use | ||
|
|
||
| ## COMMON PITFALLS | ||
|
|
||
| - Browserbase Developer plan or higher is required to use proxies | ||
| - "Cannot find module": ensure all dependencies are installed (`pnpm install`) | ||
| - Missing credentials: verify .env contains BROWSERBASE_API_KEY | ||
| - Geolocation fields are case-insensitive (city, country can be any case) | ||
| - Amazon may show different products in different regions - comparison works best for globally available products | ||
| - ERR_TUNNEL_CONNECTION_FAILED: indicates either a temporary proxy hiccup or a site unsupported by built-in proxies | ||
|
|
||
| ## USE CASES | ||
|
|
||
| • Price arbitrage: Find the best country to purchase products from for international shipping | ||
| • Market research: Compare pricing strategies across different Amazon regions | ||
| • Competitive analysis: Monitor how competitors price products globally | ||
| • Travel shopping: Check prices before international trips to plan purchases | ||
|
|
||
| ## NEXT STEPS | ||
|
|
||
| • Add more countries: Extend the COUNTRIES array with additional regions (Japan, Australia, Canada, etc.) | ||
| • Currency conversion: Add real-time currency conversion to normalize prices for comparison | ||
| • Price tracking: Store results over time to track price changes across regions | ||
| • Email alerts: Send notifications when price drops below a threshold in any country | ||
|
|
||
| ## HELPFUL RESOURCES | ||
|
|
||
| 📚 Stagehand Docs: https://docs.stagehand.dev/v3/first-steps/introduction | ||
| 🎮 Browserbase: https://www.browserbase.com | ||
| 💡 Try it out: https://www.browserbase.com/playground | ||
| 🔧 Templates: https://www.browserbase.com/templates | ||
| 📧 Need help? support@browserbase.com | ||
| 💬 Discord: http://stagehand.dev/discord |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.