@rhizogrip/spore-cli 1.27.0 → 1.28.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": "@rhizogrip/spore-cli",
3
- "version": "1.27.0",
3
+ "version": "1.28.0",
4
4
  "author": {
5
5
  "name": "Christophe Le Bars",
6
6
  "email": "clb@toort.net"
@@ -50,7 +50,7 @@
50
50
  "tui": "node bin/spore.js tui"
51
51
  },
52
52
  "dependencies": {
53
- "@rhizogrip/spore": "1.27.0",
53
+ "@rhizogrip/spore": "1.28.0",
54
54
  "chalk": "^6.0.1",
55
55
  "minimist": "^1.2.8"
56
56
  },
package/src/dispatch.js CHANGED
@@ -478,7 +478,7 @@ function renderPlugin (result) {
478
478
  }
479
479
  for (const [i, [name, path]] of Object.entries(result.programs).entries()) line(i ? '' : 'programs', `${name} → ${path}`)
480
480
  for (const [i, [name, value]] of Object.entries(result.env).entries()) line(i ? '' : 'env', `${name}=${value}`)
481
- if (result.contain) line('contain', `${result.contain.keep}, and nothing else of ${result.contain.hide}`)
481
+ if (result.contain) line('contain', result.contain.keep ? `${result.contain.keep}, and nothing else of ${result.contain.hide}` : `nothing of ${result.contain.hide}`)
482
482
  if (result.modules.length) line('modules', `${result.modules.join(', ')} → node_modules/, for the agent's programs`)
483
483
  if (result.sources.length) line('sources', `${result.sources.join(', ')} — granted with the plugin, held by the runner`)
484
484
  if (result.reference) line('reference', `${result.reference} → plugins/${result.name}.md`)
package/src/services.js CHANGED
@@ -21,7 +21,11 @@ import { dirname, join } from 'node:path'
21
21
 
22
22
  import { CONFIG_DIR, pluginRoots, pluginServices, SERVICE_STATE_DIR, SporeError, versionAt } from '@rhizogrip/spore'
23
23
 
24
- const ROOT = dirname(createRequire(import.meta.url).resolve('@rhizogrip/spore/package.json'))
24
+ const SPORE_PACKAGE = '@rhizogrip/spore'
25
+ const ROOT = dirname(createRequire(import.meta.url).resolve(`${SPORE_PACKAGE}/package.json`))
26
+
27
+ /** The spore a plugin in `dir` loads, found as node finds it from there: its own copy on a global install. */
28
+ const sporeOf = (dir) => dirname(createRequire(join(dir, 'package.json')).resolve(`${SPORE_PACKAGE}/package.json`))
25
29
 
26
30
  export const UNIT_DIR = join(process.env.XDG_CONFIG_HOME || join(homedir(), '.config'), 'systemd', 'user')
27
31
 
@@ -207,6 +211,7 @@ function fromPlugin (found) {
207
211
  plugin: found.plugin,
208
212
  package: found.package,
209
213
  version: found.version,
214
+ dir: found.dir,
210
215
  instances: found.instances,
211
216
  records: true,
212
217
  primary: named,
@@ -411,14 +416,18 @@ export function createServices ({ unitDir = UNIT_DIR, run = systemRun, cmdlineOf
411
416
  }
412
417
 
413
418
  // The version a running service recorded, when it is the process running now and not the
414
- // one installed — of spore, or of the plugin that offers it. A service that recorded nothing,
415
- // or a record left by an earlier process, says nothing either way.
419
+ // one installed — of spore, of the plugin that offers it, or of the spore that plugin loads.
420
+ // A service that recorded nothing, or a record left by an earlier process, says nothing either way.
416
421
  const outdated = (name, { service }, pid) => {
417
422
  const record = join(stateDir, `${name}.json`)
418
423
  if (!service.records || !pid || !existsSync(record)) return null
419
424
  const started = JSON.parse(readFileSync(record, 'utf8'))
425
+ if (started.pid !== pid) return null
420
426
  const installed = service.plugin ? service.version : versionAt(root)
421
- return started.pid === pid && started.version !== installed ? { from: service.package ?? 'spore', running: started.version, installed } : null
427
+ if (started.version !== installed) return { from: service.package ?? 'spore', running: started.version, installed }
428
+ if (!service.plugin || started.spore === undefined) return null
429
+ const loads = versionAt(sporeOf(service.dir))
430
+ return started.spore !== loads ? { from: SPORE_PACKAGE, running: started.spore, installed: loads } : null
422
431
  }
423
432
 
424
433
  const row = (name) => {