Comparing version 4.14.1 to 4.15.0
"use strict"; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -11,55 +9,28 @@ value: true | ||
exports.default = void 0; | ||
var _omit2 = _interopRequireDefault(require("lodash/omit")); | ||
var _get2 = _interopRequireDefault(require("lodash/get")); | ||
var _map2 = _interopRequireDefault(require("lodash/map")); | ||
var _isEmpty2 = _interopRequireDefault(require("lodash/isEmpty")); | ||
var _isArray2 = _interopRequireDefault(require("lodash/isArray")); | ||
var _pickBy2 = _interopRequireDefault(require("lodash/fp/pickBy")); | ||
var _negate2 = _interopRequireDefault(require("lodash/fp/negate")); | ||
var _isNil2 = _interopRequireDefault(require("lodash/fp/isNil")); | ||
var _pick2 = _interopRequireDefault(require("lodash/fp/pick")); | ||
var _flow2 = _interopRequireDefault(require("lodash/fp/flow")); | ||
var _path = _interopRequireDefault(require("path")); | ||
var _yargs = _interopRequireDefault(require("yargs")); | ||
var _jsBeautify = require("js-beautify"); | ||
var _htmlMinifier = require("html-minifier"); | ||
var _mjmlCore = _interopRequireWildcard(require("mjml-core")); | ||
var _mjmlMigrate = _interopRequireDefault(require("mjml-migrate")); | ||
var _mjmlValidator = _interopRequireWildcard(require("mjml-validator")); | ||
var _mjmlParserXml = _interopRequireDefault(require("mjml-parser-xml")); | ||
var _package = require("mjml-core/package.json"); | ||
var _readFile = _interopRequireWildcard(require("./commands/readFile")); | ||
var _watchFiles = _interopRequireDefault(require("./commands/watchFiles")); | ||
var _readStream = _interopRequireDefault(require("./commands/readStream")); | ||
var _outputToFile = _interopRequireWildcard(require("./commands/outputToFile")); | ||
var _outputToConsole = _interopRequireDefault(require("./commands/outputToConsole")); | ||
var _package2 = require("../package.json"); | ||
var _defaultOptions = _interopRequireDefault(require("./helpers/defaultOptions")); | ||
const beautifyConfig = { | ||
@@ -78,10 +49,7 @@ indent_size: 2, | ||
}; | ||
var _default = async () => { | ||
let EXIT_CODE = 0; | ||
let KEEP_OPEN = false; | ||
const error = msg => { | ||
console.error('\nCommand line error:'); // eslint-disable-line no-console | ||
console.error(msg); // eslint-disable-line no-console | ||
@@ -91,5 +59,3 @@ | ||
}; | ||
const pickArgs = args => (0, _flow2.default)((0, _pick2.default)(args), (0, _pickBy2.default)(e => (0, _negate2.default)(_isNil2.default)(e) && !((0, _isArray2.default)(e) && (0, _isEmpty2.default)(e)))); | ||
const { | ||
@@ -145,3 +111,2 @@ argv | ||
}).help().version(`mjml-core: ${_package.version}\nmjml-cli: ${_package2.version}`); | ||
let juiceOptions; | ||
@@ -151,3 +116,2 @@ let minifyOptions; | ||
let fonts; | ||
try { | ||
@@ -158,3 +122,2 @@ juiceOptions = argv.c && argv.c.juiceOptions && JSON.parse(argv.c.juiceOptions); | ||
} | ||
try { | ||
@@ -165,3 +128,2 @@ minifyOptions = argv.c && argv.c.minifyOptions && JSON.parse(argv.c.minifyOptions); | ||
} | ||
try { | ||
@@ -172,3 +134,2 @@ juicePreserveTags = argv.c && argv.c.juicePreserveTags && JSON.parse(argv.c.juicePreserveTags); | ||
} | ||
try { | ||
@@ -179,3 +140,2 @@ fonts = argv.c && argv.c.fonts && JSON.parse(argv.c.fonts); | ||
} | ||
const filePath = argv.c && argv.c.filePath; | ||
@@ -194,3 +154,5 @@ const config = Object.assign(_defaultOptions.default, argv.c, fonts && { | ||
const inputArgs = pickArgs(['r', 'w', 'i', '_', 'm', 'v'])(argv); | ||
const outputArgs = pickArgs(['o', 's'])(argv) // implies (until yargs pr is accepted) | ||
const outputArgs = pickArgs(['o', 's'])(argv) | ||
// implies (until yargs pr is accepted) | ||
; | ||
@@ -202,3 +164,2 @@ [[Object.keys(inputArgs).length === 0, 'No input argument received'], [Object.keys(inputArgs).length > 1, 'Too many input arguments received'], [Object.keys(outputArgs).length > 1, 'Too many output arguments received'], [argv.w && argv.w.length > 1 && !argv.o, 'Need an output option when watching files'], [argv.w && argv.w.length > 1 && argv.o && !(0, _outputToFile.isDirectory)(argv.o) && argv.o !== '', 'Need an output option when watching files']].forEach(v => v[0] ? error(v[1]) : null); | ||
const inputs = []; | ||
switch (inputOpt) { | ||
@@ -213,3 +174,2 @@ case 'r': | ||
}); | ||
if (!inputs.length) { | ||
@@ -219,8 +179,7 @@ error('No input files found'); | ||
} | ||
break; | ||
} | ||
case 'w': | ||
(0, _watchFiles.default)(inputFiles, { ...argv, | ||
(0, _watchFiles.default)(inputFiles, { | ||
...argv, | ||
config, | ||
@@ -232,11 +191,8 @@ minifyConfig, | ||
break; | ||
case 'i': | ||
inputs.push(await (0, _readStream.default)()); | ||
break; | ||
default: | ||
error('Command line error: Incorrect input options'); | ||
} | ||
const convertedStream = []; | ||
@@ -247,3 +203,2 @@ const failedStream = []; | ||
let compiled; | ||
switch (inputOpt) { | ||
@@ -257,3 +212,2 @@ case 'm': | ||
break; | ||
case 'v': | ||
@@ -274,3 +228,2 @@ // eslint-disable-next-line no-case-declarations | ||
break; | ||
default: | ||
@@ -280,13 +233,13 @@ { | ||
const minify = config.minify && config.minify !== 'false'; | ||
compiled = (0, _mjmlCore.default)(i.mjml, { ...(0, _omit2.default)(config, ['minify', 'beautify']), | ||
compiled = (0, _mjmlCore.default)(i.mjml, { | ||
...(0, _omit2.default)(config, ['minify', 'beautify']), | ||
filePath: filePath || i.file, | ||
actualPath: i.file | ||
}); | ||
if (beautify) { | ||
compiled.html = (0, _jsBeautify.html)(compiled.html, beautifyConfig); | ||
} | ||
if (minify) { | ||
compiled.html = (0, _htmlMinifier.minify)(compiled.html, { ...minifyConfig, | ||
compiled.html = (0, _htmlMinifier.minify)(compiled.html, { | ||
...minifyConfig, | ||
...config.minifyOptions | ||
@@ -297,4 +250,4 @@ }); | ||
} | ||
convertedStream.push({ ...i, | ||
convertedStream.push({ | ||
...i, | ||
compiled | ||
@@ -325,6 +278,4 @@ }); | ||
}); | ||
if (inputOpt === 'v') { | ||
const isInvalid = failedStream.length || convertedStream.some(s => !!(0, _get2.default)(s, 'compiled.errors.length')); | ||
if (isInvalid) { | ||
@@ -334,11 +285,8 @@ error('Validation failed'); | ||
} | ||
process.exitCode = 0; | ||
return; | ||
} | ||
if (!KEEP_OPEN && convertedStream.length === 0) { | ||
error('Input file(s) failed to render'); | ||
} | ||
switch (outputOpt) { | ||
@@ -350,9 +298,6 @@ case 'o': | ||
} | ||
const fullOutputPath = _path.default.parse(_path.default.resolve(process.cwd(), argv.o)); | ||
if (inputs.length === 1 && !(0, _outputToFile.isDirectory)(fullOutputPath.dir)) { | ||
error(`Output directory doesn’t exist for path : ${argv.o}`); | ||
} | ||
Promise.all(convertedStream.map((0, _outputToFile.default)(argv.o))).then(() => { | ||
@@ -372,3 +317,2 @@ if (!KEEP_OPEN) { | ||
} | ||
case 's': | ||
@@ -379,6 +323,4 @@ { | ||
.catch(() => process.exitCode = 1); // eslint-disable-line no-return-assign | ||
break; | ||
} | ||
default: | ||
@@ -388,4 +330,3 @@ error('Command line error: No output option available'); | ||
}; | ||
exports.default = _default; | ||
module.exports = exports.default; |
@@ -7,3 +7,2 @@ "use strict"; | ||
exports.default = void 0; | ||
var _default = ({ | ||
@@ -16,12 +15,9 @@ compiled: { | ||
let output = ''; | ||
if (addFileHeaderComment) { | ||
output = `<!-- FILE: ${file} -->\n`; | ||
} | ||
output += `${html}\n`; | ||
process.stdout.write(output, resolve); | ||
}); | ||
exports.default = _default; | ||
module.exports = exports.default; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = exports.isDirectory = void 0; | ||
exports.isDirectory = exports.default = void 0; | ||
var _fs = _interopRequireDefault(require("fs")); | ||
var _path = _interopRequireDefault(require("path")); | ||
const isDirectory = file => { | ||
try { | ||
const outputPath = _path.default.resolve(process.cwd(), file); | ||
return _fs.default.statSync(outputPath).isDirectory(); | ||
@@ -23,9 +18,5 @@ } catch (e) { | ||
}; | ||
exports.isDirectory = isDirectory; | ||
const replaceExtension = input => input.replace('.mjml', input.replace('.mjml', '').match(/(.)*\.(.)+$/g) ? '' : '.html'); | ||
const stripPath = input => input.match(/[^/\\]+$/g)[0]; | ||
const makeGuessOutputName = outputPath => { | ||
@@ -35,3 +26,2 @@ if (isDirectory(outputPath)) { | ||
} | ||
return input => { | ||
@@ -41,7 +31,5 @@ if (!outputPath) { | ||
} | ||
return outputPath; | ||
}; | ||
}; | ||
var _default = outputPath => { | ||
@@ -56,3 +44,2 @@ const guessOutputName = makeGuessOutputName(outputPath); | ||
const outputName = guessOutputName(file); | ||
_fs.default.writeFile(outputName, html, err => { | ||
@@ -66,3 +53,2 @@ if (err) { | ||
} | ||
return resolve(outputName); | ||
@@ -72,3 +58,2 @@ }); | ||
}; | ||
exports.default = _default; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = exports.flatMapPaths = void 0; | ||
exports.flatMapPaths = exports.default = void 0; | ||
var _flatMap2 = _interopRequireDefault(require("lodash/flatMap")); | ||
var _fs = _interopRequireDefault(require("fs")); | ||
var _glob = _interopRequireDefault(require("glob")); | ||
const flatMapPaths = paths => (0, _flatMap2.default)(paths, p => _glob.default.sync(p, { | ||
nodir: true | ||
})); | ||
exports.flatMapPaths = flatMapPaths; | ||
var _default = path => { | ||
@@ -34,3 +27,2 @@ try { | ||
}; | ||
exports.default = _default; |
@@ -7,3 +7,2 @@ "use strict"; | ||
exports.default = void 0; | ||
const stdinSync = () => new Promise(res => { | ||
@@ -17,3 +16,2 @@ let buffer = ''; | ||
}); | ||
var _default = async () => { | ||
@@ -25,4 +23,3 @@ const mjml = await stdinSync(); | ||
}; | ||
exports.default = _default; | ||
module.exports = exports.default; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,57 +8,33 @@ value: true | ||
exports.default = void 0; | ||
var _omit2 = _interopRequireDefault(require("lodash/omit")); | ||
var _remove2 = _interopRequireDefault(require("lodash/fp/remove")); | ||
var _difference2 = _interopRequireDefault(require("lodash/fp/difference")); | ||
var _uniq2 = _interopRequireDefault(require("lodash/fp/uniq")); | ||
var _flatMap3 = _interopRequireDefault(require("lodash/fp/flatMap")); | ||
var _pickBy2 = _interopRequireDefault(require("lodash/fp/pickBy")); | ||
var _flow2 = _interopRequireDefault(require("lodash/fp/flow")); | ||
var _chokidar = _interopRequireDefault(require("chokidar")); | ||
var _glob = _interopRequireDefault(require("glob")); | ||
var _path = _interopRequireDefault(require("path")); | ||
var _mjmlCore = _interopRequireDefault(require("mjml-core")); | ||
var _jsBeautify = require("js-beautify"); | ||
var _htmlMinifier = require("html-minifier"); | ||
var _readFile = _interopRequireDefault(require("./readFile")); | ||
var _outputToFile = _interopRequireDefault(require("./outputToFile")); | ||
var _fileContext = _interopRequireDefault(require("../helpers/fileContext")); | ||
/* eslint-disable no-console */ | ||
/* eslint-disable no-console */ | ||
let dirty = []; | ||
const _flatMap = _flatMap3.default.convert({ | ||
cap: false | ||
}); // eslint-disable-line no-underscore-dangle | ||
const flatMapAndJoin = _flatMap((v, k) => v.map(p => _path.default.join(k, p))); | ||
const flatMapKeyAndValues = (0, _flow2.default)(_flatMap((v, k) => [k, ...v]), _uniq2.default); | ||
var _default = (input, options) => { | ||
const dependencies = {}; | ||
const outputToFile = (0, _outputToFile.default)(options.o); | ||
const getRelatedFiles = file => (0, _flow2.default)((0, _pickBy2.default)((v, k) => k === file || v.indexOf(file) !== -1), Object.keys)(dependencies); | ||
const synchronyzeWatcher = filePath => { | ||
getRelatedFiles(filePath).forEach(f => { | ||
dependencies[f] = (0, _fileContext.default)(f, options.config.filePath); | ||
if (dirty.indexOf(f) === -1) { | ||
@@ -69,4 +44,4 @@ dirty.push(f); | ||
}); | ||
/* eslint-disable no-use-before-define */ | ||
const files = { | ||
@@ -80,3 +55,2 @@ toWatch: flatMapKeyAndValues(dependencies), | ||
}; | ||
const readAndCompile = (0, _flow2.default)(file => ({ | ||
@@ -98,14 +72,13 @@ file, | ||
}); | ||
if (beautify) { | ||
compiled.html = (0, _jsBeautify.html)(compiled.html, beautifyConfig); | ||
} | ||
if (minify) { | ||
compiled.html = (0, _htmlMinifier.minify)(compiled.html, { ...minifyConfig, | ||
compiled.html = (0, _htmlMinifier.minify)(compiled.html, { | ||
...minifyConfig, | ||
...config.minifyOptions | ||
}); | ||
} | ||
return { ...args, | ||
return { | ||
...args, | ||
compiled | ||
@@ -122,17 +95,12 @@ }; | ||
}, args => outputToFile(args).then(() => console.log(`${args.file} - Successfully compiled`)).catch(() => console.log(`${args.file} - Error while compiling file`))); | ||
const watcher = _chokidar.default.watch(input.map(i => i.replace(/\\/g, '/'))).on('change', file => synchronyzeWatcher(_path.default.resolve(file))).on('add', file => { | ||
const filePath = _path.default.resolve(file); | ||
console.log(`Now watching file: ${filePath}`); | ||
const matchInputOption = input.reduce((found, file) => found || (0, _glob.default)(_path.default.resolve(file)).minimatch.match(filePath), false); | ||
if (matchInputOption) { | ||
dependencies[filePath] = getRelatedFiles(filePath); | ||
} | ||
synchronyzeWatcher(filePath); | ||
}).on('unlink', file => { | ||
const filePath = _path.default.resolve(file); | ||
delete dependencies[_path.default.resolve(filePath)]; | ||
@@ -142,7 +110,5 @@ (0, _remove2.default)(dirty, f => f === filePath); | ||
}); | ||
setInterval(() => { | ||
dirty.forEach(f => { | ||
console.log(`${f} - Change detected`); | ||
try { | ||
@@ -159,5 +125,3 @@ readAndCompile(f); | ||
/* eslint-enable no-console */ | ||
exports.default = _default; | ||
module.exports = exports.default; |
@@ -7,7 +7,6 @@ "use strict"; | ||
exports.default = void 0; | ||
var _default = { | ||
var _default = exports.default = { | ||
beautify: true, | ||
minify: false | ||
}; | ||
exports.default = _default; | ||
module.exports = exports.default; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,22 +8,13 @@ value: true | ||
exports.default = void 0; | ||
var _fs = _interopRequireDefault(require("fs")); | ||
var _path = _interopRequireDefault(require("path")); | ||
const includeRegexp = /<mj-include[^<>]+path=['"](.*(?:\.mjml|\.css|\.html))['"]\s*[^<>]*(\/>|>\s*<\/mj-include>)/gi; | ||
const ensureIncludeIsSupportedFile = file => _path.default.extname(file).match(/\.mjml|\.css|\.html/) ? file : `${file}.mjml`; | ||
const error = e => console.error(e.stack || e); // eslint-disable-line no-console | ||
var _default = (baseFile, filePath) => { | ||
const filesIncluded = []; | ||
let filePathDirectory = ''; | ||
if (filePath) { | ||
try { | ||
const isFilePathDir = _fs.default.lstatSync(filePath).isDirectory(); | ||
filePathDirectory = isFilePathDir ? filePath : _path.default.dirname(filePath); | ||
@@ -39,11 +29,7 @@ } catch (e) { | ||
} | ||
const readIncludes = (dir, file, base) => { | ||
const currentFile = _path.default.resolve(dir ? _path.default.join(dir, ensureIncludeIsSupportedFile(file)) : ensureIncludeIsSupportedFile(file)); | ||
const currentDirectory = _path.default.dirname(currentFile); | ||
const includes = new RegExp(includeRegexp); | ||
let content; | ||
try { | ||
@@ -55,13 +41,10 @@ content = _fs.default.readFileSync(currentFile, 'utf8'); | ||
} | ||
let matchgroup = includes.exec(content); | ||
while (matchgroup != null) { | ||
const includedFile = ensureIncludeIsSupportedFile(matchgroup[1]); | ||
while (matchgroup != null) { | ||
const includedFile = ensureIncludeIsSupportedFile(matchgroup[1]); // when reading first level of includes we must join the path specified in filePath | ||
// when reading first level of includes we must join the path specified in filePath | ||
// when reading further nested includes, just take parent dir as base | ||
const targetDir = filePath && file === baseFile ? filePathDirectory : currentDirectory; | ||
const includedFilePath = _path.default.resolve(_path.default.join(targetDir, includedFile)); | ||
filesIncluded.push(includedFilePath); | ||
@@ -72,8 +55,6 @@ readIncludes(targetDir, includedFile, currentFile); | ||
}; | ||
readIncludes(null, baseFile, baseFile); | ||
return filesIncluded; | ||
}; | ||
exports.default = _default; | ||
module.exports = exports.default; |
{ | ||
"name": "mjml-cli", | ||
"description": "MJML: the only framework that makes responsive-email easy", | ||
"version": "4.14.1", | ||
"version": "4.15.0", | ||
"main": "bin/mjml", | ||
@@ -30,11 +30,11 @@ "bin": { | ||
"chokidar": "^3.0.0", | ||
"glob": "^7.1.1", | ||
"glob": "^10.3.10", | ||
"html-minifier": "^4.0.0", | ||
"js-beautify": "^1.6.14", | ||
"lodash": "^4.17.21", | ||
"mjml-core": "4.14.1", | ||
"mjml-migrate": "4.14.1", | ||
"mjml-parser-xml": "4.14.1", | ||
"mjml-core": "4.15.0", | ||
"mjml-migrate": "4.15.0", | ||
"mjml-parser-xml": "4.15.0", | ||
"mjml-validator": "4.13.0", | ||
"yargs": "^16.1.0" | ||
"yargs": "^17.7.2" | ||
}, | ||
@@ -45,3 +45,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "988819de3375867c09585d28f555166b97415200" | ||
"gitHead": "af922bd11c16f4182057077a8a060b7a7f7cc4e3" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
641
30196
+ Addedcliui@8.0.1(transitive)
+ Addedhtmlparser2@9.1.0(transitive)
+ Addedjuice@10.0.1(transitive)
+ Addedmjml-core@4.15.0(transitive)
+ Addedmjml-migrate@4.15.0(transitive)
+ Addedmjml-parser-xml@4.15.0(transitive)
+ Addedyargs@17.7.2(transitive)
+ Addedyargs-parser@21.1.1(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedcliui@7.0.4(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removeddetect-node@2.0.4(transitive)
- Removedfs.realpath@1.0.0(transitive)
- Removedglob@7.2.3(transitive)
- Removedinflight@1.0.6(transitive)
- Removedinherits@2.0.4(transitive)
- Removedjuice@9.1.0(transitive)
- Removedminimatch@3.1.2(transitive)
- Removedmjml-core@4.14.1(transitive)
- Removedmjml-migrate@4.14.1(transitive)
- Removedmjml-parser-xml@4.14.1(transitive)
- Removedonce@1.4.0(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedwrappy@1.0.2(transitive)
- Removedyargs@16.2.0(transitive)
- Removedyargs-parser@20.2.9(transitive)
Updatedglob@^10.3.10
Updatedmjml-core@4.15.0
Updatedmjml-migrate@4.15.0
Updatedmjml-parser-xml@4.15.0
Updatedyargs@^17.7.2