@h5l0/codelens 0.1.0 → 0.1.2
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/README.en.md +28 -28
- package/README.md +31 -31
- package/docs/screenshots/en/calendar.png +0 -0
- package/docs/screenshots/en/loc.png +0 -0
- package/docs/screenshots/zh/calendar.png +0 -0
- package/docs/screenshots/zh/loc.png +0 -0
- package/package.json +1 -1
package/README.en.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# codelens
|
|
2
2
|
|
|
3
|
-
A local dashboard for
|
|
3
|
+
A local dashboard for a git repository: the change history and the lines of code.
|
|
4
4
|
|
|
5
5
|
English | [简体中文](./README.md)
|
|
6
6
|
|
|
@@ -19,19 +19,19 @@ npm install -g @h5l0/codelens
|
|
|
19
19
|
codelens
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
No configuration is
|
|
22
|
+
No configuration is necessary. The tool collects the data at startup and serves it to the local browser only. It does not write to the analyzed repository.
|
|
23
23
|
|
|
24
24
|
## The two views
|
|
25
25
|
|
|
26
26
|
### Change calendar
|
|
27
27
|
|
|
28
|
-
A
|
|
28
|
+
A weekly heat map of the changes: each cell is one day and shows the lines added and removed. You can filter by group, or move the time window to see other weeks.
|
|
29
29
|
|
|
30
30
|

|
|
31
31
|
|
|
32
32
|
### Lines of code
|
|
33
33
|
|
|
34
|
-
A treemap
|
|
34
|
+
A treemap: the area of a rectangle is the line count, the color is the category, and the shade is the directory depth. Click a rectangle to open that directory, or use the switches to set the counting mode and the depth.
|
|
35
35
|
|
|
36
36
|

