@layr-labs/ecloud-cli 0.2.0-dev → 0.2.0-dev.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.
Files changed (71) hide show
  1. package/VERSION +2 -2
  2. package/dist/commands/auth/generate.js +4 -4
  3. package/dist/commands/auth/generate.js.map +1 -1
  4. package/dist/commands/auth/login.js +2 -2
  5. package/dist/commands/auth/login.js.map +1 -1
  6. package/dist/commands/auth/logout.js +2 -2
  7. package/dist/commands/auth/logout.js.map +1 -1
  8. package/dist/commands/auth/migrate.js +2 -2
  9. package/dist/commands/auth/migrate.js.map +1 -1
  10. package/dist/commands/auth/whoami.js +7 -5
  11. package/dist/commands/auth/whoami.js.map +1 -1
  12. package/dist/commands/billing/cancel.js +9 -7
  13. package/dist/commands/billing/cancel.js.map +1 -1
  14. package/dist/commands/billing/status.js +8 -5
  15. package/dist/commands/billing/status.js.map +1 -1
  16. package/dist/commands/billing/subscribe.js +14 -10
  17. package/dist/commands/billing/subscribe.js.map +1 -1
  18. package/dist/commands/compute/app/create.js +2 -2
  19. package/dist/commands/compute/app/create.js.map +1 -1
  20. package/dist/commands/compute/app/deploy.js +105 -105
  21. package/dist/commands/compute/app/deploy.js.map +1 -1
  22. package/dist/commands/compute/app/info.js +55 -8
  23. package/dist/commands/compute/app/info.js.map +1 -1
  24. package/dist/commands/compute/app/list.js +8 -9
  25. package/dist/commands/compute/app/list.js.map +1 -1
  26. package/dist/commands/compute/app/logs.js +58 -11
  27. package/dist/commands/compute/app/logs.js.map +1 -1
  28. package/dist/commands/compute/app/profile/set.js +147 -22
  29. package/dist/commands/compute/app/profile/set.js.map +1 -1
  30. package/dist/commands/compute/app/releases.js +110 -143
  31. package/dist/commands/compute/app/releases.js.map +1 -1
  32. package/dist/commands/compute/app/start.js +58 -11
  33. package/dist/commands/compute/app/start.js.map +1 -1
  34. package/dist/commands/compute/app/stop.js +58 -11
  35. package/dist/commands/compute/app/stop.js.map +1 -1
  36. package/dist/commands/compute/app/terminate.js +58 -11
  37. package/dist/commands/compute/app/terminate.js.map +1 -1
  38. package/dist/commands/compute/app/upgrade.js +121 -67
  39. package/dist/commands/compute/app/upgrade.js.map +1 -1
  40. package/dist/commands/compute/build/info.js +8 -9
  41. package/dist/commands/compute/build/info.js.map +1 -1
  42. package/dist/commands/compute/build/list.js +50 -131
  43. package/dist/commands/compute/build/list.js.map +1 -1
  44. package/dist/commands/compute/build/logs.js +9 -10
  45. package/dist/commands/compute/build/logs.js.map +1 -1
  46. package/dist/commands/compute/build/status.js +9 -10
  47. package/dist/commands/compute/build/status.js.map +1 -1
  48. package/dist/commands/compute/build/submit.js +8 -9
  49. package/dist/commands/compute/build/submit.js.map +1 -1
  50. package/dist/commands/compute/build/verify.js +59 -12
  51. package/dist/commands/compute/build/verify.js.map +1 -1
  52. package/dist/commands/compute/environment/list.js +2 -2
  53. package/dist/commands/compute/environment/list.js.map +1 -1
  54. package/dist/commands/compute/environment/set.js +2 -2
  55. package/dist/commands/compute/environment/set.js.map +1 -1
  56. package/dist/commands/compute/environment/show.js +2 -2
  57. package/dist/commands/compute/environment/show.js.map +1 -1
  58. package/dist/commands/compute/undelegate.js +8 -9
  59. package/dist/commands/compute/undelegate.js.map +1 -1
  60. package/dist/commands/{telemetry.js → telemetry/disable.js} +15 -64
  61. package/dist/commands/telemetry/disable.js.map +1 -0
  62. package/dist/commands/telemetry/enable.js +164 -0
  63. package/dist/commands/telemetry/enable.js.map +1 -0
  64. package/dist/commands/telemetry/status.js +159 -0
  65. package/dist/commands/telemetry/status.js.map +1 -0
  66. package/dist/commands/upgrade.js +2 -2
  67. package/dist/commands/upgrade.js.map +1 -1
  68. package/dist/commands/version.js +2 -2
  69. package/dist/commands/version.js.map +1 -1
  70. package/package.json +4 -2
  71. package/dist/commands/telemetry.js.map +0 -1
