@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.
- package/VERSION +2 -2
- package/dist/commands/auth/generate.js +4 -4
- package/dist/commands/auth/generate.js.map +1 -1
- package/dist/commands/auth/login.js +2 -2
- package/dist/commands/auth/login.js.map +1 -1
- package/dist/commands/auth/logout.js +2 -2
- package/dist/commands/auth/logout.js.map +1 -1
- package/dist/commands/auth/migrate.js +2 -2
- package/dist/commands/auth/migrate.js.map +1 -1
- package/dist/commands/auth/whoami.js +7 -5
- package/dist/commands/auth/whoami.js.map +1 -1
- package/dist/commands/billing/cancel.js +9 -7
- package/dist/commands/billing/cancel.js.map +1 -1
- package/dist/commands/billing/status.js +8 -5
- package/dist/commands/billing/status.js.map +1 -1
- package/dist/commands/billing/subscribe.js +14 -10
- package/dist/commands/billing/subscribe.js.map +1 -1
- package/dist/commands/compute/app/create.js +2 -2
- package/dist/commands/compute/app/create.js.map +1 -1
- package/dist/commands/compute/app/deploy.js +105 -105
- package/dist/commands/compute/app/deploy.js.map +1 -1
- package/dist/commands/compute/app/info.js +55 -8
- package/dist/commands/compute/app/info.js.map +1 -1
- package/dist/commands/compute/app/list.js +8 -9
- package/dist/commands/compute/app/list.js.map +1 -1
- package/dist/commands/compute/app/logs.js +58 -11
- package/dist/commands/compute/app/logs.js.map +1 -1
- package/dist/commands/compute/app/profile/set.js +147 -22
- package/dist/commands/compute/app/profile/set.js.map +1 -1
- package/dist/commands/compute/app/releases.js +110 -143
- package/dist/commands/compute/app/releases.js.map +1 -1
- package/dist/commands/compute/app/start.js +58 -11
- package/dist/commands/compute/app/start.js.map +1 -1
- package/dist/commands/compute/app/stop.js +58 -11
- package/dist/commands/compute/app/stop.js.map +1 -1
- package/dist/commands/compute/app/terminate.js +58 -11
- package/dist/commands/compute/app/terminate.js.map +1 -1
- package/dist/commands/compute/app/upgrade.js +121 -67
- package/dist/commands/compute/app/upgrade.js.map +1 -1
- package/dist/commands/compute/build/info.js +8 -9
- package/dist/commands/compute/build/info.js.map +1 -1
- package/dist/commands/compute/build/list.js +50 -131
- package/dist/commands/compute/build/list.js.map +1 -1
- package/dist/commands/compute/build/logs.js +9 -10
- package/dist/commands/compute/build/logs.js.map +1 -1
- package/dist/commands/compute/build/status.js +9 -10
- package/dist/commands/compute/build/status.js.map +1 -1
- package/dist/commands/compute/build/submit.js +8 -9
- package/dist/commands/compute/build/submit.js.map +1 -1
- package/dist/commands/compute/build/verify.js +59 -12
- package/dist/commands/compute/build/verify.js.map +1 -1
- package/dist/commands/compute/environment/list.js +2 -2
- package/dist/commands/compute/environment/list.js.map +1 -1
- package/dist/commands/compute/environment/set.js +2 -2
- package/dist/commands/compute/environment/set.js.map +1 -1
- package/dist/commands/compute/environment/show.js +2 -2
- package/dist/commands/compute/environment/show.js.map +1 -1
- package/dist/commands/compute/undelegate.js +8 -9
- package/dist/commands/compute/undelegate.js.map +1 -1
- package/dist/commands/{telemetry.js → telemetry/disable.js} +15 -64
- package/dist/commands/telemetry/disable.js.map +1 -0
- package/dist/commands/telemetry/enable.js +164 -0
- package/dist/commands/telemetry/enable.js.map +1 -0
- package/dist/commands/telemetry/status.js +159 -0
- package/dist/commands/telemetry/status.js.map +1 -0
- package/dist/commands/upgrade.js +2 -2
- package/dist/commands/upgrade.js.map +1 -1
- package/dist/commands/version.js +2 -2
- package/dist/commands/version.js.map +1 -1
- package/package.json +4 -2
- 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
|
|
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
|
|
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
|
|
611
|
-
//
|
|
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 =
|
|
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/
|
|
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
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
const
|
|
812
|
-
|
|
813
|
-
return
|
|
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
|
|
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
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
"-"
|
|
1101
|
-
|
|
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
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
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(
|