@kevisual/router 0.0.88 → 0.0.89

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.
package/dist/app.js CHANGED
@@ -19579,7 +19579,7 @@ app
19579
19579
  10. **中间件找不到会返回 404**,错误信息中会包含找不到的中间件列表。
19580
19580
  `;
19581
19581
  // package.json
19582
- var version2 = "0.0.88";
19582
+ var version2 = "0.0.89";
19583
19583
 
19584
19584
  // agent/routes/route-create.ts
19585
19585
  app.route({
@@ -1,6 +1,6 @@
1
1
  import { EventEmitter } from 'eventemitter3';
2
2
  import { z } from 'zod';
3
- import { program } from 'commander';
3
+ import { Command } from 'commander';
4
4
  import * as http from 'node:http';
5
5
  import { IncomingMessage, ServerResponse } from 'node:http';
6
6
  import { IncomingMessage as IncomingMessage$1, ServerResponse as ServerResponse$1 } from 'http';
@@ -804,12 +804,13 @@ declare const parseArgs: (args: string) => any;
804
804
  declare const parseDescription: (route: App["routes"][number]) => string;
805
805
  declare const createCommand: (opts: {
806
806
  app: App;
807
- program: typeof program;
807
+ program: Command;
808
808
  }) => void;
809
809
  declare const parse: (opts: {
810
810
  app: QueryRouterServer;
811
811
  description?: string;
812
812
  parse?: boolean;
813
+ program?: Command;
813
814
  }) => void;
814
815
 
815
816
  export { createCommand, groupByPath, parse, parseArgs, parseDescription };
package/dist/commander.js CHANGED
@@ -2195,7 +2195,7 @@ var createCommand2 = (opts) => {
2195
2195
  for (const path in groupRoutes) {
2196
2196
  const routeList = groupRoutes[path];
2197
2197
  const keys = routeList.map((route) => route.key).filter(Boolean);
2198
- const subProgram = program2.command(path).description(`路由《${path} ${keys.length > 0 ? ": " + keys.join(", ") : ""}`);
2198
+ const subProgram = program2.command(path).description(`路由[${path}] ${keys.length > 0 ? ": " + keys.join(", ") : ""}`);
2199
2199
  routeList.forEach((route) => {
2200
2200
  if (!route.key)
2201
2201
  return;
@@ -2227,10 +2227,11 @@ var createCommand2 = (opts) => {
2227
2227
  };
2228
2228
  var parse = (opts) => {
2229
2229
  const { app, description, parse: parse2 = true } = opts;
2230
- program.description(description || "Router 命令行工具");
2231
- createCommand2({ app, program });
2230
+ const _program = opts.program || program;
2231
+ _program.description(description || "Router 命令行工具");
2232
+ createCommand2({ app, program: _program });
2232
2233
  if (parse2) {
2233
- program.parse(process.argv);
2234
+ _program.parse(process.argv);
2234
2235
  }
2235
2236
  };
2236
2237
  export {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@kevisual/router",
4
- "version": "0.0.88",
4
+ "version": "0.0.89",
5
5
  "description": "",
6
6
  "type": "module",
7
7
  "main": "./dist/router.js",
@@ -29,7 +29,7 @@
29
29
  "@kevisual/local-proxy": "^0.0.8",
30
30
  "@kevisual/query": "^0.0.53",
31
31
  "@kevisual/use-config": "^1.0.30",
32
- "@opencode-ai/plugin": "^1.2.20",
32
+ "@opencode-ai/plugin": "^1.2.21",
33
33
  "@types/bun": "^1.3.10",
34
34
  "@types/node": "^25.3.5",
35
35
  "@types/send": "^1.2.1",
package/src/commander.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { program } from 'commander';
1
+ import { Command, program } from 'commander';
2
2
  import { App, QueryRouterServer } from './app.ts';
3
3
 
4
4
  export const groupByPath = (routes: App['routes']) => {
@@ -62,7 +62,7 @@ export const parseDescription = (route: App['routes'][number]) => {
62
62
  }
63
63
  return desc;
64
64
  }
65
- export const createCommand = (opts: { app: App, program: typeof program }) => {
65
+ export const createCommand = (opts: { app: App, program: Command }) => {
66
66
  const { app, program } = opts;
67
67
  const routes = app.routes;
68
68
 
@@ -71,7 +71,7 @@ export const createCommand = (opts: { app: App, program: typeof program }) => {
71
71
  for (const path in groupRoutes) {
72
72
  const routeList = groupRoutes[path];
73
73
  const keys = routeList.map(route => route.key).filter(Boolean);
74
- const subProgram = program.command(path).description(`路由《${path} ${keys.length > 0 ? ': ' + keys.join(', ') : ''}`);
74
+ const subProgram = program.command(path).description(`路由[${path}] ${keys.length > 0 ? ': ' + keys.join(', ') : ''}`);
75
75
  routeList.forEach(route => {
76
76
  if (!route.key) return;
77
77
  const description = parseDescription(route);
@@ -103,11 +103,12 @@ export const createCommand = (opts: { app: App, program: typeof program }) => {
103
103
  }
104
104
  }
105
105
 
106
- export const parse = (opts: { app: QueryRouterServer, description?: string, parse?: boolean }) => {
107
- const { app, description, parse = true } = opts;
108
- program.description(description || 'Router 命令行工具');
109
- createCommand({ app: app as App, program });
106
+ export const parse = (opts: { app: QueryRouterServer, description?: string, parse?: boolean, program?: Command }) => {
107
+ const { app, description, parse = true, } = opts;
108
+ const _program = opts.program || program;
109
+ _program.description(description || 'Router 命令行工具');
110
+ createCommand({ app: app as App, program: _program });
110
111
  if (parse) {
111
- program.parse(process.argv);
112
+ _program.parse(process.argv);
112
113
  }
113
114
  }