mod-build 3.6.60 → 3.6.61-beta.2
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.
|
@@ -1,31 +1,33 @@
|
|
|
1
1
|
var request = require('request');
|
|
2
2
|
var source = require('vinyl-source-stream');
|
|
3
3
|
|
|
4
|
-
function streamSharedCompsToDestination(gulp, siteSettings, fileName) {
|
|
5
|
-
return new Promise(resolve => {
|
|
6
|
-
request(`https://${siteSettings.nodeEnv}/quote/resources/mod-site
|
|
4
|
+
function streamSharedCompsToDestination(gulp, siteSettings, folder, fileName) {
|
|
5
|
+
return new Promise(resolve => {
|
|
6
|
+
request(`https://${siteSettings.nodeEnv}/quote/resources/mod-site/${folder}/${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}/${folder}/`))
|
|
14
14
|
.on('finish', resolve);
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
function getListOfSharedComponents(gulp, gulpPlugins, siteSettings) {
|
|
19
|
-
return
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
function getListOfSharedComponents(gulp, gulpPlugins, siteSettings, componentFolders) {
|
|
19
|
+
return componentFolders.map(folder => {
|
|
20
|
+
return new Promise(resolve => {
|
|
21
|
+
request(`https://${siteSettings.nodeEnv}/quote/resources/mod-site/${folder}/all.json`, function(err, resp, body) {
|
|
22
|
+
if (resp.statusCode !== 200) {
|
|
23
|
+
throw new Error(`${resp.statusCode}: Error while fetching ${folder}/all.json`);
|
|
24
|
+
}
|
|
25
|
+
var listOfComponents = JSON.parse(body);
|
|
26
|
+
const componentPromises = listOfComponents.map(function(resource) {
|
|
27
|
+
return streamSharedCompsToDestination(gulp, siteSettings, folder, `${resource}`);
|
|
28
|
+
});
|
|
29
|
+
resolve(Promise.all(componentPromises));
|
|
27
30
|
});
|
|
28
|
-
resolve(Promise.all(componentPromises)); // eslint-disable-line no-undef
|
|
29
31
|
});
|
|
30
32
|
});
|
|
31
33
|
}
|
|
@@ -37,6 +39,8 @@ module.exports = function(gulp, gulpPlugins, siteSettings) {
|
|
|
37
39
|
throw new Error('Missing environment variables. Did you start with gulp instead of npm run...?');
|
|
38
40
|
}
|
|
39
41
|
|
|
40
|
-
|
|
42
|
+
const componentFolders = ['shared-components', 'accessible-components']
|
|
43
|
+
|
|
44
|
+
return getListOfSharedComponents(gulp, gulpPlugins, siteSettings, componentFolders);
|
|
41
45
|
};
|
|
42
46
|
};
|