Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cucumber/gherkin-utils

Package Overview
Dependencies
Maintainers
2
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cucumber/gherkin-utils - npm Package Compare versions

Comparing version 8.0.5 to 8.0.6

46

dist/package.json
{
"name": "@cucumber/gherkin-utils",
"version": "8.0.5",
"version": "8.0.6",
"description": "Various Gherkin utilities",

@@ -31,34 +31,34 @@ "main": "dist/src/index.js",

"devDependencies": {
"@cucumber/compatibility-kit": "^11.0.0",
"@cucumber/compatibility-kit": "^15.0.0",
"@cucumber/gherkin-streams": "^5.0.1",
"@cucumber/message-streams": "^4.0.1",
"@types/mocha": "10.0.1",
"@types/node": "18.16.16",
"@typescript-eslint/eslint-plugin": "5.59.8",
"@typescript-eslint/parser": "5.59.8",
"@types/mocha": "10.0.6",
"@types/node": "20.11.20",
"@typescript-eslint/eslint-plugin": "6.21.0",
"@typescript-eslint/parser": "6.21.0",
"ajv": "8.12.0",
"ajv-cli": "5.0.0",
"eslint": "8.41.0",
"eslint-config-prettier": "8.8.0",
"eslint-plugin-import": "2.27.5",
"eslint": "8.56.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-prettier": "4.2.1",
"eslint-plugin-react": "7.32.2",
"eslint-plugin-prettier": "5.1.3",
"eslint-plugin-react": "7.33.2",
"eslint-plugin-react-hooks": "4.6.0",
"eslint-plugin-simple-import-sort": "10.0.0",
"fast-glob": "3.2.12",
"mocha": "10.2.0",
"npm-check-updates": "16.10.12",
"prettier": "2.8.8",
"pretty-quick": "3.1.3",
"rimraf": "^4.0.0",
"ts-node": "10.9.1",
"eslint-plugin-simple-import-sort": "12.0.0",
"fast-glob": "3.3.2",
"mocha": "10.3.0",
"npm-check-updates": "16.14.15",
"prettier": "3.2.5",
"pretty-quick": "4.0.0",
"rimraf": "^5.0.0",
"ts-node": "10.9.2",
"tsconfig-paths": "4.2.0",
"typescript": "5.1.3"
"typescript": "5.3.3"
},
"dependencies": {
"@cucumber/gherkin": "^26.0.0",
"@cucumber/messages": "^22.0.0",
"@cucumber/gherkin": "^27.0.0",
"@cucumber/messages": "^24.0.0",
"@teppeis/multimaps": "3.0.0",
"commander": "10.0.1",
"commander": "11.1.0",
"source-map-support": "^0.5.21"

@@ -65,0 +65,0 @@ },

@@ -142,4 +142,4 @@ "use strict";

this.handlers.handleRule(rule);
const backgroundKept = children.find((child) => child !== null && child.background !== null);
const scenariosKept = children.filter((child) => child !== null && child.scenario !== null);
const backgroundKept = children.find((child) => child === null || child === void 0 ? void 0 : child.background);
const scenariosKept = children.filter((child) => child === null || child === void 0 ? void 0 : child.scenario);
if (this.filters.acceptRule(rule) || backgroundKept) {

@@ -146,0 +146,0 @@ return this.copyRule(rule, rule.children);

@@ -73,2 +73,5 @@ "use strict";

}
function semiColumnName(name) {
return name == null || name.length == 0 ? ':' : ': ' + name;
}
function prettyKeywordContainer(stepContainer, syntax, level) {

@@ -83,4 +86,3 @@ const tags = 'tags' in stepContainer ? stepContainer.tags : [];

.concat(stepContainer.keyword)
.concat(': ')
.concat(stepContainer.name)
.concat(semiColumnName(stepContainer.name))
.concat('\n')

@@ -150,3 +152,3 @@ .concat(description)

tableRow.cells.forEach((tableCell, j) => {
maxWidths[j] = Math.max(maxWidths[j], escapeCell(tableCell.value).length);
maxWidths[j] = Math.max(maxWidths[j], getStringWidth(escapeCell(tableCell.value)));
});

@@ -178,3 +180,3 @@ });

