@step-forge/step-forge 0.0.25-alpha.4 → 0.0.25-alpha.5
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/RUNTIME.md +28 -28
- package/dist/{analyzer-5H699Eg4.js → analyzer-E3Kq7Eul.js} +20 -111
- package/dist/analyzer-E3Kq7Eul.js.map +1 -0
- package/dist/analyzer-cli.js +1 -1
- package/dist/analyzer-cli.js.map +1 -1
- package/dist/analyzer.js +1 -1
- package/dist/cli.cjs +1 -36
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +0 -35
- package/dist/cli.js.map +1 -1
- package/dist/{gherkinParser-_ZgvELdy.cjs → gherkinParser-CbBLr_uP.cjs} +1 -16
- package/dist/{gherkinParser-_ZgvELdy.cjs.map → gherkinParser-CbBLr_uP.cjs.map} +1 -1
- package/dist/step-forge.cjs +398 -7
- package/dist/step-forge.cjs.map +1 -1
- package/dist/step-forge.js +392 -2
- package/dist/step-forge.js.map +1 -1
- package/package.json +1 -1
- package/dist/analyzer-5H699Eg4.js.map +0 -1
- package/dist/analyzer-DRudicCk.cjs +0 -531
- package/dist/analyzer-DRudicCk.cjs.map +0 -1
- package/dist/analyzer-NsNpSFox.js +0 -507
- package/dist/analyzer-NsNpSFox.js.map +0 -1
package/dist/step-forge.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step-forge.js","names":[],"sources":["../../src/builderTypeUtils.ts","../../src/parsers.ts","../../src/utils.ts","../../src/common.ts","../../src/given.ts","../../src/when.ts","../../src/then.ts","../../src/init.ts","../../src/hooks.ts","../../src/index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nexport type StepType = \"given\" | \"when\" | \"then\";\n\n/** A dependency declaration: each key of a phase's state marked required/optional. */\nexport type RequiredOrOptional<T> = {\n [K in keyof T]?: \"required\" | \"optional\";\n};\n\n/** The dependency map for a single phase, keyed by state property name. */\nexport type DepMap = Record<string, \"required\" | \"optional\">;\n\n/** The fully-resolved dependency declaration passed to `addStep` at runtime. */\nexport type FullDependencies = {\n given: DepMap;\n when: DepMap;\n then: DepMap;\n};\n\n/**\n * Narrows a phase's full state to only the keys named in a dependency map.\n * Optional dependencies widen to `| undefined`; keys not present in the state\n * are dropped. This is the shape a step function sees for `given`/`when`/`then`.\n */\nexport type Restrict<State, Deps extends RequiredOrOptional<State>> = {\n [K in keyof State as K extends keyof Deps\n ? K\n : never]: Deps[K] extends \"optional\" ? State[K] | undefined : State[K];\n};\n\nexport type GetFunctionArgs<T> = T extends (...args: infer A) => any\n ? A\n : never;\n\nexport const isString = (\n statement: string | ((...args: [...any]) => string)\n): statement is string => typeof statement === \"string\";\n","/**\n * A Parser is a typed cucumber-expression *parameter type*: it declares how a\n * value is recognised in a Gherkin step (`regexp`) and how the matched text is\n * turned into a TypeScript value (`parse`). The step expression uses `{name}`\n * as the placeholder.\n *\n * The engine folds each parser straight into the cucumber-expression matcher —\n * `parse` is the parameter type's transform, so coercion happens exactly once,\n * during matching (no second pass). This is also what lets a parser introduce a\n * brand-new placeholder like `{color}`: it is registered as a real parameter\n * type, so text that doesn't match `regexp` simply doesn't match the step.\n *\n * The four built-ins below reuse cucumber-expressions' own built-in parameter\n * types (`{int}`, `{float}`, `{string}`) — those names are already registered,\n * so the library performs the match + coercion and each parser's `regexp`/\n * `parse` serve to document intent and to drive TypeScript inference of the\n * variable type. `booleanParser` has no built-in equivalent, so it is a genuine\n * custom parameter type whose `parse` runs at match time.\n */\nexport type Parser<T> = {\n /** Parameter-type name; the step expression uses `{name}` as the placeholder. */\n name: string;\n /** How cucumber-expressions recognises the value in the step text. */\n regexp: RegExp | RegExp[];\n /** Transform the matched text into the typed value. */\n parse: (value: string) => T;\n};\n\n/** Matches a quoted string (`{string}`) and strips the surrounding quotes. */\nexport const stringParser: Parser<string> = {\n name: \"string\",\n regexp: [/\"([^\"\\\\]*(\\\\.[^\"\\\\]*)*)\"/, /'([^'\\\\]*(\\\\.[^'\\\\]*)*)'/],\n parse: value => {\n const match = /^\"([\\s\\S]*)\"$/.exec(value) ?? /^'([\\s\\S]*)'$/.exec(value);\n return match ? match[1].replace(/\\\\([\"'])/g, \"$1\") : value;\n },\n};\n\n/** Matches an unquoted integer (`{int}`). */\nexport const intParser: Parser<number> = {\n name: \"int\",\n regexp: /-?\\d+/,\n parse: value => parseInt(value, 10),\n};\n\n/** Matches an unquoted floating point number (`{float}`). */\nexport const numberParser: Parser<number> = {\n name: \"float\",\n regexp: /-?\\d*\\.?\\d+/,\n parse: value => parseFloat(value),\n};\n\n/**\n * Matches an unquoted `true`/`false` word (`{boolean}`) and parses it to a\n * boolean. Unlike the others this is a genuine custom parameter type — cucumber\n * has no built-in `boolean` — so its `regexp`/`parse` are what the matcher uses.\n */\nexport const booleanParser: Parser<boolean> = {\n name: \"boolean\",\n regexp: /true|false/,\n parse: value => value === \"true\",\n};\n","import { MergeableWorld } from \"./world\";\n\nexport const requireFromGiven = <G>(\n keys: (keyof G)[],\n world: MergeableWorld<G, unknown, unknown>\n) => {\n keys.forEach(key => {\n if (!world.given[key]) {\n throw new Error(`Key ${String(key)} is required in given state`);\n }\n });\n return keys.reduce(\n (acc, key) => {\n return {\n ...acc,\n [key]: world.given[key],\n };\n },\n {} as { [key in keyof G]: G[key] }\n );\n};\nexport const requireFromWhen = <W>(\n keys: (keyof W)[],\n world: MergeableWorld<unknown, W, unknown>\n) => {\n keys.forEach(key => {\n if (!world.when[key]) {\n throw new Error(`Key ${String(key)} is required in when state`);\n }\n });\n return keys.reduce(\n (acc, key) => {\n return {\n ...acc,\n [key]: world.when[key],\n };\n },\n {} as { [key in keyof W]: W[key] }\n );\n};\nexport const requireFromThen = <T>(\n keys: (keyof T)[],\n world: MergeableWorld<unknown, unknown, T>\n) => {\n keys.forEach(key => {\n if (!world.then[key]) {\n throw new Error(`Key ${String(key)} is required in then state`);\n }\n });\n return keys.reduce(\n (acc, key) => {\n return {\n ...acc,\n [key]: world.then[key],\n };\n },\n {} as { [key in keyof T]: T[key] }\n );\n};\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport _ from \"lodash\";\n\nimport { DepMap, FullDependencies, StepType } from \"./builderTypeUtils\";\nimport { Parser, stringParser } from \"./parsers\";\nimport { globalRegistry } from \"./runtime/registry\";\nimport { captureDefinitionSite } from \"./sourceLocation\";\nimport { requireFromGiven, requireFromThen, requireFromWhen } from \"./utils\";\nimport { MergeableWorld } from \"./world\";\n\n/**\n * The runtime core of the builder chain. `addStep` is deliberately phase-agnostic:\n * the calling builder (given/when/then) has already computed the exact type of the\n * step function via its two type parameters:\n *\n * - `StepFnInput` — the `{ variables, given, when, then }` object the step receives,\n * with each phase already narrowed to its declared dependencies.\n * - `StepFnOutput` — the phase-appropriate return type (`Partial<State>`, or `void`).\n *\n * Everything else is plain runtime data (a statement function, the step type, the\n * dependency map, the parsers), so `addStep` carries no generics for them.\n */\nexport const addStep =\n <StepFnInput, StepFnOutput>(\n statement: (...args: any[]) => string,\n stepType: StepType,\n dependencies: FullDependencies = {\n given: {},\n when: {},\n then: {},\n },\n declaredParsers?: Parser<any>[]\n ) =>\n (stepFunction: (input: StepFnInput) => StepFnOutput) => {\n const {\n given: givenDependencies,\n when: whenDependencies,\n then: thenDependencies,\n } = dependencies;\n // Resolve the parsers up front, defaulting every variable to `stringParser`\n // (the `{string}` placeholder, value passed through unchanged) when none are\n // provided. Numeric/boolean values are opt-in via explicit parsers.\n const argCount = statement.length;\n const parsers =\n declaredParsers ?? Array.from({ length: argCount }, () => stringParser);\n const expression = statement(...parsers.map(parser => `{${parser.name}}`));\n // The fully-wired step body, decoupled from any test runner: takes an\n // explicit world plus the values captured from a Gherkin step, validates +\n // narrows dependencies, runs the user's step, and merges the result. The\n // captured values arrive already coerced — each parser is registered as the\n // cucumber-expression parameter type, so `parse` runs during matching, not\n // here.\n const execute = async (\n world: MergeableWorld<any, any, any>,\n capturedArgs: unknown[]\n ) => {\n const requiredKeys = (deps: DepMap) =>\n Object.entries(deps)\n .filter(([, value]) => value === \"required\")\n .map(([key]) => key);\n const narrowedGiven = {\n ..._.pick(world.given, Object.keys(givenDependencies)),\n ...requireFromGiven(requiredKeys(givenDependencies), world),\n };\n const narrowedWhen = {\n ..._.pick(world.when, Object.keys(whenDependencies)),\n ...requireFromWhen(requiredKeys(whenDependencies), world),\n };\n const narrowedThen = {\n ..._.pick(world.then, Object.keys(thenDependencies)),\n ...requireFromThen(requiredKeys(thenDependencies), world),\n };\n const result = await stepFunction({\n variables: capturedArgs,\n given: narrowedGiven,\n when: narrowedWhen,\n then: narrowedThen,\n } as StepFnInput);\n world[stepType].merge({\n ...(result as any),\n });\n };\n\n // Registration is the terminal action of the builder chain: calling\n // `.step(fn)` makes the step matchable and executable by the runtime. We\n // capture *this* call site (the user's `.step(...)` line) so reporters can\n // show where a failing step is defined, Cucumber-style.\n const source = captureDefinitionSite();\n globalRegistry.add({ stepType, expression, parsers, execute, source });\n\n return {\n statement,\n expression,\n dependencies,\n stepType,\n stepFunction,\n };\n };\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport {\n FullDependencies,\n GetFunctionArgs,\n isString,\n RequiredOrOptional,\n Restrict,\n StepType,\n} from \"./builderTypeUtils\";\nimport { addStep } from \"./common\";\nimport { Parser } from \"./parsers\";\n\nconst GIVEN: StepType = \"given\";\n\n// The `{ variables, given, when, then }` object a given step receives. Only\n// `given` is reachable — when/then are `never`, enforcing phase restriction.\n// `Given` is the state already narrowed to declared dependencies (`never` when\n// no dependencies were declared).\ntype GivenInput<Variables, Given> = {\n variables: Variables;\n given: Given;\n when: never;\n then: never;\n};\ntype GivenOutput<GivenState> =\n | Partial<GivenState>\n | Promise<Partial<GivenState>>;\n\nconst givenDependencies =\n <Variables, GivenState>(\n statement: (...args: any[]) => string,\n parsers?: Parser<any>[]\n ) =>\n <GivenDeps extends RequiredOrOptional<GivenState>>(dependencies: {\n given: GivenDeps;\n }) => ({\n step: addStep<\n GivenInput<Variables, Restrict<GivenState, GivenDeps>>,\n GivenOutput<GivenState>\n >(\n statement,\n GIVEN,\n { ...dependencies, when: {}, then: {} } as FullDependencies,\n parsers\n ),\n });\n\nconst givenParsers =\n <Variables extends any[], GivenState>(\n statement: (...args: any[]) => string\n ) =>\n <Parsers extends { [K in keyof Variables]: Parser<Variables[K]> }>(\n parsers: Parsers\n ) => ({\n dependencies: givenDependencies<Variables, GivenState>(\n statement,\n parsers as unknown as Parser<any>[]\n ),\n step: addStep<GivenInput<Variables, never>, GivenOutput<GivenState>>(\n statement,\n GIVEN,\n undefined,\n parsers as unknown as Parser<any>[]\n ),\n });\n\nconst givenStatement =\n <GivenState>() =>\n <Statement extends ((...args: [...any]) => string) | string>(\n statement: Statement\n ) => {\n const normalizedStatement: (...args: any[]) => string = isString(statement)\n ? () => statement\n : (statement as (...args: any[]) => string);\n\n type Variables = Statement extends string ? [] : GetFunctionArgs<Statement>;\n return {\n dependencies: givenDependencies<Variables, GivenState>(\n normalizedStatement\n ),\n parsers: givenParsers<Variables, GivenState>(normalizedStatement),\n step: addStep<GivenInput<Variables, never>, GivenOutput<GivenState>>(\n normalizedStatement,\n GIVEN\n ),\n };\n };\n\nexport const givenBuilder = <GivenState>() => ({\n statement: givenStatement<GivenState>(),\n});\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport {\n FullDependencies,\n GetFunctionArgs,\n isString,\n RequiredOrOptional,\n Restrict,\n StepType,\n} from \"./builderTypeUtils\";\nimport { addStep } from \"./common\";\nimport { Parser } from \"./parsers\";\n\nconst WHEN: StepType = \"when\";\n\n// The object a when step receives: `given` and `when` are reachable (narrowed to\n// declared dependencies, or `never` when none), `then` is always out of reach.\ntype WhenInput<Variables, Given, When> = {\n variables: Variables;\n given: Given;\n when: When;\n then: never;\n};\ntype WhenOutput<WhenState> = Partial<WhenState> | Promise<Partial<WhenState>>;\n\nconst whenDependencies =\n <Variables, GivenState, WhenState>(\n statement: (...args: any[]) => string,\n parsers?: Parser<any>[]\n ) =>\n <\n GivenDeps extends RequiredOrOptional<GivenState>,\n WhenDeps extends RequiredOrOptional<WhenState>,\n >(dependencies: {\n given?: GivenDeps;\n when?: WhenDeps;\n }) => ({\n step: addStep<\n WhenInput<\n Variables,\n Restrict<GivenState, GivenDeps>,\n Restrict<WhenState, WhenDeps>\n >,\n WhenOutput<WhenState>\n >(\n statement,\n WHEN,\n {\n given: dependencies.given ?? {},\n when: dependencies.when ?? {},\n then: {},\n } as FullDependencies,\n parsers\n ),\n });\n\nconst whenParsers =\n <Variables extends any[], GivenState, WhenState>(\n statement: (...args: any[]) => string\n ) =>\n <Parsers extends { [K in keyof Variables]: Parser<Variables[K]> }>(\n parsers: Parsers\n ) => ({\n dependencies: whenDependencies<Variables, GivenState, WhenState>(\n statement,\n parsers as unknown as Parser<any>[]\n ),\n step: addStep<WhenInput<Variables, never, never>, WhenOutput<WhenState>>(\n statement,\n WHEN,\n undefined,\n parsers as unknown as Parser<any>[]\n ),\n });\n\nconst whenStatement =\n <GivenState, WhenState>() =>\n <Statement extends ((...args: [...any]) => string) | string>(\n statement: Statement\n ) => {\n const normalizedStatement: (...args: any[]) => string = isString(statement)\n ? () => statement\n : (statement as (...args: any[]) => string);\n\n type Variables = Statement extends string ? [] : GetFunctionArgs<Statement>;\n return {\n dependencies: whenDependencies<Variables, GivenState, WhenState>(\n normalizedStatement\n ),\n parsers: whenParsers<Variables, GivenState, WhenState>(\n normalizedStatement\n ),\n step: addStep<WhenInput<Variables, never, never>, WhenOutput<WhenState>>(\n normalizedStatement,\n WHEN\n ),\n };\n };\n\nexport const whenBuilder = <GivenState, WhenState>() => ({\n statement: whenStatement<GivenState, WhenState>(),\n});\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport {\n FullDependencies,\n GetFunctionArgs,\n isString,\n RequiredOrOptional,\n Restrict,\n StepType,\n} from \"./builderTypeUtils\";\nimport { addStep } from \"./common\";\nimport { Parser } from \"./parsers\";\n\nconst THEN: StepType = \"then\";\n\n// The object a then step receives: all three phases are reachable (each narrowed\n// to declared dependencies, or `never` when none). Then steps may also return\n// nothing (assertion-only), hence the `void` in the output type.\ntype ThenInput<Variables, Given, When, Then> = {\n variables: Variables;\n given: Given;\n when: When;\n then: Then;\n};\ntype ThenOutput<ThenState> =\n | Partial<ThenState>\n | Promise<Partial<ThenState>>\n | void\n | Promise<void>;\n\nconst thenDependencies =\n <Variables, GivenState, WhenState, ThenState>(\n statement: (...args: any[]) => string,\n parsers?: Parser<any>[]\n ) =>\n <\n GivenDeps extends RequiredOrOptional<GivenState>,\n WhenDeps extends RequiredOrOptional<WhenState>,\n ThenDeps extends RequiredOrOptional<ThenState>,\n >(dependencies: {\n given?: GivenDeps;\n when?: WhenDeps;\n then?: ThenDeps;\n }) => ({\n step: addStep<\n ThenInput<\n Variables,\n Restrict<GivenState, GivenDeps>,\n Restrict<WhenState, WhenDeps>,\n Restrict<ThenState, ThenDeps>\n >,\n ThenOutput<ThenState>\n >(\n statement,\n THEN,\n {\n given: dependencies.given ?? {},\n when: dependencies.when ?? {},\n then: dependencies.then ?? {},\n } as FullDependencies,\n parsers\n ),\n });\n\nconst thenParsers =\n <Variables extends any[], GivenState, WhenState, ThenState>(\n statement: (...args: any[]) => string\n ) =>\n <Parsers extends { [K in keyof Variables]: Parser<Variables[K]> }>(\n parsers: Parsers\n ) => ({\n dependencies: thenDependencies<Variables, GivenState, WhenState, ThenState>(\n statement,\n parsers as unknown as Parser<any>[]\n ),\n step: addStep<\n ThenInput<Variables, never, never, never>,\n ThenOutput<ThenState>\n >(statement, THEN, undefined, parsers as unknown as Parser<any>[]),\n });\n\nconst thenStatement =\n <GivenState, WhenState, ThenState>() =>\n <Statement extends ((...args: [...any]) => string) | string>(\n statement: Statement\n ) => {\n const normalizedStatement: (...args: any[]) => string = isString(statement)\n ? () => statement\n : (statement as (...args: any[]) => string);\n\n type Variables = Statement extends string ? [] : GetFunctionArgs<Statement>;\n return {\n dependencies: thenDependencies<\n Variables,\n GivenState,\n WhenState,\n ThenState\n >(normalizedStatement),\n parsers: thenParsers<Variables, GivenState, WhenState, ThenState>(\n normalizedStatement\n ),\n step: addStep<\n ThenInput<Variables, never, never, never>,\n ThenOutput<ThenState>\n >(normalizedStatement, THEN),\n };\n };\n\nexport const thenBuilder = <GivenState, WhenState, ThenState>() => ({\n statement: thenStatement<GivenState, WhenState, ThenState>(),\n});\n","import { givenBuilder } from \"./given\";\nimport { thenBuilder } from \"./then\";\nimport { whenBuilder } from \"./when\";\n\nexport const createBuilders = <GivenState, WhenState, ThenState>() => {\n return {\n Given: givenBuilder<GivenState>().statement,\n When: whenBuilder<GivenState, WhenState>().statement,\n Then: thenBuilder<GivenState, WhenState, ThenState>().statement,\n };\n};\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n globalHookRegistry,\n PlainHookFn,\n ScenarioHookFn,\n ScenarioInfo,\n} from \"./runtime/hooks\";\nimport { MergeableWorld } from \"./world\";\n\n/**\n * Run before every scenario, with access to that scenario's fresh world. For\n * side effects only (reset a mock, seed an external system) — return values are\n * ignored; seed test *state* with given steps so the dependency graph stays the\n * single source of truth.\n */\nexport function beforeScenario<\n World extends MergeableWorld<any, any, any> = MergeableWorld<any, any, any>,\n>(\n fn: (context: {\n world: World;\n scenario: ScenarioInfo;\n }) => void | Promise<void>\n): void {\n globalHookRegistry.add({\n scope: \"scenario\",\n timing: \"before\",\n fn: fn as ScenarioHookFn,\n });\n}\n\n/**\n * Run after every scenario (even when a step failed), with access to that\n * scenario's world. Runs in reverse registration order so teardown unwinds\n * setup. For cleanup side effects only.\n */\nexport function afterScenario<\n World extends MergeableWorld<any, any, any> = MergeableWorld<any, any, any>,\n>(\n fn: (context: {\n world: World;\n scenario: ScenarioInfo;\n }) => void | Promise<void>\n): void {\n globalHookRegistry.add({\n scope: \"scenario\",\n timing: \"after\",\n fn: fn as ScenarioHookFn,\n });\n}\n\n/** Run once at the start of each feature file. No world exists at this boundary. */\nexport function beforeFeature(fn: PlainHookFn): void {\n globalHookRegistry.add({ scope: \"feature\", timing: \"before\", fn });\n}\n\n/** Run once at the end of each feature file (reverse registration order). */\nexport function afterFeature(fn: PlainHookFn): void {\n globalHookRegistry.add({ scope: \"feature\", timing: \"after\", fn });\n}\n\n/**\n * Run once before the entire run, ahead of any scenario (and before\n * concurrency starts). Multiple `beforeAll` hooks run **in parallel** with no\n * ordering between them — if a step of setup must precede another, sequence both\n * inside a single hook.\n */\nexport function beforeAll(fn: PlainHookFn): void {\n globalHookRegistry.add({ scope: \"global\", timing: \"before\", fn });\n}\n\n/**\n * Run once after the entire run, once every scenario is done. Multiple\n * `afterAll` hooks run **in parallel** with no ordering between them — sequence\n * dependent teardown inside a single hook.\n */\nexport function afterAll(fn: PlainHookFn): void {\n globalHookRegistry.add({ scope: \"global\", timing: \"after\", fn });\n}\n","import { givenBuilder } from \"./given\";\nimport { whenBuilder } from \"./when\";\nimport { thenBuilder } from \"./then\";\nimport { BasicWorld } from \"./world\";\nimport {\n stringParser,\n intParser,\n numberParser,\n booleanParser,\n} from \"./parsers\";\nimport type { Parser } from \"./parsers\";\nimport {\n analyze,\n extractStepDefinitions,\n parseFeatureFiles,\n parseFeatureContent,\n matchScenarioSteps,\n findMatchingDefinitions,\n defaultRules,\n} from \"./analyzer/index\";\nimport type {\n AnalyzerConfig,\n AnalyzeOptions,\n AnalysisRule,\n Diagnostic,\n StepDefinitionMeta,\n ParsedScenario,\n ParsedStep,\n MatchedStep,\n} from \"./analyzer/index\";\nimport { createBuilders } from \"./init\";\nimport {\n beforeScenario,\n afterScenario,\n beforeFeature,\n afterFeature,\n beforeAll,\n afterAll,\n} from \"./hooks\";\n\nexport {\n givenBuilder,\n whenBuilder,\n thenBuilder,\n BasicWorld,\n stringParser,\n intParser,\n numberParser,\n booleanParser,\n createBuilders,\n beforeScenario,\n afterScenario,\n beforeFeature,\n afterFeature,\n beforeAll,\n afterAll,\n};\n\nexport type { Parser };\nexport type {\n ScenarioInfo,\n PlainHookFn,\n ScenarioHookFn,\n} from \"./runtime/hooks\";\nexport type { StateFromDependencies } from \"./typeHelpers\";\n// Re-exported from the main entry so consumers can type their\n// `step-forge.config.ts` with a plain `@step-forge/step-forge` import.\nexport type { RunnerOptions } from \"./runtime/config\";\n\nexport const analyzer = {\n analyze,\n extractStepDefinitions,\n parseFeatureFiles,\n parseFeatureContent,\n matchScenarioSteps,\n findMatchingDefinitions,\n defaultRules,\n};\n\nexport type {\n AnalyzerConfig,\n AnalyzeOptions,\n AnalysisRule,\n Diagnostic,\n StepDefinitionMeta,\n ParsedScenario,\n ParsedStep,\n MatchedStep,\n};\n"],"mappings":";;;;;AAiCA,MAAa,YACX,cACwB,OAAO,cAAc;;;;ACN/C,MAAa,eAA+B;CAC1C,MAAM;CACN,QAAQ,CAAC,4BAA4B,0BAA0B;CAC/D,QAAO,UAAS;EACd,MAAM,QAAQ,gBAAgB,KAAK,KAAK,KAAK,gBAAgB,KAAK,KAAK;EACvE,OAAO,QAAQ,MAAM,EAAE,CAAC,QAAQ,aAAa,IAAI,IAAI;CACvD;AACF;;AAGA,MAAa,YAA4B;CACvC,MAAM;CACN,QAAQ;CACR,QAAO,UAAS,SAAS,OAAO,EAAE;AACpC;;AAGA,MAAa,eAA+B;CAC1C,MAAM;CACN,QAAQ;CACR,QAAO,UAAS,WAAW,KAAK;AAClC;;;;;;AAOA,MAAa,gBAAiC;CAC5C,MAAM;CACN,QAAQ;CACR,QAAO,UAAS,UAAU;AAC5B;;;AC3DA,MAAa,oBACX,MACA,UACG;CACH,KAAK,SAAQ,QAAO;EAClB,IAAI,CAAC,MAAM,MAAM,MACf,MAAM,IAAI,MAAM,OAAO,OAAO,GAAG,EAAE,4BAA4B;CAEnE,CAAC;CACD,OAAO,KAAK,QACT,KAAK,QAAQ;EACZ,OAAO;GACL,GAAG;IACF,MAAM,MAAM,MAAM;EACrB;CACF,GACA,CAAC,CACH;AACF;AACA,MAAa,mBACX,MACA,UACG;CACH,KAAK,SAAQ,QAAO;EAClB,IAAI,CAAC,MAAM,KAAK,MACd,MA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AAO;EAAU,QAAQ;EAAU;CAAG,CAAC;AAClE;;;;;;AAOA,SAAgB,SAAS,IAAuB;CAC9C,mBAAmB,IAAI;EAAE,OAAO;EAAU,QAAQ;EAAS;CAAG,CAAC;AACjE;;;ACRA,MAAa,WAAW;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;AACF"}
|
|
1
|
+
{"version":3,"file":"step-forge.js","names":[],"sources":["../../src/builderTypeUtils.ts","../../src/parsers.ts","../../src/utils.ts","../../src/common.ts","../../src/given.ts","../../src/when.ts","../../src/then.ts","../../src/analyzer/stepExtractor.ts","../../src/analyzer/stepMatcher.ts","../../src/analyzer/rules/ambiguousStepRule.ts","../../src/analyzer/rules/dependencyRule.ts","../../src/analyzer/rules/undefinedStepRule.ts","../../src/analyzer/rules/index.ts","../../src/analyzer/index.ts","../../src/init.ts","../../src/hooks.ts","../../src/index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nexport type StepType = \"given\" | \"when\" | \"then\";\n\n/** A dependency declaration: each key of a phase's state marked required/optional. */\nexport type RequiredOrOptional<T> = {\n [K in keyof T]?: \"required\" | \"optional\";\n};\n\n/** The dependency map for a single phase, keyed by state property name. */\nexport type DepMap = Record<string, \"required\" | \"optional\">;\n\n/** The fully-resolved dependency declaration passed to `addStep` at runtime. */\nexport type FullDependencies = {\n given: DepMap;\n when: DepMap;\n then: DepMap;\n};\n\n/**\n * Narrows a phase's full state to only the keys named in a dependency map.\n * Optional dependencies widen to `| undefined`; keys not present in the state\n * are dropped. This is the shape a step function sees for `given`/`when`/`then`.\n */\nexport type Restrict<State, Deps extends RequiredOrOptional<State>> = {\n [\n K in keyof State as K extends keyof Deps ? K : never\n ]: Deps[K] extends \"optional\" ? State[K] | undefined : State[K];\n};\n\nexport type GetFunctionArgs<T> = T extends (...args: infer A) => any\n ? A\n : never;\n\nexport const isString = (\n statement: string | ((...args: [...any]) => string)\n): statement is string => typeof statement === \"string\";\n","/**\n * A Parser is a typed cucumber-expression *parameter type*: it declares how a\n * value is recognised in a Gherkin step (`regexp`) and how the matched text is\n * turned into a TypeScript value (`parse`). The step expression uses `{name}`\n * as the placeholder.\n *\n * The engine folds each parser straight into the cucumber-expression matcher —\n * `parse` is the parameter type's transform, so coercion happens exactly once,\n * during matching (no second pass). This is also what lets a parser introduce a\n * brand-new placeholder like `{color}`: it is registered as a real parameter\n * type, so text that doesn't match `regexp` simply doesn't match the step.\n *\n * The four built-ins below reuse cucumber-expressions' own built-in parameter\n * types (`{int}`, `{float}`, `{string}`) — those names are already registered,\n * so the library performs the match + coercion and each parser's `regexp`/\n * `parse` serve to document intent and to drive TypeScript inference of the\n * variable type. `booleanParser` has no built-in equivalent, so it is a genuine\n * custom parameter type whose `parse` runs at match time.\n */\nexport type Parser<T> = {\n /** Parameter-type name; the step expression uses `{name}` as the placeholder. */\n name: string;\n /** How cucumber-expressions recognises the value in the step text. */\n regexp: RegExp | RegExp[];\n /** Transform the matched text into the typed value. */\n parse: (value: string) => T;\n};\n\n/** Matches a quoted string (`{string}`) and strips the surrounding quotes. */\nexport const stringParser: Parser<string> = {\n name: \"string\",\n regexp: [/\"([^\"\\\\]*(\\\\.[^\"\\\\]*)*)\"/, /'([^'\\\\]*(\\\\.[^'\\\\]*)*)'/],\n parse: value => {\n const match = /^\"([\\s\\S]*)\"$/.exec(value) ?? /^'([\\s\\S]*)'$/.exec(value);\n return match ? match[1].replace(/\\\\([\"'])/g, \"$1\") : value;\n },\n};\n\n/** Matches an unquoted integer (`{int}`). */\nexport const intParser: Parser<number> = {\n name: \"int\",\n regexp: /-?\\d+/,\n parse: value => parseInt(value, 10),\n};\n\n/** Matches an unquoted floating point number (`{float}`). */\nexport const numberParser: Parser<number> = {\n name: \"float\",\n regexp: /-?\\d*\\.?\\d+/,\n parse: value => parseFloat(value),\n};\n\n/**\n * Matches an unquoted `true`/`false` word (`{boolean}`) and parses it to a\n * boolean. Unlike the others this is a genuine custom parameter type — cucumber\n * has no built-in `boolean` — so its `regexp`/`parse` are what the matcher uses.\n */\nexport const booleanParser: Parser<boolean> = {\n name: \"boolean\",\n regexp: /true|false/,\n parse: value => value === \"true\",\n};\n","import { MergeableWorld } from \"./world\";\n\nexport const requireFromGiven = <G>(\n keys: (keyof G)[],\n world: MergeableWorld<G, unknown, unknown>\n) => {\n keys.forEach(key => {\n if (!world.given[key]) {\n throw new Error(`Key ${String(key)} is required in given state`);\n }\n });\n return keys.reduce(\n (acc, key) => {\n return {\n ...acc,\n [key]: world.given[key],\n };\n },\n {} as { [key in keyof G]: G[key] }\n );\n};\nexport const requireFromWhen = <W>(\n keys: (keyof W)[],\n world: MergeableWorld<unknown, W, unknown>\n) => {\n keys.forEach(key => {\n if (!world.when[key]) {\n throw new Error(`Key ${String(key)} is required in when state`);\n }\n });\n return keys.reduce(\n (acc, key) => {\n return {\n ...acc,\n [key]: world.when[key],\n };\n },\n {} as { [key in keyof W]: W[key] }\n );\n};\nexport const requireFromThen = <T>(\n keys: (keyof T)[],\n world: MergeableWorld<unknown, unknown, T>\n) => {\n keys.forEach(key => {\n if (!world.then[key]) {\n throw new Error(`Key ${String(key)} is required in then state`);\n }\n });\n return keys.reduce(\n (acc, key) => {\n return {\n ...acc,\n [key]: world.then[key],\n };\n },\n {} as { [key in keyof T]: T[key] }\n );\n};\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport _ from \"lodash\";\n\nimport { DepMap, FullDependencies, StepType } from \"./builderTypeUtils\";\nimport { Parser, stringParser } from \"./parsers\";\nimport { globalRegistry } from \"./runtime/registry\";\nimport { captureDefinitionSite } from \"./sourceLocation\";\nimport { requireFromGiven, requireFromThen, requireFromWhen } from \"./utils\";\nimport { MergeableWorld } from \"./world\";\n\n/**\n * The runtime core of the builder chain. `addStep` is deliberately phase-agnostic:\n * the calling builder (given/when/then) has already computed the exact type of the\n * step function via its two type parameters:\n *\n * - `StepFnInput` — the `{ variables, given, when, then }` object the step receives,\n * with each phase already narrowed to its declared dependencies.\n * - `StepFnOutput` — the phase-appropriate return type (`Partial<State>`, or `void`).\n *\n * Everything else is plain runtime data (a statement function, the step type, the\n * dependency map, the parsers), so `addStep` carries no generics for them.\n */\nexport const addStep =\n <StepFnInput, StepFnOutput>(\n statement: (...args: any[]) => string,\n stepType: StepType,\n dependencies: FullDependencies = {\n given: {},\n when: {},\n then: {},\n },\n declaredParsers?: Parser<any>[]\n ) =>\n (stepFunction: (input: StepFnInput) => StepFnOutput) => {\n const {\n given: givenDependencies,\n when: whenDependencies,\n then: thenDependencies,\n } = dependencies;\n // Resolve the parsers up front, defaulting every variable to `stringParser`\n // (the `{string}` placeholder, value passed through unchanged) when none are\n // provided. Numeric/boolean values are opt-in via explicit parsers.\n const argCount = statement.length;\n const parsers =\n declaredParsers ?? Array.from({ length: argCount }, () => stringParser);\n const expression = statement(...parsers.map(parser => `{${parser.name}}`));\n // The fully-wired step body, decoupled from any test runner: takes an\n // explicit world plus the values captured from a Gherkin step, validates +\n // narrows dependencies, runs the user's step, and merges the result. The\n // captured values arrive already coerced — each parser is registered as the\n // cucumber-expression parameter type, so `parse` runs during matching, not\n // here.\n const execute = async (\n world: MergeableWorld<any, any, any>,\n capturedArgs: unknown[]\n ) => {\n const requiredKeys = (deps: DepMap) =>\n Object.entries(deps)\n .filter(([, value]) => value === \"required\")\n .map(([key]) => key);\n const narrowedGiven = {\n ..._.pick(world.given, Object.keys(givenDependencies)),\n ...requireFromGiven(requiredKeys(givenDependencies), world),\n };\n const narrowedWhen = {\n ..._.pick(world.when, Object.keys(whenDependencies)),\n ...requireFromWhen(requiredKeys(whenDependencies), world),\n };\n const narrowedThen = {\n ..._.pick(world.then, Object.keys(thenDependencies)),\n ...requireFromThen(requiredKeys(thenDependencies), world),\n };\n const result = await stepFunction({\n variables: capturedArgs,\n given: narrowedGiven,\n when: narrowedWhen,\n then: narrowedThen,\n } as StepFnInput);\n world[stepType].merge({\n ...(result as any),\n });\n };\n\n // Registration is the terminal action of the builder chain: calling\n // `.step(fn)` makes the step matchable and executable by the runtime. We\n // capture *this* call site (the user's `.step(...)` line) so reporters can\n // show where a failing step is defined, Cucumber-style.\n const source = captureDefinitionSite();\n globalRegistry.add({ stepType, expression, parsers, execute, source });\n\n return {\n statement,\n expression,\n dependencies,\n stepType,\n stepFunction,\n };\n };\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport {\n FullDependencies,\n GetFunctionArgs,\n isString,\n RequiredOrOptional,\n Restrict,\n StepType,\n} from \"./builderTypeUtils\";\nimport { addStep } from \"./common\";\nimport { Parser } from \"./parsers\";\n\nconst GIVEN: StepType = \"given\";\n\n// The `{ variables, given, when, then }` object a given step receives. Only\n// `given` is reachable — when/then are `never`, enforcing phase restriction.\n// `Given` is the state already narrowed to declared dependencies (`never` when\n// no dependencies were declared).\ntype GivenInput<Variables, Given> = {\n variables: Variables;\n given: Given;\n when: never;\n then: never;\n};\ntype GivenOutput<GivenState> =\n Partial<GivenState> | Promise<Partial<GivenState>>;\n\nconst givenDependencies =\n <Variables, GivenState>(\n statement: (...args: any[]) => string,\n parsers?: Parser<any>[]\n ) =>\n <GivenDeps extends RequiredOrOptional<GivenState>>(dependencies: {\n given: GivenDeps;\n }) => ({\n step: addStep<\n GivenInput<Variables, Restrict<GivenState, GivenDeps>>,\n GivenOutput<GivenState>\n >(\n statement,\n GIVEN,\n { ...dependencies, when: {}, then: {} } as FullDependencies,\n parsers\n ),\n });\n\nconst givenParsers =\n <Variables extends any[], GivenState>(\n statement: (...args: any[]) => string\n ) =>\n <Parsers extends { [K in keyof Variables]: Parser<Variables[K]> }>(\n parsers: Parsers\n ) => ({\n dependencies: givenDependencies<Variables, GivenState>(\n statement,\n parsers as unknown as Parser<any>[]\n ),\n step: addStep<GivenInput<Variables, never>, GivenOutput<GivenState>>(\n statement,\n GIVEN,\n undefined,\n parsers as unknown as Parser<any>[]\n ),\n });\n\nconst givenStatement =\n <GivenState>() =>\n <Statement extends ((...args: [...any]) => string) | string>(\n statement: Statement\n ) => {\n const normalizedStatement: (...args: any[]) => string = isString(statement)\n ? () => statement\n : (statement as (...args: any[]) => string);\n\n type Variables = Statement extends string ? [] : GetFunctionArgs<Statement>;\n return {\n dependencies: givenDependencies<Variables, GivenState>(\n normalizedStatement\n ),\n parsers: givenParsers<Variables, GivenState>(normalizedStatement),\n step: addStep<GivenInput<Variables, never>, GivenOutput<GivenState>>(\n normalizedStatement,\n GIVEN\n ),\n };\n };\n\nexport const givenBuilder = <GivenState>() => ({\n statement: givenStatement<GivenState>(),\n});\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport {\n FullDependencies,\n GetFunctionArgs,\n isString,\n RequiredOrOptional,\n Restrict,\n StepType,\n} from \"./builderTypeUtils\";\nimport { addStep } from \"./common\";\nimport { Parser } from \"./parsers\";\n\nconst WHEN: StepType = \"when\";\n\n// The object a when step receives: `given` and `when` are reachable (narrowed to\n// declared dependencies, or `never` when none), `then` is always out of reach.\ntype WhenInput<Variables, Given, When> = {\n variables: Variables;\n given: Given;\n when: When;\n then: never;\n};\ntype WhenOutput<WhenState> = Partial<WhenState> | Promise<Partial<WhenState>>;\n\nconst whenDependencies =\n <Variables, GivenState, WhenState>(\n statement: (...args: any[]) => string,\n parsers?: Parser<any>[]\n ) =>\n <\n GivenDeps extends RequiredOrOptional<GivenState>,\n WhenDeps extends RequiredOrOptional<WhenState>,\n >(dependencies: {\n given?: GivenDeps;\n when?: WhenDeps;\n }) => ({\n step: addStep<\n WhenInput<\n Variables,\n Restrict<GivenState, GivenDeps>,\n Restrict<WhenState, WhenDeps>\n >,\n WhenOutput<WhenState>\n >(\n statement,\n WHEN,\n {\n given: dependencies.given ?? {},\n when: dependencies.when ?? {},\n then: {},\n } as FullDependencies,\n parsers\n ),\n });\n\nconst whenParsers =\n <Variables extends any[], GivenState, WhenState>(\n statement: (...args: any[]) => string\n ) =>\n <Parsers extends { [K in keyof Variables]: Parser<Variables[K]> }>(\n parsers: Parsers\n ) => ({\n dependencies: whenDependencies<Variables, GivenState, WhenState>(\n statement,\n parsers as unknown as Parser<any>[]\n ),\n step: addStep<WhenInput<Variables, never, never>, WhenOutput<WhenState>>(\n statement,\n WHEN,\n undefined,\n parsers as unknown as Parser<any>[]\n ),\n });\n\nconst whenStatement =\n <GivenState, WhenState>() =>\n <Statement extends ((...args: [...any]) => string) | string>(\n statement: Statement\n ) => {\n const normalizedStatement: (...args: any[]) => string = isString(statement)\n ? () => statement\n : (statement as (...args: any[]) => string);\n\n type Variables = Statement extends string ? [] : GetFunctionArgs<Statement>;\n return {\n dependencies: whenDependencies<Variables, GivenState, WhenState>(\n normalizedStatement\n ),\n parsers: whenParsers<Variables, GivenState, WhenState>(\n normalizedStatement\n ),\n step: addStep<WhenInput<Variables, never, never>, WhenOutput<WhenState>>(\n normalizedStatement,\n WHEN\n ),\n };\n };\n\nexport const whenBuilder = <GivenState, WhenState>() => ({\n statement: whenStatement<GivenState, WhenState>(),\n});\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport {\n FullDependencies,\n GetFunctionArgs,\n isString,\n RequiredOrOptional,\n Restrict,\n StepType,\n} from \"./builderTypeUtils\";\nimport { addStep } from \"./common\";\nimport { Parser } from \"./parsers\";\n\nconst THEN: StepType = \"then\";\n\n// The object a then step receives: all three phases are reachable (each narrowed\n// to declared dependencies, or `never` when none). Then steps may also return\n// nothing (assertion-only), hence the `void` in the output type.\ntype ThenInput<Variables, Given, When, Then> = {\n variables: Variables;\n given: Given;\n when: When;\n then: Then;\n};\ntype ThenOutput<ThenState> =\n Partial<ThenState> | Promise<Partial<ThenState>> | void | Promise<void>;\n\nconst thenDependencies =\n <Variables, GivenState, WhenState, ThenState>(\n statement: (...args: any[]) => string,\n parsers?: Parser<any>[]\n ) =>\n <\n GivenDeps extends RequiredOrOptional<GivenState>,\n WhenDeps extends RequiredOrOptional<WhenState>,\n ThenDeps extends RequiredOrOptional<ThenState>,\n >(dependencies: {\n given?: GivenDeps;\n when?: WhenDeps;\n then?: ThenDeps;\n }) => ({\n step: addStep<\n ThenInput<\n Variables,\n Restrict<GivenState, GivenDeps>,\n Restrict<WhenState, WhenDeps>,\n Restrict<ThenState, ThenDeps>\n >,\n ThenOutput<ThenState>\n >(\n statement,\n THEN,\n {\n given: dependencies.given ?? {},\n when: dependencies.when ?? {},\n then: dependencies.then ?? {},\n } as FullDependencies,\n parsers\n ),\n });\n\nconst thenParsers =\n <Variables extends any[], GivenState, WhenState, ThenState>(\n statement: (...args: any[]) => string\n ) =>\n <Parsers extends { [K in keyof Variables]: Parser<Variables[K]> }>(\n parsers: Parsers\n ) => ({\n dependencies: thenDependencies<Variables, GivenState, WhenState, ThenState>(\n statement,\n parsers as unknown as Parser<any>[]\n ),\n step: addStep<\n ThenInput<Variables, never, never, never>,\n ThenOutput<ThenState>\n >(statement, THEN, undefined, parsers as unknown as Parser<any>[]),\n });\n\nconst thenStatement =\n <GivenState, WhenState, ThenState>() =>\n <Statement extends ((...args: [...any]) => string) | string>(\n statement: Statement\n ) => {\n const normalizedStatement: (...args: any[]) => string = isString(statement)\n ? () => statement\n : (statement as (...args: any[]) => string);\n\n type Variables = Statement extends string ? [] : GetFunctionArgs<Statement>;\n return {\n dependencies: thenDependencies<\n Variables,\n GivenState,\n WhenState,\n ThenState\n >(normalizedStatement),\n parsers: thenParsers<Variables, GivenState, WhenState, ThenState>(\n normalizedStatement\n ),\n step: addStep<\n ThenInput<Variables, never, never, never>,\n ThenOutput<ThenState>\n >(normalizedStatement, THEN),\n };\n };\n\nexport const thenBuilder = <GivenState, WhenState, ThenState>() => ({\n statement: thenStatement<GivenState, WhenState, ThenState>(),\n});\n","import ts from \"typescript\";\nimport { StepDefinitionMeta } from \"./types.js\";\n\ntype StepType = \"given\" | \"when\" | \"then\";\n\nconst BUILDER_NAMES: Record<string, StepType> = {\n givenBuilder: \"given\",\n whenBuilder: \"when\",\n thenBuilder: \"then\",\n};\n\n/**\n * Threaded through the AST walk. `checker` is `null` on the parse-only fast\n * path; a step that genuinely needs type information sets `needsChecker`, which\n * triggers a one-time retry with a real type-checked `Program`.\n */\ninterface ExtractCtx {\n checker: ts.TypeChecker | null;\n needsChecker: boolean;\n}\n\nexport function extractStepDefinitions(\n filePaths: string[],\n tsConfigPath?: string\n): StepDefinitionMeta[] {\n // Fast path: parse each file with `createSourceFile` (tokenize + parse only,\n // no type resolution — ~1ms/file) and walk the AST. Building a full\n // type-checked `Program` loads `lib.*.d.ts` and resolves every import (~150ms)\n // and is only needed for two uncommon shapes: a `.step()` whose return isn't a\n // plain object literal, or the re-exported-builder pattern. Those set\n // `needsChecker`, and we retry once with a real Program below.\n const sources = filePaths\n .map(parseSourceFile)\n .filter((s): s is ts.SourceFile => s !== null);\n const fast = extractWithSources(sources, null);\n if (!fast.needsChecker) return fast.results;\n\n // Slow path: some step needs type information. Build the program once and\n // re-extract from *its* source files — the checker only understands nodes it\n // bound itself, so the parse-only ASTs above can't be reused here.\n const program = ts.createProgram(\n filePaths,\n resolveCompilerOptions(tsConfigPath)\n );\n const checker = program.getTypeChecker();\n const checkedSources = filePaths\n .map(fp => program.getSourceFile(fp))\n .filter((s): s is ts.SourceFile => s !== undefined);\n return extractWithSources(checkedSources, checker).results;\n}\n\n/** Parse a single file into an AST with no type resolution. */\nfunction parseSourceFile(filePath: string): ts.SourceFile | null {\n const text = ts.sys.readFile(filePath);\n if (text === undefined) return null;\n const scriptKind = filePath.endsWith(\".tsx\")\n ? ts.ScriptKind.TSX\n : ts.ScriptKind.TS;\n // setParentNodes: true — the extractor relies on `.getText()`/`.getStart()`,\n // which walk parent pointers up to the SourceFile.\n return ts.createSourceFile(\n filePath,\n text,\n ts.ScriptTarget.ESNext,\n true,\n scriptKind\n );\n}\n\n/** Resolve compiler options from tsconfig (fallback to sane defaults). */\nfunction resolveCompilerOptions(tsConfigPath?: string): ts.CompilerOptions {\n const configPath =\n tsConfigPath ?? ts.findConfigFile(process.cwd(), ts.sys.fileExists);\n let compilerOptions: ts.CompilerOptions = {\n target: ts.ScriptTarget.ESNext,\n module: ts.ModuleKind.ESNext,\n moduleResolution: ts.ModuleResolutionKind.Node10,\n strict: true,\n esModuleInterop: true,\n };\n\n if (configPath) {\n const configFile = ts.readConfigFile(configPath, ts.sys.readFile);\n if (!configFile.error) {\n const parsed = ts.parseJsonConfigFileContent(\n configFile.config,\n ts.sys,\n configPath.replace(/[/\\\\][^/\\\\]+$/, \"\")\n );\n compilerOptions = parsed.options;\n }\n }\n\n // Ensure noEmit so we don't write files\n compilerOptions.noEmit = true;\n return compilerOptions;\n}\n\nfunction extractWithSources(\n sources: ts.SourceFile[],\n checker: ts.TypeChecker | null\n): { results: StepDefinitionMeta[]; needsChecker: boolean } {\n const ctx: ExtractCtx = { checker, needsChecker: false };\n const results: StepDefinitionMeta[] = [];\n for (const sourceFile of sources) {\n results.push(...extractFromSourceFile(sourceFile, ctx));\n }\n return { results, needsChecker: ctx.needsChecker };\n}\n\nfunction extractFromSourceFile(\n sourceFile: ts.SourceFile,\n ctx: ExtractCtx\n): StepDefinitionMeta[] {\n const results: StepDefinitionMeta[] = [];\n\n function visit(node: ts.Node) {\n // The chain now terminates at `.step(...)`, which is the registration\n // point (there is no `.register()` anymore).\n if (\n ts.isCallExpression(node) &&\n ts.isPropertyAccessExpression(node.expression) &&\n node.expression.name.text === \"step\"\n ) {\n const meta = extractFromRegisterCall(node, sourceFile, ctx);\n if (meta) {\n results.push(meta);\n }\n }\n ts.forEachChild(node, visit);\n }\n\n visit(sourceFile);\n return results;\n}\n\nfunction extractFromRegisterCall(\n registerCall: ts.CallExpression,\n sourceFile: ts.SourceFile,\n ctx: ExtractCtx\n): StepDefinitionMeta | null {\n // Walk backwards through the method chain to find all parts\n // Pattern: builder().statement(...).dependencies?(...).step(...).register()\n // Or: Variable(\"...\").dependencies?(...).step(...).register()\n\n const chain = collectCallChain(registerCall);\n\n let stepType: StepType | null = null;\n let expression: string | null = null;\n let dependencies: StepDefinitionMeta[\"dependencies\"] = {\n given: {},\n when: {},\n then: {},\n };\n let produces: string[] = [];\n\n for (const link of chain) {\n const name = getCallName(link);\n if (!name) continue;\n\n if (name === \"register\") {\n // Already at register, continue\n continue;\n }\n\n if (name === \"step\") {\n produces = extractProducedKeys(link, ctx);\n continue;\n }\n\n if (name === \"dependencies\") {\n dependencies = extractDependencies(link);\n continue;\n }\n\n if (name === \"statement\") {\n expression = extractExpression(link);\n // Try to find the builder type by continuing up the chain\n continue;\n }\n\n // Check if this is a builder call like givenBuilder()\n if (BUILDER_NAMES[name]) {\n stepType = BUILDER_NAMES[name];\n continue;\n }\n }\n\n // If we didn't find the builder or expression in the chain, try the \"re-exported\" pattern:\n // const Given = givenBuilder<T>().statement;\n // Given(\"foo\").step(...).register()\n if (!stepType || !expression) {\n const reExport = resolveReExportedCall(chain, ctx);\n if (reExport) {\n if (!stepType) stepType = reExport.stepType;\n if (!expression) expression = reExport.expression;\n }\n }\n\n if (!stepType || !expression) {\n return null;\n }\n\n const line =\n sourceFile.getLineAndCharacterOfPosition(registerCall.getStart()).line + 1;\n\n return {\n stepType,\n expression,\n dependencies,\n produces,\n sourceFile: sourceFile.fileName,\n line,\n };\n}\n\n/**\n * Collect all call expressions in the method chain, from register() back to the origin.\n */\nfunction collectCallChain(call: ts.CallExpression): ts.CallExpression[] {\n const chain: ts.CallExpression[] = [call];\n let current: ts.Expression = call.expression;\n\n // Walk through PropertyAccessExpression to find the next call\n if (ts.isPropertyAccessExpression(current)) {\n current = current.expression;\n }\n\n while (ts.isCallExpression(current)) {\n chain.push(current);\n current = current.expression;\n if (ts.isPropertyAccessExpression(current)) {\n current = current.expression;\n }\n }\n\n return chain;\n}\n\nfunction getCallName(call: ts.CallExpression): string | null {\n const expr = call.expression;\n\n // .method() pattern\n if (ts.isPropertyAccessExpression(expr)) {\n return expr.name.text;\n }\n\n // direct call: functionName()\n if (ts.isIdentifier(expr)) {\n return expr.text;\n }\n\n return null;\n}\n\nfunction extractExpression(statementCall: ts.CallExpression): string | null {\n const arg = statementCall.arguments[0];\n if (!arg) return null;\n\n // String literal: .statement(\"a user\")\n if (ts.isStringLiteral(arg)) {\n return arg.text;\n }\n\n // Arrow function with template literal: .statement((name: string) => `a user named ${name}`)\n if (ts.isArrowFunction(arg)) {\n return extractExpressionFromArrowFunction(arg);\n }\n\n return null;\n}\n\nfunction extractExpressionFromArrowFunction(\n fn: ts.ArrowFunction\n): string | null {\n const params = fn.parameters.map(p => p.name.getText());\n\n // The body should be a template expression or string literal\n let body = fn.body;\n\n // If wrapped in a block with a return, unwrap\n if (ts.isBlock(body)) {\n const returnStmt = body.statements.find(ts.isReturnStatement);\n if (returnStmt?.expression) {\n body = returnStmt.expression;\n } else {\n return null;\n }\n }\n\n if (ts.isTemplateExpression(body)) {\n return reconstructExpressionFromTemplate(body, params);\n }\n\n if (ts.isNoSubstitutionTemplateLiteral(body)) {\n return body.text;\n }\n\n return null;\n}\n\nfunction reconstructExpressionFromTemplate(\n template: ts.TemplateExpression,\n paramNames: string[]\n): string {\n let result = template.head.text;\n\n for (const span of template.templateSpans) {\n if (\n ts.isIdentifier(span.expression) &&\n paramNames.includes(span.expression.text)\n ) {\n result += \"{string}\";\n } else {\n // Non-parameter expression, use {string} as fallback\n result += \"{string}\";\n }\n result += span.literal.text;\n }\n\n return result;\n}\n\nfunction extractDependencies(\n depsCall: ts.CallExpression\n): StepDefinitionMeta[\"dependencies\"] {\n const deps: StepDefinitionMeta[\"dependencies\"] = {\n given: {},\n when: {},\n then: {},\n };\n\n const arg = depsCall.arguments[0];\n if (!arg || !ts.isObjectLiteralExpression(arg)) return deps;\n\n for (const prop of arg.properties) {\n if (!ts.isPropertyAssignment(prop) || !ts.isIdentifier(prop.name)) continue;\n\n const phase = prop.name.text as \"given\" | \"when\" | \"then\";\n if (!deps[phase]) continue;\n\n if (ts.isObjectLiteralExpression(prop.initializer)) {\n for (const innerProp of prop.initializer.properties) {\n if (\n ts.isPropertyAssignment(innerProp) &&\n ts.isIdentifier(innerProp.name) &&\n ts.isStringLiteral(innerProp.initializer)\n ) {\n const val = innerProp.initializer.text;\n if (val === \"required\" || val === \"optional\") {\n deps[phase][innerProp.name.text] = val;\n }\n }\n }\n }\n }\n\n return deps;\n}\n\nfunction extractProducedKeys(\n stepCall: ts.CallExpression,\n ctx: ExtractCtx\n): string[] {\n const callback = stepCall.arguments[0];\n if (!callback) return [];\n\n // Try to get the return type of the callback by analyzing its body\n if (ts.isArrowFunction(callback) || ts.isFunctionExpression(callback)) {\n return extractProducedKeysFromCallback(callback, ctx);\n }\n\n return [];\n}\n\nfunction extractProducedKeysFromCallback(\n callback: ts.ArrowFunction | ts.FunctionExpression,\n ctx: ExtractCtx\n): string[] {\n const body = callback.body;\n\n // Concise arrow: () => ({ key: value })\n if (!ts.isBlock(body)) {\n return extractKeysFromExpression(body, ctx);\n }\n\n // Block body: look at return statements\n const keys = new Set<string>();\n function visitReturn(node: ts.Node) {\n if (ts.isReturnStatement(node) && node.expression) {\n for (const key of extractKeysFromExpression(node.expression, ctx)) {\n keys.add(key);\n }\n }\n ts.forEachChild(node, visitReturn);\n }\n visitReturn(body);\n return [...keys];\n}\n\nfunction extractKeysFromExpression(\n expr: ts.Expression,\n ctx: ExtractCtx\n): string[] {\n // Unwrap parenthesized expressions\n while (ts.isParenthesizedExpression(expr)) {\n expr = expr.expression;\n }\n\n // Object literal: { user: ..., token: ... }\n if (ts.isObjectLiteralExpression(expr)) {\n return expr.properties\n .filter(\n (p): p is ts.PropertyAssignment | ts.ShorthandPropertyAssignment =>\n ts.isPropertyAssignment(p) || ts.isShorthandPropertyAssignment(p)\n )\n .map(p => p.name.getText())\n .filter(Boolean);\n }\n\n // Non-literal return (a variable, a spread-only object, a function call): the\n // keys can only come from the type checker. On the parse-only pass we have\n // none — flag it so the caller retries with a real Program.\n if (!ctx.checker) {\n ctx.needsChecker = true;\n return [];\n }\n try {\n const type = ctx.checker.getTypeAtLocation(expr);\n return type\n .getProperties()\n .map(p => p.name)\n .filter(n => n !== \"merge\");\n } catch {\n return [];\n }\n}\n\ninterface ReExportResult {\n stepType: StepType;\n expression: string | null;\n}\n\nfunction resolveReExportedCall(\n chain: ts.CallExpression[],\n ctx: ExtractCtx\n): ReExportResult | null {\n // Look for the pattern: Variable(\"...\")... where Variable was assigned from builderType().statement\n // The last call in the chain (furthest from register) should be the variable call\n\n const lastCall = chain[chain.length - 1];\n if (!lastCall) return null;\n\n const expr = lastCall.expression;\n\n // If it's an identifier (like \"Given\", \"When\", \"Then\"), trace its declaration\n let identifier: ts.Identifier | null = null;\n if (ts.isIdentifier(expr)) {\n identifier = expr;\n } else if (\n ts.isPropertyAccessExpression(expr) &&\n ts.isIdentifier(expr.expression)\n ) {\n identifier = expr.expression;\n }\n\n if (!identifier) return null;\n\n // Tracing the re-exported builder's declaration needs symbol resolution,\n // which only a real Program provides. Flag for the checked retry.\n if (!ctx.checker) {\n ctx.needsChecker = true;\n return null;\n }\n\n const symbol = ctx.checker.getSymbolAtLocation(identifier);\n if (!symbol) return null;\n\n const decl = symbol.valueDeclaration;\n if (!decl || !ts.isVariableDeclaration(decl) || !decl.initializer)\n return null;\n\n // Check if initializer is builderType<T>().statement\n const init = decl.initializer;\n\n // Pattern: givenBuilder<T>().statement (PropertyAccessExpression)\n if (ts.isPropertyAccessExpression(init) && init.name.text === \"statement\") {\n const callExpr = init.expression;\n if (ts.isCallExpression(callExpr)) {\n const callee = callExpr.expression;\n if (ts.isIdentifier(callee) && BUILDER_NAMES[callee.text]) {\n // The lastCall IS the statement call — extract expression from it\n const expression = extractExpression(lastCall);\n return {\n stepType: BUILDER_NAMES[callee.text],\n expression,\n };\n }\n }\n }\n\n return null;\n}\n","import { MatchedStep, ParsedScenario, StepDefinitionMeta } from \"./types.js\";\n\ninterface CompiledPattern {\n regex: RegExp;\n definition: StepDefinitionMeta;\n}\n\nfunction compileDefinitions(\n definitions: StepDefinitionMeta[]\n): CompiledPattern[] {\n const compiled: CompiledPattern[] = [];\n for (const def of definitions) {\n try {\n // Replace {paramType} placeholders with (.+) to match any value,\n // regardless of which parser placeholder ({string}, {int}, ...) the\n // step definition declared.\n const placeholder = \"###PLACEHOLDER###\";\n const regexStr = def.expression\n .replace(/\\{[^}]+\\}/g, placeholder)\n .replace(/[.*+?^$()|[\\]\\\\]/g, \"\\\\$&\")\n .replace(new RegExp(placeholder, \"g\"), \"(.+)\");\n compiled.push({\n regex: new RegExp(`^${regexStr}$`, \"i\"),\n definition: def,\n });\n } catch {\n // Skip definitions with invalid expressions\n }\n }\n return compiled;\n}\n\nexport function matchScenarioSteps(\n scenario: ParsedScenario,\n definitions: StepDefinitionMeta[]\n): MatchedStep[] {\n const compiled = compileDefinitions(definitions);\n\n return scenario.steps.map(step => {\n const matches = findMatches(step.text, step.effectiveKeyword, compiled);\n return {\n ...step,\n definitions: matches,\n };\n });\n}\n\nexport function findMatchingDefinitions(\n text: string,\n effectiveKeyword: \"Given\" | \"When\" | \"Then\",\n definitions: StepDefinitionMeta[]\n): StepDefinitionMeta[] {\n const compiled = compileDefinitions(definitions);\n return findMatches(text, effectiveKeyword, compiled);\n}\n\nfunction findMatches(\n text: string,\n effectiveKeyword: \"Given\" | \"When\" | \"Then\",\n compiled: CompiledPattern[]\n): StepDefinitionMeta[] {\n const keywordToStepType: Record<string, string> = {\n Given: \"given\",\n When: \"when\",\n Then: \"then\",\n };\n const expectedStepType = keywordToStepType[effectiveKeyword];\n\n // First try to match with the correct step type\n const typedMatches: StepDefinitionMeta[] = [];\n for (const { regex, definition } of compiled) {\n if (definition.stepType !== expectedStepType) continue;\n if (regex.test(text)) typedMatches.push(definition);\n }\n\n if (typedMatches.length > 0) return typedMatches;\n\n // Fallback: match any step type\n const fallbackMatches: StepDefinitionMeta[] = [];\n for (const { regex, definition } of compiled) {\n if (regex.test(text)) fallbackMatches.push(definition);\n }\n\n return fallbackMatches;\n}\n","import {\n AnalysisRule,\n Diagnostic,\n MatchedStep,\n ParsedScenario,\n} from \"../types.js\";\n\nexport const ambiguousStepRule: AnalysisRule = {\n name: \"ambiguous-step\",\n\n check(scenario: ParsedScenario, matchedSteps: MatchedStep[]): Diagnostic[] {\n return matchedSteps\n .filter(step => step.definitions.length > 1)\n .map(step => {\n const locations = step.definitions\n .map(d => `${d.sourceFile}:${d.line}`)\n .join(\", \");\n return {\n file: scenario.file,\n range: {\n startLine: step.line,\n startColumn: step.column,\n endLine: step.line,\n endColumn: step.column + step.text.length,\n },\n severity: \"error\" as const,\n message: `Step \"${step.text}\" matches multiple step definitions: ${locations}`,\n rule: \"ambiguous-step\",\n source: \"step-forge\" as const,\n };\n });\n },\n};\n","import {\n AnalysisRule,\n Diagnostic,\n MatchedStep,\n ParsedScenario,\n} from \"../types.js\";\n\nexport const dependencyRule: AnalysisRule = {\n name: \"dependency-check\",\n\n check(scenario: ParsedScenario, matchedSteps: MatchedStep[]): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n const produced = {\n given: new Set<string>(),\n when: new Set<string>(),\n then: new Set<string>(),\n };\n\n for (const step of matchedSteps) {\n if (step.definitions.length !== 1) continue;\n\n const { dependencies, produces, stepType } = step.definitions[0];\n\n // Collect all missing required dependencies for this step\n const missing: Record<string, string[]> = {};\n for (const phase of [\"given\", \"when\", \"then\"] as const) {\n for (const [key, requirement] of Object.entries(dependencies[phase])) {\n if (requirement === \"required\" && !produced[phase].has(key)) {\n if (!missing[phase]) {\n missing[phase] = [];\n }\n missing[phase].push(key);\n }\n }\n }\n\n if (Object.keys(missing).length > 0) {\n const lines = Object.entries(missing).map(\n ([phase, keys]) =>\n `${phase.charAt(0).toUpperCase() + phase.slice(1)}: ${keys.map(k => `${phase}.${k}`).join(\", \")}`\n );\n const message = \"Missing required dependencies:\\n\" + lines.join(\"\\n\");\n\n diagnostics.push({\n file: scenario.file,\n range: {\n startLine: step.line,\n startColumn: step.column,\n endLine: step.line,\n endColumn: step.column + step.text.length,\n },\n severity: \"error\",\n message,\n rule: \"dependency-check\",\n source: \"step-forge\",\n });\n }\n\n // Add produced keys for this step\n for (const key of produces) {\n produced[stepType].add(key);\n }\n }\n\n return diagnostics;\n },\n};\n","import {\n AnalysisRule,\n Diagnostic,\n MatchedStep,\n ParsedScenario,\n} from \"../types.js\";\n\nexport const undefinedStepRule: AnalysisRule = {\n name: \"undefined-step\",\n\n check(scenario: ParsedScenario, matchedSteps: MatchedStep[]): Diagnostic[] {\n return matchedSteps\n .filter(step => step.definitions.length === 0)\n .map(step => ({\n file: scenario.file,\n range: {\n startLine: step.line,\n startColumn: step.column,\n endLine: step.line,\n endColumn: step.column + step.text.length,\n },\n severity: \"error\" as const,\n message: `Step \"${step.text}\" does not match any step definition`,\n rule: \"undefined-step\",\n source: \"step-forge\" as const,\n }));\n },\n};\n","import {\n AnalysisRule,\n Diagnostic,\n MatchedStep,\n ParsedScenario,\n} from \"../types.js\";\nimport { ambiguousStepRule } from \"./ambiguousStepRule.js\";\nimport { dependencyRule } from \"./dependencyRule.js\";\nimport { undefinedStepRule } from \"./undefinedStepRule.js\";\n\nexport const defaultRules: AnalysisRule[] = [\n undefinedStepRule,\n ambiguousStepRule,\n dependencyRule,\n];\n\nexport function runRules(\n rules: AnalysisRule[],\n scenario: ParsedScenario,\n matchedSteps: MatchedStep[]\n): Diagnostic[] {\n return rules.flatMap(rule => rule.check(scenario, matchedSteps));\n}\n","import { globFiles } from \"../globFiles.js\";\nimport { extractStepDefinitions } from \"./stepExtractor.js\";\nimport { parseFeatureFiles, parseFeatureContent } from \"./gherkinParser.js\";\nimport { matchScenarioSteps, findMatchingDefinitions } from \"./stepMatcher.js\";\nimport { defaultRules, runRules } from \"./rules/index.js\";\nimport type {\n AnalyzerConfig,\n AnalysisRule,\n Diagnostic,\n StepDefinitionMeta,\n ParsedScenario,\n MatchedStep,\n ParsedStep,\n} from \"./types.js\";\n\nexport type {\n AnalyzerConfig,\n AnalysisRule,\n Diagnostic,\n StepDefinitionMeta,\n ParsedScenario,\n MatchedStep,\n ParsedStep,\n};\n\nexport {\n extractStepDefinitions,\n parseFeatureFiles,\n parseFeatureContent,\n matchScenarioSteps,\n findMatchingDefinitions,\n defaultRules,\n};\n\nexport interface AnalyzeOptions {\n rules?: AnalysisRule[];\n}\n\nexport async function analyze(\n config: AnalyzerConfig,\n options?: AnalyzeOptions\n): Promise<Diagnostic[]> {\n const rules = options?.rules ?? defaultRules;\n\n // 1. Resolve file globs to paths\n const stepFilePaths = await globFiles(config.stepFiles);\n const featureFilePaths = await globFiles(config.featureFiles);\n\n if (stepFilePaths.length === 0) {\n return [];\n }\n if (featureFilePaths.length === 0) {\n return [];\n }\n\n // 2. Extract step metadata from step files\n const stepDefinitions = extractStepDefinitions(\n stepFilePaths,\n config.tsConfigPath\n );\n\n // 3. Parse feature files\n const scenarios = parseFeatureFiles(featureFilePaths);\n\n // 4. For each scenario, match steps and run rules\n const diagnostics: Diagnostic[] = [];\n for (const scenario of scenarios) {\n const matchedSteps = matchScenarioSteps(scenario, stepDefinitions);\n const scenarioDiags = runRules(rules, scenario, matchedSteps);\n diagnostics.push(...scenarioDiags);\n }\n\n return diagnostics;\n}\n","import { givenBuilder } from \"./given\";\nimport { thenBuilder } from \"./then\";\nimport { whenBuilder } from \"./when\";\n\nexport const createBuilders = <GivenState, WhenState, ThenState>() => {\n return {\n Given: givenBuilder<GivenState>().statement,\n When: whenBuilder<GivenState, WhenState>().statement,\n Then: thenBuilder<GivenState, WhenState, ThenState>().statement,\n };\n};\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n globalHookRegistry,\n PlainHookFn,\n ScenarioHookFn,\n ScenarioInfo,\n} from \"./runtime/hooks\";\nimport { MergeableWorld } from \"./world\";\n\n/**\n * Run before every scenario, with access to that scenario's fresh world. For\n * side effects only (reset a mock, seed an external system) — return values are\n * ignored; seed test *state* with given steps so the dependency graph stays the\n * single source of truth.\n */\nexport function beforeScenario<\n World extends MergeableWorld<any, any, any> = MergeableWorld<any, any, any>,\n>(\n fn: (context: {\n world: World;\n scenario: ScenarioInfo;\n }) => void | Promise<void>\n): void {\n globalHookRegistry.add({\n scope: \"scenario\",\n timing: \"before\",\n fn: fn as ScenarioHookFn,\n });\n}\n\n/**\n * Run after every scenario (even when a step failed), with access to that\n * scenario's world. Runs in reverse registration order so teardown unwinds\n * setup. For cleanup side effects only.\n */\nexport function afterScenario<\n World extends MergeableWorld<any, any, any> = MergeableWorld<any, any, any>,\n>(\n fn: (context: {\n world: World;\n scenario: ScenarioInfo;\n }) => void | Promise<void>\n): void {\n globalHookRegistry.add({\n scope: \"scenario\",\n timing: \"after\",\n fn: fn as ScenarioHookFn,\n });\n}\n\n/** Run once at the start of each feature file. No world exists at this boundary. */\nexport function beforeFeature(fn: PlainHookFn): void {\n globalHookRegistry.add({ scope: \"feature\", timing: \"before\", fn });\n}\n\n/** Run once at the end of each feature file (reverse registration order). */\nexport function afterFeature(fn: PlainHookFn): void {\n globalHookRegistry.add({ scope: \"feature\", timing: \"after\", fn });\n}\n\n/**\n * Run once before the entire run, ahead of any scenario (and before\n * concurrency starts). Multiple `beforeAll` hooks run **in parallel** with no\n * ordering between them — if a step of setup must precede another, sequence both\n * inside a single hook.\n */\nexport function beforeAll(fn: PlainHookFn): void {\n globalHookRegistry.add({ scope: \"global\", timing: \"before\", fn });\n}\n\n/**\n * Run once after the entire run, once every scenario is done. Multiple\n * `afterAll` hooks run **in parallel** with no ordering between them — sequence\n * dependent teardown inside a single hook.\n */\nexport function afterAll(fn: PlainHookFn): void {\n globalHookRegistry.add({ scope: \"global\", timing: \"after\", fn });\n}\n","import { givenBuilder } from \"./given\";\nimport { whenBuilder } from \"./when\";\nimport { thenBuilder } from \"./then\";\nimport { BasicWorld } from \"./world\";\nimport {\n stringParser,\n intParser,\n numberParser,\n booleanParser,\n} from \"./parsers\";\nimport type { Parser } from \"./parsers\";\nimport {\n analyze,\n extractStepDefinitions,\n parseFeatureFiles,\n parseFeatureContent,\n matchScenarioSteps,\n findMatchingDefinitions,\n defaultRules,\n} from \"./analyzer/index\";\nimport type {\n AnalyzerConfig,\n AnalyzeOptions,\n AnalysisRule,\n Diagnostic,\n StepDefinitionMeta,\n ParsedScenario,\n ParsedStep,\n MatchedStep,\n} from \"./analyzer/index\";\nimport { createBuilders } from \"./init\";\nimport {\n beforeScenario,\n afterScenario,\n beforeFeature,\n afterFeature,\n beforeAll,\n afterAll,\n} from \"./hooks\";\n\nexport {\n givenBuilder,\n whenBuilder,\n thenBuilder,\n BasicWorld,\n stringParser,\n intParser,\n numberParser,\n booleanParser,\n createBuilders,\n beforeScenario,\n afterScenario,\n beforeFeature,\n afterFeature,\n beforeAll,\n afterAll,\n};\n\nexport type { Parser };\nexport type {\n ScenarioInfo,\n PlainHookFn,\n ScenarioHookFn,\n} from \"./runtime/hooks\";\nexport type { StateFromDependencies } from \"./typeHelpers\";\n// Re-exported from the main entry so consumers can type their\n// `step-forge.config.ts` with a plain `@step-forge/step-forge` import.\nexport type { RunnerOptions } from \"./runtime/config\";\n\nexport const analyzer = {\n analyze,\n extractStepDefinitions,\n parseFeatureFiles,\n parseFeatureContent,\n matchScenarioSteps,\n findMatchingDefinitions,\n defaultRules,\n};\n\nexport type {\n AnalyzerConfig,\n AnalyzeOptions,\n AnalysisRule,\n Diagnostic,\n StepDefinitionMeta,\n ParsedScenario,\n ParsedStep,\n MatchedStep,\n};\n"],"mappings":";;;;;AAiCA,MAAa,YACX,cACwB,OAAO,cAAc;;;;ACN/C,MAAa,eAA+B;CAC1C,MAAM;CACN,QAAQ,CAAC,4BAA4B,0BAA0B;CAC/D,QAAO,UAAS;EACd,MAAM,QAAQ,gBAAgB,KAAK,KAAK,KAAK,gBAAgB,KAAK,KAAK;EACvE,OAAO,QAAQ,MAAM,EAAE,CAAC,QAAQ,aAAa,IAAI,IAAI;CACvD;AACF;;AAGA,MAAa,YAA4B;CACvC,MAAM;CACN,QAAQ;CACR,QAAO,UAAS,SAAS,OAAO,EAAE;AACpC;;AAGA,MAAa,eAA+B;CAC1C,MAAM;CACN,QAAQ;CACR,QAAO,UAAS,WAAW,KAAK;AAClC;;;;;;AAOA,MAAa,gBAAiC;CAC5C,MAAM;CACN,QAAQ;CACR,QAAO,UAAS,UAAU;AAC5B;;;AC3D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OAAO,CAAC;CAEV,IAAI,iBAAiB,WAAW,GAC9B,OAAO,CAAC;CAIV,MAAM,kBAAkB,uBACtB,eACA,OAAO,YACT;CAGA,MAAM,YAAY,kBAAkB,gBAAgB;CAGpD,MAAM,cAA4B,CAAC;CACnC,KAAK,MAAM,YAAY,WAAW;EAEhC,MAAM,gBAAgB,SAAS,OAAO,UADjB,mBAAmB,UAAU,eACS,CAAC;EAC5D,YAAY,KAAK,GAAG,aAAa;CACnC;CAEA,OAAO;AACT;;;ACrEA,MAAa,uBAAyD;CACpE,OAAO;EACL,OAAO,aAAyB,CAAC,CAAC;EAClC,MAAM,YAAmC,CAAC,CAAC;EAC3C,MAAM,YAA8C,CAAC,CAAC;CACxD;AACF;;;;;;;;;ACKA,SAAgB,eAGd,IAIM;CACN,mBAAmB,IAAI;EACrB,OAAO;EACP,QAAQ;EACJ;CACN,CAAC;AACH;;;;;;AAOA,SAAgB,cAGd,IAIM;CACN,mBAAmB,IAAI;EACrB,OAAO;EACP,QAAQ;EACJ;CACN,CAAC;AACH;;AAGA,SAAgB,cAAc,IAAuB;CACnD,mBAAmB,IAAI;EAAE,OAAO;EAAW,QAAQ;EAAU;CAAG,CAAC;AACnE;;AAGA,SAAgB,aAAa,IAAuB;CAClD,mBAAmB,IAAI;EAAE,OAAO;EAAW,QAAQ;EAAS;CAAG,CAAC;AAClE;;;;;;;AAQA,SAAgB,UAAU,IAAuB;CAC/C,mBAAmB,IAAI;EAAE,OAAO;EAAU,QAAQ;EAAU;CAAG,CAAC;AAClE;;;;;;AAOA,SAAgB,SAAS,IAAuB;CAC9C,mBAAmB,IAAI;EAAE,OAAO;EAAU,QAAQ;EAAS;CAAG,CAAC;AACjE;;;ACRA,MAAa,WAAW;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;AACF"}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"analyzer-5H699Eg4.js","names":[],"sources":["../../src/globFiles.ts","../../src/analyzer/stepExtractor.ts","../../src/analyzer/gherkinParser.ts","../../src/analyzer/stepMatcher.ts","../../src/analyzer/rules/ambiguousStepRule.ts","../../src/analyzer/rules/dependencyRule.ts","../../src/analyzer/rules/undefinedStepRule.ts","../../src/analyzer/rules/index.ts","../../src/analyzer/index.ts"],"sourcesContent":["import { glob } from \"node:fs/promises\";\nimport { stat } from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\n/** Glob metacharacters. A pattern with none of these is a literal path. */\nconst MAGIC = /[*?[\\]{}!()]/;\n\nasync function isFile(p: string): Promise<boolean> {\n try {\n return (await stat(p)).isFile();\n } catch {\n return false;\n }\n}\n\n/**\n * Resolve glob patterns to a de-duplicated list of absolute file paths, with one\n * important portability guarantee: a **literal absolute path** (no glob magic)\n * is returned directly if it exists, without being handed to `glob()`.\n *\n * This exists because `node:fs`'s `glob` diverges between runtimes — Node\n * matches an absolute-path pattern, Bun returns nothing for one. Rather than\n * depend on that behaviour, we only ever glob relative patterns (against `cwd`)\n * and short-circuit concrete absolute paths ourselves, so callers get identical\n * results under Node and Bun.\n */\nexport async function globFiles(\n patterns: string[],\n cwd: string = process.cwd()\n): Promise<string[]> {\n const files = new Set<string>();\n for (const pattern of patterns) {\n if (path.isAbsolute(pattern) && !MAGIC.test(pattern)) {\n if (await isFile(pattern)) files.add(pattern);\n continue;\n }\n for await (const match of glob(pattern, { cwd })) {\n files.add(path.resolve(cwd, match));\n }\n }\n return [...files];\n}\n","import ts from \"typescript\";\nimport { StepDefinitionMeta } from \"./types.js\";\n\ntype StepType = \"given\" | \"when\" | \"then\";\n\nconst BUILDER_NAMES: Record<string, StepType> = {\n givenBuilder: \"given\",\n whenBuilder: \"when\",\n thenBuilder: \"then\",\n};\n\n/**\n * Built-in parsers exported by the library, mapped to the cucumber-expression\n * placeholder they register. A step's `.parsers([...])` drives which `{name}`\n * each variable becomes; without this the extractor defaulted every variable to\n * `{string}`, so `the deposit amount is {int}` was recorded as `{string}` and a\n * plain number like `100` looked unmatched. Custom parsers are resolved from\n * their `name` property (see {@link resolveCustomParserName}); anything we can't\n * resolve falls back to `string`.\n */\nconst BUILTIN_PARSER_PLACEHOLDERS: Record<string, string> = {\n intParser: \"int\",\n numberParser: \"float\",\n stringParser: \"string\",\n booleanParser: \"boolean\",\n};\n\n/**\n * Threaded through the AST walk. `checker` is `null` on the parse-only fast\n * path; a step that genuinely needs type information sets `needsChecker`, which\n * triggers a one-time retry with a real type-checked `Program`.\n */\ninterface ExtractCtx {\n checker: ts.TypeChecker | null;\n needsChecker: boolean;\n}\n\nexport function extractStepDefinitions(\n filePaths: string[],\n tsConfigPath?: string\n): StepDefinitionMeta[] {\n // Fast path: parse each file with `createSourceFile` (tokenize + parse only,\n // no type resolution — ~1ms/file) and walk the AST. Building a full\n // type-checked `Program` loads `lib.*.d.ts` and resolves every import (~150ms)\n // and is only needed for two uncommon shapes: a `.step()` whose return isn't a\n // plain object literal, or the re-exported-builder pattern. Those set\n // `needsChecker`, and we retry once with a real Program below.\n const sources = filePaths\n .map(parseSourceFile)\n .filter((s): s is ts.SourceFile => s !== null);\n const fast = extractWithSources(sources, null);\n if (!fast.needsChecker) return fast.results;\n\n // Slow path: some step needs type information. Build the program once and\n // re-extract from *its* source files — the checker only understands nodes it\n // bound itself, so the parse-only ASTs above can't be reused here.\n const program = ts.createProgram(\n filePaths,\n resolveCompilerOptions(tsConfigPath)\n );\n const checker = program.getTypeChecker();\n const checkedSources = filePaths\n .map(fp => program.getSourceFile(fp))\n .filter((s): s is ts.SourceFile => s !== undefined);\n return extractWithSources(checkedSources, checker).results;\n}\n\n/** Parse a single file into an AST with no type resolution. */\nfunction parseSourceFile(filePath: string): ts.SourceFile | null {\n const text = ts.sys.readFile(filePath);\n if (text === undefined) return null;\n const scriptKind = filePath.endsWith(\".tsx\")\n ? ts.ScriptKind.TSX\n : ts.ScriptKind.TS;\n // setParentNodes: true — the extractor relies on `.getText()`/`.getStart()`,\n // which walk parent pointers up to the SourceFile.\n return ts.createSourceFile(\n filePath,\n text,\n ts.ScriptTarget.ESNext,\n true,\n scriptKind\n );\n}\n\n/** Resolve compiler options from tsconfig (fallback to sane defaults). */\nfunction resolveCompilerOptions(tsConfigPath?: string): ts.CompilerOptions {\n const configPath =\n tsConfigPath ?? ts.findConfigFile(process.cwd(), ts.sys.fileExists);\n let compilerOptions: ts.CompilerOptions = {\n target: ts.ScriptTarget.ESNext,\n module: ts.ModuleKind.ESNext,\n moduleResolution: ts.ModuleResolutionKind.Node10,\n strict: true,\n esModuleInterop: true,\n };\n\n if (configPath) {\n const configFile = ts.readConfigFile(configPath, ts.sys.readFile);\n if (!configFile.error) {\n const parsed = ts.parseJsonConfigFileContent(\n configFile.config,\n ts.sys,\n configPath.replace(/[/\\\\][^/\\\\]+$/, \"\")\n );\n compilerOptions = parsed.options;\n }\n }\n\n // Ensure noEmit so we don't write files\n compilerOptions.noEmit = true;\n return compilerOptions;\n}\n\nfunction extractWithSources(\n sources: ts.SourceFile[],\n checker: ts.TypeChecker | null\n): { results: StepDefinitionMeta[]; needsChecker: boolean } {\n const ctx: ExtractCtx = { checker, needsChecker: false };\n const results: StepDefinitionMeta[] = [];\n for (const sourceFile of sources) {\n results.push(...extractFromSourceFile(sourceFile, ctx));\n }\n return { results, needsChecker: ctx.needsChecker };\n}\n\nfunction extractFromSourceFile(\n sourceFile: ts.SourceFile,\n ctx: ExtractCtx\n): StepDefinitionMeta[] {\n const results: StepDefinitionMeta[] = [];\n\n function visit(node: ts.Node) {\n // The chain now terminates at `.step(...)`, which is the registration\n // point (there is no `.register()` anymore).\n if (\n ts.isCallExpression(node) &&\n ts.isPropertyAccessExpression(node.expression) &&\n node.expression.name.text === \"step\"\n ) {\n const meta = extractFromRegisterCall(node, sourceFile, ctx);\n if (meta) {\n results.push(meta);\n }\n }\n ts.forEachChild(node, visit);\n }\n\n visit(sourceFile);\n return results;\n}\n\nfunction extractFromRegisterCall(\n registerCall: ts.CallExpression,\n sourceFile: ts.SourceFile,\n ctx: ExtractCtx\n): StepDefinitionMeta | null {\n // Walk backwards through the method chain to find all parts\n // Pattern: builder().statement(...).dependencies?(...).step(...).register()\n // Or: Variable(\"...\").dependencies?(...).step(...).register()\n\n const chain = collectCallChain(registerCall);\n\n let stepType: StepType | null = null;\n let statementCall: ts.CallExpression | null = null;\n let expression: string | null = null;\n let dependencies: StepDefinitionMeta[\"dependencies\"] = {\n given: {},\n when: {},\n then: {},\n };\n let produces: string[] = [];\n // Placeholder names per variable, from `.parsers([...])` (positional).\n let placeholders: string[] | null = null;\n\n for (const link of chain) {\n const name = getCallName(link);\n if (!name) continue;\n\n if (name === \"register\") {\n // Already at register, continue\n continue;\n }\n\n if (name === \"step\") {\n produces = extractProducedKeys(link, ctx);\n continue;\n }\n\n if (name === \"dependencies\") {\n dependencies = extractDependencies(link);\n continue;\n }\n\n if (name === \"parsers\") {\n placeholders = resolveParserPlaceholders(link, sourceFile);\n continue;\n }\n\n if (name === \"statement\") {\n statementCall = link;\n // Try to find the builder type by continuing up the chain\n continue;\n }\n\n // Check if this is a builder call like givenBuilder()\n if (BUILDER_NAMES[name]) {\n stepType = BUILDER_NAMES[name];\n continue;\n }\n }\n\n // Build the expression after the whole chain is seen, so `.parsers([...])` —\n // which the chain visits before `.statement(...)` here, but conceptually\n // annotates it — determines each variable's placeholder.\n if (statementCall)\n expression = extractExpression(statementCall, placeholders);\n\n // If we didn't find the builder or expression in the chain, try the \"re-exported\" pattern:\n // const Given = givenBuilder<T>().statement;\n // Given(\"foo\").step(...).register()\n if (!stepType || !expression) {\n const reExport = resolveReExportedCall(chain, ctx);\n if (reExport) {\n if (!stepType) stepType = reExport.stepType;\n if (!expression) expression = reExport.expression;\n }\n }\n\n if (!stepType || !expression) {\n return null;\n }\n\n const line =\n sourceFile.getLineAndCharacterOfPosition(registerCall.getStart()).line + 1;\n\n return {\n stepType,\n expression,\n dependencies,\n produces,\n sourceFile: sourceFile.fileName,\n line,\n };\n}\n\n/**\n * Collect all call expressions in the method chain, from register() back to the origin.\n */\nfunction collectCallChain(call: ts.CallExpression): ts.CallExpression[] {\n const chain: ts.CallExpression[] = [call];\n let current: ts.Expression = call.expression;\n\n while (true) {\n // Walk through PropertyAccessExpression to find the next call\n if (ts.isPropertyAccessExpression(current)) {\n current = current.expression;\n }\n\n if (ts.isCallExpression(current)) {\n chain.push(current);\n current = current.expression;\n } else {\n break;\n }\n }\n\n return chain;\n}\n\nfunction getCallName(call: ts.CallExpression): string | null {\n const expr = call.expression;\n\n // .method() pattern\n if (ts.isPropertyAccessExpression(expr)) {\n return expr.name.text;\n }\n\n // direct call: functionName()\n if (ts.isIdentifier(expr)) {\n return expr.text;\n }\n\n return null;\n}\n\nfunction extractExpression(\n statementCall: ts.CallExpression,\n placeholders: string[] | null\n): string | null {\n const arg = statementCall.arguments[0];\n if (!arg) return null;\n\n // String literal: .statement(\"a user\")\n if (ts.isStringLiteral(arg)) {\n return arg.text;\n }\n\n // Arrow function with template literal: .statement((name: string) => `a user named ${name}`)\n if (ts.isArrowFunction(arg)) {\n return extractExpressionFromArrowFunction(arg, placeholders);\n }\n\n return null;\n}\n\nfunction extractExpressionFromArrowFunction(\n fn: ts.ArrowFunction,\n placeholders: string[] | null\n): string | null {\n const params = fn.parameters.map(p => p.name.getText());\n\n // The body should be a template expression or string literal\n let body = fn.body;\n\n // If wrapped in a block with a return, unwrap\n if (ts.isBlock(body)) {\n const returnStmt = body.statements.find(ts.isReturnStatement);\n if (returnStmt?.expression) {\n body = returnStmt.expression;\n } else {\n return null;\n }\n }\n\n if (ts.isTemplateExpression(body)) {\n return reconstructExpressionFromTemplate(body, params, placeholders);\n }\n\n if (ts.isNoSubstitutionTemplateLiteral(body)) {\n return body.text;\n }\n\n return null;\n}\n\nfunction reconstructExpressionFromTemplate(\n template: ts.TemplateExpression,\n paramNames: string[],\n placeholders: string[] | null\n): string {\n let result = template.head.text;\n\n for (const span of template.templateSpans) {\n // A variable interpolation becomes its declared parser placeholder (default\n // `{string}`); a non-variable interpolation falls back to `{string}`.\n let placeholder = \"string\";\n if (\n ts.isIdentifier(span.expression) &&\n paramNames.includes(span.expression.text)\n ) {\n const index = paramNames.indexOf(span.expression.text);\n placeholder = placeholders?.[index] ?? \"string\";\n }\n result += `{${placeholder}}`;\n result += span.literal.text;\n }\n\n return result;\n}\n\n/**\n * Resolve `.parsers([intParser, colorParser])` to the placeholder name for each\n * variable, positionally. Built-ins map via {@link BUILTIN_PARSER_PLACEHOLDERS};\n * a custom parser is resolved from its `name` property in the same source file;\n * anything unresolved defaults to `string`, matching the runtime default parser.\n */\nfunction resolveParserPlaceholders(\n parsersCall: ts.CallExpression,\n sourceFile: ts.SourceFile\n): string[] | null {\n const arg = parsersCall.arguments[0];\n if (!arg || !ts.isArrayLiteralExpression(arg)) return null;\n return arg.elements.map(element => {\n if (ts.isIdentifier(element)) {\n const builtin = BUILTIN_PARSER_PLACEHOLDERS[element.text];\n if (builtin) return builtin;\n const custom = resolveCustomParserName(element.text, sourceFile);\n if (custom) return custom;\n }\n return \"string\";\n });\n}\n\n/**\n * Find `const <identifier> = { name: \"...\", ... }` in `sourceFile` and return\n * its `name` — the cucumber placeholder a custom `Parser` registers. Scoped to\n * the file, so a parser imported from elsewhere won't resolve (it falls back to\n * `string`); the common in-file `const colorParser: Parser<Color> = {...}` does.\n */\nfunction resolveCustomParserName(\n identifier: string,\n sourceFile: ts.SourceFile\n): string | null {\n let found: string | null = null;\n const visit = (node: ts.Node): void => {\n if (found) return;\n if (\n ts.isVariableDeclaration(node) &&\n ts.isIdentifier(node.name) &&\n node.name.text === identifier &&\n node.initializer &&\n ts.isObjectLiteralExpression(node.initializer)\n ) {\n for (const prop of node.initializer.properties) {\n if (\n ts.isPropertyAssignment(prop) &&\n ts.isIdentifier(prop.name) &&\n prop.name.text === \"name\" &&\n ts.isStringLiteralLike(prop.initializer)\n ) {\n found = prop.initializer.text;\n return;\n }\n }\n }\n ts.forEachChild(node, visit);\n };\n visit(sourceFile);\n return found;\n}\n\nfunction extractDependencies(\n depsCall: ts.CallExpression\n): StepDefinitionMeta[\"dependencies\"] {\n const deps: StepDefinitionMeta[\"dependencies\"] = {\n given: {},\n when: {},\n then: {},\n };\n\n const arg = depsCall.arguments[0];\n if (!arg || !ts.isObjectLiteralExpression(arg)) return deps;\n\n for (const prop of arg.properties) {\n if (!ts.isPropertyAssignment(prop) || !ts.isIdentifier(prop.name)) continue;\n\n const phase = prop.name.text as \"given\" | \"when\" | \"then\";\n if (!deps[phase]) continue;\n\n if (ts.isObjectLiteralExpression(prop.initializer)) {\n for (const innerProp of prop.initializer.properties) {\n if (\n ts.isPropertyAssignment(innerProp) &&\n ts.isIdentifier(innerProp.name) &&\n ts.isStringLiteral(innerProp.initializer)\n ) {\n const val = innerProp.initializer.text;\n if (val === \"required\" || val === \"optional\") {\n deps[phase][innerProp.name.text] = val;\n }\n }\n }\n }\n }\n\n return deps;\n}\n\nfunction extractProducedKeys(\n stepCall: ts.CallExpression,\n ctx: ExtractCtx\n): string[] {\n const callback = stepCall.arguments[0];\n if (!callback) return [];\n\n // Try to get the return type of the callback by analyzing its body\n if (ts.isArrowFunction(callback) || ts.isFunctionExpression(callback)) {\n return extractProducedKeysFromCallback(callback, ctx);\n }\n\n return [];\n}\n\nfunction extractProducedKeysFromCallback(\n callback: ts.ArrowFunction | ts.FunctionExpression,\n ctx: ExtractCtx\n): string[] {\n const body = callback.body;\n\n // Concise arrow: () => ({ key: value })\n if (!ts.isBlock(body)) {\n return extractKeysFromExpression(body, ctx);\n }\n\n // Block body: look at return statements\n const keys = new Set<string>();\n function visitReturn(node: ts.Node) {\n if (ts.isReturnStatement(node) && node.expression) {\n for (const key of extractKeysFromExpression(node.expression, ctx)) {\n keys.add(key);\n }\n }\n ts.forEachChild(node, visitReturn);\n }\n visitReturn(body);\n return [...keys];\n}\n\nfunction extractKeysFromExpression(\n expr: ts.Expression,\n ctx: ExtractCtx\n): string[] {\n // Unwrap parenthesized expressions\n while (ts.isParenthesizedExpression(expr)) {\n expr = expr.expression;\n }\n\n // Object literal: { user: ..., token: ... }\n if (ts.isObjectLiteralExpression(expr)) {\n return expr.properties\n .filter(\n (p): p is ts.PropertyAssignment | ts.ShorthandPropertyAssignment =>\n ts.isPropertyAssignment(p) || ts.isShorthandPropertyAssignment(p)\n )\n .map(p => p.name.getText())\n .filter(Boolean);\n }\n\n // Non-literal return (a variable, a spread-only object, a function call): the\n // keys can only come from the type checker. On the parse-only pass we have\n // none — flag it so the caller retries with a real Program.\n if (!ctx.checker) {\n ctx.needsChecker = true;\n return [];\n }\n try {\n const type = ctx.checker.getTypeAtLocation(expr);\n return type\n .getProperties()\n .map(p => p.name)\n .filter(n => n !== \"merge\");\n } catch {\n return [];\n }\n}\n\ninterface ReExportResult {\n stepType: StepType;\n expression: string | null;\n}\n\nfunction resolveReExportedCall(\n chain: ts.CallExpression[],\n ctx: ExtractCtx\n): ReExportResult | null {\n // Look for the pattern: Variable(\"...\")... where Variable was assigned from builderType().statement\n // The last call in the chain (furthest from register) should be the variable call\n\n const lastCall = chain[chain.length - 1];\n if (!lastCall) return null;\n\n const expr = lastCall.expression;\n\n // If it's an identifier (like \"Given\", \"When\", \"Then\"), trace its declaration\n let identifier: ts.Identifier | null = null;\n if (ts.isIdentifier(expr)) {\n identifier = expr;\n } else if (\n ts.isPropertyAccessExpression(expr) &&\n ts.isIdentifier(expr.expression)\n ) {\n identifier = expr.expression;\n }\n\n if (!identifier) return null;\n\n // Tracing the re-exported builder's declaration needs symbol resolution,\n // which only a real Program provides. Flag for the checked retry.\n if (!ctx.checker) {\n ctx.needsChecker = true;\n return null;\n }\n\n const symbol = ctx.checker.getSymbolAtLocation(identifier);\n if (!symbol) return null;\n\n const decl = symbol.valueDeclaration;\n if (!decl || !ts.isVariableDeclaration(decl) || !decl.initializer)\n return null;\n\n // Check if initializer is builderType<T>().statement\n const init = decl.initializer;\n\n // Pattern: givenBuilder<T>().statement (PropertyAccessExpression)\n if (ts.isPropertyAccessExpression(init) && init.name.text === \"statement\") {\n const callExpr = init.expression;\n if (ts.isCallExpression(callExpr)) {\n const callee = callExpr.expression;\n if (ts.isIdentifier(callee) && BUILDER_NAMES[callee.text]) {\n // The lastCall IS the statement call — extract expression from it.\n // The re-exported-builder pattern carries no `.parsers(...)`, so\n // variables fall back to the default `{string}` placeholder.\n const expression = extractExpression(lastCall, null);\n return {\n stepType: BUILDER_NAMES[callee.text],\n expression,\n };\n }\n }\n }\n\n return null;\n}\n","import * as fs from \"node:fs\";\nimport {\n GherkinClassicTokenMatcher,\n Parser,\n AstBuilder,\n} from \"@cucumber/gherkin\";\nimport * as messages from \"@cucumber/messages\";\nimport { ParsedScenario, ParsedStep } from \"./types.js\";\n\ntype GherkinKeyword = \"Given\" | \"When\" | \"Then\" | \"And\" | \"But\";\n\nexport function parseFeatureFiles(filePaths: string[]): ParsedScenario[] {\n const scenarios: ParsedScenario[] = [];\n\n for (const filePath of filePaths) {\n const content = fs.readFileSync(filePath, \"utf-8\");\n const parsed = parseFeatureContent(content, filePath);\n scenarios.push(...parsed);\n }\n\n return scenarios;\n}\n\n/**\n * One parsed feature file: its `Feature:` title (empty if unnamed) plus every\n * scenario (outline rows expanded). {@link parseFeatureContent} exposes just the\n * scenarios; {@link parseFeatureCatalog} keeps the title too, for UIs that label\n * scenarios by their feature.\n */\nexport interface ParsedFeature {\n file: string;\n name: string;\n scenarios: ParsedScenario[];\n}\n\n/** Build a fresh gherkin parser and parse `content` into a document. */\nfunction parseDocument(content: string): messages.GherkinDocument {\n const builder = new AstBuilder(messages.IdGenerator.uuid());\n const matcher = new GherkinClassicTokenMatcher();\n return new Parser(builder, matcher).parse(content);\n}\n\n/**\n * Parse feature files into a catalog of `{ file, name, scenarios }`, one entry\n * per file (one gherkin parse each). Used by interactive mode to offer\n * feature/scenario names as typeahead choices labelled by their `Feature:` title.\n */\nexport function parseFeatureCatalog(filePaths: string[]): ParsedFeature[] {\n return filePaths.map(file => {\n const document = parseDocument(fs.readFileSync(file, \"utf-8\"));\n return {\n file,\n name: document.feature?.name ?? \"\",\n scenarios: documentToScenarios(document, file),\n };\n });\n}\n\nexport function parseFeatureContent(\n content: string,\n filePath: string\n): ParsedScenario[] {\n return documentToScenarios(parseDocument(content), filePath);\n}\n\n/** Expand a parsed gherkin document into scenarios (outline rows included). */\nfunction documentToScenarios(\n gherkinDocument: messages.GherkinDocument,\n filePath: string\n): ParsedScenario[] {\n const feature = gherkinDocument.feature;\n if (!feature) return [];\n\n // Collect background steps at the feature level\n const featureBackground: messages.Step[] = [];\n const scenarios: ParsedScenario[] = [];\n const featureTags = tagNames(feature.tags);\n\n for (const child of feature.children) {\n if (child.background) {\n featureBackground.push(...child.background.steps);\n }\n\n if (child.scenario) {\n scenarios.push(\n ...expandScenario(\n child.scenario,\n featureBackground,\n filePath,\n featureTags\n )\n );\n }\n\n if (child.rule) {\n // Rules can have their own backgrounds and tags, both inherited by the\n // rule's scenarios.\n const ruleBackground: messages.Step[] = [...featureBackground];\n const ruleTags = [...featureTags, ...tagNames(child.rule.tags)];\n for (const ruleChild of child.rule.children) {\n if (ruleChild.background) {\n ruleBackground.push(...ruleChild.background.steps);\n }\n if (ruleChild.scenario) {\n scenarios.push(\n ...expandScenario(\n ruleChild.scenario,\n ruleBackground,\n filePath,\n ruleTags\n )\n );\n }\n }\n }\n }\n\n return scenarios;\n}\n\n/** Extract tag names (each keeping its leading `@`), deduped in order. */\nfunction tagNames(tags: readonly messages.Tag[] | undefined): string[] {\n return [...new Set((tags ?? []).map(t => t.name))];\n}\n\nfunction expandScenario(\n scenario: messages.Scenario,\n backgroundSteps: messages.Step[],\n filePath: string,\n inheritedTags: string[]\n): ParsedScenario[] {\n const scenarioTags = [...inheritedTags, ...tagNames(scenario.tags)];\n const hasExamples =\n scenario.examples.length > 0 &&\n scenario.examples.some(e => e.tableBody.length > 0);\n\n if (!hasExamples) {\n // Regular scenario\n const bgParsed = convertSteps(backgroundSteps);\n const scenarioParsed = convertSteps(scenario.steps);\n const allSteps = resolveEffectiveKeywords([...bgParsed, ...scenarioParsed]);\n\n return [\n {\n name: scenario.name,\n file: filePath,\n line: scenario.location.line,\n steps: allSteps,\n tags: scenarioTags,\n },\n ];\n }\n\n // Scenario Outline — expand with each example row. Rows carry the outline's\n // base name so the runner can group them, plus the Examples-block tags.\n const results: ParsedScenario[] = [];\n for (const example of scenario.examples) {\n if (!example.tableHeader || example.tableBody.length === 0) continue;\n const headers = example.tableHeader.cells.map(c => c.value);\n const exampleTags = [...scenarioTags, ...tagNames(example.tags)];\n\n for (const row of example.tableBody) {\n const values = row.cells.map(c => c.value);\n const substitution: Record<string, string> = {};\n headers.forEach((h, i) => {\n substitution[h] = values[i];\n });\n\n const bgParsed = convertSteps(backgroundSteps);\n const scenarioSteps = convertSteps(scenario.steps).map(step => ({\n ...step,\n text: substituteExampleValues(step.text, substitution),\n }));\n const allSteps = resolveEffectiveKeywords([\n ...bgParsed,\n ...scenarioSteps,\n ]);\n\n results.push({\n name: headers.map((h, i) => `${h}=${values[i]}`).join(\", \"),\n file: filePath,\n line: row.location.line,\n steps: allSteps,\n tags: exampleTags,\n outline: { name: scenario.name },\n });\n }\n }\n\n return results;\n}\n\nfunction convertSteps(\n steps: readonly messages.Step[]\n): Omit<ParsedStep, \"effectiveKeyword\">[] {\n return steps.map(step => ({\n keyword: normalizeKeyword(step.keyword),\n text: step.text,\n line: step.location.line,\n // step.location.column points to the keyword start; shift past the\n // keyword (which includes a trailing space) so column points to the\n // start of the step text. This makes `column + text.length` produce\n // the correct end position for diagnostic ranges.\n column: (step.location.column ?? 1) + step.keyword.length,\n }));\n}\n\nfunction normalizeKeyword(keyword: string): GherkinKeyword {\n const trimmed = keyword.trim();\n // Gherkin keywords may include trailing space, e.g. \"Given \"\n if (trimmed === \"Given\") return \"Given\";\n if (trimmed === \"When\") return \"When\";\n if (trimmed === \"Then\") return \"Then\";\n if (trimmed === \"And\") return \"And\";\n if (trimmed === \"But\") return \"But\";\n // Fallback: treat as Given (shouldn't happen with valid Gherkin)\n return \"Given\";\n}\n\nfunction resolveEffectiveKeywords(\n steps: Omit<ParsedStep, \"effectiveKeyword\">[]\n): ParsedStep[] {\n let lastEffective: \"Given\" | \"When\" | \"Then\" = \"Given\";\n\n return steps.map(step => {\n let effectiveKeyword: \"Given\" | \"When\" | \"Then\";\n if (step.keyword === \"And\" || step.keyword === \"But\") {\n effectiveKeyword = lastEffective;\n } else {\n effectiveKeyword = step.keyword as \"Given\" | \"When\" | \"Then\";\n }\n lastEffective = effectiveKeyword;\n\n return {\n ...step,\n effectiveKeyword,\n };\n });\n}\n\nfunction substituteExampleValues(\n text: string,\n substitution: Record<string, string>\n): string {\n let result = text;\n for (const [key, value] of Object.entries(substitution)) {\n result = result.replace(new RegExp(`<${key}>`, \"g\"), value);\n }\n return result;\n}\n","import {\n CucumberExpression,\n ParameterType,\n ParameterTypeRegistry,\n} from \"@cucumber/cucumber-expressions\";\nimport { MatchedStep, ParsedScenario, StepDefinitionMeta } from \"./types.js\";\n\ninterface CompiledPattern {\n expression: CucumberExpression;\n definition: StepDefinitionMeta;\n}\n\n/** `{name}` tokens in a cucumber expression (empty name is the anonymous `{}`). */\nconst PARAM_TOKEN = /\\{([^}]*)\\}/g;\n\n/**\n * Compile each definition's cucumber expression with the **same** engine the\n * runtime uses (`@cucumber/cucumber-expressions`), so the analyzer and the\n * runtime agree on what a step matches.\n *\n * A hand-rolled `{param}` → `(.+)` regex used to stand in here, but it treated\n * cucumber-expression alternative (`a/b`) and optional (`text(s)`) syntax as\n * literal characters — so any step definition using them (e.g.\n * `there should be {int} error/errors`) never matched, and every such step was\n * wrongly reported as an undefined step regardless of the real state.\n *\n * Built-in placeholders (`{int}`, `{float}`, `{string}`, `{word}`) keep their\n * real, strict regexes so the analyzer disambiguates the way the runtime does\n * (e.g. `no` isn't an `{int}`). The analyzer has only the expression string, not\n * a custom parser's regexp, so each custom `{name}` is registered as a permissive\n * parameter type (any value) — lenient about the value's exact shape, but still\n * anchored by the surrounding literal text.\n */\nfunction compileDefinitions(\n definitions: StepDefinitionMeta[]\n): CompiledPattern[] {\n const compiled: CompiledPattern[] = [];\n for (const def of definitions) {\n try {\n const registry = new ParameterTypeRegistry();\n for (const [, name] of def.expression.matchAll(PARAM_TOKEN)) {\n if (!name || registry.lookupByTypeName(name)) continue;\n registry.defineParameterType(\n new ParameterType(name, /.+/, null, (value: string) => value)\n );\n }\n compiled.push({\n expression: new CucumberExpression(def.expression, registry),\n definition: def,\n });\n } catch {\n // Skip definitions whose expression can't be compiled.\n }\n }\n return compiled;\n}\n\nexport function matchScenarioSteps(\n scenario: ParsedScenario,\n definitions: StepDefinitionMeta[]\n): MatchedStep[] {\n const compiled = compileDefinitions(definitions);\n\n return scenario.steps.map(step => {\n const matches = findMatches(step.text, step.effectiveKeyword, compiled);\n return {\n ...step,\n definitions: matches,\n };\n });\n}\n\nexport function findMatchingDefinitions(\n text: string,\n effectiveKeyword: \"Given\" | \"When\" | \"Then\",\n definitions: StepDefinitionMeta[]\n): StepDefinitionMeta[] {\n const compiled = compileDefinitions(definitions);\n return findMatches(text, effectiveKeyword, compiled);\n}\n\nfunction findMatches(\n text: string,\n effectiveKeyword: \"Given\" | \"When\" | \"Then\",\n compiled: CompiledPattern[]\n): StepDefinitionMeta[] {\n const keywordToStepType: Record<string, string> = {\n Given: \"given\",\n When: \"when\",\n Then: \"then\",\n };\n const expectedStepType = keywordToStepType[effectiveKeyword];\n\n // First try to match with the correct step type\n const typedMatches: StepDefinitionMeta[] = [];\n for (const { expression, definition } of compiled) {\n if (definition.stepType !== expectedStepType) continue;\n if (expression.match(text) != null) typedMatches.push(definition);\n }\n\n if (typedMatches.length > 0) return typedMatches;\n\n // Fallback: match any step type\n const fallbackMatches: StepDefinitionMeta[] = [];\n for (const { expression, definition } of compiled) {\n if (expression.match(text) != null) fallbackMatches.push(definition);\n }\n\n return fallbackMatches;\n}\n","import {\n AnalysisRule,\n Diagnostic,\n MatchedStep,\n ParsedScenario,\n} from \"../types.js\";\n\nexport const ambiguousStepRule: AnalysisRule = {\n name: \"ambiguous-step\",\n\n check(\n scenario: ParsedScenario,\n matchedSteps: MatchedStep[]\n ): Diagnostic[] {\n return matchedSteps\n .filter((step) => step.definitions.length > 1)\n .map((step) => {\n const locations = step.definitions\n .map((d) => `${d.sourceFile}:${d.line}`)\n .join(\", \");\n return {\n file: scenario.file,\n range: {\n startLine: step.line,\n startColumn: step.column,\n endLine: step.line,\n endColumn: step.column + step.text.length,\n },\n severity: \"error\" as const,\n message: `Step \"${step.text}\" matches multiple step definitions: ${locations}`,\n rule: \"ambiguous-step\",\n source: \"step-forge\" as const,\n };\n });\n },\n};\n","import {\n AnalysisRule,\n Diagnostic,\n MatchedStep,\n ParsedScenario,\n} from \"../types.js\";\n\nexport const dependencyRule: AnalysisRule = {\n name: \"dependency-check\",\n\n check(\n scenario: ParsedScenario,\n matchedSteps: MatchedStep[]\n ): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n const produced = {\n given: new Set<string>(),\n when: new Set<string>(),\n then: new Set<string>(),\n };\n\n for (const step of matchedSteps) {\n if (step.definitions.length !== 1) continue;\n\n const { dependencies, produces, stepType } = step.definitions[0];\n\n // Collect all missing required dependencies for this step\n const missing: Record<string, string[]> = {};\n for (const phase of [\"given\", \"when\", \"then\"] as const) {\n for (const [key, requirement] of Object.entries(dependencies[phase])) {\n if (requirement === \"required\" && !produced[phase].has(key)) {\n if (!missing[phase]) {\n missing[phase] = [];\n }\n missing[phase].push(key);\n }\n }\n }\n\n if (Object.keys(missing).length > 0) {\n const lines = Object.entries(missing).map(\n ([phase, keys]) =>\n `${phase.charAt(0).toUpperCase() + phase.slice(1)}: ${keys.map((k) => `${phase}.${k}`).join(\", \")}`\n );\n const message =\n \"Missing required dependencies:\\n\" + lines.join(\"\\n\");\n\n diagnostics.push({\n file: scenario.file,\n range: {\n startLine: step.line,\n startColumn: step.column,\n endLine: step.line,\n endColumn: step.column + step.text.length,\n },\n severity: \"error\",\n message,\n rule: \"dependency-check\",\n source: \"step-forge\",\n });\n }\n\n // Add produced keys for this step\n for (const key of produces) {\n produced[stepType].add(key);\n }\n }\n\n return diagnostics;\n },\n};\n","import {\n AnalysisRule,\n Diagnostic,\n MatchedStep,\n ParsedScenario,\n} from \"../types.js\";\n\nexport const undefinedStepRule: AnalysisRule = {\n name: \"undefined-step\",\n\n check(\n scenario: ParsedScenario,\n matchedSteps: MatchedStep[]\n ): Diagnostic[] {\n return matchedSteps\n .filter((step) => step.definitions.length === 0)\n .map((step) => ({\n file: scenario.file,\n range: {\n startLine: step.line,\n startColumn: step.column,\n endLine: step.line,\n endColumn: step.column + step.text.length,\n },\n severity: \"error\" as const,\n message: `Step \"${step.text}\" does not match any step definition`,\n rule: \"undefined-step\",\n source: \"step-forge\" as const,\n }));\n },\n};\n","import {\n AnalysisRule,\n Diagnostic,\n MatchedStep,\n ParsedScenario,\n} from \"../types.js\";\nimport { ambiguousStepRule } from \"./ambiguousStepRule.js\";\nimport { dependencyRule } from \"./dependencyRule.js\";\nimport { undefinedStepRule } from \"./undefinedStepRule.js\";\n\nexport const defaultRules: AnalysisRule[] = [\n undefinedStepRule,\n ambiguousStepRule,\n dependencyRule,\n];\n\nexport function runRules(\n rules: AnalysisRule[],\n scenario: ParsedScenario,\n matchedSteps: MatchedStep[]\n): Diagnostic[] {\n return rules.flatMap((rule) => rule.check(scenario, matchedSteps));\n}\n","import { globFiles } from \"../globFiles.js\";\nimport { extractStepDefinitions } from \"./stepExtractor.js\";\nimport { parseFeatureFiles, parseFeatureContent } from \"./gherkinParser.js\";\nimport { matchScenarioSteps, findMatchingDefinitions } from \"./stepMatcher.js\";\nimport { defaultRules, runRules } from \"./rules/index.js\";\nimport type {\n AnalyzerConfig,\n AnalysisRule,\n Diagnostic,\n StepDefinitionMeta,\n ParsedScenario,\n MatchedStep,\n ParsedStep,\n} from \"./types.js\";\n\nexport type {\n AnalyzerConfig,\n AnalysisRule,\n Diagnostic,\n StepDefinitionMeta,\n ParsedScenario,\n MatchedStep,\n ParsedStep,\n};\n\nexport {\n extractStepDefinitions,\n parseFeatureFiles,\n parseFeatureContent,\n matchScenarioSteps,\n findMatchingDefinitions,\n defaultRules,\n};\n\nexport interface AnalyzeOptions {\n rules?: AnalysisRule[];\n}\n\nexport async function analyze(\n config: AnalyzerConfig,\n options?: AnalyzeOptions\n): Promise<Diagnostic[]> {\n const rules = options?.rules ?? defaultRules;\n\n // 1. Resolve file globs to paths\n const stepFilePaths = await globFiles(config.stepFiles);\n const featureFilePaths = await globFiles(config.featureFiles);\n\n if (stepFilePaths.length === 0) {\n return [];\n }\n if (featureFilePaths.length === 0) {\n return [];\n }\n\n // 2. Extract step metadata from step files\n const stepDefinitions = extractStepDefinitions(\n stepFilePaths,\n config.tsConfigPath\n );\n\n // 3. Parse feature files\n const scenarios = parseFeatureFiles(featureFilePaths);\n\n // 4. For each scenario, match steps and run rules\n const diagnostics: Diagnostic[] = [];\n for (const scenario of scenarios) {\n const matchedSteps = matchScenarioSteps(scenario, stepDefinitions);\n const scenarioDiags = runRules(rules, scenario, matchedSteps);\n diagnostics.push(...scenarioDiags);\n }\n\n return diagnostics;\n}\n"],"mappings":";;;;;;;;;AAKA,MAAM,QAAQ;AAEd,eAAe,OAAO,GAA6B;CACjD,IAAI;EACF,QAAQ,MAAM,KAAK,CAAC,EAAA,CAAG,OAAO;CAChC,QAAQ;EACN,OAAO;CACT;AACF;;;;;;;;;;;;AAaA,eAAsB,UACpB,UACA,MAAc,QAAQ,IAAI,GACP;CACnB,MAAM,wBAAQ,IAAI,IAAY;CAC9B,KAAK,MAAM,WAAW,UAAU;EAC9B,IAAI,KAAK,WAAW,OAAO,KAAK,CAAC,MAAM,KAAK,OAAO,GAAG;GACpD,IAAI,MAAM,OAAO,OAAO,GAAG,MAAM,IAAI,OAAO;GAC5C;EACF;EACA,WAAW,MAAM,SAAS,KAAK,SAAS,EAAE,IAAI,CAAC,GAC7C,MAAM,IAAI,KAAK,QAAQ,KAAK,KAAK,CAAC;CAEtC;CACA,OAAO,CAAC,GAAG,KAAK;AAClB;;;ACpCA,MAAM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