@maizzle/framework 4.2.4 → 4.3.0

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 (53) hide show
  1. package/README.md +5 -5
  2. package/package.json +8 -4
  3. package/src/generators/tailwindcss.js +1 -1
  4. package/src/transformers/filters/index.js +4 -0
  5. package/src/transformers/index.js +1 -1
  6. package/src/transformers/inlineCss.js +8 -3
  7. package/src/transformers/removeInlineSizes.js +2 -3
  8. package/src/transformers/removeUnusedCss.js +6 -2
  9. package/.editorconfig +0 -9
  10. package/.github/CONTRIBUTING.md +0 -33
  11. package/.github/ISSUE_TEMPLATE.md +0 -2
  12. package/.github/PULL_REQUEST_TEMPLATE.md +0 -9
  13. package/.github/dependabot.yml +0 -11
  14. package/.github/media/logo-dark.svg +0 -1
  15. package/.github/media/logo-light.svg +0 -1
  16. package/.github/workflows/nodejs.yml +0 -28
  17. package/test/expected/posthtml/component.html +0 -13
  18. package/test/expected/transformers/base-url.html +0 -99
  19. package/test/expected/transformers/filters.html +0 -81
  20. package/test/fixtures/basic.html +0 -9
  21. package/test/fixtures/posthtml/component.html +0 -19
  22. package/test/fixtures/transformers/base-url.html +0 -101
  23. package/test/fixtures/transformers/filters.html +0 -87
  24. package/test/stubs/assets/foo.bar +0 -1
  25. package/test/stubs/breaking/bad.html +0 -5
  26. package/test/stubs/components/component.html +0 -5
  27. package/test/stubs/config/config.js +0 -10
  28. package/test/stubs/config/config.maizzle-ci.js +0 -10
  29. package/test/stubs/data.json +0 -14
  30. package/test/stubs/empty/empty.html +0 -0
  31. package/test/stubs/events/before-create.html +0 -1
  32. package/test/stubs/layouts/basic.html +0 -1
  33. package/test/stubs/layouts/full.html +0 -12
  34. package/test/stubs/layouts/template.html +0 -5
  35. package/test/stubs/main.css +0 -5
  36. package/test/stubs/plaintext/front-matter.html +0 -9
  37. package/test/stubs/plaintext/plaintext.html +0 -5
  38. package/test/stubs/post.css +0 -6
  39. package/test/stubs/tailwind/content-source.html +0 -1
  40. package/test/stubs/tailwind/tailwind.css +0 -3
  41. package/test/stubs/template.html +0 -10
  42. package/test/stubs/templates/1.html +0 -1
  43. package/test/stubs/templates/2.html +0 -1
  44. package/test/stubs/templates/2.test +0 -1
  45. package/test/test-config.js +0 -19
  46. package/test/test-misc.js +0 -8
  47. package/test/test-postcss.js +0 -8
  48. package/test/test-posthtml.js +0 -112
  49. package/test/test-tailwindcss.js +0 -115
  50. package/test/test-todisk.js +0 -493
  51. package/test/test-tostring.js +0 -164
  52. package/test/test-transformers.js +0 -626
  53. package/xo.config.js +0 -22
