discstation 0.1.11 → 0.1.12

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/README.md CHANGED
@@ -47,9 +47,16 @@ playback, ripping, phone uploads, and ESP32 remote control.
47
47
 
48
48
  ```bash
49
49
  npm install -g discstation
50
- discstation-setup # dispatches to the installer for your OS
50
+ discstation-setup # dispatches to the installer for your OS, then opens the UI
51
51
  ```
52
52
 
53
+ The host runs as a background service; the UI is the built-in web app at
54
+ `http://localhost:8081`. `discstation-setup` opens it when it finishes, and the
55
+ `discstation` command re-opens it any time. It's a PWA — use your browser's
56
+ **Install DiscStation** (or the in-page **INSTALL APP** button on Chromium) to
57
+ get a standalone app window with a dock/taskbar icon on macOS, Linux, and
58
+ Windows.
59
+
53
60
  `discstation-setup --help` lists the forwarded env vars. From a git clone,
54
61
  `npm run setup` does the same thing. Support by OS:
55
62
 
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "discstation",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "DiscStation optical-media appliance host — one cross-OS installer",
5
5
  "bin": {
6
- "discstation-setup": "scripts/setup.mjs"
6
+ "discstation-setup": "scripts/setup.mjs",
7
+ "discstation": "scripts/open.mjs"
7
8
  },
8
9
  "scripts": {
9
10
  "setup": "node scripts/setup.mjs"
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env node
2
+ // `discstation` — open the local web UI in the default browser.
3
+ // The UI is a PWA: once open, use the browser's "Install DiscStation" (or the
4
+ // in-page INSTALL APP button on Chromium) to get a standalone app window.
5
+
6
+ import { spawn } from 'node:child_process';
7
+ import { get } from 'node:http';
8
+
9
+ const port = process.env.DISCSTATION_HTTP_PORT || '8081';
10
+ const url = process.argv[2] || `http://localhost:${port}/`;
11
+
12
+ function open(target) {
13
+ const [cmd, args] =
14
+ process.platform === 'darwin' ? ['open', [target]]
15
+ : process.platform === 'win32' ? ['cmd', ['/c', 'start', '', target]]
16
+ : ['xdg-open', [target]];
17
+ const child = spawn(cmd, args, { stdio: 'ignore', detached: true });
18
+ child.on('error', () => {
19
+ console.log(`Open this in your browser:\n ${target}`);
20
+ });
21
+ child.unref();
22
+ }
23
+
24
+ // Best-effort liveness check so a stopped host gives a clear hint.
25
+ const probe = get(url, { timeout: 1500 }, (res) => {
26
+ res.resume();
27
+ open(url);
28
+ });
29
+ probe.on('timeout', () => probe.destroy());
30
+ probe.on('error', () => {
31
+ console.log(
32
+ `DiscStation host isn't answering on ${url}\n` +
33
+ `Start it with "discstation-setup" (first run) or check the service:\n` +
34
+ ` linux: systemctl --user status discstation.service\n` +
35
+ ` macOS: launchctl print gui/$(id -u)/com.discstation.agent`,
36
+ );
37
+ open(url);
38
+ });
package/scripts/setup.mjs CHANGED
@@ -28,6 +28,9 @@ Linux script uses sudo for apt + group membership.
28
28
  Env vars (forwarded): DISCSTATION_APP_DIR, DISCSTATION_VENV_DIR,
29
29
  DISCSTATION_CONFIG_DIR, DISCSTATION_HTTP_PORT, DISC_DEVICE, DISC_PORT.
30
30
 
31
+ On success it opens the web UI (a PWA — install it from the browser for an app
32
+ window). Re-open it any time with the "discstation" command.
33
+
31
34
  Any extra arguments are passed straight to the platform script.
32
35
  `
33
36
  );
@@ -40,6 +43,15 @@ function run(cmd, cmdArgs) {
40
43
  console.error(`\n${cmd}: ${r.error.message}`);
41
44
  process.exit(1);
42
45
  }
46
+ if ((r.status ?? 1) === 0) {
47
+ const port = process.env.DISCSTATION_HTTP_PORT || '8081';
48
+ console.log(
49
+ `\nDiscStation is installed and running.\n` +
50
+ ` Web UI: http://localhost:${port}/ (run "discstation" to open it any time)\n` +
51
+ ` Install it as an app from the browser menu, or the in-page INSTALL APP button.\n`,
52
+ );
53
+ spawnSync(process.execPath, [join(ROOT, 'scripts', 'open.mjs')], { stdio: 'ignore' });
54
+ }
43
55
  process.exit(r.status ?? 1);
44
56
  }
45
57