From 8765f9ffefde863d50ad197f766f6d3a52f7022c Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Tue, 12 Dec 2023 21:01:43 -0800 Subject: [PATCH] Release v1.0.14 (#33) * ci: run on PR * ci(publish): constrain to when package.json changes * style: remove useless variable * style(es6): eslint prefer-template --- .github/workflows/ci.yml | 2 +- .github/workflows/publish.yml | 4 ++- .release | 2 +- Changes.md | 8 +++++ index.js | 63 +++++++++++++++++------------------ package.json | 2 +- 6 files changed, 44 insertions(+), 37 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d768329..5360933 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,6 @@ name: CI -on: [ push ] +on: [ push, pull_request ] env: CI: true diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 42a9bb9..e81c15f 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -4,6 +4,8 @@ on: push: branches: - master + paths: + - package.json env: CI: true @@ -11,4 +13,4 @@ env: jobs: publish: uses: haraka/.github/.github/workflows/publish.yml@master - secrets: inherit \ No newline at end of file + secrets: inherit diff --git a/.release b/.release index 9be2b27..0890e94 160000 --- a/.release +++ b/.release @@ -1 +1 @@ -Subproject commit 9be2b270ef836bcfefda085674bf62e2a91defe8 +Subproject commit 0890e945e4e061c96c7b2ab45017525904c17728 diff --git a/Changes.md b/Changes.md index 8d46c26..5cb0ea9 100644 --- a/Changes.md +++ b/Changes.md @@ -1,6 +1,13 @@ ### Unreleased +### [1.0.14] - 2023-12-12 + +- style: remove useless variable +- ci(publish): constrain to when package.json changes +- ci: run on PR + + ### [1.0.13] - 2022-06-05 - doc(README): update CI badge URL @@ -80,3 +87,4 @@ [1.0.12]: https://github.com/haraka/haraka-plugin-log-reader/releases/tag/1.0.12 [1.0.13]: https://github.com/haraka/haraka-plugin-log-reader/releases/tag/1.0.13 +[1.0.14]: https://github.com/haraka/haraka-plugin-log-reader/releases/tag/1.0.14 diff --git a/index.js b/index.js index d19d85c..229359e 100644 --- a/index.js +++ b/index.js @@ -8,8 +8,8 @@ let plugin; exports.register = function () { plugin = this; - plugin.get_logreader_ini(); - plugin.load_karma_ini(); + this.get_logreader_ini(); + this.load_karma_ini(); } exports.hook_init_http = function (next, server) { @@ -19,7 +19,6 @@ exports.hook_init_http = function (next, server) { } exports.get_logreader_ini = function () { - plugin = this; plugin.cfg = plugin.config.get('log.reader.ini', function () { plugin.get_logreader_ini(); }) @@ -71,7 +70,7 @@ exports.get_logs = function (req, res) { // spawning a grep process is quite a lot faster than fs.read // (yes, I benchmarked it) exports.grepWithShell(log, uuid, function (err, matched) { - if (err) return res.send('

' + err + '

'); + if (err) return res.send(`

${err}

`); exports.asHtml(uuid, matched, function (html) { res.send(html); @@ -128,7 +127,7 @@ exports.asHtml = function (uuid, matched, done) { if (uuidMatch && uuidMatch[1]) { transId = uuidMatch[1].match(/\.([0-9]{1,2})$/); } - if (transId && transId[1]) replaceString = '[' + transId[1] + '] '; + if (transId && transId[1]) replaceString = `[${transId[1]}] `; let trimmed = line .replace(/\[[A-F0-9\-.]{12,40}\] /, replaceString) // UUID @@ -142,7 +141,7 @@ exports.asHtml = function (uuid, matched, done) { trimmed = trimmed.replace(/(?: [a-z.-]+)? haraka: /, ' '); } - rawLogs += trimmed + '
'; + rawLogs += `${trimmed}
`; if (/\[karma/.test(line) && /awards/.test(line)) { lastKarmaLine = line; } @@ -155,22 +154,22 @@ exports.asHtml = function (uuid, matched, done) { } done( - htmlHead() + + `${htmlHead() + htmlBody( `for connection ${uuid} on ${monthDay}`, getAwards(awardNums).join(''), getResolutions(awardNums).join('') ) + - rawLogs + '' + rawLogs}` ); } // exports.grepWithFs = function (file, regex, done) { -// var wantsRe = new RegExp(regex); -// var fsOpts = { flag: 'r', encoding: 'utf8' }; +// const wantsRe = new RegExp(regex); +// const fsOpts = { flag: 'r', encoding: 'utf8' }; // require('fs').readFile(log, fsOpts, function (err, data) { // if (err) throw (err); -// var res = ''; +// let res = ''; // data.toString().split(/\n/).forEach(function (line) { // if (wantsRe && !wantsRe.test(line)) return; // res += line + '\n'; @@ -191,13 +190,12 @@ function getAwards (awardNums) { const listItems = []; awards.sort(sortByAward).forEach(function (a) { - const start = '
  • ' + a.award + ', '; + const start = `
  • ${a.award}, `; if (a.reason) { - listItems.push(start + a.reason + ' (' + a.value + ')
  • '); + listItems.push(`${start + a.reason} (${a.value})`); return; } - listItems.push(start + a.pi_name + ' ' + a.property + - ' ' + a.value + ''); + listItems.push(`${start + a.pi_name} ${a.property} ${a.value}`); }); return listItems; } @@ -217,7 +215,7 @@ function getResolutions (awardNums) { if (!a.resolution) return; if (resolutionSeen[a.resolution]) return; resolutionSeen[a.resolution] = true; - listItems.push('
  • ' + a.resolution + '
  • '); + listItems.push(`
  • ${a.resolution}
  • `); }); return listItems; } @@ -229,16 +227,15 @@ function sortByAward (a, b) { } function htmlHead () { - const str = ' \ - \ - \ - \ - \ - \ - '; - return str; + return ' \ + \ + \ + \ + \ + \ + '; } function htmlBody (uuid, awards, resolve) { @@ -250,19 +247,19 @@ function htmlBody (uuid, awards, resolve) { your IT helpdesk or Systems Administrator and ask them for help.

    '; if (awards) { - str += '

    Policy Rules Matched

    \ - '; + str += `

    Policy Rules Matched

    \ + `; } if (resolve) { - str += '

    Steps to Resolve

    \ - '; + str += `

    Steps to Resolve

    \ + `; } - str += '
    \ + str += `
    \

    Raw Logs

    \ -

    ' + uuid + '

    \ +

    ${uuid}

    \
     \
    -        \n';
    +        \n`;
       return str;
     }
    diff --git a/package.json b/package.json
    index 9653f98..de40a3d 100644
    --- a/package.json
    +++ b/package.json
    @@ -1,6 +1,6 @@
     {
       "name": "haraka-plugin-log-reader",
    -  "version": "1.0.13",
    +  "version": "1.0.14",
       "description": "display log entries from haraka log files via HTTP",
       "main": "index.js",
       "scripts": {