mod-build 3.6.10 → 3.6.11

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
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.6.11
4
+
5
+ - Adding `mod-form` & `qs-form` to the `grab-shared-scripts` gulp task. It will copy these files into the site's `resources/scripts/mod-form` folder & then update the src for both in the `foot-assets` shared component.
6
+
3
7
  ## 3.6.10
4
8
 
5
9
  - Adding `modutils` JS to the `grab-shared-scripts` gulp task. It will copy this version into the site's `resources/scripts/mod-utils` folder & then update the src in the `foot-assets` shared component.
@@ -11,11 +11,13 @@ var abandonmentJsFileName = '';
11
11
  var footerComponentJsFileName = '';
12
12
  var modFooterStylesFileName = '';
13
13
  var qsFooterStylesFileName = '';
14
+ var modFormFileName = '';
15
+ var qsFormFileName = '';
14
16
 
15
17
  function replaceModalyticsSrc(gulp, gulpPlugins, siteSettings, siteData) {
16
18
  if (siteData.siteData && siteData.siteData.isQuotePage === true || siteData.siteData && siteData.siteData.useRelativePathForResources === true) {
17
19
  return gulp.src(siteSettings.srcFolder + '/shared-components/head/head.html')
18
- .pipe(replace(/".*(modalytics).*"/, '"resources/scripts/mod-alytics/' + modAlyticsFileName + '"'))
20
+ .pipe(replace(/".*(modalytics).*"/, '"{{#if this.src}}{{this.src}}{{/if}}resources/scripts/mod-alytics/' + modAlyticsFileName + '"'))
19
21
  .pipe(gulp.dest(siteSettings.srcFolder + '/shared-components/head'));
20
22
  } else {
21
23
  return gulp.src(siteSettings.srcFolder + '/shared-components/head/head.html')
@@ -24,14 +26,20 @@ function replaceModalyticsSrc(gulp, gulpPlugins, siteSettings, siteData) {
24
26
  }
25
27
  }
26
28
 
27
- function replaceModutilsSrc(gulp, gulpPlugins, siteSettings, siteData) {
29
+ function replaceFootAssetScripts(gulp, gulpPlugins, siteSettings, siteData) {
28
30
  if (siteData.siteData && siteData.siteData.isQuotePage === true || siteData.siteData && siteData.siteData.useRelativePathForResources === true) {
29
31
  return gulp.src(siteSettings.srcFolder + '/shared-components/foot-assets/foot-assets.html')
30
- .pipe(replace(/"(?:(?!"|js")[\s\S])+(modutils|mod-utils.*?)js"/, '"resources/scripts/mod-utils/' + modUtilsFileName + '"'))
32
+ .pipe(replace(/"(?:(?!"|js")[\s\S])+(modutils|mod-utils.*?)js"/, '"{{#if this.nodeModulesPath}}{{this.nodeModulesPath}}{{/if}}resources/scripts/mod-utils/' + modUtilsFileName + '"'))
33
+ .pipe(replace(/"(?:(?!"|")[\s\S])+(footer\/footer-component.*?)js"/, '"{{#if this.nodeModulesPath}}{{this.nodeModulesPath}}{{/if}}resources/scripts/footer/' + footerComponentJsFileName + '"'))
34
+ .pipe(replace(/"(?:(?!"|")[\s\S])+(mod-form.*?)js"/, '"{{#if this.nodeModulesPath}}{{this.nodeModulesPath}}{{/if}}resources/scripts/mod-form/' + modFormFileName + '"'))
35
+ .pipe(replace(/"(?:(?!"|")[\s\S])+(qs-form.*?)js"/, '"{{#if this.nodeModulesPath}}{{this.nodeModulesPath}}{{/if}}resources/scripts/mod-form/' + qsFormFileName + '"'))
31
36
  .pipe(gulp.dest(siteSettings.srcFolder + '/shared-components/foot-assets'));
32
37
  } else {
33
38
  return gulp.src(siteSettings.srcFolder + '/shared-components/foot-assets/foot-assets.html')
34
39
  .pipe(replace(/"(?:(?!"|js")[\s\S])+(modutils|mod-utils.*?)js"/, '"/resources/scripts/mod-utils/' + modUtilsFileName + '"'))
40
+ .pipe(replace(/"(?:(?!"|")[\s\S])+(footer\/footer-component.*?)js"/, '"/resources/scripts/footer/' + footerComponentJsFileName + '"'))
41
+ .pipe(replace(/"(?:(?!"|")[\s\S])+(mod-form.*?)js"/, '"/resources/scripts/mod-form/' + modFormFileName + '"'))
42
+ .pipe(replace(/"(?:(?!"|")[\s\S])+(qs-form.*?)js"/, '"/resources/scripts/mod-form/' + qsFormFileName + '"'))
35
43
  .pipe(gulp.dest(siteSettings.srcFolder + '/shared-components/foot-assets'));
36
44
  }
37
45
  }
@@ -48,18 +56,6 @@ function replaceAbandonmentJsSrc(gulp, gulpPlugins, siteSettings, siteData) {
48
56
  }
49
57
  }
50
58
 
51
- function replaceFooterComponentJsSrc(gulp, gulpPlugins, siteSettings, siteData) {
52
- if (siteData.siteData && siteData.siteData.isQuotePage === true || siteData.siteData && siteData.siteData.useRelativePathForResources === true) {
53
- return gulp.src(siteSettings.srcFolder + '/shared-components/foot-assets/foot-assets.html')
54
- .pipe(replace(/"(?:(?!"|")[\s\S])+(footer\/footer-component.*?)js"/, '"resources/scripts/footer/' + footerComponentJsFileName + '"'))
55
- .pipe(gulp.dest(siteSettings.srcFolder + '/shared-components/foot-assets'));
56
- } else {
57
- return gulp.src(siteSettings.srcFolder + '/shared-components/foot-assets/foot-assets.html')
58
- .pipe(replace(/"(?:(?!"|")[\s\S])+(footer\/footer-component.*?)js"/, '"/resources/scripts/footer/' + footerComponentJsFileName + '"'))
59
- .pipe(gulp.dest(siteSettings.srcFolder + '/shared-components/foot-assets'));
60
- }
61
- }
62
-
63
59
  function replaceFooterStylesReference(gulp, gulpPlugins, siteSettings, siteData) {
64
60
  if (siteData.siteData && siteData.siteData.isQuotePage === true || siteData.siteData && siteData.siteData.useRelativePathForResources === true) {
65
61
  return gulp.src(siteSettings.srcFolder + '/resources/scripts/footer/' + footerComponentJsFileName)
@@ -149,8 +145,6 @@ function copyModutils(gulp, gulpPlugins, siteSettings, siteData) {
149
145
  .on('response', resp => {
150
146
  if (resp.statusCode !== 200) {
151
147
  throw new Error(`${resp.statusCode} Error while fetching modutils.min.js.map`);
152
- } else {
153
- replaceModutilsSrc(gulp, gulpPlugins, siteSettings, siteData);
154
148
  }
155
149
  })
156
150
  .pipe(source('modutils.min.js.map'))
@@ -221,8 +215,6 @@ function copyFooterComponentJs(gulp, gulpPlugins, siteSettings, siteData) {
221
215
  .on('response', resp => {
222
216
  if (resp.statusCode !== 200) {
223
217
  throw new Error(`${resp.statusCode} Error while fetching footer-component.min.js.map`);
224
- } else {
225
- replaceFooterComponentJsSrc(gulp, gulpPlugins, siteSettings, siteData);
226
218
  }
227
219
  })
228
220
  .pipe(source('footer-component.min.js.map'))
@@ -232,6 +224,76 @@ function copyFooterComponentJs(gulp, gulpPlugins, siteSettings, siteData) {
232
224
  });
233
225
  }
234
226
 
227
+ function copyModForm(gulp, gulpPlugins, siteSettings, siteData) {
228
+ return new Promise(resolve => {
229
+ request(`https://${siteSettings.nodeEnv}/quote/resources/mod-form/mod-form.min.js`)
230
+ .on('response', resp => {
231
+ if (resp.statusCode !== 200) {
232
+ throw new Error(`${resp.statusCode} Error while fetching mod-form.min.js`);
233
+ }
234
+ })
235
+ .pipe(source('mod-form.min.js'))
236
+ .pipe(hash({
237
+ hashLength: 20,
238
+ template: 'mod-form-<%= hash %>.min.js'
239
+ }))
240
+ .pipe(tap(function(file, t){
241
+ modFormFileName = path.basename(file.path);
242
+ }))
243
+ .pipe(gulp.dest(`${siteSettings.srcFolder}/resources/scripts/mod-form`))
244
+ .on('finish', resolve);
245
+ })
246
+ .then(() => {
247
+ return new Promise(resolve => {
248
+ request(`https://${siteSettings.nodeEnv}/quote/resources/mod-form/mod-form.min.js.map`)
249
+ .on('response', resp => {
250
+ if (resp.statusCode !== 200) {
251
+ throw new Error(`${resp.statusCode} Error while fetching mod-form.min.js.map`);
252
+ }
253
+ })
254
+ .pipe(source('mod-form.min.js.map'))
255
+ .pipe(gulp.dest(`${siteSettings.srcFolder}/resources/scripts/mod-form`))
256
+ .on('finish', resolve);
257
+ });
258
+ });
259
+ }
260
+
261
+ function copyQsForm(gulp, gulpPlugins, siteSettings, siteData) {
262
+ return new Promise(resolve => {
263
+ request(`https://${siteSettings.nodeEnv}/quote/resources/mod-form/qs-form.min.js`)
264
+ .on('response', resp => {
265
+ if (resp.statusCode !== 200) {
266
+ throw new Error(`${resp.statusCode} Error while fetching qs-form.min.js`);
267
+ }
268
+ })
269
+ .pipe(source('qs-form.min.js'))
270
+ .pipe(hash({
271
+ hashLength: 20,
272
+ template: 'qs-form-<%= hash %>.min.js'
273
+ }))
274
+ .pipe(tap(function(file, t){
275
+ qsFormFileName = path.basename(file.path);
276
+ }))
277
+ .pipe(gulp.dest(`${siteSettings.srcFolder}/resources/scripts/mod-form`))
278
+ .on('finish', resolve);
279
+ })
280
+ .then(() => {
281
+ return new Promise(resolve => {
282
+ request(`https://${siteSettings.nodeEnv}/quote/resources/mod-form/qs-form.min.js.map`)
283
+ .on('response', resp => {
284
+ if (resp.statusCode !== 200) {
285
+ throw new Error(`${resp.statusCode} Error while fetching qs-form.min.js.map`);
286
+ } else {
287
+ replaceFootAssetScripts(gulp, gulpPlugins, siteSettings, siteData);
288
+ }
289
+ })
290
+ .pipe(source('qs-form.min.js.map'))
291
+ .pipe(gulp.dest(`${siteSettings.srcFolder}/resources/scripts/mod-form`))
292
+ .on('finish', resolve);
293
+ });
294
+ });
295
+ }
296
+
235
297
  function copyFooterComponentStyles(gulp, gulpPlugins, siteSettings, siteData) {
236
298
  return new Promise(resolve => {
237
299
  request(`https://${siteSettings.nodeEnv}/quote/resources/shared-resources/styles/components/footer/mod-footer.min.css`)
@@ -284,6 +346,12 @@ module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
284
346
  throw new Error('Missing environment variables. Did you start with gulp instead of npm run...?');
285
347
  }
286
348
 
287
- return copyModalytics(gulp, gulpPlugins, siteSettings, siteData) && copyAbandonmentJs(gulp, gulpPlugins, siteSettings, siteData) && copyFooterComponentJs(gulp, gulpPlugins, siteSettings, siteData) && copyFooterComponentStyles(gulp, gulpPlugins, siteSettings, siteData) && copyModutils(gulp, gulpPlugins, siteSettings, siteData);
349
+ return copyModalytics(gulp, gulpPlugins, siteSettings, siteData) &&
350
+ copyAbandonmentJs(gulp, gulpPlugins, siteSettings, siteData) &&
351
+ copyFooterComponentJs(gulp, gulpPlugins, siteSettings, siteData) &&
352
+ copyFooterComponentStyles(gulp, gulpPlugins, siteSettings, siteData) &&
353
+ copyModutils(gulp, gulpPlugins, siteSettings, siteData) &&
354
+ copyModForm(gulp, gulpPlugins, siteSettings, siteData) &&
355
+ copyQsForm(gulp, gulpPlugins, siteSettings, siteData);
288
356
  };
289
357
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mod-build",
3
- "version": "3.6.10",
3
+ "version": "3.6.11",
4
4
  "description": "Share components for S3 sites.",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"