gatsby-attainlabs-cms 1.0.45 → 1.0.47

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.
@@ -12,7 +12,12 @@ export default function SliceWrapper({ sliceContext, data, }) {
12
12
  console.warn(`Component "${pathFormatted}" not found in CMS_COMPONENTS`);
13
13
  return null;
14
14
  }
15
- return (_jsx(Component, { ...props, trustPilotData: data.allTrustPilotReviews.edges[0].node, disclaimers: data.allDisclaimers, blogs: {
15
+ return (_jsx(Component, { ...props, trustPilotData: data.allTrustPilotReviews.edges[0].node,
16
+ /* CHECK_DISCLAIMERS_START */
17
+ disclaimers: data.allDisclaimers,
18
+ /* CHECK_DISCLAIMERS_END */
19
+ /* CHECK_BLOGS_START */
20
+ blogs: {
16
21
  sliderBlogs: {
17
22
  ...data.sliderBlogs,
18
23
  },
@@ -54,15 +59,18 @@ export const TrustPilotQuery = graphql `
54
59
  }
55
60
  }
56
61
  }
62
+ # CHECK_DISCLAIMERS_START
57
63
  allDisclaimers: allAttainLabsCmsDisclaimers {
58
- edges {
64
+ edges {
59
65
  node {
60
- content
61
- published
62
- order
66
+ content
67
+ published
68
+ order
63
69
  }
64
70
  }
65
71
  }
72
+ # CHECK_DISCLAIMERS_END
73
+ # CHECK_BLOGS_START
66
74
  allBlogs: allAttainLabsCmsBlogs {
67
75
  edges {
68
76
  node {
@@ -126,5 +134,6 @@ export const TrustPilotQuery = graphql `
126
134
  }
127
135
  }
128
136
  }
137
+ # CHECK_BLOGS_END
129
138
  }
130
139
  `;
package/gatsby-node.js CHANGED
@@ -101,6 +101,7 @@ exports.onPreInit = async (_, pluginOptions) => {
101
101
  azureBranch,
102
102
  personalAccessToken: patOption,
103
103
  environment,
104
+ fetch: fetchConfig,
104
105
  } = pluginOptions;
105
106
 
106
107
  // Try env first, then plugin option fallback
@@ -116,9 +117,9 @@ exports.onPreInit = async (_, pluginOptions) => {
116
117
  if (!pat) {
117
118
  console.warn(
118
119
  "⚠️ [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"
120
+ "Set it in your project's .env file (recommended) or pass via plugin options.\n" +
121
+ "Example .env:\n" +
122
+ "PERSONAL_ACCESS_TOKEN=xxxxxxx\n"
122
123
  );
123
124
  return; // stop execution early
124
125
  }
@@ -127,12 +128,12 @@ exports.onPreInit = async (_, pluginOptions) => {
127
128
  if (!brand || !brands[brand]) {
128
129
  throw new Error(
129
130
  `[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
- `}`
131
+ `You must specify one of: ${Object.keys(brands).join(", ")}\n` +
132
+ `Example:\n` +
133
+ `{\n` +
134
+ ` resolve: "gatsby-attainlabs-cms",\n` +
135
+ ` options: { brand: "Cash Money" }\n` +
136
+ `}`
136
137
  );
137
138
  }
138
139
 
@@ -183,8 +184,38 @@ exports.onPreInit = async (_, pluginOptions) => {
183
184
  }
184
185
  const fileName = path.basename(localPath);
185
186
  const destFile = path.join(targetPath, fileName);
186
- fs.copyFileSync(localPath, destFile);
187
- console.log(`✅ Copied ${destFile}`);
187
+
188
+ if (fileName === "sliceWrapper.tsx") {
189
+ let content = fs.readFileSync(localPath, "utf8");
190
+
191
+ if (!fetchConfig || !fetchConfig.includes("blogs")) {
192
+ content = content.replace(
193
+ /# CHECK_BLOGS_START[\s\S]*?# CHECK_BLOGS_END/g,
194
+ ""
195
+ );
196
+ content = content.replace(
197
+ /\/\* CHECK_BLOGS_START \*\/[\s\S]*?\/\* CHECK_BLOGS_END \*\//g,
198
+ ""
199
+ );
200
+ }
201
+
202
+ if (!fetchConfig || !fetchConfig.includes("disclaimers")) {
203
+ content = content.replace(
204
+ /# CHECK_DISCLAIMERS_START[\s\S]*?# CHECK_DISCLAIMERS_END/g,
205
+ ""
206
+ );
207
+ content = content.replace(
208
+ /\/\* CHECK_DISCLAIMERS_START \*\/[\s\S]*?\/\* CHECK_DISCLAIMERS_END \*\//g,
209
+ ""
210
+ );
211
+ }
212
+
213
+ fs.writeFileSync(destFile, content);
214
+ console.log(`✅ Copied and transformed ${destFile}`);
215
+ } else {
216
+ fs.copyFileSync(localPath, destFile);
217
+ console.log(`✅ Copied ${destFile}`);
218
+ }
188
219
  });
189
220
 
190
221
  // Loop through targets
@@ -281,7 +312,8 @@ exports.onPreInit = async (_, pluginOptions) => {
281
312
  return;
282
313
  }
283
314
 
284
- const tmpFile = destFile + ".part";
315
+ const uniqueId = Math.random().toString(36).substring(7);
316
+ const tmpFile = destFile + "." + uniqueId + ".part";
285
317
  const fileStream = fs.createWriteStream(tmpFile);
286
318
 
287
319
  res.pipe(fileStream);
@@ -320,7 +352,12 @@ exports.sourceNodes = async (
320
352
  pluginOptions
321
353
  ) => {
322
354
  const { createNode } = actions;
323
- const { trustpilotApiKey, brand, environment } = pluginOptions;
355
+ const {
356
+ trustpilotApiKey,
357
+ brand,
358
+ environment,
359
+ fetch: fetchConfig,
360
+ } = pluginOptions;
324
361
  const apiKey = process.env.TRUSTPILOT_API_KEY || trustpilotApiKey;
325
362
 
326
363
  if (environment === "dev") {
@@ -343,9 +380,9 @@ exports.sourceNodes = async (
343
380
  if (!apiKey) {
344
381
  console.warn(
345
382
  "⚠️ [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"
383
+ "Set it in your project's .env file (recommended) or pass via plugin options.\n" +
384
+ "Example .env:\n" +
385
+ "TRUSTPILOT_API_KEY=xxxxxxx\n"
349
386
  );
350
387
  return; // stop execution early
351
388
  }
@@ -353,8 +390,8 @@ exports.sourceNodes = async (
353
390
  if (!brand || !businessUnitId) {
354
391
  console.warn(
355
392
  "⚠️ [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."
393
+ `Current value: '${brand}'. Supported brands: ${Object.keys(businessIds).join(", ")}. ` +
394
+ "Trustpilot data will not be fetched."
358
395
  );
359
396
  return; // stop execution early
360
397
  }
@@ -409,7 +446,6 @@ exports.sourceNodes = async (
409
446
  }
410
447
 
411
448
  // Blogs node creation
412
-
413
449
  const fetchData = async () => {
414
450
  try {
415
451
  const response = await fetch(
@@ -426,47 +462,47 @@ exports.sourceNodes = async (
426
462
  }
427
463
  };
428
464
 
429
- const firebaseData = await fetchData();
430
-
431
- const allBlogs = getAllBlogs(firebaseData.pages);
432
-
433
- for (const blog of allBlogs) {
434
- const id = createNodeId(`attain-cms-blog-${blog.id}`);
435
- const node = {
436
- ...blog,
437
- id,
438
- _id: blog.id,
439
- parent: null,
440
- children: [],
441
- internal: {
442
- type: "AttainLabsCmsBlogs",
443
- contentDigest: createContentDigest(blog),
444
- },
445
- };
446
- createNode(node);
447
- }
448
-
449
- // Disclaimers Source Node
450
-
451
- const allDisclaimers = Object.values(firebaseData.disclaimers)
465
+ if (fetchConfig) {
466
+ const firebaseData = await fetchData();
467
+ if (fetchConfig.includes("blogs")) {
468
+ const allBlogs = getAllBlogs(firebaseData.pages);
469
+ for (const blog of allBlogs) {
470
+ const id = createNodeId(`attain-cms-blog-${blog.id}`);
471
+ const node = {
472
+ ...blog,
473
+ id,
474
+ _id: blog.id,
475
+ parent: null,
476
+ children: [],
477
+ internal: {
478
+ type: "AttainLabsCmsBlogs",
479
+ contentDigest: createContentDigest(blog),
480
+ },
481
+ };
482
+ createNode(node);
483
+ }
484
+ }
452
485
 
453
- for (const disclaimer of allDisclaimers) {
454
- const id = createNodeId(`attain-cms-disclaimer-${disclaimer.id}`);
455
- const node = {
456
- ...disclaimer,
457
- id,
458
- _id: disclaimer.id,
459
- parent: null,
460
- children: [],
461
- internal: {
462
- type: "AttainLabsCmsDisclaimers",
463
- contentDigest: createContentDigest(disclaimer),
464
- },
465
- };
466
- createNode(node);
486
+ // Disclaimers Source Node
487
+ if (fetchConfig.includes("disclaimers")) {
488
+ const allDisclaimers = Object.values(firebaseData.disclaimers);
489
+ for (const disclaimer of allDisclaimers) {
490
+ const id = createNodeId(`attain-cms-disclaimer-${disclaimer.id}`);
491
+ const node = {
492
+ ...disclaimer,
493
+ id,
494
+ _id: disclaimer.id,
495
+ parent: null,
496
+ children: [],
497
+ internal: {
498
+ type: "AttainLabsCmsDisclaimers",
499
+ contentDigest: createContentDigest(disclaimer),
500
+ },
501
+ };
502
+ createNode(node);
503
+ }
504
+ }
467
505
  }
468
-
469
-
470
506
  };
471
507
 
472
508
  exports.createPages = async ({ actions, store }, pluginOptions) => {
@@ -483,12 +519,12 @@ exports.createPages = async ({ actions, store }, pluginOptions) => {
483
519
  if (!brand || !brands[brand]) {
484
520
  throw new Error(
485
521
  `[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
- `}`
522
+ `You must specify one of: ${Object.keys(brands).join(", ")}\n` +
523
+ `Example:\n` +
524
+ `{\n` +
525
+ ` resolve: "gatsby-attainlabs-cms",\n` +
526
+ ` options: { brand: "Cash Money" }\n` +
527
+ `}`
492
528
  );
493
529
  }
494
530
  const firebaseData = await fetch(
@@ -538,7 +574,6 @@ exports.createPages = async ({ actions, store }, pluginOptions) => {
538
574
  id,
539
575
  } = page;
540
576
 
541
-
542
577
  // Create slice for each block
543
578
  await Promise.all(
544
579
  content.map(async (b) => {
@@ -557,7 +592,7 @@ exports.createPages = async ({ actions, store }, pluginOptions) => {
557
592
  },
558
593
  });
559
594
 
560
- console.log(sliceId)
595
+ console.log(sliceId);
561
596
  b["sliceId"] = sliceId;
562
597
  return b;
563
598
  })
@@ -567,10 +602,14 @@ exports.createPages = async ({ actions, store }, pluginOptions) => {
567
602
  const pageSource = await generatePage(content, layout, parentPath);
568
603
  const folderPath = parentPath ? path.join(parentPath, pageUrl) : pageUrl;
569
604
  const outPath = path.join(siteRoot, "src/cms/pages", `${folderPath}.tsx`);
570
- const gatsbyPagePath = path.join(siteRoot, "src/pages", `${folderPath}.tsx`);
605
+ const gatsbyPagePath = path.join(
606
+ siteRoot,
607
+ "src/pages",
608
+ `${folderPath}.tsx`
609
+ );
571
610
 
572
611
  await fse.outputFile(outPath, pageSource);
573
- await fse.remove(gatsbyPagePath)
612
+ await fse.remove(gatsbyPagePath);
574
613
 
575
614
  await createPage({
576
615
  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.47",
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
+ }
@@ -31,7 +31,10 @@ export default function SliceWrapper({
31
31
  <Component
32
32
  {...props}
33
33
  trustPilotData={data.allTrustPilotReviews.edges[0].node}
34
+ /* CHECK_DISCLAIMERS_START */
34
35
  disclaimers={data.allDisclaimers}
36
+ /* CHECK_DISCLAIMERS_END */
37
+ /* CHECK_BLOGS_START */
35
38
  blogs={{
36
39
  sliderBlogs: {
37
40
  ...data.sliderBlogs,
@@ -40,6 +43,7 @@ export default function SliceWrapper({
40
43
  ...data.allBlogs,
41
44
  },
42
45
  }}
46
+ /* CHECK_BLOGS_END */
43
47
  />
44
48
  );
45
49
  }
@@ -77,15 +81,18 @@ export const TrustPilotQuery = graphql`
77
81
  }
78
82
  }
79
83
  }
84
+ # CHECK_DISCLAIMERS_START
80
85
  allDisclaimers: allAttainLabsCmsDisclaimers {
81
- edges {
86
+ edges {
82
87
  node {
83
- content
84
- published
85
- order
88
+ content
89
+ published
90
+ order
86
91
  }
87
92
  }
88
93
  }
94
+ # CHECK_DISCLAIMERS_END
95
+ # CHECK_BLOGS_START
89
96
  allBlogs: allAttainLabsCmsBlogs {
90
97
  edges {
91
98
  node {
@@ -149,5 +156,6 @@ export const TrustPilotQuery = graphql`
149
156
  }
150
157
  }
151
158
  }
159
+ # CHECK_BLOGS_END
152
160
  }
153
161
  `;
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();