mod-build 4.0.102-beta.1 → 4.0.103

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.
Files changed (112) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/package.json +2 -2
  3. package/public/resources/scripts/abandonment/abandonment-a4bbb36fbc8ed64042b8.min.js +2 -0
  4. package/public/resources/scripts/abandonment/abandonment.min.js +2 -0
  5. package/public/resources/scripts/callrail/callrail-14011d73b50a928de4b4.min.js +2 -0
  6. package/public/resources/scripts/callrail/callrail.min.js +2 -0
  7. package/public/resources/scripts/footer/footer-component-46dc0d7ca6af4fc3b76b.min.js +2 -0
  8. package/public/resources/scripts/footer/footer-component.min.js +2 -0
  9. package/public/resources/scripts/geolocation/geolocation.min.js +2 -0
  10. package/public/resources/scripts/helpers/addVWOTestQueryParam.min.js +2 -0
  11. package/public/resources/scripts/helpers/addVWOTestQueryParam.min.js.map +1 -0
  12. package/public/resources/scripts/helpers/additionalOpts.min.js +2 -0
  13. package/public/resources/scripts/helpers/additionalOpts.min.js.map +1 -0
  14. package/public/resources/scripts/helpers/calls-only.min.js +2 -0
  15. package/public/resources/scripts/helpers/calls-only.min.js.map +1 -0
  16. package/public/resources/scripts/helpers/getPhoneAssignmentData.min.js +2 -0
  17. package/public/resources/scripts/helpers/getPhoneAssignmentData.min.js.map +1 -0
  18. package/public/resources/scripts/helpers/initNumericOnlyFields.min.js +2 -0
  19. package/public/resources/scripts/helpers/initNumericOnlyFields.min.js.map +1 -0
  20. package/public/resources/scripts/helpers/initQSForm.min.js +2 -0
  21. package/public/resources/scripts/helpers/initQSForm.min.js.map +1 -0
  22. package/public/resources/scripts/helpers/initQuadTransform.min.js +2 -0
  23. package/public/resources/scripts/helpers/initQuadTransform.min.js.map +1 -0
  24. package/public/resources/scripts/helpers/isZipCodeValid.min.js +2 -0
  25. package/public/resources/scripts/helpers/isZipCodeValid.min.js.map +1 -0
  26. package/public/resources/scripts/helpers/observeVWOVariation.min.js +2 -0
  27. package/public/resources/scripts/helpers/observeVWOVariation.min.js.map +1 -0
  28. package/public/resources/scripts/helpers/opts.min.js +2 -0
  29. package/public/resources/scripts/helpers/opts.min.js.map +1 -0
  30. package/public/resources/scripts/jornaya.hbs +35 -0
  31. package/public/resources/scripts/jornaya.html +35 -0
  32. package/public/resources/scripts/mod-alytics/modalytics-be44027508c0438f6709.min.js +2 -0
  33. package/public/resources/scripts/mod-alytics/modalytics.min.js +2 -0
  34. package/public/resources/scripts/mod-form/form/contractor-0918337caf3dfede1609.min.js +2 -0
  35. package/public/resources/scripts/mod-form/form/contractor.min.js +2 -0
  36. package/public/resources/scripts/mod-form/form/homeowner-19a121b0e596042326f4.min.js +2 -0
  37. package/public/resources/scripts/mod-form/form/homeowner.min.js +2 -0
  38. package/public/resources/scripts/mod-utils/modutils-bc275eb41af515f626ef.min.js +2 -0
  39. package/public/resources/scripts/mod-utils/modutils.min.js +2 -0
  40. package/public/resources/scripts/trusted-form.hbs +38 -0
  41. package/public/resources/scripts/trusted-form.html +38 -0
  42. package/public/resources/styles/components/abandonment/abandonment-8a673f060817db6cb7dc.min.css +1 -0
  43. package/public/resources/styles/components/abandonment/abandonment.min.css +1 -0
  44. package/public/resources/styles/components/footer/mod-footer-d233fa64b6c8297c70ec.min.css +1 -0
  45. package/public/resources/styles/components/footer/mod-footer.min.css +1 -0
  46. package/public/resources/styles/components/footer/qs-footer-926e67c28d10c729db46.min.css +1 -0
  47. package/public/resources/styles/components/footer/qs-footer.min.css +1 -0
  48. package/src/resources/templates/modals/privacy/index.hbs +88 -89
  49. package/src/resources/templates/modals/privacy/index.html +88 -89
  50. package/src/resources/templates/modals/terms/index.hbs +8 -7
  51. package/src/resources/templates/modals/terms/index.html +8 -7
  52. package/src/scripts/globals.js +1 -3
  53. package/src/scripts/plugins.js +0 -3
  54. package/tasks/get-default-trade-questions.js +121 -157
  55. package/tasks/templates.js +2 -4
  56. package/gulp-tasks/add-path-subdirectories.js +0 -34
  57. package/gulp-tasks/build-stat.js +0 -9
  58. package/gulp-tasks/build.js +0 -28
  59. package/gulp-tasks/cache-bust.js +0 -19
  60. package/gulp-tasks/check-seasonal-variations.js +0 -21
  61. package/gulp-tasks/clean.js +0 -10
  62. package/gulp-tasks/combine-files.js +0 -7
  63. package/gulp-tasks/compile.js +0 -44
  64. package/gulp-tasks/copy-files-to-build-path.js +0 -8
  65. package/gulp-tasks/copy-fonts.js +0 -6
  66. package/gulp-tasks/copy-json.js +0 -6
  67. package/gulp-tasks/copy-resources-to-dist.js +0 -6
  68. package/gulp-tasks/copy-videos.js +0 -6
  69. package/gulp-tasks/extras.js +0 -22
  70. package/gulp-tasks/grab-cdn.js +0 -74
  71. package/gulp-tasks/grab-form-helpers.js +0 -55
  72. package/gulp-tasks/grab-global-images.js +0 -121
  73. package/gulp-tasks/grab-images.js +0 -79
  74. package/gulp-tasks/grab-shared-components.js +0 -46
  75. package/gulp-tasks/grab-shared-scripts.js +0 -275
  76. package/gulp-tasks/grab-theme-json.js +0 -24
  77. package/gulp-tasks/grab-tooltips-json.js +0 -33
  78. package/gulp-tasks/js-lint-husky.js +0 -35
  79. package/gulp-tasks/js-lint.js +0 -24
  80. package/gulp-tasks/minify.js +0 -131
  81. package/gulp-tasks/sass-lint.js +0 -15
  82. package/gulp-tasks/serve.js +0 -74
  83. package/gulp-tasks/settings.js +0 -22
  84. package/gulp-tasks/styles.js +0 -42
  85. package/gulp-tasks/tasks.js +0 -475
  86. package/gulp-tasks/templates.js +0 -288
  87. package/src/data/footer.js +0 -119
  88. package/src/scripts/default/additional-assets.js +0 -60
  89. package/src/scripts/default/rage-clicking.js +0 -54
  90. package/src/scripts/default/show-utility-providers.js +0 -28
  91. package/src/scripts/url-cleaner.js +0 -8
  92. package/src/scripts/vendor/google-tag-manager-head.js +0 -6
  93. package/src/scripts/vendor/heap-addeventproperties-identify.js +0 -262
  94. package/src/scripts/vendor/heap-tracking.js +0 -9
  95. package/src/styles/partials/_contact-us.scss +0 -196
  96. package/src/styles/partials/_google-address-autocomplete.scss +0 -52
  97. package/src/styles/partials/_mixins.scss +0 -39
  98. package/src/styles/partials/_modal-pages.scss +0 -125
  99. package/src/styles/partials/_modernize-colors.scss +0 -128
  100. package/src/styles/partials/_qs-footer.scss +0 -68
  101. package/src/styles/partials/_quote-footer-v1.scss +0 -79
  102. package/src/styles/partials/_quote-footer-v2.scss +0 -64
  103. package/src/styles/partials/_quote-footer-v3.scss +0 -65
  104. package/src/templates/_partials/scripts/deferred-styles.html +0 -16
  105. package/src/templates/_partials/scripts/heap-bundle.html +0 -5
  106. package/src/templates/_partials/scripts/heap.html +0 -4
  107. package/src/templates/_partials/scripts/utm-params.html +0 -9
  108. package/src/templates/components/qs-footer.html +0 -55
  109. package/src/templates/components/quote-footer-v1.html +0 -148
  110. package/src/templates/components/quote-footer-v2.html +0 -169
  111. /package/tasks/{addSeasonalchanges.js → add-seasonal-changes.js} +0 -0
  112. /package/tasks/{setupDevOpsTrackingId.js → setup-dev-ops-tracking-id.js} +0 -0
