hubspot-cms-sync 0.5.2 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/republish.mjs +9 -2
package/package.json
CHANGED
package/src/republish.mjs
CHANGED
|
@@ -73,10 +73,17 @@ async function republish(argv = process.argv.slice(2), opts = {}) {
|
|
|
73
73
|
const fut = future();
|
|
74
74
|
let ok = 0;
|
|
75
75
|
let fail = 0;
|
|
76
|
+
let skipped = 0;
|
|
76
77
|
async function schedule(kind, id, publishDate) {
|
|
77
78
|
const body = { id: String(id), publishDate: publishDate || fut };
|
|
78
79
|
const { status } = await hub('POST', `/cms/v3/${kind}/schedule`, body);
|
|
79
|
-
|
|
80
|
+
// 409 = the page already has a scheduled publish (e.g. just published by a
|
|
81
|
+
// `push --publish`, or an orphan portal page) — the desired end state, not a
|
|
82
|
+
// failure. `--all` legitimately touches pages outside our manifest; don't let
|
|
83
|
+
// their conflicts fail the deploy. Log for visibility.
|
|
84
|
+
if (status === 204) ok++;
|
|
85
|
+
else if (status === 409) { skipped++; console.error(` ${kind} ${id} -> 409 already scheduled (skip)`); }
|
|
86
|
+
else { fail++; console.error(` ${kind} ${id} -> ${status}`); }
|
|
80
87
|
}
|
|
81
88
|
|
|
82
89
|
const pages = await getAll('/cms/v3/pages/site-pages?property=id,slug,state');
|
|
@@ -91,7 +98,7 @@ async function republish(argv = process.argv.slice(2), opts = {}) {
|
|
|
91
98
|
console.log(`republishing ${posts.length} blog post(s) (preserving publishDate)`);
|
|
92
99
|
for (const p of posts) await schedule('blogs/posts', p.id, p.publishDate);
|
|
93
100
|
}
|
|
94
|
-
console.log(`scheduled ${ok} | failed ${fail} (live in ~90s)`);
|
|
101
|
+
console.log(`scheduled ${ok} | already-scheduled ${skipped} | failed ${fail} (live in ~90s)`);
|
|
95
102
|
return fail ? 1 : 0;
|
|
96
103
|
}
|
|
97
104
|
|