| … | … | @@ -1,6 +1,7 @@ |
| 1 | 1 | /** pgh app install|update|rollback|list|remove|start|stop|restart|status|log|autostart|boot|shutdown|adopt */ |
| 2 | 2 | |
| 3 | 3 | import process from '#node:process' |
| 4 | import { isAbstract } from '../daemon-client.js' | |
| 4 | 5 | import { spawn } from '#node:child_process' |
| 5 | 6 | import { execSync } from '../_compat-exec.js' |
| 6 | 7 | import path from '#node:path' |
| … | … | @@ -219,7 +220,7 @@ export async function run (client, args) { |
| 219 | 220 | // Bare name — ask pgh-sidecar's NameRegistry to resolve. If that |
| 220 | 221 | // works, synthesize the pgh:// URL and proceed with the normal |
| 221 | 222 | // install flow. |
| 222 | if (fs.existsSync(SIDECAR_SOCK) && /^[a-zA-Z0-9_-][a-zA-Z0-9_.-]*$/.test(target)) { | |
| 223 | if ((isAbstract(SIDECAR_SOCK) || fs.existsSync(SIDECAR_SOCK)) && /^[a-zA-Z0-9_-][a-zA-Z0-9_.-]*$/.test(target)) { | |
| 223 | 224 | const resolved = await resolveBareName(target) |
| 224 | 225 | if (resolved) { |
| 225 | 226 | console.log('Resolved "' + target + '" → registry ' + resolved.publisher.registryKey.slice(0, 12) + '… via pgh-sidecar NameRegistry') |
| … | … | @@ -13,6 +13,7 @@ |
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | 15 | import process from '#node:process' |
| 16 | import { isAbstract } from '../daemon-client.js' | |
| 16 | 17 | import fs from '#node:fs' |
| 17 | 18 | import path from '#node:path' |
| 18 | 19 | import { homedir } from '#node:os' |
| … | … | @@ -125,7 +126,7 @@ async function runLabel (args, globals) { |
| 125 | 126 | // the autobase bootstrap keys + repo-tracker map needed for the bundle). |
| 126 | 127 | async function daemonClient (appName) { |
| 127 | 128 | const SIDECAR_SOCK = process.env.PGH_SIDECAR_SOCK || path.join(homedir(), '.pgh', 'svc.sock') |
| 128 | if (!fs.existsSync(SIDECAR_SOCK)) { | |
| 129 | if (!isAbstract(SIDECAR_SOCK) && !fs.existsSync(SIDECAR_SOCK)) { | |
| 129 | 130 | throw new Error('pgh-sidecar is not running (no socket at ' + SIDECAR_SOCK + ')') |
| 130 | 131 | } |
| 131 | 132 | const { Client } = await import('hyper-svc') |
| … | … | @@ -18,6 +18,7 @@ import { homedir } from '#node:os' |
| 18 | 18 | import fs from '#node:fs' |
| 19 | 19 | |
| 20 | 20 | import { Client } from 'hyper-svc' |
| 21 | import { isAbstract } from '../daemon-client.js' | |
| 21 | 22 | |
| 22 | 23 | const SIDECAR_SOCK = process.env.PGH_SIDECAR_SOCK || path.join(homedir(), '.pgh', 'svc.sock') |
| 23 | 24 | |
| … | … | @@ -36,7 +37,7 @@ export const usage = `pgh names / claim / release — NameRegistry (sidecar-owne |
| 36 | 37 | pgh names subscriptions List own + subscribed name registries` |
| 37 | 38 | |
| 38 | 39 | async function withClient (fn) { |
| 39 | if (!fs.existsSync(SIDECAR_SOCK)) { | |
| 40 | if (!isAbstract(SIDECAR_SOCK) && !fs.existsSync(SIDECAR_SOCK)) { | |
| 40 | 41 | throw new Error('pgh-sidecar is not running (no socket at ' + SIDECAR_SOCK + ')') |
| 41 | 42 | } |
| 42 | 43 | const c = await Client.connectUds(SIDECAR_SOCK) |
| … | … | @@ -49,6 +49,7 @@ import { execSync } from '../_compat-exec.js' |
| 49 | 49 | import { pipeline } from '#node:stream/promises' |
| 50 | 50 | import { Transform } from '#node:stream' |
| 51 | 51 | import { Client } from 'hyper-svc' |
| 52 | import { isAbstract } from '../daemon-client.js' | |
| 52 | 53 | |
| 53 | 54 | // Hash + chunk + pointer primitives are owned by hyper-overlay (canonical |
| 54 | 55 | // source). Importing keeps pgh's clean/smudge wire-compatible with every |
| … | … | @@ -72,7 +73,7 @@ async function sidecarClient () { |
| 72 | 73 | // overlay subcommands talk to pgh-sidecar (not pear-git-v3), so they |
| 73 | 74 | // open their own UDS client. Dispatcher's pure-local routing passes |
| 74 | 75 | // null for `client` since the receiver is fixed. |
| 75 | if (!fs.existsSync(SIDECAR_SOCK)) { | |
| 76 | if (!isAbstract(SIDECAR_SOCK) && !fs.existsSync(SIDECAR_SOCK)) { | |
| 76 | 77 | throw new Error('pgh-sidecar not running (no socket at ' + SIDECAR_SOCK + ')') |
| 77 | 78 | } |
| 78 | 79 | return Client.connectUds(SIDECAR_SOCK) |
| … | … | @@ -7,6 +7,7 @@ import { homedir, tmpdir } from '#node:os' |
| 7 | 7 | import Corestore from 'corestore' |
| 8 | 8 | |
| 9 | 9 | import { Client } from 'hyper-svc' |
| 10 | import { isAbstract } from '../daemon-client.js' | |
| 10 | 11 | |
| 11 | 12 | import { computeLockfile, writeLockfile, buildPublishIgnore } from '../publish.js' |
| 12 | 13 | import { PublishedIndex } from '../published-index.js' |
| … | … | @@ -381,7 +382,7 @@ export async function run (client, args) { |
| 381 | 382 | // registry lock, so talking to it over UDS avoids contention with |
| 382 | 383 | // `pgh seed` / another pgh process. Fall back to direct only when |
| 383 | 384 | // sidecar isn't running. |
| 384 | const sidecarAvailable = fs.existsSync(SIDECAR_SOCK) | |
| 385 | const sidecarAvailable = isAbstract(SIDECAR_SOCK) || fs.existsSync(SIDECAR_SOCK) | |
| 385 | 386 | if (sidecarAvailable) { |
| 386 | 387 | try { |
| 387 | 388 | const client = await Client.connectUds(SIDECAR_SOCK) |
| … | … | @@ -7,6 +7,7 @@ import { homedir } from '#node:os' |
| 7 | 7 | import Corestore from 'corestore' |
| 8 | 8 | |
| 9 | 9 | import { Client } from 'hyper-svc' |
| 10 | import { isAbstract } from '../daemon-client.js' | |
| 10 | 11 | |
| 11 | 12 | export const usage = `pgh releases — inspect the local ReleaseRegistry |
| 12 | 13 | |
| … | … | @@ -28,7 +29,7 @@ const SIDECAR_SOCK = process.env.PGH_SIDECAR_SOCK || path.join(homedir(), '.pgh' |
| 28 | 29 | // Prefer pgh-sidecar (which owns the registry lock). Fall back to |
| 29 | 30 | // opening the corestore directly when the sidecar isn't running. |
| 30 | 31 | async function withRegistry (fn) { |
| 31 | if (fs.existsSync(SIDECAR_SOCK)) { | |
| 32 | if (isAbstract(SIDECAR_SOCK) || fs.existsSync(SIDECAR_SOCK)) { | |
| 32 | 33 | let client = null |
| 33 | 34 | try { |
| 34 | 35 | client = await Client.connectUds(SIDECAR_SOCK) |
| … | … | @@ -12,6 +12,7 @@ |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | import process from '#node:process' |
| 15 | import { isAbstract } from '../daemon-client.js' | |
| 15 | 16 | import fs from '#node:fs' |
| 16 | 17 | import path from '#node:path' |
| 17 | 18 | import { homedir } from '#node:os' |
| … | … | @@ -27,7 +28,7 @@ export const usage = `pgh user — manage users on a pgh-managed app |
| 27 | 28 | The app must be running and registered with pgh-sidecar.` |
| 28 | 29 | |
| 29 | 30 | async function appClient (appName) { |
| 30 | if (!fs.existsSync(SIDECAR_SOCK)) { | |
| 31 | if (!isAbstract(SIDECAR_SOCK) && !fs.existsSync(SIDECAR_SOCK)) { | |
| 31 | 32 | throw new Error('pgh-sidecar is not running (no socket at ' + SIDECAR_SOCK + ')') |
| 32 | 33 | } |
| 33 | 34 | const { Client } = await import('hyper-svc') |
| … | … | @@ -20,7 +20,7 @@ const SIDECAR_SOCK = process.env.PGH_SIDECAR_SOCK || |
| 20 | 20 | |
| 21 | 21 | // An '@'-prefixed socket is a Linux abstract-namespace socket (no filesystem |
| 22 | 22 | // entry), used where SELinux denies pathname sockets (unrooted Android/celltron). |
| 23 | function isAbstract (p) { | |
| 23 | export function isAbstract (p) { | |
| 24 | 24 | return typeof p === 'string' && p.length > 1 && p[0] === '@' |
| 25 | 25 | } |
| 26 | 26 |
| … | … | @@ -1,6 +1,6 @@ |
| 1 | 1 | { |
| 2 | 2 | "name": "pgh", |
| 3 | "version": "0.1.146", | |
| 3 | "version": "0.1.147", | |
| 4 | 4 | "description": "pgh \u2014 P2P content-addressed package manager and app launcher", |
| 5 | 5 | "type": "module", |
| 6 | 6 | "main": "index.js", |