@@ -1,87 +0,0 @@
1
- <!-- Append -->
2
- <div append="ing append">test</div>
3
- <!-- Prepend -->
4
- <div prepend="test">ing prepend</div>
5
-
6
- <!-- Uppercase -->
7
- <div uppercase>test</div>
8
- <!-- Lowercase -->
9
- <div lowercase>TEST</div>
10
- <!-- Capitalize -->
11
- <div capitalize>test</div>
12
-
13
- <!-- Ceil -->
14
- <div ceil>1.2</div>
15
- <!-- Floor -->
16
- <div floor>1.2</div>
17
- <!-- Round -->
18
- <div round>1234.567</div>
19
-
20
- <!-- Escape -->
21
- <div escape>"&'<></div>
22
- <!-- Escape Once -->
23
- <div escape-once>1 &lt; 2 &amp; 3</div>
24
-
25
- <!-- lstrip -->
26
- <div lstrip> test </div>
27
- <!-- rstrip -->
28
- <div rstrip> test </div>
29
- <!-- trim -->
30
- <div trim> test </div>
31
-
32
- <!-- Minus -->
33
- <div minus="2">3.02</div>
34
- <!-- Plus -->
35
- <div plus="2">3.02</div>
36
- <!-- Times -->
37
- <div times="2">6.04</div>
38
- <!-- Divide -->
39
- <div divide-by="2">12.08</div>
40
- <!-- Modulo -->
41
- <div modulo="2">3</div>
42
-
43
- <!-- Newline to br -->
44
- <div newline-to-br>
45
- test
46
- test
47
- </div>
48
- <!-- Strip newlines -->
49
- <div strip-newlines>
50
- test
51
- test
52
- </div>
53
-
54
- <!-- Remove -->
55
- <div remove="rain">I strained to see the train through the rain</div>
56
- <!-- Remove First -->
57
- <div remove-first="rain">I strained to see the train through the rain</div>
58
-
59
- <!-- Replace -->
60
- <div replace="t|test">test</div>
61
- <!-- Replace First -->
62
- <div replace-first="t|test">test</div>
63
-
64
- <!-- Size -->
65
- <div size>This string is 33 characters long</div>
66
-
67
- <!-- Slice -->
68
- <div slice="1">test</div>
69
- <!-- Slice with endIndex -->
70
- <div slice="0,-1">test</div>
71
-
72
- <!-- Truncate -->
73
- <div truncate="17">Ground control to Major Tom.</div>
74
- <!-- Truncate (do nothing) -->
75
- <div truncate="17">Ground control to</div>
76
- <!-- Truncate with custom ellipsis -->
77
- <div truncate="17, no one">Ground control to Major Tom.</div>
78
-
79
- <!-- Truncate words -->
80
- <div truncate-words="2">Ground control to Major Tom.</div>
81
- <!-- Truncate words with custom ellipsis -->
82
- <div truncate-words="2, over and out">Ground control to Major Tom.</div>
83
-
84
- <!-- URL decode -->
85
- <div url-decode>%27Stop%21%27+said+Fred</div>
86
- <!-- URL encode -->
87
- <div url-encode>user@example.com</div>
@@ -1 +0,0 @@
1
- Some asset file...
@@ -1,5 +0,0 @@
1
- ---
2
- title: [THIS] should break the build
3
- ---
4
-
5
- <div class="inline">{{ page.title }}</div>
@@ -1,5 +0,0 @@
1
- <p>Variable from attribute: [[ text ]]</p>
2
-
3
- <p>Variable from locals attribute: [[ foo ]]</p>
4
-
5
- <content></content>
@@ -1,10 +0,0 @@
1
- module.exports = {
2
- build: {
3
- templates: {
4
- source: '../templates',
5
- destination: {
6
- path: 'build_local'
7
- }
8
- }
9
- }
10
- }
@@ -1,10 +0,0 @@
1
- module.exports = {
2
- build: {
3
- templates: {
4
- source: '../templates',
5
- destination: {
6
- path: 'build_production'
7
- }
8
- }
9
- }
10
- }
@@ -1,14 +0,0 @@
1
- [
2
- {
3
- "id": 1,
4
- "name": "Leanne Graham"
5
- },
6
- {
7
- "id": 2,
8
- "name": "Ervin Howell"
9
- },
10
- {
11
- "id": 3,
12
- "name": "Clementine Bauch"
13
- }
14
- ]
File without changes
@@ -1 +0,0 @@
1
- <div class="inline">Foo is {{ page.foo }}</div>
@@ -1 +0,0 @@
1
- <block name="template"></block>
@@ -1,12 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <if condition="page.css">
5
- <style>{{{ page.css }}}</style>
6
- </if>
7
- </head>
8
- <body>
9
- <block name="template"></block>
10
- </body>
11
- </html>
12
-
@@ -1,5 +0,0 @@
1
- ---
2
- template: base
3
- ---
4
-
5
- <block name="template"></block>
@@ -1,5 +0,0 @@
1
- @import "tailwindcss/utilities";
2
-
3
- .foo {
4
- color: red;
5
- }
@@ -1,9 +0,0 @@
1
- ---
2
- plaintext: true
3
- ---
4
-
5
- <div>Show in HTML</div>
6
- <plaintext>Show in plaintext</plaintext>
7
- <not-plaintext>
8
- <table><tr><td>Remove from plaintext</td></tr></table>
9
- </not-plaintext>
@@ -1,5 +0,0 @@
1
- <div>Show in HTML</div>
2
- <plaintext>Show in plaintext</plaintext>
3
- <not-plaintext>
4
- <p>Do not show <a href="url">this</a> in plaintext.</p>
5
- </not-plaintext>
@@ -1,6 +0,0 @@
1
- div {
2
- margin-top: 1px;
3
- margin-right: 2px;
4
- margin-bottom: 3px;
5
- margin-left: 4px;
6
- }
@@ -1 +0,0 @@
1
- <div class="hidden"></div>
@@ -1,3 +0,0 @@
1
- .example {
2
- @apply hidden;
3
- }
@@ -1,10 +0,0 @@
1
- ---
2
- template: first
3
- ---
4
-
5
- <extends src="test/stubs/layouts/template.html">
6
- <block name="template">
7
- Parent
8
- <block name="button">Child in first.html</block>
9
- </block>
10
- </extends>
@@ -1 +0,0 @@
1
- <div class="inline">html</div>
@@ -1 +0,0 @@
1
- <div class="inline">html modified</div>
@@ -1 +0,0 @@
1
- test
@@ -1,19 +0,0 @@
1
- const test = require('ava')
2
- const Config = require('../src/generators/config')
3
-
4
- test('returns the merged config', async t => {
5
- const config = await Config.getMerged('maizzle-ci')
6
- t.is(config.env, 'maizzle-ci')
7
- })
8
-
9
- test('throws if env name is not a string', async t => {
10
- await t.throwsAsync(async () => {
11
- await Config.getMerged(false)
12
- }, {instanceOf: TypeError, message: `env name must be a string, received boolean(false)`})
13
- })
14
-
15
- test('throws if a config could not be loaded for the specified environment', async t => {
16
- await t.throwsAsync(async () => {
17
- await Config.getMerged('fake')
18
- }, {instanceOf: Error, message: `could not load config.fake.js`})
19
- })
package/test/test-misc.js DELETED
@@ -1,8 +0,0 @@
1
- const test = require('ava')
2
- const path = require('path')
3
- const {requireUncached} = require('../src/utils/helpers')
4
-
5
- test('requires an uncached module', t => {
6
- const helpers = requireUncached(path.resolve(process.cwd(), 'src/utils/helpers'))
7
- t.is(typeof helpers.requireUncached, 'function')
8
- })
@@ -1,8 +0,0 @@
1
- const test = require('ava')
2
- const PostCSS = require('../src/generators/postcss')
3
-
4
- test('throws on processing error', async t => {
5
- await t.throwsAsync(async () => {
6
- await PostCSS.process(null, {})
7
- }, {instanceOf: SyntaxError})
8
- })
@@ -1,112 +0,0 @@
1
- const test = require('ava')
2
- const {render} = require('../src')
3
-
4
- const renderString = (string, options = {}) => render(string, options).then(({html}) => html)
5
-
6
- test('layouts', async t => {
7
- const source = `---
8
- greeting: Hello
9
- ---
10
-
11
- <extends src="test/stubs/layouts/basic.html">
12
- <block name="template">
13
- Front matter variable: {{ page.greeting }}
14
- </block>
15
- </extends>`
16
-
17
- const html = await renderString(source, {
18
- maizzle: {
19
- greeting: 'Hello'
20
- }
21
- })
22
-
23
- t.is(html.trim(), `Front matter variable: Hello`)
24
- })
25
-
26
- test('inheritance when extending a template', async t => {
27
- const source = `---
28
- template: second
29
- ---
30
-
31
- <extends src="test/stubs/template.html">
32
- <block name="button">Child in second.html</block>
33
- </extends>`
34
-
35
- let html = await renderString(source)
36
-
37
- html = html.replace(/[^\S\r\n]+$/gm, '').trim()
38
-
39
- t.is(html, `Parent
40
- Child in second.html`)
41
- })
42
-
43
- test('components', async t => {
44
- const source = `<component
45
- src="test/stubs/components/component.html"
46
- text="Example"
47
- locals='{
48
- "foo": "bar"
49
- }'
50
- >
51
- <p class="hidden">Variable from page: [[ page.env ]]</p>
52
-
53
- <component
54
- src="test/stubs/components/component.html"
55
- text="Nested component"
56
- locals='{
57
- "foo": "bar (nested)"
58
- }'
59
- >
60
- <p>Variable from page (nested): [[ page.env ]]</p>
61
- </component>
62
- </component>`
63
-
64
- const options = {
65
- maizzle: {
66
- env: 'prod',
67
- build: {
68
- components: {
69
- expressions: {
70
- delimiters: ['[[', ']]']
71
- }
72
- }
73
- }
74
- }
75
- }
76
-
77
- const html = await renderString(source, options)
78
-
79
- t.is(html.trim(), `<p>Variable from attribute: Example</p>
80
- <p>Variable from locals attribute: bar</p><p class="hidden">Variable from page: prod</p>
81
- <p>Variable from attribute: Nested component</p>
82
- <p>Variable from locals attribute: bar (nested)</p><p>Variable from page (nested): prod</p>`)
83
- })
84
-
85
- test('fetch component', async t => {
86
- const source = `<extends src="test/stubs/layouts/basic.html">
87
- <block name="template">
88
- <fetch url="test/stubs/data.json">
89
- <each loop="user in response">
90
- [[ user.name + (loop.last ? '' : ', ') ]]
91
- </each>
92
- </fetch>
93
- </block>
94
- </extends>`
95
-
96
- const options = {
97
- maizzle: {
98
- env: 'maizzle-ci',
99
- build: {
100
- posthtml: {
101
- expressions: {
102
- delimiters: ['[[', ']]']
103
- }
104
- }
105
- }
106
- }
107
- }
108
-
109
- const html = await renderString(source, options)
110
-
111
- t.is(html.trim(), 'Leanne Graham, Ervin Howell, Clementine Bauch')
112
- })
@@ -1,115 +0,0 @@
1
- const test = require('ava')
2
- const Tailwind = require('../src/generators/tailwindcss')
3
-
4
- test('throws on compile error', async t => {
5
- await t.throwsAsync(async () => {
6
- await Tailwind.compile('div {@apply inexistent;}', '<div class="inline">Test</a>', {}, {})
7
- }, {instanceOf: SyntaxError})
8
- })
9
-
10
- test('uses defaults if no config specified', async t => {
11
- const css = await Tailwind.compile(
12
- '@tailwind utilities;',
13
- '<p class="xl:z-0"></p>',
14
- {},
15
- {env: 'production'}
16
- )
17
-
18
- t.not(css, undefined)
19
- t.true(css.includes('.xl\\:z-0'))
20
- })
21
-
22
- test('uses css file provided in environment config', async t => {
23
- const config = {
24
- env: 'production',
25
- build: {
26
- tailwind: {
27
- css: './test/stubs/main.css'
28
- }
29
- }
30
- }
31
-
32
- const css = await Tailwind.compile('', '<div class="text-center foo">test</div>', {}, config)
33
-
34
- t.not(css, undefined)
35
- t.true(css.includes('.text-center'))
36
- t.true(css.includes('.foo'))
37
- })
38
-
39
- test('works with custom `content` sources', async t => {
40
- const css = await Tailwind.compile(
41
- '@tailwind utilities;',
42
- '<div class="hidden"></div>',
43
- {
44
- content: ['./test/stubs/tailwind/*.*']
45
- }
46
- )
47
-
48
- t.true(css.includes('.hidden'))
49
- })
50
-
51
- test('works with custom `files` sources', async t => {
52
- const css = await Tailwind.compile(
53
- '@tailwind utilities;',
54
- '<div class="inline"></div>',
55
- {
56
- content: {
57
- files: ['./test/stubs/tailwind/*.*']
58
- }
59
- }
60
- )
61
-
62
- t.true(css.includes('.hidden'))
63
- })
64
-
65
- test('uses maizzle template path as content source', async t => {
66
- const css = await Tailwind.compile(
67
- '@tailwind utilities;',
68
- '<div class="inline"></div>',
69
- {},
70
- {
71
- build: {
72
- templates: {
73
- source: './test/stubs/tailwind'
74
- }
75
- }
76
- }
77
- )
78
-
79
- t.true(css.includes('.hidden'))
80
- })
81
-
82
- test('uses maizzle template path as content source (single file)', async t => {
83
- const css = await Tailwind.compile(
84
- '@tailwind utilities;',
85
- '<div class="inline"></div>',
86
- {},
87
- {
88
- build: {
89
- templates: {
90
- source: './test/stubs/tailwind/content-source.html'
91
- }
92
- }
93
- }
94
- )
95
-
96
- t.true(css.includes('.hidden'))
97
- })
98
-
99
- test('uses custom postcss plugins from the maizzle config', async t => {
100
- const maizzleConfig = {
101
- env: 'production',
102
- build: {
103
- postcss: {
104
- plugins: [
105
- require('autoprefixer')({overrideBrowserslist: ['> 0.1%']})
106
- ]
107
- }
108
- }
109
- }
110
-
111
- const css = await Tailwind.compile('.test {transform: scale(0.5)}', '<div class="test inline">Test</a>', {}, maizzleConfig)
112
-
113
- t.not(css, undefined)
114
- t.is(css.trim(), '.inline {display: inline !important} .test {-webkit-transform: scale(0.5);transform: scale(0.5)}')
115
- })