From 55f0308b89f50ff8344b9f743540b6778a8b9300 Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Tue, 12 Dec 2023 14:50:50 -0800 Subject: [PATCH] packaging updates --- .github/workflows/ci.yml | 2 +- .github/workflows/publish.yml | 2 ++ .gitignore | 6 ++++ .gitmodules | 3 ++ .npmignore | 56 +++++++++++++++++++++++++++++++---- .release | 1 + Changes.md | 1 + index.js | 12 +++++--- package.json | 2 +- 9 files changed, 73 insertions(+), 12 deletions(-) create mode 100644 .gitmodules create mode 160000 .release diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6494d1d..94be697 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..d489fbd 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 diff --git a/.gitignore b/.gitignore index f8faa6b..625981f 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,9 @@ jspm_packages .node_repl_history package-lock.json +bower_components +# Optional npm cache directory +.npmrc +.idea +.DS_Store +haraka-update.sh \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..a8e94cb --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule ".release"] + path = .release + url = git@github.com:msimerson/.release.git diff --git a/.npmignore b/.npmignore index 22ce579..3e8e260 100644 --- a/.npmignore +++ b/.npmignore @@ -1,14 +1,58 @@ -.github +# Logs +logs +*.log +npm-debug.log* + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules +jspm_packages + +# Optional npm cache directory +.npm + +# Optional REPL history +.node_repl_history + +package-lock.json +bower_components +# Optional npm cache directory +.npmrc +.idea .DS_Store +haraka-update.sh + +.github +.release +.codeclimate.yml .editorconfig .gitignore .gitmodules .lgtm.yml -http/bower_components -http/node_modules -.travis.yml appveyor.yml +codecov.yml +.travis.yml .eslintrc.yaml .eslintrc.json -codecov.yml -.codeclimate.yml \ No newline at end of file diff --git a/.release b/.release new file mode 160000 index 0000000..0890e94 --- /dev/null +++ b/.release @@ -0,0 +1 @@ +Subproject commit 0890e945e4e061c96c7b2ab45017525904c17728 diff --git a/Changes.md b/Changes.md index 9543517..792851e 100644 --- a/Changes.md +++ b/Changes.md @@ -83,3 +83,4 @@ - don't break when no [redis] config exists +[2.0.6]: https://github.com/haraka/haraka-plugin-redis/releases/tag/2.0.6 diff --git a/index.js b/index.js index 316c525..25efa01 100644 --- a/index.js +++ b/index.js @@ -150,6 +150,7 @@ exports.redis_ping = async function () { const r = await this.db.ping() if (r !== 'PONG') throw new Error('not PONG'); this.redis_pings=true + return true } @@ -193,6 +194,7 @@ exports.get_redis_client = async function (opts) { } } + exports.get_redis_pub_channel = function (conn) { return `result-${conn.transaction ? conn.transaction.uuid : conn.uuid}`; } @@ -201,18 +203,20 @@ exports.get_redis_sub_channel = function (conn) { return `result-${conn.uuid}*`; } -exports.redis_subscribe_pattern = async function (pattern) { +// formerly used by pi-watch +exports.redis_subscribe_pattern = async function (pattern, onMessage) { if (this.redis) return // already subscribed? this.redis = redis.createClient(this.redisCfg.pubsub) await this.redis.connect() - await this.redis.pSubscribe(pattern); + await this.redis.pSubscribe(pattern, onMessage); this.logdebug(this, `pSubscribed to ${pattern}`); } -exports.redis_subscribe = async function (connection) { +// the next two functions are use by pi-karma +exports.redis_subscribe = async function (connection, onMessage) { if (connection.notes.redis) { connection.logdebug(this, `redis already subscribed`); @@ -229,7 +233,7 @@ exports.redis_subscribe = async function (connection) { clearTimeout(timer); const pattern = this.get_redis_sub_channel(connection) - connection.notes.redis.pSubscribe(pattern); + connection.notes.redis.pSubscribe(pattern, onMessage); connection.logdebug(this, `pSubscribed to ${pattern}`); } diff --git a/package.json b/package.json index 315012f..be2e86f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "haraka-plugin-redis", - "version": "2.0.5", + "version": "2.0.6", "description": "Redis plugin for Haraka & other plugins to inherit from", "main": "index.js", "directories": {