@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.
Files changed (122) hide show
  1. package/.prettierrc +11 -11
  2. package/CHANGELOG.md +214 -210
  3. package/README.md +102 -102
  4. package/bin/builder.js +40 -40
  5. package/eslint.config.js +39 -39
  6. package/gulpfile.js +63 -63
  7. package/init/default/config/config.js +44 -44
  8. package/init/default/src/html/data/global.js +9 -9
  9. package/init/default/src/javascripts/_entries.js +14 -14
  10. package/init/index.js +63 -63
  11. package/init/test/.env +6 -6
  12. package/init/test/.env.local +3 -2
  13. package/init/test/config/config.js +71 -67
  14. package/init/test/src/html/404.twig +12 -12
  15. package/init/test/src/html/data/global.js +10 -10
  16. package/init/test/src/html/env.twig +21 -21
  17. package/init/test/src/html/layouts/base.twig +1 -1
  18. package/init/test/src/html/other.twig +9 -9
  19. package/init/test/src/html/preposition.twig +4 -4
  20. package/init/test/src/javascripts/_entries-alt.js +10 -10
  21. package/init/test/src/javascripts/_entries.js +19 -19
  22. package/init/test/src/javascripts/common.js +13 -13
  23. package/init/test/src/javascripts/main.js +8 -8
  24. package/init/test/src/javascripts/something.ts +9 -9
  25. package/init/test/src/stylesheets/autoprefixer-test.scss +3 -3
  26. package/init/test/src/stylesheets/env-test.scss +28 -28
  27. package/init/test/src/stylesheets/ignore-test.scss +4 -4
  28. package/init/test/src/stylesheets/nested-calc-test.scss +3 -3
  29. package/init/test/src/stylesheets/sub-folder/import-test.scss +2 -2
  30. package/lib/camelize-file-name.js +21 -21
  31. package/lib/generate-gulp-tasks.js +85 -85
  32. package/lib/get-config.js +203 -204
  33. package/lib/get-file-names.js +23 -23
  34. package/lib/get-path.js +102 -102
  35. package/lib/globs-helper.js +243 -243
  36. package/lib/gulp/dynamic-task.js +8 -8
  37. package/lib/gulp/resolve-dynamic-task.js +11 -11
  38. package/lib/gulp/task-before-dest.js +8 -8
  39. package/lib/gulp/task-end.js +10 -10
  40. package/lib/gulp/task-start.js +12 -12
  41. package/lib/gulp/task-watch.js +66 -66
  42. package/lib/init/copy-folder.js +50 -50
  43. package/lib/init/folder-exists.js +10 -10
  44. package/lib/init/get-folder-list.js +16 -16
  45. package/lib/init/merge-package.js +17 -17
  46. package/lib/init/read-package.js +17 -17
  47. package/lib/log-error.js +15 -15
  48. package/lib/merge.js +27 -27
  49. package/lib/run-preprocess.js +32 -32
  50. package/lib/task-order.js +19 -19
  51. package/package.json +68 -68
  52. package/plugins/example/preprocess-config.js +17 -17
  53. package/plugins/example/task.js +55 -55
  54. package/plugins/example.js +38 -38
  55. package/plugins/sass-engine/preprocess-config.js +59 -59
  56. package/plugins/sass.js +41 -41
  57. package/plugins/twig/lodash-filters/filters.js +91 -91
  58. package/plugins/twig/lodash-filters.js +14 -14
  59. package/plugins/twig/symfony-filters/filters.js +102 -102
  60. package/plugins/twig/symfony-filters/preposition_nbsp.js +77 -77
  61. package/plugins/twig/symfony-filters.js +14 -14
  62. package/plugins/twig/symfony-functions/functions.js +31 -31
  63. package/plugins/twig/symfony-functions.js +14 -14
  64. package/plugins/twig-engine/preprocess-config.js +53 -53
  65. package/plugins/twig.js +74 -74
  66. package/tasks/browser-sync/config.js +39 -39
  67. package/tasks/browser-sync/preprocess-config.js +32 -32
  68. package/tasks/browser-sync/task.js +9 -9
  69. package/tasks/clean/config.js +20 -20
  70. package/tasks/clean/preprocess-config.js +19 -19
  71. package/tasks/clean/task.js +7 -7
  72. package/tasks/data/config.js +34 -34
  73. package/tasks/data/data-loader-js.js +14 -14
  74. package/tasks/data/data-loader-json.js +5 -5
  75. package/tasks/data/get-data.js +96 -96
  76. package/tasks/env/config.js +26 -23
  77. package/tasks/env/get-env.js +113 -81
  78. package/tasks/fonts/config.js +24 -24
  79. package/tasks/fonts/task.js +47 -47
  80. package/tasks/global/config.js +7 -7
  81. package/tasks/html/config.js +42 -42
  82. package/tasks/html/task.js +91 -91
  83. package/tasks/icons/config.js +47 -47
  84. package/tasks/icons/preprocess-config.js +60 -60
  85. package/tasks/icons/task.js +56 -56
  86. package/tasks/images/config.js +27 -27
  87. package/tasks/images/task.js +46 -46
  88. package/tasks/javascripts/config.js +69 -69
  89. package/tasks/javascripts/preprocess-config.js +109 -109
  90. package/tasks/javascripts/task.js +86 -86
  91. package/tasks/sitemap/config.js +48 -48
  92. package/tasks/sitemap/preprocess-config.js +18 -18
  93. package/tasks/sitemap/task.js +69 -69
  94. package/tasks/sizereport/config.js +23 -23
  95. package/tasks/sizereport/task.js +16 -16
  96. package/tasks/static/config.js +27 -27
  97. package/tasks/static/task.js +46 -46
  98. package/tasks/stylesheets/config.js +85 -85
  99. package/tasks/stylesheets/preprocess-config.js +41 -41
  100. package/tasks/stylesheets/task.js +73 -73
  101. package/tests/build/build.test.js +153 -153
  102. package/tests/camelize-file-name.test.js +11 -11
  103. package/tests/generate-gulp-tasks.test.js +78 -78
  104. package/tests/glob-helper.test.js +99 -99
  105. package/tests/merge.test.js +10 -10
  106. package/tests/preposition_nbsp.test.js +50 -50
  107. package/tests/run-preprocess.test.js +90 -90
  108. package/tests/sass-stringify.test.js +24 -24
  109. package/tests/sitemap.test.js +12 -12
  110. package/vendor/gulp-rolldown/index.js +151 -151
  111. package/vendor/gulp-rolldown/plugin-raw.js +17 -17
  112. package/vendor/gulp-rolldown/plugin-virtual-entry.js +30 -30
  113. package/vendor/gulp-sass/CHANGELOG.md +168 -168
  114. package/vendor/gulp-sass/LICENSE +20 -20
  115. package/vendor/gulp-sass/README.md +187 -187
  116. package/vendor/gulp-sass/index.js +208 -208
  117. package/vendor/gulp-sass/package.json +61 -61
  118. package/vendor/gulp-sass/sass-stringify.js +32 -32
  119. package/vendor/gulp-twig/LICENSE +20 -20
  120. package/vendor/gulp-twig/README.md +167 -167
  121. package/vendor/gulp-twig/index.js +138 -138
  122. package/vendor/gulp-twig/package.json +44 -44
