mod-build 3.6.61-beta.1 → 3.6.61-beta.10

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,8 +2,11 @@
2
2
 
3
3
  ## 3.6.61
4
4
 
5
- - added functionality to increase the fileInclude maxRecursion value from site level
6
- - fixed bug in `templates` task. It was not completing as expected.
5
+ - Adding the accessible components to the `grab-shared-components` task; As well as pulling the accessible `defaultFormFieldConfig` for the new template.js configuration (& merging to the new template stucture appropriately);
6
+
7
+ ## 3.6.60
8
+
9
+ - Adding consoles allllll throughout the `grab-shared-scripts` task. It is still breaking down somewhere; and the first step to trying to force-fail our builds is figure out where the issue is
7
10
 
8
11
  ## 3.6.59
9
12
 
@@ -19,6 +22,7 @@
19
22
  - adding `!window.Modalytics.privacyPreferencesDetected` conditional to check privacy settings to not load Heap for modernize.com
20
23
 
21
24
  ## 3.6.55
25
+
22
26
  - Added conditional to check if `siteData` is empty — so our `fetchTcpaFromSitegenie()` and `getDefaultFormFieldConfig()` functions won't try to run on modify.modernize.com
23
27
 
24
28
  ## 3.6.54
@@ -1,31 +1,33 @@
1
1
  var request = require('request');
2
2
  var source = require('vinyl-source-stream');
3
3
 
4
- function streamSharedCompsToDestination(gulp, siteSettings, fileName) {
5
- return new Promise(resolve => { // eslint-disable-line no-undef
6
- request(`https://${siteSettings.nodeEnv}/quote/resources/mod-site/shared-components/${fileName}`)
4
+ function streamSharedCompsToDestination(gulp, siteSettings, folder, fileName) {
5
+ return new Promise(resolve => {
6
+ request(`https://${siteSettings.nodeEnv}/quote/resources/mod-site/${folder}/${fileName}`)
7
7
  .on('response', resp => {
8
8
  if (resp.statusCode !== 200) {
9
9
  throw new Error(`${resp.statusCode} Error while fetching ${fileName}`);
10
10
  }
11
11
  })
12
12
  .pipe(source(fileName))
13
- .pipe(gulp.dest(`${siteSettings.srcFolder}/shared-components/`))
13
+ .pipe(gulp.dest(`${siteSettings.srcFolder}/${folder}/`))
14
14
  .on('finish', resolve);
15
15
  });
16
16
  }
17
17
 
18
- function getListOfSharedComponents(gulp, gulpPlugins, siteSettings) {
19
- return new Promise(resolve => { // eslint-disable-line no-undef
20
- request(`https://${siteSettings.nodeEnv}/quote/resources/mod-site/shared-components/all.json`, function(err, resp, body) {
21
- if (resp.statusCode !== 200) {
22
- throw new Error(`${resp.statusCode}: Error while fetching shared-components/all.json`);
23
- }
24
- var listOfComponents = JSON.parse(body);
25
- const componentPromises = listOfComponents.map(function(resource) {
26
- return streamSharedCompsToDestination(gulp, siteSettings, `${resource}`);
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));
27
30
  });
28
- resolve(Promise.all(componentPromises)); // eslint-disable-line no-undef
29
31
  });
30
32
  });
31
33
  }
@@ -37,6 +39,8 @@ module.exports = function(gulp, gulpPlugins, siteSettings) {
37
39
  throw new Error('Missing environment variables. Did you start with gulp instead of npm run...?');
38
40
  }
39
41
 
40
- return getListOfSharedComponents(gulp, gulpPlugins, siteSettings); // eslint-disable-line no-undef
42
+ const componentFolders = ['shared-components', 'accessible-components']
43
+
44
+ return getListOfSharedComponents(gulp, gulpPlugins, siteSettings, componentFolders);
41
45
  };
42
46
  };
