@layr-labs/ecloud-cli 0.1.0-dev.3 → 0.1.0-rc.2

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 (53) hide show
  1. package/README.md +4 -4
  2. package/VERSION +2 -2
  3. package/dist/commands/auth/generate.js +46 -184
  4. package/dist/commands/auth/generate.js.map +1 -1
  5. package/dist/commands/auth/login.js +93 -234
  6. package/dist/commands/auth/login.js.map +1 -1
  7. package/dist/commands/auth/logout.js +30 -170
  8. package/dist/commands/auth/logout.js.map +1 -1
  9. package/dist/commands/auth/migrate.js +76 -216
  10. package/dist/commands/auth/migrate.js.map +1 -1
  11. package/dist/commands/auth/whoami.js +17 -145
  12. package/dist/commands/auth/whoami.js.map +1 -1
  13. package/dist/commands/billing/cancel.js +30 -164
  14. package/dist/commands/billing/cancel.js.map +1 -1
  15. package/dist/commands/billing/status.js +80 -213
  16. package/dist/commands/billing/status.js.map +1 -1
  17. package/dist/commands/billing/subscribe.js +45 -179
  18. package/dist/commands/billing/subscribe.js.map +1 -1
  19. package/dist/commands/compute/app/create.js +20 -148
  20. package/dist/commands/compute/app/create.js.map +1 -1
  21. package/dist/commands/compute/app/deploy.js +145 -243
  22. package/dist/commands/compute/app/deploy.js.map +1 -1
  23. package/dist/commands/compute/app/info.js +1 -2
  24. package/dist/commands/compute/app/info.js.map +1 -1
  25. package/dist/commands/compute/app/list.js +111 -194
  26. package/dist/commands/compute/app/list.js.map +1 -1
  27. package/dist/commands/compute/app/logs.js +20 -105
  28. package/dist/commands/compute/app/logs.js.map +1 -1
  29. package/dist/commands/compute/app/profile/set.js +64 -153
  30. package/dist/commands/compute/app/profile/set.js.map +1 -1
  31. package/dist/commands/compute/app/start.js +43 -132
  32. package/dist/commands/compute/app/start.js.map +1 -1
  33. package/dist/commands/compute/app/stop.js +43 -132
  34. package/dist/commands/compute/app/stop.js.map +1 -1
  35. package/dist/commands/compute/app/terminate.js +44 -131
  36. package/dist/commands/compute/app/terminate.js.map +1 -1
  37. package/dist/commands/compute/app/upgrade.js +108 -209
  38. package/dist/commands/compute/app/upgrade.js.map +1 -1
  39. package/dist/commands/compute/environment/list.js +12 -104
  40. package/dist/commands/compute/environment/list.js.map +1 -1
  41. package/dist/commands/compute/environment/set.js +18 -103
  42. package/dist/commands/compute/environment/set.js.map +1 -1
  43. package/dist/commands/compute/environment/show.js +30 -122
  44. package/dist/commands/compute/environment/show.js.map +1 -1
  45. package/dist/commands/compute/undelegate.js +18 -112
  46. package/dist/commands/compute/undelegate.js.map +1 -1
  47. package/dist/commands/upgrade.js +19 -159
  48. package/dist/commands/upgrade.js.map +1 -1
  49. package/dist/commands/version.js +23 -163
  50. package/dist/commands/version.js.map +1 -1
  51. package/package.json +2 -2
  52. package/dist/commands/telemetry.js +0 -213
  53. package/dist/commands/telemetry.js.map +0 -1
@@ -5,7 +5,7 @@ import { Command, Args } from "@oclif/core";
5
5
 
6
6
  // src/client.ts
