@constellation-network/node-pilot 0.2.0 → 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.
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.2.0 darwin-arm64 node-v22.15.0
24
+ @constellation-network/node-pilot/0.2.1 darwin-arm64 node-v22.15.0
25
25
  $ cpilot --help [COMMAND]
26
26
  USAGE
27
27
  $ cpilot COMMAND
@@ -37,7 +37,7 @@ If no command is entered, node-pilot will automatically perform a series of chec
37
37
 
38
38
  # Commands
39
39
  <!-- commands -->
40
- * [`cpilot clean LAYER`](#cpilot-clean-layer)
40
+ * [`cpilot clean [LAYER]`](#cpilot-clean-layer)
41
41
  * [`cpilot config`](#cpilot-config)
42
42
  * [`cpilot config get [NAME]`](#cpilot-config-get-name)
43
43
  * [`cpilot config set NAME VALUE`](#cpilot-config-set-name-value)
@@ -48,21 +48,21 @@ If no command is entered, node-pilot will automatically perform a series of chec
48
48
  * [`cpilot shutdown`](#cpilot-shutdown)
49
49
  * [`cpilot status`](#cpilot-status)
50
50
 
51
- ## `cpilot clean LAYER`
51
+ ## `cpilot clean [LAYER]`
52
52
 
53
53
  Remove data and/or logs from a validator node
54
54
 
55
55
  ```
56
56
  USAGE
57
- $ cpilot clean LAYER [-a] [-d] [-l]
57
+ $ cpilot clean [LAYER] [-d] [-j] [-l]
58
58
 
59
59
  ARGUMENTS
60
60
  LAYER network layer to clean. e.g. gl0
61
61
 
62
62
  FLAGS
63
- -a, --all remove all data and logs
64
- -d, --data remove data
65
- -l, --logs remove logs
63
+ -d, --data remove only data
64
+ -j, --jars remove only jars
65
+ -l, --logs remove only logs
66
66
 
67
67
  DESCRIPTION
68
68
  Remove data and/or logs from a validator node
@@ -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.2.0/src/commands/clean.ts)_
74
+ _See code: [src/commands/clean.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.2.1/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.2.0/src/commands/config.ts)_
91
+ _See code: [src/commands/config.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.2.1/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.2.0/src/commands/config/get.ts)_
115
+ _See code: [src/commands/config/get.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.2.1/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.2.0/src/commands/config/set.ts)_
138
+ _See code: [src/commands/config/set.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.2.1/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.2.0/src/commands/info.ts)_
175
+ _See code: [src/commands/info.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.2.1/src/commands/info.ts)_
176
176
 
177
177
  ## `cpilot logs LAYER`
178
178
 
@@ -198,7 +198,7 @@ EXAMPLES
198
198
  $ cpilot logs
199
199
  ```
200
200
 
201
- _See code: [src/commands/logs.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.2.0/src/commands/logs.ts)_
201
+ _See code: [src/commands/logs.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.2.1/src/commands/logs.ts)_
202
202
 
203
203
  ## `cpilot restart [LAYER]`
204
204
 
@@ -226,7 +226,7 @@ EXAMPLES
226
226
  $ cpilot restart
227
227
  ```
228
228
 
229
- _See code: [src/commands/restart.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.2.0/src/commands/restart.ts)_
229
+ _See code: [src/commands/restart.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.2.1/src/commands/restart.ts)_
230
230
 
231
231
  ## `cpilot shutdown`
232
232
 
@@ -246,7 +246,7 @@ EXAMPLES
246
246
  $ cpilot shutdown
247
247
  ```
248
248
 
249
- _See code: [src/commands/shutdown.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.2.0/src/commands/shutdown.ts)_
249
+ _See code: [src/commands/shutdown.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.2.1/src/commands/shutdown.ts)_
250
250
 
251
251
  ## `cpilot status`
252
252
 
@@ -260,5 +260,5 @@ DESCRIPTION
260
260
  Display node status and configuration settings
261
261
  ```
262
262
 
263
- _See code: [src/commands/status.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.2.0/src/commands/status.ts)_
263
+ _See code: [src/commands/status.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.2.1/src/commands/status.ts)_
264
264
  <!-- commandsstop -->
@@ -1,5 +1,6 @@
1
1
  export declare const checkNodePilot: {
2
2
  checkDiscordRegistration(): Promise<void>;
3
3
  checkVersion(): Promise<void>;
4
+ isDiscordAlertsEnabled(): any;
4
5
  promptDiscordRegistration(): Promise<void>;
5
6
  };
@@ -67,6 +67,11 @@ export const checkNodePilot = {
67
67
  clm.postStep('Update completed. Run cpilot again to use the latest version');
68
68
  process.exit(0);
69
69
  },
70
+ isDiscordAlertsEnabled() {
71
+ const hcStorage = getHcStorage();
72
+ const user = hcStorage.getItem('user');
73
+ return user && user.webHookEnabled;
74
+ },
70
75
  async promptDiscordRegistration() {
71
76
  const hcStorage = getHcStorage();
72
77
  const join = await promptHelper.confirmPrompt('Do you want to enable Discord notifications for your node?:');
@@ -1,13 +1,13 @@
1
1
  import { Command } from '@oclif/core';
2
2
  export default class Clean extends Command {
3
3
  static args: {
4
- layer: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
4
+ layer: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
5
5
  };
6
6
  static description: string;
7
7
  static examples: string[];
8
8
  static flags: {
9
- all: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
9
  data: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
+ jars: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
11
  logs: import("@oclif/core/interfaces").BooleanFlag<boolean>;
12
12
  };
13
13
  run(): Promise<void>;
@@ -7,40 +7,50 @@ import { dockerService } from "../services/docker-service.js";
7
7
  import { shellService } from "../services/shell-service.js";
8
8
  export default class Clean extends Command {
9
9
  static args = {
10
- layer: Args.string({ description: 'network layer to clean. e.g. gl0', required: true }),
10
+ layer: Args.string({ description: 'network layer to clean. e.g. gl0', required: false }),
11
11
  };
12
12
  static description = 'Remove data and/or logs from a validator node';
13
13
  static examples = [
14
14
  '<%= config.bin %> <%= command.id %>',
15
15
  ];
16
16
  static flags = {
17
- all: Flags.boolean({ char: 'a', description: 'remove all data and logs' }),
18
- data: Flags.boolean({ char: 'd', description: 'remove data' }),
19
- logs: Flags.boolean({ char: 'l', description: 'remove logs' })
17
+ data: Flags.boolean({ char: 'd', description: 'remove only data' }),
18
+ jars: Flags.boolean({ char: 'j', description: 'remove only jars' }),
19
+ logs: Flags.boolean({ char: 'l', description: 'remove only logs' })
20
20
  };
21
21
  async run() {
22
22
  const { args, flags } = await this.parse(Clean);
23
23
  const { layersToRun } = configStore.getProjectInfo();
24
- if (!layersToRun.includes(args.layer)) {
24
+ if (args.layer && !layersToRun.includes(args.layer)) {
25
25
  this.error(`Invalid layer: ${args.layer}. Available layers: ${layersToRun.join(',')}`);
26
26
  }
27
- const deleteLogs = flags.logs || flags.all;
28
- const deleteData = flags.data || flags.all;
29
- if (!deleteLogs && !deleteData) {
30
- this.error('At least one of --data or --logs must be specified.');
31
- }
27
+ const layers = args.layer ? [args.layer] : layersToRun;
28
+ const deleteAll = !flags.data && !flags.logs && !flags.jars;
29
+ const deleteLogs = flags.logs || deleteAll;
30
+ const deleteData = flags.data || deleteAll;
31
+ const deleteJars = flags.jars || deleteAll;
32
32
  if (await dockerService.isRunning()) {
33
33
  clm.preStep('The validator node must be stopped first.');
34
34
  await promptHelper.doYouWishToContinue();
35
35
  await dockerService.dockerDown();
36
36
  }
37
- if (deleteData) {
38
- await shellService.runProjectCommand(`sudo rm -rf ${args.layer}/data`);
39
- projectHelper.prepareDataFolder();
40
- configStore.setProjectFlag('discordChecked', false);
41
- }
42
- if (deleteLogs) {
43
- await shellService.runProjectCommand(`sudo rm -rf ${args.layer}/logs`);
37
+ for (const layer of layers) {
38
+ if (deleteData) {
39
+ // eslint-disable-next-line no-await-in-loop
40
+ await shellService.runProjectCommand(`sudo rm -rf ${layer}/data`);
41
+ if (layer === 'gl0') {
42
+ projectHelper.prepareDataFolder();
43
+ configStore.setProjectFlag('discordChecked', false);
44
+ }
45
+ }
46
+ if (deleteLogs) {
47
+ // eslint-disable-next-line no-await-in-loop
48
+ await shellService.runProjectCommand(`sudo rm -rf ${layer}/logs`);
49
+ }
50
+ if (deleteJars) {
51
+ // eslint-disable-next-line no-await-in-loop
52
+ await shellService.runProjectCommand(`sudo rm -rf ${layer}/dist`);
53
+ }
44
54
  }
45
55
  }
46
56
  }
@@ -1,6 +1,7 @@
1
1
  import { Command } from '@oclif/core';
2
2
  import { configStore } from "../config-store.js";
3
3
  import { configHelper } from "../helpers/config-helper.js";
4
+ import { checkNodePilot } from "../checks/check-pilot.js";
4
5
  export default class Info extends Command {
5
6
  static description = 'Display general info about the validator node';
6
7
  static examples = [
@@ -28,6 +29,8 @@ export default class Info extends Command {
28
29
  // Project Directory
29
30
  configHelper.showEnvInfo('Project Directory', projectInfo.projectDir);
30
31
  // Fast Forward
31
- configHelper.showEnvInfo('Fast Forward Enabled', (projectInfo.fastForward === undefined || Boolean(projectInfo.fastForward)).toString());
32
+ // configHelper.showEnvInfo('Fast Forward Enabled', (projectInfo.fastForward === undefined || Boolean(projectInfo.fastForward)).toString());
33
+ // Discord alerts
34
+ configHelper.showEnvInfo('Discord Alerts Enabled', checkNodePilot.isDiscordAlertsEnabled());
32
35
  }
33
36
  }
@@ -19,7 +19,7 @@ export class StatusTable {
19
19
  });
20
20
  const table = new StatusTable();
21
21
  const cols = process.stdout.columns;
22
- console.log(String('Colspan: ' + cols));
22
+ // console.log(String('Colspan: ' + cols));
23
23
  if (cols > 120) {
24
24
  table.monitorWide();
25
25
  }
@@ -94,7 +94,7 @@ export class StatusTable {
94
94
  tables.push({ error: errorMsg, label, row1: [row1], row2: [row2] });
95
95
  }
96
96
  this.renderNarrow(tables);
97
- process.stdout.write("\n * press any key to cancel");
97
+ process.stdout.write("\n * press any key to stop monitoring");
98
98
  // eslint-disable-next-line no-await-in-loop
99
99
  await sleep(1);
100
100
  }
@@ -141,7 +141,7 @@ export class StatusTable {
141
141
  // projects.push({ error: errorMsg, label, row1, row2 });
142
142
  }
143
143
  this.renderWide({ error: errorMsg, label: '', row1: rows, row2: [] });
144
- process.stdout.write("\n * press any key to cancel");
144
+ process.stdout.write("\n * press any key to stop monitoring");
145
145
  // eslint-disable-next-line no-await-in-loop
146
146
  await sleep(1);
147
147
  }
@@ -6,7 +6,7 @@
6
6
  "layer": {
7
7
  "description": "network layer to clean. e.g. gl0",
8
8
  "name": "layer",
9
- "required": true
9
+ "required": false
10
10
  }
11
11
  },
12
12
  "description": "Remove data and/or logs from a validator node",
@@ -14,23 +14,23 @@
14
14
  "<%= config.bin %> <%= command.id %>"
15
15
  ],
16
16
  "flags": {
17
- "all": {
18
- "char": "a",
19
- "description": "remove all data and logs",
20
- "name": "all",
21
- "allowNo": false,
22
- "type": "boolean"
23
- },
24
17
  "data": {
25
18
  "char": "d",
26
- "description": "remove data",
19
+ "description": "remove only data",
27
20
  "name": "data",
28
21
  "allowNo": false,
29
22
  "type": "boolean"
30
23
  },
24
+ "jars": {
25
+ "char": "j",
26
+ "description": "remove only jars",
27
+ "name": "jars",
28
+ "allowNo": false,
29
+ "type": "boolean"
30
+ },
31
31
  "logs": {
32
32
  "char": "l",
33
- "description": "remove logs",
33
+ "description": "remove only logs",
34
34
  "name": "logs",
35
35
  "allowNo": false,
36
36
  "type": "boolean"
@@ -349,5 +349,5 @@
349
349
  ]
350
350
  }
351
351
  },
352
- "version": "0.2.0"
352
+ "version": "0.2.1"
353
353
  }
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.2.0",
4
+ "version": "0.2.1",
5
5
  "author": "Frank Fox",
6
6
  "bin": {
7
7
  "cpilot": "bin/run.js"
@@ -20,8 +20,8 @@ services:
20
20
  volumes:
21
21
  - ./gl0/data:/app/data
22
22
  - ./gl0/logs:/app/logs
23
+ - ./seedlist:/app/seedlist
23
24
  - ./key.p12:/app/key.p12:ro
24
- - ./seedlist:/app/seedlist:ro
25
25
  healthcheck:
26
26
  test: ["CMD", "cpilotHC"]
27
27
  # test: ["CMD", "/health-check/bin/run.sh"]