@kevisual/cli 0.0.85 → 0.0.87

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -95523,32 +95523,38 @@ class AssistantInit extends AssistantConfig {
95523
95523
  "description": "assistant-app package pnpm, node pkgs projects",
95524
95524
  "type": "module",
95525
95525
  "scripts": {
95526
- "start": "pm2 start apps/root/code-center/app.mjs --name root/code-center",
95527
- "cnb": "ASSISTANT_CONFIG_DIR=/workspace asst server -s -p 7878"
95526
+ "start": "pm2 start apps/code-center/dist/app.mjs --name code-center",
95527
+ "proxy": "pm2 start apps/page-proxy/dist/app.mjs --name page-proxy",
95528
+ "preview": "pnpm i && ASSISTANT_CONFIG_DIR=/workspace asst server -s -p 8686"
95528
95529
  },
95529
95530
  "keywords": [],
95530
95531
  "author": "",
95531
95532
  "license": "ISC",
95532
95533
  "dependencies": {
95534
+ "@aws-sdk/client-s3": "latest",
95535
+ "@kevisual/oss": "latest",
95536
+ "@kevisual/query": "latest",
95533
95537
  "@kevisual/router": "latest",
95534
95538
  "@kevisual/use-config": "latest",
95535
- "@kevisual/query": "latest",
95539
+ "better-sqlite3": "latest",
95540
+ "crypto-js": "latest",
95541
+ "dayjs": "latest",
95542
+ "dotenv": "latest",
95543
+ "es-toolkit": "latest",
95544
+ "eventemitter3": "latest",
95536
95545
  "ioredis": "latest",
95537
95546
  "minio": "latest",
95547
+ "node-cron": "latest",
95538
95548
  "pg": "latest",
95539
95549
  "pm2": "latest",
95540
95550
  "sequelize": "latest",
95541
- "crypto-js": "latest",
95542
- "better-sqlite3": "latest",
95543
- "unstorage": "latest",
95544
- "dayjs": "latest",
95545
- "es-toolkit": "latest",
95546
- "node-cron": "latest",
95547
- "dotenv": "latest"
95551
+ "unstorage": "latest"
95548
95552
  },
95549
95553
  "devDependencies": {
95550
- "@types/node": "latest",
95551
- "@types/crypto-js": "latest"
95554
+ "@kevisual/types": "^0.0.11",
95555
+ "@types/bun": "^1.3.6",
95556
+ "@types/crypto-js": "latest",
95557
+ "@types/node": "latest"
95552
95558
  }
95553
95559
  }
