@rolexjs/parser 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +36 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/package.json +47 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { GherkinDocument } from '@cucumber/messages';
|
|
2
|
+
export { Background, Comment, DataTable, DocString, Examples, Feature, FeatureChild, GherkinDocument, Location, Rule, RuleChild, Scenario, Step, StepKeywordType, TableCell, TableRow, Tag } from '@cucumber/messages';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @rolexjs/parser
|
|
6
|
+
*
|
|
7
|
+
* Gherkin parser for Rolex — wraps @cucumber/gherkin.
|
|
8
|
+
* Re-exports Gherkin document types and provides a simple parse() function.
|
|
9
|
+
*
|
|
10
|
+
* Own the interface, delegate the implementation.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Parse a Gherkin source string into a GherkinDocument.
|
|
15
|
+
*
|
|
16
|
+
* @param source - Raw Gherkin text content
|
|
17
|
+
* @returns Parsed GherkinDocument with Feature, Scenarios, Steps, etc.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* import { parse } from "@rolexjs/parser";
|
|
22
|
+
*
|
|
23
|
+
* const doc = parse(`
|
|
24
|
+
* Feature: My Feature
|
|
25
|
+
* Scenario: My Scenario
|
|
26
|
+
* Given a precondition
|
|
27
|
+
* When an action
|
|
28
|
+
* Then an outcome
|
|
29
|
+
* `);
|
|
30
|
+
*
|
|
31
|
+
* console.log(doc.feature?.name); // "My Feature"
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
declare function parse(source: string): GherkinDocument;
|
|
35
|
+
|
|
36
|
+
export { parse };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { Parser, AstBuilder, GherkinClassicTokenMatcher } from "@cucumber/gherkin";
|
|
3
|
+
import { IdGenerator } from "@cucumber/messages";
|
|
4
|
+
import { StepKeywordType } from "@cucumber/messages";
|
|
5
|
+
function parse(source) {
|
|
6
|
+
const builder = new AstBuilder(IdGenerator.incrementing());
|
|
7
|
+
const matcher = new GherkinClassicTokenMatcher();
|
|
8
|
+
const parser = new Parser(builder, matcher);
|
|
9
|
+
return parser.parse(source);
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
StepKeywordType,
|
|
13
|
+
parse
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @rolexjs/parser\n *\n * Gherkin parser for Rolex — wraps @cucumber/gherkin.\n * Re-exports Gherkin document types and provides a simple parse() function.\n *\n * Own the interface, delegate the implementation.\n */\n\nimport { Parser, AstBuilder, GherkinClassicTokenMatcher } from \"@cucumber/gherkin\";\nimport { IdGenerator } from \"@cucumber/messages\";\nimport type { GherkinDocument } from \"@cucumber/messages\";\n\n// ========== Re-export Gherkin Document Types ==========\n\nexport type {\n GherkinDocument,\n Feature,\n Scenario,\n Step,\n DataTable,\n DocString,\n TableRow,\n TableCell,\n Tag,\n Comment,\n Location,\n Background,\n Rule,\n RuleChild,\n FeatureChild,\n Examples,\n} from \"@cucumber/messages\";\n\nexport { StepKeywordType } from \"@cucumber/messages\";\n\n// ========== Parse Function ==========\n\n/**\n * Parse a Gherkin source string into a GherkinDocument.\n *\n * @param source - Raw Gherkin text content\n * @returns Parsed GherkinDocument with Feature, Scenarios, Steps, etc.\n *\n * @example\n * ```typescript\n * import { parse } from \"@rolexjs/parser\";\n *\n * const doc = parse(`\n * Feature: My Feature\n * Scenario: My Scenario\n * Given a precondition\n * When an action\n * Then an outcome\n * `);\n *\n * console.log(doc.feature?.name); // \"My Feature\"\n * ```\n */\nexport function parse(source: string): GherkinDocument {\n const builder = new AstBuilder(IdGenerator.incrementing());\n const matcher = new GherkinClassicTokenMatcher();\n const parser = new Parser(builder, matcher);\n return parser.parse(source);\n}\n"],"mappings":";AASA,SAAS,QAAQ,YAAY,kCAAkC;AAC/D,SAAS,mBAAmB;AAwB5B,SAAS,uBAAuB;AAyBzB,SAAS,MAAM,QAAiC;AACrD,QAAM,UAAU,IAAI,WAAW,YAAY,aAAa,CAAC;AACzD,QAAM,UAAU,IAAI,2BAA2B;AAC/C,QAAM,SAAS,IAAI,OAAO,SAAS,OAAO;AAC1C,SAAO,OAAO,MAAM,MAAM;AAC5B;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rolexjs/parser",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Gherkin parser for Rolex — wraps @cucumber/gherkin",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"rolex",
|
|
7
|
+
"gherkin",
|
|
8
|
+
"parser",
|
|
9
|
+
"bdd"
|
|
10
|
+
],
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/Deepractice/RoleX.git",
|
|
14
|
+
"directory": "packages/parser"
|
|
15
|
+
},
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=22.0.0"
|
|
19
|
+
},
|
|
20
|
+
"type": "module",
|
|
21
|
+
"main": "./dist/index.js",
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"default": "./dist/index.js"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist"
|
|
31
|
+
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "tsup",
|
|
34
|
+
"test": "bun test",
|
|
35
|
+
"lint": "eslint .",
|
|
36
|
+
"typecheck": "tsc --noEmit",
|
|
37
|
+
"clean": "rm -rf dist"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@cucumber/gherkin": "^38.0.0",
|
|
41
|
+
"@cucumber/messages": "^32.0.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {},
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public"
|
|
46
|
+
}
|
|
47
|
+
}
|