mod-build 3.6.22-beta.5 → 3.6.23-beta.1
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/gulp-tasks/build.js
CHANGED
|
@@ -10,7 +10,7 @@ module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
|
|
|
10
10
|
if (siteData.isQSPage) {
|
|
11
11
|
sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', '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', 'grab-shared-scripts', 'templates', 'styles', 'combine-files', 'grab-images',
|
|
13
|
+
sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', '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
16
|
sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', 'templates', 'styles', 'js-lint', 'html-min', 'css-min', 'js-min', 'img-min', 'extras', 'brand', 'cache-bust', 'build-stat'];
|
|
@@ -28,6 +28,7 @@ function replaceFootAssetScripts(gulp, gulpPlugins, siteSettings, siteData) {
|
|
|
28
28
|
.pipe(replace(/"(?:(?!"|js")[\s\S])+(modutils|mod-utils.*?)js"/, resourcePath + '/mod-utils/' + fileNames.modUtilsFileName))
|
|
29
29
|
.pipe(replace(/"(?:(?!"|")[\s\S])+(footer\/footer-component.*?)js"/, resourcePath + '/footer/' + fileNames.footerComponentJsFileName))
|
|
30
30
|
.pipe(replace(/"(?:(?!"|")[\s\S])+(mod-form\/mod-form.*?)js"/, resourcePath + '/mod-form/' + fileNames.modFormFileName))
|
|
31
|
+
.pipe(replace(/"(?:(?!"|")[\s\S])+(mod-form\/form\/mod-form.*?)js"/, resourcePath + '/mod-form/form/' + fileNames.newModFormFileName))
|
|
31
32
|
.pipe(replace(/"(?:(?!"|")[\s\S])+(qs-form.*?)js"/, resourcePath + '/mod-form/' + fileNames.qsFormFileName))
|
|
32
33
|
.pipe(gulp.dest(siteSettings.srcFolder + '/shared-components/foot-assets'));
|
|
33
34
|
}
|
|
@@ -73,18 +74,21 @@ function getResource(url, config = {}, fn, fnArray) {
|
|
|
73
74
|
|
|
74
75
|
return new Promise(resolve => {
|
|
75
76
|
const file = getFileFromURL(url);
|
|
76
|
-
|
|
77
|
+
const doNotAddHash = ['mod-form-beta.min.js']
|
|
78
|
+
let stream = request(`${resourceURL}/${url}`)
|
|
77
79
|
.on('response', resp => {
|
|
78
80
|
if (resp.statusCode !== 200) {
|
|
79
81
|
throw new Error(`${resp.statusCode} Error while fetching ${file}`);
|
|
80
82
|
}
|
|
81
83
|
})
|
|
82
84
|
.pipe(source(`${file}`))
|
|
83
|
-
.
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
if (!doNotAddHash.includes(file)) {
|
|
86
|
+
stream = stream.pipe(hash({
|
|
87
|
+
hashLength: 20,
|
|
88
|
+
template: file.replace(/^([^.]*)\.(.*)$/, '$1-<%= hash %>.$2')
|
|
89
|
+
}))
|
|
90
|
+
}
|
|
91
|
+
stream.pipe(tap(function(file, t) {
|
|
88
92
|
fileNames[config.fileName] = path.basename(file.path);
|
|
89
93
|
}))
|
|
90
94
|
.pipe(config.gulp.dest(`${config.siteSettings.srcFolder}/resources/${config.dest}`))
|
|
@@ -170,6 +174,16 @@ const TASKS = {
|
|
|
170
174
|
srcReplaceFn: null,
|
|
171
175
|
additionalSrcReplaceFns: []
|
|
172
176
|
},
|
|
177
|
+
copyNewModForm: {
|
|
178
|
+
url: `mod-form/form/mod-form-beta.min.js`,
|
|
179
|
+
mapUrl: `mod-form/form/mod-form-beta.min.js.map`,
|
|
180
|
+
config: {
|
|
181
|
+
fileName: 'newModFormFileName',
|
|
182
|
+
dest: 'scripts/mod-form/form'
|
|
183
|
+
},
|
|
184
|
+
srcReplaceFn: null,
|
|
185
|
+
additionalSrcReplaceFns: []
|
|
186
|
+
},
|
|
173
187
|
copyQsForm: {
|
|
174
188
|
url: `mod-form/qs-form.min.js`,
|
|
175
189
|
config: {
|
package/gulp-tasks/serve.js
CHANGED
|
@@ -8,7 +8,7 @@ module.exports.src = function(gulp, gulpPlugins, siteSettings, siteData) {
|
|
|
8
8
|
} else if (siteData.isQSPage) {
|
|
9
9
|
sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', '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', 'grab-shared-scripts', 'templates', 'styles', 'grab-tooltips-json', 'combine-files', 'grab-images',
|
|
11
|
+
sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', 'templates', 'styles', 'grab-tooltips-json', 'combine-files', 'grab-images', 'js-lint'];
|
|
12
12
|
}
|
|
13
13
|
runSequence(...sequenceOpts, () => {
|
|
14
14
|
// Run a BrowserSync server
|
|
@@ -36,13 +36,7 @@ module.exports.src = function(gulp, gulpPlugins, siteSettings, siteData) {
|
|
|
36
36
|
]).on('change', gulpPlugins.browserSync.reload);
|
|
37
37
|
|
|
38
38
|
// If templates changed, rerun templates task
|
|
39
|
-
|
|
40
|
-
gulp.watch(siteSettings.srcFolder + '/' + siteSettings.templatesSubfolder + '/**/*.html', function() {
|
|
41
|
-
runSequence('templates','grab-global-images')
|
|
42
|
-
});
|
|
43
|
-
} else {
|
|
44
|
-
gulp.watch(siteSettings.srcFolder + '/' + siteSettings.templatesSubfolder + '/**/*.html', ['templates'])
|
|
45
|
-
}
|
|
39
|
+
gulp.watch(siteSettings.srcFolder + '/' + siteSettings.templatesSubfolder + '/**/*.html', ['templates']);
|
|
46
40
|
|
|
47
41
|
// If styles changed, rerun styles task
|
|
48
42
|
gulp.watch(siteSettings.srcFolder + '/' + siteSettings.stylesSubfolder + '/**/*.scss', ['styles']);
|
package/gulp-tasks/tasks.js
CHANGED
|
@@ -346,18 +346,6 @@ module.exports = function() {
|
|
|
346
346
|
|
|
347
347
|
return require(opts.gulpTasksFolderPath + '/grab-images')(opts.gulp, opts.gulpSettings, opts.siteData);
|
|
348
348
|
}
|
|
349
|
-
},
|
|
350
|
-
|
|
351
|
-
// Get global images
|
|
352
|
-
'grab-global-images': {
|
|
353
|
-
subtasks: [],
|
|
354
|
-
func: function(opts) {
|
|
355
|
-
if ('undefined' === typeof opts.gulpTasksFolderPath) {
|
|
356
|
-
opts.gulpTasksFolderPath = '.';
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
return require(opts.gulpTasksFolderPath + '/grab-global-images')(opts.gulp, opts.gulpSettings, opts.siteData);
|
|
360
|
-
}
|
|
361
349
|
},
|
|
362
350
|
|
|
363
351
|
// Copy json files to dist
|
package/package.json
CHANGED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
var fs = require('fs');
|
|
2
|
-
var request = require('request');
|
|
3
|
-
var source = require('vinyl-source-stream');
|
|
4
|
-
var replace = require('gulp-replace');
|
|
5
|
-
|
|
6
|
-
var images = [];
|
|
7
|
-
|
|
8
|
-
function streamToDestination(gulp, siteSettings, url, fileName) {
|
|
9
|
-
var finalDestination;
|
|
10
|
-
|
|
11
|
-
if (!fs.existsSync(siteSettings.distFolder)) {
|
|
12
|
-
finalDestination = siteSettings.srcFolder;
|
|
13
|
-
} else {
|
|
14
|
-
finalDestination = siteSettings.distFolder;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return new Promise(resolve => { // eslint-disable-line no-undef
|
|
18
|
-
request(url)
|
|
19
|
-
.on('response', resp => {
|
|
20
|
-
if (resp.statusCode !== 200 && resp.statusCode !== 206) {
|
|
21
|
-
throw new Error(`${resp.statusCode} Error while fetching ${fileName}`);
|
|
22
|
-
} else {
|
|
23
|
-
images.push(fileName);
|
|
24
|
-
}
|
|
25
|
-
})
|
|
26
|
-
.pipe(source(fileName))
|
|
27
|
-
.pipe(gulp.dest(`${finalDestination}/resources/images/`))
|
|
28
|
-
.on('finish', resolve);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function replaceImagePath(gulp, siteSettings) {
|
|
33
|
-
var finalDestination;
|
|
34
|
-
|
|
35
|
-
if (!fs.existsSync(siteSettings.distFolder)) {
|
|
36
|
-
finalDestination = siteSettings.tmpFolder;
|
|
37
|
-
} else {
|
|
38
|
-
finalDestination = siteSettings.distFolder;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
var stream = gulp.src(`${finalDestination}/index.html`);
|
|
42
|
-
|
|
43
|
-
if (images.length) {
|
|
44
|
-
images.forEach(function(image) {
|
|
45
|
-
stream = stream.pipe(replace(new RegExp(`"(?:(?!"|")[\\s\\S])+(${image})"`, 'gm'), '"/resources/images/' + image + '"'))
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
return stream.pipe(gulp.dest(finalDestination))
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const getTags = (string) => {
|
|
52
|
-
const regExs = [/<img.*?src="(.*?)"[^\>]+>/g, /<use.*?href="(.*?)".*?>/g, /<source.*?srcset="(.*?)".*?>/g, /url\('#{\$path}.*?'\)/g];
|
|
53
|
-
let tags = [];
|
|
54
|
-
|
|
55
|
-
regExs.forEach((regEx) => {
|
|
56
|
-
const match = string.match(regEx);
|
|
57
|
-
|
|
58
|
-
if (match) {
|
|
59
|
-
tags = [...tags, ...match];
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
return tags;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const getUrls = (tags) => {
|
|
67
|
-
const urls = [];
|
|
68
|
-
|
|
69
|
-
tags.forEach((tag) => {
|
|
70
|
-
if (tag) {
|
|
71
|
-
let url = tag;
|
|
72
|
-
url = url.match(/(https?:\/\/[^\s]+)/gim);
|
|
73
|
-
if (url) {
|
|
74
|
-
url = url[0];
|
|
75
|
-
url = url.replace(/"/g, "")
|
|
76
|
-
urls.push(url)
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
return [...new Set(urls)]; // eslint-disable-line no-undef
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
const parseImageSources = (gulp, siteSettings) => {
|
|
85
|
-
const text = fs.readFileSync(`${siteSettings.tmpFolder}/index.html`, 'utf8');
|
|
86
|
-
const textMatches = getTags(text);
|
|
87
|
-
return getUrls(textMatches);
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
module.exports = function(gulp, siteSettings, siteData) {
|
|
91
|
-
return async function() {
|
|
92
|
-
const urls = parseImageSources(gulp, siteSettings);
|
|
93
|
-
const urlsPromises = urls.map(async(url) => {
|
|
94
|
-
const fileName = await url.slice(url.lastIndexOf('/') + 1);
|
|
95
|
-
return await streamToDestination(gulp, siteSettings, url, fileName);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
return await Promise.all(urlsPromises).then(function() { // eslint-disable-line no-undef
|
|
99
|
-
replaceImagePath(gulp, siteSettings)
|
|
100
|
-
})
|
|
101
|
-
};
|
|
102
|
-
};
|