# node-lts-notifier

> A CLI tool that checks the node.js RSS feed and sends a mail notification mail whenver it detects a new LTS version is

Latest version **0.4.1** (published 2018-12-04) · ISC license · 0 weekly downloads

## Install

```sh
npm install node-lts-notifier
pnpm add node-lts-notifier
yarn add node-lts-notifier
bun add node-lts-notifier
```

Provides the command `node-lts-notif`.

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.4.1 |
| Published | 2018-12-04 |
| First published | 2018-10-14 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 11.8 KB |
| Known vulnerabilities | 0 (+48 in 3 direct dependencies) |
| Install scripts | no |
| GitHub stars | 3 |
| Maintainers | osher |
| Keywords | nodejs, lts, mail-notification |

## Links

- npm: https://www.npmjs.com/package/node-lts-notifier
- Repository: https://github.com/osher/node-lts-notifier
- Homepage: https://github.com/osher/node-lts-notifier#readme
- Issues: https://github.com/osher/node-lts-notifier/issues
- npm.io page: https://npm.io/package/node-lts-notifier

## Dependencies (6)

- [axios](https://npm.io/package/axios.md) ^0.18.0
- [debug](https://npm.io/package/debug.md) ^4.0.1
- [colors](https://npm.io/package/colors.md) ^1.3.2
- [xml2js](https://npm.io/package/xml2js.md) ^0.4.19
- [js-yaml](https://npm.io/package/js-yaml.md) ^3.12.0
- [nodemailer](https://npm.io/package/nodemailer.md) ^4.6.8

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 0.4.1 (latest) — 2018-12-04
- 0.4.0 — 2018-12-03
- 0.1.2 — 2018-11-05
- 0.1.1 — 2018-11-05
- 0.1.0 — 2018-10-14

## README

# node-lts-notifier

A CLI tool that checks the node.js RSS feed and sends a notification mail whenver it detects a new LTS version.

The tool is intended to be run by a schedueler such as a cron-task or a jenkins job.

Uses the `nodemailer` npm package, and requires to be configured with an SMTP server.

# Install
```
npm i node-lts-notifier -g
```

## since: `0.4.0`:
Installing `node-lts-notifier` using `-g` adds an additional command to your machine:
 - `node-lts-notif`

Run it from your shell or from your favorite schedueler.
 
# Configure
## since: `0.4.0`

Once ran, it expects a configuration file, and will terminate with an error and a friendly 
message if this file is not found, or if it cannot be parsed as a valid `yaml`.

e.g:
```
ERROR: Cannot open configuration file
tried path:
  /home/centos/.lts-notif.yaml

effecting env-vars:
 - LTS_NOTIF_FILE - path to the yaml file
 - LTS_NOTIF_HOME - when LTS_NOTIF_FILE is unset, may indicate location of a .lts-notif.yaml file
 - HOME/HOMEPATH  - when LTS_NOTIF_HOME is unset, .lts-notif.yaml is searched in user's home directory

error:
  ENOENT: no such file or directory, open '/home/centos/.lts-notif.yaml'
```

If you provided a full path usign `LTS_NOTIF_FILE` or you provided the path to the directory a `.lts-notif.yaml` is found using `LTS_NOTIF_HOME`, or you have placed it in your home directory -
the file it's looking for should look like the following example:

```
message:
  to:
   - name:    Osher E.
     address: onetanany@mycooldomain.com
  from:
   - name:    Node LTS
     address: noreply@mycooldomain.com

nodemailer:
  type:     smtp
  options:
    host:   mailgw.mycooldomain.com
    tls:
      rejectUnauthorized: false

reported:

```
*NOTES:* 
1. This is a rather basic example, which passes to `nodemailer` smtp configuration of a relay server.
   However - you can pass in `nodemailer.options` any valid [`nodemailer`](https://community.nodemailer.com/2-0-0-beta/setup-smtp/) configuration.
   version `0.4.0` supports just `smtp` setups - because they do not require any processing and can be passed as is to `nodemailer`.
   Future versions will add `gmail`, `aws`, etc.
   Having said that - `nodemailer`'s `smtp` setup support quite a lot :)
2. The `reported` section must be in the end of the file and the file *must end with an empty line*.
   The code appends a line as a string array-item to this file for each reported LTS version.
   It does so in order to remember what it has already reported before.

# Usage
## since `0.4.0`:

Run the `node-lts-notif` from your shell or from your favorite schedueler.

## since `0.1.2`:
This initial version implements only the core module, without the `bin` file to wrap it in a mature CLI - this wrap will come in the future, as my free time allows it.

The way I run it now is using a Jenkins job, where the command is in the following spirit (domain and emails replaced with `example.com`):

```
node -e "require('node-lts-notifier/lib')({reportFrom: 'Node LTS Notifier<no-reply@example.com>', reportTo: ['devteam@example.com','opsteam@example.com'], smtp: { host: 'mailgw.example.com',  tls: { rejectUnauthorized: false }}}).then(console.log);"
```

Mind the `smtp` field in the passed options.
This example is the simplest - it uses a relay smtp in the local LAN.

However - this  `smtp` object is currently passed as is to `nodemailer` - so you may pass whatever you need, including creds.
The only `nodemailer` config that is not trivial is `aws transport` - which will be dealt in the future.

# Custom formatter
## since `0.4.0`
*_experimental_*:
You can provide a node.js module to handle message formatting by providing in your configuration a `customFormatter` key.
 - When it's an object - it's expected to have property `module` - a path to the module.
 - When it's a string - it's converted to an object, using the string value as the `module` property. 

If the loaded module exports an .init(conf) method - it's being passed the `customFormatter` section, 
and the returned value is used as the custom formatter.
If not - the returned value of the required module is passed as the custom formatter as is.

The value is overriding the built-in formatter, and may override:
 - `subject({title}):String` - format your own subject
 - `body({title, pubDate, link, description}):String` - format your own body from the info in feed
 - `message(feed, msgDefaults): message` - overriding this method negates the previous two.
    it should return a valid `nodemailer` message object.
    The default returns:
     - `from` and `to` from `msgDefaults` - which is basically, the `message` section from the config, 
     - `subject`, and `html` as formatted by the previous two APIs.

# Future
 - config check with idiot-proof error messages
 - mature the repo
   - add a test suite
   - add CI
   - add coverage tool
   - move docs to a site / wiki
 - support nodemailer gmail transport
 - support nodemailer aws transport

---
_Source: https://npm.io/package/node-lts-notifier · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
