@zjex/git-workflow 0.2.2 → 0.2.4
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 +10 -19
- package/package.json +1 -1
- package/src/index.ts +3 -3
- package/src/update-notifier.ts +8 -11
- package/tsup.config.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
3
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
4
|
-
}) : x)(function(x) {
|
|
5
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
6
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
-
});
|
|
1
|
+
#!/usr/bin/env -S node --no-warnings=ExperimentalWarning
|
|
8
2
|
|
|
9
3
|
// src/index.ts
|
|
10
4
|
import { cac } from "cac";
|
|
@@ -1345,6 +1339,9 @@ Commit \u547D\u4EE4:
|
|
|
1345
1339
|
|
|
1346
1340
|
// src/update-notifier.ts
|
|
1347
1341
|
import { execSync as execSync6 } from "child_process";
|
|
1342
|
+
import { readFileSync as readFileSync3, writeFileSync as writeFileSync3, existsSync as existsSync3 } from "fs";
|
|
1343
|
+
import { homedir } from "os";
|
|
1344
|
+
import { join as join2 } from "path";
|
|
1348
1345
|
import boxen from "boxen";
|
|
1349
1346
|
import { select as select7 } from "@inquirer/prompts";
|
|
1350
1347
|
import ora5 from "ora";
|
|
@@ -1467,14 +1464,11 @@ async function performUpdate(packageName) {
|
|
|
1467
1464
|
}
|
|
1468
1465
|
function readCache() {
|
|
1469
1466
|
try {
|
|
1470
|
-
const
|
|
1471
|
-
|
|
1472
|
-
const path = __require("path");
|
|
1473
|
-
const cacheFile = path.join(os.homedir(), CACHE_FILE);
|
|
1474
|
-
if (!fs.existsSync(cacheFile)) {
|
|
1467
|
+
const cacheFile = join2(homedir(), CACHE_FILE);
|
|
1468
|
+
if (!existsSync3(cacheFile)) {
|
|
1475
1469
|
return null;
|
|
1476
1470
|
}
|
|
1477
|
-
const content =
|
|
1471
|
+
const content = readFileSync3(cacheFile, "utf-8");
|
|
1478
1472
|
return JSON.parse(content);
|
|
1479
1473
|
} catch {
|
|
1480
1474
|
return null;
|
|
@@ -1482,11 +1476,8 @@ function readCache() {
|
|
|
1482
1476
|
}
|
|
1483
1477
|
function writeCache(cache) {
|
|
1484
1478
|
try {
|
|
1485
|
-
const
|
|
1486
|
-
|
|
1487
|
-
const path = __require("path");
|
|
1488
|
-
const cacheFile = path.join(os.homedir(), CACHE_FILE);
|
|
1489
|
-
fs.writeFileSync(cacheFile, JSON.stringify(cache), "utf-8");
|
|
1479
|
+
const cacheFile = join2(homedir(), CACHE_FILE);
|
|
1480
|
+
writeFileSync3(cacheFile, JSON.stringify(cache), "utf-8");
|
|
1490
1481
|
} catch {
|
|
1491
1482
|
}
|
|
1492
1483
|
}
|
|
@@ -1499,7 +1490,7 @@ process.on("uncaughtException", (err) => {
|
|
|
1499
1490
|
console.error(err);
|
|
1500
1491
|
process.exit(1);
|
|
1501
1492
|
});
|
|
1502
|
-
var version = true ? "0.2.
|
|
1493
|
+
var version = true ? "0.2.4" : "0.0.0-dev";
|
|
1503
1494
|
async function mainMenu() {
|
|
1504
1495
|
checkForUpdates(version, "@zjex/git-workflow").catch(() => {
|
|
1505
1496
|
});
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { stash } from "./commands/stash.js";
|
|
|
12
12
|
import { commit } from "./commands/commit.js";
|
|
13
13
|
import { showHelp } from "./commands/help.js";
|
|
14
14
|
import { checkForUpdates } from "./update-notifier.js";
|
|
15
|
+
import { checkForUpdates } from "./update-notifier.js";
|
|
15
16
|
|
|
16
17
|
// 捕获 Ctrl+C 退出,静默处理
|
|
17
18
|
process.on("uncaughtException", (err) => {
|
|
@@ -26,10 +27,9 @@ declare const __VERSION__: string | undefined;
|
|
|
26
27
|
|
|
27
28
|
// 开发环境下从 package.json 读取版本号
|
|
28
29
|
const version: string =
|
|
29
|
-
typeof __VERSION__ !== "undefined"
|
|
30
|
+
typeof __VERSION__ !== "undefined" && __VERSION__ !== ""
|
|
30
31
|
? __VERSION__
|
|
31
|
-
:
|
|
32
|
-
.version;
|
|
32
|
+
: "0.0.0-dev";
|
|
33
33
|
|
|
34
34
|
// 交互式主菜单
|
|
35
35
|
async function mainMenu(): Promise<void> {
|
package/src/update-notifier.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { execSync } from "child_process";
|
|
2
|
+
import { readFileSync, writeFileSync, existsSync } from "fs";
|
|
3
|
+
import { homedir } from "os";
|
|
4
|
+
import { join } from "path";
|
|
2
5
|
import boxen from "boxen";
|
|
3
6
|
import { select } from "@inquirer/prompts";
|
|
4
7
|
import ora from "ora";
|
|
@@ -180,16 +183,13 @@ async function performUpdate(packageName: string): Promise<void> {
|
|
|
180
183
|
*/
|
|
181
184
|
function readCache(): UpdateCache | null {
|
|
182
185
|
try {
|
|
183
|
-
const
|
|
184
|
-
const os = require("os");
|
|
185
|
-
const path = require("path");
|
|
186
|
-
const cacheFile = path.join(os.homedir(), CACHE_FILE);
|
|
186
|
+
const cacheFile = join(homedir(), CACHE_FILE);
|
|
187
187
|
|
|
188
|
-
if (!
|
|
188
|
+
if (!existsSync(cacheFile)) {
|
|
189
189
|
return null;
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
-
const content =
|
|
192
|
+
const content = readFileSync(cacheFile, "utf-8");
|
|
193
193
|
return JSON.parse(content);
|
|
194
194
|
} catch {
|
|
195
195
|
return null;
|
|
@@ -201,12 +201,9 @@ function readCache(): UpdateCache | null {
|
|
|
201
201
|
*/
|
|
202
202
|
function writeCache(cache: UpdateCache): void {
|
|
203
203
|
try {
|
|
204
|
-
const
|
|
205
|
-
const os = require("os");
|
|
206
|
-
const path = require("path");
|
|
207
|
-
const cacheFile = path.join(os.homedir(), CACHE_FILE);
|
|
204
|
+
const cacheFile = join(homedir(), CACHE_FILE);
|
|
208
205
|
|
|
209
|
-
|
|
206
|
+
writeFileSync(cacheFile, JSON.stringify(cache), "utf-8");
|
|
210
207
|
} catch {
|
|
211
208
|
// 静默失败
|
|
212
209
|
}
|