更新 CLI 版本至 0.1.33,重构构建配置,添加新的路由和中间件,增强身份验证支持

This commit is contained in:
xiongxiao
2026-03-24 17:38:37 +08:00
committed by cnb
parent b05f059aea
commit 4e2ae49372
27 changed files with 125 additions and 97 deletions

2
bin/cli.js Executable file
View File

@@ -0,0 +1,2 @@
#!/usr/bin/env bun
import '../dist/cli.js';

View File

@@ -1,19 +1,5 @@
// @ts-check import { buildWithBun } from '@kevisual/code-builder';
// https://bun.sh/docs/bundler
// @ts-ignore await buildWithBun({ naming: 'envision', entry: 'src/oldindex.ts',});
import pkg from './package.json'; await buildWithBun({ naming: 'cli', entry: 'src/cli.ts' });
// bun run src/index.ts --
const external = ['bun'];
await Bun.build({
target: 'node',
format: 'esm',
entrypoints: ['./src/oldindex.ts'],
outdir: './dist',
naming: {
entry: 'envision.js',
},
external: external,
define: {
ENVISION_VERSION: JSON.stringify(pkg.version),
},
});

View File

@@ -1,6 +1,6 @@
{ {
"name": "@kevisual/cli", "name": "@kevisual/cli",
"version": "0.1.32", "version": "0.1.33",
"description": "envision 命令行工具", "description": "envision 命令行工具",
"type": "module", "type": "module",
"basename": "/root/cli", "basename": "/root/cli",
@@ -15,6 +15,7 @@
"bin": { "bin": {
"envision": "bin/envision.js", "envision": "bin/envision.js",
"ev": "bin/envision.js", "ev": "bin/envision.js",
"ev-next": "bin/cli.js",
"assistant": "bin/assistant.js", "assistant": "bin/assistant.js",
"assistant-server": "bin/assistant-server.js", "assistant-server": "bin/assistant-server.js",
"asst": "bin/assistant.js", "asst": "bin/assistant.js",
@@ -64,6 +65,7 @@
"devDependencies": { "devDependencies": {
"@kevisual/api": "^0.0.65", "@kevisual/api": "^0.0.65",
"@kevisual/cnb": "^0.0.60", "@kevisual/cnb": "^0.0.60",
"@kevisual/code-builder": "^0.0.6",
"@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",

9
pnpm-lock.yaml generated
View File

@@ -72,6 +72,9 @@ importers:
'@kevisual/cnb': '@kevisual/cnb':
specifier: ^0.0.60 specifier: ^0.0.60
version: 0.0.60(dotenv@17.3.1)(idb-keyval@6.2.2) version: 0.0.60(dotenv@17.3.1)(idb-keyval@6.2.2)
'@kevisual/code-builder':
specifier: ^0.0.6
version: 0.0.6
'@kevisual/dts': '@kevisual/dts':
specifier: ^0.0.4 specifier: ^0.0.4
version: 0.0.4(typescript@5.9.3) version: 0.0.4(typescript@5.9.3)
@@ -640,6 +643,10 @@ packages:
resolution: {integrity: sha512-I13DKPntnneyM+o+eJ5hemIQGhaScCNPQiinaSlrxPHpsCKU8XFookjzfMA6T+D4hi0pWfZYILtXnpOHGh3k/Q==} resolution: {integrity: sha512-I13DKPntnneyM+o+eJ5hemIQGhaScCNPQiinaSlrxPHpsCKU8XFookjzfMA6T+D4hi0pWfZYILtXnpOHGh3k/Q==}
hasBin: true hasBin: true
'@kevisual/code-builder@0.0.6':
resolution: {integrity: sha512-0aqATB31/yw4k4s5/xKnfr4DKbUnx8e3Z3BmKbiXTrc+CqWiWTdlGe9bKI9dZ2Df+xNp6g11W4xM2NICNyyCCw==}
hasBin: true
'@kevisual/context@0.0.4': '@kevisual/context@0.0.4':
resolution: {integrity: sha512-HJeLeZQLU+7tCluSfOyvkgKLs0HjCZrdJlZgEgKRSa8XTwZfMAUt6J7qZTbrZAHBlPtX68EPu/PI8JMCeu3WAQ==} resolution: {integrity: sha512-HJeLeZQLU+7tCluSfOyvkgKLs0HjCZrdJlZgEgKRSa8XTwZfMAUt6J7qZTbrZAHBlPtX68EPu/PI8JMCeu3WAQ==}
@@ -3150,6 +3157,8 @@ snapshots:
- ioredis - ioredis
- uploadthing - uploadthing
'@kevisual/code-builder@0.0.6': {}
'@kevisual/context@0.0.4': {} '@kevisual/context@0.0.4': {}
'@kevisual/context@0.0.8': {} '@kevisual/context@0.0.8': {}

View File

@@ -1,7 +1,33 @@
import { app } from './app.ts' import { app } from './app.ts'
import './routes/login.ts' // 导入所有路由模块
import './routes/app.ts';
import './routes/cc.ts';
import './routes/ccc.ts';
import './routes/config.ts';
import './routes/deploy.ts';
import './routes/docker.ts';
import './routes/download.ts';
import './routes/gist.ts';
import './routes/jwks.ts';
import './routes/login.ts';
import './routes/npm.ts';
import './routes/proxy.ts';
import './routes/publish.ts';
import './routes/remote-config.ts';
import './routes/remote-secret.ts';
import './routes/sync.ts';
import './routes/token-ls.ts';
import './routes/update.ts';
export { app };
app.createAuth(() => { }) app.createAuth(() => { })
app.createRouteList() app.createRouteList()
export const runApp = async (msg: {
path: string,
key?: string,
payload: any
}) => {
return await app.run(msg);
}
export { app };

View File

@@ -4,7 +4,7 @@ import { useContextKey } from '@kevisual/context'
// 将多个子命令加入主程序中 // 将多个子命令加入主程序中
const version = useContextKey('version', () => { const version = useContextKey('version', () => {
let version = '0.0.64'; let version = '0.1.33';
try { try {
// @ts-ignore // @ts-ignore
if (ENVISION_VERSION) version = ENVISION_VERSION; if (ENVISION_VERSION) version = ENVISION_VERSION;

View File

@@ -1,45 +0,0 @@
import { app } from '../app.ts';
import { app as aiApp } from '../ai/index.ts';
import { z } from 'zod';
import { chalk } from '@/module/chalk.ts';
import { logger } from '@/module/logger.ts';
const runCmd = async (cmd: string) => {
const res = await aiApp.router.call({ path: 'cmd-run', payload: { cmd } });
const { body } = res;
const steps = body?.steps || [];
for (const step of steps) {
logger.debug(chalk.blue(`\n==== 步骤: ${step.cmd || '结束'} ====`));
logger.debug(step.result || 'No result');
}
}
app.route({
path: 'ai',
key: 'run',
description: '执行 AI 命令',
metadata: {
args: {
cmd: z.string().optional().describe('要执行的 CMD 命令'),
}
}
}).define(async (ctx) => {
const { cmd } = ctx.args;
if (cmd) {
await runCmd(cmd);
} else {
console.log('请提供要执行的 CMD 命令');
}
}).addTo(app)
app.route({
path: 'ai',
key: 'deploy',
description: '部署 AI 后端应用',
metadata: {
args: {}
}
}).define(async () => {
const cmd = 'ev pack -p -u';
await runCmd(cmd);
}).addTo(app)

View File

@@ -14,6 +14,7 @@ app.route({
path: 'app', path: 'app',
key: 'download', key: 'download',
description: '下载 app serve client的包', description: '下载 app serve client的包',
middleware: ['auth'],
metadata: { metadata: {
args: { args: {
id: z.string().optional().describe('下载 app serve client的包, id 或者user/key'), id: z.string().optional().describe('下载 app serve client的包, id 或者user/key'),
@@ -73,9 +74,9 @@ app.route({
app.route({ app.route({
path: 'app', path: 'app',
key: 'uninstall', key: 'uninstall',
alias: 'remove',
description: '卸载 app serve client的包', description: '卸载 app serve client的包',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
id: z.string().optional().describe('user/key'), id: z.string().optional().describe('user/key'),
path: z.string().optional().describe('删除的路径'), path: z.string().optional().describe('删除的路径'),
@@ -135,6 +136,7 @@ app.route({
key: 'link', key: 'link',
description: '从 URL 链接应用', description: '从 URL 链接应用',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
url: z.string().describe('URL'), url: z.string().describe('URL'),
output: z.string().optional().describe('输出目录'), output: z.string().optional().describe('输出目录'),

View File

@@ -5,6 +5,7 @@ import path from 'node:path';
import os from 'node:os'; import os from 'node:os';
import fs from 'node:fs'; import fs from 'node:fs';
import { select } from '@inquirer/prompts'; import { select } from '@inquirer/prompts';
import { useKey } from '@kevisual/context';
const MODELS = ['minimax', 'glm', 'volcengine', 'bailian'] as const; const MODELS = ['minimax', 'glm', 'volcengine', 'bailian'] as const;
@@ -119,6 +120,7 @@ app.route({
key: 'main', key: 'main',
description: '切换claude code模型', description: '切换claude code模型',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
models: z.string().optional().describe(`选择模型: ${MODELS.join(' | ')}`), models: z.string().optional().describe(`选择模型: ${MODELS.join(' | ')}`),
} }

View File

@@ -71,6 +71,7 @@ app.route({
key: 'main', key: 'main',
description: '切换 opencode 模型', description: '切换 opencode 模型',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
model: z.string().optional().describe('选择模型 (格式: provider/model)'), model: z.string().optional().describe('选择模型 (格式: provider/model)'),
} }
@@ -117,6 +118,7 @@ app.route({
key: 'show', key: 'show',
description: '显示当前 opencode 配置的 model', description: '显示当前 opencode 配置的 model',
metadata: { metadata: {
middleware: ['auth'],
args: {} args: {}
} }
}).define(async () => { }).define(async () => {

View File

@@ -9,6 +9,7 @@ app.route({
key: 'live', key: 'live',
description: '启动 CNB Keep Alive 服务', description: '启动 CNB Keep Alive 服务',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
json: z.string().optional().describe('JSON数据'), json: z.string().optional().describe('JSON数据'),
config: z.string().optional().describe('配置文件路径'), config: z.string().optional().describe('配置文件路径'),
@@ -54,9 +55,9 @@ app.route({
app.route({ app.route({
path: 'cnb', path: 'cnb',
key: 'workspace', key: 'workspace',
alias: 'w',
description: '工作区live保活', description: '工作区live保活',
metadata: { metadata: {
middleware: ['auth'],
args: {} args: {}
} }
}).define(async () => { }).define(async () => {

View File

@@ -41,6 +41,7 @@ app.route({
key: 'main', key: 'main',
description: 'config 命令', description: 'config 命令',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
dev: z.string().optional().describe('Specify dev'), dev: z.string().optional().describe('Specify dev'),
set: z.string().optional().describe('set config'), set: z.string().optional().describe('set config'),
@@ -114,6 +115,7 @@ app.route({
key: 'set', key: 'set',
description: 'set config', description: 'set config',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
key: z.string().describe('配置键名'), key: z.string().describe('配置键名'),
value: z.string().optional().describe('配置值'), value: z.string().optional().describe('配置值'),
@@ -173,6 +175,7 @@ app.route({
key: 'get', key: 'get',
description: 'get config', description: 'get config',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
key: z.string().optional().describe('配置键名'), key: z.string().optional().describe('配置键名'),
} }
@@ -201,6 +204,7 @@ app.route({
key: 'remove', key: 'remove',
description: 'remove config', description: 'remove config',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
key: z.string().describe('配置键名'), key: z.string().describe('配置键名'),
} }
@@ -220,6 +224,7 @@ app.route({
key: 'list', key: 'list',
description: 'list config', description: 'list config',
metadata: { metadata: {
middleware: ['auth'],
args: {} args: {}
} }
}).define(async () => { }).define(async () => {

View File

@@ -128,6 +128,7 @@ app.route({
key: 'main', key: 'main',
description: '把前端文件传到服务器', description: '把前端文件传到服务器',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
filePath: z.string().describe('Path to the file to be uploaded'), filePath: z.string().describe('Path to the file to be uploaded'),
version: z.string().optional().describe('verbose'), version: z.string().optional().describe('verbose'),
@@ -168,7 +169,7 @@ app.route({
isDirectory = true; isDirectory = true;
const files = await glob('**/*', { const files = await glob('**/*', {
cwd: deployDir, cwd: deployDir,
ignore: ['node_modules/**/*', '.git/**/*', '.DS_Store'], ignore: ['node_modules/**/*', '.git/**/*', '.DS_Store', '.astro'],
onlyFiles: true, onlyFiles: true,
dot: dot || false, dot: dot || false,
absolute: true, absolute: true,
@@ -239,6 +240,7 @@ app.route({
key: 'load', key: 'load',
description: '部署加载', description: '部署加载',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
id: z.string().describe('id'), id: z.string().describe('id'),
org: z.string().optional().describe('org'), org: z.string().optional().describe('org'),

View File

@@ -9,6 +9,7 @@ app.route({
key: 'login', key: 'login',
description: '登录 Docker 镜像仓库', description: '登录 Docker 镜像仓库',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
registry: z.string().optional().describe('Docker 镜像仓库地址'), registry: z.string().optional().describe('Docker 镜像仓库地址'),
} }
@@ -55,6 +56,7 @@ app.route({
key: 'login', key: 'login',
description: '登录 Helm 镜像仓库', description: '登录 Helm 镜像仓库',
metadata: { metadata: {
middleware: ['auth'],
args: {} args: {}
} }
}).define(async () => { }).define(async () => {

View File

@@ -21,6 +21,7 @@ app.route({
key: 'main', key: 'main',
description: '下载项目', description: '下载项目',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
link: z.string().optional().describe('下载链接'), link: z.string().optional().describe('下载链接'),
directory: z.string().optional().describe('下载目录'), directory: z.string().optional().describe('下载目录'),

View File

@@ -11,6 +11,7 @@ app.route({
key: 'main', key: 'main',
description: '同步片段代码', description: '同步片段代码',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
dir: z.string().optional().describe('配置目录'), dir: z.string().optional().describe('配置目录'),
link: z.string().describe('链接'), link: z.string().describe('链接'),
@@ -39,6 +40,7 @@ app.route({
key: 'download', key: 'download',
description: '克隆代码片段', description: '克隆代码片段',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
dir: z.string().optional().describe('配置目录'), dir: z.string().optional().describe('配置目录'),
config: z.string().optional().describe('配置文件的名字'), config: z.string().optional().describe('配置文件的名字'),

View File

@@ -20,9 +20,9 @@ export const getPath = async (dir: string) => {
app.route({ app.route({
path: 'jwks', path: 'jwks',
key: 'generate', key: 'generate',
alias: 'gen',
description: '生成 JWKS 密钥对', description: '生成 JWKS 密钥对',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
dir: z.string().optional().describe('指定保存目录'), dir: z.string().optional().describe('指定保存目录'),
} }
@@ -47,6 +47,7 @@ app.route({
key: 'get', key: 'get',
description: '获取 JWKS 内容', description: '获取 JWKS 内容',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
dir: z.string().optional().describe('指定 JWKS 所在目录'), dir: z.string().optional().describe('指定 JWKS 所在目录'),
type: z.string().optional().describe('指定获取类型jwks 或 privateJWK'), type: z.string().optional().describe('指定获取类型jwks 或 privateJWK'),

View File

@@ -46,6 +46,7 @@ app.route({
key: 'login', key: 'login',
description: '登录', description: '登录',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
username: z.string().optional().describe('用户名'), username: z.string().optional().describe('用户名'),
password: z.string().optional().describe('密码'), password: z.string().optional().describe('密码'),
@@ -117,6 +118,7 @@ app.route({
key: 'me', key: 'me',
description: '查看当前登录用户信息', description: '查看当前登录用户信息',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
all: z.boolean().optional().describe('是否显示全部信息默认为false'), all: z.boolean().optional().describe('是否显示全部信息默认为false'),
} }
@@ -164,6 +166,7 @@ app.route({
key: 'switch', key: 'switch',
description: '切换到其他组织或用户', description: '切换到其他组织或用户',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
username: z.string().describe('用户名或组织名'), username: z.string().describe('用户名或组织名'),
} }
@@ -182,7 +185,9 @@ app.route({
path: 'user', path: 'user',
key: 'logout', key: 'logout',
description: '退出登录', description: '退出登录',
metadata: {} metadata: {
middleware: ['auth'],
}
}).define(async () => { }).define(async () => {
try { try {
await queryLogin.logout(); await queryLogin.logout();

View File

@@ -106,15 +106,15 @@ app.route({
key: 'publish', key: 'publish',
description: '发布 npm 包', description: '发布 npm 包',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
registry: z.string().optional().describe('发布源'), registry: z.string().optional().describe('发布源'),
proxy: z.boolean().optional().describe('使用代理'), proxy: z.boolean().optional().describe('使用代理'),
tag: z.boolean().optional().describe('使用 tag'),
update: z.boolean().optional().describe('更新新版本'), update: z.boolean().optional().describe('更新新版本'),
} }
} }
}).define(async (ctx) => { }).define(async (ctx) => {
let { registry, proxy, tag, update } = ctx.args; let { registry, proxy, update } = ctx.args;
if (!registry) { if (!registry) {
registry = await select({ registry = await select({
message: 'Select the registry to publish', message: 'Select the registry to publish',
@@ -145,7 +145,7 @@ app.route({
publishRegistry({ execPath, registry: 'npm', config, env: setEnv }); publishRegistry({ execPath, registry: 'npm', config, env: setEnv });
publishRegistry({ execPath, registry: 'cnb', config, env: setEnv }); publishRegistry({ execPath, registry: 'cnb', config, env: setEnv });
} else { } else {
publishRegistry({ execPath, registry, tag, config, env: setEnv }); publishRegistry({ execPath, registry, config, env: setEnv });
} }
}).addTo(app) }).addTo(app)
@@ -154,6 +154,7 @@ app.route({
key: 'get', key: 'get',
description: '获取 .npmrc 内容', description: '获取 .npmrc 内容',
metadata: { metadata: {
middleware: ['auth'],
args: {} args: {}
} }
}).define(async () => { }).define(async () => {
@@ -170,6 +171,7 @@ app.route({
key: 'set', key: 'set',
description: '设置 .npmrc', description: '设置 .npmrc',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
force: z.boolean().optional().describe('强制覆盖'), force: z.boolean().optional().describe('强制覆盖'),
} }
@@ -211,6 +213,7 @@ app.route({
key: 'remove', key: 'remove',
description: '删除 .npmrc', description: '删除 .npmrc',
metadata: { metadata: {
middleware: ['auth'],
args: {} args: {}
} }
}).define(async () => { }).define(async () => {
@@ -229,6 +232,7 @@ app.route({
key: 'install', key: 'install',
description: 'npm install 使用代理', description: 'npm install 使用代理',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
noproxy: z.boolean().optional().describe('不使用代理'), noproxy: z.boolean().optional().describe('不使用代理'),
} }
@@ -260,6 +264,7 @@ app.route({
key: 'patch', key: 'patch',
description: 'npm patch 发布补丁版本', description: 'npm patch 发布补丁版本',
metadata: { metadata: {
middleware: ['auth'],
args: {} args: {}
} }
}).define(async () => { }).define(async () => {

View File

@@ -7,6 +7,7 @@ app.route({
key: 'main', key: 'main',
description: '执行代理相关的命令', description: '执行代理相关的命令',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
start: z.boolean().optional().describe('启动代理'), start: z.boolean().optional().describe('启动代理'),
unset: z.boolean().optional().describe('关闭代理'), unset: z.boolean().optional().describe('关闭代理'),

View File

@@ -194,6 +194,7 @@ app.route({
key: 'main', key: 'main',
description: '发布应用', description: '发布应用',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
key: z.string().optional().describe('应用 key'), key: z.string().optional().describe('应用 key'),
version: z.string().optional().describe('应用版本'), version: z.string().optional().describe('应用版本'),
@@ -210,6 +211,7 @@ app.route({
key: 'main', key: 'main',
description: '打包应用', description: '打包应用',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
publish: z.boolean().optional().describe('打包并发布'), publish: z.boolean().optional().describe('打包并发布'),
update: z.boolean().optional().describe('发布后显示更新命令'), update: z.boolean().optional().describe('发布后显示更新命令'),
@@ -265,6 +267,7 @@ app.route({
key: 'main', key: 'main',
description: 'Pack 部署', description: 'Pack 部署',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
id: z.string().describe('id'), id: z.string().describe('id'),
key: z.string().optional().describe('fileKey'), key: z.string().optional().describe('fileKey'),
@@ -281,6 +284,7 @@ app.route({
key: 'main', key: 'main',
description: '服务器服务管理', description: '服务器服务管理',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
list: z.boolean().optional().describe('list services'), list: z.boolean().optional().describe('list services'),
restart: z.string().optional().describe('restart services'), restart: z.string().optional().describe('restart services'),
@@ -387,6 +391,7 @@ app.route({
key: 'detect', key: 'detect',
description: '检测服务', description: '检测服务',
metadata: { metadata: {
middleware: ['auth'],
args: {} args: {}
} }
}).define(async () => { }).define(async () => {

View File

@@ -11,9 +11,9 @@ const queryConfig = new QueryConfig({ query: query as any });
app.route({ app.route({
path: 'remote-config', path: 'remote-config',
key: 'get', key: 'get',
alias: 'rc',
description: '获取远程配置', description: '获取远程配置',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
key: z.string().optional().describe('配置键名'), key: z.string().optional().describe('配置键名'),
} }
@@ -24,7 +24,7 @@ app.route({
console.log('Please provide a key using -k or --key option.'); console.log('Please provide a key using -k or --key option.');
return; return;
} }
const res = await queryConfig.getConfigByKey(key); const res = await queryConfig.getConfigByKey(key as any);
console.log('res Config Result:', showMore(res.data)); console.log('res Config Result:', showMore(res.data));
}).addTo(app) }).addTo(app)
@@ -33,6 +33,7 @@ app.route({
key: 'list', key: 'list',
description: '列出所有远程配置', description: '列出所有远程配置',
metadata: { metadata: {
middleware: ['auth'],
args: {} args: {}
} }
}).define(async () => { }).define(async () => {
@@ -51,6 +52,7 @@ app.route({
key: 'update', key: 'update',
description: '更新远程配置', description: '更新远程配置',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
key: z.string().describe('配置键名'), key: z.string().describe('配置键名'),
value: z.string().optional().describe('配置值'), value: z.string().optional().describe('配置值'),
@@ -94,6 +96,7 @@ app.route({
key: 'delete', key: 'delete',
description: '删除远程配置', description: '删除远程配置',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
id: z.string().optional().describe('配置ID'), id: z.string().optional().describe('配置ID'),
key: z.string().optional().describe('配置键名'), key: z.string().optional().describe('配置键名'),

View File

@@ -3,17 +3,15 @@ import { z } from 'zod';
import { query } from '@/module/query.ts'; import { query } from '@/module/query.ts';
import { QueryConfig } from '@kevisual/api/query-secret'; import { QueryConfig } from '@kevisual/api/query-secret';
import { showMore } from '@/uitls/show-more.ts'; import { showMore } from '@/uitls/show-more.ts';
import fs from 'node:fs';
import path from 'node:path';
const queryConfig = new QueryConfig({ query: query as any }); const queryConfig = new QueryConfig({ query: query as any });
app.route({ app.route({
path: 'remote-secret', path: 'remote-secret',
key: 'get', key: 'get',
alias: 'rs',
description: '获取远程密钥', description: '获取远程密钥',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
key: z.string().optional().describe('配置键名'), key: z.string().optional().describe('配置键名'),
} }
@@ -33,6 +31,7 @@ app.route({
key: 'list', key: 'list',
description: '列出所有密钥', description: '列出所有密钥',
metadata: { metadata: {
middleware: ['auth'],
args: {} args: {}
} }
}).define(async () => { }).define(async () => {
@@ -52,6 +51,7 @@ app.route({
key: 'update', key: 'update',
description: '更新密钥', description: '更新密钥',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
id: z.string().optional().describe('配置ID'), id: z.string().optional().describe('配置ID'),
title: z.string().optional().describe('配置值'), title: z.string().optional().describe('配置值'),
@@ -79,6 +79,7 @@ app.route({
key: 'delete', key: 'delete',
description: '删除密钥', description: '删除密钥',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
id: z.string().optional().describe('配置ID'), id: z.string().optional().describe('配置ID'),
key: z.string().optional().describe('配置键名'), key: z.string().optional().describe('配置键名'),

View File

@@ -10,6 +10,7 @@ app.route({
key: 'service', key: 'service',
description: 'router services get', description: 'router services get',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
path: z.string().optional().describe('第一路径 path'), path: z.string().optional().describe('第一路径 path'),
key: z.string().optional().describe('第二路径 key'), key: z.string().optional().describe('第二路径 key'),

View File

@@ -16,6 +16,7 @@ app.route({
key: 'main', key: 'main',
description: '同步项目', description: '同步项目',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
dir: z.string().optional().describe('配置目录'), dir: z.string().optional().describe('配置目录'),
} }
@@ -29,6 +30,7 @@ app.route({
key: 'upload', key: 'upload',
description: '上传项目', description: '上传项目',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
dir: z.string().optional().describe('配置目录'), dir: z.string().optional().describe('配置目录'),
config: z.string().optional().describe('配置文件的名字'), config: z.string().optional().describe('配置文件的名字'),
@@ -113,6 +115,7 @@ app.route({
key: 'download', key: 'download',
description: '下载项目', description: '下载项目',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
dir: z.string().optional().describe('配置目录'), dir: z.string().optional().describe('配置目录'),
config: z.string().optional().describe('配置文件的名字'), config: z.string().optional().describe('配置文件的名字'),
@@ -156,6 +159,7 @@ app.route({
key: 'list', key: 'list',
description: '列出同步列表', description: '列出同步列表',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
dir: z.string().optional().describe('配置目录'), dir: z.string().optional().describe('配置目录'),
config: z.string().optional().describe('配置文件的名字'), config: z.string().optional().describe('配置文件的名字'),
@@ -184,6 +188,7 @@ app.route({
key: 'create', key: 'create',
description: '创建同步配置', description: '创建同步配置',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
dir: z.string().optional().describe('配置目录'), dir: z.string().optional().describe('配置目录'),
config: z.string().optional().describe('配置文件的名字'), config: z.string().optional().describe('配置文件的名字'),
@@ -218,6 +223,7 @@ app.route({
key: 'clone', key: 'clone',
description: '克隆同步目录', description: '克隆同步目录',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
dir: z.string().optional().describe('配置目录'), dir: z.string().optional().describe('配置目录'),
config: z.string().optional().describe('配置文件的名字'), config: z.string().optional().describe('配置文件的名字'),

View File

@@ -26,6 +26,7 @@ app.route({
key: 'ls', key: 'ls',
description: '显示 token 列表', description: '显示 token 列表',
metadata: { metadata: {
middleware: ['auth'],
args: {} args: {}
} }
}).define(async () => { }).define(async () => {
@@ -39,6 +40,7 @@ app.route({
key: 'info', key: 'info',
description: '显示 token 信息', description: '显示 token 信息',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
env: z.boolean().optional().describe('显示环境变量中的 token'), env: z.boolean().optional().describe('显示环境变量中的 token'),
} }
@@ -58,6 +60,7 @@ app.route({
key: 'create', key: 'create',
description: '创建 jwks token', description: '创建 jwks token',
metadata: { metadata: {
middleware: ['auth'],
args: {} args: {}
} }
}).define(async () => { }).define(async () => {
@@ -77,6 +80,7 @@ app.route({
key: 'info', key: 'info',
description: '显示 baseURL', description: '显示 baseURL',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
add: z.string().optional().describe('添加 baseURL'), add: z.string().optional().describe('添加 baseURL'),
remove: z.number().optional().describe('按编号移除 baseURL'), remove: z.number().optional().describe('按编号移除 baseURL'),
@@ -166,6 +170,7 @@ app.route({
key: 'set', key: 'set',
description: '设置 baseURL', description: '设置 baseURL',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
baseURL: z.string().optional().describe('baseURL 地址'), baseURL: z.string().optional().describe('baseURL 地址'),
} }
@@ -185,6 +190,7 @@ app.route({
key: 'manage', key: 'manage',
description: 'registry 管理', description: 'registry 管理',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
list: z.boolean().optional().describe('列出 registry'), list: z.boolean().optional().describe('列出 registry'),
set: z.string().optional().describe('设置 registry'), set: z.string().optional().describe('设置 registry'),
@@ -219,7 +225,10 @@ app.route({
path: 'baseURL', path: 'baseURL',
key: 'kevisual', key: 'kevisual',
description: 'kevisual registry', description: 'kevisual registry',
metadata: { args: {} } metadata: {
middleware: ['auth'],
args: {}
}
}).define(async () => { }).define(async () => {
const config = getConfig(); const config = getConfig();
const defaultRegistry = ['https://kevisual.cn']; const defaultRegistry = ['https://kevisual.cn'];
@@ -227,23 +236,14 @@ app.route({
showList(defaultRegistry); showList(defaultRegistry);
}).addTo(app) }).addTo(app)
app.route({
path: 'baseURL',
key: 'silky',
description: 'silky registry',
metadata: { args: {} }
}).define(async () => {
const config = getConfig();
const defaultRegistry = ['https://kevisual.silkyai.cn'];
writeConfig({ ...config, baseURL: defaultRegistry[0] });
showList(defaultRegistry);
}).addTo(app)
app.route({ app.route({
path: 'baseURL', path: 'baseURL',
key: 'local', key: 'local',
description: 'local registry', description: 'local registry',
metadata: { args: {} } metadata: {
middleware: ['auth'],
args: {}
}
}).define(async () => { }).define(async () => {
const config = getConfig(); const config = getConfig();
const defaultRegistry = ['http://localhost:3005']; const defaultRegistry = ['http://localhost:3005'];

View File

@@ -97,6 +97,7 @@ app.route({
key: 'main', key: 'main',
description: 'update cli', description: 'update cli',
metadata: { metadata: {
middleware: ['auth'],
args: { args: {
global: z.boolean().optional().describe('update global'), global: z.boolean().optional().describe('update global'),
npm: z.boolean().optional().describe('use npm to update'), npm: z.boolean().optional().describe('use npm to update'),
@@ -107,7 +108,7 @@ app.route({
const { global, npm, force } = ctx.args; const { global, npm, force } = ctx.args;
try { try {
if (npm) { if (npm) {
const cmd = global ? 'npm install -g @kevisual/envision-cli' : 'npm install -D @kevisual/envision-cli'; const cmd = global ? 'npm install -g @kevisual/cli' : 'npm install -D @kevisual/cli';
execSync(cmd, { stdio: 'inherit', encoding: 'utf-8' }); execSync(cmd, { stdio: 'inherit', encoding: 'utf-8' });
} else { } else {
const forceUpdate = force ? true : false; const forceUpdate = force ? true : false;