mod-build 3.5.1 → 3.5.3

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,8 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.5.2
4
+ - `grab-shared-components` task updated: now it grabs all shared-components files that are listed under `mod-site/shared-components/all.json` So there's no need to update the task every time we add a new component.
5
+
3
6
  ## 3.5.1
4
7
 
5
8
  - `grab-shared-components` task was created; added to tasks.js, serve.js & build.js to grab the new shared-components folder from mod-site and copy them to your local env
@@ -1,4 +1,11 @@
1
1
  const webpack = require('webpack-stream');
2
+ const glob = require('glob');
3
+
4
+ const entry = glob.sync('./src/scripts/**.ts').reduce((entry, path) => {
5
+ const pathName = path.replace(/(\.\/src\/scripts\/|\.ts)/g, ''); // remove `./src/scripts/`, `.ts`
6
+ entry[pathName] = path;
7
+ return entry;
8
+ }, {});
2
9
 
3
10
  module.exports = function(gulp, gulpPlugins, siteSettings, mode) {
4
11
  let assetUrl = siteSettings.tmpFolder + '/scripts';
@@ -7,18 +14,15 @@ module.exports = function(gulp, gulpPlugins, siteSettings, mode) {
7
14
  }
8
15
 
9
16
  return function() {
10
- return gulp.src('src/scripts/home.ts')
17
+ return gulp.src('src/scripts/**.ts')
11
18
  .on('error', function() {
12
19
  this.end();
13
20
  })
14
21
  .pipe(webpack({
15
22
  mode: mode,
16
- // entry: {
17
- // app: 'src/app.js',
18
- // test: 'test/test.js',
19
- // },
23
+ entry,
20
24
  output: {
21
- filename: 'home.js'
25
+ filename: '[name].js'
22
26
  },
23
27
  resolve: {
24
28
  // Add `.ts` and `.tsx` as a resolvable extension.
@@ -1,47 +1,42 @@
1
1
  var request = require('request');
2
2
  var source = require('vinyl-source-stream');
3
3
 
4
- function streamToDestination(gulp, siteSettings, inputPath, destPath, fileName) {
4
+ function streamSharedCompsToDestination(gulp, siteSettings, fileName) {
5
5
  return new Promise(resolve => { // eslint-disable-line no-undef
6
- request(`https://${siteSettings.nodeEnv}/quote/resources/mod-site${inputPath}`)
6
+ request(`https://${siteSettings.nodeEnv}/quote/resources/mod-site/shared-components/${fileName}`)
7
7
  .on('response', resp => {
8
8
  if (resp.statusCode !== 200) {
9
9
  throw new Error(`${resp.statusCode} Error while fetching ${fileName}`);
10
10
  }
11
11
  })
12
12
  .pipe(source(fileName))
13
- .pipe(gulp.dest(`${siteSettings.srcFolder}/${destPath}`))
13
+ .pipe(gulp.dest(`${siteSettings.srcFolder}/shared-components/`))
14
14
  .on('finish', resolve);
15
15
  });
16
16
  }
17
17
 
18
- module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
19
- return function() {
20
- const { nodeEnv, isLocal } = siteSettings;
21
- const { isQSPage, isWhiteLabel, includeFaqLink, domain } = siteData;
22
- const isModWhiteLabel = isWhiteLabel && !isQSPage
23
- const domainHasModernize = domain.indexOf('modernize') > -1;
24
-
25
- let externalResources;
26
- // listing of Static Resources sub-path and site destination paths
27
- // key: inputPath, value: destPath
28
-
29
- externalResources = {
30
- '/shared-components/carousel/carousel.html': ['/shared-components/carousel', 'carousel.html'],
31
- '/shared-components/carousel/_carousel.scss': ['/shared-components/carousel', '_carousel.scss']
32
- };
18
+ function getListOfSharedComponents(gulp, gulpPlugins, siteSettings) {
19
+ return new Promise(resolve => { // eslint-disable-line no-undef
20
+ request(`https://${siteSettings.nodeEnv}/quote/resources/mod-site/shared-components/all.json`, function(err, resp, body) {
21
+ if (resp.statusCode !== 200) {
22
+ throw new Error(`${resp.statusCode}: Error while fetching shared-components/all.json`);
23
+ }
24
+ var listOfComponents = JSON.parse(body);
25
+ const componentPromises = listOfComponents.map(function(resource) {
26
+ return streamSharedCompsToDestination(gulp, siteSettings, `${resource}`);
27
+ });
28
+ resolve(Promise.all(componentPromises)); // eslint-disable-line no-undef
29
+ });
30
+ });
31
+ }
33
32
 
33
+ module.exports = function(gulp, gulpPlugins, siteSettings) {
34
+ return function() {
35
+ const { nodeEnv } = siteSettings;
34
36
  if (!nodeEnv) {
35
37
  throw new Error('Missing environment variables. Did you start with gulp instead of npm run...?');
36
38
  }
37
39
 
38
- const filesPromiseMap = Object.keys(externalResources).map(key => {
39
- const destinationPath = externalResources[key][0];
40
- const fileName = externalResources[key][1];
41
- return streamToDestination(gulp, siteSettings, key, destinationPath, fileName);
42
- });
43
-
44
- // when Promise.all resolves, the streams are done and we can go to the next step
45
- return Promise.all(filesPromiseMap); // eslint-disable-line no-undef
40
+ return getListOfSharedComponents(gulp, gulpPlugins, siteSettings); // eslint-disable-line no-undef
46
41
  };
47
42
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mod-build",
3
- "version": "3.5.1",
3
+ "version": "3.5.3",
4
4
  "description": "Share components for S3 sites.",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"