@constellation-network/node-pilot 0.0.19 → 0.0.20

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/README.md CHANGED
@@ -21,7 +21,7 @@ $ npm install -g @constellation-network/node-pilot
21
21
  $ cpilot COMMAND
22
22
  running command...
23
23
  $ cpilot (--version|-v)
24
- @constellation-network/node-pilot/0.0.19 darwin-arm64 node-v24.8.0
24
+ @constellation-network/node-pilot/0.0.20 darwin-arm64 node-v24.8.0
25
25
  $ cpilot --help [COMMAND]
26
26
  USAGE
27
27
  $ cpilot COMMAND
@@ -71,7 +71,7 @@ EXAMPLES
71
71
  $ cpilot clean
72
72
  ```
73
73
 
74
- _See code: [src/commands/clean.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.19/src/commands/clean.ts)_
74
+ _See code: [src/commands/clean.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.20/src/commands/clean.ts)_
75
75
 
76
76
  ## `cpilot config`
77
77
 
@@ -88,7 +88,7 @@ EXAMPLES
88
88
  $ cpilot config
89
89
  ```
90
90
 
91
- _See code: [src/commands/config.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.19/src/commands/config.ts)_
91
+ _See code: [src/commands/config.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.20/src/commands/config.ts)_
92
92
 
93
93
  ## `cpilot config get [NAME]`
94
94
 
@@ -112,7 +112,7 @@ EXAMPLES
112
112
  $ cpilot config get gl0:CL_PUBLIC_HTTP_PORT
113
113
  ```
114
114
 
115
- _See code: [src/commands/config/get.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.19/src/commands/config/get.ts)_
115
+ _See code: [src/commands/config/get.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.20/src/commands/config/get.ts)_
116
116
 
117
117
  ## `cpilot config set NAME VALUE`
118
118
 
@@ -135,7 +135,7 @@ EXAMPLES
135
135
  $ cpilot config set gl0:CL_PUBLIC_HTTP_PORT 9000
136
136
  ```
137
137
 
138
- _See code: [src/commands/config/set.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.19/src/commands/config/set.ts)_
138
+ _See code: [src/commands/config/set.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.20/src/commands/config/set.ts)_
139
139
 
140
140
  ## `cpilot help [COMMAND]`
141
141
 
@@ -172,7 +172,7 @@ EXAMPLES
172
172
  $ cpilot info
173
173
  ```
174
174
 
175
- _See code: [src/commands/info.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.19/src/commands/info.ts)_
175
+ _See code: [src/commands/info.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.20/src/commands/info.ts)_
176
176
 
177
177
  ## `cpilot logs LAYER`
178
178
 
@@ -196,7 +196,7 @@ EXAMPLES
196
196
  $ cpilot logs
197
197
  ```
198
198
 
199
- _See code: [src/commands/logs.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.19/src/commands/logs.ts)_
199
+ _See code: [src/commands/logs.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.20/src/commands/logs.ts)_
200
200
 
201
201
  ## `cpilot restart [LAYER]`
202
202
 
@@ -224,7 +224,7 @@ EXAMPLES
224
224
  $ cpilot restart
225
225
  ```
226
226
 
227
- _See code: [src/commands/restart.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.19/src/commands/restart.ts)_
227
+ _See code: [src/commands/restart.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.20/src/commands/restart.ts)_
228
228
 
229
229
  ## `cpilot shutdown`
230
230
 
@@ -244,7 +244,7 @@ EXAMPLES
244
244
  $ cpilot shutdown
245
245
  ```
246
246
 
247
- _See code: [src/commands/shutdown.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.19/src/commands/shutdown.ts)_
247
+ _See code: [src/commands/shutdown.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.20/src/commands/shutdown.ts)_
248
248
 
249
249
  ## `cpilot status`
250
250
 
@@ -258,5 +258,5 @@ DESCRIPTION
258
258
  Display node status and configuration settings