95554
95560
  `);
@@ -102190,7 +102196,7 @@ var authFilter = async (req, res) => {
102190
102196
  const share = auth.share || "protected";
102191
102197
  const noAdmin = !auth.username;
102192
102198
  if (noAdmin)
102193
- return false;
102199
+ return { code: 500, message: "没有管理员" };
102194
102200
  const admin = auth.username;
102195
102201
  const admins = auth.admin || [];
102196
102202
  if (admin) {
@@ -102199,39 +102205,40 @@ var authFilter = async (req, res) => {
102199
102205
  const url3 = new URL(req.url, "http://localhost");
102200
102206
  const pathname = decodeURIComponent(url3.pathname);
102201
102207
  if (pathname === "/" || pathname === "/favicon.ico") {
102202
- return false;
102208
+ return { code: 200, message: "允许访问根路径" };
102203
102209
  }
102204
102210
  if (pathname.startsWith("/root/home") || pathname === "/root/cli") {
102205
- return false;
102211
+ return { code: 200, message: "允许访问首页" };
102206
102212
  }
102207
- const openApiPaths = ["/api", "/v1", "/client", "/serve"];
102213
+ const openApiPaths = ["/api", "/v1", "/client", "/serve", "/proxy"];
102208
102214
  for (const openPath of openApiPaths) {
102209
102215
  if (pathname.startsWith(openPath)) {
102210
- return false;
102216
+ return { code: 200, message: "允许访问API" };
102211
102217
  }
102212
102218
  }
102213
102219
  if (share === "public") {
102214
- return false;
102220
+ return { code: 200, message: "公开模式允许访问" };
102215
102221
  }
102216
102222
  const { token } = await getToken(req);
102217
102223
  if (!token) {
102218
102224
  res.writeHead(302, { Location: `/root/home/` });
102219
102225
  res.end();
102220
- return false;
102226
+ return { code: 500, message: "未登录" };
102221
102227
  }
102222
102228
  const tokenUser = await getTokenUserCache(token);
102229
+ console.log("authFilter tokenUser", tokenUser, token);
102223
102230
  if (share === "protected" && tokenUser?.code === 200) {
102224
- return false;
102231
+ return { code: 200, message: "受保护模式已登录允许访问" };
102225
102232
  }
102226
102233
  if (share === "private") {
102227
102234
  if (tokenUser?.code === 200) {
102228
102235
  const username = tokenUser?.data?.username;
102229
102236
  if (admins.includes(username)) {
102230
- return false;
102237
+ return { code: 200, message: "私有模式管理员允许访问" };
102231
102238
  }
102232
102239
  }
102233
102240
  }
102234
- return true;
102241
+ return { code: 500, message: "没有权限访问" };
102235
102242
  };
102236
102243
  var proxyRoute = async (req, res) => {
102237
102244
  const _assistantConfig = assistantConfig2.getCacheAssistantConfig();
@@ -102271,6 +102278,14 @@ var proxyRoute = async (req, res) => {
102271
102278
  const apiBackendProxy = allProxy.find((item) => pathname.startsWith(item.path));
102272
102279
  if (apiBackendProxy) {
102273
102280
  log.debug("apiBackendProxy", { apiBackendProxy, url: req.url });
102281
+ if (apiBackendProxy.s3?.id) {
102282
+ const storage = _assistantConfig?.storage || [];
102283
+ const storageConfig = storage.find((item) => item.id === apiBackendProxy.s3?.id);
102284
+ apiBackendProxy.s3 = {
102285
+ ...storageConfig,
102286
+ ...apiBackendProxy.s3
102287
+ };
102288
+ }
102274
102289
  return proxy(req, res, {
102275
102290
  path: apiBackendProxy.path,
102276
102291
  target: apiBackendProxy.target,
@@ -102319,7 +102334,8 @@ var proxyRoute = async (req, res) => {
102319
102334
  });
102320
102335
  }
102321
102336
  const filter2 = await authFilter(req, res);
102322
- if (filter2) {
102337
+ if (filter2.code !== 200) {
102338
+ console.log("auth filter deny", filter2);
102323
102339
  res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
102324
102340
  return res.end(renderNoAuthAndLogin("Not Authorized Proxy"));
102325
102341
  }
package/dist/assistant.js CHANGED
@@ -55189,32 +55189,38 @@ class AssistantInit extends AssistantConfig {
55189
55189
  "description": "assistant-app package pnpm, node pkgs projects",
55190
55190
  "type": "module",
55191
55191
  "scripts": {
55192
- "start": "pm2 start apps/root/code-center/app.mjs --name root/code-center",
55193
- "cnb": "ASSISTANT_CONFIG_DIR=/workspace asst server -s -p 7878"
55192
+ "start": "pm2 start apps/code-center/dist/app.mjs --name code-center",
55193
+ "proxy": "pm2 start apps/page-proxy/dist/app.mjs --name page-proxy",
55194
+ "preview": "pnpm i && ASSISTANT_CONFIG_DIR=/workspace asst server -s -p 8686"
55194
55195
  },
55195
55196
  "keywords": [],
55196
55197
  "author": "",
55197
55198
  "license": "ISC",
55198
55199
  "dependencies": {
55200
+ "@aws-sdk/client-s3": "latest",
55201
+ "@kevisual/oss": "latest",
55202
+ "@kevisual/query": "latest",
55199
55203
  "@kevisual/router": "latest",
55200
55204
  "@kevisual/use-config": "latest",
55201
- "@kevisual/query": "latest",
55205
+ "better-sqlite3": "latest",
55206
+ "crypto-js": "latest",
55207
+ "dayjs": "latest",
55208
+ "dotenv": "latest",
55209
+ "es-toolkit": "latest",
55210
+ "eventemitter3": "latest",
55202
55211
  "ioredis": "latest",
55203
55212
  "minio": "latest",
55213
+ "node-cron": "latest",
55204
55214
  "pg": "latest",
55205
55215
  "pm2": "latest",
55206
55216
  "sequelize": "latest",
55207
- "crypto-js": "latest",
55208
- "better-sqlite3": "latest",
55209
- "unstorage": "latest",
55210
- "dayjs": "latest",
55211
- "es-toolkit": "latest",
55212
- "node-cron": "latest",
55213
- "dotenv": "latest"
55217
+ "unstorage": "latest"
55214
55218
  },
55215
55219
  "devDependencies": {
55216
- "@types/node": "latest",
55217
- "@types/crypto-js": "latest"
55220
+ "@kevisual/types": "^0.0.11",
55221
+ "@types/bun": "^1.3.6",
55222
+ "@types/crypto-js": "latest",
55223
+ "@types/node": "latest"
55218
55224
  }
55219
55225
  }
55220
55226
  `);
