Socket
Socket
Sign inDemoInstall

@cucumber/cucumber

Package Overview
Dependencies
Maintainers
3
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 10.6.0 to 10.7.0

lib/formatter/builtin/html.d.ts

4

lib/api/formatters.d.ts

@@ -8,4 +8,5 @@ /// <reference types="node" />

import { ILogger } from '../logger';
import { PluginManager } from '../plugin';
import { IRunOptionsFormats } from './types';
export declare function initializeFormatters({ env, cwd, stdout, logger, onStreamError, eventBroadcaster, eventDataCollector, configuration, supportCodeLibrary, }: {
export declare function initializeFormatters({ env, cwd, stdout, logger, onStreamError, eventBroadcaster, eventDataCollector, configuration, supportCodeLibrary, pluginManager, }: {
env: NodeJS.ProcessEnv;

@@ -21,2 +22,3 @@ cwd: string;

supportCodeLibrary: SupportCodeLibrary;
pluginManager: PluginManager;
}): Promise<() => Promise<void>>;

@@ -8,52 +8,43 @@ "use strict";

const node_util_1 = require("node:util");
const node_path_1 = __importDefault(require("node:path"));
const fs_1 = __importDefault(require("mz/fs"));
const mkdirp_1 = require("mkdirp");
const builder_1 = __importDefault(require("../formatter/builder"));
async function initializeFormatters({ env, cwd, stdout, logger, onStreamError, eventBroadcaster, eventDataCollector, configuration, supportCodeLibrary, }) {
async function initializeFormatter(stream, target, type) {
stream.on('error', (error) => {
logger.error(error.message);
onStreamError();
});
const typeOptions = {
env,
cwd,
eventBroadcaster,
eventDataCollector,
log: stream.write.bind(stream),
parsedArgvOptions: configuration.options,
stream,
cleanup: stream === stdout
? async () => await Promise.resolve()
: (0, node_util_1.promisify)(stream.end.bind(stream)),
supportCodeLibrary,
};
if (type === 'progress-bar' && !stream.isTTY) {
const create_stream_1 = require("../formatter/create_stream");
const resolve_implementation_1 = require("../formatter/resolve_implementation");
async function initializeFormatters({ env, cwd, stdout, logger, onStreamError, eventBroadcaster, eventDataCollector, configuration, supportCodeLibrary, pluginManager, }) {
const cleanupFns = [];
async function initializeFormatter(stream, target, specifier) {
if (specifier === 'progress-bar' && !stream.isTTY) {
logger.warn(`Cannot use 'progress-bar' formatter for output to '${target}' as not a TTY. Switching to 'progress' formatter.`);
type = 'progress';
specifier = 'progress';
}
return await builder_1.default.build(type, typeOptions);
const implementation = await (0, resolve_implementation_1.resolveImplementation)(specifier, cwd);
if (typeof implementation === 'function') {
const typeOptions = {
env,
cwd,
eventBroadcaster,
eventDataCollector,
log: stream.write.bind(stream),
parsedArgvOptions: configuration.options,
stream,
cleanup: stream === stdout
? async () => await Promise.resolve()
: (0, node_util_1.promisify)(stream.end.bind(stream)),
supportCodeLibrary,
};
const formatter = await builder_1.default.build(implementation, typeOptions);
cleanupFns.push(async () => formatter.finished());
}
else {
await pluginManager.initFormatter(implementation, configuration.options, stream.write.bind(stream));
if (stream !== stdout) {
cleanupFns.push((0, node_util_1.promisify)(stream.end.bind(stream)));
}
}
}
const formatters = [];
formatters.push(await initializeFormatter(stdout, 'stdout', configuration.stdout));
const streamPromises = [];
Object.entries(configuration.files).forEach(([target, type]) => {
streamPromises.push((async (target, type) => {
const absoluteTarget = node_path_1.default.resolve(cwd, target);
try {
await (0, mkdirp_1.mkdirp)(node_path_1.default.dirname(absoluteTarget));
}
catch (error) {
logger.warn('Failed to ensure directory for formatter target exists');
}
const stream = fs_1.default.createWriteStream(null, {
fd: await fs_1.default.open(absoluteTarget, 'w'),
});
formatters.push(await initializeFormatter(stream, target, type));
})(target, type));
});
await Promise.all(streamPromises);
await initializeFormatter(stdout, 'stdout', configuration.stdout);
for (const [target, specifier] of Object.entries(configuration.files)) {
await initializeFormatter(await (0, create_stream_1.createStream)(target, onStreamError, cwd, logger), target, specifier);
}
return async function () {
await Promise.all(formatters.map(async (f) => await f.finished()));
await Promise.all(cleanupFns.map((cleanupFn) => cleanupFn()));
};

@@ -60,0 +51,0 @@ }

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

const pluginManager = new plugin_1.PluginManager();
await pluginManager.init('loadSources', filter_1.default, coordinates, logger, environment);
await pluginManager.initCoordinator('loadSources', filter_1.default, coordinates, logger, environment);
return pluginManager;

@@ -26,4 +26,4 @@ }

const pluginManager = new plugin_1.PluginManager();
await pluginManager.init('runCucumber', publish_1.default, configuration.formats.publish, logger, environment);
await pluginManager.init('runCucumber', filter_1.default, configuration.sources, logger, environment);
await pluginManager.initCoordinator('runCucumber', publish_1.default, configuration.formats.publish, logger, environment);
await pluginManager.initCoordinator('runCucumber', filter_1.default, configuration.sources, logger, environment);
return pluginManager;

@@ -30,0 +30,0 @@ }

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

supportCodeLibrary,
pluginManager,
});

@@ -116,4 +117,4 @@ await (0, helpers_2.emitMetaMessage)(eventBroadcaster, env);

const success = await runtime.start();
await pluginManager.cleanup();
await cleanupFormatters();
await pluginManager.cleanup();
return {

@@ -120,0 +121,0 @@ success: success && !formatterStreamError,

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

const gherkin_1 = require("@cucumber/gherkin");
const formatters_1 = __importDefault(require("../formatter/helpers/formatters"));
const version_1 = require("../version");
const builtin_1 = __importDefault(require("../formatter/builtin"));
const ArgvParser = {

@@ -63,3 +63,3 @@ collect(val, memo = []) {

.option('-f, --format <TYPE[:PATH]>', 'specify the output format, optionally supply PATH to redirect formatter output (repeatable). Available formats:\n' +
formatters_1.default.buildFormattersDocumentationString(), ArgvParser.collect)
Object.entries(builtin_1.default).reduce((previous, [key, formatter]) => previous + ` ${key}: ${formatter.documentation}\n`, ''), ArgvParser.collect)
.option('--format-options <JSON>', 'provide options for formatters (repeatable)', ArgvParser.mergeJson('--format-options'))

@@ -66,0 +66,0 @@ .option('--i18n-keywords <ISO 639-1>', 'list language keywords', ArgvParser.validateLanguage)

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

declare const FormatterBuilder: {
build(type: string, options: IBuildOptions): Promise<Formatter>;
build(FormatterConstructor: string | typeof Formatter, options: IBuildOptions): Promise<Formatter>;
getConstructorByType(type: string, cwd: string): Promise<typeof Formatter>;

@@ -33,0 +33,0 @@ getStepDefinitionSnippetBuilder({ cwd, snippetInterface, snippetSyntax, supportCodeLibrary, }: IGetStepDefinitionSnippetBuilderOptions): Promise<StepDefinitionSnippetBuilder>;

@@ -6,4 +6,2 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const node_path_1 = __importDefault(require("node:path"));
const node_url_1 = require("node:url");
const value_checker_1 = require("../value_checker");

@@ -15,5 +13,8 @@ const snippet_syntax_1 = require("./step_definition_snippet_builder/snippet_syntax");

const formatters_1 = __importDefault(require("./helpers/formatters"));
const import_code_1 = require("./import_code");
const FormatterBuilder = {
async build(type, options) {
const FormatterConstructor = await FormatterBuilder.getConstructorByType(type, options.cwd);
async build(FormatterConstructor, options) {
if (typeof FormatterConstructor === 'string') {
FormatterConstructor = await FormatterBuilder.getConstructorByType(FormatterConstructor, options.cwd);
}
const colorFns = (0, get_color_fns_1.default)(options.stream, options.env, options.parsedArgvOptions.colorsEnabled);

@@ -52,11 +53,3 @@ const snippetBuilder = await FormatterBuilder.getStepDefinitionSnippetBuilder({

async loadCustomClass(type, descriptor, cwd) {
let normalized = descriptor;
if (descriptor.startsWith('.')) {
normalized = (0, node_url_1.pathToFileURL)(node_path_1.default.resolve(cwd, descriptor));
}
else if (descriptor.startsWith('file://')) {
normalized = new URL(descriptor);
}
let CustomClass = await FormatterBuilder.loadFile(normalized);
CustomClass = FormatterBuilder.resolveConstructor(CustomClass);
const CustomClass = FormatterBuilder.resolveConstructor(await (0, import_code_1.importCode)(descriptor, cwd));
if ((0, value_checker_1.doesHaveValue)(CustomClass)) {

@@ -63,0 +56,0 @@ return CustomClass;

import Formatter from '../.';
declare const Formatters: {
getFormatters(): Record<string, typeof Formatter>;
buildFormattersDocumentationString(): string;
};
export default Formatters;

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

const json_formatter_1 = __importDefault(require("../json_formatter"));
const message_formatter_1 = __importDefault(require("../message_formatter"));
const progress_bar_formatter_1 = __importDefault(require("../progress_bar_formatter"));

@@ -16,3 +15,2 @@ const progress_formatter_1 = __importDefault(require("../progress_formatter"));

const usage_json_formatter_1 = __importDefault(require("../usage_json_formatter"));
const html_formatter_1 = __importDefault(require("../html_formatter"));
const junit_formatter_1 = __importDefault(require("../junit_formatter"));

@@ -23,4 +21,2 @@ const Formatters = {

json: json_formatter_1.default,
message: message_formatter_1.default,
html: html_formatter_1.default,
progress: progress_formatter_1.default,

@@ -36,12 +32,4 @@ 'progress-bar': progress_bar_formatter_1.default,

},
buildFormattersDocumentationString() {
let concatenatedFormattersDocumentation = '';
const formatters = this.getFormatters();
for (const formatterName in formatters) {
concatenatedFormattersDocumentation += ` ${formatterName}: ${formatters[formatterName].documentation}\n`;
}
return concatenatedFormattersDocumentation;
},
};
exports.default = Formatters;
//# sourceMappingURL=formatters.js.map

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

import { SupportCodeLibrary } from '../support_code_library_builder/types';
import { FormatterPlugin } from '../plugin';
import { IColorFns } from './get_color_fns';

@@ -22,2 +23,3 @@ import { EventDataCollector } from './helpers';

}
export type FormatterImplementation = typeof Formatter | FormatterPlugin;
export type IFormatterStream = Writable;

@@ -24,0 +26,0 @@ export type IFormatterLogFn = (buffer: string | Uint8Array) => void;

import { IRunEnvironment } from '../api';
import { ILogger } from '../logger';
import { InternalPlugin, CoordinatorPluginEventValues, CoordinatorPluginEventKey, CoordinatorPluginTransformEventKey, Operation } from './types';
import { InternalPlugin, CoordinatorPluginEventValues, CoordinatorPluginEventKey, CoordinatorPluginTransformEventKey, Operation, FormatterPlugin } from './types';
export declare class PluginManager {

@@ -8,3 +8,4 @@ private handlers;

private register;
init<OptionsType>(operation: Operation, plugin: InternalPlugin<OptionsType>, options: OptionsType, logger: ILogger, environment: Required<IRunEnvironment>): Promise<void>;
initFormatter<OptionsType>(plugin: FormatterPlugin<OptionsType>, options: OptionsType, write: (buffer: string | Uint8Array) => void): Promise<void>;
initCoordinator<OptionsType>(operation: Operation, plugin: InternalPlugin<OptionsType>, options: OptionsType, logger: ILogger, environment: Required<IRunEnvironment>): Promise<void>;
emit<K extends CoordinatorPluginEventKey>(event: K, value: CoordinatorPluginEventValues[K]): void;

@@ -11,0 +12,0 @@ transform<K extends CoordinatorPluginTransformEventKey>(event: K, value: CoordinatorPluginEventValues[K]): Promise<CoordinatorPluginEventValues[K]>;

@@ -13,5 +13,15 @@ "use strict";

async register(event, handler) {
this.handlers[event].push(handler);
this.handlers[event]?.push(handler);
}
async init(operation, plugin, options, logger, environment) {
async initFormatter(plugin, options, write) {
const cleanupFn = await plugin.formatter({
on: (key, handler) => this.register(key, handler),
options,
write,
});
if (typeof cleanupFn === 'function') {
this.cleanupFns.push(cleanupFn);
}
}
async initCoordinator(operation, plugin, options, logger, environment) {
const cleanupFn = await plugin.coordinator({

@@ -18,0 +28,0 @@ operation,

@@ -39,1 +39,12 @@ import { Envelope } from '@cucumber/messages';

}
export interface FormatterPluginContext<OptionsType> {
on: (key: 'message', handler: (value: Envelope) => void) => void;
options: OptionsType;
write: (buffer: string | Uint8Array) => void;
}
export type FormatterPluginFunction<OptionsType> = (context: FormatterPluginContext<OptionsType>) => Promisable<PluginCleanup | void>;
export interface FormatterPlugin<OptionsType = any> {
type: 'formatter';
formatter: FormatterPluginFunction<OptionsType>;
documentation: string;
}

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

onWorkerProcessClose(exitCode: number): void;
parseTestCaseResult(testCaseFinished: messages.TestCaseFinished): void;
parseTestCaseResult(testCaseFinished: messages.TestCaseFinished, workerId: string): void;
start(): Promise<boolean>;

@@ -63,0 +63,0 @@ nextPicklePlacement(): IPicklePlacement;

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

if ((0, value_checker_1.doesHaveValue)(envelope.testCaseFinished)) {
delete this.inProgressPickles[worker.id];
this.parseTestCaseResult(envelope.testCaseFinished);
this.parseTestCaseResult(envelope.testCaseFinished, worker.id);
}

@@ -126,7 +125,9 @@ }

}
parseTestCaseResult(testCaseFinished) {
parseTestCaseResult(testCaseFinished, workerId) {
const { worstTestStepResult } = this.eventDataCollector.getTestCaseAttempt(testCaseFinished.testCaseStartedId);
if (!testCaseFinished.willBeRetried &&
(0, helpers_1.shouldCauseFailure)(worstTestStepResult.status, this.options)) {
this.success = false;
if (!testCaseFinished.willBeRetried) {
delete this.inProgressPickles[workerId];
if ((0, helpers_1.shouldCauseFailure)(worstTestStepResult.status, this.options)) {
this.success = false;
}
}

@@ -133,0 +134,0 @@ }

@@ -1,1 +0,1 @@

export declare const version = "10.6.0";
export declare const version = "10.7.0";

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

// Generated by genversion.
exports.version = '10.6.0';
exports.version = '10.7.0';
//# sourceMappingURL=version.js.map

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

],
"version": "10.6.0",
"version": "10.7.0",
"funding": "https://opencollective.com/cucumber",

@@ -168,2 +168,3 @@ "homepage": "https://github.com/cucumber/cucumber-js",

"Tristan Dunn <tristanzdunn@gmail.com>",
"Tristan Zander <tristan.zander@ncino.com>",
"unknown <jharlin@NormanDev2.telogical.com>",

@@ -214,3 +215,3 @@ "Valerio Innocenti Sedili <valerio.innocenti.ext@yoox.com>",

"enginesTested": {
"node": "18 || 20 || 21"
"node": "18 || 20 || 21 || 22"
},

@@ -217,0 +218,0 @@ "dependencies": {

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