@@ -1,74 +0,0 @@
1
- var request = require('request');
2
- var source = require('vinyl-source-stream');
3
-
4
- // helper to allow us to define an "end" event to multiple streams
5
- function streamToDestination(gulp, siteSettings, inputPath, destPath, fileName) {
6
- var url = `https://${siteSettings.nodeEnv}${inputPath}`;
7
-
8
- return new Promise(resolve => { // eslint-disable-line no-undef
9
- request(url)
10
- .on('response', resp => {
11
- if (resp.statusCode !== 200) {
12
- throw new Error(`Error fetching ${url}`);
13
- }
14
- })
15
- .pipe(source(fileName))
16
- .pipe(gulp.dest(`${siteSettings.srcFolder}/${destPath}`))
17
- .on('finish', resolve);
18
- });
19
- }
20
-
21
- module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
22
- return function() {
23
- const { nodeEnv, isLocal } = siteSettings;
24
- const { isQSPage, isWhiteLabel, domain } = siteData;
25
- const isModWhiteLabel = isWhiteLabel && !isQSPage
26
- const domainHasModernize = domain.indexOf('modernize') > -1;
27
-
28
- let externalResources;
29
- // listing of Static Resources sub-path and site destination paths
30
- // key: inputPath, value: destPath
31
-
32
- externalResources = {
33
- '/quote/resources/mod-site/templates/scripts/trusted-form.html': ['/templates/scripts/', 'trusted-form.html']
34
- };
35
-
36
- // grab footer modals and place under the resources
37
- Object.assign(externalResources, {
38
- '/quote/resources/shared-resources/templates/modals/about/': ['/resources/templates/modals/about/', 'index.html'],
39
- '/quote/resources/shared-resources/templates/modals/privacy/': ['/resources/templates/modals/privacy/', 'index.html'],
40
- '/quote/resources/shared-resources/templates/modals/terms/': ['/resources/templates/modals/terms/', 'index.html'],
41
- '/quote/resources/shared-resources/templates/modals/contact-us/': ['/resources/templates/modals/contact-us/', 'index.html'],
42
- '/quote/resources/shared-resources/templates/modals/faq/': ['/resources/templates/modals/faq/', 'index.html']
43
- })
44
-
45
- Object.assign(externalResources, {'/quote/resources/mod-site/templates/scripts/jornaya.html': ['/templates/scripts/', 'jornaya.html']});
46
-
47
- if (isModWhiteLabel || domainHasModernize) {
48
- Object.assign(externalResources, {'/quote/resources/mod-site/templates/scripts/recaptcha.html': ['/templates/scripts/', 'recaptcha.html']});
49
- }
50
-
51
- // local dev files
52
- const remoteFilesForLocalDev = {
53
- '/quote/resources/mod-site/scripts/vendor/maxmind-geoip2.js': ['/temp/scripts/', 'maxmind-geoip2.js']
54
- };
55
-
56
- if (!nodeEnv) {
57
- throw new Error('Missing environment variables. Did you start with gulp instead of npm run...?');
58
- }
59
-
60
- // only save modform/utils if its local development
61
- if (isLocal) {
62
- externalResources = { ...externalResources, ...remoteFilesForLocalDev };
63
- }
64
-
65
- const filesPromiseMap = Object.keys(externalResources).map(key => {
66
- const destinationPath = externalResources[key][0];
67
- const fileName = externalResources[key][1];
68
- return streamToDestination(gulp, siteSettings, key, destinationPath, fileName);
69
- });
70
-
71
- // when Promise.all resolves, the streams are done and we can go to the next step
72
- return Promise.all(filesPromiseMap); // eslint-disable-line no-undef
73
- };
74
- };
@@ -1,55 +0,0 @@
1
- /* globals Promise */
2
- var request = require('request');
3
- var source = require('vinyl-source-stream');
4
-
5
- // helper to allow us to define an "end" event to multiple streams
6
- function streamToDestination(gulp, siteSettings, destPath, fileName) {
7
- if (!fileName) {
8
- return false;
9
- }
10
-
11
- var url = `https://${siteSettings.nodeEnv}/quote/resources/mod-form/form/${fileName}`;
12
- return new Promise(resolve => { // eslint-disable-line no-undef
13
- request(url)
14
- .on('response', (resp) => {
15
- if (resp.statusCode !== 200) {
16
- throw new Error(`Error fetching ${url}`);
17
- }
18
- })
19
- .pipe(source(fileName))
20
- .pipe(gulp.dest(`${siteSettings.srcFolder}/${destPath}`))
21
- .on('finish', resolve);
22
- });
23
- }
24
-
25
- async function getHelpers(siteSettings) {
26
- let helpers = [];
27
- await new Promise(resolve => {
28
- request(`https://${siteSettings.nodeEnv}/quote/resources/mod-form/form/chunks.txt`, function(err, response, body) {
29
- if (response.statusCode === 200) {
30
- helpers = body.split('\n');
31
- }
32
- resolve();
33
- });
34
- });
35
- return helpers;
36
- }
37
-
38
- module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
39
- return async function() {
40
- const { nodeEnv } = siteSettings;
41
- const helpers = await getHelpers(siteSettings);
42
-
43
- if (!nodeEnv) {
44
- throw new Error('Missing environment variables. Did you start with gulp instead of npm run...?');
45
- }
46
- const destinationPath = '/resources/scripts/helpers/';
47
- const filesPromiseMap = helpers.map(helper => {
48
- const fileName = helper;
49
- return streamToDestination(gulp, siteSettings, destinationPath, fileName);
50
- });
51
-
52
- // when Promise.all resolves, the streams are done and we can go to the next step
53
- return Promise.all(filesPromiseMap); // eslint-disable-line no-undef
54
- };
55
- };
@@ -1,121 +0,0 @@
1
- var fs = require('fs');
2
- var request = require('request');
3
- var source = require('vinyl-source-stream');
4
- var replace = require('gulp-replace');
5
- var path = require('path')
6
-
7
- var imagePaths = [];
8
-
9
- function getFilePathFromURL(url) {
10
- let pathName = new URL(url).pathname;
11
- pathName = pathName.substring(0, pathName.lastIndexOf('/'));
12
- pathName = pathName.replace('/quote/resources/', '');
13
-
14
- return pathName;
15
- }
16
-
17
- function streamToDestination(gulp, siteSettings, url) {
18
- let finalDestination;
19
- let fileName = path.basename(url);
20
- const filePath = getFilePathFromURL(url);
21
-
22
- if (!fs.existsSync(siteSettings.distFolder)) {
23
- finalDestination = siteSettings.srcFolder;
24
- } else {
25
- finalDestination = siteSettings.distFolder;
26
- }
27
-
28
- // fix for svg sprites
29
- if (fileName.includes(".svg#")) {
30
- const hashIndex = fileName.indexOf("#");
31
- const strippedFileName = fileName.substring(0, hashIndex);
32
- fileName = strippedFileName;
33
- }
34
-
35
- return new Promise(resolve => { // eslint-disable-line no-undef
36
- request(url)
37
- .on('response', resp => {
38
- if (resp.statusCode !== 200 && resp.statusCode !== 206) {
39
- throw new Error(`${resp.statusCode} Error while fetching ${fileName}`);
40
- } else {
41
- imagePaths.push(url);
42
- }
43
- })
44
- .pipe(source(fileName))
45
- .pipe(gulp.dest(`${finalDestination}/resources/${filePath}`))
46
- .on('finish', resolve);
47
- });
48
- }
49
-
50
- function replaceImagePath(gulp, siteSettings) {
51
- var finalDestination;
52
-
53
- if (!fs.existsSync(siteSettings.distFolder)) {
54
- finalDestination = siteSettings.tmpFolder;
55
- } else {
56
- finalDestination = siteSettings.distFolder;
57
- }
58
-
59
- var stream = gulp.src(`${finalDestination}/index.html`);
60
-
61
- if (imagePaths.length) {
62
- imagePaths.forEach(function(imagePath) {
63
- const fileName = path.basename(imagePath);
64
- const filePath = getFilePathFromURL(imagePath);
65
- stream = stream.pipe(replace(new RegExp(`"${imagePath}"`, 'gm'), `"/resources/${filePath}/${fileName}"`))
66
- });
67
- }
68
- return stream.pipe(gulp.dest(finalDestination))
69
- }
70
-
71
- const getTags = (string) => {
72
- const regExs = [/<img.*?src="(.*?)"[^\>]+>/g, /<use.*?href="(.*?)".*?>/g, /<source.*?srcset="(.*?)".*?>/g, /url\('#{\$path}.*?'\)/g];
73
- let tags = [];
74
-
75
- regExs.forEach((regEx) => {
76
- const match = string.match(regEx);
77
-
78
- if (match) {
79
- tags = [...tags, ...match];
80
- }
81
- });
82
-
83
- return tags;
84
- };
85
-
86
- const getUrls = (tags) => {
87
- const urls = [];
88
-
89
- tags.forEach((tag) => {
90
- if (tag) {
91
- let url = tag;
92
- url = url.match(/(https?:\/\/[^\s]+)/gim);
93
- if (url) {
94
- url = url[0];
95
- url = url.replace(/"/g, "")
96
- urls.push(url)
97
- }
98
- }
99
- });
100
-
101
- return [...new Set(urls)]; // eslint-disable-line no-undef
102
- };
103
-
104
- const parseImageSources = (gulp, siteSettings) => {
105
- const text = fs.readFileSync(`${siteSettings.tmpFolder}/index.html`, 'utf8');
106
- const textMatches = getTags(text);
107
- return getUrls(textMatches);
108
- };
109
-
110
- module.exports = function(gulp, siteSettings, siteData) {
111
- return async function() {
112
- const urls = parseImageSources(gulp, siteSettings);
113
- const urlsPromises = urls.map(async (url) => {
114
- return await streamToDestination(gulp, siteSettings, url);
115
- });
116
-
117
- return await Promise.all(urlsPromises).then(function() { // eslint-disable-line no-undef
118
- replaceImagePath(gulp, siteSettings)
119
- })
120
- };
121
- };
@@ -1,79 +0,0 @@
1
- var fs = require('fs');
2
- var request = require('request');
3
- var source = require('vinyl-source-stream');
4
-
5
- function streamToDestination(gulp, siteSettings, externalPath, fileName, destPath) {
6
- return new Promise(resolve => { // eslint-disable-line no-undef
7
- request(`https://${siteSettings.nodeEnv}/quote/resources/assets/images/${externalPath}`)
8
- .on('response', resp => {
9
- if (resp.statusCode !== 200 && resp.statusCode !== 206) {
10
- throw new Error(`${resp.statusCode} Error while fetching ${fileName}`);
11
- }
12
- })
13
- .pipe(source(fileName))
14
- .pipe(gulp.dest(`${siteSettings.srcFolder}/${destPath}`))
15
- .on('finish', resolve);
16
- });
17
- }
18
-
19
- const getTags = (string) => {
20
- const regExs = [/<img.*?src="(.*?)"[^\>]+>/g, /<use.*?href="(.*?)".*?>/g, /<source.*?srcset="(.*?)".*?>/g, /url\('#{\$path}.*?'\)/g];
21
- let tags = [];
22
-
23
- regExs.forEach((regEx) => {
24
- const match = string.match(regEx);
25
-
26
- if (match) {
27
- tags = [...tags, ...match];
28
- }
29
- });
30
-
31
- return tags;
32
- };
33
-
34
- const getUrls = (tags) => {
35
- const urls = [];
36
-
37
- tags.forEach((tag) => {
38
- const isHTML = tag.indexOf('{{assetsPath}}');
39
- const isCSS = tag.indexOf('url(\'#{$path}');
40
- const varName = isHTML > -1 ? '{{assetsPath}}' : 'url(\'#{$path}';
41
-
42
- if (isHTML > -1 || isCSS > -1) {
43
- let url = tag;
44
-
45
- if (isHTML > -1) {
46
- url = url.slice(tag.indexOf(varName));
47
- url = url.indexOf('#') > -1 ? url.slice(0, url.indexOf('#')) : url.slice(0, url.indexOf('"'));
48
- } else {
49
- url = url.replace('\')', '');
50
- }
51
-
52
- url = url.replace(`${varName}/images/`, '');
53
- urls.push(url);
54
- }
55
- });
56
-
57
- return [...new Set(urls)]; // eslint-disable-line no-undef
58
- };
59
-
60
- const parseImageSources = (gulp, siteSettings) => {
61
- const text = fs.readFileSync(`${siteSettings.tmpFolder}/all.txt`, 'utf8');
62
- const textMatches = getTags(text);
63
- return getUrls(textMatches);
64
- };
65
-
66
- module.exports = function(gulp, siteSettings, siteData) {
67
- return function() {
68
- const { isWhiteLabel } = siteData;
69
- const urls = parseImageSources(gulp, siteSettings);
70
- const ouputPath = isWhiteLabel ? 'images/' : 'temp/assets/images/';
71
- const urlsPromises = urls.map((url) => {
72
- const fileName = url.slice(url.lastIndexOf('/') + 1);
73
- const relativePath = ouputPath + url.replace(fileName, '');
74
- return streamToDestination(gulp, siteSettings, url, fileName, relativePath);
75
- });
76
-
77
- return Promise.all(urlsPromises); // eslint-disable-line no-undef
78
- };
79
- };
@@ -1,46 +0,0 @@
1
- var request = require('request');
2
- var source = require('vinyl-source-stream');
3
-
4
- function streamSharedCompsToDestination(gulp, siteSettings, folder, fileName) {
5
- return new Promise(resolve => {
6
- request(`https://${siteSettings.nodeEnv}/quote/resources/mod-site/${folder}/${fileName}`)
7
- .on('response', resp => {
8
- if (resp.statusCode !== 200) {
9
- throw new Error(`${resp.statusCode} Error while fetching ${fileName}`);
10
- }
11
- })
12
- .pipe(source(fileName))
13
- .pipe(gulp.dest(`${siteSettings.srcFolder}/${folder}/`))
14
- .on('finish', resolve);
15
- });
16
- }
17
-
18
- function getListOfSharedComponents(gulp, gulpPlugins, siteSettings, componentFolders) {
19
- return componentFolders.map(folder => {
20
- return new Promise(resolve => {
21
- request(`https://${siteSettings.nodeEnv}/quote/resources/mod-site/${folder}/all.json`, function(err, resp, body) {
22
- if (resp.statusCode !== 200) {
23
- throw new Error(`${resp.statusCode}: Error while fetching ${folder}/all.json`);
24
- }
25
- var listOfComponents = JSON.parse(body);
26
- const componentPromises = listOfComponents.map(function(resource) {
27
- return streamSharedCompsToDestination(gulp, siteSettings, folder, `${resource}`);
28
- });
29
- resolve(Promise.all(componentPromises));
30
- });
31
- });
32
- });
33
- }
34
-
35
- module.exports = function(gulp, gulpPlugins, siteSettings) {
36
- return function() {
37
- const { nodeEnv } = siteSettings;
38
- if (!nodeEnv) {
39
- throw new Error('Missing environment variables. Did you start with gulp instead of npm run...?');
40
- }
41
-
42
- const componentFolders = ['shared-components', 'accessible-components']
43
-
44
- return getListOfSharedComponents(gulp, gulpPlugins, siteSettings, componentFolders);
45
- };
46
- };
@@ -1,275 +0,0 @@
1
- var request = require('request');
2
- var source = require('vinyl-source-stream');
3
- var replace = require('gulp-replace');
4
- var hash = require('gulp-hash');
5
- var tap = require('gulp-tap');
6
- var path = require('path');
7
- var buffer = require('gulp-buffer');
8
-
9
- const fileNames = {
10
- modAlyticsFileName: '',
11
- modUtilsFileName: '',
12
- abandonmentJsFileName: '',
13
- footerComponentJsFileName: '',
14
- modFooterStylesFileName: '',
15
- qsFooterStylesFileName: '',
16
- homeownerFormFileName: '',
17
- callrailFileName: ''
18
- };
19
- var isQuotePageOrUseRelativePath = false;
20
- var resourceURL = '';
21
- var pathSubdirectory = '';
22
- var componentFolderPath = '';
23
-
24
- function replaceModalyticsSrc(gulp, gulpPlugins, siteSettings, siteData) {
25
- const resourcePath = isQuotePageOrUseRelativePath ? `${pathSubdirectory}{{#if this.src}}{{this.src}}{{/if}}resources/scripts/mod-alytics/` : '/resources/scripts/mod-alytics/';
26
- return gulp.src(`${siteSettings.srcFolder}/${componentFolderPath}/head/head.html`)
27
- .pipe(replace(/".*(modalytics).*"/, `"${resourcePath}${fileNames.modAlyticsFileName}"`))
28
- .pipe(gulp.dest(`${siteSettings.srcFolder}/${componentFolderPath}/head`));
29
- }
30
- function replaceFootAssetScripts(gulp, gulpPlugins, siteSettings, siteData) {
31
- const resourcePath = isQuotePageOrUseRelativePath ? `${pathSubdirectory}{{#if this.nodeModulesPath}}{{this.nodeModulesPath}}{{/if}}resources/scripts` : '/resources/scripts';
32
- return gulp.src(`${siteSettings.srcFolder}/${componentFolderPath}/foot-assets/foot-assets.html`)
33
- .pipe(replace(/"(?:(?!"|js")[\s\S])+(modutils|mod-utils.*?)js"|"(?:(?!"|")[\s\S])+(callrail.*?)js"|"(?:(?!"|")[\s\S])+(footer\/footer-component.*?)js"|"(?:(?!"|")[\s\S])+(mod-form\/form.*?)js"/g, function(match) {
34
- if (match.includes('mod-form/form')) {
35
- return `"${resourcePath}/mod-form/form/${fileNames.homeownerFormFileName}"`;
36
- } else if (match.includes('callrail')) {
37
- return `"${resourcePath}/callrail/${fileNames.callrailFileName}"`;
38
- } else if (match.includes('modutils') || match.includes('mod-utils')) {
39
- return `"${resourcePath}/mod-utils/${fileNames.modUtilsFileName}"`;
40
- } else if (match.includes('footer-component')) {
41
- return `"${resourcePath}/footer/${fileNames.footerComponentJsFileName}"`;
42
- }
43
- }))
44
- .pipe(gulp.dest(`${siteSettings.srcFolder}/${componentFolderPath}/foot-assets`))
45
- .on('end', function() {
46
- console.log('>> FINISHED replacing foot asset scripts');
47
- });
48
- }
49
- function replaceAbandonmentJsCssSrc(gulp, gulpPlugins, siteSettings, siteData) {
50
- const jsResourcePath = isQuotePageOrUseRelativePath ? `${pathSubdirectory}resources/scripts/abandonment/` : '/resources/scripts/abandonment/';
51
- const cssResourcePath = isQuotePageOrUseRelativePath ? `${pathSubdirectory}resources/styles/components/abandonment/` : '/resources/styles/components/abandonment/';
52
- return gulp.src(siteSettings.srcFolder + '/templates/abandonment/*.html')
53
- .pipe(replace(/"(?:(?!"|")[\s\S])+(abandonment\/abandonment.*?)js"/, `"${jsResourcePath}${fileNames.abandonmentJsFileName}"`))
54
- .pipe(replace(/"(?:(?!"|")[\s\S])+(components\/abandonment\/abandonment.*?)css"/, `"${cssResourcePath}${fileNames.abandonmentStylesFileName}"`))
55
- .pipe(gulp.dest(siteSettings.srcFolder + '/templates/abandonment'));
56
- }
57
- function replaceFooterStylesReference(gulp, gulpPlugins, siteSettings, siteData) {
58
- if (siteData.siteData && siteData.siteData.useRelativePathForResources === true) {
59
- return gulp.src(siteSettings.srcFolder + '/resources/scripts/footer/' + fileNames.footerComponentJsFileName)
60
- .pipe(replace(/concat\((?:(?!concat\(|\))[\s\S])+(components\/footer\/mod.*?)\)/, `concat("${pathSubdirectory}resources/styles/components/footer/` + fileNames.modFooterStylesFileName + '")'))
61
- .pipe(replace(/concat\((?:(?!concat\(|\))[\s\S])+(components\/footer\/qs.*?)\)/, `concat("${pathSubdirectory}resources/styles/components/footer/` + fileNames.qsFooterStylesFileName + '")'))
62
- .pipe(gulp.dest(siteSettings.srcFolder + '/resources/scripts/footer'))
63
- } else if (!siteData.siteData || siteData.siteData && !siteData.siteData.isQuotePage) {
64
- return gulp.src(siteSettings.srcFolder + '/resources/scripts/footer/' + fileNames.footerComponentJsFileName)
65
- .pipe(replace(/concat\((?:(?!concat\(|\))[\s\S])+(components\/footer\/mod.*?)\)/, 'concat("/resources/styles/components/footer/' + fileNames.modFooterStylesFileName + '")'))
66
- .pipe(replace(/concat\((?:(?!concat\(|\))[\s\S])+(components\/footer\/qs.*?)\)/, 'concat("/resources/styles/components/footer/' + fileNames.qsFooterStylesFileName + '")'))
67
- .pipe(gulp.dest(siteSettings.srcFolder + '/resources/scripts/footer'))
68
- }
69
- }
70
- function replaceFooterStylesReferenceInMap(gulp, gulpPlugins, siteSettings, siteData) {
71
- if (siteData.siteData && siteData.siteData.useRelativePathForResources === true) {
72
- return gulp.src(siteSettings.srcFolder + '/resources/scripts/footer/footer-component.min.js.map')
73
- .pipe(replace(/\`(?:(?!\`|\`)[\s\S])+(components\/footer\/mod.*?)\`/, '`' + pathSubdirectory + 'resources/styles/components/footer/' + fileNames.modFooterStylesFileName + '`'))
74
- .pipe(replace(/\`(?:(?!\`|\`)[\s\S])+(components\/footer\/mod.*?)\`/, '`' + pathSubdirectory + 'resources/styles/components/footer/' + fileNames.qsFooterStylesFileName + '`'))
75
- .pipe(gulp.dest(siteSettings.srcFolder + '/resources/scripts/footer'));
76
- } else if (!siteData.siteData || siteData.siteData && !siteData.siteData.isQuotePage) {
77
- return gulp.src(siteSettings.srcFolder + '/resources/scripts/footer/footer-component.min.js.map')
78
- .pipe(replace(/\`(?:(?!\`|\`)[\s\S])+(components\/footer\/mod.*?)\`/, '`/resources/styles/components/footer/' + fileNames.modFooterStylesFileName + '`'))
79
- .pipe(replace(/\`(?:(?!\`|\`)[\s\S])+(components\/footer\/mod.*?)\`/, '`/resources/styles/components/footer/' + fileNames.qsFooterStylesFileName + '`'))
80
- .pipe(gulp.dest(siteSettings.srcFolder + '/resources/scripts/footer'));
81
- }
82
- }
83
- function getFileFromURL(url) {
84
- return url.split('/').pop();
85
- }
86
- function getResource(url, config = {}, fn, fnArray) {
87
- if (Object.keys(config).length === 0) {
88
- return false;
89
- }
90
-
91
- return new Promise(resolve => {
92
- const file = getFileFromURL(url);
93
- request(`${resourceURL}/${url}`)
94
- .on('response', resp => {
95
- if (resp.statusCode !== 200) {
96
- throw new Error(`${resp.statusCode} Error while fetching ${file}`);
97
- }
98
- })
99
- .pipe(source(file))
100
- .pipe(buffer())
101
- .pipe(hash({
102
- hashLength: 20,
103
- algorithm: 'md5',
104
- template: file.replace(/^([^.]*)\.(.*)$/, '$1-<%= hash %>.$2')
105
- }))
106
- .pipe(tap(function(file, t) {
107
- fileNames[config.fileName] = path.basename(file.path);
108
- }))
109
- .pipe(config.gulp.dest(`${config.siteSettings.srcFolder}/resources/${config.dest}`))
110
- .on('finish', function(){
111
- resolve();
112
- });
113
- })
114
- .then(() => {
115
- if (!config.mapUrl) { return false };
116
- const file = getFileFromURL(config.mapUrl);
117
- return new Promise((resolve) => {
118
- request(`${resourceURL}/${config.mapUrl}`)
119
- .on('response', (resp) => {
120
- if (resp.statusCode !== 200) {
121
- throw new Error(`${resp.statusCode} Error while fetching ${file}`);
122
- } else {
123
- if (typeof fn === 'function') {
124
- fn.call(null, config.gulp, config.gulpSettings, config.siteSettings, config.siteData);
125
- }
126
- }
127
- })
128
- .pipe(source(file))
129
- .pipe(config.gulp.dest(`${config.siteSettings.srcFolder}/resources/${config.dest}`))
130
- .on('finish', function(){
131
- resolve();
132
- });
133
- });
134
- })
135
- .then(() => {
136
- if (fnArray && fnArray.length) {
137
- fnArray.map(function(fn) {
138
- if (typeof fn === 'function') {
139
- fn.call(null, config.gulp, config.gulpSettings, config.siteSettings, config.siteData)
140
- }
141
- });
142
- }
143
- });
144
- }
145
- const TASKS = {
146
- copyCallrail: {
147
- url: 'shared-resources/scripts/callrail/callrail.min.js',
148
- config: {
149
- fileName: 'callrailFileName',
150
- dest: 'scripts/callrail',
151
- mapUrl: 'shared-resources/scripts/callrail/callrail.min.js.map',
152
- },
153
- srcReplaceFn: null,
154
- additionalSrcReplaceFns: []
155
- },
156
- copyModutils: {
157
- url: 'mod-utils/modutils.min.js',
158
- config: {
159
- fileName: 'modUtilsFileName',
160
- dest: 'scripts/mod-utils',
161
- mapUrl: 'mod-utils/modutils.min.js.map',
162
- },
163
- srcReplaceFn: null,
164
- additionalSrcReplaceFns: []
165
- },
166
- copyFooterComponentJs: {
167
- url: 'shared-resources/scripts/footer/footer-component.min.js',
168
- config: {
169
- fileName: 'footerComponentJsFileName',
170
- dest: 'scripts/footer',
171
- mapUrl: 'shared-resources/scripts/footer/footer-component.min.js.map',
172
- },
173
- srcReplaceFn: null,
174
- additionalSrcReplaceFns: []
175
- },
176
- copyHomeownerForm: {
177
- url: 'mod-form/form/homeowner.min.js',
178
- config: {
179
- fileName: 'homeownerFormFileName',
180
- dest: 'scripts/mod-form/form',
181
- mapUrl: 'mod-form/form/homeowner.min.js.map',
182
- },
183
- srcReplaceFn: replaceFootAssetScripts,
184
- additionalSrcReplaceFns: []
185
- },
186
- copyModalytics: {
187
- url: 'mod-alytics/modalytics.min.js',
188
- config: {
189
- fileName: 'modAlyticsFileName',
190
- dest: 'scripts/mod-alytics',
191
- mapUrl: 'mod-alytics/modalytics.min.js.map',
192
- },
193
- srcReplaceFn: replaceModalyticsSrc,
194
- additionalSrcReplaceFns: []
195
- },
196
- copyAbandonmentComponentStyles: {
197
- url: 'shared-resources/styles/components/abandonment/abandonment.min.css',
198
- config: {
199
- fileName: 'abandonmentStylesFileName',
200
- dest: 'styles/components/abandonment',
201
- mapUrl: null,
202
- },
203
- srcReplaceFn: null,
204
- additionalSrcReplaceFns: []
205
- },
206
- copyAbandonmentJs: {
207
- url: 'shared-resources/scripts/abandonment/abandonment.min.js',
208
- config: {
209
- fileName: 'abandonmentJsFileName',
210
- dest: 'scripts/abandonment',
211
- mapUrl: 'shared-resources/scripts/abandonment/abandonment.min.js.map',
212
- },
213
- srcReplaceFn: replaceAbandonmentJsCssSrc,
214
- additionalSrcReplaceFns: []
215
- },
216
- copyModFooterComponentStyles: {
217
- url: 'shared-resources/styles/components/footer/mod-footer.min.css',
218
- config: {
219
- fileName: 'modFooterStylesFileName',
220
- dest: 'styles/components/footer',
221
- mapUrl: null,
222
- },
223
- srcReplaceFn: null,
224
- additionalSrcReplaceFns: []
225
- },
226
- copyQsFooterComponentStyles: {
227
- url: 'shared-resources/styles/components/footer/qs-footer.min.css',
228
- config: {
229
- fileName: 'qsFooterStylesFileName',
230
- dest: 'styles/components/footer',
231
- mapUrl: null,
232
- },
233
- srcReplaceFn: null,
234
- additionalSrcReplaceFns: [replaceFooterStylesReference, replaceFooterStylesReferenceInMap]
235
- }
236
- };
237
- module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
238
- const { isLocal } = siteSettings
239
- const isQuotePage = siteData.siteData && siteData.siteData.isQuotePage || siteData && siteData.isQuotePage;
240
- const useAccessibleComponents = siteData.siteData && siteData.siteData.useAccessibleConfig || siteData && siteData.useAccessibleConfig;
241
- const useRelativePathForResources = siteData.siteData && siteData.siteData.useRelativePathForResources || siteData && siteData.useRelativePathForResources;
242
- componentFolderPath = useAccessibleComponents === true ? 'accessible-components' : 'shared-components';
243
- isQuotePageOrUseRelativePath = isQuotePage === true || useRelativePathForResources === true;
244
- resourceURL = `https://${siteSettings.nodeEnv}/quote/resources`;
245
- const isPathSubdirectory = siteData.siteData && siteData.siteData.pathSubdirectory || siteData && siteData.pathSubdirectory;
246
- pathSubdirectory = !isLocal && isPathSubdirectory ? isPathSubdirectory : '';
247
-
248
- return function() {
249
- const { nodeEnv } = siteSettings;
250
- if (!nodeEnv) {
251
- throw new Error('Missing environment variables. Did you start with gulp instead of npm run...?');
252
- }
253
- return (function() {
254
- const tasks = Object.values(TASKS)
255
-
256
- if (tasks.length) {
257
- var getAllResources = tasks.map(function(task) {
258
- if (useAccessibleComponents === true) {
259
- if (task.url.includes('abandonment.min.js')) {
260
- task.url = 'shared-resources/scripts/abandonment/accessible/abandonment.min.js';
261
- task.config.mapUrl = 'shared-resources/scripts/abandonment/accessible/abandonment.min.js.map';
262
- }
263
- }
264
- Object.assign(task.config, { gulp, gulpPlugins, siteSettings, siteData });
265
- return getResource(task.url, task.config, task.srcReplaceFn, task.additionalSrcReplaceFns)
266
- });
267
- }
268
-
269
- return Promise.all(getAllResources)
270
- .then(() => {
271
- console.log(`>> FILENAMES object = ${JSON.stringify(fileNames)}`);
272
- })
273
- }());
274
- };
275
- };
@@ -1,24 +0,0 @@
1
- var request = require('request');
2
- var source = require('vinyl-source-stream');
3
-
4
- // helper to allow us to define an "end" event to multiple streams
5
- function streamToDestination(gulp, gulpPlugins, siteSettings, fileName) {
6
- return new Promise(resolve => { // eslint-disable-line no-undef
7
- request(`https://${siteSettings.nodeEnv}/quote/resources/data/themes/${fileName}.json`)
8
- .on('response', resp => {
9
- if (resp.statusCode !== 200) {
10
- throw new Error(`${resp.statusCode}: Error while fetching ${fileName}.json`);
11
- }
12
- })
13
- .pipe(source(fileName))
14
- .pipe(gulpPlugins.rename('theme.json'))
15
- .pipe(gulp.dest(`${siteSettings.srcFolder}/data`))
16
- .on('finish', resolve);
17
- });
18
- }
19
-
20
- module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
21
- return function() {
22
- return streamToDestination(gulp, gulpPlugins, siteSettings, siteData.page.themeFile);
23
- };
24
- };