@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/gulp/task-watch.js
CHANGED
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
import { parallel } from 'gulp';
|
|
2
|
-
import chokidar from 'chokidar';
|
|
3
|
-
import debounce from 'lodash/debounce.js';
|
|
4
|
-
import asyncDone from 'async-done';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Gulp task watch function using latest chokidar
|
|
8
|
-
* with better OSX support and file watching functionality
|
|
9
|
-
* than outdated gulp.watch
|
|
10
|
-
*/
|
|
11
|
-
export default function taskWatch(globs, callback, isParallel = false) {
|
|
12
|
-
const parallelCallback = isParallel ? callback : parallel(callback);
|
|
13
|
-
const debouncedCallback = debounce(onChange, 120);
|
|
14
|
-
let running = false;
|
|
15
|
-
let queued = false;
|
|
16
|
-
|
|
17
|
-
function onChange() {
|
|
18
|
-
if (running) {
|
|
19
|
-
queued = true;
|
|
20
|
-
} else {
|
|
21
|
-
running = true;
|
|
22
|
-
asyncDone(parallelCallback, runComplete);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
function runComplete(_err) {
|
|
26
|
-
running = false;
|
|
27
|
-
|
|
28
|
-
// If we have a run queued, start onChange again
|
|
29
|
-
if (queued) {
|
|
30
|
-
queued = false;
|
|
31
|
-
onChange();
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Re-check that file matches!
|
|
36
|
-
// This is needed because for ignore filter for extensions we allow filter to go through if there is no Stats object,
|
|
37
|
-
// otherwise `chokidar` will not emit `change` event for new filters and sub-folders.
|
|
38
|
-
// That's why we need to re-check here to make sure that file matches!
|
|
39
|
-
function isIgnoredPath(path) {
|
|
40
|
-
return globs.ignore.some((ignore) => ignore(path));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (!globs.paths) {
|
|
44
|
-
throw new Error('No paths provided for chokidar watch');
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return chokidar
|
|
48
|
-
.watch(globs.paths, {
|
|
49
|
-
ignoreInitial: true,
|
|
50
|
-
})
|
|
51
|
-
.on('add', (path) => {
|
|
52
|
-
if (!isIgnoredPath(path)) {
|
|
53
|
-
debouncedCallback(path);
|
|
54
|
-
}
|
|
55
|
-
})
|
|
56
|
-
.on('change', (path) => {
|
|
57
|
-
if (!isIgnoredPath(path)) {
|
|
58
|
-
debouncedCallback(path);
|
|
59
|
-
}
|
|
60
|
-
})
|
|
61
|
-
.on('unlink', (path) => {
|
|
62
|
-
if (!isIgnoredPath(path)) {
|
|
63
|
-
debouncedCallback(path);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
1
|
+
import { parallel } from 'gulp';
|
|
2
|
+
import chokidar from 'chokidar';
|
|
3
|
+
import debounce from 'lodash/debounce.js';
|
|
4
|
+
import asyncDone from 'async-done';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Gulp task watch function using latest chokidar
|
|
8
|
+
* with better OSX support and file watching functionality
|
|
9
|
+
* than outdated gulp.watch
|
|
10
|
+
*/
|
|
11
|
+
export default function taskWatch(globs, callback, isParallel = false) {
|
|
12
|
+
const parallelCallback = isParallel ? callback : parallel(callback);
|
|
13
|
+
const debouncedCallback = debounce(onChange, 120);
|
|
14
|
+
let running = false;
|
|
15
|
+
let queued = false;
|
|
16
|
+
|
|
17
|
+
function onChange() {
|
|
18
|
+
if (running) {
|
|
19
|
+
queued = true;
|
|
20
|
+
} else {
|
|
21
|
+
running = true;
|
|
22
|
+
asyncDone(parallelCallback, runComplete);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function runComplete(_err) {
|
|
26
|
+
running = false;
|
|
27
|
+
|
|
28
|
+
// If we have a run queued, start onChange again
|
|
29
|
+
if (queued) {
|
|
30
|
+
queued = false;
|
|
31
|
+
onChange();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Re-check that file matches!
|
|
36
|
+
// This is needed because for ignore filter for extensions we allow filter to go through if there is no Stats object,
|
|
37
|
+
// otherwise `chokidar` will not emit `change` event for new filters and sub-folders.
|
|
38
|
+
// That's why we need to re-check here to make sure that file matches!
|
|
39
|
+
function isIgnoredPath(path) {
|
|
40
|
+
return globs.ignore.some((ignore) => ignore(path));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (!globs.paths) {
|
|
44
|
+
throw new Error('No paths provided for chokidar watch');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return chokidar
|
|
48
|
+
.watch(globs.paths, {
|
|
49
|
+
ignoreInitial: true,
|
|
50
|
+
})
|
|
51
|
+
.on('add', (path) => {
|
|
52
|
+
if (!isIgnoredPath(path)) {
|
|
53
|
+
debouncedCallback(path);
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
.on('change', (path) => {
|
|
57
|
+
if (!isIgnoredPath(path)) {
|
|
58
|
+
debouncedCallback(path);
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
.on('unlink', (path) => {
|
|
62
|
+
if (!isIgnoredPath(path)) {
|
|
63
|
+
debouncedCallback(path);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
package/lib/init/copy-folder.js
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import fsPromise from 'fs/promises';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function copyFile(from, to, file) {
|
|
7
|
-
const fileName = path.join(from, file);
|
|
8
|
-
|
|
9
|
-
if (file !== 'package.json') {
|
|
10
|
-
return fsPromise.lstat(fileName).then((stats) => {
|
|
11
|
-
if (stats.isFile()) {
|
|
12
|
-
return fsPromise
|
|
13
|
-
.copyFile(fileName, path.join(to, file))
|
|
14
|
-
.catch((err) => {
|
|
15
|
-
throw err;
|
|
16
|
-
});
|
|
17
|
-
} else {
|
|
18
|
-
return copyFolder(fileName, path.join(to, file));
|
|
19
|
-
}
|
|
20
|
-
}, (err) => {
|
|
21
|
-
throw err;
|
|
22
|
-
});
|
|
23
|
-
} else {
|
|
24
|
-
return Promise.resolve();
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function copyFolderContents(from, to) {
|
|
29
|
-
return fsPromise.readdir(from).then((files) => {
|
|
30
|
-
return Promise.all(files.map((file) => copyFile(from, to, file)));
|
|
31
|
-
}, (err) => {
|
|
32
|
-
throw err;
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function copyFolder(from, to) {
|
|
37
|
-
try {
|
|
38
|
-
fs.accessSync(to);
|
|
39
|
-
return copyFolderContents(from, to);
|
|
40
|
-
} catch (err) {
|
|
41
|
-
return fsPromise.mkdir(to).then(() => {
|
|
42
|
-
return copyFolderContents(from, to);
|
|
43
|
-
}, (err) => {
|
|
44
|
-
throw err;
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
export default copyFolder;
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import fsPromise from 'fs/promises';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
function copyFile(from, to, file) {
|
|
7
|
+
const fileName = path.join(from, file);
|
|
8
|
+
|
|
9
|
+
if (file !== 'package.json') {
|
|
10
|
+
return fsPromise.lstat(fileName).then((stats) => {
|
|
11
|
+
if (stats.isFile()) {
|
|
12
|
+
return fsPromise
|
|
13
|
+
.copyFile(fileName, path.join(to, file))
|
|
14
|
+
.catch((err) => {
|
|
15
|
+
throw err;
|
|
16
|
+
});
|
|
17
|
+
} else {
|
|
18
|
+
return copyFolder(fileName, path.join(to, file));
|
|
19
|
+
}
|
|
20
|
+
}, (err) => {
|
|
21
|
+
throw err;
|
|
22
|
+
});
|
|
23
|
+
} else {
|
|
24
|
+
return Promise.resolve();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function copyFolderContents(from, to) {
|
|
29
|
+
return fsPromise.readdir(from).then((files) => {
|
|
30
|
+
return Promise.all(files.map((file) => copyFile(from, to, file)));
|
|
31
|
+
}, (err) => {
|
|
32
|
+
throw err;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function copyFolder(from, to) {
|
|
37
|
+
try {
|
|
38
|
+
fs.accessSync(to);
|
|
39
|
+
return copyFolderContents(from, to);
|
|
40
|
+
} catch (err) {
|
|
41
|
+
return fsPromise.mkdir(to).then(() => {
|
|
42
|
+
return copyFolderContents(from, to);
|
|
43
|
+
}, (err) => {
|
|
44
|
+
throw err;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
export default copyFolder;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
|
|
3
|
-
export default function folderExists (folder) {
|
|
4
|
-
try {
|
|
5
|
-
const stat = fs.lstatSync(folder);
|
|
6
|
-
return stat.isDirectory();
|
|
7
|
-
} catch (err) {
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
|
|
3
|
+
export default function folderExists (folder) {
|
|
4
|
+
try {
|
|
5
|
+
const stat = fs.lstatSync(folder);
|
|
6
|
+
return stat.isDirectory();
|
|
7
|
+
} catch (err) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import fsPromise from 'fs/promises';
|
|
3
|
-
|
|
4
|
-
export default function getFolderList (folder) {
|
|
5
|
-
return fsPromise.readdir(folder).then((files) => {
|
|
6
|
-
return Promise.all(files.map((file) => {
|
|
7
|
-
return fsPromise.lstat(path.join(folder, file)).then((stats) => {
|
|
8
|
-
return stats.isDirectory() ? file : null;
|
|
9
|
-
});
|
|
10
|
-
})).then((files) => {
|
|
11
|
-
return files.filter((file) => !!file);
|
|
12
|
-
});
|
|
13
|
-
}, (err) => {
|
|
14
|
-
throw err;
|
|
15
|
-
});
|
|
16
|
-
}
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import fsPromise from 'fs/promises';
|
|
3
|
+
|
|
4
|
+
export default function getFolderList (folder) {
|
|
5
|
+
return fsPromise.readdir(folder).then((files) => {
|
|
6
|
+
return Promise.all(files.map((file) => {
|
|
7
|
+
return fsPromise.lstat(path.join(folder, file)).then((stats) => {
|
|
8
|
+
return stats.isDirectory() ? file : null;
|
|
9
|
+
});
|
|
10
|
+
})).then((files) => {
|
|
11
|
+
return files.filter((file) => !!file);
|
|
12
|
+
});
|
|
13
|
+
}, (err) => {
|
|
14
|
+
throw err;
|
|
15
|
+
});
|
|
16
|
+
}
|
|
@@ -1,17 +1,17 @@
|
|
|
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
|
-
|
|
6
|
-
export default function mergePackage (fileName, content) {
|
|
7
|
-
return readPackage(fileName).then((packageContent) => {
|
|
8
|
-
const newPackage = merge({}, packageContent, content);
|
|
9
|
-
|
|
10
|
-
// Write only if file has changed
|
|
11
|
-
if (!isEqual(packageContent, newPackage)) {
|
|
12
|
-
return fsPromise.writeFile(fileName, JSON.stringify(newPackage, null, ' '));
|
|
13
|
-
} else {
|
|
14
|
-
return Promise.resolve();
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
};
|
|
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
|
+
|
|
6
|
+
export default function mergePackage (fileName, content) {
|
|
7
|
+
return readPackage(fileName).then((packageContent) => {
|
|
8
|
+
const newPackage = merge({}, packageContent, content);
|
|
9
|
+
|
|
10
|
+
// Write only if file has changed
|
|
11
|
+
if (!isEqual(packageContent, newPackage)) {
|
|
12
|
+
return fsPromise.writeFile(fileName, JSON.stringify(newPackage, null, ' '));
|
|
13
|
+
} else {
|
|
14
|
+
return Promise.resolve();
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
};
|
package/lib/init/read-package.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import fsPromise from 'fs/promises';
|
|
2
|
-
|
|
3
|
-
export default function mergePackage (fileName, defaultValue = null) {
|
|
4
|
-
return fsPromise.readFile(fileName, {'encoding': 'utf8'}).then((data) => {
|
|
5
|
-
try {
|
|
6
|
-
return JSON.parse(data);
|
|
7
|
-
} catch (err) {
|
|
8
|
-
return Promise.reject(err);
|
|
9
|
-
}
|
|
10
|
-
}).catch((err) => {
|
|
11
|
-
if (defaultValue) {
|
|
12
|
-
return Promise.resolve(defaultValue);
|
|
13
|
-
} else {
|
|
14
|
-
return Promise.reject(err);
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
};
|
|
1
|
+
import fsPromise from 'fs/promises';
|
|
2
|
+
|
|
3
|
+
export default function mergePackage (fileName, defaultValue = null) {
|
|
4
|
+
return fsPromise.readFile(fileName, {'encoding': 'utf8'}).then((data) => {
|
|
5
|
+
try {
|
|
6
|
+
return JSON.parse(data);
|
|
7
|
+
} catch (err) {
|
|
8
|
+
return Promise.reject(err);
|
|
9
|
+
}
|
|
10
|
+
}).catch((err) => {
|
|
11
|
+
if (defaultValue) {
|
|
12
|
+
return Promise.resolve(defaultValue);
|
|
13
|
+
} else {
|
|
14
|
+
return Promise.reject(err);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
};
|
package/lib/log-error.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
|
|
3
|
-
export default function (error, failOnError = false) {
|
|
4
|
-
const message = String(error.messageFormatted || error.message);
|
|
5
|
-
const messageTrimmed = message.length > 4096 ? message.slice(0, 512) + '...' : message;
|
|
6
|
-
|
|
7
|
-
console.log(chalk.red('Error') + ' in \'' + chalk.cyan(error.plugin || error.type) + '\'\nMessage:\n ' + messageTrimmed);
|
|
8
|
-
|
|
9
|
-
if (failOnError) {
|
|
10
|
-
throw error;
|
|
11
|
-
} else if (this && typeof this.emit === 'function') {
|
|
12
|
-
// Emit the end event, to properly end the task
|
|
13
|
-
this.emit('end');
|
|
14
|
-
}
|
|
15
|
-
}
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
|
|
3
|
+
export default function (error, failOnError = false) {
|
|
4
|
+
const message = String(error.messageFormatted || error.message);
|
|
5
|
+
const messageTrimmed = message.length > 4096 ? message.slice(0, 512) + '...' : message;
|
|
6
|
+
|
|
7
|
+
console.log(chalk.red('Error') + ' in \'' + chalk.cyan(error.plugin || error.type) + '\'\nMessage:\n ' + messageTrimmed);
|
|
8
|
+
|
|
9
|
+
if (failOnError) {
|
|
10
|
+
throw error;
|
|
11
|
+
} else if (this && typeof this.emit === 'function') {
|
|
12
|
+
// Emit the end event, to properly end the task
|
|
13
|
+
this.emit('end');
|
|
14
|
+
}
|
|
15
|
+
}
|
package/lib/merge.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import isArray from 'lodash/isArray.js';
|
|
2
|
-
import mergeWith from 'lodash/mergeWith.js';
|
|
3
|
-
|
|
4
|
-
function customizer (objValue, srcValue, key) {
|
|
5
|
-
if (objValue !== srcValue && isArray(objValue) && isArray(srcValue)) {
|
|
6
|
-
return objValue.concat(srcValue);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Merge multiple objest together, with array concatanation
|
|
12
|
-
* object is mutated
|
|
13
|
-
*
|
|
14
|
-
* @param {object|array} object Object into which to merge into
|
|
15
|
-
* @param {object|array} ...sources List of sources which to merge into object
|
|
16
|
-
* @returns {object|array} Merged object
|
|
17
|
-
*/
|
|
18
|
-
export default function merge (object, ...sources) {
|
|
19
|
-
for (let i = 0; i < sources.length; i++) {
|
|
20
|
-
if (sources[i] && typeof sources[i] === 'object') {
|
|
21
|
-
object = mergeWith(object, sources[i], customizer);
|
|
22
|
-
} else {
|
|
23
|
-
object = sources[i];
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return object;
|
|
27
|
-
}
|
|
1
|
+
import isArray from 'lodash/isArray.js';
|
|
2
|
+
import mergeWith from 'lodash/mergeWith.js';
|
|
3
|
+
|
|
4
|
+
function customizer (objValue, srcValue, key) {
|
|
5
|
+
if (objValue !== srcValue && isArray(objValue) && isArray(srcValue)) {
|
|
6
|
+
return objValue.concat(srcValue);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Merge multiple objest together, with array concatanation
|
|
12
|
+
* object is mutated
|
|
13
|
+
*
|
|
14
|
+
* @param {object|array} object Object into which to merge into
|
|
15
|
+
* @param {object|array} ...sources List of sources which to merge into object
|
|
16
|
+
* @returns {object|array} Merged object
|
|
17
|
+
*/
|
|
18
|
+
export default function merge (object, ...sources) {
|
|
19
|
+
for (let i = 0; i < sources.length; i++) {
|
|
20
|
+
if (sources[i] && typeof sources[i] === 'object') {
|
|
21
|
+
object = mergeWith(object, sources[i], customizer);
|
|
22
|
+
} else {
|
|
23
|
+
object = sources[i];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return object;
|
|
27
|
+
}
|
package/lib/run-preprocess.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import isPlainObject from 'lodash/isPlainObject.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Call all preprocess functions, preprocess validates and transforms configuration
|
|
5
|
-
*
|
|
6
|
-
* @param {object} taskConfig Task config
|
|
7
|
-
* @returns {object} Preprocessed task config
|
|
8
|
-
*/
|
|
9
|
-
export default function runPreprocess (taskConfig) {
|
|
10
|
-
if (taskConfig.preprocess) {
|
|
11
|
-
for (let taskName in taskConfig.preprocess) {
|
|
12
|
-
// Make sure task is not disabled
|
|
13
|
-
if (taskConfig[taskName] !== false) {
|
|
14
|
-
const functions = taskConfig.preprocess[taskName];
|
|
15
|
-
|
|
16
|
-
for (let i = 0; i < functions.length; i++) {
|
|
17
|
-
let newTaskConfig = functions[i](taskConfig[taskName], taskConfig);
|
|
18
|
-
|
|
19
|
-
if (newTaskConfig === false) {
|
|
20
|
-
taskConfig[taskName] = false;
|
|
21
|
-
break;
|
|
22
|
-
} else if (newTaskConfig && (isPlainObject(newTaskConfig) || Array.isArray(newTaskConfig))) {
|
|
23
|
-
// Safeguard against empty values
|
|
24
|
-
taskConfig[taskName] = newTaskConfig;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return taskConfig;
|
|
32
|
-
}
|
|
1
|
+
import isPlainObject from 'lodash/isPlainObject.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Call all preprocess functions, preprocess validates and transforms configuration
|
|
5
|
+
*
|
|
6
|
+
* @param {object} taskConfig Task config
|
|
7
|
+
* @returns {object} Preprocessed task config
|
|
8
|
+
*/
|
|
9
|
+
export default function runPreprocess (taskConfig) {
|
|
10
|
+
if (taskConfig.preprocess) {
|
|
11
|
+
for (let taskName in taskConfig.preprocess) {
|
|
12
|
+
// Make sure task is not disabled
|
|
13
|
+
if (taskConfig[taskName] !== false) {
|
|
14
|
+
const functions = taskConfig.preprocess[taskName];
|
|
15
|
+
|
|
16
|
+
for (let i = 0; i < functions.length; i++) {
|
|
17
|
+
let newTaskConfig = functions[i](taskConfig[taskName], taskConfig);
|
|
18
|
+
|
|
19
|
+
if (newTaskConfig === false) {
|
|
20
|
+
taskConfig[taskName] = false;
|
|
21
|
+
break;
|
|
22
|
+
} else if (newTaskConfig && (isPlainObject(newTaskConfig) || Array.isArray(newTaskConfig))) {
|
|
23
|
+
// Safeguard against empty values
|
|
24
|
+
taskConfig[taskName] = newTaskConfig;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return taskConfig;
|
|
32
|
+
}
|
package/lib/task-order.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
export const BEFORE_BUILD = 'beforeBuild';
|
|
2
|
-
export const BUILD = 'build';
|
|
3
|
-
export const AFTER_BUILD = 'afterBuild';
|
|
4
|
-
|
|
5
|
-
export const BEFORE_WATCH = 'beforeWatch';
|
|
6
|
-
export const WATCH = 'watch';
|
|
7
|
-
|
|
8
|
-
export const DEFAULT_TASKS = [
|
|
9
|
-
BEFORE_BUILD,
|
|
10
|
-
BUILD,
|
|
11
|
-
BEFORE_WATCH,
|
|
12
|
-
WATCH,
|
|
13
|
-
];
|
|
14
|
-
|
|
15
|
-
export const BUILD_TASKS = [
|
|
16
|
-
BEFORE_BUILD,
|
|
17
|
-
BUILD,
|
|
18
|
-
AFTER_BUILD,
|
|
19
|
-
];
|
|
1
|
+
export const BEFORE_BUILD = 'beforeBuild';
|
|
2
|
+
export const BUILD = 'build';
|
|
3
|
+
export const AFTER_BUILD = 'afterBuild';
|
|
4
|
+
|
|
5
|
+
export const BEFORE_WATCH = 'beforeWatch';
|
|
6
|
+
export const WATCH = 'watch';
|
|
7
|
+
|
|
8
|
+
export const DEFAULT_TASKS = [
|
|
9
|
+
BEFORE_BUILD,
|
|
10
|
+
BUILD,
|
|
11
|
+
BEFORE_WATCH,
|
|
12
|
+
WATCH,
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
export const BUILD_TASKS = [
|
|
16
|
+
BEFORE_BUILD,
|
|
17
|
+
BUILD,
|
|
18
|
+
AFTER_BUILD,
|
|
19
|
+
];
|