wukong-gitlog-cli 1.0.1 → 1.0.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/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.0.2](https://github.com/tomatobybike/wukong-gitlog-cli/compare/v1.0.1...v1.0.2) (2025-11-28)
6
+
7
+
8
+ ### Features
9
+
10
+ * 🎸 await zx ([79343d6](https://github.com/tomatobybike/wukong-gitlog-cli/commit/79343d6722c19b8c6381211b1a9b35923443abb5))
11
+
5
12
  ### [1.0.1](https://github.com/tomatobybike/wukong-gitlog-cli/compare/v0.0.15...v1.0.1) (2025-11-28)
6
13
 
7
14
 
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import('../src/cli.mjs');
2
+ import('../src/cli.mjs')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wukong-gitlog-cli",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Advanced Git commit log exporter with Excel/JSON/TXT output, grouping, stats and CLI.",
5
5
  "keywords": [
6
6
  "git",
@@ -96,7 +96,7 @@
96
96
  "string-width": "5.1.2",
97
97
  "exceljs": "4.4.0",
98
98
  "zx": "7.2.4",
99
- "is-online": "12.0.1",
99
+ "is-online": "12.0.2",
100
100
  "boxen": "8.0.1",
101
101
  "chalk": "5.6.2"
102
102
  },
package/src/cli.mjs CHANGED
@@ -4,7 +4,6 @@ import fs from 'fs'
4
4
  import path from 'path'
5
5
  import { fileURLToPath } from 'url'
6
6
 
7
-
8
7
  import { CLI_NAME } from './constants/index.mjs'
9
8
  import { exportExcel, exportExcelPerPeriodSheets } from './excel.mjs'
10
9
  import { getGitLogs } from './git.mjs'
@@ -27,7 +26,6 @@ import { showVersionInfo } from './utils/showVersionInfo.mjs'
27
26
 
28
27
  const __dirname = path.dirname(fileURLToPath(import.meta.url))
29
28
 
30
-
31
29
  const pkg = JSON.parse(
32
30
  fs.readFileSync(path.resolve(__dirname, '../package.json'), 'utf8')
33
31
  )
@@ -52,106 +50,110 @@ const version = async () => {
52
50
  process.exit(0)
53
51
  }
54
52
 
55
- const program = new Command()
53
+ const main = async () => {
54
+ const program = new Command()
56
55
 
57
- program
58
- .name('git-commits')
59
- .description('Advanced Git commit log exporter.')
60
- .option('--author <name>', '指定 author 名')
61
- .option('--email <email>', '指定 email')
62
- .option('--since <date>', '起始日期')
63
- .option('--until <date>', '结束日期')
64
- .option('--limit <n>', '限制数量', parseInt)
65
- .option('--no-merges', '不包含 merge commit')
66
- .option('--json', '输出 JSON')
67
- .option('--format <type>', '输出格式: text | excel | json', 'text')
68
- .option('--group-by <type>', '按日期分组: day | month | week')
69
- .option('--stats', '输出每日统计数据')
70
- .option(
71
- '--gerrit <prefix>',
72
- '显示 Gerrit 地址,支持在 prefix 中使用 {{hash}} 占位符'
73
- )
74
- .option(
75
- '--gerrit-api <url>',
76
- '可选:Gerrit REST API 基础地址,用于解析 changeNumber,例如 `https://gerrit.example.com`'
77
- )
78
- .option(
79
- '--gerrit-auth <tokenOrUserPass>',
80
- '可选:Gerrit API 授权,格式为 `user:pass` 或 `TOKEN`(表示 Bearer token)'
81
- )
82
- .option('--overtime', '分析公司加班文化(输出下班时间与非工作日提交占比)')
83
- .option('--country <code>', '节假日国家:CN 或 US,默认为 CN', 'CN')
84
- .option(
85
- '--work-start <hour>',
86
- '上班开始小时,默认 9',
87
- (v) => parseInt(v, 10),
88
- 9
89
- )
90
- .option('--work-end <hour>', '下班小时,默认 18', (v) => parseInt(v, 10), 18)
91
- .option(
92
- '--lunch-start <hour>',
93
- '午休开始小时,默认 12',
94
- (v) => parseInt(v, 10),
95
- 12
96
- )
97
- .option(
98
- '--lunch-end <hour>',
99
- '午休结束小时,默认 14',
100
- (v) => parseInt(v, 10),
101
- 14
102
- )
103
- .option('--out <file>', '输出文件名(不含路径)')
104
- .option(
105
- '--out-dir <dir>',
106
- '自定义输出目录,支持相对路径或绝对路径,例如 `--out-dir ../output`'
107
- )
108
- .option(
109
- '--out-parent',
110
- '将输出目录放到当前工程的父目录的 `output/`(等同于 `--out-dir ../output`)'
111
- )
112
- .option(
113
- '--per-period-formats <formats>',
114
- '每个周期单独输出的格式,逗号分隔:text,csv,tab,xlsx。默认为空(不输出 CSV/Tab/XLSX)',
115
- ''
116
- )
117
- .option(
118
- '--per-period-excel-mode <mode>',
119
- 'per-period Excel 模式:sheets|files(默认:sheets)',
120
- 'sheets'
121
- )
122
- .option(
123
- '--per-period-only',
124
- '仅输出 per-period(month/week)文件,不输出合并的 monthly/weekly 汇总文件'
125
- )
126
- .option(
127
- '--serve',
128
- '启动本地 web 服务,查看提交统计(将在 output/data 下生成数据文件)'
129
- )
130
- .option(
131
- '--port <n>',
132
- '本地 web 服务端口(默认 3000)',
133
- (v) => parseInt(v, 10),
134
- 3000
135
- )
136
- .option(
137
- '--serve-only',
138
- '仅启动 web 服务,不导出或分析数据(使用 output/data 中已有的数据)'
139
- )
140
- .option('--version', 'show version information')
141
- .parse()
56
+ program
57
+ .name('git-commits')
58
+ .description('Advanced Git commit log exporter.')
59
+ .option('--author <name>', '指定 author 名')
60
+ .option('--email <email>', '指定 email')
61
+ .option('--since <date>', '起始日期')
62
+ .option('--until <date>', '结束日期')
63
+ .option('--limit <n>', '限制数量', parseInt)
64
+ .option('--no-merges', '不包含 merge commit')
65
+ .option('--json', '输出 JSON')
66
+ .option('--format <type>', '输出格式: text | excel | json', 'text')
67
+ .option('--group-by <type>', '按日期分组: day | month | week')
68
+ .option('--stats', '输出每日统计数据')
69
+ .option(
70
+ '--gerrit <prefix>',
71
+ '显示 Gerrit 地址,支持在 prefix 中使用 {{hash}} 占位符'
72
+ )
73
+ .option(
74
+ '--gerrit-api <url>',
75
+ '可选:Gerrit REST API 基础地址,用于解析 changeNumber,例如 `https://gerrit.example.com`'
76
+ )
77
+ .option(
78
+ '--gerrit-auth <tokenOrUserPass>',
79
+ '可选:Gerrit API 授权,格式为 `user:pass` 或 `TOKEN`(表示 Bearer token)'
80
+ )
81
+ .option('--overtime', '分析公司加班文化(输出下班时间与非工作日提交占比)')
82
+ .option('--country <code>', '节假日国家:CN 或 US,默认为 CN', 'CN')
83
+ .option(
84
+ '--work-start <hour>',
85
+ '上班开始小时,默认 9',
86
+ (v) => parseInt(v, 10),
87
+ 9
88
+ )
89
+ .option(
90
+ '--work-end <hour>',
91
+ '下班小时,默认 18',
92
+ (v) => parseInt(v, 10),
93
+ 18
94
+ )
95
+ .option(
96
+ '--lunch-start <hour>',
97
+ '午休开始小时,默认 12',
98
+ (v) => parseInt(v, 10),
99
+ 12
100
+ )
101
+ .option(
102
+ '--lunch-end <hour>',
103
+ '午休结束小时,默认 14',
104
+ (v) => parseInt(v, 10),
105
+ 14
106
+ )
107
+ .option('--out <file>', '输出文件名(不含路径)')
108
+ .option(
109
+ '--out-dir <dir>',
110
+ '自定义输出目录,支持相对路径或绝对路径,例如 `--out-dir ../output`'
111
+ )
112
+ .option(
113
+ '--out-parent',
114
+ '将输出目录放到当前工程的父目录的 `output/`(等同于 `--out-dir ../output`)'
115
+ )
116
+ .option(
117
+ '--per-period-formats <formats>',
118
+ '每个周期单独输出的格式,逗号分隔:text,csv,tab,xlsx。默认为空(不输出 CSV/Tab/XLSX)',
119
+ ''
120
+ )
121
+ .option(
122
+ '--per-period-excel-mode <mode>',
123
+ 'per-period Excel 模式:sheets|files(默认:sheets)',
124
+ 'sheets'
125
+ )
126
+ .option(
127
+ '--per-period-only',
128
+ '仅输出 per-period(month/week)文件,不输出合并的 monthly/weekly 汇总文件'
129
+ )
130
+ .option(
131
+ '--serve',
132
+ '启动本地 web 服务,查看提交统计(将在 output/data 下生成数据文件)'
133
+ )
134
+ .option(
135
+ '--port <n>',
136
+ '本地 web 服务端口(默认 3000)',
137
+ (v) => parseInt(v, 10),
138
+ 3000
139
+ )
140
+ .option(
141
+ '--serve-only',
142
+ '仅启动 web 服务,不导出或分析数据(使用 output/data 中已有的数据)'
143
+ )
144
+ .option('--version', 'show version information')
145
+ .parse()
142
146
 
143
- const opts = program.opts()
144
- // compute output directory root early (so serve-only can use it)
145
- const outDir = opts.outParent
146
- ? path.resolve(process.cwd(), '..', 'output')
147
- : opts.outDir || undefined
147
+ const opts = program.opts()
148
+ // compute output directory root early (so serve-only can use it)
149
+ const outDir = opts.outParent
150
+ ? path.resolve(process.cwd(), '..', 'output')
151
+ : opts.outDir || undefined
148
152
 
149
- ;(async () => {
150
153
  if (opts.version) {
151
154
  await version()
152
155
  return
153
156
  }
154
- await autoCheckUpdate()
155
157
  // if serve-only is requested, start server and exit
156
158
  if (opts.serveOnly) {
157
159
  try {
@@ -621,4 +623,7 @@ const outDir = opts.outParent
621
623
  console.log(chalk.green(`Excel 已导出: ${excelPath}`))
622
624
  console.log(chalk.green(`文本已自动导出: ${txtPath}`))
623
625
  }
624
- })()
626
+ await autoCheckUpdate()
627
+ }
628
+
629
+ main()
package/src/git.mjs CHANGED
@@ -1,5 +1,5 @@
1
- #!/usr/bin/env zx
2
- import 'zx/globals'
1
+ import { $ } from 'zx'
2
+
3
3
 
4
4
  export async function getGitLogs(opts) {
5
5
  const { author, email, since, until, limit, merges } = opts