@maizzle/framework 4.4.0-beta.5 → 4.4.0-beta.7

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/README.md CHANGED
@@ -34,9 +34,9 @@ The Maizzle framework is open-sourced software licensed under the [MIT license](
34
34
 
35
35
  [npm]: https://www.npmjs.com/package/@maizzle/framework
36
36
  [npm-stats]: https://npm-stat.com/charts.html?package=%40maizzle%2Fframework&from=2019-03-27
37
- [npm-version-shield]: https://img.shields.io/npm/v/@maizzle/framework.svg?style=flat-square
38
- [npm-stats-shield]: https://img.shields.io/npm/dt/@maizzle/framework.svg?style=flat-square&color=4f46e5
37
+ [npm-version-shield]: https://img.shields.io/npm/v/@maizzle/framework.svg
38
+ [npm-stats-shield]: https://img.shields.io/npm/dt/@maizzle/framework.svg?color=4f46e5
39
39
  [github-ci]: https://github.com/maizzle/framework/actions
40
- [github-ci-shield]: https://img.shields.io/github/workflow/status/maizzle/framework/Node.js%20CI?style=flat-square
40
+ [github-ci-shield]: https://github.com/maizzle/framework/actions/workflows/nodejs.yml/badge.svg
41
41
  [license]: ./LICENSE
42
- [license-shield]: https://img.shields.io/npm/l/@maizzle/framework.svg?style=flat-square&color=0e9f6e
42
+ [license-shield]: https://img.shields.io/npm/l/@maizzle/framework.svg?color=0e9f6e
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maizzle/framework",
3
- "version": "4.4.0-beta.5",
3
+ "version": "4.4.0-beta.7",
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",
@@ -42,7 +42,7 @@
42
42
  "dependencies": {
43
43
  "@maizzle/cli": "^1.5.1",
44
44
  "autoprefixer": "^10.4.13",
45
- "browser-sync": "^2.26.13",
45
+ "browser-sync": "^2.27.11",
46
46
  "color-shorthand-hex-to-six-digit": "^3.0.2",
47
47
  "email-comb": "^5.2.0",
48
48
  "front-matter": "^4.0.0",
@@ -53,7 +53,7 @@
53
53
  "juice": "^8.0.0",
54
54
  "lodash": "^4.17.20",
55
55
  "ora": "^5.1.0",
56
- "postcss": "^8.4.19",
56
+ "postcss": "^8.4.21",
57
57
  "postcss-import": "^15.0.0",
58
58
  "postcss-merge-longhand": "^5.1.7",
59
59
  "posthtml": "^0.16.6",
@@ -64,20 +64,20 @@
64
64
  "posthtml-extend": "^0.6.0",
65
65
  "posthtml-extra-attributes": "^1.0.0",
66
66
  "posthtml-fetch": "^2.2.0",
67
- "posthtml-markdownit": "^1.3.0",
67
+ "posthtml-markdownit": "^1.3.1",
68
68
  "posthtml-match-helper": "^1.0.3",
69
69
  "posthtml-mso": "^1.0.4",
70
70
  "posthtml-postcss-merge-longhand": "^1.0.2",
71
71
  "posthtml-safe-class-names": "^2.0.0",
72
72
  "posthtml-url-parameters": "^1.0.4",
73
73
  "pretty": "^2.0.0",
74
- "query-string": "^7.1.0",
74
+ "query-string": "^7.1.3",
75
75
  "string-remove-widows": "^2.1.0",
76
76
  "string-strip-html": "^8.2.0",
77
77
  "tailwindcss": "^3.2.4"
78
78
  },
79
79
  "devDependencies": {
80
- "ava": "^5.1.0",
80
+ "ava": "^5.1.1",
81
81
  "c8": "^7.11.0",
82
82
  "np": "*",
83
83
  "xo": "0.39.1"
@@ -9,6 +9,10 @@ const renderToString = require('../functions/render')
9
9
  const {get, merge, isObject} = require('lodash')
10
10
  const {clearConsole} = require('../utils/helpers')
11
11
 
12
+ /**
13
+ * Initialize Browsersync on-demand
14
+ * https://github.com/maizzle/framework/issues/605
15
+ */
12
16
  const browsersync = () => {
13
17
  if (!global.cachedBrowserSync) {
14
18
  const bs = require('browser-sync')
@@ -18,16 +22,17 @@ const browsersync = () => {
18
22
  return global.cachedBrowserSync
19
23
  }
20
24
 
25
+ const getConfig = async (env = 'local', config = {}) => merge(
26
+ config,
27
+ await Config.getMerged(env)
28
+ )
29
+
21
30
  const serve = async (env = 'local', config = {}) => {
22
- config = merge(
23
- config,
24
- await Config.getMerged(env),
25
- {
26
- build: {
27
- command: 'serve'
28
- }
31
+ config = await getConfig(env, merge(config, {
32
+ build: {
33
+ command: 'serve'
29
34
  }
30
- )
35
+ }))
31
36
 
32
37
  const spinner = ora()
33
38
 
@@ -43,14 +48,17 @@ const serve = async (env = 'local', config = {}) => {
43
48
  'src/**',
44
49
  ...new Set(get(config, 'build.browsersync.watch', []))
45
50
  ]
51
+
46
52
  if (typeof tailwindConfig === 'string') {
47
- globalPaths.push(tailwindConfig);
53
+ globalPaths.push(tailwindConfig)
48
54
  }
49
55
 
50
56
  // Watch for Template file changes
51
57
  browsersync()
52
58
  .watch(templatePaths)
53
59
  .on('change', async file => {
60
+ config = await getConfig(env, config)
61
+
54
62
  if (config.events && typeof config.events.beforeCreate === 'function') {
55
63
  await config.events.beforeCreate(config)
56
64
  }
@@ -13,16 +13,23 @@ module.exports = {
13
13
 
14
14
  const cwd = env === 'maizzle-ci' ? './test/stubs/config' : process.cwd()
15
15
 
16
- for (const module of ['./config', './config.local']) {
16
+ for (const module of ['./config', './config.cjs', './config.local', './config.local.cjs']) {
17
17
  try {
18
18
  baseConfig = merge(baseConfig, requireUncached(path.resolve(cwd, module)))
19
19
  } catch {}
20
20
  }
21
21
 
22
22
  if (typeof env === 'string' && env !== 'local') {
23
- try {
24
- envConfig = merge(envConfig, requireUncached(path.resolve(cwd, `./config.${env}`)))
25
- } catch {
23
+ let loaded = false
24
+ for (const module of [`./config.${env}`, `./config.${env}.cjs`]) {
25
+ try {
26
+ envConfig = merge(envConfig, requireUncached(path.resolve(cwd, module)))
27
+ loaded = true
28
+ break
29
+ } catch {}
30
+ }
31
+
32
+ if (!loaded) {
26
33
  throw new Error(`could not load config.${env}.js`)
27
34
  }
28
35
  }
@@ -32,6 +32,11 @@ module.exports = async (env, spinner, config) => {
32
32
 
33
33
  // Parse each template config object
34
34
  await asyncForEach(templatesConfig, async templateConfig => {
35
+ if (!templateConfig) {
36
+ const configFileName = env === 'local' ? 'config.js' : `config.${env}.js`
37
+ throw new Error(`No template sources defined in \`build.templates\`, check your ${configFileName} file`)
38
+ }
39
+
35
40
  const outputDir = get(templateConfig, 'destination.path', `build_${env}`)
36
41
 
37
42
  await fs.remove(outputDir)
@@ -134,7 +139,7 @@ module.exports = async (env, spinner, config) => {
134
139
  ...config.events
135
140
  })
136
141
 
137
- const destination = config.permalink || file
142
+ const destination = get(compiled, 'config.permalink', file)
138
143
 
139
144
  /**
140
145
  * Generate plaintext
@@ -145,7 +150,7 @@ module.exports = async (env, spinner, config) => {
145
150
 
146
151
  // Check if plaintext: true globally, fallback to template's front matter
147
152
  const plaintextConfig = get(templateConfig, 'plaintext', get(compiled.config, 'plaintext', false))
148
- const plaintextPath = get(plaintextConfig, 'destination.path', config.permalink || file)
153
+ const plaintextPath = get(plaintextConfig, 'destination.path', destination)
149
154
 
150
155
  if (Boolean(plaintextConfig) || !isEmpty(plaintextConfig)) {
151
156
  await Plaintext
@@ -23,7 +23,11 @@ module.exports = async (html, config = {}, direct = false) => {
23
23
  if (isObject(url) && !isEmpty(url)) {
24
24
  html = rewriteVMLs(html, get(url, 'url', ''))
25
25
 
26
- return posthtml([baseUrl(url)]).process(html, posthtmlOptions).then(result => result.html)
26
+ return posthtml([
27
+ baseUrl(merge({styleTag: true, inlineCss: true}, url))
28
+ ])
29
+ .process(html, posthtmlOptions)
30
+ .then(result => result.html)
27
31
  }
28
32
 
29
33
  return html