{"id":24598462,"url":"https://github.com/origin-1/code-path-graph","last_synced_at":"2025-07-24T16:36:28.741Z","repository":{"id":194946534,"uuid":"691874988","full_name":"origin-1/code-path-graph","owner":"origin-1","description":"A Node.js library and command-line tool to create Mermaid state diagrams of code paths in JavaScript files.","archived":false,"fork":false,"pushed_at":"2024-05-12T10:24:19.000Z","size":34,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-26T04:20:21.481Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/origin-1.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-15T04:40:36.000Z","updated_at":"2024-05-17T16:55:18.000Z","dependencies_parsed_at":"2023-09-15T22:43:58.689Z","dependency_job_id":"f95b2c6e-1442-4211-b80c-a93f690964d7","html_url":"https://github.com/origin-1/code-path-graph","commit_stats":null,"previous_names":["origin-1/code-path-graph"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/origin-1%2Fcode-path-graph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/origin-1%2Fcode-path-graph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/origin-1%2Fcode-path-graph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/origin-1%2Fcode-path-graph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/origin-1","download_url":"https://codeload.github.com/origin-1/code-path-graph/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244164160,"owners_count":20408874,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-24T12:16:32.784Z","updated_at":"2025-03-18T05:29:48.623Z","avatar_url":"https://github.com/origin-1.png","language":"JavaScript","readme":"# `code-path-graph` · [![npm version][npm badge]][npm url]\n\nA Node.js library and command-line tool to create [Mermaid state diagrams](https://mermaid.js.org/syntax/stateDiagram.html) of code paths in JavaScript files.\n\nThe diagrams are generated using the [code path analysis](https://eslint.org/docs/latest/extend/code-path-analysis) functionality of ESLint and can be embedded in GitHub markdown using fenced code blocks (i.e. ```` ```mermaid ```` … ```` ``` ````).\n\n## Installation\n\nA version of Node.js [supported by ESLint 8](https://eslint.org/docs/user-guide/getting-started#prerequisites) is required.\n\n### Install locally as a library\n\n```console\nnpm i code-path-graph\n```\n\n### Install globally as a command-line tool\n\n```console\nnpm i -g code-path-graph\n```\n\n## Usage\n\n```console\ncode-path-graph [--detail=\u003c...\u003e] [--ecma-version=\u003c...\u003e] [--source-type=\u003c...\u003e] \u003cfile\u003e\n```\n\n**`--detail`** controls the information printed in nodes of the graph. Valid values are:\n\n* `nodes`\\\nPrint node traversal info only (default)\n* `segments`\\\nPrint segment names only\n* `full`\\\nPrint both segment names and node traversal info\n\n**`--ecma-version`** specifies the JavaScript language version.\nValid values are numbers or the string `latest` (default).\n\n**`--source-type`** specifies the type of JavaScript code. Valid values are:\n\n* `script`\\\nScript (default when `--ecma-version` is `3` or `5`)\n* `module`\\\nECMAScript module (default for other values of `--ecma-version`)\n* `commonjs`\\\nCommonJS module\n\n## Example\n\nGiven is a JavaScript file `test.js` with the following content:\n```js\nif (foo)\n{\n    throw bar();\n}\n```\n\nRunning the command\n```console\ncode-graph-path test.js\n```\nproduces the following output:\n```\n---\ntitle: s1\n---\nstateDiagram-v2\nclassDef common fill: white, stroke: black\nclass s1_1, s1_2, s1_4, s1_3 common\nclassDef unreachable fill: #FF9800, stroke-dasharray: 5 5\nclass s1_3 unreachable\nclassDef thrown fill: none, stroke: none\nstate \"Program:enter\\nIfStatement:enter\\nIdentifier (foo)\" as s1_1\nstate \"BlockStatement:enter\\nThrowStatement:enter\\nCallExpression:enter\\nIdentifier (bar)\\nCallExpression:exit\\nThrowStatement:exit\" as s1_2\nstate \"IfStatement:exit\\nProgram:exit\" as s1_4\nstate \"BlockStatement:exit\" as s1_3\nthrown:::thrown: ✘\n[*] --\u003e s1_1\ns1_1 --\u003e s1_2\ns1_1 --\u003e s1_4\ns1_2 --\u003e s1_3\ns1_3 --\u003e s1_4\ns1_4 --\u003e [*]\ns1_2 --\u003e thrown\n```\n\nIn a GitHub markdown file, this text can be inserted in a fenced code block (see below)\n````\n```mermaid\n---\ntitle: s1\n---\nstateDiagram-v2\nclassDef common fill: white, stroke: black\nclass s1_1, s1_2, s1_4, s1_3 common\nclassDef unreachable fill: #FF9800, stroke-dasharray: 5 5\nclass s1_3 unreachable\nclassDef thrown fill: none, stroke: none\nstate \"Program:enter\\nIfStatement:enter\\nIdentifier (foo)\" as s1_1\nstate \"BlockStatement:enter\\nThrowStatement:enter\\nCallExpression:enter\\nIdentifier (bar)\\nCallExpression:exit\\nThrowStatement:exit\" as s1_2\nstate \"IfStatement:exit\\nProgram:exit\" as s1_4\nstate \"BlockStatement:exit\" as s1_3\nthrown:::thrown: ✘\n[*] --\u003e s1_1\ns1_1 --\u003e s1_2\ns1_1 --\u003e s1_4\ns1_2 --\u003e s1_3\ns1_3 --\u003e s1_4\ns1_4 --\u003e [*]\ns1_2 --\u003e thrown\n```\n````\nto produce a visible diagram like the following.\n```mermaid\n---\ntitle: s1\n---\nstateDiagram-v2\nclassDef common fill: white, stroke: black\nclass s1_1, s1_2, s1_4, s1_3 common\nclassDef unreachable fill: #FF9800, stroke-dasharray: 5 5\nclass s1_3 unreachable\nclassDef thrown fill: none, stroke: none\nstate \"Program:enter\\nIfStatement:enter\\nIdentifier (foo)\" as s1_1\nstate \"BlockStatement:enter\\nThrowStatement:enter\\nCallExpression:enter\\nIdentifier (bar)\\nCallExpression:exit\\nThrowStatement:exit\" as s1_2\nstate \"IfStatement:exit\\nProgram:exit\" as s1_4\nstate \"BlockStatement:exit\" as s1_3\nthrown:::thrown: ✘\n[*] --\u003e s1_1\ns1_1 --\u003e s1_2\ns1_1 --\u003e s1_4\ns1_2 --\u003e s1_3\ns1_3 --\u003e s1_4\ns1_4 --\u003e [*]\ns1_2 --\u003e thrown\n```\n\n[npm badge]: https://img.shields.io/npm/v/code-path-graph?logo=npm\n[npm url]: https://www.npmjs.com/package/code-path-graph\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forigin-1%2Fcode-path-graph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Forigin-1%2Fcode-path-graph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forigin-1%2Fcode-path-graph/lists"}