Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Fix worktree setup
Damian Legawiecaf3aae217137
diff --git a/scripts/worktree/make-template.sh b/scripts/worktree/make-template.shindex 63338f91b3..f13f447d18 100755--- a/scripts/worktree/make-template.sh+++ b/scripts/worktree/make-template.sh@@ -17,12 +17,15 @@ require_current_starter# rebuilds from scratch, so a config that ignored it would destroy the# developer's own spree_development database. Needs the bundle above, and# keeps stderr so a boot failure reports itself instead of looking like a-# resolution mismatch.+# resolution mismatch. Boot can print its own lines to stdout (Spree's+# missing-migration warnings on a fresh clone), so the name is fenced with a+# marker rather than taken as the whole output.resolved=$(cd server && DATABASE_NAME="$TEMPLATE_DB" \- bin/rails runner 'print ActiveRecord::Base.connection_db_config.database') || {+ bin/rails runner 'print "\n__RESOLVED__#{ActiveRecord::Base.connection_db_config.database}"') || {echo "Could not read the database configuration from server/ — see the error above." >&2exit 1}+resolved="${resolved##*__RESOLVED__}"if [ "$resolved" != "$TEMPLATE_DB" ]; thenecho "Rails resolved the development database to '$resolved', not '$TEMPLATE_DB'." >&2echo "Refusing to rebuild — check server/config/database.yml and server/.env." >&2diff --git a/scripts/worktree/setup.sh b/scripts/worktree/setup.shindex 3a5f163ddb..b7c4cf3eed 100755--- a/scripts/worktree/setup.sh+++ b/scripts/worktree/setup.sh@@ -37,10 +37,25 @@ setup_storefront() {echo "▸ Provisioning worktree '$(branch_slug)' (db: $(db_name))"+primary_root=$(git worktree list --porcelain | head -1 | sed 's/^worktree //')+if [ ! -d server ]; thenecho "▸ Cloning spree-starter into server/"git clone --depth 1 --branch 6-0-dev https://github.com/spree/spree-starter.git serverrm -rf server/.git server/.gitignore++ # Adopt the primary checkout's migration set (and its schema snapshot) before+ # the first migrate. `spree:install:migrations` stamps newly-copied gem+ # migrations with the current time, so a fresh clone would give any gem+ # migration the starter has not committed yet a version the template database+ # (built from the primary's server) has never seen — and db:migrate would+ # re-run it against tables the template already has. Copying the primary's+ # files keeps the versions identical; migrations this branch adds on top are+ # still installed and run normally below.+ if [ "$primary_root" != "$(pwd)" ] && [ -d "$primary_root/server/db/migrate" ]; then+ rsync -a --delete "$primary_root/server/db/migrate/" server/db/migrate/+ [ -f "$primary_root/server/db/schema.rb" ] && cp "$primary_root/server/db/schema.rb" server/db/schema.rb+ fifiif [ ! -f server/.env ]; then@@ -101,7 +116,6 @@ if ! db_exists "$(db_name)"; thenfi# Warm boot caches from the primary checkout's server, if it has any.-primary_root=$(git worktree list --porcelain | head -1 | sed 's/^worktree //')if [ -d "$primary_root/server/tmp/cache/bootsnap" ] && [ ! -d server/tmp/cache/bootsnap ]; thenmkdir -p server/tmp/cachecp -R "$primary_root/server/tmp/cache/bootsnap" server/tmp/cache/