@42ailab/42cc 0.2.1
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/README.md +92 -0
- package/assets/.gitkeep +0 -0
- package/assets/42cc.dmg +0 -0
- package/assets/42cc.exe +0 -0
- package/bin/42cc.js +134 -0
- package/index.js +5 -0
- package/package.json +45 -0
- package/scripts/install.js +252 -0
package/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# 42cc
|
|
2
|
+
|
|
3
|
+
Claude Code 模型配置工具 - npm 安装器
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
### npm
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g @42ailab/42cc
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### bun
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
bun add -g --trust @42ailab/42cc
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### 其他包管理器
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# yarn
|
|
23
|
+
yarn global add @42ailab/42cc
|
|
24
|
+
|
|
25
|
+
# pnpm
|
|
26
|
+
pnpm add -g @42ailab/42cc
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## 使用
|
|
30
|
+
|
|
31
|
+
安装完成后,应用会自动安装并启动。安装包已内置在 npm 包中,无需额外下载。
|
|
32
|
+
|
|
33
|
+
### macOS
|
|
34
|
+
|
|
35
|
+
- 自动安装到 `/Applications/42cc.app`
|
|
36
|
+
- 自动启动应用(首次需要确认 Gatekeeper 安全提示)
|
|
37
|
+
- 下次可从 Launchpad 或访达搜索 "42cc" 启动
|
|
38
|
+
|
|
39
|
+
### Windows
|
|
40
|
+
|
|
41
|
+
- 自动安装到 `%LocalAppData%\42cc`
|
|
42
|
+
- 自动创建开始菜单快捷方式
|
|
43
|
+
- 自动启动应用
|
|
44
|
+
- 下次可从开始菜单搜索 "42cc" 启动
|
|
45
|
+
|
|
46
|
+
## 系统要求
|
|
47
|
+
|
|
48
|
+
- **macOS**: 10.13 (High Sierra) 或更高
|
|
49
|
+
- **Windows**: Windows 10 或更高
|
|
50
|
+
- **Node.js**: 14.0.0 或更高
|
|
51
|
+
|
|
52
|
+
## 注意事项
|
|
53
|
+
|
|
54
|
+
- **macOS**: 首次运行时需要在 Gatekeeper 安全提示中点击"打开"
|
|
55
|
+
- **Windows**: 如遇到 SmartScreen 提示,点击"仍要运行"
|
|
56
|
+
- 安装过程中可能需要管理员权限
|
|
57
|
+
|
|
58
|
+
## 其他安装方式
|
|
59
|
+
|
|
60
|
+
### Homebrew (macOS)
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
brew tap 42ailab/42cc
|
|
64
|
+
brew install --cask 42cc
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### 直接下载
|
|
68
|
+
|
|
69
|
+
访问 [https://get.42plugin.com/42cc/](https://get.42plugin.com/42cc/) 下载安装包。
|
|
70
|
+
|
|
71
|
+
## 功能
|
|
72
|
+
|
|
73
|
+
42cc 是一款极简的 Claude Code 模型配置工具:
|
|
74
|
+
|
|
75
|
+
- 选择模型供应商
|
|
76
|
+
- 输入 API 密钥
|
|
77
|
+
- 一键完成配置
|
|
78
|
+
|
|
79
|
+
支持的模型供应商:
|
|
80
|
+
- GLM (智谱)
|
|
81
|
+
- MiniMax
|
|
82
|
+
- Anthropic 官方
|
|
83
|
+
- 自定义供应商
|
|
84
|
+
|
|
85
|
+
## 链接
|
|
86
|
+
|
|
87
|
+
- **主页**: https://42cc.42ailab.com
|
|
88
|
+
- **问题反馈**: https://cnb.cool/42ailab/42plugin/meta/-/issues
|
|
89
|
+
|
|
90
|
+
## LICENSE
|
|
91
|
+
|
|
92
|
+
Proprietary
|
package/assets/.gitkeep
ADDED
|
File without changes
|
package/assets/42cc.dmg
ADDED
|
Binary file
|
package/assets/42cc.exe
ADDED
|
Binary file
|
package/bin/42cc.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { execSync } = require('child_process');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const https = require('https');
|
|
7
|
+
|
|
8
|
+
const platform = process.platform;
|
|
9
|
+
const VERSION_URL = 'https://get.42plugin.com/42cc/version.json';
|
|
10
|
+
|
|
11
|
+
function showHelp() {
|
|
12
|
+
console.log(`
|
|
13
|
+
42cc - Claude Code 模型配置工具
|
|
14
|
+
|
|
15
|
+
用法:
|
|
16
|
+
42cc 启动应用(仅 macOS)
|
|
17
|
+
42cc --help 显示帮助信息
|
|
18
|
+
42cc --version 显示版本信息
|
|
19
|
+
42cc --update 检查并更新到最新版本
|
|
20
|
+
|
|
21
|
+
安装位置:
|
|
22
|
+
macOS: /Applications/42cc.app
|
|
23
|
+
Windows: 请从开始菜单启动
|
|
24
|
+
|
|
25
|
+
更多信息: https://42ailab.com
|
|
26
|
+
`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function getVersion() {
|
|
30
|
+
const pkg = require('../package.json');
|
|
31
|
+
console.log(`v${pkg.version}`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function launch() {
|
|
35
|
+
if (platform === 'darwin') {
|
|
36
|
+
try {
|
|
37
|
+
execSync('open -a 42cc', { stdio: 'inherit' });
|
|
38
|
+
} catch (error) {
|
|
39
|
+
console.error('错误: 未找到 42cc 应用');
|
|
40
|
+
console.error('请尝试重新安装: npm install -g @42ailab/42cc');
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
} else if (platform === 'win32') {
|
|
44
|
+
console.log('Windows: 请从开始菜单启动 42cc');
|
|
45
|
+
console.log('或运行安装目录下的 42cc.exe');
|
|
46
|
+
} else {
|
|
47
|
+
console.error('不支持的平台');
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// 获取本地已安装的版本号
|
|
53
|
+
function getLocalVersion() {
|
|
54
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE;
|
|
55
|
+
|
|
56
|
+
let versionFile;
|
|
57
|
+
if (platform === 'darwin') {
|
|
58
|
+
versionFile = path.join(homeDir, '.42cc', 'version');
|
|
59
|
+
} else {
|
|
60
|
+
versionFile = path.join(process.env.APPDATA || homeDir, '42cc', 'version');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
return fs.readFileSync(versionFile, 'utf8').trim();
|
|
65
|
+
} catch (e) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// 获取远程最新版本号
|
|
71
|
+
function fetchRemoteVersion() {
|
|
72
|
+
return new Promise((resolve, reject) => {
|
|
73
|
+
https.get(VERSION_URL, (res) => {
|
|
74
|
+
// 检查 HTTP 状态码
|
|
75
|
+
if (res.statusCode !== 200) {
|
|
76
|
+
reject(new Error(`HTTP 请求失败: ${res.statusCode}`));
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
let data = '';
|
|
81
|
+
res.on('data', (chunk) => data += chunk);
|
|
82
|
+
res.on('end', () => {
|
|
83
|
+
try {
|
|
84
|
+
const json = JSON.parse(data);
|
|
85
|
+
resolve(json.version);
|
|
86
|
+
} catch (e) {
|
|
87
|
+
reject(new Error('解析版本信息失败'));
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}).on('error', (err) => {
|
|
91
|
+
reject(new Error(`网络请求失败: ${err.message}`));
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// 检查并更新
|
|
97
|
+
async function checkAndUpdate() {
|
|
98
|
+
console.log('检查更新中...\n');
|
|
99
|
+
|
|
100
|
+
try {
|
|
101
|
+
const localVersion = getLocalVersion();
|
|
102
|
+
const remoteVersion = await fetchRemoteVersion();
|
|
103
|
+
|
|
104
|
+
console.log(`本地版本: ${localVersion || '未安装'}`);
|
|
105
|
+
console.log(`最新版本: ${remoteVersion}`);
|
|
106
|
+
|
|
107
|
+
if (localVersion === remoteVersion) {
|
|
108
|
+
console.log('\n已是最新版本,无需更新。');
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
console.log('\n发现新版本,开始更新...\n');
|
|
113
|
+
|
|
114
|
+
// 调用 install.js 进行安装
|
|
115
|
+
const installScript = path.join(__dirname, '..', 'scripts', 'install.js');
|
|
116
|
+
require(installScript).install();
|
|
117
|
+
|
|
118
|
+
} catch (error) {
|
|
119
|
+
console.error(`更新失败: ${error.message}`);
|
|
120
|
+
process.exit(1);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const arg = process.argv[2];
|
|
125
|
+
|
|
126
|
+
if (arg === '--help' || arg === '-h') {
|
|
127
|
+
showHelp();
|
|
128
|
+
} else if (arg === '--version' || arg === '-v') {
|
|
129
|
+
getVersion();
|
|
130
|
+
} else if (arg === '--update' || arg === '-u') {
|
|
131
|
+
checkAndUpdate();
|
|
132
|
+
} else {
|
|
133
|
+
launch();
|
|
134
|
+
}
|
package/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@42ailab/42cc",
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "Claude Code model configuration tool - Installer | Claude Code \u6a21\u578b\u914d\u7f6e\u5de5\u5177 - \u5b89\u88c5\u5668",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"42cc": "./bin/42cc.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"postinstall": "node scripts/install.js",
|
|
11
|
+
"test": "bash test.sh"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"claude-code",
|
|
15
|
+
"ai",
|
|
16
|
+
"model-configuration",
|
|
17
|
+
"42plugin",
|
|
18
|
+
"42ailab"
|
|
19
|
+
],
|
|
20
|
+
"author": "42ailab <email@huoshuiai.com>",
|
|
21
|
+
"license": "Proprietary",
|
|
22
|
+
"homepage": "https://42cc.42ailab.com",
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "https://github.com/42ailab/get.42plugin.com.git",
|
|
26
|
+
"directory": "npm-package"
|
|
27
|
+
},
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://cnb.cool/42ailab/42plugin/meta/-/issues"
|
|
30
|
+
},
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=14.0.0"
|
|
33
|
+
},
|
|
34
|
+
"os": [
|
|
35
|
+
"darwin",
|
|
36
|
+
"win32"
|
|
37
|
+
],
|
|
38
|
+
"files": [
|
|
39
|
+
"bin/",
|
|
40
|
+
"scripts/install.js",
|
|
41
|
+
"assets/",
|
|
42
|
+
"index.js",
|
|
43
|
+
"README.md"
|
|
44
|
+
]
|
|
45
|
+
}
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const { execSync } = require('child_process');
|
|
6
|
+
|
|
7
|
+
const ASSETS_DIR = path.join(__dirname, '..', 'assets');
|
|
8
|
+
const APP_VERSION = require('../package.json').version;
|
|
9
|
+
|
|
10
|
+
// 颜色输出
|
|
11
|
+
const colors = {
|
|
12
|
+
reset: '\x1b[0m',
|
|
13
|
+
green: '\x1b[32m',
|
|
14
|
+
yellow: '\x1b[33m',
|
|
15
|
+
blue: '\x1b[34m',
|
|
16
|
+
red: '\x1b[31m'
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
function log(msg, color = 'reset') {
|
|
20
|
+
console.log(`${colors[color]}${msg}${colors.reset}`);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function getPlatform() {
|
|
24
|
+
const platform = process.platform;
|
|
25
|
+
if (platform === 'darwin') return 'macos';
|
|
26
|
+
if (platform === 'win32') return 'windows';
|
|
27
|
+
throw new Error(`不支持的平台: ${platform}`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// 保存已安装的版本号到本地文件
|
|
31
|
+
function saveInstalledVersion(version) {
|
|
32
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE;
|
|
33
|
+
const platform = process.platform;
|
|
34
|
+
|
|
35
|
+
let versionDir;
|
|
36
|
+
if (platform === 'darwin') {
|
|
37
|
+
versionDir = path.join(homeDir, '.42cc');
|
|
38
|
+
} else {
|
|
39
|
+
versionDir = path.join(process.env.APPDATA || homeDir, '42cc');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const versionFile = path.join(versionDir, 'version');
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
if (!fs.existsSync(versionDir)) {
|
|
46
|
+
fs.mkdirSync(versionDir, { recursive: true });
|
|
47
|
+
}
|
|
48
|
+
fs.writeFileSync(versionFile, version, 'utf8');
|
|
49
|
+
} catch (e) {
|
|
50
|
+
// 写入版本文件失败不影响安装流程
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// macOS 自动安装
|
|
55
|
+
async function autoInstallMacOS() {
|
|
56
|
+
const dmgPath = path.join(ASSETS_DIR, '42cc.dmg');
|
|
57
|
+
|
|
58
|
+
if (!fs.existsSync(dmgPath)) {
|
|
59
|
+
throw new Error('未找到安装文件: ' + dmgPath);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
log('\n开始安装...', 'yellow');
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
// 1. 挂载 DMG
|
|
66
|
+
log('1. 挂载 DMG...', 'blue');
|
|
67
|
+
execSync(`hdiutil attach "${dmgPath}" -nobrowse -quiet`);
|
|
68
|
+
|
|
69
|
+
// 2. 找到挂载点
|
|
70
|
+
const volumes = fs.readdirSync('/Volumes');
|
|
71
|
+
const mountPoint = volumes.find(v => v.includes('42cc'));
|
|
72
|
+
if (!mountPoint) {
|
|
73
|
+
throw new Error('未找到挂载点');
|
|
74
|
+
}
|
|
75
|
+
const mountPath = `/Volumes/${mountPoint}`;
|
|
76
|
+
|
|
77
|
+
// 3. 复制到 Applications
|
|
78
|
+
log('2. 安装到 Applications...', 'blue');
|
|
79
|
+
const appPath = `${mountPath}/42cc.app`;
|
|
80
|
+
const targetPath = '/Applications/42cc.app';
|
|
81
|
+
|
|
82
|
+
// 检查是否已存在
|
|
83
|
+
if (fs.existsSync(targetPath)) {
|
|
84
|
+
log('检测到已安装的版本,将替换...', 'yellow');
|
|
85
|
+
try {
|
|
86
|
+
execSync(`rm -rf "${targetPath}"`);
|
|
87
|
+
} catch (e) {
|
|
88
|
+
log('需要管理员权限删除旧版本,请输入密码:', 'yellow');
|
|
89
|
+
try {
|
|
90
|
+
execSync(`sudo rm -rf "${targetPath}"`);
|
|
91
|
+
} catch (sudoErr) {
|
|
92
|
+
throw new Error('删除旧版本失败,请手动删除 /Applications/42cc.app 后重试');
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// 复制应用
|
|
98
|
+
try {
|
|
99
|
+
execSync(`cp -R "${appPath}" /Applications/`);
|
|
100
|
+
log('+ 安装成功', 'green');
|
|
101
|
+
} catch (e) {
|
|
102
|
+
log('需要管理员权限,请输入密码:', 'yellow');
|
|
103
|
+
try {
|
|
104
|
+
execSync(`sudo cp -R "${appPath}" /Applications/`);
|
|
105
|
+
log('+ 安装成功', 'green');
|
|
106
|
+
} catch (sudoErr) {
|
|
107
|
+
throw new Error('安装失败,请检查 /Applications 目录权限');
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// 4. 卸载 DMG
|
|
112
|
+
log('3. 清理...', 'blue');
|
|
113
|
+
execSync(`hdiutil detach "${mountPath}" -quiet`);
|
|
114
|
+
|
|
115
|
+
// 5. 启动应用
|
|
116
|
+
log('4. 启动应用...', 'blue');
|
|
117
|
+
log('\nGatekeeper 安全提示:', 'yellow');
|
|
118
|
+
log('即将弹出安全确认窗口,请点击"打开"', 'yellow');
|
|
119
|
+
log('(此提示仅首次运行时出现)\n', 'blue');
|
|
120
|
+
|
|
121
|
+
execSync('open -a 42cc');
|
|
122
|
+
|
|
123
|
+
log('\n+ 安装完成', 'green');
|
|
124
|
+
log('=====================================', 'blue');
|
|
125
|
+
log('');
|
|
126
|
+
log('+ 安装位置: /Applications/42cc.app', 'green');
|
|
127
|
+
log('+ 应用已启动并显示在菜单栏', 'green');
|
|
128
|
+
log('+ 下次可从 Launchpad 搜索 "42cc" 启动', 'green');
|
|
129
|
+
log('');
|
|
130
|
+
log('=====================================\n', 'blue');
|
|
131
|
+
|
|
132
|
+
return true;
|
|
133
|
+
} catch (error) {
|
|
134
|
+
log(`\n安装失败: ${error.message}`, 'red');
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Windows 自动安装
|
|
140
|
+
async function autoInstallWindows() {
|
|
141
|
+
const exePath = path.join(ASSETS_DIR, '42cc.exe');
|
|
142
|
+
|
|
143
|
+
if (!fs.existsSync(exePath)) {
|
|
144
|
+
throw new Error('未找到安装文件: ' + exePath);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
log('\n开始安装...', 'yellow');
|
|
148
|
+
|
|
149
|
+
try {
|
|
150
|
+
const userProfile = process.env.USERPROFILE || process.env.HOME;
|
|
151
|
+
const installDir = path.join(userProfile, 'AppData', 'Local', '42cc');
|
|
152
|
+
const targetPath = path.join(installDir, '42cc.exe');
|
|
153
|
+
|
|
154
|
+
log('1. 安装到用户目录...', 'blue');
|
|
155
|
+
|
|
156
|
+
// 创建目录
|
|
157
|
+
if (!fs.existsSync(installDir)) {
|
|
158
|
+
fs.mkdirSync(installDir, { recursive: true });
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// 复制可执行文件
|
|
162
|
+
fs.copyFileSync(exePath, targetPath);
|
|
163
|
+
log(`+ 已安装到: ${installDir}`, 'green');
|
|
164
|
+
|
|
165
|
+
// 创建开始菜单快捷方式
|
|
166
|
+
log('\n2. 创建开始菜单快捷方式...', 'blue');
|
|
167
|
+
try {
|
|
168
|
+
const startMenuDir = path.join(userProfile, 'AppData', 'Roaming', 'Microsoft', 'Windows', 'Start Menu', 'Programs');
|
|
169
|
+
const shortcutPath = path.join(startMenuDir, '42cc.lnk');
|
|
170
|
+
|
|
171
|
+
// 使用 PowerShell 创建快捷方式
|
|
172
|
+
const psScript = `
|
|
173
|
+
$WshShell = New-Object -ComObject WScript.Shell
|
|
174
|
+
$Shortcut = $WshShell.CreateShortcut("${shortcutPath.replace(/\\/g, '\\\\')}")
|
|
175
|
+
$Shortcut.TargetPath = "${targetPath.replace(/\\/g, '\\\\')}"
|
|
176
|
+
$Shortcut.WorkingDirectory = "${installDir.replace(/\\/g, '\\\\')}"
|
|
177
|
+
$Shortcut.Description = "42cc - Claude Code 模型配置工具"
|
|
178
|
+
$Shortcut.Save()
|
|
179
|
+
`;
|
|
180
|
+
|
|
181
|
+
execSync(`powershell -Command "${psScript}"`, { stdio: 'ignore' });
|
|
182
|
+
log('+ 已添加到开始菜单', 'green');
|
|
183
|
+
} catch (e) {
|
|
184
|
+
log('x 创建开始菜单快捷方式失败,可手动创建', 'yellow');
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// 直接运行应用
|
|
188
|
+
log('\n3. 启动应用...', 'blue');
|
|
189
|
+
try {
|
|
190
|
+
execSync(`start "" "${targetPath}"`, { stdio: 'ignore' });
|
|
191
|
+
|
|
192
|
+
log('\n+ 安装完成', 'green');
|
|
193
|
+
log('=====================================', 'blue');
|
|
194
|
+
log('');
|
|
195
|
+
log('+ 安装位置: ' + installDir, 'green');
|
|
196
|
+
log('+ 应用已启动并显示在系统托盘', 'green');
|
|
197
|
+
log('+ 下次可从开始菜单搜索 "42cc" 启动', 'green');
|
|
198
|
+
log('');
|
|
199
|
+
log('=====================================\n', 'blue');
|
|
200
|
+
} catch (e) {
|
|
201
|
+
log('\n+ 安装完成', 'green');
|
|
202
|
+
log('=====================================', 'blue');
|
|
203
|
+
log('');
|
|
204
|
+
log('+ 安装位置: ' + installDir, 'green');
|
|
205
|
+
log('+ 可从开始菜单搜索 "42cc" 启动', 'green');
|
|
206
|
+
log('x 自动启动失败,请手动打开', 'yellow');
|
|
207
|
+
log('');
|
|
208
|
+
log('=====================================\n', 'blue');
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return true;
|
|
212
|
+
} catch (error) {
|
|
213
|
+
log(`\n安装失败: ${error.message}`, 'red');
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
async function install() {
|
|
219
|
+
try {
|
|
220
|
+
log('\n42cc 安装程序', 'blue');
|
|
221
|
+
log('================\n', 'blue');
|
|
222
|
+
|
|
223
|
+
const platform = getPlatform();
|
|
224
|
+
log(`平台: ${platform}`, 'green');
|
|
225
|
+
log(`版本: ${APP_VERSION}`, 'green');
|
|
226
|
+
|
|
227
|
+
let success = false;
|
|
228
|
+
if (platform === 'macos') {
|
|
229
|
+
success = await autoInstallMacOS();
|
|
230
|
+
} else {
|
|
231
|
+
success = await autoInstallWindows();
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (success) {
|
|
235
|
+
saveInstalledVersion(APP_VERSION);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
log('\n更多信息: https://42ailab.com\n', 'blue');
|
|
239
|
+
|
|
240
|
+
} catch (error) {
|
|
241
|
+
log(`\n错误: ${error.message}`, 'red');
|
|
242
|
+
log('\n如需帮助,请访问: https://cnb.cool/42ailab/42plugin/meta/-/issues\n', 'yellow');
|
|
243
|
+
process.exit(1);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// 仅在 postinstall 时运行
|
|
248
|
+
if (require.main === module) {
|
|
249
|
+
install();
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
module.exports = { install };
|