Refactor code structure for improved readability and maintainability
This commit is contained in:
@@ -52,7 +52,7 @@
|
|||||||
"@kevisual/router": "^0.1.1",
|
"@kevisual/router": "^0.1.1",
|
||||||
"@kevisual/types": "^0.0.12",
|
"@kevisual/types": "^0.0.12",
|
||||||
"@kevisual/use-config": "^1.0.30",
|
"@kevisual/use-config": "^1.0.30",
|
||||||
"@opencode-ai/plugin": "^1.2.24",
|
"@opencode-ai/plugin": "^1.2.26",
|
||||||
"@types/bun": "^1.3.10",
|
"@types/bun": "^1.3.10",
|
||||||
"@types/node": "^25.5.0",
|
"@types/node": "^25.5.0",
|
||||||
"@types/send": "^1.2.1",
|
"@types/send": "^1.2.1",
|
||||||
@@ -77,15 +77,15 @@
|
|||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aws-sdk/client-s3": "^3.1008.0",
|
"@aws-sdk/client-s3": "^3.1009.0",
|
||||||
"@kevisual/js-filter": "^0.0.6",
|
"@kevisual/js-filter": "^0.0.6",
|
||||||
"@kevisual/oss": "^0.0.20",
|
"@kevisual/oss": "^0.0.20",
|
||||||
"@kevisual/video-tools": "^0.0.13",
|
"@kevisual/video-tools": "^0.0.13",
|
||||||
"@opencode-ai/sdk": "^1.2.24",
|
"@opencode-ai/sdk": "^1.2.26",
|
||||||
"es-toolkit": "^1.45.1",
|
"es-toolkit": "^1.45.1",
|
||||||
"eventemitter3": "^5.0.4",
|
"eventemitter3": "^5.0.4",
|
||||||
"lowdb": "^7.0.1",
|
"lowdb": "^7.0.1",
|
||||||
"lru-cache": "^11.2.6",
|
"lru-cache": "^11.2.7",
|
||||||
"pm2": "^6.0.14",
|
"pm2": "^6.0.14",
|
||||||
"unstorage": "^1.17.4",
|
"unstorage": "^1.17.4",
|
||||||
"zod": "^4.3.6"
|
"zod": "^4.3.6"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@kevisual/cli",
|
"name": "@kevisual/cli",
|
||||||
"version": "0.1.24",
|
"version": "0.1.25",
|
||||||
"description": "envision 命令行工具",
|
"description": "envision 命令行工具",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"basename": "/root/cli",
|
"basename": "/root/cli",
|
||||||
@@ -47,13 +47,13 @@
|
|||||||
"@kevisual/context": "^0.0.8",
|
"@kevisual/context": "^0.0.8",
|
||||||
"@kevisual/router": "^0.1.1",
|
"@kevisual/router": "^0.1.1",
|
||||||
"@kevisual/use-config": "^1.0.30",
|
"@kevisual/use-config": "^1.0.30",
|
||||||
"@opencode-ai/sdk": "^1.2.24",
|
"@opencode-ai/sdk": "^1.2.26",
|
||||||
"@types/busboy": "^1.5.4",
|
"@types/busboy": "^1.5.4",
|
||||||
"busboy": "^1.6.0",
|
"busboy": "^1.6.0",
|
||||||
"eventemitter3": "^5.0.4",
|
"eventemitter3": "^5.0.4",
|
||||||
"jose": "^6.2.1",
|
"jose": "^6.2.1",
|
||||||
"lowdb": "^7.0.1",
|
"lowdb": "^7.0.1",
|
||||||
"lru-cache": "^11.2.6",
|
"lru-cache": "^11.2.7",
|
||||||
"micromatch": "^4.0.8",
|
"micromatch": "^4.0.8",
|
||||||
"nanoid": "^5.1.6",
|
"nanoid": "^5.1.6",
|
||||||
"pm2": "latest",
|
"pm2": "latest",
|
||||||
@@ -62,7 +62,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@kevisual/api": "^0.0.64",
|
"@kevisual/api": "^0.0.64",
|
||||||
"@kevisual/cnb": "^0.0.45",
|
"@kevisual/cnb": "^0.0.46",
|
||||||
"@kevisual/dts": "^0.0.4",
|
"@kevisual/dts": "^0.0.4",
|
||||||
"@kevisual/load": "^0.0.6",
|
"@kevisual/load": "^0.0.6",
|
||||||
"@kevisual/logger": "^0.0.4",
|
"@kevisual/logger": "^0.0.4",
|
||||||
|
|||||||
4982
pnpm-lock.yaml
generated
Normal file
4982
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -14,53 +14,14 @@ const parseIfJson = (str: string) => {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const command = new Command('npm').description('npm command show publish and set .npmrc').action(async (options) => { });
|
const publishRegistry = (options: { execPath: string, registry: string, tag?: string, config: any, env: any }) => {
|
||||||
const publish = new Command('publish')
|
const packageJson = path.resolve(options.execPath, 'package.json');
|
||||||
.argument('[registry]')
|
|
||||||
.option('-p --proxy', 'proxy')
|
|
||||||
.option('-t, --tag', 'tag')
|
|
||||||
.description('publish npm')
|
|
||||||
.action(async (registry, options) => {
|
|
||||||
if (!registry) {
|
|
||||||
registry = await select({
|
|
||||||
message: 'Select the registry to publish',
|
|
||||||
choices: [
|
|
||||||
{
|
|
||||||
name: 'me',
|
|
||||||
value: 'me',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'npm',
|
|
||||||
value: 'npm',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'cnb',
|
|
||||||
value: 'cnb'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
const config = getConfig();
|
|
||||||
let cmd = '';
|
let cmd = '';
|
||||||
const execPath = process.cwd();
|
const config = options.config || {};
|
||||||
let setEnv = {};
|
const execPath = options.execPath;
|
||||||
const proxyEnv = {
|
const registry = options.registry;
|
||||||
https_proxy: 'http://127.0.0.1:7890',
|
const setEnv = options.env || {};
|
||||||
http_proxy: 'http://127.0.0.1:7890',
|
|
||||||
all_proxy: 'socks5://127.0.0.1:7890',
|
|
||||||
...config?.proxy,
|
|
||||||
};
|
|
||||||
if (options?.proxy) {
|
|
||||||
setEnv = {
|
|
||||||
...proxyEnv,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (registry) {
|
|
||||||
const packageJson = path.resolve(execPath, 'package.json');
|
|
||||||
switch (registry) {
|
switch (registry) {
|
||||||
case 'me':
|
|
||||||
cmd = 'npm publish -s --registry https://npm.xiongxiao.me';
|
|
||||||
break;
|
|
||||||
case 'npm':
|
case 'npm':
|
||||||
cmd = 'npm publish -s --registry https://registry.npmjs.org';
|
cmd = 'npm publish -s --registry https://registry.npmjs.org';
|
||||||
break;
|
break;
|
||||||
@@ -68,7 +29,7 @@ const publish = new Command('publish')
|
|||||||
cmd = 'npm publish -s --registry https://npm.cnb.cool/kevisual/registry/-/packages/';
|
cmd = 'npm publish -s --registry https://npm.cnb.cool/kevisual/registry/-/packages/';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
cmd = 'npm publish -s --registry https://npm.xiongxiao.me';
|
cmd = 'npm publish -s --registry https://registry.npmjs.org';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (fileIsExist(packageJson)) {
|
if (fileIsExist(packageJson)) {
|
||||||
@@ -119,6 +80,57 @@ const publish = new Command('publish')
|
|||||||
} else {
|
} else {
|
||||||
console.error(chalk.red('package.json not found'));
|
console.error(chalk.red('package.json not found'));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
const command = new Command('npm').description('npm command show publish and set .npmrc').action(async (options) => { });
|
||||||
|
const publish = new Command('publish')
|
||||||
|
.argument('[registry]')
|
||||||
|
.option('-p --proxy', 'proxy')
|
||||||
|
.option('-t, --tag', 'tag')
|
||||||
|
.option('-u, --update', 'update new version')
|
||||||
|
.description('publish npm')
|
||||||
|
.action(async (registry, options) => {
|
||||||
|
if (!registry) {
|
||||||
|
registry = await select({
|
||||||
|
message: 'Select the registry to publish',
|
||||||
|
choices: [
|
||||||
|
{
|
||||||
|
name: 'all',
|
||||||
|
value: 'all',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'npm',
|
||||||
|
value: 'npm',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'cnb',
|
||||||
|
value: 'cnb'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const config = getConfig();
|
||||||
|
const execPath = process.cwd();
|
||||||
|
let setEnv = {};
|
||||||
|
const proxyEnv = {
|
||||||
|
https_proxy: 'http://127.0.0.1:7890',
|
||||||
|
http_proxy: 'http://127.0.0.1:7890',
|
||||||
|
all_proxy: 'socks5://127.0.0.1:7890',
|
||||||
|
...config?.proxy,
|
||||||
|
};
|
||||||
|
if (options?.proxy) {
|
||||||
|
setEnv = {
|
||||||
|
...proxyEnv,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (options?.update) {
|
||||||
|
patchFunc({ directory: execPath });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (registry === 'all') {
|
||||||
|
publishRegistry({ execPath, registry: 'npm', config, env: setEnv });
|
||||||
|
publishRegistry({ execPath, registry: 'cnb', config, env: setEnv });
|
||||||
|
} else {
|
||||||
|
publishRegistry({ execPath, registry, tag: options?.tag, config, env: setEnv });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -142,8 +154,7 @@ const npmrc = new Command('set')
|
|||||||
const config = getConfig();
|
const config = getConfig();
|
||||||
const npmrcContent =
|
const npmrcContent =
|
||||||
config?.npmrc ||
|
config?.npmrc ||
|
||||||
`//npm.xiongxiao.me/:_authToken=\${ME_NPM_TOKEN}
|
`/npm.cnb.cool/kevisual/registry/-/packages/:_authToken=\${CNB_API_KEY}
|
||||||
//npm.cnb.cool/kevisual/registry/-/packages/:_authToken=\${CNB_API_KEY}
|
|
||||||
//registry.npmjs.org/:_authToken=\${NPM_TOKEN}
|
//registry.npmjs.org/:_authToken=\${NPM_TOKEN}
|
||||||
`;
|
`;
|
||||||
const execPath = process.cwd();
|
const execPath = process.cwd();
|
||||||
@@ -210,9 +221,8 @@ const install = new Command('install')
|
|||||||
});
|
});
|
||||||
command.addCommand(install);
|
command.addCommand(install);
|
||||||
|
|
||||||
// npm patch
|
const patchFunc = (opts?: { directory?: string }) => {
|
||||||
const patch = new Command('patch').description('npm patch 发布补丁版本').action(async () => {
|
const cwd = opts?.directory || process.cwd();
|
||||||
const cwd = process.cwd();
|
|
||||||
const packageJson = path.resolve(cwd, 'package.json');
|
const packageJson = path.resolve(cwd, 'package.json');
|
||||||
if (fileIsExist(packageJson)) {
|
if (fileIsExist(packageJson)) {
|
||||||
const pkg = fs.readFileSync(packageJson, 'utf-8');
|
const pkg = fs.readFileSync(packageJson, 'utf-8');
|
||||||
@@ -229,6 +239,10 @@ const patch = new Command('patch').description('npm patch 发布补丁版本').a
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// npm patch
|
||||||
|
const patch = new Command('patch').description('npm patch 发布补丁版本').action(async () => {
|
||||||
|
patchFunc();
|
||||||
});
|
});
|
||||||
command.addCommand(patch);
|
command.addCommand(patch);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user