@maizzle/framework 4.7.3 → 4.7.5

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.7.3",
3
+ "version": "4.7.5",
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",
@@ -46,9 +46,9 @@
46
46
  "browser-sync": "^3.0.2",
47
47
  "color-shorthand-hex-to-six-digit": "^3.0.2",
48
48
  "email-comb": "^5.2.0",
49
+ "fast-glob": "^3.3.2",
49
50
  "front-matter": "^4.0.0",
50
51
  "fs-extra": "^11.2.0",
51
- "glob-promise": "^4.1.0",
52
52
  "html-crush": "^4.0.0",
53
53
  "is-url-superb": "^5.0.0",
54
54
  "juice": "^10.0.0",
@@ -71,13 +71,14 @@
71
71
  "posthtml-postcss-merge-longhand": "^2.0.1",
72
72
  "posthtml-safe-class-names": "^3.0.0",
73
73
  "posthtml-url-parameters": "^2.0.0",
74
- "prettier": "^3.1.1",
74
+ "pretty": "^2.0.0",
75
75
  "query-string": "^7.1.3",
76
76
  "string-remove-widows": "^2.1.0",
77
77
  "string-strip-html": "^8.2.0",
78
78
  "tailwindcss": "^3.2.7"
79
79
  },
80
80
  "devDependencies": {
81
+ "@types/js-beautify": "^1.14.0",
81
82
  "@types/markdown-it": "^13.0.0",
82
83
  "ava": "^5.2.0",
83
84
  "c8": "^9.0.0",
@@ -1,6 +1,6 @@
1
1
  const path = require('path')
2
2
  const fs = require('fs-extra')
3
- const glob = require('glob-promise')
3
+ const {glob} = require('fast-glob')
4
4
  const {get, merge, isEmpty} = require('lodash')
5
5
 
6
6
  const Config = require('../config')
@@ -73,9 +73,10 @@ module.exports = async (env, spinner, config) => {
73
73
 
74
74
  // Create a pipe-delimited list of allowed extensions
75
75
  // We only compile these, the rest are copied as-is
76
- const extensions = Array.isArray(templateConfig.filetypes)
77
- ? templateConfig.filetypes.join('|')
78
- : templateConfig.filetypes || get(templateConfig, 'filetypes', 'html')
76
+ const fileTypes = get(templateConfig, 'filetypes', 'html')
77
+ const extensionsList = Array.isArray(fileTypes)
78
+ ? fileTypes.join(',')
79
+ : fileTypes.split('|').join(',')
79
80
 
80
81
  // List of files that won't be copied to the output directory
81
82
  const omitted = Array.isArray(templateConfig.omit)
@@ -101,7 +102,10 @@ module.exports = async (env, spinner, config) => {
101
102
  .some(omit => path.normalize(file).includes(path.normalize(omit)))
102
103
  }})
