@layr-labs/ecloud-cli 0.1.1-dev → 0.1.2-dev

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/VERSION +2 -2
  2. package/dist/commands/auth/generate.js +2 -2
  3. package/dist/commands/auth/generate.js.map +1 -1
  4. package/dist/commands/auth/login.js.map +1 -1
  5. package/dist/commands/auth/logout.js.map +1 -1
  6. package/dist/commands/auth/migrate.js.map +1 -1
  7. package/dist/commands/auth/whoami.js +5 -3
  8. package/dist/commands/auth/whoami.js.map +1 -1
  9. package/dist/commands/billing/cancel.js +5 -3
  10. package/dist/commands/billing/cancel.js.map +1 -1
  11. package/dist/commands/billing/status.js +5 -3
  12. package/dist/commands/billing/status.js.map +1 -1
  13. package/dist/commands/billing/subscribe.js +10 -6
  14. package/dist/commands/billing/subscribe.js.map +1 -1
  15. package/dist/commands/compute/app/create.js.map +1 -1
  16. package/dist/commands/compute/app/deploy.js +143 -76
  17. package/dist/commands/compute/app/deploy.js.map +1 -1
  18. package/dist/commands/compute/app/info.js +54 -8
  19. package/dist/commands/compute/app/info.js.map +1 -1
  20. package/dist/commands/compute/app/list.js +6 -7
  21. package/dist/commands/compute/app/list.js.map +1 -1
  22. package/dist/commands/compute/app/logs.js +55 -9
  23. package/dist/commands/compute/app/logs.js.map +1 -1
  24. package/dist/commands/compute/app/profile/set.js +141 -20
  25. package/dist/commands/compute/app/profile/set.js.map +1 -1
  26. package/dist/commands/compute/app/start.js +55 -9
  27. package/dist/commands/compute/app/start.js.map +1 -1
  28. package/dist/commands/compute/app/stop.js +55 -9
  29. package/dist/commands/compute/app/stop.js.map +1 -1
  30. package/dist/commands/compute/app/terminate.js +55 -9
  31. package/dist/commands/compute/app/terminate.js.map +1 -1
  32. package/dist/commands/compute/app/upgrade.js +172 -49
  33. package/dist/commands/compute/app/upgrade.js.map +1 -1
  34. package/dist/commands/compute/environment/list.js.map +1 -1
  35. package/dist/commands/compute/environment/set.js.map +1 -1
  36. package/dist/commands/compute/environment/show.js.map +1 -1
  37. package/dist/commands/compute/undelegate.js +6 -7
  38. package/dist/commands/compute/undelegate.js.map +1 -1
  39. package/dist/commands/telemetry/disable.js.map +1 -1
  40. package/dist/commands/telemetry/enable.js.map +1 -1
  41. package/dist/commands/telemetry/status.js.map +1 -1
  42. package/dist/commands/upgrade.js.map +1 -1
  43. package/dist/commands/version.js.map +1 -1
  44. package/package.json +3 -2
@@ -11,6 +11,7 @@ import {
11
11
 
12
12
  // src/flags.ts
13
13
  import { Flags } from "@oclif/core";
14
+ import { getBuildType as getBuildType2 } from "@layr-labs/ecloud-sdk";
14
15
 
15
16
  // src/utils/prompts.ts
16
17
  import { input, select, password, confirm as inquirerConfirm } from "@inquirer/prompts";
@@ -92,6 +93,27 @@ function saveGlobalConfig(config) {
92
93
  const content = dumpYaml(config, { lineWidth: -1 });
93
94
  fs.writeFileSync(configPath, content, { mode: 420 });
94
95
  }
96
+ function normalizeDirectoryPath(directoryPath) {
97
+ const resolved = path.resolve(directoryPath);
98
+ try {
99
+ return fs.realpathSync(resolved);
100
+ } catch {
101
+ return resolved;
102
+ }
103
+ }
104
+ function getLinkedAppForDirectory(environment, directoryPath) {
105
+ if (!directoryPath) {
106
+ return null;
107
+ }
108
+ const config = loadGlobalConfig();
109
+ const links = config.directory_links?.[environment];
110
+ if (!links) {
111
+ return null;
112
+ }
113
+ const normalizedPath = normalizeDirectoryPath(directoryPath);
114
+ const appId = links[normalizedPath];
115
+ return appId || null;
116
+ }
95
117
  function getDefaultEnvironment() {
96
118
  const config = loadGlobalConfig();
97
119
  return config.default_environment;
@@ -166,7 +188,7 @@ function listApps(environment) {
166
188
 
167
189
  // src/utils/version.ts
168
190
  function getCliVersion() {
169
- return true ? "0.1.1-dev" : "0.0.0";
191
+ return true ? "0.1.2-dev" : "0.0.0";
170
192
  }
171
193
  function getClientId() {
172
194
  return `ecloud-cli/v${getCliVersion()}`;
@@ -195,6 +217,9 @@ function addHexPrefix(value) {
195
217
  }
196
218
  return `0x${value}`;
197
219
  }
220
+ function getCurrentProjectPath() {
221
+ return process.env.INIT_CWD || process.cwd();
222
+ }
198
223
  var ContractAppStatusStarted = 1;
199
224
  var ContractAppStatusStopped = 2;
200
225
  var ContractAppStatusTerminated = 3;
@@ -361,7 +386,19 @@ Select an app to ${action}:
361
386
  index: i
362
387
  });
363
388
  }
389
+ const linkedAppId = getLinkedAppForDirectory(environment, getCurrentProjectPath());
390
+ const normalizedLinkedAppId = linkedAppId ? linkedAppId.toLowerCase() : "";
364
391
  appItems.sort((a, b) => {
392
+ if (normalizedLinkedAppId) {
393
+ const aLinked = String(a.addr).toLowerCase() === normalizedLinkedAppId;
394
+ const bLinked = String(b.addr).toLowerCase() === normalizedLinkedAppId;
395
+ if (aLinked && !bLinked) {
396
+ return -1;
397
+ }
398
+ if (bLinked && !aLinked) {
399
+ return 1;
400
+ }
401
+ }
365
402
  const aPriority = getStatusPriority(a.status, false);
366
403
  const bPriority = getStatusPriority(b.status, false);
367
404
  if (aPriority !== bPriority) {
@@ -427,7 +464,18 @@ async function getAppIDInteractiveFromRegistry(environment, action) {
427
464
  }
428
465
  throw new Error(`Invalid app ID address: ${appIDInput}`);
429
466
  }
430
- const choices = Object.entries(allApps).map(([name, appID]) => {
467
+ const entries = Object.entries(allApps);
468
+ const linkedAppId = getLinkedAppForDirectory(environment, getCurrentProjectPath());
469
+ if (linkedAppId) {
470
+ const linkedIndex = entries.findIndex(
471
+ ([, appId]) => String(appId).toLowerCase() === linkedAppId.toLowerCase()
472
+ );
473
+ if (linkedIndex > 0) {
474
+ const [linkedEntry] = entries.splice(linkedIndex, 1);
475
+ entries.unshift(linkedEntry);
476
+ }
477
+ }
478
+ const choices = entries.map(([name, appID]) => {
431
479
  const displayName = `${name} (${appID})`;
432
480
  return { name: displayName, value: appID };
433
481
  });
@@ -546,7 +594,8 @@ var commonFlags = {
546
594
  environment: Flags.string({
547
595
  required: false,
548
596
  description: "Deployment environment to use",
549
- env: "ECLOUD_ENV"
597
+ env: "ECLOUD_ENV",
598
+ default: async () => getDefaultEnvironment() || (getBuildType2() === "dev" ? "sepolia-dev" : "sepolia")
550
599
  }),
551
600
  "private-key": Flags.string({
552
601
  required: false,
@@ -565,9 +614,6 @@ var commonFlags = {
565
614
  })
566
615
  };
567
616
  async function validateCommonFlags(flags) {
568
- if (!flags["environment"]) {
569
- flags["environment"] = getDefaultEnvironment();
570
- }
571
617
  flags["environment"] = await getEnvironmentInteractive(flags["environment"]);
572
618
  flags["private-key"] = await getPrivateKeyInteractive(flags["private-key"]);
573
619
  return flags;
@@ -724,7 +770,7 @@ var AppInfo2 = class _AppInfo extends Command {
724
770
  async run() {
725
771
  const { args, flags } = await this.parse(_AppInfo);
726
772
  const validatedFlags = await validateCommonFlags(flags);
727
- const environment = validatedFlags.environment || "sepolia";
773
+ const environment = validatedFlags.environment;
728
774
  const environmentConfig = getEnvironmentConfig2(environment);
729
775
  const rpcUrl = validatedFlags["rpc-url"] || environmentConfig.defaultRPCURL;
730
776
  const privateKey = validatedFlags["private-key"];
@@ -809,7 +855,7 @@ async function showCountdown(seconds) {
809
855
  for (let i = seconds; i >= 0; i--) {
810
856
  process.stdout.write(chalk2.gray(`\rRefreshing in ${i}...`));
811
857
  if (i > 0) {
812
- await new Promise((resolve) => setTimeout(resolve, 1e3));
858
+ await new Promise((resolve2) => setTimeout(resolve2, 1e3));
813
859
  }
814
860
  }
815
861
  }