[object Object]

← back to Japan Enrich

japan: viewer strips -sg subdomain suffix (koroseal-sg→Koroseal scope, avoids clobbering existing vendor subdomains); create-distributor-dns.sh (16 free + 3 -sg records, idempotent)

a6bb3a260a41425a5685cd1cb92e61c0fd988c22 · 2026-07-06 17:13:30 -0700 · Steve

Files touched

Diff

commit a6bb3a260a41425a5685cd1cb92e61c0fd988c22
Author: Steve <steve@designerwallcoverings.com>
Date:   Mon Jul 6 17:13:30 2026 -0700

    japan: viewer strips -sg subdomain suffix (koroseal-sg→Koroseal scope, avoids clobbering existing vendor subdomains); create-distributor-dns.sh (16 free + 3 -sg records, idempotent)
---
 scripts/create-distributor-dns.sh | 25 +++++++++++++++++++++++++
 viewer-local/server.js            |  6 ++++--
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/scripts/create-distributor-dns.sh b/scripts/create-distributor-dns.sh
new file mode 100755
index 0000000..4accb7b
--- /dev/null
+++ b/scripts/create-distributor-dns.sh
@@ -0,0 +1,25 @@
+#!/usr/bin/env bash
+# Create the 19 distributor microsite subdomains in Cloudflare (dns-only A → Kamatera),
+# matching the existing DW vendor-subdomain pattern. Idempotent (skips existing).
+# GATED: run under Steve (DNS on the live designerwallcoverings.com zone).
+#   bash scripts/create-distributor-dns.sh
+set -uo pipefail
+CF=$(grep -m1 -hoE "CLOUDFLARE_API_TOKEN=.*" ~/Projects/secrets-manager/.env | cut -d= -f2- | tr -d '"'"'"'')
+ZID="e4b88c70e4c949f4556cc693133c2f42"   # designerwallcoverings.com
+IP="45.61.58.125"
+# 16 free slugs (plain) + 3 colliders as <slug>-sg (koroseal/harlequin/cole-son already own the plain subdomain)
+SUBS="j-josephson eijffinger omexco goodrich p3tec vahallan la-scala-milano zambaiti-parati \
+carlise-co zintra versa-design-surfaces sangetsu greenland texam texdecor zambaiti \
+koroseal-sg harlequin-sg cole-son-sg"
+created=0; skipped=0; failed=0
+for s in $SUBS; do
+  name="$s.designerwallcoverings.com"
+  exists=$(curl -s -H "Authorization: Bearer $CF" "https://api.cloudflare.com/client/v4/zones/$ZID/dns_records?name=$name&type=A" | python3 -c "import sys,json;print(len(json.load(sys.stdin).get('result',[])))")
+  if [ "$exists" != "0" ]; then echo "  skip (exists): $name"; skipped=$((skipped+1)); continue; fi
+  ok=$(curl -s -X POST -H "Authorization: Bearer $CF" -H "Content-Type: application/json" \
+    "https://api.cloudflare.com/client/v4/zones/$ZID/dns_records" \
+    -d "{\"type\":\"A\",\"name\":\"$name\",\"content\":\"$IP\",\"ttl\":1,\"proxied\":false}" \
+    | python3 -c "import sys,json;print(json.load(sys.stdin).get('success'))")
+  [ "$ok" = "True" ] && { echo "  ✓ created: $name"; created=$((created+1)); } || { echo "  ✗ FAILED: $name"; failed=$((failed+1)); }
+done
+echo "created=$created skipped=$skipped failed=$failed"
diff --git a/viewer-local/server.js b/viewer-local/server.js
index 587a70b..1497bfe 100644
--- a/viewer-local/server.js
+++ b/viewer-local/server.js
@@ -388,8 +388,10 @@ function hostScope(req) {
     return { id: 'china', label: 'China — Greenland', sub: 'Greenland vendor · staged offline · read-only preview',
       sources: ['greenland'], tabs: [{ src: 'greenland', label: 'Greenland' }] };
   }
-  // per-distributor microsite: <slug>.designerwallcoverings.com → only that distributor's rows
-  const sub = host.split('.')[0];
+  // per-distributor microsite: <slug>.designerwallcoverings.com → only that distributor's rows.
+  // Colliding brands (koroseal/harlequin/cole-son already own a subdomain) use <slug>-sg;
+  // strip the -sg so both koroseal. and koroseal-sg. resolve to the same distributor scope.
+  const sub = host.split('.')[0].replace(/-sg$/, '');
   if (DIST_SLUGS[sub] && !['japan', 'china', 'www', 'localhost'].includes(sub)) {
     const label = DIST_SLUGS[sub];
     return { id: 'dist-' + sub, label, sub: `${label} · Sangetsu distribution · internal · read-only`,

← b34412a japan: loader gives each distributor its OWN vendor id + uni  ·  back to Japan Enrich  ·  japan: wrapper scripts for the 3 Steve-gated steps — create- d08e031 →