const escapedCellValue = escapeCell(cell.value);
const spaceCount = maxWidths[j] - escapedCellValue.length;
const spaceCount = maxWidths[j] - getStringWidth(escapedCellValue);
const spaces = new Array(spaceCount + 1).join(' ');

@@ -185,2 +187,13 @@ return isNumeric(escapedCellValue) ? spaces + escapedCellValue : escapedCellValue + spaces;

}
function getStringWidth(str) {
let width = 0;
for (const character of str) {
width += isCJKorFullWidth(character) ? 2 : 1;
}
return width;
}
function isCJKorFullWidth(character) {
const pattern = /[\u3000-\u9fff\uac00-\ud7af\uff01-\uff60]/;
return pattern.test(character);
}
function escapeCell(s) {

@@ -187,0 +200,0 @@ let e = '';

@@ -43,2 +43,3 @@ "use strict";

}
acc = walkComments(popRemainingContents(), acc);
return acc;

@@ -106,2 +107,5 @@ function walkComments(comments, acc) {

}
function popRemainingContents() {
return commentsStack.splice(0, commentsStack.length);
}
}

@@ -108,0 +112,0 @@ exports.walkGherkinDocument = walkGherkinDocument;

@@ -142,4 +142,3 @@ "use strict";

});
// TODO before merging https://github.com/cucumber/cucumber/pull/1419
xit('keeps a hit background', () => {
it('keeps a hit background', () => {
const gherkinDocument = (0, parse_1.default)(`Feature: Solar System

@@ -209,4 +208,3 @@

});
// TODO before merging https://github.com/cucumber/cucumber/pull/1419
xit('keeps scenario in rule', () => {
it('keeps scenario in rule', () => {
const gherkinDocument = (0, parse_1.default)(`Feature: Solar System

@@ -213,0 +211,0 @@

@@ -21,7 +21,9 @@ "use strict";

const fast_glob_1 = __importDefault(require("fast-glob"));
const path_1 = require("fast-glob/out/utils/path");
const util_1 = require("util");
const asyncPipeline = (0, util_1.promisify)(stream_1.pipeline);
describe('Walking with messages', () => {
const localMessageFiles = fast_glob_1.default.sync(`${__dirname}/messages/**/*.ndjson`);
const tckMessageFiles = fast_glob_1.default.sync(`${__dirname}/../node_modules/@cucumber/compatibility-kit/features/**/*.ndjson`);
const currentDir = (0, path_1.convertWindowsPathToPattern)(__dirname);
const localMessageFiles = fast_glob_1.default.sync(`${currentDir}/messages/**/*.ndjson`);
const tckMessageFiles = fast_glob_1.default.sync(`${currentDir}/../node_modules/@cucumber/compatibility-kit/features/**/*.ndjson`);
const messageFiles = [].concat(localMessageFiles, tckMessageFiles);

@@ -28,0 +30,0 @@ it('must have some messages for comparison', () => {

@@ -135,2 +135,13 @@ "use strict";

});
it('renders tables with cjk characters', () => {
checkGherkinToAstToMarkdownToAstToGherkin(`Feature: hello
Scenario: one
Given a data table:
| 路 | numbers |
| 路 | 1 |
| 路步 | 10 |
| 路步路 | 100 |
`);
});
describe('DocString', () => {

@@ -205,2 +216,19 @@ it('is rendered with type', () => {

});
it('renders trailing comments', () => {
checkGherkinToAstToGherkin(`# one
Feature: hello
Scenario: one
# one
Given a doc string:
"""
a
\\"\\"\\"
b
"""
# two
# three
# four
`);
});
it('renders descriptions when set', () => {

@@ -224,2 +252,13 @@ checkGherkinToAstToGherkin(`Feature: hello

});
it('renders titles without trailing whitespace', () => {
checkGherkinToAstToGherkin(`Feature:
Rule:
Background:
Scenario Outlines:
Examples:
`);
});
const featureFiles = fast_glob_1.default.sync(`${__dirname}/../../testdata/good/*.feature`);

@@ -226,0 +265,0 @@ for (const featureFile of featureFiles) {

{
"name": "@cucumber/gherkin-utils",
"version": "8.0.5",
"version": "8.0.6",
"description": "Various Gherkin utilities",

@@ -31,34 +31,34 @@ "main": "dist/src/index.js",

"devDependencies": {
"@cucumber/compatibility-kit": "^11.0.0",
"@cucumber/compatibility-kit": "^15.0.0",
"@cucumber/gherkin-streams": "^5.0.1",
"@cucumber/message-streams": "^4.0.1",
"@types/mocha": "10.0.1",
"@types/node": "18.16.16",
"@typescript-eslint/eslint-plugin": "5.59.8",
"@typescript-eslint/parser": "5.59.8",
"@types/mocha": "10.0.6",
"@types/node": "20.11.20",
"@typescript-eslint/eslint-plugin": "6.21.0",
"@typescript-eslint/parser": "6.21.0",
"ajv": "8.12.0",
"ajv-cli": "5.0.0",
"eslint": "8.41.0",
"eslint-config-prettier": "8.8.0",
"eslint-plugin-import": "2.27.5",
"eslint": "8.56.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-prettier": "4.2.1",
"eslint-plugin-react": "7.32.2",
"eslint-plugin-prettier": "5.1.3",
"eslint-plugin-react": "7.33.2",
"eslint-plugin-react-hooks": "4.6.0",
"eslint-plugin-simple-import-sort": "10.0.0",
"fast-glob": "3.2.12",
"mocha": "10.2.0",
"npm-check-updates": "16.10.12",
"prettier": "2.8.8",
"pretty-quick": "3.1.3",
"rimraf": "^4.0.0",
"ts-node": "10.9.1",
"eslint-plugin-simple-import-sort": "12.0.0",
"fast-glob": "3.3.2",
"mocha": "10.3.0",
"npm-check-updates": "16.14.15",
"prettier": "3.2.5",
"pretty-quick": "4.0.0",
"rimraf": "^5.0.0",
"ts-node": "10.9.2",
"tsconfig-paths": "4.2.0",
"typescript": "5.1.3"
"typescript": "5.3.3"
},
"dependencies": {
"@cucumber/gherkin": "^26.0.0",
"@cucumber/messages": "^22.0.0",
"@cucumber/gherkin": "^27.0.0",
"@cucumber/messages": "^24.0.0",
"@teppeis/multimaps": "3.0.0",
"commander": "10.0.1",
"commander": "11.1.0",
"source-map-support": "^0.5.21"

@@ -65,0 +65,0 @@ },

@@ -204,4 +204,4 @@ // This file is DEPRECATED - use ./walkGherkinDocument instead

const backgroundKept = children.find((child) => child !== null && child.background !== null)
const scenariosKept = children.filter((child) => child !== null && child.scenario !== null)
const backgroundKept = children.find((child) => child?.background)
const scenariosKept = children.filter((child) => child?.scenario)

@@ -208,0 +208,0 @@ if (this.filters.acceptRule(rule) || backgroundKept) {

@@ -77,2 +77,6 @@ import * as messages from '@cucumber/messages'

function semiColumnName(name: string | null): string {
return name == null || name.length == 0 ? ':' : ': ' + name
}
function prettyKeywordContainer(

@@ -97,4 +101,3 @@ stepContainer:

.concat(stepContainer.keyword)
.concat(': ')
.concat(stepContainer.name)
.concat(semiColumnName(stepContainer.name))
.concat('\n')

@@ -170,3 +173,3 @@ .concat(description)

tableRow.cells.forEach((tableCell, j) => {
maxWidths[j] = Math.max(maxWidths[j], escapeCell(tableCell.value).length)
maxWidths[j] = Math.max(maxWidths[j], getStringWidth(escapeCell(tableCell.value)))
})

@@ -205,3 +208,3 @@ })

const escapedCellValue = escapeCell(cell.value)
const spaceCount = maxWidths[j] - escapedCellValue.length
const spaceCount = maxWidths[j] - getStringWidth(escapedCellValue)
const spaces = new Array(spaceCount + 1).join(' ')

@@ -213,2 +216,15 @@ return isNumeric(escapedCellValue) ? spaces + escapedCellValue : escapedCellValue + spaces

function getStringWidth(str: string): number {
let width = 0
for (const character of str) {
width += isCJKorFullWidth(character) ? 2 : 1
}
return width
}
function isCJKorFullWidth(character: string): boolean {
const pattern = /[\u3000-\u9fff\uac00-\ud7af\uff01-\uff60]/
return pattern.test(character)
}
export function escapeCell(s: string) {

@@ -215,0 +231,0 @@ let e = ''

@@ -44,2 +44,3 @@ import * as messages from '@cucumber/messages'

}
acc = walkComments(popRemainingContents(), acc);
return acc

@@ -118,2 +119,6 @@

}
function popRemainingContents(): readonly messages.Comment[] {
return commentsStack.splice(0, commentsStack.length)
}
}

@@ -120,0 +125,0 @@

@@ -158,4 +158,3 @@ import assert from 'assert'

// TODO before merging https://github.com/cucumber/cucumber/pull/1419
xit('keeps a hit background', () => {
it('keeps a hit background', () => {
const gherkinDocument = parse(`Feature: Solar System

@@ -235,4 +234,3 @@

// TODO before merging https://github.com/cucumber/cucumber/pull/1419
xit('keeps scenario in rule', () => {
it('keeps scenario in rule', () => {
const gherkinDocument = parse(`Feature: Solar System

@@ -239,0 +237,0 @@

@@ -9,2 +9,3 @@ import assert from 'assert'

import fg from 'fast-glob'
import { convertWindowsPathToPattern } from 'fast-glob/out/utils/path'
import { promisify } from 'util'

@@ -15,5 +16,6 @@

describe('Walking with messages', () => {
const localMessageFiles = fg.sync(`${__dirname}/messages/**/*.ndjson`)
const currentDir = convertWindowsPathToPattern(__dirname)
const localMessageFiles = fg.sync(`${currentDir}/messages/**/*.ndjson`)
const tckMessageFiles = fg.sync(
`${__dirname}/../node_modules/@cucumber/compatibility-kit/features/**/*.ndjson`
`${currentDir}/../node_modules/@cucumber/compatibility-kit/features/**/*.ndjson`
)

@@ -20,0 +22,0 @@ const messageFiles = [].concat(localMessageFiles, tckMessageFiles)

@@ -119,2 +119,14 @@ import assert from 'assert'

it('renders tables with cjk characters', () => {
checkGherkinToAstToMarkdownToAstToGherkin(`Feature: hello
Scenario: one
Given a data table:
| 路 | numbers |
| 路 | 1 |
| 路步 | 10 |
| 路步路 | 100 |
`)
})
describe('DocString', () => {

@@ -194,2 +206,20 @@ it('is rendered with type', () => {

it('renders trailing comments', () => {
checkGherkinToAstToGherkin(`# one
Feature: hello
Scenario: one
# one
Given a doc string:
"""
a
\\"\\"\\"
b
"""
# two
# three
# four
`)
});
it('renders descriptions when set', () => {

@@ -214,2 +244,15 @@ checkGherkinToAstToGherkin(`Feature: hello

it('renders titles without trailing whitespace', () => {
checkGherkinToAstToGherkin(`Feature:
Rule:
Background:
Scenario Outlines:
Examples:
`)
})
const featureFiles = fg.sync(`${__dirname}/../../testdata/good/*.feature`)

@@ -216,0 +259,0 @@ for (const featureFile of featureFiles) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc