@infernetprotocol/cli 0.1.86 → 0.1.87

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.
@@ -11,8 +11,8 @@
11
11
  import { spawn } from 'node:child_process';
12
12
  import { compareVersions } from '@profullstack/cli';
13
13
  import setup from './setup.js';
14
- import { CURRENT_VERSION, fetchLatestVersion } from '../lib/version.js';
15
- import { pruneCliCopies, wrapperTarget } from '../lib/cli-copies.js';
14
+ import { CLI_DIR, CURRENT_VERSION, fetchLatestVersion } from '../lib/version.js';
15
+ import { pruneCliCopies, wrapperPath, wrapperTarget } from '../lib/cli-copies.js';
16
16
 
17
17
  const HELP = `infernet update — pull latest CLI + autonomous post-upgrade setup
18
18
 
@@ -125,23 +125,61 @@ export default async function update(args, ctx) {
125
125
  const ok = await pullLatestBinary({ quiet });
126
126
  if (!ok) return 1;
127
127
 
128
- // The installer already pruned other copies (install.sh); this catches an
129
- // older installer and copies the installer could not see.
130
- if (!args.has('keep-copies')) cleanCliCopies({ quiet, version: latest });
131
-
132
128
  if (args.has('skip-setup')) {
129
+ if (!args.has('keep-copies')) cleanCliCopies({ quiet, version: latest });
133
130
  process.stdout.write("\n✓ Binary updated (skipped setup).\n");
134
131
  return 0;
135
132
  }
136
133
 
137
134
  process.stdout.write("\n→ Running post-upgrade setup (keys + register + daemon restart)\n");
138
135
 
139
- const setupArgs = new Map([['yes', true], ['confirm', true], ['skip-pull', true]]);
136
+ const passthrough = [];
140
137
  for (const k of ['port', 'address', 'no-advertise']) {
141
- if (args.has(k)) setupArgs.set(k, args.get(k) ?? true);
138
+ if (!args.has(k)) continue;
139
+ const v = args.get(k);
140
+ passthrough.push(`--${k}`, ...(v === undefined ? [] : [String(v)]));
142
141
  }
143
142
 
144
- return setup(setupArgs, ctx);
143
+ // Setup writes the daemon's unit from the CLI that runs it. If this
144
+ // process is not the CLI the installer just installed (a stale npm-global
145
+ // copy, or the npm copy of a node the installer kept on git), running
146
+ // setup here would point infernet.service at this copy, which the cleanup
147
+ // below then deletes: bonita's daemon crash-looped on exactly that during
148
+ // the 0.1.86 rollout. Hand setup to the installed CLI instead, and clean
149
+ // up copies only after it has rewritten the unit.
150
+ const installed = wrapperTarget();
151
+ let code;
152
+ if (setupRunsFrom(installed, CLI_DIR) === 'installed') {
153
+ process.stdout.write(` (running setup from the installed CLI at ${installed})\n`);
154
+ code = await runInstalledSetup(['setup', '--yes', '--confirm', '--skip-pull', ...passthrough]);
155
+ } else {
156
+ const setupArgs = new Map([['yes', true], ['confirm', true], ['skip-pull', true]]);
157
+ for (const k of ['port', 'address', 'no-advertise']) {
158
+ if (args.has(k)) setupArgs.set(k, args.get(k) ?? true);
159
+ }
160
+ code = await setup(setupArgs, ctx);
161
+ }
162
+
163
+ // The installer already pruned other copies (install.sh); this catches an
164
+ // older installer and copies it could not see. After setup, never before.
165
+ if (!args.has('keep-copies')) cleanCliCopies({ quiet, version: latest });
166
+ return code;
167
+ }
168
+
169
+ /** 'installed' when the wrapper runs another CLI than this process. */
170
+ export function setupRunsFrom(installedDir, selfDir) {
171
+ return installedDir && installedDir !== selfDir ? 'installed' : 'self';
172
+ }
173
+
174
+ function runInstalledSetup(argv) {
175
+ return new Promise((resolve) => {
176
+ const child = spawn(wrapperPath(), argv, { stdio: 'inherit' });
177
+ child.on('exit', (c) => resolve(c ?? 1));
178
+ child.on('error', (err) => {
179
+ process.stderr.write(`error: could not run the installed CLI: ${err?.message ?? err}\n`);
180
+ resolve(1);
181
+ });
182
+ });
145
183
  }
146
184
 
147
185
  export { HELP, INSTALLER_URL };
package/lib/version.js CHANGED
@@ -1,4 +1,4 @@
1
- import { readFileSync } from 'node:fs';
1
+ import { readFileSync, realpathSync } from 'node:fs';
2
2
  import { join, dirname } from 'node:path';
3
3
  import { homedir } from 'node:os';
4
4
  import { fileURLToPath } from 'node:url';
@@ -6,7 +6,10 @@ import { fileURLToPath } from 'node:url';
6
6
  const _dir = dirname(fileURLToPath(import.meta.url));
7
7
 
8
8
  /** The CLI package directory this code is running from. */
9
- export const CLI_DIR = join(_dir, '..');
9
+ export const CLI_DIR = (() => {
10
+ const dir = join(_dir, '..');
11
+ try { return realpathSync(dir); } catch { return dir; }
12
+ })();
10
13
 
11
14
  /**
12
15
  * The version of the code that is actually running: the package.json next to
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infernetprotocol/cli",
3
- "version": "0.1.86",
3
+ "version": "0.1.87",
4
4
  "description": "GPU-node CLI / daemon for the Infernet Protocol — register a GPU server with a Supabase control plane and start earning.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -32,14 +32,14 @@
32
32
  "ora": "^9.4.1",
33
33
  "react": "^17.0.2",
34
34
  "react-blessed": "^0.7.2",
35
- "@infernetprotocol/auth": "0.1.86",
36
- "@infernetprotocol/config": "0.1.86",
37
- "@infernetprotocol/deploy-providers": "0.1.86",
38
- "@infernetprotocol/engine": "0.1.86",
39
- "@infernetprotocol/gpu": "0.1.86",
40
- "@infernetprotocol/liquid-agent": "0.1.86",
41
- "@infernetprotocol/rpc-adapter": "0.1.86",
42
- "@infernetprotocol/training": "0.1.86"
35
+ "@infernetprotocol/auth": "0.1.87",
36
+ "@infernetprotocol/config": "0.1.87",
37
+ "@infernetprotocol/deploy-providers": "0.1.87",
38
+ "@infernetprotocol/gpu": "0.1.87",
39
+ "@infernetprotocol/engine": "0.1.87",
40
+ "@infernetprotocol/liquid-agent": "0.1.87",
41
+ "@infernetprotocol/rpc-adapter": "0.1.87",
42
+ "@infernetprotocol/training": "0.1.87"
43
43
  },
44
44
  "repository": {
45
45
  "type": "git",