diff --git a/assistant/tasks/silkyai-cli/src/mdoules/talkshow.ts b/assistant/tasks/silkyai-cli/src/mdoules/talkshow.ts
index 10e5694..16380b0 100644
--- a/assistant/tasks/silkyai-cli/src/mdoules/talkshow.ts
+++ b/assistant/tasks/silkyai-cli/src/mdoules/talkshow.ts
@@ -88,29 +88,3 @@ const task3 = {
};
silkyCommand.addTask(task3);
-// ===========================
-const testTask = {
- description: '测试',
- command: 'npm i -g nodemon --registry=https://registry.npmmirror.com',
- type: 'npm-install',
- before: 'nodemon -v',
- beforeCheck: '.',
- key: 'test-task',
-};
-silkyCommand.addTask(testTask);
-
-const runTask1 = async () => {
- const tasksCommand = new TasksCommand();
- tasksCommand.addTask(init2);
- const res = tasksCommand.runTask(init2.description);
- console.log(res);
-};
-// runTask1();
-const runTestTask = async () => {
- const tasksCommand = new TasksCommand();
- tasksCommand.addTask(testTask);
- const res = tasksCommand.runTask(testTask);
- console.log(res);
- return res;
-};
-// runTestTask();
diff --git a/src/command/sync/modules/base.ts b/src/command/sync/modules/base.ts
index f5a5917..e45c58e 100644
--- a/src/command/sync/modules/base.ts
+++ b/src/command/sync/modules/base.ts
@@ -47,6 +47,12 @@ export class SyncBase {
return {} as Config;
}
}
+ getRelativeFile(filename?: string) {
+ if (!filename) return false;
+ const dir = this.#dir;
+ const file = path.join(dir, filename);
+ return { relative: path.relative(dir, file), absolute: file };
+ }
async canDone(syncType: SyncConfigType, type?: SyncConfigType) {
if (syncType === 'sync') return true;
return syncType === type;
diff --git a/src/command/sync/sync.ts b/src/command/sync/sync.ts
index d2956c5..7cc1394 100644
--- a/src/command/sync/sync.ts
+++ b/src/command/sync/sync.ts
@@ -13,10 +13,12 @@ const command = new Command('sync')
.action(() => {
console.log('同步项目');
});
+
const syncUpload = new Command('upload')
.option('-d --dir
', '配置目录')
.option('-s --share ', '共享设置')
.option('-c --config ', '配置文件的名字', 'kevisual.json')
+ .option('-f --file ', '操作的对应的文件名')
.description('上传项目')
.action(async (opts) => {
console.log('上传项目');
@@ -31,6 +33,7 @@ const syncUpload = new Command('upload')
if (opts.share) {
meta.share = opts.share;
}
+ const filepath = sync.getRelativeFile(opts.file);
for (const item of syncList) {
if (!item.auth || !item.exist) {
nodonwArr.push(item);
@@ -40,6 +43,9 @@ const syncUpload = new Command('upload')
nodonwArr.push(item);
continue;
}
+ if (filepath && item.filepath !== filepath.absolute) {
+ continue;
+ }
const res = await upload({
token,
file: fs.readFileSync(item.filepath),
@@ -59,24 +65,29 @@ const syncUpload = new Command('upload')
}
logger.debug(res);
}
- if (nodonwArr.length) {
+ if (nodonwArr.length && !filepath) {
logger.warn('以下文件未上传\n', nodonwArr.map((item) => item.key).join(','));
}
});
const syncDownload = new Command('download')
.option('-d --dir ', '配置目录')
.option('-c --config ', '配置文件的名字', 'kevisual.json')
+ .option('-f --file ', '操作的对应的文件名')
.description('下载项目')
.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][] = [];
+ const filepath = sync.getRelativeFile(opts.file);
for (const item of syncList) {
if (!sync.canDone(item.type, 'download')) {
nodonwArr.push(item);
continue;
}
+ if (filepath && item.filepath !== filepath.absolute) {
+ continue;
+ }
const hash = sync.getHash(item.filepath);
const { content, status } = await fetchLink(item.url, { setToken: item.auth, returnContent: true, hash });
if (status === 200) {
@@ -89,7 +100,7 @@ const syncDownload = new Command('download')
logger.error('下载失败', item.key, chalk.red(item.url));
}
}
- if (nodonwArr.length) {
+ if (nodonwArr.length && !filepath) {
logger.warn('以下文件未下载', nodonwArr.map((item) => item.key).join(','));
}
});
@@ -106,9 +117,36 @@ const syncList = new Command('list')
logger.info(chalk.blue(item.key), chalk.gray(item.type), chalk.green(item.url));
});
});
+const syncCreateList = new Command('create')
+ .option('-d --dir ', '配置目录')
+ .option('-c --config ', '配置文件的名字', 'kevisual.json')
+ .option('-o --output