← back to Dw Silver Mylar Rename

verify.mjs

24 lines

// Re-fetch ALL scoped products live from Shopify; assert 0 residual "Silver Mylar"
// in title / descriptionHtml / option values.
import { readFileSync } from 'node:fs';
import { gql, has } from './lib.mjs';
const scope = JSON.parse(readFileSync(new URL('./data/scope.json', import.meta.url)));
const Q = `query($id: ID!){ product(id:$id){ id status title descriptionHtml options{ optionValues{ name } } } }`;
let residTitle = 0, residBody = 0, residOpt = 0, missing = 0;
const bad = [];
for (const row of scope) {
  const d = await gql(Q, { id: row.gid });
  const p = d.product;
  if (!p) { missing++; bad.push({ gid: row.gid, why: 'missing' }); continue; }
  const t = has(p.title), b = has(p.descriptionHtml);
  const o = p.options.some(op => op.optionValues.some(v => has(v.name)));
  if (t) residTitle++; if (b) residBody++; if (o) residOpt++;
  if (t || b || o) bad.push({ gid: p.gid, status: p.status, title: t, body: b, opt: o, t: p.title });
}
console.log('=== VERIFY (live Shopify, all 91) ===');
console.log('residual titles:', residTitle);
console.log('residual bodies:', residBody);
console.log('residual option values:', residOpt);
console.log('missing:', missing);
console.log(bad.length ? 'RESIDUALS:\n' + JSON.stringify(bad, null, 2) : 'CLEAN: 0 residual "Silver Mylar" across all surfaces.');