wechat-media-writer 2.2.2 → 2.2.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/bin/cli.js +6 -0
- package/package.json +1 -1
- package/scripts/install.js +51 -14
package/bin/cli.js
CHANGED
|
@@ -90,6 +90,12 @@ function main() {
|
|
|
90
90
|
return;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
if (command === '--version' || command === '-v') {
|
|
94
|
+
const pkg = require('../package.json');
|
|
95
|
+
console.log(`wechat-media-writer v${pkg.version}`);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
93
99
|
const python = checkPython();
|
|
94
100
|
checkDependencies();
|
|
95
101
|
|
package/package.json
CHANGED
package/scripts/install.js
CHANGED
|
@@ -1,29 +1,66 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const { execSync } = require('child_process');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const os = require('os');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
|
|
8
|
+
const PKG_ROOT = path.resolve(__dirname, '..');
|
|
9
|
+
const HOME = os.homedir();
|
|
4
10
|
|
|
5
11
|
console.log('正在检查 Python 环境...');
|
|
6
12
|
|
|
7
13
|
try {
|
|
8
|
-
// 检查 Python 3
|
|
9
14
|
execSync('python3 --version', { stdio: 'pipe' });
|
|
10
15
|
console.log('✓ Python 3 已安装');
|
|
11
|
-
|
|
12
|
-
|
|
16
|
+
} catch {
|
|
17
|
+
console.error('警告: Python 3 未安装,部分功能不可用');
|
|
18
|
+
console.error('请访问 https://www.python.org/downloads/ 安装');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
execSync('python3 -c "from PIL import Image"', { stdio: 'pipe' });
|
|
23
|
+
console.log('✓ Pillow 已安装');
|
|
24
|
+
} catch {
|
|
13
25
|
try {
|
|
14
|
-
execSync('python3 -c "from PIL import Image"', { stdio: 'pipe' });
|
|
15
|
-
console.log('✓ Pillow 已安装');
|
|
16
|
-
} catch {
|
|
17
26
|
console.log('正在安装 Pillow...');
|
|
18
27
|
execSync('pip3 install Pillow', { stdio: 'inherit' });
|
|
19
28
|
console.log('✓ Pillow 安装完成');
|
|
29
|
+
} catch {
|
|
30
|
+
console.error('警告: Pillow 安装失败,封面图处理功能不可用');
|
|
20
31
|
}
|
|
21
|
-
|
|
22
|
-
console.log('\n安装完成!使用方法:');
|
|
23
|
-
console.log(' npx wechat-book-review help');
|
|
24
|
-
|
|
25
|
-
} catch (e) {
|
|
26
|
-
console.error('\n警告: Python 3 未安装');
|
|
27
|
-
console.error('请手动安装 Python 3: https://www.python.org/downloads/');
|
|
28
|
-
console.error('\n安装后仍可使用,但需要手动运行 Python 脚本');
|
|
29
32
|
}
|
|
33
|
+
|
|
34
|
+
// 将 Skill 软链到各模型的 skills 目录
|
|
35
|
+
function linkSkillTo(skillsDir, label) {
|
|
36
|
+
const target = path.join(skillsDir, 'wechat-media-writer');
|
|
37
|
+
try {
|
|
38
|
+
fs.mkdirSync(skillsDir, { recursive: true });
|
|
39
|
+
// 已存在且指向同一目录则跳过
|
|
40
|
+
if (fs.existsSync(target)) {
|
|
41
|
+
const cur = fs.lstatSync(target);
|
|
42
|
+
if (cur.isSymbolicLink()) {
|
|
43
|
+
const linkTo = fs.readlinkSync(target);
|
|
44
|
+
if (path.resolve(linkTo) === path.resolve(PKG_ROOT)) {
|
|
45
|
+
console.log(`✓ [${label}] Skill 已链接到最新版本`);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// 指向旧版本,移除并重建
|
|
50
|
+
fs.rmSync(target, { recursive: true, force: true });
|
|
51
|
+
}
|
|
52
|
+
fs.symlinkSync(PKG_ROOT, target, 'dir');
|
|
53
|
+
console.log(`✓ [${label}] Skill 已链接: ${target} -> ${PKG_ROOT}`);
|
|
54
|
+
} catch (e) {
|
|
55
|
+
console.error(`警告: 无法链接 Skill 到 [${label}] ${target}: ${e.message}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
console.log('\n正在注册 Skill...');
|
|
60
|
+
linkSkillTo(path.join(HOME, '.claude', 'skills'), 'Claude Code');
|
|
61
|
+
linkSkillTo(path.join(HOME, '.config', 'opencode', 'skills'), 'OpenCode');
|
|
62
|
+
|
|
63
|
+
console.log('\n安装完成!');
|
|
64
|
+
console.log(' npx wechat-media-writer --version # 查看版本');
|
|
65
|
+
console.log(' npx wechat-media-writer help # 查看命令');
|
|
66
|
+
console.log('\nSkill 已自动注册,可直接说"帮我写《书名》书评发到公众号"');
|