mod-build 4.0.20-beta.1 → 4.0.20
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/gulp-tasks/templates.js +6 -47
- package/package.json +1 -1
- package/tasks/templates.js +50 -9
package/gulp-tasks/templates.js
CHANGED
|
@@ -19,54 +19,13 @@ 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
|
|
27
22
|
if (activeSeason.length !== 0) {
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
}
|
|
23
|
+
if (siteData.seasonalVariations) {
|
|
24
|
+
activeSeason.forEach(season => {
|
|
25
|
+
if (season in siteData.seasonalVariations) {
|
|
26
|
+
siteData = merge(siteData, siteData.seasonalVariations[season]);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
70
29
|
}
|
|
71
30
|
}
|
|
72
31
|
|
package/package.json
CHANGED
package/tasks/templates.js
CHANGED
|
@@ -113,7 +113,7 @@ const fetchTcpaFromSitegenie = async (config, tempConfig) => {
|
|
|
113
113
|
} else {
|
|
114
114
|
console.log('Response error...using default TCPA language');
|
|
115
115
|
}
|
|
116
|
-
|
|
116
|
+
|
|
117
117
|
let defaultTcpa = JSON.parse(fs.readFileSync('src/resources/data/tcpa.json', 'utf8'));
|
|
118
118
|
tempConfig.tcpaText = defaultTcpa.tcpaText;
|
|
119
119
|
resolve(error);
|
|
@@ -137,13 +137,54 @@ export default async function(config) {
|
|
|
137
137
|
...{ isLocal, nodeEnv, assetsPath, buildPath },
|
|
138
138
|
};
|
|
139
139
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
140
|
+
const HVAC_INTEREST = 'HVACInterest';
|
|
141
|
+
const SEASON = 'warmerWeather';
|
|
142
|
+
const CENTRAL_AC = 'Central AC';
|
|
143
|
+
const CENTRAL_HEATING = 'Central Heating';
|
|
144
|
+
tempConfig.isWarmWeather = false; // will use this variable in site level to update the hero title/subtitle wherever required
|
|
145
|
+
if (activeSeason.length !== 0) {
|
|
146
|
+
if (activeSeason.includes(SEASON)) {
|
|
147
|
+
tempConfig.isWarmWeather = true;
|
|
148
|
+
const data = JSON.stringify(tempConfig, null, 4);
|
|
149
|
+
const heating = '(Heating|heating|calentadores|Calentadores|calefactores|Calefactores)';
|
|
150
|
+
const and = '(\\s&\\s|\\sand\\s|and|\\sy\\s)'; // eslint-disable-line no-useless-escape
|
|
151
|
+
const ac = '(AC|Cooling|cooling|aires.*?acondicionados|Aires.*?Acondicionados)';
|
|
152
|
+
const spaces = '.*?';
|
|
153
|
+
|
|
154
|
+
const regex = new RegExp(`${heating}${spaces}${and}${spaces}${ac}`, 'gm');
|
|
155
|
+
// Find and reverse the required words in the string using regex group capture
|
|
156
|
+
const processedData = data.replaceAll(regex, '$3 $2 $1');
|
|
157
|
+
// Convert data into JSON
|
|
158
|
+
tempConfig = JSON.parse(processedData);
|
|
159
|
+
// Find the HVACInterest step and reverse the options array
|
|
160
|
+
if (tempConfig.steps && (tempConfig.steps.items && tempConfig.steps.items.length)) {
|
|
161
|
+
tempConfig.steps.items.forEach(function(step) {
|
|
162
|
+
const isHvacInterestStep = step && (step.stepName && step.stepName === HVAC_INTEREST) || (step.attributes && step.attributes.data && step.attributes.data['step-name'] === HVAC_INTEREST);
|
|
163
|
+
if (isHvacInterestStep) {
|
|
164
|
+
const stepFields = step.fields || step.stepContent.fields;
|
|
165
|
+
if (stepFields && stepFields.length) {
|
|
166
|
+
stepFields.forEach(function(field) {
|
|
167
|
+
const firstOption = field.options[0];
|
|
168
|
+
const lastOption = field.options[field.options.length - 1];
|
|
169
|
+
const firstOptionIsCentralHeating = (firstOption.attributes && firstOption.attributes.value === CENTRAL_HEATING) || firstOption.value === CENTRAL_HEATING;
|
|
170
|
+
const lastOptionIsCentralAC = (lastOption.attributes && lastOption.attributes.value === CENTRAL_AC) || lastOption.value === CENTRAL_AC;
|
|
171
|
+
// if the first option is central heating & last option is central ac then only swap those options
|
|
172
|
+
if (firstOptionIsCentralHeating && lastOptionIsCentralAC) {
|
|
173
|
+
field.options[0] = lastOption;
|
|
174
|
+
field.options[field.options.length - 1] = firstOption;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
field.options.some(function(option) {
|
|
178
|
+
if (option.checked) {
|
|
179
|
+
option.checked = false;
|
|
180
|
+
field.options[0].checked = true;
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
}
|
|
147
188
|
}
|
|
148
189
|
}
|
|
149
190
|
|
|
@@ -158,7 +199,7 @@ export default async function(config) {
|
|
|
158
199
|
if (!config.tcpaText && config.primary_trade && !tempConfigCreated) {
|
|
159
200
|
await fetchTcpaFromSitegenie(config, tempConfig);
|
|
160
201
|
}
|
|
161
|
-
}
|
|
202
|
+
}
|
|
162
203
|
|
|
163
204
|
if (!tempConfigCreated) {
|
|
164
205
|
if (!fs.existsSync(`${defaultSettings.srcFolder}/${defaultSettings.tmpFolder}`)) {
|