pmtiles-swarm 0.3.1 โ†’ 0.3.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.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,23 @@
7
7
  ### ๐Ÿž Bug fixes
8
8
  - _...Add new stuff here..._
9
9
 
10
+ ## 0.3.2
11
+ ### โœจ Features and improvements
12
+ - **The console has a footer naming the version it is running**, beside `ยฉ <year> TechIdiots LLC`
13
+ and a link to the source. The version comes from `package.json` through `/api/status` rather than
14
+ being written into the page, since the number on screen is the one somebody quotes when reporting
15
+ a problem.
16
+
17
+ ### ๐Ÿ“š Documentation
18
+ - **How to update an installed service**, which was missing: reinstall into the same prefix and
19
+ restart. The restart is not optional โ€” the Python sidecar is started with the process and lives
20
+ as long as it does, so a new one sits on disk doing nothing until then, and most of what changes
21
+ between releases is in there.
22
+ - The WebRTC check given in two places imported a directory path, which ESM refuses whatever the
23
+ state of the install โ€” so it reported a failure that was never about WebRTC. It now imports
24
+ `node-datachannel` by name from the install directory, which is the binary the install script
25
+ fetches.
26
+
10
27
  ## 0.3.1
11
28
 
12
29
  Depends on pmtiles-torrent 0.3.0, which is what carries the resume-data fix below to an installed
@@ -104,8 +104,8 @@ the prebuilt binary WebTorrent needs for WebRTC, and it is not in the published
104
104
  tarball. Check it landed:
105
105
 
106
106
  ```sh
107
- sudo -u pmtiles-swarm -H node -e \
108
- "import('/var/lib/pmtiles-swarm/node_modules/webtorrent').then(() => console.log('ok'))"
107
+ cd /var/lib/pmtiles-swarm && sudo -u pmtiles-swarm -H node -e \
108
+ "import('node-datachannel').then(() => console.log('webrtc ok'))"
109
109
  ```
110
110
 
111
111
  `npm approve-scripts node-datachannel` records the approval in `package.json`
@@ -243,6 +243,43 @@ Four listeners, and only the peer ports want a firewall rule. See
243
243
  | `port` โ€” 8090 | your proxy or CDN |
244
244
  | `adminPort` โ€” 8091, bound to `127.0.0.1` | nothing; that is the point |
245
245
 
