feat: 添加上传和列出命令的本地文件选项

This commit is contained in:
2026-03-12 14:51:34 +08:00
parent 3243baa872
commit 9df4021d68
2 changed files with 16 additions and 2 deletions

View File

@@ -20,7 +20,13 @@ const checkAuth = (value: string = '', baseURL: string = '') => {
};
const DEFAULT_IGNORE = [
'node_modules/**', '.git/**', '.next/**', '.astro/**', '.pack-dist/**',
'node_modules/**',
'.git/**',
'.next/**',
'.astro/**',
'.pack-dist/**',
"dist/**",
".swc/**"
];
export class SyncBase {
config: Config;

View File

@@ -20,9 +20,11 @@ const syncUpload = new Command('upload')
.option('-d --dir <dir>', '配置目录')
.option('-c --config <config>', '配置文件的名字', 'kevisual.json')
.option('-f --file <file>', '操作的对应的文件名')
.option('-l --list', '显示上传列表,不上传文件')
.description('上传项目, 上传需要和registry的地址同步。')
.action(async (opts) => {
console.log('上传项目');
const isUpload = opts.list ? false : true;
const sync = new SyncBase({ dir: opts.dir, baseURL: baseURL, configFilename: opts.config });
const syncList = await sync.getSyncList({ getFile: true });
logger.debug(syncList);
@@ -58,6 +60,10 @@ const syncUpload = new Command('upload')
if (filepath && item.filepath !== filepath.absolute) {
continue;
}
if (!isUpload) {
console.log('上传列表', item.key, chalk.green(item.url));
continue
}
const res = await upload({
token,
file: fs.readFileSync(item.filepath),
@@ -127,10 +133,12 @@ const syncList = new Command('list')
.option('-d --dir <dir>', '配置目录')
.option('-c --config <config>', '配置文件的名字', 'kevisual.json')
.option('-a --all', '显示所有的文件')
.option('-l --local', '显示本地的文件列表')
.description('列出同步列表')
.action(async (opts) => {
const sync = new SyncBase({ dir: opts.dir, baseURL: baseURL, configFilename: opts.config });
const syncList = await sync.getSyncList();
let getLocalFile = opts?.local ? true : false;
const syncList = await sync.getSyncList({ getFile: true, getLocalFile });
logger.debug(syncList);
logger.info('同步列表\n');
syncList.forEach((item) => {