@@ -18,29 +18,34 @@ const fileNames = {
18
18
  var isQuotePageOrUseRelativePath = false;
19
19
  var resourceURL = '';
20
20
  var pathSubdirectory = '';
21
+ var componentFolderPath = '';
21
22
 
22
23
  function replaceModalyticsSrc(gulp, gulpPlugins, siteSettings, siteData) {
23
24
  const resourcePath = isQuotePageOrUseRelativePath ? `${pathSubdirectory}{{#if this.src}}{{this.src}}{{/if}}resources/scripts/mod-alytics/` : '/resources/scripts/mod-alytics/';
24
- return gulp.src(siteSettings.srcFolder + '/shared-components/head/head.html')
25
+ console.log(`>> VARIABLE modAlyticsFileName = ${fileNames.modAlyticsFileName}`)
26
+ return gulp.src(`${siteSettings.srcFolder}/${componentFolderPath}/head/head.html`)
25
27
  .pipe(replace(/".*(modalytics).*"/, `"${resourcePath}${fileNames.modAlyticsFileName}"`))
26
- .pipe(gulp.dest(siteSettings.srcFolder + '/shared-components/head'));
28
+ .pipe(gulp.dest(`${siteSettings.srcFolder}/${componentFolderPath}/head`));
27
29
  }
28
30
  function replaceFootAssetScripts(gulp, gulpPlugins, siteSettings, siteData) {
29
- console.log('>> STARTING Replacing Foot Asset Scripts');
31
+ console.log('>> STARTING replacing foot asset scripts');
30
32
  const resourcePath = isQuotePageOrUseRelativePath ? `${pathSubdirectory}{{#if this.nodeModulesPath}}{{this.nodeModulesPath}}{{/if}}resources/scripts` : '/resources/scripts';
31
- return gulp.src(siteSettings.srcFolder + '/shared-components/foot-assets/foot-assets.html')
33
+ return gulp.src(`${siteSettings.srcFolder}/${componentFolderPath}/foot-assets/foot-assets.html`)
32
34
  .pipe(replace(/"(?:(?!"|js")[\s\S])+(modutils|mod-utils.*?)js"|"(?:(?!"|")[\s\S])+(footer\/footer-component.*?)js"|"(?:(?!"|")[\s\S])+(mod-form\/form.*?)js"/g, function(match) {
33
35
  if (match.includes('mod-form/form')) {
36
+ console.log(`>> VARIABLE homeownerFormFileName = ${fileNames.homeownerFormFileName}`);
34
37
  return `"${resourcePath}/mod-form/form/${fileNames.homeownerFormFileName}"`;
35
38
  } else if (match.includes('modutils') || match.includes('mod-utils')) {
39
+ console.log(`>> VARIABLE modUtilsFileName = ${fileNames.modUtilsFileName}`)
36
40
  return `"${resourcePath}/mod-utils/${fileNames.modUtilsFileName}"`;
37
41
  } else if (match.includes('footer-component')) {
42
+ console.log(`>> VARIABLE footerComponentJsFileName = ${fileNames.footerComponentJsFileName}`)
38
43
  return `"${resourcePath}/footer/${fileNames.footerComponentJsFileName}"`;
39
44
  }
40
45
  }))
41
- .pipe(gulp.dest(siteSettings.srcFolder + '/shared-components/foot-assets'))
46
+ .pipe(gulp.dest(`${siteSettings.srcFolder}/${componentFolderPath}/foot-assets`))
42
47
  .on('end', function() {
43
- console.log('>> FINISHED Replacing Foot Asset Scripts');
48
+ console.log('>> FINISHED replacing foot asset scripts');
44
49
  });
45
50
  }
46
51
  function replaceAbandonmentJsCssSrc(gulp, gulpPlugins, siteSettings, siteData) {
@@ -52,6 +57,8 @@ function replaceAbandonmentJsCssSrc(gulp, gulpPlugins, siteSettings, siteData) {
52
57
  .pipe(gulp.dest(siteSettings.srcFolder + '/templates/abandonment'));
53
58
  }
54
59
  function replaceFooterStylesReference(gulp, gulpPlugins, siteSettings, siteData) {
60
+ console.log(`>> VARIABLE modFooterStylesFileName (main styles) = ${fileNames.modFooterStylesFileName}`)
61
+ console.log(`>> VARIABLE qsFooterStylesFileName (main styles) = ${fileNames.qsFooterStylesFileName}`)
55
62
  if (siteData.siteData && siteData.siteData.useRelativePathForResources === true) {
56
63
  return gulp.src(siteSettings.srcFolder + '/resources/scripts/footer/' + fileNames.footerComponentJsFileName)
57
64
  .pipe(replace(/concat\((?:(?!concat\(|\))[\s\S])+(components\/footer\/mod.*?)\)/, `concat("${pathSubdirectory}resources/styles/components/footer/` + fileNames.modFooterStylesFileName + '")'))
@@ -65,6 +72,8 @@ function replaceFooterStylesReference(gulp, gulpPlugins, siteSettings, siteData)
65
72
  }
66
73
  }
67
74
  function replaceFooterStylesReferenceInMap(gulp, gulpPlugins, siteSettings, siteData) {
75
+ console.log(`>> VARIABLE modFooterStylesFileName (map styles) = ${fileNames.modFooterStylesFileName}`)
76
+ console.log(`>> VARIABLE qsFooterStylesFileName (map styles) = ${fileNames.qsFooterStylesFileName}`)
68
77
  if (siteData.siteData && siteData.siteData.useRelativePathForResources === true) {
69
78
  return gulp.src(siteSettings.srcFolder + '/resources/scripts/footer/footer-component.min.js.map')
70
79
  .pipe(replace(/\`(?:(?!\`|\`)[\s\S])+(components\/footer\/mod.*?)\`/, '`' + pathSubdirectory + 'resources/styles/components/footer/' + fileNames.modFooterStylesFileName + '`'))
@@ -125,7 +134,10 @@ function getResource(url, config = {}, fn, fnArray) {
125
134
  })
126
135
  .pipe(source(file))
127
136
  .pipe(config.gulp.dest(`${config.siteSettings.srcFolder}/resources/${config.dest}`))
128
- .on('finish', resolve);
137
+ .on('finish', function(){
138
+ console.log(`>> SUCCESSFULLY copied map file = ${file}`);
139
+ resolve();
140
+ });
129
141
  });
130
142
  })
131
143
  .then(() => {
@@ -223,11 +235,14 @@ const TASKS = {
223
235
  module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
224
236
  const { isLocal } = siteSettings
225
237
  const isQuotePage = siteData.siteData && siteData.siteData.isQuotePage || siteData && siteData.isQuotePage;
238
+ const useAccessibleComponents = siteData.siteData && siteData.siteData.useAccessibleConfig || siteData && siteData.useAccessibleConfig;
226
239
  const useRelativePathForResources = siteData.siteData && siteData.siteData.useRelativePathForResources || siteData && siteData.useRelativePathForResources;
240
+ componentFolderPath = useAccessibleComponents === true ? 'accessible-components' : 'shared-components';
227
241
  isQuotePageOrUseRelativePath = isQuotePage === true || useRelativePathForResources === true;
228
242
  resourceURL = `https://${siteSettings.nodeEnv}/quote/resources`;
229
243
  const isPathSubdirectory = siteData.siteData && siteData.siteData.pathSubdirectory || siteData && siteData.pathSubdirectory;
230
244
  pathSubdirectory = !isLocal && isPathSubdirectory ? isPathSubdirectory : '';
245
+
231
246
  return function() {
232
247
  const { nodeEnv } = siteSettings;
233
248
  if (!nodeEnv) {
@@ -235,14 +250,28 @@ module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
235
250
  }
236
251
  return (function() {
237
252
  const tasks = Object.values(TASKS)
253
+
238
254
  if (tasks.length) {
239
255
  var getAllResources = tasks.map(function(task) {
256
+ if (useAccessibleComponents === true) {
257
+ if (task.url.includes('abandonment.min.js')) {
258
+ task.url = 'shared-resources/scripts/abandonment/accessible/abandonment.min.js';
259
+ task.config.mapUrl = 'shared-resources/scripts/abandonment/accessible/abandonment.min.js.map';
260
+ }
261
+ }
240
262
  Object.assign(task.config, { gulp, gulpPlugins, siteSettings, siteData });
241
263
  return getResource(task.url, task.config, task.srcReplaceFn, task.additionalSrcReplaceFns)
242
264
  });
243
265
  }
244
266
 
245
- return Promise.all(getAllResources);
267
+ return Promise.all(getAllResources)
268
+ .then(() => {
269
+ console.log(`>> FILENAMES object = ${JSON.stringify(fileNames)}`);
270
+ return gulp.src(`${siteSettings.srcFolder}/${componentFolderPath}/foot-assets/foot-assets.html`)
271
+ .on('data', function (file) {
272
+ console.log(`>> FOOT ASSETS HTML = ${file.contents.toString()}`);
273
+ });
274
+ })
246
275
  }());
247
276
  };
248
277
  };
@@ -65,7 +65,7 @@ module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
65
65
  name: 'xif',
66
66
  fn: function(expression, options) {
67
67
  return handlebarsX(expression, this, options) ? options.fn(this) : options.inverse(this);
68
- }
68
+ },
69
69
  },
70
70
  // Reverse array
71
71
  {
@@ -167,7 +167,7 @@ module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
167
167
  }
168
168
  ];
169
169
 
170
- var mergeDefaultFormFieldConfig = function(steps, defaultConfig) {
170
+ var mergeDefaultFormFieldConfig = function(steps, defaultConfig, folder) {
171
171
  if (!steps.items) {
172
172
  console.error('No items[ ] found in steps{}!');
173
173
  return steps;
@@ -175,9 +175,12 @@ module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
175
175
  steps.items.forEach(item => {
176
176
  if (item.fields) {
177
177
  item.fields = item.fields.map(field => {
178
- if (field.name && defaultConfig[field.name]) {
178
+ if (folder === 'shared-components' && field.name && defaultConfig[field.name]) {
179
179
  field = Object.assign(defaultConfig[field.name], field);
180
180
  }
181
+ if (folder === 'accessible-components' && field.attributes && field.attributes.name && defaultConfig[field.attributes.name]) {
182
+ field = merge(defaultConfig[field.attributes.name], field);
183
+ }
181
184
  return field;
182
185
  });
183
186
  }
@@ -186,25 +189,25 @@ module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
186
189
  return steps;
187
190
  };
188
191
 
189
- var getDefaultFormFieldConfig = async function() {
192
+ var getDefaultFormFieldConfig = async function(folder) {
190
193
  console.time('Finished fetch-default-form-config after');
191
194
  console.log('Starting fetch-default-form-config: ');
192
195
  await new Promise((resolve) => {
193
- request(`https://${siteSettings.nodeEnv}/quote/resources/mod-site/shared-components/steps/defaultFormFieldConfig.json`, async function(err, xhr, response) {
196
+ request(`https://${siteSettings.nodeEnv}/quote/resources/mod-site/${folder}/steps/defaultFormFieldConfig.json`, async function(err, xhr, response) {
194
197
  if (xhr.statusCode !== 200) {
195
- throw new Error(`${xhr.statusCode}: Error while fetching shared-components/defaultFormFieldConfig.json`);
198
+ throw new Error(`${xhr.statusCode}: Error while fetching ${folder}/defaultFormFieldConfig.json`);
196
199
  }
197
200
 
198
201
  const defaultConfig = await JSON.parse(response);
199
202
 
200
203
  if (templatesData.steps) {
201
- templatesData.steps = await mergeDefaultFormFieldConfig(templatesData.steps, defaultConfig);
204
+ templatesData.steps = await mergeDefaultFormFieldConfig(templatesData.steps, defaultConfig, folder);
202
205
  }
203
206
  if (templatesData.qsSteps) {
204
- templatesData.qsSteps = await mergeDefaultFormFieldConfig(templatesData.qsSteps, defaultConfig);
207
+ templatesData.qsSteps = await mergeDefaultFormFieldConfig(templatesData.qsSteps, defaultConfig, folder);
205
208
  }
206
209
  if (templatesData.modSteps) {
207
- templatesData.modSteps = await mergeDefaultFormFieldConfig(templatesData.modSteps, defaultConfig);
210
+ templatesData.modSteps = await mergeDefaultFormFieldConfig(templatesData.modSteps, defaultConfig, folder);
208
211
  }
209
212
 
210
213
  templatesData.defaultConfigCompleted = true;
@@ -231,8 +234,9 @@ module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
231
234
  throw new Error(`${xhr.statusCode}: Error while fetching TCPA`);
232
235
  }
233
236
  const responseJson = await JSON.parse(response);
234
- const finalTCPA = await (company === 'Modernize' || templatesData.useModernizeInTCPA) ? responseJson.tcpa.replace(/QuinStreet/g, 'Modernize') : responseJson.tcpa;
235
-
237
+ let finalTCPA = await (company === 'Modernize' || templatesData.useModernizeInTCPA) ? responseJson.tcpa.replace(/QuinStreet/g, 'Modernize') : responseJson.tcpa;
238
+ const removeInlineStyleRegex = / style="[^"]*"/g;
239
+ finalTCPA = finalTCPA.replace(removeInlineStyleRegex, '');
236
240
  templatesData.tcpaText = await finalTCPA;
237
241
 
238
242
  resolve();
@@ -244,7 +248,11 @@ module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
244
248
  return async function() {
245
249
  if (Object.keys(siteData).length > 0) {
246
250
  if (!templatesData.doNotUseDefaultFieldConfig && !templatesData.defaultConfigCompleted) {
247
- await getDefaultFormFieldConfig();
251
+ if (templatesData.siteData.useAccessibleConfig) {
252
+ await getDefaultFormFieldConfig('accessible-components');
253
+ } else {
254
+ await getDefaultFormFieldConfig('shared-components');
255
+ }
248
256
  }
249
257
 
250
258
  if (!templatesData.tcpaText && templatesData.primary_trade) {
@@ -252,20 +260,14 @@ module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
252
260
  }
253
261
  }
254
262
 
255
- return new Promise(function(resolve) {
256
- return gulp.src([
257
- siteSettings.srcFolder + '/' + siteSettings.templatesSubfolder + '/**/*.html',
258
- '!' + siteSettings.srcFolder + '/' + siteSettings.templatesSubfolder + '/_partials/**/*.html'
259
- ])
260
- .pipe(gulpPlugins.handlebarsFileInclude(templatesData, {
261
- maxRecursion: siteData.fileIncludeMaxRecursion ? siteData.fileIncludeMaxRecursion : 500,
262
- handlebarsHelpers: handlebarsHelpers
263
- }))
264
- .pipe(gulp.dest(siteSettings.tmpFolder))
265
- .on('finish', function() {
266
- resolve();
267
- console.log('Templates completed')
268
- });
269
- });
263
+ return gulp.src([
264
+ siteSettings.srcFolder + '/' + siteSettings.templatesSubfolder + '/**/*.html',
265
+ '!' + siteSettings.srcFolder + '/' + siteSettings.templatesSubfolder + '/_partials/**/*.html'
266
+ ])
267
+ .pipe(gulpPlugins.handlebarsFileInclude(templatesData, {
268
+ maxRecursion: 500,
269
+ handlebarsHelpers: handlebarsHelpers
270
+ }))
271
+ .pipe(gulp.dest(siteSettings.tmpFolder));
270
272
  };
271
273
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mod-build",
3
- "version": "3.6.61-beta.1",
3
+ "version": "3.6.61-beta.10",
4
4
  "description": "Share components for S3 sites.",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",