mod-build 3.7.7-beta.1 → 3.7.9-beta.1
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/CHANGELOG.md +6 -2
- package/gulp-tasks/grab-cdn.js +22 -13
- package/gulp-tasks/templates.js +55 -20
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 3.7.
|
|
3
|
+
## 3.7.9
|
|
4
4
|
|
|
5
|
-
-
|
|
5
|
+
- Updated `isBranded` sites to grab the display name from HS Form Service API to add to the `brandedConsentLanguage`.
|
|
6
|
+
|
|
7
|
+
## 3.7.8
|
|
8
|
+
|
|
9
|
+
- removed race condition from grab-cdn task.
|
|
6
10
|
|
|
7
11
|
## 3.7.6
|
|
8
12
|
|
package/gulp-tasks/grab-cdn.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
+
/* globals Promise */
|
|
1
2
|
var request = require('request');
|
|
2
3
|
var source = require('vinyl-source-stream');
|
|
3
4
|
|
|
4
5
|
// helper to allow us to define an "end" event to multiple streams
|
|
5
|
-
function streamToDestination(gulp, siteSettings, inputPath, destPath, fileName) {
|
|
6
|
+
async function streamToDestination(gulp, siteSettings, inputPath, destPath, fileName, index) {
|
|
6
7
|
var url = `https://${siteSettings.nodeEnv}${inputPath}`;
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
return await new Promise(async function(resolve) { // eslint-disable-line no-undef
|
|
9
|
+
console.time(`${index + 1} Finished after`);
|
|
10
|
+
console.log(`${index + 1} Starting:`, url);
|
|
9
11
|
request(url)
|
|
10
|
-
.on('response', resp
|
|
12
|
+
.on('response', async function(resp) {
|
|
11
13
|
if (resp.statusCode !== 200) {
|
|
12
14
|
throw new Error(`Error fetching ${url}`);
|
|
13
15
|
}
|
|
16
|
+
console.timeEnd(`${index + 1} Finished after`);
|
|
14
17
|
})
|
|
15
18
|
.pipe(source(fileName))
|
|
16
19
|
.pipe(gulp.dest(`${siteSettings.srcFolder}/${destPath}`))
|
|
@@ -19,7 +22,7 @@ function streamToDestination(gulp, siteSettings, inputPath, destPath, fileName)
|
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
module.exports = function(gulp, _gulpPlugins, siteSettings, siteData) {
|
|
22
|
-
return function() {
|
|
25
|
+
return async function() {
|
|
23
26
|
const { nodeEnv, isLocal } = siteSettings;
|
|
24
27
|
const { isQSPage, isWhiteLabel, domain } = siteData;
|
|
25
28
|
const isModWhiteLabel = isWhiteLabel && !isQSPage;
|
|
@@ -43,7 +46,7 @@ module.exports = function(gulp, _gulpPlugins, siteSettings, siteData) {
|
|
|
43
46
|
});
|
|
44
47
|
|
|
45
48
|
if (isModWhiteLabel || domainHasModernize) {
|
|
46
|
-
Object.assign(externalResources, {'/quote/resources/mod-site/templates/scripts/recaptcha.html': ['/templates/scripts/', 'recaptcha.html']});
|
|
49
|
+
Object.assign(externalResources, { '/quote/resources/mod-site/templates/scripts/recaptcha.html': ['/templates/scripts/', 'recaptcha.html'] });
|
|
47
50
|
}
|
|
48
51
|
|
|
49
52
|
// local dev files
|
|
@@ -67,13 +70,19 @@ module.exports = function(gulp, _gulpPlugins, siteSettings, siteData) {
|
|
|
67
70
|
]
|
|
68
71
|
});
|
|
69
72
|
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
const totalRequests = Object.keys(externalResources).length;
|
|
74
|
+
return await new Promise(async function(resolve) {
|
|
75
|
+
const sequentialRequests = async function(key, index) {
|
|
76
|
+
if (index === totalRequests) {
|
|
77
|
+
resolve();
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const destinationPath = externalResources[key][0];
|
|
81
|
+
const fileName = externalResources[key][1];
|
|
82
|
+
return await streamToDestination(gulp, siteSettings, key, destinationPath, fileName, index).then(() => sequentialRequests(Object.keys(externalResources)[index + 1], index + 1));
|
|
83
|
+
};
|
|
75
84
|
|
|
76
|
-
|
|
77
|
-
|
|
85
|
+
sequentialRequests(Object.keys(externalResources)[0], 0);
|
|
86
|
+
});
|
|
78
87
|
};
|
|
79
88
|
};
|
package/gulp-tasks/templates.js
CHANGED
|
@@ -194,17 +194,6 @@ module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
|
|
|
194
194
|
return index;
|
|
195
195
|
}
|
|
196
196
|
},
|
|
197
|
-
// Adding helper to check if mobile (< 768px)
|
|
198
|
-
{
|
|
199
|
-
name: 'isMobile',
|
|
200
|
-
fn: function(expression, options) {
|
|
201
|
-
if (window.innerWidth < 768) {
|
|
202
|
-
return options.fn(expression);
|
|
203
|
-
} else {
|
|
204
|
-
return options.inverse(expression);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
},
|
|
208
197
|
// Loop to go through and add each attribute defined in the attributes: {} object
|
|
209
198
|
{
|
|
210
199
|
name: 'addAttributes',
|
|
@@ -331,16 +320,62 @@ module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
|
|
|
331
320
|
};
|
|
332
321
|
|
|
333
322
|
var getConsentCaptureLanguage = async function() {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
323
|
+
const requestPromise = (url) => {
|
|
324
|
+
return new Promise((resolve, reject) => {
|
|
325
|
+
request(url, (error, xhr, response) => {
|
|
326
|
+
if (error) {
|
|
327
|
+
reject(error);
|
|
328
|
+
} else {
|
|
329
|
+
resolve({ xhr, response });
|
|
330
|
+
}
|
|
331
|
+
});
|
|
342
332
|
});
|
|
343
|
-
}
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
try {
|
|
336
|
+
const tcpaJson = `https://${siteSettings.nodeEnv}/quote/resources/mod-site/consent-capture/tcpa.json`;
|
|
337
|
+
const { xhr: tcpaXhr, response: tcpaResponse } = await requestPromise(tcpaJson);
|
|
338
|
+
|
|
339
|
+
if (tcpaXhr.statusCode !== 200) {
|
|
340
|
+
throw new Error(`${tcpaXhr.statusCode}: Error while fetching tcpa.json`);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
let brandedDisplayName = '';
|
|
344
|
+
const responseJson = JSON.parse(tcpaResponse),
|
|
345
|
+
consentCaptureObject = responseJson;
|
|
346
|
+
|
|
347
|
+
const brandedSiteIdentifiers = `https://${siteSettings.nodeEnv}/quote/resources/mod-site/data/branded-site-identifiers.json`;
|
|
348
|
+
const { xhr: brandedXhr, response: brandedResponse } = await requestPromise(brandedSiteIdentifiers);
|
|
349
|
+
|
|
350
|
+
if (brandedXhr.statusCode !== 200) {
|
|
351
|
+
throw new Error(`${brandedXhr.statusCode}: Error while fetching branded-site-identifiers.json`);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
const brandedResponseJson = JSON.parse(brandedResponse);
|
|
355
|
+
|
|
356
|
+
if (templatesData.isBranded) {
|
|
357
|
+
const websiteName = templatesData.website_name;
|
|
358
|
+
if (brandedResponseJson[websiteName] && brandedResponseJson[websiteName].vendorPublicIdentifier) {
|
|
359
|
+
const vendorPublicIdentifier = brandedResponseJson[websiteName].vendorPublicIdentifier,
|
|
360
|
+
apiDomain = 'https://form-service-hs.qnst.com/',
|
|
361
|
+
apiUrl = `${apiDomain}utils/vendor-display-name?vendorKeys=${vendorPublicIdentifier}`;
|
|
362
|
+
|
|
363
|
+
const { xhr: displayNameXhr, response: displayNameResponse } = await requestPromise(apiUrl);
|
|
364
|
+
|
|
365
|
+
if (displayNameXhr.statusCode !== 200) {
|
|
366
|
+
throw new Error(`${displayNameXhr.statusCode}: Error while getting branded display name from HS Form Service`);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
const displayNameResponseJson = JSON.parse(displayNameResponse);
|
|
370
|
+
brandedDisplayName = displayNameResponseJson.data[vendorPublicIdentifier];
|
|
371
|
+
consentCaptureObject.brandedConsentCapture.tcpaStart = responseJson.brandedConsentCapture.tcpaStart.replace(/<span data-branded-consent><\/span>/g, `<span data-branded-consent>${brandedDisplayName}</span>`);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
Object.assign(templatesData, consentCaptureObject);
|
|
376
|
+
} catch (error) {
|
|
377
|
+
console.error('Error fetching data:', error);
|
|
378
|
+
}
|
|
344
379
|
};
|
|
345
380
|
|
|
346
381
|
return async function() {
|