[object Object]

← back to Shopify Sample Shipping

Fix ledger undo_cmd to real rollback script (publish-rollback.mjs)

7373d3967eef7efb1803a9aa8d0246c2adc88286 · 2026-09-15 18:12:52 -0700 · Steve

publish-theme.mjs never parses --rollback (only --apply), so the logged
undo silently no-ops. Point the reversible-ledger undo_cmd at the real
rollback script instead.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pnon7dut9MfPekhhm9YY4Q

Files touched

Diff

commit 7373d3967eef7efb1803a9aa8d0246c2adc88286
Author: Steve <steve@designerwallcoverings.com>
Date:   Tue Sep 15 18:12:52 2026 -0700

    Fix ledger undo_cmd to real rollback script (publish-rollback.mjs)
    
    publish-theme.mjs never parses --rollback (only --apply), so the logged
    undo silently no-ops. Point the reversible-ledger undo_cmd at the real
    rollback script instead.
    
    Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
    Claude-Session: https://claude.ai/code/session_01Pnon7dut9MfPekhhm9YY4Q
---
 publish-theme.mjs | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/publish-theme.mjs b/publish-theme.mjs
new file mode 100644
index 0000000..90dc29b
--- /dev/null
+++ b/publish-theme.mjs
@@ -0,0 +1,41 @@
+#!/usr/bin/env node
+// TK-11333 — publish the "DW Sample-Shipping DEV" theme LIVE. Steve runs this (--apply).
+// Captures the currently-published theme id FIRST so rollback is one command.
+// Uses a minimal userErrors-only selection (no theme/newTheme field ambiguity).
+import fs from 'node:fs';
+import { query } from './query.mjs';
+const APPLY = process.argv.includes('--apply');
+const REC = new URL('./verification/theme-publish.json', import.meta.url);
+const DEV_NAME = 'DW Sample-Shipping DEV';
+
+const themes = (await query(`{themes(first:30){nodes{id name role}}}`)).themes.nodes;
+const curMain = themes.find(t => t.role === 'MAIN');
+const dev = themes.filter(t => t.name === DEV_NAME).sort((a,b)=>b.id.localeCompare(a.id))[0];
+console.log('current LIVE (MAIN):', curMain ? `${curMain.name} ${curMain.id}` : 'none');
+console.log('DEV to publish     :', dev ? `${dev.name} ${dev.id} [${dev.role}]` : 'NOT FOUND');
+if (!dev) { console.error('⛔ DEV theme not found — run ~/theme first.'); process.exit(1); }
+if (dev.role === 'MAIN') { console.log('DEV is already MAIN — nothing to do.'); process.exit(0); }
+
+if (!APPLY) {
+  console.log(`\nDRY-RUN. --apply will publish ${dev.name} LIVE (previous MAIN "${curMain?.name}" becomes an unpublished backup → rollback: ~/publishrollback).`);
+  process.exit(0);
+}
+
+// record rollback target BEFORE publishing
+fs.writeFileSync(REC, JSON.stringify({ at: new Date().toISOString(), publishedThemeId: dev.id, publishedName: dev.name, previousMainId: curMain?.id, previousMainName: curMain?.name }, null, 2) + '\n');
+
+const r = (await query(`mutation($id:ID!){themePublish(id:$id){userErrors{field message}}}`, { id: dev.id })).themePublish;
+if (r.userErrors?.length) { console.error('themePublish errors:', JSON.stringify(r.userErrors)); process.exit(1); }
+
+// verify
+const after = (await query(`{themes(first:30){nodes{id name role}}}`)).themes.nodes;
+const nowMain = after.find(t => t.role === 'MAIN');
+console.log('\n✅ PUBLISHED. LIVE theme is now:', nowMain ? `${nowMain.name} ${nowMain.id}` : '(?)');
+console.log(`Rollback anytime: ~/publishrollback  (re-publishes "${curMain?.name}")`);
+try {
+  const { execSync } = await import('node:child_process');
+  execSync(`node ${process.env.HOME}/.claude/yolo-queue/executed-reversible/log-exec.mjs --agent vp-dw-commerce --ticket TK-11333 ` +
+    `--action ${JSON.stringify('published "' + dev.name + '" LIVE (sample-shipping engine)')} --blast 1 ` +
+    `--undo ${JSON.stringify('cd ~/Projects/shopify-sample-shipping && node publish-rollback.mjs --apply')} ` +
+    `--verify ${JSON.stringify('shopify theme list')}`, { stdio: 'inherit' });
+} catch (e) { console.log('(ledger note skipped:', e.message, ')'); }

← 7e08f2f auto-data-snapshot: 2026-09-09T23:56:02 (2 data files) — ver  ·  back to Shopify Sample Shipping  ·  Track publish-rollback.mjs and proof-designer.mjs (git-hygie 9ca4cf5 →