|
|
37
37
|
|
|
@@ -56,17 +56,17 @@ codelens [directory] [options]
|
|
|
56
56
|
|
|
57
57
|
## Profiles
|
|
58
58
|
|
|
59
|
-
`--profile`
|
|
59
|
+
`--profile` sets how the tool splits the repository:
|
|
60
60
|
|
|
61
61
|
1. Point it at a JSON file: `--profile ./my-profile.json`;
|
|
62
|
-
2. Or use a name under `profiles` in `codelens.config.json`
|
|
62
|
+
2. Or use a name under `profiles` in `codelens.config.json`. Use `--config` to move that file: `--profile web`.
|
|
63
63
|
|
|
64
64
|
Two profiles are built in:
|
|
65
65
|
|
|
66
66
|
| Name | What it does |
|
|
67
67
|
| --- | --- |
|
|
68
|
-
| `all` | Default; no
|
|
69
|
-
| `web` |
|
|
68
|
+
| `all` | Default; no groups, the tool counts the whole repository together |
|
|
69
|
+
| `web` | `frontend/`, `web/`, `client/`, `ui/` and similar directories count as frontend, everything else as backend |
|
|
70
70
|
|
|
71
71
|
### Config file format
|
|
72
72
|
|
|
@@ -97,40 +97,40 @@ Two profiles are built in:
|
|
|
97
97
|
|
|
98
98
|
Field notes:
|
|
99
99
|
|
|
100
|
-
- `groups[].match`, `categories[].match` and `ignore` use globs relative to the repository root: `**` crosses directories, `*` does not, `?` matches one character, `{a,b}` matches either
|
|
101
|
-
- The config file
|
|
102
|
-
- `groups[].id` must not be
|
|
103
|
-
- `hue` and `sat` are HSL color components for group and category colors
|
|
104
|
-
- `categories[].defaultOn: false` means the category starts
|
|
100
|
+
- `groups[].match`, `categories[].match` and `ignore` use globs relative to the repository root: `**` crosses directories, `*` does not, `?` matches one character, and `{a,b}` matches either. A pattern without `/` matches items of that name at any depth. `/foo` is anchored to the root. `foo/` means the directory and everything inside it.
|
|
101
|
+
- The config file accepts `//` and `/* */` comments and trailing commas.
|
|
102
|
+
- `groups[].id` must not be `all`, and it must be unique in one profile.
|
|
103
|
+
- `hue` and `sat` are HSL color components for the group and category colors. The defaults are 214 and 50.
|
|
104
|
+
- `categories[].defaultOn: false` means the category starts off in the legend. Of the built-in categories, "generated code", "docs" and "config" start off.
|
|
105
105
|
|
|
106
|
-
Without `categories`, six built-in
|
|
106
|
+
Without `categories`, the tool uses six built-in categories: application code, tests, scripts, docs, config and generated code.
|
|
107
107
|
|
|
108
|
-
A profile name the config file does not define falls back to the built-in profile
|
|
108
|
+
A profile name that the config file does not define falls back to the built-in profile. A repository with a `codelens.config.json` that defines only custom profiles still supports `codelens --profile all` and `--profile web`. A name that is missing from both places is an error.
|
|
109
109
|
|
|
110
110
|
## Counting rules
|
|
111
111
|
|
|
112
|
-
- `.gitignore`
|
|
113
|
-
-
|
|
114
|
-
- `--exclude` and the config's `ignore` apply to both views
|
|
115
|
-
-
|
|
116
|
-
-
|
|
117
|
-
- Merge commits, empty commits and commits that only change file modes or binaries have no line counts
|
|
118
|
-
-
|
|
112
|
+
- The tool honors `.gitignore` by default. If the directory is not a git repository, the tool applies equivalent ignore rules instead. `--no-gitignore` turns this off.
|
|
113
|
+
- The tool always skips dependency and build directories, such as `node_modules`, `dist`, `build`, `coverage`, `.venv`, `__pycache__` and `target`.
|
|
114
|
+
- `--exclude` and the config's `ignore` apply to both views. The tool does not count excluded directories, and the calendar does not show them.
|
|
115
|
+
- The tool skips binary files, files larger than 3MB and empty files. If the tool cannot read a file, it skips that file and reports the count in the startup log. Line counts are physical lines; the newline at the end of a file does not count as one more line.
|
|
116
|
+
- The calendar puts each commit in the day of its commit time (committer date). This matches the `--days` filter. "Changed lines" means insertions plus deletions.
|
|
117
|
+
- Merge commits, empty commits and commits that only change file modes or binaries have no line counts. They still appear in the commit list and count as commits.
|
|
118
|
+
- If you run the tool on a subdirectory of a repository, both views count that subdirectory only and resolve paths relative to it.
|
|
119
119
|
|
|
120
120
|
## Known limits
|
|
121
121
|
|
|
122
|
-
- The change calendar needs git
|
|
123
|
-
- Line counts
|
|
124
|
-
- The treemap draws at most 6000 rectangles
|
|
125
|
-
- The calendar is padded to whole weeks
|
|
122
|
+
- The change calendar needs git. A repository without commits, or without git, leaves the calendar empty. The lines view still works.
|
|
123
|
+
- Line counts do not show the code complexity.
|
|
124
|
+
- The treemap draws at most 6000 rectangles. The rest are not shown.
|
|
125
|
+
- The calendar is padded to whole weeks. A window that does not start or end on a week boundary shows a few extra days without data, with a paler background.
|
|
126
126
|
|
|
127
127
|
## Languages
|
|
128
128
|
|
|
129
|
-
The page follows
|
|
129
|
+
The page follows the browser language. Simplified Chinese, English, Japanese and Korean are built in. Other languages fall back to English. Append `?lang={langCode}` to the URL to override the language, for example `?lang=zh` or `?lang=ko`.
|
|
130
130
|
|
|
131
131
|
## Development
|
|
132
132
|
|
|
133
|
-
See [DEV.md](./DEV.md) for the development setup, project layout and release process.
|
|
133
|
+
See [DEV.md](./DEV.md) for the development setup, the project layout and the release process.
|
|
134
134
|
|
|
135
135
|
## License
|
|
136
136
|
|
package/README.md
CHANGED
|
@@ -12,26 +12,26 @@ npx @h5l0/codelens ../my-repo # 统计指定仓库
|
|
|
12
12
|
npx @h5l0/codelens --profile web # 按前后端拆分改动日历
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
也可以全局安装:
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
18
|
npm install -g @h5l0/codelens
|
|
19
19
|
codelens
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
无需配置。数据在启动时生成,只提供给本机浏览器,不写入被统计的仓库。
|
|
23
23
|
|
|
24
24
|
## 两个视图
|
|
25
25
|
|
|
26
26
|
### 改动日历
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
按周排布的改动热力图:每格是一天,显示当天新增与删除的行数。可以按分组过滤,也可以平移时间窗口看其他周。
|
|
29
29
|
|
|
30
30
|

