Compare commits

...

17 Commits

Author SHA1 Message Date
dependabot[bot] fa285fc598
Bump copy-props from 2.0.4 to 2.0.5 (#103)
Bumps [copy-props](https://github.com/gulpjs/copy-props) from 2.0.4 to 2.0.5.
- [Release notes](https://github.com/gulpjs/copy-props/releases)
- [Changelog](https://github.com/gulpjs/copy-props/blob/master/CHANGELOG.md)
- [Commits](https://github.com/gulpjs/copy-props/compare/2.0.4...2.0.5)

---
updated-dependencies:
- dependency-name: copy-props
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-02-23 11:36:19 +01:00
dependabot[bot] 8fb1037afa
Bump is-my-json-valid from 2.15.0 to 2.20.6 (#104)
Bumps [is-my-json-valid](https://github.com/mafintosh/is-my-json-valid) from 2.15.0 to 2.20.6.
- [Release notes](https://github.com/mafintosh/is-my-json-valid/releases)
- [Commits](https://github.com/mafintosh/is-my-json-valid/compare/v2.15.0...v2.20.6)

---
updated-dependencies:
- dependency-name: is-my-json-valid
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-02-11 10:10:29 +01:00
dependabot[bot] 8b371bb49c
Bump trim-off-newlines from 1.0.1 to 1.0.3 (#102)
Bumps [trim-off-newlines](https://github.com/stevemao/trim-off-newlines) from 1.0.1 to 1.0.3.
- [Release notes](https://github.com/stevemao/trim-off-newlines/releases)
- [Commits](https://github.com/stevemao/trim-off-newlines/compare/v1.0.1...v1.0.3)

---
updated-dependencies:
- dependency-name: trim-off-newlines
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-02-11 10:10:00 +01:00
dependabot[bot] e721efe2ca
Bump node-sass from 4.14.1 to 7.0.0 (#101)
Bumps [node-sass](https://github.com/sass/node-sass) from 4.14.1 to 7.0.0.
- [Release notes](https://github.com/sass/node-sass/releases)
- [Changelog](https://github.com/sass/node-sass/blob/master/CHANGELOG.md)
- [Commits](https://github.com/sass/node-sass/compare/v4.14.1...v7.0.0)

---
updated-dependencies:
- dependency-name: node-sass
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-02-10 08:39:21 +01:00
Dan Mindru 96e868bdf2 Bump version 2021-09-04 09:39:10 +02:00
Anuj Punjani d7baeec5ab
Added custom inline-image plugin & modified build.js (#100)
* Modified build.js to use custom inline-image plugin
* Added inlineRemoteUrl property for inline image processing

Co-authored-by: Dan Mindru <nadurdnim@icloud.com>
2021-09-04 09:36:47 +02:00
Dan Mindru 0c1ff6d3dc
Build on PR 2021-09-01 21:18:08 +02:00
dependabot[bot] 6bc6ab5c9d
Bump postcss from 7.0.2 to 7.0.36 (#96)
Bumps [postcss](https://github.com/postcss/postcss) from 7.0.2 to 7.0.36.
- [Release notes](https://github.com/postcss/postcss/releases)
- [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md)
- [Commits](https://github.com/postcss/postcss/compare/7.0.2...7.0.36)

---
updated-dependencies:
- dependency-name: postcss
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-16 14:39:12 +02:00
dependabot[bot] b9ef0953de
Bump normalize-url from 4.5.0 to 4.5.1 (#95)
Bumps [normalize-url](https://github.com/sindresorhus/normalize-url) from 4.5.0 to 4.5.1.
- [Release notes](https://github.com/sindresorhus/normalize-url/releases)
- [Commits](https://github.com/sindresorhus/normalize-url/commits)

---
updated-dependencies:
- dependency-name: normalize-url
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-10 12:51:54 +02:00
dependabot[bot] 5f68bf303a
Bump browserslist from 4.8.7 to 4.16.6 (#94)
Bumps [browserslist](https://github.com/browserslist/browserslist) from 4.8.7 to 4.16.6.
- [Release notes](https://github.com/browserslist/browserslist/releases)
- [Changelog](https://github.com/browserslist/browserslist/blob/main/CHANGELOG.md)
- [Commits](https://github.com/browserslist/browserslist/compare/4.8.7...4.16.6)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-25 16:31:55 +02:00
dependabot[bot] 5b2710d3c2
Bump lodash from 4.17.15 to 4.17.21 (#93)
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.21.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.21)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-07 09:14:24 +02:00
dependabot[bot] deb81dd037
Bump y18n from 3.2.1 to 3.2.2 (#92)
Bumps [y18n](https://github.com/yargs/y18n) from 3.2.1 to 3.2.2.
- [Release notes](https://github.com/yargs/y18n/releases)
- [Changelog](https://github.com/yargs/y18n/blob/master/CHANGELOG.md)
- [Commits](https://github.com/yargs/y18n/commits)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-03-30 13:12:37 +02:00
dependabot[bot] f57fd62ce9
Bump ini from 1.3.4 to 1.3.7 (#91)
Bumps [ini](https://github.com/isaacs/ini) from 1.3.4 to 1.3.7.
- [Release notes](https://github.com/isaacs/ini/releases)
- [Commits](https://github.com/isaacs/ini/compare/v1.3.4...v1.3.7)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-12-18 15:00:51 +01:00
Ben Mares 1c27a30ab4
Fix typo which prevents clearing cached config (#90)
Closes #84
2020-10-30 08:33:35 +01:00
Dan Mindru 83c3389945 Merge branch 'master' of github.com:fadeit/responsive-html-email-signature 2020-09-21 22:38:21 +02:00
Dan Mindru aeaadaae53 Bump version 2020-09-21 22:37:49 +02:00
Dan Mindru 51857f1129
Add support for node 12 (#88)
* Add support for node 12

* Remove deps task completely
2020-09-21 22:35:10 +02:00
10 changed files with 17249 additions and 2891 deletions

View File

@ -1,6 +1,6 @@
name: Test template output
on: [push]
on: [push, pull_request]
jobs:
test:
@ -9,7 +9,7 @@ jobs:
strategy:
matrix:
node_version: [10, 11, 12]
node_version: [10, 11, 12, 13, 14]
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:

2
.nvmrc
View File

@ -1 +1 @@
v10
v12

View File

@ -23,7 +23,6 @@ require('./tasks/lint')(options);
require('./tasks/postcss')(options);
require('./tasks/sass')(options);
require('./tasks/check-for-unused').checkForUnusedTask(options);
require('./tasks/check-deps')(options);
/* Runs the entire pipeline once. */
gulp.task(

19919
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "responsive-html-email-signature",
"version": "6.0.1",
"version": "6.1.0",
"description": "Responsive template for emails & email signatures.",
"main": "index.js",
"repository": {
@ -36,14 +36,14 @@
"dependencies": {
"autoprefixer": "^9.6.1",
"chalk": "^2.4.2",
"cheerio": "^0.22.0",
"del": "^5.1.0",
"graceful-fs": "^4.2.3",
"gulp": "^4.0.2",
"gulp-autoprefixer": "^7.0.1",
"gulp-david": "^1.0.1",
"gulp-inline-css": "^3.5.0",
"gulp-inline-images-no-http": "^1.3.0",
"gulp-jsonlint": "^1.3.1",
"gulp-inline-images-no-http": "^1.3.3",
"gulp-jsonlint": "^1.3.2",
"gulp-less": "^4.0.1",
"gulp-minify-html": "~1.0.5",
"gulp-minify-inline": "^1.1.0",
@ -51,28 +51,32 @@
"gulp-postcss": "^8.0.0",
"gulp-preprocess": "^3.0.3",
"gulp-rename": "^2.0.0",
"gulp-sass": "^4.0.2",
"gulp-sass": "^4.1.0",
"klaw": "^3.0.0",
"node-sass": "^4.13.1"
},
"resolutions": {
"graceful-fs": "^4.1.15"
"node-sass": "^7.0.0",
"plugin-error": "^1.0.1",
"through2": "^2.0.5"
},
"devDependencies": {
"ava": "^2.4.0",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.0",
"eslint-config-standard": "^14.1.0",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-prettier": "^3.1.2",
"eslint-config-prettier": "^6.11.0",
"eslint-config-standard": "^14.1.1",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"gulp-cli": "^2.2.0",
"opencollective-postinstall": "^2.0.2",
"graceful-fs": "^4.2.4",
"gulp-cli": "^2.3.0",
"opencollective-postinstall": "^2.0.3",
"prettier": "^1.19.1",
"pretty-quick": "^2.0.1"
},
"resolutions": {
"graceful-fs": "^4.2.4",
"vinyl-fs": "^3.0.3"
},
"browserslist": [
"last 5 versions"
],

View File

@ -5,7 +5,7 @@ const minifyInline = require('gulp-minify-inline');
const preprocess = require('gulp-preprocess');
const rename = require('gulp-rename');
const del = require('del');
const inlineimg = require('gulp-inline-images-no-http');
const { inlineImg } = require('./check-for-image-url');
const { getConfigsForDir, getFilePathsForDir, getCssLinkTagsFromFilelist } = require('./util/util');
function buildTask(options) {
@ -34,7 +34,7 @@ function buildTask(options) {
return options
.src([cwd + '/**/*.html', '!' + cwd + '/**/*.inc.html'])
.pipe(preprocess({ context }))
.pipe(inlineimg())
.pipe(inlineImg({ getHTTP: confItems[0]['inlineRemoteUrl'] }))
.pipe(
inlineCss({
applyTableAttributes: true,

View File

@ -1,10 +0,0 @@
const gulp = require('gulp');
const david = require('gulp-david');
function checkDepsTask() {
gulp.task('check-deps', function checkDeps() {
gulp.src('package.json').pipe(david());
});
}
module.exports = checkDepsTask;

View File

@ -0,0 +1,155 @@
'use strict';
const https = require('https');
const http = require('http');
const path = require('path');
const url = require('url');
const fs = require('fs');
const PluginError = require('plugin-error');
const through = require('through2');
const cheerio = require('cheerio');
const { log } = require('./util/util');
const PLUGIN_NAME = 'gulp-inline-images';
const MIME_TYPE_REGEX = /.+\/([^\s]*)/;
const INLINE_ATTR = 'inline';
const NOT_INLINE_ATTR = `!${INLINE_ATTR}`;
function inlineImg(options = {}) {
const selector = options.selector || 'img[src]';
const attribute = options.attribute || 'src';
const getHTTP = options.getHTTP || false;
return through.obj(function(file, encoding, callback) {
if (file.isStream()) {
this.emit('error', new PluginError(PLUGIN_NAME, 'Streams are not supported!'));
return callback();
}
if (file.isBuffer()) {
const contents = file.contents.toString(encoding);
// Load it into cheerio's virtual DOM for easy manipulation
const $ = cheerio.load(contents);
const inlineFlag = $(`img[${INLINE_ATTR}]`);
// If images with an inline attr are found that is the selection we want
const imgTags = inlineFlag.length ? inlineFlag : $(selector);
let count = 0;
imgTags.each(function() {
const $img = $(this);
const src = $img.attr(attribute);
// Save the file format from the extension
const extFormat = path.extname(src).substr(1);
// If inlineFlag tags were found we want to remove the inline tag
if (inlineFlag.length) {
$img.removeAttr(INLINE_ATTR);
}
// Find !inline attribute
const notInlineFlag = $img.attr(NOT_INLINE_ATTR);
if (typeof notInlineFlag !== typeof undefined && notInlineFlag !== false) {
// Remove the tag and don't process this file
return $img.removeAttr(NOT_INLINE_ATTR);
}
// Count async ops
count++;
getSrcBase64(options.basedir || file.base, getHTTP, src, (err, result, resFormat, skipFormatting) => {
if (err) {
log.warn(`Failed to load http image. Check the format of ${src}.`);
log.error(err);
} else {
// Need a format in and a result for this to work
if (!skipFormatting) {
if (result && (extFormat || resFormat)) {
$img.attr('src', `data:image/${extFormat};base64,${result}`);
} else {
$img.attr('src', ``);
$img.attr('alt', `Image not found, Please check Url`);
log.warn(`Failed to read image. Check the format of ${src}.`);
}
}
if (!--count) {
file.contents = Buffer.from($.html());
callback(null, file);
}
}
});
});
// If no files are processing we don't need to wait as none were ever started
if (!imgTags.length) {
file.contents = Buffer.from($.html());
callback(null, file);
}
}
});
}
function getHTTPBase64(url, callback) {
// Get applicable library
const lib = url.startsWith('https') ? https : http;
// Initiate a git request to our URL
const req = lib.get(url, res => {
// Check for redirect
if (res.statusCode >= 301 && res.statusCode < 400 && res.headers.location) {
// Redirect
return getHTTPBase64(res.headers.location, callback);
}
// Check for HTTP errors
if (res.statusCode < 200 || res.statusCode >= 400) {
return callback(new Error('Failed to load page, status code: ' + res.statusCode));
}
// Get file format
let format;
if (res.headers['content-type']) {
const matches = res.headers['content-type'].match(MIME_TYPE_REGEX);
if (matches) {
format = matches[1];
}
}
// Create an empty buffer to store the body in
let body = Buffer.from([]);
// Append each chunk to the body
res.on('data', chunk => (body = Buffer.concat([body, chunk])));
// Done callback
res.on('end', () => callback(null, body.toString('base64'), format));
});
// Listen for network errors
req.on('error', err => callback(err));
}
function getSrcBase64(base, getHTTP, src, callback) {
// TODO: @deprecated — since v11.0.0 url.parse should be replaced with url.URL() ctor
if (!url.parse(src).hostname) {
// Get local file
const filePath = path.join(base, src);
if (fs.existsSync(filePath)) {
fs.readFile(filePath, 'base64', callback);
} else {
callback(null);
}
} else {
// Get remote file
if (getHTTP) {
return getHTTPBase64(src, callback);
} else {
callback(null, src, null, true);
}
}
}
module.exports = {
inlineImg,
getHTTPBase64,
getSrcBase64
};

View File

@ -28,7 +28,9 @@ const outputWarningsForUnusedItems = (unusedItems, configs) => {
const { dir } = configs[index];
unusedInConfigs.forEach(unusedInConfItems => {
const unusedItemsToLog = unusedInConfItems.filter(item => item !== `${OUTPUT_KEYWORD} id`);
const unusedItemsToLog = unusedInConfItems
.filter(item => item !== `${OUTPUT_KEYWORD} id`)
.filter(item => item !== '@echo inlineRemoteUrl');
if (unusedItemsToLog.length) {
log.warn(

View File

@ -25,8 +25,9 @@ const getConfigsForDir = (rootDir, configFileName) => {
let current = null;
let confItems;
delete require.cache[require.resolve(rootDir, confPath)]; // NB: For 'watch' to properly work, the cache needs to be deleted before each require.
current = require(path.resolve(rootDir, confPath));
const resolvedPath = path.resolve(rootDir, confPath);
delete require.cache[resolvedPath]; // NB: For 'watch' to properly work, the cache needs to be deleted before each require.
current = require(resolvedPath);
// Handle single objects or arrays of configs.
if (current && current.length) {