更新 CLI 版本至 0.1.33,重构构建配置,添加新的路由和中间件,增强身份验证支持
This commit is contained in:
2
bin/cli.js
Executable file
2
bin/cli.js
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env bun
|
||||
import '../dist/cli.js';
|
||||
@@ -1,19 +1,5 @@
|
||||
// @ts-check
|
||||
// https://bun.sh/docs/bundler
|
||||
// @ts-ignore
|
||||
import pkg from './package.json';
|
||||
// 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),
|
||||
},
|
||||
});
|
||||
import { buildWithBun } from '@kevisual/code-builder';
|
||||
|
||||
await buildWithBun({ naming: 'envision', entry: 'src/oldindex.ts',});
|
||||
await buildWithBun({ naming: 'cli', entry: 'src/cli.ts' });
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@kevisual/cli",
|
||||
"version": "0.1.32",
|
||||
"version": "0.1.33",
|
||||
"description": "envision 命令行工具",
|
||||
"type": "module",
|
||||
"basename": "/root/cli",
|
||||
@@ -15,6 +15,7 @@
|
||||
"bin": {
|
||||
"envision": "bin/envision.js",
|
||||
"ev": "bin/envision.js",
|
||||
"ev-next": "bin/cli.js",
|
||||
"assistant": "bin/assistant.js",
|
||||
"assistant-server": "bin/assistant-server.js",
|
||||
"asst": "bin/assistant.js",
|
||||
@@ -64,6 +65,7 @@
|
||||
"devDependencies": {
|
||||
"@kevisual/api": "^0.0.65",
|
||||
"@kevisual/cnb": "^0.0.60",
|
||||
"@kevisual/code-builder": "^0.0.6",
|
||||
"@kevisual/dts": "^0.0.4",
|
||||
"@kevisual/load": "^0.0.6",
|
||||
"@kevisual/logger": "^0.0.4",
|
||||
|
||||
9
pnpm-lock.yaml
generated
9
pnpm-lock.yaml
generated
@@ -72,6 +72,9 @@ importers:
|
||||
'@kevisual/cnb':
|
||||
specifier: ^0.0.60
|
||||
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':
|
||||
specifier: ^0.0.4
|
||||
version: 0.0.4(typescript@5.9.3)
|
||||
@@ -640,6 +643,10 @@ packages:
|
||||
resolution: {integrity: sha512-I13DKPntnneyM+o+eJ5hemIQGhaScCNPQiinaSlrxPHpsCKU8XFookjzfMA6T+D4hi0pWfZYILtXnpOHGh3k/Q==}
|
||||
hasBin: true
|
||||
|
||||
'@kevisual/code-builder@0.0.6':
|
||||
resolution: {integrity: sha512-0aqATB31/yw4k4s5/xKnfr4DKbUnx8e3Z3BmKbiXTrc+CqWiWTdlGe9bKI9dZ2Df+xNp6g11W4xM2NICNyyCCw==}
|
||||
hasBin: true
|
||||
|
||||
'@kevisual/context@0.0.4':
|
||||
resolution: {integrity: sha512-HJeLeZQLU+7tCluSfOyvkgKLs0HjCZrdJlZgEgKRSa8XTwZfMAUt6J7qZTbrZAHBlPtX68EPu/PI8JMCeu3WAQ==}
|
||||
|
||||
@@ -3150,6 +3157,8 @@ snapshots:
|
||||
- ioredis
|
||||
- uploadthing
|
||||
|
||||
'@kevisual/code-builder@0.0.6': {}
|
||||
|
||||
'@kevisual/context@0.0.4': {}
|
||||
|
||||
'@kevisual/context@0.0.8': {}
|
||||
|
||||
32
src/index.ts
32
src/index.ts
@@ -1,7 +1,33 @@
|
||||
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.createRouteList()
|
||||
app.createRouteList()
|
||||
|
||||
export const runApp = async (msg: {
|
||||
path: string,
|
||||
key?: string,
|
||||
payload: any
|
||||
}) => {
|
||||
return await app.run(msg);
|
||||
}
|
||||
export { app };
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useContextKey } from '@kevisual/context'
|
||||
|
||||
// 将多个子命令加入主程序中
|
||||
const version = useContextKey('version', () => {
|
||||
let version = '0.0.64';
|
||||
let version = '0.1.33';
|
||||
try {
|
||||
// @ts-ignore
|
||||
if (ENVISION_VERSION) version = ENVISION_VERSION;
|
||||
|
||||
@@ -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)
|
||||
@@ -14,6 +14,7 @@ app.route({
|
||||
path: 'app',
|
||||
key: 'download',
|
||||
description: '下载 app serve client的包',
|
||||
middleware: ['auth'],
|
||||
metadata: {
|
||||
args: {
|
||||
id: z.string().optional().describe('下载 app serve client的包, id 或者user/key'),
|
||||
@@ -73,9 +74,9 @@ app.route({
|
||||
app.route({
|
||||
path: 'app',
|
||||
key: 'uninstall',
|
||||
alias: 'remove',
|
||||
description: '卸载 app serve client的包',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
id: z.string().optional().describe('user/key'),
|
||||
path: z.string().optional().describe('删除的路径'),
|
||||
@@ -135,6 +136,7 @@ app.route({
|
||||
key: 'link',
|
||||
description: '从 URL 链接应用',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
url: z.string().describe('URL'),
|
||||
output: z.string().optional().describe('输出目录'),
|
||||
|
||||
@@ -5,6 +5,7 @@ import path from 'node:path';
|
||||
import os from 'node:os';
|
||||
import fs from 'node:fs';
|
||||
import { select } from '@inquirer/prompts';
|
||||
import { useKey } from '@kevisual/context';
|
||||
|
||||
const MODELS = ['minimax', 'glm', 'volcengine', 'bailian'] as const;
|
||||
|
||||
@@ -119,6 +120,7 @@ app.route({
|
||||
key: 'main',
|
||||
description: '切换claude code模型',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
models: z.string().optional().describe(`选择模型: ${MODELS.join(' | ')}`),
|
||||
}
|
||||
|
||||
@@ -71,6 +71,7 @@ app.route({
|
||||
key: 'main',
|
||||
description: '切换 opencode 模型',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
model: z.string().optional().describe('选择模型 (格式: provider/model)'),
|
||||
}
|
||||
@@ -117,6 +118,7 @@ app.route({
|
||||
key: 'show',
|
||||
description: '显示当前 opencode 配置的 model',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {}
|
||||
}
|
||||
}).define(async () => {
|
||||
|
||||
@@ -9,6 +9,7 @@ app.route({
|
||||
key: 'live',
|
||||
description: '启动 CNB Keep Alive 服务',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
json: z.string().optional().describe('JSON数据'),
|
||||
config: z.string().optional().describe('配置文件路径'),
|
||||
@@ -54,9 +55,9 @@ app.route({
|
||||
app.route({
|
||||
path: 'cnb',
|
||||
key: 'workspace',
|
||||
alias: 'w',
|
||||
description: '工作区live保活',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {}
|
||||
}
|
||||
}).define(async () => {
|
||||
|
||||
@@ -41,6 +41,7 @@ app.route({
|
||||
key: 'main',
|
||||
description: 'config 命令',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
dev: z.string().optional().describe('Specify dev'),
|
||||
set: z.string().optional().describe('set config'),
|
||||
@@ -114,6 +115,7 @@ app.route({
|
||||
key: 'set',
|
||||
description: 'set config',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
key: z.string().describe('配置键名'),
|
||||
value: z.string().optional().describe('配置值'),
|
||||
@@ -173,6 +175,7 @@ app.route({
|
||||
key: 'get',
|
||||
description: 'get config',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
key: z.string().optional().describe('配置键名'),
|
||||
}
|
||||
@@ -201,6 +204,7 @@ app.route({
|
||||
key: 'remove',
|
||||
description: 'remove config',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
key: z.string().describe('配置键名'),
|
||||
}
|
||||
@@ -220,6 +224,7 @@ app.route({
|
||||
key: 'list',
|
||||
description: 'list config',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {}
|
||||
}
|
||||
}).define(async () => {
|
||||
|
||||
@@ -128,6 +128,7 @@ app.route({
|
||||
key: 'main',
|
||||
description: '把前端文件传到服务器',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
filePath: z.string().describe('Path to the file to be uploaded'),
|
||||
version: z.string().optional().describe('verbose'),
|
||||
@@ -168,7 +169,7 @@ app.route({
|
||||
isDirectory = true;
|
||||
const files = await glob('**/*', {
|
||||
cwd: deployDir,
|
||||
ignore: ['node_modules/**/*', '.git/**/*', '.DS_Store'],
|
||||
ignore: ['node_modules/**/*', '.git/**/*', '.DS_Store', '.astro'],
|
||||
onlyFiles: true,
|
||||
dot: dot || false,
|
||||
absolute: true,
|
||||
@@ -239,6 +240,7 @@ app.route({
|
||||
key: 'load',
|
||||
description: '部署加载',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
id: z.string().describe('id'),
|
||||
org: z.string().optional().describe('org'),
|
||||
|
||||
@@ -9,6 +9,7 @@ app.route({
|
||||
key: 'login',
|
||||
description: '登录 Docker 镜像仓库',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
registry: z.string().optional().describe('Docker 镜像仓库地址'),
|
||||
}
|
||||
@@ -55,6 +56,7 @@ app.route({
|
||||
key: 'login',
|
||||
description: '登录 Helm 镜像仓库',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {}
|
||||
}
|
||||
}).define(async () => {
|
||||
|
||||
@@ -21,6 +21,7 @@ app.route({
|
||||
key: 'main',
|
||||
description: '下载项目',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
link: z.string().optional().describe('下载链接'),
|
||||
directory: z.string().optional().describe('下载目录'),
|
||||
|
||||
@@ -11,6 +11,7 @@ app.route({
|
||||
key: 'main',
|
||||
description: '同步片段代码',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
dir: z.string().optional().describe('配置目录'),
|
||||
link: z.string().describe('链接'),
|
||||
@@ -39,6 +40,7 @@ app.route({
|
||||
key: 'download',
|
||||
description: '克隆代码片段',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
dir: z.string().optional().describe('配置目录'),
|
||||
config: z.string().optional().describe('配置文件的名字'),
|
||||
|
||||
@@ -20,9 +20,9 @@ export const getPath = async (dir: string) => {
|
||||
app.route({
|
||||
path: 'jwks',
|
||||
key: 'generate',
|
||||
alias: 'gen',
|
||||
description: '生成 JWKS 密钥对',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
dir: z.string().optional().describe('指定保存目录'),
|
||||
}
|
||||
@@ -47,6 +47,7 @@ app.route({
|
||||
key: 'get',
|
||||
description: '获取 JWKS 内容',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
dir: z.string().optional().describe('指定 JWKS 所在目录'),
|
||||
type: z.string().optional().describe('指定获取类型,jwks 或 privateJWK'),
|
||||
|
||||
@@ -46,6 +46,7 @@ app.route({
|
||||
key: 'login',
|
||||
description: '登录',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
username: z.string().optional().describe('用户名'),
|
||||
password: z.string().optional().describe('密码'),
|
||||
@@ -117,6 +118,7 @@ app.route({
|
||||
key: 'me',
|
||||
description: '查看当前登录用户信息',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
all: z.boolean().optional().describe('是否显示全部信息,默认为false'),
|
||||
}
|
||||
@@ -164,6 +166,7 @@ app.route({
|
||||
key: 'switch',
|
||||
description: '切换到其他组织或用户',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
username: z.string().describe('用户名或组织名'),
|
||||
}
|
||||
@@ -182,7 +185,9 @@ app.route({
|
||||
path: 'user',
|
||||
key: 'logout',
|
||||
description: '退出登录',
|
||||
metadata: {}
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
}
|
||||
}).define(async () => {
|
||||
try {
|
||||
await queryLogin.logout();
|
||||
|
||||
@@ -106,15 +106,15 @@ app.route({
|
||||
key: 'publish',
|
||||
description: '发布 npm 包',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
registry: z.string().optional().describe('发布源'),
|
||||
proxy: z.boolean().optional().describe('使用代理'),
|
||||
tag: z.boolean().optional().describe('使用 tag'),
|
||||
update: z.boolean().optional().describe('更新新版本'),
|
||||
}
|
||||
}
|
||||
}).define(async (ctx) => {
|
||||
let { registry, proxy, tag, update } = ctx.args;
|
||||
let { registry, proxy, update } = ctx.args;
|
||||
if (!registry) {
|
||||
registry = await select({
|
||||
message: 'Select the registry to publish',
|
||||
@@ -145,7 +145,7 @@ app.route({
|
||||
publishRegistry({ execPath, registry: 'npm', config, env: setEnv });
|
||||
publishRegistry({ execPath, registry: 'cnb', config, env: setEnv });
|
||||
} else {
|
||||
publishRegistry({ execPath, registry, tag, config, env: setEnv });
|
||||
publishRegistry({ execPath, registry, config, env: setEnv });
|
||||
}
|
||||
}).addTo(app)
|
||||
|
||||
@@ -154,6 +154,7 @@ app.route({
|
||||
key: 'get',
|
||||
description: '获取 .npmrc 内容',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {}
|
||||
}
|
||||
}).define(async () => {
|
||||
@@ -170,6 +171,7 @@ app.route({
|
||||
key: 'set',
|
||||
description: '设置 .npmrc',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
force: z.boolean().optional().describe('强制覆盖'),
|
||||
}
|
||||
@@ -211,6 +213,7 @@ app.route({
|
||||
key: 'remove',
|
||||
description: '删除 .npmrc',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {}
|
||||
}
|
||||
}).define(async () => {
|
||||
@@ -229,6 +232,7 @@ app.route({
|
||||
key: 'install',
|
||||
description: 'npm install 使用代理',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
noproxy: z.boolean().optional().describe('不使用代理'),
|
||||
}
|
||||
@@ -260,6 +264,7 @@ app.route({
|
||||
key: 'patch',
|
||||
description: 'npm patch 发布补丁版本',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {}
|
||||
}
|
||||
}).define(async () => {
|
||||
|
||||
@@ -7,6 +7,7 @@ app.route({
|
||||
key: 'main',
|
||||
description: '执行代理相关的命令',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
start: z.boolean().optional().describe('启动代理'),
|
||||
unset: z.boolean().optional().describe('关闭代理'),
|
||||
|
||||
@@ -194,6 +194,7 @@ app.route({
|
||||
key: 'main',
|
||||
description: '发布应用',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
key: z.string().optional().describe('应用 key'),
|
||||
version: z.string().optional().describe('应用版本'),
|
||||
@@ -210,6 +211,7 @@ app.route({
|
||||
key: 'main',
|
||||
description: '打包应用',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
publish: z.boolean().optional().describe('打包并发布'),
|
||||
update: z.boolean().optional().describe('发布后显示更新命令'),
|
||||
@@ -265,6 +267,7 @@ app.route({
|
||||
key: 'main',
|
||||
description: 'Pack 部署',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
id: z.string().describe('id'),
|
||||
key: z.string().optional().describe('fileKey'),
|
||||
@@ -281,6 +284,7 @@ app.route({
|
||||
key: 'main',
|
||||
description: '服务器服务管理',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
list: z.boolean().optional().describe('list services'),
|
||||
restart: z.string().optional().describe('restart services'),
|
||||
@@ -387,6 +391,7 @@ app.route({
|
||||
key: 'detect',
|
||||
description: '检测服务',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {}
|
||||
}
|
||||
}).define(async () => {
|
||||
|
||||
@@ -11,9 +11,9 @@ const queryConfig = new QueryConfig({ query: query as any });
|
||||
app.route({
|
||||
path: 'remote-config',
|
||||
key: 'get',
|
||||
alias: 'rc',
|
||||
description: '获取远程配置',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
key: z.string().optional().describe('配置键名'),
|
||||
}
|
||||
@@ -24,7 +24,7 @@ app.route({
|
||||
console.log('Please provide a key using -k or --key option.');
|
||||
return;
|
||||
}
|
||||
const res = await queryConfig.getConfigByKey(key);
|
||||
const res = await queryConfig.getConfigByKey(key as any);
|
||||
console.log('res Config Result:', showMore(res.data));
|
||||
}).addTo(app)
|
||||
|
||||
@@ -33,6 +33,7 @@ app.route({
|
||||
key: 'list',
|
||||
description: '列出所有远程配置',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {}
|
||||
}
|
||||
}).define(async () => {
|
||||
@@ -51,6 +52,7 @@ app.route({
|
||||
key: 'update',
|
||||
description: '更新远程配置',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
key: z.string().describe('配置键名'),
|
||||
value: z.string().optional().describe('配置值'),
|
||||
@@ -94,6 +96,7 @@ app.route({
|
||||
key: 'delete',
|
||||
description: '删除远程配置',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
id: z.string().optional().describe('配置ID'),
|
||||
key: z.string().optional().describe('配置键名'),
|
||||
|
||||
@@ -3,17 +3,15 @@ import { z } from 'zod';
|
||||
import { query } from '@/module/query.ts';
|
||||
import { QueryConfig } from '@kevisual/api/query-secret';
|
||||
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 });
|
||||
|
||||
app.route({
|
||||
path: 'remote-secret',
|
||||
key: 'get',
|
||||
alias: 'rs',
|
||||
description: '获取远程密钥',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
key: z.string().optional().describe('配置键名'),
|
||||
}
|
||||
@@ -33,6 +31,7 @@ app.route({
|
||||
key: 'list',
|
||||
description: '列出所有密钥',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {}
|
||||
}
|
||||
}).define(async () => {
|
||||
@@ -52,6 +51,7 @@ app.route({
|
||||
key: 'update',
|
||||
description: '更新密钥',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
id: z.string().optional().describe('配置ID'),
|
||||
title: z.string().optional().describe('配置值'),
|
||||
@@ -79,6 +79,7 @@ app.route({
|
||||
key: 'delete',
|
||||
description: '删除密钥',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
id: z.string().optional().describe('配置ID'),
|
||||
key: z.string().optional().describe('配置键名'),
|
||||
|
||||
@@ -10,6 +10,7 @@ app.route({
|
||||
key: 'service',
|
||||
description: 'router services get',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
path: z.string().optional().describe('第一路径 path'),
|
||||
key: z.string().optional().describe('第二路径 key'),
|
||||
|
||||
@@ -16,6 +16,7 @@ app.route({
|
||||
key: 'main',
|
||||
description: '同步项目',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
dir: z.string().optional().describe('配置目录'),
|
||||
}
|
||||
@@ -29,6 +30,7 @@ app.route({
|
||||
key: 'upload',
|
||||
description: '上传项目',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
dir: z.string().optional().describe('配置目录'),
|
||||
config: z.string().optional().describe('配置文件的名字'),
|
||||
@@ -113,6 +115,7 @@ app.route({
|
||||
key: 'download',
|
||||
description: '下载项目',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
dir: z.string().optional().describe('配置目录'),
|
||||
config: z.string().optional().describe('配置文件的名字'),
|
||||
@@ -156,6 +159,7 @@ app.route({
|
||||
key: 'list',
|
||||
description: '列出同步列表',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
dir: z.string().optional().describe('配置目录'),
|
||||
config: z.string().optional().describe('配置文件的名字'),
|
||||
@@ -184,6 +188,7 @@ app.route({
|
||||
key: 'create',
|
||||
description: '创建同步配置',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
dir: z.string().optional().describe('配置目录'),
|
||||
config: z.string().optional().describe('配置文件的名字'),
|
||||
@@ -218,6 +223,7 @@ app.route({
|
||||
key: 'clone',
|
||||
description: '克隆同步目录',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
dir: z.string().optional().describe('配置目录'),
|
||||
config: z.string().optional().describe('配置文件的名字'),
|
||||
|
||||
@@ -26,6 +26,7 @@ app.route({
|
||||
key: 'ls',
|
||||
description: '显示 token 列表',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {}
|
||||
}
|
||||
}).define(async () => {
|
||||
@@ -39,6 +40,7 @@ app.route({
|
||||
key: 'info',
|
||||
description: '显示 token 信息',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
env: z.boolean().optional().describe('显示环境变量中的 token'),
|
||||
}
|
||||
@@ -58,6 +60,7 @@ app.route({
|
||||
key: 'create',
|
||||
description: '创建 jwks token',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {}
|
||||
}
|
||||
}).define(async () => {
|
||||
@@ -77,6 +80,7 @@ app.route({
|
||||
key: 'info',
|
||||
description: '显示 baseURL',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
add: z.string().optional().describe('添加 baseURL'),
|
||||
remove: z.number().optional().describe('按编号移除 baseURL'),
|
||||
@@ -166,6 +170,7 @@ app.route({
|
||||
key: 'set',
|
||||
description: '设置 baseURL',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
baseURL: z.string().optional().describe('baseURL 地址'),
|
||||
}
|
||||
@@ -185,6 +190,7 @@ app.route({
|
||||
key: 'manage',
|
||||
description: 'registry 管理',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
list: z.boolean().optional().describe('列出 registry'),
|
||||
set: z.string().optional().describe('设置 registry'),
|
||||
@@ -219,7 +225,10 @@ app.route({
|
||||
path: 'baseURL',
|
||||
key: 'kevisual',
|
||||
description: 'kevisual registry',
|
||||
metadata: { args: {} }
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {}
|
||||
}
|
||||
}).define(async () => {
|
||||
const config = getConfig();
|
||||
const defaultRegistry = ['https://kevisual.cn'];
|
||||
@@ -227,23 +236,14 @@ app.route({
|
||||
showList(defaultRegistry);
|
||||
}).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({
|
||||
path: 'baseURL',
|
||||
key: 'local',
|
||||
description: 'local registry',
|
||||
metadata: { args: {} }
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {}
|
||||
}
|
||||
}).define(async () => {
|
||||
const config = getConfig();
|
||||
const defaultRegistry = ['http://localhost:3005'];
|
||||
|
||||
@@ -97,6 +97,7 @@ app.route({
|
||||
key: 'main',
|
||||
description: 'update cli',
|
||||
metadata: {
|
||||
middleware: ['auth'],
|
||||
args: {
|
||||
global: z.boolean().optional().describe('update global'),
|
||||
npm: z.boolean().optional().describe('use npm to update'),
|
||||
@@ -107,7 +108,7 @@ app.route({
|
||||
const { global, npm, force } = ctx.args;
|
||||
try {
|
||||
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' });
|
||||
} else {
|
||||
const forceUpdate = force ? true : false;
|
||||
|
||||
Reference in New Issue
Block a user