@videinfra/static-website-builder 1.10.1 → 1.11.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.
Files changed (38) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/init/index.js +56 -56
  3. package/init/test/config/config.js +36 -36
  4. package/init/test/src/stylesheets/autoprefixer-test.scss +3 -3
  5. package/init/test/src/stylesheets/ignore-test.scss +4 -4
  6. package/init/test/src/stylesheets/nested-calc-test.scss +3 -3
  7. package/init/test/src/stylesheets/sub-folder/import-test.scss +2 -2
  8. package/lib/camelize-file-name.js +21 -21
  9. package/lib/get-config.js +157 -157
  10. package/lib/get-file-names.js +23 -23
  11. package/lib/get-path.js +109 -109
  12. package/lib/globs-helper.js +136 -136
  13. package/lib/log-error.js +15 -15
  14. package/lib/merge.js +27 -27
  15. package/package.json +5 -2
  16. package/plugins/sass-engine/preprocess-config.js +54 -54
  17. package/plugins/sass.js +38 -38
  18. package/plugins/twig-engine/preprocess-config.js +47 -47
  19. package/plugins/twig.js +65 -65
  20. package/tasks/data/data-loader-js.js +5 -5
  21. package/tasks/data/get-data.js +87 -87
  22. package/tasks/html/task.js +91 -91
  23. package/tasks/icons/config.js +52 -52
  24. package/tasks/javascripts/preprocess-config.js +21 -5
  25. package/tasks/javascripts/task.js +1 -1
  26. package/tasks/stylesheets/config.js +88 -88
  27. package/tasks/stylesheets/preprocess-config.js +41 -41
  28. package/tasks/stylesheets/task.js +69 -69
  29. package/tests/build/build.test.js +101 -101
  30. package/tests/camelize-file-name.test.js +11 -11
  31. package/tests/glob-helper.test.js +99 -99
  32. package/vendor/gulp-twig/LICENSE +20 -20
  33. package/vendor/gulp-twig/README.md +167 -167
  34. package/vendor/gulp-twig/index.js +130 -130
  35. package/vendor/gulp-twig/package.json +43 -43
  36. package/vendor/webpack-stream/index.js +261 -0
  37. package/vendor/webpack-stream/package.json +91 -0
  38. package/vendor/webpack-stream/readme.md +239 -0
