@layr-labs/ecloud-cli 0.2.0-dev.2 → 0.2.0
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 +2 -2
- package/dist/commands/auth/generate.js.map +1 -1
- package/dist/commands/auth/login.js.map +1 -1
- package/dist/commands/auth/logout.js.map +1 -1
- package/dist/commands/auth/migrate.js.map +1 -1
- package/dist/commands/auth/whoami.js +5 -3
- package/dist/commands/auth/whoami.js.map +1 -1
- package/dist/commands/billing/cancel.js +6 -3
- package/dist/commands/billing/cancel.js.map +1 -1
- package/dist/commands/billing/status.js +6 -3
- package/dist/commands/billing/status.js.map +1 -1
- package/dist/commands/billing/subscribe.js +12 -7
- package/dist/commands/billing/subscribe.js.map +1 -1
- package/dist/commands/compute/app/create.js.map +1 -1
- package/dist/commands/compute/app/deploy.js +614 -86
- package/dist/commands/compute/app/deploy.js.map +1 -1
- package/dist/commands/compute/app/info.js +59 -10
- package/dist/commands/compute/app/info.js.map +1 -1
- package/dist/commands/compute/app/list.js +10 -9
- package/dist/commands/compute/app/list.js.map +1 -1
- package/dist/commands/compute/app/logs.js +61 -11
- package/dist/commands/compute/app/logs.js.map +1 -1
- package/dist/commands/compute/app/profile/set.js +145 -20
- package/dist/commands/compute/app/profile/set.js.map +1 -1
- package/dist/commands/compute/app/releases.js +1111 -0
- package/dist/commands/compute/app/releases.js.map +1 -0
- package/dist/commands/compute/app/start.js +61 -11
- package/dist/commands/compute/app/start.js.map +1 -1
- package/dist/commands/compute/app/stop.js +61 -11
- package/dist/commands/compute/app/stop.js.map +1 -1
- package/dist/commands/compute/app/terminate.js +61 -11
- package/dist/commands/compute/app/terminate.js.map +1 -1
- package/dist/commands/compute/app/upgrade.js +615 -52
- package/dist/commands/compute/app/upgrade.js.map +1 -1
- package/dist/commands/compute/build/info.js +500 -0
- package/dist/commands/compute/build/info.js.map +1 -0
- package/dist/commands/compute/build/list.js +494 -0
- package/dist/commands/compute/build/list.js.map +1 -0
- package/dist/commands/compute/build/logs.js +459 -0
- package/dist/commands/compute/build/logs.js.map +1 -0
- package/dist/commands/compute/build/status.js +481 -0
- package/dist/commands/compute/build/status.js.map +1 -0
- package/dist/commands/compute/build/submit.js +618 -0
- package/dist/commands/compute/build/submit.js.map +1 -0
- package/dist/commands/compute/build/verify.js +439 -0
- package/dist/commands/compute/build/verify.js.map +1 -0
- package/dist/commands/compute/environment/list.js.map +1 -1
- package/dist/commands/compute/environment/set.js.map +1 -1
- package/dist/commands/compute/environment/show.js.map +1 -1
- package/dist/commands/compute/undelegate.js +11 -9
- package/dist/commands/compute/undelegate.js.map +1 -1
- package/dist/commands/telemetry/disable.js.map +1 -1
- package/dist/commands/telemetry/enable.js.map +1 -1
- package/dist/commands/telemetry/status.js.map +1 -1
- package/dist/commands/upgrade.js.map +1 -1
- package/dist/commands/version.js.map +1 -1
- package/package.json +7 -2
|
@@ -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
|
|
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
|
|
257
|
+
return true ? "0.2.0" : "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
|
|
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
|
|
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,7 +1147,7 @@ import {
|
|
|
1015
1147
|
addMetric,
|
|
1016
1148
|
addMetricWithDimensions,
|
|
1017
1149
|
emitMetrics,
|
|
1018
|
-
getBuildType as
|
|
1150
|
+
getBuildType as getBuildType3
|
|
1019
1151
|
} from "@layr-labs/ecloud-sdk";
|
|
1020
1152
|
function createCLITelemetryClient() {
|
|
1021
1153
|
const userUUID = getOrCreateUserUUID();
|
|
@@ -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 =
|
|
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
|
|
1104
|
-
const
|
|
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 =
|
|
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
|
|
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(`
|