Lines 1-33javascript
2// lib/nodes/commands.js — subcomandi CLI `nodes` e `node` (design §3, §4, §4b).
4// nodes add/list/remove/test/up/down/restart/set-token + node on/off.
6// - token per-nodo MAI loggati/stampati (redazione sempre; set-token li legge
7// da stdin/env, mai da argv -> niente segreti in `ps`).
8// - NEXUSCREW_READONLY blocca le MUTAZIONI DI CONFIG (add/remove/set-token/
9// on/off), non list/test/status/up/down/restart (lifecycle tunnel, non config).
10// - niente shell interpolation: ssh-keygen via execFile (argv), tunnel via spawn argv.
11const fs = require('node:fs');
12const os = require('node:os');
13const path = require('node:path');
14const { execFileSync } = require('node:child_process');
15const store = require('./store.js');
16const tunnel = require('./tunnel.js');
17const { resolvePaths, loadPort, DEFAULT_PORT } = require('../cli/url.js');
19const LOCAL_PORT_BASE = 43001; // porte locali stabili per i forward (design: stabili da nodes.json)
21function isReadonly(opts) {
22 return process.env.NEXUSCREW_READONLY === '1' || !!opts.readonly;
23}
MediumInstall Persistence
Source writes installer persistence such as shell profile or service configuration.
lib/nodes/commands.jsView on unpkg · L13 25function resolveNodePaths(opts) {
26 const { home, configDir, configPath } = resolvePaths(opts);
27 const nodesPath = opts.nodesPath || path.join(configDir, 'nodes.json');
28 return { home, configDir, configPath, nodesPath };
31// Prima localPort libera >= base, evitando le porte gia' assegnate (porta STABILE:
32// una volta scelta resta in nodes.json, non si ricicla).
33function assignLocalPort(st) {