mod-build 3.6.75-beta.2 → 4.0.0-alpha.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/.eslintignore +3 -0
- package/.eslintrc +18 -0
- package/CHANGELOG.md +2 -252
- package/README.md +16 -263
- package/gulp-tasks/grab-cdn.js +0 -10
- package/package.json +18 -68
- package/siteconfig.js +38 -0
- package/src/data/footer.js +117 -0
- package/src/data/seasons.js +5 -7
- package/src/index.html +18 -0
- package/src/main.js +45 -0
- package/src/scripts/has-qs-params.js +6 -5
- package/src/scripts/url-cleaner.js +3 -3
- package/src/scripts/utils.js +178 -0
- package/src/styles/home.scss +1 -0
- package/src/templates/_partials/scripts/deferred-styles.html +16 -16
- package/src/templates/_partials/scripts/vwo-redirect-callback.html +43 -45
- package/src/templates/components/head.html +70 -0
- package/tasks/clean.js +13 -0
- package/tasks/grab-cdn.js +107 -0
- package/tasks/grab-form-helpers.js +94 -0
- package/tasks/grab-shared-components.js +81 -0
- package/tasks/grab-shared-scripts.js +267 -0
- package/tasks/serve.js +15 -0
- package/tasks/templates.js +168 -0
- package/template.js +801 -0
- package/vite.config.js +56 -0
- package/.eslintrc.yml +0 -59
- package/src/data/common.js +0 -704
- package/src/data/components/qs-footer.js +0 -55
- package/src/data/components/quote-footer.js +0 -73
- package/src/scripts/apt-block.js +0 -919
- package/src/scripts/components/custom-selects.js +0 -48
- package/src/scripts/components/radio-panels.js +0 -45
- package/src/scripts/es6-1.js +0 -6
- package/src/scripts/es6-2.js +0 -2
- package/src/scripts/qs-form.js +0 -839
- package/src/scripts/vendor/maxmind-geoip2.js +0 -2
- package/src/scripts/vendor/swiper.min.js +0 -13
- package/src/styles/apt-block.scss +0 -888
- package/src/templates/_partials/apt-block.html +0 -30
- package/src/templates/_partials/scripts/analytics.html +0 -4
- package/src/templates/_partials/scripts/go-page-hiding-snippet.html +0 -8
- package/src/templates/_partials/scripts/google-maps.html +0 -1
- package/src/templates/_partials/scripts/google-optimize.html +0 -12
- package/src/templates/_partials/scripts/gtm-editorials/body/google-tag-manager-body.html +0 -5
- package/src/templates/_partials/scripts/gtm-editorials/head/google-tag-manager-head.html +0 -10
- package/src/templates/_partials/scripts/gtm-hil/body/google-tag-manager-body.html +0 -5
- package/src/templates/_partials/scripts/gtm-hil/head/google-tag-manager-head.html +0 -10
- package/src/templates/_partials/scripts/gtm-pro/body/google-tag-manager-body.html +0 -5
- package/src/templates/_partials/scripts/gtm-pro/head/google-tag-manager-head.html +0 -10
- package/src/templates/_partials/scripts/gtm-quote/body/google-tag-manager-body.html +0 -5
- package/src/templates/_partials/scripts/gtm-quote/head/google-tag-manager-head.html +0 -9
- package/src/templates/_partials/scripts/gtm-whitelabel/body/mod-google-tag-manager-body.html +0 -5
- package/src/templates/_partials/scripts/gtm-whitelabel/body/non-mod-google-tag-manager-body.html +0 -5
- package/src/templates/_partials/scripts/gtm-whitelabel/head/mod-google-tag-manager-head.html +0 -10
- package/src/templates/_partials/scripts/gtm-whitelabel/head/non-mod-google-tag-manager-head.html +0 -9
- package/src/templates/_partials/scripts/gtm-wordpress/body/google-tag-manager-body.html +0 -5
- package/src/templates/_partials/scripts/gtm-wordpress/head/google-tag-manager-head.html +0 -9
- package/src/templates/_partials/scripts/visual-website-optimizer.html +0 -5
- package/src/templates/index.html +0 -46
- /package/{src → public}/favicon.ico +0 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { defaultSettings, siteData, setSiteData } from '../siteconfig.js'
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
import footer from '../src/data/footer.js';
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import { getActiveSeasons, handlebarsHelpers } from '../src/scripts/utils.js';
|
|
6
|
+
import gulpHandlebarsFileInclude from 'gulp-handlebars-file-include';
|
|
7
|
+
import gulp from 'gulp';
|
|
8
|
+
|
|
9
|
+
const { isLocal, resourceDomain, buildPath } = defaultSettings;
|
|
10
|
+
const { isWhiteLabel } = siteData;
|
|
11
|
+
const assetsPath = isWhiteLabel ? '' : (isLocal ? '/temp/assets' : `https://${resourceDomain}/quote/resources/assets`);
|
|
12
|
+
|
|
13
|
+
const activeSeason = getActiveSeasons();
|
|
14
|
+
|
|
15
|
+
if (activeSeason.length) {
|
|
16
|
+
if (siteData.seasonalVariations) {
|
|
17
|
+
activeSeason.forEach(season => {
|
|
18
|
+
if (season in siteData.seasonalVariations) {
|
|
19
|
+
setSiteData({ ...siteData, ...siteData.seasonalVariations[season] });
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const templatesData = {
|
|
26
|
+
...siteData,
|
|
27
|
+
...footer(siteData),
|
|
28
|
+
...{ isLocal, resourceDomain, assetsPath, buildPath },
|
|
29
|
+
steps: {
|
|
30
|
+
items: [
|
|
31
|
+
{
|
|
32
|
+
stepContent: {
|
|
33
|
+
fields: []
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
function mergeDefaultFormFieldConfig(steps, defaultConfig) {
|
|
41
|
+
if (!steps.items) {
|
|
42
|
+
console.error('No items[ ] found in steps{}!');
|
|
43
|
+
return steps;
|
|
44
|
+
}
|
|
45
|
+
if (templatesData.siteData?.useAccessibleConfig) {
|
|
46
|
+
steps.items.forEach(item => {
|
|
47
|
+
if (item.stepContent?.fields) {
|
|
48
|
+
item.stepContent.fields = item.stepContent.fields.map(field => {
|
|
49
|
+
if (field.attributes && field.attributes.name && defaultConfig[field.attributes.name]) {
|
|
50
|
+
field = { ...defaultConfig[field.attributes.name], ...field };
|
|
51
|
+
}
|
|
52
|
+
return field;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
} else {
|
|
57
|
+
steps.items.forEach(item => {
|
|
58
|
+
if (item.fields) {
|
|
59
|
+
item.fields = item.fields.map(field => {
|
|
60
|
+
if (field.name && defaultConfig[field.name]) {
|
|
61
|
+
field = Object.assign({}, defaultConfig[field.name], field);
|
|
62
|
+
}
|
|
63
|
+
return field;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return steps;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const getDefaultFormFieldConfig = async (folder = 'accessible-components') => {
|
|
73
|
+
console.time('Finished fetch-default-form-config after');
|
|
74
|
+
console.log('Starting fetch-default-form-config: ');
|
|
75
|
+
|
|
76
|
+
if (!templatesData.defaultConfigCompleted) {
|
|
77
|
+
await new Promise((resolve) => {
|
|
78
|
+
axios.get(`https://${defaultSettings.nodeEnv}/quote/resources/mod-site/${folder}/steps/defaultFormFieldConfig.json`)
|
|
79
|
+
.then(async resp => {
|
|
80
|
+
if (resp.status !== 200) {
|
|
81
|
+
throw new Error(`${resp.status}: Error while fetching ${folder}/defaultFormFieldConfig.json`);
|
|
82
|
+
}
|
|
83
|
+
const defaultConfig = resp.data;
|
|
84
|
+
if (templatesData.steps) {
|
|
85
|
+
templatesData.steps = await mergeDefaultFormFieldConfig(templatesData.steps, defaultConfig);
|
|
86
|
+
}
|
|
87
|
+
if (templatesData.qsSteps) {
|
|
88
|
+
templatesData.qsSteps = await mergeDefaultFormFieldConfig(templatesData.qsSteps, defaultConfig);
|
|
89
|
+
}
|
|
90
|
+
if (templatesData.modSteps) {
|
|
91
|
+
templatesData.modSteps = await mergeDefaultFormFieldConfig(templatesData.modSteps, defaultConfig);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
templatesData.defaultConfigCompleted = true;
|
|
95
|
+
console.log(templatesData.defaultConfigCompleted);
|
|
96
|
+
resolve();
|
|
97
|
+
}).catch(error => {
|
|
98
|
+
console.error(error);
|
|
99
|
+
resolve();
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
console.timeEnd('Finished fetch-default-form-config after');
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const fetchTcpaFromSitegenie = async () => {
|
|
107
|
+
const company = templatesData.company_name;
|
|
108
|
+
const website = templatesData.website_name;
|
|
109
|
+
const c_level = templatesData.cLevel || 'default';
|
|
110
|
+
const affiliateKey = templatesData.affiliateKey || 0;
|
|
111
|
+
const service = templatesData.service ? templatesData.service.toLowerCase().replace(' ', '_') : templatesData.primary_trade.toLowerCase().replace(' ', '_');
|
|
112
|
+
const apiEnv = 'https://' + (templatesData.resourceDomain === 'modernize.com' ? 'hs.leadpost.net/' : 'hsleadpost1.quinstage.com/');
|
|
113
|
+
|
|
114
|
+
const url = `${apiEnv}coreg/getTCPAConsent?website=${website}&service=${service}&affiliateKey=${affiliateKey}&c_level=${c_level}`;
|
|
115
|
+
|
|
116
|
+
console.time('Finished fetch-tcpa-from-sitegenie after');
|
|
117
|
+
console.log('Starting fetch-tcpa-from-sitegenie: ',url);
|
|
118
|
+
|
|
119
|
+
await new Promise(function(resolve) {
|
|
120
|
+
axios.get(url).then(async resp => {
|
|
121
|
+
if (resp.status !== 200) {
|
|
122
|
+
throw new Error(`${resp.status}: Error while fetching TCPA`);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const responseJson = resp.data;
|
|
126
|
+
let finalTCPA = await (company === 'Modernize' || templatesData.useModernizeInTCPA) ? responseJson.tcpa.replace(/QuinStreet/g, 'Modernize') : responseJson.tcpa;
|
|
127
|
+
const removeInlineStyleRegex = / style="[^"]*"/g;
|
|
128
|
+
finalTCPA = finalTCPA.replace(removeInlineStyleRegex, '');
|
|
129
|
+
templatesData.tcpaText = await finalTCPA;
|
|
130
|
+
resolve();
|
|
131
|
+
}).catch(error => {
|
|
132
|
+
console.error(error);
|
|
133
|
+
resolve();
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
console.timeEnd('Finished fetch-tcpa-from-sitegenie after');
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export default async function(done) {
|
|
140
|
+
if (Object.keys(siteData).length > 0) {
|
|
141
|
+
if (!templatesData.doNotUseDefaultFieldConfig && !templatesData.defaultConfigCompleted) {
|
|
142
|
+
if (siteData.useAccessibleConfig) {
|
|
143
|
+
await getDefaultFormFieldConfig('accessible-components');
|
|
144
|
+
} else {
|
|
145
|
+
await getDefaultFormFieldConfig('shared-components');
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (!templatesData.tcpaText && templatesData.primary_trade) {
|
|
150
|
+
await fetchTcpaFromSitegenie();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (!fs.existsSync(`${defaultSettings.srcFolder}/${defaultSettings.tmpFolder}`)) {
|
|
155
|
+
fs.mkdirSync(`${defaultSettings.srcFolder}/${defaultSettings.tmpFolder}`, { recursive: true });
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
gulp.src([
|
|
159
|
+
defaultSettings.srcFolder + '/' + defaultSettings.templatesSubfolder + '/**/*.html',
|
|
160
|
+
'!' + defaultSettings.srcFolder + '/' + defaultSettings.templatesSubfolder + '/_partials/**/*.html'
|
|
161
|
+
]).pipe(gulpHandlebarsFileInclude(templatesData, {
|
|
162
|
+
maxRecursion: siteData.fileIncludeMaxRecursion || 500,
|
|
163
|
+
handlebarsHelpers
|
|
164
|
+
}))
|
|
165
|
+
.pipe(gulp.dest(defaultSettings.tmpFolder));
|
|
166
|
+
|
|
167
|
+
done();
|
|
168
|
+
}
|