@constellation-network/node-pilot 0.18.0-testnet → 0.18.1-testnet

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.
Files changed (44) hide show
  1. package/README.md +12 -16
  2. package/dist/base-command.d.ts +1 -1
  3. package/dist/base-command.js +13 -4
  4. package/dist/checks/check-hardware.js +2 -2
  5. package/dist/checks/check-initial-setup.js +2 -1
  6. package/dist/checks/check-network.js +0 -7
  7. package/dist/checks/check-project.js +6 -4
  8. package/dist/clm.js +2 -2
  9. package/dist/commands/config/get.js +8 -0
  10. package/dist/commands/config/set.js +5 -1
  11. package/dist/commands/config.js +8 -0
  12. package/dist/commands/info.js +6 -0
  13. package/dist/commands/project.d.ts +12 -0
  14. package/dist/commands/project.js +46 -0
  15. package/dist/commands/restart.d.ts +2 -2
  16. package/dist/commands/restart.js +15 -16
  17. package/dist/commands/shutdown.js +2 -1
  18. package/dist/commands/status.d.ts +1 -1
  19. package/dist/commands/status.js +1 -1
  20. package/dist/config-store.d.ts +12 -20
  21. package/dist/config-store.js +9 -116
  22. package/dist/helpers/config-helper.js +2 -1
  23. package/dist/helpers/pilot-manager.d.ts +23 -0
  24. package/dist/helpers/pilot-manager.js +170 -0
  25. package/dist/helpers/project-helper.d.ts +3 -2
  26. package/dist/helpers/project-helper.js +39 -17
  27. package/dist/helpers/prompt-helper.d.ts +1 -0
  28. package/dist/helpers/prompt-helper.js +15 -3
  29. package/dist/helpers/service-log.js +2 -2
  30. package/dist/helpers/status-table.js +5 -4
  31. package/dist/services/cluster-service.d.ts +2 -1
  32. package/dist/services/cluster-service.js +28 -7
  33. package/dist/services/docker-service.js +3 -2
  34. package/dist/services/node-service.js +3 -2
  35. package/oclif.manifest.json +42 -13
  36. package/package.json +1 -1
  37. package/projects/hypergraph/docker-compose.yml +8 -4
  38. package/projects/hypergraph/networks/integrationnet/gl0.env +2 -1
  39. package/projects/hypergraph/networks/integrationnet/gl1.env +4 -3
  40. package/projects/hypergraph/networks/mainnet/gl0.env +2 -1
  41. package/projects/hypergraph/networks/mainnet/gl1.env +2 -1
  42. package/projects/hypergraph/networks/testnet/gl0.env +1 -0
  43. package/projects/hypergraph/networks/testnet/gl1.env +1 -0
  44. package/projects/hypergraph/scripts/install-dependencies.sh +2 -2
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.18.0-testnet darwin-arm64 node-v22.15.0
24
+ @constellation-network/node-pilot/0.18.1-testnet darwin-arm64 node-v22.15.0
25
25
  $ cpilot --help [COMMAND]
26
26
  USAGE
27
27
  $ cpilot COMMAND
@@ -72,7 +72,7 @@ EXAMPLES
72
72
  $ cpilot clean
73
73
  ```
74
74
 
75
- _See code: [src/commands/clean.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.18.0-testnet/src/commands/clean.ts)_
75
+ _See code: [src/commands/clean.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.18.1-testnet/src/commands/clean.ts)_
76
76
 
77
77
  ## `cpilot config`
78
78
 
@@ -89,7 +89,7 @@ EXAMPLES
89
89
  $ cpilot config
90
90
  ```
91
91
 
92
- _See code: [src/commands/config.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.18.0-testnet/src/commands/config.ts)_
92
+ _See code: [src/commands/config.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.18.1-testnet/src/commands/config.ts)_
93
93
 
94
94
  ## `cpilot config get [NAME]`
95
95
 
@@ -113,7 +113,7 @@ EXAMPLES
113
113
  $ cpilot config get gl0:CL_PUBLIC_HTTP_PORT
114
114
  ```
115
115
 
116
- _See code: [src/commands/config/get.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.18.0-testnet/src/commands/config/get.ts)_
116
+ _See code: [src/commands/config/get.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.18.1-testnet/src/commands/config/get.ts)_
117
117
 
118
118
  ## `cpilot config set NAME VALUE`
119
119
 
@@ -136,7 +136,7 @@ EXAMPLES
136
136
  $ cpilot config set gl0:CL_PUBLIC_HTTP_PORT 9000
137
137
  ```