259
259
  ```
260
260
 
261
- _See code: [src/commands/status.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.19/src/commands/status.ts)_
261
+ _See code: [src/commands/status.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.0.20/src/commands/status.ts)_
262
262
  <!-- commandsstop -->
@@ -1,6 +1,6 @@
1
- import { input } from "@inquirer/prompts";
2
1
  import { JSONStorage } from "node-localstorage";
3
2
  import fs from "node:fs";
3
+ import os from "node:os";
4
4
  import path from "node:path";
5
5
  import packageJson from '../../package.json' with { type: 'json' };
6
6
  import { clm } from "../clm.js";
@@ -27,10 +27,11 @@ export const checkNodePilot = {
27
27
  return;
28
28
  }
29
29
  const latestVersion = result['dist-tags'].latest;
30
+ // console.log(`Current version: "${packageJson.version}", Latest version: "${latestVersion}"`);
30
31
  if (packageJson.version !== latestVersion) {
31
- console.log('There is a new node-pilot version available.');
32
- if (await promptHelper.confirmPrompt('Do you wish to upgrade now?')) {
33
- await shellService.runCommand('npm install -g @constellationnetwork/node-pilot@latest');
32
+ console.log(`There is a new node-pilot version available. Current version: "${packageJson.version}", Latest version: "${latestVersion}"`);
33
+ if (os.platform() === 'linux' && await promptHelper.confirmPrompt('Do you wish to upgrade now?')) {
34
+ await shellService.runCommand('sudo npm install -g @constellation-network/node-pilot@latest');
34
35
  await projectHelper.upgradeHypergraph();
35
36
  clm.postStep('Run cpilot again to use the latest version');
36
37
  process.exit(0);
@@ -45,19 +46,21 @@ export const checkNodePilot = {
45
46
  clm.postStep('Discord notifications are disabled.');
46
47
  return;
47
48
  }
48
- let answer = await input({
49
- default: '',
50
- message: `Provide your Discord username to have it included in the notification: `
51
- });
52
- answer = answer.trim();
53
- if (answer === '') {
54
- hcStorage.setItem('user', { webHookEnabled: true });
55
- }
56
- else {
57
- if (answer.charAt(0) === '@')
58
- answer = answer.slice(1);
59
- hcStorage.setItem('user', { discordUser: answer.trim(), webHookEnabled: true });
60
- }
49
+ // let answer = await input({
50
+ // default: '',
51
+ // message: `Provide your Discord username to have it included in the notification: `
52
+ // });
53
+ //
54
+ // answer = answer.trim();
55
+ //
56
+ // if (answer === '') {
57
+ // hcStorage.setItem('user', {webHookEnabled: true});
58
+ // }
59
+ // else {
60
+ // if (answer.charAt(0) === '@') answer = answer.slice(1);
61
+ // hcStorage.setItem('user', {discordUser: answer.trim(), webHookEnabled: true});
62
+ // }
63
+ hcStorage.setItem('user', { webHookEnabled: true });
61
64
  clm.postStep('Discord notifications are enabled.');
62
65
  }
63
66
  };
@@ -103,8 +103,11 @@ export const checkProject = {
103
103
  // spinner.color = 'green';
104
104
  // }
105
105
  // else {
106
- clm.preStep('Tessellation and dependencies need to be installed. This may take a few minutes...');
107
- await promptHelper.doYouWishToContinue();
106
+ if (!rInfo) {
107
+ // First time install
108
+ clm.preStep('Tessellation and dependencies need to be installed. This may take a few minutes...');
109
+ await promptHelper.doYouWishToContinue();
110
+ }
108
111
  // }
109
112
  // const node = await clusterService.getClusterNodeInfo();
110
113
  // const NODE_URL = `http://${node.host}:${node.publicPort}`;
@@ -78,26 +78,30 @@ export default class Restart extends BaseCommand {
78
78
  // const pAll = layersToRun.map(l => nodeService.getNodeInfo(l));
79
79
  // const info = await Promise.all(pAll);
80
80
  // const isRunning = info.some(n => n.state !== 'Unavailable');
81
- if (configStore.isRestarting()) {
81
+ const startRestarted = configStore.isRestarting();
82
+ if (startRestarted && (startRestarted + 1000 * 60 * 5 > Date.now())) {
82
83
  serviceLog.log('Restart already ACTIVE');
83
84
  return;
84
85
  }
85
- configStore.setIsRestarting(true);
86
+ configStore.setIsRestarting(Date.now());
86
87
  try {
87
88
  if (await dockerService.isRunning()) {
88
89
  await nodeService.leaveClusterAllLayers();
89
90
  const { layersToRun } = configStore.getProjectInfo();
90
91
  await nodeService.pollForLayersState(layersToRun, 'Offline');
91
92
  clm.preStep('Stopping the node...');
93
+ serviceLog.log('Stopping the node...');
92
94
  await dockerService.dockerDown();
93
95
  }
94
96
  clm.preStep('Checking for a new version...');
97
+ serviceLog.log('Checking for a new version...');
95
98
  await checkProject.runUpgrade();
96
99
  clm.preStep('Starting the node...');
100
+ serviceLog.log('Starting the node...');
97
101
  await dockerService.dockerRestartAll();
98
102
  }
99
103
  finally {
100
- configStore.setIsRestarting(false);
104
+ configStore.setIsRestarting(0);
101
105
  }
102
106
  }
103
107
  }
