mod-build 3.6.7 → 3.6.8--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.
- package/CHANGELOG.md +4 -0
- package/gulp-tasks/grab-shared-scripts.js +184 -5
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.6.8
|
|
4
|
+
|
|
5
|
+
- Adding a new `useRelativePathForResources` parameter for special use-cases that need to use a relative path for shared scripts (ie. the improvementcenter pages)
|
|
6
|
+
|
|
3
7
|
## 3.6.7
|
|
4
8
|
|
|
5
9
|
- Adding a new `grab-shared-scripts` gulp task grab the most recent version from `mod-analytics`. It will copy this version into the site's `resources/scripts/mod-alytics` folder & then update the src in the `head` shared component. Also updated `cache-bust` to ignore this file on build.
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
var request = require('request');
|
|
2
2
|
var source = require('vinyl-source-stream');
|
|
3
3
|
var replace = require('gulp-replace');
|
|
4
|
+
var debug = require('gulp-debug');
|
|
4
5
|
var hash = require('gulp-hash');
|
|
5
6
|
var tap = require('gulp-tap');
|
|
6
7
|
var path = require('path');
|
|
7
8
|
|
|
8
9
|
var modAlyticsFileName = '';
|
|
10
|
+
var abandonmentJsFileName = '';
|
|
11
|
+
var footerComponentJsFileName = '';
|
|
12
|
+
var modFooterStylesFileName = '';
|
|
13
|
+
var qsFooterStylesFileName = '';
|
|
9
14
|
|
|
10
|
-
function
|
|
11
|
-
if (siteData.siteData && siteData.siteData.isQuotePage === true) {
|
|
15
|
+
function replaceModalyticsSrc(gulp, gulpPlugins, siteSettings, siteData) {
|
|
16
|
+
if (siteData.siteData && siteData.siteData.isQuotePage === true || siteData.siteData && siteData.siteData.useRelativePathForResources === true) {
|
|
12
17
|
return gulp.src(siteSettings.srcFolder + '/shared-components/head/head.html')
|
|
13
18
|
.pipe(replace(/".*(modalytics).*"/, '"resources/scripts/mod-alytics/' + modAlyticsFileName + '"'))
|
|
14
19
|
.pipe(gulp.dest(siteSettings.srcFolder + '/shared-components/head'));
|
|
@@ -19,7 +24,60 @@ function replaceModalyticsSrcInHead(gulp, gulpPlugins, siteSettings, siteData) {
|
|
|
19
24
|
}
|
|
20
25
|
}
|
|
21
26
|
|
|
22
|
-
function
|
|
27
|
+
function replaceAbandonmentJsSrc(gulp, gulpPlugins, siteSettings, siteData) {
|
|
28
|
+
if (siteData.siteData && siteData.siteData.isQuotePage === true || siteData.siteData && siteData.siteData.useRelativePathForResources === true) {
|
|
29
|
+
return gulp.src(siteSettings.srcFolder + '/templates/abandonment/index.html')
|
|
30
|
+
.pipe(replace(/"(?:(?!"|")[\s\S])+(abandonment\/abandonment.*?)js"/, '"resources/scripts/abandonment/' + abandonmentJsFileName + '"'))
|
|
31
|
+
.pipe(gulp.dest(siteSettings.srcFolder + '/templates/abandonment'));
|
|
32
|
+
} else {
|
|
33
|
+
return gulp.src(siteSettings.srcFolder + '/templates/abandonment/index.html')
|
|
34
|
+
.pipe(replace(/"(?:(?!"|")[\s\S])+(abandonment\/abandonment.*?)js"/, '"/resources/scripts/abandonment/' + abandonmentJsFileName + '"'))
|
|
35
|
+
.pipe(gulp.dest(siteSettings.srcFolder + '/templates/abandonment'));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function replaceFooterComponentJsSrc(gulp, gulpPlugins, siteSettings, siteData) {
|
|
40
|
+
if (siteData.siteData && siteData.siteData.isQuotePage === true || siteData.siteData && siteData.siteData.useRelativePathForResources === true) {
|
|
41
|
+
return gulp.src(siteSettings.srcFolder + '/shared-components/foot-assets/foot-assets.html')
|
|
42
|
+
.pipe(replace(/"(?:(?!"|")[\s\S])+(footer\/footer-component.*?)js"/, '"resources/scripts/footer/' + footerComponentJsFileName + '"'))
|
|
43
|
+
.pipe(gulp.dest(siteSettings.srcFolder + '/shared-components/foot-assets'));
|
|
44
|
+
} else {
|
|
45
|
+
return gulp.src(siteSettings.srcFolder + '/shared-components/foot-assets/foot-assets.html')
|
|
46
|
+
.pipe(replace(/"(?:(?!"|")[\s\S])+(footer\/footer-component.*?)js"/, '"/resources/scripts/footer/' + footerComponentJsFileName + '"'))
|
|
47
|
+
.pipe(gulp.dest(siteSettings.srcFolder + '/shared-components/foot-assets'));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function replaceFooterStylesReference(gulp, gulpPlugins, siteSettings, siteData) {
|
|
52
|
+
if (siteData.siteData && siteData.siteData.isQuotePage === true || siteData.siteData && siteData.siteData.useRelativePathForResources === true) {
|
|
53
|
+
return gulp.src(siteSettings.srcFolder + '/resources/scripts/footer/' + footerComponentJsFileName)
|
|
54
|
+
// .pipe(replace(/\`(?:(?!\`|\`)[\s\S])+(components\/footer\/mod.*?)\`/, '`resources/styles/components/footer/' + modFooterStylesFileName + '`'))
|
|
55
|
+
.pipe(replace(/\`(?:(?!\`|\`)[\s\S])+(components\/footer\/qs.*?)\`/, '`resources/styles/components/footer/' + qsFooterStylesFileName + '`'))
|
|
56
|
+
.pipe(gulp.dest(siteSettings.srcFolder + '/resources/scripts/footer'));
|
|
57
|
+
} else {
|
|
58
|
+
return gulp.src(siteSettings.srcFolder + '/resources/scripts/footer/' + footerComponentJsFileName)
|
|
59
|
+
// .pipe(replace(/\`(?:(?!\`|\`)[\s\S])+(components\/footer\/mod.*?)\`/, '`/resources/styles/components/footer/' + modFooterStylesFileName + '`'))
|
|
60
|
+
// .pipe(replace(/\`(?:(?!\`|\`)[\s\S])+(components\/footer\/qs.*?)\`/, '`/resources/styles/components/footer/' + qsFooterStylesFileName + '`'))
|
|
61
|
+
// .pipe(gulp.dest(siteSettings.srcFolder + '/resources/scripts/footer'))
|
|
62
|
+
.pipe(debug());
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function replaceFooterStylesReferenceInMap(gulp, gulpPlugins, siteSettings, siteData) {
|
|
67
|
+
if (siteData.siteData && siteData.siteData.isQuotePage === true || siteData.siteData && siteData.siteData.useRelativePathForResources === true) {
|
|
68
|
+
return gulp.src(siteSettings.srcFolder + '/resources/scripts/footer/footer-component.min.js.map')
|
|
69
|
+
.pipe(replace(/concat\((?:(?!concat\(|\))[\s\S])+(components\/footer\/mod.*?)\)/, 'concat("resources/styles/components/footer/' + modFooterStylesFileName + '")'))
|
|
70
|
+
.pipe(replace(/concat\((?:(?!concat\(|\))[\s\S])+(components\/footer\/qs.*?)\)/, 'concat("resources/styles/components/footer/' + qsFooterStylesFileName + '")'))
|
|
71
|
+
.pipe(gulp.dest(siteSettings.srcFolder + '/resources/scripts/footer'));
|
|
72
|
+
} else {
|
|
73
|
+
return gulp.src(siteSettings.srcFolder + '/resources/scripts/footer/footer-component.min.js.map')
|
|
74
|
+
.pipe(replace(/concat\((?:(?!concat\(|\))[\s\S])+(components\/footer\/mod.*?)\)/, 'concat("/resources/styles/components/footer/' + modFooterStylesFileName + '")'))
|
|
75
|
+
.pipe(replace(/concat\((?:(?!concat\(|\))[\s\S])+(components\/footer\/qs.*?)\)/, 'concat("/resources/styles/components/footer/' + qsFooterStylesFileName + '")'))
|
|
76
|
+
.pipe(gulp.dest(siteSettings.srcFolder + '/resources/scripts/footer'));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function copyModalytics(gulp, gulpPlugins, siteSettings, siteData) {
|
|
23
81
|
return new Promise(resolve => {
|
|
24
82
|
request(`https://${siteSettings.nodeEnv}/quote/resources/mod-alytics/modalytics.min.js`)
|
|
25
83
|
.on('response', resp => {
|
|
@@ -45,7 +103,7 @@ function copyCurrentModalytics(gulp, gulpPlugins, siteSettings, siteData) {
|
|
|
45
103
|
if (resp.statusCode !== 200) {
|
|
46
104
|
throw new Error(`${resp.statusCode} Error while fetching modalytics.min.js.map`);
|
|
47
105
|
} else {
|
|
48
|
-
|
|
106
|
+
replaceModalyticsSrc(gulp, gulpPlugins, siteSettings, siteData);
|
|
49
107
|
}
|
|
50
108
|
})
|
|
51
109
|
.pipe(source('modalytics.min.js.map'))
|
|
@@ -54,6 +112,127 @@ function copyCurrentModalytics(gulp, gulpPlugins, siteSettings, siteData) {
|
|
|
54
112
|
});
|
|
55
113
|
});
|
|
56
114
|
}
|
|
115
|
+
|
|
116
|
+
function copyAbandonmentJs(gulp, gulpPlugins, siteSettings, siteData) {
|
|
117
|
+
return new Promise(resolve => {
|
|
118
|
+
request(`https://${siteSettings.nodeEnv}/quote/resources/shared-resources/scripts/abandonment/abandonment.min.js`)
|
|
119
|
+
.on('response', resp => {
|
|
120
|
+
if (resp.statusCode !== 200) {
|
|
121
|
+
throw new Error(`${resp.statusCode} Error while fetching abandonment.min.js`);
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
.pipe(source('abandonment.min.js'))
|
|
125
|
+
.pipe(hash({
|
|
126
|
+
hashLength: 20,
|
|
127
|
+
template: 'abandonment-<%= hash %>.min.js'
|
|
128
|
+
}))
|
|
129
|
+
.pipe(tap(function(file, t){
|
|
130
|
+
abandonmentJsFileName = path.basename(file.path);
|
|
131
|
+
}))
|
|
132
|
+
.pipe(gulp.dest(`${siteSettings.srcFolder}/resources/scripts/abandonment`))
|
|
133
|
+
.on('finish', resolve);
|
|
134
|
+
})
|
|
135
|
+
.then(() => {
|
|
136
|
+
return new Promise(resolve => {
|
|
137
|
+
request(`https://${siteSettings.nodeEnv}/quote/resources/shared-resources/scripts/abandonment/abandonment.min.js.map`)
|
|
138
|
+
.on('response', resp => {
|
|
139
|
+
if (resp.statusCode !== 200) {
|
|
140
|
+
throw new Error(`${resp.statusCode} Error while fetching abandonment.min.js.map`);
|
|
141
|
+
} else {
|
|
142
|
+
replaceAbandonmentJsSrc(gulp, gulpPlugins, siteSettings, siteData);
|
|
143
|
+
}
|
|
144
|
+
})
|
|
145
|
+
.pipe(source('abandonment.min.js.map'))
|
|
146
|
+
.pipe(gulp.dest(`${siteSettings.srcFolder}/resources/scripts/abandonment`))
|
|
147
|
+
.on('finish', resolve);
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function copyFooterComponentJs(gulp, gulpPlugins, siteSettings, siteData) {
|
|
153
|
+
return new Promise(resolve => {
|
|
154
|
+
request(`https://${siteSettings.nodeEnv}/quote/resources/shared-resources/scripts/footer/footer-component.min.js`)
|
|
155
|
+
.on('response', resp => {
|
|
156
|
+
if (resp.statusCode !== 200) {
|
|
157
|
+
throw new Error(`${resp.statusCode} Error while fetching footer-component.min.js`);
|
|
158
|
+
}
|
|
159
|
+
})
|
|
160
|
+
.pipe(source('footer-component.min.js'))
|
|
161
|
+
.pipe(hash({
|
|
162
|
+
hashLength: 20,
|
|
163
|
+
template: 'footer-component-<%= hash %>.min.js'
|
|
164
|
+
}))
|
|
165
|
+
.pipe(tap(function(file, t){
|
|
166
|
+
footerComponentJsFileName = path.basename(file.path);
|
|
167
|
+
}))
|
|
168
|
+
.pipe(gulp.dest(`${siteSettings.srcFolder}/resources/scripts/footer`))
|
|
169
|
+
.on('finish', resolve);
|
|
170
|
+
})
|
|
171
|
+
.then(() => {
|
|
172
|
+
return new Promise(resolve => {
|
|
173
|
+
request(`https://${siteSettings.nodeEnv}/quote/resources/shared-resources/scripts/footer/footer-component.min.js.map`)
|
|
174
|
+
.on('response', resp => {
|
|
175
|
+
if (resp.statusCode !== 200) {
|
|
176
|
+
throw new Error(`${resp.statusCode} Error while fetching footer-component.min.js.map`);
|
|
177
|
+
} else {
|
|
178
|
+
replaceFooterComponentJsSrc(gulp, gulpPlugins, siteSettings, siteData);
|
|
179
|
+
}
|
|
180
|
+
})
|
|
181
|
+
.pipe(source('footer-component.min.js.map'))
|
|
182
|
+
.pipe(gulp.dest(`${siteSettings.srcFolder}/resources/scripts/footer`))
|
|
183
|
+
.on('finish', resolve);
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function copyFooterComponentStyles(gulp, gulpPlugins, siteSettings, siteData) {
|
|
189
|
+
return new Promise(resolve => {
|
|
190
|
+
request(`https://${siteSettings.nodeEnv}/quote/resources/shared-resources/styles/components/footer/qs-footer.min.css`)
|
|
191
|
+
.on('response', resp => {
|
|
192
|
+
if (resp.statusCode !== 200) {
|
|
193
|
+
throw new Error(`${resp.statusCode} Error while fetching qs-footer.min.css`);
|
|
194
|
+
}
|
|
195
|
+
})
|
|
196
|
+
.pipe(source('qs-footer.min.css'))
|
|
197
|
+
.pipe(hash({
|
|
198
|
+
hashLength: 20,
|
|
199
|
+
template: 'qs-footer-<%= hash %>.min.css'
|
|
200
|
+
}))
|
|
201
|
+
.pipe(tap(function(file, t){
|
|
202
|
+
qsFooterStylesFileName = path.basename(file.path);
|
|
203
|
+
}))
|
|
204
|
+
.pipe(gulp.dest(`${siteSettings.srcFolder}/resources/styles/components/footer`))
|
|
205
|
+
.on('finish', resolve);
|
|
206
|
+
})
|
|
207
|
+
.then(() => {
|
|
208
|
+
return new Promise(resolve => {
|
|
209
|
+
request(`https://${siteSettings.nodeEnv}/quote/resources/shared-resources/styles/components/footer/mod-footer.min.css`)
|
|
210
|
+
.on('response', resp => {
|
|
211
|
+
if (resp.statusCode !== 200) {
|
|
212
|
+
throw new Error(`${resp.statusCode} Error while fetching mod-footer.min.css`);
|
|
213
|
+
} else {
|
|
214
|
+
console.log(qsFooterStylesFileName);
|
|
215
|
+
replaceFooterStylesReference(gulp, gulpPlugins, siteSettings, siteData);
|
|
216
|
+
}
|
|
217
|
+
})
|
|
218
|
+
.pipe(source('mod-footer.min.css'))
|
|
219
|
+
.pipe(hash({
|
|
220
|
+
hashLength: 20,
|
|
221
|
+
template: 'mod-footer-<%= hash %>.min.css'
|
|
222
|
+
}))
|
|
223
|
+
.pipe(tap(function(file, t){
|
|
224
|
+
modFooterStylesFileName = path.basename(file.path);
|
|
225
|
+
}))
|
|
226
|
+
.pipe(gulp.dest(`${siteSettings.srcFolder}/resources/styles/components/footer`))
|
|
227
|
+
.on('finish', resolve);
|
|
228
|
+
});
|
|
229
|
+
})
|
|
230
|
+
// .then(() => {
|
|
231
|
+
// replaceFooterStylesReference(gulp, gulpPlugins, siteSettings, siteData);
|
|
232
|
+
// replaceFooterStylesReferenceInMap(gulp, gulpPlugins, siteSettings, siteData);
|
|
233
|
+
// });
|
|
234
|
+
}
|
|
235
|
+
|
|
57
236
|
module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
|
|
58
237
|
return function() {
|
|
59
238
|
const { nodeEnv } = siteSettings;
|
|
@@ -61,6 +240,6 @@ module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
|
|
|
61
240
|
throw new Error('Missing environment variables. Did you start with gulp instead of npm run...?');
|
|
62
241
|
}
|
|
63
242
|
|
|
64
|
-
return
|
|
243
|
+
return copyModalytics(gulp, gulpPlugins, siteSettings, siteData) && copyAbandonmentJs(gulp, gulpPlugins, siteSettings, siteData) && copyFooterComponentJs(gulp, gulpPlugins, siteSettings, siteData) && copyFooterComponentStyles(gulp, gulpPlugins, siteSettings, siteData);
|
|
65
244
|
};
|
|
66
245
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mod-build",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.8--beta.2",
|
|
4
4
|
"description": "Share components for S3 sites.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"gulp-concat": "^2.6.1",
|
|
22
22
|
"gulp-cssmin": "^0.1.7",
|
|
23
23
|
"gulp-csso": "^3.0.0",
|
|
24
|
+
"gulp-debug": "^4.0.0",
|
|
24
25
|
"gulp-eslint": "^5.0.0",
|
|
25
26
|
"gulp-eslint-threshold": "^0.1.1",
|
|
26
27
|
"gulp-filter": "^5.0.0",
|