@lynxwall/cucumber-tsflow 7.1.2 → 7.3.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/README.md +154 -61
- package/lib/api/convert-configuration.d.ts +7 -0
- package/lib/api/convert-configuration.js +65 -0
- package/lib/api/convert-configuration.js.map +1 -0
- package/lib/api/index.d.ts +1 -0
- package/lib/api/index.js +1 -0
- package/lib/api/index.js.map +1 -1
- package/lib/api/load-configuration.d.ts +3 -2
- package/lib/api/load-configuration.js +78 -18
- package/lib/api/load-configuration.js.map +1 -1
- package/lib/api/run-cucumber.d.ts +5 -1
- package/lib/api/run-cucumber.js +12 -0
- package/lib/api/run-cucumber.js.map +1 -1
- package/lib/api/wrapper.mjs +1 -0
- package/lib/bindings/binding-context.d.ts +54 -3
- package/lib/bindings/binding-context.js +80 -5
- package/lib/bindings/binding-context.js.map +1 -1
- package/lib/bindings/binding-decorator.js +85 -36
- package/lib/bindings/binding-decorator.js.map +1 -1
- package/lib/bindings/binding-registry.js +10 -0
- package/lib/bindings/binding-registry.js.map +1 -1
- package/lib/bindings/hook-decorators.js +44 -19
- package/lib/bindings/hook-decorators.js.map +1 -1
- package/lib/bindings/step-decorators.js +120 -51
- package/lib/bindings/step-decorators.js.map +1 -1
- package/lib/bindings/types.js.map +1 -1
- package/lib/cli/argv-parser.d.ts +1 -0
- package/lib/cli/argv-parser.js +2 -2
- package/lib/cli/argv-parser.js.map +1 -1
- package/lib/cli/index.js +1 -4
- package/lib/cli/index.js.map +1 -1
- package/lib/runtime/make-runtime.d.ts +3 -2
- package/lib/runtime/make-runtime.js.map +1 -1
- package/lib/runtime/message-collector.d.ts +1 -1
- package/lib/runtime/message-collector.js.map +1 -1
- package/lib/runtime/parallel/adapter.d.ts +3 -2
- package/lib/runtime/parallel/adapter.js +2 -1
- package/lib/runtime/parallel/adapter.js.map +1 -1
- package/lib/runtime/parallel/run-worker.js +3 -2
- package/lib/runtime/parallel/run-worker.js.map +1 -1
- package/lib/runtime/parallel/worker.d.ts +3 -2
- package/lib/runtime/parallel/worker.js +4 -2
- package/lib/runtime/parallel/worker.js.map +1 -1
- package/lib/runtime/test-case-runner.d.ts +2 -1
- package/lib/runtime/test-case-runner.js +8 -5
- package/lib/runtime/test-case-runner.js.map +1 -1
- package/lib/runtime/{parallel/types.d.ts → types.d.ts} +12 -1
- package/lib/runtime/types.js.map +1 -0
- package/lib/transpilers/esbuild-transpiler.d.ts +1 -1
- package/lib/transpilers/esbuild-transpiler.js.map +1 -1
- package/lib/transpilers/esbuild.js +18 -1
- package/lib/transpilers/esbuild.js.map +1 -1
- package/lib/transpilers/esm/esbuild-transpiler-cjs.js +2174 -0
- package/lib/transpilers/esm/esbuild-transpiler.mjs +19 -0
- package/lib/transpilers/esm/esbuild.mjs +141 -0
- package/lib/transpilers/esm/esmbuild-transpiler.d.ts +4 -0
- package/lib/transpilers/esm/esmbuild-transpiler.js +19 -0
- package/lib/transpilers/esm/esmbuild-transpiler.js.map +1 -0
- package/lib/transpilers/esm/esmbuild.d.ts +12 -0
- package/lib/transpilers/esm/esmbuild.js +72 -0
- package/lib/transpilers/esm/esmbuild.js.map +1 -0
- package/lib/transpilers/esm/esmnode.js +8 -0
- package/lib/transpilers/esm/esmnode.js.map +1 -0
- package/lib/transpilers/esm/esmvue.js +29 -0
- package/lib/transpilers/esm/esmvue.js.map +1 -0
- package/lib/transpilers/esm/esnode-loader.mjs +9 -0
- package/lib/transpilers/esm/esvue-loader.mjs +9 -0
- package/lib/transpilers/esm/loader-utils.mjs +278 -0
- package/lib/transpilers/esm/tsnode-esm.js +25 -0
- package/lib/transpilers/esm/tsnode-esm.js.map +1 -0
- package/lib/{esnode.js → transpilers/esm/tsnode-exp-esm.js} +8 -6
- package/lib/transpilers/esm/tsnode-exp-esm.js.map +1 -0
- package/lib/transpilers/esm/tsnode-loader.mjs +107 -0
- package/lib/transpilers/esm/tsnode-service.mjs +40 -0
- package/lib/transpilers/esm/tsvue-esm.d.ts +1 -0
- package/lib/{tsvue.js → transpilers/esm/tsvue-esm.js} +8 -5
- package/lib/transpilers/esm/tsvue-esm.js.map +1 -0
- package/lib/transpilers/esm/tsvue-exp-esm.d.ts +1 -0
- package/lib/transpilers/esm/tsvue-exp-esm.js +40 -0
- package/lib/transpilers/esm/tsvue-exp-esm.js.map +1 -0
- package/lib/transpilers/esm/vue-jsdom-setup.mjs +19 -0
- package/lib/transpilers/esm/vue-loader.mjs +113 -0
- package/lib/transpilers/esm/vue-sfc-compiler.mjs +216 -0
- package/lib/transpilers/esnode.d.ts +1 -0
- package/lib/transpilers/esnode.js +8 -0
- package/lib/transpilers/esnode.js.map +1 -0
- package/lib/transpilers/esvue.d.ts +1 -0
- package/lib/transpilers/esvue.js +29 -0
- package/lib/transpilers/esvue.js.map +1 -0
- package/lib/transpilers/tsnode-exp.d.ts +1 -0
- package/lib/transpilers/tsnode-exp.js +19 -0
- package/lib/transpilers/tsnode-exp.js.map +1 -0
- package/lib/transpilers/tsnode.d.ts +1 -0
- package/lib/{tsnode.js → transpilers/tsnode.js} +5 -2
- package/lib/transpilers/tsnode.js.map +1 -0
- package/lib/transpilers/tsvue-exp.d.ts +1 -0
- package/lib/transpilers/tsvue-exp.js +40 -0
- package/lib/transpilers/tsvue-exp.js.map +1 -0
- package/lib/transpilers/tsvue.d.ts +1 -0
- package/lib/{esvue.js → transpilers/tsvue.js} +9 -7
- package/lib/transpilers/tsvue.js.map +1 -0
- package/lib/transpilers/vue-sfc/index.js.map +1 -1
- package/lib/tsconfig.node.tsbuildinfo +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 +38 -25
- package/lib/esnode.js.map +0 -1
- package/lib/esvue.js.map +0 -1
- package/lib/runtime/parallel/types.js.map +0 -1
- package/lib/tsnode.js.map +0 -1
- package/lib/tsvue.js.map +0 -1
- /package/lib/runtime/{parallel/types.js → types.js} +0 -0
- /package/lib/{esnode.d.ts → transpilers/esm/esmnode.d.ts} +0 -0
- /package/lib/{esvue.d.ts → transpilers/esm/esmvue.d.ts} +0 -0
- /package/lib/{tsnode.d.ts → transpilers/esm/tsnode-esm.d.ts} +0 -0
- /package/lib/{tsvue.d.ts → transpilers/esm/tsnode-exp-esm.d.ts} +0 -0
|
@@ -7,11 +7,13 @@ exports.loadConfiguration = void 0;
|
|
|
7
7
|
const locate_file_1 = require("@cucumber/cucumber/lib/configuration/locate_file");
|
|
8
8
|
const index_1 = require("@cucumber/cucumber/lib/configuration/index");
|
|
9
9
|
const validate_configuration_1 = require("@cucumber/cucumber/lib/configuration/validate_configuration");
|
|
10
|
-
const convert_configuration_1 = require("
|
|
10
|
+
const convert_configuration_1 = require("./convert-configuration");
|
|
11
11
|
const index_2 = require("@cucumber/cucumber/lib/environment/index");
|
|
12
12
|
const helpers_1 = require("../utils/helpers");
|
|
13
13
|
const gherkin_manager_1 = __importDefault(require("../gherkin/gherkin-manager"));
|
|
14
14
|
const ansis_1 = __importDefault(require("ansis"));
|
|
15
|
+
const console_1 = require("console");
|
|
16
|
+
const path_1 = require("path");
|
|
15
17
|
/**
|
|
16
18
|
* Load user-authored configuration to be used in a test run.
|
|
17
19
|
*
|
|
@@ -22,15 +24,20 @@ const ansis_1 = __importDefault(require("ansis"));
|
|
|
22
24
|
const loadConfiguration = async (options = {}, environment = {}) => {
|
|
23
25
|
const { cwd, env, logger } = (0, index_2.makeEnvironment)(environment);
|
|
24
26
|
const configFile = options.file ?? (0, locate_file_1.locateFile)(cwd);
|
|
27
|
+
let msg = '';
|
|
25
28
|
if (configFile) {
|
|
26
|
-
|
|
29
|
+
msg = `Loading configuration from "${configFile}".`;
|
|
27
30
|
}
|
|
28
31
|
else if (configFile === false) {
|
|
29
|
-
|
|
32
|
+
msg = 'Skipping configuration file resolution';
|
|
30
33
|
}
|
|
31
34
|
else {
|
|
32
|
-
|
|
35
|
+
msg = 'No configuration file found';
|
|
33
36
|
}
|
|
37
|
+
// log this to debug and console
|
|
38
|
+
const consoleLogger = new console_1.Console(environment.stdout, environment.stderr);
|
|
39
|
+
logger.debug(msg);
|
|
40
|
+
consoleLogger.log(ansis_1.default.cyanBright(msg));
|
|
34
41
|
const profileConfiguration = configFile ? await (0, index_1.fromFile)(logger, cwd, configFile, options.profiles) : {};
|
|
35
42
|
// if a feature was passed in on command line it's added
|
|
36
43
|
// to the provided configuration as paths. We need to clear
|
|
@@ -41,20 +48,73 @@ const loadConfiguration = async (options = {}, environment = {}) => {
|
|
|
41
48
|
profileConfiguration.paths = [];
|
|
42
49
|
}
|
|
43
50
|
const original = (0, index_1.mergeConfigurations)(index_1.DEFAULT_CONFIGURATION, profileConfiguration, (0, index_1.parseConfiguration)(logger, 'Provided', options.provided));
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
// Get the experimental decorators setting
|
|
52
|
+
if (original.experimentalDecorators === undefined) {
|
|
53
|
+
original.experimentalDecorators = false;
|
|
54
|
+
}
|
|
55
|
+
const experimentalDecorators = original.experimentalDecorators;
|
|
56
|
+
global.experimentalDecorators = experimentalDecorators;
|
|
57
|
+
process.env.CUCUMBER_EXPERIMENTAL_DECORATORS = String(experimentalDecorators); // need to set here so can be accessed in mjs files
|
|
58
|
+
/**
|
|
59
|
+
* Ensures JSDOM environment is initialized before any test files are loaded.
|
|
60
|
+
* This adds the Vue-specific JSDOM setup to the beginning of Cucumber's require array,
|
|
61
|
+
* establishing the DOM environment needed for Vue component testing.
|
|
62
|
+
*
|
|
63
|
+
* Must run before test execution begins (mise en place for Vue testing).
|
|
64
|
+
*/
|
|
65
|
+
const initJsDom = () => {
|
|
66
|
+
// Use require.resolve to get the absolute path
|
|
67
|
+
try {
|
|
68
|
+
const setupPath = require.resolve('@lynxwall/cucumber-tsflow/lib/transpilers/esm/vue-jsdom-setup');
|
|
69
|
+
original.require.unshift(setupPath);
|
|
70
|
+
}
|
|
71
|
+
catch (e) {
|
|
72
|
+
// Fallback to relative path from lib directory
|
|
73
|
+
const setupPath = (0, path_1.join)(__dirname, '../../transpilers/esm/vue-jsdom-setup.mjs');
|
|
74
|
+
original.require.unshift(setupPath);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
if (original.transpiler) {
|
|
78
|
+
switch (original.transpiler) {
|
|
79
|
+
case 'es-vue':
|
|
80
|
+
original.requireModule.push('@lynxwall/cucumber-tsflow/lib/transpilers/esvue');
|
|
81
|
+
break;
|
|
82
|
+
case 'ts-vue': {
|
|
83
|
+
const module = experimentalDecorators ? 'tsvue-exp' : 'tsvue';
|
|
84
|
+
original.requireModule.push(`@lynxwall/cucumber-tsflow/lib/transpilers/${module}`);
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
case 'es-node': {
|
|
88
|
+
original.requireModule.push('@lynxwall/cucumber-tsflow/lib/transpilers/esnode');
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
case 'ts-node': {
|
|
92
|
+
const module = experimentalDecorators ? 'tsnode-exp' : 'tsnode';
|
|
93
|
+
original.requireModule.push(`@lynxwall/cucumber-tsflow/lib/transpilers/${module}`);
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
case 'ts-node-esm': {
|
|
97
|
+
original.loader.push(`@lynxwall/cucumber-tsflow/lib/transpilers/esm/tsnode-loader`); // per cucumber docs, we want to add this to the loader for esm
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
case 'es-node-esm': {
|
|
101
|
+
original.loader.push(`@lynxwall/cucumber-tsflow/lib/transpilers/esm/esnode-loader`); // per cucumber docs, we want to add this to the loader for esm
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
case 'ts-vue-esm': {
|
|
105
|
+
original.loader.push(`@lynxwall/cucumber-tsflow/lib/transpilers/esm/vue-loader`); // per cucumber docs, we want to add this to the loader for esm
|
|
106
|
+
initJsDom();
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
case 'es-vue-esm': {
|
|
110
|
+
original.loader.push(`@lynxwall/cucumber-tsflow/lib/transpilers/esm/esvue-loader`); // per cucumber docs, we want to add this to the loader for esm
|
|
111
|
+
initJsDom();
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
default:
|
|
115
|
+
// default sets nothing -- this allows users to not set the transpiler & use their own loaders/transpilers
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
58
118
|
}
|
|
59
119
|
// set the snippet syntax
|
|
60
120
|
if (!original.formatOptions.snippetSyntax) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-configuration.js","sourceRoot":"","sources":["../../src/api/load-configuration.ts"],"names":[],"mappings":";;;;;;AACA,kFAA8E;AAC9E,sEAMoD;AACpD,wGAAoG;AACpG,4FAAwF;AACxF,oEAA4F;AAE5F,8CAAkD;AAClD,iFAAwD;AACxD,kDAA0B;AAc1B;;;;;;GAMG;AACI,MAAM,iBAAiB,GAAG,KAAK,EACrC,UAAqC,EAAE,EACvC,cAA+B,EAAE,EACO,EAAE;IAC1C,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,IAAA,uBAAe,EAAC,WAAW,CAAC,CAAC;IAC1D,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,IAAI,IAAA,wBAAU,EAAC,GAAG,CAAC,CAAC;IACnD,IAAI,UAAU,EAAE,CAAC;QAChB,MAAM,CAAC,KAAK,CAAC,sCAAsC,UAAU,GAAG,CAAC,CAAC;IACnE,CAAC;SAAM,IAAI,UAAU,KAAK,KAAK,EAAE,CAAC;QACjC,MAAM,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAC;IACxD,CAAC;SAAM,CAAC;QACP,MAAM,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;IAC7C,CAAC;IACD,MAAM,oBAAoB,GA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AC,CAAC,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;QAC3D,CAAC;aAAM,CAAC;YACP,iDAAiD;YACjD,MAAM,CAAC,IAAI,CAAC,eAAK,CAAC,MAAM,CAAC,2CAA2C,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;YAC3F,MAAM,CAAC,IAAI,CAAC,eAAK,CAAC,MAAM,CAAC,8BAA8B,CAAC,CAAC,CAAC;QAC3D,CAAC;IACF,CAAC;IAED,2CAA2C;IAC3C,8BAA8B;IAC9B,IAAI,QAAQ,CAAC,cAAc,KAAK,IAAI,IAAI,QAAQ,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;QAC/E,QAAQ,CAAC,cAAc,GAAG,KAAK,CAAC;IACjC,CAAC;IACD,sDAAsD;IACtD,qDAAqD;IACrD,MAAM,CAAC,cAAc,GAAG,QAAQ,CAAC,cAAc,CAAC;IAEhD,IAAA,8CAAqB,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACxC,MAAM,QAAQ,GAAG,MAAM,IAAA,4CAAoB,EAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;IACnE,OAAO;QACN,gBAAgB,EAAE,QAAQ;QAC1B,gBAAgB,EAAE,QAAQ;KAC1B,CAAC;AACH,CAAC,CAAC;AAhHW,QAAA,iBAAiB,qBAgH5B","sourcesContent":["import { ILoadConfigurationOptions, IRunConfiguration } from '@cucumber/cucumber/lib/api/types';\r\nimport { locateFile } from '@cucumber/cucumber/lib/configuration/locate_file';\r\nimport {\r\n\tDEFAULT_CONFIGURATION,\r\n\tfromFile,\r\n\tIConfiguration,\r\n\tparseConfiguration,\r\n\tmergeConfigurations\r\n} from '@cucumber/cucumber/lib/configuration/index';\r\nimport { validateConfiguration } from '@cucumber/cucumber/lib/configuration/validate_configuration';\r\nimport { convertConfiguration } from '@cucumber/cucumber/lib/api/convert_configuration';\r\nimport { IRunEnvironment, makeEnvironment } from '@cucumber/cucumber/lib/environment/index';\r\nimport { ITsflowConfiguration } from '../cli/argv-parser';\r\nimport { hasStringValue } from '../utils/helpers';\r\nimport GherkinManager from '../gherkin/gherkin-manager';\r\nimport chalk from 'ansis';\r\nimport logger from '../utils/logger';\r\n\r\nexport interface ITsflowResolvedConfiguration {\r\n\t/**\r\n\t * The final flat configuration object resolved from the configuration file/profiles plus any extra provided.\r\n\t */\r\n\tuseConfiguration: ITsflowConfiguration;\r\n\t/**\r\n\t * The format that can be passed into `runCucumber`.\r\n\t */\r\n\trunConfiguration: IRunConfiguration;\r\n}\r\n\r\n/**\r\n * Load user-authored configuration to be used in a test run.\r\n *\r\n * @public\r\n * @param options - Coordinates required to find configuration.\r\n * @param environment - Project environment.\r\n */\r\nexport const loadConfiguration = async (\r\n\toptions: ILoadConfigurationOptions = {},\r\n\tenvironment: IRunEnvironment = {}\r\n): Promise<ITsflowResolvedConfiguration> => {\r\n\tconst { cwd, env, logger } = makeEnvironment(environment);\r\n\tconst configFile = options.file ?? locateFile(cwd);\r\n\tif (configFile) {\r\n\t\tlogger.debug(`Configuration will be loaded from \"${configFile}\"`);\r\n\t} else if (configFile === false) {\r\n\t\tlogger.debug('Skipping configuration file resolution');\r\n\t} else {\r\n\t\tlogger.debug('No configuration file found');\r\n\t}\r\n\tconst profileConfiguration = configFile ? await fromFile(logger, cwd, configFile, options.profiles) : {};\r\n\r\n\t// if a feature was passed in on command line it's added\r\n\t// to the provided configuration as paths. We need to clear\r\n\t// any paths from configuration so that only the feature passed\r\n\t// in is executed.\r\n\tconst paths = (options.provided as Partial<IConfiguration>).paths;\r\n\tif (paths && paths?.length > 0) {\r\n\t\tprofileConfiguration.paths = [];\r\n\t}\r\n\r\n\tconst original = mergeConfigurations(\r\n\t\tDEFAULT_CONFIGURATION,\r\n\t\tprofileConfiguration,\r\n\t\tparseConfiguration(logger, 'Provided', options.provided)\r\n\t) as ITsflowConfiguration;\r\n\r\n\tswitch (original.transpiler) {\r\n\t\tcase 'esvue':\r\n\t\t\toriginal.requireModule.push('@lynxwall/cucumber-tsflow/lib/esvue');\r\n\t\t\tbreak;\r\n\t\tcase 'tsvue':\r\n\t\t\toriginal.requireModule.push('@lynxwall/cucumber-tsflow/lib/tsvue');\r\n\t\t\tbreak;\r\n\t\tcase 'tsnode':\r\n\t\t\toriginal.requireModule.push('@lynxwall/cucumber-tsflow/lib/tsnode');\r\n\t\t\tbreak;\r\n\t\tdefault:\r\n\t\t\t// defaulting to esbuild\r\n\t\t\toriginal.requireModule.push('@lynxwall/cucumber-tsflow/lib/esnode');\r\n\t\t\tbreak;\r\n\t}\r\n\t// set the snippet syntax\r\n\tif (!original.formatOptions.snippetSyntax) {\r\n\t\toriginal.formatOptions.snippetSyntax = '@lynxwall/cucumber-tsflow/snippet';\r\n\t}\r\n\t// look for behave format\r\n\tfor (let idx = 0; idx < original.format.length; idx++) {\r\n\t\tif (typeof original.format[idx] === 'string') {\r\n\t\t\tconst formatItem = original.format[idx] as string;\r\n\t\t\tif (formatItem.startsWith('behave:')) {\r\n\t\t\t\toriginal.format[idx] = formatItem.replace('behave', '@lynxwall/cucumber-tsflow/behave');\r\n\t\t\t}\r\n\t\t} else if (original.format[idx].length > 0) {\r\n\t\t\tconst formatItem = original.format[idx][0] as string;\r\n\t\t\tif (formatItem.startsWith('behave')) {\r\n\t\t\t\tconst newVal = formatItem.replace('behave', '@lynxwall/cucumber-tsflow/behave');\r\n\t\t\t\toriginal.format[idx] = original.format[idx].length > 1 ? [newVal, original.format[idx][1]] : [newVal];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// look for junitbamboo format\r\n\tfor (let idx = 0; idx < original.format.length; idx++) {\r\n\t\tif (typeof original.format[idx] === 'string') {\r\n\t\t\tconst formatItem = original.format[idx] as string;\r\n\t\t\tif (formatItem.startsWith('junitbamboo:')) {\r\n\t\t\t\toriginal.format[idx] = formatItem.replace('junitbamboo', '@lynxwall/cucumber-tsflow/junitbamboo');\r\n\t\t\t}\r\n\t\t} else if (original.format[idx].length > 0) {\r\n\t\t\tconst formatItem = original.format[idx][0] as string;\r\n\t\t\tif (formatItem.startsWith('junitbamboo')) {\r\n\t\t\t\tconst newVal = formatItem.replace('junitbamboo', '@lynxwall/cucumber-tsflow/junitbamboo');\r\n\t\t\t\toriginal.format[idx] = original.format[idx].length > 1 ? [newVal, original.format[idx][1]] : [newVal];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// check to see if a debugFile was passed in\r\n\tif (hasStringValue(original.debugFile)) {\r\n\t\t// Initialize gherkin manager with path to feature files\r\n\t\tconst gherkin = new GherkinManager();\r\n\t\tawait gherkin.loadFeatures(original.paths);\r\n\t\tconst features = gherkin.findFeaturesByStepFile(original.debugFile);\r\n\t\tif (features.length > 0) {\r\n\t\t\toriginal.paths = [];\r\n\t\t\tfeatures.forEach(x => original.paths.push(x.featureFile));\r\n\t\t} else {\r\n\t\t\t// log a message if the feature path is not found\r\n\t\t\tlogger.warn(chalk.yellow(`\\nUnable to find feature for debugFile: ${original.debugFile}`));\r\n\t\t\tlogger.warn(chalk.yellow('All tests will be executed\\n'));\r\n\t\t}\r\n\t}\r\n\r\n\t// check to see if enable-vue-style was set\r\n\t// if not, default it to false\r\n\tif (original.enableVueStyle === null || original.enableVueStyle === undefined) {\r\n\t\toriginal.enableVueStyle = false;\r\n\t}\r\n\t// set our global parameter used by the Vue transpiler\r\n\t// to determine if Vue Style Blocks should be enabled\r\n\tglobal.enableVueStyle = original.enableVueStyle;\r\n\r\n\tvalidateConfiguration(original, logger);\r\n\tconst runnable = await convertConfiguration(logger, original, env);\r\n\treturn {\r\n\t\tuseConfiguration: original,\r\n\t\trunConfiguration: runnable\r\n\t};\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"load-configuration.js","sourceRoot":"","sources":["../../src/api/load-configuration.ts"],"names":[],"mappings":";;;;;;AACA,kFAA8E;AAC9E,sEAMoD;AACpD,wGAAoG;AACpG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AM,QAAQ,GAAG,OAAO,CAAC,sBAAsB,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QACpE,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzB,QAAQ,CAAC,KAAK,GAAG,EAAE,CAAC;YACpB,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;QAC3D,CAAC;aAAM,CAAC;YACP,iDAAiD;YACjD,MAAM,CAAC,IAAI,CAAC,eAAK,CAAC,MAAM,CAAC,2CAA2C,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;YAC3F,MAAM,CAAC,IAAI,CAAC,eAAK,CAAC,MAAM,CAAC,8BAA8B,CAAC,CAAC,CAAC;QAC3D,CAAC;IACF,CAAC;IAED,2CAA2C;IAC3C,8BAA8B;IAC9B,IAAI,QAAQ,CAAC,cAAc,KAAK,IAAI,IAAI,QAAQ,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;QAC/E,QAAQ,CAAC,cAAc,GAAG,KAAK,CAAC;IACjC,CAAC;IACD,sDAAsD;IACtD,qDAAqD;IACrD,MAAM,CAAC,cAAc,GAAG,QAAQ,CAAC,cAAc,CAAC;IAEhD,IAAA,8CAAqB,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACxC,MAAM,QAAQ,GAAG,MAAM,IAAA,4CAAoB,EAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;IAEnE,OAAO;QACN,gBAAgB,EAAE,QAAQ;QAC1B,gBAAgB,EAAE,QAAQ;KAC1B,CAAC;AACH,CAAC,CAAC;AA9KW,QAAA,iBAAiB,qBA8K5B","sourcesContent":["import { ILoadConfigurationOptions } from '@cucumber/cucumber/lib/api/types';\r\nimport { locateFile } from '@cucumber/cucumber/lib/configuration/locate_file';\r\nimport {\r\n\tDEFAULT_CONFIGURATION,\r\n\tfromFile,\r\n\tIConfiguration,\r\n\tparseConfiguration,\r\n\tmergeConfigurations\r\n} from '@cucumber/cucumber/lib/configuration/index';\r\nimport { validateConfiguration } from '@cucumber/cucumber/lib/configuration/validate_configuration';\r\nimport { convertConfiguration } from './convert-configuration';\r\nimport { IRunEnvironment, makeEnvironment } from '@cucumber/cucumber/lib/environment/index';\r\nimport { ITsflowConfiguration } from '../cli/argv-parser';\r\nimport { hasStringValue } from '../utils/helpers';\r\nimport GherkinManager from '../gherkin/gherkin-manager';\r\nimport ansis from 'ansis';\r\nimport { ITsFlowRunConfiguration } from '../runtime/types';\r\nimport { Console } from 'console';\r\nimport { join } from 'path';\r\n\r\nexport interface ITsflowResolvedConfiguration {\r\n\t/**\r\n\t * The final flat configuration object resolved from the configuration file/profiles plus any extra provided.\r\n\t */\r\n\tuseConfiguration: ITsflowConfiguration;\r\n\t/**\r\n\t * The format that can be passed into `runCucumber`.\r\n\t */\r\n\trunConfiguration: ITsFlowRunConfiguration;\r\n}\r\n\r\n/**\r\n * Load user-authored configuration to be used in a test run.\r\n *\r\n * @public\r\n * @param options - Coordinates required to find configuration.\r\n * @param environment - Project environment.\r\n */\r\nexport const loadConfiguration = async (\r\n\toptions: ILoadConfigurationOptions = {},\r\n\tenvironment: IRunEnvironment = {}\r\n): Promise<ITsflowResolvedConfiguration> => {\r\n\tconst { cwd, env, logger } = makeEnvironment(environment);\r\n\tconst configFile = options.file ?? locateFile(cwd);\r\n\tlet msg = '';\r\n\tif (configFile) {\r\n\t\tmsg = `Loading configuration from \"${configFile}\".`;\r\n\t} else if (configFile === false) {\r\n\t\tmsg = 'Skipping configuration file resolution';\r\n\t} else {\r\n\t\tmsg = 'No configuration file found';\r\n\t}\r\n\t// log this to debug and console\r\n\tconst consoleLogger = new Console(environment.stdout as any, environment.stderr);\r\n\tlogger.debug(msg);\r\n\tconsoleLogger.log(ansis.cyanBright(msg));\r\n\r\n\tconst profileConfiguration = configFile ? await fromFile(logger, cwd, configFile, options.profiles) : {};\r\n\r\n\t// if a feature was passed in on command line it's added\r\n\t// to the provided configuration as paths. We need to clear\r\n\t// any paths from configuration so that only the feature passed\r\n\t// in is executed.\r\n\tconst paths = (options.provided as Partial<IConfiguration>).paths;\r\n\tif (paths && paths?.length > 0) {\r\n\t\tprofileConfiguration.paths = [];\r\n\t}\r\n\r\n\tconst original = mergeConfigurations(\r\n\t\tDEFAULT_CONFIGURATION,\r\n\t\tprofileConfiguration,\r\n\t\tparseConfiguration(logger, 'Provided', options.provided)\r\n\t) as ITsflowConfiguration;\r\n\r\n\t// Get the experimental decorators setting\r\n\tif (original.experimentalDecorators === undefined) {\r\n\t\toriginal.experimentalDecorators = false;\r\n\t}\r\n\r\n\tconst experimentalDecorators = original.experimentalDecorators;\r\n\tglobal.experimentalDecorators = experimentalDecorators;\r\n\tprocess.env.CUCUMBER_EXPERIMENTAL_DECORATORS = String(experimentalDecorators); // need to set here so can be accessed in mjs files\r\n\r\n\t/**\r\n\t * Ensures JSDOM environment is initialized before any test files are loaded.\r\n\t * This adds the Vue-specific JSDOM setup to the beginning of Cucumber's require array,\r\n\t * establishing the DOM environment needed for Vue component testing.\r\n\t *\r\n\t * Must run before test execution begins (mise en place for Vue testing).\r\n\t */\r\n\tconst initJsDom = () => {\r\n\t\t// Use require.resolve to get the absolute path\r\n\t\ttry {\r\n\t\t\tconst setupPath = require.resolve('@lynxwall/cucumber-tsflow/lib/transpilers/esm/vue-jsdom-setup');\r\n\t\t\toriginal.require.unshift(setupPath);\r\n\t\t} catch (e) {\r\n\t\t\t// Fallback to relative path from lib directory\r\n\t\t\tconst setupPath = join(__dirname, '../../transpilers/esm/vue-jsdom-setup.mjs');\r\n\t\t\toriginal.require.unshift(setupPath);\r\n\t\t}\r\n\t};\r\n\r\n\tif (original.transpiler) {\r\n\t\tswitch (original.transpiler) {\r\n\t\t\tcase 'es-vue':\r\n\t\t\t\toriginal.requireModule.push('@lynxwall/cucumber-tsflow/lib/transpilers/esvue');\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'ts-vue': {\r\n\t\t\t\tconst module = experimentalDecorators ? 'tsvue-exp' : 'tsvue';\r\n\t\t\t\toriginal.requireModule.push(`@lynxwall/cucumber-tsflow/lib/transpilers/${module}`);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tcase 'es-node': {\r\n\t\t\t\toriginal.requireModule.push('@lynxwall/cucumber-tsflow/lib/transpilers/esnode');\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tcase 'ts-node': {\r\n\t\t\t\tconst module = experimentalDecorators ? 'tsnode-exp' : 'tsnode';\r\n\t\t\t\toriginal.requireModule.push(`@lynxwall/cucumber-tsflow/lib/transpilers/${module}`);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tcase 'ts-node-esm': {\r\n\t\t\t\toriginal.loader.push(`@lynxwall/cucumber-tsflow/lib/transpilers/esm/tsnode-loader`); // per cucumber docs, we want to add this to the loader for esm\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tcase 'es-node-esm': {\r\n\t\t\t\toriginal.loader.push(`@lynxwall/cucumber-tsflow/lib/transpilers/esm/esnode-loader`); // per cucumber docs, we want to add this to the loader for esm\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tcase 'ts-vue-esm': {\r\n\t\t\t\toriginal.loader.push(`@lynxwall/cucumber-tsflow/lib/transpilers/esm/vue-loader`); // per cucumber docs, we want to add this to the loader for esm\r\n\t\t\t\tinitJsDom();\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tcase 'es-vue-esm': {\r\n\t\t\t\toriginal.loader.push(`@lynxwall/cucumber-tsflow/lib/transpilers/esm/esvue-loader`); // per cucumber docs, we want to add this to the loader for esm\r\n\t\t\t\tinitJsDom();\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tdefault:\r\n\t\t\t\t// default sets nothing -- this allows users to not set the transpiler & use their own loaders/transpilers\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\t// set the snippet syntax\r\n\tif (!original.formatOptions.snippetSyntax) {\r\n\t\toriginal.formatOptions.snippetSyntax = '@lynxwall/cucumber-tsflow/snippet';\r\n\t}\r\n\t// look for behave format\r\n\tfor (let idx = 0; idx < original.format.length; idx++) {\r\n\t\tif (typeof original.format[idx] === 'string') {\r\n\t\t\tconst formatItem = original.format[idx] as string;\r\n\t\t\tif (formatItem.startsWith('behave:')) {\r\n\t\t\t\toriginal.format[idx] = formatItem.replace('behave', '@lynxwall/cucumber-tsflow/behave');\r\n\t\t\t}\r\n\t\t} else if (original.format[idx].length > 0) {\r\n\t\t\tconst formatItem = original.format[idx][0] as string;\r\n\t\t\tif (formatItem.startsWith('behave')) {\r\n\t\t\t\tconst newVal = formatItem.replace('behave', '@lynxwall/cucumber-tsflow/behave');\r\n\t\t\t\toriginal.format[idx] = original.format[idx].length > 1 ? [newVal, original.format[idx][1]] : [newVal];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// look for junitbamboo format\r\n\tfor (let idx = 0; idx < original.format.length; idx++) {\r\n\t\tif (typeof original.format[idx] === 'string') {\r\n\t\t\tconst formatItem = original.format[idx] as string;\r\n\t\t\tif (formatItem.startsWith('junitbamboo:')) {\r\n\t\t\t\toriginal.format[idx] = formatItem.replace('junitbamboo', '@lynxwall/cucumber-tsflow/junitbamboo');\r\n\t\t\t}\r\n\t\t} else if (original.format[idx].length > 0) {\r\n\t\t\tconst formatItem = original.format[idx][0] as string;\r\n\t\t\tif (formatItem.startsWith('junitbamboo')) {\r\n\t\t\t\tconst newVal = formatItem.replace('junitbamboo', '@lynxwall/cucumber-tsflow/junitbamboo');\r\n\t\t\t\toriginal.format[idx] = original.format[idx].length > 1 ? [newVal, original.format[idx][1]] : [newVal];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// check to see if a debugFile was passed in\r\n\tif (hasStringValue(original.debugFile)) {\r\n\t\t// Initialize gherkin manager with path to feature files\r\n\t\tconst gherkin = new GherkinManager();\r\n\t\tawait gherkin.loadFeatures(original.paths);\r\n\t\tconst features = gherkin.findFeaturesByStepFile(original.debugFile);\r\n\t\tif (features.length > 0) {\r\n\t\t\toriginal.paths = [];\r\n\t\t\tfeatures.forEach(x => original.paths.push(x.featureFile));\r\n\t\t} else {\r\n\t\t\t// log a message if the feature path is not found\r\n\t\t\tlogger.warn(ansis.yellow(`\\nUnable to find feature for debugFile: ${original.debugFile}`));\r\n\t\t\tlogger.warn(ansis.yellow('All tests will be executed\\n'));\r\n\t\t}\r\n\t}\r\n\r\n\t// check to see if enable-vue-style was set\r\n\t// if not, default it to false\r\n\tif (original.enableVueStyle === null || original.enableVueStyle === undefined) {\r\n\t\toriginal.enableVueStyle = false;\r\n\t}\r\n\t// set our global parameter used by the Vue transpiler\r\n\t// to determine if Vue Style Blocks should be enabled\r\n\tglobal.enableVueStyle = original.enableVueStyle;\r\n\r\n\tvalidateConfiguration(original, logger);\r\n\tconst runnable = await convertConfiguration(logger, original, env);\r\n\r\n\treturn {\r\n\t\tuseConfiguration: original,\r\n\t\trunConfiguration: runnable\r\n\t};\r\n};\r\n"]}
|
|
@@ -2,6 +2,10 @@ import { Envelope } from '@cucumber/messages';
|
|
|
2
2
|
import { IRunOptions, IRunResult } from '@cucumber/cucumber/lib/api/types';
|
|
3
3
|
import { IRunEnvironment } from '@cucumber/cucumber/lib/environment/index';
|
|
4
4
|
import 'polyfill-symbol-metadata';
|
|
5
|
+
import { ITsFlowRunOptionsRuntime } from '../runtime/types';
|
|
6
|
+
export interface ITsFlowRunOptions extends IRunOptions {
|
|
7
|
+
runtime: ITsFlowRunOptionsRuntime;
|
|
8
|
+
}
|
|
5
9
|
/**
|
|
6
10
|
* Execute a Cucumber test run.
|
|
7
11
|
*
|
|
@@ -13,4 +17,4 @@ import 'polyfill-symbol-metadata';
|
|
|
13
17
|
* @param environment - Project environment.
|
|
14
18
|
* @param onMessage - Callback fired each time Cucumber emits a message.
|
|
15
19
|
*/
|
|
16
|
-
export declare function runCucumber(options:
|
|
20
|
+
export declare function runCucumber(options: ITsFlowRunOptions, environment?: IRunEnvironment, onMessage?: (message: Envelope) => void): Promise<IRunResult>;
|
package/lib/api/run-cucumber.js
CHANGED
|
@@ -18,6 +18,8 @@ const version_1 = require("../version");
|
|
|
18
18
|
const plugins_1 = require("@cucumber/cucumber/lib/api/plugins");
|
|
19
19
|
require("polyfill-symbol-metadata");
|
|
20
20
|
const binding_registry_1 = require("../bindings/binding-registry");
|
|
21
|
+
const console_1 = require("console");
|
|
22
|
+
const ansis_1 = __importDefault(require("ansis"));
|
|
21
23
|
/**
|
|
22
24
|
* Execute a Cucumber test run.
|
|
23
25
|
*
|
|
@@ -36,6 +38,16 @@ async function runCucumber(options, environment = {}, onMessage) {
|
|
|
36
38
|
Working directory: ${cwd}
|
|
37
39
|
Running from: ${__dirname}
|
|
38
40
|
`);
|
|
41
|
+
const consoleLogger = new console_1.Console(environment.stdout, environment.stderr);
|
|
42
|
+
if (options.runtime.experimentalDecorators) {
|
|
43
|
+
consoleLogger.info(ansis_1.default.yellowBright('Using Experimental Decorators.'));
|
|
44
|
+
}
|
|
45
|
+
if (options.runtime.parallel > 0) {
|
|
46
|
+
consoleLogger.info(ansis_1.default.cyanBright(`Running Cucumber-TsFlow in Parallel with ${options.runtime.parallel} worker(s).\n`));
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
consoleLogger.info(ansis_1.default.cyanBright('Running Cucumber-TsFlow in Serial mode.\n'));
|
|
50
|
+
}
|
|
39
51
|
const newId = messages_1.IdGenerator.uuid();
|
|
40
52
|
const supportCoordinates = 'originalCoordinates' in options.support
|
|
41
53
|
? options.support.originalCoordinates
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-cucumber.js","sourceRoot":"","sources":["../../src/api/run-cucumber.ts"],"names":[],"mappings":";;;;;AA8BA,kCAiJC;AA/KD,iDAAuE;AACvE,mCAAsC;AAEtC,gEAA8F;AA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B;QAChB,kBAAkB;QAClB,KAAK;KACL,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,IAAA,0BAAW,EAAC;QACjC,WAAW;QACX,MAAM;QACN,gBAAgB;QAChB,cAAc,EAAE,eAAe;QAC/B,KAAK;QACL,kBAAkB;QAClB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,WAAW,EAAE,OAAO,CAAC,OAAO;KAC5B,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,EAAE,CAAC;IACpC,MAAM,aAAa,CAAC,OAAO,EAAE,CAAC;IAC9B,MAAM,iBAAiB,EAAE,CAAC;IAE1B,OAAO;QACN,OAAO,EAAE,OAAO,IAAI,CAAC,oBAAoB;QACzC,OAAO,EAAE,kBAAkB;KAC3B,CAAC;AACH,CAAC","sourcesContent":["import { Envelope, IdGenerator, ParseError } from '@cucumber/messages';\r\nimport { EventEmitter } from 'events';\r\nimport { EventDataCollector } from '@cucumber/cucumber/lib/formatter/helpers/index';\r\nimport { emitMetaMessage, emitSupportCodeMessages } from '@cucumber/cucumber/lib/cli/helpers';\r\nimport { IRunOptions, IRunResult } from '@cucumber/cucumber/lib/api/types';\r\nimport { resolvePaths } from '@cucumber/cucumber/lib/paths/index';\r\nimport { SupportCodeLibrary } from '@cucumber/cucumber/lib/support_code_library_builder/types';\r\nimport { makeRuntime } from '../runtime/make-runtime';\r\nimport { initializeFormatters } from '@cucumber/cucumber/lib/api/formatters';\r\nimport { getSupportCodeLibrary } from '@cucumber/cucumber/lib/api/support';\r\nimport { IRunEnvironment, makeEnvironment } from '@cucumber/cucumber/lib/environment/index';\r\nimport { getPicklesAndErrors } from '@cucumber/cucumber/lib/api/gherkin';\r\nimport MessageCollector from '../runtime/message-collector';\r\nimport { version } from '../version';\r\nimport { initializeForRunCucumber } from '@cucumber/cucumber/lib/api/plugins';\r\nimport { IFilterablePickle } from '@cucumber/cucumber/lib/filter/index';\r\nimport 'polyfill-symbol-metadata';\r\nimport { BindingRegistry } from '../bindings/binding-registry';\r\n\r\n/**\r\n * Execute a Cucumber test run.\r\n *\r\n * Extended from cucumber.js so that we can use our own implementation\r\n * of makeRuntime\r\n *\r\n * @public\r\n * @param options - Configuration loaded from `loadConfiguration`.\r\n * @param environment - Project environment.\r\n * @param onMessage - Callback fired each time Cucumber emits a message.\r\n */\r\nexport async function runCucumber(\r\n\toptions: IRunOptions,\r\n\tenvironment: IRunEnvironment = {},\r\n\tonMessage?: (message: Envelope) => void\r\n): Promise<IRunResult> {\r\n\tconst mergedEnvironment = makeEnvironment(environment);\r\n\tconst { cwd, stdout, stderr, env, logger } = mergedEnvironment;\r\n\r\n\tlogger.debug(`Running cucumber-tsflow ${version}\r\nWorking directory: ${cwd}\r\nRunning from: ${__dirname}\r\n`);\r\n\r\n\tconst newId = IdGenerator.uuid();\r\n\r\n\tconst supportCoordinates =\r\n\t\t'originalCoordinates' in options.support\r\n\t\t\t? options.support.originalCoordinates\r\n\t\t\t: Object.assign(\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\trequireModules: [],\r\n\t\t\t\t\t\trequirePaths: [],\r\n\t\t\t\t\t\tloaders: [],\r\n\t\t\t\t\t\timportPaths: []\r\n\t\t\t\t\t},\r\n\t\t\t\t\toptions.support\r\n\t\t\t\t);\r\n\r\n\tconst pluginManager = await initializeForRunCucumber(\r\n\t\t{\r\n\t\t\t...options,\r\n\t\t\tsupport: supportCoordinates\r\n\t\t},\r\n\t\tmergedEnvironment\r\n\t);\r\n\r\n\tconst resolvedPaths = await resolvePaths(logger, cwd, options.sources, supportCoordinates);\r\n\tpluginManager.emit('paths:resolve', resolvedPaths);\r\n\tconst { sourcePaths, requirePaths, importPaths } = resolvedPaths;\r\n\r\n\t/**\r\n\t * The support code library contains all of the hook and step definitions.\r\n\t * These are loaded into the library when calling getSupportCodeLibrary,\r\n\t * which loads all of the step definitions using require or import.\r\n\t */\r\n\tlet supportCodeLibrary =\r\n\t\t'originalCoordinates' in options.support\r\n\t\t\t? (options.support as SupportCodeLibrary)\r\n\t\t\t: await getSupportCodeLibrary({\r\n\t\t\t\t\tlogger,\r\n\t\t\t\t\tcwd,\r\n\t\t\t\t\tnewId,\r\n\t\t\t\t\trequirePaths,\r\n\t\t\t\t\trequireModules: supportCoordinates.requireModules,\r\n\t\t\t\t\timportPaths,\r\n\t\t\t\t\tloaders: supportCoordinates.loaders\r\n\t\t\t\t});\r\n\r\n\t// Set support to the updated step and hook definitions\r\n\t// in the supportCodeLibrary. We also need to initialize originalCoordinates\r\n\t// to support parallel execution.\r\n\tsupportCodeLibrary = BindingRegistry.instance.updateSupportCodeLibrary(supportCodeLibrary);\r\n\tsupportCodeLibrary = { ...supportCodeLibrary, ...{ originalCoordinates: supportCoordinates } };\r\n\toptions.support = supportCodeLibrary;\r\n\r\n\tconst eventBroadcaster = new EventEmitter();\r\n\tif (onMessage) {\r\n\t\teventBroadcaster.on('envelope', onMessage);\r\n\t}\r\n\teventBroadcaster.on('envelope', value => pluginManager.emit('message', value));\r\n\r\n\t// create a global instance of the message collector and bind it\r\n\t// to the event broadcaster. This is used by cucumber and for tests\r\n\t// that are not running in parallel.\r\n\tglobal.messageCollector = new MessageCollector(eventBroadcaster);\r\n\r\n\t// cast the MessageCollector to an EventDataCollector\r\n\tconst eventDataCollector = global.messageCollector as unknown as EventDataCollector;\r\n\r\n\tlet formatterStreamError = false;\r\n\tconst cleanupFormatters = await initializeFormatters({\r\n\t\tenv,\r\n\t\tcwd,\r\n\t\tstdout,\r\n\t\tstderr,\r\n\t\tlogger,\r\n\t\tonStreamError: () => (formatterStreamError = true),\r\n\t\teventBroadcaster,\r\n\t\teventDataCollector: eventDataCollector,\r\n\t\tconfiguration: options.formats,\r\n\t\tsupportCodeLibrary,\r\n\t\tpluginManager\r\n\t});\r\n\tawait emitMetaMessage(eventBroadcaster, env);\r\n\r\n\tlet filteredPickles: ReadonlyArray<IFilterablePickle> = [];\r\n\tlet parseErrors: ParseError[] = [];\r\n\tif (sourcePaths.length > 0) {\r\n\t\tconst gherkinResult = await getPicklesAndErrors({\r\n\t\t\tnewId,\r\n\t\t\tcwd,\r\n\t\t\tsourcePaths,\r\n\t\t\tcoordinates: options.sources,\r\n\t\t\tonEnvelope: envelope => eventBroadcaster.emit('envelope', envelope)\r\n\t\t});\r\n\t\tfilteredPickles = await pluginManager.transform('pickles:filter', gherkinResult.filterablePickles);\r\n\t\tfilteredPickles = await pluginManager.transform('pickles:order', filteredPickles);\r\n\t\tparseErrors = gherkinResult.parseErrors;\r\n\t}\r\n\tif (parseErrors.length) {\r\n\t\tparseErrors.forEach(parseError => {\r\n\t\t\tlogger.error(`Parse error in \"${parseError.source.uri}\" ${parseError.message}`);\r\n\t\t});\r\n\t\tawait cleanupFormatters();\r\n\t\tawait pluginManager.cleanup();\r\n\t\treturn {\r\n\t\t\tsuccess: false,\r\n\t\t\tsupport: supportCodeLibrary\r\n\t\t};\r\n\t}\r\n\r\n\temitSupportCodeMessages({\r\n\t\teventBroadcaster,\r\n\t\tsupportCodeLibrary,\r\n\t\tnewId\r\n\t});\r\n\r\n\tconst runtime = await makeRuntime({\r\n\t\tenvironment,\r\n\t\tlogger,\r\n\t\teventBroadcaster,\r\n\t\tsourcedPickles: filteredPickles,\r\n\t\tnewId,\r\n\t\tsupportCodeLibrary,\r\n\t\toptions: options.runtime,\r\n\t\tcoordinates: options.sources\r\n\t});\r\n\tconst success = await runtime.run();\r\n\tawait pluginManager.cleanup();\r\n\tawait cleanupFormatters();\r\n\r\n\treturn {\r\n\t\tsuccess: success && !formatterStreamError,\r\n\t\tsupport: supportCodeLibrary\r\n\t};\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"run-cucumber.js","sourceRoot":"","sources":["../../src/api/run-cucumber.ts"],"names":[],"mappings":";;;;;AAqCA,kCA4JC;AAjMD,iDAAuE;AACvE,mCAAsC;AAEtC,gEAA8F;AAE9F,8DAAkE;AAElE,0DAAsD;AACtD,sEAA6E;AAC7E,gEAA2E;AAC3E,oEA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C,eAAe,EAAE,eAAe,CAAC,CAAC;QAClF,WAAW,GAAG,aAAa,CAAC,WAAW,CAAC;IACzC,CAAC;IACD,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC;QACxB,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;YAChC,MAAM,CAAC,KAAK,CAAC,mBAAmB,UAAU,CAAC,MAAM,CAAC,GAAG,KAAK,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;QACjF,CAAC,CAAC,CAAC;QACH,MAAM,iBAAiB,EAAE,CAAC;QAC1B,MAAM,aAAa,CAAC,OAAO,EAAE,CAAC;QAC9B,OAAO;YACN,OAAO,EAAE,KAAK;YACd,OAAO,EAAE,kBAAkB;SAC3B,CAAC;IACH,CAAC;IAED,IAAA,iCAAuB,EAAC;QACvB,gBAAgB;QAChB,kBAAkB;QAClB,KAAK;KACL,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,IAAA,0BAAW,EAAC;QACjC,WAAW;QACX,MAAM;QACN,gBAAgB;QAChB,cAAc,EAAE,eAAe;QAC/B,KAAK;QACL,kBAAkB;QAClB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,WAAW,EAAE,OAAO,CAAC,OAAO;KAC5B,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,EAAE,CAAC;IACpC,MAAM,aAAa,CAAC,OAAO,EAAE,CAAC;IAC9B,MAAM,iBAAiB,EAAE,CAAC;IAE1B,OAAO;QACN,OAAO,EAAE,OAAO,IAAI,CAAC,oBAAoB;QACzC,OAAO,EAAE,kBAAkB;KAC3B,CAAC;AACH,CAAC","sourcesContent":["import { Envelope, IdGenerator, ParseError } from '@cucumber/messages';\r\nimport { EventEmitter } from 'events';\r\nimport { EventDataCollector } from '@cucumber/cucumber/lib/formatter/helpers/index';\r\nimport { emitMetaMessage, emitSupportCodeMessages } from '@cucumber/cucumber/lib/cli/helpers';\r\nimport { IRunOptions, IRunResult } from '@cucumber/cucumber/lib/api/types';\r\nimport { resolvePaths } from '@cucumber/cucumber/lib/paths/index';\r\nimport { SupportCodeLibrary } from '@cucumber/cucumber/lib/support_code_library_builder/types';\r\nimport { makeRuntime } from '../runtime/make-runtime';\r\nimport { initializeFormatters } from '@cucumber/cucumber/lib/api/formatters';\r\nimport { getSupportCodeLibrary } from '@cucumber/cucumber/lib/api/support';\r\nimport { IRunEnvironment, makeEnvironment } from '@cucumber/cucumber/lib/environment/index';\r\nimport { getPicklesAndErrors } from '@cucumber/cucumber/lib/api/gherkin';\r\nimport MessageCollector from '../runtime/message-collector';\r\nimport { version } from '../version';\r\nimport { initializeForRunCucumber } from '@cucumber/cucumber/lib/api/plugins';\r\nimport { IFilterablePickle } from '@cucumber/cucumber/lib/filter/index';\r\nimport 'polyfill-symbol-metadata';\r\nimport { BindingRegistry } from '../bindings/binding-registry';\r\nimport { ITsFlowRunOptionsRuntime } from '../runtime/types';\r\nimport { Console } from 'console';\r\nimport ansis from 'ansis';\r\n\r\nexport interface ITsFlowRunOptions extends IRunOptions {\r\n\truntime: ITsFlowRunOptionsRuntime;\r\n}\r\n\r\n/**\r\n * Execute a Cucumber test run.\r\n *\r\n * Extended from cucumber.js so that we can use our own implementation\r\n * of makeRuntime\r\n *\r\n * @public\r\n * @param options - Configuration loaded from `loadConfiguration`.\r\n * @param environment - Project environment.\r\n * @param onMessage - Callback fired each time Cucumber emits a message.\r\n */\r\nexport async function runCucumber(\r\n\toptions: ITsFlowRunOptions,\r\n\tenvironment: IRunEnvironment = {},\r\n\tonMessage?: (message: Envelope) => void\r\n): Promise<IRunResult> {\r\n\tconst mergedEnvironment = makeEnvironment(environment);\r\n\tconst { cwd, stdout, stderr, env, logger } = mergedEnvironment;\r\n\r\n\tlogger.debug(`Running cucumber-tsflow ${version}\r\nWorking directory: ${cwd}\r\nRunning from: ${__dirname}\r\n`);\r\n\tconst consoleLogger = new Console(environment.stdout as any, environment.stderr);\r\n\tif (options.runtime.experimentalDecorators) {\r\n\t\tconsoleLogger.info(ansis.yellowBright('Using Experimental Decorators.'));\r\n\t}\r\n\tif (options.runtime.parallel > 0) {\r\n\t\tconsoleLogger.info(\r\n\t\t\tansis.cyanBright(`Running Cucumber-TsFlow in Parallel with ${options.runtime.parallel} worker(s).\\n`)\r\n\t\t);\r\n\t} else {\r\n\t\tconsoleLogger.info(ansis.cyanBright('Running Cucumber-TsFlow in Serial mode.\\n'));\r\n\t}\r\n\r\n\tconst newId = IdGenerator.uuid();\r\n\r\n\tconst supportCoordinates =\r\n\t\t'originalCoordinates' in options.support\r\n\t\t\t? options.support.originalCoordinates\r\n\t\t\t: Object.assign(\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\trequireModules: [],\r\n\t\t\t\t\t\trequirePaths: [],\r\n\t\t\t\t\t\tloaders: [],\r\n\t\t\t\t\t\timportPaths: []\r\n\t\t\t\t\t},\r\n\t\t\t\t\toptions.support\r\n\t\t\t\t);\r\n\r\n\tconst pluginManager = await initializeForRunCucumber(\r\n\t\t{\r\n\t\t\t...options,\r\n\t\t\tsupport: supportCoordinates\r\n\t\t},\r\n\t\tmergedEnvironment\r\n\t);\r\n\r\n\tconst resolvedPaths = await resolvePaths(logger, cwd, options.sources, supportCoordinates);\r\n\tpluginManager.emit('paths:resolve', resolvedPaths);\r\n\tconst { sourcePaths, requirePaths, importPaths } = resolvedPaths;\r\n\r\n\t/**\r\n\t * The support code library contains all of the hook and step definitions.\r\n\t * These are loaded into the library when calling getSupportCodeLibrary,\r\n\t * which loads all of the step definitions using require or import.\r\n\t */\r\n\tlet supportCodeLibrary =\r\n\t\t'originalCoordinates' in options.support\r\n\t\t\t? (options.support as SupportCodeLibrary)\r\n\t\t\t: await getSupportCodeLibrary({\r\n\t\t\t\t\tlogger,\r\n\t\t\t\t\tcwd,\r\n\t\t\t\t\tnewId,\r\n\t\t\t\t\trequirePaths,\r\n\t\t\t\t\trequireModules: supportCoordinates.requireModules,\r\n\t\t\t\t\timportPaths,\r\n\t\t\t\t\tloaders: supportCoordinates.loaders\r\n\t\t\t\t});\r\n\r\n\t// Set support to the updated step and hook definitions\r\n\t// in the supportCodeLibrary. We also need to initialize originalCoordinates\r\n\t// to support parallel execution.\r\n\tsupportCodeLibrary = BindingRegistry.instance.updateSupportCodeLibrary(supportCodeLibrary);\r\n\tsupportCodeLibrary = { ...supportCodeLibrary, ...{ originalCoordinates: supportCoordinates } };\r\n\toptions.support = supportCodeLibrary;\r\n\r\n\tconst eventBroadcaster = new EventEmitter();\r\n\tif (onMessage) {\r\n\t\teventBroadcaster.on('envelope', onMessage);\r\n\t}\r\n\teventBroadcaster.on('envelope', value => pluginManager.emit('message', value));\r\n\r\n\t// create a global instance of the message collector and bind it\r\n\t// to the event broadcaster. This is used by cucumber and for tests\r\n\t// that are not running in parallel.\r\n\tglobal.messageCollector = new MessageCollector(eventBroadcaster);\r\n\r\n\t// cast the MessageCollector to an EventDataCollector\r\n\tconst eventDataCollector = global.messageCollector as unknown as EventDataCollector;\r\n\r\n\tlet formatterStreamError = false;\r\n\tconst cleanupFormatters = await initializeFormatters({\r\n\t\tenv,\r\n\t\tcwd,\r\n\t\tstdout,\r\n\t\tstderr,\r\n\t\tlogger,\r\n\t\tonStreamError: () => (formatterStreamError = true),\r\n\t\teventBroadcaster,\r\n\t\teventDataCollector: eventDataCollector,\r\n\t\tconfiguration: options.formats,\r\n\t\tsupportCodeLibrary,\r\n\t\tpluginManager\r\n\t});\r\n\tawait emitMetaMessage(eventBroadcaster, env);\r\n\r\n\tlet filteredPickles: ReadonlyArray<IFilterablePickle> = [];\r\n\tlet parseErrors: ParseError[] = [];\r\n\tif (sourcePaths.length > 0) {\r\n\t\tconst gherkinResult = await getPicklesAndErrors({\r\n\t\t\tnewId,\r\n\t\t\tcwd,\r\n\t\t\tsourcePaths,\r\n\t\t\tcoordinates: options.sources,\r\n\t\t\tonEnvelope: envelope => eventBroadcaster.emit('envelope', envelope)\r\n\t\t});\r\n\t\tfilteredPickles = await pluginManager.transform('pickles:filter', gherkinResult.filterablePickles);\r\n\t\tfilteredPickles = await pluginManager.transform('pickles:order', filteredPickles);\r\n\t\tparseErrors = gherkinResult.parseErrors;\r\n\t}\r\n\tif (parseErrors.length) {\r\n\t\tparseErrors.forEach(parseError => {\r\n\t\t\tlogger.error(`Parse error in \"${parseError.source.uri}\" ${parseError.message}`);\r\n\t\t});\r\n\t\tawait cleanupFormatters();\r\n\t\tawait pluginManager.cleanup();\r\n\t\treturn {\r\n\t\t\tsuccess: false,\r\n\t\t\tsupport: supportCodeLibrary\r\n\t\t};\r\n\t}\r\n\r\n\temitSupportCodeMessages({\r\n\t\teventBroadcaster,\r\n\t\tsupportCodeLibrary,\r\n\t\tnewId\r\n\t});\r\n\r\n\tconst runtime = await makeRuntime({\r\n\t\tenvironment,\r\n\t\tlogger,\r\n\t\teventBroadcaster,\r\n\t\tsourcedPickles: filteredPickles,\r\n\t\tnewId,\r\n\t\tsupportCodeLibrary,\r\n\t\toptions: options.runtime,\r\n\t\tcoordinates: options.sources\r\n\t});\r\n\tconst success = await runtime.run();\r\n\tawait pluginManager.cleanup();\r\n\tawait cleanupFormatters();\r\n\r\n\treturn {\r\n\t\tsuccess: success && !formatterStreamError,\r\n\t\tsupport: supportCodeLibrary\r\n\t};\r\n}\r\n"]}
|
package/lib/api/wrapper.mjs
CHANGED
|
@@ -1,14 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Step Binding Storage Management
|
|
3
|
+
*
|
|
4
|
+
* This module manages three different storage mechanisms for StepBindings to support both experimental (legacy) and standard (TC39 Stage 3) decorators:
|
|
5
|
+
*
|
|
6
|
+
* 1. Experimental Decorators (global.experimentalDecorators = true):
|
|
7
|
+
* - Uses the 'stepBindings' array
|
|
8
|
+
* - Functions: addStepBindingExp(), getStepBindingsExp()
|
|
9
|
+
*
|
|
10
|
+
* 2. Standard Decorators - Decoration Phase:
|
|
11
|
+
* - Uses context.metadata.stepBindings
|
|
12
|
+
* - Functions: addStepBinding(), getStepBindings()
|
|
13
|
+
*
|
|
14
|
+
* 3. Standard Decorators - Initialization Phase:
|
|
15
|
+
* - Uses 'collectedBindings' array
|
|
16
|
+
* - Functions: collectStepBinding(), getCollectedBindings()
|
|
17
|
+
* - Needed because context.metadata can't be modified during initialization
|
|
18
|
+
*
|
|
19
|
+
* The @binding class decorator determines which storage mechanism to use based on
|
|
20
|
+
* the global.experimentalDecorators flag.
|
|
21
|
+
*/
|
|
1
22
|
import { StepBinding } from './step-binding';
|
|
2
23
|
/**
|
|
3
|
-
* Add a StepBinding to the
|
|
24
|
+
* Add a StepBinding to the collection (for standard decorators)
|
|
25
|
+
* Used by method decorators to store bindings that will be processed
|
|
26
|
+
* when the class decorator's initializer runs.
|
|
27
|
+
*/
|
|
28
|
+
export declare const collectStepBinding: (binding: StepBinding) => void;
|
|
29
|
+
/**
|
|
30
|
+
* Get all collected bindings and reset the collection
|
|
31
|
+
* Called by the @binding class decorator's initializer to process
|
|
32
|
+
* all method decorators that were applied to the class.
|
|
33
|
+
*/
|
|
34
|
+
export declare const getCollectedBindings: () => StepBinding[];
|
|
35
|
+
/**
|
|
36
|
+
* Add a StepBinding to a local array for Experimental Decorators
|
|
37
|
+
* Used when global.experimentalDecorators = true
|
|
4
38
|
*
|
|
5
|
-
* @param context Current DecoratorContext
|
|
6
39
|
* @param binding StepBinding to add
|
|
7
40
|
*/
|
|
8
|
-
export declare const
|
|
41
|
+
export declare const addStepBindingExp: (binding: StepBinding) => void;
|
|
42
|
+
/**
|
|
43
|
+
* Get all step bindings in the local array and then reset
|
|
44
|
+
* to an empty array if reset = true (default)
|
|
45
|
+
* Used when global.experimentalDecorators = true
|
|
46
|
+
*
|
|
47
|
+
* @param context Current DecoratorContext
|
|
48
|
+
* @param reset Reset metadata on the context. Default=true
|
|
49
|
+
* @returns Array of StepBindings
|
|
50
|
+
*/
|
|
51
|
+
export declare const getStepBindingsExp: (reset?: boolean) => StepBinding[];
|
|
52
|
+
/**
|
|
53
|
+
* Add a StepBinding to the DecoratorContext metadata
|
|
54
|
+
* Used during the decoration phase of standard decorators.
|
|
55
|
+
* Note: This is separate from collectedBindings which is used during initialization.
|
|
56
|
+
* Returns true if successful, false if context not ready
|
|
57
|
+
*/
|
|
58
|
+
export declare const addStepBinding: (context: DecoratorContext, binding: StepBinding) => boolean;
|
|
9
59
|
/**
|
|
10
60
|
* Get all step bindings in DecoratorContext metadata and then reset
|
|
11
61
|
* stepBindings in the metadata to an empty array if reset = true (default)
|
|
62
|
+
* Used during the decoration phase of standard decorators.
|
|
12
63
|
*
|
|
13
64
|
* @param context Current DecoratorContext
|
|
14
65
|
* @param reset Reset metadata on the context. Default=true
|
|
@@ -1,21 +1,96 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getStepBindings = exports.addStepBinding = void 0;
|
|
3
|
+
exports.getStepBindings = exports.addStepBinding = exports.getStepBindingsExp = exports.addStepBindingExp = exports.getCollectedBindings = exports.collectStepBinding = void 0;
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Storage for experimental decorators (legacy TypeScript decorators).
|
|
6
|
+
* Used when global.experimentalDecorators = true.
|
|
7
|
+
* These decorators don't have access to context.metadata, so we use a module-level array.
|
|
8
|
+
*/
|
|
9
|
+
let stepBindings = null;
|
|
10
|
+
/**
|
|
11
|
+
* Storage for standard decorators (TC39 Stage 3 decorators).
|
|
12
|
+
* Used when global.experimentalDecorators = false.
|
|
13
|
+
* Standard decorators can't always access context.metadata during initialization,
|
|
14
|
+
* so we need this fallback storage for the addInitializer phase.
|
|
15
|
+
*/
|
|
16
|
+
let collectedBindings = [];
|
|
17
|
+
/**
|
|
18
|
+
* Add a StepBinding to the collection (for standard decorators)
|
|
19
|
+
* Used by method decorators to store bindings that will be processed
|
|
20
|
+
* when the class decorator's initializer runs.
|
|
21
|
+
*/
|
|
22
|
+
const collectStepBinding = (binding) => {
|
|
23
|
+
collectedBindings.push(binding);
|
|
24
|
+
};
|
|
25
|
+
exports.collectStepBinding = collectStepBinding;
|
|
26
|
+
/**
|
|
27
|
+
* Get all collected bindings and reset the collection
|
|
28
|
+
* Called by the @binding class decorator's initializer to process
|
|
29
|
+
* all method decorators that were applied to the class.
|
|
30
|
+
*/
|
|
31
|
+
const getCollectedBindings = () => {
|
|
32
|
+
const bindings = [...collectedBindings];
|
|
33
|
+
collectedBindings = [];
|
|
34
|
+
return bindings;
|
|
35
|
+
};
|
|
36
|
+
exports.getCollectedBindings = getCollectedBindings;
|
|
37
|
+
/**
|
|
38
|
+
* Add a StepBinding to a local array for Experimental Decorators
|
|
39
|
+
* Used when global.experimentalDecorators = true
|
|
6
40
|
*
|
|
7
|
-
* @param context Current DecoratorContext
|
|
8
41
|
* @param binding StepBinding to add
|
|
9
42
|
*/
|
|
43
|
+
const addStepBindingExp = (binding) => {
|
|
44
|
+
if (!stepBindings)
|
|
45
|
+
stepBindings = new Array();
|
|
46
|
+
stepBindings.push(binding);
|
|
47
|
+
};
|
|
48
|
+
exports.addStepBindingExp = addStepBindingExp;
|
|
49
|
+
/**
|
|
50
|
+
* Get all step bindings in the local array and then reset
|
|
51
|
+
* to an empty array if reset = true (default)
|
|
52
|
+
* Used when global.experimentalDecorators = true
|
|
53
|
+
*
|
|
54
|
+
* @param context Current DecoratorContext
|
|
55
|
+
* @param reset Reset metadata on the context. Default=true
|
|
56
|
+
* @returns Array of StepBindings
|
|
57
|
+
*/
|
|
58
|
+
const getStepBindingsExp = (reset = true) => {
|
|
59
|
+
let bindings = [];
|
|
60
|
+
if (stepBindings && stepBindings.length > 0) {
|
|
61
|
+
bindings = [...stepBindings];
|
|
62
|
+
if (reset) {
|
|
63
|
+
stepBindings = new Array();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return bindings;
|
|
67
|
+
};
|
|
68
|
+
exports.getStepBindingsExp = getStepBindingsExp;
|
|
69
|
+
/**
|
|
70
|
+
* Add a StepBinding to the DecoratorContext metadata
|
|
71
|
+
* Used during the decoration phase of standard decorators.
|
|
72
|
+
* Note: This is separate from collectedBindings which is used during initialization.
|
|
73
|
+
* Returns true if successful, false if context not ready
|
|
74
|
+
*/
|
|
10
75
|
const addStepBinding = (context, binding) => {
|
|
11
|
-
if (!context.metadata.stepBindings)
|
|
12
|
-
|
|
76
|
+
if (!context.metadata.stepBindings) {
|
|
77
|
+
// Check if we can initialize it
|
|
78
|
+
if (context.metadata && typeof context.metadata === 'object') {
|
|
79
|
+
context.metadata.stepBindings = new Array();
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
// Context not ready
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
13
86
|
context.metadata.stepBindings.push(binding);
|
|
87
|
+
return true;
|
|
14
88
|
};
|
|
15
89
|
exports.addStepBinding = addStepBinding;
|
|
16
90
|
/**
|
|
17
91
|
* Get all step bindings in DecoratorContext metadata and then reset
|
|
18
92
|
* stepBindings in the metadata to an empty array if reset = true (default)
|
|
93
|
+
* Used during the decoration phase of standard decorators.
|
|
19
94
|
*
|
|
20
95
|
* @param context Current DecoratorContext
|
|
21
96
|
* @param reset Reset metadata on the context. Default=true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binding-context.js","sourceRoot":"","sources":["../../src/bindings/binding-context.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"binding-context.js","sourceRoot":"","sources":["../../src/bindings/binding-context.ts"],"names":[],"mappings":";;;AAuBA;;;;GAIG;AACH,IAAI,YAAY,GAAuB,IAAI,CAAC;AAC5C;;;;;GAKG;AACH,IAAI,iBAAiB,GAAkB,EAAE,CAAC;AAE1C;;;;GAIG;AACI,MAAM,kBAAkB,GAAG,CAAC,OAAoB,EAAQ,EAAE;IAChE,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC,CAAC;AAFW,QAAA,kBAAkB,sBAE7B;AAEF;;;;GAIG;AACI,MAAM,oBAAoB,GAAG,GAAkB,EA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CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpE,OAAO,IAAI,CAAC;AACb,CAAC,CAAC;AAZW,QAAA,cAAc,kBAYzB;AAEF;;;;;;;;GAQG;AACI,MAAM,eAAe,GAAG,CAAC,OAAyB,EAAE,QAAiB,IAAI,EAAiB,EAAE;IAClG,IAAI,QAAQ,GAAkB,EAAE,CAAC;IACjC,MAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,YAAkC,CAAC;IACzE,IAAI,YAAY,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7C,QAAQ,GAAG,CAAC,GAAG,YAAY,CAAC,CAAC;QAC7B,IAAI,KAAK,EAAE,CAAC;YACX,OAAO,CAAC,QAAQ,CAAC,YAAY,GAAG,IAAI,KAAK,EAAe,CAAC;QAC1D,CAAC;IACF,CAAC;IACD,OAAO,QAAQ,CAAC;AACjB,CAAC,CAAC;AAVW,QAAA,eAAe,mBAU1B","sourcesContent":["/**\r\n * Step Binding Storage Management\r\n *\r\n * This module manages three different storage mechanisms for StepBindings to support both experimental (legacy) and standard (TC39 Stage 3) decorators:\r\n *\r\n * 1. Experimental Decorators (global.experimentalDecorators = true):\r\n * - Uses the 'stepBindings' array\r\n * - Functions: addStepBindingExp(), getStepBindingsExp()\r\n *\r\n * 2. Standard Decorators - Decoration Phase:\r\n * - Uses context.metadata.stepBindings\r\n * - Functions: addStepBinding(), getStepBindings()\r\n *\r\n * 3. Standard Decorators - Initialization Phase:\r\n * - Uses 'collectedBindings' array\r\n * - Functions: collectStepBinding(), getCollectedBindings()\r\n * - Needed because context.metadata can't be modified during initialization\r\n *\r\n * The @binding class decorator determines which storage mechanism to use based on\r\n * the global.experimentalDecorators flag.\r\n */\r\nimport { StepBinding } from './step-binding';\r\n\r\n/**\r\n * Storage for experimental decorators (legacy TypeScript decorators).\r\n * Used when global.experimentalDecorators = true.\r\n * These decorators don't have access to context.metadata, so we use a module-level array.\r\n */\r\nlet stepBindings: Array<StepBinding> = null;\r\n/**\r\n * Storage for standard decorators (TC39 Stage 3 decorators).\r\n * Used when global.experimentalDecorators = false.\r\n * Standard decorators can't always access context.metadata during initialization,\r\n * so we need this fallback storage for the addInitializer phase.\r\n */\r\nlet collectedBindings: StepBinding[] = [];\r\n\r\n/**\r\n * Add a StepBinding to the collection (for standard decorators)\r\n * Used by method decorators to store bindings that will be processed\r\n * when the class decorator's initializer runs.\r\n */\r\nexport const collectStepBinding = (binding: StepBinding): void => {\r\n\tcollectedBindings.push(binding);\r\n};\r\n\r\n/**\r\n * Get all collected bindings and reset the collection\r\n * Called by the @binding class decorator's initializer to process\r\n * all method decorators that were applied to the class.\r\n */\r\nexport const getCollectedBindings = (): StepBinding[] => {\r\n\tconst bindings = [...collectedBindings];\r\n\tcollectedBindings = [];\r\n\treturn bindings;\r\n};\r\n\r\n/**\r\n * Add a StepBinding to a local array for Experimental Decorators\r\n * Used when global.experimentalDecorators = true\r\n *\r\n * @param binding StepBinding to add\r\n */\r\nexport const addStepBindingExp = (binding: StepBinding): void => {\r\n\tif (!stepBindings) stepBindings = new Array<StepBinding>();\r\n\tstepBindings.push(binding);\r\n};\r\n\r\n/**\r\n * Get all step bindings in the local array and then reset\r\n * to an empty array if reset = true (default)\r\n * Used when global.experimentalDecorators = true\r\n *\r\n * @param context Current DecoratorContext\r\n * @param reset Reset metadata on the context. Default=true\r\n * @returns Array of StepBindings\r\n */\r\nexport const getStepBindingsExp = (reset: boolean = true): StepBinding[] => {\r\n\tlet bindings: StepBinding[] = [];\r\n\tif (stepBindings && stepBindings.length > 0) {\r\n\t\tbindings = [...stepBindings];\r\n\t\tif (reset) {\r\n\t\t\tstepBindings = new Array<StepBinding>();\r\n\t\t}\r\n\t}\r\n\treturn bindings;\r\n};\r\n\r\n/**\r\n * Add a StepBinding to the DecoratorContext metadata\r\n * Used during the decoration phase of standard decorators.\r\n * Note: This is separate from collectedBindings which is used during initialization.\r\n * Returns true if successful, false if context not ready\r\n */\r\nexport const addStepBinding = (context: DecoratorContext, binding: StepBinding): boolean => {\r\n\tif (!context.metadata.stepBindings) {\r\n\t\t// Check if we can initialize it\r\n\t\tif (context.metadata && typeof context.metadata === 'object') {\r\n\t\t\tcontext.metadata.stepBindings = new Array<StepBinding>();\r\n\t\t} else {\r\n\t\t\t// Context not ready\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\t(context.metadata.stepBindings as Array<StepBinding>).push(binding);\r\n\treturn true;\r\n};\r\n\r\n/**\r\n * Get all step bindings in DecoratorContext metadata and then reset\r\n * stepBindings in the metadata to an empty array if reset = true (default)\r\n * Used during the decoration phase of standard decorators.\r\n *\r\n * @param context Current DecoratorContext\r\n * @param reset Reset metadata on the context. Default=true\r\n * @returns Array of StepBindings\r\n */\r\nexport const getStepBindings = (context: DecoratorContext, reset: boolean = true): StepBinding[] => {\r\n\tlet bindings: StepBinding[] = [];\r\n\tconst stepBindings = context.metadata.stepBindings as Array<StepBinding>;\r\n\tif (stepBindings && stepBindings.length > 0) {\r\n\t\tbindings = [...stepBindings];\r\n\t\tif (reset) {\r\n\t\t\tcontext.metadata.stepBindings = new Array<StepBinding>();\r\n\t\t}\r\n\t}\r\n\treturn bindings;\r\n};\r\n"]}
|