gatsby-attainlabs-cms 1.0.45 → 1.0.46

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/gatsby-node.js CHANGED
@@ -116,9 +116,9 @@ exports.onPreInit = async (_, pluginOptions) => {
116
116
  if (!pat) {
117
117
  console.warn(
118
118
  "⚠️ [gatsby-attainlabs-cms] No PERSONAL_ACCESS_TOKEN found. " +
119
- "Set it in your project's .env file (recommended) or pass via plugin options.\n" +
120
- "Example .env:\n" +
121
- "PERSONAL_ACCESS_TOKEN=xxxxxxx\n"
119
+ "Set it in your project's .env file (recommended) or pass via plugin options.\n" +
120
+ "Example .env:\n" +
121
+ "PERSONAL_ACCESS_TOKEN=xxxxxxx\n"
122
122
  );
123
123
  return; // stop execution early
124
124
  }
@@ -127,12 +127,12 @@ exports.onPreInit = async (_, pluginOptions) => {
127
127
  if (!brand || !brands[brand]) {
128
128
  throw new Error(
129
129
  `[gatsby-attainlabs-cms] Invalid or missing "brand" option.\n` +
130
- `You must specify one of: ${Object.keys(brands).join(", ")}\n` +
131
- `Example:\n` +
132
- `{\n` +
133
- ` resolve: "gatsby-attainlabs-cms",\n` +
134
- ` options: { brand: "Cash Money" }\n` +
135
- `}`
130
+ `You must specify one of: ${Object.keys(brands).join(", ")}\n` +
131
+ `Example:\n` +
132
+ `{\n` +
133
+ ` resolve: "gatsby-attainlabs-cms",\n` +
134
+ ` options: { brand: "Cash Money" }\n` +
135
+ `}`
136
136
  );
137
137
  }
138
138
 
@@ -281,7 +281,8 @@ exports.onPreInit = async (_, pluginOptions) => {
281
281
  return;
282
282
  }
283
283
 
284
- const tmpFile = destFile + ".part";
284
+ const uniqueId = Math.random().toString(36).substring(7);
285
+ const tmpFile = destFile + "." + uniqueId + ".part";
285
286
  const fileStream = fs.createWriteStream(tmpFile);
286
287
 
287
288
  res.pipe(fileStream);
@@ -343,9 +344,9 @@ exports.sourceNodes = async (
343
344
  if (!apiKey) {
344
345
  console.warn(
345
346
  "⚠️ [gatsby-attainlabs-cms] No TRUSTPILOT_API_KEY found. " +
346
- "Set it in your project's .env file (recommended) or pass via plugin options.\n" +
347
- "Example .env:\n" +
348
- "TRUSTPILOT_API_KEY=xxxxxxx\n"
347
+ "Set it in your project's .env file (recommended) or pass via plugin options.\n" +
348
+ "Example .env:\n" +
349
+ "TRUSTPILOT_API_KEY=xxxxxxx\n"
349
350
  );
350
351
  return; // stop execution early
351
352
  }
@@ -353,8 +354,8 @@ exports.sourceNodes = async (
353
354
  if (!brand || !businessUnitId) {
354
355
  console.warn(
355
356
  "⚠️ [gatsby-attainlabs-cms] Invalid or missing 'brand' option for Trustpilot integration. " +
356
- `Current value: '${brand}'. Supported brands: ${Object.keys(businessIds).join(", ")}. ` +
357
- "Trustpilot data will not be fetched."
357
+ `Current value: '${brand}'. Supported brands: ${Object.keys(businessIds).join(", ")}. ` +
358
+ "Trustpilot data will not be fetched."
358
359
  );
359
360
  return; // stop execution early
360
361
  }
@@ -446,9 +447,9 @@ exports.sourceNodes = async (
446
447
  createNode(node);
447
448
  }
448
449
 
449
- // Disclaimers Source Node
450
+ // Disclaimers Source Node
450
451
 
451
- const allDisclaimers = Object.values(firebaseData.disclaimers)
452
+ const allDisclaimers = Object.values(firebaseData.disclaimers);
452
453
 
453
454
  for (const disclaimer of allDisclaimers) {
454
455
  const id = createNodeId(`attain-cms-disclaimer-${disclaimer.id}`);
@@ -465,8 +466,6 @@ exports.sourceNodes = async (
465
466
  };
466
467
  createNode(node);
467
468
  }
468
-
469
-
470
469
  };
471
470
 
472
471
  exports.createPages = async ({ actions, store }, pluginOptions) => {
@@ -483,12 +482,12 @@ exports.createPages = async ({ actions, store }, pluginOptions) => {
483
482
  if (!brand || !brands[brand]) {
484
483
  throw new Error(
485
484
  `[gatsby-attainlabs-cms] Invalid or missing "brand" option.\n` +
486
- `You must specify one of: ${Object.keys(brands).join(", ")}\n` +
487
- `Example:\n` +
488
- `{\n` +
489
- ` resolve: "gatsby-attainlabs-cms",\n` +
490
- ` options: { brand: "Cash Money" }\n` +
491
- `}`
485
+ `You must specify one of: ${Object.keys(brands).join(", ")}\n` +
486
+ `Example:\n` +
487
+ `{\n` +
488
+ ` resolve: "gatsby-attainlabs-cms",\n` +
489
+ ` options: { brand: "Cash Money" }\n` +
490
+ `}`
492
491
  );
493
492
  }
494
493
  const firebaseData = await fetch(
@@ -538,7 +537,6 @@ exports.createPages = async ({ actions, store }, pluginOptions) => {
538
537
  id,
539
538
  } = page;
540
539
 
541
-
542
540
  // Create slice for each block
543
541
  await Promise.all(
544
542
  content.map(async (b) => {
@@ -557,7 +555,7 @@ exports.createPages = async ({ actions, store }, pluginOptions) => {
557
555
  },
558
556
  });
559
557
 
560
- console.log(sliceId)
558
+ console.log(sliceId);
561
559
  b["sliceId"] = sliceId;
562
560
  return b;
563
561
  })
@@ -567,10 +565,14 @@ exports.createPages = async ({ actions, store }, pluginOptions) => {
567
565
  const pageSource = await generatePage(content, layout, parentPath);
568
566
  const folderPath = parentPath ? path.join(parentPath, pageUrl) : pageUrl;
569
567
  const outPath = path.join(siteRoot, "src/cms/pages", `${folderPath}.tsx`);
570
- const gatsbyPagePath = path.join(siteRoot, "src/pages", `${folderPath}.tsx`);
568
+ const gatsbyPagePath = path.join(
569
+ siteRoot,
570
+ "src/pages",
571
+ `${folderPath}.tsx`
572
+ );
571
573
 
572
574
  await fse.outputFile(outPath, pageSource);
573
- await fse.remove(gatsbyPagePath)
575
+ await fse.remove(gatsbyPagePath);
574
576
 
575
577
  await createPage({
576
578
  path: folderPath.endsWith("index")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-attainlabs-cms",
3
- "version": "1.0.45",
3
+ "version": "1.0.46",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -31,4 +31,4 @@
31
31
  "devDependencies": {
32
32
  "typescript": "^5.9.2"
33
33
  }
34
- }
34
+ }
package/test-trust.js CHANGED
@@ -0,0 +1,29 @@
1
+ const https = require('https');
2
+
3
+ const options = {
4
+ hostname: 'your_secure_server_hostname.com', // MUST match the Common Name (CN) in your server's certificate
5
+ port: 443,
6
+ path: '/',
7
+ method: 'GET',
8
+ rejectUnauthorized: true // Ensure verification is mandatory
9
+ };
10
+
11
+ console.log(`Testing HTTPS connection to ${options.hostname}...`);
12
+ console.log(`Expecting NODE_EXTRA_CA_CERTS value: process.env.NODE_EXTRA_CA_CERTS`);
13
+
14
+ const req = https.request(options, (res) => {
15
+ console.log(`\n✅ Connection Successful! Status Code: ${res.statusCode}`);
16
+ console.log('The certificate was successfully trusted using the provided CA file.');
17
+ res.resume();
18
+ });
19
+
20
+ req.on('error', (e) => {
21
+ console.error('\n❌ Connection Failed!');
22
+ console.error('Error details:', e.message);
23
+ if (e.code === 'UNABLE_TO_VERIFY_LEAF_SIGNATURE' || e.code === 'CERT_HAS_EXPIRED') {
24
+ console.error('\nRecommendation: Ensure NODE_EXTRA_CA_CERTS is set correctly and the file path is accurate.');
25
+ console.error('Do not use NODE_TLS_REJECT_UNAUTHORIZED="0".');
26
+ }
27
+ });
28
+
29
+ req.end();