@maizzle/framework 4.0.0-alpha.8 → 4.0.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/.editorconfig +9 -9
- package/.github/media/logo-dark.svg +1 -0
- package/.github/media/logo-light.svg +1 -0
- package/.github/workflows/nodejs.yml +28 -28
- package/LICENSE +21 -21
- package/README.md +42 -35
- package/bin/maizzle +3 -0
- package/package.json +91 -87
- package/src/commands/serve.js +15 -5
- package/src/generators/config.js +32 -32
- package/src/generators/output/index.js +4 -4
- package/src/generators/output/to-disk.js +208 -208
- package/src/generators/output/to-string.js +67 -71
- package/src/generators/postcss.js +29 -29
- package/src/generators/posthtml.js +66 -66
- package/src/generators/tailwindcss.js +116 -116
- package/src/index.js +17 -17
- package/src/transformers/attributeToStyle.js +90 -90
- package/src/transformers/baseUrl.js +69 -45
- package/src/transformers/extraAttributes.js +26 -26
- package/src/transformers/filters/defaultFilters.js +126 -0
- package/src/transformers/{transform.js → filters/index.js} +55 -51
- package/src/transformers/index.js +63 -60
- package/src/transformers/inlineCss.js +37 -50
- package/src/transformers/markdown.js +19 -19
- package/src/transformers/minify.js +21 -21
- package/src/transformers/plaintext.js +23 -23
- package/src/transformers/posthtmlMso.js +10 -10
- package/src/transformers/prettify.js +27 -20
- package/src/transformers/preventWidows.js +13 -13
- package/src/transformers/removeAttributes.js +17 -17
- package/src/transformers/removeInlineBackgroundColor.js +52 -52
- package/src/transformers/removeInlineSizes.js +41 -41
- package/src/transformers/removeInlinedSelectors.js +70 -71
- package/src/transformers/removeUnusedCss.js +40 -35
- package/src/transformers/replaceStrings.js +14 -14
- package/src/transformers/safeClassNames.js +24 -24
- package/src/transformers/shorthandInlineCSS.js +19 -0
- package/src/transformers/sixHex.js +33 -33
- package/src/transformers/urlParameters.js +17 -17
- package/src/utils/helpers.js +17 -17
- package/test/expected/posthtml/component.html +13 -13
- package/test/expected/posthtml/extend-template.html +2 -2
- package/test/expected/posthtml/fetch.html +5 -5
- package/test/expected/posthtml/layout.html +3 -3
- package/test/expected/transformers/atimport-in-style.html +2 -1
- package/test/expected/transformers/{base-image-url.html → base-url.html} +18 -2
- package/test/expected/transformers/filters.html +81 -0
- package/test/expected/transformers/preserve-transform-css.html +12 -3
- package/test/expected/useConfig.html +9 -9
- package/test/fixtures/basic.html +6 -6
- package/test/fixtures/posthtml/component.html +19 -19
- package/test/fixtures/posthtml/extend-template.html +7 -7
- package/test/fixtures/posthtml/fetch.html +9 -9
- package/test/fixtures/posthtml/layout.html +11 -11
- package/test/fixtures/transformers/{base-image-url.html → base-url.html} +18 -2
- package/test/fixtures/transformers/filters.html +87 -0
- package/test/fixtures/useConfig.html +9 -9
- package/test/stubs/assets/foo.bar +1 -1
- package/test/stubs/breaking/bad.html +5 -5
- package/test/stubs/components/component.html +5 -5
- package/test/stubs/config/config.js +10 -10
- package/test/stubs/config/config.maizzle-ci.js +10 -10
- package/test/stubs/data.json +14 -14
- package/test/stubs/events/before-create.html +1 -1
- package/test/stubs/layouts/basic.html +1 -1
- package/test/stubs/layouts/full.html +12 -12
- package/test/stubs/layouts/template.html +5 -5
- package/test/stubs/main.css +5 -5
- package/test/stubs/tailwind/content-source.html +1 -1
- package/test/stubs/tailwind/tailwind.css +3 -3
- package/test/stubs/template.html +10 -10
- package/test/stubs/templates/1.html +1 -1
- package/test/stubs/templates/2.test +1 -0
- package/test/test-config.js +19 -19
- package/test/test-postcss.js +8 -8
- package/test/test-posthtml.js +72 -66
- package/test/test-tailwindcss.js +117 -117
- package/test/test-todisk.js +42 -28
- package/test/test-tostring.js +148 -142
- package/test/test-transformers.js +78 -46
- package/xo.config.js +22 -22
- package/test/stubs/templates/2.html +0 -1
- package/test/stubs/templates/3.mzl +0 -1
package/test/test-tailwindcss.js
CHANGED
|
@@ -1,117 +1,117 @@
|
|
|
1
|
-
const test = require('ava')
|
|
2
|
-
const ora = require('ora')
|
|
3
|
-
const Tailwind = require('../src/generators/tailwindcss')
|
|
4
|
-
|
|
5
|
-
test('throws on compile error', async t => {
|
|
6
|
-
await t.throwsAsync(async () => {
|
|
7
|
-
const spinner = ora('Compiling Tailwind CSS...').start()
|
|
8
|
-
await Tailwind.compile('.test {@apply inexistent;}', '<div class="test">Test</a>', {}, {}, spinner)
|
|
9
|
-
}, {instanceOf: Error, message: 'Tailwind CSS compilation failed'})
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
test('uses defaults if no config specified', async t => {
|
|
13
|
-
const css = await Tailwind.compile(
|
|
14
|
-
'@tailwind utilities;',
|
|
15
|
-
'<p class="xl:z-0"></p>',
|
|
16
|
-
{},
|
|
17
|
-
{env: 'production'}
|
|
18
|
-
)
|
|
19
|
-
|
|
20
|
-
t.not(css, undefined)
|
|
21
|
-
t.true(css.includes('.xl\\:z-0'))
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
test('uses css file provided in environment config', async t => {
|
|
25
|
-
const config = {
|
|
26
|
-
env: 'production',
|
|
27
|
-
build: {
|
|
28
|
-
tailwind: {
|
|
29
|
-
css: './test/stubs/main.css'
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const css = await Tailwind.compile('', '<div class="text-center foo">test</div>', {}, config)
|
|
35
|
-
|
|
36
|
-
t.not(css, undefined)
|
|
37
|
-
t.true(css.includes('.text-center'))
|
|
38
|
-
t.true(css.includes('.foo'))
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
test('works with custom `content` sources', async t => {
|
|
42
|
-
const css = await Tailwind.compile(
|
|
43
|
-
'@tailwind utilities;',
|
|
44
|
-
'<div class="hidden"></div>',
|
|
45
|
-
{
|
|
46
|
-
content: ['./test/stubs/tailwind/*.*']
|
|
47
|
-
}
|
|
48
|
-
)
|
|
49
|
-
|
|
50
|
-
t.true(css.includes('.hidden'))
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
test('works with custom `files` sources', async t => {
|
|
54
|
-
const css = await Tailwind.compile(
|
|
55
|
-
'@tailwind utilities;',
|
|
56
|
-
'<div></div>',
|
|
57
|
-
{
|
|
58
|
-
content: {
|
|
59
|
-
files: ['./test/stubs/tailwind/*.*']
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
)
|
|
63
|
-
|
|
64
|
-
t.true(css.includes('.hidden'))
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
test('uses maizzle template path as content source', async t => {
|
|
68
|
-
const css = await Tailwind.compile(
|
|
69
|
-
'@tailwind utilities;',
|
|
70
|
-
'<div></div>',
|
|
71
|
-
{},
|
|
72
|
-
{
|
|
73
|
-
build: {
|
|
74
|
-
templates: {
|
|
75
|
-
source: './test/stubs/tailwind'
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
t.true(css.includes('.hidden'))
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
test('uses maizzle template path as content source (single file)', async t => {
|
|
85
|
-
const css = await Tailwind.compile(
|
|
86
|
-
'@tailwind utilities;',
|
|
87
|
-
'<div></div>',
|
|
88
|
-
{},
|
|
89
|
-
{
|
|
90
|
-
build: {
|
|
91
|
-
templates: {
|
|
92
|
-
source: './test/stubs/tailwind/content-source.html'
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
t.true(css.includes('.hidden'))
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
test('uses custom postcss plugins from the maizzle config', async t => {
|
|
102
|
-
const maizzleConfig = {
|
|
103
|
-
env: 'production',
|
|
104
|
-
build: {
|
|
105
|
-
postcss: {
|
|
106
|
-
plugins: [
|
|
107
|
-
require('autoprefixer')({overrideBrowserslist: ['> 0.1%']})
|
|
108
|
-
]
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const css = await Tailwind.compile('.test {transform: scale(0.5)}', '<div class="test">Test</a>', {}, maizzleConfig)
|
|
114
|
-
|
|
115
|
-
t.not(css, undefined)
|
|
116
|
-
t.is(css.trim(), '.inline {display: inline !important} .table {display: table !important} .contents {display: contents !important} .
|
|
117
|
-
})
|
|
1
|
+
const test = require('ava')
|
|
2
|
+
const ora = require('ora')
|
|
3
|
+
const Tailwind = require('../src/generators/tailwindcss')
|
|
4
|
+
|
|
5
|
+
test('throws on compile error', async t => {
|
|
6
|
+
await t.throwsAsync(async () => {
|
|
7
|
+
const spinner = ora('Compiling Tailwind CSS...').start()
|
|
8
|
+
await Tailwind.compile('.test {@apply inexistent;}', '<div class="test">Test</a>', {}, {}, spinner)
|
|
9
|
+
}, {instanceOf: Error, message: 'Tailwind CSS compilation failed'})
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
test('uses defaults if no config specified', async t => {
|
|
13
|
+
const css = await Tailwind.compile(
|
|
14
|
+
'@tailwind utilities;',
|
|
15
|
+
'<p class="xl:z-0"></p>',
|
|
16
|
+
{},
|
|
17
|
+
{env: 'production'}
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
t.not(css, undefined)
|
|
21
|
+
t.true(css.includes('.xl\\:z-0'))
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
test('uses css file provided in environment config', async t => {
|
|
25
|
+
const config = {
|
|
26
|
+
env: 'production',
|
|
27
|
+
build: {
|
|
28
|
+
tailwind: {
|
|
29
|
+
css: './test/stubs/main.css'
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const css = await Tailwind.compile('', '<div class="text-center foo">test</div>', {}, config)
|
|
35
|
+
|
|
36
|
+
t.not(css, undefined)
|
|
37
|
+
t.true(css.includes('.text-center'))
|
|
38
|
+
t.true(css.includes('.foo'))
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
test('works with custom `content` sources', async t => {
|
|
42
|
+
const css = await Tailwind.compile(
|
|
43
|
+
'@tailwind utilities;',
|
|
44
|
+
'<div class="hidden"></div>',
|
|
45
|
+
{
|
|
46
|
+
content: ['./test/stubs/tailwind/*.*']
|
|
47
|
+
}
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
t.true(css.includes('.hidden'))
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
test('works with custom `files` sources', async t => {
|
|
54
|
+
const css = await Tailwind.compile(
|
|
55
|
+
'@tailwind utilities;',
|
|
56
|
+
'<div></div>',
|
|
57
|
+
{
|
|
58
|
+
content: {
|
|
59
|
+
files: ['./test/stubs/tailwind/*.*']
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
t.true(css.includes('.hidden'))
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
test('uses maizzle template path as content source', async t => {
|
|
68
|
+
const css = await Tailwind.compile(
|
|
69
|
+
'@tailwind utilities;',
|
|
70
|
+
'<div></div>',
|
|
71
|
+
{},
|
|
72
|
+
{
|
|
73
|
+
build: {
|
|
74
|
+
templates: {
|
|
75
|
+
source: './test/stubs/tailwind'
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
t.true(css.includes('.hidden'))
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
test('uses maizzle template path as content source (single file)', async t => {
|
|
85
|
+
const css = await Tailwind.compile(
|
|
86
|
+
'@tailwind utilities;',
|
|
87
|
+
'<div></div>',
|
|
88
|
+
{},
|
|
89
|
+
{
|
|
90
|
+
build: {
|
|
91
|
+
templates: {
|
|
92
|
+
source: './test/stubs/tailwind/content-source.html'
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
t.true(css.includes('.hidden'))
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
test('uses custom postcss plugins from the maizzle config', async t => {
|
|
102
|
+
const maizzleConfig = {
|
|
103
|
+
env: 'production',
|
|
104
|
+
build: {
|
|
105
|
+
postcss: {
|
|
106
|
+
plugins: [
|
|
107
|
+
require('autoprefixer')({overrideBrowserslist: ['> 0.1%']})
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const css = await Tailwind.compile('.test {transform: scale(0.5)}', '<div class="test">Test</a>', {}, maizzleConfig)
|
|
114
|
+
|
|
115
|
+
t.not(css, undefined)
|
|
116
|
+
t.is(css.trim(), '.inline {display: inline !important} .table {display: table !important} .contents {display: contents !important} .truncate {overflow: hidden !important;text-overflow: ellipsis !important;white-space: nowrap !important} .uppercase {text-transform: uppercase !important} .lowercase {text-transform: lowercase !important} .capitalize {text-transform: capitalize !important} .test {-webkit-transform: scale(0.5);transform: scale(0.5)}')
|
|
117
|
+
})
|
package/test/test-todisk.js
CHANGED
|
@@ -67,9 +67,9 @@ test('outputs files at the correct location', async t => {
|
|
|
67
67
|
}
|
|
68
68
|
})
|
|
69
69
|
|
|
70
|
-
t.true(fs.
|
|
71
|
-
t.is(string.length,
|
|
72
|
-
t.is(array.length,
|
|
70
|
+
t.true(await fs.pathExists(t.context.folder))
|
|
71
|
+
t.is(string.length, 2)
|
|
72
|
+
t.is(array.length, 2)
|
|
73
73
|
})
|
|
74
74
|
|
|
75
75
|
test('outputs files at the correct location if multiple template sources are used', async t => {
|
|
@@ -93,8 +93,8 @@ test('outputs files at the correct location if multiple template sources are use
|
|
|
93
93
|
}
|
|
94
94
|
})
|
|
95
95
|
|
|
96
|
-
t.true(fs.
|
|
97
|
-
t.is(files.length,
|
|
96
|
+
t.true(await fs.pathExists(t.context.folder))
|
|
97
|
+
t.is(files.length, 3)
|
|
98
98
|
})
|
|
99
99
|
|
|
100
100
|
test('copies all files in the `filetypes` option to destination', async t => {
|
|
@@ -103,7 +103,7 @@ test('copies all files in the `filetypes` option to destination', async t => {
|
|
|
103
103
|
fail: 'silent',
|
|
104
104
|
templates: {
|
|
105
105
|
source: 'test/stubs/templates',
|
|
106
|
-
filetypes: ['html', '
|
|
106
|
+
filetypes: ['html', 'test'],
|
|
107
107
|
destination: {
|
|
108
108
|
path: t.context.folder
|
|
109
109
|
}
|
|
@@ -116,8 +116,8 @@ test('copies all files in the `filetypes` option to destination', async t => {
|
|
|
116
116
|
}
|
|
117
117
|
})
|
|
118
118
|
|
|
119
|
-
t.true(fs.
|
|
120
|
-
t.is(files.length,
|
|
119
|
+
t.true(await fs.pathExists(t.context.folder))
|
|
120
|
+
t.is(files.length, 3)
|
|
121
121
|
})
|
|
122
122
|
|
|
123
123
|
test('outputs files with the correct extension', async t => {
|
|
@@ -139,9 +139,9 @@ test('outputs files with the correct extension', async t => {
|
|
|
139
139
|
}
|
|
140
140
|
})
|
|
141
141
|
|
|
142
|
-
|
|
142
|
+
const filelist = await fs.readdir(t.context.folder)
|
|
143
143
|
|
|
144
|
-
t.true(
|
|
144
|
+
t.true(filelist.includes('1.blade.php'))
|
|
145
145
|
})
|
|
146
146
|
|
|
147
147
|
test('outputs plaintext files', async t => {
|
|
@@ -230,8 +230,10 @@ test('copies assets to destination', async t => {
|
|
|
230
230
|
}
|
|
231
231
|
})
|
|
232
232
|
|
|
233
|
-
|
|
234
|
-
|
|
233
|
+
const filelist = await fs.readdir(`${t.context.folder}/images`)
|
|
234
|
+
|
|
235
|
+
t.is(await fs.pathExists(`${t.context.folder}/images`), true)
|
|
236
|
+
t.is(filelist.length, 1)
|
|
235
237
|
})
|
|
236
238
|
|
|
237
239
|
test('runs the `beforeCreate` event', async t => {
|
|
@@ -257,9 +259,10 @@ test('runs the `beforeCreate` event', async t => {
|
|
|
257
259
|
}
|
|
258
260
|
})
|
|
259
261
|
|
|
260
|
-
const
|
|
262
|
+
const filename = await fs.readdir(t.context.folder)
|
|
263
|
+
const html = await fs.readFile(`${t.context.folder}/${filename[0]}`, 'utf8')
|
|
261
264
|
|
|
262
|
-
t.is(html, 'Foo is bar')
|
|
265
|
+
t.is(html.trim(), 'Foo is bar')
|
|
263
266
|
})
|
|
264
267
|
|
|
265
268
|
test('runs the `afterBuild` event', async t => {
|
|
@@ -312,9 +315,9 @@ test('supports multiple asset paths', async t => {
|
|
|
312
315
|
}
|
|
313
316
|
})
|
|
314
317
|
|
|
315
|
-
t.true(fs.
|
|
316
|
-
t.true(fs.
|
|
317
|
-
t.false(fs.
|
|
318
|
+
t.true(await fs.pathExists(`${t.context.folder}/extras/foo.bar`))
|
|
319
|
+
t.true(await fs.pathExists(`${t.context.folder}/extras/plaintext.html`))
|
|
320
|
+
t.false(await fs.pathExists(`${t.context.folder}/extras/invalid`))
|
|
318
321
|
})
|
|
319
322
|
|
|
320
323
|
test('warns if a template cannot be rendered and `fail` option is undefined', async t => {
|
|
@@ -394,31 +397,42 @@ test('spins up local development server', async t => {
|
|
|
394
397
|
}
|
|
395
398
|
})
|
|
396
399
|
|
|
397
|
-
t.true(fs.
|
|
400
|
+
t.true(await fs.pathExists(t.context.folder))
|
|
398
401
|
})
|
|
399
402
|
|
|
400
403
|
test('local server does not compile unwanted file types', async t => {
|
|
401
404
|
await Maizzle.serve('local', {
|
|
402
405
|
build: {
|
|
406
|
+
console: {
|
|
407
|
+
clear: true
|
|
408
|
+
},
|
|
403
409
|
browsersync: {
|
|
404
410
|
ui: false
|
|
405
411
|
},
|
|
406
412
|
templates: {
|
|
407
413
|
source: 'test/stubs/templates',
|
|
408
414
|
destination: {
|
|
409
|
-
path: t.context.folder
|
|
415
|
+
path: `${t.context.folder}`
|
|
410
416
|
}
|
|
411
417
|
}
|
|
418
|
+
},
|
|
419
|
+
events: {
|
|
420
|
+
beforeCreate(config) {
|
|
421
|
+
config.foo = 'bar'
|
|
422
|
+
}
|
|
412
423
|
}
|
|
413
424
|
})
|
|
414
425
|
|
|
415
|
-
fs.
|
|
416
|
-
fs.
|
|
426
|
+
t.true(await fs.pathExists(`${t.context.folder}`))
|
|
427
|
+
t.true(await fs.pathExists(`${t.context.folder}/2.test`))
|
|
417
428
|
|
|
418
|
-
|
|
419
|
-
|
|
429
|
+
// Tests watching changes to files
|
|
430
|
+
await fs.outputFile('test/stubs/templates/1.html', 'html\n')
|
|
431
|
+
t.is(await fs.readFile('test/stubs/templates/1.html', 'utf8'), 'html\n')
|
|
420
432
|
|
|
421
|
-
|
|
433
|
+
// Don't trigger rebuilds on files not in filetypes
|
|
434
|
+
await fs.outputFile('test/stubs/templates/2.test', 'test\n')
|
|
435
|
+
t.is(await fs.readFile('test/stubs/templates/2.test', 'utf8'), 'test\n')
|
|
422
436
|
})
|
|
423
437
|
|
|
424
438
|
test('throws if it cannot spin up local development server', async t => {
|
|
@@ -440,8 +454,8 @@ test('works with templates.source defined as function (string paths)', async t =
|
|
|
440
454
|
}
|
|
441
455
|
})
|
|
442
456
|
|
|
443
|
-
t.true(fs.
|
|
444
|
-
t.is(files.length,
|
|
457
|
+
t.true(await fs.pathExists(t.context.folder))
|
|
458
|
+
t.is(files.length, 2)
|
|
445
459
|
})
|
|
446
460
|
|
|
447
461
|
test('works with templates.source defined as function (array paths)', async t => {
|
|
@@ -460,8 +474,8 @@ test('works with templates.source defined as function (array paths)', async t =>
|
|
|
460
474
|
}
|
|
461
475
|
})
|
|
462
476
|
|
|
463
|
-
t.true(fs.
|
|
464
|
-
t.is(files.length,
|
|
477
|
+
t.true(await fs.pathExists(t.context.folder))
|
|
478
|
+
t.is(files.length, 2)
|
|
465
479
|
})
|
|
466
480
|
|
|
467
481
|
test('throws if templates path is invalid', async t => {
|