From aa45913a27a63da17eb055edb55f4bd6249aa069 Mon Sep 17 00:00:00 2001 From: gnought <1684105+gnought@users.noreply.github.com> Date: Mon, 29 Jul 2019 14:15:45 +0800 Subject: [PATCH 1/8] Added collaborators --- README.md | 4 ++++ package.json | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/README.md b/README.md index 4f50be7..2fc02ac 100644 --- a/README.md +++ b/README.md @@ -281,6 +281,10 @@ abs({ }) ``` +## Collaborators + +* [__Gnought__](https://github.com/gnought) + ## License MIT diff --git a/package.json b/package.json index 630b133..6294872 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,12 @@ "aedes" ], "author": "Matteo Collina ", + "contributors": [ + { + "name": "Gnought", + "url": "https://github.com/gnought" + } + ], "license": "MIT", "bugs": { "url": "https://github.com/mcollina/aedes-persistence/issues" From fd3d195c18a6074de00eba97307063f6ba83ca17 Mon Sep 17 00:00:00 2001 From: gnought <1684105+gnought@users.noreply.github.com> Date: Thu, 18 Jul 2019 02:29:39 +0800 Subject: [PATCH 2/8] Add coverage & license check, format lint output --- package.json | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 6294872..f14ca6a 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,15 @@ "description": "The spec for an Aedes persistence, with abstract tests and a fast in-memory implementation.", "main": "persistence.js", "scripts": { - "test": "standard && tape test.js | faucet" + "lint": "standard --verbose | snazzy", + "test": "tape test.js | faucet", + "coverage": "nyc --reporter=lcov tape test.js", + "license-checker": "license-checker --production --onlyAllow='MIT;ISC;BSD-3-Clause;BSD-2-Clause'" }, - "pre-commit": "test", + "pre-commit": [ + "lint", + "test" + ], "repository": { "type": "git", "url": "git+https://github.com/mcollina/aedes-persistence.git" @@ -32,7 +38,9 @@ "devDependencies": { "concat-stream": "^2.0.0", "faucet": "0.0.1", + "license-checker": "^25.0.1", "mqemitter": "^3.0.0", + "nyc": "^14.1.1", "pre-commit": "^1.2.2", "pump": "^3.0.0", "standard": "^13.0.2", From 5b91ff9437894f6f38ca55ba04a8d49eb16e4e9f Mon Sep 17 00:00:00 2001 From: gnought <1684105+gnought@users.noreply.github.com> Date: Thu, 18 Jul 2019 02:29:50 +0800 Subject: [PATCH 3/8] Update .gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 123ae94..09c0cc1 100644 --- a/.gitignore +++ b/.gitignore @@ -10,8 +10,9 @@ pids # Directory for instrumented libs generated by jscoverage/JSCover lib-cov -# Coverage directory used by tools like istanbul +# Coverage directory used by tools like nyc coverage +.nyc_output # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) .grunt From 6d35e00ca3a67096e192838a6138ebe0e5d63888 Mon Sep 17 00:00:00 2001 From: gnought <1684105+gnought@users.noreply.github.com> Date: Thu, 18 Jul 2019 02:30:10 +0800 Subject: [PATCH 4/8] Added more badges --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2fc02ac..a024d0f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ -# aedes-persistence  [![Build Status](https://travis-ci.org/mcollina/aedes-persistence.svg)](https://travis-ci.org/mcollina/aedes-persistence) +# aedes-persistence +[![Build Status](https://travis-ci.org/mcollina/aedes-persistence.svg?branch=master)](https://travis-ci.org/mcollina/aedes-persistence) [![Known Vulnerabilities](https://snyk.io/test/github/mcollina/aedes-persistence/badge.svg)](https://snyk.io/test/github/mcollina/aedes-persistence) [![Coverage Status](https://coveralls.io/repos/mcollina/aedes-persistence/badge.svg?branch=master&service=github)](https://coveralls.io/github/mcollina/aedes-persistence?branch=master) [![NPM version](https://img.shields.io/npm/v/aedes-persistence.svg?style=flat)](https://www.npmjs.com/package/aedes-persistence) [![NPM downloads](https://img.shields.io/npm/dm/aedes-persistence.svg?style=flat)](https://www.npmjs.com/package/aedes-persistence) The spec for an [Aedes](http://npm.im/aedes) persistence, with abstract tests and a fast in-memory implementation. @@ -240,7 +241,7 @@ format: ### instance.getClientList(topic) -Returns a stream which has all the clientIds subscribed to the +Returns a stream which has all the clientIds subscribed to the specified topic From 02242f42bb9abd17ba4e80de258eeaa208671c3b Mon Sep 17 00:00:00 2001 From: gnought <1684105+gnought@users.noreply.github.com> Date: Thu, 18 Jul 2019 02:42:14 +0800 Subject: [PATCH 5/8] MessageId should be unassigned in queue outgoingEnqueue and outgoingEnqueueCombi functions should not store messageId. outgoingUpdate function will do. This PR requires https://github.com/mcollina/aedes-packet/pull/5 --- abstract.js | 42 +++++++++++++++++++++++++++++------------- persistence.js | 3 --- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/abstract.js b/abstract.js index 068d9e6..eed5739 100644 --- a/abstract.js +++ b/abstract.js @@ -770,8 +770,7 @@ function abstractPersistence (opts) { qos: 1, retain: false, brokerId: instance.broker.id, - brokerCounter: 42, - messageId: 1 + brokerCounter: 42 } instance.outgoingEnqueue(sub, packet, function (err) { @@ -779,7 +778,11 @@ function abstractPersistence (opts) { var stream = instance.outgoingStream(client) stream.pipe(concat(function (list) { - t.deepEqual(list, [expected], 'must return the packet') + var packet = list[0] + t.ok(Object.prototype.hasOwnProperty.call(packet, 'messageId')) + t.equal(packet.messageId, undefined, 'should have an unassigned messageId in queue') + delete packet.messageId + t.deepEqual(packet, expected, 'must return the packet') instance.destroy(t.end.bind(t)) })) }) @@ -821,19 +824,26 @@ function abstractPersistence (opts) { qos: 1, retain: false, brokerId: instance.broker.id, - brokerCounter: 42, - messageId: 1 + brokerCounter: 42 } instance.outgoingEnqueueCombi(subs, packet, function (err) { t.error(err) var stream = instance.outgoingStream(client) stream.pipe(concat(function (list) { - t.deepEqual(list, [expected], 'must return the packet') + var packet = list[0] + t.ok(Object.prototype.hasOwnProperty.call(packet, 'messageId')) + t.equal(packet.messageId, undefined, 'should have an unassigned messageId in queue') + delete packet.messageId + t.deepEqual(packet, expected, 'must return the packet') var stream2 = instance.outgoingStream(client2) stream2.pipe(concat(function (list) { - t.deepEqual(list, [expected], 'must return the packet') + var packet = list[0] + t.ok(Object.prototype.hasOwnProperty.call(packet, 'messageId')) + t.equal(packet.messageId, undefined, 'should have an unassigned messageId in queue') + delete packet.messageId + t.deepEqual(packet, expected, 'must return the packet') instance.destroy(t.end.bind(t)) })) })) @@ -916,8 +926,7 @@ function abstractPersistence (opts) { qos: 1, retain: false, brokerId: instance.broker.id, - brokerCounter: 42, - messageId: 1 + brokerCounter: 42 } instance.outgoingEnqueueCombi([sub], packet, function (err) { @@ -925,7 +934,11 @@ function abstractPersistence (opts) { var stream = instance.outgoingStream(client) stream.pipe(concat(function (list) { - t.deepEqual(list, [expected], 'must return the packet') + var packet = list[0] + t.ok(Object.prototype.hasOwnProperty.call(packet, 'messageId')) + t.equal(packet.messageId, undefined, 'should have an unassigned messageId in queue') + delete packet.messageId + t.deepEqual(packet, expected, 'must return the packet') instance.destroy(t.end.bind(t)) })) }) @@ -959,8 +972,7 @@ function abstractPersistence (opts) { qos: 1, retain: false, brokerId: instance.broker.id, - brokerCounter: 42, - messageId: 4242 + brokerCounter: 42 } instance.outgoingEnqueueCombi([sub], packet, function (err) { @@ -968,7 +980,11 @@ function abstractPersistence (opts) { var stream = instance.outgoingStream(client) stream.pipe(concat(function (list) { - t.deepEqual(list, [expected], 'must return the packet') + var packet = list[0] + t.ok(Object.prototype.hasOwnProperty.call(packet, 'messageId')) + t.equal(packet.messageId, undefined, 'should have an unassigned messageId in queue') + delete packet.messageId + t.deepEqual(packet, expected, 'must return the packet') var stream = instance.outgoingStream(client) diff --git a/persistence.js b/persistence.js index 805378a..b239691 100644 --- a/persistence.js +++ b/persistence.js @@ -185,9 +185,6 @@ function _outgoingEnqueue (sub, packet) { this._outgoing[id] = queue var p = new Packet(packet) - if (packet.messageId) { - p.messageId = packet.messageId - } queue[queue.length] = p } From 5b41d5cc3715bdab4c4653c12091336f633142e9 Mon Sep 17 00:00:00 2001 From: Gnought <1684105+gnought@users.noreply.github.com> Date: Mon, 29 Jul 2019 14:29:35 +0800 Subject: [PATCH 6/8] Update .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 09c0cc1..d54dbe9 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,5 @@ build/Release # Dependency directory # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git node_modules + +package-lock.json \ No newline at end of file From 303f9581ae33bb0027d3f2e5032863309497f173 Mon Sep 17 00:00:00 2001 From: Gnought <1684105+gnought@users.noreply.github.com> Date: Mon, 29 Jul 2019 14:33:01 +0800 Subject: [PATCH 7/8] Update dependencies --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f14ca6a..7b7377c 100644 --- a/package.json +++ b/package.json @@ -43,12 +43,13 @@ "nyc": "^14.1.1", "pre-commit": "^1.2.2", "pump": "^3.0.0", - "standard": "^13.0.2", + "snazzy": "^8.0.0", + "standard": "^13.1.0", "tape": "^4.11.0", "through2": "^3.0.1" }, "dependencies": { - "aedes-packet": "^2.0.0", + "aedes-packet": "^2.1.0", "from2": "^2.3.0", "qlobber": "^3.1.0" } From af4f20ae3c4b3c7cfabade3b27c0db269148b26c Mon Sep 17 00:00:00 2001 From: Gnought <1684105+gnought@users.noreply.github.com> Date: Mon, 29 Jul 2019 14:33:27 +0800 Subject: [PATCH 8/8] Add more badges in README.md --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a024d0f..0e6cc87 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,12 @@ # aedes-persistence -[![Build Status](https://travis-ci.org/mcollina/aedes-persistence.svg?branch=master)](https://travis-ci.org/mcollina/aedes-persistence) [![Known Vulnerabilities](https://snyk.io/test/github/mcollina/aedes-persistence/badge.svg)](https://snyk.io/test/github/mcollina/aedes-persistence) [![Coverage Status](https://coveralls.io/repos/mcollina/aedes-persistence/badge.svg?branch=master&service=github)](https://coveralls.io/github/mcollina/aedes-persistence?branch=master) [![NPM version](https://img.shields.io/npm/v/aedes-persistence.svg?style=flat)](https://www.npmjs.com/package/aedes-persistence) [![NPM downloads](https://img.shields.io/npm/dm/aedes-persistence.svg?style=flat)](https://www.npmjs.com/package/aedes-persistence) +[![Build Status](https://travis-ci.org/mcollina/aedes-persistence.svg?branch=master)](https://travis-ci.org/mcollina/aedes-persistence) +[![Dependencies Status](https://david-dm.org/mcollina/aedes-persistence/status.svg)](https://david-dm.org/mcollina/aedes-persistence) +[![devDependencies Status](https://david-dm.org/mcollina/aedes-persistence/dev-status.svg)](https://david-dm.org/mcollina/aedes-persistence?type=dev) +
+[![Known Vulnerabilities](https://snyk.io/test/github/mcollina/aedes-persistence/badge.svg)](https://snyk.io/test/github/mcollina/aedes-persistence) +[![Coverage Status](https://coveralls.io/repos/mcollina/aedes-persistence/badge.svg?branch=master&service=github)](https://coveralls.io/github/mcollina/aedes-persistence?branch=master) +[![NPM version](https://img.shields.io/npm/v/aedes-persistence.svg?style=flat)](https://www.npmjs.com/package/aedes-persistence) +[![NPM downloads](https://img.shields.io/npm/dm/aedes-persistence.svg?style=flat)](https://www.npmjs.com/package/aedes-persistence) The spec for an [Aedes](http://npm.im/aedes) persistence, with abstract tests and a fast in-memory implementation.