mod-build 3.6.29 → 3.6.31-beta.1

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.30
4
+
5
+ - Adding in the `copy-videos` gulp task needed for native landing pages.
6
+
3
7
  ## 3.6.29
4
8
 
5
9
  - added enhancements to abandonment path replace function in grab-shared-scripts task
@@ -8,12 +8,12 @@ module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
8
8
  sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', 'templates', 'styles', 'compile-prod', 'js-lint', 'html-min', 'css-min', 'js-min', 'img-min', 'extras', 'brand', 'cache-bust', 'build-stat'];
9
9
  } else if (siteData.isWhiteLabel) {
10
10
  if (siteData.isQSPage) {
11
- sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', 'templates', 'styles', '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', 'build-stat'];
11
+ sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', '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', 'build-stat'];
12
12
  } else {
13
- sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', 'templates', 'styles', 'combine-files', 'grab-images', 'js-lint', 'html-min','grab-global-images', 'css-min', 'js-min', 'img-min', 'extras', 'brand', 'cache-bust', 'grab-tooltips-json', 'build-stat'];
13
+ sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', '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', 'build-stat'];
14
14
  }
15
15
  } else {
16
- sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', 'templates', 'styles', 'js-lint', 'html-min', 'css-min', 'js-min', 'img-min', 'extras', 'brand', 'cache-bust', 'build-stat'];
16
+ sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', 'templates', 'styles', 'copy-videos', 'js-lint', 'html-min', 'css-min', 'js-min', 'img-min', 'extras', 'brand', 'cache-bust', 'build-stat'];
17
17
  }
18
18
 
19
19
  runSequence(...sequenceOpts, function() {
@@ -0,0 +1,6 @@
1
+ module.exports = function(gulp, siteSettings) {
2
+ return function() {
3
+ return gulp.src(siteSettings.srcFolder + '/videos' + '/*.mp4')
4
+ .pipe(gulp.dest(siteSettings.distFolder + '/videos'));
5
+ };
6
+ };
@@ -2,11 +2,22 @@ var fs = require('fs');
2
2
  var request = require('request');
3
3
  var source = require('vinyl-source-stream');
4
4
  var replace = require('gulp-replace');
5
+ var path = require('path')
5
6
 
6
- var images = [];
7
+ var imagePaths = [];
7
8
 
8
- function streamToDestination(gulp, siteSettings, url, fileName) {
9
- var finalDestination;
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
+ const fileName = path.basename(url);
20
+ const filePath = getFilePathFromURL(url);
10
21
 
11
22
  if (!fs.existsSync(siteSettings.distFolder)) {
12
23
  finalDestination = siteSettings.srcFolder;
@@ -20,29 +31,31 @@ function streamToDestination(gulp, siteSettings, url, fileName) {
20
31
  if (resp.statusCode !== 200 && resp.statusCode !== 206) {
21
32
  throw new Error(`${resp.statusCode} Error while fetching ${fileName}`);
22
33
  } else {
23
- images.push(fileName);
34
+ imagePaths.push(url);
24
35
  }
25
36
  })
26
37
  .pipe(source(fileName))
27
- .pipe(gulp.dest(`${finalDestination}/resources/images/`))
38
+ .pipe(gulp.dest(`${finalDestination}/resources/${filePath}`))
28
39
  .on('finish', resolve);
29
40
  });
30
41
  }
31
42
 
32
43
  function replaceImagePath(gulp, siteSettings) {
33
- var finalDestination;
44
+ var finalDestination;
34
45
 
35
46
  if (!fs.existsSync(siteSettings.distFolder)) {
36
47
  finalDestination = siteSettings.tmpFolder;
37
48
  } else {
38
49
  finalDestination = siteSettings.distFolder;
39
- }
50
+ }
40
51
 
41
- var stream = gulp.src(`${finalDestination}/index.html`);
52
+ var stream = gulp.src(`${finalDestination}/index.html`);
42
53
 
43
- if (images.length) {
44
- images.forEach(function(image) {
45
- stream = stream.pipe(replace(new RegExp(`"(?:(?!"|")[\\s\\S])+(\/${image})"`, 'gm'), '"/resources/images/' + image + '"'))
54
+ if (imagePaths.length) {
55
+ imagePaths.forEach(function(imagePath) {
56
+ const fileName = path.basename(imagePath);
57
+ const filePath = getFilePathFromURL(imagePath);
58
+ stream = stream.pipe(replace(new RegExp(`"${imagePath}"`, 'gm'), `"/resources/${filePath}/${fileName}"`))
46
59
  });
47
60
  }
48
61
  return stream.pipe(gulp.dest(finalDestination))
@@ -90,9 +103,8 @@ const parseImageSources = (gulp, siteSettings) => {
90
103
  module.exports = function(gulp, siteSettings, siteData) {
91
104
  return async function() {
92
105
  const urls = parseImageSources(gulp, siteSettings);
93
- const urlsPromises = urls.map(async(url) => {
94
- const fileName = await url.slice(url.lastIndexOf('/') + 1);
95
- return await streamToDestination(gulp, siteSettings, url, fileName);
106
+ const urlsPromises = urls.map(async (url) => {
107
+ return await streamToDestination(gulp, siteSettings, url);
96
108
  });
97
109
 
98
110
  return await Promise.all(urlsPromises).then(function() { // eslint-disable-line no-undef
@@ -384,6 +384,18 @@ module.exports = function() {
384
384
  }
385
385
  },
386
386
 
387
+ // Copy videos
388
+ 'copy-videos': {
389
+ subtasks: [],
390
+ func: function(opts) {
391
+ if ('undefined' === typeof opts.gulpTasksFolderPath) {
392
+ opts.gulpTasksFolderPath = '.';
393
+ }
394
+
395
+ return require(opts.gulpTasksFolderPath + '/copy-videos')(opts.gulp, opts.gulpSettings);
396
+ }
397
+ },
398
+
387
399
  // Grab theme json file from shared resources
388
400
  'grab-theme-json': {
389
401
  subtasks: [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mod-build",
3
- "version": "3.6.29",
3
+ "version": "3.6.31-beta.1",
4
4
  "description": "Share components for S3 sites.",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"