@videinfra/static-website-builder 2.0.0-beta.2 → 2.0.0-beta.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 -0
- package/README.md +2 -2
- package/bin/builder.js +17 -11
- package/eslint.config.js +39 -0
- package/gulpfile.js +63 -0
- package/init/default/config/config.js +18 -15
- package/init/default/src/html/data/global.js +1 -1
- package/init/default/src/javascripts/_entries.js +1 -1
- package/init/index.js +44 -37
- package/init/test/config/config.js +20 -16
- package/init/test/src/html/data/global.js +1 -1
- package/lib/camelize-file-name.js +1 -1
- package/lib/generate-gulp-tasks.js +12 -10
- package/lib/get-config.js +99 -52
- package/lib/get-file-names.js +3 -3
- package/lib/get-path.js +15 -22
- package/lib/globs-helper.js +22 -47
- package/lib/gulp/dynamic-task.js +1 -1
- package/lib/gulp/resolve-dynamic-task.js +1 -1
- package/lib/gulp/task-before-dest.js +2 -2
- package/lib/gulp/task-end.js +5 -5
- package/lib/gulp/task-start.js +3 -3
- package/lib/gulp/task-watch.js +10 -10
- package/lib/init/copy-folder.js +4 -4
- package/lib/init/folder-exists.js +2 -2
- package/lib/init/get-folder-list.js +3 -3
- package/lib/init/merge-package.js +8 -8
- package/lib/init/read-package.js +2 -2
- package/lib/log-error.js +3 -3
- package/lib/merge.js +3 -3
- package/lib/run-preprocess.js +2 -2
- package/lib/task-order.js +7 -13
- package/package.json +6 -4
- package/plugins/example/preprocess-config.js +1 -1
- package/plugins/example/task.js +13 -13
- package/plugins/example.js +8 -6
- package/plugins/sass-engine/preprocess-config.js +15 -19
- package/plugins/sass.js +5 -3
- package/plugins/twig/lodash-filters/filters.js +12 -10
- package/plugins/twig/lodash-filters.js +3 -3
- package/plugins/twig/symfony-filters/filters.js +18 -14
- package/plugins/twig/symfony-filters/preposition_nbsp.js +1 -1
- package/plugins/twig/symfony-filters.js +6 -6
- package/plugins/twig/symfony-functions/functions.js +2 -2
- package/plugins/twig/symfony-functions.js +6 -6
- package/plugins/twig-engine/preprocess-config.js +8 -8
- package/plugins/twig.js +11 -6
- package/tasks/browser-sync/config.js +9 -6
- package/tasks/browser-sync/preprocess-config.js +5 -7
- package/tasks/browser-sync/task.js +5 -5
- package/tasks/clean/config.js +8 -5
- package/tasks/clean/preprocess-config.js +5 -5
- package/tasks/clean/task.js +5 -5
- package/tasks/data/config.js +11 -13
- package/tasks/data/data-loader-js.js +11 -2
- package/tasks/data/data-loader-json.js +3 -3
- package/tasks/data/get-data.js +55 -52
- package/tasks/env/config.js +2 -2
- package/tasks/env/get-env.js +34 -19
- package/tasks/fonts/config.js +9 -10
- package/tasks/fonts/task.js +27 -27
- package/tasks/global/config.js +1 -1
- package/tasks/html/config.js +13 -15
- package/tasks/html/task.js +55 -54
- package/tasks/icons/config.js +17 -22
- package/tasks/icons/preprocess-config.js +4 -4
- package/tasks/icons/task.js +34 -35
- package/tasks/images/config.js +11 -14
- package/tasks/images/task.js +26 -26
- package/tasks/javascripts/config.js +12 -14
- package/tasks/javascripts/preprocess-config.js +45 -32
- package/tasks/javascripts/task.js +40 -43
- package/tasks/sitemap/config.js +12 -13
- package/tasks/sitemap/preprocess-config.js +2 -2
- package/tasks/sitemap/task.js +44 -38
- package/tasks/sizereport/config.js +5 -3
- package/tasks/sizereport/task.js +8 -8
- package/tasks/static/config.js +12 -15
- package/tasks/static/task.js +27 -28
- package/tasks/stylesheets/config.js +16 -19
- package/tasks/stylesheets/preprocess-config.js +5 -5
- package/tasks/stylesheets/task.js +28 -28
- package/tests/build/build.test.js +23 -22
- package/tests/camelize-file-name.test.js +1 -1
- package/tests/generate-gulp-tasks.test.js +11 -5
- package/tests/glob-helper.test.js +1 -1
- package/tests/merge.test.js +1 -1
- package/tests/preposition_nbsp.test.js +7 -6
- package/tests/run-preprocess.test.js +2 -1
- package/tests/sass-stringify.test.js +1 -1
- package/tests/sitemap.test.js +7 -6
- package/vendor/gulp-rolldown/index.js +24 -56
- package/vendor/gulp-rolldown/plugin-raw.js +17 -0
- package/vendor/gulp-rolldown/plugin-virtual-entry.js +30 -0
- package/vendor/gulp-sass/README.md +10 -19
- package/vendor/gulp-sass/index.js +129 -135
- package/vendor/gulp-sass/package.json +1 -0
- package/vendor/gulp-sass/sass-stringify.js +1 -1
- package/vendor/gulp-twig/index.js +32 -27
- package/vendor/gulp-twig/package.json +1 -0
- package/.eslintrc.js +0 -35
- package/gulpfile.js/index.js +0 -32
package/lib/get-config.js
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const runPreprocess = require('./run-preprocess');
|
|
5
|
-
const merge = require('./merge');
|
|
6
|
-
const logError = require('./log-error');
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const reduce = require('lodash/reduce');
|
|
13
|
-
const get = require('lodash/get');
|
|
5
|
+
import { getProjectPath } from './get-path.js';
|
|
6
|
+
import runPreprocess from './run-preprocess.js';
|
|
7
|
+
import merge from './merge.js';
|
|
8
|
+
import logError from './log-error.js';
|
|
14
9
|
|
|
10
|
+
import each from 'lodash/each.js';
|
|
11
|
+
import omit from 'lodash/omit.js';
|
|
12
|
+
import isPlainObject from 'lodash/isPlainObject.js';
|
|
13
|
+
import isArray from 'lodash/isArray.js';
|
|
14
|
+
import reduce from 'lodash/reduce.js';
|
|
15
|
+
import get from 'lodash/get.js';
|
|
16
|
+
import { Module } from 'node:module';
|
|
17
|
+
|
|
18
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
15
19
|
|
|
16
20
|
/**
|
|
17
21
|
* Returns builder and project specific task and plugin configurations combined
|
|
@@ -22,25 +26,33 @@ const get = require('lodash/get');
|
|
|
22
26
|
|
|
23
27
|
let taskConfig = null;
|
|
24
28
|
|
|
25
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Load and process config files
|
|
31
|
+
*
|
|
32
|
+
* @param {string} builderConfigFile Builder config file path
|
|
33
|
+
* @returns {object} Task configurations
|
|
34
|
+
*/
|
|
35
|
+
export async function getConfigAsync(builderConfigFile) {
|
|
26
36
|
if (!taskConfig) {
|
|
27
37
|
// Load all task configs
|
|
28
|
-
taskConfig = itterateConfig(loadConfig(), mergeConfigMode);
|
|
38
|
+
taskConfig = itterateConfig(await loadConfig(), mergeConfigMode);
|
|
29
39
|
|
|
30
40
|
// 1. First load project specific config.js
|
|
31
|
-
const projectConfigPath =
|
|
32
|
-
let
|
|
33
|
-
let
|
|
41
|
+
const projectConfigPath = getProjectPath(builderConfigFile);
|
|
42
|
+
let projectTaskConfig = {};
|
|
43
|
+
let hasProjectConfigFile = true;
|
|
34
44
|
|
|
35
45
|
try {
|
|
36
46
|
fs.accessSync(projectConfigPath);
|
|
37
47
|
} catch (err) {
|
|
38
|
-
logError({
|
|
48
|
+
logError({ plugin: 'static-website-builder', message: `Couldn't find configuration file "${projectConfigPath}"` });
|
|
39
49
|
hasProjectConfigFile = false;
|
|
40
50
|
}
|
|
41
51
|
|
|
42
52
|
if (hasProjectConfigFile) {
|
|
43
|
-
|
|
53
|
+
await import(projectConfigPath).then((config) => {
|
|
54
|
+
projectTaskConfig = itterateConfig(config, mergeConfigMode);
|
|
55
|
+
});
|
|
44
56
|
}
|
|
45
57
|
|
|
46
58
|
// 2. Marge plugins into the config, each plugin is just a config
|
|
@@ -64,7 +76,20 @@ function getConfig (builderConfigFile) {
|
|
|
64
76
|
}
|
|
65
77
|
|
|
66
78
|
return taskConfig;
|
|
67
|
-
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Returns loaded task config
|
|
83
|
+
*
|
|
84
|
+
* @returns {object} Task configurations
|
|
85
|
+
*/
|
|
86
|
+
export function getConfig() {
|
|
87
|
+
if (!taskConfig) {
|
|
88
|
+
throw new Error('Task config not loaded yet');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return taskConfig;
|
|
92
|
+
}
|
|
68
93
|
|
|
69
94
|
/**
|
|
70
95
|
* Returns task sub-config by path
|
|
@@ -72,7 +97,7 @@ function getConfig (builderConfigFile) {
|
|
|
72
97
|
* @param {...string} path Path to the sub-config
|
|
73
98
|
* @returns {any} Task sub-config
|
|
74
99
|
*/
|
|
75
|
-
function getTaskConfig
|
|
100
|
+
export function getTaskConfig(...path) {
|
|
76
101
|
return get(getConfig(), path, null);
|
|
77
102
|
}
|
|
78
103
|
|
|
@@ -84,21 +109,43 @@ function getTaskConfig (...path) {
|
|
|
84
109
|
* @param {*} fn
|
|
85
110
|
* @protected
|
|
86
111
|
*/
|
|
87
|
-
function itterateConfig
|
|
112
|
+
function itterateConfig(config, fn) {
|
|
88
113
|
if (config === false) return false;
|
|
89
114
|
const base = isPlainObject(config) ? {} : [];
|
|
90
115
|
|
|
91
|
-
return reduce(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
116
|
+
return reduce(
|
|
117
|
+
config,
|
|
118
|
+
(object, value, key) => {
|
|
119
|
+
// Detect ES modules and extract 'default' and other properties
|
|
120
|
+
if (value && Object.prototype.toString.call(value) === '[object Module]') {
|
|
121
|
+
const module = value;
|
|
122
|
+
|
|
123
|
+
if ('default' in module) {
|
|
124
|
+
value = module.default;
|
|
125
|
+
value.default = module.default;
|
|
126
|
+
} else {
|
|
127
|
+
value = {};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
for (let key in module) {
|
|
131
|
+
if (key !== 'default') {
|
|
132
|
+
value[key] = module[key];
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (isPlainObject(value)) {
|
|
138
|
+
object[key] = itterateConfig(fn(value), fn);
|
|
139
|
+
} else if (isArray(value)) {
|
|
140
|
+
object[key] = itterateConfig(value, fn);
|
|
141
|
+
} else {
|
|
142
|
+
object[key] = value;
|
|
143
|
+
}
|
|
99
144
|
|
|
100
|
-
|
|
101
|
-
|
|
145
|
+
return object;
|
|
146
|
+
},
|
|
147
|
+
base,
|
|
148
|
+
);
|
|
102
149
|
}
|
|
103
150
|
|
|
104
151
|
/**
|
|
@@ -109,7 +156,7 @@ function itterateConfig (config, fn) {
|
|
|
109
156
|
* @returns {object} Config
|
|
110
157
|
* @protected
|
|
111
158
|
*/
|
|
112
|
-
function mergeConfigMode
|
|
159
|
+
function mergeConfigMode(config) {
|
|
113
160
|
if ('production' in config || 'development' in config) {
|
|
114
161
|
const mode = global.production ? 'production' : 'development';
|
|
115
162
|
const value = merge(config, config[mode]);
|
|
@@ -130,28 +177,28 @@ function mergeConfigMode (config) {
|
|
|
130
177
|
* @returns {object} Configuration
|
|
131
178
|
* @protected
|
|
132
179
|
*/
|
|
133
|
-
function loadConfig
|
|
180
|
+
async function loadConfig() {
|
|
134
181
|
const taskFolder = path.resolve(__dirname, '../tasks');
|
|
135
182
|
let taskConfig = {};
|
|
136
183
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
184
|
+
await Promise.all(
|
|
185
|
+
fs.readdirSync(taskFolder).map((folderName) => {
|
|
186
|
+
// Ignore task folders which start with underscore
|
|
187
|
+
if (folderName[0] !== '_') {
|
|
188
|
+
const configFileName = path.resolve(taskFolder, folderName, 'config.js');
|
|
189
|
+
|
|
190
|
+
try {
|
|
191
|
+
fs.accessSync(configFileName);
|
|
192
|
+
} catch (err) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return import(configFileName).then((config) => {
|
|
197
|
+
taskConfig = merge(taskConfig, config);
|
|
198
|
+
});
|
|
146
199
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
});
|
|
200
|
+
}),
|
|
201
|
+
);
|
|
151
202
|
|
|
152
203
|
return taskConfig;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
exports.getConfig = getConfig;
|
|
157
|
-
exports.getTaskConfig = getTaskConfig;
|
|
204
|
+
}
|
package/lib/get-file-names.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Returns list of filenames in folder recursively
|
|
@@ -8,7 +8,7 @@ const path = require('path');
|
|
|
8
8
|
* @param {string} [subFolder=''] Subfolder path
|
|
9
9
|
* @returns {array} List of filenames, relative to folder
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
export default function getFileNamesSync (folder, subFolder = '') {
|
|
12
12
|
let fileNames = []
|
|
13
13
|
|
|
14
14
|
fs.readdirSync(folder, { withFileTypes: true }).forEach(file => {
|
package/lib/get-path.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import nanomemoize from 'nano-memoize';
|
|
4
|
+
import { getConfig } from './get-config.js';
|
|
4
5
|
|
|
6
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* Returns builder and project specific path configurations merged
|
|
@@ -9,8 +11,8 @@ const getConfig = require('./get-config');
|
|
|
9
11
|
* @returns {object} Configuration
|
|
10
12
|
*/
|
|
11
13
|
|
|
12
|
-
const getPathConfig = nanomemoize(function () {
|
|
13
|
-
return getConfig
|
|
14
|
+
export const getPathConfig = nanomemoize.nanomemoize(function () {
|
|
15
|
+
return getConfig().paths;
|
|
14
16
|
});
|
|
15
17
|
|
|
16
18
|
/**
|
|
@@ -19,9 +21,9 @@ const getPathConfig = nanomemoize(function () {
|
|
|
19
21
|
* @param {...any} paths List of paths
|
|
20
22
|
* @returns {string} Path
|
|
21
23
|
*/
|
|
22
|
-
function getProjectPath
|
|
24
|
+
export function getProjectPath(...paths) {
|
|
23
25
|
return path.resolve(process.env.INIT_CWD || process.cwd(), ...paths);
|
|
24
|
-
}
|
|
26
|
+
}
|
|
25
27
|
|
|
26
28
|
/**
|
|
27
29
|
* Returns a path relative to the builder folder
|
|
@@ -29,9 +31,9 @@ function getProjectPath (...paths) {
|
|
|
29
31
|
* @param {...any} paths List of paths
|
|
30
32
|
* @returns {string} Path
|
|
31
33
|
*/
|
|
32
|
-
function getBuilderPath
|
|
34
|
+
export function getBuilderPath(...paths) {
|
|
33
35
|
return path.resolve(__dirname, '../', ...paths);
|
|
34
|
-
}
|
|
36
|
+
}
|
|
35
37
|
|
|
36
38
|
/**
|
|
37
39
|
* Returns task source path or paths
|
|
@@ -40,7 +42,7 @@ function getBuilderPath (...paths) {
|
|
|
40
42
|
* @param {...string} paths Additional sub paths
|
|
41
43
|
* @returns {string|array} Task source path or list of paths
|
|
42
44
|
*/
|
|
43
|
-
function getSourcePath
|
|
45
|
+
export function getSourcePath(name, ...paths) {
|
|
44
46
|
const pathConfig = getPathConfig();
|
|
45
47
|
const path = pathConfig[name].src;
|
|
46
48
|
|
|
@@ -60,7 +62,7 @@ function getSourcePath (name, ...paths) {
|
|
|
60
62
|
* @param {...string} paths Additional sub paths
|
|
61
63
|
* @returns {array} Task source paths
|
|
62
64
|
*/
|
|
63
|
-
function getSourcePaths
|
|
65
|
+
export function getSourcePaths(name, ...paths) {
|
|
64
66
|
const path = getSourcePath(name, ...paths);
|
|
65
67
|
|
|
66
68
|
if (typeof path === 'string') {
|
|
@@ -77,7 +79,7 @@ function getSourcePaths (name, ...paths) {
|
|
|
77
79
|
* @param {...string} paths Additional sub paths
|
|
78
80
|
* @returns {string} Task destination path
|
|
79
81
|
*/
|
|
80
|
-
function getDestPath
|
|
82
|
+
export function getDestPath(name, ...paths) {
|
|
81
83
|
const pathConfig = getPathConfig();
|
|
82
84
|
|
|
83
85
|
if (name) {
|
|
@@ -93,17 +95,8 @@ function getDestPath (name, ...paths) {
|
|
|
93
95
|
* @param {string} [name] Task name
|
|
94
96
|
* @returns {string} Task public path
|
|
95
97
|
*/
|
|
96
|
-
function getPublicPath
|
|
98
|
+
export function getPublicPath(name) {
|
|
97
99
|
const destFullPath = getDestPath(name);
|
|
98
100
|
const destPath = getDestPath();
|
|
99
101
|
return destFullPath.replace(destPath, '') + '/';
|
|
100
102
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
exports.getPathConfig = getPathConfig;
|
|
104
|
-
exports.getSourcePath = getSourcePath;
|
|
105
|
-
exports.getSourcePaths = getSourcePaths;
|
|
106
|
-
exports.getDestPath = getDestPath;
|
|
107
|
-
exports.getProjectPath = getProjectPath;
|
|
108
|
-
exports.getBuilderPath = getBuilderPath;
|
|
109
|
-
exports.getPublicPath = getPublicPath;
|
package/lib/globs-helper.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
5
|
|
|
6
6
|
const REGEX_DOT_PREFIX = /^\.+/;
|
|
7
7
|
const REGEX_WINDOWS_BACKSLASH = /\\/g;
|
|
@@ -18,45 +18,31 @@ class GlobObject {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
paths(paths) {
|
|
21
|
-
const pathsArr = Array.isArray(paths)
|
|
22
|
-
? paths
|
|
23
|
-
: typeof paths === "string"
|
|
24
|
-
? [paths]
|
|
25
|
-
: [];
|
|
21
|
+
const pathsArr = Array.isArray(paths) ? paths : typeof paths === 'string' ? [paths] : [];
|
|
26
22
|
|
|
27
23
|
if (pathsArr.length) {
|
|
28
24
|
if (this.pathsArr.length) {
|
|
29
25
|
this.map((basePath) => {
|
|
30
26
|
return pathsArr.map((subPath) => {
|
|
31
27
|
// If subpath starts with specia character "!" then prepend that to the begining of full paths
|
|
32
|
-
const negativePath = subPath[0] ===
|
|
33
|
-
const subPathNormalized = negativePath
|
|
34
|
-
? subPath.substr(1)
|
|
35
|
-
: subPath;
|
|
28
|
+
const negativePath = subPath[0] === '!' ? '!' : '';
|
|
29
|
+
const subPathNormalized = negativePath ? subPath.substr(1) : subPath;
|
|
36
30
|
|
|
37
|
-
return (
|
|
38
|
-
negativePath +
|
|
39
|
-
path.join(basePath, subPathNormalized)
|
|
40
|
-
);
|
|
31
|
+
return negativePath + path.join(basePath, subPathNormalized);
|
|
41
32
|
});
|
|
42
33
|
});
|
|
43
34
|
|
|
44
35
|
this.mapRaw((basePath) => {
|
|
45
36
|
return pathsArr.map((subPath) => {
|
|
46
37
|
// If subpath starts with specia character "!" then prepend that to the begining of full paths
|
|
47
|
-
const negativePath = subPath[0] ===
|
|
48
|
-
const subPathNormalized = negativePath
|
|
49
|
-
? subPath.substr(1)
|
|
50
|
-
: subPath;
|
|
38
|
+
const negativePath = subPath[0] === '!' ? '!' : '';
|
|
39
|
+
const subPathNormalized = negativePath ? subPath.substr(1) : subPath;
|
|
51
40
|
|
|
52
41
|
if (negativePath) {
|
|
53
42
|
this.isIgnore = true;
|
|
54
43
|
}
|
|
55
44
|
|
|
56
|
-
return (
|
|
57
|
-
negativePath +
|
|
58
|
-
path.join(basePath, subPathNormalized)
|
|
59
|
-
);
|
|
45
|
+
return negativePath + path.join(basePath, subPathNormalized);
|
|
60
46
|
});
|
|
61
47
|
});
|
|
62
48
|
} else {
|
|
@@ -77,19 +63,16 @@ class GlobObject {
|
|
|
77
63
|
* @returns {object} GlobObject
|
|
78
64
|
*/
|
|
79
65
|
filesWithExtensions(extensions) {
|
|
80
|
-
const extensionsArr =
|
|
81
|
-
typeof extensions === "string" ? [extensions] : extensions;
|
|
66
|
+
const extensionsArr = typeof extensions === 'string' ? [extensions] : extensions;
|
|
82
67
|
|
|
83
68
|
if (extensionsArr && extensionsArr.length) {
|
|
84
|
-
let extensionString =
|
|
69
|
+
let extensionString = '';
|
|
85
70
|
|
|
86
71
|
// Remove dot from the extension name
|
|
87
|
-
let extensionsArrNormalized = map(extensionsArr, (extension) =>
|
|
88
|
-
extension.replace(REGEX_DOT_PREFIX, ""),
|
|
89
|
-
);
|
|
72
|
+
let extensionsArrNormalized = map(extensionsArr, (extension) => extension.replace(REGEX_DOT_PREFIX, ''));
|
|
90
73
|
|
|
91
74
|
if (extensionsArrNormalized.length > 1) {
|
|
92
|
-
extensionString = `/**/*.{${extensionsArrNormalized.join(
|
|
75
|
+
extensionString = `/**/*.{${extensionsArrNormalized.join(',')}}`;
|
|
93
76
|
} else {
|
|
94
77
|
extensionString = `/**/*.${extensionsArrNormalized}`;
|
|
95
78
|
}
|
|
@@ -129,10 +112,7 @@ class GlobObject {
|
|
|
129
112
|
* @returns {object} GlobObject
|
|
130
113
|
*/
|
|
131
114
|
map(fn) {
|
|
132
|
-
this.pathsArr = filter(
|
|
133
|
-
flatten(map(this.pathsArr, fn)),
|
|
134
|
-
(path) => !!path,
|
|
135
|
-
);
|
|
115
|
+
this.pathsArr = filter(flatten(map(this.pathsArr, fn)), (path) => !!path);
|
|
136
116
|
return this;
|
|
137
117
|
}
|
|
138
118
|
|
|
@@ -143,10 +123,7 @@ class GlobObject {
|
|
|
143
123
|
* @returns {object} GlobObject
|
|
144
124
|
*/
|
|
145
125
|
mapRaw(fn) {
|
|
146
|
-
this.pathsArrRaw = filter(
|
|
147
|
-
flatten(map(this.pathsArrRaw, fn)),
|
|
148
|
-
(path) => !!path,
|
|
149
|
-
);
|
|
126
|
+
this.pathsArrRaw = filter(flatten(map(this.pathsArrRaw, fn)), (path) => !!path);
|
|
150
127
|
return this;
|
|
151
128
|
}
|
|
152
129
|
|
|
@@ -161,7 +138,7 @@ class GlobObject {
|
|
|
161
138
|
return [];
|
|
162
139
|
} else {
|
|
163
140
|
return map(this.pathsArr, (path) => {
|
|
164
|
-
return path.replace(REGEX_WINDOWS_BACKSLASH,
|
|
141
|
+
return path.replace(REGEX_WINDOWS_BACKSLASH, '/');
|
|
165
142
|
});
|
|
166
143
|
}
|
|
167
144
|
}
|
|
@@ -177,7 +154,7 @@ class GlobObject {
|
|
|
177
154
|
return [];
|
|
178
155
|
} else {
|
|
179
156
|
return map(this.pathsArrRaw, (path) => {
|
|
180
|
-
return path.replace(REGEX_WINDOWS_BACKSLASH,
|
|
157
|
+
return path.replace(REGEX_WINDOWS_BACKSLASH, '/');
|
|
181
158
|
});
|
|
182
159
|
}
|
|
183
160
|
}
|
|
@@ -189,9 +166,7 @@ class GlobObject {
|
|
|
189
166
|
*/
|
|
190
167
|
generate(forChokidar = false) {
|
|
191
168
|
if (forChokidar) {
|
|
192
|
-
const paths = this.toArrayRaw().map((path) =>
|
|
193
|
-
this.isAllFiles || this.hasExtensions ? path + "/." : path,
|
|
194
|
-
);
|
|
169
|
+
const paths = this.toArrayRaw().map((path) => (this.isAllFiles || this.hasExtensions ? path + '/.' : path));
|
|
195
170
|
|
|
196
171
|
if (this.hadEmptyPaths && this.isIgnore) {
|
|
197
172
|
return {
|
|
@@ -225,7 +200,7 @@ function paths(paths) {
|
|
|
225
200
|
}
|
|
226
201
|
|
|
227
202
|
function generate(...globs) {
|
|
228
|
-
const isLastArgBoolean = typeof globs[globs.length - 1] ===
|
|
203
|
+
const isLastArgBoolean = typeof globs[globs.length - 1] === 'boolean';
|
|
229
204
|
const forChokidar = isLastArgBoolean ? globs.pop() : false;
|
|
230
205
|
|
|
231
206
|
if (forChokidar) {
|
|
@@ -262,7 +237,7 @@ function chokidarFilterIgnorePaths(ignorePaths) {
|
|
|
262
237
|
};
|
|
263
238
|
}
|
|
264
239
|
|
|
265
|
-
|
|
240
|
+
export default {
|
|
266
241
|
generate,
|
|
267
242
|
paths,
|
|
268
243
|
};
|
package/lib/gulp/dynamic-task.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Similar to parallel() and serial() but instead of getting tasks immediatelly
|
|
3
3
|
* it's executed after config has been loaded
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
export default function resolveDynamicTask (fn) {
|
|
6
6
|
if (fn.dynamicTasks) {
|
|
7
7
|
return fn();
|
|
8
8
|
} else {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import plumber from 'gulp-plumber';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Gulp task pipe function which handles errors
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
export default function taskBeforeDest () {
|
|
7
7
|
return plumber.stop();
|
|
8
8
|
}
|
package/lib/gulp/task-end.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import gulpif from 'gulp-if';
|
|
2
|
+
import { getTaskConfig } from '../get-config.js';
|
|
3
|
+
import browserSync from 'browser-sync';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Gulp task pipe function which handles browsersync reloading
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
return gulpif(!!
|
|
8
|
+
export default function taskEnd () {
|
|
9
|
+
return gulpif(!!getTaskConfig('browserSync'), browserSync.stream());
|
|
10
10
|
};
|
package/lib/gulp/task-start.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import plumber from 'gulp-plumber';
|
|
2
|
+
import logError from '../log-error.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Gulp task pipe function which handles errors
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
export default function taskStart () {
|
|
8
8
|
return plumber(function (error) {
|
|
9
9
|
// Fail whole gulp process if in production mode
|
|
10
10
|
logError.call(this, error, global.production);
|
package/lib/gulp/task-watch.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { parallel } from 'gulp';
|
|
2
|
+
import chokidar from 'chokidar';
|
|
3
|
+
import debounce from 'lodash/debounce.js';
|
|
4
|
+
import asyncDone from 'async-done';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Gulp task watch function using latest chokidar
|
|
8
8
|
* with better OSX support and file watching functionality
|
|
9
9
|
* than outdated gulp.watch
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
export default function taskWatch(globs, callback, isParallel = false) {
|
|
12
12
|
const parallelCallback = isParallel ? callback : parallel(callback);
|
|
13
13
|
const debouncedCallback = debounce(onChange, 120);
|
|
14
14
|
let running = false;
|
|
@@ -41,26 +41,26 @@ module.exports = function taskWatch(globs, callback, isParallel = false) {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
if (!globs.paths) {
|
|
44
|
-
throw new Error(
|
|
44
|
+
throw new Error('No paths provided for chokidar watch');
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
return chokidar
|
|
48
48
|
.watch(globs.paths, {
|
|
49
49
|
ignoreInitial: true,
|
|
50
50
|
})
|
|
51
|
-
.on(
|
|
51
|
+
.on('add', (path) => {
|
|
52
52
|
if (!isIgnoredPath(path)) {
|
|
53
53
|
debouncedCallback(path);
|
|
54
54
|
}
|
|
55
55
|
})
|
|
56
|
-
.on(
|
|
56
|
+
.on('change', (path) => {
|
|
57
57
|
if (!isIgnoredPath(path)) {
|
|
58
58
|
debouncedCallback(path);
|
|
59
59
|
}
|
|
60
60
|
})
|
|
61
|
-
.on(
|
|
61
|
+
.on('unlink', (path) => {
|
|
62
62
|
if (!isIgnoredPath(path)) {
|
|
63
63
|
debouncedCallback(path);
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
|
-
}
|
|
66
|
+
}
|
package/lib/init/copy-folder.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import fsPromise from 'fs/promises';
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
function copyFile(from, to, file) {
|
|
@@ -47,4 +47,4 @@ function copyFolder(from, to) {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
export default copyFolder;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import fsPromise from 'fs/promises';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
export default function getFolderList (folder) {
|
|
5
5
|
return fsPromise.readdir(folder).then((files) => {
|
|
6
6
|
return Promise.all(files.map((file) => {
|
|
7
7
|
return fsPromise.lstat(path.join(folder, file)).then((stats) => {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import readPackage from './read-package.js';
|
|
2
|
+
import merge from '../merge.js';
|
|
3
|
+
import fsPromise from 'fs/promises';
|
|
4
|
+
import isEqual from 'lodash/isEqual.js';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
return readPackage(fileName).then((
|
|
8
|
-
const newPackage = merge({},
|
|
6
|
+
export default function mergePackage (fileName, content) {
|
|
7
|
+
return readPackage(fileName).then((packageContent) => {
|
|
8
|
+
const newPackage = merge({}, packageContent, content);
|
|
9
9
|
|
|
10
10
|
// Write only if file has changed
|
|
11
|
-
if (!isEqual(
|
|
11
|
+
if (!isEqual(packageContent, newPackage)) {
|
|
12
12
|
return fsPromise.writeFile(fileName, JSON.stringify(newPackage, null, ' '));
|
|
13
13
|
} else {
|
|
14
14
|
return Promise.resolve();
|