246
+ ## Updating
247
+
248
+ ```sh
249
+ sudo -u pmtiles-swarm -H npm install --prefix /var/lib/pmtiles-swarm pmtiles-swarm@latest
250
+ sudo systemctl restart pmtiles-swarm
251
+ ```
252
+
253
+ **The restart is not optional.** The Python sidecar is started with the process
254
+ and lives as long as it does, so a new sidecar sits on disk doing nothing until
255
+ the service is restarted. Most of what changes between releases is in there.
256
+
257
+ Nothing under `/etc/pmtiles-swarm` is touched, and restarting does not re-check
258
+ the archives: a clean stop writes resume data, and `TimeoutStopSec` above
259
+ leaves room for it.
260
+
261
+ Confirm both halves moved, since the sidecar has its own version:
262
+
263
+ ```sh
264
+ sudo -u pmtiles-swarm -H npm ls --prefix /var/lib/pmtiles-swarm --depth 1 \
265
+ pmtiles-swarm pmtiles-torrent
266
+ ```
267
+
268
+ An install runs the dependency install scripts again, so check WebRTC survived
269
+ it โ€” see [the allowScripts warning](#the-allowscripts-warning):
270
+
271
+ ```sh
272
+ cd /var/lib/pmtiles-swarm && sudo -u pmtiles-swarm -H node -e \
273
+ "import('node-datachannel').then(() => console.log('webrtc ok'))"
274
+ ```
275
+
276
+ To pin a version, or to go back to one:
277
+
278
+ ```sh
279
+ sudo -u pmtiles-swarm -H npm install --prefix /var/lib/pmtiles-swarm pmtiles-swarm@0.3.0
280
+ sudo systemctl restart pmtiles-swarm
281
+ ```
282
+
246
283
  ## Checking it
247
284
 
248
285
  ```sh
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmtiles-swarm",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "BitTorrent distribution for PMTiles map archives: create torrents, watch folders, publish and subscribe to RSS feeds, and seed through qBittorrent or an embedded client",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/api.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import crypto from 'node:crypto';
2
+ import fsSync from 'node:fs';
2
3
  import fs from 'node:fs/promises';
3
4
  import { createRequire } from 'node:module';
4
5
  import path from 'node:path';
@@ -24,6 +25,17 @@ import { TileReadError } from './tiles.js';
24
25
 
25
26
  const here = path.dirname(fileURLToPath(import.meta.url));
26
27
 
28
+ /**
29
+ * This package's version, for the console to show.
30
+ *
31
+ * Read from package.json rather than repeated in a constant: a version in two
32
+ * places is a version that disagrees with itself, and the one on screen is the
33
+ * one somebody will quote when reporting a problem.
34
+ */
35
+ const VERSION = JSON.parse(
36
+ fsSync.readFileSync(path.join(here, '..', 'package.json'), 'utf8'),
37
+ ).version;
38
+
27
39
  /**
28
40
  * Wraps an async route so a rejection becomes a 500 rather than an unhandled
29
41
  * rejection that takes the process down.
@@ -395,6 +407,7 @@ export function createApp({
395
407
  engineError = error.message;
396
408
  }
397
409
  res.json({
410
+ version: VERSION,
398
411
  engine: { name: engine.name, ok: engineOk, error: engineError },
399
412
  archives: catalog.list().length,
400
413
  categories: catalog.categories(),
@@ -254,6 +254,20 @@
254
254
  }
255
255
  .choice > span { flex: 1; }
256
256
 
257
+ footer {
258
+ margin-top: 2.5rem;
259
+ padding: 1rem 0 0.5rem;
260
+ border-top: 1px solid var(--line);
261
+ color: var(--muted);
262
+ font-size: 0.8rem;
263
+ display: flex;
264
+ gap: 0.6rem;
265
+ flex-wrap: wrap;
266
+ align-items: baseline;
267
+ }
268
+ footer a { color: var(--muted); }
269
+ footer .version { font-variant-numeric: tabular-nums; }
270
+
257
271
  /* Speed limits. Declared after .field on purpose: `.field input` is
258
272
  width:100%, which would push the unit label onto its own line. */
259
273
  .rates { display: flex; gap: 1rem; flex-wrap: wrap; }
@@ -362,6 +376,14 @@
362
376
  </section>
363
377
  </main>
364
378
 
379
+ <footer>
380
+ <span>&copy; <span id="year"></span> TechIdiots LLC</span>
381
+ <span>ยท</span>
382
+ <span>pmtiles-swarm <span class="version" id="version">โ€ฆ</span></span>
383
+ <span>ยท</span>
384
+ <a href="https://github.com/TechIdiots-LLC/pmtiles-swarm" rel="noreferrer">source</a>
385
+ </footer>
386
+
365
387
  <dialog id="move-dialog">
366
388
  <form method="dialog" id="move-form">
367
389
  <h2>Set location</h2>
@@ -859,6 +881,7 @@
859
881
  ]);
860
882
  renderSpeed(speed);
861
883
  renderFetching(adds?.running);
884
+ if (status.version) $('version').textContent = `v${status.version}`;
862
885
  const engine = status.engine;
863
886
  $('status').innerHTML =
864
887
  `engine <b>${engine.name}</b> ${engine.ok ? 'ready' : 'unavailable'}` +
@@ -3436,6 +3459,11 @@
3436
3459
  if (name === 'settings') loadSettings().catch((e) => toast(e.message));
3437
3460
  if (name === 'categories') loadCategories().catch((e) => toast(e.message));
3438
3461
  };
3462
+ // The footer's year, set from the clock rather than typed into a file
3463
+ // nobody will remember to edit. The version beside it arrives with the
3464
+ // first status, and reads "โ€ฆ" until then.
3465
+ $('year').textContent = String(new Date().getFullYear());
3466
+
3439
3467
  $('tab-archives').onclick = () => showTab('archives');
3440
3468
  $('tab-categories').onclick = () => showTab('categories');
3441
3469
  $('tab-settings').onclick = () => showTab('settings');