@@ -2,10 +2,11 @@
2
2
 
3
3
  // src/commands/compute/app/profile/set.ts
4
4
  import { Command, Args, Flags as Flags2 } from "@oclif/core";
5
- import { getEnvironmentConfig as getEnvironmentConfig2, UserApiClient as UserApiClient3 } from "@layr-labs/ecloud-sdk";
5
+ import { getEnvironmentConfig as getEnvironmentConfig3 } from "@layr-labs/ecloud-sdk";
6
6
 
7
7
  // src/flags.ts
8
8
  import { Flags } from "@oclif/core";
9
+ import { getBuildType as getBuildType2 } from "@layr-labs/ecloud-sdk";
9
10
 
10
11
  // src/utils/prompts.ts
11
12
  import { input, select, password, confirm as inquirerConfirm } from "@inquirer/prompts";
@@ -87,6 +88,27 @@ function saveGlobalConfig(config) {
87
88
  const content = dumpYaml(config, { lineWidth: -1 });
88
89
  fs.writeFileSync(configPath, content, { mode: 420 });
89
90
  }
91
+ function normalizeDirectoryPath(directoryPath) {
92
+ const resolved = path.resolve(directoryPath);
93
+ try {
94
+ return fs.realpathSync(resolved);
95
+ } catch {
96
+ return resolved;
97
+ }
98
+ }
99
+ function getLinkedAppForDirectory(environment, directoryPath) {
100
+ if (!directoryPath) {
101
+ return null;
102
+ }
103
+ const config = loadGlobalConfig();
104
+ const links = config.directory_links?.[environment];
105
+ if (!links) {
106
+ return null;
107
+ }
108
+ const normalizedPath = normalizeDirectoryPath(directoryPath);
109
+ const appId = links[normalizedPath];
110
+ return appId || null;
111
+ }
90
112
  function getDefaultEnvironment() {
91
113
  const config = loadGlobalConfig();
92
114
  return config.default_environment;
@@ -232,7 +254,7 @@ function listApps(environment) {
232
254
 
233
255
  // src/utils/version.ts
234
256
  function getCliVersion() {
235
- return true ? "0.2.0-dev" : "0.0.0";
257
+ return true ? "0.2.0-dev.1" : "0.0.0";
236
258
  }
237
259
  function getClientId() {
238
260
  return `ecloud-cli/v${getCliVersion()}`;
@@ -423,6 +445,9 @@ function addHexPrefix(value) {
423
445
  }
424
446
  return `0x${value}`;
425
447
  }
448
+ function getCurrentProjectPath() {
449
+ return process.env.INIT_CWD || process.cwd();
450
+ }
426
451
  var ContractAppStatusStarted = 1;
427
452
  var ContractAppStatusStopped = 2;
428
453
  var ContractAppStatusTerminated = 3;
@@ -561,6 +586,7 @@ Select an app to ${action}:
561
586
  switch (action) {
562
587
  case "view":
563
588
  case "view info for":
589
+ case "view releases for":
564
590
  case "set profile for":
565
591
  return true;
566
592
  case "start":
@@ -589,7 +615,19 @@ Select an app to ${action}:
589
615
  index: i
590
616
  });
591
617
  }
