@kongyo2/ts-comment-scanner 0.0.0
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/LICENSE +21 -0
- package/README.md +95 -0
- package/dist/args.d.ts +8 -0
- package/dist/args.d.ts.map +1 -0
- package/dist/args.js +25 -0
- package/dist/args.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +12 -0
- package/dist/cli.js.map +1 -0
- package/dist/files.d.ts +9 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/files.js +56 -0
- package/dist/files.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/report.d.ts +4 -0
- package/dist/report.d.ts.map +1 -0
- package/dist/report.js +32 -0
- package/dist/report.js.map +1 -0
- package/dist/run.d.ts +7 -0
- package/dist/run.d.ts.map +1 -0
- package/dist/run.js +42 -0
- package/dist/run.js.map +1 -0
- package/dist/scanner.d.ts +6 -0
- package/dist/scanner.d.ts.map +1 -0
- package/dist/scanner.js +50 -0
- package/dist/scanner.js.map +1 -0
- package/dist/types.d.ts +14 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +7 -0
- package/dist/version.js.map +1 -0
- package/package.json +68 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 kongyo2
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# ts-comment-scanner
|
|
2
|
+
|
|
3
|
+
TypeScript プロジェクト内のコメントを検出して一覧・集計する CLI / ライブラリです。TypeScript の AST を使って解析するため、文字列やコードの一部を誤検出しません。
|
|
4
|
+
|
|
5
|
+
## 特徴
|
|
6
|
+
|
|
7
|
+
- `.ts` `.tsx` `.mts` `.cts` を再帰的にスキャン(`node_modules` と `.git` は除外)
|
|
8
|
+
- 行コメント (`//`) とブロックコメント (`/* */`) を位置情報つきで報告
|
|
9
|
+
- テキスト形式と JSON 形式の出力に対応
|
|
10
|
+
- CLI としても、ライブラリとしても利用可能
|
|
11
|
+
|
|
12
|
+
## インストール
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @kongyo2/ts-comment-scanner
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
インストールせずに実行する場合:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npx @kongyo2/ts-comment-scanner src
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## CLI の使い方
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
ts-comment-scanner [options] [paths...]
|
|
28
|
+
|
|
29
|
+
Options:
|
|
30
|
+
--json 結果を JSON で出力
|
|
31
|
+
-v, --version バージョンを表示
|
|
32
|
+
-h, --help ヘルプを表示
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
パスを省略するとカレントディレクトリを対象にします。
|
|
36
|
+
|
|
37
|
+
### 出力例
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
$ ts-comment-scanner src
|
|
41
|
+
src/index.ts:1:1 [line] // エントリーポイント
|
|
42
|
+
src/scanner.ts:8:3 [block] /* AST を走査する */
|
|
43
|
+
|
|
44
|
+
2 comments across 2 files
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
JSON 出力:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
$ ts-comment-scanner --json src
|
|
51
|
+
{
|
|
52
|
+
"summary": { "files": 1, "comments": 1 },
|
|
53
|
+
"files": [
|
|
54
|
+
{
|
|
55
|
+
"file": "src/index.ts",
|
|
56
|
+
"comments": [
|
|
57
|
+
{ "kind": "line", "text": "// エントリーポイント", "start": 0, "end": 12, "line": 1, "column": 1 }
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## ライブラリとして使う
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
import { scanPaths, scanComments, formatText } from "@kongyo2/ts-comment-scanner";
|
|
68
|
+
|
|
69
|
+
// ファイル / ディレクトリをまとめてスキャン
|
|
70
|
+
const results = await scanPaths(["src"]);
|
|
71
|
+
console.log(formatText(results));
|
|
72
|
+
|
|
73
|
+
// ソース文字列を直接スキャン
|
|
74
|
+
const comments = scanComments("// hello\nconst x = 1;");
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 主な API
|
|
78
|
+
|
|
79
|
+
| 関数 | 概要 |
|
|
80
|
+
| --- | --- |
|
|
81
|
+
| `scanComments(source, options?)` | ソース文字列からコメント配列を取得(`options.jsx` で TSX を解析) |
|
|
82
|
+
| `scanFile(file)` | 1 ファイルをスキャン |
|
|
83
|
+
| `scanPaths(inputs, options?)` | ファイル / ディレクトリ群を再帰的にスキャン |
|
|
84
|
+
| `collectFiles(inputs, options?)` | 対象ファイルのパス一覧を収集 |
|
|
85
|
+
| `formatText(results)` / `formatJson(results)` | スキャン結果を整形 |
|
|
86
|
+
|
|
87
|
+
型: `Comment` / `CommentKind` / `FileScanResult` / `ScanOptions` / `CollectOptions`
|
|
88
|
+
|
|
89
|
+
## 必要環境
|
|
90
|
+
|
|
91
|
+
Node.js 20 以上
|
|
92
|
+
|
|
93
|
+
## ライセンス
|
|
94
|
+
|
|
95
|
+
MIT
|
package/dist/args.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CAyBpD"}
|
package/dist/args.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function parseArgs(argv) {
|
|
2
|
+
const paths = [];
|
|
3
|
+
let json = false;
|
|
4
|
+
let help = false;
|
|
5
|
+
let version = false;
|
|
6
|
+
for (const arg of argv) {
|
|
7
|
+
switch (arg) {
|
|
8
|
+
case "--json":
|
|
9
|
+
json = true;
|
|
10
|
+
break;
|
|
11
|
+
case "-h":
|
|
12
|
+
case "--help":
|
|
13
|
+
help = true;
|
|
14
|
+
break;
|
|
15
|
+
case "-v":
|
|
16
|
+
case "--version":
|
|
17
|
+
version = true;
|
|
18
|
+
break;
|
|
19
|
+
default:
|
|
20
|
+
paths.push(arg);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return { paths: paths.length > 0 ? paths : ["."], json, help, version };
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=args.js.map
|
package/dist/args.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"args.js","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,SAAS,CAAC,IAAc;IACtC,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,IAAI,GAAG,KAAK,CAAC;IACjB,IAAI,IAAI,GAAG,KAAK,CAAC;IACjB,IAAI,OAAO,GAAG,KAAK,CAAC;IAEpB,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,QAAQ,GAAG,EAAE,CAAC;YACZ,KAAK,QAAQ;gBACX,IAAI,GAAG,IAAI,CAAC;gBACZ,MAAM;YACR,KAAK,IAAI,CAAC;YACV,KAAK,QAAQ;gBACX,IAAI,GAAG,IAAI,CAAC;gBACZ,MAAM;YACR,KAAK,IAAI,CAAC;YACV,KAAK,WAAW;gBACd,OAAO,GAAG,IAAI,CAAC;gBACf,MAAM;YACR;gBACE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAC1E,CAAC"}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import { run } from "./run.js";
|
|
4
|
+
process.exitCode = await run(process.argv.slice(2), {
|
|
5
|
+
out: (text) => {
|
|
6
|
+
process.stdout.write(text);
|
|
7
|
+
},
|
|
8
|
+
err: (text) => {
|
|
9
|
+
process.stderr.write(text);
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,OAAO,CAAC,QAAQ,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;IAClD,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE;QACZ,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IACD,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE;QACZ,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF,CAAC,CAAC"}
|
package/dist/files.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FileScanResult } from "./types.js";
|
|
2
|
+
export interface CollectOptions {
|
|
3
|
+
extensions?: string[];
|
|
4
|
+
ignoreDirs?: string[];
|
|
5
|
+
}
|
|
6
|
+
export declare function collectFiles(inputs: string[], options?: CollectOptions): Promise<string[]>;
|
|
7
|
+
export declare function scanFile(file: string): Promise<FileScanResult>;
|
|
8
|
+
export declare function scanPaths(inputs: string[], options?: CollectOptions): Promise<FileScanResult[]>;
|
|
9
|
+
//# sourceMappingURL=files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAMjD,MAAM,WAAW,cAAc;IAC7B,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,wBAAsB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAiBpG;AAmBD,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAGpE;AAED,wBAAsB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAGzG"}
|
package/dist/files.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { readFile, readdir, stat } from "node:fs/promises";
|
|
2
|
+
import { extname, join } from "node:path";
|
|
3
|
+
import { scanComments } from "./scanner.js";
|
|
4
|
+
const DEFAULT_EXTENSIONS = [".ts", ".tsx", ".mts", ".cts"];
|
|
5
|
+
const DEFAULT_IGNORE_DIRS = ["node_modules", ".git"];
|
|
6
|
+
const READ_CONCURRENCY = 16;
|
|
7
|
+
export async function collectFiles(inputs, options = {}) {
|
|
8
|
+
const extensions = options.extensions ?? DEFAULT_EXTENSIONS;
|
|
9
|
+
const ignoreDirs = new Set(options.ignoreDirs ?? DEFAULT_IGNORE_DIRS);
|
|
10
|
+
const found = new Set();
|
|
11
|
+
await Promise.all(inputs.map(async (input) => {
|
|
12
|
+
const info = await stat(input);
|
|
13
|
+
if (info.isDirectory()) {
|
|
14
|
+
await walk(input, extensions, ignoreDirs, found);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
found.add(input);
|
|
18
|
+
}
|
|
19
|
+
}));
|
|
20
|
+
return [...found].sort();
|
|
21
|
+
}
|
|
22
|
+
async function walk(dir, extensions, ignoreDirs, found) {
|
|
23
|
+
const entries = await readdir(dir, { withFileTypes: true });
|
|
24
|
+
await Promise.all(entries.map(async (entry) => {
|
|
25
|
+
const full = join(dir, entry.name);
|
|
26
|
+
if (entry.isDirectory()) {
|
|
27
|
+
if (!ignoreDirs.has(entry.name)) {
|
|
28
|
+
await walk(full, extensions, ignoreDirs, found);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else if (entry.isFile() && extensions.includes(extname(entry.name))) {
|
|
32
|
+
found.add(full);
|
|
33
|
+
}
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
export async function scanFile(file) {
|
|
37
|
+
const source = await readFile(file, "utf8");
|
|
38
|
+
return { file, comments: scanComments(source, { jsx: file.endsWith(".tsx") || file.endsWith(".jsx") }) };
|
|
39
|
+
}
|
|
40
|
+
export async function scanPaths(inputs, options = {}) {
|
|
41
|
+
const files = await collectFiles(inputs, options);
|
|
42
|
+
return mapLimit(files, READ_CONCURRENCY, scanFile);
|
|
43
|
+
}
|
|
44
|
+
async function mapLimit(items, limit, fn) {
|
|
45
|
+
const results = [];
|
|
46
|
+
const processFrom = async (start) => {
|
|
47
|
+
if (start >= items.length)
|
|
48
|
+
return;
|
|
49
|
+
const batch = await Promise.all(items.slice(start, start + limit).map(fn));
|
|
50
|
+
results.push(...batch);
|
|
51
|
+
await processFrom(start + limit);
|
|
52
|
+
};
|
|
53
|
+
await processFrom(0);
|
|
54
|
+
return results;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAA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AAa,EAAiB,EAAE;QACzD,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM;YAAE,OAAO;QAClC,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;QAC3E,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;QACvB,MAAM,WAAW,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC;IACnC,CAAC,CAAC;IAEF,MAAM,WAAW,CAAC,CAAC,CAAC,CAAC;IACrB,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { scanComments, type ScanOptions } from "./scanner.js";
|
|
2
|
+
export { collectFiles, scanFile, scanPaths, type CollectOptions } from "./files.js";
|
|
3
|
+
export { formatText, formatJson } from "./report.js";
|
|
4
|
+
export type { Comment, CommentKind, FileScanResult } from "./types.js";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AACpF,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAoB,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAuB,MAAM,YAAY,CAAC;AACpF,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/report.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../src/report.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,wBAAgB,UAAU,CAAC,OAAO,EAAE,cAAc,EAAE,GAAG,MAAM,CAkB5D;AAcD,wBAAgB,UAAU,CAAC,OAAO,EAAE,cAAc,EAAE,GAAG,MAAM,CAK5D"}
|
package/dist/report.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export function formatText(results) {
|
|
2
|
+
const withComments = results.filter((result) => result.comments.length > 0);
|
|
3
|
+
if (withComments.length === 0) {
|
|
4
|
+
return "No comments found.";
|
|
5
|
+
}
|
|
6
|
+
const lines = [];
|
|
7
|
+
let total = 0;
|
|
8
|
+
for (const { file, comments } of withComments) {
|
|
9
|
+
for (const comment of comments) {
|
|
10
|
+
lines.push(`${file}:${comment.line}:${comment.column} [${comment.kind}] ${preview(comment.text)}`);
|
|
11
|
+
total += 1;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
lines.push("", `${count(total, "comment")} across ${count(withComments.length, "file")}`);
|
|
15
|
+
return lines.join("\n");
|
|
16
|
+
}
|
|
17
|
+
function preview(text) {
|
|
18
|
+
return text
|
|
19
|
+
.split("\n")
|
|
20
|
+
.map((line) => line.trim())
|
|
21
|
+
.join(" ")
|
|
22
|
+
.trim();
|
|
23
|
+
}
|
|
24
|
+
function count(value, noun) {
|
|
25
|
+
return `${value} ${noun}${value === 1 ? "" : "s"}`;
|
|
26
|
+
}
|
|
27
|
+
export function formatJson(results) {
|
|
28
|
+
const files = results.filter((result) => result.comments.length > 0);
|
|
29
|
+
const comments = files.reduce((sum, file) => sum + file.comments.length, 0);
|
|
30
|
+
return JSON.stringify({ summary: { files: files.length, comments }, files }, null, 2);
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=report.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.js","sourceRoot":"","sources":["../src/report.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,UAAU,CAAC,OAAyB;IAClD,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAE5E,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9B,OAAO,oBAAoB,CAAC;IAC9B,CAAC;IAED,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,YAAY,EAAE,CAAC;QAC9C,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,IAAI,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,MAAM,KAAK,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACnG,KAAK,IAAI,CAAC,CAAC;QACb,CAAC;IACH,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,KAAK,CAAC,KAAK,EAAE,SAAS,CAAC,WAAW,KAAK,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;IAC1F,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,SAAS,OAAO,CAAC,IAAY;IAC3B,OAAO,IAAI;SACR,KAAK,CAAC,IAAI,CAAC;SACX,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;SAC1B,IAAI,CAAC,GAAG,CAAC;SACT,IAAI,EAAE,CAAC;AACZ,CAAC;AAED,SAAS,KAAK,CAAC,KAAa,EAAE,IAAY;IACxC,OAAO,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,OAAyB;IAClD,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACrE,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAE5E,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACxF,CAAC"}
|
package/dist/run.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface CliIO {
|
|
2
|
+
out: (text: string) => void;
|
|
3
|
+
err: (text: string) => void;
|
|
4
|
+
}
|
|
5
|
+
export declare const HELP_TEXT = "Usage: ts-comment-scanner [options] [paths...]\n\nDetect and report comments across a TypeScript project.\n\nOptions:\n --json Output results as JSON\n -v, --version Print the version number\n -h, --help Show this help\n\nPaths default to the current directory. Directories are scanned recursively\nfor .ts, .tsx, .mts and .cts files, skipping node_modules and .git.\n\nExamples:\n ts-comment-scanner src\n ts-comment-scanner --json src test\n";
|
|
6
|
+
export declare function run(argv: string[], io: CliIO): Promise<number>;
|
|
7
|
+
//# sourceMappingURL=run.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,KAAK;IACpB,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7B;AAED,eAAO,MAAM,SAAS,kdAerB,CAAC;AAEF,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,CAsBpE"}
|
package/dist/run.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { parseArgs } from "./args.js";
|
|
2
|
+
import { scanPaths } from "./files.js";
|
|
3
|
+
import { formatJson, formatText } from "./report.js";
|
|
4
|
+
import { getVersion } from "./version.js";
|
|
5
|
+
export const HELP_TEXT = `Usage: ts-comment-scanner [options] [paths...]
|
|
6
|
+
|
|
7
|
+
Detect and report comments across a TypeScript project.
|
|
8
|
+
|
|
9
|
+
Options:
|
|
10
|
+
--json Output results as JSON
|
|
11
|
+
-v, --version Print the version number
|
|
12
|
+
-h, --help Show this help
|
|
13
|
+
|
|
14
|
+
Paths default to the current directory. Directories are scanned recursively
|
|
15
|
+
for .ts, .tsx, .mts and .cts files, skipping node_modules and .git.
|
|
16
|
+
|
|
17
|
+
Examples:
|
|
18
|
+
ts-comment-scanner src
|
|
19
|
+
ts-comment-scanner --json src test
|
|
20
|
+
`;
|
|
21
|
+
export async function run(argv, io) {
|
|
22
|
+
const options = parseArgs(argv);
|
|
23
|
+
if (options.help) {
|
|
24
|
+
io.out(HELP_TEXT);
|
|
25
|
+
return 0;
|
|
26
|
+
}
|
|
27
|
+
if (options.version) {
|
|
28
|
+
io.out(`${await getVersion()}\n`);
|
|
29
|
+
return 0;
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
const results = await scanPaths(options.paths);
|
|
33
|
+
io.out(`${options.json ? formatJson(results) : formatText(results)}\n`);
|
|
34
|
+
return 0;
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
38
|
+
io.err(`ts-comment-scanner: ${message}\n`);
|
|
39
|
+
return 1;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=run.js.map
|
package/dist/run.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAO1C,MAAM,CAAC,MAAM,SAAS,GAAG;;;;;;;;;;;;;;;CAexB,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,IAAc,EAAE,EAAS;IACjD,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;IAEhC,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAClB,OAAO,CAAC,CAAC;IACX,CAAC;IAED,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,EAAE,CAAC,GAAG,CAAC,GAAG,MAAM,UAAU,EAAE,IAAI,CAAC,CAAC;QAClC,OAAO,CAAC,CAAC;IACX,CAAC;IAED,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC/C,EAAE,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACxE,OAAO,CAAC,CAAC;IACX,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,EAAE,CAAC,GAAG,CAAC,uBAAuB,OAAO,IAAI,CAAC,CAAC;QAC3C,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scanner.d.ts","sourceRoot":"","sources":["../src/scanner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAe,MAAM,YAAY,CAAC;AAEvD,MAAM,WAAW,WAAW;IAC1B,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,EAAE,CAkDjF"}
|
package/dist/scanner.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
export function scanComments(source, options = {}) {
|
|
3
|
+
const scriptKind = options.jsx === true ? ts.ScriptKind.TSX : ts.ScriptKind.TS;
|
|
4
|
+
const sourceFile = ts.createSourceFile("module.ts", source, ts.ScriptTarget.Latest, true, scriptKind);
|
|
5
|
+
const jsxTextSpans = [];
|
|
6
|
+
const ranges = [];
|
|
7
|
+
const seen = new Set();
|
|
8
|
+
const collect = (found) => {
|
|
9
|
+
if (!found)
|
|
10
|
+
return;
|
|
11
|
+
for (const range of found) {
|
|
12
|
+
if (seen.has(range.pos))
|
|
13
|
+
continue;
|
|
14
|
+
seen.add(range.pos);
|
|
15
|
+
ranges.push(range);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const visit = (node) => {
|
|
19
|
+
const children = node.getChildren(sourceFile);
|
|
20
|
+
if (children.length === 0) {
|
|
21
|
+
if (node.kind === ts.SyntaxKind.JsxText) {
|
|
22
|
+
jsxTextSpans.push([node.getFullStart(), node.getEnd()]);
|
|
23
|
+
}
|
|
24
|
+
collect(ts.getLeadingCommentRanges(source, node.getFullStart()));
|
|
25
|
+
collect(ts.getTrailingCommentRanges(source, node.getEnd()));
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
for (const child of children) {
|
|
29
|
+
visit(child);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
visit(sourceFile);
|
|
33
|
+
const insideJsxText = (pos) => jsxTextSpans.some(([start, end]) => pos >= start && pos < end);
|
|
34
|
+
return ranges
|
|
35
|
+
.filter((range) => !insideJsxText(range.pos))
|
|
36
|
+
.sort((a, b) => a.pos - b.pos)
|
|
37
|
+
.map((range) => {
|
|
38
|
+
const kind = range.kind === ts.SyntaxKind.SingleLineCommentTrivia ? "line" : "block";
|
|
39
|
+
const position = sourceFile.getLineAndCharacterOfPosition(range.pos);
|
|
40
|
+
return {
|
|
41
|
+
kind,
|
|
42
|
+
text: source.slice(range.pos, range.end),
|
|
43
|
+
start: range.pos,
|
|
44
|
+
end: range.end,
|
|
45
|
+
line: position.line + 1,
|
|
46
|
+
column: position.character + 1,
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=scanner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scanner.js","sourceRoot":"","sources":["../src/scanner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAO5B,MAAM,UAAU,YAAY,CAAC,MAAc,EAAE,UAAuB,EAAE;IACpE,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAA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export type CommentKind = "line" | "block";
|
|
2
|
+
export interface Comment {
|
|
3
|
+
kind: CommentKind;
|
|
4
|
+
text: string;
|
|
5
|
+
start: number;
|
|
6
|
+
end: number;
|
|
7
|
+
line: number;
|
|
8
|
+
column: number;
|
|
9
|
+
}
|
|
10
|
+
export interface FileScanResult {
|
|
11
|
+
file: string;
|
|
12
|
+
comments: Comment[];
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,OAAO,CAAC;AAE3C,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAEA,wBAAsB,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,CAIlD"}
|
package/dist/version.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,MAAM,CAAC,KAAK,UAAU,UAAU;IAC9B,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,iBAAiB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACxD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,CAAwB,CAAC;IAC3E,OAAO,GAAG,CAAC,OAAO,CAAC;AACrB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kongyo2/ts-comment-scanner",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "CLI to detect and report comments across a TypeScript project.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"typescript",
|
|
7
|
+
"comments",
|
|
8
|
+
"comment",
|
|
9
|
+
"cli",
|
|
10
|
+
"scanner",
|
|
11
|
+
"ast",
|
|
12
|
+
"code-analysis",
|
|
13
|
+
"kongyo2"
|
|
14
|
+
],
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"author": "kongyo2",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/kongyo2/ts-comment-scanner.git"
|
|
20
|
+
},
|
|
21
|
+
"type": "module",
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=20.0.0"
|
|
24
|
+
},
|
|
25
|
+
"bin": {
|
|
26
|
+
"ts-comment-scanner": "dist/cli.js"
|
|
27
|
+
},
|
|
28
|
+
"main": "./dist/index.js",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"import": "./dist/index.js",
|
|
34
|
+
"default": "./dist/index.js"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"sideEffects": false,
|
|
38
|
+
"files": [
|
|
39
|
+
"dist"
|
|
40
|
+
],
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "tsc",
|
|
43
|
+
"build:watch": "tsc --watch",
|
|
44
|
+
"typecheck": "tsc --noEmit",
|
|
45
|
+
"typecheck:watch": "tsc --noEmit --watch",
|
|
46
|
+
"start": "node dist/cli.js",
|
|
47
|
+
"test": "vitest run",
|
|
48
|
+
"test:watch": "vitest",
|
|
49
|
+
"lint": "oxlint --format agent",
|
|
50
|
+
"lint:fix": "oxlint --fix",
|
|
51
|
+
"lint:strict": "oxlint --deny-warnings",
|
|
52
|
+
"format": "prettier --write .",
|
|
53
|
+
"format:check": "prettier --check .",
|
|
54
|
+
"prepublishOnly": "npm run build"
|
|
55
|
+
},
|
|
56
|
+
"publishConfig": {
|
|
57
|
+
"access": "public"
|
|
58
|
+
},
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"typescript": "^6.0.3"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@types/node": "^25.9.3",
|
|
64
|
+
"oxlint": "^1.70.0",
|
|
65
|
+
"prettier": "^3.8.4",
|
|
66
|
+
"vitest": "^4.1.9"
|
|
67
|
+
}
|
|
68
|
+
}
|