@zjex/git-workflow 0.2.21 → 0.2.22
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/dist/index.js +45 -20
- package/package.json +1 -1
- package/src/commands/update.ts +32 -12
- package/src/update-notifier.ts +33 -8
package/dist/index.js
CHANGED
|
@@ -145,6 +145,14 @@ function backgroundCheck(currentVersion, packageName) {
|
|
|
145
145
|
}
|
|
146
146
|
});
|
|
147
147
|
}
|
|
148
|
+
function isUsingVolta() {
|
|
149
|
+
try {
|
|
150
|
+
const whichGw = execSync6("which gw", { encoding: "utf-8" }).trim();
|
|
151
|
+
return whichGw.includes(".volta");
|
|
152
|
+
} catch {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
148
156
|
async function getLatestVersion(packageName) {
|
|
149
157
|
try {
|
|
150
158
|
const result = execSync6(`npm view ${packageName} version`, {
|
|
@@ -192,6 +200,8 @@ async function showUpdateMessage(current, latest, packageName) {
|
|
|
192
200
|
width: 40
|
|
193
201
|
})
|
|
194
202
|
);
|
|
203
|
+
const usingVolta = isUsingVolta();
|
|
204
|
+
const updateCommand = usingVolta ? `volta install ${packageName}@latest` : `npm install -g ${packageName}@latest`;
|
|
195
205
|
try {
|
|
196
206
|
const action = await select7({
|
|
197
207
|
message: "\u4F60\u60F3\u505A\u4EC0\u4E48\uFF1F",
|
|
@@ -199,7 +209,7 @@ async function showUpdateMessage(current, latest, packageName) {
|
|
|
199
209
|
{
|
|
200
210
|
name: "\u{1F680} \u7ACB\u5373\u66F4\u65B0",
|
|
201
211
|
value: "update",
|
|
202
|
-
description: `\u8FD0\u884C
|
|
212
|
+
description: `\u8FD0\u884C ${updateCommand}`
|
|
203
213
|
},
|
|
204
214
|
{
|
|
205
215
|
name: "\u23ED\uFE0F \u7A0D\u540E\u66F4\u65B0\uFF0C\u7EE7\u7EED\u4F7F\u7528",
|
|
@@ -221,12 +231,14 @@ async function showUpdateMessage(current, latest, packageName) {
|
|
|
221
231
|
}
|
|
222
232
|
async function performUpdate(packageName) {
|
|
223
233
|
console.log("");
|
|
234
|
+
const usingVolta = isUsingVolta();
|
|
235
|
+
const updateCommand = usingVolta ? `volta install ${packageName}@latest` : `npm install -g ${packageName}@latest`;
|
|
224
236
|
const spinner = ora5({
|
|
225
237
|
text: "\u6B63\u5728\u66F4\u65B0...",
|
|
226
238
|
spinner: "dots"
|
|
227
239
|
}).start();
|
|
228
240
|
try {
|
|
229
|
-
execSync6(
|
|
241
|
+
execSync6(updateCommand, {
|
|
230
242
|
encoding: "utf-8",
|
|
231
243
|
stdio: ["pipe", "pipe", "pipe"]
|
|
232
244
|
});
|
|
@@ -238,15 +250,18 @@ async function performUpdate(packageName) {
|
|
|
238
250
|
[
|
|
239
251
|
colors.green(colors.bold("\u2728 \u66F4\u65B0\u5B8C\u6210\uFF01")),
|
|
240
252
|
"",
|
|
241
|
-
colors.dim("\u8BF7\
|
|
253
|
+
colors.dim("\u8BF7\u6267\u884C\u4EE5\u4E0B\u547D\u4EE4\u9A8C\u8BC1:"),
|
|
254
|
+
colors.cyan(" hash -r && gw --version"),
|
|
255
|
+
"",
|
|
256
|
+
colors.dim("\u6216\u91CD\u65B0\u6253\u5F00\u7EC8\u7AEF")
|
|
242
257
|
].join("\n"),
|
|
243
258
|
{
|
|
244
|
-
padding: { top: 1, bottom: 1, left:
|
|
259
|
+
padding: { top: 1, bottom: 1, left: 2, right: 2 },
|
|
245
260
|
margin: { top: 0, bottom: 1, left: 2, right: 2 },
|
|
246
261
|
borderStyle: "round",
|
|
247
262
|
borderColor: "green",
|
|
248
|
-
align: "
|
|
249
|
-
width:
|
|
263
|
+
align: "left",
|
|
264
|
+
width: 50
|
|
250
265
|
}
|
|
251
266
|
)
|
|
252
267
|
);
|
|
@@ -255,7 +270,7 @@ async function performUpdate(packageName) {
|
|
|
255
270
|
spinner.fail(colors.red("\u66F4\u65B0\u5931\u8D25"));
|
|
256
271
|
console.log("");
|
|
257
272
|
console.log(colors.dim(" \u4F60\u53EF\u4EE5\u624B\u52A8\u8FD0\u884C\u4EE5\u4E0B\u547D\u4EE4\u66F4\u65B0:"));
|
|
258
|
-
console.log(colors.cyan(`
|
|
273
|
+
console.log(colors.cyan(` ${updateCommand}`));
|
|
259
274
|
console.log("");
|
|
260
275
|
}
|
|
261
276
|
}
|
|
@@ -2293,8 +2308,17 @@ async function getLatestVersion2(packageName) {
|
|
|
2293
2308
|
return null;
|
|
2294
2309
|
}
|
|
2295
2310
|
}
|
|
2311
|
+
function isUsingVolta2() {
|
|
2312
|
+
try {
|
|
2313
|
+
const whichGw = execSync7("which gw", { encoding: "utf-8" }).trim();
|
|
2314
|
+
return whichGw.includes(".volta");
|
|
2315
|
+
} catch {
|
|
2316
|
+
return false;
|
|
2317
|
+
}
|
|
2318
|
+
}
|
|
2296
2319
|
async function update(currentVersion) {
|
|
2297
2320
|
const packageName = "@zjex/git-workflow";
|
|
2321
|
+
const usingVolta = isUsingVolta2();
|
|
2298
2322
|
console.log("");
|
|
2299
2323
|
console.log(colors.bold("\u{1F50D} \u68C0\u67E5\u66F4\u65B0..."));
|
|
2300
2324
|
console.log("");
|
|
@@ -2327,12 +2351,6 @@ async function update(currentVersion) {
|
|
|
2327
2351
|
return;
|
|
2328
2352
|
}
|
|
2329
2353
|
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
|
-
);
|
|
2336
2354
|
console.log(
|
|
2337
2355
|
boxen2(
|
|
2338
2356
|
[
|
|
@@ -2353,7 +2371,8 @@ async function update(currentVersion) {
|
|
|
2353
2371
|
)
|
|
2354
2372
|
);
|
|
2355
2373
|
const updateSpinner = ora6("\u6B63\u5728\u66F4\u65B0...").start();
|
|
2356
|
-
|
|
2374
|
+
const updateCommand = usingVolta ? `volta install ${packageName}@latest` : `npm install -g ${packageName}@latest`;
|
|
2375
|
+
execSync7(updateCommand, {
|
|
2357
2376
|
encoding: "utf-8",
|
|
2358
2377
|
stdio: ["pipe", "pipe", "pipe"]
|
|
2359
2378
|
});
|
|
@@ -2365,15 +2384,20 @@ async function update(currentVersion) {
|
|
|
2365
2384
|
[
|
|
2366
2385
|
colors.green(colors.bold("\u2728 \u66F4\u65B0\u5B8C\u6210\uFF01")),
|
|
2367
2386
|
"",
|
|
2368
|
-
|
|
2387
|
+
`\u65B0\u7248\u672C: ${colors.green(colors.bold(latestVersion))}`,
|
|
2388
|
+
"",
|
|
2389
|
+
colors.dim("\u8BF7\u6267\u884C\u4EE5\u4E0B\u547D\u4EE4\u9A8C\u8BC1:"),
|
|
2390
|
+
colors.cyan(" hash -r && gw --version"),
|
|
2391
|
+
"",
|
|
2392
|
+
colors.dim("\u6216\u91CD\u65B0\u6253\u5F00\u7EC8\u7AEF")
|
|
2369
2393
|
].join("\n"),
|
|
2370
2394
|
{
|
|
2371
|
-
padding: { top: 1, bottom: 1, left:
|
|
2395
|
+
padding: { top: 1, bottom: 1, left: 2, right: 2 },
|
|
2372
2396
|
margin: { top: 0, bottom: 1, left: 2, right: 2 },
|
|
2373
2397
|
borderStyle: "round",
|
|
2374
2398
|
borderColor: "green",
|
|
2375
|
-
align: "
|
|
2376
|
-
width:
|
|
2399
|
+
align: "left",
|
|
2400
|
+
width: 50
|
|
2377
2401
|
}
|
|
2378
2402
|
)
|
|
2379
2403
|
);
|
|
@@ -2382,7 +2406,8 @@ async function update(currentVersion) {
|
|
|
2382
2406
|
spinner.fail(colors.red("\u66F4\u65B0\u5931\u8D25"));
|
|
2383
2407
|
console.log("");
|
|
2384
2408
|
console.log(colors.dim(" \u4F60\u53EF\u4EE5\u624B\u52A8\u8FD0\u884C\u4EE5\u4E0B\u547D\u4EE4\u66F4\u65B0:"));
|
|
2385
|
-
|
|
2409
|
+
const updateCommand = usingVolta ? `volta install ${packageName}@latest` : `npm install -g ${packageName}@latest`;
|
|
2410
|
+
console.log(colors.cyan(` ${updateCommand}`));
|
|
2386
2411
|
console.log("");
|
|
2387
2412
|
process.exit(1);
|
|
2388
2413
|
}
|
|
@@ -2413,7 +2438,7 @@ process.on("SIGTERM", () => {
|
|
|
2413
2438
|
console.log("");
|
|
2414
2439
|
process.exit(0);
|
|
2415
2440
|
});
|
|
2416
|
-
var version = true ? "0.2.
|
|
2441
|
+
var version = true ? "0.2.22" : "0.0.0-dev";
|
|
2417
2442
|
async function mainMenu() {
|
|
2418
2443
|
console.log(
|
|
2419
2444
|
colors.green(`
|
package/package.json
CHANGED
package/src/commands/update.ts
CHANGED
|
@@ -39,11 +39,24 @@ async function getLatestVersion(packageName: string): Promise<string | null> {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
/**
|
|
43
|
+
* 检测是否使用 Volta
|
|
44
|
+
*/
|
|
45
|
+
function isUsingVolta(): boolean {
|
|
46
|
+
try {
|
|
47
|
+
const whichGw = execSync("which gw", { encoding: "utf-8" }).trim();
|
|
48
|
+
return whichGw.includes(".volta");
|
|
49
|
+
} catch {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
42
54
|
/**
|
|
43
55
|
* 手动更新命令
|
|
44
56
|
*/
|
|
45
57
|
export async function update(currentVersion: string): Promise<void> {
|
|
46
58
|
const packageName = "@zjex/git-workflow";
|
|
59
|
+
const usingVolta = isUsingVolta();
|
|
47
60
|
|
|
48
61
|
console.log("");
|
|
49
62
|
console.log(colors.bold("🔍 检查更新..."));
|
|
@@ -85,12 +98,6 @@ export async function update(currentVersion: string): Promise<void> {
|
|
|
85
98
|
|
|
86
99
|
// 有新版本
|
|
87
100
|
const versionText = `${currentVersion} → ${latestVersion}`;
|
|
88
|
-
const maxWidth = Math.max(
|
|
89
|
-
"🎉 发现新版本!".length,
|
|
90
|
-
versionText.length,
|
|
91
|
-
"✨ 更新完成!".length,
|
|
92
|
-
"请重新打开终端使用新版本".length
|
|
93
|
-
);
|
|
94
101
|
|
|
95
102
|
console.log(
|
|
96
103
|
boxen(
|
|
@@ -115,7 +122,12 @@ export async function update(currentVersion: string): Promise<void> {
|
|
|
115
122
|
// 开始更新
|
|
116
123
|
const updateSpinner = ora("正在更新...").start();
|
|
117
124
|
|
|
118
|
-
|
|
125
|
+
// 根据包管理器选择更新命令
|
|
126
|
+
const updateCommand = usingVolta
|
|
127
|
+
? `volta install ${packageName}@latest`
|
|
128
|
+
: `npm install -g ${packageName}@latest`;
|
|
129
|
+
|
|
130
|
+
execSync(updateCommand, {
|
|
119
131
|
encoding: "utf-8",
|
|
120
132
|
stdio: ["pipe", "pipe", "pipe"],
|
|
121
133
|
});
|
|
@@ -131,15 +143,20 @@ export async function update(currentVersion: string): Promise<void> {
|
|
|
131
143
|
[
|
|
132
144
|
colors.green(colors.bold("✨ 更新完成!")),
|
|
133
145
|
"",
|
|
134
|
-
colors.
|
|
146
|
+
`新版本: ${colors.green(colors.bold(latestVersion))}`,
|
|
147
|
+
"",
|
|
148
|
+
colors.dim("请执行以下命令验证:"),
|
|
149
|
+
colors.cyan(" hash -r && gw --version"),
|
|
150
|
+
"",
|
|
151
|
+
colors.dim("或重新打开终端"),
|
|
135
152
|
].join("\n"),
|
|
136
153
|
{
|
|
137
|
-
padding: { top: 1, bottom: 1, left:
|
|
154
|
+
padding: { top: 1, bottom: 1, left: 2, right: 2 },
|
|
138
155
|
margin: { top: 0, bottom: 1, left: 2, right: 2 },
|
|
139
156
|
borderStyle: "round",
|
|
140
157
|
borderColor: "green",
|
|
141
|
-
align: "
|
|
142
|
-
width:
|
|
158
|
+
align: "left",
|
|
159
|
+
width: 50,
|
|
143
160
|
}
|
|
144
161
|
)
|
|
145
162
|
);
|
|
@@ -150,7 +167,10 @@ export async function update(currentVersion: string): Promise<void> {
|
|
|
150
167
|
spinner.fail(colors.red("更新失败"));
|
|
151
168
|
console.log("");
|
|
152
169
|
console.log(colors.dim(" 你可以手动运行以下命令更新:"));
|
|
153
|
-
|
|
170
|
+
const updateCommand = usingVolta
|
|
171
|
+
? `volta install ${packageName}@latest`
|
|
172
|
+
: `npm install -g ${packageName}@latest`;
|
|
173
|
+
console.log(colors.cyan(` ${updateCommand}`));
|
|
154
174
|
console.log("");
|
|
155
175
|
process.exit(1);
|
|
156
176
|
}
|
package/src/update-notifier.ts
CHANGED
|
@@ -107,6 +107,18 @@ function backgroundCheck(currentVersion: string, packageName: string): void {
|
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
/**
|
|
111
|
+
* 检测是否使用 Volta
|
|
112
|
+
*/
|
|
113
|
+
function isUsingVolta(): boolean {
|
|
114
|
+
try {
|
|
115
|
+
const whichGw = execSync("which gw", { encoding: "utf-8" }).trim();
|
|
116
|
+
return whichGw.includes(".volta");
|
|
117
|
+
} catch {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
110
122
|
/**
|
|
111
123
|
* 获取 npm 上的最新版本
|
|
112
124
|
*/
|
|
@@ -172,6 +184,11 @@ async function showUpdateMessage(
|
|
|
172
184
|
})
|
|
173
185
|
);
|
|
174
186
|
|
|
187
|
+
const usingVolta = isUsingVolta();
|
|
188
|
+
const updateCommand = usingVolta
|
|
189
|
+
? `volta install ${packageName}@latest`
|
|
190
|
+
: `npm install -g ${packageName}@latest`;
|
|
191
|
+
|
|
175
192
|
try {
|
|
176
193
|
const action = await select({
|
|
177
194
|
message: "你想做什么?",
|
|
@@ -179,7 +196,7 @@ async function showUpdateMessage(
|
|
|
179
196
|
{
|
|
180
197
|
name: "🚀 立即更新",
|
|
181
198
|
value: "update",
|
|
182
|
-
description: `运行
|
|
199
|
+
description: `运行 ${updateCommand}`,
|
|
183
200
|
},
|
|
184
201
|
{
|
|
185
202
|
name: "⏭️ 稍后更新,继续使用",
|
|
@@ -208,14 +225,19 @@ async function showUpdateMessage(
|
|
|
208
225
|
async function performUpdate(packageName: string): Promise<void> {
|
|
209
226
|
console.log("");
|
|
210
227
|
|
|
228
|
+
const usingVolta = isUsingVolta();
|
|
229
|
+
const updateCommand = usingVolta
|
|
230
|
+
? `volta install ${packageName}@latest`
|
|
231
|
+
: `npm install -g ${packageName}@latest`;
|
|
232
|
+
|
|
211
233
|
const spinner = ora({
|
|
212
234
|
text: "正在更新...",
|
|
213
235
|
spinner: "dots",
|
|
214
236
|
}).start();
|
|
215
237
|
|
|
216
238
|
try {
|
|
217
|
-
//
|
|
218
|
-
execSync(
|
|
239
|
+
// 根据包管理器选择更新命令
|
|
240
|
+
execSync(updateCommand, {
|
|
219
241
|
encoding: "utf-8",
|
|
220
242
|
stdio: ["pipe", "pipe", "pipe"],
|
|
221
243
|
});
|
|
@@ -231,15 +253,18 @@ async function performUpdate(packageName: string): Promise<void> {
|
|
|
231
253
|
[
|
|
232
254
|
colors.green(colors.bold("✨ 更新完成!")),
|
|
233
255
|
"",
|
|
234
|
-
colors.dim("
|
|
256
|
+
colors.dim("请执行以下命令验证:"),
|
|
257
|
+
colors.cyan(" hash -r && gw --version"),
|
|
258
|
+
"",
|
|
259
|
+
colors.dim("或重新打开终端"),
|
|
235
260
|
].join("\n"),
|
|
236
261
|
{
|
|
237
|
-
padding: { top: 1, bottom: 1, left:
|
|
262
|
+
padding: { top: 1, bottom: 1, left: 2, right: 2 },
|
|
238
263
|
margin: { top: 0, bottom: 1, left: 2, right: 2 },
|
|
239
264
|
borderStyle: "round",
|
|
240
265
|
borderColor: "green",
|
|
241
|
-
align: "
|
|
242
|
-
width:
|
|
266
|
+
align: "left",
|
|
267
|
+
width: 50,
|
|
243
268
|
}
|
|
244
269
|
)
|
|
245
270
|
);
|
|
@@ -250,7 +275,7 @@ async function performUpdate(packageName: string): Promise<void> {
|
|
|
250
275
|
spinner.fail(colors.red("更新失败"));
|
|
251
276
|
console.log("");
|
|
252
277
|
console.log(colors.dim(" 你可以手动运行以下命令更新:"));
|
|
253
|
-
console.log(colors.cyan(`
|
|
278
|
+
console.log(colors.cyan(` ${updateCommand}`));
|
|
254
279
|
console.log("");
|
|
255
280
|
}
|
|
256
281
|
}
|