@cucumber/cucumber 12.3.0 → 12.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/configuration/from_file.js +66 -37
- package/lib/configuration/from_file.js.map +1 -1
- package/lib/publish/publish_plugin.js +18 -12
- package/lib/publish/publish_plugin.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/package.json +3 -3
|
@@ -11,6 +11,17 @@ const node_url_1 = require("node:url");
|
|
|
11
11
|
const yaml_1 = __importDefault(require("yaml"));
|
|
12
12
|
const merge_configurations_1 = require("./merge_configurations");
|
|
13
13
|
const parse_configuration_1 = require("./parse_configuration");
|
|
14
|
+
const SUPPORTED_EXTENSIONS = [
|
|
15
|
+
'.json',
|
|
16
|
+
'.yaml',
|
|
17
|
+
'.yml',
|
|
18
|
+
'.js',
|
|
19
|
+
'.cjs',
|
|
20
|
+
'.mjs',
|
|
21
|
+
'.ts',
|
|
22
|
+
'.cts',
|
|
23
|
+
'.mts',
|
|
24
|
+
];
|
|
14
25
|
async function fromFile(logger, cwd, file, profiles = []) {
|
|
15
26
|
let definitions = await loadFile(logger, cwd, file);
|
|
16
27
|
const defaultDefinition = definitions.default;
|
|
@@ -49,45 +60,63 @@ async function handleDefaultFunctionDefinition(definitions, defaultDefinition) {
|
|
|
49
60
|
async function loadFile(logger, cwd, file) {
|
|
50
61
|
const filePath = node_path_1.default.join(cwd, file);
|
|
51
62
|
const extension = node_path_1.default.extname(filePath);
|
|
63
|
+
if (!SUPPORTED_EXTENSIONS.includes(extension)) {
|
|
64
|
+
throw new Error(`Unsupported configuration file extension "${extension}"`);
|
|
65
|
+
}
|
|
52
66
|
let definitions;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
67
|
+
try {
|
|
68
|
+
switch (extension) {
|
|
69
|
+
case '.json':
|
|
70
|
+
definitions = JSON.parse(await (0, node_util_1.promisify)(node_fs_1.default.readFile)(filePath, { encoding: 'utf-8' }));
|
|
71
|
+
break;
|
|
72
|
+
case '.yaml':
|
|
73
|
+
case '.yml':
|
|
74
|
+
definitions = yaml_1.default.parse(await (0, node_util_1.promisify)(node_fs_1.default.readFile)(filePath, { encoding: 'utf-8' }));
|
|
75
|
+
break;
|
|
76
|
+
case '.cjs':
|
|
77
|
+
logger.debug(`Loading configuration file "${file}" as CommonJS based on extension`);
|
|
78
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
79
|
+
definitions = require(filePath);
|
|
80
|
+
break;
|
|
81
|
+
case '.cts':
|
|
82
|
+
logger.debug(`Loading configuration file "${file}" as TypeScript based on extension`);
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
84
|
+
definitions = require(filePath);
|
|
85
|
+
break;
|
|
86
|
+
case '.mjs':
|
|
87
|
+
logger.debug(`Loading configuration file "${file}" as ESM based on extension`);
|
|
88
|
+
definitions = await import((0, node_url_1.pathToFileURL)(filePath).toString());
|
|
89
|
+
break;
|
|
90
|
+
case '.mts':
|
|
91
|
+
case '.ts':
|
|
92
|
+
logger.debug(`Loading configuration file "${file}" as TypeScript based on extension`);
|
|
93
|
+
definitions = await import((0, node_url_1.pathToFileURL)(filePath).toString());
|
|
94
|
+
break;
|
|
95
|
+
case '.js':
|
|
96
|
+
{
|
|
97
|
+
const parentPackage = await readPackageJson(filePath);
|
|
98
|
+
if (!parentPackage) {
|
|
99
|
+
logger.debug(`Loading configuration file "${file}" as CommonJS based on absence of a parent package`);
|
|
100
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
101
|
+
definitions = require(filePath);
|
|
102
|
+
}
|
|
103
|
+
else if (parentPackage.type === 'module') {
|
|
104
|
+
logger.debug(`Loading configuration file "${file}" as ESM based on "${parentPackage.name}" package type`);
|
|
105
|
+
definitions = await import((0, node_url_1.pathToFileURL)(filePath).toString());
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
logger.debug(`Loading configuration file "${file}" as CommonJS based on "${parentPackage.name}" package type`);
|
|
109
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
110
|
+
definitions = require(filePath);
|
|
111
|
+
}
|
|
86
112
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
throw new Error(`Configuration file "${file}" failed to load/parse`, {
|
|
118
|
+
cause: error,
|
|
119
|
+
});
|
|
91
120
|
}
|
|
92
121
|
if (typeof definitions !== 'object') {
|
|
93
122
|
throw new Error(`Configuration file ${filePath} does not export an object`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"from_file.js","sourceRoot":"","sources":["../../src/configuration/from_file.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"from_file.js","sourceRoot":"","sources":["../../src/configuration/from_file.ts"],"names":[],"mappings":";;;;;AAsBA,4BA4CC;AAlED,sDAAwB;AACxB,0DAA4B;AAC5B,yCAAqC;AACrC,uCAAwC;AACxC,gDAAuB;AAGvB,iEAA4D;AAC5D,+DAA0D;AAE1D,MAAM,oBAAoB,GAAG;IAC3B,OAAO;IACP,OAAO;IACP,MAAM;IACN,KAAK;IACL,MAAM;IACN,MAAM;IACN,KAAK;IACL,MAAM;IACN,MAAM;CACP,CAAA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AAK,CACV,+BAA+B,IAAI,2BAA2B,aAAa,CAAC,IAAI,gBAAgB,CACjG,CAAA;wBACD,iEAAiE;wBACjE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;oBACjC,CAAC;gBACH,CAAC;gBACD,MAAK;QACT,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,uBAAuB,IAAI,wBAAwB,EAAE;YACnE,KAAK,EAAE,KAAK;SACb,CAAC,CAAA;IACJ,CAAC;IAED,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,sBAAsB,QAAQ,4BAA4B,CAAC,CAAA;IAC7E,CAAC;IACD,OAAO,WAAW,CAAA;AACpB,CAAC;AAED,KAAK,UAAU,eAAe,CAAC,QAAgB;IAC7C,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,MAAM,CAAC,iBAAiB,CAAC,CAAA;IACzD,MAAM,aAAa,GAAG,MAAM,aAAa,CAAC,EAAE,GAAG,EAAE,mBAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;IAC1E,OAAO,aAAa,EAAE,WAAW,CAAA;AACnC,CAAC","sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\nimport { promisify } from 'node:util'\nimport { pathToFileURL } from 'node:url'\nimport YAML from 'yaml'\nimport { ILogger } from '../environment'\nimport { IConfiguration } from './types'\nimport { mergeConfigurations } from './merge_configurations'\nimport { parseConfiguration } from './parse_configuration'\n\nconst SUPPORTED_EXTENSIONS = [\n '.json',\n '.yaml',\n '.yml',\n '.js',\n '.cjs',\n '.mjs',\n '.ts',\n '.cts',\n '.mts',\n]\n\nexport async function fromFile(\n logger: ILogger,\n cwd: string,\n file: string,\n profiles: string[] = []\n): Promise<Partial<IConfiguration>> {\n let definitions = await loadFile(logger, cwd, file)\n\n const defaultDefinition: unknown = definitions.default\n\n if (defaultDefinition) {\n if (typeof defaultDefinition === 'function') {\n logger.debug('Default function found; loading profiles')\n definitions = await handleDefaultFunctionDefinition(\n definitions,\n defaultDefinition\n )\n }\n } else {\n logger.debug('No default profile defined in configuration file')\n definitions.default = {}\n }\n\n if (profiles.length < 1) {\n logger.debug('No profiles specified; using default profile')\n profiles = ['default']\n }\n\n const definedKeys = Object.keys(definitions)\n profiles.forEach((profileKey) => {\n if (!definedKeys.includes(profileKey)) {\n throw new Error(`Requested profile \"${profileKey}\" doesn't exist`)\n }\n })\n return mergeConfigurations(\n {},\n ...profiles.map((profileKey) =>\n parseConfiguration(\n logger,\n `Profile \"${profileKey}\"`,\n definitions[profileKey]\n )\n )\n )\n}\n\nasync function handleDefaultFunctionDefinition(\n definitions: Record<string, any>,\n defaultDefinition: Function\n): Promise<Record<string, any>> {\n if (Object.keys(definitions).length > 1) {\n throw new Error(\n 'Invalid profiles specified: if a default function definition is provided, no other static profiles should be specified'\n )\n }\n\n const definitionsFromDefault = await defaultDefinition()\n\n return {\n default: {},\n ...definitionsFromDefault,\n }\n}\n\nasync function loadFile(\n logger: ILogger,\n cwd: string,\n file: string\n): Promise<Record<string, any>> {\n const filePath: string = path.join(cwd, file)\n const extension = path.extname(filePath)\n if (!SUPPORTED_EXTENSIONS.includes(extension)) {\n throw new Error(`Unsupported configuration file extension \"${extension}\"`)\n }\n let definitions\n try {\n switch (extension) {\n case '.json':\n definitions = JSON.parse(\n await promisify(fs.readFile)(filePath, { encoding: 'utf-8' })\n )\n break\n case '.yaml':\n case '.yml':\n definitions = YAML.parse(\n await promisify(fs.readFile)(filePath, { encoding: 'utf-8' })\n )\n break\n case '.cjs':\n logger.debug(\n `Loading configuration file \"${file}\" as CommonJS based on extension`\n )\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n definitions = require(filePath)\n break\n case '.cts':\n logger.debug(\n `Loading configuration file \"${file}\" as TypeScript based on extension`\n )\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n definitions = require(filePath)\n break\n case '.mjs':\n logger.debug(\n `Loading configuration file \"${file}\" as ESM based on extension`\n )\n definitions = await import(pathToFileURL(filePath).toString())\n break\n case '.mts':\n case '.ts':\n logger.debug(\n `Loading configuration file \"${file}\" as TypeScript based on extension`\n )\n definitions = await import(pathToFileURL(filePath).toString())\n break\n case '.js':\n {\n const parentPackage = await readPackageJson(filePath)\n if (!parentPackage) {\n logger.debug(\n `Loading configuration file \"${file}\" as CommonJS based on absence of a parent package`\n )\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n definitions = require(filePath)\n } else if (parentPackage.type === 'module') {\n logger.debug(\n `Loading configuration file \"${file}\" as ESM based on \"${parentPackage.name}\" package type`\n )\n definitions = await import(pathToFileURL(filePath).toString())\n } else {\n logger.debug(\n `Loading configuration file \"${file}\" as CommonJS based on \"${parentPackage.name}\" package type`\n )\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n definitions = require(filePath)\n }\n }\n break\n }\n } catch (error) {\n throw new Error(`Configuration file \"${file}\" failed to load/parse`, {\n cause: error,\n })\n }\n\n if (typeof definitions !== 'object') {\n throw new Error(`Configuration file ${filePath} does not export an object`)\n }\n return definitions\n}\n\nasync function readPackageJson(filePath: string) {\n const { readPackageUp } = await import('read-package-up')\n const parentPackage = await readPackageUp({ cwd: path.dirname(filePath) })\n return parentPackage?.packageJson\n}\n"]}
|
|
@@ -4,11 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.publishPlugin = void 0;
|
|
7
|
+
const promises_1 = require("node:stream/promises");
|
|
7
8
|
const node_util_1 = require("node:util");
|
|
8
|
-
const
|
|
9
|
+
const promises_2 = require("node:fs/promises");
|
|
9
10
|
const node_path_1 = __importDefault(require("node:path"));
|
|
10
11
|
const node_os_1 = require("node:os");
|
|
11
12
|
const node_fs_1 = require("node:fs");
|
|
13
|
+
const node_zlib_1 = require("node:zlib");
|
|
12
14
|
const supports_color_1 = require("supports-color");
|
|
13
15
|
const has_ansi_1 = __importDefault(require("has-ansi"));
|
|
14
16
|
const DEFAULT_CUCUMBER_PUBLISH_URL = 'https://messages.cucumber.io/api/reports';
|
|
@@ -37,22 +39,26 @@ exports.publishPlugin = {
|
|
|
37
39
|
};
|
|
38
40
|
}
|
|
39
41
|
const uploadUrl = touchResponse.headers.get('Location');
|
|
40
|
-
const tempDir = await (0,
|
|
41
|
-
const tempFilePath = node_path_1.default.join(tempDir, 'envelopes.
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
on('message', (value) => tempFileStream.write(JSON.stringify(value) + '\n'));
|
|
42
|
+
const tempDir = await (0, promises_2.mkdtemp)(node_path_1.default.join((0, node_os_1.tmpdir)(), `cucumber-js-publish-`));
|
|
43
|
+
const tempFilePath = node_path_1.default.join(tempDir, 'envelopes.jsonl.gz');
|
|
44
|
+
const writeStream = (0, node_zlib_1.createGzip)();
|
|
45
|
+
const finishedWriting = (0, promises_1.pipeline)(writeStream, (0, node_fs_1.createWriteStream)(tempFilePath));
|
|
46
|
+
on('message', (value) => writeStream.write(JSON.stringify(value) + '\n'));
|
|
46
47
|
return () => {
|
|
47
48
|
return new Promise((resolve) => {
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
writeStream.end(async () => {
|
|
50
|
+
await finishedWriting;
|
|
51
|
+
const stats = await (0, promises_2.stat)(tempFilePath);
|
|
52
|
+
const contentLength = stats.size.toString();
|
|
53
|
+
logger.debug('Uploading envelopes to Cucumber Reports with content length:', contentLength);
|
|
50
54
|
const uploadResponse = await fetch(uploadUrl, {
|
|
51
55
|
method: 'PUT',
|
|
52
56
|
headers: {
|
|
53
|
-
'Content-
|
|
57
|
+
'Content-Type': 'application/jsonl',
|
|
58
|
+
'Content-Encoding': 'gzip',
|
|
59
|
+
'Content-Length': contentLength,
|
|
54
60
|
},
|
|
55
|
-
body: (0, node_fs_1.createReadStream)(tempFilePath
|
|
61
|
+
body: (0, node_fs_1.createReadStream)(tempFilePath),
|
|
56
62
|
duplex: 'half',
|
|
57
63
|
});
|
|
58
64
|
if (uploadResponse.ok) {
|
|
@@ -60,7 +66,7 @@ exports.publishPlugin = {
|
|
|
60
66
|
}
|
|
61
67
|
else {
|
|
62
68
|
logger.error(`Failed to upload report to ${new URL(uploadUrl).origin} with status ${uploadResponse.status}`);
|
|
63
|
-
logger.debug(uploadResponse);
|
|
69
|
+
logger.debug(await uploadResponse.text());
|
|
64
70
|
}
|
|
65
71
|
resolve();
|
|
66
72
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish_plugin.js","sourceRoot":"","sources":["../../src/publish/publish_plugin.ts"],"names":[],"mappings":";;;;;;AACA,yCAAoD;AACpD,+CAAgD;AAChD,0DAA4B;AAC5B,qCAAgC;AAChC,qCAA6D;AAC7D,mDAA8C;AAC9C,wDAA8B;AAI9B,MAAM,4BAA4B,GAAG,0CAA0C,CAAA;AAElE,QAAA,aAAa,GAA2C;IACnE,IAAI,EAAE,QAAQ;IACd,WAAW,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE;QAC1D,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,SAAS,CAAA;QAClB,CAAC;QACD,MAAM,EAAE,GAAG,GAAG,4BAA4B,EAAE,KAAK,EAAE,GAAG,OAAO,CAAA;QAC7D,MAAM,OAAO,GAA8B,EAAE,CAAA;QAC7C,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO,CAAC,aAAa,GAAG,UAAU,KAAK,EAAE,CAAA;QAC3C,CAAC;QACD,MAAM,aAAa,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,CAAC,CAAA;QACnD,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,IAAI,EAAE,CAAA;QAEzC,IAAI,CAAC,aAAa,CAAC,EAAE,EAAE,CAAC;YACtB,OAA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CAAC,CAAC,CAAA;QACJ,CAAC,CAAA;IACH,CAAC;CACF,CAAA;AAED;;;;;GAKG;AACH,SAAS,qBAAqB,CAAC,GAAW,EAAE,MAAgB;IAC1D,IAAI,CAAC,IAAA,8BAAa,EAAC,MAAM,CAAC,IAAI,IAAA,kBAAO,EAAC,GAAG,CAAC,EAAE,CAAC;QAC3C,OAAO,IAAA,oCAAwB,EAAC,GAAG,CAAC,CAAA;IACtC,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC","sourcesContent":["import { Writable } from 'node:stream'\nimport { pipeline } from 'node:stream/promises'\nimport { stripVTControlCharacters } from 'node:util'\nimport { mkdtemp, stat } from 'node:fs/promises'\nimport path from 'node:path'\nimport { tmpdir } from 'node:os'\nimport { createReadStream, createWriteStream } from 'node:fs'\nimport { createGzip } from 'node:zlib'\nimport { supportsColor } from 'supports-color'\nimport hasAnsi from 'has-ansi'\nimport { InternalPlugin } from '../plugin'\nimport { IPublishConfig } from './types'\n\nconst DEFAULT_CUCUMBER_PUBLISH_URL = 'https://messages.cucumber.io/api/reports'\n\nexport const publishPlugin: InternalPlugin<IPublishConfig | false> = {\n type: 'plugin',\n coordinator: async ({ on, logger, options, environment }) => {\n if (!options) {\n return undefined\n }\n const { url = DEFAULT_CUCUMBER_PUBLISH_URL, token } = options\n const headers: { [key: string]: string } = {}\n if (token !== undefined) {\n headers.Authorization = `Bearer ${token}`\n }\n const touchResponse = await fetch(url, { headers })\n const banner = await touchResponse.text()\n\n if (!touchResponse.ok) {\n return () => {\n if (touchResponse.status < 500) {\n environment.stderr.write(\n sanitisePublishOutput(banner, environment.stderr) + '\\n'\n )\n } else {\n logger.error(\n `Failed to publish report to ${new URL(url).origin} with status ${\n touchResponse.status\n }`\n )\n logger.debug(touchResponse)\n }\n }\n }\n\n const uploadUrl = touchResponse.headers.get('Location')\n const tempDir = await mkdtemp(path.join(tmpdir(), `cucumber-js-publish-`))\n const tempFilePath = path.join(tempDir, 'envelopes.jsonl.gz')\n const writeStream = createGzip()\n const finishedWriting = pipeline(\n writeStream,\n createWriteStream(tempFilePath)\n )\n on('message', (value) => writeStream.write(JSON.stringify(value) + '\\n'))\n\n return () => {\n return new Promise<void>((resolve) => {\n writeStream.end(async () => {\n await finishedWriting\n const stats = await stat(tempFilePath)\n const contentLength = stats.size.toString()\n logger.debug(\n 'Uploading envelopes to Cucumber Reports with content length:',\n contentLength\n )\n const uploadResponse = await fetch(uploadUrl, {\n method: 'PUT',\n headers: {\n 'Content-Type': 'application/jsonl',\n 'Content-Encoding': 'gzip',\n 'Content-Length': contentLength,\n },\n body: createReadStream(tempFilePath),\n duplex: 'half',\n })\n if (uploadResponse.ok) {\n environment.stderr.write(\n sanitisePublishOutput(banner, environment.stderr) + '\\n'\n )\n } else {\n logger.error(\n `Failed to upload report to ${\n new URL(uploadUrl).origin\n } with status ${uploadResponse.status}`\n )\n logger.debug(await uploadResponse.text())\n }\n resolve()\n })\n })\n }\n },\n}\n\n/*\nThis is because the Cucumber Reports service returns a pre-formatted console message\nincluding ANSI escapes, so if our stderr stream doesn't support those we need to\nstrip them back out. Ideally we should get structured data from the service and\ncompose the console message on this end.\n */\nfunction sanitisePublishOutput(raw: string, stderr: Writable) {\n if (!supportsColor(stderr) && hasAnsi(raw)) {\n return stripVTControlCharacters(raw)\n }\n return raw\n}\n"]}
|
package/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "12.
|
|
1
|
+
export declare const version = "12.4.0";
|
package/lib/version.js
CHANGED
package/lib/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAA,2BAA2B;AACd,QAAA,OAAO,GAAG,QAAQ,CAAA","sourcesContent":["// Generated by genversion.\nexport const version = '12.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAA,2BAA2B;AACd,QAAA,OAAO,GAAG,QAAQ,CAAA","sourcesContent":["// Generated by genversion.\nexport const version = '12.4.0'\n"]}
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"gherkin",
|
|
9
9
|
"tests"
|
|
10
10
|
],
|
|
11
|
-
"version": "12.
|
|
11
|
+
"version": "12.4.0",
|
|
12
12
|
"funding": "https://opencollective.com/cucumber",
|
|
13
13
|
"homepage": "https://github.com/cucumber/cucumber-js",
|
|
14
14
|
"author": "Julien Biezemans <jb@jbpros.com>",
|
|
@@ -260,11 +260,11 @@
|
|
|
260
260
|
},
|
|
261
261
|
"devDependencies": {
|
|
262
262
|
"@cucumber/compatibility-kit": "^26.0.0",
|
|
263
|
-
"@cucumber/query": "14.
|
|
263
|
+
"@cucumber/query": "14.7.0",
|
|
264
264
|
"@eslint/compat": "^2.0.0",
|
|
265
265
|
"@eslint/eslintrc": "^3.3.1",
|
|
266
266
|
"@eslint/js": "^9.29.0",
|
|
267
|
-
"@microsoft/api-extractor": "7.55.
|
|
267
|
+
"@microsoft/api-extractor": "7.55.2",
|
|
268
268
|
"@sinonjs/fake-timers": "15.0.0",
|
|
269
269
|
"@types/chai": "4.3.20",
|
|
270
270
|
"@types/debug": "4.1.12",
|