Socket
Socket
Sign inDemoInstall

@cucumber/cucumber

Package Overview
Dependencies
Maintainers
2
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cucumber/cucumber - npm Package Compare versions

Comparing version 7.1.0 to 7.2.0

lib/importers.js

1

lib/cli/argv_parser.d.ts

@@ -15,2 +15,3 @@ import { SnippetInterface } from '../formatter/step_definition_snippet_builder/snippet_syntax';

dryRun: boolean;
esm: boolean;
exit: boolean;

@@ -17,0 +18,0 @@ failFast: boolean;

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

.option('-d, --dry-run', 'invoke formatters without executing steps', false)
.option('--esm', 'import support code via ES module imports', false)
.option('--exit', 'force shutdown of the event loop when the test run has finished: cucumber will call process.exit', false)

@@ -64,0 +65,0 @@ .option('--fail-fast', 'abort the run on first failure', false)

@@ -9,2 +9,3 @@ import { IParsedArgvFormatOptions } from './argv_parser';

export interface IConfiguration {
esm: boolean;
featureDefaultLanguage: string;

@@ -11,0 +12,0 @@ featurePaths: string[];

3

lib/cli/configuration_builder.js

@@ -40,5 +40,6 @@ "use strict";

}
supportCodePaths = await this.expandPaths(unexpandedSupportCodePaths, '.js');
supportCodePaths = await this.expandPaths(unexpandedSupportCodePaths, this.options.esm ? '.@(js|mjs)' : '.js');
}
return {
esm: this.options.esm,
featureDefaultLanguage: this.options.language,

@@ -45,0 +46,0 @@ featurePaths,

@@ -17,7 +17,10 @@ "use strict";

const support_code_library_builder_1 = require("../support_code_library_builder");
// eslint-disable-next-line @typescript-eslint/no-var-requires
const importers = require('../importers');
const StepDefinitionPatternType = messages_1.messages.StepDefinition.StepDefinitionPattern.StepDefinitionPatternType;
async function getExpandedArgv({ argv, cwd, }) {
const { options } = argv_parser_1.default.parse(argv);
const importer = options.esm ? importers.esm : importers.legacy;
let fullArgv = argv;
const profileArgv = await new profile_loader_1.default(cwd).getArgv(options.profile);
const profileArgv = await new profile_loader_1.default(cwd, importer).getArgv(options.profile);
if (profileArgv.length > 0) {

@@ -24,0 +27,0 @@ fullArgv = lodash_1.default.concat(argv.slice(0, 2), profileArgv, argv.slice(2));

@@ -25,2 +25,3 @@ /// <reference types="node" />

}
export declare type IUserCodeImporter = (path: string, isFilePath?: boolean) => Promise<any>;
export default class Cli {

@@ -30,2 +31,3 @@ private readonly argv;

private readonly stdout;
private importer;
constructor({ argv, cwd, stdout, }: {

@@ -38,5 +40,5 @@ argv: string[];

initializeFormatters({ eventBroadcaster, eventDataCollector, formatOptions, formats, supportCodeLibrary, }: IInitializeFormattersRequest): Promise<() => Promise<void>>;
getSupportCodeLibrary({ newId, supportCodeRequiredModules, supportCodePaths, }: IGetSupportCodeLibraryRequest): ISupportCodeLibrary;
getSupportCodeLibrary({ newId, supportCodeRequiredModules, supportCodePaths, }: IGetSupportCodeLibraryRequest): Promise<ISupportCodeLibrary>;
run(): Promise<ICliRunResult>;
}
export {};

@@ -44,5 +44,8 @@ "use strict";

const stream_1 = require("stream");
// eslint-disable-next-line @typescript-eslint/no-var-requires
const importers = require('../importers');
const { incrementing, uuid } = messages_1.IdGenerator;
class Cli {
constructor({ argv, cwd, stdout, }) {
this.importer = importers.legacy;
this.argv = argv;

@@ -96,2 +99,3 @@ this.cwd = cwd;

parsedArgvOptions: formatOptions,
importer: this.importer,
stream,

@@ -111,3 +115,3 @@ cleanup: stream === this.stdout

}
return builder_1.default.build(type, typeOptions);
return await builder_1.default.build(type, typeOptions);
});

@@ -120,6 +124,10 @@ return async function () {

}
getSupportCodeLibrary({ newId, supportCodeRequiredModules, supportCodePaths, }) {
supportCodeRequiredModules.map((module) => require(module));
async getSupportCodeLibrary({ newId, supportCodeRequiredModules, supportCodePaths, }) {
for (const requiredModule of supportCodeRequiredModules) {
await this.importer(requiredModule);
}
support_code_library_builder_1.default.reset(this.cwd, newId);
supportCodePaths.forEach((codePath) => require(codePath));
for (const codePath of supportCodePaths) {
await this.importer(codePath, true);
}
return support_code_library_builder_1.default.finalize();

@@ -141,3 +149,6 @@ }

: uuid();
const supportCodeLibrary = this.getSupportCodeLibrary({
if (configuration.esm) {
this.importer = importers.esm;
}
const supportCodeLibrary = await this.getSupportCodeLibrary({
newId,

@@ -144,0 +155,0 @@ supportCodePaths: configuration.supportCodePaths,

import { Dictionary } from 'lodash';
import { IUserCodeImporter } from './index';
export default class ProfileLoader {
private readonly directory;
constructor(directory: string);
private readonly importer;
constructor(directory: string, importer: IUserCodeImporter);
getDefinitions(): Promise<Dictionary<string>>;
getArgv(profiles: string[]): Promise<string[]>;
}

@@ -12,4 +12,5 @@ "use strict";

class ProfileLoader {
constructor(directory) {
constructor(directory, importer) {
this.directory = directory;
this.importer = importer;
}

@@ -22,3 +23,3 @@ async getDefinitions() {

}
const definitions = require(definitionsFilePath); // eslint-disable-line @typescript-eslint/no-var-requires
const definitions = await this.importer(definitionsFilePath, true);
if (typeof definitions !== 'object') {

@@ -25,0 +26,0 @@ throw new Error(`${definitionsFilePath} does not export an object`);

@@ -10,4 +10,6 @@ /// <reference types="node" />

import { SnippetInterface } from './step_definition_snippet_builder/snippet_syntax';
import { IUserCodeImporter } from '../cli';
interface IGetStepDefinitionSnippetBuilderOptions {
cwd: string;
importer: IUserCodeImporter;
snippetInterface?: SnippetInterface;

@@ -23,2 +25,3 @@ snippetSyntax?: string;

parsedArgvOptions: IParsedArgvFormatOptions;
importer: IUserCodeImporter;
stream: WritableStream;

@@ -29,7 +32,8 @@ cleanup: IFormatterCleanupFn;

declare const FormatterBuilder: {
build(type: string, options: IBuildOptions): Formatter;
getConstructorByType(type: string, cwd: string): typeof Formatter;
getStepDefinitionSnippetBuilder({ cwd, snippetInterface, snippetSyntax, supportCodeLibrary, }: IGetStepDefinitionSnippetBuilderOptions): StepDefinitionSnippetBuilder;
loadCustomFormatter(customFormatterPath: string, cwd: string): any;
build(type: string, options: IBuildOptions): Promise<Formatter>;
getConstructorByType(type: string, cwd: string, importer: IUserCodeImporter): Promise<typeof Formatter>;
getStepDefinitionSnippetBuilder({ cwd, importer, snippetInterface, snippetSyntax, supportCodeLibrary, }: IGetStepDefinitionSnippetBuilderOptions): Promise<StepDefinitionSnippetBuilder>;
loadCustomFormatter(customFormatterPath: string, cwd: string, importer: IUserCodeImporter): Promise<any>;
resolveConstructor(ImportedCode: any): any;
};
export default FormatterBuilder;

@@ -22,9 +22,9 @@ "use strict";

const html_formatter_1 = __importDefault(require("./html_formatter"));
const create_require_1 = __importDefault(require("create-require"));
const FormatterBuilder = {
build(type, options) {
const FormatterConstructor = FormatterBuilder.getConstructorByType(type, options.cwd);
async build(type, options) {
const FormatterConstructor = await FormatterBuilder.getConstructorByType(type, options.cwd, options.importer);
const colorFns = get_color_fns_1.default(options.parsedArgvOptions.colorsEnabled);
const snippetBuilder = FormatterBuilder.getStepDefinitionSnippetBuilder({
const snippetBuilder = await FormatterBuilder.getStepDefinitionSnippetBuilder({
cwd: options.cwd,
importer: options.importer,
snippetInterface: options.parsedArgvOptions.snippetInterface,

@@ -34,6 +34,9 @@ snippetSyntax: options.parsedArgvOptions.snippetSyntax,

});
return new FormatterConstructor(Object.assign({ colorFns,
snippetBuilder }, options));
return new FormatterConstructor({
colorFns,
snippetBuilder,
...options,
});
},
getConstructorByType(type, cwd) {
async getConstructorByType(type, cwd, importer) {
switch (type) {

@@ -61,6 +64,6 @@ case 'json':

default:
return FormatterBuilder.loadCustomFormatter(type, cwd);
return await FormatterBuilder.loadCustomFormatter(type, cwd, importer);
}
},
getStepDefinitionSnippetBuilder({ cwd, snippetInterface, snippetSyntax, supportCodeLibrary, }) {
async getStepDefinitionSnippetBuilder({ cwd, importer, snippetInterface, snippetSyntax, supportCodeLibrary, }) {
if (value_checker_1.doesNotHaveValue(snippetInterface)) {

@@ -72,3 +75,4 @@ snippetInterface = snippet_syntax_1.SnippetInterface.Synchronous;

const fullSyntaxPath = path_1.default.resolve(cwd, snippetSyntax);
Syntax = require(fullSyntaxPath); // eslint-disable-line @typescript-eslint/no-var-requires
Syntax = await importer(fullSyntaxPath, true);
Syntax = FormatterBuilder.resolveConstructor(Syntax);
}

@@ -80,15 +84,26 @@ return new step_definition_snippet_builder_1.default({

},
loadCustomFormatter(customFormatterPath, cwd) {
const CustomFormatter = create_require_1.default(cwd)(customFormatterPath);
if (typeof CustomFormatter === 'function') {
async loadCustomFormatter(customFormatterPath, cwd, importer) {
let CustomFormatter = customFormatterPath.startsWith(`.`)
? await importer(path_1.default.resolve(cwd, customFormatterPath), true)
: await importer(customFormatterPath);
CustomFormatter = FormatterBuilder.resolveConstructor(CustomFormatter);
if (value_checker_1.doesHaveValue(CustomFormatter)) {
return CustomFormatter;
}
else if (value_checker_1.doesHaveValue(CustomFormatter) &&
typeof CustomFormatter.default === 'function') {
return CustomFormatter.default;
else {
throw new Error(`Custom formatter (${customFormatterPath}) does not export a function`);
}
throw new Error(`Custom formatter (${customFormatterPath}) does not export a function`);
},
resolveConstructor(ImportedCode) {
if (typeof ImportedCode === 'function') {
return ImportedCode;
}
else if (value_checker_1.doesHaveValue(ImportedCode) &&
typeof ImportedCode.default === 'function') {
return ImportedCode.default;
}
return null;
},
};
exports.default = FormatterBuilder;
//# sourceMappingURL=builder.js.map
"use strict";
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -80,4 +69,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

return lodash_1.default.chain(mapping)
.map((_a) => {
var { matches } = _a, rest = __rest(_a, ["matches"]);
.map(({ matches, ...rest }) => {
const sortedMatches = lodash_1.default.sortBy(matches, [

@@ -87,3 +75,3 @@ (match) => invertDuration(match.duration),

]);
const result = Object.assign({ matches: sortedMatches }, rest);
const result = { matches: sortedMatches, ...rest };
const durations = lodash_1.default.chain(matches)

@@ -90,0 +78,0 @@ .map((m) => m.duration)

@@ -89,3 +89,3 @@ "use strict";

}
const allHeaders = Object.assign(Object.assign({}, headers), additionalHttpHeaders);
const allHeaders = { ...headers, ...additionalHttpHeaders };
const req = httpx.request(url, {

@@ -92,0 +92,0 @@ method,

@@ -29,8 +29,8 @@ "use strict";

defineTestRunHook: [
Object.assign({ identifier: 'first argument' }, optionsValidation),
{ identifier: 'first argument', ...optionsValidation },
optionsTimeoutValidation,
Object.assign({ identifier: 'second argument' }, fnValidation),
{ identifier: 'second argument', ...fnValidation },
],
defineTestCaseHook: [
Object.assign({ identifier: 'first argument' }, optionsValidation),
{ identifier: 'first argument', ...optionsValidation },
{

@@ -44,6 +44,6 @@ identifier: '"options.tags"',

optionsTimeoutValidation,
Object.assign({ identifier: 'second argument' }, fnValidation),
{ identifier: 'second argument', ...fnValidation },
],
defineTestStepHook: [
Object.assign({ identifier: 'first argument' }, optionsValidation),
{ identifier: 'first argument', ...optionsValidation },
{

@@ -57,3 +57,3 @@ identifier: '"options.tags"',

optionsTimeoutValidation,
Object.assign({ identifier: 'second argument' }, fnValidation),
{ identifier: 'second argument', ...fnValidation },
],

@@ -68,5 +68,5 @@ defineStep: [

},
Object.assign({ identifier: 'second argument' }, optionsValidation),
{ identifier: 'second argument', ...optionsValidation },
optionsTimeoutValidation,
Object.assign({ identifier: 'third argument' }, fnValidation),
{ identifier: 'third argument', ...fnValidation },
],

@@ -73,0 +73,0 @@ };

@@ -11,3 +11,3 @@ {

],
"version": "7.1.0",
"version": "7.2.0",
"homepage": "https://github.com/cucumber/cucumber-js",

@@ -167,2 +167,6 @@ "author": "Julien Biezemans <jb@jbpros.com>",

"main": "./lib/index.js",
"exports": {
"import": "./lib/wrapper.mjs",
"require": "./lib/index.js"
},
"types": "./lib/index.d.ts",

@@ -187,3 +191,2 @@ "engines": {

"commander": "^7.0.0",
"create-require": "^1.1.1",
"duration": "^0.2.2",

@@ -263,3 +266,3 @@ "durations": "^3.4.2",

"scripts": {
"build-local": "tsc -p tsconfig.node.json",
"build-local": "tsc -p tsconfig.node.json && cp src/importers.js lib/ && cp src/wrapper.mjs lib/",
"cck-test": "mocha 'compatibility/**/*_spec.ts'",

@@ -266,0 +269,0 @@ "feature-test": "node ./bin/cucumber-js",

@@ -5,4 +5,5 @@ # Cucumber.js

[![OpenCollective](https://opencollective.com/cucumber/sponsors/badge.svg)](https://opencollective.com/cucumber)
[![pull requests](https://oselvar.com/api/badge?label=pull%20requests&csvUrl=https%3A%2F%2Fraw.githubusercontent.com%2Fcucumber%2Foselvar-github-metrics%2Fmain%2Fdata%2Fcucumber%2Fcucumber-js%2FpullRequests.csv)](https://oselvar.com/github/cucumber/oselvar-github-metrics/main/cucumber/cucumber-js)
[![issues](https://oselvar.com/api/badge?label=issues&csvUrl=https%3A%2F%2Fraw.githubusercontent.com%2Fcucumber%2Foselvar-github-metrics%2Fmain%2Fdata%2Fcucumber%2Fcucumber-js%2Fissues.csv)](https://oselvar.com/github/cucumber/oselvar-github-metrics/main/cucumber/cucumber-js)
[![GitHub Actions](https://github.com/cucumber/cucumber-js/workflows/Build/badge.svg)](https://github.com/cucumber/cucumber-js/actions)

@@ -9,0 +10,0 @@ [![Dependencies](https://david-dm.org/cucumber/cucumber-js.svg)](https://david-dm.org/cucumber/cucumber-js)

Sorry, the diff of this file is too big to display

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