@rhizogrip/spore-cli 1.49.5 → 1.51.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.49.5",
3
+ "version": "1.51.0",
4
4
  "author": {
5
5
  "name": "Christophe Le Bars",
6
6
  "email": "clb@toort.net"
@@ -54,7 +54,7 @@
54
54
  "minimist": "^1.2.8"
55
55
  },
56
56
  "optionalDependencies": {
57
- "@rhizogrip/spore": "1.49.5"
57
+ "@rhizogrip/spore": "1.51.0"
58
58
  },
59
59
  "license": "Apache-2.0"
60
60
  }
package/src/dispatch.js CHANGED
@@ -165,7 +165,7 @@ function renderShow (result) {
165
165
  line('delivered', shown.join('\n' + ' '.repeat(13)) + (rest ? `\n${' '.repeat(13)}…and ${rest} more` : ''))
166
166
  }
167
167
  if (result.precursors.length) line('precursors', result.precursors.join(', '))
168
- if (result.plugins.length) line('plugins', result.plugins.join(', '))
168
+ if (result.plugins.length) line('plugins', result.plugins.map(name => pluginText(name, result.pluginOptions[name])).join(', '))
169
169
  if (result.differs.length) line('docs', `${result.differs.join(', ')} differ from what is installed — spore upgrade ${basename(result.ws)}`)
170
170
  const { disk } = result
171
171
  line('disk', `${bytesText(disk.total)} — data ${bytesText(disk.data)} · records ${bytesText(disk.state)} · streams ${bytesText(disk.calls)} · sent ${bytesText(disk.inbox)} · other ${bytesText(disk.other)}`)
@@ -259,6 +259,10 @@ export function scheduleLine (one) {
259
259
  return `${one.name} ${when} ${one.state}${where}`
260
260
  }
261
261
 
262
+ const pluginText = (name, set) => set
263
+ ? `${name} (${Object.entries(set).map(([option, value]) => `${option}: ${value}`).join(', ')})`
264
+ : name
265
+
262
266
  const jobGrant = (grant) => grant
263
267
  ? `${grant.count} at once, ${durationText(grant.wall)} each${grant.maxWait ? `, routed within ${durationText(grant.maxWait)}` : ''}${grant.perDay ? `, ${grant.perDay} triage cells a day` : ''}`
264
268
  : 'none granted'
@@ -462,6 +466,9 @@ function renderPlugin (result) {
462
466
  for (const [i, [key, kind]] of Object.entries(result.settings).entries()) {
463
467
  line(i ? '' : 'settings', `${key} (${kind})${result.configured?.[key] === undefined ? '' : ` = ${result.configured[key]}`}`)
464
468
  }
469
+ for (const [i, [name, spec]] of Object.entries(result.options).entries()) {
470
+ line(i ? '' : 'options', `${result.name}.${name}: ${spec.values.map(value => value === spec.default ? `${value} (default)` : value).join(' | ')}`)
471
+ }
465
472
  for (const [i, [name, path]] of Object.entries(result.programs).entries()) line(i ? '' : 'programs', `${name} → ${path}`)
466
473
  for (const [i, [name, value]] of Object.entries(result.env).entries()) line(i ? '' : 'env', `${name}=${value}`)
467
474
  if (result.contain) line('contain', result.contain.keep ? `${result.contain.keep}, and nothing else of ${result.contain.hide}` : `nothing of ${result.contain.hide}`)
package/src/doctor.js CHANGED
@@ -39,6 +39,8 @@ function serviceFindings (services, needsTick, replies) {
39
39
  if (row.outdated) problem(row.name, `runs ${row.outdated.from} ${row.outdated.running}, and ${row.outdated.installed} is installed`, `spore service restart ${row.name}`)
40
40
  if (row.enabled && row.active !== 'active') problem(row.name, `is enabled and ${row.active} (${row.sub})`, `spore service log ${row.name}`)
41
41
  if (row.restarts) note(row.name, `systemd has restarted it ${row.restarts} time${row.restarts > 1 ? 's' : ''}`, `spore service log ${row.name}`)
42
+ const checked = services.check(row.name)
43
+ if (checked && !checked.ok) problem(row.name, `does not pass its check: ${checked.detail}`, `spore service show ${row.name}`)
42
44
  }
43
45
  const tick = listed.services.find(row => row.name === 'tick')
44
46
  if (needsTick.length && !(tick.defined && tick.active === 'active')) {
package/src/services.js CHANGED
@@ -438,21 +438,25 @@ export function createServices ({ roots = pluginRoots() } = {}) {
438
438
  return { ...shown, units, log }
439
439
  },
440
440
 
441
+ /**
442
+ * What the service's `check` says now, as `define` runs it: `{ ok, detail }`, `detail` what it
443
+ * wrote on stderr, or else on stdout; null for a service that declares none.
444
+ */
445
+ check (name) {
446
+ const { service, instance } = parse(name, { verb: 'show' })
447
+ if (!service.check) return null
448
+ const [command, args] = service.check({ ...INSTALL, instance })
449
+ const checked = systemRun(command, args)
450
+ return { ok: checked.status === 0, detail: (checked.stderr || checked.stdout || '').trim() || `exit ${checked.status}` }
451
+ },
452
+
441
453
  define (name) {
442
454
  const one = parse(name, { verb: 'define' })
443
- const { service, instance } = one
455
+ const { service } = one
444
456
  requireSystemd()
445
457
  refuseForeign(one, name)
446
- if (service.check) {
447
- const [command, args] = service.check({ ...INSTALL, instance })
448
- const checked = systemRun(command, args)
449
- if (checked.status !== 0) {
450
- throw new SporeError(`${name} would not start`, {
451
- type: 'SERVICE_NOT_READY',
452
- detail: (checked.stderr || checked.stdout || '').trim() || `exit ${checked.status}`
453
- })
454
- }
455
- }
458
+ const checked = this.check(name)
459
+ if (checked && !checked.ok) throw new SporeError(`${name} did not pass its check`, { type: 'SERVICE_NOT_READY', detail: checked.detail })
456
460
  mkdirSync(UNIT_DIR, { recursive: true })
457
461
  const units = []
458
462
  for (const [file, text] of Object.entries(renderUnits(one.base, { roots }))) {