ccpanel 0.1.0 → 0.1.2

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.
Files changed (2) hide show
  1. package/dist/cli.js +32 -6
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -7,10 +7,11 @@ import {
7
7
  } from "./chunk-7ROXP6AO.js";
8
8
 
9
9
  // src/cli.ts
10
- import { homedir } from "os";
10
+ import { homedir, networkInterfaces } from "os";
11
11
  import { join as join6 } from "path";
12
12
  import { createServer } from "net";
13
- import { fileURLToPath, pathToFileURL } from "url";
13
+ import { fileURLToPath } from "url";
14
+ import { realpathSync } from "fs";
14
15
  import { serve } from "@hono/node-server";
15
16
  import open from "open";
16
17
 
@@ -1037,14 +1038,38 @@ async function main() {
1037
1038
  registryFile,
1038
1039
  webRoot
1039
1040
  });
1040
- const port = await findFreePort(7788);
1041
- serve({ fetch: app.fetch, port });
1041
+ const host = process.env.HOST ?? "0.0.0.0";
1042
+ const desired = process.env.PORT ? Number(process.env.PORT) : 7788;
1043
+ const port = await findFreePort(desired);
1044
+ serve({ fetch: app.fetch, port, hostname: host });
1042
1045
  const url = `http://localhost:${port}`;
1043
1046
  console.log(`ccpanel \u5DF2\u542F\u52A8\uFF1A${url}`);
1044
- await open(url);
1047
+ for (const ip of lanAddresses()) {
1048
+ console.log(` \u5C40\u57DF\u7F51\u8BBF\u95EE\uFF1A http://${ip}:${port}`);
1049
+ }
1050
+ if (!process.argv.includes("--no-open")) {
1051
+ open(url).then((sub) => sub?.on?.("error", () => {
1052
+ })).catch(() => console.log("\uFF08\u672A\u80FD\u81EA\u52A8\u6253\u5F00\u6D4F\u89C8\u5668\uFF0C\u8BF7\u624B\u52A8\u8BBF\u95EE\u4E0A\u9762\u7684\u5730\u5740\uFF09"));
1053
+ }
1054
+ }
1055
+ function lanAddresses() {
1056
+ const out = [];
1057
+ for (const addrs of Object.values(networkInterfaces())) {
1058
+ for (const a of addrs ?? []) {
1059
+ if (a.family === "IPv4" && !a.internal) out.push(a.address);
1060
+ }
1061
+ }
1062
+ return out;
1045
1063
  }
1046
1064
  function isMainModule(argvPath, moduleUrl) {
1047
- return !!argvPath && moduleUrl === pathToFileURL(argvPath).href;
1065
+ if (!argvPath) return false;
1066
+ const modulePath = fileURLToPath(moduleUrl);
1067
+ if (argvPath === modulePath) return true;
1068
+ try {
1069
+ return realpathSync(argvPath) === realpathSync(modulePath);
1070
+ } catch {
1071
+ return false;
1072
+ }
1048
1073
  }
1049
1074
  if (isMainModule(process.argv[1], import.meta.url)) {
1050
1075
  void main();
@@ -1052,5 +1077,6 @@ if (isMainModule(process.argv[1], import.meta.url)) {
1052
1077
  export {
1053
1078
  findFreePort,
1054
1079
  isMainModule,
1080
+ lanAddresses,
1055
1081
  main
1056
1082
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccpanel",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "本地图形化管理 Claude Code 配置:MCP、Skills、子 Agent、Commands、配置文件、Memory、Sessions、Plugins",
5
5
  "type": "module",
6
6
  "repository": { "type": "git", "url": "git+https://gitee.com/jerry123456789099/ccpanel.git" },