feat: 添加上传和列出命令的本地文件选项
This commit is contained in:
@@ -20,7 +20,13 @@ const checkAuth = (value: string = '', baseURL: string = '') => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const DEFAULT_IGNORE = [
|
const DEFAULT_IGNORE = [
|
||||||
'node_modules/**', '.git/**', '.next/**', '.astro/**', '.pack-dist/**',
|
'node_modules/**',
|
||||||
|
'.git/**',
|
||||||
|
'.next/**',
|
||||||
|
'.astro/**',
|
||||||
|
'.pack-dist/**',
|
||||||
|
"dist/**",
|
||||||
|
".swc/**"
|
||||||
];
|
];
|
||||||
export class SyncBase {
|
export class SyncBase {
|
||||||
config: Config;
|
config: Config;
|
||||||
|
|||||||
@@ -20,9 +20,11 @@ const syncUpload = new Command('upload')
|
|||||||
.option('-d --dir <dir>', '配置目录')
|
.option('-d --dir <dir>', '配置目录')
|
||||||
.option('-c --config <config>', '配置文件的名字', 'kevisual.json')
|
.option('-c --config <config>', '配置文件的名字', 'kevisual.json')
|
||||||
.option('-f --file <file>', '操作的对应的文件名')
|
.option('-f --file <file>', '操作的对应的文件名')
|
||||||
|
.option('-l --list', '显示上传列表,不上传文件')
|
||||||
.description('上传项目, 上传需要和registry的地址同步。')
|
.description('上传项目, 上传需要和registry的地址同步。')
|
||||||
.action(async (opts) => {
|
.action(async (opts) => {
|
||||||
console.log('上传项目');
|
console.log('上传项目');
|
||||||
|
const isUpload = opts.list ? false : true;
|
||||||
const sync = new SyncBase({ dir: opts.dir, baseURL: baseURL, configFilename: opts.config });
|
const sync = new SyncBase({ dir: opts.dir, baseURL: baseURL, configFilename: opts.config });
|
||||||
const syncList = await sync.getSyncList({ getFile: true });
|
const syncList = await sync.getSyncList({ getFile: true });
|
||||||
logger.debug(syncList);
|
logger.debug(syncList);
|
||||||
@@ -58,6 +60,10 @@ const syncUpload = new Command('upload')
|
|||||||
if (filepath && item.filepath !== filepath.absolute) {
|
if (filepath && item.filepath !== filepath.absolute) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (!isUpload) {
|
||||||
|
console.log('上传列表', item.key, chalk.green(item.url));
|
||||||
|
continue
|
||||||
|
}
|
||||||
const res = await upload({
|
const res = await upload({
|
||||||
token,
|
token,
|
||||||
file: fs.readFileSync(item.filepath),
|
file: fs.readFileSync(item.filepath),
|
||||||
@@ -127,10 +133,12 @@ const syncList = new Command('list')
|
|||||||
.option('-d --dir <dir>', '配置目录')
|
.option('-d --dir <dir>', '配置目录')
|
||||||
.option('-c --config <config>', '配置文件的名字', 'kevisual.json')
|
.option('-c --config <config>', '配置文件的名字', 'kevisual.json')
|
||||||
.option('-a --all', '显示所有的文件')
|
.option('-a --all', '显示所有的文件')
|
||||||
|
.option('-l --local', '显示本地的文件列表')
|
||||||
.description('列出同步列表')
|
.description('列出同步列表')
|
||||||
.action(async (opts) => {
|
.action(async (opts) => {
|
||||||
const sync = new SyncBase({ dir: opts.dir, baseURL: baseURL, configFilename: opts.config });
|
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.debug(syncList);
|
||||||
logger.info('同步列表\n');
|
logger.info('同步列表\n');
|
||||||
syncList.forEach((item) => {
|
syncList.forEach((item) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user