@vforsh/notif 0.2.0 → 0.3.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vforsh/notif",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "CLI for sending push notifications via ntfy",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -43,13 +43,14 @@ notif --topic other-channel "Override topic"
43
43
 
44
44
  **NEVER send `localhost` or `127.0.0.1` URLs in notifications.** Notifications arrive on mobile devices on the same Wi-Fi network — localhost is unreachable there.
45
45
 
46
- Replace with the machine's LAN IP before sending:
46
+ Use `lan_ip` from config (check with `notif cfg ls`) instead:
47
47
 
48
48
  ```bash
49
- LAN_IP=$(ipconfig getifaddr en0)
50
- notif --click "http://$LAN_IP:3000" "Dev server ready"
49
+ notif --click "http://192.168.1.12:3000" "Dev server ready"
51
50
  ```
52
51
 
52
+ Fallback if `lan_ip` is not configured: `ipconfig getifaddr en0`.
53
+
53
54
  This applies to `--click` URLs, URLs in message body, and any other link.
54
55
 
55
56
  ## Config
@@ -70,6 +71,7 @@ This applies to `--click` URLs, URLs in message body, and any other link.
70
71
  | `token` | Auth token (secret, set via stdin) |
71
72
  | `upload_provider` | Storage provider for `--file` uploads (e.g. `yadisk`) |
72
73
  | `upload_path` | Remote directory for uploads (default: `/notif-uploads`) |
74
+ | `lan_ip` | Machine's LAN IP — use instead of `localhost` in notification URLs |
73
75
 
74
76
  ## Errors
75
77
 
@@ -70,6 +70,7 @@ export function registerConfigCommand(program: Command) {
70
70
  const topic = await prompt("topic", current.topic);
71
71
  const upload_provider = await prompt("upload_provider", current.upload_provider);
72
72
  const upload_path = await prompt("upload_path", current.upload_path);
73
+ const lan_ip = await prompt("lan_ip", current.lan_ip);
73
74
  const user = await prompt("user", current.user, true);
74
75
  const token = await prompt("token", current.token, true);
75
76
 
@@ -78,6 +79,7 @@ export function registerConfigCommand(program: Command) {
78
79
  if (topic) updated.topic = topic;
79
80
  if (upload_provider) updated.upload_provider = upload_provider;
80
81
  if (upload_path) updated.upload_path = upload_path;
82
+ if (lan_ip) updated.lan_ip = lan_ip;
81
83
  if (user) updated.user = user;
82
84
  if (token) updated.token = token;
83
85
 
package/src/lib/config.ts CHANGED
@@ -12,11 +12,12 @@ const ConfigSchema = z.object({
12
12
  token: z.string().optional(),
13
13
  upload_provider: z.string().optional(),
14
14
  upload_path: z.string().optional(),
15
+ lan_ip: z.string().optional(),
15
16
  });
16
17
 
17
18
  export type Config = z.infer<typeof ConfigSchema>;
18
19
 
19
- const VALID_KEYS = ["server", "topic", "user", "token", "upload_provider", "upload_path"] as const;
20
+ const VALID_KEYS = ["server", "topic", "user", "token", "upload_provider", "upload_path", "lan_ip"] as const;
20
21
  type ConfigKey = (typeof VALID_KEYS)[number];
21
22
 
22
23
  export function isValidKey(key: string): key is ConfigKey {