|
|
31
31
|
|
|
32
32
|
### 代码行数
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
面积树形图:方块面积表示行数,颜色表示分类,深浅表示目录层级。点方块进入该目录,右侧开关控制统计规则与展开层级。
|
|
35
35
|
|
|
36
36
|

|
|
37
37
|
|
|
@@ -40,12 +40,12 @@ codelens
|
|
|
40
40
|
```
|
|
41
41
|
codelens [目录] [选项]
|
|
42
42
|
|
|
43
|
-
--profile <名称|文件>
|
|
43
|
+
--profile <名称|文件> 配置档,见下节,内置 all、web
|
|
44
44
|
--config <文件> 配置文件,默认 <目录>/codelens.config.json
|
|
45
|
-
--days <天数>
|
|
45
|
+
--days <天数> 日历时间跨度,0 表示全部历史(默认 120)
|
|
46
46
|
--exclude <glob> 额外忽略的路径,可重复
|
|
47
47
|
--port <端口> 监听端口,默认 5178,被占用时向后尝试
|
|
48
|
-
--host <地址> 监听地址,默认 127.0.0.1
|
|
48
|
+
--host <地址> 监听地址,默认 127.0.0.1;监听其他地址时页面对同网段可见
|
|
49
49
|
--no-open 不自动打开浏览器
|
|
50
50
|
--no-gitignore 不按 .gitignore 过滤,只跳过内置的重目录
|
|
51
51
|
--dump <目录> 只写出 data.json 与 loc.json 后退出,不启动服务
|
|
@@ -56,17 +56,17 @@ codelens [目录] [选项]
|
|
|
56
56
|
|
|
57
57
|
## 配置档
|
|
58
58
|
|
|
59
|
-
`--profile`
|
|
59
|
+
`--profile` 决定切分仓库的维度:
|
|
60
60
|
|
|
61
|
-
1.
|
|
62
|
-
2. 取 `codelens.config.json
|
|
61
|
+
1. 指向 json 文件:`--profile ./my-profile.json`;
|
|
62
|
+
2. 取 `codelens.config.json` 里 `profiles` 下的档名,位置可用 `--config` 改:`--profile web`。
|
|
63
63
|
|
|
64
64
|
内置两档:
|
|
65
65
|
|
|
66
66
|
| 名称 | 作用 |
|
|
67
67
|
| --- | --- |
|
|
68
|
-
| `all` |
|
|
69
|
-
| `web` |
|
|
68
|
+
| `all` | 默认档,不分组,整个仓库一起统计 |
|
|
69
|
+
| `web` | `frontend/`、`web/`、`client/`、`ui/` 等算前端,其余算后端 |
|
|
70
70
|
|
|
71
71
|
### 配置文件格式
|
|
72
72
|
|
|
@@ -97,36 +97,36 @@ codelens [目录] [选项]
|
|
|
97
97
|
|
|
98
98
|
字段说明:
|
|
99
99
|
|
|
100
|
-
- `groups[].match`、`categories[].match`、`ignore`
|
|
101
|
-
-
|
|
100
|
+
- `groups[].match`、`categories[].match`、`ignore` 使用仓库相对路径的 glob:`**` 跨目录,`*` 不跨目录,`?` 匹配单个字符,`{a,b}` 择一;不含 `/` 的模式匹配任意层级的同名项,`/foo` 从仓库根起算,`foo/` 表示目录及其全部内容。
|
|
101
|
+
- 配置文件允许 `//`、`/* */` 注释与尾随逗号。
|
|
102
102
|
- `groups[].id` 不能是保留的 `all`,同一档里不能重复。
|
|
103
|
-
- `hue`、`sat`
|
|
104
|
-
- `categories[].defaultOn` 为 `false`
|
|
103
|
+
- `hue`、`sat` 是 HSL 颜色分量,用于分组色与分类色,缺省为 214、50。
|
|
104
|
+
- `categories[].defaultOn` 为 `false` 表示该分类在页面图例里默认关闭;内置分类中「生成代码」「文档」「配置」默认关闭。
|
|
105
105
|
|
|
106
|
-
不写 `categories`
|
|
106
|
+
不写 `categories` 时使用内置六类:应用代码、测试、脚本、文档、配置、生成代码。
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
配置里没有的档名回退到内置档:仓库里放一份只定义自定义档的 `codelens.config.json`,`--profile all`、`--profile web` 依然可用。两边都没有的档名才报错。
|
|
109
109
|
|
|
110
|
-
##
|
|
110
|
+
## 统计规则
|
|
111
111
|
|
|
112
|
-
-
|
|
113
|
-
-
|
|
114
|
-
- `--exclude
|
|
115
|
-
- 二进制文件、超过 3MB
|
|
116
|
-
- 改动日历按提交时间(committer date)归入所在天,与 `--days`
|
|
117
|
-
-
|
|
118
|
-
-
|
|
112
|
+
- 默认遵守仓库的 `.gitignore`;目录不是 git 仓库时改用等价的忽略规则。`--no-gitignore` 关闭该过滤。
|
|
113
|
+
- 始终跳过 `node_modules`、`dist`、`build`、`coverage`、`.venv`、`__pycache__`、`target` 等依赖与构建目录。
|
|
114
|
+
- `--exclude` 与配置里的 `ignore` 对两个视图同时生效:被排除的目录既不统计行数,也不计入改动日历。
|
|
115
|
+
- 二进制文件、超过 3MB 的文件、空文件不统计;读不出的文件只跳过它,并在启动日志里给出数量。行数为物理行数,文件末尾换行不计一行。
|
|
116
|
+
- 改动日历按提交时间(committer date)归入所在天,与 `--days` 的过滤规则一致;改动行数 = 新增 + 删除。
|
|
117
|
+
- 合并提交、空提交、只改权限或只动二进制的提交没有行数,但仍出现在提交列表里并计入提交数。
|
|
118
|
+
- 对仓库的子目录运行时,两个视图都只统计该子目录,路径也相对它计算。
|
|
119
119
|
|
|
120
|
-
##
|
|
120
|
+
## 已知限制
|
|
121
121
|
|
|
122
|
-
- 改动日历依赖 git
|
|
123
|
-
-
|
|
124
|
-
- 树形图一次最多绘制 6000
|
|
122
|
+
- 改动日历依赖 git:没有提交或没有 git 时日历为空,行数视图仍可用。
|
|
123
|
+
- 行数只反映文本行数,不反映代码复杂度。
|
|
124
|
+
- 树形图一次最多绘制 6000 个方块,超出部分不显示。
|
|
125
125
|
- 日历按整周补齐,窗口首尾不足一周时会多画出几天没有数据的格子(底色更白)。
|
|
126
126
|
|
|
127
127
|
## 多语言
|
|
128
128
|
|
|
129
|
-
|
|
129
|
+
页面语言跟随浏览器,内置简体中文、English、日本語、한국어,其余回落到英文。地址后加 `?lang={langCode}` 可临时覆盖,例如 `?lang=en`。
|
|
130
130
|
|
|
131
131
|
## 开发
|
|
132
132
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|