Add self-update command and fix hash mismatch after pull
- kisync update: show available releases from Gitea - kisync update --apply: download and replace exe in-place - Background update check after every command (non-blocking) - Fix: compute hash from disk-read object (not server object) to prevent false "modified" status after pull due to line-ending differences Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
34
src/index.ts
34
src/index.ts
@@ -6,13 +6,16 @@ import { initCommand } from './commands/init';
|
||||
import { pullCommand } from './commands/pull';
|
||||
import { pushCommand } from './commands/push';
|
||||
import { statusCommand } from './commands/status';
|
||||
import { updateCommand, updateApplyCommand, checkForUpdateBackground } from './commands/update';
|
||||
|
||||
const VERSION = '1.0.0';
|
||||
|
||||
const program = new Command();
|
||||
|
||||
program
|
||||
.name('kisync')
|
||||
.description('CLI tool for syncing local folders with KIS API Builder')
|
||||
.version('1.0.0');
|
||||
.version(VERSION);
|
||||
|
||||
program
|
||||
.command('init')
|
||||
@@ -20,8 +23,9 @@ program
|
||||
.action(async () => {
|
||||
try {
|
||||
await initCommand();
|
||||
await checkForUpdateBackground(VERSION);
|
||||
} catch (err: any) {
|
||||
console.error(chalk.red(`Error: ${err.message}`));
|
||||
console.error(chalk.red(`Ошибка: ${err.message}`));
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
@@ -33,8 +37,9 @@ program
|
||||
.action(async (opts) => {
|
||||
try {
|
||||
await pullCommand(opts.force);
|
||||
await checkForUpdateBackground(VERSION);
|
||||
} catch (err: any) {
|
||||
console.error(chalk.red(`Error: ${err.message}`));
|
||||
console.error(chalk.red(`Ошибка: ${err.message}`));
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
@@ -46,8 +51,9 @@ program
|
||||
.action(async (opts) => {
|
||||
try {
|
||||
await pushCommand(opts.force);
|
||||
await checkForUpdateBackground(VERSION);
|
||||
} catch (err: any) {
|
||||
console.error(chalk.red(`Error: ${err.message}`));
|
||||
console.error(chalk.red(`Ошибка: ${err.message}`));
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
@@ -58,8 +64,26 @@ program
|
||||
.action(async () => {
|
||||
try {
|
||||
await statusCommand();
|
||||
await checkForUpdateBackground(VERSION);
|
||||
} catch (err: any) {
|
||||
console.error(chalk.red(`Error: ${err.message}`));
|
||||
console.error(chalk.red(`Ошибка: ${err.message}`));
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
|
||||
program
|
||||
.command('update')
|
||||
.description('Проверить обновления и обновить kisync')
|
||||
.option('--apply', 'Скачать и установить обновление')
|
||||
.action(async (opts) => {
|
||||
try {
|
||||
if (opts.apply) {
|
||||
await updateApplyCommand(VERSION);
|
||||
} else {
|
||||
await updateCommand(VERSION);
|
||||
}
|
||||
} catch (err: any) {
|
||||
console.error(chalk.red(`Ошибка: ${err.message}`));
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user