From 5d0ed963a0b4003ca45b0c18114102e3faca2120 Mon Sep 17 00:00:00 2001 From: Manuel Spigolon Date: Tue, 21 Sep 2021 13:25:46 +0200 Subject: [PATCH 1/4] add ci --- .github/workflows/ci.yml | 36 ++++++++++++++++++++++++++++++++++++ .gitignore | 2 ++ 2 files changed, 38 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..f175a26 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,36 @@ +name: CI +on: + push: + paths-ignore: + - '*.md' + pull_request: + paths-ignore: + - '*.md' +jobs: + test: + name: ${{ matrix.node-version }} ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + node-version: [12, 14, 16] + steps: + - uses: actions/checkout@v2.3.4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2.4.0 + with: + node-version: ${{ matrix.node-version }} + - name: Install + run: npm i + - name: Tests + run: npm run ci + + automerge: + needs: test + runs-on: ubuntu-latest + steps: + - uses: fastify/github-action-merge-dependabot@v2.5.0 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + target: minor diff --git a/.gitignore b/.gitignore index 39fd574..7ec73e9 100644 --- a/.gitignore +++ b/.gitignore @@ -103,3 +103,5 @@ Icon Network Trash Folder Temporary Items .apdisk + +package-lock.json From 58720343a2839643f687c4c6edbe052aeec50dc0 Mon Sep 17 00:00:00 2001 From: Manuel Spigolon Date: Tue, 21 Sep 2021 13:26:00 +0200 Subject: [PATCH 2/4] update linter --- lib/rfc3164.js | 4 ++-- lib/rfc5424.js | 2 +- lib/utils.js | 4 ++-- package.json | 7 ++++--- psyslog.js | 2 +- test/3164.test.js | 2 +- test/5424.test.js | 4 ++-- 7 files changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/rfc3164.js b/lib/rfc3164.js index 49e68ac..552fd6a 100644 --- a/lib/rfc3164.js +++ b/lib/rfc3164.js @@ -16,7 +16,7 @@ function buildMessage (data, headerBytes) { } if (options.includeProperties.length > 0) { - options.includeProperties.map((p) => { message[p] = data[p] }) + options.includeProperties.forEach((p) => { message[p] = data[p] }) message = stringify(message) } else { message = stringify(data) @@ -44,7 +44,7 @@ module.exports = function ($options) { if (timestamp[4] === '0') { timestamp = timestamp.substr(0, 4) + ' ' + timestamp.substr(5) } - const hostname = data.hostname.split('.')[ 0 ] + const hostname = data.hostname.split('.')[0] const header = `<${pri}>${timestamp} ${hostname} ${options.appname}[${data.pid}]: ` const message = buildMessage(data, header.length) let output = (options.cee && !options.messageOnly) ? `${header}@cee: ${message}` : `${header}${message}` diff --git a/lib/rfc5424.js b/lib/rfc5424.js index 4ae86f3..81dc4a4 100644 --- a/lib/rfc5424.js +++ b/lib/rfc5424.js @@ -15,7 +15,7 @@ function buildMessage (data) { } if (options.includeProperties.length > 0) { - options.includeProperties.map((p) => { message[p] = data[p] }) + options.includeProperties.forEach((p) => { message[p] = data[p] }) message = stringify(message) } else { message = stringify(data) diff --git a/lib/utils.js b/lib/utils.js index 28cfe8d..223e692 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -29,12 +29,12 @@ function levelToSeverity (level) { case 50: // pino: error result = severity.error break - default: case 60: // pino: fatal + default: result = severity.critical break } return result } -module.exports = {severity, levelToSeverity} +module.exports = { severity, levelToSeverity } diff --git a/package.json b/package.json index fe70396..69055ae 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,9 @@ "homepage": "https://github.com/pinojs/pino-syslog", "main": "psyslog.js", "scripts": { - "test": "tap --no-cov 'test/**/*.test.js'", - "lint": "standard" + "test": "npm run lint && tap --no-cov 'test/**/*.test.js'", + "lint": "standard", + "lint:fix": "standard --fix" }, "bin": { "pino-syslog": "./app.js" @@ -29,7 +30,7 @@ "devDependencies": { "istanbul": "^0.4.5", "pre-commit": "^1.2.2", - "standard": "^10.0.2", + "standard": "^16.0.3", "tap": "^11.0.1" }, "dependencies": { diff --git a/psyslog.js b/psyslog.js index 4ce6aa6..ebaef05 100644 --- a/psyslog.js +++ b/psyslog.js @@ -52,7 +52,7 @@ if (args.config) { } } -const options = Object.assign({}, defaults, jsonOptions, args); +const options = Object.assign({}, defaults, jsonOptions, args) let myTransport if (options.modern) { diff --git a/test/3164.test.js b/test/3164.test.js index 86a554b..bc51e29 100644 --- a/test/3164.test.js +++ b/test/3164.test.js @@ -169,7 +169,7 @@ test('truncates overly long message only log', (t) => { test('appends newline', (t) => { t.plan(1) const expected = '<134>Apr 1 16:44:58 MacBook-Pro-3 none[94473]: ' + messages.helloWorld + '\n' - const psyslog = spawn('node', [ psyslogPath, '-c', configPath('3164', 'newline.json') ]) + const psyslog = spawn('node', [psyslogPath, '-c', configPath('3164', 'newline.json')]) psyslog.stdout.on('data', (data) => { const msg = data.toString() diff --git a/test/5424.test.js b/test/5424.test.js index f6ea5f0..410b009 100644 --- a/test/5424.test.js +++ b/test/5424.test.js @@ -127,7 +127,7 @@ test('does not prepend `@cee ` for non-json messages', (t) => { test('appends newline', (t) => { t.plan(1) const expected = '<134>1 2016-04-01T16:44:58Z MacBook-Pro-3 - 94473 - - ' + messages.helloWorld + '\n' - const psyslog = spawn('node', [ psyslogPath, '-c', configPath('5424', 'newline.json') ]) + const psyslog = spawn('node', [psyslogPath, '-c', configPath('5424', 'newline.json')]) psyslog.stdout.on('data', (data) => { const msg = data.toString() @@ -141,7 +141,7 @@ test('appends newline', (t) => { test('uses structured data', (t) => { t.plan(1) const expected = '<134>1 2016-04-01T16:44:58Z MacBook-Pro-3 - 94473 - [a@b x="y"] ' + messages.helloWorld - const psyslog = spawn('node', [ psyslogPath, '-c', configPath('5424', 'structuredData.json') ]) + const psyslog = spawn('node', [psyslogPath, '-c', configPath('5424', 'structuredData.json')]) psyslog.stdout.on('data', (data) => { const msg = data.toString() From d57377fd91ee6aa3bf689a94213d0a7ae5c1ed63 Mon Sep 17 00:00:00 2001 From: Manuel Spigolon Date: Tue, 21 Sep 2021 13:27:30 +0200 Subject: [PATCH 3/4] update tap --- package.json | 4 ++-- test/3164.test.js | 24 ++++++++++++------------ test/5424.test.js | 20 ++++++++++---------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/package.json b/package.json index 69055ae..e638c41 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "istanbul": "^0.4.5", "pre-commit": "^1.2.2", "standard": "^16.0.3", - "tap": "^11.0.1" + "tap": "^15.0.9" }, "dependencies": { "fast-json-parse": "^1.0.2", @@ -39,7 +39,7 @@ "moment-timezone": "^0.5.13", "nopt": "^4.0.1", "pump": "^2.0.1", - "split2": "^2.1.1", + "split2": "^3.2.2", "through2": "^2.0.3" } } diff --git a/test/3164.test.js b/test/3164.test.js index bc51e29..35da1fb 100644 --- a/test/3164.test.js +++ b/test/3164.test.js @@ -20,7 +20,7 @@ test('skips non-json input', (t) => { }) psyslog.on('close', (code) => { - t.is(code, 0) + t.equal(code, 0) }) psyslog.stdin.end('this is not json\n') @@ -33,7 +33,7 @@ test('returns error for overly long rfc3164 messages', (t) => { psyslog.stdout.on('data', (data) => { const msg = data.toString() - t.is(msg, expected) + t.equal(msg, expected) psyslog.kill() }) @@ -47,7 +47,7 @@ test('formats to message only', (t) => { psyslog.stdout.on('data', (data) => { const msg = data.toString() - t.is(msg, expected) + t.equal(msg, expected) psyslog.kill() }) @@ -61,7 +61,7 @@ test('sets application name', (t) => { psyslog.stdout.on('data', (data) => { const msg = data.toString() - t.is(msg, expected) + t.equal(msg, expected) psyslog.kill() }) @@ -75,7 +75,7 @@ test('sets facility', (t) => { psyslog.stdout.on('data', (data) => { const msg = data.toString() - t.is(msg, expected) + t.equal(msg, expected) psyslog.kill() }) @@ -89,7 +89,7 @@ test('format timestamp with leading zero in days', (t) => { psyslog.stdout.on('data', (data) => { const msg = data.toString() - t.is(msg, expected) + t.equal(msg, expected) psyslog.kill() }) @@ -103,7 +103,7 @@ test('format timestamp with trailing zero in days', (t) => { psyslog.stdout.on('data', (data) => { const msg = data.toString() - t.is(msg, expected) + t.equal(msg, expected) psyslog.kill() }) @@ -117,7 +117,7 @@ test('sets timezone', (t) => { psyslog.stdout.on('data', (data) => { const msg = data.toString() - t.is(msg, expected) + t.equal(msg, expected) psyslog.kill() }) @@ -131,7 +131,7 @@ test('prepends `@cee `', (t) => { psyslog.stdout.on('data', (data) => { const msg = data.toString() - t.is(msg, header + messages.helloWorld) + t.equal(msg, header + messages.helloWorld) psyslog.kill() }) @@ -145,7 +145,7 @@ test('does not prepend `@cee ` for non-json messages', (t) => { psyslog.stdout.on('data', (data) => { const msg = data.toString() - t.is(msg, expected) + t.equal(msg, expected) psyslog.kill() }) @@ -159,7 +159,7 @@ test('truncates overly long message only log', (t) => { psyslog.stdout.on('data', (data) => { const msg = data.toString() - t.is(msg, expected) + t.equal(msg, expected) psyslog.kill() }) @@ -173,7 +173,7 @@ test('appends newline', (t) => { psyslog.stdout.on('data', (data) => { const msg = data.toString() - t.is(msg, expected) + t.equal(msg, expected) psyslog.kill() }) diff --git a/test/5424.test.js b/test/5424.test.js index 410b009..3f707c8 100644 --- a/test/5424.test.js +++ b/test/5424.test.js @@ -20,7 +20,7 @@ test('skips non-json input', (t) => { }) psyslog.on('close', (code) => { - t.is(code, 0) + t.equal(code, 0) }) psyslog.stdin.end('this is not json\n') @@ -33,7 +33,7 @@ test('hello world', (t) => { psyslog.stdout.on('data', (data) => { const msg = data.toString() - t.is(msg, header + messages.helloWorld) + t.equal(msg, header + messages.helloWorld) psyslog.kill() }) @@ -47,7 +47,7 @@ test('formats to message only', (t) => { psyslog.stdout.on('data', (data) => { const msg = data.toString() - t.is(msg, expected) + t.equal(msg, expected) psyslog.kill() }) @@ -61,7 +61,7 @@ test('sets application name', (t) => { psyslog.stdout.on('data', (data) => { const msg = data.toString() - t.is(msg, expected) + t.equal(msg, expected) psyslog.kill() }) @@ -75,7 +75,7 @@ test('sets facility', (t) => { psyslog.stdout.on('data', (data) => { const msg = data.toString() - t.is(msg, expected) + t.equal(msg, expected) psyslog.kill() }) @@ -89,7 +89,7 @@ test('sets timezone', (t) => { psyslog.stdout.on('data', (data) => { const msg = data.toString() - t.is(msg, expected) + t.equal(msg, expected) psyslog.kill() }) @@ -103,7 +103,7 @@ test('prepends `@cee `', (t) => { psyslog.stdout.on('data', (data) => { const msg = data.toString() - t.is(msg, header + messages.helloWorld) + t.equal(msg, header + messages.helloWorld) psyslog.kill() }) @@ -117,7 +117,7 @@ test('does not prepend `@cee ` for non-json messages', (t) => { psyslog.stdout.on('data', (data) => { const msg = data.toString() - t.is(msg, expected) + t.equal(msg, expected) psyslog.kill() }) @@ -131,7 +131,7 @@ test('appends newline', (t) => { psyslog.stdout.on('data', (data) => { const msg = data.toString() - t.is(msg, expected) + t.equal(msg, expected) psyslog.kill() }) @@ -145,7 +145,7 @@ test('uses structured data', (t) => { psyslog.stdout.on('data', (data) => { const msg = data.toString() - t.is(msg, expected) + t.equal(msg, expected) psyslog.kill() }) From 6a1933fb6aa520c981a5b922e7bdaafbfc070c82 Mon Sep 17 00:00:00 2001 From: Manuel Spigolon Date: Tue, 21 Sep 2021 13:31:33 +0200 Subject: [PATCH 4/4] update dep --- .github/workflows/ci.yml | 2 +- package.json | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f175a26..7691246 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,7 @@ jobs: - name: Install run: npm i - name: Tests - run: npm run ci + run: npm test automerge: needs: test diff --git a/package.json b/package.json index e638c41..811b2f8 100644 --- a/package.json +++ b/package.json @@ -37,9 +37,9 @@ "fast-json-parse": "^1.0.2", "fast-safe-stringify": "^2.0.2", "moment-timezone": "^0.5.13", - "nopt": "^4.0.1", - "pump": "^2.0.1", + "nopt": "^5.0.0", + "pump": "^3.0.0", "split2": "^3.2.2", - "through2": "^2.0.3" + "through2": "^4.0.2" } }