aicodeswitch 1.3.3 → 1.3.5
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 +6 -50
- package/package.json +1 -1
package/bin/update.js
CHANGED
|
@@ -130,29 +130,6 @@ const needsSudo = () => {
|
|
|
130
130
|
return false;
|
|
131
131
|
};
|
|
132
132
|
|
|
133
|
-
// 停止服务器
|
|
134
|
-
const stopServer = async () => {
|
|
135
|
-
const stopPath = path.join(__dirname, 'stop.js');
|
|
136
|
-
try {
|
|
137
|
-
await execCommand('node', [stopPath], { silent: true });
|
|
138
|
-
return true;
|
|
139
|
-
} catch (err) {
|
|
140
|
-
// 停止失败可能是因为服务未运行,这不是致命错误
|
|
141
|
-
return false;
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
// 启动服务器
|
|
146
|
-
const startServer = async () => {
|
|
147
|
-
const startPath = path.join(__dirname, 'start.js');
|
|
148
|
-
try {
|
|
149
|
-
await execCommand('node', [startPath], { silent: true });
|
|
150
|
-
return true;
|
|
151
|
-
} catch (err) {
|
|
152
|
-
return false;
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
|
|
156
133
|
// 比较版本号
|
|
157
134
|
const compareVersions = (v1, v2) => {
|
|
158
135
|
const parts1 = v1.split('.').map(Number);
|
|
@@ -253,38 +230,23 @@ const update = async () => {
|
|
|
253
230
|
console.log(chalk.gray('If prompted, please enter your password.\n'));
|
|
254
231
|
}
|
|
255
232
|
|
|
256
|
-
// 停止服务器
|
|
257
|
-
const stopSpinner = ora({
|
|
258
|
-
text: chalk.cyan('Stopping server...'),
|
|
259
|
-
color: 'cyan'
|
|
260
|
-
}).start();
|
|
261
|
-
|
|
262
|
-
await stopServer();
|
|
263
|
-
stopSpinner.succeed(chalk.green('Server stopped'));
|
|
264
|
-
|
|
265
233
|
// 执行更新
|
|
266
234
|
const updateSpinner = ora({
|
|
267
235
|
text: chalk.cyan('Updating to latest version...'),
|
|
268
236
|
color: 'cyan'
|
|
269
237
|
}).start();
|
|
270
238
|
|
|
271
|
-
const
|
|
272
|
-
|
|
273
|
-
npmArgs.unshift('sudo');
|
|
274
|
-
}
|
|
239
|
+
const npmCommand = needSudo ? 'sudo' : 'npm';
|
|
240
|
+
const npmArgs = needSudo ? ['npm', 'install', '-g', `${PACKAGE_NAME}@latest`] : ['install', '-g', `${PACKAGE_NAME}@latest`];
|
|
275
241
|
|
|
276
242
|
try {
|
|
277
|
-
await execCommand(npmArgs);
|
|
243
|
+
await execCommand(npmCommand, npmArgs);
|
|
278
244
|
updateSpinner.succeed(chalk.green('Update successful!'));
|
|
279
245
|
} catch (err) {
|
|
280
246
|
updateSpinner.fail(chalk.red('Update failed'));
|
|
281
247
|
console.log(chalk.yellow(`\nUpdate failed with error code ${err.code || 'unknown'}\n`));
|
|
282
248
|
console.log(chalk.white('You can try manually updating:\n'));
|
|
283
|
-
console.log(chalk.cyan(` ${npmArgs.join(' ')}\n`));
|
|
284
|
-
|
|
285
|
-
// 尝试重新启动服务器
|
|
286
|
-
console.log(chalk.yellow('Attempting to restart server...\n'));
|
|
287
|
-
await startServer();
|
|
249
|
+
console.log(chalk.cyan(` ${npmCommand} ${npmArgs.join(' ')}\n`));
|
|
288
250
|
process.exit(1);
|
|
289
251
|
}
|
|
290
252
|
|
|
@@ -292,8 +254,7 @@ const update = async () => {
|
|
|
292
254
|
console.log(boxen(
|
|
293
255
|
chalk.green.bold('✓ Successfully updated!\n\n') +
|
|
294
256
|
chalk.white('Previous version: ') + chalk.gray(currentVersion) + '\n' +
|
|
295
|
-
chalk.white('New version: ') + chalk.green.bold(latestVersion)
|
|
296
|
-
chalk.gray('Starting server...'),
|
|
257
|
+
chalk.white('New version: ') + chalk.green.bold(latestVersion),
|
|
297
258
|
{
|
|
298
259
|
padding: 1,
|
|
299
260
|
margin: 1,
|
|
@@ -301,15 +262,10 @@ const update = async () => {
|
|
|
301
262
|
borderColor: 'green'
|
|
302
263
|
}
|
|
303
264
|
));
|
|
304
|
-
console.log('');
|
|
305
|
-
|
|
306
|
-
// 启动服务器
|
|
307
|
-
await startServer();
|
|
308
|
-
|
|
309
265
|
console.log('');
|
|
310
266
|
console.log(chalk.cyan('💡 Tips:\n'));
|
|
267
|
+
console.log(chalk.white(' • Restart server: ') + chalk.cyan('aicos restart'));
|
|
311
268
|
console.log(chalk.white(' • Check version: ') + chalk.cyan('aicos version'));
|
|
312
|
-
console.log(chalk.white(' • View logs: ') + chalk.gray('tail -f ~/.aicodeswitch/server.log'));
|
|
313
269
|
console.log('\n');
|
|
314
270
|
};
|
|
315
271
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aicodeswitch",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.5",
|
|
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": "GPL-3.0",
|