easy-vps 0.1.9 → 0.2.1

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.
@@ -58,6 +58,12 @@ const domains = __importStar(require("./domain"));
58
58
  const ssh_1 = require("./ssh");
59
59
  /** Where clones live on the VPS, under the login user's home. */
60
60
  const APPS_DIR = '"$HOME/easy-vps-apps"';
61
+ // A non-interactive login shell misses tools installed outside the system
62
+ // prefix — nvm's node/npm in particular — so the user's install/build/run
63
+ // commands can't find them. Seed PATH the same way the system service does.
64
+ const PATH_PRIMER = 'export PATH="/usr/local/bin:/usr/bin:/snap/bin:$PATH"; ' +
65
+ 'for nvm_bin in "$HOME"/.nvm/versions/node/*/bin; do ' +
66
+ '[ -d "$nvm_bin" ] && PATH="$PATH:$nvm_bin"; done; export PATH;';
61
67
  /** Names are validated on the way in; this is the guard for any other caller. */
62
68
  const SAFE_NAME = /^[a-z0-9][a-z0-9._-]*$/i;
63
69
  // remote.writeFile()/readFile() single-quote their path argument, so a literal
@@ -232,6 +238,7 @@ function buildScript(config) {
232
238
  // Double quotes, not quote(): the shell has to expand $HOME itself.
233
239
  const dir = `"$HOME/easy-vps-apps/${config.name}"`;
234
240
  return [
241
+ PATH_PRIMER,
235
242
  'set -e',
236
243
  `echo "==> Deploying ${config.name} (${config.domain ?? `port ${config.port}`})"`,
237
244
  `mkdir -p ${APPS_DIR}`,
@@ -284,6 +291,7 @@ function rebuildScript(config) {
284
291
  throw new Error('Invalid project name');
285
292
  const dir = `"$HOME/easy-vps-apps/${config.name}"`;
286
293
  return [
294
+ PATH_PRIMER,
287
295
  'set -e',
288
296
  `echo "==> Rebuilding ${config.name} (${config.domain ?? `port ${config.port}`})"`,
289
297
  `if [ ! -d "$HOME/easy-vps-apps/${config.name}/.git" ]; then
@@ -362,7 +370,10 @@ async function clones(remote) {
362
370
  ' name=$(basename "$dir")',
363
371
  ' repo=$(git -C "$dir" config --get remote.origin.url 2>/dev/null)',
364
372
  ' branch=$(git -C "$dir" rev-parse --abbrev-ref HEAD 2>/dev/null)',
365
- ' printf "%s\\t%s\\t%s\\n" "$name" "$repo" "$branch"',
373
+ // The port is the authoritative one (it's what Nginx proxies to); read it
374
+ // from the deploy config the panel mirrors next to the clone.
375
+ ' port=$(grep -oE \'"port"[[:space:]]*:[[:space:]]*[0-9]+\' "$dir/.easy-vps.json" 2>/dev/null | grep -oE \'[0-9]+\' | head -n1)',
376
+ ' printf "%s\\t%s\\t%s\\t%s\\n" "$name" "$repo" "$branch" "$port"',
366
377
  'done',
367
378
  ].join('\n');
368
379
  const { stdout, code } = await remote.exec((0, ssh_1.loginShell)(script), 15_000);
@@ -372,10 +383,11 @@ async function clones(remote) {
372
383
  .split('\n')
373
384
  .map((line) => line.split('\t'))
374
385
  .filter((parts) => parts[0]?.trim())
375
- .map(([name, repository, branch]) => ({
386
+ .map(([name, repository, branch, port]) => ({
376
387
  name: name.trim(),
377
388
  repository: repository?.trim() ?? '',
378
389
  branch: branch?.trim() || 'main',
390
+ port: port?.trim() ? Number(port.trim()) : undefined,
379
391
  }));
380
392
  }
381
393
  /** PM2 processes by name, with the port they were started on. */
@@ -439,11 +451,13 @@ async function list(remote) {
439
451
  domains.list(remote).catch(() => []),
440
452
  ]);
441
453
  const domainForPort = new Map(configured.map((entry) => [entry.port, entry.domain]));
442
- return cloned.map(({ name, repository, branch }) => {
454
+ return cloned.map(({ name, repository, branch, port: configPort }) => {
443
455
  const process = pm2.get(name);
444
456
  const container = docker.get(name);
445
457
  const runtime = container && !process ? 'docker' : 'pm2';
446
- const port = process?.port ?? container?.port ?? 0;
458
+ // Prefer the saved deploy config's port (authoritative for the domain
459
+ // mapping); fall back to what PM2/Docker report, then 0.
460
+ const port = configPort ?? process?.port ?? container?.port ?? 0;
447
461
  let status = 'unknown';
448
462
  if (process)
449
463
  status = process.status === 'online' ? 'running' : 'stopped';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easy-vps",
3
- "version": "0.1.9",
3
+ "version": "0.2.1",
4
4
  "description": "Install dependencies, point domains, deploy apps and run Postgres on a VPS from one UI",
5
5
  "keywords": [
6
6
  "easy-vps",