@syengup/friday-channel-next 0.0.2 → 0.0.5

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 (3) hide show
  1. package/install.js +41 -8
  2. package/install.sh +38 -7
  3. package/package.json +3 -2
package/install.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { execSync } from "node:child_process";
3
3
  import { cpSync, existsSync, readFileSync, writeFileSync } from "node:fs";
4
- import { homedir } from "node:os";
4
+ import { homedir, networkInterfaces } from "node:os";
5
5
  import { dirname, join, relative, resolve, sep } from "node:path";
6
6
  import { fileURLToPath } from "node:url";
7
7
 
@@ -15,15 +15,14 @@ const REPO_URL = process.env.FRIDAY_NEXT_REPO || "https://github.com/SyengUp/ope
15
15
  const G = (s) => `\x1b[32m${s}\x1b[0m`;
16
16
  const Y = (s) => `\x1b[33m${s}\x1b[0m`;
17
17
  const R = (s) => `\x1b[31m${s}\x1b[0m`;
18
-
19
18
  function log(msg) {
20
- console.log(`${G("[friday-next]")} ${msg}`);
19
+ console.log(` ${msg}`);
21
20
  }
22
21
  function warn(msg) {
23
- console.log(`${Y("[friday-next]")} ${msg}`);
22
+ console.log(` ${Y("!")} ${msg}`);
24
23
  }
25
24
  function err(msg) {
26
- console.error(`${R("[friday-next]")} ${msg}`);
25
+ console.error(` ${R("X")} ${msg}`);
27
26
  }
28
27
 
