discstation 0.1.22 → 0.1.23

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": "discstation",
3
- "version": "0.1.22",
3
+ "version": "0.1.23",
4
4
  "description": "DiscStation optical-media appliance host — one cross-OS installer",
5
5
  "bin": {
6
6
  "discstation-setup": "scripts/setup.mjs",
@@ -0,0 +1,14 @@
1
+ import { networkInterfaces } from 'node:os';
2
+
3
+ /** First non-internal IPv4 LAN address, so other devices on the network know
4
+ * what to open — mirrors discstation.py's local_ip(). Falls back to
5
+ * 'localhost' if nothing's found (e.g. no network connection). */
6
+ export function lanIp() {
7
+ const nets = networkInterfaces();
8
+ for (const name of Object.keys(nets)) {
9
+ for (const net of nets[name] || []) {
10
+ if (net.family === 'IPv4' && !net.internal) return net.address;
11
+ }
12
+ }
13
+ return 'localhost';
14
+ }
package/scripts/open.mjs CHANGED
@@ -5,6 +5,7 @@
5
5
 
6
6
  import { spawn } from 'node:child_process';
7
7
  import { get } from 'node:http';
8
+ import { lanIp } from './lib/net.mjs';
8
9
 
9
10
  const port = process.env.DISCSTATION_HTTP_PORT || '8081';
10
11
  const url = process.argv[2] || `http://localhost:${port}/`;
@@ -24,6 +25,7 @@ function open(target) {
24
25
  // Best-effort liveness check so a stopped host gives a clear hint.
25
26
  const probe = get(url, { timeout: 1500 }, (res) => {
26
27
  res.resume();
28
+ console.log(`Also reachable at http://${lanIp()}:${port}/ from any phone/computer on your network.`);
27
29
  open(url);
28
30
  });
29
31
  probe.on('timeout', () => probe.destroy());
package/scripts/setup.mjs CHANGED
@@ -8,6 +8,7 @@ import { spawnSync } from 'node:child_process';
8
8
  import { existsSync } from 'node:fs';
9
9
  import { dirname, join, resolve } from 'node:path';
10
10
  import { fileURLToPath } from 'node:url';
11
+ import { lanIp } from './lib/net.mjs';
11
12
 
12
13
  const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..');
13
14
  const args = process.argv.slice(2);
@@ -45,9 +46,11 @@ function run(cmd, cmdArgs) {
45
46
  }
46
47
  if ((r.status ?? 1) === 0) {
47
48
  const port = process.env.DISCSTATION_HTTP_PORT || '8081';
49
+ const ip = lanIp();
48
50
  console.log(
49
51
  `\nDiscStation is installed and running.\n` +
50
- ` Web UI: http://localhost:${port}/ (run "discstation" to open it any time)\n` +
52
+ ` Web UI: http://${ip}:${port}/ (run "discstation" to open it any time)\n` +
53
+ ` Open that address from any phone/computer on your network too.\n` +
51
54
  ` Install it as an app from the browser menu, or the in-page INSTALL APP button.\n`,
52
55
  );
53
56
  spawnSync(process.execPath, [join(ROOT, 'scripts', 'open.mjs')], { stdio: 'ignore' });