@videinfra/static-website-builder 2.0.2 → 2.0.4
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/.prettierrc +11 -11
- package/CHANGELOG.md +214 -210
- package/README.md +102 -102
- package/bin/builder.js +40 -40
- package/eslint.config.js +39 -39
- package/gulpfile.js +63 -63
- package/init/default/config/config.js +44 -44
- package/init/default/src/html/data/global.js +9 -9
- package/init/default/src/javascripts/_entries.js +14 -14
- package/init/index.js +63 -63
- package/init/test/.env +6 -6
- package/init/test/.env.local +3 -2
- package/init/test/config/config.js +71 -67
- package/init/test/src/html/404.twig +12 -12
- package/init/test/src/html/data/global.js +10 -10
- package/init/test/src/html/env.twig +21 -21
- package/init/test/src/html/layouts/base.twig +1 -1
- package/init/test/src/html/other.twig +9 -9
- package/init/test/src/html/preposition.twig +4 -4
- package/init/test/src/javascripts/_entries-alt.js +10 -10
- package/init/test/src/javascripts/_entries.js +19 -19
- package/init/test/src/javascripts/common.js +13 -13
- package/init/test/src/javascripts/main.js +8 -8
- package/init/test/src/javascripts/something.ts +9 -9
- package/init/test/src/stylesheets/autoprefixer-test.scss +3 -3
- package/init/test/src/stylesheets/env-test.scss +28 -28
- package/init/test/src/stylesheets/ignore-test.scss +4 -4
- package/init/test/src/stylesheets/nested-calc-test.scss +3 -3
- package/init/test/src/stylesheets/sub-folder/import-test.scss +2 -2
- package/lib/camelize-file-name.js +21 -21
- package/lib/generate-gulp-tasks.js +85 -85
- package/lib/get-config.js +203 -204
- package/lib/get-file-names.js +23 -23
- package/lib/get-path.js +102 -102
- package/lib/globs-helper.js +243 -243
- package/lib/gulp/dynamic-task.js +8 -8
- package/lib/gulp/resolve-dynamic-task.js +11 -11
- package/lib/gulp/task-before-dest.js +8 -8
- package/lib/gulp/task-end.js +10 -10
- package/lib/gulp/task-start.js +12 -12
- package/lib/gulp/task-watch.js +66 -66
- package/lib/init/copy-folder.js +50 -50
- package/lib/init/folder-exists.js +10 -10
- package/lib/init/get-folder-list.js +16 -16
- package/lib/init/merge-package.js +17 -17
- package/lib/init/read-package.js +17 -17
- package/lib/log-error.js +15 -15
- package/lib/merge.js +27 -27
- package/lib/run-preprocess.js +32 -32
- package/lib/task-order.js +19 -19
- package/package.json +68 -68
- package/plugins/example/preprocess-config.js +17 -17
- package/plugins/example/task.js +55 -55
- package/plugins/example.js +38 -38
- package/plugins/sass-engine/preprocess-config.js +59 -59
- package/plugins/sass.js +41 -41
- package/plugins/twig/lodash-filters/filters.js +91 -91
- package/plugins/twig/lodash-filters.js +14 -14
- package/plugins/twig/symfony-filters/filters.js +102 -102
- package/plugins/twig/symfony-filters/preposition_nbsp.js +77 -77
- package/plugins/twig/symfony-filters.js +14 -14
- package/plugins/twig/symfony-functions/functions.js +31 -31
- package/plugins/twig/symfony-functions.js +14 -14
- package/plugins/twig-engine/preprocess-config.js +53 -53
- package/plugins/twig.js +74 -74
- package/tasks/browser-sync/config.js +39 -39
- package/tasks/browser-sync/preprocess-config.js +32 -32
- package/tasks/browser-sync/task.js +9 -9
- package/tasks/clean/config.js +20 -20
- package/tasks/clean/preprocess-config.js +19 -19
- package/tasks/clean/task.js +7 -7
- package/tasks/data/config.js +34 -34
- package/tasks/data/data-loader-js.js +14 -14
- package/tasks/data/data-loader-json.js +5 -5
- package/tasks/data/get-data.js +96 -96
- package/tasks/env/config.js +26 -23
- package/tasks/env/get-env.js +113 -81
- package/tasks/fonts/config.js +24 -24
- package/tasks/fonts/task.js +47 -47
- package/tasks/global/config.js +7 -7
- package/tasks/html/config.js +42 -42
- package/tasks/html/task.js +91 -91
- package/tasks/icons/config.js +47 -47
- package/tasks/icons/preprocess-config.js +60 -60
- package/tasks/icons/task.js +56 -56
- package/tasks/images/config.js +27 -27
- package/tasks/images/task.js +46 -46
- package/tasks/javascripts/config.js +69 -69
- package/tasks/javascripts/preprocess-config.js +109 -109
- package/tasks/javascripts/task.js +86 -86
- package/tasks/sitemap/config.js +48 -48
- package/tasks/sitemap/preprocess-config.js +18 -18
- package/tasks/sitemap/task.js +69 -69
- package/tasks/sizereport/config.js +23 -23
- package/tasks/sizereport/task.js +16 -16
- package/tasks/static/config.js +27 -27
- package/tasks/static/task.js +46 -46
- package/tasks/stylesheets/config.js +85 -85
- package/tasks/stylesheets/preprocess-config.js +41 -41
- package/tasks/stylesheets/task.js +73 -73
- package/tests/build/build.test.js +153 -153
- package/tests/camelize-file-name.test.js +11 -11
- package/tests/generate-gulp-tasks.test.js +78 -78
- package/tests/glob-helper.test.js +99 -99
- package/tests/merge.test.js +10 -10
- package/tests/preposition_nbsp.test.js +50 -50
- package/tests/run-preprocess.test.js +90 -90
- package/tests/sass-stringify.test.js +24 -24
- package/tests/sitemap.test.js +12 -12
- package/vendor/gulp-rolldown/index.js +151 -151
- package/vendor/gulp-rolldown/plugin-raw.js +17 -17
- package/vendor/gulp-rolldown/plugin-virtual-entry.js +30 -30
- package/vendor/gulp-sass/CHANGELOG.md +168 -168
- package/vendor/gulp-sass/LICENSE +20 -20
- package/vendor/gulp-sass/README.md +187 -187
- package/vendor/gulp-sass/index.js +208 -208
- package/vendor/gulp-sass/package.json +61 -61
- package/vendor/gulp-sass/sass-stringify.js +32 -32
- package/vendor/gulp-twig/LICENSE +20 -20
- package/vendor/gulp-twig/README.md +167 -167
- package/vendor/gulp-twig/index.js +138 -138
- package/vendor/gulp-twig/package.json +44 -44
package/lib/globs-helper.js
CHANGED
|
@@ -1,243 +1,243 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import flatten from 'lodash/flatten.js';
|
|
3
|
-
import map from 'lodash/map.js';
|
|
4
|
-
import filter from 'lodash/filter.js';
|
|
5
|
-
|
|
6
|
-
const REGEX_DOT_PREFIX = /^\.+/;
|
|
7
|
-
const REGEX_WINDOWS_BACKSLASH = /\\/g;
|
|
8
|
-
|
|
9
|
-
class GlobObject {
|
|
10
|
-
constructor() {
|
|
11
|
-
this.hadEmptyPaths = false;
|
|
12
|
-
this.isIgnore = false;
|
|
13
|
-
this.isAllFiles = false;
|
|
14
|
-
this.hasExtensions = false;
|
|
15
|
-
this.extensions = [];
|
|
16
|
-
this.pathsArr = [];
|
|
17
|
-
this.pathsArrRaw = [];
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
paths(paths) {
|
|
21
|
-
const pathsArr = Array.isArray(paths) ? paths : typeof paths === 'string' ? [paths] : [];
|
|
22
|
-
|
|
23
|
-
if (pathsArr.length) {
|
|
24
|
-
if (this.pathsArr.length) {
|
|
25
|
-
this.map((basePath) => {
|
|
26
|
-
return pathsArr.map((subPath) => {
|
|
27
|
-
// If subpath starts with specia character "!" then prepend that to the begining of full paths
|
|
28
|
-
const negativePath = subPath[0] === '!' ? '!' : '';
|
|
29
|
-
const subPathNormalized = negativePath ? subPath.substr(1) : subPath;
|
|
30
|
-
|
|
31
|
-
return negativePath + path.join(basePath, subPathNormalized);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
this.mapRaw((basePath) => {
|
|
36
|
-
return pathsArr.map((subPath) => {
|
|
37
|
-
// If subpath starts with specia character "!" then prepend that to the begining of full paths
|
|
38
|
-
const negativePath = subPath[0] === '!' ? '!' : '';
|
|
39
|
-
const subPathNormalized = negativePath ? subPath.substr(1) : subPath;
|
|
40
|
-
|
|
41
|
-
if (negativePath) {
|
|
42
|
-
this.isIgnore = true;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return negativePath + path.join(basePath, subPathNormalized);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
} else {
|
|
49
|
-
this.pathsArr = pathsArr;
|
|
50
|
-
this.pathsArrRaw = pathsArr;
|
|
51
|
-
}
|
|
52
|
-
} else {
|
|
53
|
-
this.hadEmptyPaths = true;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return this;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Adds extensions to the paths
|
|
61
|
-
*
|
|
62
|
-
* @param {string|array} extensions An extension or list of extensions
|
|
63
|
-
* @returns {object} GlobObject
|
|
64
|
-
*/
|
|
65
|
-
filesWithExtensions(extensions) {
|
|
66
|
-
const extensionsArr = typeof extensions === 'string' ? [extensions] : extensions;
|
|
67
|
-
|
|
68
|
-
if (extensionsArr && extensionsArr.length) {
|
|
69
|
-
let extensionString = '';
|
|
70
|
-
|
|
71
|
-
// Remove dot from the extension name
|
|
72
|
-
let extensionsArrNormalized = map(extensionsArr, (extension) => extension.replace(REGEX_DOT_PREFIX, ''));
|
|
73
|
-
|
|
74
|
-
if (extensionsArrNormalized.length > 1) {
|
|
75
|
-
extensionString = `/**/*.{${extensionsArrNormalized.join(',')}}`;
|
|
76
|
-
} else {
|
|
77
|
-
extensionString = `/**/*.${extensionsArrNormalized}`;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
this.extensions = this.extensions.concat(extensionsArr);
|
|
81
|
-
this.hasExtensions = !!this.extensions.length > 0;
|
|
82
|
-
return this.map((path) => `${path}${extensionString}`);
|
|
83
|
-
} else {
|
|
84
|
-
return this;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Add a wildcard to select all files
|
|
90
|
-
*
|
|
91
|
-
* @returns {object} GlobObject
|
|
92
|
-
*/
|
|
93
|
-
allFiles() {
|
|
94
|
-
this.isAllFiles = true;
|
|
95
|
-
return this.map((path) => `${path}/**`);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Adds all paths to the ignore list
|
|
100
|
-
*
|
|
101
|
-
* @returns {object} GlobObject
|
|
102
|
-
*/
|
|
103
|
-
ignore() {
|
|
104
|
-
this.isIgnore = true;
|
|
105
|
-
return this.map((path) => `!${path}`);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Itterates through all paths
|
|
110
|
-
*
|
|
111
|
-
* @param {function} fn Itteratee function
|
|
112
|
-
* @returns {object} GlobObject
|
|
113
|
-
*/
|
|
114
|
-
map(fn) {
|
|
115
|
-
this.pathsArr = filter(flatten(map(this.pathsArr, fn)), (path) => !!path);
|
|
116
|
-
return this;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Itterates through all paths
|
|
121
|
-
*
|
|
122
|
-
* @param {function} fn Itteratee function
|
|
123
|
-
* @returns {object} GlobObject
|
|
124
|
-
*/
|
|
125
|
-
mapRaw(fn) {
|
|
126
|
-
this.pathsArrRaw = filter(flatten(map(this.pathsArrRaw, fn)), (path) => !!path);
|
|
127
|
-
return this;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Converts paths to an array of normalized glob paths
|
|
132
|
-
*
|
|
133
|
-
* @returns {array} Array of glob paths
|
|
134
|
-
*/
|
|
135
|
-
toArray() {
|
|
136
|
-
if (this.hadEmptyPaths && this.isIgnore) {
|
|
137
|
-
// Since we exclude files / paths, don't return anything if path list was empty
|
|
138
|
-
return [];
|
|
139
|
-
} else {
|
|
140
|
-
return map(this.pathsArr, (path) => {
|
|
141
|
-
return path.replace(REGEX_WINDOWS_BACKSLASH, '/');
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Converts paths to an array of normalized glob paths
|
|
148
|
-
*
|
|
149
|
-
* @returns {array} Array of glob paths
|
|
150
|
-
*/
|
|
151
|
-
toArrayRaw() {
|
|
152
|
-
if (this.hadEmptyPaths && this.isIgnore) {
|
|
153
|
-
// Since we exclude files / paths, don't return anything if path list was empty
|
|
154
|
-
return [];
|
|
155
|
-
} else {
|
|
156
|
-
return map(this.pathsArrRaw, (path) => {
|
|
157
|
-
return path.replace(REGEX_WINDOWS_BACKSLASH, '/');
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Alias for toArray
|
|
164
|
-
*
|
|
165
|
-
* @returns {array} Array of glob paths
|
|
166
|
-
*/
|
|
167
|
-
generate(forChokidar = false) {
|
|
168
|
-
if (forChokidar) {
|
|
169
|
-
const paths = this.toArrayRaw().map((path) => (this.isAllFiles || this.hasExtensions ? path + '/.' : path));
|
|
170
|
-
|
|
171
|
-
if (this.hadEmptyPaths && this.isIgnore) {
|
|
172
|
-
return {
|
|
173
|
-
paths: [],
|
|
174
|
-
ignore: [],
|
|
175
|
-
};
|
|
176
|
-
} else if (this.isIgnore) {
|
|
177
|
-
return {
|
|
178
|
-
paths: paths,
|
|
179
|
-
ignore: chokidarFilterIgnorePaths(this.toArrayRaw()),
|
|
180
|
-
};
|
|
181
|
-
} else if (this.hasExtensions) {
|
|
182
|
-
return {
|
|
183
|
-
paths: paths,
|
|
184
|
-
ignore: [chokidarFilterOnlyExtensions(this.extensions)],
|
|
185
|
-
};
|
|
186
|
-
} else {
|
|
187
|
-
return {
|
|
188
|
-
paths: paths,
|
|
189
|
-
ignore: [],
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
} else {
|
|
193
|
-
return this.toArray();
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
function paths(paths) {
|
|
199
|
-
return new GlobObject().paths(paths);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
function generate(...globs) {
|
|
203
|
-
const isLastArgBoolean = typeof globs[globs.length - 1] === 'boolean';
|
|
204
|
-
const forChokidar = isLastArgBoolean ? globs.pop() : false;
|
|
205
|
-
|
|
206
|
-
if (forChokidar) {
|
|
207
|
-
const results = map(flatten(globs), (glob) => glob.generate(true));
|
|
208
|
-
|
|
209
|
-
return {
|
|
210
|
-
paths: flatten(results.map((result) => result.paths)),
|
|
211
|
-
ignore: flatten(results.map((result) => result.ignore)),
|
|
212
|
-
};
|
|
213
|
-
} else {
|
|
214
|
-
return flatten(map(flatten(globs), (glob) => glob.generate(false)));
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Create chokidar filter function to only allow certain extensions
|
|
220
|
-
* @param {array} extensions
|
|
221
|
-
* @returns {function}
|
|
222
|
-
*/
|
|
223
|
-
function chokidarFilterOnlyExtensions(extensions) {
|
|
224
|
-
return function (path, _stats) {
|
|
225
|
-
return !extensions.some((extension) => path.endsWith(`.${extension}`));
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* Create chokidar filter function to ignore certain paths
|
|
231
|
-
* @param {array} ignorePaths
|
|
232
|
-
* @returns {function}
|
|
233
|
-
*/
|
|
234
|
-
function chokidarFilterIgnorePaths(ignorePaths) {
|
|
235
|
-
return function (path, _stats) {
|
|
236
|
-
return ignorePaths.some((ignorePath) => path.startsWith(ignorePath));
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
export default {
|
|
241
|
-
generate,
|
|
242
|
-
paths,
|
|
243
|
-
};
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import flatten from 'lodash/flatten.js';
|
|
3
|
+
import map from 'lodash/map.js';
|
|
4
|
+
import filter from 'lodash/filter.js';
|
|
5
|
+
|
|
6
|
+
const REGEX_DOT_PREFIX = /^\.+/;
|
|
7
|
+
const REGEX_WINDOWS_BACKSLASH = /\\/g;
|
|
8
|
+
|
|
9
|
+
class GlobObject {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.hadEmptyPaths = false;
|
|
12
|
+
this.isIgnore = false;
|
|
13
|
+
this.isAllFiles = false;
|
|
14
|
+
this.hasExtensions = false;
|
|
15
|
+
this.extensions = [];
|
|
16
|
+
this.pathsArr = [];
|
|
17
|
+
this.pathsArrRaw = [];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
paths(paths) {
|
|
21
|
+
const pathsArr = Array.isArray(paths) ? paths : typeof paths === 'string' ? [paths] : [];
|
|
22
|
+
|
|
23
|
+
if (pathsArr.length) {
|
|
24
|
+
if (this.pathsArr.length) {
|
|
25
|
+
this.map((basePath) => {
|
|
26
|
+
return pathsArr.map((subPath) => {
|
|
27
|
+
// If subpath starts with specia character "!" then prepend that to the begining of full paths
|
|
28
|
+
const negativePath = subPath[0] === '!' ? '!' : '';
|
|
29
|
+
const subPathNormalized = negativePath ? subPath.substr(1) : subPath;
|
|
30
|
+
|
|
31
|
+
return negativePath + path.join(basePath, subPathNormalized);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
this.mapRaw((basePath) => {
|
|
36
|
+
return pathsArr.map((subPath) => {
|
|
37
|
+
// If subpath starts with specia character "!" then prepend that to the begining of full paths
|
|
38
|
+
const negativePath = subPath[0] === '!' ? '!' : '';
|
|
39
|
+
const subPathNormalized = negativePath ? subPath.substr(1) : subPath;
|
|
40
|
+
|
|
41
|
+
if (negativePath) {
|
|
42
|
+
this.isIgnore = true;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return negativePath + path.join(basePath, subPathNormalized);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
} else {
|
|
49
|
+
this.pathsArr = pathsArr;
|
|
50
|
+
this.pathsArrRaw = pathsArr;
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
this.hadEmptyPaths = true;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Adds extensions to the paths
|
|
61
|
+
*
|
|
62
|
+
* @param {string|array} extensions An extension or list of extensions
|
|
63
|
+
* @returns {object} GlobObject
|
|
64
|
+
*/
|
|
65
|
+
filesWithExtensions(extensions) {
|
|
66
|
+
const extensionsArr = typeof extensions === 'string' ? [extensions] : extensions;
|
|
67
|
+
|
|
68
|
+
if (extensionsArr && extensionsArr.length) {
|
|
69
|
+
let extensionString = '';
|
|
70
|
+
|
|
71
|
+
// Remove dot from the extension name
|
|
72
|
+
let extensionsArrNormalized = map(extensionsArr, (extension) => extension.replace(REGEX_DOT_PREFIX, ''));
|
|
73
|
+
|
|
74
|
+
if (extensionsArrNormalized.length > 1) {
|
|
75
|
+
extensionString = `/**/*.{${extensionsArrNormalized.join(',')}}`;
|
|
76
|
+
} else {
|
|
77
|
+
extensionString = `/**/*.${extensionsArrNormalized}`;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
this.extensions = this.extensions.concat(extensionsArr);
|
|
81
|
+
this.hasExtensions = !!this.extensions.length > 0;
|
|
82
|
+
return this.map((path) => `${path}${extensionString}`);
|
|
83
|
+
} else {
|
|
84
|
+
return this;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Add a wildcard to select all files
|
|
90
|
+
*
|
|
91
|
+
* @returns {object} GlobObject
|
|
92
|
+
*/
|
|
93
|
+
allFiles() {
|
|
94
|
+
this.isAllFiles = true;
|
|
95
|
+
return this.map((path) => `${path}/**`);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Adds all paths to the ignore list
|
|
100
|
+
*
|
|
101
|
+
* @returns {object} GlobObject
|
|
102
|
+
*/
|
|
103
|
+
ignore() {
|
|
104
|
+
this.isIgnore = true;
|
|
105
|
+
return this.map((path) => `!${path}`);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Itterates through all paths
|
|
110
|
+
*
|
|
111
|
+
* @param {function} fn Itteratee function
|
|
112
|
+
* @returns {object} GlobObject
|
|
113
|
+
*/
|
|
114
|
+
map(fn) {
|
|
115
|
+
this.pathsArr = filter(flatten(map(this.pathsArr, fn)), (path) => !!path);
|
|
116
|
+
return this;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Itterates through all paths
|
|
121
|
+
*
|
|
122
|
+
* @param {function} fn Itteratee function
|
|
123
|
+
* @returns {object} GlobObject
|
|
124
|
+
*/
|
|
125
|
+
mapRaw(fn) {
|
|
126
|
+
this.pathsArrRaw = filter(flatten(map(this.pathsArrRaw, fn)), (path) => !!path);
|
|
127
|
+
return this;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Converts paths to an array of normalized glob paths
|
|
132
|
+
*
|
|
133
|
+
* @returns {array} Array of glob paths
|
|
134
|
+
*/
|
|
135
|
+
toArray() {
|
|
136
|
+
if (this.hadEmptyPaths && this.isIgnore) {
|
|
137
|
+
// Since we exclude files / paths, don't return anything if path list was empty
|
|
138
|
+
return [];
|
|
139
|
+
} else {
|
|
140
|
+
return map(this.pathsArr, (path) => {
|
|
141
|
+
return path.replace(REGEX_WINDOWS_BACKSLASH, '/');
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Converts paths to an array of normalized glob paths
|
|
148
|
+
*
|
|
149
|
+
* @returns {array} Array of glob paths
|
|
150
|
+
*/
|
|
151
|
+
toArrayRaw() {
|
|
152
|
+
if (this.hadEmptyPaths && this.isIgnore) {
|
|
153
|
+
// Since we exclude files / paths, don't return anything if path list was empty
|
|
154
|
+
return [];
|
|
155
|
+
} else {
|
|
156
|
+
return map(this.pathsArrRaw, (path) => {
|
|
157
|
+
return path.replace(REGEX_WINDOWS_BACKSLASH, '/');
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Alias for toArray
|
|
164
|
+
*
|
|
165
|
+
* @returns {array} Array of glob paths
|
|
166
|
+
*/
|
|
167
|
+
generate(forChokidar = false) {
|
|
168
|
+
if (forChokidar) {
|
|
169
|
+
const paths = this.toArrayRaw().map((path) => (this.isAllFiles || this.hasExtensions ? path + '/.' : path));
|
|
170
|
+
|
|
171
|
+
if (this.hadEmptyPaths && this.isIgnore) {
|
|
172
|
+
return {
|
|
173
|
+
paths: [],
|
|
174
|
+
ignore: [],
|
|
175
|
+
};
|
|
176
|
+
} else if (this.isIgnore) {
|
|
177
|
+
return {
|
|
178
|
+
paths: paths,
|
|
179
|
+
ignore: chokidarFilterIgnorePaths(this.toArrayRaw()),
|
|
180
|
+
};
|
|
181
|
+
} else if (this.hasExtensions) {
|
|
182
|
+
return {
|
|
183
|
+
paths: paths,
|
|
184
|
+
ignore: [chokidarFilterOnlyExtensions(this.extensions)],
|
|
185
|
+
};
|
|
186
|
+
} else {
|
|
187
|
+
return {
|
|
188
|
+
paths: paths,
|
|
189
|
+
ignore: [],
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
} else {
|
|
193
|
+
return this.toArray();
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function paths(paths) {
|
|
199
|
+
return new GlobObject().paths(paths);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function generate(...globs) {
|
|
203
|
+
const isLastArgBoolean = typeof globs[globs.length - 1] === 'boolean';
|
|
204
|
+
const forChokidar = isLastArgBoolean ? globs.pop() : false;
|
|
205
|
+
|
|
206
|
+
if (forChokidar) {
|
|
207
|
+
const results = map(flatten(globs), (glob) => glob.generate(true));
|
|
208
|
+
|
|
209
|
+
return {
|
|
210
|
+
paths: flatten(results.map((result) => result.paths)),
|
|
211
|
+
ignore: flatten(results.map((result) => result.ignore)),
|
|
212
|
+
};
|
|
213
|
+
} else {
|
|
214
|
+
return flatten(map(flatten(globs), (glob) => glob.generate(false)));
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Create chokidar filter function to only allow certain extensions
|
|
220
|
+
* @param {array} extensions
|
|
221
|
+
* @returns {function}
|
|
222
|
+
*/
|
|
223
|
+
function chokidarFilterOnlyExtensions(extensions) {
|
|
224
|
+
return function (path, _stats) {
|
|
225
|
+
return !extensions.some((extension) => path.endsWith(`.${extension}`));
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Create chokidar filter function to ignore certain paths
|
|
231
|
+
* @param {array} ignorePaths
|
|
232
|
+
* @returns {function}
|
|
233
|
+
*/
|
|
234
|
+
function chokidarFilterIgnorePaths(ignorePaths) {
|
|
235
|
+
return function (path, _stats) {
|
|
236
|
+
return ignorePaths.some((ignorePath) => path.startsWith(ignorePath));
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export default {
|
|
241
|
+
generate,
|
|
242
|
+
paths,
|
|
243
|
+
};
|
package/lib/gulp/dynamic-task.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Similar to parallel() and serial() but instead of getting tasks immediatelly
|
|
3
|
-
* it's executed after config has been loaded
|
|
4
|
-
*/
|
|
5
|
-
export default function dynamicTask (fn) {
|
|
6
|
-
fn.dynamicTasks = true;
|
|
7
|
-
return fn;
|
|
8
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Similar to parallel() and serial() but instead of getting tasks immediatelly
|
|
3
|
+
* it's executed after config has been loaded
|
|
4
|
+
*/
|
|
5
|
+
export default function dynamicTask (fn) {
|
|
6
|
+
fn.dynamicTasks = true;
|
|
7
|
+
return fn;
|
|
8
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Similar to parallel() and serial() but instead of getting tasks immediatelly
|
|
3
|
-
* it's executed after config has been loaded
|
|
4
|
-
*/
|
|
5
|
-
export default function resolveDynamicTask (fn) {
|
|
6
|
-
if (fn.dynamicTasks) {
|
|
7
|
-
return fn();
|
|
8
|
-
} else {
|
|
9
|
-
return fn;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Similar to parallel() and serial() but instead of getting tasks immediatelly
|
|
3
|
+
* it's executed after config has been loaded
|
|
4
|
+
*/
|
|
5
|
+
export default function resolveDynamicTask (fn) {
|
|
6
|
+
if (fn.dynamicTasks) {
|
|
7
|
+
return fn();
|
|
8
|
+
} else {
|
|
9
|
+
return fn;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import plumber from 'gulp-plumber';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Gulp task pipe function which handles errors
|
|
5
|
-
*/
|
|
6
|
-
export default function taskBeforeDest () {
|
|
7
|
-
return plumber.stop();
|
|
8
|
-
}
|
|
1
|
+
import plumber from 'gulp-plumber';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Gulp task pipe function which handles errors
|
|
5
|
+
*/
|
|
6
|
+
export default function taskBeforeDest () {
|
|
7
|
+
return plumber.stop();
|
|
8
|
+
}
|
package/lib/gulp/task-end.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import gulpif from 'gulp-if';
|
|
2
|
-
import { getTaskConfig } from '../get-config.js';
|
|
3
|
-
import browserSync from 'browser-sync';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Gulp task pipe function which handles browsersync reloading
|
|
7
|
-
*/
|
|
8
|
-
export default function taskEnd () {
|
|
9
|
-
return gulpif(!!getTaskConfig('browserSync'), browserSync.stream());
|
|
10
|
-
};
|
|
1
|
+
import gulpif from 'gulp-if';
|
|
2
|
+
import { getTaskConfig } from '../get-config.js';
|
|
3
|
+
import browserSync from 'browser-sync';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Gulp task pipe function which handles browsersync reloading
|
|
7
|
+
*/
|
|
8
|
+
export default function taskEnd () {
|
|
9
|
+
return gulpif(!!getTaskConfig('browserSync'), browserSync.stream());
|
|
10
|
+
};
|
package/lib/gulp/task-start.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import plumber from 'gulp-plumber';
|
|
2
|
-
import logError from '../log-error.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Gulp task pipe function which handles errors
|
|
6
|
-
*/
|
|
7
|
-
export default function taskStart () {
|
|
8
|
-
return plumber(function (error) {
|
|
9
|
-
// Fail whole gulp process if in production mode
|
|
10
|
-
logError.call(this, error, global.production);
|
|
11
|
-
});
|
|
12
|
-
}
|
|
1
|
+
import plumber from 'gulp-plumber';
|
|
2
|
+
import logError from '../log-error.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Gulp task pipe function which handles errors
|
|
6
|
+
*/
|
|
7
|
+
export default function taskStart () {
|
|
8
|
+
return plumber(function (error) {
|
|
9
|
+
// Fail whole gulp process if in production mode
|
|
10
|
+
logError.call(this, error, global.production);
|
|
11
|
+
});
|
|
12
|
+
}
|