mod-build 4.0.51-beta.1 → 4.0.51-beta.2
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/package.json +1 -1
- package/src/scripts/plugins.js +3 -0
- package/tasks/addSeasonalchanges.js +61 -0
- package/tasks/templates.js +3 -54
package/package.json
CHANGED
package/src/scripts/plugins.js
CHANGED
|
@@ -4,6 +4,7 @@ import gulpHandlebarsFileInclude from "gulp-handlebars-file-include";
|
|
|
4
4
|
import { defaultSettings } from "../data/config.js";
|
|
5
5
|
import footer from '../data/footer.js';
|
|
6
6
|
import { handlebarsHelpers } from "./utils.js";
|
|
7
|
+
import { addSeasonalchanges } from "../../tasks/addSeasonalchanges.js";
|
|
7
8
|
|
|
8
9
|
export const STATIC_COPY_TARGETS = [
|
|
9
10
|
{
|
|
@@ -59,6 +60,7 @@ export const updateConfig = async (config) => {
|
|
|
59
60
|
name: 'update-config',
|
|
60
61
|
async configResolved({ configFileDependencies }) {
|
|
61
62
|
await checkForTempConfig();
|
|
63
|
+
await addSeasonalchanges(mergedConfig);
|
|
62
64
|
|
|
63
65
|
configFileDependencies.forEach((file) => {
|
|
64
66
|
if (file.endsWith('siteconfig.js') || file.endsWith('template.js')) {
|
|
@@ -109,6 +111,7 @@ export const updateHandlebarsOnWatch = async (config) => {
|
|
|
109
111
|
enforce: 'pre',
|
|
110
112
|
async configResolved({ configFileDependencies }) {
|
|
111
113
|
await checkForTempConfig();
|
|
114
|
+
await addSeasonalchanges(mergedConfig);
|
|
112
115
|
|
|
113
116
|
configFileDependencies.forEach((file) => {
|
|
114
117
|
if (file.endsWith('siteconfig.js') || file.endsWith('template.js')) {
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { getActiveSeasons } from '../src/scripts/utils.js';
|
|
2
|
+
|
|
3
|
+
export default async function(tempConfig) {
|
|
4
|
+
await new Promise(async (resolve) => {
|
|
5
|
+
console.log('Satrted Seasonal Updates');
|
|
6
|
+
const activeSeason = getActiveSeasons();
|
|
7
|
+
const HVAC_INTEREST = 'HVACInterest';
|
|
8
|
+
const SEASON = 'warmerWeather';
|
|
9
|
+
const CENTRAL_AC = 'Central AC';
|
|
10
|
+
const CENTRAL_HEATING = 'Central Heating';
|
|
11
|
+
tempConfig.isWarmWeather = false; // will use this variable in site level to update the hero title/subtitle wherever required
|
|
12
|
+
if (activeSeason.length !== 0) {
|
|
13
|
+
if (activeSeason.includes(SEASON)) {
|
|
14
|
+
tempConfig.isWarmWeather = true;
|
|
15
|
+
const data = JSON.stringify(tempConfig, null, 4);
|
|
16
|
+
const heating = '(Heating|heating|calentadores|Calentadores|calefactores|Calefactores)';
|
|
17
|
+
const and = '(\\s&\\s|\\sand\\s|and|\\sy\\s)'; // eslint-disable-line no-useless-escape
|
|
18
|
+
const ac = '(AC|Cooling|cooling|aires.*?acondicionados|Aires.*?Acondicionados)';
|
|
19
|
+
const spaces = '.*?';
|
|
20
|
+
|
|
21
|
+
const regex = new RegExp(`${heating}${spaces}${and}${spaces}${ac}`, 'gm');
|
|
22
|
+
// Find and reverse the required words in the string using regex group capture
|
|
23
|
+
const processedData = data.replaceAll(regex, '$3 $2 $1');
|
|
24
|
+
// Convert data into JSON
|
|
25
|
+
tempConfig = JSON.parse(processedData);
|
|
26
|
+
// Find the HVACInterest step and reverse the options array
|
|
27
|
+
if (tempConfig.steps && (tempConfig.steps.items && tempConfig.steps.items.length)) {
|
|
28
|
+
tempConfig.steps.items.forEach(function(step) {
|
|
29
|
+
const isHvacInterestStep = step && (step.stepName && step.stepName === HVAC_INTEREST) || (step.attributes && step.attributes.data && step.attributes.data['step-name'] === HVAC_INTEREST);
|
|
30
|
+
if (isHvacInterestStep) {
|
|
31
|
+
const stepFields = step.fields || step.stepContent.fields;
|
|
32
|
+
if (stepFields && stepFields.length) {
|
|
33
|
+
stepFields.forEach(function(field) {
|
|
34
|
+
const firstOption = field.options[0];
|
|
35
|
+
const lastOption = field.options[field.options.length - 1];
|
|
36
|
+
const firstOptionIsCentralHeating = (firstOption.attributes && firstOption.attributes.value === CENTRAL_HEATING) || firstOption.value === CENTRAL_HEATING;
|
|
37
|
+
const lastOptionIsCentralAC = (lastOption.attributes && lastOption.attributes.value === CENTRAL_AC) || lastOption.value === CENTRAL_AC;
|
|
38
|
+
// if the first option is central heating & last option is central ac then only swap those options
|
|
39
|
+
if (firstOptionIsCentralHeating && lastOptionIsCentralAC) {
|
|
40
|
+
field.options[0] = lastOption;
|
|
41
|
+
field.options[field.options.length - 1] = firstOption;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
field.options.some(function(option) {
|
|
45
|
+
if (option.checked) {
|
|
46
|
+
option.checked = false;
|
|
47
|
+
field.options[0].checked = true;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
resolve();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}).then(() => {
|
|
59
|
+
console.log('Finished Seasonal Updates');
|
|
60
|
+
})
|
|
61
|
+
}
|
package/tasks/templates.js
CHANGED
|
@@ -3,9 +3,9 @@ import footer from '../src/data/footer.js';
|
|
|
3
3
|
import fs from 'node:fs';
|
|
4
4
|
import merge from 'lodash.merge';
|
|
5
5
|
import { responseInterceptor } from '../src/scripts/retry-axios.js';
|
|
6
|
+
import { addSeasonalchanges } from './addSeasonalchanges.js';
|
|
6
7
|
|
|
7
8
|
import { defaultSettings } from '../src/data/config.js';
|
|
8
|
-
import { getActiveSeasons } from '../src/scripts/utils.js';
|
|
9
9
|
|
|
10
10
|
import setupDevOpsTrackingId from './setupDevOpsTrackingId.js';
|
|
11
11
|
|
|
@@ -257,64 +257,13 @@ export default async function(config) {
|
|
|
257
257
|
const isPathSubdirectory = typeof config.pathSubdirectory !== 'undefined';
|
|
258
258
|
const pathSubdirectory = !isLocal && isPathSubdirectory ? isPathSubdirectory : '';
|
|
259
259
|
|
|
260
|
-
const activeSeason = getActiveSeasons();
|
|
261
|
-
|
|
262
260
|
let tempConfig = {
|
|
263
261
|
...config,
|
|
264
262
|
...footer(config),
|
|
265
263
|
...{ isLocal, nodeEnv, assetsPath, buildPath },
|
|
266
264
|
};
|
|
267
265
|
|
|
268
|
-
|
|
269
|
-
const SEASON = 'warmerWeather';
|
|
270
|
-
const CENTRAL_AC = 'Central AC';
|
|
271
|
-
const CENTRAL_HEATING = 'Central Heating';
|
|
272
|
-
tempConfig.isWarmWeather = false; // will use this variable in site level to update the hero title/subtitle wherever required
|
|
273
|
-
if (activeSeason.length !== 0) {
|
|
274
|
-
if (activeSeason.includes(SEASON)) {
|
|
275
|
-
tempConfig.isWarmWeather = true;
|
|
276
|
-
const data = JSON.stringify(tempConfig, null, 4);
|
|
277
|
-
const heating = '(Heating|heating|calentadores|Calentadores|calefactores|Calefactores)';
|
|
278
|
-
const and = '(\\s&\\s|\\sand\\s|and|\\sy\\s)'; // eslint-disable-line no-useless-escape
|
|
279
|
-
const ac = '(AC|Cooling|cooling|aires.*?acondicionados|Aires.*?Acondicionados)';
|
|
280
|
-
const spaces = '.*?';
|
|
281
|
-
|
|
282
|
-
const regex = new RegExp(`${heating}${spaces}${and}${spaces}${ac}`, 'gm');
|
|
283
|
-
// Find and reverse the required words in the string using regex group capture
|
|
284
|
-
const processedData = data.replaceAll(regex, '$3 $2 $1');
|
|
285
|
-
// Convert data into JSON
|
|
286
|
-
tempConfig = JSON.parse(processedData);
|
|
287
|
-
// Find the HVACInterest step and reverse the options array
|
|
288
|
-
if (tempConfig.steps && (tempConfig.steps.items && tempConfig.steps.items.length)) {
|
|
289
|
-
tempConfig.steps.items.forEach(function(step) {
|
|
290
|
-
const isHvacInterestStep = step && (step.stepName && step.stepName === HVAC_INTEREST) || (step.attributes && step.attributes.data && step.attributes.data['step-name'] === HVAC_INTEREST);
|
|
291
|
-
if (isHvacInterestStep) {
|
|
292
|
-
const stepFields = step.fields || step.stepContent.fields;
|
|
293
|
-
if (stepFields && stepFields.length) {
|
|
294
|
-
stepFields.forEach(function(field) {
|
|
295
|
-
const firstOption = field.options[0];
|
|
296
|
-
const lastOption = field.options[field.options.length - 1];
|
|
297
|
-
const firstOptionIsCentralHeating = (firstOption.attributes && firstOption.attributes.value === CENTRAL_HEATING) || firstOption.value === CENTRAL_HEATING;
|
|
298
|
-
const lastOptionIsCentralAC = (lastOption.attributes && lastOption.attributes.value === CENTRAL_AC) || lastOption.value === CENTRAL_AC;
|
|
299
|
-
// if the first option is central heating & last option is central ac then only swap those options
|
|
300
|
-
if (firstOptionIsCentralHeating && lastOptionIsCentralAC) {
|
|
301
|
-
field.options[0] = lastOption;
|
|
302
|
-
field.options[field.options.length - 1] = firstOption;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
field.options.some(function(option) {
|
|
306
|
-
if (option.checked) {
|
|
307
|
-
option.checked = false;
|
|
308
|
-
field.options[0].checked = true;
|
|
309
|
-
}
|
|
310
|
-
});
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
}
|
|
266
|
+
// await addSeasonalchanges(tempConfig);
|
|
318
267
|
|
|
319
268
|
if (Object.keys(config).length > 0) {
|
|
320
269
|
if (!config.doNotUseDefaultFieldConfig && !tempConfigCreated) {
|
|
@@ -339,7 +288,7 @@ export default async function(config) {
|
|
|
339
288
|
if (!fs.existsSync(`${defaultSettings.srcFolder}/${defaultSettings.tmpFolder}`)) {
|
|
340
289
|
fs.mkdirSync(`${defaultSettings.srcFolder}/${defaultSettings.tmpFolder}`, { recursive: true });
|
|
341
290
|
}
|
|
342
|
-
|
|
291
|
+
|
|
343
292
|
fs.writeFileSync(`${defaultSettings.srcFolder}/${defaultSettings.tmpFolder}/config.json`, JSON.stringify(tempConfig, null, 2));
|
|
344
293
|
}
|
|
345
294
|
}
|