@woodsportal/hubspot-kit 1.0.42-dev.3 → 1.0.42-dev.4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@woodsportal/hubspot-kit",
3
- "version": "1.0.42-dev.3",
3
+ "version": "1.0.42-dev.4",
4
4
  "packageManager": "pnpm@10.12.1",
5
5
  "description": "WoodsCLI — HubSpot CMS dev kit by WoodsPortal. wp CLI, Vite presets, module-config overlay, and theme/module build pipelines.",
6
6
  "type": "module",
@@ -53,6 +53,36 @@ function fail(msg) {
53
53
  process.exit(1)
54
54
  }
55
55
 
56
+ function sleep(ms) {
57
+ return new Promise((resolve) => {
58
+ setTimeout(resolve, ms)
59
+ })
60
+ }
61
+
62
+ /** Retry jsDelivr HEAD checks — propagation after git push often takes several minutes. */
63
+ async function retryJsDelivrCheck(fn, { attempts = 10, delayMs = 30_000 } = {}) {
64
+ let lastError
65
+ for (let attempt = 1; attempt <= attempts; attempt += 1) {
66
+ try {
67
+ await fn()
68
+ if (attempt > 1) {
69
+ log(`jsDelivr check passed on attempt ${attempt}/${attempts}`)
70
+ }
71
+ return
72
+ } catch (err) {
73
+ lastError = err
74
+ if (attempt >= attempts) {
75
+ break
76
+ }
77
+ log(
78
+ `jsDelivr not ready (attempt ${attempt}/${attempts}): ${err instanceof Error ? err.message : String(err)} — retrying in ${delayMs / 1000}s`,
79
+ )
80
+ await sleep(delayMs)
81
+ }
82
+ }
83
+ throw lastError instanceof Error ? lastError : new Error(String(lastError))
84
+ }
85
+
56
86
  function run(cmd, cmdArgs, options = {}) {
57
87
  const result = spawnSync(cmd, cmdArgs, {
58
88
  stdio: portalSubprocessStdio(),
@@ -166,14 +196,14 @@ async function headJsDelivrFile(base, file, { required = false } = {}) {
166
196
  }
167
197
  const msg = `${file} → HTTP ${res.status}${required ? '' : ' (jsDelivr may still be propagating — wait 5–15 min)'}`
168
198
  if (required) {
169
- fail(msg)
199
+ throw new Error(msg)
170
200
  }
171
201
  log(` ${msg}`)
172
202
  return false
173
203
  } catch (err) {
174
204
  const msg = `Could not reach jsDelivr for ${file}: ${err.message}`
175
205
  if (required) {
176
- fail(msg)
206
+ throw new Error(msg)
177
207
  }
178
208
  log(` ${msg}`)
179
209
  return false
@@ -203,7 +233,7 @@ async function headJsDelivrFiles(base, files, { required = false, concurrency =
203
233
  if (failed.length > 0) {
204
234
  const msg = `jsDelivr lazy chunk(s) not reachable: ${failed.join(', ')}`
205
235
  if (required) {
206
- fail(msg)
236
+ throw new Error(msg)
207
237
  }
208
238
  log(` ${msg}`)
209
239
  }
@@ -397,5 +427,12 @@ const manifestPath = join(sourceCdn, 'manifest.json')
397
427
  const lazyChunkFiles = readLazyChunkFilesFromManifest(manifestPath)
398
428
 
399
429
  if (!skipJsDelivrCheck) {
400
- await checkJsDelivr(config, vendorFile, appFile, appCssFile, lazyChunkFiles)
430
+ try {
431
+ await retryJsDelivrCheck(
432
+ () => checkJsDelivr(config, vendorFile, appFile, appCssFile, lazyChunkFiles),
433
+ { attempts: 10, delayMs: 30_000 },
434
+ )
435
+ } catch (err) {
436
+ fail(err instanceof Error ? err.message : String(err))
437
+ }
401
438
  }