← back to Corkwallcovering
chore: lint (HTTP guard) + refactor (dead code, idiomatic counters) on tag-apply scripts, v0.2.0 (session close)
850fc1550212f83a52c9ff30dff4ad082c0d2d17 · 2026-07-01 14:50:19 -0700 · Steve Abrams
Files touched
M package-lock.jsonM package.jsonM scripts/apply-shopify-tags-PROD.mjsM scripts/apply-shopify-tags.mjs
Diff
commit 850fc1550212f83a52c9ff30dff4ad082c0d2d17
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Wed Jul 1 14:50:19 2026 -0700
chore: lint (HTTP guard) + refactor (dead code, idiomatic counters) on tag-apply scripts, v0.2.0 (session close)
---
package-lock.json | 4 ++--
package.json | 2 +-
scripts/apply-shopify-tags-PROD.mjs | 14 +++++++++-----
scripts/apply-shopify-tags.mjs | 6 +++++-
4 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/package-lock.json b/package-lock.json
index 20862b4..1518207 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "corkwallcovering",
- "version": "0.1.1",
+ "version": "0.2.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "corkwallcovering",
- "version": "0.1.1",
+ "version": "0.2.0",
"dependencies": {
"dotenv": "^17.4.2",
"express": "^4.21.0",
diff --git a/package.json b/package.json
index 90634e2..e4aaef8 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "corkwallcovering",
- "version": "0.1.1",
+ "version": "0.2.0",
"description": "CORK WALLCOVERING — DW family vertical",
"main": "server.js",
"scripts": {
diff --git a/scripts/apply-shopify-tags-PROD.mjs b/scripts/apply-shopify-tags-PROD.mjs
index d28e9b8..ee71421 100644
--- a/scripts/apply-shopify-tags-PROD.mjs
+++ b/scripts/apply-shopify-tags-PROD.mjs
@@ -112,6 +112,7 @@ async function gql(query, variables) {
headers: { 'content-type': 'application/json', 'X-Shopify-Access-Token': TOKEN },
body: JSON.stringify({ query, variables }),
});
+ if (!r.ok) throw new Error(`Shopify HTTP ${r.status} ${r.statusText}`);
const j = await r.json();
if (j.errors) throw new Error(JSON.stringify(j.errors).slice(0, 300));
return j.data;
@@ -185,7 +186,6 @@ if (APPLY) {
}
let resolved = 0, wouldChange = 0, noChange = 0, notFound = 0, failed = 0, applied = 0;
-const samples = [];
let pg = null;
if (APPLY) pg = await pgConnect();
@@ -199,7 +199,7 @@ for (const [handle, spec] of entries) {
notFound++;
continue;
}
- resolved += (prod ? 1 : 0);
+ if (prod) resolved++;
const storeTags = prod ? prod.tags : [];
const have = new Set(storeTags.map(t => t.toLowerCase()));
@@ -207,13 +207,17 @@ for (const [handle, spec] of entries) {
if (!fresh.length) {
// Already present (idempotent) — only meaningful when we actually resolved.
- if (prod) { console.log(` · ${handle}: already has ${[...spec.want].join(', ')} — skip`); noChange++; }
- else { console.log(` ~ ${handle}: would add ${[...spec.want].join(', ')} (unresolved — no store creds)`); wouldChange++; if (samples.length < 8) samples.push({ handle, add: [...spec.want], note: 'unresolved' }); }
+ if (prod) {
+ console.log(` · ${handle}: already has ${[...spec.want].join(', ')} — skip`);
+ noChange++;
+ } else {
+ console.log(` ~ ${handle}: would add ${[...spec.want].join(', ')} (unresolved — no store creds)`);
+ wouldChange++;
+ }
continue;
}
wouldChange++;
- if (samples.length < 8) samples.push({ handle, title: spec.title, storeTagCount: storeTags.length, add: fresh });
if (APPLY) {
// PG FIRST
diff --git a/scripts/apply-shopify-tags.mjs b/scripts/apply-shopify-tags.mjs
index b56672a..361c59c 100644
--- a/scripts/apply-shopify-tags.mjs
+++ b/scripts/apply-shopify-tags.mjs
@@ -31,7 +31,10 @@ const CAP = 200;
const API = '2024-10';
function envFrom(file, key) {
- try { const m = readFileSync(file, 'utf8').match(new RegExp('^' + key + '=(.+)$', 'm')); return m ? m[1].trim().replace(/^["']|["']$/g, '') : null; } catch { return null; }
+ try {
+ const m = readFileSync(file, 'utf8').match(new RegExp('^' + key + '=(.+)$', 'm'));
+ return m ? m[1].trim().replace(/^["']|["']$/g, '') : null;
+ } catch { return null; }
}
const MASTER = path.join(os.homedir(), 'Projects/secrets-manager/.env');
const STORE = process.env.SHOPIFY_STORE_DOMAIN || envFrom(MASTER, 'SHOPIFY_STORE_DOMAIN');
@@ -44,6 +47,7 @@ async function gql(query, variables) {
headers: { 'content-type': 'application/json', 'X-Shopify-Access-Token': TOKEN },
body: JSON.stringify({ query, variables }),
});
+ if (!r.ok) throw new Error(`Shopify HTTP ${r.status} ${r.statusText}`);
const j = await r.json();
if (j.errors) throw new Error(JSON.stringify(j.errors).slice(0, 300));
return j.data;
← bbf65d9 auto-save: 2026-07-01T14:06:35 (3 files) — scripts/_cork-app
·
back to Corkwallcovering
·
chore: macstudio3 migration — reconcile from mac2 + repoint 21b50ec →