mod-build 3.6.94-beta.9 → 3.6.94

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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## 3.6.94
4
4
 
5
- - Updating the `gulp-uglify` package to use a newer version of `gulp-uglify-es` as we have had issues with `gulp-uglify` in the past
5
+ - Fixed bugs in seasonal updates
6
6
 
7
7
  ## 3.6.93
8
8
 
@@ -1,4 +1,4 @@
1
- module.exports = function(gulp, gulpPlugins, siteSettings) {
1
+ module.exports = function(gulp, _gulpPlugins, siteSettings) {
2
2
  var fs = require('fs');
3
3
  var gulpESLintNew = require('gulp-eslint-new');
4
4
 
@@ -1,5 +1,3 @@
1
- let uglify = require('gulp-uglify-es').default;
2
-
3
1
  const babelOpts = {
4
2
  presets: ['@babel/preset-env']
5
3
  };
@@ -14,7 +12,7 @@ module.exports.html = function(gulp, gulpPlugins, siteSettings) {
14
12
  searchPath: [siteSettings.tmpFolder, './']
15
13
  }))
16
14
  .pipe(gulpPlugins.if('*.js', gulpPlugins.babel(babelOpts)))
17
- .pipe(gulpPlugins.if('*.js', uglify()))
15
+ .pipe(gulpPlugins.if('*.js', gulpPlugins.uglify()))
18
16
  .pipe(gulpPlugins.if('*.css', gulpPlugins.cleanCss(cleanCssOpts)))
19
17
  .pipe(gulpPlugins.if('*.css', gulpPlugins.csso()))
20
18
  .pipe(gulpPlugins.revReplace())
@@ -41,7 +39,7 @@ module.exports.js = function(gulp, gulpPlugins, siteSettings) {
41
39
  return function() {
42
40
  return gulp.src([siteSettings.srcFolder + '/**/*.js', '!' + siteSettings.srcFolder + '/data/**/*.js'])
43
41
  .pipe(gulpPlugins.babel(babelOpts))
44
- .pipe(uglify())
42
+ .pipe(gulpPlugins.uglify())
45
43
  .on('error', function(err) {
46
44
  console.log(err);
47
45
  this.end();
@@ -19,13 +19,54 @@ module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
19
19
  // Checking for seasonal variations in the template.js + updating content
20
20
  var checkSeasonalVariations = require('./check-seasonal-variations.js');
21
21
  const activeSeason = checkSeasonalVariations();
22
+ const HVAC_INTEREST = 'HVACInterest';
23
+ const SEASON = 'warmerWeather';
24
+ const CENTRAL_AC = 'Central AC';
25
+ const CENTRAL_HEATING = 'Central Heating';
26
+ siteData.isWarmWeather = false; // will use this variable in site level to update the hero title/subtitle wherever required
22
27
  if (activeSeason.length !== 0) {
23
- if (siteData.seasonalVariations) {
24
- activeSeason.forEach(season => {
25
- if (season in siteData.seasonalVariations) {
26
- siteData = merge(siteData, siteData.seasonalVariations[season]);
27
- }
28
- });
28
+ if (activeSeason.includes(SEASON)) {
29
+ siteData.isWarmWeather = true;
30
+ const data = JSON.stringify(siteData, null, 4);
31
+ const heating = '(Heating|heating|calentadores|Calentadores|calefactores|Calefactores)';
32
+ const and = '(\\s&\\s|\\sand\\s|and|\\sy\\s)'; // eslint-disable-line no-useless-escape
33
+ const ac = '(AC|Cooling|cooling|aires.*?acondicionados|Aires.*?Acondicionados)';
34
+ const spaces = '.*?';
35
+
36
+ const regex = new RegExp(`${heating}${spaces}${and}${spaces}${ac}`, 'gm');
37
+ // Find and reverse the required words in the string using regex group capture
38
+ const processedData = data.replaceAll(regex, '$3 $2 $1');
39
+ // Convert data into JSON
40
+ siteData = JSON.parse(processedData);
41
+ // Find the HVACInterest step and reverse the options array
42
+ if (siteData.steps && (siteData.steps.items && siteData.steps.items.length)) {
43
+ siteData.steps.items.forEach(function(step) {
44
+ const isHvacInterestStep = step && (step.stepName && step.stepName === HVAC_INTEREST) || (step.attributes && step.attributes.data && step.attributes.data['step-name'] === HVAC_INTEREST);
45
+ if (isHvacInterestStep) {
46
+ const stepFields = step.fields || step.stepContent.fields;
47
+ if (stepFields && stepFields.length) {
48
+ stepFields.forEach(function(field) {
49
+ const firstOption = field.options[0];
50
+ const lastOption = field.options[field.options.length - 1];
51
+ const firstOptionIsCentralHeating = (firstOption.attributes && firstOption.attributes.value === CENTRAL_HEATING) || firstOption.value === CENTRAL_HEATING;
52
+ const lastOptionIsCentralAC = (lastOption.attributes && lastOption.attributes.value === CENTRAL_AC) || lastOption.value === CENTRAL_AC;
53
+ // if the first option is central heating & last option is central ac then only swap those options
54
+ if (firstOptionIsCentralHeating && lastOptionIsCentralAC) {
55
+ field.options[0] = lastOption;
56
+ field.options[field.options.length - 1] = firstOption;
57
+ }
58
+
59
+ field.options.some(function(option) {
60
+ if (option.checked) {
61
+ option.checked = false;
62
+ field.options[0].checked = true;
63
+ }
64
+ });
65
+ });
66
+ }
67
+ }
68
+ });
69
+ }
29
70
  }
30
71
  }
31
72
 
@@ -214,7 +255,7 @@ module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
214
255
  console.time('Finished fetch-default-form-config after');
215
256
  console.log('Starting fetch-default-form-config: ');
216
257
  await new Promise((resolve) => {
217
- request(`https://${siteSettings.nodeEnv}/quote/resources/mod-site/${folder}/steps/defaultFormFieldConfig.json`, async function(err, xhr, response) {
258
+ request(`https://${siteSettings.nodeEnv}/quote/resources/mod-site/${folder}/steps/defaultFormFieldConfig.json`, async function(_err, xhr, response) {
218
259
  if (xhr.statusCode !== 200) {
219
260
  throw new Error(`${xhr.statusCode}: Error while fetching ${folder}/defaultFormFieldConfig.json`);
220
261
  }
@@ -253,7 +294,7 @@ module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
253
294
  console.time('Finished fetch-tcpa-from-sitegenie after');
254
295
  console.log('Starting fetch-tcpa-from-sitegenie: ',url);
255
296
  await new Promise(function(resolve) {
256
- request(reqConfig, async function(err, xhr, response) {
297
+ request(reqConfig, async function(_err, xhr, response) {
257
298
  if (xhr.statusCode !== 200) {
258
299
  throw new Error(`${xhr.statusCode}: Error while fetching TCPA`);
259
300
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mod-build",
3
- "version": "3.6.94-beta.9",
3
+ "version": "3.6.94",
4
4
  "description": "Share components for S3 sites.",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",
@@ -50,7 +50,7 @@
50
50
  "gulp-size": "^2.1.0",
51
51
  "gulp-sourcemaps": "^2.6.0",
52
52
  "gulp-tap": "^2.0.0",
53
- "gulp-uglify-es": "^3.0.0",
53
+ "gulp-uglify": "^2.1.2",
54
54
  "gulp-useref": "^5.0.0",
55
55
  "husky": "^1.3.1",
56
56
  "imagemin-mozjpeg": "^7.0.0",