weixin-mcp 1.3.2 → 1.3.3
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/cli.js +31 -0
- package/package.json +1 -1
- package/src/cli.ts +33 -0
package/dist/cli.js
CHANGED
|
@@ -12,6 +12,15 @@
|
|
|
12
12
|
* logs [-f] Show daemon logs (tail -f with -f flag)
|
|
13
13
|
*/
|
|
14
14
|
const command = process.argv[2];
|
|
15
|
+
if (command === "--version" || command === "-v") {
|
|
16
|
+
const { createRequire } = await import("node:module");
|
|
17
|
+
const { fileURLToPath } = await import("node:url");
|
|
18
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
19
|
+
const req = createRequire(__filename);
|
|
20
|
+
const { version } = req("../package.json");
|
|
21
|
+
console.log(`weixin-mcp v${version}`);
|
|
22
|
+
process.exit(0);
|
|
23
|
+
}
|
|
15
24
|
if (command === "login") {
|
|
16
25
|
const { main } = await import("./login.js");
|
|
17
26
|
await main();
|
|
@@ -45,6 +54,26 @@ else if (command === "accounts") {
|
|
|
45
54
|
const { manageAccounts } = await import("./accounts.js");
|
|
46
55
|
await manageAccounts(process.argv.slice(3));
|
|
47
56
|
}
|
|
57
|
+
else if (command === "update") {
|
|
58
|
+
const { execSync } = await import("node:child_process");
|
|
59
|
+
const { createRequire } = await import("node:module");
|
|
60
|
+
const { fileURLToPath } = await import("node:url");
|
|
61
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
62
|
+
const req = createRequire(__filename);
|
|
63
|
+
const current = req("../package.json").version;
|
|
64
|
+
process.stdout.write("Checking latest version... ");
|
|
65
|
+
const res = await fetch("https://registry.npmjs.org/weixin-mcp/latest");
|
|
66
|
+
const { version: latest } = await res.json();
|
|
67
|
+
console.log(`current: ${current} → latest: ${latest}`);
|
|
68
|
+
if (current === latest) {
|
|
69
|
+
console.log("✅ Already up to date.");
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
console.log(`Updating weixin-mcp ${current} → ${latest}...`);
|
|
73
|
+
execSync("npm install -g weixin-mcp@latest", { stdio: "inherit" });
|
|
74
|
+
console.log("✅ Updated! Run: npx weixin-mcp --version");
|
|
75
|
+
}
|
|
76
|
+
}
|
|
48
77
|
else if (command === "send") {
|
|
49
78
|
const { cliSend } = await import("./messaging.js");
|
|
50
79
|
await cliSend(process.argv.slice(3)); // <userId> <text...>
|
|
@@ -70,6 +99,8 @@ Commands:
|
|
|
70
99
|
stop Stop daemon
|
|
71
100
|
restart Restart daemon
|
|
72
101
|
logs [-f] Show daemon logs (-f to follow)
|
|
102
|
+
update Check and install latest version
|
|
103
|
+
--version / -v Print version
|
|
73
104
|
send <userId> <text> Send a message from CLI
|
|
74
105
|
poll [--watch|-w] [--reset] Poll messages once, or watch continuously
|
|
75
106
|
accounts [list] List all accounts
|
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -14,6 +14,16 @@
|
|
|
14
14
|
|
|
15
15
|
const command = process.argv[2];
|
|
16
16
|
|
|
17
|
+
if (command === "--version" || command === "-v") {
|
|
18
|
+
const { createRequire } = await import("node:module");
|
|
19
|
+
const { fileURLToPath } = await import("node:url");
|
|
20
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
21
|
+
const req = createRequire(__filename);
|
|
22
|
+
const { version } = req("../package.json") as { version: string };
|
|
23
|
+
console.log(`weixin-mcp v${version}`);
|
|
24
|
+
process.exit(0);
|
|
25
|
+
}
|
|
26
|
+
|
|
17
27
|
if (command === "login") {
|
|
18
28
|
const { main } = await import("./login.js");
|
|
19
29
|
await main();
|
|
@@ -47,6 +57,27 @@ if (command === "login") {
|
|
|
47
57
|
const { manageAccounts } = await import("./accounts.js");
|
|
48
58
|
await manageAccounts(process.argv.slice(3));
|
|
49
59
|
|
|
60
|
+
} else if (command === "update") {
|
|
61
|
+
const { execSync } = await import("node:child_process");
|
|
62
|
+
const { createRequire } = await import("node:module");
|
|
63
|
+
const { fileURLToPath } = await import("node:url");
|
|
64
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
65
|
+
const req = createRequire(__filename);
|
|
66
|
+
const current = (req("../package.json") as { version: string }).version;
|
|
67
|
+
|
|
68
|
+
process.stdout.write("Checking latest version... ");
|
|
69
|
+
const res = await fetch("https://registry.npmjs.org/weixin-mcp/latest");
|
|
70
|
+
const { version: latest } = await res.json() as { version: string };
|
|
71
|
+
console.log(`current: ${current} → latest: ${latest}`);
|
|
72
|
+
|
|
73
|
+
if (current === latest) {
|
|
74
|
+
console.log("✅ Already up to date.");
|
|
75
|
+
} else {
|
|
76
|
+
console.log(`Updating weixin-mcp ${current} → ${latest}...`);
|
|
77
|
+
execSync("npm install -g weixin-mcp@latest", { stdio: "inherit" });
|
|
78
|
+
console.log("✅ Updated! Run: npx weixin-mcp --version");
|
|
79
|
+
}
|
|
80
|
+
|
|
50
81
|
} else if (command === "send") {
|
|
51
82
|
const { cliSend } = await import("./messaging.js");
|
|
52
83
|
await cliSend(process.argv.slice(3)); // <userId> <text...>
|
|
@@ -72,6 +103,8 @@ Commands:
|
|
|
72
103
|
stop Stop daemon
|
|
73
104
|
restart Restart daemon
|
|
74
105
|
logs [-f] Show daemon logs (-f to follow)
|
|
106
|
+
update Check and install latest version
|
|
107
|
+
--version / -v Print version
|
|
75
108
|
send <userId> <text> Send a message from CLI
|
|
76
109
|
poll [--watch|-w] [--reset] Poll messages once, or watch continuously
|
|
77
110
|
accounts [list] List all accounts
|