@@ -58645,82 +58651,8 @@ commdands.forEach((name) => {
58645
58651
  });
58646
58652
 
58647
58653
  // src/command/run-scripts/index.ts
58648
- import { spawnSync as spawnSync5 } from "node:child_process";
58649
58654
  import path11 from "node:path";
58650
58655
  import fs12 from "node:fs";
58651
- var runScriptsCommand = new Command("run-scripts").alias("run").arguments("<cmd> [env]").option("-l --local", "使用当前文件夹的package.json中的scripts", false).description("运行脚本,在assistant.config.json中配置的脚本").action(async (cmd, env3, opts) => {
58652
- const useLocal = opts.local;
58653
- const showScripts = cmd === "show";
58654
- const showScriptFunc = (scripts2) => {
58655
- console.log("可用的本地脚本:");
58656
- let has = false;
58657
- Object.keys(scripts2).forEach((key) => {
58658
- console.log(`- ${key}: ${scripts2[key]}`);
58659
- has = true;
58660
- });
58661
- if (!has) {
58662
- console.log("当前未定义任何脚本。");
58663
- }
58664
- };
58665
- if (useLocal) {
58666
- const pkgPath = path11.join(process.cwd(), "package.json");
58667
- if (checkFileExists(pkgPath) === false) {
58668
- console.error("当前目录下未找到 package.json 文件。");
58669
- return;
58670
- }
58671
- const pkg = JSON.parse(fs12.readFileSync(pkgPath, "utf-8"));
58672
- const scripts2 = pkg.scripts || {};
58673
- if (showScripts) {
58674
- showScriptFunc(scripts2);
58675
- return;
58676
- }
58677
- const script = scripts2[cmd];
58678
- if (!script) {
58679
- console.error(`Script "${cmd}" not found in local package.json.`);
58680
- return;
58681
- }
58682
- const command2 = [script, ...env3 ? [env3] : []].join(" ");
58683
- const res = spawnSync5(command2, { shell: true, stdio: "inherit", cwd: assistantConfig2.configDir });
58684
- console.log(`执行 "[${command2}]"...`);
58685
- if (res.error) {
58686
- console.error(`执行失败 "${cmd}":`, res.error);
58687
- return;
58688
- }
58689
- if (res.status !== 0) {
58690
- console.error(`本地脚本 "${cmd}" 以代码 ${res.status} 退出`);
58691
- return;
58692
- }
58693
- return;
58694
- }
58695
- assistantConfig2.checkMounted();
58696
- const configs = assistantConfig2.getCacheAssistantConfig();
58697
- const scripts = configs?.scripts || {};
58698
- try {
58699
- const script = scripts[cmd];
58700
- if (showScripts) {
58701
- showScriptFunc(scripts);
58702
- return;
58703
- }
58704
- if (!script) {
58705
- console.error(`Script "${cmd}" not found.`);
58706
- return;
58707
- }
58708
- const command2 = [script, ...env3 ? [env3] : []].join(" ");
58709
- const res = spawnSync5(command2, { shell: true, stdio: "inherit", cwd: assistantConfig2.configDir });
58710
- if (res.error) {
58711
- console.error(`Error running script "${cmd}":`, res.error);
58712
- return;
58713
- }
58714
- if (res.status !== 0) {
58715
- console.error(`Script "${cmd}" exited with code ${res.status}`);
58716
- return;
58717
- }
58718
- console.log(`Script "${cmd}" run successfully.`);
58719
- } catch (error2) {
58720
- console.error(`Failed to run script "${cmd}":`, error2);
58721
- }
58722
- });
58723
- program.addCommand(runScriptsCommand);
58724
58656
  var createRandomApp = (opts) => {
58725
58657
  const { app, package: packageJson, pwd } = opts;
58726
58658
  if (!app.status) {