feat: clear rollup
This commit is contained in:
@@ -3,14 +3,27 @@ import { getConfig, writeConfig } from '@/module/index.ts';
|
||||
import { queryLogin, storage } from '@/module/query.ts';
|
||||
import inquirer from 'inquirer';
|
||||
import util from 'util';
|
||||
|
||||
function isNumeric(str: string) {
|
||||
return /^-?\d+\.?\d*$/.test(str);
|
||||
}
|
||||
const showList = (list: string[]) => {
|
||||
if (list.length === 0) {
|
||||
console.log('expand baseURLList is empty');
|
||||
return;
|
||||
}
|
||||
const config = getConfig();
|
||||
console.log('----current baseURL:' + config.baseURL + '----\n');
|
||||
list.forEach((item, index) => {
|
||||
console.log(`${index + 1}: ${item}`);
|
||||
});
|
||||
};
|
||||
const token = new Command('token')
|
||||
.option('-e, --env', 'show token in env')
|
||||
.description('show token')
|
||||
.action(async (opts) => {
|
||||
const token = storage.getItem('token');
|
||||
if (opts.env) {
|
||||
console.log('token', process.env.KEVISUAL_TOKEN);
|
||||
console.log('token in env', process.env.KEVISUAL_TOKEN);
|
||||
} else {
|
||||
console.log('token', token);
|
||||
}
|
||||
@@ -30,7 +43,6 @@ app.addCommand(token);
|
||||
|
||||
const baseURL = new Command('baseURL')
|
||||
.alias('base')
|
||||
.alias('registry')
|
||||
.description('show baseURL')
|
||||
.option('-a, --add <baseURL>', 'add baseURL')
|
||||
.option('-r, --remove <number>', 'remove baseURL number')
|
||||
@@ -49,20 +61,7 @@ const baseURL = new Command('baseURL')
|
||||
const newList = new Set(list);
|
||||
return Array.from(newList);
|
||||
};
|
||||
const showList = (list: string[]) => {
|
||||
if (list.length === 0) {
|
||||
console.log('expand baseURLList is empty');
|
||||
return;
|
||||
}
|
||||
const config = getConfig();
|
||||
console.log('----current baseURL:' + config.baseURL + '----\n');
|
||||
list.forEach((item, index) => {
|
||||
console.log(`${index + 1}: ${item}`);
|
||||
});
|
||||
};
|
||||
function isNumeric(str: string) {
|
||||
return /^-?\d+\.?\d*$/.test(str);
|
||||
}
|
||||
|
||||
if (opts.add || opts.set) {
|
||||
let change = false;
|
||||
if (opts.add) {
|
||||
@@ -132,12 +131,10 @@ app.addCommand(baseURL);
|
||||
|
||||
const setBaseURL = new Command('set')
|
||||
.option('-b, --baseURL <baseURL>', 'set baseURL')
|
||||
// .argument('<baseURL>', 'set baseURL', '')
|
||||
.description('set baseURL')
|
||||
.action(async (opt) => {
|
||||
const config = getConfig();
|
||||
let baseURL = opt.baseURL;
|
||||
// let baseURL = opt;
|
||||
if (!baseURL) {
|
||||
const answers = await inquirer.prompt([
|
||||
{
|
||||
@@ -147,6 +144,10 @@ const setBaseURL = new Command('set')
|
||||
},
|
||||
]);
|
||||
baseURL = answers.baseURL;
|
||||
if (!baseURL) {
|
||||
console.log('baseURL is required');
|
||||
return;
|
||||
}
|
||||
}
|
||||
writeConfig({ ...config, baseURL });
|
||||
});
|
||||
@@ -158,3 +159,44 @@ baseURL.addCommand(setBaseURL);
|
||||
// });
|
||||
|
||||
// app.addCommand(showQueryURL);
|
||||
|
||||
const rvm = new Command('registry')
|
||||
.alias('reg')
|
||||
.description('registry manager')
|
||||
.option('-l, --list', 'list registry')
|
||||
.option('-s, --set <registry>', 'set registry')
|
||||
.action(async (opts) => {
|
||||
const config = getConfig();
|
||||
const defaultRegistry = ['https://kevisual.cn', 'https://kevisual.silkyai.cn', 'https://kevisual.xiongxiao.me'];
|
||||
if (opts.list) {
|
||||
showList(defaultRegistry);
|
||||
return;
|
||||
}
|
||||
if (opts.set) {
|
||||
const isNumber = isNumeric(opts.set);
|
||||
if (isNumber) {
|
||||
const index = Number(opts.set) - 1;
|
||||
if (index < 0 || index >= defaultRegistry.length) {
|
||||
console.log('index out of range');
|
||||
return;
|
||||
}
|
||||
writeConfig({ ...config, baseURL: defaultRegistry[index] });
|
||||
console.log('set registry', defaultRegistry[index]);
|
||||
} else {
|
||||
writeConfig({ ...config, baseURL: opts.set });
|
||||
console.log('set registry', opts.set);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
app.addCommand(rvm);
|
||||
|
||||
const silky = new Command('silky').description('silky registry').action(async (opts) => {
|
||||
console.log('silky registry');
|
||||
const config = getConfig();
|
||||
const defaultRegistry = ['https://kevisual.silkyai.cn'];
|
||||
writeConfig({ ...config, baseURL: defaultRegistry[0] });
|
||||
showList(defaultRegistry);
|
||||
});
|
||||
|
||||
app.addCommand(silky);
|
||||
|
||||
Reference in New Issue
Block a user