From 4b63eed22e208d555cafe3d65b97c03f340b09f5 Mon Sep 17 00:00:00 2001 From: cukebot Date: Sun, 30 May 2021 21:09:04 +0000 Subject: [PATCH] Release message-streams v2.1.0 --- fake-cucumber/javascript/package.json | 2 +- gherkin-streams/javascript/package.json | 2 +- gherkin-utils/javascript/package.json | 2 +- gherkin/javascript/package.json | 2 +- html-formatter/javascript/package.json | 2 +- json-to-messages/javascript/package.json | 2 +- message-streams/CHANGELOG.md | 11 ++++- message-streams/javascript/package.json | 4 +- .../javascript/src/NdjsonToMessageStream.ts | 15 ++++-- package-lock.json | 48 ++++++++++++------- react/javascript/package.json | 2 +- 11 files changed, 61 insertions(+), 31 deletions(-) diff --git a/fake-cucumber/javascript/package.json b/fake-cucumber/javascript/package.json index b2d8cc1a25..fb64ced0e2 100644 --- a/fake-cucumber/javascript/package.json +++ b/fake-cucumber/javascript/package.json @@ -46,7 +46,7 @@ "@cucumber/gherkin-streams": "^2.0.2", "@cucumber/gherkin-utils": "^5.1.0", "@cucumber/messages": "^16.0.1", - "@cucumber/message-streams": "^2.0.0", + "@cucumber/message-streams": "^2.1.0", "@cucumber/tag-expressions": "^3.0.1", "@types/stack-utils": "2.0.0", "commander": "7.2.0", diff --git a/gherkin-streams/javascript/package.json b/gherkin-streams/javascript/package.json index 56865a6708..c70bb71cb5 100644 --- a/gherkin-streams/javascript/package.json +++ b/gherkin-streams/javascript/package.json @@ -19,7 +19,7 @@ }, "dependencies": { "@cucumber/messages": "^16.0.1", - "@cucumber/message-streams": "^2.0.0", + "@cucumber/message-streams": "^2.1.0", "@cucumber/gherkin": "^19.0.3", "commander": "7.2.0", "source-map-support": "0.5.19" diff --git a/gherkin-utils/javascript/package.json b/gherkin-utils/javascript/package.json index f6c3fe7d2c..0dfd9867bb 100644 --- a/gherkin-utils/javascript/package.json +++ b/gherkin-utils/javascript/package.json @@ -24,7 +24,7 @@ "devDependencies": { "@cucumber/gherkin": "^19.0.3", "@cucumber/gherkin-streams": "^2.0.2", - "@cucumber/message-streams": "^2.0.0", + "@cucumber/message-streams": "^2.1.0", "@types/glob": "7.1.3", "@types/mocha": "8.2.2", "@types/node": "15.6.1", diff --git a/gherkin/javascript/package.json b/gherkin/javascript/package.json index 6fee1ae229..15920b71e5 100644 --- a/gherkin/javascript/package.json +++ b/gherkin/javascript/package.json @@ -32,7 +32,7 @@ }, "dependencies": { "@cucumber/messages": "^16.0.1", - "@cucumber/message-streams": "^2.0.0" + "@cucumber/message-streams": "^2.1.0" }, "directories": { "test": "test" diff --git a/html-formatter/javascript/package.json b/html-formatter/javascript/package.json index 63d52cc655..8ed313615c 100644 --- a/html-formatter/javascript/package.json +++ b/html-formatter/javascript/package.json @@ -26,7 +26,7 @@ "@babel/core": "7.14.3", "@cucumber/gherkin-streams": "^2.0.2", "@cucumber/gherkin-utils": "^5.1.0", - "@cucumber/message-streams": "^2.0.0", + "@cucumber/message-streams": "^2.1.0", "@cucumber/query": "^10.0.0", "@cucumber/react": "^16.1.0", "@types/mocha": "8.2.2", diff --git a/json-to-messages/javascript/package.json b/json-to-messages/javascript/package.json index 1d202bf9ea..c616449fbc 100644 --- a/json-to-messages/javascript/package.json +++ b/json-to-messages/javascript/package.json @@ -40,7 +40,7 @@ "@cucumber/gherkin-streams": "^2.0.2", "@cucumber/gherkin-utils": "^5.1.0", "@cucumber/messages": "^16.0.1", - "@cucumber/message-streams": "^2.0.0", + "@cucumber/message-streams": "^2.1.0", "commander": "7.2.0", "glob": "7.1.7", "source-map-support": "0.5.19" diff --git a/message-streams/CHANGELOG.md b/message-streams/CHANGELOG.md index a791f56221..063808f44f 100644 --- a/message-streams/CHANGELOG.md +++ b/message-streams/CHANGELOG.md @@ -17,6 +17,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed +## [2.1.0] - 2021-05-30 + +### Added + +* The `NdjsonToMessageStream` constructor accepts an optional function for parsing + a line, which may return null if a line is ignored. This can be used to improve performance + by ignoring certain lines. + ## [2.0.0] - 2021-05-17 ### Changed @@ -28,7 +36,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). * First release -[Unreleased]: https://github.com/cucumber/cucumber/compare/message-streams/v2.0.0...main +[Unreleased]: https://github.com/cucumber/cucumber/compare/message-streams/v2.1.0...main +[2.1.0]: https://github.com/cucumber/cucumber/releases/tag/message-streams/v2.0.0 [2.0.0]: https://github.com/cucumber/cucumber/releases/tag/message-streams/v1.0.0 [1.0.0]: https://github.com/cucumber/cucumber/releases/tag/message-streams/v1.0.0 diff --git a/message-streams/javascript/package.json b/message-streams/javascript/package.json index df519ed05a..f7f710f36d 100644 --- a/message-streams/javascript/package.json +++ b/message-streams/javascript/package.json @@ -1,6 +1,6 @@ { "name": "@cucumber/message-streams", - "version": "2.0.0", + "version": "2.1.0", "description": "Streams for reading/writing messages", "main": "dist/src/index.js", "types": "dist/src/index.d.ts", @@ -19,7 +19,7 @@ }, "devDependencies": { "@types/mocha": "8.2.2", - "@types/node": "15.3.1", + "@types/node": "15.6.1", "mocha": "8.4.0", "typescript": "4.3.2" }, diff --git a/message-streams/javascript/src/NdjsonToMessageStream.ts b/message-streams/javascript/src/NdjsonToMessageStream.ts index a6d9469e3d..04db78c56a 100644 --- a/message-streams/javascript/src/NdjsonToMessageStream.ts +++ b/message-streams/javascript/src/NdjsonToMessageStream.ts @@ -1,5 +1,5 @@ import { Transform, TransformCallback } from 'stream' -import { parseEnvelope } from '@cucumber/messages' +import { Envelope, parseEnvelope } from '@cucumber/messages' /** * Transforms an NDJSON stream to a stream of message objects @@ -7,7 +7,12 @@ import { parseEnvelope } from '@cucumber/messages' export default class NdjsonToMessageStream extends Transform { private buffer: string - constructor() { + /** + * Create a new stream + * + * @param parseLine a function that parses a line. This function may ignore a line by returning null. + */ + constructor(private readonly parseLine: (line: string) => Envelope | null = parseEnvelope) { super({ writableObjectMode: false, readableObjectMode: true }) } @@ -21,8 +26,10 @@ export default class NdjsonToMessageStream extends Transform { for (const line of lines) { if (line.trim().length > 0) { try { - const envelope = parseEnvelope(line) - this.push(envelope) + const envelope = this.parseLine(line) + if (envelope !== null) { + this.push(envelope) + } } catch (err) { err.message = err.message + diff --git a/package-lock.json b/package-lock.json index a29a241456..0c98dbc881 100644 --- a/package-lock.json +++ b/package-lock.json @@ -117,7 +117,7 @@ "@cucumber/gherkin": "^19.0.3", "@cucumber/gherkin-streams": "^2.0.2", "@cucumber/gherkin-utils": "^5.1.0", - "@cucumber/message-streams": "^2.0.0", + "@cucumber/message-streams": "^2.1.0", "@cucumber/messages": "^16.0.1", "@cucumber/tag-expressions": "^3.0.1", "@types/stack-utils": "2.0.0", @@ -154,7 +154,7 @@ "license": "MIT", "dependencies": { "@cucumber/gherkin": "^19.0.3", - "@cucumber/message-streams": "^2.0.0", + "@cucumber/message-streams": "^2.1.0", "@cucumber/messages": "^16.0.1", "commander": "7.2.0", "source-map-support": "0.5.19" @@ -189,7 +189,7 @@ "devDependencies": { "@cucumber/gherkin": "^19.0.3", "@cucumber/gherkin-streams": "^2.0.2", - "@cucumber/message-streams": "^2.0.0", + "@cucumber/message-streams": "^2.1.0", "@types/glob": "7.1.3", "@types/mocha": "8.2.2", "@types/node": "15.6.1", @@ -210,7 +210,7 @@ "version": "19.0.3", "license": "MIT", "dependencies": { - "@cucumber/message-streams": "^2.0.0", + "@cucumber/message-streams": "^2.1.0", "@cucumber/messages": "^16.0.1" }, "devDependencies": { @@ -244,7 +244,7 @@ "@babel/core": "7.14.3", "@cucumber/gherkin-streams": "^2.0.2", "@cucumber/gherkin-utils": "^5.1.0", - "@cucumber/message-streams": "^2.0.0", + "@cucumber/message-streams": "^2.1.0", "@cucumber/query": "^10.0.0", "@cucumber/react": "^16.1.0", "@types/mocha": "8.2.2", @@ -300,7 +300,7 @@ "@cucumber/gherkin": "^19.0.3", "@cucumber/gherkin-streams": "^2.0.2", "@cucumber/gherkin-utils": "^5.1.0", - "@cucumber/message-streams": "^2.0.0", + "@cucumber/message-streams": "^2.1.0", "@cucumber/messages": "^16.0.1", "commander": "7.2.0", "glob": "7.1.7", @@ -336,18 +336,24 @@ }, "message-streams/javascript": { "name": "@cucumber/message-streams", - "version": "2.0.0", + "version": "2.1.0", "license": "MIT", "dependencies": { "@cucumber/messages": "^16.0.1" }, "devDependencies": { "@types/mocha": "8.2.2", - "@types/node": "15.3.1", + "@types/node": "15.6.1", "mocha": "8.4.0", "typescript": "4.3.2" } }, + "message-streams/javascript/node_modules/@types/node": { + "version": "15.6.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-15.6.1.tgz", + "integrity": "sha512-7EIraBEyRHEe7CH+Fm1XvgqU6uwZN8Q7jppJGcqjROMT29qhAuuOxYB1uEY5UMYQKEmA5D+5tBnhdaPXSsLONA==", + "dev": true + }, "messages/javascript": { "name": "@cucumber/messages", "version": "16.0.1", @@ -27340,7 +27346,7 @@ "@cucumber/fake-cucumber": "^12.0.2", "@cucumber/gherkin": "^19.0.3", "@cucumber/gherkin-streams": "^2.0.2", - "@cucumber/message-streams": "^2.0.0", + "@cucumber/message-streams": "^2.1.0", "@storybook/addon-actions": "6.2.9", "@storybook/addon-links": "6.2.9", "@storybook/builder-webpack5": "6.2.9", @@ -28882,7 +28888,7 @@ "@cucumber/gherkin": "^19.0.3", "@cucumber/gherkin-streams": "^2.0.2", "@cucumber/gherkin-utils": "^5.1.0", - "@cucumber/message-streams": "^2.0.0", + "@cucumber/message-streams": "^2.1.0", "@cucumber/messages": "^16.0.1", "@cucumber/tag-expressions": "^3.0.1", "@types/glob": "7.1.3", @@ -28910,7 +28916,7 @@ "@cucumber/gherkin": { "version": "file:gherkin/javascript", "requires": { - "@cucumber/message-streams": "^2.0.0", + "@cucumber/message-streams": "^2.1.0", "@cucumber/messages": "^16.0.1", "@types/mocha": "8.2.2", "@types/node": "15.6.0", @@ -28932,7 +28938,7 @@ "version": "file:gherkin-streams/javascript", "requires": { "@cucumber/gherkin": "^19.0.3", - "@cucumber/message-streams": "^2.0.0", + "@cucumber/message-streams": "^2.1.0", "@cucumber/messages": "^16.0.1", "@types/mocha": "8.2.2", "@types/node": "15.3.1", @@ -28955,7 +28961,7 @@ "requires": { "@cucumber/gherkin": "^19.0.3", "@cucumber/gherkin-streams": "^2.0.2", - "@cucumber/message-streams": "^2.0.0", + "@cucumber/message-streams": "^2.1.0", "@cucumber/messages": "^16.0.1", "@teppeis/multimaps": "2.0.0", "@types/glob": "7.1.3", @@ -28981,7 +28987,7 @@ "@babel/core": "7.14.3", "@cucumber/gherkin-streams": "^2.0.2", "@cucumber/gherkin-utils": "^5.1.0", - "@cucumber/message-streams": "^2.0.0", + "@cucumber/message-streams": "^2.1.0", "@cucumber/messages": "^16.0.1", "@cucumber/query": "^10.0.0", "@cucumber/react": "^16.1.0", @@ -29035,7 +29041,7 @@ "@cucumber/gherkin": "^19.0.3", "@cucumber/gherkin-streams": "^2.0.2", "@cucumber/gherkin-utils": "^5.1.0", - "@cucumber/message-streams": "^2.0.0", + "@cucumber/message-streams": "^2.1.0", "@cucumber/messages": "^16.0.1", "@types/glob": "7.1.3", "@types/mocha": "8.2.2", @@ -29061,9 +29067,17 @@ "requires": { "@cucumber/messages": "^16.0.1", "@types/mocha": "8.2.2", - "@types/node": "15.3.1", + "@types/node": "15.6.1", "mocha": "8.4.0", "typescript": "4.3.2" + }, + "dependencies": { + "@types/node": { + "version": "15.6.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-15.6.1.tgz", + "integrity": "sha512-7EIraBEyRHEe7CH+Fm1XvgqU6uwZN8Q7jppJGcqjROMT29qhAuuOxYB1uEY5UMYQKEmA5D+5tBnhdaPXSsLONA==", + "dev": true + } } }, "@cucumber/messages": { @@ -29118,7 +29132,7 @@ "@cucumber/gherkin": "^19.0.3", "@cucumber/gherkin-streams": "^2.0.2", "@cucumber/gherkin-utils": "^5.1.0", - "@cucumber/message-streams": "^2.0.0", + "@cucumber/message-streams": "^2.1.0", "@cucumber/messages": "^16.0.1", "@cucumber/query": "^10.0.0", "@cucumber/tag-expressions": "^3.0.1", diff --git a/react/javascript/package.json b/react/javascript/package.json index b27dc7ff94..e35b9c4a2a 100644 --- a/react/javascript/package.json +++ b/react/javascript/package.json @@ -46,7 +46,7 @@ "@cucumber/fake-cucumber": "^12.0.2", "@cucumber/gherkin": "^19.0.3", "@cucumber/gherkin-streams": "^2.0.2", - "@cucumber/message-streams": "^2.0.0", + "@cucumber/message-streams": "^2.1.0", "@storybook/addon-actions": "6.2.9", "@storybook/addon-links": "6.2.9", "@storybook/builder-webpack5": "6.2.9",