103
104
  .then(async () => {
104
- const allSourceFiles = await glob(`${outputDir}/**/*.+(${extensions})`)
105
+ const extensions = extensionsList.includes(',')
106
+ ? `{${extensionsList}}`
107
+ : extensionsList
108
+ const allSourceFiles = await glob(`${outputDir}/**/*.${extensions}`)
105
109
 
106
110
  const skipped = Array.isArray(templateConfig.skip) ?
107
111
  templateConfig.skip :
@@ -223,7 +227,7 @@ module.exports = async (env, spinner, config) => {
223
227
  }
224
228
  }
225
229
 
226
- await glob(path.join(templateConfig.destination.path, '/**/*.*'))
230
+ await glob(path.join(templateConfig.destination.path, '/**').replace(/\\/g, '/'))
227
231
  .then(contents => {
228
232
  files = [...new Set([...files, ...contents])]
229
233
  })
package/src/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type {StringifyOptions} from 'query-string';
2
- import type {Config as PrettierOptions} from 'prettier';
2
+ import type {CoreBeautifyOptions} from 'js-beautify';
3
3
  import type {Options as MarkdownItOptions} from 'markdown-it';
4
4
  import type {Opts as PlaintextOptions} from 'string-strip-html';
5
5
 
@@ -1773,7 +1773,7 @@ declare namespace MaizzleFramework {
1773
1773
  }
1774
1774
  ```
1775
1775
  */
1776
- prettify?: boolean | PrettierOptions;
1776
+ prettify?: boolean | CoreBeautifyOptions;
1777
1777
 
1778
1778
  /**
1779
1779
  Minify the compiled HTML email code.
@@ -2041,9 +2041,9 @@ declare namespace MaizzleFramework {
2041
2041
  /**
2042
2042
  Pretty print HTML code so that it's nicely indented and more human-readable.
2043
2043
  @param {string} html The HTML string to prettify.
2044
- @param {PrettierOptions} [options] Options to pass to the prettifier.
2044
+ @param {CoreBeautifyOptions} [options] Options to pass to the prettifier.
2045
2045
  */
2046
- function prettify(html: string, options?: PrettierOptions): string;
2046
+ function prettify(html: string, options?: CoreBeautifyOptions): string;
2047
2047
 
2048
2048
  /**
2049
2049
  Prepend a string to sources and hrefs in an HTML string.
@@ -1,69 +1,27 @@
1
- const {format} = require('prettier')
1
+ /* eslint-disable camelcase */
2
+ const pretty = require('pretty')
2
3
  const {get, merge, isEmpty, isObject} = require('lodash')
3
4
 
4
5
  module.exports = async (html, config = {}, direct = false) => {
5
- config = direct ? config : get(config, 'prettify')
6
-
7
6
  const defaultConfig = {
8
- parser: 'html',
9
- printWidth: 500,
10
- htmlWhitespaceSensitivity: 'ignore',
11
- xmlMode: get(config, 'posthtml.options.xmlMode', false),
12
- rewriteSelfClosing: true,
13
- selfClosingTags: [
14
- 'area',
15
- 'base',
16
- 'br',
17
- 'col',
18
- 'embed',
19
- 'hr',
20
- 'img',
21
- 'input',
22
- 'link',
23
- 'meta',
24
- 'param',
25
- 'source',
26
- 'track',
27
- 'wbr'
28
- ]
7
+ space_around_combinator: true, // Preserve space around CSS selector combinators
8
+ newline_between_rules: false, // Remove empty lines between CSS rules
9
+ indent_inner_html: false, // Helps reduce file size
10
+ extra_liners: [] // Don't add extra new line before any tag
29
11
  }
30
12
 
13
+ config = direct ? config : get(config, 'prettify')
14
+
31
15
  // Don't prettify if not explicitly enabled in config
32
16
  if (!config || (isObject(config) && isEmpty(config))) {
33
17
  return html
34
18
  }
35
19
 
36
20
  if (typeof config === 'boolean' && config) {
37
- return format(html, defaultConfig).then(html => reFormat(html, defaultConfig))
21
+ return pretty(html, defaultConfig)
38
22
  }
39
23
 
40
24
  config = merge(defaultConfig, config)
41
25
 
42
- return format(html, config).then(html => reFormat(html, config))
43
- }
44
-
45
- const reFormat = (html, config) => {
46
- if (/<!doctype html>/i.test(html) && !config.xmlMode && config.rewriteSelfClosing) {
47
- html = html.replace(new RegExp(`<(${config.selfClosingTags.join('|')})\s?([^>]*?)\s?\/>`, 'g'), (match, p1, p2) => {
48
- return `<${p1}${p2.trimEnd()}>`
49
- })
50
- }
51
-
52
- return html
53
- // Fix style="" attributes broken down on multiple lines
54
- .replace(/(\s+style="\s+)([\s\S]*?)(\s+")/g, (match, p1, p2, p3) => {
55
- return p1.replace(/\n\s+?(style)/g, ' $1').trimEnd()
56
- + p2.replace(/\s+/g, ' ').trim()
57
- + p3.trim()
58
- })
59
- // Fix closing </pre> tags broken down on multiple lines (</pre>\n\s+>)
60
- .replace(/(<\/pre)\s+>/g, '$1>')
61
- // Undo escaping of quotes in attribute values
62
- .replace(/="(.*?)"/g, (match, p1) => {
63
- return `="${p1.replace(/&quot;/g, '\'')}"`
64
- })
65
- // Fix <tag \n\s+{attrs}\n\s+> => <tag {attrs}>
66
- .replace(/<([^>]+)\n\s*([^>]+)\n\s*>/g, '<$1 $2>')
67
- // Fix <tag {attrs}\n[\s\t]*> => <tag {attrs}>
68
- .replace(/<([^>]+)\n\s*>/g, '<$1>')
26
+ return pretty(html, config)
69
27
  }