@zjex/git-workflow 0.5.0 → 0.5.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
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## [v0.5.1](https://github.com/iamzjt-front-end/git-workflow/compare/v0.5.0...v0.5.1) (2026-02-06)
4
+
5
+ - 🔖 chore(release): 发布 v0.5.1 ([88c2089](https://github.com/iamzjt-front-end/git-workflow/commit/88c2089))
6
+ - feat(release): 优化发布脚本,自动同步更新 CHANGELOG 和 README 版本号 ([89af235](https://github.com/iamzjt-front-end/git-workflow/commit/89af235))
7
+
8
+ ## [v0.5.0](https://github.com/iamzjt-front-end/git-workflow/compare/v0.4.7...v0.5.0) (2026-02-06)
9
+
10
+ - 🔖 chore(release): 发布 v0.5.0 ([51c5740](https://github.com/iamzjt-front-end/git-workflow/commit/51c5740))
11
+ - docs(readme): Add AI code review command example and update command list ([7e4ab78](https://github.com/iamzjt-front-end/git-workflow/commit/7e4ab78))
12
+ - 📝 docs: 自动更新测试数量徽章 [skip ci] ([bba208d](https://github.com/iamzjt-front-end/git-workflow/commit/bba208d))
13
+ - feat(review): Add AI code review command and documentation ([3f7b3b2](https://github.com/iamzjt-front-end/git-workflow/commit/3f7b3b2))
14
+
3
15
  ## [v0.4.7](https://github.com/iamzjt-front-end/git-workflow/compare/v0.4.6...v0.4.7) (2026-01-21)
4
16
 
5
17
  - 🔖 chore(release): 发布 v0.4.7 ([61ae098](https://github.com/iamzjt-front-end/git-workflow/commit/61ae098))
package/README.md CHANGED
@@ -150,7 +150,7 @@ gw
150
150
  ███████╗╚█████╔╝███████╗██╔╝ ██╗
151
151
  ╚══════╝ ╚════╝ ╚══════╝╚═╝ ╚═╝
152
152
 
153
- git-workflow v0.2.16
153
+ git-workflow v0.5.0
154
154
 
155
155
  ? 选择操作:
156
156
  [1] ✨ 创建 feature 分支 gw f
package/dist/index.js CHANGED
@@ -182,12 +182,11 @@ import { join as join4 } from "path";
182
182
  import boxen2 from "boxen";
183
183
  import { select as select7 } from "@inquirer/prompts";
184
184
  import ora5 from "ora";
185
- import semver from "semver";
186
185
  async function checkForUpdates(currentVersion, packageName = "@zjex/git-workflow", interactive = false) {
187
186
  try {
188
187
  const cache = readCache();
189
188
  const now = Date.now();
190
- if (cache?.latestVersion && semver.gt(cache.latestVersion, currentVersion)) {
189
+ if (cache?.latestVersion && cache.latestVersion !== currentVersion) {
191
190
  const isDismissed = cache.lastDismiss && now - cache.lastDismiss < DISMISS_INTERVAL;
192
191
  if (!isDismissed) {
193
192
  if (interactive) {
@@ -214,20 +213,13 @@ async function checkForUpdates(currentVersion, packageName = "@zjex/git-workflow
214
213
  }
215
214
  }
216
215
  function backgroundCheck(currentVersion, packageName) {
217
- const cache = readCache();
218
- const now = Date.now();
219
- const isUpToDate = cache?.latestVersion && !semver.gt(cache.latestVersion, currentVersion);
220
- const recentlyChecked = cache?.lastCheck && now - cache.lastCheck < CHECK_INTERVAL;
221
- if (isUpToDate && recentlyChecked) {
222
- return;
223
- }
224
216
  setImmediate(async () => {
225
217
  try {
226
218
  const latestVersion = await getLatestVersion(packageName);
227
219
  if (latestVersion) {
228
- const cache2 = readCache() || {};
220
+ const cache = readCache() || {};
229
221
  writeCache({
230
- ...cache2,
222
+ ...cache,
231
223
  lastCheck: Date.now(),
232
224
  latestVersion,
233
225
  checkedVersion: currentVersion
@@ -393,13 +385,12 @@ function writeCache(cache) {
393
385
  } catch {
394
386
  }
395
387
  }
396
- var DISMISS_INTERVAL, CHECK_INTERVAL, CACHE_FILE;
388
+ var DISMISS_INTERVAL, CACHE_FILE;
397
389
  var init_update_notifier = __esm({
398
390
  "src/update-notifier.ts"() {
399
391
  "use strict";
400
392
  init_utils();
401
393
  DISMISS_INTERVAL = 1e3 * 60 * 60 * 24;
402
- CHECK_INTERVAL = 1e3 * 60 * 60 * 1;
403
394
  CACHE_FILE = ".gw-update-check";
404
395
  }
405
396
  });
@@ -2820,7 +2811,7 @@ init_utils();
2820
2811
  import { execSync as execSync4, spawn as spawn3 } from "child_process";
2821
2812
  import ora6 from "ora";
2822
2813
  import boxen3 from "boxen";
2823
- import semver2 from "semver";
2814
+ import semver from "semver";
2824
2815
  import { existsSync as existsSync4, unlinkSync as unlinkSync3 } from "fs";
2825
2816
  import { homedir as homedir4 } from "os";
2826
2817
  import { join as join5 } from "path";
@@ -2881,7 +2872,7 @@ async function update(currentVersion) {
2881
2872
  return;
2882
2873
  }
2883
2874
  spinner.stop();
2884
- if (semver2.gte(currentVersion, latestVersion)) {
2875
+ if (semver.gte(currentVersion, latestVersion)) {
2885
2876
  console.log(
2886
2877
  boxen3(
2887
2878
  [
@@ -4210,7 +4201,7 @@ process.on("SIGTERM", () => {
4210
4201
  console.log("");
4211
4202
  process.exit(0);
4212
4203
  });
4213
- var version = true ? "0.5.0" : "0.0.0-dev";
4204
+ var version = true ? "0.5.2" : "0.0.0-dev";
4214
4205
  async function mainMenu() {
4215
4206
  console.log(
4216
4207
  colors.green(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zjex/git-workflow",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "🚀 极简的 Git 工作流 CLI 工具,让分支管理和版本发布变得轻松愉快",
5
5
  "type": "module",
6
6
  "bin": {
@@ -327,6 +327,20 @@ if check_tag_exists "$NEW_VERSION"; then
327
327
  exit 1
328
328
  fi
329
329
 
330
+ # 生成 changelog(在测试之前,这样可以包含在提交中)
331
+ print_step "生成 CHANGELOG..."
332
+ if [[ "$DRY_RUN" == false ]]; then
333
+ npm run changelog
334
+ fi
335
+ print_success "CHANGELOG 已更新"
336
+
337
+ # 更新 README 中的版本号
338
+ print_step "更新 README 版本号..."
339
+ if [[ "$DRY_RUN" == false ]]; then
340
+ node scripts/update-version-badge.js "$NEW_VERSION"
341
+ fi
342
+ print_success "README 版本号已更新"
343
+
330
344
  # 运行测试(如果有)
331
345
  if grep -q '"test"' package.json; then
332
346
  print_step "运行测试..."
@@ -357,13 +371,6 @@ if [[ "$DRY_RUN" == false ]]; then
357
371
  print_success "构建产物验证通过"
358
372
  fi
359
373
 
360
- # 生成 changelog
361
- print_step "生成 CHANGELOG..."
362
- if [[ "$DRY_RUN" == false ]]; then
363
- npm run changelog
364
- fi
365
- print_success "CHANGELOG 已更新"
366
-
367
374
  # 预览 changelog
368
375
  if [[ "$DRY_RUN" == false ]]; then
369
376
  echo ""
@@ -388,8 +395,8 @@ if [[ "$DRY_RUN" == true ]]; then
388
395
  echo ""
389
396
  print_success "Dry-run 完成!以下是将要执行的操作:"
390
397
  echo ""
391
- echo " 1. 提交更改: package.json, package-lock.json, CHANGELOG.md"
392
- echo " 2. Commit 信息: 🔖 chore(release): v${NEW_VERSION}"
398
+ echo " 1. 提交更改: package.json, package-lock.json, CHANGELOG.md, README.md"
399
+ echo " 2. Commit 信息: 🔖 chore(release): 发布 v${NEW_VERSION}"
393
400
  echo " 3. 创建 tag: v${NEW_VERSION}"
394
401
  echo " 4. 推送到 GitHub: ${CURRENT_BRANCH} + v${NEW_VERSION}"
395
402
  echo " 5. 发布到 npm: @zjex/git-workflow@${NEW_VERSION}"
@@ -410,8 +417,8 @@ fi
410
417
 
411
418
  # 提交更改
412
419
  print_step "提交更改..."
413
- git add package.json package-lock.json CHANGELOG.md
414
- git commit -m "🔖 chore(release): v${NEW_VERSION}"
420
+ git add package.json package-lock.json CHANGELOG.md README.md
421
+ git commit -m "🔖 chore(release): 发布 v${NEW_VERSION}"
415
422
  print_success "更改已提交"
416
423
 
417
424
  # 创建 tag
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * 更新 README 中的版本号显示
5
+ * 用于发布时同步更新示例中的版本号
6
+ */
7
+
8
+ import { readFileSync, writeFileSync } from 'fs';
9
+
10
+ const version = process.argv[2];
11
+
12
+ if (!version) {
13
+ console.error('❌ 请提供版本号参数');
14
+ console.error('用法: node scripts/update-version-badge.js 0.5.0');
15
+ process.exit(1);
16
+ }
17
+
18
+ try {
19
+ const readmePath = 'README.md';
20
+ let content = readFileSync(readmePath, 'utf8');
21
+
22
+ // 更新示例中的版本号 (git-workflow v0.x.x)
23
+ const versionRegex = /git-workflow v\d+\.\d+\.\d+/g;
24
+ const newVersion = `git-workflow v${version}`;
25
+
26
+ if (content.match(versionRegex)) {
27
+ const oldContent = content;
28
+ content = content.replace(versionRegex, newVersion);
29
+
30
+ if (oldContent !== content) {
31
+ writeFileSync(readmePath, content);
32
+ console.log(`✅ README 版本号已更新为 v${version}`);
33
+ } else {
34
+ console.log(`ℹ️ 版本号无变化,保持 v${version}`);
35
+ }
36
+ } else {
37
+ console.log('⚠️ 未找到版本号模式,跳过更新');
38
+ }
39
+
40
+ } catch (error) {
41
+ console.error('❌ 更新版本号失败:', error.message);
42
+ process.exit(1);
43
+ }
@@ -5,11 +5,9 @@ import { join } from "path";
5
5
  import boxen from "boxen";
6
6
  import { select } from "@inquirer/prompts";
7
7
  import ora from "ora";
8
- import semver from "semver";
9
8
  import { colors } from "./utils.js";
10
9
 
11
10
  const DISMISS_INTERVAL = 1000 * 60 * 60 * 24; // 24 小时后再次提示
12
- const CHECK_INTERVAL = 1000 * 60 * 60 * 1; // 已是最新版本时,1 小时检查一次
13
11
  const CACHE_FILE = ".gw-update-check";
14
12
 
15
13
  interface UpdateCache {
@@ -35,10 +33,10 @@ export async function checkForUpdates(
35
33
  const cache = readCache();
36
34
  const now = Date.now();
37
35
 
38
- // 1. 先用缓存的结果提示用户(如果有新版本)
36
+ // 1. 先用缓存的结果提示用户(如果版本不一致)
39
37
  if (
40
38
  cache?.latestVersion &&
41
- semver.gt(cache.latestVersion, currentVersion)
39
+ cache.latestVersion !== currentVersion
42
40
  ) {
43
41
  // 检查用户是否在 24 小时内关闭过提示
44
42
  const isDismissed =
@@ -76,23 +74,9 @@ export async function checkForUpdates(
76
74
 
77
75
  /**
78
76
  * 后台异步检查更新(不阻塞)
79
- * - 有新版本时:每次都检查
80
- * - 已是最新版本时:1 小时检查一次
77
+ * 每次运行命令时都异步检查一次
81
78
  */
82
79
  function backgroundCheck(currentVersion: string, packageName: string): void {
83
- const cache = readCache();
84
- const now = Date.now();
85
-
86
- // 如果已是最新版本,且距离上次检查不到 1 小时,跳过
87
- const isUpToDate =
88
- cache?.latestVersion && !semver.gt(cache.latestVersion, currentVersion);
89
- const recentlyChecked =
90
- cache?.lastCheck && now - cache.lastCheck < CHECK_INTERVAL;
91
-
92
- if (isUpToDate && recentlyChecked) {
93
- return;
94
- }
95
-
96
80
  // 使用 setImmediate 确保不阻塞主流程
97
81
  setImmediate(async () => {
98
82
  try {
@@ -153,7 +153,7 @@ describe("Update Notifier 模块测试", () => {
153
153
  consoleSpy.mockRestore();
154
154
  });
155
155
 
156
- it("已是最新版本且1小时内不应该重复检查", async () => {
156
+ it("每次运行都应该后台检查最新版本", async () => {
157
157
  const mockCache = {
158
158
  lastCheck: Date.now(),
159
159
  latestVersion: "1.0.0",
@@ -167,14 +167,13 @@ describe("Update Notifier 模块测试", () => {
167
167
  await checkForUpdates("1.0.0");
168
168
  await vi.runAllTimersAsync();
169
169
 
170
- // writeFileSync 不应该被调用(因为已是最新版本且在1小时内)
171
- expect(writeFileSync).not.toHaveBeenCalled();
170
+ // 每次运行都应该后台检查
171
+ expect(writeFileSync).toHaveBeenCalled();
172
172
  });
173
173
 
174
- it("已是最新版本但超过1小时应该重新检查", async () => {
175
- const oneHourAgo = Date.now() - 2 * 60 * 60 * 1000; // 2小时前
174
+ it("后台检查应该更新缓存中的最新版本", async () => {
176
175
  const mockCache = {
177
- lastCheck: oneHourAgo,
176
+ lastCheck: Date.now() - 2 * 60 * 60 * 1000,
178
177
  latestVersion: "1.0.0",
179
178
  checkedVersion: "1.0.0",
180
179
  };
@@ -311,7 +310,7 @@ describe("Update Notifier 模块测试", () => {
311
310
  { current: "1.0.0", latest: "1.0.1", shouldShow: true },
312
311
  { current: "1.0.0", latest: "1.1.0", shouldShow: true },
313
312
  { current: "1.0.0", latest: "2.0.0", shouldShow: true },
314
- { current: "1.0.1", latest: "1.0.0", shouldShow: false },
313
+ { current: "1.0.1", latest: "1.0.0", shouldShow: true }, // 回滚场景也应该提示
315
314
  { current: "1.0.0", latest: "1.0.0", shouldShow: false },
316
315
  ];
317
316