mod-build 4.0.0-beta.4g → 4.0.0-beta.5
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/package.json +1 -1
- package/tasks/grab-shared-scripts.js +65 -16
package/package.json
CHANGED
|
@@ -12,10 +12,13 @@ import { getFileFromURL } from '../src/scripts/utils.js';
|
|
|
12
12
|
|
|
13
13
|
let fileNames = {};
|
|
14
14
|
let componentFolderPath = '';
|
|
15
|
+
let replacementFunctions = [];
|
|
16
|
+
|
|
17
|
+
let pathSubdirectory = '';
|
|
15
18
|
|
|
16
19
|
function replaceModalyticsSrc(gulp, defaultSettings) {
|
|
17
20
|
const resourcePath = '/resources/scripts/mod-alytics/';
|
|
18
|
-
return new Promise((resolve
|
|
21
|
+
return new Promise((resolve) => {
|
|
19
22
|
gulp.src(`${defaultSettings.srcFolder}/${componentFolderPath}/head/head.html`)
|
|
20
23
|
.pipe(replace(/".*(modalytics).*"/, `"${resourcePath}${fileNames.modAlyticsFileName}"`))
|
|
21
24
|
.pipe(gulp.dest(`${defaultSettings.srcFolder}/${componentFolderPath}/head`))
|
|
@@ -25,7 +28,7 @@ function replaceModalyticsSrc(gulp, defaultSettings) {
|
|
|
25
28
|
|
|
26
29
|
function replaceFootAssetScripts(gulp, defaultSettings) {
|
|
27
30
|
const resourcePath = '/resources/scripts';
|
|
28
|
-
return new Promise((resolve
|
|
31
|
+
return new Promise((resolve) => {
|
|
29
32
|
gulp.src(`${defaultSettings.srcFolder}/${componentFolderPath}/foot-assets/foot-assets.html`)
|
|
30
33
|
.pipe(replace(/"(?:(?!"|js")[\s\S])+(modutils|mod-utils.*?)js"|"(?:(?!"|")[\s\S])+(callrail.*?)js"|"(?:(?!"|")[\s\S])+(footer\/footer-component.*?)js"|"(?:(?!"|")[\s\S])+(mod-form\/form.*?)js"/g, function(match) {
|
|
31
34
|
if (match.includes('mod-form/form')) {
|
|
@@ -49,7 +52,7 @@ function replaceFootAssetScripts(gulp, defaultSettings) {
|
|
|
49
52
|
function replaceAbandonmentJsCssSrc(gulp, defaultSettings) {
|
|
50
53
|
const jsResourcePath = '/resources/scripts/abandonment/';
|
|
51
54
|
const cssResourcePath = '/resources/styles/components/abandonment/';
|
|
52
|
-
return new Promise((resolve
|
|
55
|
+
return new Promise((resolve) => {
|
|
53
56
|
gulp.src(defaultSettings.srcFolder + '/templates/abandonment/*.html')
|
|
54
57
|
.pipe(replace(/"(?:(?!"|")[\s\S])+(abandonment\/abandonment.*?)js"/, `"${jsResourcePath}${fileNames.abandonmentJsFileName}"`))
|
|
55
58
|
.pipe(replace(/"(?:(?!"|")[\s\S])+(components\/abandonment\/abandonment.*?)css"/, `"${cssResourcePath}${fileNames.abandonmentStylesFileName}"`))
|
|
@@ -58,20 +61,40 @@ function replaceAbandonmentJsCssSrc(gulp, defaultSettings) {
|
|
|
58
61
|
});
|
|
59
62
|
}
|
|
60
63
|
|
|
64
|
+
function replaceFooterStylesReference(gulp, defaultSettings) {
|
|
65
|
+
if (pathSubdirectory.length > 0) {
|
|
66
|
+
return new Promise((resolve) => {
|
|
67
|
+
gulp.src(defaultSettings.publicFolder + '/resources/scripts/footer/' + fileNames.footerComponentJsFileName)
|
|
68
|
+
.pipe(replace(/concat\((?:(?!concat\(|\))[\s\S])+(components\/footer\/mod.*?)\)/, `concat("${pathSubdirectory}resources/styles/components/footer/` + fileNames.modFooterStylesFileName + '")'))
|
|
69
|
+
.pipe(replace(/concat\((?:(?!concat\(|\))[\s\S])+(components\/footer\/qs.*?)\)/, `concat("${pathSubdirectory}resources/styles/components/footer/` + fileNames.qsFooterStylesFileName + '")'))
|
|
70
|
+
.pipe(gulp.dest(defaultSettings.publicFolder + '/resources/scripts/footer'))
|
|
71
|
+
.on('finish', resolve);
|
|
72
|
+
});
|
|
73
|
+
} else {
|
|
74
|
+
return new Promise((resolve) => {
|
|
75
|
+
gulp.src(defaultSettings.publicFolder + '/resources/scripts/footer/' + fileNames.footerComponentJsFileName)
|
|
76
|
+
.pipe(replace(/concat\((?:(?!concat\(|\))[\s\S])+(components\/footer\/mod.*?)\)/, 'concat("/resources/styles/components/footer/' + fileNames.modFooterStylesFileName + '")'))
|
|
77
|
+
.pipe(replace(/concat\((?:(?!concat\(|\))[\s\S])+(components\/footer\/qs.*?)\)/, 'concat("/resources/styles/components/footer/' + fileNames.qsFooterStylesFileName + '")'))
|
|
78
|
+
.pipe(gulp.dest(defaultSettings.publicFolder + '/resources/scripts/footer'))
|
|
79
|
+
.on('finish', resolve);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
61
84
|
const TASKS = {
|
|
62
85
|
copyModutils: {
|
|
63
|
-
url: '
|
|
86
|
+
url: 'mod-utils/modutils.min.js',
|
|
64
87
|
config: {
|
|
65
|
-
fileName: '
|
|
66
|
-
dest: 'scripts/
|
|
88
|
+
fileName: 'modUtilsFileName',
|
|
89
|
+
dest: 'scripts/mod-utils',
|
|
67
90
|
},
|
|
68
91
|
srcReplaceFn: null,
|
|
69
92
|
},
|
|
70
93
|
copyCallrail: {
|
|
71
|
-
url: '
|
|
94
|
+
url: 'shared-resources/scripts/callrail/callrail.min.js',
|
|
72
95
|
config: {
|
|
73
|
-
fileName: '
|
|
74
|
-
dest: 'scripts/
|
|
96
|
+
fileName: 'callrailFileName',
|
|
97
|
+
dest: 'scripts/callrail',
|
|
75
98
|
},
|
|
76
99
|
srcReplaceFn: null,
|
|
77
100
|
},
|
|
@@ -114,6 +137,22 @@ const TASKS = {
|
|
|
114
137
|
dest: 'scripts/abandonment',
|
|
115
138
|
},
|
|
116
139
|
srcReplaceFn: replaceAbandonmentJsCssSrc,
|
|
140
|
+
},
|
|
141
|
+
copyModFooterComponentStyles: {
|
|
142
|
+
url: 'shared-resources/styles/components/footer/mod-footer.min.css',
|
|
143
|
+
config: {
|
|
144
|
+
fileName: 'modFooterStylesFileName',
|
|
145
|
+
dest: 'styles/components/footer',
|
|
146
|
+
},
|
|
147
|
+
srcReplaceFn: null,
|
|
148
|
+
},
|
|
149
|
+
copyQsFooterComponentStyles: {
|
|
150
|
+
url: 'shared-resources/styles/components/footer/qs-footer.min.css',
|
|
151
|
+
config: {
|
|
152
|
+
fileName: 'qsFooterStylesFileName',
|
|
153
|
+
dest: 'styles/components/footer',
|
|
154
|
+
},
|
|
155
|
+
srcReplaceFn: replaceFooterStylesReference,
|
|
117
156
|
}
|
|
118
157
|
};
|
|
119
158
|
|
|
@@ -172,15 +211,16 @@ function getResource(task, fileNames, resourcePath = 'quote/resources') {
|
|
|
172
211
|
})
|
|
173
212
|
});
|
|
174
213
|
})
|
|
175
|
-
.then(
|
|
214
|
+
.then(() => {
|
|
176
215
|
if (!srcReplaceFn) {
|
|
177
216
|
return false;
|
|
178
217
|
}
|
|
179
218
|
|
|
180
219
|
if (typeof srcReplaceFn === 'function') {
|
|
181
|
-
|
|
220
|
+
replacementFunctions.push(() => srcReplaceFn(gulp, task.config.defaultSettings, task.config.config));
|
|
182
221
|
}
|
|
183
|
-
|
|
222
|
+
|
|
223
|
+
return true;
|
|
184
224
|
})
|
|
185
225
|
.then(() => {
|
|
186
226
|
resolve();
|
|
@@ -193,9 +233,12 @@ function getResource(task, fileNames, resourcePath = 'quote/resources') {
|
|
|
193
233
|
}
|
|
194
234
|
|
|
195
235
|
export default async function(config) {
|
|
236
|
+
const { isLocal } = defaultSettings;
|
|
196
237
|
const useAccessibleComponents = config.useAccessibleConfig;
|
|
197
238
|
componentFolderPath = useAccessibleComponents === true ? 'accessible-components' : 'shared-components';
|
|
198
239
|
const tasks = Object.values(TASKS);
|
|
240
|
+
const isPathSubdirectory = config.siteData?.pathSubdirectory || config.pathSubdirectory;
|
|
241
|
+
pathSubdirectory = isLocal === "false" && isPathSubdirectory ? isPathSubdirectory : '';
|
|
199
242
|
|
|
200
243
|
if (tasks.length) {
|
|
201
244
|
const getAllResources = tasks.map(async function(task) {
|
|
@@ -206,9 +249,15 @@ export default async function(config) {
|
|
|
206
249
|
await getResource(task, fileNames);
|
|
207
250
|
});
|
|
208
251
|
|
|
209
|
-
await Promise.all(getAllResources)
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
252
|
+
await Promise.all(getAllResources);
|
|
253
|
+
|
|
254
|
+
console.log(`>> FILENAMES OBJECT: ${JSON.stringify(fileNames)}`);
|
|
255
|
+
|
|
256
|
+
await Promise.all(replacementFunctions.map(async function(fn) {
|
|
257
|
+
if (typeof fn === 'function') {
|
|
258
|
+
await fn();
|
|
259
|
+
}
|
|
260
|
+
}));
|
|
261
|
+
console.log('>> FINISHED replacing all resource paths');
|
|
213
262
|
}
|
|
214
263
|
}
|