Intial Commit

This commit is contained in:
valki
2020-10-17 18:42:50 +02:00
commit 664c6d8ca3
5892 changed files with 759183 additions and 0 deletions

21
nodered/rootfs/data/node_modules/tail/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2011 2012 2013 Forward
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

118
nodered/rootfs/data/node_modules/tail/README.md generated vendored Normal file
View File

@@ -0,0 +1,118 @@
# Tail
The **zero** dependency Node.js module for tailing a file
[![NPM](https://nodei.co/npm/tail.png?downloads=true&downloadRank=true)](https://nodei.co/npm/tail.png?downloads=true&downloadRank=true)
[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/lucagrulla/node-tail/blob/master/LICENSE)
[![npm](https://img.shields.io/npm/v/tail.svg?style=plastic)](https://www.npmjs.com/package/tail)
![npm](https://img.shields.io/npm/dm/tail.svg)
Author: [Luca Grulla](https://www.lucagrulla.com) - [www.lucagrulla.com](https://www.lucagrulla.com)
## Installation
```bash
npm install tail
```
## Use
```javascript
Tail = require('tail').Tail;
tail = new Tail("fileToTail");
tail.on("line", function(data) {
console.log(data);
});
tail.on("error", function(error) {
console.log('ERROR: ', error);
});
```
If you want to stop tail:
```javascript
tail.unwatch()
```
To start watching again:
```javascript
tail.watch()
```
## Configuration
The only mandatory parameter is the path to the file to tail.
```javascript
var fileToTail = "/path/to/fileToTail.txt";
new Tail(fileToTail)
```
If the file is **missing or invalid** ```Tail``` constructor will throw an Exception and won't initialize.
```javascript
try {
new Tail('missingFile.txt')
} catch ex {
console.log(ex)
}
```
Optional parameters can be passed via a hash:
```javascript
var options= {separator: /[\r]{0,1}\n/, fromBeginning: false, fsWatchOptions: {}, follow: true, logger: console}
new Tail(fileToTail, options)
```
### Constructor parameters
* `separator`: the line separator token (default: `/[\r]{0,1}\n/` to handle linux/mac (9+)/windows). Pass null if your file is binary there's no line separator.
* `fsWatchOptions`: the full set of options that can be passed to `fs.watch` as per node documentation (default: {}).
* `fromBeginning`: forces the tail of the file from the very beginning of it instead of from the first new line that will be appended (default: `false`).
* `follow`: simulate `tail -F` option. In the case the file is moved/renamed (or logrotated), if set to `true` `tail` will try to start tailing again after a 1 second delay, if set to `false` it will just emit an error event (default: `true`).
* `logger`: a logger object(default: no logger). The passed logger has to respond to two methods:
* `info([data][, ...])`
* `error([data][, ...])`
* `useWatchFile`: if set to `true` will force the use of `fs.watchFile` rather than delegating to the library the choice between `fs.watch` and `fs.watchFile` (default: `false`).
* `encoding`: the encoding of the file to tail (default:`utf-8`).
* `flushAtEOF`: set to `true` if you want to force flush of content when end of file is reached. Particularly useful when there's no separator character at the end of the file (default: `false`).
## Emitted events
`Tail` emits two events:
* line
```javascript
tail.on('line', (data) => {
console.log(data)
})
```
* error
```javascript
tail.on('error', (err) => {
console.log(err)
})
```
## How to contribute
Tail is written in [CoffeeScript](http://jashkenas.github.com/coffee-script/).
The Cakefile generates the javascript that is then published to npm.
## History
Tail was born as part of a data firehose. Read about it [here](https://www.lucagrulla.com/posts/building-a-firehose-with-nodejs/).
## License
MIT. Please see [License](https://github.com/lucagrulla/node-tail/blob/master/LICENSE) file for more details.

222
nodered/rootfs/data/node_modules/tail/lib/tail.js generated vendored Normal file
View File

@@ -0,0 +1,222 @@
// Generated by CoffeeScript 2.4.1
var Tail, environment, events, fs,
boundMethodCheck = function(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new Error('Bound instance method accessed before binding'); } };
events = require("events");
fs = require('fs');
environment = process.env['NODE_ENV'] || 'development';
Tail = class Tail extends events.EventEmitter {
readBlock() {
var block, stream;
boundMethodCheck(this, Tail);
if (this.queue.length >= 1) {
block = this.queue[0];
if (block.end > block.start) {
stream = fs.createReadStream(this.filename, {
start: block.start,
end: block.end - 1,
encoding: this.encoding
});
stream.on('error', (error) => {
if (this.logger) {
this.logger.error(`Tail error: ${error}`);
}
return this.emit('error', error);
});
stream.on('end', () => {
var x;
x = this.queue.shift();
if (this.queue.length > 0) {
this.internalDispatcher.emit("next");
}
if (this.flushAtEOF && this.buffer.length > 0) {
this.emit("line", this.buffer);
return this.buffer = '';
}
});
return stream.on('data', (data) => {
var chunk, i, len, parts, results;
if (this.separator === null) {
return this.emit("line", data);
} else {
this.buffer += data;
parts = this.buffer.split(this.separator);
this.buffer = parts.pop();
results = [];
for (i = 0, len = parts.length; i < len; i++) {
chunk = parts[i];
results.push(this.emit("line", chunk));
}
return results;
}
});
}
}
}
constructor(filename, options = {}) {
var err, fromBeginning;
super(filename, options);
this.readBlock = this.readBlock.bind(this);
this.change = this.change.bind(this);
this.filename = filename;
({separator: this.separator = /[\r]{0,1}\n/, fsWatchOptions: this.fsWatchOptions = {}, follow: this.follow = true, logger: this.logger, useWatchFile: this.useWatchFile = false, flushAtEOF: this.flushAtEOF = false, encoding: this.encoding = "utf-8", fromBeginning = false} = options);
if (this.logger) {
this.logger.info("Tail starting...");
this.logger.info(`filename: ${this.filename}`);
this.logger.info(`encoding: ${this.encoding}`);
try {
fs.accessSync(this.filename, fs.constants.F_OK);
} catch (error1) {
err = error1;
if (err.code === 'ENOENT') {
throw err;
}
}
}
this.buffer = '';
this.internalDispatcher = new events.EventEmitter();
this.queue = [];
this.isWatching = false;
this.internalDispatcher.on('next', () => {
return this.readBlock();
});
this.watch(fromBeginning);
}
change(filename) {
var err, stats;
boundMethodCheck(this, Tail);
try {
stats = fs.statSync(filename);
} catch (error1) {
err = error1;
if (this.logger) {
this.logger.error(`change event for ${filename} failed: ${err}`);
}
this.emit("error", `change event for ${filename} failed: ${err}`);
return;
}
if (stats.size < this.pos) { //scenario where texts is not appended but it's actually a w+
this.pos = stats.size;
}
if (stats.size > this.pos) {
this.queue.push({
start: this.pos,
end: stats.size
});
this.pos = stats.size;
if (this.queue.length === 1) {
return this.internalDispatcher.emit("next");
}
}
}
watch(fromBeginning) {
var err, stats;
if (this.isWatching) {
return;
}
if (this.logger) {
this.logger.info(`filesystem.watch present? ${fs.watch !== void 0}`);
this.logger.info(`useWatchFile: ${this.useWatchFile}`);
this.logger.info(`fromBeginning: ${fromBeginning}`);
}
this.isWatching = true;
try {
stats = fs.statSync(this.filename);
} catch (error1) {
err = error1;
if (this.logger) {
this.logger.error(`watch for ${this.filename} failed: ${err}`);
}
this.emit("error", `watch for ${this.filename} failed: ${err}`);
return;
}
this.pos = fromBeginning ? 0 : stats.size;
if (this.pos === 0) {
this.change(this.filename);
}
if (!this.useWatchFile && fs.watch) {
if (this.logger) {
this.logger.info("watch strategy: watch");
}
return this.watcher = fs.watch(this.filename, this.fsWatchOptions, (e, filename) => {
return this.watchEvent(e, filename);
});
} else {
if (this.logger) {
this.logger.info("watch strategy: watchFile");
}
return fs.watchFile(this.filename, this.fsWatchOptions, (curr, prev) => {
return this.watchFileEvent(curr, prev);
});
}
}
rename(filename) {
//MacOS sometimes throws a rename event for no reason.
//Different platforms might behave differently.
//see https://nodejs.org/api/fs.html#fs_fs_watch_filename_options_listener
//filename might not be present.
//https://nodejs.org/api/fs.html#fs_filename_argument
//Better solution would be check inode but it will require a timeout and
// a sync file read.
if (filename === void 0 || filename !== this.filename) {
this.unwatch();
if (this.follow) {
return setTimeout((() => {
return this.watch();
}), 1000);
} else {
if (this.logger) {
this.logger.error(`'rename' event for ${this.filename}. File not available.`);
}
return this.emit("error", `'rename' event for ${this.filename}. File not available.`);
}
} else {
}
}
// @logger.info("rename event but same filename")
watchEvent(e, evtFilename) {
if (e === 'change') {
return this.change(this.filename);
} else if (e === 'rename') {
return this.rename(evtFilename);
}
}
watchFileEvent(curr, prev) {
if (curr.size > prev.size) {
this.pos = curr.size; // Update @pos so that a consumer can determine if entire file has been handled
this.queue.push({
start: prev.size,
end: curr.size
});
if (this.queue.length === 1) {
return this.internalDispatcher.emit("next");
}
}
}
unwatch() {
if (this.watcher) {
this.watcher.close();
} else {
fs.unwatchFile(this.filename);
}
this.isWatching = false;
this.queue = [];
if (this.logger) {
return this.logger.info("Unwatch ", this.filename);
}
}
};
exports.Tail = Tail;

72
nodered/rootfs/data/node_modules/tail/package.json generated vendored Normal file
View File

@@ -0,0 +1,72 @@
{
"_from": "tail@^2.0.3",
"_id": "tail@2.0.3",
"_inBundle": false,
"_integrity": "sha512-s9NOGkLqqiDEtBttQZI7acLS8ycYK5sTlDwNjGnpXG9c8AWj0cfAtwEIzo/hVRMMiC5EYz+bXaJWC1u1u0GPpQ==",
"_location": "/tail",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "tail@^2.0.3",
"name": "tail",
"escapedName": "tail",
"rawSpec": "^2.0.3",
"saveSpec": null,
"fetchSpec": "^2.0.3"
},
"_requiredBy": [
"/node-red-node-tail"
],
"_resolved": "https://registry.npmjs.org/tail/-/tail-2.0.3.tgz",
"_shasum": "37567adc4624a70b35f1d146c3376fa3d6ef7c04",
"_spec": "tail@^2.0.3",
"_where": "/data/node_modules/node-red-node-tail",
"author": {
"name": "Luca Grulla",
"url": "https://www.lucagrulla.com"
},
"bugs": {
"url": "https://github.com/lucagrulla/node-tail/issues"
},
"bundleDependencies": false,
"contributors": [
{
"name": "Luca Grulla"
},
{
"name": "Tom Hall"
}
],
"dependencies": {},
"deprecated": false,
"description": "tail a file in node",
"devDependencies": {
"chai": "4.x",
"coffeescript": "2.4.1",
"mocha": "6.x"
},
"engines": {
"node": ">= 6.0.0"
},
"homepage": "https://www.lucagrulla.com/node-tail",
"keywords": [
"tail",
"file",
"logs"
],
"license": "MIT",
"main": "lib/tail",
"name": "tail",
"repository": {
"type": "git",
"url": "git://github.com/lucagrulla/node-tail.git"
},
"scripts": {
"build": "cake build",
"prepare": "npm run build",
"prepublishOnly": "npm run test",
"test": "mocha"
},
"version": "2.0.3"
}