138
138
 
139
- _See code: [src/commands/config/set.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.18.0-testnet/src/commands/config/set.ts)_
139
+ _See code: [src/commands/config/set.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.18.1-testnet/src/commands/config/set.ts)_
140
140
 
141
141
  ## `cpilot help [COMMAND]`
142
142
 
@@ -173,7 +173,7 @@ EXAMPLES
173
173
  $ cpilot info
174
174
  ```
175
175
 
176
- _See code: [src/commands/info.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.18.0-testnet/src/commands/info.ts)_
176
+ _See code: [src/commands/info.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.18.1-testnet/src/commands/info.ts)_
177
177
 
178
178
  ## `cpilot logs LAYER`
179
179
 
@@ -199,7 +199,7 @@ EXAMPLES
199
199
  $ cpilot logs
200
200
  ```
201
201
 
202
- _See code: [src/commands/logs.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.18.0-testnet/src/commands/logs.ts)_
202
+ _See code: [src/commands/logs.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.18.1-testnet/src/commands/logs.ts)_
203
203
 
204
204
  ## `cpilot restart [LAYER]`
205
205
 
@@ -207,7 +207,7 @@ A full shutdown of the validator node, then restart
207
207
 
208
208
  ```
209
209
  USAGE
210
- $ cpilot restart [LAYER] [-p hypergraph] [--autostart] [--update]
210
+ $ cpilot restart [LAYER] [--autostart] [--update]
211
211
 
212
212
  ARGUMENTS
213
213
  LAYER network layer to restart. e.g. gl0
@@ -216,10 +216,6 @@ FLAGS
216
216
  --autostart restart each running project if it has been stopped
217
217
  --update update each project if a new version is available
218
218
 
219
- GLOBAL FLAGS
220
- -p, --project=<option> Specify the project name to use
221
- <options: hypergraph>
222
-
223
219
  DESCRIPTION
224
220
  A full shutdown of the validator node, then restart
225
221
 
@@ -227,7 +223,7 @@ EXAMPLES
227
223
  $ cpilot restart
228
224
  ```
229
225
 
230
- _See code: [src/commands/restart.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.18.0-testnet/src/commands/restart.ts)_
226
+ _See code: [src/commands/restart.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.18.1-testnet/src/commands/restart.ts)_
231
227
 
232
228
  ## `cpilot shutdown`
233
229
 
@@ -244,7 +240,7 @@ EXAMPLES
244
240
  $ cpilot shutdown
245
241
  ```
246
242
 
247
- _See code: [src/commands/shutdown.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.18.0-testnet/src/commands/shutdown.ts)_
243
+ _See code: [src/commands/shutdown.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.18.1-testnet/src/commands/shutdown.ts)_
248
244
 
249
245
  ## `cpilot status`
250
246
 
@@ -258,7 +254,7 @@ DESCRIPTION
258
254
  Display node status and configuration settings
259
255
  ```
260
256
 
261
- _See code: [src/commands/status.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.18.0-testnet/src/commands/status.ts)_
257
+ _See code: [src/commands/status.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.18.1-testnet/src/commands/status.ts)_
262
258
 
263
259
  ## `cpilot uninstall`
264
260
 
@@ -275,5 +271,5 @@ EXAMPLES
275
271
  $ cpilot uninstall
