← back to Tk 10965 Zero Price Analysis

run-with-inventory-token.sh

23 lines

#!/usr/bin/env bash
# TK-10965 — invoke apply-fix.mjs / verify.mjs with the SANCTIONED inventory-write token.
# The canonical secrets-manager SHOPIFY_ADMIN_TOKEN is products-scoped only (no write_inventory).
# The DW importer runtime's SHOPIFY_ADMIN_ACCESS_TOKEN (in Designer-Wallcoverings/.env) carries
# read/write_inventory — this is the same token the sync-shopify-products.js / setInventory2026
# importer stack uses to write inventory. We load it via the importer's own dotenv path (value
# never printed) and inject it into the child process env.
set -euo pipefail
REPO="/Users/macstudio3/Projects/tk-10965-zero-price-analysis"
IMPORTER_SCRIPTS="/Users/macstudio3/Projects/Designer-Wallcoverings/shopify/scripts"
IMPORTER_ENV="/Users/macstudio3/Projects/Designer-Wallcoverings/.env"
cd "$IMPORTER_SCRIPTS"   # so the importer's local node_modules/dotenv resolves
node -e '
require("dotenv").config({ path: process.env.IMPORTER_ENV });
if(!process.env.SHOPIFY_ADMIN_ACCESS_TOKEN){ console.error("FATAL: no SHOPIFY_ADMIN_ACCESS_TOKEN (sanctioned inventory token)"); process.exit(1); }
process.env.SHOPIFY_STORE_DOMAIN = process.env.SHOPIFY_STORE_DOMAIN || "designer-laboratory-sandbox.myshopify.com";
const { spawnSync } = require("child_process");
const target = process.env.TARGET_SCRIPT;
const args = JSON.parse(process.env.TARGET_ARGS || "[]");
const r = spawnSync("node", [target, ...args], { stdio:"inherit", env:process.env, cwd: process.env.REPO });
process.exit(r.status ?? 1);
'