@maizzle/framework 4.4.0-beta.8 → 4.4.0-beta.9

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@maizzle/framework",
3
- "version": "4.4.0-beta.8",
3
+ "version": "4.4.0-beta.9",
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",
@@ -74,10 +74,10 @@
74
74
  "query-string": "^7.1.3",
75
75
  "string-remove-widows": "^2.1.0",
76
76
  "string-strip-html": "^8.2.0",
77
- "tailwindcss": "^3.2.4"
77
+ "tailwindcss": "^3.2.6"
78
78
  },
79
79
  "devDependencies": {
80
- "ava": "^5.1.1",
80
+ "ava": "^5.2.0",
81
81
  "c8": "^7.11.0",
82
82
  "np": "*",
83
83
  "xo": "0.39.1"
@@ -81,16 +81,21 @@ const serve = async (env = 'local', config = {}) => {
81
81
 
82
82
  spinner.start('Building email...')
83
83
 
84
- file = file.replace(/\\/g, '/')
85
-
86
- const renderOptions = {
87
- maizzle: config,
88
- ...config.events
89
- }
90
-
91
84
  renderToString(
92
- await fs.readFile(file, 'utf8'),
93
- renderOptions
85
+ await fs.readFile(file.replace(/\\/g, '/'), 'utf8'),
86
+ {
87
+ maizzle: merge(
88
+ config,
89
+ {
90
+ build: {
91
+ current: {
92
+ path: path.parse(file)
93
+ }
94
+ }
95
+ }
96
+ ),
97
+ ...config.events
98
+ }
94
99
  )
95
100
  .then(async ({html, config}) => {
96
101
  let source = ''
@@ -2,7 +2,6 @@ const path = require('path')
2
2
  const fs = require('fs-extra')
3
3
  const glob = require('glob-promise')
4
4
  const {get, isEmpty, merge} = require('lodash')
5
- const {asyncForEach} = require('../../utils/helpers')
6
5
 
7
6
  const Config = require('../config')
8
7
  const Tailwind = require('../tailwindcss')
@@ -31,7 +30,7 @@ module.exports = async (env, spinner, config) => {
31
30
  : await Tailwind.compile({config})
32
31
 
33
32
  // Parse each template config object
34
- await asyncForEach(templatesConfig, async templateConfig => {
33
+ for await (const templateConfig of templatesConfig) {
35
34
  if (!templateConfig) {
36
35
  const configFileName = env === 'local' ? 'config.js' : `config.${env}.js`
37
36
  throw new Error(`No template sources defined in \`build.templates\`, check your ${configFileName} file`)
@@ -79,18 +78,20 @@ module.exports = async (env, spinner, config) => {
79
78
  : templateConfig.filetypes || get(templateConfig, 'filetypes', 'html')
80
79
 
81
80
  // List of files that won't be copied to the output directory
82
- const omitted = Array.isArray(templateConfig.omit) ?
83
- templateConfig.omit :
84
- [get(templateConfig, 'omit', '')]
81
+ const omitted = Array.isArray(templateConfig.omit)
82
+ ? templateConfig.omit
83
+ : [get(templateConfig, 'omit', '')]
85
84
 
86
85
  // Parse each template source
87
- await asyncForEach(templateSource, async source => {
86
+ for await (const source of templateSource) {
88
87
  /**
89
88
  * Copy single-file sources correctly
90
89
  * If `src` is a file, `dest` cannot be a directory
91
90
  * https://github.com/jprichardson/node-fs-extra/issues/323
92
91
  */
93
- const out = fs.lstatSync(source).isFile() ? `${outputDir}/${path.basename(source)}` : outputDir
92
+ const out = fs.lstatSync(source).isFile()
93
+ ? `${outputDir}/${path.basename(source)}`
94
+ : outputDir
94
95
 
95
96
  await fs
96
97
  .copy(source, out, {filter: file => {
@@ -119,7 +120,7 @@ module.exports = async (env, spinner, config) => {
119
120
  await config.events.beforeCreate(config)
120
121
  }
121
122
 
122
- await asyncForEach(templates, async file => {
123
+ for await (const file of templates) {
123
124
  config.build.current = {
124
125
  path: path.parse(file)
125
126
  }
@@ -202,18 +203,18 @@ module.exports = async (env, spinner, config) => {
202
203
  throw error
203
204
  }
204
205
  }
205
- })
206
+ }
206
207
 
207
208
  const assets = {source: '', destination: 'assets', ...get(templateConfig, 'assets')}
208
209
 
209
210
  if (Array.isArray(assets.source)) {
210
- await asyncForEach(assets.source, async source => {
211
+ for await (const source of assets.source) {
211
212
  if (fs.existsSync(source)) {
212
213
  await fs
213
214
  .copy(source, path.join(templateConfig.destination.path, assets.destination))
214
215
  .catch(error => spinner.warn(error.message))
215
216
  }
216
- })
217
+ }
217
218
  } else {
218
219
  if (fs.existsSync(assets.source)) {
219
220
  await fs
@@ -228,8 +229,8 @@ module.exports = async (env, spinner, config) => {
228
229
  })
229
230
  })
230
231
  .catch(error => spinner.warn(error.message))
231
- })
232
- })
232
+ }
233
+ }
233
234
 
234
235
  if (config.events && typeof config.events.afterBuild === 'function') {
235
236
  await config.events.afterBuild(files)
@@ -1,9 +1,4 @@
1
1
  module.exports = {
2
- asyncForEach: async (array, callback) => {
3
- for (let index = 0; index < array.length; index++) {
4
- await callback(array[index], index, array) // eslint-disable-line
5
- }
6
- },
7
2
  requireUncached: module => {
8
3
  try {
9
4
  delete require.cache[require.resolve(module)]