Skip to content

Commit

Permalink
feat: modernize, require node >= 14, bump deps
Browse files Browse the repository at this point in the history
  • Loading branch information
titanism committed Jul 4, 2022
1 parent 8a73adc commit 1b0ecdc
Show file tree
Hide file tree
Showing 24 changed files with 205 additions and 8,708 deletions.
10 changes: 0 additions & 10 deletions .babelrc

This file was deleted.

3 changes: 3 additions & 0 deletions .commitlintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ['@commitlint/config-conventional']
};
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!.*.js
6 changes: 0 additions & 6 deletions .eslintrc

This file was deleted.

2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* text=auto
* text=auto eol=lf
4 changes: 0 additions & 4 deletions .github/FUNDING.yml

This file was deleted.

26 changes: 26 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: CI
on:
- push
- pull_request
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
node_version:
- 14
- 16
- 18
name: Node ${{ matrix.node_version }} on ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node_version }}
- name: Install dependencies
run: npm install
- name: Run tests
run: npm run test
11 changes: 9 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,12 @@
node_modules
coverage
.nyc_output
locales
lib
locales/
package-lock.json
yarn.lock

Thumbs.db
tmp/
temp/
*.lcov
.env
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install commitlint --edit $1
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install lint-staged && npm test
5 changes: 5 additions & 0 deletions .lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
'*.md': (filenames) => filenames.map((filename) => `remark ${filename} -qfo`),
'package.json': 'fixpack',
'*.js': 'xo --fix'
};
5 changes: 0 additions & 5 deletions .npmignore

This file was deleted.

1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
5 changes: 5 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
singleQuote: true,
bracketSpacing: true,
trailingComma: 'none'
};
3 changes: 3 additions & 0 deletions .remarkrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
plugins: ['preset-github']
};
10 changes: 0 additions & 10 deletions .travis.yml

This file was deleted.

6 changes: 6 additions & 0 deletions .xo-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
prettier: true,
space: true,
extends: ['xo-lass'],
ignore: ['config.js']
};
61 changes: 22 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
# [**Email Templates**](https://github.com/forwardemail/email-templates)