@@ -1,54 +1,54 @@
1
- const paths = require('./../../lib/get-path');
2
- const getConfig = require('./../../lib/get-config');
3
- const getPaths = require('./../../lib/get-path');
4
- const assign = require('lodash/assign');
5
- const gulpSass = require('gulp-sass');
6
-
7
-
8
- /**
9
- * Modify configuration
10
- *
11
- * @param {object} config Stylesheet configuration
12
- * @param {object} fullConfig Full configuration
13
- * @returns {object} Transformed stylesheet configuration
14
- */
15
- module.exports = function processSASSConfig (config, fullConfig) {
16
- if (config && config.sass) {
17
- if (config.sass.includePaths) {
18
- // Map include paths to the project folder
19
- config.sass.includePaths = config.sass.includePaths.map((path) => paths.getProjectPath(path));
20
- } else {
21
- config.sass.includePaths = [];
22
- }
23
-
24
- // Add stylesheet source path
25
- const stylesheetSourcePath = getPaths.getSourcePaths('stylesheets')
26
-
27
- stylesheetSourcePath.forEach((path) => {
28
- if (!config.sass.includePaths.includes(path)) {
29
- config.sass.includePaths.push(path);
30
- }
31
- });
32
-
33
- // Engine is a function which returns a gulp pipe function
34
- config.engine = function getSASSEngine () {
35
- const sass = config.legacy ? gulpSass(require('node-sass')) : gulpSass(require('sass'));
36
- return sass(getConfig.getTaskConfig('stylesheets', 'sass')).on('error', sass.logError)
37
- };
38
-
39
- // Main 'dependents' config is shared between all tasks
40
- if (config.dependents) {
41
-
42
- for (let extension in config.dependents) {
43
- config.dependents[extension].basePaths = config.dependents[extension].basePaths || [];
44
- config.dependents[extension].basePaths = config.dependents[extension].basePaths.concat(
45
- getPaths.getSourcePaths('stylesheets')
46
- );
47
- }
48
-
49
- fullConfig.dependents = assign(fullConfig.dependents || {}, config.dependents);
50
- }
51
- }
52
-
53
- return config;
54
- }
1
+ const paths = require('./../../lib/get-path');
2
+ const getConfig = require('./../../lib/get-config');
3
+ const getPaths = require('./../../lib/get-path');
4
+ const assign = require('lodash/assign');
5
+ const gulpSass = require('gulp-sass');
6
+
7
+
8
+ /**
9
+ * Modify configuration
10
+ *
11
+ * @param {object} config Stylesheet configuration
12
+ * @param {object} fullConfig Full configuration
13
+ * @returns {object} Transformed stylesheet configuration
14
+ */
15
+ module.exports = function processSASSConfig (config, fullConfig) {
16
+ if (config && config.sass) {
17
+ if (config.sass.includePaths) {
18
+ // Map include paths to the project folder
19
+ config.sass.includePaths = config.sass.includePaths.map((path) => paths.getProjectPath(path));
20
+ } else {
21
+ config.sass.includePaths = [];
22
+ }
23
+
24
+ // Add stylesheet source path
25
+ const stylesheetSourcePath = getPaths.getSourcePaths('stylesheets')
26
+
27
+ stylesheetSourcePath.forEach((path) => {
28
+ if (!config.sass.includePaths.includes(path)) {
29
+ config.sass.includePaths.push(path);
30
+ }
31
+ });
32
+
33
+ // Engine is a function which returns a gulp pipe function
34
+ config.engine = function getSASSEngine () {
35
+ const sass = config.legacy ? gulpSass(require('node-sass')) : gulpSass(require('sass'));
36
+ return sass(getConfig.getTaskConfig('stylesheets', 'sass')).on('error', sass.logError)
37
+ };
38
+
39
+ // Main 'dependents' config is shared between all tasks
40
+ if (config.dependents) {
41
+
42
+ for (let extension in config.dependents) {
43
+ config.dependents[extension].basePaths = config.dependents[extension].basePaths || [];
44
+ config.dependents[extension].basePaths = config.dependents[extension].basePaths.concat(
45
+ getPaths.getSourcePaths('stylesheets')
46
+ );
47
+ }
48
+
49
+ fullConfig.dependents = assign(fullConfig.dependents || {}, config.dependents);
50
+ }
51
+ }
52
+
53
+ return config;
54
+ }
package/plugins/sass.js CHANGED
@@ -1,38 +1,38 @@
1
- /**
2
- * SASS plugin attaches itself to the stylesheets task
3
- */
4
- exports.stylesheets = {
5
- // Add sass to the extensions
6
- extensions: ['scss', 'sass'],
7
-
8
- // Use legacy `node-sass` instead of `sass`
9
- legacy: true,
10
-
11
- // SASS options
12
- // see https://github.com/sass/node-sass#options
13
- sass: {
14
- includePaths: ['./node_modules'],
15
- },
16
-
17
- // Dependents plugin for faster builds
18
- dependents: {
19
- '.scss': {
20
- parserSteps:
21
- [
22
- // The language semantics allow import statements with a comma-separated list of file paths.
23
- // Therefore, we first extract the whole statement, and then extract each of the paths from that.
24
- /(?:^|;|{|}|\*\/)\s*@(import|use|forward)\s+((?:"[^"]+"|'[^']+'|url\((?:"[^"]+"|'[^']+'|[^)]+)\))(?:\s*,\s*(?:"[^"]+"|'[^']+'|url\((?:"[^"]+"|'[^']+'|[^)]+)\)))*)(?=[^;]*;)/gm,
25
- /"([^"]+)"|'([^']+)'|url\((?:"([^"]+)"|'([^']+)'|([^)]+))\)/gm
26
- ],
27
- prefixes: ['', '_'],
28
- postfixes: ['.scss', '.sass'],
29
- basePaths: []
30
- },
31
- },
32
- };
33
-
34
- exports.preprocess = {
35
- stylesheets: [
36
- require('./sass-engine/preprocess-config'),
37
- ]
38
- };
1
+ /**
2
+ * SASS plugin attaches itself to the stylesheets task
3
+ */
4
+ exports.stylesheets = {
5
+ // Add sass to the extensions
6
+ extensions: ['scss', 'sass'],
7
+
8
+ // Use legacy `node-sass` instead of `sass`
9
+ legacy: true,
10
+
11
+ // SASS options
12
+ // see https://github.com/sass/node-sass#options
13
+ sass: {
14
+ includePaths: ['./node_modules'],
15
+ },
16
+
17
+ // Dependents plugin for faster builds
18
+ dependents: {
19
+ '.scss': {
20
+ parserSteps:
21
+ [
22
+ // The language semantics allow import statements with a comma-separated list of file paths.
23
+ // Therefore, we first extract the whole statement, and then extract each of the paths from that.
24
+ /(?:^|;|{|}|\*\/)\s*@(import|use|forward)\s+((?:"[^"]+"|'[^']+'|url\((?:"[^"]+"|'[^']+'|[^)]+)\))(?:\s*,\s*(?:"[^"]+"|'[^']+'|url\((?:"[^"]+"|'[^']+'|[^)]+)\)))*)(?=[^;]*;)/gm,
25
+ /"([^"]+)"|'([^']+)'|url\((?:"([^"]+)"|'([^']+)'|([^)]+))\)/gm
26
+ ],
27
+ prefixes: ['', '_'],
28
+ postfixes: ['.scss', '.sass'],
29
+ basePaths: []
30
+ },
31
+ },
32
+ };
33
+
34
+ exports.preprocess = {
35
+ stylesheets: [
36
+ require('./sass-engine/preprocess-config'),
37
+ ]
38
+ };
@@ -1,47 +1,47 @@
1
- const twig = require('../../vendor/gulp-twig/index');
2
- const getConfig = require('./../../lib/get-config');
3
- const getPaths = require('./../../lib/get-path');
4
- const flattenDeep = require('lodash/flattenDeep');
5
- const assign = require('lodash/assign');
6
-
7
-
8
- /**
9
- * Modify configuration
10
- *
11
- * @param {object} config HTML configuration
12
- * @param {object} fullConfig Full configuration
13
- * @returns {object} Transformed HTML configuration
14
- */
15
- module.exports = function preprocessHTMLConfig (config = {}, fullConfig) {
16
- if (config.twig) {
17
- config.twig.base = getPaths.getSourcePaths('html');
18
-
19
- // Engine is a function which returns a gulp pipe function
20
- config.engine = function getTwigEngine () {
21
- return twig(getConfig.getTaskConfig('html', 'twig'));
22
- };
23
-
24
- if (config.twig.functions) {
25
- config.twig.functions = flattenDeep(config.twig.functions);
26
- }
27
- if (config.twig.filters) {
28
- config.twig.filters = flattenDeep(config.twig.filters);
29
- }
30
-
31
- // Main 'dependents' config is shared between all tasks
32
- if (config.dependents) {
33
- for (let extension in config.dependents) {
34
- config.dependents[extension].basePaths = config.dependents[extension].basePaths || [];
35
- config.dependents[extension].basePaths = config.dependents[extension].basePaths.concat(
36
- config.twig.base
37
- );
38
- }
39
-
40
- fullConfig.dependents = assign(fullConfig.dependents || {}, config.dependents);
41
- }
42
- } else {
43
- config.twig = false;
44
- }
45
-
46
- return config;
47
- }
1
+ const twig = require('../../vendor/gulp-twig/index');
2
+ const getConfig = require('./../../lib/get-config');
3
+ const getPaths = require('./../../lib/get-path');
4
+ const flattenDeep = require('lodash/flattenDeep');
5
+ const assign = require('lodash/assign');
6
+
7
+
8
+ /**
9
+ * Modify configuration
10
+ *
11
+ * @param {object} config HTML configuration
12
+ * @param {object} fullConfig Full configuration
13
+ * @returns {object} Transformed HTML configuration
14
+ */
15
+ module.exports = function preprocessHTMLConfig (config = {}, fullConfig) {
16
+ if (config.twig) {
17
+ config.twig.base = getPaths.getSourcePaths('html');
18
+
19
+ // Engine is a function which returns a gulp pipe function
20
+ config.engine = function getTwigEngine () {
21
+ return twig(getConfig.getTaskConfig('html', 'twig'));
22
+ };
23
+
24
+ if (config.twig.functions) {
25
+ config.twig.functions = flattenDeep(config.twig.functions);
26
+ }
27
+ if (config.twig.filters) {
28
+ config.twig.filters = flattenDeep(config.twig.filters);
29
+ }
30
+
31
+ // Main 'dependents' config is shared between all tasks
32
+ if (config.dependents) {
33
+ for (let extension in config.dependents) {
34
+ config.dependents[extension].basePaths = config.dependents[extension].basePaths || [];
35
+ config.dependents[extension].basePaths = config.dependents[extension].basePaths.concat(
36
+ config.twig.base
37
+ );
38
+ }
39
+
40
+ fullConfig.dependents = assign(fullConfig.dependents || {}, config.dependents);
41
+ }
42
+ } else {
43
+ config.twig = false;
44
+ }
45
+
46
+ return config;
47
+ }
package/plugins/twig.js CHANGED
@@ -1,65 +1,65 @@
1
- /**
2
- * TWIG plugin attaches itself to the HTML task
3
- */
4
- exports.html = {
5
- // Add twig to the extensions
6
- extensions: ['twig'],
7
-
8
- // Glob list of files, which to ignore
9
- // see https://gulpjs.com/docs/en/getting-started/explaining-globs/
10
- ignore: [
11
- 'shared/**/*',
12
- 'partials/**/*',
13
- 'macros/**/*',
14
- 'layouts/**/*',
15
- ],
16
-
17
- // Dependents plugin for faster builds
18
- dependents: {
19
- '.twig': {
20
- parserSteps: [
21
- /\{%\s+(?:from|extends|include)\s+['"]([^'"]+)/gm,
22
- ],
23
- prefixes: [],
24
- postfixes: [],
25
- basePaths: []
26
- }
27
- },
28
-
29
- twig: {
30
- // Async rendering
31
- async: true,
32
-
33
- // Disabled cache by default, it's enabled for production build only
34
- cache: false,
35
-
36
- // Custom functions
37
- functions: [
38
- // require('../../plugins/twig/symfony-functions.js'),
39
- ],
40
-
41
- // Custom filters
42
- filters: [
43
- // require('../../plugins/twig/lodash-filters.js'),
44
- // require('../../plugins/twig/symfony-functions.js'),
45
- ],
46
-
47
- // Production only settings, overwrites default settings
48
- production: {
49
- // Enable cache for improved performance during production build
50
- cache: true,
51
- },
52
- },
53
-
54
- // List of CDNs when using symphony filters / funtions
55
- cdns: [],
56
-
57
- // Add file version number when using symphony filters / funtions
58
- version: false,
59
- };
60
-
61
- exports.preprocess = {
62
- html: [
63
- require('./twig-engine/preprocess-config'),
64
- ]
65
- };
1
+ /**
2
+ * TWIG plugin attaches itself to the HTML task
3
+ */
4
+ exports.html = {
5
+ // Add twig to the extensions
6
+ extensions: ['twig'],
7
+
8
+ // Glob list of files, which to ignore
9
+ // see https://gulpjs.com/docs/en/getting-started/explaining-globs/
10
+ ignore: [
11
+ 'shared/**/*',
12
+ 'partials/**/*',
13
+ 'macros/**/*',
14
+ 'layouts/**/*',
15
+ ],
16
+
17
+ // Dependents plugin for faster builds
18
+ dependents: {
19
+ '.twig': {
20
+ parserSteps: [
21
+ /\{%\s+(?:from|extends|include)\s+['"]([^'"]+)/gm,
22
+ ],
23
+ prefixes: [],
24
+ postfixes: [],
25
+ basePaths: []
26
+ }
27
+ },
28
+
29
+ twig: {
30
+ // Async rendering
31
+ async: true,
32
+
33
+ // Disabled cache by default, it's enabled for production build only
34
+ cache: false,
35
+
36
+ // Custom functions
37
+ functions: [
38
+ // require('../../plugins/twig/symfony-functions.js'),
39
+ ],
40
+
41
+ // Custom filters
42
+ filters: [
43
+ // require('../../plugins/twig/lodash-filters.js'),
44
+ // require('../../plugins/twig/symfony-functions.js'),
45
+ ],
46
+
47
+ // Production only settings, overwrites default settings
48
+ production: {
49
+ // Enable cache for improved performance during production build
50
+ cache: true,
51
+ },
52
+ },
53
+
54
+ // List of CDNs when using symphony filters / funtions
55
+ cdns: [],
56
+
57
+ // Add file version number when using symphony filters / funtions
58
+ version: false,
59
+ };
60
+
61
+ exports.preprocess = {
62
+ html: [
63
+ require('./twig-engine/preprocess-config'),
64
+ ]
65
+ };
@@ -1,5 +1,5 @@
1
- module.exports = function dataLoaderJS (fileName) {
2
- // Re-load script each time this function is called
3
- delete require.cache[require.resolve(fileName)];
4
- return require(fileName);
5
- };
1
+ module.exports = function dataLoaderJS (fileName) {
2
+ // Re-load script each time this function is called
3
+ delete require.cache[require.resolve(fileName)];
4
+ return require(fileName);
5
+ };
@@ -1,87 +1,87 @@
1
- const path = require('path');
2
- const reduce = require('lodash/reduce');
3
- const micromatch = require('micromatch'); // gulp dependency
4
-
5
- const merge = require('../../lib/merge');
6
- const getPaths = require('../../lib/get-path');
7
- const getConfig = require('../../lib/get-config');
8
- const logError = require('../../lib/log-error');
9
- const getFileNamesSync = require('../../lib/get-file-names');
10
- const camelizeFileName = require('../../lib/camelize-file-name');
11
-
12
-
13
- function getData () {
14
- const folders = getPaths.getSourcePaths('data');
15
- const extensions = getConfig.getTaskConfig('data', 'extensions');
16
- const loaders = getConfig.getTaskConfig('data', 'loaders');
17
- const ignore = getConfig.getTaskConfig('data', 'ignore');
18
- const group = getConfig.getTaskConfig('data', 'groupByFileName');
19
-
20
- const data = reduce(folders, (data, folder) => {
21
- getFileNamesSync(folder).forEach(fileName => {
22
- // Ignore files matching 'ignore' list
23
- if (ignore.length && micromatch.isMatch(fileName, ignore)) {
24
- return;
25
- }
26
-
27
- // Ignore files starting with underscore
28
- if (fileName[0] !== '_') {
29
- const extension = fileName.split('.').pop();
30
-
31
- if (extension && extensions.indexOf(extension) !== -1) {
32
- if (extension in loaders) {
33
- try {
34
- const fullFilePath = path.resolve(folder, fileName);
35
- const fileData = loaders[extension](fullFilePath);
36
-
37
- if (group) {
38
- // Group data
39
- const name = camelizeFileName(fileName);
40
- data = merge(data, {[name]: fileData});
41
- } else {
42
- // Merge together
43
- data = merge(data, fileData);
44
- }
45
- } catch (err) {
46
- logError({
47
- 'message': `Failed to parse "${ path.join(getPaths.getPathConfig().src, getPaths.getPathConfig().data.src, fileName) }"`,
48
- 'plugin': 'data'
49
- });
50
- }
51
- } else {
52
- logError({
53
- 'message': `Data loader for files with "${ extension }" extension is not defined in configuration data.loaders property`,
54
- 'plugin': 'data'
55
- });
56
- }
57
- }
58
- }
59
- });
60
-
61
- return data;
62
- }, {});
63
-
64
- return data;
65
- }
66
-
67
-
68
- let cache = null;
69
-
70
- module.exports = function (options) {
71
- const build = options && !!options.build;
72
-
73
- return function () {
74
- if (build) {
75
- // Cache during full build
76
- if (!cache) {
77
- cache = getData();
78
- }
79
-
80
- return cache;
81
- } else {
82
- // Don't cache during watch build
83
- cache = null;
84
- return getData();
85
- }
86
- }
87
- }
1
+ const path = require('path');
2
+ const reduce = require('lodash/reduce');
3
+ const micromatch = require('micromatch'); // gulp dependency
4
+
5
+ const merge = require('../../lib/merge');
6
+ const getPaths = require('../../lib/get-path');
7
+ const getConfig = require('../../lib/get-config');
8
+ const logError = require('../../lib/log-error');
9
+ const getFileNamesSync = require('../../lib/get-file-names');
10
+ const camelizeFileName = require('../../lib/camelize-file-name');
11
+
12
+
13
+ function getData () {
14
+ const folders = getPaths.getSourcePaths('data');
15
+ const extensions = getConfig.getTaskConfig('data', 'extensions');
16
+ const loaders = getConfig.getTaskConfig('data', 'loaders');
17
+ const ignore = getConfig.getTaskConfig('data', 'ignore');
18
+ const group = getConfig.getTaskConfig('data', 'groupByFileName');
19
+
20
+ const data = reduce(folders, (data, folder) => {
21
+ getFileNamesSync(folder).forEach(fileName => {
22
+ // Ignore files matching 'ignore' list
23
+ if (ignore.length && micromatch.isMatch(fileName, ignore)) {
24
+ return;
25
+ }
26
+
27
+ // Ignore files starting with underscore
28
+ if (fileName[0] !== '_') {
29
+ const extension = fileName.split('.').pop();
30
+
31
+ if (extension && extensions.indexOf(extension) !== -1) {
32
+ if (extension in loaders) {
33
+ try {
34
+ const fullFilePath = path.resolve(folder, fileName);
35
+ const fileData = loaders[extension](fullFilePath);
36
+
37
+ if (group) {
38
+ // Group data
39
+ const name = camelizeFileName(fileName);
40
+ data = merge(data, {[name]: fileData});
41
+ } else {
42
+ // Merge together
43
+ data = merge(data, fileData);
44
+ }
45
+ } catch (err) {
46
+ logError({
47
+ 'message': `Failed to parse "${ path.join(getPaths.getPathConfig().src, getPaths.getPathConfig().data.src, fileName) }"`,
48
+ 'plugin': 'data'
49
+ });
50
+ }
51
+ } else {
52
+ logError({
53
+ 'message': `Data loader for files with "${ extension }" extension is not defined in configuration data.loaders property`,
54
+ 'plugin': 'data'
55
+ });
56
+ }
57
+ }
58
+ }
59
+ });
60
+
61
+ return data;
62
+ }, {});
63
+
64
+ return data;
65
+ }
66
+
67
+
68
+ let cache = null;
69
+
70
+ module.exports = function (options) {
71
+ const build = options && !!options.build;
72
+
73
+ return function () {
74
+ if (build) {
75
+ // Cache during full build
76
+ if (!cache) {
77
+ cache = getData();
78
+ }
79
+
80
+ return cache;
81
+ } else {
82
+ // Don't cache during watch build
83
+ cache = null;
84
+ return getData();
85
+ }
86
+ }
87
+ }