fix: fix sync add config file name

This commit is contained in:
2025-05-13 02:10:18 +08:00
parent 785bd7b004
commit f26bc59e29
3 changed files with 47 additions and 7 deletions

View File

@@ -16,10 +16,11 @@ const command = new Command('sync')
const syncUpload = new Command('upload')
.option('-d --dir <dir>', '配置目录')
.option('-s --share <share>', '共享设置')
.option('-c --config <config>', '配置文件的名字', 'kevisual.json')
.description('上传项目')
.action(async (opts) => {
console.log('上传项目');
const sync = new SyncBase({ baseURL: baseURL });
const sync = new SyncBase({ dir: opts.dir, baseURL: baseURL, configFilename: opts.config });
const syncList = await sync.getSyncList({ getFile: true });
logger.debug(syncList);
const nodonwArr: (typeof syncList)[number][] = [];
@@ -48,7 +49,13 @@ const syncUpload = new Command('upload')
meta,
});
if (res.code === 200) {
logger.info('上传成功', item.key, chalk.green(item.url));
if (res.data?.isNew) {
logger.info('上传成功', item.key, chalk.green(item.url), chalk.green('文件上传'));
} else if (res.data?.isNewMeta) {
logger.info('上传成功', item.key, chalk.green(item.url), chalk.green('元数据更新'));
} else {
logger.info('上传成功', item.key, chalk.green(item.url), chalk.blue('文件未更新'));
}
}
logger.debug(res);
}
@@ -58,9 +65,10 @@ const syncUpload = new Command('upload')
});
const syncDownload = new Command('download')
.option('-d --dir <dir>', '配置目录')
.option('-c --config <config>', '配置文件的名字', 'kevisual.json')
.description('下载项目')
.action(async () => {
const sync = new SyncBase({ baseURL: baseURL });
.action(async (opts) => {
const sync = new SyncBase({ dir: opts.dir, baseURL: baseURL, configFilename: opts.config });
const syncList = await sync.getSyncList();
logger.debug(syncList);
const nodonwArr: (typeof syncList)[number][] = [];
@@ -85,7 +93,22 @@ const syncDownload = new Command('download')
logger.warn('以下文件未下载', nodonwArr.map((item) => item.key).join(','));
}
});
const syncList = new Command('list')
.option('-d --dir <dir>', '配置目录')
.option('-c --config <config>', '配置文件的名字', 'kevisual.json')
.description('列出同步列表')
.action(async (opts) => {
const sync = new SyncBase({ dir: opts.dir, baseURL: baseURL, configFilename: opts.config });
const syncList = await sync.getSyncList();
logger.debug(syncList);
logger.info('同步列表\n');
syncList.forEach((item) => {
logger.info(chalk.blue(item.key), chalk.gray(item.type), chalk.green(item.url));
});
});
command.addCommand(syncUpload);
command.addCommand(syncDownload);
command.addCommand(syncList);
app.addCommand(command);