← back to Hollywood Import
stage-names-alt.mjs
31 lines
// Stage private-label name-scrub + alt-tag generation for the Hollywood (Momentum) catalog.
// READ-ONLY: reads vc_hw_names.tsv (export of vendor_catalog hollywood: id,dw_sku,mfr_sku,
// pattern_name,color_name,slug) and writes stage-names-alt.tsv for Steve's review. No DB writes.
// Decisions: CA-place naming scheme (keep existing proper names; only scrub vendor suffix),
// colors keep Momentum names, alt = "<clean name> wallcovering in <color> — Hollywood Wallcoverings".
import fs from 'node:fs';
const rows = fs.readFileSync(new URL('vc_hw_names.tsv', import.meta.url), 'utf8').trim().split('\n').map(l => l.split('\t'));
// Drop trailing vendor suffix after "|", strip Momentum/Versa, collapse whitespace.
function cleanName(s) {
if (!s) return '';
let n = s.split('|')[0];
n = n.replace(/\b(momentum(\s+textiles( and walls)?)?|versa(’s)?(\s+designed\s+surfaces)?)\b/gi, '');
return n.replace(/\s{2,}/g, ' ').replace(/\s+,/g, ',').trim();
}
const out = []; let suffixScrub = 0, missingColor = 0, leak = 0;
for (const [id, dw, mfr, name, color, slug] of rows) {
const clean = cleanName(name);
if (name !== clean && /\|/.test(name)) suffixScrub++;
if (!color) missingColor++;
const alt = color
? `${clean} wallcovering in ${color} — Hollywood Wallcoverings`
: `${clean} wallcovering — Hollywood Wallcoverings`;
if (/momentum|versa/i.test(alt)) leak++;
out.push([id, dw, mfr, name, clean, color, name !== clean ? 'name_scrubbed' : '', color ? '' : 'MISSING_COLOR', alt].join('\t'));
}
fs.writeFileSync(new URL('stage-names-alt.tsv', import.meta.url),
'id\tdw_sku\tmfr_sku\told_name\tclean_name\tcolor\tname_flag\tcolor_flag\tproposed_alt\n' + out.join('\n'));
console.log('staged', out.length, '| name scrub', suffixScrub, '| missing color', missingColor, '| alt leaks', leak);