@@ -1,99 +1,99 @@
1
- import glob from '../lib/globs-helper.js';
2
-
3
- test('glob normalize unix path', () => {
4
- const input = '/some/folder';
5
- const output = glob.paths(input).generate();
6
- expect(output).toEqual([input]);
7
- });
8
-
9
- test('glob normalize windows path', () => {
10
- const output = glob.paths('I:\\\\some\\folder\\').generate();
11
- expect(output).toEqual(['I://some/folder/']);
12
- });
13
-
14
- test('glob normalize with array', () => {
15
- const output = glob.paths([
16
- '/some/folder',
17
- 'I:\\\\some\\folder\\'
18
- ]).generate();
19
-
20
- expect(output).toEqual([
21
- '/some/folder',
22
- 'I://some/folder/'
23
- ]);
24
- });
25
-
26
- test('glob path merging', () => {
27
- const output = glob.paths('/some/folder').paths(['', '/a', '/b']).generate();
28
- expect(output).toEqual(['/some/folder', '/some/folder/a', '/some/folder/b']);
29
- });
30
-
31
- test('glob multi path merging', () => {
32
- const output = glob.paths(['/some/folder', '/other/folder']).paths(['/a', '/b']).generate();
33
- expect(output).toEqual(['/some/folder/a', '/some/folder/b', '/other/folder/a', '/other/folder/b']);
34
- });
35
-
36
- test('glob filesWithExtensions, without extensions', () => {
37
- const output = glob.paths('/some/folder').filesWithExtensions().generate();
38
- expect(output).toEqual(['/some/folder']);
39
- });
40
-
41
- test('glob filesWithExtensions, single extension', () => {
42
- const output = glob.paths('/some/folder').filesWithExtensions('jpg').generate();
43
- expect(output).toEqual(['/some/folder/**/*.jpg']);
44
- });
45
-
46
- test('glob filesWithExtensions, single extension array', () => {
47
- const output = glob.paths('/some/folder').filesWithExtensions(['jpg']).generate();
48
- expect(output).toEqual(['/some/folder/**/*.jpg']);
49
- });
50
-
51
- test('glob filesWithExtensions, multiple extensions', () => {
52
- const output1 = glob.paths('/some/folder').filesWithExtensions(['jpg', 'png']).generate();
53
- expect(output1).toEqual(['/some/folder/**/*.{jpg,png}']);
54
-
55
- const output2 = glob.paths(['/some/folder', '/other/folder']).filesWithExtensions(['jpg', 'png']).generate();
56
- expect(output2).toEqual(['/some/folder/**/*.{jpg,png}', '/other/folder/**/*.{jpg,png}']);
57
- });
58
-
59
-
60
- test('glob allFiles', () => {
61
- const output1 = glob.paths('/some/folder').allFiles().generate();
62
- expect(output1).toEqual(['/some/folder/**']);
63
-
64
- const output2 = glob.paths(['/some/folder', '/other/folder']).allFiles().generate();
65
- expect(output2).toEqual(['/some/folder/**', '/other/folder/**']);
66
- });
67
-
68
- test('glob allFiles with ignore', () => {
69
- const output1 = glob.paths('/some/folder').allFiles().ignore().generate();
70
- expect(output1).toEqual(['!/some/folder/**']);
71
-
72
- const output2 = glob.paths('/some/folder').ignore().allFiles().generate();
73
- expect(output2).toEqual(['!/some/folder/**']);
74
-
75
- const output3 = glob.paths(['/some/folder', '/other/folder']).ignore().allFiles().generate();
76
- expect(output3).toEqual(['!/some/folder/**', '!/other/folder/**']);
77
- });
78
-
79
- test('glob map', () => {
80
- const output1 = glob.paths('/some/folder').map((path) => `/a${ path }/b`).generate();
81
- expect(output1).toEqual(['/a/some/folder/b']);
82
-
83
- const output2 = glob.paths(['/some/folder', '/other/folder']).map((path) => `/a${ path }/b`).generate();
84
- expect(output2).toEqual(['/a/some/folder/b', '/a/other/folder/b']);
85
- });
86
-
87
- test('glob negative', () => {
88
- const output = glob.paths('/some/folder').paths('!/assets/**/*.*').generate();
89
- expect(output).toEqual(['!/some/folder/assets/**/*.*']);
90
- });
91
-
92
- test('glob generate', () => {
93
- const output = glob.generate(
94
- glob.paths(['/a', '/b']).allFiles(),
95
- glob.paths(['/c', '/d']).allFiles().ignore(),
96
- );
97
-
98
- expect(output).toEqual(['/a/**', '/b/**', '!/c/**', '!/d/**']);
99
- });
1
+ import glob from '../lib/globs-helper.js';
2
+
3
+ test('glob normalize unix path', () => {
4
+ const input = '/some/folder';
5
+ const output = glob.paths(input).generate();
6
+ expect(output).toEqual([input]);
7
+ });
8
+
9
+ test('glob normalize windows path', () => {
10
+ const output = glob.paths('I:\\\\some\\folder\\').generate();
11
+ expect(output).toEqual(['I://some/folder/']);
12
+ });
13
+
14
+ test('glob normalize with array', () => {
15
+ const output = glob.paths([
16
+ '/some/folder',
17
+ 'I:\\\\some\\folder\\'
18
+ ]).generate();
19
+
20
+ expect(output).toEqual([
21
+ '/some/folder',
22
+ 'I://some/folder/'
23
+ ]);
24
+ });
25
+
26
+ test('glob path merging', () => {
27
+ const output = glob.paths('/some/folder').paths(['', '/a', '/b']).generate();
28
+ expect(output).toEqual(['/some/folder', '/some/folder/a', '/some/folder/b']);
29
+ });
30
+
31
+ test('glob multi path merging', () => {
32
+ const output = glob.paths(['/some/folder', '/other/folder']).paths(['/a', '/b']).generate();
33
+ expect(output).toEqual(['/some/folder/a', '/some/folder/b', '/other/folder/a', '/other/folder/b']);
34
+ });
35
+
36
+ test('glob filesWithExtensions, without extensions', () => {
37
+ const output = glob.paths('/some/folder').filesWithExtensions().generate();
38
+ expect(output).toEqual(['/some/folder']);
39
+ });
40
+
41
+ test('glob filesWithExtensions, single extension', () => {
42
+ const output = glob.paths('/some/folder').filesWithExtensions('jpg').generate();
43
+ expect(output).toEqual(['/some/folder/**/*.jpg']);
44
+ });
45
+
46
+ test('glob filesWithExtensions, single extension array', () => {
47
+ const output = glob.paths('/some/folder').filesWithExtensions(['jpg']).generate();
48
+ expect(output).toEqual(['/some/folder/**/*.jpg']);
49
+ });
50
+
51
+ test('glob filesWithExtensions, multiple extensions', () => {
52
+ const output1 = glob.paths('/some/folder').filesWithExtensions(['jpg', 'png']).generate();
53
+ expect(output1).toEqual(['/some/folder/**/*.{jpg,png}']);
54
+
55
+ const output2 = glob.paths(['/some/folder', '/other/folder']).filesWithExtensions(['jpg', 'png']).generate();
56
+ expect(output2).toEqual(['/some/folder/**/*.{jpg,png}', '/other/folder/**/*.{jpg,png}']);
57
+ });
58
+
59
+
60
+ test('glob allFiles', () => {
61
+ const output1 = glob.paths('/some/folder').allFiles().generate();
62
+ expect(output1).toEqual(['/some/folder/**']);
63
+
64
+ const output2 = glob.paths(['/some/folder', '/other/folder']).allFiles().generate();
65
+ expect(output2).toEqual(['/some/folder/**', '/other/folder/**']);
66
+ });
67
+
68
+ test('glob allFiles with ignore', () => {
69
+ const output1 = glob.paths('/some/folder').allFiles().ignore().generate();
70
+ expect(output1).toEqual(['!/some/folder/**']);
71
+
72
+ const output2 = glob.paths('/some/folder').ignore().allFiles().generate();
73
+ expect(output2).toEqual(['!/some/folder/**']);
74
+
75
+ const output3 = glob.paths(['/some/folder', '/other/folder']).ignore().allFiles().generate();
76
+ expect(output3).toEqual(['!/some/folder/**', '!/other/folder/**']);
77
+ });
78
+
79
+ test('glob map', () => {
80
+ const output1 = glob.paths('/some/folder').map((path) => `/a${ path }/b`).generate();
81
+ expect(output1).toEqual(['/a/some/folder/b']);
82
+
83
+ const output2 = glob.paths(['/some/folder', '/other/folder']).map((path) => `/a${ path }/b`).generate();
84
+ expect(output2).toEqual(['/a/some/folder/b', '/a/other/folder/b']);
85
+ });
86
+
87
+ test('glob negative', () => {
88
+ const output = glob.paths('/some/folder').paths('!/assets/**/*.*').generate();
89
+ expect(output).toEqual(['!/some/folder/assets/**/*.*']);
90
+ });
91
+
92
+ test('glob generate', () => {
93
+ const output = glob.generate(
94
+ glob.paths(['/a', '/b']).allFiles(),
95
+ glob.paths(['/c', '/d']).allFiles().ignore(),
96
+ );
97
+
98
+ expect(output).toEqual(['/a/**', '/b/**', '!/c/**', '!/d/**']);
99
+ });
@@ -1,10 +1,10 @@
1
- import merge from '../lib/merge.js';
2
-
3
- test('Merge arrays', () => {
4
- const obj1 = {'arr': ['a', 'b', {'c': 1, 'd': 2}]};
5
- const obj2 = {'arr': ['d', 'e', {'d': 3, 'f': 4}]};
6
-
7
- expect(merge(obj1, obj2)).toEqual(
8
- {'arr': ['a', 'b', {'c': 1, 'd': 2}, 'd', 'e', {'d': 3, 'f': 4}]}
9
- );
10
- });
1
+ import merge from '../lib/merge.js';
2
+
3
+ test('Merge arrays', () => {
4
+ const obj1 = {'arr': ['a', 'b', {'c': 1, 'd': 2}]};
5
+ const obj2 = {'arr': ['d', 'e', {'d': 3, 'f': 4}]};
6
+
7
+ expect(merge(obj1, obj2)).toEqual(
8
+ {'arr': ['a', 'b', {'c': 1, 'd': 2}, 'd', 'e', {'d': 3, 'f': 4}]}
9
+ );
10
+ });
@@ -1,50 +1,50 @@
1
- import path from 'path';
2
- import { fileURLToPath } from 'node:url';
3
- import fsPromises from 'fs/promises';
4
- import preposition_nbsp from '../plugins/twig/symfony-filters/preposition_nbsp.js';
5
-
6
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
7
- const publicPath = path.resolve(__dirname, 'build', 'public');
8
-
9
- test('preposition_nbsp english', () => {
10
- expect(preposition_nbsp('hello world')).toEqual('hello world');
11
- expect(preposition_nbsp('hello at')).toEqual('hello at');
12
- expect(preposition_nbsp('hello at. world')).toEqual('hello at. world');
13
- expect(preposition_nbsp('hello at world')).toEqual('hello at world');
14
- expect(preposition_nbsp('hello before at world')).toEqual('hello before at world');
15
- });
16
-
17
- test('preposition_nbsp russian', () => {
18
- expect(preposition_nbsp('ппппп дддд')).toEqual('ппппп дддд');
19
- expect(preposition_nbsp('ппппп над')).toEqual('ппппп над');
20
- expect(preposition_nbsp('ппппп над. дддд')).toEqual('ппппп над. дддд');
21
- expect(preposition_nbsp('ппппп над дддд')).toEqual('ппппп над дддд');
22
- expect(preposition_nbsp('ппппп before над дддд')).toEqual('ппппп before над дддд');
23
- });
24
-
25
- test('preposition_nbsp hyphens', () => {
26
- expect(preposition_nbsp('hello — world')).toEqual('hello — world');
27
- expect(preposition_nbsp('hello – world')).toEqual('hello – world');
28
- expect(preposition_nbsp('hello - world')).toEqual('hello - world');
29
- expect(preposition_nbsp('hello ‐ world')).toEqual('hello ‐ world');
30
- expect(preposition_nbsp('hello ‒ world')).toEqual('hello ‒ world');
31
- expect(preposition_nbsp('hello ‐ world')).toEqual('hello ‐ world');
32
-
33
- // Don't replace hyphens with entities if not needed
34
- expect(preposition_nbsp('hello— world')).toEqual('hello— world');
35
-
36
- // Hyphens + prepositions
37
- expect(preposition_nbsp('hello ‒ at world')).toEqual('hello ‒ at world');
38
- });
39
-
40
- test('preposition_nbsp skip tags', () => {
41
- expect(preposition_nbsp('<a href="https://www.google.com">A nice day</a>')).toEqual('<a href="https://www.google.com">A&nbsp;nice day</a>');
42
- expect(preposition_nbsp('Start <a download>This is a nice day</a> at <a download>another nice day</a>')).toEqual('Start <a download>This is a&nbsp;nice day</a> at&nbsp;<a download>another nice day</a>');
43
- expect(preposition_nbsp('<link rel="preload" href="/assets/fonts/...ttf" as="font" type="font/ttf" crossorigin>')).toEqual('<link rel="preload" href="/assets/fonts/...ttf" as="font" type="font/ttf" crossorigin>');
44
- });
45
-
46
- test('Preposition TWIG filter applied', () => {
47
- return fsPromises.readFile(path.resolve(publicPath, 'preposition.html'), { encoding: 'utf8' }).then((html) => {
48
- expect(html).toBe('<html><body>hello at&nbsp;world</body></html>');
49
- });
50
- });
1
+ import path from 'path';
2
+ import { fileURLToPath } from 'node:url';
3
+ import fsPromises from 'fs/promises';
4
+ import preposition_nbsp from '../plugins/twig/symfony-filters/preposition_nbsp.js';
5
+
6
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
7
+ const publicPath = path.resolve(__dirname, 'build', 'public');
8
+
9
+ test('preposition_nbsp english', () => {
10
+ expect(preposition_nbsp('hello world')).toEqual('hello world');
11
+ expect(preposition_nbsp('hello at')).toEqual('hello at');
12
+ expect(preposition_nbsp('hello at. world')).toEqual('hello at. world');
13
+ expect(preposition_nbsp('hello at world')).toEqual('hello at&nbsp;world');
14
+ expect(preposition_nbsp('hello before at world')).toEqual('hello before&nbsp;at&nbsp;world');
15
+ });
16
+
17
+ test('preposition_nbsp russian', () => {
18
+ expect(preposition_nbsp('ппппп дддд')).toEqual('ппппп дддд');
19
+ expect(preposition_nbsp('ппппп над')).toEqual('ппппп над');
20
+ expect(preposition_nbsp('ппппп над. дддд')).toEqual('ппппп над. дддд');
21
+ expect(preposition_nbsp('ппппп над дддд')).toEqual('ппппп над&nbsp;дддд');
22
+ expect(preposition_nbsp('ппппп before над дддд')).toEqual('ппппп before&nbsp;над&nbsp;дддд');
23
+ });
24
+
25
+ test('preposition_nbsp hyphens', () => {
26
+ expect(preposition_nbsp('hello — world')).toEqual('hello&nbsp;&mdash; world');
27
+ expect(preposition_nbsp('hello – world')).toEqual('hello&nbsp;&ndash; world');
28
+ expect(preposition_nbsp('hello - world')).toEqual('hello&nbsp;&#45; world');
29
+ expect(preposition_nbsp('hello ‐ world')).toEqual('hello&nbsp;&hyphen; world');
30
+ expect(preposition_nbsp('hello ‒ world')).toEqual('hello&nbsp;&#x2012; world');
31
+ expect(preposition_nbsp('hello &dash; world')).toEqual('hello&nbsp;&dash; world');
32
+
33
+ // Don't replace hyphens with entities if not needed
34
+ expect(preposition_nbsp('hello— world')).toEqual('hello— world');
35
+
36
+ // Hyphens + prepositions
37
+ expect(preposition_nbsp('hello ‒ at world')).toEqual('hello&nbsp;&#x2012; at&nbsp;world');
38
+ });
39
+
40
+ test('preposition_nbsp skip tags', () => {
41
+ expect(preposition_nbsp('<a href="https://www.google.com">A nice day</a>')).toEqual('<a href="https://www.google.com">A&nbsp;nice day</a>');
42
+ expect(preposition_nbsp('Start <a download>This is a nice day</a> at <a download>another nice day</a>')).toEqual('Start <a download>This is a&nbsp;nice day</a> at&nbsp;<a download>another nice day</a>');
43
+ expect(preposition_nbsp('<link rel="preload" href="/assets/fonts/...ttf" as="font" type="font/ttf" crossorigin>')).toEqual('<link rel="preload" href="/assets/fonts/...ttf" as="font" type="font/ttf" crossorigin>');
44
+ });
45
+
46
+ test('Preposition TWIG filter applied', () => {
47
+ return fsPromises.readFile(path.resolve(publicPath, 'preposition.html'), { encoding: 'utf8' }).then((html) => {
48
+ expect(html).toBe('<html><body>hello at&nbsp;world</body></html>');
49
+ });
50
+ });
@@ -1,90 +1,90 @@
1
- import runPreprocess from '../lib/run-preprocess.js';
2
- import { jest } from '@jest/globals';
3
-
4
- test('Disabled task doesn\'t run preprocess', () => {
5
- const preprocessCalled = jest.fn();
6
- const config = {
7
- 'task': false,
8
- 'preprocess': {
9
- 'task': [
10
- function () {
11
- preprocessCalled();
12
- }
13
- ]
14
- }
15
- };
16
-
17
- expect(runPreprocess(config).task).toBe(false);
18
- expect(preprocessCalled).not.toHaveBeenCalled();
19
- });
20
-
21
- test('Task without preprocess is the same', () => {
22
- const configTrue = {'task': {'a': 1}, 'preprocess': {'task': []}};
23
- expect(runPreprocess(configTrue).task).toEqual({'a': 1});
24
- });
25
-
26
- test('Preprocess returning false should result in false config', () => {
27
- const config = {
28
- 'task': {},
29
- 'preprocess': {
30
- 'task': [
31
- () => false
32
- ]
33
- }
34
- };
35
-
36
- expect(runPreprocess(config).task).toBe(false);
37
- });
38
-
39
- test('Preprocess returning non-object should result in same config config', () => {
40
- const configTrue = {'task': {'a': 1}, 'preprocess': {'task': [() => true]}};
41
- expect(runPreprocess(configTrue).task).toEqual({'a': 1});
42
-
43
- const configNumber = {'task': {'a': 1}, 'preprocess': {'task': [() => 1]}};
44
- expect(runPreprocess(configNumber).task).toEqual({'a': 1});
45
-
46
- const configString = {'task': {'a': 1}, 'preprocess': {'task': [() => 'string']}};
47
- expect(runPreprocess(configString).task).toEqual({'a': 1});
48
-
49
- // Task config can be an array, this is used for javascripts
50
- const configArray = {'task': {'a': 1}, 'preprocess': {'task': [() => ['a', 'b']]}};
51
- expect(runPreprocess(configArray).task).toEqual(['a', 'b']);
52
- });
53
-
54
- test('Preprocess returning false shouldn\'t call other preprocesses', () => {
55
- const preprocessCalled = jest.fn();
56
- const config = {
57
- 'task': {'a': 1},
58
- 'preprocess': {
59
- 'task': [
60
- () => false,
61
- () => preprocessCalled()
62
- ]
63
- }
64
- };
65
-
66
- expect(runPreprocess(config).task).toBe(false);
67
- expect(preprocessCalled).not.toHaveBeenCalled();
68
- });
69
-
70
- test('Preprocess values are passed', () => {
71
- const config = {
72
- 'task': {
73
- 'value0': 0
74
- },
75
- 'preprocess': {
76
- 'task': [
77
- (config) => {
78
- config.value1 = config.value0 + 1;
79
- return config;
80
- },
81
- (config) => {
82
- config.value2 = config.value1 + 1;
83
- return config;
84
- }
85
- ]
86
- }
87
- };
88
-
89
- expect(runPreprocess(config).task).toEqual({'value0': 0, 'value1': 1, 'value2': 2});
90
- });
1
+ import runPreprocess from '../lib/run-preprocess.js';
2
+ import { jest } from '@jest/globals';
3
+
4
+ test('Disabled task doesn\'t run preprocess', () => {
5
+ const preprocessCalled = jest.fn();
6
+ const config = {
7
+ 'task': false,
8
+ 'preprocess': {
9
+ 'task': [
10
+ function () {
11
+ preprocessCalled();
12
+ }
13
+ ]
14
+ }
15
+ };
16
+
17
+ expect(runPreprocess(config).task).toBe(false);
18
+ expect(preprocessCalled).not.toHaveBeenCalled();
19
+ });
20
+
21
+ test('Task without preprocess is the same', () => {
22
+ const configTrue = {'task': {'a': 1}, 'preprocess': {'task': []}};
23
+ expect(runPreprocess(configTrue).task).toEqual({'a': 1});
24
+ });
25
+
26
+ test('Preprocess returning false should result in false config', () => {
27
+ const config = {
28
+ 'task': {},
29
+ 'preprocess': {
30
+ 'task': [
31
+ () => false
32
+ ]
33
+ }
34
+ };
35
+
36
+ expect(runPreprocess(config).task).toBe(false);
37
+ });
38
+
39
+ test('Preprocess returning non-object should result in same config config', () => {
40
+ const configTrue = {'task': {'a': 1}, 'preprocess': {'task': [() => true]}};
41
+ expect(runPreprocess(configTrue).task).toEqual({'a': 1});
42
+
43
+ const configNumber = {'task': {'a': 1}, 'preprocess': {'task': [() => 1]}};
44
+ expect(runPreprocess(configNumber).task).toEqual({'a': 1});
45
+
46
+ const configString = {'task': {'a': 1}, 'preprocess': {'task': [() => 'string']}};
47
+ expect(runPreprocess(configString).task).toEqual({'a': 1});
48
+
49
+ // Task config can be an array, this is used for javascripts
50
+ const configArray = {'task': {'a': 1}, 'preprocess': {'task': [() => ['a', 'b']]}};
51
+ expect(runPreprocess(configArray).task).toEqual(['a', 'b']);
52
+ });
53
+
54
+ test('Preprocess returning false shouldn\'t call other preprocesses', () => {
55
+ const preprocessCalled = jest.fn();
56
+ const config = {
57
+ 'task': {'a': 1},
58
+ 'preprocess': {
59
+ 'task': [
60
+ () => false,
61
+ () => preprocessCalled()
62
+ ]
63
+ }
64
+ };
65
+
66
+ expect(runPreprocess(config).task).toBe(false);
67
+ expect(preprocessCalled).not.toHaveBeenCalled();
68
+ });
69
+
70
+ test('Preprocess values are passed', () => {
71
+ const config = {
72
+ 'task': {
73
+ 'value0': 0
74
+ },
75
+ 'preprocess': {
76
+ 'task': [
77
+ (config) => {
78
+ config.value1 = config.value0 + 1;
79
+ return config;
80
+ },
81
+ (config) => {
82
+ config.value2 = config.value1 + 1;
83
+ return config;
84
+ }
85
+ ]
86
+ }
87
+ };
88
+
89
+ expect(runPreprocess(config).task).toEqual({'value0': 0, 'value1': 1, 'value2': 2});
90
+ });
@@ -1,24 +1,24 @@
1
- import sassStingify from '../vendor/gulp-sass/sass-stringify.js';
2
-
3
- test('SASS stringify boolean', () => {
4
- expect(sassStingify(true)).toEqual('true');
5
- expect(sassStingify(false)).toEqual('false');
6
- });
7
-
8
- test('SASS stringify number', () => {
9
- expect(sassStingify(0)).toEqual('0');
10
- expect(sassStingify(-123)).toEqual('-123');
11
- expect(sassStingify(123.456)).toEqual('123.456');
12
- });
13
-
14
- test('SASS stringify falsy', () => {
15
- expect(sassStingify(null)).toEqual('false');
16
- expect(sassStingify(undefined)).toEqual('false');
17
- });
18
-
19
- test('SASS stringify object', () => {
20
- const obj1 = {env: {key1: 'value1', key2: null, key3: undefined, arr: ['a', 123, true] }};
21
- const out1 = "$env: (key1: 'value1', key2: false, key3: false, arr: ('a',123,true));";
22
-
23
- expect(sassStingify(obj1)).toEqual(out1);
24
- });
1
+ import sassStingify from '../vendor/gulp-sass/sass-stringify.js';
2
+
3
+ test('SASS stringify boolean', () => {
4
+ expect(sassStingify(true)).toEqual('true');
5
+ expect(sassStingify(false)).toEqual('false');
6
+ });
7
+
8
+ test('SASS stringify number', () => {
9
+ expect(sassStingify(0)).toEqual('0');
10
+ expect(sassStingify(-123)).toEqual('-123');
11
+ expect(sassStingify(123.456)).toEqual('123.456');
12
+ });
13
+
14
+ test('SASS stringify falsy', () => {
15
+ expect(sassStingify(null)).toEqual('false');
16
+ expect(sassStingify(undefined)).toEqual('false');
17
+ });
18
+
19
+ test('SASS stringify object', () => {
20
+ const obj1 = {env: {key1: 'value1', key2: null, key3: undefined, arr: ['a', 123, true] }};
21
+ const out1 = "$env: (key1: 'value1', key2: false, key3: false, arr: ('a',123,true));";
22
+
23
+ expect(sassStingify(obj1)).toEqual(out1);
24
+ });
@@ -1,12 +1,12 @@
1
- import path from 'path';
2
- import { fileURLToPath } from 'node:url';
3
- import fsPromises from 'fs/promises';
4
-
5
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
6
- const publicPath = path.resolve(__dirname, 'build', 'public');
7
-
8
- test("Sitemap generated, but doesn't include 404 page", () => {
9
- return fsPromises.readFile(path.resolve(publicPath, 'sitemap.xml'), { encoding: 'utf8' }).then((html) => {
10
- expect(html.includes('<loc>https://test-local.tld/404.html</loc>')).toBe(false);
11
- });
12
- });
1
+ import path from 'path';
2
+ import { fileURLToPath } from 'node:url';
3
+ import fsPromises from 'fs/promises';
4
+
5
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
6
+ const publicPath = path.resolve(__dirname, 'build', 'public');
7
+
8
+ test("Sitemap generated, but doesn't include 404 page", () => {
9
+ return fsPromises.readFile(path.resolve(publicPath, 'sitemap.xml'), { encoding: 'utf8' }).then((html) => {
10
+ expect(html.includes('<loc>https://test-local.tld/404.html</loc>')).toBe(false);
11
+ });
12
+ });