@zjex/git-workflow 0.2.19 → 0.2.21
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/CODE_DOCUMENTATION.md +169 -0
- package/dist/index.js +396 -214
- package/package.json +4 -2
- package/src/commands/commit.ts +93 -32
- package/src/commands/help.ts +4 -1
- package/src/commands/tag.ts +49 -22
- package/src/commands/update.ts +43 -8
- package/src/index.ts +68 -11
- package/src/update-notifier.ts +122 -34
package/dist/index.js
CHANGED
|
@@ -1,31 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env -S node --no-warnings=ExperimentalWarning
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __esm = (fn, res) => function __init() {
|
|
5
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
6
|
+
};
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
7
11
|
|
|
8
12
|
// src/utils.ts
|
|
9
13
|
import { execSync } from "child_process";
|
|
10
|
-
var colors = {
|
|
11
|
-
red: (s) => `\x1B[31m${s}\x1B[0m`,
|
|
12
|
-
green: (s) => `\x1B[32m${s}\x1B[0m`,
|
|
13
|
-
yellow: (s) => `\x1B[33m${s}\x1B[0m`,
|
|
14
|
-
cyan: (s) => `\x1B[36m${s}\x1B[0m`,
|
|
15
|
-
dim: (s) => `\x1B[2m${s}\x1B[0m`,
|
|
16
|
-
bold: (s) => `\x1B[1m${s}\x1B[0m`,
|
|
17
|
-
reset: "\x1B[0m"
|
|
18
|
-
};
|
|
19
|
-
var TODAY = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10).replace(/-/g, "");
|
|
20
|
-
var theme = {
|
|
21
|
-
helpMode: "always",
|
|
22
|
-
style: {
|
|
23
|
-
keysHelpTip: (keys) => {
|
|
24
|
-
const tips = keys.map(([key, label]) => `${key} ${label}`).join(" \u2022 ");
|
|
25
|
-
return `\x1B[2m${tips} \u2022 Ctrl+C quit\x1B[0m`;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
14
|
function exec(cmd, silent = false) {
|
|
30
15
|
try {
|
|
31
16
|
const options = {
|
|
@@ -66,13 +51,267 @@ function getMainBranch() {
|
|
|
66
51
|
function divider() {
|
|
67
52
|
console.log(colors.dim("\u2500".repeat(40)));
|
|
68
53
|
}
|
|
54
|
+
var colors, TODAY, theme;
|
|
55
|
+
var init_utils = __esm({
|
|
56
|
+
"src/utils.ts"() {
|
|
57
|
+
"use strict";
|
|
58
|
+
colors = {
|
|
59
|
+
red: (s) => `\x1B[31m${s}\x1B[0m`,
|
|
60
|
+
green: (s) => `\x1B[32m${s}\x1B[0m`,
|
|
61
|
+
yellow: (s) => `\x1B[33m${s}\x1B[0m`,
|
|
62
|
+
cyan: (s) => `\x1B[36m${s}\x1B[0m`,
|
|
63
|
+
dim: (s) => `\x1B[2m${s}\x1B[0m`,
|
|
64
|
+
bold: (s) => `\x1B[1m${s}\x1B[0m`,
|
|
65
|
+
reset: "\x1B[0m"
|
|
66
|
+
};
|
|
67
|
+
TODAY = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10).replace(/-/g, "");
|
|
68
|
+
theme = {
|
|
69
|
+
helpMode: "always",
|
|
70
|
+
style: {
|
|
71
|
+
keysHelpTip: (keys) => {
|
|
72
|
+
const tips = keys.map(([key, label]) => `${key} ${label}`).join(" \u2022 ");
|
|
73
|
+
return `\x1B[2m${tips} \u2022 Ctrl+C quit\x1B[0m`;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// src/update-notifier.ts
|
|
81
|
+
var update_notifier_exports = {};
|
|
82
|
+
__export(update_notifier_exports, {
|
|
83
|
+
checkForUpdates: () => checkForUpdates,
|
|
84
|
+
clearUpdateCache: () => clearUpdateCache
|
|
85
|
+
});
|
|
86
|
+
import { execSync as execSync6 } from "child_process";
|
|
87
|
+
import { readFileSync as readFileSync3, writeFileSync as writeFileSync3, existsSync as existsSync3, unlinkSync } from "fs";
|
|
88
|
+
import { homedir as homedir3 } from "os";
|
|
89
|
+
import { join as join3 } from "path";
|
|
90
|
+
import boxen from "boxen";
|
|
91
|
+
import { select as select7 } from "@inquirer/prompts";
|
|
92
|
+
import ora5 from "ora";
|
|
93
|
+
import semver from "semver";
|
|
94
|
+
async function checkForUpdates(currentVersion, packageName = "@zjex/git-workflow", interactive = false) {
|
|
95
|
+
try {
|
|
96
|
+
const cache = readCache();
|
|
97
|
+
const now = Date.now();
|
|
98
|
+
if (cache?.latestVersion && cache.checkedVersion === currentVersion) {
|
|
99
|
+
if (cache.lastDismiss && now - cache.lastDismiss < DISMISS_INTERVAL) {
|
|
100
|
+
backgroundCheck(currentVersion, packageName);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (semver.gt(cache.latestVersion, currentVersion)) {
|
|
104
|
+
if (interactive) {
|
|
105
|
+
const action = await showUpdateMessage(
|
|
106
|
+
currentVersion,
|
|
107
|
+
cache.latestVersion,
|
|
108
|
+
packageName
|
|
109
|
+
);
|
|
110
|
+
if (action === "update") {
|
|
111
|
+
await performUpdate(packageName);
|
|
112
|
+
} else if (action === "dismiss") {
|
|
113
|
+
writeCache({ ...cache, lastDismiss: now });
|
|
114
|
+
}
|
|
115
|
+
} else {
|
|
116
|
+
showSimpleNotification(currentVersion, cache.latestVersion);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
backgroundCheck(currentVersion, packageName);
|
|
121
|
+
} catch (error) {
|
|
122
|
+
if (error?.constructor?.name === "ExitPromptError") {
|
|
123
|
+
throw error;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function backgroundCheck(currentVersion, packageName) {
|
|
128
|
+
const cache = readCache();
|
|
129
|
+
const now = Date.now();
|
|
130
|
+
if (cache?.lastCheck && now - cache.lastCheck < CHECK_INTERVAL) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
Promise.resolve().then(async () => {
|
|
134
|
+
try {
|
|
135
|
+
const latestVersion = await getLatestVersion(packageName);
|
|
136
|
+
if (latestVersion) {
|
|
137
|
+
writeCache({
|
|
138
|
+
...cache,
|
|
139
|
+
lastCheck: now,
|
|
140
|
+
latestVersion,
|
|
141
|
+
checkedVersion: currentVersion
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
} catch {
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
async function getLatestVersion(packageName) {
|
|
149
|
+
try {
|
|
150
|
+
const result = execSync6(`npm view ${packageName} version`, {
|
|
151
|
+
encoding: "utf-8",
|
|
152
|
+
timeout: 3e3,
|
|
153
|
+
stdio: ["pipe", "pipe", "ignore"]
|
|
154
|
+
// 忽略 stderr
|
|
155
|
+
});
|
|
156
|
+
return result.trim();
|
|
157
|
+
} catch {
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
function showSimpleNotification(current, latest) {
|
|
162
|
+
const message = `${colors.yellow("\u{1F389} \u53D1\u73B0\u65B0\u7248\u672C")} ${colors.dim(
|
|
163
|
+
current
|
|
164
|
+
)} \u2192 ${colors.green(latest)} ${colors.dim("\u8FD0\u884C")} ${colors.cyan(
|
|
165
|
+
"gw update"
|
|
166
|
+
)} ${colors.dim("\u66F4\u65B0")}`;
|
|
167
|
+
console.log("");
|
|
168
|
+
console.log(
|
|
169
|
+
boxen(message, {
|
|
170
|
+
padding: { top: 0, bottom: 0, left: 2, right: 2 },
|
|
171
|
+
margin: { top: 0, bottom: 1, left: 0, right: 0 },
|
|
172
|
+
borderStyle: "round",
|
|
173
|
+
borderColor: "yellow",
|
|
174
|
+
align: "center"
|
|
175
|
+
})
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
async function showUpdateMessage(current, latest, packageName) {
|
|
179
|
+
const message = [
|
|
180
|
+
colors.yellow(colors.bold("\u{1F389} \u53D1\u73B0\u65B0\u7248\u672C\uFF01")),
|
|
181
|
+
"",
|
|
182
|
+
`${colors.dim(current)} \u2192 ${colors.green(colors.bold(latest))}`
|
|
183
|
+
].join("\n");
|
|
184
|
+
console.log("");
|
|
185
|
+
console.log(
|
|
186
|
+
boxen(message, {
|
|
187
|
+
padding: { top: 1, bottom: 1, left: 3, right: 3 },
|
|
188
|
+
margin: 1,
|
|
189
|
+
borderStyle: "round",
|
|
190
|
+
borderColor: "yellow",
|
|
191
|
+
align: "center",
|
|
192
|
+
width: 40
|
|
193
|
+
})
|
|
194
|
+
);
|
|
195
|
+
try {
|
|
196
|
+
const action = await select7({
|
|
197
|
+
message: "\u4F60\u60F3\u505A\u4EC0\u4E48\uFF1F",
|
|
198
|
+
choices: [
|
|
199
|
+
{
|
|
200
|
+
name: "\u{1F680} \u7ACB\u5373\u66F4\u65B0",
|
|
201
|
+
value: "update",
|
|
202
|
+
description: `\u8FD0\u884C npm install -g ${packageName}`
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
name: "\u23ED\uFE0F \u7A0D\u540E\u66F4\u65B0\uFF0C\u7EE7\u7EED\u4F7F\u7528",
|
|
206
|
+
value: "continue",
|
|
207
|
+
description: "\u4E0B\u6B21\u542F\u52A8\u65F6\u4F1A\u518D\u6B21\u63D0\u793A"
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
name: "\u{1F648} \u8DF3\u8FC7\u6B64\u7248\u672C (24h \u5185\u4E0D\u518D\u63D0\u793A)",
|
|
211
|
+
value: "dismiss",
|
|
212
|
+
description: "24 \u5C0F\u65F6\u5185\u4E0D\u4F1A\u518D\u63D0\u793A\u6B64\u7248\u672C"
|
|
213
|
+
}
|
|
214
|
+
]
|
|
215
|
+
});
|
|
216
|
+
return action;
|
|
217
|
+
} catch (error) {
|
|
218
|
+
console.log("");
|
|
219
|
+
throw error;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
async function performUpdate(packageName) {
|
|
223
|
+
console.log("");
|
|
224
|
+
const spinner = ora5({
|
|
225
|
+
text: "\u6B63\u5728\u66F4\u65B0...",
|
|
226
|
+
spinner: "dots"
|
|
227
|
+
}).start();
|
|
228
|
+
try {
|
|
229
|
+
execSync6(`npm install -g ${packageName}@latest`, {
|
|
230
|
+
encoding: "utf-8",
|
|
231
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
232
|
+
});
|
|
233
|
+
spinner.succeed(colors.green("\u66F4\u65B0\u6210\u529F\uFF01"));
|
|
234
|
+
clearUpdateCache();
|
|
235
|
+
console.log("");
|
|
236
|
+
console.log(
|
|
237
|
+
boxen(
|
|
238
|
+
[
|
|
239
|
+
colors.green(colors.bold("\u2728 \u66F4\u65B0\u5B8C\u6210\uFF01")),
|
|
240
|
+
"",
|
|
241
|
+
colors.dim("\u8BF7\u91CD\u65B0\u6253\u5F00\u7EC8\u7AEF\u4F7F\u7528\u65B0\u7248\u672C")
|
|
242
|
+
].join("\n"),
|
|
243
|
+
{
|
|
244
|
+
padding: { top: 1, bottom: 1, left: 3, right: 3 },
|
|
245
|
+
margin: { top: 0, bottom: 1, left: 2, right: 2 },
|
|
246
|
+
borderStyle: "round",
|
|
247
|
+
borderColor: "green",
|
|
248
|
+
align: "center",
|
|
249
|
+
width: 40
|
|
250
|
+
}
|
|
251
|
+
)
|
|
252
|
+
);
|
|
253
|
+
process.exit(0);
|
|
254
|
+
} catch (error) {
|
|
255
|
+
spinner.fail(colors.red("\u66F4\u65B0\u5931\u8D25"));
|
|
256
|
+
console.log("");
|
|
257
|
+
console.log(colors.dim(" \u4F60\u53EF\u4EE5\u624B\u52A8\u8FD0\u884C\u4EE5\u4E0B\u547D\u4EE4\u66F4\u65B0:"));
|
|
258
|
+
console.log(colors.cyan(` npm install -g ${packageName}@latest`));
|
|
259
|
+
console.log("");
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function clearUpdateCache() {
|
|
263
|
+
try {
|
|
264
|
+
const cacheFile = join3(homedir3(), CACHE_FILE);
|
|
265
|
+
if (existsSync3(cacheFile)) {
|
|
266
|
+
unlinkSync(cacheFile);
|
|
267
|
+
}
|
|
268
|
+
} catch {
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
function readCache() {
|
|
272
|
+
try {
|
|
273
|
+
const cacheFile = join3(homedir3(), CACHE_FILE);
|
|
274
|
+
if (!existsSync3(cacheFile)) {
|
|
275
|
+
return null;
|
|
276
|
+
}
|
|
277
|
+
const content = readFileSync3(cacheFile, "utf-8");
|
|
278
|
+
return JSON.parse(content);
|
|
279
|
+
} catch {
|
|
280
|
+
return null;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
function writeCache(cache) {
|
|
284
|
+
try {
|
|
285
|
+
const cacheFile = join3(homedir3(), CACHE_FILE);
|
|
286
|
+
writeFileSync3(cacheFile, JSON.stringify(cache), "utf-8");
|
|
287
|
+
} catch {
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
var CHECK_INTERVAL, DISMISS_INTERVAL, CACHE_FILE;
|
|
291
|
+
var init_update_notifier = __esm({
|
|
292
|
+
"src/update-notifier.ts"() {
|
|
293
|
+
"use strict";
|
|
294
|
+
init_utils();
|
|
295
|
+
CHECK_INTERVAL = 1e3 * 60 * 60 * 4;
|
|
296
|
+
DISMISS_INTERVAL = 1e3 * 60 * 60 * 24;
|
|
297
|
+
CACHE_FILE = ".gw-update-check";
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
// src/index.ts
|
|
302
|
+
init_utils();
|
|
303
|
+
import { cac } from "cac";
|
|
304
|
+
import { select as select8 } from "@inquirer/prompts";
|
|
305
|
+
import { ExitPromptError } from "@inquirer/core";
|
|
69
306
|
|
|
70
307
|
// src/commands/branch.ts
|
|
308
|
+
init_utils();
|
|
71
309
|
import { execSync as execSync2 } from "child_process";
|
|
72
310
|
import { select, input } from "@inquirer/prompts";
|
|
73
311
|
import ora from "ora";
|
|
74
312
|
|
|
75
313
|
// src/config.ts
|
|
314
|
+
init_utils();
|
|
76
315
|
import { existsSync, readFileSync } from "fs";
|
|
77
316
|
import { join } from "path";
|
|
78
317
|
import { homedir } from "os";
|
|
@@ -392,6 +631,7 @@ async function deleteBranch(branchArg) {
|
|
|
392
631
|
}
|
|
393
632
|
|
|
394
633
|
// src/commands/tag.ts
|
|
634
|
+
init_utils();
|
|
395
635
|
import { execSync as execSync3 } from "child_process";
|
|
396
636
|
import { select as select2, input as input2 } from "@inquirer/prompts";
|
|
397
637
|
import ora2 from "ora";
|
|
@@ -738,38 +978,55 @@ async function updateTag() {
|
|
|
738
978
|
divider();
|
|
739
979
|
const choices = tags.map((tag) => ({ name: tag, value: tag }));
|
|
740
980
|
choices.push({ name: "\u53D6\u6D88", value: "__cancel__" });
|
|
741
|
-
const
|
|
742
|
-
message: "\u9009\u62E9\u8981\
|
|
981
|
+
const oldTag = await select2({
|
|
982
|
+
message: "\u9009\u62E9\u8981\u91CD\u547D\u540D\u7684 tag:",
|
|
743
983
|
choices,
|
|
744
984
|
theme
|
|
745
985
|
});
|
|
746
|
-
if (
|
|
986
|
+
if (oldTag === "__cancel__") {
|
|
747
987
|
console.log(colors.yellow("\u5DF2\u53D6\u6D88"));
|
|
748
988
|
return;
|
|
749
989
|
}
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
990
|
+
console.log("");
|
|
991
|
+
console.log(colors.dim(`\u5F53\u524D tag: ${oldTag}`));
|
|
992
|
+
console.log("");
|
|
993
|
+
const newTag = await input2({
|
|
994
|
+
message: "\u8F93\u5165\u65B0\u7684 tag \u540D\u79F0:",
|
|
995
|
+
default: oldTag,
|
|
753
996
|
theme
|
|
754
997
|
});
|
|
755
|
-
if (!
|
|
998
|
+
if (!newTag || newTag === oldTag) {
|
|
756
999
|
console.log(colors.yellow("\u5DF2\u53D6\u6D88"));
|
|
757
1000
|
return;
|
|
758
1001
|
}
|
|
1002
|
+
const existingTags = execOutput("git tag -l").split("\n").filter(Boolean);
|
|
1003
|
+
if (existingTags.includes(newTag)) {
|
|
1004
|
+
console.log(colors.red(`Tag ${newTag} \u5DF2\u5B58\u5728\uFF0C\u65E0\u6CD5\u91CD\u547D\u540D`));
|
|
1005
|
+
return;
|
|
1006
|
+
}
|
|
759
1007
|
divider();
|
|
760
|
-
const spinner = ora2(`\u6B63\u5728\
|
|
1008
|
+
const spinner = ora2(`\u6B63\u5728\u91CD\u547D\u540D tag: ${oldTag} \u2192 ${newTag}`).start();
|
|
761
1009
|
try {
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
1010
|
+
const commit2 = execOutput(`git rev-list -n 1 "${oldTag}"`).trim();
|
|
1011
|
+
const message = execOutput(
|
|
1012
|
+
`git tag -l --format='%(contents)' "${oldTag}"`
|
|
1013
|
+
).trim();
|
|
1014
|
+
if (message) {
|
|
1015
|
+
execSync3(`git tag -a "${newTag}" "${commit2}" -m "${message}"`, {
|
|
1016
|
+
stdio: "pipe"
|
|
1017
|
+
});
|
|
1018
|
+
} else {
|
|
1019
|
+
execSync3(`git tag "${newTag}" "${commit2}"`, { stdio: "pipe" });
|
|
1020
|
+
}
|
|
1021
|
+
execSync3(`git tag -d "${oldTag}"`, { stdio: "pipe" });
|
|
1022
|
+
spinner.succeed(`Tag \u5DF2\u91CD\u547D\u540D: ${oldTag} \u2192 ${newTag}`);
|
|
1023
|
+
} catch (error) {
|
|
1024
|
+
spinner.fail("tag \u91CD\u547D\u540D\u5931\u8D25");
|
|
1025
|
+
console.log(colors.red(String(error)));
|
|
769
1026
|
return;
|
|
770
1027
|
}
|
|
771
1028
|
const pushRemote = await select2({
|
|
772
|
-
message: "\u662F\u5426\
|
|
1029
|
+
message: "\u662F\u5426\u540C\u6B65\u5230\u8FDC\u7A0B?",
|
|
773
1030
|
choices: [
|
|
774
1031
|
{ name: "\u662F", value: true },
|
|
775
1032
|
{ name: "\u5426", value: false }
|
|
@@ -777,19 +1034,23 @@ async function updateTag() {
|
|
|
777
1034
|
theme
|
|
778
1035
|
});
|
|
779
1036
|
if (pushRemote) {
|
|
780
|
-
const pushSpinner = ora2("\u6B63\u5728\
|
|
1037
|
+
const pushSpinner = ora2("\u6B63\u5728\u540C\u6B65\u5230\u8FDC\u7A0B...").start();
|
|
781
1038
|
try {
|
|
782
|
-
execSync3(`git push origin "${
|
|
783
|
-
|
|
1039
|
+
execSync3(`git push origin "${newTag}"`, { stdio: "pipe" });
|
|
1040
|
+
execSync3(`git push origin --delete "${oldTag}"`, { stdio: "pipe" });
|
|
1041
|
+
pushSpinner.succeed(`\u8FDC\u7A0B tag \u5DF2\u540C\u6B65: ${oldTag} \u2192 ${newTag}`);
|
|
784
1042
|
} catch {
|
|
785
1043
|
pushSpinner.warn(
|
|
786
|
-
`\u8FDC\u7A0B\
|
|
1044
|
+
`\u8FDC\u7A0B\u540C\u6B65\u5931\u8D25\uFF0C\u53EF\u7A0D\u540E\u624B\u52A8\u6267\u884C:
|
|
1045
|
+
git push origin ${newTag}
|
|
1046
|
+
git push origin --delete ${oldTag}`
|
|
787
1047
|
);
|
|
788
1048
|
}
|
|
789
1049
|
}
|
|
790
1050
|
}
|
|
791
1051
|
|
|
792
1052
|
// src/commands/release.ts
|
|
1053
|
+
init_utils();
|
|
793
1054
|
import { readFileSync as readFileSync2, writeFileSync } from "fs";
|
|
794
1055
|
import { select as select3 } from "@inquirer/prompts";
|
|
795
1056
|
function getPackageVersion() {
|
|
@@ -888,6 +1149,7 @@ async function release() {
|
|
|
888
1149
|
}
|
|
889
1150
|
|
|
890
1151
|
// src/commands/init.ts
|
|
1152
|
+
init_utils();
|
|
891
1153
|
import { existsSync as existsSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
892
1154
|
import { join as join2 } from "path";
|
|
893
1155
|
import { homedir as homedir2 } from "os";
|
|
@@ -1172,6 +1434,7 @@ async function init() {
|
|
|
1172
1434
|
}
|
|
1173
1435
|
|
|
1174
1436
|
// src/commands/stash.ts
|
|
1437
|
+
init_utils();
|
|
1175
1438
|
import { execSync as execSync4 } from "child_process";
|
|
1176
1439
|
import { select as select5, input as input4 } from "@inquirer/prompts";
|
|
1177
1440
|
import ora3 from "ora";
|
|
@@ -1406,11 +1669,13 @@ async function dropStash(index) {
|
|
|
1406
1669
|
}
|
|
1407
1670
|
|
|
1408
1671
|
// src/commands/commit.ts
|
|
1672
|
+
init_utils();
|
|
1409
1673
|
import { execSync as execSync5 } from "child_process";
|
|
1410
1674
|
import { select as select6, input as input5, checkbox } from "@inquirer/prompts";
|
|
1411
1675
|
import ora4 from "ora";
|
|
1412
1676
|
|
|
1413
1677
|
// src/ai-service.ts
|
|
1678
|
+
init_utils();
|
|
1414
1679
|
var AI_PROVIDERS = {
|
|
1415
1680
|
github: {
|
|
1416
1681
|
name: "GitHub Models",
|
|
@@ -1637,8 +1902,7 @@ var DEFAULT_COMMIT_TYPES = [
|
|
|
1637
1902
|
{ type: "test", emoji: "\u2705", description: "\u6D4B\u8BD5\u76F8\u5173" },
|
|
1638
1903
|
{ type: "build", emoji: "\u{1F4E6}", description: "\u6784\u5EFA/\u4F9D\u8D56\u76F8\u5173" },
|
|
1639
1904
|
{ type: "ci", emoji: "\u{1F477}", description: "CI/CD \u76F8\u5173" },
|
|
1640
|
-
{ type: "chore", emoji: "\u{1F527}", description: "\u5176\u4ED6\u6742\u9879" }
|
|
1641
|
-
{ type: "revert", emoji: "\u23EA", description: "\u56DE\u9000\u63D0\u4EA4" }
|
|
1905
|
+
{ type: "chore", emoji: "\u{1F527}", description: "\u5176\u4ED6\u6742\u9879" }
|
|
1642
1906
|
];
|
|
1643
1907
|
function getCommitTypes(config2) {
|
|
1644
1908
|
const customEmojis = config2.commitEmojis || {};
|
|
@@ -1670,11 +1934,17 @@ function parseGitStatus() {
|
|
|
1670
1934
|
function formatFileStatus(status) {
|
|
1671
1935
|
const statusMap = {
|
|
1672
1936
|
M: colors.yellow("M"),
|
|
1937
|
+
// 修改
|
|
1673
1938
|
A: colors.green("A"),
|
|
1939
|
+
// 新增
|
|
1674
1940
|
D: colors.red("D"),
|
|
1941
|
+
// 删除
|
|
1675
1942
|
R: colors.yellow("R"),
|
|
1943
|
+
// 重命名
|
|
1676
1944
|
C: colors.yellow("C"),
|
|
1945
|
+
// 复制
|
|
1677
1946
|
"?": colors.green("?")
|
|
1947
|
+
// 未跟踪
|
|
1678
1948
|
};
|
|
1679
1949
|
return statusMap[status] || status;
|
|
1680
1950
|
}
|
|
@@ -1749,7 +2019,7 @@ async function commit() {
|
|
|
1749
2019
|
theme
|
|
1750
2020
|
});
|
|
1751
2021
|
}
|
|
1752
|
-
let message;
|
|
2022
|
+
let message = "";
|
|
1753
2023
|
if (commitMode === "ai") {
|
|
1754
2024
|
const spinner2 = ora4("AI \u6B63\u5728\u5206\u6790\u4EE3\u7801\u53D8\u66F4...").start();
|
|
1755
2025
|
try {
|
|
@@ -1804,6 +2074,17 @@ async function commit() {
|
|
|
1804
2074
|
}
|
|
1805
2075
|
const spinner = ora4("\u6B63\u5728\u63D0\u4EA4...").start();
|
|
1806
2076
|
try {
|
|
2077
|
+
const finalStatus = parseGitStatus();
|
|
2078
|
+
if (finalStatus.staged.length === 0) {
|
|
2079
|
+
spinner.fail("\u6CA1\u6709\u6682\u5B58\u7684\u6587\u4EF6\u53EF\u4EE5\u63D0\u4EA4");
|
|
2080
|
+
console.log("");
|
|
2081
|
+
console.log(colors.yellow("\u8BF7\u5148\u6682\u5B58\u6587\u4EF6:"));
|
|
2082
|
+
console.log(colors.cyan(" git add <file>"));
|
|
2083
|
+
console.log(colors.dim(" \u6216"));
|
|
2084
|
+
console.log(colors.cyan(" git add -A"));
|
|
2085
|
+
console.log("");
|
|
2086
|
+
return;
|
|
2087
|
+
}
|
|
1807
2088
|
const escapedMessage = message.replace(/"/g, '\\"');
|
|
1808
2089
|
execSync5(`git commit -m "${escapedMessage}"`, { stdio: "pipe" });
|
|
1809
2090
|
spinner.succeed("\u63D0\u4EA4\u6210\u529F");
|
|
@@ -1811,19 +2092,31 @@ async function commit() {
|
|
|
1811
2092
|
console.log(colors.dim(`commit: ${commitHash}`));
|
|
1812
2093
|
} catch (error) {
|
|
1813
2094
|
spinner.fail("\u63D0\u4EA4\u5931\u8D25");
|
|
2095
|
+
console.log("");
|
|
1814
2096
|
if (error instanceof Error) {
|
|
1815
|
-
console.log(colors.red(
|
|
2097
|
+
console.log(colors.red("\u9519\u8BEF\u4FE1\u606F:"));
|
|
2098
|
+
console.log(colors.dim(` ${error.message}`));
|
|
1816
2099
|
}
|
|
2100
|
+
console.log("");
|
|
2101
|
+
console.log(colors.yellow("\u4F60\u53EF\u4EE5\u624B\u52A8\u6267\u884C\u4EE5\u4E0B\u547D\u4EE4:"));
|
|
2102
|
+
console.log(colors.cyan(` git commit -m "${message}"`));
|
|
2103
|
+
console.log("");
|
|
1817
2104
|
}
|
|
1818
2105
|
}
|
|
1819
2106
|
async function buildManualCommitMessage(config2) {
|
|
1820
2107
|
const commitTypes = getCommitTypes(config2);
|
|
1821
2108
|
const typeChoice = await select6({
|
|
1822
2109
|
message: "\u9009\u62E9\u63D0\u4EA4\u7C7B\u578B:",
|
|
1823
|
-
choices: commitTypes.map((t) =>
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
2110
|
+
choices: commitTypes.map((t) => {
|
|
2111
|
+
const typeText = t.type.padEnd(10);
|
|
2112
|
+
const spacing = t.type === "refactor" ? " " : " ";
|
|
2113
|
+
return {
|
|
2114
|
+
name: `${t.emoji}${spacing}${typeText} ${colors.dim(t.description)}`,
|
|
2115
|
+
value: t
|
|
2116
|
+
};
|
|
2117
|
+
}),
|
|
2118
|
+
pageSize: commitTypes.length,
|
|
2119
|
+
// 显示所有选项,不滚动
|
|
1827
2120
|
theme
|
|
1828
2121
|
});
|
|
1829
2122
|
const scope = await input5({
|
|
@@ -1890,6 +2183,7 @@ ${issues}`;
|
|
|
1890
2183
|
}
|
|
1891
2184
|
|
|
1892
2185
|
// src/commands/help.ts
|
|
2186
|
+
init_utils();
|
|
1893
2187
|
function showHelp() {
|
|
1894
2188
|
return `
|
|
1895
2189
|
\u5206\u652F\u547D\u4EE4:
|
|
@@ -1915,7 +2209,7 @@ Tag \u547D\u4EE4:
|
|
|
1915
2209
|
gw tag:delete \u5220\u9664 tag
|
|
1916
2210
|
gw td \u540C\u4E0A (\u522B\u540D)
|
|
1917
2211
|
|
|
1918
|
-
gw tag:update \
|
|
2212
|
+
gw tag:update \u91CD\u547D\u540D tag
|
|
1919
2213
|
gw tu \u540C\u4E0A (\u522B\u540D)
|
|
1920
2214
|
|
|
1921
2215
|
\u53D1\u5E03\u547D\u4EE4:
|
|
@@ -1932,6 +2226,9 @@ Tag \u547D\u4EE4:
|
|
|
1932
2226
|
gw update \u68C0\u67E5\u5E76\u66F4\u65B0\u5230\u6700\u65B0\u7248\u672C
|
|
1933
2227
|
gw upt \u540C\u4E0A (\u522B\u540D)
|
|
1934
2228
|
|
|
2229
|
+
\u6E05\u7406\u547D\u4EE4:
|
|
2230
|
+
gw clean \u6E05\u7406\u7F13\u5B58\u6587\u4EF6
|
|
2231
|
+
|
|
1935
2232
|
Stash \u547D\u4EE4:
|
|
1936
2233
|
gw stash \u4EA4\u4E92\u5F0F\u7BA1\u7406 stash
|
|
1937
2234
|
gw s \u540C\u4E0A (\u522B\u540D)
|
|
@@ -1962,160 +2259,28 @@ Commit \u547D\u4EE4:
|
|
|
1962
2259
|
`;
|
|
1963
2260
|
}
|
|
1964
2261
|
|
|
1965
|
-
// src/
|
|
1966
|
-
|
|
1967
|
-
import { readFileSync as readFileSync3, writeFileSync as writeFileSync3, existsSync as existsSync3 } from "fs";
|
|
1968
|
-
import { homedir as homedir3 } from "os";
|
|
1969
|
-
import { join as join3 } from "path";
|
|
1970
|
-
import boxen from "boxen";
|
|
1971
|
-
import { select as select7 } from "@inquirer/prompts";
|
|
1972
|
-
import ora5 from "ora";
|
|
1973
|
-
var DISMISS_INTERVAL = 1e3 * 60 * 60 * 24;
|
|
1974
|
-
var CACHE_FILE = ".gw-update-check";
|
|
1975
|
-
async function checkForUpdates(currentVersion, packageName = "@zjex/git-workflow") {
|
|
1976
|
-
try {
|
|
1977
|
-
const cache = readCache();
|
|
1978
|
-
const now = Date.now();
|
|
1979
|
-
if (cache?.lastDismiss && now - cache.lastDismiss < DISMISS_INTERVAL) {
|
|
1980
|
-
return;
|
|
1981
|
-
}
|
|
1982
|
-
const latestVersion = await getLatestVersion(packageName);
|
|
1983
|
-
if (latestVersion && latestVersion !== currentVersion) {
|
|
1984
|
-
const action = await showUpdateMessage(
|
|
1985
|
-
currentVersion,
|
|
1986
|
-
latestVersion,
|
|
1987
|
-
packageName
|
|
1988
|
-
);
|
|
1989
|
-
if (action === "update") {
|
|
1990
|
-
await performUpdate(packageName);
|
|
1991
|
-
} else if (action === "dismiss") {
|
|
1992
|
-
writeCache({ lastDismiss: now, latestVersion });
|
|
1993
|
-
}
|
|
1994
|
-
}
|
|
1995
|
-
} catch (error) {
|
|
1996
|
-
if (error?.constructor?.name === "ExitPromptError") {
|
|
1997
|
-
throw error;
|
|
1998
|
-
}
|
|
1999
|
-
}
|
|
2000
|
-
}
|
|
2001
|
-
async function getLatestVersion(packageName) {
|
|
2002
|
-
try {
|
|
2003
|
-
const result = execSync6(`npm view ${packageName} version`, {
|
|
2004
|
-
encoding: "utf-8",
|
|
2005
|
-
timeout: 3e3,
|
|
2006
|
-
stdio: ["pipe", "pipe", "ignore"]
|
|
2007
|
-
// 忽略 stderr
|
|
2008
|
-
});
|
|
2009
|
-
return result.trim();
|
|
2010
|
-
} catch {
|
|
2011
|
-
return null;
|
|
2012
|
-
}
|
|
2013
|
-
}
|
|
2014
|
-
async function showUpdateMessage(current, latest, packageName) {
|
|
2015
|
-
const message = [
|
|
2016
|
-
colors.bold("\uFFFD \u53D1\u73B0\u65B0\u7248\u65B0\u672C\u53EF\u7528\uFF01"),
|
|
2017
|
-
"",
|
|
2018
|
-
`${colors.dim(current)} \u2192 ${colors.green(colors.bold(latest))}`
|
|
2019
|
-
].join("\n");
|
|
2020
|
-
console.log("");
|
|
2021
|
-
console.log(
|
|
2022
|
-
boxen(message, {
|
|
2023
|
-
padding: 1,
|
|
2024
|
-
margin: 1,
|
|
2025
|
-
borderStyle: "round",
|
|
2026
|
-
borderColor: "yellow",
|
|
2027
|
-
align: "left"
|
|
2028
|
-
})
|
|
2029
|
-
);
|
|
2030
|
-
try {
|
|
2031
|
-
const action = await select7({
|
|
2032
|
-
message: "\u4F60\u60F3\u505A\u4EC0\u4E48\uFF1F",
|
|
2033
|
-
choices: [
|
|
2034
|
-
{
|
|
2035
|
-
name: "\u{1F680} \u7ACB\u5373\u66F4\u65B0",
|
|
2036
|
-
value: "update",
|
|
2037
|
-
description: `\u8FD0\u884C npm install -g ${packageName}`
|
|
2038
|
-
},
|
|
2039
|
-
{
|
|
2040
|
-
name: "\u23ED\uFE0F \u7A0D\u540E\u66F4\u65B0\uFF0C\u7EE7\u7EED\u4F7F\u7528",
|
|
2041
|
-
value: "continue",
|
|
2042
|
-
description: "\u4E0B\u6B21\u542F\u52A8\u65F6\u4F1A\u518D\u6B21\u63D0\u793A"
|
|
2043
|
-
},
|
|
2044
|
-
{
|
|
2045
|
-
name: "\u{1F648} \u8DF3\u8FC7\u6B64\u7248\u672C (24h \u5185\u4E0D\u518D\u63D0\u793A)",
|
|
2046
|
-
value: "dismiss",
|
|
2047
|
-
description: "24 \u5C0F\u65F6\u5185\u4E0D\u4F1A\u518D\u63D0\u793A\u6B64\u7248\u672C"
|
|
2048
|
-
}
|
|
2049
|
-
]
|
|
2050
|
-
});
|
|
2051
|
-
return action;
|
|
2052
|
-
} catch (error) {
|
|
2053
|
-
console.log("");
|
|
2054
|
-
throw error;
|
|
2055
|
-
}
|
|
2056
|
-
}
|
|
2057
|
-
async function performUpdate(packageName) {
|
|
2058
|
-
console.log("");
|
|
2059
|
-
const spinner = ora5({
|
|
2060
|
-
text: "\u6B63\u5728\u66F4\u65B0...",
|
|
2061
|
-
spinner: "dots"
|
|
2062
|
-
}).start();
|
|
2063
|
-
try {
|
|
2064
|
-
execSync6(`npm install -g ${packageName}@latest`, {
|
|
2065
|
-
encoding: "utf-8",
|
|
2066
|
-
stdio: ["pipe", "pipe", "pipe"]
|
|
2067
|
-
});
|
|
2068
|
-
spinner.succeed(colors.green("\u66F4\u65B0\u6210\u529F\uFF01"));
|
|
2069
|
-
console.log("");
|
|
2070
|
-
console.log(
|
|
2071
|
-
boxen(
|
|
2072
|
-
[
|
|
2073
|
-
colors.bold("\u2728 \u66F4\u65B0\u5B8C\u6210\uFF01"),
|
|
2074
|
-
"",
|
|
2075
|
-
colors.dim("\u8BF7\u91CD\u65B0\u6253\u5F00\u7EC8\u7AEF\u4F7F\u7528\u65B0\u7248\u672C")
|
|
2076
|
-
].join("\n"),
|
|
2077
|
-
{
|
|
2078
|
-
padding: 1,
|
|
2079
|
-
margin: { top: 0, bottom: 1, left: 2, right: 2 },
|
|
2080
|
-
borderStyle: "round",
|
|
2081
|
-
borderColor: "green",
|
|
2082
|
-
align: "left"
|
|
2083
|
-
}
|
|
2084
|
-
)
|
|
2085
|
-
);
|
|
2086
|
-
process.exit(0);
|
|
2087
|
-
} catch (error) {
|
|
2088
|
-
spinner.fail(colors.red("\u66F4\u65B0\u5931\u8D25"));
|
|
2089
|
-
console.log("");
|
|
2090
|
-
console.log(colors.dim(" \u4F60\u53EF\u4EE5\u624B\u52A8\u8FD0\u884C\u4EE5\u4E0B\u547D\u4EE4\u66F4\u65B0:"));
|
|
2091
|
-
console.log(colors.cyan(` npm install -g ${packageName}@latest`));
|
|
2092
|
-
console.log("");
|
|
2093
|
-
}
|
|
2094
|
-
}
|
|
2095
|
-
function readCache() {
|
|
2096
|
-
try {
|
|
2097
|
-
const cacheFile = join3(homedir3(), CACHE_FILE);
|
|
2098
|
-
if (!existsSync3(cacheFile)) {
|
|
2099
|
-
return null;
|
|
2100
|
-
}
|
|
2101
|
-
const content = readFileSync3(cacheFile, "utf-8");
|
|
2102
|
-
return JSON.parse(content);
|
|
2103
|
-
} catch {
|
|
2104
|
-
return null;
|
|
2105
|
-
}
|
|
2106
|
-
}
|
|
2107
|
-
function writeCache(cache) {
|
|
2108
|
-
try {
|
|
2109
|
-
const cacheFile = join3(homedir3(), CACHE_FILE);
|
|
2110
|
-
writeFileSync3(cacheFile, JSON.stringify(cache), "utf-8");
|
|
2111
|
-
} catch {
|
|
2112
|
-
}
|
|
2113
|
-
}
|
|
2262
|
+
// src/index.ts
|
|
2263
|
+
init_update_notifier();
|
|
2114
2264
|
|
|
2115
2265
|
// src/commands/update.ts
|
|
2266
|
+
init_utils();
|
|
2116
2267
|
import { execSync as execSync7 } from "child_process";
|
|
2117
2268
|
import ora6 from "ora";
|
|
2118
2269
|
import boxen2 from "boxen";
|
|
2270
|
+
import semver2 from "semver";
|
|
2271
|
+
import { existsSync as existsSync4, unlinkSync as unlinkSync2 } from "fs";
|
|
2272
|
+
import { homedir as homedir4 } from "os";
|
|
2273
|
+
import { join as join4 } from "path";
|
|
2274
|
+
var CACHE_FILE2 = ".gw-update-check";
|
|
2275
|
+
function clearUpdateCache2() {
|
|
2276
|
+
try {
|
|
2277
|
+
const cacheFile = join4(homedir4(), CACHE_FILE2);
|
|
2278
|
+
if (existsSync4(cacheFile)) {
|
|
2279
|
+
unlinkSync2(cacheFile);
|
|
2280
|
+
}
|
|
2281
|
+
} catch {
|
|
2282
|
+
}
|
|
2283
|
+
}
|
|
2119
2284
|
async function getLatestVersion2(packageName) {
|
|
2120
2285
|
try {
|
|
2121
2286
|
const result = execSync7(`npm view ${packageName} version`, {
|
|
@@ -2142,11 +2307,11 @@ async function update(currentVersion) {
|
|
|
2142
2307
|
return;
|
|
2143
2308
|
}
|
|
2144
2309
|
spinner.stop();
|
|
2145
|
-
if (latestVersion
|
|
2310
|
+
if (semver2.gte(currentVersion, latestVersion)) {
|
|
2146
2311
|
console.log(
|
|
2147
2312
|
boxen2(
|
|
2148
2313
|
[
|
|
2149
|
-
colors.bold("\u2705 \u5DF2\u662F\u6700\u65B0\u7248\u672C"),
|
|
2314
|
+
colors.green(colors.bold("\u2705 \u5DF2\u662F\u6700\u65B0\u7248\u672C")),
|
|
2150
2315
|
"",
|
|
2151
2316
|
`\u5F53\u524D\u7248\u672C: ${colors.green(currentVersion)}`
|
|
2152
2317
|
].join("\n"),
|
|
@@ -2161,21 +2326,29 @@ async function update(currentVersion) {
|
|
|
2161
2326
|
);
|
|
2162
2327
|
return;
|
|
2163
2328
|
}
|
|
2329
|
+
const versionText = `${currentVersion} \u2192 ${latestVersion}`;
|
|
2330
|
+
const maxWidth = Math.max(
|
|
2331
|
+
"\u{1F389} \u53D1\u73B0\u65B0\u7248\u672C\uFF01".length,
|
|
2332
|
+
versionText.length,
|
|
2333
|
+
"\u2728 \u66F4\u65B0\u5B8C\u6210\uFF01".length,
|
|
2334
|
+
"\u8BF7\u91CD\u65B0\u6253\u5F00\u7EC8\u7AEF\u4F7F\u7528\u65B0\u7248\u672C".length
|
|
2335
|
+
);
|
|
2164
2336
|
console.log(
|
|
2165
2337
|
boxen2(
|
|
2166
2338
|
[
|
|
2167
|
-
colors.bold("\u{1F389} \u53D1\u73B0\u65B0\u7248\u672C\uFF01"),
|
|
2339
|
+
colors.yellow(colors.bold("\u{1F389} \u53D1\u73B0\u65B0\u7248\u672C\uFF01")),
|
|
2168
2340
|
"",
|
|
2169
2341
|
`${colors.dim(currentVersion)} \u2192 ${colors.green(
|
|
2170
2342
|
colors.bold(latestVersion)
|
|
2171
2343
|
)}`
|
|
2172
2344
|
].join("\n"),
|
|
2173
2345
|
{
|
|
2174
|
-
padding: 1,
|
|
2346
|
+
padding: { top: 1, bottom: 1, left: 3, right: 3 },
|
|
2175
2347
|
margin: { top: 0, bottom: 1, left: 2, right: 2 },
|
|
2176
2348
|
borderStyle: "round",
|
|
2177
2349
|
borderColor: "yellow",
|
|
2178
|
-
align: "
|
|
2350
|
+
align: "center",
|
|
2351
|
+
width: 40
|
|
2179
2352
|
}
|
|
2180
2353
|
)
|
|
2181
2354
|
);
|
|
@@ -2185,20 +2358,22 @@ async function update(currentVersion) {
|
|
|
2185
2358
|
stdio: ["pipe", "pipe", "pipe"]
|
|
2186
2359
|
});
|
|
2187
2360
|
updateSpinner.succeed(colors.green("\u66F4\u65B0\u6210\u529F\uFF01"));
|
|
2361
|
+
clearUpdateCache2();
|
|
2188
2362
|
console.log("");
|
|
2189
2363
|
console.log(
|
|
2190
2364
|
boxen2(
|
|
2191
2365
|
[
|
|
2192
|
-
colors.bold("\u2728 \u66F4\u65B0\u5B8C\u6210\uFF01"),
|
|
2366
|
+
colors.green(colors.bold("\u2728 \u66F4\u65B0\u5B8C\u6210\uFF01")),
|
|
2193
2367
|
"",
|
|
2194
2368
|
colors.dim("\u8BF7\u91CD\u65B0\u6253\u5F00\u7EC8\u7AEF\u4F7F\u7528\u65B0\u7248\u672C")
|
|
2195
2369
|
].join("\n"),
|
|
2196
2370
|
{
|
|
2197
|
-
padding: 1,
|
|
2371
|
+
padding: { top: 1, bottom: 1, left: 3, right: 3 },
|
|
2198
2372
|
margin: { top: 0, bottom: 1, left: 2, right: 2 },
|
|
2199
2373
|
borderStyle: "round",
|
|
2200
2374
|
borderColor: "green",
|
|
2201
|
-
align: "
|
|
2375
|
+
align: "center",
|
|
2376
|
+
width: 40
|
|
2202
2377
|
}
|
|
2203
2378
|
)
|
|
2204
2379
|
);
|
|
@@ -2238,7 +2413,7 @@ process.on("SIGTERM", () => {
|
|
|
2238
2413
|
console.log("");
|
|
2239
2414
|
process.exit(0);
|
|
2240
2415
|
});
|
|
2241
|
-
var version = true ? "0.2.
|
|
2416
|
+
var version = true ? "0.2.21" : "0.0.0-dev";
|
|
2242
2417
|
async function mainMenu() {
|
|
2243
2418
|
console.log(
|
|
2244
2419
|
colors.green(`
|
|
@@ -2280,7 +2455,7 @@ async function mainMenu() {
|
|
|
2280
2455
|
value: "tag-delete"
|
|
2281
2456
|
},
|
|
2282
2457
|
{
|
|
2283
|
-
name: `[7] \u270F\uFE0F \
|
|
2458
|
+
name: `[7] \u270F\uFE0F \u91CD\u547D\u540D tag ${colors.dim("gw tu")}`,
|
|
2284
2459
|
value: "tag-update"
|
|
2285
2460
|
},
|
|
2286
2461
|
{
|
|
@@ -2357,7 +2532,7 @@ async function mainMenu() {
|
|
|
2357
2532
|
}
|
|
2358
2533
|
var cli = cac("gw");
|
|
2359
2534
|
cli.command("", "\u663E\u793A\u4EA4\u4E92\u5F0F\u83DC\u5355").action(async () => {
|
|
2360
|
-
await checkForUpdates(version, "@zjex/git-workflow");
|
|
2535
|
+
await checkForUpdates(version, "@zjex/git-workflow", true);
|
|
2361
2536
|
return mainMenu();
|
|
2362
2537
|
});
|
|
2363
2538
|
cli.command("feature", "\u521B\u5EFA feature \u5206\u652F").alias("feat").alias("f").option("--base <branch>", "\u6307\u5B9A\u57FA\u7840\u5206\u652F").action(async (options) => {
|
|
@@ -2390,7 +2565,7 @@ cli.command("tag:delete", "\u5220\u9664 tag").alias("td").action(async () => {
|
|
|
2390
2565
|
checkGitRepo();
|
|
2391
2566
|
return deleteTag();
|
|
2392
2567
|
});
|
|
2393
|
-
cli.command("tag:update", "\
|
|
2568
|
+
cli.command("tag:update", "\u91CD\u547D\u540D tag").alias("tu").action(async () => {
|
|
2394
2569
|
await checkForUpdates(version, "@zjex/git-workflow");
|
|
2395
2570
|
checkGitRepo();
|
|
2396
2571
|
return updateTag();
|
|
@@ -2416,6 +2591,13 @@ cli.command("commit", "\u4EA4\u4E92\u5F0F\u63D0\u4EA4 (Conventional Commits + Gi
|
|
|
2416
2591
|
cli.command("update", "\u68C0\u67E5\u5E76\u66F4\u65B0\u5230\u6700\u65B0\u7248\u672C").alias("upt").action(async () => {
|
|
2417
2592
|
return update(version);
|
|
2418
2593
|
});
|
|
2594
|
+
cli.command("clean", "\u6E05\u7406\u7F13\u5B58\u6587\u4EF6").action(async () => {
|
|
2595
|
+
const { clearUpdateCache: clearUpdateCache3 } = await Promise.resolve().then(() => (init_update_notifier(), update_notifier_exports));
|
|
2596
|
+
clearUpdateCache3();
|
|
2597
|
+
console.log("");
|
|
2598
|
+
console.log(colors.green("\u2714 \u7F13\u5B58\u5DF2\u6E05\u7406"));
|
|
2599
|
+
console.log("");
|
|
2600
|
+
});
|
|
2419
2601
|
cli.help((sections) => {
|
|
2420
2602
|
sections.push({
|
|
2421
2603
|
body: showHelp()
|