{"id":22908263,"url":"https://github.com/yumemi-inc/statictrace","last_synced_at":"2025-09-16T03:47:23.575Z","repository":{"id":57170054,"uuid":"371637217","full_name":"yumemi-inc/statictrace","owner":"yumemi-inc","description":"A library for semi-automatic static testing.","archived":false,"fork":false,"pushed_at":"2023-10-17T04:56:35.000Z","size":394,"stargazers_count":11,"open_issues_count":9,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-08-19T21:07:06.515Z","etag":null,"topics":["cli","mermaid","static-analysis","testing","testing-tools","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yumemi-inc.png","metadata":{"files":{"readme":"README.JP.md","changelog":null,"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":"2021-05-28T08:44:39.000Z","updated_at":"2023-05-30T04:03:52.000Z","dependencies_parsed_at":"2024-12-14T03:33:04.704Z","dependency_job_id":null,"html_url":"https://github.com/yumemi-inc/statictrace","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/yumemi-inc/statictrace","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yumemi-inc%2Fstatictrace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yumemi-inc%2Fstatictrace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yumemi-inc%2Fstatictrace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yumemi-inc%2Fstatictrace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yumemi-inc","download_url":"https://codeload.github.com/yumemi-inc/statictrace/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yumemi-inc%2Fstatictrace/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275358838,"owners_count":25450443,"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","status":"online","status_checked_at":"2025-09-16T02:00:10.229Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["cli","mermaid","static-analysis","testing","testing-tools","typescript"],"created_at":"2024-12-14T03:20:31.404Z","updated_at":"2025-09-16T03:47:23.545Z","avatar_url":"https://github.com/yumemi-inc.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# statictrace\n\n## Requirements\n\nNode.js 14.15.0 以上が動作する環境。\n\n## Installation\n\n### Install\n\n`npm install @yumemi-inc/statictrace`\n\n`statictrace`はプロジェクトごとにインストールできるし、グローバルなパッケージとしてもインストールできます。\n\n### Build from source\n\n```\npnpm install\npnpm run build\n```\n\n### `ts-node`\n\n```\npnpx ts-node src/lib.ts -p /absolute/path/to/tsconfig.json\n```\n\n### Use as CLI\n\n```\nstatictrace -- -p /absolute/path/to/tsconfig.json\n```\n\n`.env`ファイルを作成し、`TS_PROJECT_CONFIG`環境変数を定義することで、`-p`オプションは省略できます。\n\n```\nTS_PROJECT_CONFIG=/absolute/path/to/tsconfig.json\n```\n\n**その他のオプション**\n\n- `u, --use \u003cprinter\u003e` (optional): デフォルトの中からプリンターを選択する (`text`または`mermaid`).\n\n### 使い方\n\n`statictrace`は、開発者が特殊なコメントでヒントした箇所からコードの静的な分析をはじめる。例えば以下のように登録フローを分析するために、フローがはじまることを表すヒント (`@entrypoint フローの名前`) を関数に JSDoc 形式で追加します。\n\n```ts\n/**\n * @entrypoint Registration\n */\nfunction startRegistration() {\n  processRegistration();\n  finishRegistration();\n  untracedFunction();\n  cleanupSomething();\n}\n```\n\nこれだけでは何もアウトプットされないが、`statictrace` は `startRegistration()` の中で呼ばれる関数やメソッドをすべて把握します。開発者がテストやドキュメントの目的で、呼び出しの有無・順番・親子関係を記録したい場合は、気になる関数とメソッドだけ別の特殊なヒントでマークできる。そのヒントは `@trace`。\n\n```ts\n/** @trace */\nfunction processRegistration() {\n  someRegistrationProcedure();\n}\n```\n\nこれで `statictrace` を実行すると以下のアウトプットが得られる：\n\n```\nEntrypoint: Registration\nstartRegistration\n        processRegistration\n                someRegistrationProcedure\n```\n\nこのアウトプットをスナップショットのように使って、好みのテストライブラリでリファクタリング前と後の差分でフローが変わっていないことを保証できる。または [`mermaid`](https://mermaid-js.github.io/mermaid/#/) として結果をアウトプットできる（以下に画像がある）。\n\n### 例\n\n- デバッガーのスタックトレースのようにインデントされたテキストとしてアウトプットする：\n\n```sh\n$ statictrace\n\n=======================\nEntrypoint: SomeEntrypoint\nbegin\n        funcA\n                funcC\n        beingNestedEntrypoint\n                funcA\n                        funcC\n                funcB\n        funcB\n```\n\n- mermaid グラフとしてマークダウンファイルにアウトプットする: `statictrace -u mermaid \u003e graphs.md`\n\nこの場合のグラフが以下のように表示されます：\n![mermaid](./assets/mermaid.png)\n\n### Use API programmatically\n\n```js\nconst { run } = require('./build/lib');\nconst output = run('/absolute/path/to/tsconfig.json', 'text');\n// ...do something with output\n```\n\n#### `run(pathToTsConfig: string, printerType: \"text\" | \"mermaid\"): any`\n\n全てのプロジェクトのファイルをロードし、`@entrypoint`か`@trace`でマークされている全ての関数のコールのグラフを作る。第二の引数としてプリンタータイプを指定する。プリンターというのは静的分析の結果をなんらかの形で表示できるインターフェースを指します。現在、独自の実装は不可能で、デフォルトのタイプから選択する必要がある。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyumemi-inc%2Fstatictrace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyumemi-inc%2Fstatictrace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyumemi-inc%2Fstatictrace/lists"}