@videinfra/static-website-builder 1.4.2 → 1.5.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.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,18 @@ 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.5.1] - 2022-04-14
8
+ ### Fixed
9
+ - Dependency update
10
+
11
+ ## [1.5.0] - 2022-04-13
12
+ ### Fixed
13
+ - Read files in `data` folder recursively
14
+
15
+ ## [1.4.3] - 2022-03-08
16
+ ### Fixed
17
+ - Fixed negative glob paths not working
18
+
7
19
  ## [1.4.2] - 2021-08-27
8
20
  ### Fixed
9
21
  - Fixed postcss-ignore-plugin only removing and adding content in unrelated files
package/init/index.js CHANGED
@@ -6,7 +6,6 @@ const folderExists = require('../lib/init/folder-exists');
6
6
  const getFolderList = require('../lib/init/get-folder-list');
7
7
  const chalk = require('chalk');
8
8
 
9
-
10
9
  module.exports = function init (template = 'default') {
11
10
  let templateName = template || 'default';
12
11
  let copyFrom = path.getBuilderPath('init', templateName);
@@ -0,0 +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
+ }
@@ -0,0 +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
+ }
@@ -22,7 +22,10 @@ class GlobObject {
22
22
  if (this.pathsArr.length) {
23
23
  this.map((basePath) => {
24
24
  return pathsArr.map((subPath) => {
25
- return path.join(basePath, subPath);
25
+ // If subpath starts with specia character "!" then prepend that to the begining of full paths
26
+ const negativePath = subPath[0] === '!' ? '!' : '';
27
+ const subPathNormalized = negativePath ? subPath.substr(1) : subPath;
28
+ return negativePath + path.join(basePath, subPathNormalized);
26
29
  });
27
30
  });
28
31
  } else {
package/lib/log-error.js CHANGED
@@ -1,4 +1,4 @@
1
- var chalk = require('chalk');
1
+ const chalk = require('chalk');
2
2
 
3
3
  module.exports = function (error) {
4
4
  if (error.plugin) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@videinfra/static-website-builder",
3
- "version": "1.4.2",
3
+ "version": "1.5.1",
4
4
  "description": "Customizable static site project builder",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -24,16 +24,16 @@
24
24
  "test": "gulp build --silent --config=init/test/config/config.js && jest"
25
25
  },
26
26
  "dependencies": {
27
- "@babel/core": "^7.12.3",
28
- "@babel/preset-env": "^7.12.1",
29
- "autoprefixer": "^9.6.1",
30
- "babel-loader": "^8.2.1",
31
- "browser-sync": "^2.26.13",
27
+ "@babel/core": "^7.17.9",
28
+ "@babel/preset-env": "^7.16.11",
29
+ "autoprefixer": "^9.8.8",
30
+ "babel-loader": "^8.2.4",
31
+ "browser-sync": "^2.27.9",
32
32
  "chalk": "4.0.0",
33
- "chokidar": "^3.5.1",
34
- "cross-env": "^7.0.2",
35
- "cssnano": "^4.1.10",
36
- "del": "^5.1.0",
33
+ "chokidar": "^3.5.3",
34
+ "cross-env": "^7.0.3",
35
+ "cssnano": "^4.1.11",
36
+ "del": "^6.0.0",
37
37
  "gulp": "^4.0.2",
38
38
  "gulp-cached": "^1.1.1",
39
39
  "gulp-data": "^1.3.1",
@@ -43,18 +43,18 @@
43
43
  "gulp-ignore": "^3.0.0",
44
44
  "gulp-plumber": "^1.2.1",
45
45
  "gulp-postcss": "^8.0.0",
46
- "gulp-sass": "^4.1.0",
46
+ "gulp-sass": "^4.1.1",
47
47
  "gulp-sizereport": "^1.2.1",
48
48
  "gulp-sourcemaps": "^3.0.0",
49
- "gulp-svgmin": "^3.0.0",
50
- "gulp-svgstore": "^7.0.1",
49
+ "gulp-svgmin": "^4.1.0",
50
+ "gulp-svgstore": "^9.0.0",
51
51
  "gulp-twig": "^1.2.0",
52
- "minimist": "^1.2.5",
53
- "nano-memoize": "^1.2.1",
54
- "webpack": "^4.44.2",
52
+ "minimist": "^1.2.6",
53
+ "nano-memoize": "^1.3.0",
54
+ "webpack": "^4.46.0",
55
55
  "webpack-stream": "^5.2.1"
56
56
  },
57
57
  "devDependencies": {
58
- "jest": "^26.6.3"
58
+ "jest": "^27.5.1"
59
59
  }
60
60
  }
@@ -1,4 +1,3 @@
1
- const fs = require('fs');
2
1
  const path = require('path');
3
2
  const reduce = require('lodash/reduce');
4
3
  const micromatch = require('micromatch'); // gulp dependency
@@ -7,26 +6,9 @@ const merge = require('../../lib/merge');
7
6
  const getPaths = require('../../lib/get-path');
8
7
  const getConfig = require('../../lib/get-config');
9
8
  const logError = require('../../lib/log-error');
9
+ const getFileNamesSync = require('../../lib/get-file-names');
10
+ const camelizeFileName = require('../../lib/camelize-file-name');
10
11
 
11
- /**
12
- * Camelize filename
13
- *
14
- * @param {string} str File name
15
- * @returns {string} Camelized name
16
- */
17
- function camelizeFileName (str) {
18
- return str
19
- // Remove extension
20
- .replace(/\.[^.]+$/ig, '')
21
- // Replace non alpha-numeric characters
22
- .replace(/[^a-z0-9]/ig, ' ')
23
- // Uppercase words
24
- .replace(/(?:^\w|[A-Z]|\b\w)/g, function(word, index) {
25
- return index === 0 ? word.toLowerCase() : word.toUpperCase();
26
- })
27
- // Remove empty spaces
28
- .replace(/\s+/g, '');
29
- }
30
12
 
31
13
  module.exports = function getData () {
32
14
  const folders = getPaths.getSourcePaths('data');
@@ -36,7 +18,7 @@ module.exports = function getData () {
36
18
  const group = getConfig.getTaskConfig('data', 'groupByFileName');
37
19
 
38
20
  const data = reduce(folders, (data, folder) => {
39
- fs.readdirSync(folder).forEach(fileName => {
21
+ getFileNamesSync(folder).forEach(fileName => {
40
22
  // Ignore files matching 'ignore' list
41
23
  if (ignore.length && micromatch.isMatch(fileName, ignore)) {
42
24
  return;
@@ -0,0 +1,11 @@
1
+ const camelizeFileName = require('../lib/camelize-file-name');
2
+
3
+ test('Camelize file name', () => {
4
+ expect(camelizeFileName('test-file-name')).toBe('testFileName');
5
+ expect(camelizeFileName('testFileName')).toBe('testFileName');
6
+ expect(camelizeFileName('testFile_name')).toBe('testFileName');
7
+ expect(camelizeFileName('test-file-name.jpg')).toBe('testFileName');
8
+ expect(camelizeFileName('testFileName.jpg')).toBe('testFileName');
9
+ expect(camelizeFileName('test-āēūīķļ-name.jpg.png')).toBe('testName');
10
+ expect(camelizeFileName('.gitignore')).toBe('gitignore');
11
+ });
@@ -84,6 +84,11 @@ test('glob map', () => {
84
84
  expect(output2).toEqual(['/a/some/folder/b', '/a/other/folder/b']);
85
85
  });
86
86
 
87
+ test('glob negative', () => {
88
+ const output = glob.paths('/some/folder').paths('!/assets/**/*.*').generate();
89
+ expect(output).toEqual(['!/some/folder/assets/**/*.*']);
90
+ });
91
+
87
92
  test('glob generate', () => {
88
93
  const output = glob.generate(
89
94
  glob.paths(['/a', '/b']).allFiles(),