@videinfra/static-website-builder 2.0.3 → 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 -214
  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 -3
  13. package/init/test/config/config.js +71 -71
  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 -26
  77. package/tasks/env/get-env.js +113 -113
  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,153 +1,153 @@
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, 'public');
7
-
8
- test('TWIG templates rendered and minified with JS and JSON data', () => {
9
- return fsPromises.readFile(path.resolve(publicPath, 'index.html'), { encoding: 'utf8' }).then((html) => {
10
- expect(html).toBe('<html><body><h1>Hello World!</h1></body></html>');
11
- });
12
- });
13
-
14
- test('Multiple TWIG templates rendered', () => {
15
- expect.assertions(1);
16
- return expect(fsPromises.access(path.resolve(publicPath, 'other.html'))).resolves.toBe(undefined);
17
- });
18
-
19
- test('SASS variable test', () => {
20
- return fsPromises.readFile(path.resolve(publicPath, 'assets/stylesheets/variable-test.css'), { encoding: 'utf8' }).then((css) => {
21
- expect(css).toBe('main{background:#fff;color:#222}');
22
- });
23
- });
24
-
25
- test('SASS import test', () => {
26
- return fsPromises.readFile(path.resolve(publicPath, 'assets/stylesheets/import-test.css'), { encoding: 'utf8' }).then((css) => {
27
- expect(css).toBe('.btn{background:#222;color:#fff}');
28
- });
29
- });
30
-
31
- test('SASS sub-folder import test', () => {
32
- return fsPromises.readFile(path.resolve(publicPath, 'assets/stylesheets/sub-folder/import-test.css'), { encoding: 'utf8' }).then((css) => {
33
- expect(css).toBe('.btn{background:#222;color:#fff}');
34
- });
35
- });
36
-
37
- test('SASS autoprefixer test', () => {
38
- return fsPromises.readFile(path.resolve(publicPath, 'assets/stylesheets/autoprefixer-test.css'), { encoding: 'utf8' }).then((css) => {
39
- expect(css).toBe('main{clip-path:polygon(0 0,100% 0,100% 100%,0 100%)}');
40
- });
41
- });
42
-
43
- test('CSS nano ignore test', () => {
44
- return fsPromises.readFile(path.resolve(publicPath, 'assets/stylesheets/ignore-test.css'), { encoding: 'utf8' }).then((css) => {
45
- expect(css).toBe(':root{--yes: ;--no:initial}');
46
- });
47
- });
48
-
49
- test('CSS nano nested calc test', () => {
50
- return fsPromises.readFile(path.resolve(publicPath, 'assets/stylesheets/nested-calc-test.css'), { encoding: 'utf8' }).then((css) => {
51
- expect(css).toBe('body{padding-top:calc(10vw + 15vh)}');
52
- });
53
- });
54
-
55
- test('Font file woff copied', () => {
56
- expect.assertions(1);
57
- return expect(fsPromises.access(path.resolve(publicPath, 'assets/fonts/font.woff'))).resolves.toBe(undefined);
58
- });
59
-
60
- test('Font file fake not copied', () => {
61
- expect.assertions(1);
62
- return expect(fsPromises.access(path.resolve(publicPath, 'assets/fonts/font.fake'))).rejects.toThrow('no such file or directory');
63
- });
64
-
65
- test('shared.js file exists', () => {
66
- return Promise.all([
67
- fsPromises.readFile(path.resolve(publicPath, 'assets/javascripts/shared.js'), { encoding: 'utf8' }).then((js) => {
68
- expect(js.indexOf('console.log(`Shared file loaded`)')).not.toBe(-1);
69
- }),
70
- ]);
71
- });
72
-
73
- test('main.js file exists', () => {
74
- return Promise.all([
75
- fsPromises.readFile(path.resolve(publicPath, 'assets/javascripts/main.js'), { encoding: 'utf8' }).then((js) => {
76
- expect(js.indexOf('console.log(`Hello from main page!`')).not.toBe(-1);
77
- }),
78
- fsPromises.readFile(path.resolve(publicPath, 'assets/javascripts/alt/main.js'), { encoding: 'utf8' }).then((js) => {
79
- expect(js.indexOf('console.log(`Hello from main page!`')).not.toBe(-1);
80
- }),
81
- ]);
82
- });
83
-
84
- test('other.js file exists', () => {
85
- return fsPromises.readFile(path.resolve(publicPath, 'assets/javascripts/other.js'), { encoding: 'utf8' }).then((js) => {
86
- expect(js.indexOf('console.log(`Hello from other page!`)')).not.toBe(-1);
87
- });
88
- });
89
-
90
- test('something.ts was converted', () => {
91
- return Promise.all([
92
- fsPromises.readFile(path.resolve(publicPath, 'assets/javascripts/something.js'), { encoding: 'utf8' }).then((js) => {
93
- expect(js.indexOf('console.log({name:`something`})')).not.toBe(-1);
94
- }),
95
- ]);
96
- });
97
-
98
- test("alt/other.js file doesn't exist", async () => {
99
- expect(fsPromises.stat(path.resolve(publicPath, 'assets/javascripts/alt/other.js'))).rejects.toThrow();
100
- });
101
-
102
- test('.env and .env.local files loaded', () => {
103
- return Promise.all([
104
- fsPromises.readFile(path.resolve(publicPath, 'assets/javascripts/main.js'), { encoding: 'utf8' }).then((js) => {
105
- expect(js.indexOf('console.log(`env.host ==`,`https://test-local.tld`)')).not.toBe(-1);
106
- expect(js.indexOf('console.log(`env.foo ==`,`foo-global`)')).not.toBe(-1);
107
- expect(js.indexOf('console.log(`env.bar ==`,`bar-local`)')).not.toBe(-1);
108
- expect(js.indexOf('console.log(`env.typeBoolTrue ==`,!0)')).not.toBe(-1);
109
- expect(js.indexOf('console.log(`env.typeBoolFalse ==`,!1)')).not.toBe(-1);
110
- expect(js.indexOf('console.log(`env.typeNumber ==`,123.456)')).not.toBe(-1);
111
- }),
112
- fsPromises.readFile(path.resolve(publicPath, 'env.html'), { encoding: 'utf8' }).then((html) => {
113
- expect(html.indexOf('<p>HOST: https://test-local.tld</p>')).not.toBe(-1);
114
- expect(html.indexOf('<p>TYPE_BOOL_TRUE: pass</p>')).not.toBe(-1);
115
- expect(html.indexOf('<p>TYPE_BOOL_FALSE: pass</p>')).not.toBe(-1);
116
- expect(html.indexOf('<p>TYPE_NUMBER: 123.456</p>')).not.toBe(-1);
117
- }),
118
- fsPromises.readFile(path.resolve(publicPath, 'assets/stylesheets/env-test.css'), { encoding: 'utf8' }).then((css) => {
119
- expect(css.indexOf('.env-test:before{content:"https://test-local.tld"}')).not.toBe(-1);
120
- expect(css.indexOf('--env-test-bool-true:true')).not.toBe(-1);
121
- expect(css.indexOf('--env-test-bool-false:false')).not.toBe(-1);
122
- expect(css.indexOf('--env-test-type-number:123.456')).not.toBe(-1);
123
- expect(css.indexOf('--env-test-type-empty:""')).not.toBe(-1);
124
- }),
125
- ]);
126
- });
127
-
128
- test('process.env available in html/data', () => {
129
- return fsPromises.readFile(path.resolve(publicPath, 'env.html'), { encoding: 'utf8' }).then((html) => {
130
- expect(html.indexOf('<p>HOST FROM GLOBAL JS: https://test-local.tld</p>')).not.toBe(-1);
131
- });
132
- });
133
-
134
- test('icons generated', () => {
135
- return fsPromises.readFile(path.resolve(publicPath, 'assets/images/icons.svg'), { encoding: 'utf8' }).then((svg) => {
136
- expect(svg.indexOf('<symbol id="example-arrow">')).not.toBe(-1);
137
- });
138
- });
139
-
140
- test('image copied', () => {
141
- expect.assertions(1);
142
- return expect(fsPromises.access(path.resolve(publicPath, 'assets/images/px.gif'))).resolves.toBe(undefined);
143
- });
144
-
145
- test('static copied', () => {
146
- expect.assertions(1);
147
- return expect(fsPromises.access(path.resolve(publicPath, 'assets/manifest/manifest.webmanifest'))).resolves.toBe(undefined);
148
- });
149
-
150
- test('static file merged into images', () => {
151
- expect.assertions(1);
152
- return expect(fsPromises.access(path.resolve(publicPath, 'assets/images/static.png'))).resolves.toBe(undefined);
153
- });
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, 'public');
7
+
8
+ test('TWIG templates rendered and minified with JS and JSON data', () => {
9
+ return fsPromises.readFile(path.resolve(publicPath, 'index.html'), { encoding: 'utf8' }).then((html) => {
10
+ expect(html).toBe('<html><body><h1>Hello World!</h1></body></html>');
11
+ });
12
+ });
13
+
14
+ test('Multiple TWIG templates rendered', () => {
15
+ expect.assertions(1);
16
+ return expect(fsPromises.access(path.resolve(publicPath, 'other.html'))).resolves.toBe(undefined);
17
+ });
18
+
19
+ test('SASS variable test', () => {
20
+ return fsPromises.readFile(path.resolve(publicPath, 'assets/stylesheets/variable-test.css'), { encoding: 'utf8' }).then((css) => {
21
+ expect(css).toBe('main{background:#fff;color:#222}');
22
+ });
23
+ });
24
+
25
+ test('SASS import test', () => {
26
+ return fsPromises.readFile(path.resolve(publicPath, 'assets/stylesheets/import-test.css'), { encoding: 'utf8' }).then((css) => {
27
+ expect(css).toBe('.btn{background:#222;color:#fff}');
28
+ });
29
+ });
30
+
31
+ test('SASS sub-folder import test', () => {
32
+ return fsPromises.readFile(path.resolve(publicPath, 'assets/stylesheets/sub-folder/import-test.css'), { encoding: 'utf8' }).then((css) => {
33
+ expect(css).toBe('.btn{background:#222;color:#fff}');
34
+ });
35
+ });
36
+
37
+ test('SASS autoprefixer test', () => {
38
+ return fsPromises.readFile(path.resolve(publicPath, 'assets/stylesheets/autoprefixer-test.css'), { encoding: 'utf8' }).then((css) => {
39
+ expect(css).toBe('main{clip-path:polygon(0 0,100% 0,100% 100%,0 100%)}');
40
+ });
41
+ });
42
+
43
+ test('CSS nano ignore test', () => {
44
+ return fsPromises.readFile(path.resolve(publicPath, 'assets/stylesheets/ignore-test.css'), { encoding: 'utf8' }).then((css) => {
45
+ expect(css).toBe(':root{--yes: ;--no:initial}');
46
+ });
47
+ });
48
+
49
+ test('CSS nano nested calc test', () => {
50
+ return fsPromises.readFile(path.resolve(publicPath, 'assets/stylesheets/nested-calc-test.css'), { encoding: 'utf8' }).then((css) => {
51
+ expect(css).toBe('body{padding-top:calc(10vw + 15vh)}');
52
+ });
53
+ });
54
+
55
+ test('Font file woff copied', () => {
56
+ expect.assertions(1);
57
+ return expect(fsPromises.access(path.resolve(publicPath, 'assets/fonts/font.woff'))).resolves.toBe(undefined);
58
+ });
59
+
60
+ test('Font file fake not copied', () => {
61
+ expect.assertions(1);
62
+ return expect(fsPromises.access(path.resolve(publicPath, 'assets/fonts/font.fake'))).rejects.toThrow('no such file or directory');
63
+ });
64
+
65
+ test('shared.js file exists', () => {
66
+ return Promise.all([
67
+ fsPromises.readFile(path.resolve(publicPath, 'assets/javascripts/shared.js'), { encoding: 'utf8' }).then((js) => {
68
+ expect(js.indexOf('console.log(`Shared file loaded`)')).not.toBe(-1);
69
+ }),
70
+ ]);
71
+ });
72
+
73
+ test('main.js file exists', () => {
74
+ return Promise.all([
75
+ fsPromises.readFile(path.resolve(publicPath, 'assets/javascripts/main.js'), { encoding: 'utf8' }).then((js) => {
76
+ expect(js.indexOf('console.log(`Hello from main page!`')).not.toBe(-1);
77
+ }),
78
+ fsPromises.readFile(path.resolve(publicPath, 'assets/javascripts/alt/main.js'), { encoding: 'utf8' }).then((js) => {
79
+ expect(js.indexOf('console.log(`Hello from main page!`')).not.toBe(-1);
80
+ }),
81
+ ]);
82
+ });
83
+
84
+ test('other.js file exists', () => {
85
+ return fsPromises.readFile(path.resolve(publicPath, 'assets/javascripts/other.js'), { encoding: 'utf8' }).then((js) => {
86
+ expect(js.indexOf('console.log(`Hello from other page!`)')).not.toBe(-1);
87
+ });
88
+ });
89
+
90
+ test('something.ts was converted', () => {
91
+ return Promise.all([
92
+ fsPromises.readFile(path.resolve(publicPath, 'assets/javascripts/something.js'), { encoding: 'utf8' }).then((js) => {
93
+ expect(js.indexOf('console.log({name:`something`})')).not.toBe(-1);
94
+ }),
95
+ ]);
96
+ });
97
+
98
+ test("alt/other.js file doesn't exist", async () => {
99
+ expect(fsPromises.stat(path.resolve(publicPath, 'assets/javascripts/alt/other.js'))).rejects.toThrow();
100
+ });
101
+
102
+ test('.env and .env.local files loaded', () => {
103
+ return Promise.all([
104
+ fsPromises.readFile(path.resolve(publicPath, 'assets/javascripts/main.js'), { encoding: 'utf8' }).then((js) => {
105
+ expect(js.indexOf('console.log(`env.host ==`,`https://test-local.tld`)')).not.toBe(-1);
106
+ expect(js.indexOf('console.log(`env.foo ==`,`foo-global`)')).not.toBe(-1);
107
+ expect(js.indexOf('console.log(`env.bar ==`,`bar-local`)')).not.toBe(-1);
108
+ expect(js.indexOf('console.log(`env.typeBoolTrue ==`,!0)')).not.toBe(-1);
109
+ expect(js.indexOf('console.log(`env.typeBoolFalse ==`,!1)')).not.toBe(-1);
110
+ expect(js.indexOf('console.log(`env.typeNumber ==`,123.456)')).not.toBe(-1);
111
+ }),
112
+ fsPromises.readFile(path.resolve(publicPath, 'env.html'), { encoding: 'utf8' }).then((html) => {
113
+ expect(html.indexOf('<p>HOST: https://test-local.tld</p>')).not.toBe(-1);
114
+ expect(html.indexOf('<p>TYPE_BOOL_TRUE: pass</p>')).not.toBe(-1);
115
+ expect(html.indexOf('<p>TYPE_BOOL_FALSE: pass</p>')).not.toBe(-1);
116
+ expect(html.indexOf('<p>TYPE_NUMBER: 123.456</p>')).not.toBe(-1);
117
+ }),
118
+ fsPromises.readFile(path.resolve(publicPath, 'assets/stylesheets/env-test.css'), { encoding: 'utf8' }).then((css) => {
119
+ expect(css.indexOf('.env-test:before{content:"https://test-local.tld"}')).not.toBe(-1);
120
+ expect(css.indexOf('--env-test-bool-true:true')).not.toBe(-1);
121
+ expect(css.indexOf('--env-test-bool-false:false')).not.toBe(-1);
122
+ expect(css.indexOf('--env-test-type-number:123.456')).not.toBe(-1);
123
+ expect(css.indexOf('--env-test-type-empty:""')).not.toBe(-1);
124
+ }),
125
+ ]);
126
+ });
127
+
128
+ test('process.env available in html/data', () => {
129
+ return fsPromises.readFile(path.resolve(publicPath, 'env.html'), { encoding: 'utf8' }).then((html) => {
130
+ expect(html.indexOf('<p>HOST FROM GLOBAL JS: https://test-local.tld</p>')).not.toBe(-1);
131
+ });
132
+ });
133
+
134
+ test('icons generated', () => {
135
+ return fsPromises.readFile(path.resolve(publicPath, 'assets/images/icons.svg'), { encoding: 'utf8' }).then((svg) => {
136
+ expect(svg.indexOf('<symbol id="example-arrow">')).not.toBe(-1);
137
+ });
138
+ });
139
+
140
+ test('image copied', () => {
141
+ expect.assertions(1);
142
+ return expect(fsPromises.access(path.resolve(publicPath, 'assets/images/px.gif'))).resolves.toBe(undefined);
143
+ });
144
+
145
+ test('static copied', () => {
146
+ expect.assertions(1);
147
+ return expect(fsPromises.access(path.resolve(publicPath, 'assets/manifest/manifest.webmanifest'))).resolves.toBe(undefined);
148
+ });
149
+
150
+ test('static file merged into images', () => {
151
+ expect.assertions(1);
152
+ return expect(fsPromises.access(path.resolve(publicPath, 'assets/images/static.png'))).resolves.toBe(undefined);
153
+ });
@@ -1,11 +1,11 @@
1
- import camelizeFileName from '../lib/camelize-file-name.js';
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
- });
1
+ import camelizeFileName from '../lib/camelize-file-name.js';
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
+ });
@@ -1,78 +1,78 @@
1
- import pick from 'lodash/pick.js';
2
- import { generateTaskList } from '../lib/generate-gulp-tasks.js';
3
- import { BEFORE_BUILD, BUILD, AFTER_BUILD, BEFORE_WATCH, WATCH } from '../lib/task-order.js';
4
-
5
- test('Tasks are organized correctly', () => {
6
- const beforeBuildA = () => {};
7
- const beforeBuildB = () => {};
8
- const buildA = () => {};
9
- const buildB = () => {};
10
- const beforeWatchA = () => {};
11
- const watchA = () => {};
12
- const afterBuildA = () => {};
13
-
14
- const taskConfig = {'tasks': {
15
- 'task1': [
16
- {[BEFORE_BUILD]: beforeBuildA},
17
- {[BEFORE_BUILD]: beforeBuildB},
18
- ],
19
- 'task2': [
20
- {[BUILD]: buildA, [WATCH]: watchA}
21
- ],
22
- 'task3': [
23
- {[BUILD]: buildB, [AFTER_BUILD]: afterBuildA}
24
- ],
25
- 'task4': [
26
- {[BEFORE_WATCH]: beforeWatchA}
27
- ],
28
- }};
29
-
30
- expect(pick(generateTaskList(taskConfig), ['default', 'watch', 'build'])).toEqual({
31
- default: [
32
- [beforeBuildA, beforeBuildB],
33
- [buildA, buildB],
34
- [beforeWatchA],
35
- [watchA],
36
- ],
37
- watch: [
38
- [beforeBuildA, beforeBuildB],
39
- [buildA, buildB],
40
- [beforeWatchA],
41
- [watchA],
42
- ],
43
- build: [
44
- [beforeBuildA, beforeBuildB],
45
- [buildA, buildB],
46
- [afterBuildA],
47
- ]
48
- });
49
- });
50
-
51
- test('Skipping tasks doesn\'t genearate empty arrays', () => {
52
- const beforeBuildA = () => {};
53
- const beforeBuildB = () => {};
54
- const buildA = () => {};
55
- const buildB = () => {};
56
- const afterBuildA = () => {};
57
-
58
- const taskConfig = {'tasks': {
59
- 'task1': [
60
- {[BEFORE_BUILD]: beforeBuildA},
61
- {[BEFORE_BUILD]: beforeBuildB},
62
- ],
63
- 'task2': [
64
- {[BUILD]: buildA}
65
- ],
66
- 'task3': [
67
- {[BUILD]: buildB, [AFTER_BUILD]: afterBuildA}
68
- ],
69
- }};
70
-
71
- const taskList = pick(generateTaskList(taskConfig), ['default', 'watch', 'build']);
72
-
73
- for (let taskName in taskList) {
74
- taskList[taskName].forEach((parallel) => {
75
- expect(parallel.length).not.toBe(0);
76
- });
77
- }
78
- });
1
+ import pick from 'lodash/pick.js';
2
+ import { generateTaskList } from '../lib/generate-gulp-tasks.js';
3
+ import { BEFORE_BUILD, BUILD, AFTER_BUILD, BEFORE_WATCH, WATCH } from '../lib/task-order.js';
4
+
5
+ test('Tasks are organized correctly', () => {
6
+ const beforeBuildA = () => {};
7
+ const beforeBuildB = () => {};
8
+ const buildA = () => {};
9
+ const buildB = () => {};
10
+ const beforeWatchA = () => {};
11
+ const watchA = () => {};
12
+ const afterBuildA = () => {};
13
+
14
+ const taskConfig = {'tasks': {
15
+ 'task1': [
16
+ {[BEFORE_BUILD]: beforeBuildA},
17
+ {[BEFORE_BUILD]: beforeBuildB},
18
+ ],
19
+ 'task2': [
20
+ {[BUILD]: buildA, [WATCH]: watchA}
21
+ ],
22
+ 'task3': [
23
+ {[BUILD]: buildB, [AFTER_BUILD]: afterBuildA}
24
+ ],
25
+ 'task4': [
26
+ {[BEFORE_WATCH]: beforeWatchA}
27
+ ],
28
+ }};
29
+
30
+ expect(pick(generateTaskList(taskConfig), ['default', 'watch', 'build'])).toEqual({
31
+ default: [
32
+ [beforeBuildA, beforeBuildB],
33
+ [buildA, buildB],
34
+ [beforeWatchA],
35
+ [watchA],
36
+ ],
37
+ watch: [
38
+ [beforeBuildA, beforeBuildB],
39
+ [buildA, buildB],
40
+ [beforeWatchA],
41
+ [watchA],
42
+ ],
43
+ build: [
44
+ [beforeBuildA, beforeBuildB],
45
+ [buildA, buildB],
46
+ [afterBuildA],
47
+ ]
48
+ });
49
+ });
50
+
51
+ test('Skipping tasks doesn\'t genearate empty arrays', () => {
52
+ const beforeBuildA = () => {};
53
+ const beforeBuildB = () => {};
54
+ const buildA = () => {};
55
+ const buildB = () => {};
56
+ const afterBuildA = () => {};
57
+
58
+ const taskConfig = {'tasks': {
59
+ 'task1': [
60
+ {[BEFORE_BUILD]: beforeBuildA},
61
+ {[BEFORE_BUILD]: beforeBuildB},
62
+ ],
63
+ 'task2': [
64
+ {[BUILD]: buildA}
65
+ ],
66
+ 'task3': [
67
+ {[BUILD]: buildB, [AFTER_BUILD]: afterBuildA}
68
+ ],
69
+ }};
70
+
71
+ const taskList = pick(generateTaskList(taskConfig), ['default', 'watch', 'build']);
72
+
73
+ for (let taskName in taskList) {
74
+ taskList[taskName].forEach((parallel) => {
75
+ expect(parallel.length).not.toBe(0);
76
+ });
77
+ }
78
+ });