mod-build 3.6.1--beta.19 → 3.6.1--beta.20

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.
@@ -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', 'templates', 'styles', 'compile-prod', 'js-lint', 'html-min', 'css-min', 'js-min', 'img-min', 'extras', 'brand', 'cache-bust', 'build-stat'];
8
+ sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'check-seasonal-variations', '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', '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', 'check-seasonal-variations', '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'];
12
12
  } else {
13
- sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'templates', 'styles', 'combine-files', 'grab-images', 'js-lint', 'html-min', 'css-min', 'js-min', 'img-min', 'extras', 'brand', 'cache-bust', 'grab-tooltips-json', 'build-stat'];
13
+ sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'check-seasonal-variations', 'templates', 'styles', 'combine-files', 'grab-images', 'js-lint', 'html-min', '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', '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', 'check-seasonal-variations', 'templates', 'styles', '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,52 @@
1
+ var request = require('request');
2
+ var source = require('vinyl-source-stream');
3
+
4
+ function getDefinedSeasons(gulp, gulpPlugins, siteSettings) {
5
+ return {
6
+ "warmerWeather": {
7
+ "firstDay": "03-14",
8
+ "lastDay": "09-25"
9
+ },
10
+ "spookySeason": {
11
+ "startDate": "10-01",
12
+ "endDate": "10-31"
13
+ }
14
+ }
15
+ }
16
+
17
+ function getActiveSeasons() {
18
+ var seasons = getDefinedSeasons();
19
+ const today = new Date();
20
+ const year = today.getFullYear();
21
+ let activeSeason = [];
22
+
23
+ for (const key in seasons) {
24
+ var seasonName = key;
25
+ var dateRanges = seasons[key];
26
+ var startDate = new Date(`${Object.values(dateRanges)[0]}-${year}`);
27
+ var endDate = new Date(`${Object.values(dateRanges)[1]}-${year}`);
28
+
29
+ if (startDate < today && today < endDate) {
30
+ activeSeason.push(seasonName)
31
+ }
32
+ }
33
+ return activeSeason;
34
+ }
35
+
36
+ module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
37
+ const activeSeason = getActiveSeasons();
38
+ if (activeSeason !== ''){
39
+ if (activeSeason in siteData.seasonalVariations) {
40
+ siteData = {...siteData, ...siteData.seasonalVariations[activeSeason]};
41
+ }
42
+ }
43
+
44
+ console.log(siteData);
45
+
46
+ return function() {
47
+ const { nodeEnv } = siteSettings;
48
+ if (!nodeEnv) {
49
+ throw new Error('Missing environment variables. Did you start with gulp instead of npm run...?');
50
+ }
51
+ };
52
+ };
@@ -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', 'templates', 'styles', 'compile', 'grab-tooltips-json', 'combine-files', 'grab-images', 'js-lint'];
7
+ sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'check-seasonal-variations', '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', 'templates', 'styles', 'grab-theme-json', 'grab-tooltips-json', 'combine-files', 'grab-images', 'js-lint'];
9
+ sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'check-seasonal-variations', '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', 'templates', 'styles', 'grab-tooltips-json', 'combine-files', 'grab-images', 'js-lint'];
11
+ sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'check-seasonal-variations', 'templates', 'styles', 'grab-tooltips-json', 'combine-files', 'grab-images', 'js-lint'];
12
12
  }
13
13
  runSequence(...sequenceOpts, () => {
14
14
  // Run a BrowserSync server
@@ -56,6 +56,20 @@ module.exports = function() {
56
56
  }
57
57
  },
58
58
 
59
+ // Check seasons defined on CDN & update seasonal variations accordingly
60
+ 'check-seasonal-variations': {
61
+ subtasks: [],
62
+ func: function(opts) {
63
+ if ('undefined' === typeof opts.gulpTasksFolderPath) {
64
+ opts.gulpTasksFolderPath = '.';
65
+ }
66
+
67
+ if (opts.siteData.useCDN) {
68
+ return require(opts.gulpTasksFolderPath + '/check-seasonal-variations')(opts.gulp, opts.gulpPlugins, opts.gulpSettings, opts.siteData);
69
+ }
70
+ }
71
+ },
72
+
59
73
  // Link scss files
60
74
  'sass-lint': {
61
75
  subtasks: [],
@@ -66,24 +66,6 @@ module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
66
66
  }
67
67
  }
68
68
  },
69
- // Check to see if seasonal changes should be made
70
- {
71
- name: 'ifSeason',
72
- fn: function(season, block) {
73
- const today = new Date();
74
- const year = today.getFullYear();
75
- let isSeason = false;
76
-
77
- switch(season) {
78
- case 'coolerWeather':
79
- const startOfSpring = new Date(`03-14-${year}`);
80
- const startOfFall = new Date(`09-25-${year}`);
81
- isSeason = !(today > startOfSpring && today < startOfFall);
82
- break
83
- }
84
- return isSeason ? block.fn(this) : block.inverse(this);
85
- }
86
- },
87
69
  // Convert string to uppercase
88
70
  {
89
71
  name: 'uppercase',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mod-build",
3
- "version": "3.6.1--beta.19",
3
+ "version": "3.6.1--beta.20",
4
4
  "description": "Share components for S3 sites.",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"