@maizzle/framework 4.5.0 → 4.6.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.
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@maizzle/framework",
3
- "version": "4.5.0",
3
+ "version": "4.6.0",
4
4
  "description": "Maizzle is a framework that helps you quickly build HTML emails with Tailwind CSS.",
5
5
  "license": "MIT",
6
6
  "main": "src/index.js",
7
+ "types": "src/index.d.ts",
7
8
  "bin": {
8
9
  "maizzle": "bin/maizzle"
9
10
  },
@@ -77,6 +78,8 @@
77
78
  "tailwindcss": "^3.2.7"
78
79
  },
79
80
  "devDependencies": {
81
+ "@types/js-beautify": "^1.14.0",
82
+ "@types/markdown-it": "^13.0.0",
80
83
  "ava": "^5.2.0",
81
84
  "c8": "^8.0.0",
82
85
  "np": "*",
@@ -6,8 +6,8 @@ const Config = require('../generators/config')
6
6
  const buildToFile = require('../commands/build')
7
7
  const renderToString = require('../functions/render')
8
8
 
9
- const {get, merge, isObject} = require('lodash')
10
- const {clearConsole} = require('../utils/helpers')
9
+ const {get, isObject} = require('lodash')
10
+ const {clearConsole, merge} = require('../utils/helpers')
11
11
 
12
12
  /**
13
13
  * Initialize Browsersync on-demand
@@ -1,6 +1,5 @@
1
1
  const path = require('path')
2
- const {merge} = require('lodash')
3
- const {requireUncached} = require('../utils/helpers')
2
+ const {merge, requireUncached} = require('../utils/helpers')
4
3
 
5
4
  module.exports = {
6
5
  getMerged: async (env = 'local') => {
@@ -1,7 +1,8 @@
1
1
  const path = require('path')
2
2
  const fs = require('fs-extra')
3
3
  const glob = require('glob-promise')
4
- const {get, isEmpty, merge} = require('lodash')
4
+ const {get, isEmpty} = require('lodash')
5
+ const {merge} = require('../../utils/helpers')
5
6
 
6
7
  const Config = require('../config')
7
8
  const Tailwind = require('../tailwindcss')
@@ -1,6 +1,7 @@
1
1
  const fm = require('front-matter')
2
- const {get, merge} = require('lodash')
2
+ const {get} = require('lodash')
3
3
  const posthtml = require('../posthtml')
4
+ const {merge} = require('../../utils/helpers')
4
5
  const Transformers = require('../../transformers')
5
6
  const Tailwind = require('../tailwindcss')
6
7
  const Config = require('../config')
@@ -1,6 +1,7 @@
1
1
  const path = require('path')
2
+ const {get} = require('lodash')
2
3
  const posthtml = require('posthtml')
3
- const {get, merge} = require('lodash')
4
+ const {merge} = require('../utils/helpers')
4
5
  const {stripHtml} = require('string-strip-html')
5
6
  const defaultConfig = require('./posthtml/defaultConfig')
6
7
 
@@ -1,26 +1,28 @@
1
1
  const fm = require('front-matter')
2
2
  const posthtml = require('posthtml')
3
- const {get, merge} = require('lodash')
3
+ const {get, omit} = require('lodash')
4
4
  const fetch = require('posthtml-fetch')
5
5
  const layouts = require('posthtml-extend')
6
+ const {merge} = require('../../utils/helpers')
6
7
  const components = require('posthtml-component')
7
- const defaultConfig = require('./defaultConfig')
8
+ const defaultPosthtmlConfig = require('./defaultConfig')
8
9
  const defaultComponentsConfig = require('./defaultComponentsConfig')
9
10
 
10
11
  module.exports = async (html, config) => {
11
- const layoutsOptions = get(config, 'build.layouts', {})
12
- const componentsOptions = get(config, 'build.components', {})
12
+ const posthtmlOptions = merge(defaultPosthtmlConfig, get(config, 'build.posthtml.options', {}))
13
+ const posthtmlPlugins = get(config, 'build.posthtml.plugins', [])
14
+
15
+ const componentsUserOptions = get(config, 'build.components', {})
16
+
13
17
  const expressionsOptions = merge(
14
18
  {
15
19
  loopTags: ['each', 'for'],
16
20
  strictMode: false
17
21
  },
18
- get(config, 'build.posthtml.expressions', {})
22
+ get(config, 'build.posthtml.expressions', {}),
23
+ get(componentsUserOptions, 'expressions', {})
19
24
  )
20
25
 
21
- const posthtmlOptions = merge(defaultConfig, get(config, 'build.posthtml.options', {}))
22
- const posthtmlPlugins = get(config, 'build.posthtml.plugins', [])
23
-
24
26
  const locals = merge(
25
27
  get(expressionsOptions, 'locals', {}),
26
28
  get(config, 'locals', {}),
@@ -30,24 +32,29 @@ module.exports = async (html, config) => {
30
32
  const fetchPlugin = fetch(
31
33
  merge(
32
34
  {
33
- expressions: merge({...expressionsOptions, locals})
35
+ expressions: merge(expressionsOptions, {locals})
34
36
  },
35
37
  get(config, 'build.posthtml.fetch', {})
36
38
  )
37
39
  )
38
40
 
39
- const defaultComponentsOptions = merge(
41
+ const componentsOptions = merge(
40
42
  {
41
43
  ...defaultComponentsConfig,
42
44
  folders: [
43
- ...defaultComponentsConfig.folders,
44
- ...get(componentsOptions, 'folders', [])
45
+ ...get(componentsUserOptions, 'folders', []),
46
+ ...defaultComponentsConfig.folders
45
47
  ],
46
- expressions: {...expressionsOptions, locals}
48
+ expressions: merge(expressionsOptions, {locals})
47
49
  },
48
50
  {
49
- root: componentsOptions.root || './'
50
- }
51
+ root: componentsUserOptions.root || './'
52
+ },
53
+ /**
54
+ * We omit `folders`, `root` and `expressions` in order to prevent duplicate
55
+ * array values, as they are already added above
56
+ */
57
+ omit(componentsUserOptions, ['folders', 'root', 'expressions'])
51
58
  )
52
59
 
53
60
  return posthtml([
@@ -56,17 +63,12 @@ module.exports = async (html, config) => {
56
63
  merge(
57
64
  {
58
65
  strict: false,
59
- expressions: merge({...expressionsOptions, locals})
66
+ expressions: merge(expressionsOptions, {locals})
60
67
  },
61
- layoutsOptions
62
- )
63
- ),
64
- components(
65
- merge(
66
- defaultComponentsOptions,
67
- componentsOptions
68
+ get(config, 'build.layouts', {})
68
69
  )
69
70
  ),
71
+ components(componentsOptions),
70
72
  ...posthtmlPlugins
71
73
  ])
72
74
  .process(html, {...posthtmlOptions})
@@ -3,10 +3,10 @@ const fs = require('fs-extra')
3
3
  const postcss = require('postcss')
4
4
  const tailwindcss = require('tailwindcss')
5
5
  const postcssImport = require('postcss-import')
6
+ const {get, isObject, isEmpty} = require('lodash')
6
7
  const postcssNested = require('tailwindcss/nesting')
7
- const {requireUncached} = require('../utils/helpers')
8
+ const {merge, requireUncached} = require('../utils/helpers')
8
9
  const mergeLonghand = require('postcss-merge-longhand')
9
- const {get, isObject, isEmpty, merge} = require('lodash')
10
10
  const defaultComponentsConfig = require('./posthtml/defaultComponentsConfig')
11
11
 
12
12
  const addImportantPlugin = () => {