mod-build 3.6.44 → 3.6.45

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.45
4
+
5
+ - Added `add-path-subdirectories` task. If `siteData.pathSubdirectory` exists at a site level, it will get the value & append the path to all of the existing RELATIVE paths (build task only – doesn't run on gulp serve). Also updated `grab-shared-scripts` to include the `pathSubdirectory` in the replacement paths during `build` if it exists.
6
+
3
7
  ## 3.6.44
4
8
 
5
9
  - Added a `grab-form-helpers` task
@@ -0,0 +1,27 @@
1
+ var replace = require('gulp-replace');
2
+
3
+ module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
4
+ return function() {
5
+ if (siteData.siteData && siteData.siteData.pathSubdirectory || siteData && siteData.pathSubdirectory) {
6
+ const pathSubdirectory = siteData.siteData && siteData.siteData.pathSubdirectory || siteData && siteData.pathSubdirectory;
7
+
8
+ return gulp.src(siteSettings.distFolder + '/**/*.html')
9
+ .pipe(replace(/(href="favicon.ico")/g, function(match, path) {
10
+ return `href="${pathSubdirectory}favicon.ico"`;
11
+ }))
12
+ .pipe(replace(/((src=")(images|scripts|shared-components)\/[^"]+")/g, function(match, path) {
13
+ if (path.startsWith('src="images') || path.startsWith('src="scripts') || path.startsWith('src="shared-components')) {
14
+ return `src="${pathSubdirectory}${path.slice(5)}`;
15
+ }
16
+ return match;
17
+ }))
18
+ .pipe(replace(/((href=")(images|styles|shared-components)\/[^"]+")/g, function(match, path) {
19
+ if (path.startsWith('href="images') || path.startsWith('href="styles') || path.startsWith('href="shared-components')) {
20
+ return `href="${pathSubdirectory}${path.slice(6)}`;
21
+ }
22
+ return match;
23
+ }))
24
+ .pipe(gulp.dest(siteSettings.distFolder));
25
+ }
26
+ }
27
+ };
@@ -5,15 +5,15 @@ module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
5
5
  var sequenceOpts;
6
6
 
7
7
  if (siteData.useTypescript) {
8
- sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', 'grab-form-helpers', 'templates', 'styles', 'compile-prod', 'js-lint', 'html-min', 'css-min', 'js-min', 'img-min', 'extras', 'brand', 'cache-bust', 'copy-resources-to-dist', 'build-stat'];
8
+ sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', 'grab-form-helpers', 'templates', 'styles', 'compile-prod', 'js-lint', 'html-min', 'css-min', 'js-min', 'img-min', 'extras', 'brand', 'cache-bust', 'add-path-subdirectories', 'copy-resources-to-dist', 'build-stat'];
9
9
  } else if (siteData.isWhiteLabel) {
10
10
  if (siteData.isQSPage) {
11
- sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', 'grab-form-helpers', 'templates', 'styles', 'copy-videos', 'grab-theme-json', 'combine-files', 'grab-images', 'copy-json', 'js-lint', 'html-min', 'css-min', 'js-min', 'img-min', 'extras', 'brand', 'copy-files-to-build-path', 'cache-bust', 'grab-tooltips-json', 'copy-resources-to-dist', 'build-stat'];
11
+ sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', 'grab-form-helpers', 'templates', 'styles', 'copy-videos', 'grab-theme-json', 'combine-files', 'grab-images', 'copy-json', 'js-lint', 'html-min', 'css-min', 'js-min', 'img-min', 'extras', 'brand', 'copy-files-to-build-path', 'cache-bust', 'add-path-subdirectories', 'grab-tooltips-json', 'copy-resources-to-dist', 'build-stat'];
12
12
  } else {
13
- sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', 'grab-form-helpers', 'templates', 'styles', 'copy-videos', 'combine-files', 'grab-images', 'js-lint', 'html-min','grab-global-images', 'css-min', 'js-min', 'img-min', 'extras', 'brand', 'cache-bust', 'grab-tooltips-json', 'copy-resources-to-dist', 'build-stat'];
13
+ sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', 'grab-form-helpers', 'templates', 'styles', 'copy-videos', 'combine-files', 'grab-images', 'js-lint', 'html-min','grab-global-images', 'css-min', 'js-min', 'img-min', 'extras', 'brand', 'cache-bust', 'add-path-subdirectories', 'grab-tooltips-json', 'copy-resources-to-dist', 'build-stat'];
14
14
  }
15
15
  } else {
16
- sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', 'grab-form-helpers', 'templates', 'styles', 'copy-videos', 'js-lint', 'html-min', 'css-min', 'js-min', 'img-min', 'extras', 'brand', 'cache-bust', 'copy-resources-to-dist', 'build-stat'];
16
+ sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', 'grab-form-helpers', 'templates', 'styles', 'copy-videos', 'js-lint', 'html-min', 'css-min', 'js-min', 'img-min', 'extras', 'brand', 'cache-bust', 'add-path-subdirectories', 'copy-resources-to-dist', 'build-stat'];
17
17
  }