7
7
  import {
8
- createComputeModule,
8
+ createAppModule,
9
9
  createBillingModule,
10
10
  getEnvironmentConfig as getEnvironmentConfig2,
11
11
  requirePrivateKey,
@@ -52,7 +52,6 @@ import * as path from "path";
52
52
  import * as os from "os";
53
53
  import { load as loadYaml, dump as dumpYaml } from "js-yaml";
54
54
  import { getBuildType } from "@layr-labs/ecloud-sdk";
55
- import * as crypto from "crypto";
56
55
  var GLOBAL_CONFIG_FILE = "config.yaml";
57
56
  var PROFILE_CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
58
57
  function getGlobalConfigDir() {
@@ -99,10 +98,6 @@ function getDefaultEnvironment() {
99
98
  const config = loadGlobalConfig();
100
99
  return config.default_environment;
101
100
  }
102
- function getGlobalTelemetryPreference() {
103
- const config = loadGlobalConfig();
104
- return config.telemetry_enabled;
105
- }
106
101
  function getProfileCache(environment) {
107
102
  const config = loadGlobalConfig();
108
103
  const cacheEntry = config.profile_cache?.[environment];
@@ -126,24 +121,6 @@ function setProfileCache(environment, profiles) {
126
121
  };
127
122
  saveGlobalConfig(config);
128
123
  }
129
- function getOrCreateUserUUID() {
130
- const config = loadGlobalConfig();
131
- if (config.user_uuid) {
132
- return config.user_uuid;
133
- }
134
- const uuid = generateUUID();
135
- config.user_uuid = uuid;
136
- config.first_run = false;
137
- saveGlobalConfig(config);
138
- return uuid;
139
- }
140
- function generateUUID() {
141
- const bytes = crypto.randomBytes(16);
142
- bytes[6] = bytes[6] & 15 | 64;
143
- bytes[8] = bytes[8] & 63 | 128;
144
- const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0"));
145
- return hex.slice(0, 4).join("") + hex.slice(4, 6).join("") + "-" + hex.slice(6, 8).join("") + "-" + hex.slice(8, 10).join("") + "-" + hex.slice(10, 12).join("") + "-" + hex.slice(12, 16).join("");
146
- }
147
124
 
148
125
  // src/utils/appNames.ts
149
126
  import * as fs2 from "fs";
@@ -191,7 +168,7 @@ function listApps(environment) {
191
168
 
192
169
  // src/utils/version.ts
193
170
  function getCliVersion() {
194
- return true ? "0.1.0-dev.3" : "0.0.0";
171
+ return true ? "0.1.0-rc.2" : "0.0.0";
195
172
  }
196
173
  function getClientId() {
197
174
  return `ecloud-cli/v${getCliVersion()}`;
@@ -608,7 +585,7 @@ async function validateCommonFlags(flags) {
608
585
  }
609
586
 
610
587
  // src/client.ts
611
- async function createComputeClient(flags) {
588
+ async function createAppClient(flags) {
612
589
  flags = await validateCommonFlags(flags);
613
590
  const environment = flags.environment;
614
591
  const environmentConfig = getEnvironmentConfig2(environment);
@@ -619,14 +596,12 @@ async function createComputeClient(flags) {
619
596
  if (flags.verbose) {
620
597
  console.log(`Using private key from: ${source}`);
621
598
  }
622
- return createComputeModule({
599
+ return createAppModule({
623
600
  verbose: flags.verbose,
624
601
  privateKey,
625
602
  rpcUrl,
626
603
  environment,
627
- clientId: getClientId(),
628
- skipTelemetry: true
629
- // CLI already has telemetry, skip SDK telemetry
604
+ clientId: getClientId()
630
605
  });
631
606
  }
632
607
 
@@ -638,66 +613,6 @@ import {
638
613
  isMainnet
639
614
  } from "@layr-labs/ecloud-sdk";
640
615
  import chalk from "chalk";
641
-
642
- // src/telemetry.ts
643
- import {
644
- createTelemetryClient,
645
- createAppEnvironment,
646
- createMetricsContext,
647
- addMetric,
648
- addMetricWithDimensions,
649
- emitMetrics,
650
- getBuildType as getBuildType2
651
- } from "@layr-labs/ecloud-sdk";
652
- function createCLITelemetryClient() {
653
- const userUUID = getOrCreateUserUUID();
654
- const environment = createAppEnvironment(userUUID);
655
- const telemetryEnabled = getGlobalTelemetryPreference();
656
- return createTelemetryClient(environment, "ecloud-cli", {
657
- telemetryEnabled: telemetryEnabled === true
658
- // Only enabled if explicitly set to true
659
- });
660
- }
661
- async function withTelemetry(command, action) {
662
- const client = createCLITelemetryClient();
663
- const metrics = createMetricsContext();
664
- metrics.properties["source"] = "ecloud-cli";
665
- metrics.properties["command"] = command.id || command.constructor.name;
666
- const environment = getDefaultEnvironment() || "sepolia";
667
- metrics.properties["environment"] = environment;
668
- const buildType = getBuildType2() || "prod";
669
- metrics.properties["build_type"] = buildType;
670
- const cliVersion = command.config.version;
671
- if (cliVersion) {
672
- metrics.properties["cli_version"] = cliVersion;
673
- }
674
- addMetric(metrics, "Count", 1);
675
- let actionError;
676
- let result;
677
- try {
678
- result = await action();
679
- return result;
680
- } catch (err) {
681
- actionError = err instanceof Error ? err : new Error(String(err));
682
- throw err;
683
- } finally {
684
- const resultValue = actionError ? "Failure" : "Success";
685
- const dimensions = {};
686
- if (actionError) {
687
- dimensions["error"] = actionError.message;
688
- }
689
- addMetricWithDimensions(metrics, resultValue, 1, dimensions);
690
- const duration = Date.now() - metrics.startTime.getTime();
691
- addMetric(metrics, "DurationMilliseconds", duration);
692
- try {
693
- await emitMetrics(client, metrics);
694
- await client.close();
695
- } catch {
696
- }
697
- }
698
- }
699
-
700
- // src/commands/compute/app/stop.ts
701
616
  var AppLifecycleStop = class _AppLifecycleStop extends Command {
702
617
  static description = "Stop running app (stop GCP instance)";
703
618
  static args = {
@@ -710,52 +625,48 @@ var AppLifecycleStop = class _AppLifecycleStop extends Command {
710
625
  ...commonFlags
711
626
  };
712
627
  async run() {
713
- return withTelemetry(this, async () => {
714
- const { args, flags } = await this.parse(_AppLifecycleStop);
715
- const compute = await createComputeClient(flags);
716
- const environment = flags.environment || "sepolia";
717
- const environmentConfig = getEnvironmentConfig3(environment);
718
- const rpcUrl = flags.rpcUrl || environmentConfig.defaultRPCURL;
719
- const privateKey = flags["private-key"] || await getPrivateKeyInteractive(environment);
720
- const appId = await getOrPromptAppID({
721
- appID: args["app-id"],
722
- environment: flags["environment"],
723
- privateKey,
724
- rpcUrl,
725
- action: "stop"
726
- });
727
- const callData = encodeStopAppData(appId);
728
- const estimate = await estimateTransactionGas({
729
- privateKey,
730
- rpcUrl,
731
- environmentConfig,
732
- to: environmentConfig.appControllerAddress,
733
- data: callData
734
- });
735
- if (isMainnet(environmentConfig)) {
736
- const confirmed = await confirm(
737
- `This will cost up to ${estimate.maxCostEth} ETH. Continue?`
738
- );
739
- if (!confirmed) {
740
- this.log(`
628
+ const { args, flags } = await this.parse(_AppLifecycleStop);
629
+ const app = await createAppClient(flags);
630
+ const environment = flags.environment || "sepolia";
631
+ const environmentConfig = getEnvironmentConfig3(environment);
632
+ const rpcUrl = flags.rpcUrl || environmentConfig.defaultRPCURL;
633
+ const privateKey = flags["private-key"] || await getPrivateKeyInteractive(environment);
634
+ const appId = await getOrPromptAppID({
635
+ appID: args["app-id"],
636
+ environment: flags["environment"],
637
+ privateKey,
638
+ rpcUrl,
639
+ action: "stop"
640
+ });
641
+ const callData = encodeStopAppData(appId);
642
+ const estimate = await estimateTransactionGas({
643
+ privateKey,
644
+ rpcUrl,
645
+ environmentConfig,
646
+ to: environmentConfig.appControllerAddress,
647
+ data: callData
648
+ });
649
+ if (isMainnet(environmentConfig)) {
650
+ const confirmed = await confirm(`This will cost up to ${estimate.maxCostEth} ETH. Continue?`);
651
+ if (!confirmed) {
652
+ this.log(`
741
653
  ${chalk.gray(`Stop cancelled`)}`);
742
- return;
743
- }
654
+ return;
744
655
  }
745
- const res = await compute.app.stop(appId, {
746
- gas: {
747
- maxFeePerGas: estimate.maxFeePerGas,
748
- maxPriorityFeePerGas: estimate.maxPriorityFeePerGas
749
- }
750
- });
751
- if (!res.tx) {
752
- this.log(`
753
- ${chalk.gray(`Stop failed`)}`);
754
- } else {
755
- this.log(`
756
- \u2705 ${chalk.green(`App stopped successfully`)}`);
656
+ }
657
+ const res = await app.stop(appId, {
658
+ gas: {
659
+ maxFeePerGas: estimate.maxFeePerGas,
660
+ maxPriorityFeePerGas: estimate.maxPriorityFeePerGas
757
661
  }
758
662
  });
663
+ if (!res.tx) {
664
+ this.log(`
665
+ ${chalk.gray(`Stop failed`)}`);
666
+ } else {
667
+ this.log(`
668
+ \u2705 ${chalk.green(`App stopped successfully`)}`);
669
+ }
759
670
  }
760
671
  };
761
672
  export {