29
28
  function has(cmd) {
@@ -149,10 +148,44 @@ console.log(" Config updated.");
149
148
  log("Restarting OpenClaw gateway...");
150
149
  execSync("openclaw gateway restart", { stdio: "inherit" });
151
150
 
151
+ // --------------- show connection info ---------------
152
+
153
+ function getLanIp() {
154
+ const nets = networkInterfaces();
155
+ for (const name of Object.keys(nets)) {
156
+ for (const net of nets[name]) {
157
+ if (net.family === "IPv4" && !net.internal) {
158
+ return net.address;
159
+ }
160
+ }
161
+ }
162
+ return "127.0.0.1";
163
+ }
164
+
165
+ const gatewayPort = config.gateway?.port || 18789;
166
+ const gatewayToken = config.gateway?.auth?.token || "(not set)";
167
+ const bindMode = config.gateway?.bind || "localhost";
168
+
169
+ let gatewayUrl;
170
+ if (bindMode === "lan") {
171
+ const ip = getLanIp();
172
+ gatewayUrl = `http://${ip}:${gatewayPort}`;
173
+ } else {
174
+ gatewayUrl = `http://127.0.0.1:${gatewayPort}`;
175
+ }
176
+
152
177
  log("--------------------------------------------------");
153
178
  log("Installation complete! Friday Next channel is now active.");
179
+ const BOLD_YELLOW = (s) => `\x1b[1;33m${s}\x1b[0m`;
180
+
181
+ log("");
182
+ log("Gateway URL: " + BOLD_YELLOW(gatewayUrl));
183
+ log("Bearer Token: " + BOLD_YELLOW(gatewayToken));
184
+ log("");
185
+ log(BOLD_YELLOW("Input the URL and Token above into your FridayNext app to connect."));
186
+ log(BOLD_YELLOW("请将上方 URL 和 Token 输入至 FridayNext App 完成连接。"));
154
187
  log("");
155
- log("The channel uses your gateway auth token by default.");
156
- log("To use a different token, set FRIDAY_NEXT_AUTH_TOKEN env var or");
157
- log("add authToken to channels.friday-next in openclaw.json.");
188
+ log("This is a LOCAL network URL (bind=" + bindMode + ").");
189
+ log("If you need a public URL for remote access, configure it");
190
+ log("via HTTPS, Tailscale, or a reverse proxy yourself.");
158
191
  log("--------------------------------------------------");
package/install.sh CHANGED
@@ -15,9 +15,9 @@ GREEN='\033[0;32m'
15
15
  YELLOW='\033[1;33m'
16
16
  NC='\033[0m'
17
17
 
18
- log() { printf "%b%s\\n" "${GREEN}[friday-next]${NC} " "$1"; }
19
- warn() { printf "%b%s\\n" "${YELLOW}[friday-next]${NC} " "$1"; }
20
- err() { printf "%b%s\\n" "${RED}[friday-next]${NC} " "$1" >&2; }
18
+ log() { printf " %s\\n" "$1"; }
19
+ warn() { printf " ${YELLOW}!${NC} %s\\n" "$1"; }
20
+ err() { printf " ${RED}X${NC} %s\\n" "$1" >&2; }
21
21
 
22
22
  trap 'err "Install failed."' ERR
23
23
 
@@ -109,10 +109,41 @@ console.log(" Config updated.");
109
109
  log "Restarting OpenClaw gateway..."
110
110
  openclaw gateway restart
111
111
 
112
+ # Show connection info
113
+ node --input-type=module -e '
114
+ import { readFileSync } from "node:fs";
115
+ import { networkInterfaces } from "node:os";
116
+
117
+ const config = JSON.parse(readFileSync(process.argv[1], "utf8"));
118
+
119
+ function getLanIp() {
120
+ const nets = networkInterfaces();
121
+ for (const name of Object.keys(nets)) {
122
+ for (const net of nets[name]) {
123
+ if (net.family === "IPv4" && !net.internal) return net.address;
124
+ }
125
+ }
126
+ return "127.0.0.1";
127
+ }
128
+
129
+ const port = config.gateway?.port || 18789;
130
+ const token = config.gateway?.auth?.token || "(not set)";
131
+ const bind = config.gateway?.bind || "localhost";
132
+ const host = bind === "lan" ? getLanIp() : "127.0.0.1";
133
+
134
+ const YB = '\x1b[1;33m', N = '\x1b[0m';
135
+ console.log("");
136
+ console.log("Gateway URL: " + YB + "http://" + host + ":" + port + N);
137
+ console.log("Bearer Token: " + YB + token + N);
138
+ console.log("");
139
+ console.log(YB + "Input the URL and Token above into your FridayNext app to connect." + N);
140
+ console.log(YB + "请将上方 URL 和 Token 输入至 FridayNext App 完成连接。" + N);
141
+ console.log("");
142
+ console.log("This is a LOCAL network URL (bind=" + bind + ").");
143
+ console.log("If you need a public URL for remote access, configure it");
144
+ console.log("via HTTPS, Tailscale, or a reverse proxy yourself.");
145
+ ' "$OPENCLAW_CONFIG"
146
+
112
147
  log "--------------------------------------------------"
113
148
  log "Installation complete! Friday Next channel is now active."
114
- log ""
115
- log "The channel uses your gateway auth token by default."
116
- log "To use a different token, set FRIDAY_NEXT_AUTH_TOKEN env var or"
117
- log "add authToken to channels.friday-next in openclaw.json."
118
149
  log "--------------------------------------------------"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syengup/friday-channel-next",
3
- "version": "0.0.2",
3
+ "version": "0.0.5",
4
4
  "description": "OpenClaw Friday Next Apple channel plugin",
5
5
  "type": "module",
6
6
  "files": [
@@ -21,7 +21,8 @@
21
21
  "test:msg-live": "node scripts/message-roundtrip-live.mjs"
22
22
  },
23
23
  "bin": {
24
- "install-friday-next": "./install.mjs"
24
+ "friday-channel-next": "./install.js",
25
+ "install-friday-next": "./install.js"
25
26
  },
26
27
  "main": "./dist/index.js",
27
28
  "types": "./dist/index.d.ts",