@step-forge/step-forge 0.0.25-alpha.3 → 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.
@@ -1,441 +0,0 @@
1
- const require_gherkinParser = require("./gherkinParser-_ZgvELdy.cjs");
2
- let typescript = require("typescript");
3
- typescript = require_gherkinParser.__toESM(typescript, 1);
4
- //#region src/analyzer/stepExtractor.ts
5
- const BUILDER_NAMES = {
6
- givenBuilder: "given",
7
- whenBuilder: "when",
8
- thenBuilder: "then"
9
- };
10
- function extractStepDefinitions(filePaths, tsConfigPath) {
11
- const fast = extractWithSources(filePaths.map(parseSourceFile).filter((s) => s !== null), null);
12
- if (!fast.needsChecker) return fast.results;
13
- const program = typescript.default.createProgram(filePaths, resolveCompilerOptions(tsConfigPath));
14
- const checker = program.getTypeChecker();
15
- return extractWithSources(filePaths.map((fp) => program.getSourceFile(fp)).filter((s) => s !== void 0), checker).results;
16
- }
17
- /** Parse a single file into an AST with no type resolution. */
18
- function parseSourceFile(filePath) {
19
- const text = typescript.default.sys.readFile(filePath);
20
- if (text === void 0) return null;
21
- const scriptKind = filePath.endsWith(".tsx") ? typescript.default.ScriptKind.TSX : typescript.default.ScriptKind.TS;
22
- return typescript.default.createSourceFile(filePath, text, typescript.default.ScriptTarget.ESNext, true, scriptKind);
23
- }
24
- /** Resolve compiler options from tsconfig (fallback to sane defaults). */
25
- function resolveCompilerOptions(tsConfigPath) {
26
- const configPath = tsConfigPath ?? typescript.default.findConfigFile(process.cwd(), typescript.default.sys.fileExists);
27
- let compilerOptions = {
28
- target: typescript.default.ScriptTarget.ESNext,
29
- module: typescript.default.ModuleKind.ESNext,
30
- moduleResolution: typescript.default.ModuleResolutionKind.Node10,
31
- strict: true,
32
- esModuleInterop: true
33
- };
34
- if (configPath) {
35
- const configFile = typescript.default.readConfigFile(configPath, typescript.default.sys.readFile);
36
- if (!configFile.error) compilerOptions = typescript.default.parseJsonConfigFileContent(configFile.config, typescript.default.sys, configPath.replace(/[/\\][^/\\]+$/, "")).options;
37
- }
38
- compilerOptions.noEmit = true;
39
- return compilerOptions;
40
- }
41
- function extractWithSources(sources, checker) {
42
- const ctx = {
43
- checker,
44
- needsChecker: false
45
- };
46
- const results = [];
47
- for (const sourceFile of sources) results.push(...extractFromSourceFile(sourceFile, ctx));
48
- return {
49
- results,
50
- needsChecker: ctx.needsChecker
51
- };
52
- }
53
- function extractFromSourceFile(sourceFile, ctx) {
54
- const results = [];
55
- function visit(node) {
56
- if (typescript.default.isCallExpression(node) && typescript.default.isPropertyAccessExpression(node.expression) && node.expression.name.text === "step") {
57
- const meta = extractFromRegisterCall(node, sourceFile, ctx);
58
- if (meta) results.push(meta);
59
- }
60
- typescript.default.forEachChild(node, visit);
61
- }
62
- visit(sourceFile);
63
- return results;
64
- }
65
- function extractFromRegisterCall(registerCall, sourceFile, ctx) {
66
- const chain = collectCallChain(registerCall);
67
- let stepType = null;
68
- let expression = null;
69
- let dependencies = {
70
- given: {},
71
- when: {},
72
- then: {}
73
- };
74
- let produces = [];
75
- for (const link of chain) {
76
- const name = getCallName(link);
77
- if (!name) continue;
78
- if (name === "register") continue;
79
- if (name === "step") {
80
- produces = extractProducedKeys(link, ctx);
81
- continue;
82
- }
83
- if (name === "dependencies") {
84
- dependencies = extractDependencies(link);
85
- continue;
86
- }
87
- if (name === "statement") {
88
- expression = extractExpression(link);
89
- continue;
90
- }
91
- if (BUILDER_NAMES[name]) {
92
- stepType = BUILDER_NAMES[name];
93
- continue;
94
- }
95
- }
96
- if (!stepType || !expression) {
97
- const reExport = resolveReExportedCall(chain, ctx);
98
- if (reExport) {
99
- if (!stepType) stepType = reExport.stepType;
100
- if (!expression) expression = reExport.expression;
101
- }
102
- }
103
- if (!stepType || !expression) return null;
104
- const line = sourceFile.getLineAndCharacterOfPosition(registerCall.getStart()).line + 1;
105
- return {
106
- stepType,
107
- expression,
108
- dependencies,
109
- produces,
110
- sourceFile: sourceFile.fileName,
111
- line
112
- };
113
- }
114
- /**
115
- * Collect all call expressions in the method chain, from register() back to the origin.
116
- */
117
- function collectCallChain(call) {
118
- const chain = [call];
119
- let current = call.expression;
120
- while (true) {
121
- if (typescript.default.isPropertyAccessExpression(current)) current = current.expression;
122
- if (typescript.default.isCallExpression(current)) {
123
- chain.push(current);
124
- current = current.expression;
125
- } else break;
126
- }
127
- return chain;
128
- }
129
- function getCallName(call) {
130
- const expr = call.expression;
131
- if (typescript.default.isPropertyAccessExpression(expr)) return expr.name.text;
132
- if (typescript.default.isIdentifier(expr)) return expr.text;
133
- return null;
134
- }
135
- function extractExpression(statementCall) {
136
- const arg = statementCall.arguments[0];
137
- if (!arg) return null;
138
- if (typescript.default.isStringLiteral(arg)) return arg.text;
139
- if (typescript.default.isArrowFunction(arg)) return extractExpressionFromArrowFunction(arg);
140
- return null;
141
- }
142
- function extractExpressionFromArrowFunction(fn) {
143
- const params = fn.parameters.map((p) => p.name.getText());
144
- let body = fn.body;
145
- if (typescript.default.isBlock(body)) {
146
- const returnStmt = body.statements.find(typescript.default.isReturnStatement);
147
- if (returnStmt?.expression) body = returnStmt.expression;
148
- else return null;
149
- }
150
- if (typescript.default.isTemplateExpression(body)) return reconstructExpressionFromTemplate(body, params);
151
- if (typescript.default.isNoSubstitutionTemplateLiteral(body)) return body.text;
152
- return null;
153
- }
154
- function reconstructExpressionFromTemplate(template, paramNames) {
155
- let result = template.head.text;
156
- for (const span of template.templateSpans) {
157
- if (typescript.default.isIdentifier(span.expression) && paramNames.includes(span.expression.text)) result += "{string}";
158
- else result += "{string}";
159
- result += span.literal.text;
160
- }
161
- return result;
162
- }
163
- function extractDependencies(depsCall) {
164
- const deps = {
165
- given: {},
166
- when: {},
167
- then: {}
168
- };
169
- const arg = depsCall.arguments[0];
170
- if (!arg || !typescript.default.isObjectLiteralExpression(arg)) return deps;
171
- for (const prop of arg.properties) {
172
- if (!typescript.default.isPropertyAssignment(prop) || !typescript.default.isIdentifier(prop.name)) continue;
173
- const phase = prop.name.text;
174
- if (!deps[phase]) continue;
175
- if (typescript.default.isObjectLiteralExpression(prop.initializer)) {
176
- for (const innerProp of prop.initializer.properties) if (typescript.default.isPropertyAssignment(innerProp) && typescript.default.isIdentifier(innerProp.name) && typescript.default.isStringLiteral(innerProp.initializer)) {
177
- const val = innerProp.initializer.text;
178
- if (val === "required" || val === "optional") deps[phase][innerProp.name.text] = val;
179
- }
180
- }
181
- }
182
- return deps;
183
- }
184
- function extractProducedKeys(stepCall, ctx) {
185
- const callback = stepCall.arguments[0];
186
- if (!callback) return [];
187
- if (typescript.default.isArrowFunction(callback) || typescript.default.isFunctionExpression(callback)) return extractProducedKeysFromCallback(callback, ctx);
188
- return [];
189
- }
190
- function extractProducedKeysFromCallback(callback, ctx) {
191
- const body = callback.body;
192
- if (!typescript.default.isBlock(body)) return extractKeysFromExpression(body, ctx);
193
- const keys = /* @__PURE__ */ new Set();
194
- function visitReturn(node) {
195
- if (typescript.default.isReturnStatement(node) && node.expression) for (const key of extractKeysFromExpression(node.expression, ctx)) keys.add(key);
196
- typescript.default.forEachChild(node, visitReturn);
197
- }
198
- visitReturn(body);
199
- return [...keys];
200
- }
201
- function extractKeysFromExpression(expr, ctx) {
202
- while (typescript.default.isParenthesizedExpression(expr)) expr = expr.expression;
203
- if (typescript.default.isObjectLiteralExpression(expr)) return expr.properties.filter((p) => typescript.default.isPropertyAssignment(p) || typescript.default.isShorthandPropertyAssignment(p)).map((p) => p.name.getText()).filter(Boolean);
204
- if (!ctx.checker) {
205
- ctx.needsChecker = true;
206
- return [];
207
- }
208
- try {
209
- return ctx.checker.getTypeAtLocation(expr).getProperties().map((p) => p.name).filter((n) => n !== "merge");
210
- } catch {
211
- return [];
212
- }
213
- }
214
- function resolveReExportedCall(chain, ctx) {
215
- const lastCall = chain[chain.length - 1];
216
- if (!lastCall) return null;
217
- const expr = lastCall.expression;
218
- let identifier = null;
219
- if (typescript.default.isIdentifier(expr)) identifier = expr;
220
- else if (typescript.default.isPropertyAccessExpression(expr) && typescript.default.isIdentifier(expr.expression)) identifier = expr.expression;
221
- if (!identifier) return null;
222
- if (!ctx.checker) {
223
- ctx.needsChecker = true;
224
- return null;
225
- }
226
- const symbol = ctx.checker.getSymbolAtLocation(identifier);
227
- if (!symbol) return null;
228
- const decl = symbol.valueDeclaration;
229
- if (!decl || !typescript.default.isVariableDeclaration(decl) || !decl.initializer) return null;
230
- const init = decl.initializer;
231
- if (typescript.default.isPropertyAccessExpression(init) && init.name.text === "statement") {
232
- const callExpr = init.expression;
233
- if (typescript.default.isCallExpression(callExpr)) {
234
- const callee = callExpr.expression;
235
- if (typescript.default.isIdentifier(callee) && BUILDER_NAMES[callee.text]) {
236
- const expression = extractExpression(lastCall);
237
- return {
238
- stepType: BUILDER_NAMES[callee.text],
239
- expression
240
- };
241
- }
242
- }
243
- }
244
- return null;
245
- }
246
- //#endregion
247
- //#region src/analyzer/stepMatcher.ts
248
- function compileDefinitions(definitions) {
249
- const compiled = [];
250
- for (const def of definitions) try {
251
- const placeholder = "###PLACEHOLDER###";
252
- const regexStr = def.expression.replace(/\{[^}]+\}/g, placeholder).replace(/[.*+?^$()|[\]\\]/g, "\\$&").replace(new RegExp(placeholder, "g"), "(.+)");
253
- compiled.push({
254
- regex: new RegExp(`^${regexStr}$`, "i"),
255
- definition: def
256
- });
257
- } catch {}
258
- return compiled;
259
- }
260
- function matchScenarioSteps(scenario, definitions) {
261
- const compiled = compileDefinitions(definitions);
262
- return scenario.steps.map((step) => {
263
- const matches = findMatches(step.text, step.effectiveKeyword, compiled);
264
- return {
265
- ...step,
266
- definitions: matches
267
- };
268
- });
269
- }
270
- function findMatchingDefinitions(text, effectiveKeyword, definitions) {
271
- return findMatches(text, effectiveKeyword, compileDefinitions(definitions));
272
- }
273
- function findMatches(text, effectiveKeyword, compiled) {
274
- const expectedStepType = {
275
- Given: "given",
276
- When: "when",
277
- Then: "then"
278
- }[effectiveKeyword];
279
- const typedMatches = [];
280
- for (const { regex, definition } of compiled) {
281
- if (definition.stepType !== expectedStepType) continue;
282
- if (regex.test(text)) typedMatches.push(definition);
283
- }
284
- if (typedMatches.length > 0) return typedMatches;
285
- const fallbackMatches = [];
286
- for (const { regex, definition } of compiled) if (regex.test(text)) fallbackMatches.push(definition);
287
- return fallbackMatches;
288
- }
289
- //#endregion
290
- //#region src/analyzer/rules/index.ts
291
- const defaultRules = [
292
- {
293
- name: "undefined-step",
294
- check(scenario, matchedSteps) {
295
- return matchedSteps.filter((step) => step.definitions.length === 0).map((step) => ({
296
- file: scenario.file,
297
- range: {
298
- startLine: step.line,
299
- startColumn: step.column,
300
- endLine: step.line,
301
- endColumn: step.column + step.text.length
302
- },
303
- severity: "error",
304
- message: `Step "${step.text}" does not match any step definition`,
305
- rule: "undefined-step",
306
- source: "step-forge"
307
- }));
308
- }
309
- },
310
- {
311
- name: "ambiguous-step",
312
- check(scenario, matchedSteps) {
313
- return matchedSteps.filter((step) => step.definitions.length > 1).map((step) => {
314
- const locations = step.definitions.map((d) => `${d.sourceFile}:${d.line}`).join(", ");
315
- return {
316
- file: scenario.file,
317
- range: {
318
- startLine: step.line,
319
- startColumn: step.column,
320
- endLine: step.line,
321
- endColumn: step.column + step.text.length
322
- },
323
- severity: "error",
324
- message: `Step "${step.text}" matches multiple step definitions: ${locations}`,
325
- rule: "ambiguous-step",
326
- source: "step-forge"
327
- };
328
- });
329
- }
330
- },
331
- {
332
- name: "dependency-check",
333
- check(scenario, matchedSteps) {
334
- const diagnostics = [];
335
- const produced = {
336
- given: /* @__PURE__ */ new Set(),
337
- when: /* @__PURE__ */ new Set(),
338
- then: /* @__PURE__ */ new Set()
339
- };
340
- for (const step of matchedSteps) {
341
- if (step.definitions.length !== 1) continue;
342
- const { dependencies, produces, stepType } = step.definitions[0];
343
- const missing = {};
344
- for (const phase of [
345
- "given",
346
- "when",
347
- "then"
348
- ]) for (const [key, requirement] of Object.entries(dependencies[phase])) if (requirement === "required" && !produced[phase].has(key)) {
349
- if (!missing[phase]) missing[phase] = [];
350
- missing[phase].push(key);
351
- }
352
- if (Object.keys(missing).length > 0) {
353
- const message = "Missing required dependencies:\n" + Object.entries(missing).map(([phase, keys]) => `${phase.charAt(0).toUpperCase() + phase.slice(1)}: ${keys.map((k) => `${phase}.${k}`).join(", ")}`).join("\n");
354
- diagnostics.push({
355
- file: scenario.file,
356
- range: {
357
- startLine: step.line,
358
- startColumn: step.column,
359
- endLine: step.line,
360
- endColumn: step.column + step.text.length
361
- },
362
- severity: "error",
363
- message,
364
- rule: "dependency-check",
365
- source: "step-forge"
366
- });
367
- }
368
- for (const key of produces) produced[stepType].add(key);
369
- }
370
- return diagnostics;
371
- }
372
- }
373
- ];
374
- function runRules(rules, scenario, matchedSteps) {
375
- return rules.flatMap((rule) => rule.check(scenario, matchedSteps));
376
- }
377
- //#endregion
378
- //#region src/analyzer/index.ts
379
- var analyzer_exports = /* @__PURE__ */ require_gherkinParser.__exportAll({
380
- analyze: () => analyze,
381
- defaultRules: () => defaultRules,
382
- extractStepDefinitions: () => extractStepDefinitions,
383
- findMatchingDefinitions: () => findMatchingDefinitions,
384
- matchScenarioSteps: () => matchScenarioSteps,
385
- parseFeatureContent: () => require_gherkinParser.parseFeatureContent,
386
- parseFeatureFiles: () => require_gherkinParser.parseFeatureFiles
387
- });
388
- async function analyze(config, options) {
389
- const rules = options?.rules ?? defaultRules;
390
- const stepFilePaths = await require_gherkinParser.globFiles(config.stepFiles);
391
- const featureFilePaths = await require_gherkinParser.globFiles(config.featureFiles);
392
- if (stepFilePaths.length === 0) return [];
393
- if (featureFilePaths.length === 0) return [];
394
- const stepDefinitions = extractStepDefinitions(stepFilePaths, config.tsConfigPath);
395
- const scenarios = require_gherkinParser.parseFeatureFiles(featureFilePaths);
396
- const diagnostics = [];
397
- for (const scenario of scenarios) {
398
- const scenarioDiags = runRules(rules, scenario, matchScenarioSteps(scenario, stepDefinitions));
399
- diagnostics.push(...scenarioDiags);
400
- }
401
- return diagnostics;
402
- }
403
- //#endregion
404
- Object.defineProperty(exports, "analyze", {
405
- enumerable: true,
406
- get: function() {
407
- return analyze;
408
- }
409
- });
410
- Object.defineProperty(exports, "analyzer_exports", {
411
- enumerable: true,
412
- get: function() {
413
- return analyzer_exports;
414
- }
415
- });
416
- Object.defineProperty(exports, "defaultRules", {
417
- enumerable: true,
418
- get: function() {
419
- return defaultRules;
420
- }
421
- });
422
- Object.defineProperty(exports, "extractStepDefinitions", {
423
- enumerable: true,
424
- get: function() {
425
- return extractStepDefinitions;
426
- }
427
- });
428
- Object.defineProperty(exports, "findMatchingDefinitions", {
429
- enumerable: true,
430
- get: function() {
431
- return findMatchingDefinitions;
432
- }
433
- });
434
- Object.defineProperty(exports, "matchScenarioSteps", {
435
- enumerable: true,
436
- get: function() {
437
- return matchScenarioSteps;
438
- }
439
- });
440
-
441
- //# sourceMappingURL=analyzer-DIZPMxzN.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"analyzer-DIZPMxzN.cjs","names":["ts","globFiles","parseFeatureFiles"],"sources":["../../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"],"sourcesContent":["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 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(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 (ts.isIdentifier(span.expression) && paramNames.includes(span.expression.text)) {\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))\n 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(\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,gBAA0C;CAC9C,cAAc;CACd,aAAa;CACb,aAAa;AACf;AAYA,SAAgB,uBACd,WACA,cACsB;CAUtB,MAAM,OAAO,mBAHG,UACb,IAAI,eAAe,CAAC,CACpB,QAAQ,MAA0B,MAAM,IACL,GAAG,IAAI;CAC7C,IAAI,CAAC,KAAK,cAAc,OAAO,KAAK;CAKpC,MAAM,UAAUA,WAAAA,QAAG,cACjB,WACA,uBAAuB,YAAY,CACrC;CACA,MAAM,UAAU,QAAQ,eAAe;CAIvC,OAAO,mBAHgB,UACpB,KAAI,OAAM,QAAQ,cAAc,EAAE,CAAC,CAAC,CACpC,QAAQ,MAA0B,MAAM,KAAA,CACJ,GAAG,OAAO,CAAC,CAAC;AACrD;;AAGA,SAAS,gBAAgB,UAAwC;CAC/D,MAAM,OAAOA,WAAAA,QAAG,IAAI,SAAS,QAAQ;CACrC,IAAI,SAAS,KAAA,GAAW,OAAO;CAC/B,MAAM,aAAa,SAAS,SAAS,MAAM,IACvCA,WAAAA,QAAG,WAAW,MACdA,WAAAA,QAAG,WAAW;CAGlB,OAAOA,WAAAA,QAAG,iBACR,UACA,MACAA,WAAAA,QAAG,aAAa,QAChB,MACA,UACF;AACF;;AAGA,SAAS,uBAAuB,cAA2C;CACzE,MAAM,aACJ,gBAAgBA,W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