[![build status](https://travis-ci.com/forwardemail/email-templates.svg)](https://travis-ci.com/forwardemail/email-templates)
[![code coverage](https://img.shields.io/codecov/c/github/forwardemail/email-templates.svg)](https://codecov.io/gh/forwardemail/email-templates)
[![build status](https://github.com/forwardemail/email-templates/actions/workflows/ci.yml/badge.svg)](https://github.com/forwardemail/email-templates/actions/workflows/ci.yml)
[![code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![made with lass](https://img.shields.io/badge/made_with-lass-95CC28.svg)](https://lass.js.org)
[![license](https://img.shields.io/github/license/forwardemail/email-templates.svg)](LICENSE)

> :heart: Love this project? Support <a href="https://github.com/niftylettuce" target="_blank">@niftylettuce's</a> [FOSS](https://en.wikipedia.org/wiki/Free_and_open-source_software) on <a href="https://patreon.com/niftylettuce" target="_blank">Patreon</a> or <a href="https://paypal.me/niftylettuce">PayPal</a> :unicorn:
Create, [preview][preview-email], and send custom email templates for [Node.js][node]. Highly configurable and supports automatic inline CSS, stylesheets, embedded images and fonts, and much more! Made for sending beautiful emails with [Lad][].
Create, [preview][preview-email], and send custom email templates for [Node.js][node]. Highly configurable and supports automatic inline CSS, stylesheets, embedded images and fonts, and much more! Made for [Forward Email][forward-email] and [Lad][].


## Table of Contents
Expand All @@ -35,6 +32,7 @@ Create, [preview][preview-email], and send custom email templates for [Node.js][
* [Options](#options)
* [Plugins](#plugins)
* [Breaking Changes](#breaking-changes)
* [v10.0.0](#v1000)
* [v9.0.0](#v900)
* [v8.0.0](#v800)
* [v7.0.0](#v700)
Expand All @@ -58,12 +56,6 @@ Create, [preview][preview-email], and send custom email templates for [Node.js][
npm install email-templates pug
```

[yarn][]:

```sh
yarn add email-templates pug
```


## Preview

Expand All @@ -82,10 +74,10 @@ See the example below for [Open Email Previews in Firefox](#open-email-previews-

#### Environment Flag

If you run into any issues with configuration, files, templates, locals, etc, then you can use the `DEBUG` environment flag:
If you run into any issues with configuration, files, templates, locals, etc, then you can use the `NODE_DEBUG` environment flag:

```sh
DEBUG=email-templates node app.js
NODE_DEBUG=email-templates node app.js
```

This will output to the console all debug statements in our codebase for this package.
Expand Down Expand Up @@ -124,7 +116,7 @@ const Email = require('email-templates');

const email = new Email({
message: {
from: 'niftylettuce@gmail.com'
from: 'test@example.com'
},
// uncomment below to send emails in development/test env:
// send: true
Expand Down Expand Up @@ -184,7 +176,7 @@ const Email = require('email-templates');

const email = new Email({
message: {
from: 'niftylettuce@gmail.com',
from: 'test@example.com',
attachments: [
{
filename: 'text1.txt',
Expand Down Expand Up @@ -215,7 +207,7 @@ const Email = require('email-templates');

const email = new Email({
message: {
from: 'niftylettuce@gmail.com'
from: 'test@example.com'
},
transport: {
jsonTransport: true
Expand Down Expand Up @@ -414,7 +406,7 @@ const Email = require('email-templates');

const email = new Email({
message: {
from: 'niftylettuce@gmail.com'
from: 'test@example.com'
},
transport: {
jsonTransport: true
Expand Down Expand Up @@ -533,7 +525,7 @@ const Email = require('email-templates');

const email = new Email({
message: {
from: 'niftylettuce@gmail.com'
from: 'test@example.com'
},
transport: {
jsonTransport: true
Expand Down Expand Up @@ -572,7 +564,7 @@ const env = process.env.NODE_ENV || 'development';

const email = new Email({
message: {
from: 'niftylettuce@gmail.com'
from: 'test@example.com'
},
transport: {
jsonTransport: true
Expand All @@ -594,7 +586,7 @@ const Email = require('email-templates');

const email = new Email({
message: {
from: 'niftylettuce@gmail.com'
from: 'test@example.com'
},
transport: {
jsonTransport: true
Expand Down Expand Up @@ -633,20 +625,14 @@ email
npm install ejs
```

[yarn][]:

```sh
yarn add ejs
```

2. Set the extension in options and send an email

```js
const Email = require('email-templates');

const email = new Email({
message: {
from: 'niftylettuce@gmail.com'
from: 'test@example.com'
},
transport: {
jsonTransport: true
Expand All @@ -672,12 +658,12 @@ const Email = require('email-templates');

const email = new Email({
message: {
from: 'niftylettuce@gmail.com',
from: 'test@example.com',
headers: {
'X-Some-Custom-Thing': 'Some-Value'
},
list: {
unsubscribe: 'https://niftylettuce.com/unsubscribe'
unsubscribe: 'https://example.com/unsubscribe'
}
},
transport: {
Expand Down Expand Up @@ -843,6 +829,10 @@ We also highly recommend to add to your default `config.locals` the following:

See the [Releases](https://github.com/forwardemail/email-templates/releases) page for an up to date changelog.

### v10.0.0

This package now requires Node v14+.

### v9.0.0

This package now requires Node v10.x+ due to [web-resource-inliner](https://github.com/jrit/web-resource-inliner/blob/master/HISTORY.md#2020-07-09-v500) dependency.
Expand Down Expand Up @@ -871,7 +861,7 @@ We upgraded `preview-email` to `v2.0.0`, which supports stream attachments, and
* Performance should be significantly improved as the rendering of subject, html, and text parts now occurs asynchronously in parallel (previously it was in series and had blocking lookup calls).
* We removed [bluebird][] and replaced it with a lightweight alternative [pify][] (since all we were using was the `Promise.promisify` method from `bluebird` as well).
* This package now only supports Node v8.x+ (due to [preview-email][]'s [open][] dependency requiring it).
* Configuration for the `preview` option has slightly changed, which now allows you to [specify a custom template and stylesheets](https://github.com/niftylettuce/preview-email#custom-preview-template-and-stylesheets) for preview rendering.
* Configuration for the `preview` option has slightly changed, which now allows you to [specify a custom template and stylesheets](https://github.com/forwardemail/preview-email#custom-preview-template-and-stylesheets) for preview rendering.

> If you were using a custom `preview` option before, you will need to change it slightly:
Expand Down Expand Up @@ -951,7 +941,6 @@ Instead of having to configure this for yourself, you could just use [Lad][] ins
* [lass][] - Scaffold a modern boilerplate for [Node.js][node]
* [cabin][] - Logging and analytics solution for [Node.js][node], [Lad][], [Koa][], and [Express][]
* [forward-email][] - Free, encrypted, and open-source email forwarding service for custom domains
* [lipo][] - Free image manipulation API service built on top of [Sharp][]


## Contributors
Expand All @@ -972,8 +961,6 @@ Instead of having to configure this for yourself, you could just use [Lad][] ins

[npm]: https://www.npmjs.com/

[yarn]: https://yarnpkg.com/

[pug]: https://pugjs.org

[supported-engines]: https://github.com/tj/consolidate.js/#supported-template-engines
Expand All @@ -1000,7 +987,7 @@ Instead of having to configure this for yourself, you could just use [Lad][] ins

[cache-pug-templates]: https://github.com/ladjs/cache-pug-templates

[preview-email]: https://github.com/niftylettuce/preview-email
[preview-email]: https://github.com/forwardemail/preview-email

[attachments]: https://nodemailer.com/message/attachments/

Expand All @@ -1010,17 +997,13 @@ Instead of having to configure this for yourself, you could just use [Lad][] ins

[forward-email]: https://forwardemail.net

[lipo]: https://lipo.io

[koa]: https://koajs.com/

[sharp]: http://sharp.dimens.io/

[express]: https://expressjs.com

[open-options]: https://github.com/sindresorhus/open#options

[mandarin]: https://github.com/niftylettuce/mandarin
[mandarin]: https://github.com/ladjs/mandarin

[consolidate]: https://github.com/tj/consolidate.js

Expand Down
9 changes: 3 additions & 6 deletions config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
docute.init({
debug: true,
title: 'Email Templates',
repo: 'niftylettuce/email-templates',
'edit-link': 'https://github.com/niftylettuce/email-templates/tree/master/',
twitter: 'niftylettuce',
repo: 'forwardemail/email-templates',
'edit-link': 'https://github.com/forwardemail/email-templates/tree/master/',
nav: {
default: [
{
Expand All @@ -12,7 +11,5 @@ docute.init({
}
]
},
plugins: [
docuteEmojify()
]
plugins: [docuteEmojify()]
});
2 changes: 1 addition & 1 deletion examples/sendgrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const transport = nodemailer.createTransport(

const email = new Email({
message: {
from: 'niftylettuce@gmail.com'
from: 'test@example.com'
},
// uncomment below to send emails in development/test env:
// send: true
Expand Down
3 changes: 2 additions & 1 deletion src/index.js → index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ const util = require('util');
const I18N = require('@ladjs/i18n');
const _ = require('lodash');
const consolidate = require('consolidate');
const debug = require('debug')('email-templates');
const getPaths = require('get-paths');
const { convert } = require('html-to-text');
const juice = require('juice');
const nodemailer = require('nodemailer');
const previewEmail = require('preview-email');

const debug = util.debuglog('email-templates');

// promise version of `juice.juiceResources`
const juiceResources = (html, options) => {
return new Promise((resolve, reject) => {
Expand Down

0 comments on commit 1b0ecdc

Please sign in to comment.