@@ -18,7 +18,7 @@ declare class ConfigStore {
18
18
  getSystemInfo(): SystemInfo;
19
19
  hasProjectFlag(name: string): any;
20
20
  hasProjects(): boolean;
21
- isRestarting(): boolean;
21
+ isRestarting(): number;
22
22
  setActiveProject(name: string): void;
23
23
  setClusterStats(info: Partial<ClusterStats>): void;
24
24
  setDockerEnvInfo(info: Partial<{
@@ -28,7 +28,7 @@ declare class ConfigStore {
28
28
  setEnvInfo(info: Partial<EnvInfo>): void;
29
29
  setEnvLayerInfo(network: NetworkType, layer: TessellationLayer, info: Partial<EnvLayerInfo>): void;
30
30
  setEnvNetworkInfo(network: NetworkType, info: Partial<EnvNetworkInfo>): void;
31
- setIsRestarting(val: boolean): void;
31
+ setIsRestarting(val: number): void;
32
32
  setNetworkInfo(info: Partial<NetworkInfo>): void;
33
33
  setProjectFlag(name: string, value: boolean): any;
34
34
  setProjectInfo(info: Partial<ProjectInfo>): void;
@@ -20,7 +20,7 @@ class ConfigStore {
20
20
  this.pilotStore = new JSONStorage(path.join(appDir, 'config'));
21
21
  const appInfo = this.pilotStore.getItem('pilot');
22
22
  if (!appInfo) {
23
- this.pilotStore.setItem('pilot', { appDir, project: 'undefined', projects: [], restarting: false, running: [] });
23
+ this.pilotStore.setItem('pilot', { appDir, project: 'undefined', projects: [], restarting: 0, running: [] });
24
24
  }
25
25
  const { project } = this.pilotStore.getItem('pilot');
26
26
  this.projectStore = project === 'undefined' ? new EmptyStorage() : new JSONStorage(path.join(appDir, project, 'config'));
@@ -57,7 +57,7 @@ class CellFormatter {
57
57
  return this.style(value, "bgRed", "bold");
58
58
  if (value === 'Ready')
59
59
  return this.style(value, "green");
60
- if (value === 'ReadyToJoin')
60
+ if (value === 'ReadyToJoin' || value === 'JoiningCluster')
61
61
  return this.style(value, "yellow", "bold");
62
62
  if (value === 'Restarting')
63
63
  return this.style(value, "yellow", "bold");
@@ -79,13 +79,15 @@ export class StatusTable {
79
79
  err.timeAgo = formatTimeAgo(Date.now() - n.errorDate) || '';
80
80
  }
81
81
  }
82
- this.render(rows, err.msg !== '');
83
- if (err.msg) {
82
+ let hasError = err.msg !== '';
83
+ if (hasError) {
84
84
  const d = new Date(err.date);
85
85
  // if under 8 hours ago
86
- if (d.getTime() + (8 * 60 * 60 * 1000) > Date.now()) {
87
- process.stdout.write(chalk.green(` AUTO HEALED (${err.timeAgo}): `) + chalk.red(`${err.layer}:${err.msg} - ${err.date}\n`));
88
- }
86
+ hasError = (d.getTime() + (8 * 60 * 60 * 1000) > Date.now());
87
+ }
88
+ this.render(rows, hasError);
89
+ if (hasError) {
90
+ process.stdout.write(chalk.green(` AUTO HEALED (${err.timeAgo}): `) + chalk.red(`${err.layer}:${err.msg} - ${err.date}\n`));
89
91
  }
90
92
  process.stdout.write(" * press any key to cancel");
91
93
  // eslint-disable-next-line no-await-in-loop
@@ -336,5 +336,5 @@
336
336
  ]
337
337
  }
338
338
  },
339
- "version": "0.0.19"
339
+ "version": "0.0.20"
340
340
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@constellation-network/node-pilot",
3
3
  "description": "An easy deployment and monitoring tool for Constellation nodes.",
4
- "version": "0.0.19",
4
+ "version": "0.0.20",
5
5
  "author": "Frank Fox",
6
6
  "bin": {
7
7
  "cpilot": "bin/run.js"