276
272
  ```
277
273
 
278
- _See code: [src/commands/uninstall.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.18.0-testnet/src/commands/uninstall.ts)_
274
+ _See code: [src/commands/uninstall.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.18.1-testnet/src/commands/uninstall.ts)_
279
275
  <!-- commandsstop -->
@@ -5,5 +5,5 @@ export declare abstract class BaseCommand extends Command {
5
5
  };
6
6
  checkProject(flags: {
7
7
  project?: string;
8
- }): void;
8
+ }): Promise<void>;
9
9
  }
@@ -1,20 +1,29 @@
1
+ import { select } from "@inquirer/prompts";
1
2
  // src/base.ts
2
3
  import { Command, Flags } from '@oclif/core';
3
- import { configStore } from "./config-store.js";
4
+ import { clm } from "./clm.js";
4
5
  import { configHelper } from "./helpers/config-helper.js";
6
+ import { pilotManager } from "./helpers/pilot-manager.js";
5
7
  export class BaseCommand extends Command {
6
8
  static baseFlags = {
7
9
  project: Flags.string({
8
10
  char: 'p',
9
11
  description: 'Specify the project name to use',
10
12
  helpGroup: 'GLOBAL', // Optional: Group this flag in the help output
11
- options: configStore.getProjects()
13
+ // options: configStore.getProjects()
12
14
  })
13
15
  };
14
- checkProject(flags) {
16
+ async checkProject(flags) {
15
17
  configHelper.assertProject('No project found. ');
16
18
  if (flags.project) {
17
- configStore.setActiveProject(flags.project);
19
+ const projects = pilotManager.getProjects();
20
+ if (projects.includes(flags.project)) {
21
+ pilotManager.setActiveProject(flags.project);
22
+ clm.postStep(`Active project set to ${flags.project}`);
23
+ }
24
+ else {
25
+ await select({ choices: [...projects, `Create new project [${flags.project}]`], message: 'Change active project' });
26
+ }
18
27
  }
19
28
  }
20
29
  }
@@ -3,7 +3,7 @@ import fs from "node:fs";
3
3
  import os from "node:os";
4
4
  import ttyTable from "tty-table";
5
5
  import { clm } from "../clm.js";
6
- import { configStore } from "../config-store.js";
6
+ import { pilotManager } from "../helpers/pilot-manager.js";
7
7
  import { promptHelper } from "../helpers/prompt-helper.js";
8
8
  export const checkHardware = {
9
9
  async systemRequirements() {
@@ -50,6 +50,6 @@ export const checkHardware = {
50
50
  else {
51
51
  clm.error("System requirements not met.\n");
52
52
  }
53
- configStore.setSystemInfo({ cores: numOfCores, disk: totalSpaceGB, memory: totalMemoryGB, platform: os.platform(), user: os.userInfo().username });
53
+ pilotManager.setSystemInfo({ cores: numOfCores, disk: totalSpaceGB, memory: totalMemoryGB, platform: os.platform(), user: os.userInfo().username });
54
54
  }
55
55
  };
@@ -3,6 +3,7 @@ import os from "node:os";
3
3
  import path from "node:path";
4
4
  import { clm } from "../clm.js";
5
5
  import { configStore } from "../config-store.js";
6
+ import { pilotManager } from "../helpers/pilot-manager.js";
6
7
  import { shellService } from "../services/shell-service.js";
7
8
  import { systemdService } from "../services/systemd-service.js";
8
9
  import { checkDependencies } from "./check-dependencies.js";
@@ -22,7 +23,7 @@ export const checkInitialSetup = {
22
23
  }
23
24
  await checkDependencies();
24
25
  await this.checkExistingUsers();
25
- if (configStore.getSystemInfo() === null) {
26
+ if (pilotManager.getSystemInfo() === null) {
26
27
  await checkHardware.systemRequirements();
27
28
  }
28
29
  // console.log(chalk.whiteBright("\n ****************************************"));
@@ -144,13 +144,6 @@ export const checkNetwork = {
144
144
  const { type } = configStore.getNetworkInfo();
145
145
  return clusterService.getClusterInfo()
146
146
  .then(async (nodes) => {
147
- const someAreReady = nodes.some(node => node.state === 'Ready');
148
- if (!someAreReady) {
149
- if (nodes.length > 0) {
150
- clm.warn(`Found ${nodes.length} nodes in the cluster, but none are READY.`);
151
- }
152
- throw new Error(`Network is not connectable.`);
153
- }
154
147
  clm.debug(`${type} is live. Found ${nodes.length} nodes in the cluster.`);
155
148
  configStore.setClusterStats({ total: nodes.length });
156
149
  return true;
@@ -4,6 +4,7 @@ import ora from "ora";
4
4
  import { clm } from "../clm.js";
5
5
  import { configStore } from "../config-store.js";
6
6
  import { configHelper } from "../helpers/config-helper.js";
7
+ import { pilotManager } from "../helpers/pilot-manager.js";
7
8
  import { projectHelper } from "../helpers/project-helper.js";
8
9
  import { promptHelper } from "../helpers/prompt-helper.js";
9
10
  import { clusterService } from "../services/cluster-service.js";
@@ -14,7 +15,7 @@ function getJavaMemoryOptions(network, mem) {
14
15
  if (network === 'testnet') {
15
16
  const linuxOpt = (os.platform() === 'linux') ? ' -XX:+UseZGC -XX:+ZGenerational -XX:ZAllocationSpikeTolerance=5 -XX:ZCollectionInterval=10' : '';
16
17
  // return `-Xms${mem}g -Xmx${mem}g -XX:+UnlockExperimentalVMOptions${linuxOpt} -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=./heap_dumps/ -XX:+ExitOnOutOfMemoryError`;
17
- return `-Xms${mem}g -Xmx${mem}g${linuxOpt} -XX:+UseStringDeduplication`;
18
+ return `-Xms${mem - 2}g -Xmx${mem}g${linuxOpt} -XX:+UseStringDeduplication`;
18
19
  }
19
20
  if (network === 'integrationnet') {
20
21
  const linuxOpt = (os.platform() === 'linux') ? ' -XX:+UseZGC -XX:+ZGenerational' : '';
@@ -31,7 +32,7 @@ export const checkProject = {
31
32
  await this.configureJavaMemoryArguments();
32
33
  },
33
34
  async configureJavaMemoryArguments() {
34
- const { memory } = configStore.getSystemInfo();
35
+ const { memory } = pilotManager.getSystemInfo();
35
36
  const { layersToRun, name } = configStore.getProjectInfo();
36
37
  const { type: currentNetwork } = configStore.getNetworkInfo();
37
38
  const xmx = Number(memory);
@@ -85,7 +86,7 @@ export const checkProject = {
85
86
  async projectInstallation() {
86
87
  let updateNetworkType = false;
87
88
  let updateLayers = false;
88
- if (!configStore.hasProjects()) {
89
+ if (!pilotManager.isProjectInstalled()) {
89
90
  await projectHelper.selectProject();
90
91
  await checkNetwork.configureIpAddress();
91
92
  updateNetworkType = true;
@@ -100,6 +101,7 @@ export const checkProject = {
100
101
  if (!layersToRun || updateLayers) {
101
102
  await promptHelper.selectLayers();
102
103
  await this.configureJavaMemoryArguments();
104
+ projectHelper.updateDockerEnv();
103
105
  }
104
106
  },
105
107
  async releaseVersion() {
@@ -162,7 +164,7 @@ export const checkProject = {
162
164
  if (isRunning) {
163
165
  await dockerService.dockerDown();
164
166
  }
165
- const showSpinner = !configStore.isRestarting();
167
+ const showSpinner = !pilotManager.isRestarting();
166
168
  const spinner = ora('');
167
169
  if (showSpinner) {
168
170
  spinner.start();
package/dist/clm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import chalk from "chalk";
2
- import { configStore } from "./config-store.js";
2
+ import { pilotManager } from "./helpers/pilot-manager.js";
3
3
  import { serviceLog } from "./helpers/service-log.js";
4
4
  /*
5
5
  Command Line Messaging with color styling
@@ -34,5 +34,5 @@ export const clm = {
34
34
  }
35
35
  };
36
36
  function o() {
37
- return configStore.isRestarting() ? serviceLog : console;
37
+ return pilotManager.isRestarting() ? serviceLog : console;
38
38
  }
@@ -37,9 +37,12 @@ export default class ConfigGet extends Command {
37
37
  const layersList = layersToRun.map(l => (Object.keys(layerEnvNames).map(k => ({ name: `${l}:${k}`, value: gl(l)[k] }))));
38
38
  const keyInfo = this.getKeyInfo();
39
39
  const keyInfoList = Object.keys(keyInfo).map(k => ({ name: 'key:' + k, value: keyInfo[k] }));
40
+ const dockerInfo = configStore.getDockerEnvInfo();
41
+ const dockerInfoList = Object.keys(dockerInfo).map(k => ({ name: 'docker:' + k, value: dockerInfo[k] }));
40
42
  configHelper.showEnvInfoList(networkList);
41
43
  configHelper.showEnvInfoList(keyInfoList);
42
44
  configHelper.showEnvInfoList(layersList.flat());
45
+ configHelper.showEnvInfoList(dockerInfoList);
43
46
  }
44
47
  else if (args.name.includes(':')) {
45
48
  const [layer, name] = args.name.split(':');
@@ -62,6 +65,11 @@ export default class ConfigGet extends Command {
62
65
  clm.warn('Invalid layer property. Valid properties are: ' + Object.keys(layerEnvNames).join(', '));
63
66
  }
64
67
  }
68
+ else if (args.name === 'docker') {
69
+ const dockerInfo = configStore.getDockerEnvInfo();
70
+ const dockerInfoList = Object.keys(dockerInfo).map(k => ({ name: 'docker:' + k, value: dockerInfo[k] }));
71
+ configHelper.showEnvInfoList(dockerInfoList);
72
+ }
65
73
  else if (args.name === 'key') {
66
74
  const keyInfo = this.getKeyInfo();
67
75
  const keyInfoList = Object.keys(keyInfo).map(k => ({ name: 'key:' + k, value: keyInfo[k] }));
@@ -17,9 +17,13 @@ export default class ConfigSet extends Command {
17
17
  configHelper.assertProject('No configuration found. ');
18
18
  const { args } = await this.parse(ConfigSet);
19
19
  const { layersToRun } = configStore.getProjectInfo();
20
- if (args.name.startsWith('key')) {
20
+ if (args.name.startsWith('key:')) {
21
21
  clm.error(`Key properties cannot be set directly. Please run ${chalk.cyan('cpilot config')} and select ${chalk.cyan('Key Info')} to manage the key file.`);
22
22
  }
23
+ if (args.name.startsWith('docker:')) {
24
+ // Note: Multiple places need to be updated (LayerInfo and DockerInfo). It's easier to require the user to run the config command to update docker properties.
25
+ clm.error(`Docker ports cannot be set directly. Please run ${chalk.cyan('cpilot config')} and select ${chalk.cyan('Container Ports')} to manage.`);
26
+ }
23
27
  const { type: network } = configStore.getNetworkInfo();
24
28
  if (args.name.includes(':')) {
25
29
  const [layer, name] = args.name.split(':');
@@ -28,6 +28,7 @@ export default class Config extends Command {
28
28
  { name: 'Layers To Run', value: 'layersToRun' },
29
29
  { name: 'Constellation Network', value: 'network' },
30
30
  { name: 'External IP Address', value: 'externalIp' },
31
+ { name: 'Container Ports', value: 'ports' },
31
32
  ],
32
33
  message: 'What would you like to change?:',
33
34
  });
@@ -41,6 +42,11 @@ export default class Config extends Command {
41
42
  else if (answer === 'delegatedStaking') {
42
43
  await delegatedStakingService.configureNodeParams();
43
44
  }
45
+ else if (answer === 'ports') {
46
+ await promptHelper.configurePorts();
47
+ projectHelper.updateDockerEnv();
48
+ ;
49
+ }
44
50
  else if (answer === 'javaMemory') {
45
51
  await promptHelper.shutdownNodeIfRunning();
46
52
  await checkProject.configureJavaMemoryArguments();
@@ -54,6 +60,7 @@ export default class Config extends Command {
54
60
  await promptHelper.shutdownNodeIfRunning();
55
61
  await promptHelper.selectLayers();
56
62
  await checkProject.configureJavaMemoryArguments();
63
+ projectHelper.updateDockerEnv();
57
64
  }
58
65
  else if (answer === 'network') {
59
66
  clm.warn('Changing the network will DELETE all the data and logs from the validator node.');
@@ -61,6 +68,7 @@ export default class Config extends Command {
61
68
  const { layersToRun } = configStore.getProjectInfo();
62
69
  await projectHelper.cleanup(layersToRun, true, true, true);
63
70
  await promptHelper.selectNetwork();
71
+ projectHelper.updateDockerEnv();
64
72
  await checkNodePilot.checkVersion(); // each network may have its own release
65
73
  await checkProject.runInstall();
66
74
  }
@@ -2,6 +2,7 @@ import { Command } from '@oclif/core';
2
2
  import { checkNodePilot } from "../checks/check-pilot.js";
3
3
  import { configStore } from "../config-store.js";
4
4
  import { configHelper } from "../helpers/config-helper.js";
5
+ import { pilotManager } from "../helpers/pilot-manager.js";
5
6
  export default class Info extends Command {
6
7
  static description = 'Display general info about the validator node';
7
8
  static examples = [
@@ -10,12 +11,17 @@ export default class Info extends Command {
10
11
  async run() {
11
12
  configHelper.assertProject('No project info found. ');
12
13
  const projectInfo = configStore.getProjectInfo();
14
+ const projects = pilotManager.getProjects();
13
15
  const networkInfo = configStore.getNetworkInfo();
14
16
  const { CL_EXTERNAL_IP: currentIpAddress } = configStore.getEnvInfo();
15
17
  const { CL_DOCKER_JAVA_OPTS } = configStore.getEnvLayerInfo(networkInfo.type, 'gl0');
16
18
  const { version } = configStore.getPilotReleaseInfo();
17
19
  // Project Name
18
20
  configHelper.showEnvInfo('Project Name', projectInfo.name);
21
+ // Active Project
22
+ if (projects.length > 1) {
23
+ configHelper.showEnvInfo('Project List', projects.join(', '));
24
+ }
19
25
  // Pilot Version
20
26
  configHelper.showEnvInfo('Node Pilot Version', version);
21
27
  // External IP Address
@@ -0,0 +1,12 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class Project extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ create: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ delete: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ };
9
+ static hidden: boolean;
10
+ checkProject(project: string): Promise<void>;
11
+ run(): Promise<void>;
12
+ }
@@ -0,0 +1,46 @@
1
+ import { select } from "@inquirer/prompts";
2
+ import { Command, Flags } from '@oclif/core';
3
+ import { clm } from "../clm.js";
4
+ import { pilotManager } from "../helpers/pilot-manager.js";
5
+ export default class Project extends Command {
6
+ static description = 'Create a new project, list all projects or change active project';
7
+ static examples = [
8
+ '<%= config.bin %> <%= command.id %>',
9
+ ];
10
+ static flags = {
11
+ create: Flags.string({ char: 'c', description: 'create a new project with the given name' }),
12
+ delete: Flags.string({ char: 'd', description: 'delete a project with the given name. WARNING: this will remove all data and logs associated with the project. Use with caution.' }),
13
+ };
14
+ static hidden = true;
15
+ async checkProject(project) {
16
+ if (project) {
17
+ const projects = pilotManager.getProjects();
18
+ if (projects.includes(project)) {
19
+ pilotManager.setActiveProject(project);
20
+ clm.postStep(`Active project set to ${project}`);
21
+ }
22
+ else {
23
+ const choices = projects.map(p => ({ name: p, value: p }));
24
+ choices.push({ name: `Create new project [${project}]`, value: project });
25
+ const choice = await select({ choices, message: 'Change active project' });
26
+ console.log(choice, project);
27
+ if (choice === project) {
28
+ pilotManager.setActiveProject(project, true);
29
+ }
30
+ }
31
+ }
32
+ }
33
+ async run() {
34
+ const { flags } = await this.parse(Project);
35
+ if (flags.create) {
36
+ await this.checkProject(flags.create);
37
+ }
38
+ else if (flags.delete) {
39
+ await pilotManager.removeProject(flags.delete);
40
+ }
41
+ else {
42
+ clm.preStep('Available projects: ' + pilotManager.getProjects().join(', '));
43
+ clm.postStep('Active project: ' + pilotManager.getActiveProject());
44
+ }
45
+ }
46
+ }
@@ -1,5 +1,5 @@
1
- import { BaseCommand } from "../base-command.js";
2
- export default class Restart extends BaseCommand {
1
+ import { Command } from '@oclif/core';
2
+ export default class Restart extends Command {
3
3
  static args: {
4
4
  layer: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
5
5
  };
@@ -1,13 +1,13 @@
1
- import { Args, Flags } from '@oclif/core';
2
- import { BaseCommand } from "../base-command.js";
1
+ import { Args, Command, Flags } from '@oclif/core';
3
2
  import { checkProject } from "../checks/check-project.js";
4
3
  import { clm } from "../clm.js";
5
4
  import { configStore } from "../config-store.js";
6
5
  import { configHelper } from "../helpers/config-helper.js";
6
+ import { pilotManager } from "../helpers/pilot-manager.js";
7
7
  import { serviceLog } from "../helpers/service-log.js";
8
8
  import { dockerService } from "../services/docker-service.js";
9
9
  import { nodeService } from "../services/node-service.js";
10
- export default class Restart extends BaseCommand {
10
+ export default class Restart extends Command {
11
11
  static args = {
12
12
  layer: Args.string({ description: 'network layer to restart. e.g. gl0' }),
13
13
  };
@@ -21,15 +21,14 @@ export default class Restart extends BaseCommand {
21
21
  };
22
22
  async run() {
23
23
  const { args, flags } = await this.parse(Restart);
24
- this.checkProject(flags);
25
24
  configHelper.assertProject('No project found. ');
26
25
  if (flags.update) {
27
26
  serviceLog.log('Executing "cpilot restart --update" at ' + new Date().toLocaleString('en-US', { timeZone: 'America/Los_Angeles' }));
28
27
  this.setIsRestarting(true);
29
- const project = configStore.getActiveProject();
30
- const activeProjects = configStore.getRunningProjects();
28
+ const project = pilotManager.getActiveProject();
29
+ const activeProjects = pilotManager.getRunningProjects();
31
30
  for (const project of activeProjects) {
32
- configStore.setActiveProject(project);
31
+ pilotManager.setActiveProject(project);
33
32
  // eslint-disable-next-line no-await-in-loop
34
33
  if (await checkProject.hasVersionChanged()) {
35
34
  serviceLog.log(' ' + project + ' version has changed. Restarting...');
@@ -40,22 +39,22 @@ export default class Restart extends BaseCommand {
40
39
  serviceLog.log(' ' + project + ' version is the same. ');
41
40
  }
42
41
  }
43
- configStore.setActiveProject(project);
42
+ pilotManager.setActiveProject(project);
44
43
  this.setIsRestarting(false);
45
44
  return;
46
45
  }
47
46
  if (flags.autostart) {
48
47
  serviceLog.log('Executing "cpilot restart --autostart" at ' + new Date().toLocaleString('en-US', { timeZone: 'America/Los_Angeles' }));
49
48
  this.setIsRestarting(true);
50
- const project = configStore.getActiveProject();
51
- const activeProjects = configStore.getRunningProjects();
49
+ const project = pilotManager.getActiveProject();
50
+ const activeProjects = pilotManager.getRunningProjects();
52
51
  for (const project of activeProjects) {
53
52
  serviceLog.log(' ' + project + ' is being auto started...');
54
- configStore.setActiveProject(project);
53
+ pilotManager.setActiveProject(project);
55
54
  // eslint-disable-next-line no-await-in-loop
56
55
  await this.restart();
57
56
  }
58
- configStore.setActiveProject(project);
57
+ pilotManager.setActiveProject(project);
59
58
  this.setIsRestarting(false);
60
59
  return;
61
60
  }
@@ -92,18 +91,18 @@ export default class Restart extends BaseCommand {
92
91
  }
93
92
  setIsRestarting(val) {
94
93
  if (val) {
95
- if (configStore.isRestarting()) {
94
+ if (pilotManager.isRestarting()) {
96
95
  serviceLog.log('Restart already ACTIVE');
97
96
  process.exit(0);
98
97
  }
99
98
  process.on("exit", () => {
100
99
  // serviceLog.log('exiting, clearing isRestarting flag');
101
- configStore.setIsRestarting(0);
100
+ pilotManager.setIsRestarting(0);
102
101
  });
103
- configStore.setIsRestarting(Date.now());
102
+ pilotManager.setIsRestarting(Date.now());
104
103
  }
105
104
  else {
106
- configStore.setIsRestarting(0);
105
+ pilotManager.setIsRestarting(0);
107
106
  }
108
107
  }
109
108
  }
@@ -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 { pilotManager } from "../helpers/pilot-manager.js";
4
5
  import { dockerService } from "../services/docker-service.js";
5
6
  import { nodeService } from "../services/node-service.js";
6
7
  export default class Shutdown extends Command {
@@ -15,7 +16,7 @@ export default class Shutdown extends Command {
15
16
  async run() {
16
17
  configHelper.assertProject('No project found. ');
17
18
  const { layersToRun } = configStore.getProjectInfo();
18
- configStore.setProjectStatusToRunning(false);
19
+ pilotManager.setProjectStatusToRunning(false);
19
20
  await nodeService.leaveClusterAllLayers();
20
21
  await nodeService.pollForLayersState(layersToRun, 'Offline');
21
22
  await dockerService.dockerDown();
@@ -1,4 +1,4 @@
1
- import { Command } from '@oclif/core';
1
+ import { Command } from "@oclif/core";
2
2
  export default class Status extends Command {
3
3
  static description: string;
4
4
  run(): Promise<void>;
@@ -1,4 +1,4 @@
1
- import { Command } from '@oclif/core';
1
+ import { Command } from "@oclif/core";
2
2
  import { checkInitialSetup } from "../checks/check-initial-setup.js";
3
3
  import { checkLayers } from "../checks/check-layers.js";
4
4
  import { checkNetwork } from "../checks/check-network.js";
@@ -1,11 +1,6 @@
1
1
  import { ClusterStats, TessellationLayer } from "./types.js";
2
2
  declare class ConfigStore {
3
- private pilotStore;
4
3
  private projectStore;
5
- constructor();
6
- applyNewProjectStore(name: string): Promise<void>;
7
- getActiveProject(): string;
8
- getAppDir(): string;
9
4
  getDockerEnvInfo(): object;
10
5
  getEnvInfo(): EnvInfo;
11
6
  getEnvLayerInfo(network: NetworkType, layer: TessellationLayer): EnvLayerInfo;
@@ -17,31 +12,25 @@ declare class ConfigStore {
17
12
  version: string;
18
13
  };
19
14
  getProjectInfo(): ProjectInfo;
20
- getProjects(): string[];
21
- getRunningProjects(): string[];
22
- getSystemInfo(): SystemInfo;
23
15
  hasProjectFlag(name: string): any;
24
- hasProjects(): boolean;
25
- isRestarting(): boolean;
26
- setActiveProject(name: string): void;
27
16
  setClusterStats(info: Partial<ClusterStats>): void;
28
- setDockerEnvInfo(info: Partial<{
29
- DOCKER_IMAGE_VERSION: string;
30
- DOCKER_USER_ID: string;
31
- }>): void;
17
+ setDockerEnvInfo(info: Partial<DockerEnvInfo>): void;
32
18
  setEnvInfo(info: Partial<EnvInfo>): void;
33
19
  setEnvLayerInfo(network: NetworkType, layer: TessellationLayer, info: Partial<EnvLayerInfo>): void;
34
20
  setEnvNetworkInfo(network: NetworkType, info: Partial<EnvNetworkInfo>): void;
35
- setIsRestarting(val: number): void;
36
21
  setNetworkInfo(info: Partial<NetworkInfo>): void;
22
+ setProjectConfig(config: string): void;
37
23
  setProjectFlag(name: string, value: boolean): any;
38
24
  setProjectInfo(info: Partial<ProjectInfo>): void;
39
- setProjectStatusToRunning(isRunning: boolean): void;
40
- setSystemInfo(info: Partial<SystemInfo>): void;
41
- private getPilotInfo;
42
- private setPilotInfo;
43
25
  }
44
26
  export declare const configStore: ConfigStore;
27
+ export type DockerEnvInfo = {
28
+ CL_GL0_P2P_PORT: string;
29
+ CL_GL0_PUBLIC_PORT: string;
30
+ CL_GL1_P2P_PORT: string;
31
+ CL_GL1_PUBLIC_PORT: string;
32
+ DOCKER_IMAGE_VERSION: string;
33
+ };
45
34
  export type EnvInfo = EnvKeyInfo & {
46
35
  CL_ARCHIVE_NODE: boolean;
47
36
  CL_EXTERNAL_IP: string;
@@ -89,6 +78,7 @@ export type EnvLayerInfo = EnvPeerInfo & {
89
78
  CL_LB: string;
90
79
  CL_P2P_HTTP_PORT: string;
91
80
  CL_PUBLIC_HTTP_PORT: string;
81
+ CL_SOURCE_HTTP_PORT: string;
92
82
  };
93
83
  export declare const layerEnvNames: {
94
84
  CL_CLI_HTTP_PORT: number;
@@ -103,6 +93,7 @@ export declare const layerEnvNames: {
103
93
  CL_LB: number;
104
94
  CL_P2P_HTTP_PORT: number;
105
95
  CL_PUBLIC_HTTP_PORT: number;
96
+ CL_SOURCE_HTTP_PORT: number;
106
97
  };
107
98
  export type SystemInfo = {
108
99
  cores: number;
@@ -121,6 +112,7 @@ export type ProjectInfo = {
121
112
  name: string;
122
113
  nodeId: string;
123
114
  projectDir: string;
115
+ type: 'hypergraph' | 'metagraph';
124
116
  version: string;
125
117
  };
126
118
  export type NetworkInfo = {