aicodeswitch 1.2.3 → 1.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/bin/update.js +38 -0
- package/package.json +1 -1
package/bin/update.js
CHANGED
|
@@ -161,6 +161,29 @@ const extractTarball = (tarballPath, destDir) => {
|
|
|
161
161
|
});
|
|
162
162
|
};
|
|
163
163
|
|
|
164
|
+
// 安装 npm 依赖
|
|
165
|
+
const installDependencies = (dir) => {
|
|
166
|
+
return new Promise((resolve, reject) => {
|
|
167
|
+
console.log(chalk.cyan('Installing dependencies...'));
|
|
168
|
+
|
|
169
|
+
const installProcess = spawn('npm', ['install', '--production'], {
|
|
170
|
+
cwd: dir,
|
|
171
|
+
stdio: 'inherit'
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
installProcess.on('close', (code) => {
|
|
175
|
+
if (code === 0) {
|
|
176
|
+
console.log(chalk.green('Dependencies installed successfully'));
|
|
177
|
+
resolve();
|
|
178
|
+
} else {
|
|
179
|
+
reject(new Error(`npm install failed with exit code ${code}`));
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
installProcess.on('error', reject);
|
|
184
|
+
});
|
|
185
|
+
};
|
|
186
|
+
|
|
164
187
|
// 更新 current 文件
|
|
165
188
|
const updateCurrentFile = (versionPath) => {
|
|
166
189
|
fs.writeFileSync(CURRENT_FILE, versionPath);
|
|
@@ -289,6 +312,21 @@ const update = async () => {
|
|
|
289
312
|
}
|
|
290
313
|
}
|
|
291
314
|
|
|
315
|
+
// 安装依赖
|
|
316
|
+
const installSpinner = ora({
|
|
317
|
+
text: chalk.cyan('Installing dependencies...'),
|
|
318
|
+
color: 'cyan'
|
|
319
|
+
}).start();
|
|
320
|
+
|
|
321
|
+
try {
|
|
322
|
+
await installDependencies(versionDir);
|
|
323
|
+
installSpinner.succeed(chalk.green('Dependencies installed'));
|
|
324
|
+
} catch (err) {
|
|
325
|
+
installSpinner.fail(chalk.red('Dependencies installation failed'));
|
|
326
|
+
console.log(chalk.red(`Error: ${err.message}\n`));
|
|
327
|
+
process.exit(1);
|
|
328
|
+
}
|
|
329
|
+
|
|
292
330
|
// 更新 current 文件
|
|
293
331
|
updateCurrentFile(versionDir);
|
|
294
332
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aicodeswitch",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"description": "A tool to help you manage AI programming tools to access large language models locally. It allows your Claude Code, Codex and other tools to no longer be limited to official models.",
|
|
5
5
|
"author": "tangshuang",
|
|
6
6
|
"license": "MIT",
|