@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
@@ -6,6 +6,7 @@ import { getEnvironmentConfig as getEnvironmentConfig2, UserApiClient as UserApi
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;
@@ -183,7 +205,7 @@ function listApps(environment) {
183
205
 
184
206
  // src/utils/version.ts
185
207
  function getCliVersion() {
186
- return true ? "0.2.0-dev" : "0.0.0";
208
+ return true ? "0.2.0-dev.1" : "0.0.0";
187
209
  }
188
210
  function getClientId() {
189
211
  return `ecloud-cli/v${getCliVersion()}`;
@@ -212,6 +234,9 @@ function addHexPrefix(value) {
212
234
  }
213
235
  return `0x${value}`;
214
236
  }
237
+ function getCurrentProjectPath() {
238
+ return process.env.INIT_CWD || process.cwd();
239
+ }
215
240
  var ContractAppStatusStarted = 1;
216
241
  var ContractAppStatusStopped = 2;
217
242
  var ContractAppStatusTerminated = 3;
@@ -350,6 +375,7 @@ Select an app to ${action}:
350
375
  switch (action) {
351
376
  case "view":
352
377
  case "view info for":
378
+ case "view releases for":
353
379
  case "set profile for":
354
380
  return true;
355
381
  case "start":
@@ -378,7 +404,19 @@ Select an app to ${action}:
378
404
  index: i
379
405
  });
380
406
  }
