@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
package/CHANGELOG.md CHANGED
@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
+ ## [1.11.1] - 2024-02-24
8
+ ### Fixed
9
+ - Fixed dependencies
10
+
11
+ ## [1.11.0] - 2024-02-24
12
+ ### Updated
13
+ - Added dynamic entries, webpack will rebuild when entries change
14
+
7
15
  ## [1.10.1] - 2024-02-13
8
16
  ### Fixed
9
17
  - TWIG config
package/init/index.js CHANGED
@@ -1,56 +1,56 @@
1
- const path = require('../lib/get-path');
2
- const copyFolder = require('../lib/init/copy-folder');
3
- const readPackage = require('../lib/init/read-package');
4
- const mergePackage = require('../lib/init/merge-package');
5
- const folderExists = require('../lib/init/folder-exists');
6
- const getFolderList = require('../lib/init/get-folder-list');
7
- const chalk = require('chalk');
8
-
9
- module.exports = function init (template = 'default') {
10
- let templateName = template || 'default';
11
- let copyFrom = path.getBuilderPath('init', templateName);
12
- const copyTo = path.getProjectPath();
13
-
14
- if (template === 'test' || !folderExists(copyFrom)) {
15
- console.log(chalk.red(`Template "${ templateName }" doesn't exist`));
16
-
17
- getFolderList(path.getBuilderPath('init')).then((templates) => {
18
- console.log('Available templates:');
19
- console.log(chalk.cyan(` ${ templates.join('\n ') }`));
20
- });
21
- return;
22
- }
23
-
24
- console.log(chalk.magenta(`Generating project files using template "${ templateName }"`));
25
-
26
- // Copy files
27
- const filesCopied = copyFolder(copyFrom, copyTo);
28
-
29
- // Merge template package.json into projects package.json
30
- const packageMerged = readPackage(path.getBuilderPath('init', templateName, 'package.json'), {}).then((package) => {
31
- return mergePackage(path.getProjectPath('package.json'), package).then(() => {
32
- if (package.dependencies || package.devDependencies) {
33
- console.log(chalk.magenta('Installing npm dependencies'));
34
-
35
- return new Promise((resolve, reject) => {
36
- require('child_process').exec('npm install', function (error, stdout, stderr) {
37
- resolve();
38
- });
39
- });
40
- }
41
- }).catch((err) => {
42
- // Skip errors
43
- return Promise.resolve();
44
- });
45
- });
46
-
47
- Promise.all([filesCopied, packageMerged]).then(() => {
48
- console.log(chalk.green('All done\n'));
49
-
50
- console.log('To start the dev server:\n' + chalk.cyan(' npm run start'));
51
-
52
- console.log('To build the project:\n' + chalk.cyan(' npm run build'));
53
- }, (err) => {
54
- throw err;
55
- });
56
- }
1
+ const path = require('../lib/get-path');
2
+ const copyFolder = require('../lib/init/copy-folder');
3
+ const readPackage = require('../lib/init/read-package');
4
+ const mergePackage = require('../lib/init/merge-package');
5
+ const folderExists = require('../lib/init/folder-exists');
6
+ const getFolderList = require('../lib/init/get-folder-list');
7
+ const chalk = require('chalk');
8
+
9
+ module.exports = function init (template = 'default') {
10
+ let templateName = template || 'default';
11
+ let copyFrom = path.getBuilderPath('init', templateName);
12
+ const copyTo = path.getProjectPath();
13
+
14
+ if (template === 'test' || !folderExists(copyFrom)) {
15
+ console.log(chalk.red(`Template "${ templateName }" doesn't exist`));
16
+
17
+ getFolderList(path.getBuilderPath('init')).then((templates) => {
18
+ console.log('Available templates:');
19
+ console.log(chalk.cyan(` ${ templates.join('\n ') }`));
20
+ });
21
+ return;
22
+ }
23
+
24
+ console.log(chalk.magenta(`Generating project files using template "${ templateName }"`));
25
+
26
+ // Copy files
27
+ const filesCopied = copyFolder(copyFrom, copyTo);
28
+
29
+ // Merge template package.json into projects package.json
30
+ const packageMerged = readPackage(path.getBuilderPath('init', templateName, 'package.json'), {}).then((package) => {
31
+ return mergePackage(path.getProjectPath('package.json'), package).then(() => {
32
+ if (package.dependencies || package.devDependencies) {
33
+ console.log(chalk.magenta('Installing npm dependencies'));
34
+
35
+ return new Promise((resolve, reject) => {
36
+ require('child_process').exec('npm install', function (error, stdout, stderr) {
37
+ resolve();
38
+ });
39
+ });
40
+ }
41
+ }).catch((err) => {
42
+ // Skip errors
43
+ return Promise.resolve();
44
+ });
45
+ });
46
+
47
+ Promise.all([filesCopied, packageMerged]).then(() => {
48
+ console.log(chalk.green('All done\n'));
49
+
50
+ console.log('To start the dev server:\n' + chalk.cyan(' npm run start'));
51
+
52
+ console.log('To build the project:\n' + chalk.cyan(' npm run build'));
53
+ }, (err) => {
54
+ throw err;
55
+ });
56
+ }
@@ -1,36 +1,36 @@
1
- /*
2
- * Build a project for testing
3
- */
4
-
5
- exports.clean = {};
6
- exports.static = {};
7
- exports.html = {};
8
- exports.data = {};
9
- exports.fonts = {};
10
- exports.icons = {};
11
- exports.images = {};
12
- exports.javascripts = {};
13
- exports.stylesheets = {};
14
- exports.sizereport = false;
15
-
16
- exports.plugins = [
17
- // Enables SASS engine and .sass and .scss file compilation
18
- require('../../../plugins/sass'),
19
-
20
- // Enables TwigJS engine .twig file compilation
21
- require('../../../plugins/twig'),
22
- ];
23
-
24
-
25
- /*
26
- * Path configuration
27
- * All options will be merged with defaults, but not replaces whole configuration object
28
- *
29
- * Default configuration can be seen here https://github.com/videinfra/static-website-builder/tree/master/tasks
30
- * in each tasks config.js file
31
- */
32
-
33
- exports.paths = {
34
- src: './init/test/src',
35
- dest: './tests/build/public',
36
- };
1
+ /*
2
+ * Build a project for testing
3
+ */
4
+
5
+ exports.clean = {};
6
+ exports.static = {};
7
+ exports.html = {};
8
+ exports.data = {};
9
+ exports.fonts = {};
10
+ exports.icons = {};
11
+ exports.images = {};
12
+ exports.javascripts = {};
13
+ exports.stylesheets = {};
14
+ exports.sizereport = false;
15
+
16
+ exports.plugins = [
17
+ // Enables SASS engine and .sass and .scss file compilation
18
+ require('../../../plugins/sass'),
19
+
20
+ // Enables TwigJS engine .twig file compilation
21
+ require('../../../plugins/twig'),
22
+ ];
23
+
24
+
25
+ /*
26
+ * Path configuration
27
+ * All options will be merged with defaults, but not replaces whole configuration object
28
+ *
29
+ * Default configuration can be seen here https://github.com/videinfra/static-website-builder/tree/master/tasks
30
+ * in each tasks config.js file
31
+ */
32
+
33
+ exports.paths = {
34
+ src: './init/test/src',
35
+ dest: './tests/build/public',
36
+ };
@@ -1,3 +1,3 @@
1
- main {
2
- clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%);
3
- }
1
+ main {
2
+ clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%);
3
+ }
@@ -1,4 +1,4 @@
1
- :root {
2
- --yes: ;
3
- --no: initial;
4
- }
1
+ :root {
2
+ --yes: ;
3
+ --no: initial;
4
+ }
@@ -1,3 +1,3 @@
1
- body {
2
- padding-top: calc(10vw + calc(10vh * 1.5));
3
- }
1
+ body {
2
+ padding-top: calc(10vw + calc(10vh * 1.5));
3
+ }
@@ -1,2 +1,2 @@
1
- @import "settings/colors";
2
- @import "components/button";
1
+ @import "settings/colors";
2
+ @import "components/button";
@@ -1,21 +1,21 @@
1
- /**
2
- * Camelize filename
3
- *
4
- * @param {string} str File name
5
- * @returns {string} Camelized name
6
- */
7
- module.exports = function camelizeFileName (str) {
8
- return str
9
- // Remove extension
10
- .replace(/(.+?)\..*$/ig, '$1')
11
- // Remove dot
12
- .replace(/\./g, '')
13
- // Replace non alpha-numeric characters
14
- .replace(/[^a-z0-9]/ig, ' ')
15
- // Uppercase words
16
- .replace(/(?:^\w|[A-Z]|\b\w)/g, function(word, index) {
17
- return index === 0 ? word.toLowerCase() : word.toUpperCase();
18
- })
19
- // Remove empty spaces
20
- .replace(/\s+/g, '');
21
- }
1
+ /**
2
+ * Camelize filename
3
+ *
4
+ * @param {string} str File name
5
+ * @returns {string} Camelized name
6
+ */
7
+ module.exports = function camelizeFileName (str) {
8
+ return str
9
+ // Remove extension
10
+ .replace(/(.+?)\..*$/ig, '$1')
11
+ // Remove dot
12
+ .replace(/\./g, '')
13
+ // Replace non alpha-numeric characters
14
+ .replace(/[^a-z0-9]/ig, ' ')
15
+ // Uppercase words
16
+ .replace(/(?:^\w|[A-Z]|\b\w)/g, function(word, index) {
17
+ return index === 0 ? word.toLowerCase() : word.toUpperCase();
18
+ })
19
+ // Remove empty spaces
20
+ .replace(/\s+/g, '');
21
+ }
package/lib/get-config.js CHANGED
@@ -1,157 +1,157 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const getPath = require('./get-path');
4
- const runPreprocess = require('./run-preprocess');
5
- const merge = require('./merge');
6
- const logError = require('./log-error');
7
-
8
- const each = require('lodash/each');
9
- const omit = require('lodash/omit');
10
- const isPlainObject = require('lodash/isPlainObject');
11
- const isArray = require('lodash/isArray');
12
- const reduce = require('lodash/reduce');
13
- const get = require('lodash/get');
14
-
15
-
16
- /**
17
- * Returns builder and project specific task and plugin configurations combined
18
- * Configuration is preprocessed
19
- *
20
- * @returns {object} Task configurations
21
- */
22
-
23
- let taskConfig = null;
24
-
25
- function getConfig (builderConfigFile) {
26
- if (!taskConfig) {
27
- // Load all task configs
28
- taskConfig = itterateConfig(loadConfig(), mergeConfigMode);
29
-
30
- // 1. First load project specific config.js
31
- const projectConfigPath = getPath.getProjectPath(builderConfigFile);
32
- let projectTaskConfig = {};
33
- let hasProjectConfigFile = true;
34
-
35
- try {
36
- fs.accessSync(projectConfigPath);
37
- } catch (err) {
38
- logError({'plugin': 'static-website-builder', 'message': `Couldn't find configuration file "${ projectConfigPath }"`});
39
- hasProjectConfigFile = false;
40
- }
41
-
42
- if (hasProjectConfigFile) {
43
- projectTaskConfig = itterateConfig(require(projectConfigPath), mergeConfigMode);
44
- }
45
-
46
- // 2. Marge plugins into the config, each plugin is just a config
47
- const plugins = (taskConfig.plugins || []).concat(projectTaskConfig.plugins || []);
48
- if (plugins) {
49
- taskConfig.plugins = null;
50
- projectTaskConfig.plugins = null;
51
-
52
- each(plugins, (plugin) => {
53
- taskConfig = merge(taskConfig, itterateConfig(plugin, mergeConfigMode));
54
- });
55
- }
56
-
57
- // 3. Only after plugins has been executed, merge project specific config.js into main config
58
- if (projectTaskConfig) {
59
- taskConfig = merge(taskConfig, projectTaskConfig);
60
- }
61
-
62
- // 4. Preprocess
63
- taskConfig = runPreprocess(taskConfig);
64
- }
65
-
66
- return taskConfig;
67
- };
68
-
69
- /**
70
- * Returns task sub-config by path
71
- *
72
- * @param {...string} path Path to the sub-config
73
- * @returns {any} Task sub-config
74
- */
75
- function getTaskConfig (...path) {
76
- return get(getConfig(), path, null);
77
- }
78
-
79
- /**
80
- * Itterate over each config property and call function on
81
- * each object or array
82
- *
83
- * @param {*} object
84
- * @param {*} fn
85
- * @protected
86
- */
87
- function itterateConfig (config, fn) {
88
- if (config === false) return false;
89
- const base = isPlainObject(config) ? {} : [];
90
-
91
- return reduce(config, (object, value, key) => {
92
- if (isPlainObject(value)) {
93
- object[key]= itterateConfig(fn(value), fn);
94
- } else if (isArray(value)) {
95
- object[key]= itterateConfig(value, fn);
96
- } else {
97
- object[key] = value;
98
- }
99
-
100
- return object;
101
- }, base);
102
- }
103
-
104
- /**
105
- * Merge 'production' or 'development' mode sub-ojbects into an object and remove
106
- * mode sub-objects
107
- *
108
- * @param {object} config Config
109
- * @returns {object} Config
110
- * @protected
111
- */
112
- function mergeConfigMode (config) {
113
- if ('production' in config || 'development' in config) {
114
- const mode = global.production ? 'production' : 'development';
115
- const value = merge(config, config[mode]);
116
-
117
- if (value !== false) {
118
- return omit(value, ['production', 'development']);
119
- } else {
120
- return value;
121
- }
122
- } else {
123
- return config;
124
- }
125
- }
126
-
127
- /**
128
- * Load config files
129
- *
130
- * @returns {object} Configuration
131
- * @protected
132
- */
133
- function loadConfig () {
134
- const taskFolder = path.resolve(__dirname, '../tasks');
135
- let taskConfig = {};
136
-
137
- fs.readdirSync(taskFolder).forEach(folderName => {
138
- // Ignore task folders which start with underscore
139
- if (folderName[0] !== '_') {
140
- const configFileName = path.resolve(taskFolder, folderName, 'config.js');
141
-
142
- try {
143
- fs.accessSync(configFileName);
144
- } catch (err) {
145
- return;
146
- }
147
-
148
- taskConfig = merge(taskConfig, require(configFileName));
149
- }
150
- });
151
-
152
- return taskConfig;
153
- };
154
-
155
-
156
- exports.getConfig = getConfig;
157
- exports.getTaskConfig = getTaskConfig;
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const getPath = require('./get-path');
4
+ const runPreprocess = require('./run-preprocess');
5
+ const merge = require('./merge');
6
+ const logError = require('./log-error');
7
+
8
+ const each = require('lodash/each');
9
+ const omit = require('lodash/omit');
10
+ const isPlainObject = require('lodash/isPlainObject');
11
+ const isArray = require('lodash/isArray');
12
+ const reduce = require('lodash/reduce');
13
+ const get = require('lodash/get');
14
+
15
+
16
+ /**
17
+ * Returns builder and project specific task and plugin configurations combined
18
+ * Configuration is preprocessed
19
+ *
20
+ * @returns {object} Task configurations
21
+ */
22
+
23
+ let taskConfig = null;
24
+
25
+ function getConfig (builderConfigFile) {
26
+ if (!taskConfig) {
27
+ // Load all task configs
28
+ taskConfig = itterateConfig(loadConfig(), mergeConfigMode);
29
+
30
+ // 1. First load project specific config.js
31
+ const projectConfigPath = getPath.getProjectPath(builderConfigFile);
32
+ let projectTaskConfig = {};
33
+ let hasProjectConfigFile = true;
34
+
35
+ try {
36
+ fs.accessSync(projectConfigPath);
37
+ } catch (err) {
38
+ logError({'plugin': 'static-website-builder', 'message': `Couldn't find configuration file "${ projectConfigPath }"`});
39
+ hasProjectConfigFile = false;
40
+ }
41
+
42
+ if (hasProjectConfigFile) {
43
+ projectTaskConfig = itterateConfig(require(projectConfigPath), mergeConfigMode);
44
+ }
45
+
46
+ // 2. Marge plugins into the config, each plugin is just a config
47
+ const plugins = (taskConfig.plugins || []).concat(projectTaskConfig.plugins || []);
48
+ if (plugins) {
49
+ taskConfig.plugins = null;
50
+ projectTaskConfig.plugins = null;
51
+
52
+ each(plugins, (plugin) => {
53
+ taskConfig = merge(taskConfig, itterateConfig(plugin, mergeConfigMode));
54
+ });
55
+ }
56
+
57
+ // 3. Only after plugins has been executed, merge project specific config.js into main config
58
+ if (projectTaskConfig) {
59
+ taskConfig = merge(taskConfig, projectTaskConfig);
60
+ }
61
+
62
+ // 4. Preprocess
63
+ taskConfig = runPreprocess(taskConfig);
64
+ }
65
+
66
+ return taskConfig;
67
+ };
68
+
69
+ /**
70
+ * Returns task sub-config by path
71
+ *
72
+ * @param {...string} path Path to the sub-config
73
+ * @returns {any} Task sub-config
74
+ */
75
+ function getTaskConfig (...path) {
76
+ return get(getConfig(), path, null);
77
+ }
78
+
79
+ /**
80
+ * Itterate over each config property and call function on
81
+ * each object or array
82
+ *
83
+ * @param {*} object
84
+ * @param {*} fn
85
+ * @protected
86
+ */
87
+ function itterateConfig (config, fn) {
88
+ if (config === false) return false;
89
+ const base = isPlainObject(config) ? {} : [];
90
+
91
+ return reduce(config, (object, value, key) => {
92
+ if (isPlainObject(value)) {
93
+ object[key]= itterateConfig(fn(value), fn);
94
+ } else if (isArray(value)) {
95
+ object[key]= itterateConfig(value, fn);
96
+ } else {
97
+ object[key] = value;
98
+ }
99
+
100
+ return object;
101
+ }, base);
102
+ }
103
+
104
+ /**
105
+ * Merge 'production' or 'development' mode sub-ojbects into an object and remove
106
+ * mode sub-objects
107
+ *
108
+ * @param {object} config Config
109
+ * @returns {object} Config
110
+ * @protected
111
+ */
112
+ function mergeConfigMode (config) {
113
+ if ('production' in config || 'development' in config) {
114
+ const mode = global.production ? 'production' : 'development';
115
+ const value = merge(config, config[mode]);
116
+
117
+ if (value !== false) {
118
+ return omit(value, ['production', 'development']);
119
+ } else {
120
+ return value;
121
+ }
122
+ } else {
123
+ return config;
124
+ }
125
+ }
126
+
127
+ /**
128
+ * Load config files
129
+ *
130
+ * @returns {object} Configuration
131
+ * @protected
132
+ */
133
+ function loadConfig () {
134
+ const taskFolder = path.resolve(__dirname, '../tasks');
135
+ let taskConfig = {};
136
+
137
+ fs.readdirSync(taskFolder).forEach(folderName => {
138
+ // Ignore task folders which start with underscore
139
+ if (folderName[0] !== '_') {
140
+ const configFileName = path.resolve(taskFolder, folderName, 'config.js');
141
+
142
+ try {
143
+ fs.accessSync(configFileName);
144
+ } catch (err) {
145
+ return;
146
+ }
147
+
148
+ taskConfig = merge(taskConfig, require(configFileName));
149
+ }
150
+ });
151
+
152
+ return taskConfig;
153
+ };
154
+
155
+
156
+ exports.getConfig = getConfig;
157
+ exports.getTaskConfig = getTaskConfig;
@@ -1,23 +1,23 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
-
4
- /**
5
- * Returns list of filenames in folder recursively
6
- *
7
- * @param {string} folder Folder path
8
- * @param {string} [subFolder=''] Subfolder path
9
- * @returns {array} List of filenames, relative to folder
10
- */
11
- module.exports = function getFileNamesSync (folder, subFolder = '') {
12
- let fileNames = []
13
-
14
- fs.readdirSync(folder, { withFileTypes: true }).forEach(file => {
15
- if (file.isDirectory()) {
16
- fileNames = fileNames.concat(getFileNamesSync(path.join(folder, file.name), path.join(subFolder, file.name)));
17
- } else {
18
- fileNames.push(path.join(subFolder, file.name))
19
- }
20
- });
21
-
22
- return fileNames;
23
- }
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ /**
5
+ * Returns list of filenames in folder recursively
6
+ *
7
+ * @param {string} folder Folder path
8
+ * @param {string} [subFolder=''] Subfolder path
9
+ * @returns {array} List of filenames, relative to folder
10
+ */
11
+ module.exports = function getFileNamesSync (folder, subFolder = '') {
12
+ let fileNames = []
13
+
14
+ fs.readdirSync(folder, { withFileTypes: true }).forEach(file => {
15
+ if (file.isDirectory()) {
16
+ fileNames = fileNames.concat(getFileNamesSync(path.join(folder, file.name), path.join(subFolder, file.name)));
17
+ } else {
18
+ fileNames.push(path.join(subFolder, file.name))
19
+ }
20
+ });
21
+
22
+ return fileNames;
23
+ }