18
18
 
19
19
  runSequence(...sequenceOpts, function() {
@@ -19,16 +19,17 @@ const fileNames = {
19
19
  };
20
20
  var isQuotePageOrUseRelativePath = false;
21
21
  var resourceURL = '';
22
+ var pathSubdirectory = '';
22
23
 
23
24
  function replaceModalyticsSrc(gulp, gulpPlugins, siteSettings, siteData) {
24
- const resourcePath = isQuotePageOrUseRelativePath ? '{{#if this.src}}{{this.src}}{{/if}}resources/scripts/mod-alytics/' : '/resources/scripts/mod-alytics/';
25
+ const resourcePath = isQuotePageOrUseRelativePath ? `${pathSubdirectory}{{#if this.src}}{{this.src}}{{/if}}resources/scripts/mod-alytics/` : '/resources/scripts/mod-alytics/';
25
26
  return gulp.src(siteSettings.srcFolder + '/shared-components/head/head.html')
26
27
  .pipe(replace(/".*(modalytics).*"/, `"${resourcePath}${fileNames.modAlyticsFileName}"`))
27
28
  .pipe(gulp.dest(siteSettings.srcFolder + '/shared-components/head'));
28
29
  }
29
30
  function replaceFootAssetScripts(gulp, gulpPlugins, siteSettings, siteData) {
30
31
  console.log('>> STARTING Replacing Foot Asset Scripts');
31
- const resourcePath = isQuotePageOrUseRelativePath ? '{{#if this.nodeModulesPath}}{{this.nodeModulesPath}}{{/if}}resources/scripts' : '/resources/scripts';
32
+ const resourcePath = isQuotePageOrUseRelativePath ? `${pathSubdirectory}{{#if this.nodeModulesPath}}{{this.nodeModulesPath}}{{/if}}resources/scripts` : '/resources/scripts';
32
33
  return gulp.src(siteSettings.srcFolder + '/shared-components/foot-assets/foot-assets.html')
33
34
  .pipe(replace(/"(?:(?!"|js")[\s\S])+(modutils|mod-utils.*?)js"|"(?:(?!"|")[\s\S])+(footer\/footer-component.*?)js"|"(?:(?!"|")[\s\S])+(mod-form\/mod-form.*?)js"|"(?:(?!"|")[\s\S])+(qs-form.*?)js"|"(?:(?!"|")[\s\S])+(mod-form\/form.*?)js"/g, function(match) {
34
35
  if (match.includes('mod-form')) {
@@ -51,8 +52,8 @@ function replaceFootAssetScripts(gulp, gulpPlugins, siteSettings, siteData) {
51
52
  });
52
53
  }
53
54
  function replaceAbandonmentJsCssSrc(gulp, gulpPlugins, siteSettings, siteData) {
54
- const jsResourcePath = isQuotePageOrUseRelativePath ? 'resources/scripts/abandonment/' : '/resources/scripts/abandonment/';
55
- const cssResourcePath = isQuotePageOrUseRelativePath ? 'resources/styles/components/abandonment/' : '/resources/styles/components/abandonment/';
55
+ const jsResourcePath = isQuotePageOrUseRelativePath ? `${pathSubdirectory}resources/scripts/abandonment/` : '/resources/scripts/abandonment/';
56
+ const cssResourcePath = isQuotePageOrUseRelativePath ? `${pathSubdirectory}resources/styles/components/abandonment/` : '/resources/styles/components/abandonment/';
56
57
  return gulp.src(siteSettings.srcFolder + '/templates/abandonment/*.html')
57
58
  .pipe(replace(/"(?:(?!"|")[\s\S])+(abandonment\/abandonment.*?)js"/, `"${jsResourcePath}${fileNames.abandonmentJsFileName}"`))
58
59
  .pipe(replace(/"(?:(?!"|")[\s\S])+(components\/abandonment\/abandonment.*?)css"/, `"${cssResourcePath}${fileNames.abandonmentStylesFileName}"`))
@@ -61,8 +62,8 @@ function replaceAbandonmentJsCssSrc(gulp, gulpPlugins, siteSettings, siteData) {
61
62
  function replaceFooterStylesReference(gulp, gulpPlugins, siteSettings, siteData) {
62
63
  if (siteData.siteData && siteData.siteData.useRelativePathForResources === true) {
63
64
  return gulp.src(siteSettings.srcFolder + '/resources/scripts/footer/' + fileNames.footerComponentJsFileName)
64
- .pipe(replace(/concat\((?:(?!concat\(|\))[\s\S])+(components\/footer\/mod.*?)\)/, 'concat("resources/styles/components/footer/' + fileNames.modFooterStylesFileName + '")'))
65
- .pipe(replace(/concat\((?:(?!concat\(|\))[\s\S])+(components\/footer\/qs.*?)\)/, 'concat("resources/styles/components/footer/' + fileNames.qsFooterStylesFileName + '")'))
65
+ .pipe(replace(/concat\((?:(?!concat\(|\))[\s\S])+(components\/footer\/mod.*?)\)/, `concat("${pathSubdirectory}resources/styles/components/footer/` + fileNames.modFooterStylesFileName + '")'))
66
+ .pipe(replace(/concat\((?:(?!concat\(|\))[\s\S])+(components\/footer\/qs.*?)\)/, `concat("${pathSubdirectory}resources/styles/components/footer/` + fileNames.qsFooterStylesFileName + '")'))
66
67
  .pipe(gulp.dest(siteSettings.srcFolder + '/resources/scripts/footer'))
67
68
  } else if (!siteData.siteData || siteData.siteData && !siteData.siteData.isQuotePage) {
68
69
  return gulp.src(siteSettings.srcFolder + '/resources/scripts/footer/' + fileNames.footerComponentJsFileName)
@@ -74,8 +75,8 @@ function replaceFooterStylesReference(gulp, gulpPlugins, siteSettings, siteData)
74
75
  function replaceFooterStylesReferenceInMap(gulp, gulpPlugins, siteSettings, siteData) {
75
76
  if (siteData.siteData && siteData.siteData.useRelativePathForResources === true) {
76
77
  return gulp.src(siteSettings.srcFolder + '/resources/scripts/footer/footer-component.min.js.map')
77
- .pipe(replace(/\`(?:(?!\`|\`)[\s\S])+(components\/footer\/mod.*?)\`/, '`resources/styles/components/footer/' + fileNames.modFooterStylesFileName + '`'))
78
- .pipe(replace(/\`(?:(?!\`|\`)[\s\S])+(components\/footer\/mod.*?)\`/, '`resources/styles/components/footer/' + fileNames.qsFooterStylesFileName + '`'))
78
+ .pipe(replace(/\`(?:(?!\`|\`)[\s\S])+(components\/footer\/mod.*?)\`/, '`' + pathSubdirectory + 'resources/styles/components/footer/' + fileNames.modFooterStylesFileName + '`'))
79
+ .pipe(replace(/\`(?:(?!\`|\`)[\s\S])+(components\/footer\/mod.*?)\`/, '`' + pathSubdirectory + 'resources/styles/components/footer/' + fileNames.qsFooterStylesFileName + '`'))
79
80
  .pipe(gulp.dest(siteSettings.srcFolder + '/resources/scripts/footer'));
80
81
  } else if (!siteData.siteData || siteData.siteData && !siteData.siteData.isQuotePage) {
81
82
  return gulp.src(siteSettings.srcFolder + '/resources/scripts/footer/footer-component.min.js.map')
@@ -248,10 +249,12 @@ const TASKS = {
248
249
  }
249
250
  };
250
251
  module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
252
+ const { isLocal } = siteSettings
251
253
  const isQuotePage = siteData.siteData && siteData.siteData.isQuotePage || siteData && siteData.isQuotePage;
252
254
  const useRelativePathForResources = siteData.siteData && siteData.siteData.useRelativePathForResources || siteData && siteData.useRelativePathForResources;
253
255
  isQuotePageOrUseRelativePath = isQuotePage === true || useRelativePathForResources === true;
254
256
  resourceURL = `https://${siteSettings.nodeEnv}/quote/resources`;
257
+ pathSubdirectory = isLocal ? '' : siteData.siteData && siteData.siteData.pathSubdirectory || siteData && siteData.pathSubdirectory;
255
258
  return function() {
256
259
  const { nodeEnv } = siteSettings;
257
260
  if (!nodeEnv) {
@@ -360,7 +360,7 @@ module.exports = function() {
360
360
 
361
361
  return require(opts.gulpTasksFolderPath + '/grab-images')(opts.gulp, opts.gulpSettings, opts.siteData);
362
362
  }
363
- },
363
+ },
364
364
 
365
365
  // Get global images
366
366
  'grab-global-images': {
@@ -432,7 +432,7 @@ module.exports = function() {
432
432
 
433
433
  return require(opts.gulpTasksFolderPath + '/grab-tooltips-json')(opts.gulp, opts.gulpPlugins, opts.gulpSettings, opts.siteData);
434
434
  }
435
- },
435
+ },
436
436
 
437
437
  // copy resources directory into dist
438
438
  'copy-resources-to-dist': {
@@ -446,6 +446,18 @@ module.exports = function() {
446
446
  }
447
447
  },
448
448
 
449
+ // If siteData.pathSubdirectory exists...append the directory path to all of the existing RELATIVE URL paths
450
+ 'add-path-subdirectories': {
451
+ subtasks: [],
452
+ func: function(opts) {
453
+ if ('undefined' === typeof opts.gulpTasksFolderPath) {
454
+ opts.gulpTasksFolderPath = '.';
455
+ }
456
+
457
+ return require(opts.gulpTasksFolderPath + '/add-path-subdirectories')(opts.gulp, opts.gulpPlugins, opts.gulpSettings, opts.siteData);
458
+ }
459
+ },
460
+
449
461
  // Create a build
450
462
  'build': {
451
463
  func: function(opts) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mod-build",
3
- "version": "3.6.44",
3
+ "version": "3.6.45",
4
4
  "description": "Share components for S3 sites.",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",