407
+ const linkedAppId = getLinkedAppForDirectory(environment, getCurrentProjectPath());
408
+ const normalizedLinkedAppId = linkedAppId ? linkedAppId.toLowerCase() : "";
381
409
  appItems.sort((a, b) => {
410
+ if (normalizedLinkedAppId) {
411
+ const aLinked = String(a.addr).toLowerCase() === normalizedLinkedAppId;
412
+ const bLinked = String(b.addr).toLowerCase() === normalizedLinkedAppId;
413
+ if (aLinked && !bLinked) {
414
+ return -1;
415
+ }
416
+ if (bLinked && !aLinked) {
417
+ return 1;
418
+ }
419
+ }
382
420
  const aPriority = getStatusPriority(a.status, false);
383
421
  const bPriority = getStatusPriority(b.status, false);
384
422
  if (aPriority !== bPriority) {
@@ -444,7 +482,18 @@ async function getAppIDInteractiveFromRegistry(environment, action) {
444
482
  }
445
483
  throw new Error(`Invalid app ID address: ${appIDInput}`);
446
484
  }
447
- const choices = Object.entries(allApps).map(([name, appID]) => {
485
+ const entries = Object.entries(allApps);
486
+ const linkedAppId = getLinkedAppForDirectory(environment, getCurrentProjectPath());
487
+ if (linkedAppId) {
488
+ const linkedIndex = entries.findIndex(
489
+ ([, appId]) => String(appId).toLowerCase() === linkedAppId.toLowerCase()
490
+ );
491
+ if (linkedIndex > 0) {
492
+ const [linkedEntry] = entries.splice(linkedIndex, 1);
493
+ entries.unshift(linkedEntry);
494
+ }
495
+ }
496
+ const choices = entries.map(([name, appID]) => {
448
497
  const displayName = `${name} (${appID})`;
449
498
  return { name: displayName, value: appID };
450
499
  });
@@ -563,7 +612,8 @@ var commonFlags = {
563
612
  environment: Flags.string({
564
613
  required: false,
565
614
  description: "Deployment environment to use",
566
- env: "ECLOUD_ENV"
615
+ env: "ECLOUD_ENV",
616
+ default: async () => getDefaultEnvironment() || (getBuildType2() === "dev" ? "sepolia-dev" : "sepolia")
567
617
  }),
568
618
  "private-key": Flags.string({
569
619
  required: false,
@@ -582,9 +632,6 @@ var commonFlags = {
582
632
  })
583
633
  };
584
634
  async function validateCommonFlags(flags, options) {
585
- if (!flags["environment"]) {
586
- flags["environment"] = getDefaultEnvironment();
587
- }
588
635
  flags["environment"] = await getEnvironmentInteractive(flags["environment"]);
589
636
  if (options?.requirePrivateKey !== false) {
590
637
  flags["private-key"] = await getPrivateKeyInteractive(flags["private-key"]);
@@ -600,15 +647,15 @@ import {
600
647
  addMetric,
601
648
  addMetricWithDimensions,
602
649
  emitMetrics,
603
- getBuildType as getBuildType2
650
+ getBuildType as getBuildType3
604
651
  } from "@layr-labs/ecloud-sdk";
605
652
  function createCLITelemetryClient() {
606
653
  const userUUID = getOrCreateUserUUID();
607
654
  const environment = createAppEnvironment(userUUID);
608
655
  const telemetryEnabled = getGlobalTelemetryPreference();
609
656
  return createTelemetryClient(environment, "ecloud-cli", {
610
- telemetryEnabled: telemetryEnabled === true
611
- // Only enabled if explicitly set to true
657
+ telemetryEnabled: telemetryEnabled !== false
658
+ // Enabled by default, disabled only if explicitly set to false
612
659
  });
613
660
  }
614
661
  async function withTelemetry(command, action) {
@@ -618,7 +665,7 @@ async function withTelemetry(command, action) {
618
665
  metrics.properties["command"] = command.id || command.constructor.name;
619
666
  const environment = getDefaultEnvironment() || "sepolia";
620
667
  metrics.properties["environment"] = environment;
621
- const buildType = getBuildType2() || "prod";
668
+ const buildType = getBuildType3() || "prod";
622
669
  metrics.properties["build_type"] = buildType;
623
670
  const cliVersion = command.config.version;
624
671
  if (cliVersion) {
@@ -790,32 +837,28 @@ function formatAppRelease(release, index) {
790
837
 
791
838
  // src/commands/compute/app/releases.ts
792
839
  import { isAddress as isAddress3 } from "viem";
840
+ import Table from "cli-table3";
793
841
 
794
- // src/utils/cliTable.ts
842
+ // src/utils/cliFormat.ts
795
843
  function terminalWidth(fallback = 120) {
796
844
  const cols = typeof process.stdout.columns === "number" ? process.stdout.columns : void 0;
797
845
  return cols && cols > 0 ? cols : fallback;
798
846
  }
799
- function stripAnsi(s) {
800
- return s.replace(/\u001b\[[0-9;]*m/g, "");
801
- }
802
- function padRight(s, width) {
803
- const plain = stripAnsi(s);
804
- const delta = width - plain.length;
805
- return delta > 0 ? s + " ".repeat(delta) : s;
806
- }
807
- function shortenMiddle(value, max) {
808
- if (value.length <= max) return value;
809
- if (max <= 3) return value.slice(0, max);
810
- const keep = max - 1;
811
- const head = Math.ceil(keep * 0.6);
812
- const tail = keep - head;
813
- return `${value.slice(0, head)}\u2026${value.slice(value.length - tail)}`;
814
- }
815
- function truncateCell(s, width) {
816
- const plain = stripAnsi(s);
817
- if (plain.length <= width) return s;
818
- return shortenMiddle(plain, width);
847
+ function formatHumanTime(value) {
848
+ const raw = String(value ?? "").trim();
849
+ if (!raw) return "-";
850
+ if (/^\d+$/.test(raw)) {
851
+ const n = Number(raw);
852
+ if (Number.isFinite(n) && n > 0) {
853
+ const ms = raw.length <= 10 ? n * 1e3 : n;
854
+ const d2 = new Date(ms);
855
+ if (!Number.isNaN(d2.getTime())) return d2.toLocaleString();
856
+ }
857
+ return raw;
858
+ }
859
+ const d = new Date(raw);
860
+ if (Number.isNaN(d.getTime())) return raw;
861
+ return d.toLocaleString();
819
862
  }
820
863
  function formatRepoDisplay(repoUrl) {
821
864
  const normalized = String(repoUrl || "").replace(/\.git$/i, "").replace(/\/+$/, "");
@@ -846,22 +889,6 @@ function formatImageDisplay(imageUrl) {
846
889
  const s = String(imageUrl || "");
847
890
  return s.replace(/^docker\.io\//i, "");
848
891
  }
849
- function formatHumanTime(value) {
850
- const raw = String(value ?? "").trim();
851
- if (!raw) return "-";
852
- if (/^\d+$/.test(raw)) {
853
- const n = Number(raw);
854
- if (Number.isFinite(n) && n > 0) {
855
- const ms = raw.length <= 10 ? n * 1e3 : n;
856
- const d2 = new Date(ms);
857
- if (!Number.isNaN(d2.getTime())) return d2.toLocaleString();
858
- }
859
- return raw;
860
- }
861
- const d = new Date(raw);
862
- if (Number.isNaN(d.getTime())) return raw;
863
- return d.toLocaleString();
864
- }
865
892
  function provenanceSummary(options) {
866
893
  const parts = [];
867
894
  if (options.provenanceJson) parts.push("prov\u2713");
@@ -998,57 +1025,8 @@ ${separator()}
998
1025
  prov: chalk2.bold("Prov"),
999
1026
  deps: chalk2.bold("Deps")
1000
1027
  };
1001
- const sep = " ";
1002
1028
  const tw = terminalWidth();
1003
- const maxContentLen = (key) => Math.max(headers[key].length, ...rows.map((r) => stripAnsi(String(r[key])).length));
1004
- const min = {
1005
- rel: 4,
1006
- block: 8,
1007
- created: 18,
1008
- repo: 18,
1009
- commit: 40,
1010
- digest: 18,
1011
- image: 18,
1012
- build: 36,
1013
- prov: 12,
1014
- deps: 8
1015
- };
1016
- const max = {
1017
- rel: 10,
1018
- block: 12,
1019
- created: 24,
1020
- repo: 48,
1021
- commit: 40,
1022
- digest: 64,
1023
- image: 48,
1024
- build: 36,
1025
- prov: 18,
1026
- deps: 10
1027
- };
1028
- let widths = {
1029
- rel: Math.min(max.rel, Math.max(min.rel, maxContentLen("rel"))),
1030
- block: Math.min(max.block, Math.max(min.block, maxContentLen("block"))),
1031
- created: Math.min(max.created, Math.max(min.created, maxContentLen("created"))),
1032
- repo: Math.min(max.repo, Math.max(min.repo, maxContentLen("repo"))),
1033
- commit: Math.min(max.commit, Math.max(min.commit, maxContentLen("commit"))),
1034
- digest: Math.min(max.digest, Math.max(min.digest, maxContentLen("digest"))),
1035
- image: Math.min(max.image, Math.max(min.image, maxContentLen("image"))),
1036
- build: Math.min(max.build, Math.max(min.build, maxContentLen("build"))),
1037
- prov: Math.min(max.prov, Math.max(min.prov, maxContentLen("prov"))),
1038
- deps: Math.min(max.deps, Math.max(min.deps, maxContentLen("deps")))
1039
- };
1040
- const totalWidth = () => widths.rel + widths.block + widths.created + widths.repo + widths.commit + widths.digest + widths.image + widths.build + widths.prov + widths.deps + sep.length * 9;
1041
- const shrink = (key, amount) => {
1042
- widths[key] = Math.max(min[key], widths[key] - amount);
1043
- };
1044
- while (totalWidth() > tw && (widths.repo > min.repo || widths.image > min.image || widths.digest > min.digest)) {
1045
- if (widths.repo > min.repo) shrink("repo", 1);
1046
- if (totalWidth() <= tw) break;
1047
- if (widths.image > min.image) shrink("image", 1);
1048
- if (totalWidth() <= tw) break;
1049
- if (widths.digest > min.digest) shrink("digest", 1);
1050
- }
1051
- const shouldStack = totalWidth() > tw;
1029
+ const shouldStack = tw < 140;
1052
1030
  if (shouldStack) {
1053
1031
  for (const r of rows) {
1054
1032
  this.log(`${chalk2.cyan(r.rel)} ${r.created} (block ${r.block})`);
@@ -1077,54 +1055,43 @@ ${separator()}
1077
1055
  );
1078
1056
  return;
1079
1057
  }
1080
- const headerLine = [
1081
- padRight(headers.rel, widths.rel),
1082
- padRight(headers.block, widths.block),
1083
- padRight(headers.created, widths.created),
1084
- padRight(headers.repo, widths.repo),
1085
- padRight(headers.commit, widths.commit),
1086
- padRight(headers.digest, widths.digest),
1087
- padRight(headers.image, widths.image),
1088
- padRight(headers.build, widths.build),
1089
- padRight(headers.prov, widths.prov),
1090
- padRight(headers.deps, widths.deps)
1091
- ].join(sep);
1092
- const ruleLine = [
1093
- "-".repeat(widths.rel),
1094
- "-".repeat(widths.block),
1095
- "-".repeat(widths.created),
1096
- "-".repeat(widths.repo),
1097
- "-".repeat(widths.commit),
1098
- "-".repeat(widths.digest),
1099
- "-".repeat(widths.image),
1100
- "-".repeat(widths.build),
1101
- "-".repeat(widths.prov),
1102
- "-".repeat(widths.deps)
1103
- ].join(sep);
1104
- this.log(headerLine);
1105
- this.log(ruleLine);
1058
+ const fixed = 6 + 10 + 20 + 36 + 12 + 8 + 10;
1059
+ const remaining = Math.max(60, tw - fixed);
1060
+ const repoW = Math.max(18, Math.floor(remaining * 0.25));
1061
+ const digestW = Math.max(18, Math.floor(remaining * 0.35));
1062
+ const imageW = Math.max(18, remaining - repoW - digestW);
1063
+ const table = new Table({
1064
+ head: [
1065
+ headers.rel,
1066
+ headers.block,
1067
+ headers.created,
1068
+ headers.repo,
1069
+ headers.commit,
1070
+ headers.digest,
1071
+ headers.image,
1072
+ headers.build,
1073
+ headers.prov,
1074
+ headers.deps
1075
+ ],
1076
+ colWidths: [6, 10, 20, repoW, 10, digestW, imageW, 36, 12, 8],
1077
+ wordWrap: true,
1078
+ style: { "padding-left": 0, "padding-right": 1, head: [], border: [] }
1079
+ });
1106
1080
  for (const r of rows) {
1107
- this.log(
1108
- [
1109
- padRight(truncateCell(r.rel, widths.rel), widths.rel),
1110
- padRight(truncateCell(r.block, widths.block), widths.block),
1111
- padRight(truncateCell(r.created, widths.created), widths.created),
1112
- padRight(truncateCell(shortenMiddle(r.repo, widths.repo), widths.repo), widths.repo),
1113
- padRight(r.commit, widths.commit),
1114
- padRight(
1115
- truncateCell(shortenMiddle(r.digest, widths.digest), widths.digest),
1116
- widths.digest
1117
- ),
1118
- padRight(
1119
- truncateCell(shortenMiddle(r.image, widths.image), widths.image),
1120
- widths.image
1121
- ),
1122
- padRight(r.build, widths.build),
1123
- padRight(truncateCell(r.prov, widths.prov), widths.prov),
1124
- padRight(truncateCell(r.deps, widths.deps), widths.deps)
1125
- ].join(sep)
1126
- );
1081
+ table.push([
1082
+ r.rel,
1083
+ r.block,
1084
+ r.created,
1085
+ r.repo,
1086
+ r.commit,
1087
+ r.digest,
1088
+ r.image,
1089
+ r.build,
1090
+ r.prov,
1091
+ r.deps
1092
+ ]);
1127
1093
  }
1094
+ this.log(table.toString());
1128
1095
  this.log("");
1129
1096
  this.log(
1130
1097
  chalk2.gray(