@autometa/coordinator 0.3.33 → 1.0.0-rc.1

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 CHANGED
@@ -1,3 +1,3 @@
1
1
  # Introduction
2
2
 
3
- There's nothing here yet
3
+ There's nothing here yet
package/dist/index.cjs ADDED
@@ -0,0 +1,82 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var errors = require('@autometa/errors');
6
+ var executor = require('@autometa/executor');
7
+ var scopes = require('@autometa/scopes');
8
+ var testBuilder = require('@autometa/test-builder');
9
+
10
+ // src/index.ts
11
+ function coordinateFeature(options) {
12
+ const { feature, scopePlan, config } = options;
13
+ assertFeature(feature);
14
+ assertScopePlan(scopePlan);
15
+ assertConfig(config);
16
+ const createAdapter = options.adapterFactory ?? defaultAdapterFactory;
17
+ const buildPlan = options.planBuilder ?? defaultPlanBuilder;
18
+ const register = options.registerPlan ?? defaultRegistrationHandler;
19
+ const adapter = createAdapter(scopePlan);
20
+ const planOptions = {
21
+ feature,
22
+ adapter,
23
+ ...options.featureScope !== void 0 ? { featureScope: options.featureScope } : {}
24
+ };
25
+ const plan = buildPlan(planOptions);
26
+ return {
27
+ feature,
28
+ adapter,
29
+ plan,
30
+ config,
31
+ register(runtime) {
32
+ const executorRuntime = runtime ?? options.runtime;
33
+ if (!executorRuntime) {
34
+ throw new errors.AutomationError(
35
+ "An executor runtime is required to register the feature plan"
36
+ );
37
+ }
38
+ register({
39
+ plan,
40
+ adapter,
41
+ runtime: executorRuntime,
42
+ config,
43
+ ...options.hookLogger ? { hookLogger: options.hookLogger } : {}
44
+ });
45
+ }
46
+ };
47
+ }
48
+ function defaultAdapterFactory(plan) {
49
+ return scopes.createExecutionAdapter(plan);
50
+ }
51
+ function defaultPlanBuilder(options) {
52
+ return testBuilder.buildTestPlan(options);
53
+ }
54
+ function defaultRegistrationHandler(options) {
55
+ executor.registerFeaturePlan(options);
56
+ }
57
+ function assertFeature(feature) {
58
+ if (!feature) {
59
+ throw new errors.AutomationError("A Gherkin feature is required to coordinate execution");
60
+ }
61
+ }
62
+ function assertScopePlan(plan) {
63
+ if (!plan) {
64
+ throw new errors.AutomationError("A scope plan is required to coordinate execution");
65
+ }
66
+ if (!plan.root || plan.root.children.length === 0) {
67
+ throw new errors.AutomationError("The provided scope plan does not contain any feature scopes");
68
+ }
69
+ }
70
+ function assertConfig(config) {
71
+ if (!config) {
72
+ throw new errors.AutomationError("An executor configuration is required to coordinate execution");
73
+ }
74
+ }
75
+ var src_default = {
76
+ coordinateFeature
77
+ };
78
+
79
+ exports.coordinateFeature = coordinateFeature;
80
+ exports.default = src_default;
81
+ //# sourceMappingURL=out.js.map
82
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";AACA,SAAS,uBAAuB;AAEhC,SAAS,2BAAiD;AAK1D,SAAS,8BAA8B;AAEvC,SAAS,qBAAqB;AA8BvB,SAAS,kBACf,SACiC;AACjC,QAAM,EAAE,SAAS,WAAW,OAAO,IAAI;AAEvC,gBAAc,OAAO;AACrB,kBAAgB,SAAS;AACzB,eAAa,MAAM;AAEnB,QAAM,gBAAgB,QAAQ,kBAAkB;AAChD,QAAM,YAAY,QAAQ,eAAe;AACzC,QAAM,WAAW,QAAQ,gBAAgB;AAEzC,QAAM,UAAU,cAAc,SAAS;AACvC,QAAM,cAA2C;AAAA,IAChD;AAAA,IACA;AAAA,IACA,GAAI,QAAQ,iBAAiB,SAC1B,EAAE,cAAc,QAAQ,aAAa,IACrC,CAAC;AAAA,EACL;AAEA,QAAM,OAAO,UAAU,WAAW;AAElC,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS,SAAS;AACjB,YAAM,kBAAkB,WAAW,QAAQ;AAC3C,UAAI,CAAC,iBAAiB;AACrB,cAAM,IAAI;AAAA,UACT;AAAA,QACD;AAAA,MACD;AACA,eAAS;AAAA,QACR;AAAA,QACA;AAAA,QACA,SAAS;AAAA,QACT;AAAA,QACA,GAAI,QAAQ,aAAa,EAAE,YAAY,QAAQ,WAAW,IAAI,CAAC;AAAA,MAChE,CAAC;AAAA,IACF;AAAA,EACD;AACD;AAEA,SAAS,sBAA6B,MAAsD;AAC3F,SAAO,uBAAuB,IAAI;AACnC;AAEA,SAAS,mBAA0B,SAAuD;AACzF,SAAO,cAAc,OAAO;AAC7B;AAEA,SAAS,2BAAkC,SAA6C;AACvF,sBAAoB,OAAO;AAC5B;AAEA,SAAS,cAAc,SAAsE;AAC5F,MAAI,CAAC,SAAS;AACb,UAAM,IAAI,gBAAgB,uDAAuD;AAAA,EAClF;AACD;AAEA,SAAS,gBAAuB,MAAsE;AACrG,MAAI,CAAC,MAAM;AACV,UAAM,IAAI,gBAAgB,kDAAkD;AAAA,EAC7E;AACA,MAAI,CAAC,KAAK,QAAQ,KAAK,KAAK,SAAS,WAAW,GAAG;AAClD,UAAM,IAAI,gBAAgB,6DAA6D;AAAA,EACxF;AACD;AAEA,SAAS,aAAa,QAAsE;AAC3F,MAAI,CAAC,QAAQ;AACZ,UAAM,IAAI,gBAAgB,+DAA+D;AAAA,EAC1F;AACD;AAEA,IAAO,cAAQ;AAAA,EACd;AACD","sourcesContent":["import type { ExecutorConfig } from \"@autometa/config\";\nimport { AutomationError } from \"@autometa/errors\";\nimport type { ExecuteFeatureOptions, ExecutorRuntime } from \"@autometa/executor\";\nimport { registerFeaturePlan, type HookLogListener } from \"@autometa/executor\";\nimport type {\n\tScopeExecutionAdapter,\n\tScopePlan,\n} from \"@autometa/scopes\";\nimport { createExecutionAdapter } from \"@autometa/scopes\";\nimport type { SimpleFeature } from \"@autometa/gherkin\";\nimport { buildTestPlan } from \"@autometa/test-builder\";\nimport type {\n\tBuildTestPlanOptions,\n\tTestPlan,\n} from \"@autometa/test-builder\";\n\ntype AdapterFactory<World> = (plan: ScopePlan<World>) => ScopeExecutionAdapter<World>;\ntype PlanBuilder<World> = (options: BuildTestPlanOptions<World>) => TestPlan<World>;\ntype RegistrationHandler<World> = (options: ExecuteFeatureOptions<World>) => void;\n\nexport interface CoordinateFeatureOptions<World> {\n\treadonly feature: SimpleFeature;\n\treadonly scopePlan: ScopePlan<World>;\n\treadonly config: ExecutorConfig;\n\treadonly runtime?: ExecutorRuntime;\n\treadonly planBuilder?: PlanBuilder<World>;\n\treadonly adapterFactory?: AdapterFactory<World>;\n\treadonly registerPlan?: RegistrationHandler<World>;\n\treadonly featureScope?: BuildTestPlanOptions<World>[\"featureScope\"];\n\treadonly hookLogger?: HookLogListener;\n}\n\nexport interface CoordinateFeatureResult<World> {\n\treadonly feature: SimpleFeature;\n\treadonly adapter: ScopeExecutionAdapter<World>;\n\treadonly plan: TestPlan<World>;\n\treadonly config: ExecutorConfig;\n\tregister(runtime?: ExecutorRuntime): void;\n}\n\nexport function coordinateFeature<World>(\n\toptions: CoordinateFeatureOptions<World>\n): CoordinateFeatureResult<World> {\n\tconst { feature, scopePlan, config } = options;\n\n\tassertFeature(feature);\n\tassertScopePlan(scopePlan);\n\tassertConfig(config);\n\n\tconst createAdapter = options.adapterFactory ?? defaultAdapterFactory;\n\tconst buildPlan = options.planBuilder ?? defaultPlanBuilder;\n\tconst register = options.registerPlan ?? defaultRegistrationHandler;\n\n\tconst adapter = createAdapter(scopePlan);\n\tconst planOptions: BuildTestPlanOptions<World> = {\n\t\tfeature,\n\t\tadapter,\n\t\t...(options.featureScope !== undefined\n\t\t\t? { featureScope: options.featureScope }\n\t\t\t: {}),\n\t};\n\n\tconst plan = buildPlan(planOptions);\n\n\treturn {\n\t\tfeature,\n\t\tadapter,\n\t\tplan,\n\t\tconfig,\n\t\tregister(runtime) {\n\t\t\tconst executorRuntime = runtime ?? options.runtime;\n\t\t\tif (!executorRuntime) {\n\t\t\t\tthrow new AutomationError(\n\t\t\t\t\t\"An executor runtime is required to register the feature plan\"\n\t\t\t\t);\n\t\t\t}\n\t\t\tregister({\n\t\t\t\tplan,\n\t\t\t\tadapter,\n\t\t\t\truntime: executorRuntime,\n\t\t\t\tconfig,\n\t\t\t\t...(options.hookLogger ? { hookLogger: options.hookLogger } : {}),\n\t\t\t});\n\t\t},\n\t};\n}\n\nfunction defaultAdapterFactory<World>(plan: ScopePlan<World>): ScopeExecutionAdapter<World> {\n\treturn createExecutionAdapter(plan);\n}\n\nfunction defaultPlanBuilder<World>(options: BuildTestPlanOptions<World>): TestPlan<World> {\n\treturn buildTestPlan(options);\n}\n\nfunction defaultRegistrationHandler<World>(options: ExecuteFeatureOptions<World>): void {\n\tregisterFeaturePlan(options);\n}\n\nfunction assertFeature(feature: SimpleFeature | undefined): asserts feature is SimpleFeature {\n\tif (!feature) {\n\t\tthrow new AutomationError(\"A Gherkin feature is required to coordinate execution\");\n\t}\n}\n\nfunction assertScopePlan<World>(plan: ScopePlan<World> | undefined): asserts plan is ScopePlan<World> {\n\tif (!plan) {\n\t\tthrow new AutomationError(\"A scope plan is required to coordinate execution\");\n\t}\n\tif (!plan.root || plan.root.children.length === 0) {\n\t\tthrow new AutomationError(\"The provided scope plan does not contain any feature scopes\");\n\t}\n}\n\nfunction assertConfig(config: ExecutorConfig | undefined): asserts config is ExecutorConfig {\n\tif (!config) {\n\t\tthrow new AutomationError(\"An executor configuration is required to coordinate execution\");\n\t}\n}\n\nexport default {\n\tcoordinateFeature,\n};"]}
package/dist/index.d.ts CHANGED
@@ -1,49 +1,32 @@
1
- import { Config } from '@autometa/config';
2
- import { FeatureBridge } from '@autometa/test-builder';
3
- import { App, World } from '@autometa/app';
4
- import { TestEventEmitter } from '@autometa/events';
5
- import { Class } from '@autometa/types';
6
- import { GlobalScope, FeatureScope, Files } from '@autometa/scopes';
7
-
8
- type CoordinatorOpts = {
9
- app: Class<App>;
10
- world: Class<World>;
11
- };
12
-
13
- declare class Coordinator {
14
- #private;
15
- readonly global: GlobalScope;
16
- readonly configs: Config;
17
- readonly opts: Record<string, CoordinatorOpts>;
18
- constructor(global: GlobalScope, configs: Config, opts: Record<string, CoordinatorOpts>);
19
- run(feature: FeatureScope, caller: string, events: TestEventEmitter, executor: ({ app, world }: {
20
- app: Class<App>;
21
- world: Class<World>;
22
- }, global: GlobalScope, bridge: FeatureBridge, events: TestEventEmitter, config: Config) => void): void;
23
- private start;
24
- get fs(): Files;
25
- get config(): {
26
- runner: "jest" | "vitest";
27
- roots: {
28
- features: string[];
29
- steps: string[];
30
- app: string[];
31
- parameterTypes?: string[] | undefined;
32
- };
33
- environment?: string | undefined;
34
- test?: {
35
- timeout?: number | [number, "ms" | "s" | "m" | "h"] | undefined;
36
- tagFilter?: string | undefined;
37
- groupLogging?: boolean | undefined;
38
- } | undefined;
39
- shim?: {
40
- errorCause?: boolean | undefined;
41
- } | undefined;
42
- events?: string[] | undefined;
43
- };
44
- fileSystem(caller: string): Files;
45
- loadSteps(): void;
46
- loadParameterTypes(): void;
1
+ import type { ExecutorConfig } from "@autometa/config";
2
+ import type { ExecuteFeatureOptions, ExecutorRuntime } from "@autometa/executor";
3
+ import { type HookLogListener } from "@autometa/executor";
4
+ import type { ScopeExecutionAdapter, ScopePlan } from "@autometa/scopes";
5
+ import type { SimpleFeature } from "@autometa/gherkin";
6
+ import type { BuildTestPlanOptions, TestPlan } from "@autometa/test-builder";
7
+ type AdapterFactory<World> = (plan: ScopePlan<World>) => ScopeExecutionAdapter<World>;
8
+ type PlanBuilder<World> = (options: BuildTestPlanOptions<World>) => TestPlan<World>;
9
+ type RegistrationHandler<World> = (options: ExecuteFeatureOptions<World>) => void;
10
+ export interface CoordinateFeatureOptions<World> {
11
+ readonly feature: SimpleFeature;
12
+ readonly scopePlan: ScopePlan<World>;
13
+ readonly config: ExecutorConfig;
14
+ readonly runtime?: ExecutorRuntime;
15
+ readonly planBuilder?: PlanBuilder<World>;
16
+ readonly adapterFactory?: AdapterFactory<World>;
17
+ readonly registerPlan?: RegistrationHandler<World>;
18
+ readonly featureScope?: BuildTestPlanOptions<World>["featureScope"];
19
+ readonly hookLogger?: HookLogListener;
20
+ }
21
+ export interface CoordinateFeatureResult<World> {
22
+ readonly feature: SimpleFeature;
23
+ readonly adapter: ScopeExecutionAdapter<World>;
24
+ readonly plan: TestPlan<World>;
25
+ readonly config: ExecutorConfig;
26
+ register(runtime?: ExecutorRuntime): void;
47
27
  }
48
-
49
- export { Coordinator, CoordinatorOpts };
28
+ export declare function coordinateFeature<World>(options: CoordinateFeatureOptions<World>): CoordinateFeatureResult<World>;
29
+ declare const _default: {
30
+ coordinateFeature: typeof coordinateFeature;
31
+ };
32
+ export default _default;
package/dist/index.js CHANGED
@@ -1,131 +1,77 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var __accessCheck = (obj, member, msg) => {
20
- if (!member.has(obj))
21
- throw TypeError("Cannot " + msg);
22
- };
23
- var __privateGet = (obj, member, getter) => {
24
- __accessCheck(obj, member, "read from private field");
25
- return getter ? getter.call(obj) : member.get(obj);
26
- };
27
- var __privateAdd = (obj, member, value) => {
28
- if (member.has(obj))
29
- throw TypeError("Cannot add the same private member more than once");
30
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
31
- };
32
- var __privateSet = (obj, member, value, setter) => {
33
- __accessCheck(obj, member, "write to private field");
34
- setter ? setter.call(obj, value) : member.set(obj, value);
35
- return value;
36
- };
1
+ import { AutomationError } from '@autometa/errors';
2
+ import { registerFeaturePlan } from '@autometa/executor';
3
+ import { createExecutionAdapter } from '@autometa/scopes';
4
+ import { buildTestPlan } from '@autometa/test-builder';
37
5
 
38
6
  // src/index.ts
39
- var src_exports = {};
40
- __export(src_exports, {
41
- Coordinator: () => Coordinator
42
- });
43
- module.exports = __toCommonJS(src_exports);
44
-
45
- // src/coordinator.ts
46
- var import_test_builder = require("@autometa/test-builder");
47
- var import_scopes = require("@autometa/scopes");
48
- var import_errors = require("@autometa/errors");
49
- var import_asserters = require("@autometa/asserters");
50
- var _fs, _builder, _bridge;
51
- var Coordinator = class {
52
- constructor(global, configs, opts) {
53
- this.global = global;
54
- this.configs = configs;
55
- this.opts = opts;
56
- __privateAdd(this, _fs, void 0);
57
- __privateAdd(this, _builder, void 0);
58
- __privateAdd(this, _bridge, void 0);
59
- (0, import_asserters.AssertDefined)(configs, "Config");
60
- }
61
- run(feature, caller, events, executor) {
62
- (0, import_asserters.AssertDefined)(executor, "Executor");
63
- const fs = this.fileSystem(caller);
64
- const path = fs.fromUrlPattern(feature.path);
65
- path.loadApps();
66
- const gherkin = path.getFeatureFile();
67
- if (!Array.isArray(gherkin)) {
68
- this.start(gherkin, feature, events, executor);
69
- } else {
70
- for (const featGherkin of gherkin) {
71
- this.start(featGherkin, feature, events, executor);
7
+ function coordinateFeature(options) {
8
+ const { feature, scopePlan, config } = options;
9
+ assertFeature(feature);
10
+ assertScopePlan(scopePlan);
11
+ assertConfig(config);
12
+ const createAdapter = options.adapterFactory ?? defaultAdapterFactory;
13
+ const buildPlan = options.planBuilder ?? defaultPlanBuilder;
14
+ const register = options.registerPlan ?? defaultRegistrationHandler;
15
+ const adapter = createAdapter(scopePlan);
16
+ const planOptions = {
17
+ feature,
18
+ adapter,
19
+ ...options.featureScope !== void 0 ? { featureScope: options.featureScope } : {}
20
+ };
21
+ const plan = buildPlan(planOptions);
22
+ return {
23
+ feature,
24
+ adapter,
25
+ plan,
26
+ config,
27
+ register(runtime) {
28
+ const executorRuntime = runtime ?? options.runtime;
29
+ if (!executorRuntime) {
30
+ throw new AutomationError(
31
+ "An executor runtime is required to register the feature plan"
32
+ );
72
33
  }
34
+ register({
35
+ plan,
36
+ adapter,
37
+ runtime: executorRuntime,
38
+ config,
39
+ ...options.hookLogger ? { hookLogger: options.hookLogger } : {}
40
+ });
73
41
  }
42
+ };
43
+ }
44
+ function defaultAdapterFactory(plan) {
45
+ return createExecutionAdapter(plan);
46
+ }
47
+ function defaultPlanBuilder(options) {
48
+ return buildTestPlan(options);
49
+ }
50
+ function defaultRegistrationHandler(options) {
51
+ registerFeaturePlan(options);
52
+ }
53
+ function assertFeature(feature) {
54
+ if (!feature) {
55
+ throw new AutomationError("A Gherkin feature is required to coordinate execution");
74
56
  }
75
- start(gherkin, feature, events, executor) {
76
- this.global.unlock();
77
- this.loadParameterTypes();
78
- this.loadSteps();
79
- this.global.lock();
80
- __privateSet(this, _builder, new import_test_builder.TestBuilder(gherkin));
81
- __privateSet(this, _bridge, __privateGet(this, _builder).onFeatureExecuted(feature));
82
- const { app, world } = this.opts[this.config.environment ?? "default"];
83
- executor({ app, world }, this.global, __privateGet(this, _bridge), events, this.configs);
57
+ }
58
+ function assertScopePlan(plan) {
59
+ if (!plan) {
60
+ throw new AutomationError("A scope plan is required to coordinate execution");
84
61
  }
85
- get fs() {
86
- if (!__privateGet(this, _fs)) {
87
- throw new import_errors.AutomationError("File System not initialized");
88
- }
89
- return __privateGet(this, _fs);
62
+ if (!plan.root || plan.root.children.length === 0) {
63
+ throw new AutomationError("The provided scope plan does not contain any feature scopes");
90
64
  }
91
- get config() {
92
- return this.configs.current;
93
- }
94
- fileSystem(caller) {
95
- const { roots } = this.config;
96
- const { steps, features, app, parameterTypes } = roots;
97
- __privateSet(this, _fs, new import_scopes.Files().withFeatureRoot(features).withCallerFile(caller).withStepsRoot(steps).withParameterTypes(parameterTypes).withAppRoot(app));
98
- return this.fs;
99
- }
100
- loadSteps() {
101
- const { steps } = this.config.roots;
102
- if (typeof steps === "string") {
103
- this.fs.fromUrlPattern(steps).loadStepDefinitions();
104
- return;
105
- }
106
- for (const stepRoot of steps) {
107
- this.fs.fromUrlPattern(stepRoot).loadStepDefinitions();
108
- }
109
- }
110
- loadParameterTypes() {
111
- const { parameterTypes } = this.config.roots;
112
- if (parameterTypes === void 0) {
113
- return;
114
- }
115
- if (typeof parameterTypes === "string") {
116
- this.fs.fromUrlPattern(parameterTypes).loadParameterTypes();
117
- return;
118
- }
119
- for (const paramTypeRoot of parameterTypes) {
120
- this.fs.fromUrlPattern(paramTypeRoot).loadParameterTypes();
121
- }
65
+ }
66
+ function assertConfig(config) {
67
+ if (!config) {
68
+ throw new AutomationError("An executor configuration is required to coordinate execution");
122
69
  }
70
+ }
71
+ var src_default = {
72
+ coordinateFeature
123
73
  };
124
- _fs = new WeakMap();
125
- _builder = new WeakMap();
126
- _bridge = new WeakMap();
127
- // Annotate the CommonJS export names for ESM import in node:
128
- 0 && (module.exports = {
129
- Coordinator
130
- });
74
+
75
+ export { coordinateFeature, src_default as default };
76
+ //# sourceMappingURL=out.js.map
131
77
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/coordinator.ts"],"sourcesContent":["export * from \"./coordinator\";\nexport * from \"./types\";\n","import { Config } from \"@autometa/config\";\nimport { FeatureBridge, TestBuilder } from \"@autometa/test-builder\";\nimport { App, World } from \"@autometa/app\";\nimport { TestEventEmitter } from \"@autometa/events\";\nimport { Class } from \"@autometa/types\";\nimport { FeatureScope, Files, GlobalScope } from \"@autometa/scopes\";\nimport { AutomationError } from \"@autometa/errors\";\nimport { AssertDefined } from \"@autometa/asserters\";\nimport { CoordinatorOpts } from \"./types\";\nimport { Feature } from \"@autometa/gherkin\";\nexport class Coordinator {\n #fs: Files;\n #builder: TestBuilder;\n #bridge: FeatureBridge;\n constructor(\n readonly global: GlobalScope,\n readonly configs: Config,\n readonly opts: Record<string, CoordinatorOpts>\n ) {\n AssertDefined(configs, \"Config\");\n }\n\n run(\n feature: FeatureScope,\n caller: string,\n events: TestEventEmitter,\n executor: (\n { app, world }: { app: Class<App>; world: Class<World> },\n global: GlobalScope,\n bridge: FeatureBridge,\n events: TestEventEmitter,\n config: Config\n ) => void\n ) {\n AssertDefined(executor, \"Executor\");\n\n const fs = this.fileSystem(caller);\n const path = fs.fromUrlPattern(feature.path);\n path.loadApps();\n\n const gherkin = path.getFeatureFile();\n if (!Array.isArray(gherkin)) {\n this.start(gherkin, feature, events, executor);\n } else {\n for (const featGherkin of gherkin) {\n this.start(featGherkin, feature, events, executor);\n }\n }\n }\n\n private start(\n gherkin: Feature,\n feature: FeatureScope,\n events: TestEventEmitter,\n executor: (\n { app, world }: { app: Class<App>; world: Class<World> },\n global: GlobalScope,\n bridge: FeatureBridge,\n events: TestEventEmitter,\n config: Config\n ) => void\n ) {\n this.global.unlock();\n this.loadParameterTypes();\n this.loadSteps();\n this.global.lock();\n this.#builder = new TestBuilder(gherkin);\n this.#bridge = this.#builder.onFeatureExecuted(feature);\n const { app, world } = this.opts[this.config.environment ?? \"default\"];\n executor({ app, world }, this.global, this.#bridge, events, this.configs);\n }\n\n get fs() {\n if (!this.#fs) {\n throw new AutomationError(\"File System not initialized\");\n }\n return this.#fs;\n }\n\n get config() {\n return this.configs.current;\n }\n\n fileSystem(caller: string) {\n const { roots } = this.config;\n const { steps, features, app, parameterTypes } = roots;\n\n this.#fs = new Files()\n .withFeatureRoot(features)\n .withCallerFile(caller)\n .withStepsRoot(steps)\n .withParameterTypes(parameterTypes)\n .withAppRoot(app);\n return this.fs;\n }\n\n loadSteps() {\n const { steps } = this.config.roots;\n if (typeof steps === \"string\") {\n this.fs.fromUrlPattern(steps).loadStepDefinitions();\n return;\n }\n for (const stepRoot of steps) {\n this.fs.fromUrlPattern(stepRoot).loadStepDefinitions();\n }\n }\n\n loadParameterTypes() {\n const { parameterTypes } = this.config.roots;\n if (parameterTypes === undefined) {\n return;\n }\n\n if (typeof parameterTypes === \"string\") {\n this.fs.fromUrlPattern(parameterTypes).loadParameterTypes();\n return;\n }\n\n for (const paramTypeRoot of parameterTypes) {\n this.fs.fromUrlPattern(paramTypeRoot).loadParameterTypes();\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,0BAA2C;AAI3C,oBAAiD;AACjD,oBAAgC;AAChC,uBAA8B;AAP9B;AAUO,IAAM,cAAN,MAAkB;AAAA,EAIvB,YACW,QACA,SACA,MACT;AAHS;AACA;AACA;AANX;AACA;AACA;AAME,wCAAc,SAAS,QAAQ;AAAA,EACjC;AAAA,EAEA,IACE,SACA,QACA,QACA,UAOA;AACA,wCAAc,UAAU,UAAU;AAElC,UAAM,KAAK,KAAK,WAAW,MAAM;AACjC,UAAM,OAAO,GAAG,eAAe,QAAQ,IAAI;AAC3C,SAAK,SAAS;AAEd,UAAM,UAAU,KAAK,eAAe;AACpC,QAAI,CAAC,MAAM,QAAQ,OAAO,GAAG;AAC3B,WAAK,MAAM,SAAS,SAAS,QAAQ,QAAQ;AAAA,IAC/C,OAAO;AACL,iBAAW,eAAe,SAAS;AACjC,aAAK,MAAM,aAAa,SAAS,QAAQ,QAAQ;AAAA,MACnD;AAAA,IACF;AAAA,EACF;AAAA,EAEQ,MACN,SACA,SACA,QACA,UAOA;AACA,SAAK,OAAO,OAAO;AACnB,SAAK,mBAAmB;AACxB,SAAK,UAAU;AACf,SAAK,OAAO,KAAK;AACjB,uBAAK,UAAW,IAAI,gCAAY,OAAO;AACvC,uBAAK,SAAU,mBAAK,UAAS,kBAAkB,OAAO;AACtD,UAAM,EAAE,KAAK,MAAM,IAAI,KAAK,KAAK,KAAK,OAAO,eAAe,SAAS;AACrE,aAAS,EAAE,KAAK,MAAM,GAAG,KAAK,QAAQ,mBAAK,UAAS,QAAQ,KAA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AAa,QAAsE;AAC3F,MAAI,CAAC,QAAQ;AACZ,UAAM,IAAI,gBAAgB,+DAA+D;AAAA,EAC1F;AACD;AAEA,IAAO,cAAQ;AAAA,EACd;AACD","sourcesContent":["import type { ExecutorConfig } from \"@autometa/config\";\nimport { AutomationError } from \"@autometa/errors\";\nimport type { ExecuteFeatureOptions, ExecutorRuntime } from \"@autometa/executor\";\nimport { registerFeaturePlan, type HookLogListener } from \"@autometa/executor\";\nimport type {\n\tScopeExecutionAdapter,\n\tScopePlan,\n} from \"@autometa/scopes\";\nimport { createExecutionAdapter } from \"@autometa/scopes\";\nimport type { SimpleFeature } from \"@autometa/gherkin\";\nimport { buildTestPlan } from \"@autometa/test-builder\";\nimport type {\n\tBuildTestPlanOptions,\n\tTestPlan,\n} from \"@autometa/test-builder\";\n\ntype AdapterFactory<World> = (plan: ScopePlan<World>) => ScopeExecutionAdapter<World>;\ntype PlanBuilder<World> = (options: BuildTestPlanOptions<World>) => TestPlan<World>;\ntype RegistrationHandler<World> = (options: ExecuteFeatureOptions<World>) => void;\n\nexport interface CoordinateFeatureOptions<World> {\n\treadonly feature: SimpleFeature;\n\treadonly scopePlan: ScopePlan<World>;\n\treadonly config: ExecutorConfig;\n\treadonly runtime?: ExecutorRuntime;\n\treadonly planBuilder?: PlanBuilder<World>;\n\treadonly adapterFactory?: AdapterFactory<World>;\n\treadonly registerPlan?: RegistrationHandler<World>;\n\treadonly featureScope?: BuildTestPlanOptions<World>[\"featureScope\"];\n\treadonly hookLogger?: HookLogListener;\n}\n\nexport interface CoordinateFeatureResult<World> {\n\treadonly feature: SimpleFeature;\n\treadonly adapter: ScopeExecutionAdapter<World>;\n\treadonly plan: TestPlan<World>;\n\treadonly config: ExecutorConfig;\n\tregister(runtime?: ExecutorRuntime): void;\n}\n\nexport function coordinateFeature<World>(\n\toptions: CoordinateFeatureOptions<World>\n): CoordinateFeatureResult<World> {\n\tconst { feature, scopePlan, config } = options;\n\n\tassertFeature(feature);\n\tassertScopePlan(scopePlan);\n\tassertConfig(config);\n\n\tconst createAdapter = options.adapterFactory ?? defaultAdapterFactory;\n\tconst buildPlan = options.planBuilder ?? defaultPlanBuilder;\n\tconst register = options.registerPlan ?? defaultRegistrationHandler;\n\n\tconst adapter = createAdapter(scopePlan);\n\tconst planOptions: BuildTestPlanOptions<World> = {\n\t\tfeature,\n\t\tadapter,\n\t\t...(options.featureScope !== undefined\n\t\t\t? { featureScope: options.featureScope }\n\t\t\t: {}),\n\t};\n\n\tconst plan = buildPlan(planOptions);\n\n\treturn {\n\t\tfeature,\n\t\tadapter,\n\t\tplan,\n\t\tconfig,\n\t\tregister(runtime) {\n\t\t\tconst executorRuntime = runtime ?? options.runtime;\n\t\t\tif (!executorRuntime) {\n\t\t\t\tthrow new AutomationError(\n\t\t\t\t\t\"An executor runtime is required to register the feature plan\"\n\t\t\t\t);\n\t\t\t}\n\t\t\tregister({\n\t\t\t\tplan,\n\t\t\t\tadapter,\n\t\t\t\truntime: executorRuntime,\n\t\t\t\tconfig,\n\t\t\t\t...(options.hookLogger ? { hookLogger: options.hookLogger } : {}),\n\t\t\t});\n\t\t},\n\t};\n}\n\nfunction defaultAdapterFactory<World>(plan: ScopePlan<World>): ScopeExecutionAdapter<World> {\n\treturn createExecutionAdapter(plan);\n}\n\nfunction defaultPlanBuilder<World>(options: BuildTestPlanOptions<World>): TestPlan<World> {\n\treturn buildTestPlan(options);\n}\n\nfunction defaultRegistrationHandler<World>(options: ExecuteFeatureOptions<World>): void {\n\tregisterFeaturePlan(options);\n}\n\nfunction assertFeature(feature: SimpleFeature | undefined): asserts feature is SimpleFeature {\n\tif (!feature) {\n\t\tthrow new AutomationError(\"A Gherkin feature is required to coordinate execution\");\n\t}\n}\n\nfunction assertScopePlan<World>(plan: ScopePlan<World> | undefined): asserts plan is ScopePlan<World> {\n\tif (!plan) {\n\t\tthrow new AutomationError(\"A scope plan is required to coordinate execution\");\n\t}\n\tif (!plan.root || plan.root.children.length === 0) {\n\t\tthrow new AutomationError(\"The provided scope plan does not contain any feature scopes\");\n\t}\n}\n\nfunction assertConfig(config: ExecutorConfig | undefined): asserts config is ExecutorConfig {\n\tif (!config) {\n\t\tthrow new AutomationError(\"An executor configuration is required to coordinate execution\");\n\t}\n}\n\nexport default {\n\tcoordinateFeature,\n};"]}
package/package.json CHANGED
@@ -1,56 +1,58 @@
1
1
  {
2
2
  "name": "@autometa/coordinator",
3
- "version": "0.3.33",
3
+ "version": "1.0.0-rc.1",
4
4
  "description": "",
5
5
  "type": "module",
6
- "main": "dist/index.js",
7
- "module": "dist/esm/index.js",
6
+ "main": "dist/index.cjs",
7
+ "module": "dist/index.js",
8
8
  "types": "dist/index.d.ts",
9
+ "files": [
10
+ "dist"
11
+ ],
9
12
  "exports": {
10
- "import": "./dist/esm/index.js",
11
- "require": "./dist/index.js",
12
- "default": "./dist/esm/index.js",
13
+ "import": "./dist/index.js",
14
+ "require": "./dist/index.cjs",
15
+ "default": "./dist/index.js",
13
16
  "types": "./dist/index.d.ts"
14
17
  },
18
+ "dependencies": {
19
+ "@autometa/config": "1.0.0-rc.1",
20
+ "@autometa/gherkin": "1.0.0-rc.1",
21
+ "@autometa/scopes": "1.0.0-rc.1",
22
+ "@autometa/errors": "1.0.0-rc.1",
23
+ "@autometa/executor": "1.0.0-rc.1",
24
+ "@autometa/test-builder": "1.0.0-rc.1"
25
+ },
15
26
  "license": "MIT",
16
27
  "devDependencies": {
17
28
  "@types/node": "^18.11.18",
18
- "@types/uuid": "^9.0.5",
19
29
  "@typescript-eslint/eslint-plugin": "^5.54.1",
20
30
  "@typescript-eslint/parser": "^5.54.1",
21
- "@vitest/coverage-istanbul": "^1.4.0",
22
- "@vitest/coverage-v8": "^1.4.0",
23
31
  "eslint": "^8.37.0",
24
32
  "eslint-config-prettier": "^8.3.0",
25
- "istanbul": "^0.4.5",
26
33
  "rimraf": "^4.1.2",
27
34
  "tsup": "^7.2.0",
28
35
  "typescript": "^4.9.5",
36
+ "vite-tsconfig-paths": "^5.1.4",
29
37
  "vitest": "1.4.0",
30
38
  "tsconfig": "0.7.0",
39
+ "tsup-config": "0.1.0",
31
40
  "eslint-config-custom": "0.6.0"
32
41
  },
33
- "dependencies": {
34
- "tsyringe": "^4.8.0",
35
- "@autometa/app": "^0.4.2",
36
- "@autometa/asserters": "^0.1.8",
37
- "@autometa/config": "^0.1.27",
38
- "@autometa/errors": "^0.2.2",
39
- "@autometa/events": "^0.3.2",
40
- "@autometa/gherkin": "^0.7.2",
41
- "@autometa/scopes": "^0.7.2",
42
- "@autometa/test-builder": "^0.4.2",
43
- "@autometa/types": "^0.4.1",
44
- "@autometa/jest-executor": "^0.6.4"
45
- },
46
42
  "scripts": {
43
+ "type-check": "tsc --noEmit -p tsconfig.dev.json",
44
+ "type-check:watch": "tsc --noEmit --watch -p tsconfig.dev.json",
45
+ "build": "tsup && pnpm run build:types",
46
+ "build:types": "rimraf tsconfig.types.tsbuildinfo && tsc --build tsconfig.types.json",
47
+ "build:watch": "tsup --watch",
48
+ "dev": "tsup --watch",
47
49
  "test": "vitest run --passWithNoTests",
50
+ "test:watch": "vitest --passWithNoTests",
51
+ "test:ui": "vitest --ui --passWithNoTests",
48
52
  "coverage": "vitest run --coverage --passWithNoTests",
49
- "prettify": "prettier --config .prettierrc 'src/**/*.ts' --write",
50
53
  "lint": "eslint . --max-warnings 0",
51
54
  "lint:fix": "eslint . --fix",
52
- "clean": "rimraf dist",
53
- "build": "tsup",
54
- "build:watch": "tsup --watch"
55
+ "prettify": "prettier --config .prettierrc 'src/**/*.ts' --write",
56
+ "clean": "rimraf dist"
55
57
  }
56
58
  }
package/.eslintignore DELETED
@@ -1,3 +0,0 @@
1
- /dist
2
- /out
3
- node_modules
package/.eslintrc.cjs DELETED
@@ -1,4 +0,0 @@
1
- module.exports = {
2
- root: true,
3
- extends: ["custom"],
4
- };
@@ -1,19 +0,0 @@
1
-
2
- > @autometa/coordinator@0.1.1 coverage /Users/ben.aherne/Documents/GitHub/autometa/packages/coordinator
3
- > vitest run --coverage --passWithNoTests
4
-
5
-
6
- RUN v0.29.8 /Users/ben.aherne/Documents/GitHub/autometa/packages/coordinator
7
- Coverage enabled with istanbul
8
-
9
- % Coverage report from istanbul
10
- ----------|---------|----------|---------|---------|-------------------
11
- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
12
- ----------|---------|----------|---------|---------|-------------------
13
- All files | 0 | 0 | 0 | 0 |
14
- ----------|---------|----------|---------|---------|-------------------
15
- No test files found, exiting with code 0
16
-
17
- include: **/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}
18
- exclude: **/node_modules/**, **/dist/**, **/cypress/**, **/.{idea,git,cache,output,temp}/**, **/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*
19
- watch exclude: **/node_modules/**, **/dist/**
@@ -1,4 +0,0 @@
1
-
2
- > @autometa/coordinator@0.3.17 lint:fix /Users/ben.aherne/Documents/GitHub/autometa/packages/coordinator
3
- > eslint . --fix "--max-warnings=0"
4
-
File without changes
@@ -1,12 +0,0 @@
1
-
2
- > @autometa/coordinator@0.3.28 test /Users/ben.aherne/Documents/GitHub/autometa/packages/coordinator
3
- > vitest run --passWithNoTests
4
-
5
-
6
- RUN v1.4.0 /Users/ben.aherne/Documents/GitHub/autometa/packages/coordinator
7
-
8
- No test files found, exiting with code 0
9
- include: **/*.{test,spec}.?(c|m)[jt]s?(x)
10
- exclude: **/node_modules/**, **/dist/**, **/cypress/**, **/.{idea,git,cache,output,temp}/**, **/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*
11
-
12
- watch exclude: **/node_modules/**, **/dist/**