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 +3 -0
- package/gulp-tasks/compile.js +10 -6
- package/gulp-tasks/grab-shared-components.js +21 -26
- package/package.json +1 -1
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
|
package/gulp-tasks/compile.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
17
|
-
// app: 'src/app.js',
|
|
18
|
-
// test: 'test/test.js',
|
|
19
|
-
// },
|
|
23
|
+
entry,
|
|
20
24
|
output: {
|
|
21
|
-
filename: '
|
|
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
|
|
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
|
|
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}
|
|
13
|
+
.pipe(gulp.dest(`${siteSettings.srcFolder}/shared-components/`))
|
|
14
14
|
.on('finish', resolve);
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
return
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
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
|
};
|