mod-build 3.6.43 → 3.6.44

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.44
4
+
5
+ - Added a `grab-form-helpers` task
6
+
3
7
  ## 3.6.42
4
8
 
5
9
  - moved the `replaceFootAssetScripts` function to run off the largest file; reordered the tasks for `grab-shared-scripts`; also added consoles to print out the hashes for each file name & print `start` & `finish` states for replacing the foot asset paths
@@ -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', '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', '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', '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', 'grab-tooltips-json', 'copy-resources-to-dist', 'build-stat'];
12
12
  } else {
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', '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', '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', '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', 'copy-resources-to-dist', 'build-stat'];
17
17
  }
18
18
 
19
19
  runSequence(...sequenceOpts, function() {
@@ -0,0 +1,55 @@
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
+ };
@@ -4,11 +4,11 @@ module.exports.src = function(gulp, gulpPlugins, siteSettings, siteData) {
4
4
  var runSequence = require('run-sequence');
5
5
  var sequenceOpts;
6
6
  if (siteData.useTypescript) {
7
- sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', 'templates', 'styles', 'compile', 'grab-tooltips-json', 'combine-files', 'grab-images', 'js-lint'];
7
+ sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', 'grab-form-helpers', 'templates', 'styles', 'compile', 'grab-tooltips-json', 'combine-files', 'grab-images', 'js-lint'];
8
8
  } else if (siteData.isQSPage) {
9
- sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', 'templates', 'styles', 'grab-theme-json', 'grab-tooltips-json', 'combine-files', 'grab-images', 'js-lint'];
9
+ sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', 'grab-form-helpers', 'templates', 'styles', 'grab-theme-json', 'grab-tooltips-json', 'combine-files', 'grab-images', 'js-lint'];
10
10
  } else {
11
- sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', 'templates', 'styles', 'grab-tooltips-json', 'combine-files', 'grab-images','grab-global-images', 'js-lint'];
11
+ sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', 'grab-form-helpers', 'templates', 'styles', 'grab-tooltips-json', 'combine-files', 'grab-images','grab-global-images', 'js-lint'];
12
12
  }
13
13
  runSequence(...sequenceOpts, () => {
14
14
  // Run a BrowserSync server
@@ -40,6 +40,20 @@ module.exports = function() {
40
40
  return require(opts.gulpTasksFolderPath + '/grab-cdn')(opts.gulp, opts.gulpPlugins, opts.gulpSettings, opts.siteData);
41
41
  }
42
42
  }
43
+ },
44
+
45
+ // Grab form helpers files from CDN
46
+ 'grab-form-helpers': {
47
+ subtasks: [],
48
+ func: function(opts) {
49
+ if ('undefined' === typeof opts.gulpTasksFolderPath) {
50
+ opts.gulpTasksFolderPath = '.';
51
+ }
52
+
53
+ if (opts.siteData.useCDN) {
54
+ return require(opts.gulpTasksFolderPath + '/grab-form-helpers')(opts.gulp, opts.gulpPlugins, opts.gulpSettings, opts.siteData);
55
+ }
56
+ }
43
57
  },
44
58
 
45
59
  // Grab component files from CDN so they can be swapped into build
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mod-build",
3
- "version": "3.6.43",
3
+ "version": "3.6.44",
4
4
  "description": "Share components for S3 sites.",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",