← back to Pattern Vault
wpb-uploaders/run.js
45 lines
#!/usr/bin/env node
/*
* WPB marketplace uploader dispatcher.
* node run.js <platform> <manifest.json>
* node run.js list
*
* Platforms: etsy, creativemarket, redbubble, society6, patternbank.
* ALL DISARMED by default — an upload only fires live if platforms/<key>.ARMED exists
* (arming is Steve-gated). Without it, every platform runs dry-run (no live action).
* Fernwick/Spoonflower keeps its own dedicated pipeline (whimsical-compare/daily) — not here.
*/
const path = require('path'), fs = require('fs');
const { run } = require('./lib/base');
const PLATFORMS = ['etsy', 'creativemarket', 'redbubble', 'society6', 'patternbank'];
const [, , platform, manifestArg] = process.argv;
function loadPlatform(key) { return require(path.join(__dirname, 'platforms', `${key}.js`)); }
(async () => {
if (!platform || platform === 'list') {
console.log('WPB uploaders (all DISARMED until Steve arms each):');
for (const k of PLATFORMS) {
const c = loadPlatform(k);
const armed = fs.existsSync(path.join(__dirname, 'platforms', `${k}.ARMED`));
console.log(` ${k.padEnd(14)} → ${c.name.padEnd(16)} brand=${c.brand.padEnd(24)} ${c.apiBased ? '[API]' : '[web]'} armed=${armed}`);
}
return;
}
if (!PLATFORMS.includes(platform)) { console.error(`unknown platform "${platform}" — one of ${PLATFORMS.join(', ')}`); process.exit(1); }
const cfg = loadPlatform(platform);
const manifest = manifestArg || path.join(require('os').homedir(), 'Projects/pattern-vault/data/catalog.json');
if (cfg.apiBased) { // Etsy path — no browser
if (process.argv.includes('--dry-run') && cfg.dryRun) {
console.log(JSON.stringify({ platform: cfg.key, apiBased: true, ...cfg.dryRun() }, null, 2));
return;
}
const r = await cfg.uploadFn();
console.log(JSON.stringify({ platform: cfg.key, apiBased: true, result: r }, null, 2));
return;
}
await run(cfg, manifest);
})();