618
+ const linkedAppId = getLinkedAppForDirectory(environment, getCurrentProjectPath());
619
+ const normalizedLinkedAppId = linkedAppId ? linkedAppId.toLowerCase() : "";
592
620
  appItems.sort((a, b) => {
621
+ if (normalizedLinkedAppId) {
622
+ const aLinked = String(a.addr).toLowerCase() === normalizedLinkedAppId;
623
+ const bLinked = String(b.addr).toLowerCase() === normalizedLinkedAppId;
624
+ if (aLinked && !bLinked) {
625
+ return -1;
626
+ }
627
+ if (bLinked && !aLinked) {
628
+ return 1;
629
+ }
630
+ }
593
631
  const aPriority = getStatusPriority(a.status, false);
594
632
  const bPriority = getStatusPriority(b.status, false);
595
633
  if (aPriority !== bPriority) {
@@ -655,7 +693,18 @@ async function getAppIDInteractiveFromRegistry(environment, action) {
655
693
  }
656
694
  throw new Error(`Invalid app ID address: ${appIDInput}`);
657
695
  }
658
- const choices = Object.entries(allApps).map(([name, appID]) => {
696
+ const entries = Object.entries(allApps);
697
+ const linkedAppId = getLinkedAppForDirectory(environment, getCurrentProjectPath());
698
+ if (linkedAppId) {
699
+ const linkedIndex = entries.findIndex(
700
+ ([, appId]) => String(appId).toLowerCase() === linkedAppId.toLowerCase()
701
+ );
702
+ if (linkedIndex > 0) {
703
+ const [linkedEntry] = entries.splice(linkedIndex, 1);
704
+ entries.unshift(linkedEntry);
705
+ }
706
+ }
707
+ const choices = entries.map(([name, appID]) => {
659
708
  const displayName = `${name} (${appID})`;
660
709
  return { name: displayName, value: appID };
661
710
  });
@@ -703,8 +752,8 @@ async function getPrivateKeyInteractive(privateKey) {
703
752
  }
704
753
  return privateKey;
705
754
  }
706
- const { getPrivateKeyWithSource } = await import("@layr-labs/ecloud-sdk");
707
- const result = await getPrivateKeyWithSource({ privateKey: void 0 });
755
+ const { getPrivateKeyWithSource: getPrivateKeyWithSource2 } = await import("@layr-labs/ecloud-sdk");
756
+ const result = await getPrivateKeyWithSource2({ privateKey: void 0 });
708
757
  if (result) {
709
758
  return result.key;
710
759
  }
@@ -723,6 +772,50 @@ async function getPrivateKeyInteractive(privateKey) {
723
772
  });
724
773
  return key.trim();
725
774
  }
775
+ async function getEnvironmentInteractive(environment) {
776
+ if (environment) {
777
+ try {
778
+ getEnvironmentConfig(environment);
779
+ if (!isEnvironmentAvailable(environment)) {
780
+ throw new Error(`Environment ${environment} is not available in this build`);
781
+ }
782
+ return environment;
783
+ } catch {
784
+ }
785
+ }
786
+ const availableEnvs = getAvailableEnvironments();
787
+ let defaultEnv;
788
+ const configDefaultEnv = getDefaultEnvironment();
789
+ if (configDefaultEnv && availableEnvs.includes(configDefaultEnv)) {
790
+ try {
791
+ getEnvironmentConfig(configDefaultEnv);
792
+ defaultEnv = configDefaultEnv;
793
+ } catch {
794
+ }
795
+ }
796
+ const choices = [];
797
+ if (availableEnvs.includes("sepolia")) {
798
+ choices.push({ name: "sepolia - Ethereum Sepolia testnet", value: "sepolia" });
799
+ }
800
+ if (availableEnvs.includes("sepolia-dev")) {
801
+ choices.push({ name: "sepolia-dev - Ethereum Sepolia testnet (dev)", value: "sepolia-dev" });
802
+ }
803
+ if (availableEnvs.includes("mainnet-alpha")) {
804
+ choices.push({
805
+ name: "mainnet-alpha - Ethereum mainnet (\u26A0\uFE0F uses real funds)",
806
+ value: "mainnet-alpha"
807
+ });
808
+ }
809
+ if (choices.length === 0) {
810
+ throw new Error("No environments available in this build");
811
+ }
812
+ const env = await select({
813
+ message: "Select environment:",
814
+ choices,
815
+ default: defaultEnv
816
+ });
817
+ return env;
818
+ }
726
819
  var MAX_DESCRIPTION_LENGTH = 1e3;
727
820
  var MAX_IMAGE_SIZE = 4 * 1024 * 1024;
728
821
  var VALID_IMAGE_EXTENSIONS = [".jpg", ".jpeg", ".png"];
@@ -985,7 +1078,8 @@ var commonFlags = {
985
1078
  environment: Flags.string({
986
1079
  required: false,
987
1080
  description: "Deployment environment to use",
988
- env: "ECLOUD_ENV"
1081
+ env: "ECLOUD_ENV",
1082
+ default: async () => getDefaultEnvironment() || (getBuildType2() === "dev" ? "sepolia-dev" : "sepolia")
989
1083
  }),
990
1084
  "private-key": Flags.string({
991
1085
  required: false,
@@ -1003,6 +1097,44 @@ var commonFlags = {
1003
1097
  default: false
1004
1098
  })
1005
1099
  };
1100
+ async function validateCommonFlags(flags, options) {
1101
+ flags["environment"] = await getEnvironmentInteractive(flags["environment"]);
1102
+ if (options?.requirePrivateKey !== false) {
1103
+ flags["private-key"] = await getPrivateKeyInteractive(flags["private-key"]);
1104
+ }
1105
+ return flags;
1106
+ }
1107
+
1108
+ // src/client.ts
1109
+ import {
1110
+ createComputeModule,
1111
+ createBillingModule,
1112
+ createBuildModule,
1113
+ getEnvironmentConfig as getEnvironmentConfig2,
1114
+ requirePrivateKey,
1115
+ getPrivateKeyWithSource
1116
+ } from "@layr-labs/ecloud-sdk";
1117
+ async function createComputeClient(flags) {
1118
+ flags = await validateCommonFlags(flags);
1119
+ const environment = flags.environment;
1120
+ const environmentConfig = getEnvironmentConfig2(environment);
1121
+ const rpcUrl = flags["rpc-url"] || environmentConfig.defaultRPCURL;
1122
+ const { key: privateKey, source } = await requirePrivateKey({
1123
+ privateKey: flags["private-key"]
1124
+ });
1125
+ if (flags.verbose) {
1126
+ console.log(`Using private key from: ${source}`);
1127
+ }
1128
+ return createComputeModule({
1129
+ verbose: flags.verbose,
1130
+ privateKey,
1131
+ rpcUrl,
1132
+ environment,
1133
+ clientId: getClientId(),
1134
+ skipTelemetry: true
1135
+ // CLI already has telemetry, skip SDK telemetry
1136
+ });
1137
+ }
1006
1138
 
1007
1139
  // src/commands/compute/app/profile/set.ts
1008
1140
  import chalk from "chalk";
@@ -1015,15 +1147,15 @@ import {
1015
1147
  addMetric,
1016
1148
  addMetricWithDimensions,
1017
1149
  emitMetrics,
1018
- getBuildType as getBuildType2
1150
+ getBuildType as getBuildType3
1019
1151
  } from "@layr-labs/ecloud-sdk";
1020
1152
  function createCLITelemetryClient() {
1021
1153
  const userUUID = getOrCreateUserUUID();
1022
1154
  const environment = createAppEnvironment(userUUID);
1023
1155
  const telemetryEnabled = getGlobalTelemetryPreference();
1024
1156
  return createTelemetryClient(environment, "ecloud-cli", {
1025
- telemetryEnabled: telemetryEnabled === true
1026
- // Only enabled if explicitly set to true
1157
+ telemetryEnabled: telemetryEnabled !== false
1158
+ // Enabled by default, disabled only if explicitly set to false
1027
1159
  });
1028
1160
  }
1029
1161
  async function withTelemetry(command, action) {
@@ -1033,7 +1165,7 @@ async function withTelemetry(command, action) {
1033
1165
  metrics.properties["command"] = command.id || command.constructor.name;
1034
1166
  const environment = getDefaultEnvironment() || "sepolia";
1035
1167
  metrics.properties["environment"] = environment;
1036
- const buildType = getBuildType2() || "prod";
1168
+ const buildType = getBuildType3() || "prod";
1037
1169
  metrics.properties["build_type"] = buildType;
1038
1170
  const cliVersion = command.config.version;
1039
1171
  if (cliVersion) {
@@ -1100,10 +1232,11 @@ var ProfileSet = class _ProfileSet extends Command {
1100
1232
  async run() {
1101
1233
  return withTelemetry(this, async () => {
1102
1234
  const { args, flags } = await this.parse(_ProfileSet);
1103
- const environment = flags.environment || "sepolia";
1104
- const environmentConfig = getEnvironmentConfig2(environment);
1235
+ const compute = await createComputeClient(flags);
1236
+ const environment = flags.environment;
1237
+ const environmentConfig = getEnvironmentConfig3(environment);
1105
1238
  const rpcUrl = flags["rpc-url"] || environmentConfig.defaultRPCURL;
1106
- const privateKey = await getPrivateKeyInteractive(flags["private-key"]);
1239
+ const privateKey = flags["private-key"];
1107
1240
  const resolver = createAppResolver(environment, environmentConfig, privateKey, rpcUrl);
1108
1241
  const appId = await getOrPromptAppID({
1109
1242
  appID: args["app-id"],
@@ -1143,16 +1276,8 @@ ${chalk.gray("Profile setup cancelled")}`);
1143
1276
  }
1144
1277
  }
1145
1278
  this.log("\nUploading app profile...");
1146
- const userApiClient = new UserApiClient3(environmentConfig, privateKey, rpcUrl);
1147
1279
  try {
1148
- const response = await userApiClient.uploadAppProfile(
1149
- appId,
1150
- profile.name,
1151
- profile.website,
1152
- profile.description,
1153
- profile.xURL,
1154
- profile.imagePath
1155
- );
1280
+ const response = await compute.app.setProfile(appId, profile);
1156
1281
  resolver.updateCacheEntry(appId, response.name);
1157
1282
  invalidateProfileCache(environment);
1158
1283
  this.log(`