@layr-labs/ecloud-cli 0.1.0-dev.3 → 0.1.0-rc.2
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/README.md +4 -4
- package/VERSION +2 -2
- package/dist/commands/auth/generate.js +46 -184
- package/dist/commands/auth/generate.js.map +1 -1
- package/dist/commands/auth/login.js +93 -234
- package/dist/commands/auth/login.js.map +1 -1
- package/dist/commands/auth/logout.js +30 -170
- package/dist/commands/auth/logout.js.map +1 -1
- package/dist/commands/auth/migrate.js +76 -216
- package/dist/commands/auth/migrate.js.map +1 -1
- package/dist/commands/auth/whoami.js +17 -145
- package/dist/commands/auth/whoami.js.map +1 -1
- package/dist/commands/billing/cancel.js +30 -164
- package/dist/commands/billing/cancel.js.map +1 -1
- package/dist/commands/billing/status.js +80 -213
- package/dist/commands/billing/status.js.map +1 -1
- package/dist/commands/billing/subscribe.js +45 -179
- package/dist/commands/billing/subscribe.js.map +1 -1
- package/dist/commands/compute/app/create.js +20 -148
- package/dist/commands/compute/app/create.js.map +1 -1
- package/dist/commands/compute/app/deploy.js +145 -243
- package/dist/commands/compute/app/deploy.js.map +1 -1
- package/dist/commands/compute/app/info.js +1 -2
- package/dist/commands/compute/app/info.js.map +1 -1
- package/dist/commands/compute/app/list.js +111 -194
- package/dist/commands/compute/app/list.js.map +1 -1
- package/dist/commands/compute/app/logs.js +20 -105
- package/dist/commands/compute/app/logs.js.map +1 -1
- package/dist/commands/compute/app/profile/set.js +64 -153
- package/dist/commands/compute/app/profile/set.js.map +1 -1
- package/dist/commands/compute/app/start.js +43 -132
- package/dist/commands/compute/app/start.js.map +1 -1
- package/dist/commands/compute/app/stop.js +43 -132
- package/dist/commands/compute/app/stop.js.map +1 -1
- package/dist/commands/compute/app/terminate.js +44 -131
- package/dist/commands/compute/app/terminate.js.map +1 -1
- package/dist/commands/compute/app/upgrade.js +108 -209
- package/dist/commands/compute/app/upgrade.js.map +1 -1
- package/dist/commands/compute/environment/list.js +12 -104
- package/dist/commands/compute/environment/list.js.map +1 -1
- package/dist/commands/compute/environment/set.js +18 -103
- package/dist/commands/compute/environment/set.js.map +1 -1
- package/dist/commands/compute/environment/show.js +30 -122
- package/dist/commands/compute/environment/show.js.map +1 -1
- package/dist/commands/compute/undelegate.js +18 -112
- package/dist/commands/compute/undelegate.js.map +1 -1
- package/dist/commands/upgrade.js +19 -159
- package/dist/commands/upgrade.js.map +1 -1
- package/dist/commands/version.js +23 -163
- package/dist/commands/version.js.map +1 -1
- package/package.json +2 -2
- package/dist/commands/telemetry.js +0 -213
- package/dist/commands/telemetry.js.map +0 -1
|
@@ -44,7 +44,6 @@ import * as path from "path";
|
|
|
44
44
|
import * as os from "os";
|
|
45
45
|
import { load as loadYaml, dump as dumpYaml } from "js-yaml";
|
|
46
46
|
import { getBuildType } from "@layr-labs/ecloud-sdk";
|
|
47
|
-
import * as crypto from "crypto";
|
|
48
47
|
var GLOBAL_CONFIG_FILE = "config.yaml";
|
|
49
48
|
var PROFILE_CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
50
49
|
function getGlobalConfigDir() {
|
|
@@ -87,14 +86,6 @@ function saveGlobalConfig(config) {
|
|
|
87
86
|
const content = dumpYaml(config, { lineWidth: -1 });
|
|
88
87
|
fs.writeFileSync(configPath, content, { mode: 420 });
|
|
89
88
|
}
|
|
90
|
-
function getDefaultEnvironment() {
|
|
91
|
-
const config = loadGlobalConfig();
|
|
92
|
-
return config.default_environment;
|
|
93
|
-
}
|
|
94
|
-
function getGlobalTelemetryPreference() {
|
|
95
|
-
const config = loadGlobalConfig();
|
|
96
|
-
return config.telemetry_enabled;
|
|
97
|
-
}
|
|
98
89
|
function getProfileCache(environment) {
|
|
99
90
|
const config = loadGlobalConfig();
|
|
100
91
|
const cacheEntry = config.profile_cache?.[environment];
|
|
@@ -146,24 +137,6 @@ function updateProfileCacheEntry(environment, appId, profileName) {
|
|
|
146
137
|
config.profile_cache[environment].updated_at = Date.now();
|
|
147
138
|
saveGlobalConfig(config);
|
|
148
139
|
}
|
|
149
|
-
function getOrCreateUserUUID() {
|
|
150
|
-
const config = loadGlobalConfig();
|
|
151
|
-
if (config.user_uuid) {
|
|
152
|
-
return config.user_uuid;
|
|
153
|
-
}
|
|
154
|
-
const uuid = generateUUID();
|
|
155
|
-
config.user_uuid = uuid;
|
|
156
|
-
config.first_run = false;
|
|
157
|
-
saveGlobalConfig(config);
|
|
158
|
-
return uuid;
|
|
159
|
-
}
|
|
160
|
-
function generateUUID() {
|
|
161
|
-
const bytes = crypto.randomBytes(16);
|
|
162
|
-
bytes[6] = bytes[6] & 15 | 64;
|
|
163
|
-
bytes[8] = bytes[8] & 63 | 128;
|
|
164
|
-
const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0"));
|
|
165
|
-
return hex.slice(0, 4).join("") + hex.slice(4, 6).join("") + "-" + hex.slice(6, 8).join("") + "-" + hex.slice(8, 10).join("") + "-" + hex.slice(10, 12).join("") + "-" + hex.slice(12, 16).join("");
|
|
166
|
-
}
|
|
167
140
|
|
|
168
141
|
// src/utils/appNames.ts
|
|
169
142
|
import * as fs2 from "fs";
|
|
@@ -232,7 +205,7 @@ function listApps(environment) {
|
|
|
232
205
|
|
|
233
206
|
// src/utils/version.ts
|
|
234
207
|
function getCliVersion() {
|
|
235
|
-
return true ? "0.1.0-
|
|
208
|
+
return true ? "0.1.0-rc.2" : "0.0.0";
|
|
236
209
|
}
|
|
237
210
|
function getClientId() {
|
|
238
211
|
return `ecloud-cli/v${getCliVersion()}`;
|
|
@@ -1006,66 +979,6 @@ var commonFlags = {
|
|
|
1006
979
|
|
|
1007
980
|
// src/commands/compute/app/profile/set.ts
|
|
1008
981
|
import chalk from "chalk";
|
|
1009
|
-
|
|
1010
|
-
// src/telemetry.ts
|
|
1011
|
-
import {
|
|
1012
|
-
createTelemetryClient,
|
|
1013
|
-
createAppEnvironment,
|
|
1014
|
-
createMetricsContext,
|
|
1015
|
-
addMetric,
|
|
1016
|
-
addMetricWithDimensions,
|
|
1017
|
-
emitMetrics,
|
|
1018
|
-
getBuildType as getBuildType2
|
|
1019
|
-
} from "@layr-labs/ecloud-sdk";
|
|
1020
|
-
function createCLITelemetryClient() {
|
|
1021
|
-
const userUUID = getOrCreateUserUUID();
|
|
1022
|
-
const environment = createAppEnvironment(userUUID);
|
|
1023
|
-
const telemetryEnabled = getGlobalTelemetryPreference();
|
|
1024
|
-
return createTelemetryClient(environment, "ecloud-cli", {
|
|
1025
|
-
telemetryEnabled: telemetryEnabled === true
|
|
1026
|
-
// Only enabled if explicitly set to true
|
|
1027
|
-
});
|
|
1028
|
-
}
|
|
1029
|
-
async function withTelemetry(command, action) {
|
|
1030
|
-
const client = createCLITelemetryClient();
|
|
1031
|
-
const metrics = createMetricsContext();
|
|
1032
|
-
metrics.properties["source"] = "ecloud-cli";
|
|
1033
|
-
metrics.properties["command"] = command.id || command.constructor.name;
|
|
1034
|
-
const environment = getDefaultEnvironment() || "sepolia";
|
|
1035
|
-
metrics.properties["environment"] = environment;
|
|
1036
|
-
const buildType = getBuildType2() || "prod";
|
|
1037
|
-
metrics.properties["build_type"] = buildType;
|
|
1038
|
-
const cliVersion = command.config.version;
|
|
1039
|
-
if (cliVersion) {
|
|
1040
|
-
metrics.properties["cli_version"] = cliVersion;
|
|
1041
|
-
}
|
|
1042
|
-
addMetric(metrics, "Count", 1);
|
|
1043
|
-
let actionError;
|
|
1044
|
-
let result;
|
|
1045
|
-
try {
|
|
1046
|
-
result = await action();
|
|
1047
|
-
return result;
|
|
1048
|
-
} catch (err) {
|
|
1049
|
-
actionError = err instanceof Error ? err : new Error(String(err));
|
|
1050
|
-
throw err;
|
|
1051
|
-
} finally {
|
|
1052
|
-
const resultValue = actionError ? "Failure" : "Success";
|
|
1053
|
-
const dimensions = {};
|
|
1054
|
-
if (actionError) {
|
|
1055
|
-
dimensions["error"] = actionError.message;
|
|
1056
|
-
}
|
|
1057
|
-
addMetricWithDimensions(metrics, resultValue, 1, dimensions);
|
|
1058
|
-
const duration = Date.now() - metrics.startTime.getTime();
|
|
1059
|
-
addMetric(metrics, "DurationMilliseconds", duration);
|
|
1060
|
-
try {
|
|
1061
|
-
await emitMetrics(client, metrics);
|
|
1062
|
-
await client.close();
|
|
1063
|
-
} catch {
|
|
1064
|
-
}
|
|
1065
|
-
}
|
|
1066
|
-
}
|
|
1067
|
-
|
|
1068
|
-
// src/commands/compute/app/profile/set.ts
|
|
1069
982
|
var ProfileSet = class _ProfileSet extends Command {
|
|
1070
983
|
static description = "Set public profile information for an app";
|
|
1071
984
|
static args = {
|
|
@@ -1098,75 +1011,73 @@ var ProfileSet = class _ProfileSet extends Command {
|
|
|
1098
1011
|
})
|
|
1099
1012
|
};
|
|
1100
1013
|
async run() {
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
this.log(`
|
|
1014
|
+
const { args, flags } = await this.parse(_ProfileSet);
|
|
1015
|
+
const environment = flags.environment || "sepolia";
|
|
1016
|
+
const environmentConfig = getEnvironmentConfig2(environment);
|
|
1017
|
+
const rpcUrl = flags["rpc-url"] || environmentConfig.defaultRPCURL;
|
|
1018
|
+
const privateKey = await getPrivateKeyInteractive(flags["private-key"]);
|
|
1019
|
+
const resolver = createAppResolver(environment, environmentConfig, privateKey, rpcUrl);
|
|
1020
|
+
const appId = await getOrPromptAppID({
|
|
1021
|
+
appID: args["app-id"],
|
|
1022
|
+
environment,
|
|
1023
|
+
privateKey,
|
|
1024
|
+
rpcUrl,
|
|
1025
|
+
action: "set profile for"
|
|
1026
|
+
});
|
|
1027
|
+
this.log(`
|
|
1116
1028
|
Setting profile for app: ${chalk.cyan(appId)}`);
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
}
|
|
1130
|
-
this.log("\n\u{1F4CB} Profile Summary:");
|
|
1131
|
-
this.log(` Name: ${profile.name}`);
|
|
1132
|
-
if (profile.website) this.log(` Website: ${profile.website}`);
|
|
1133
|
-
if (profile.description) this.log(` Description: ${profile.description}`);
|
|
1134
|
-
if (profile.xURL) this.log(` X URL: ${profile.xURL}`);
|
|
1135
|
-
if (profile.imagePath) this.log(` Image: ${profile.imagePath}`);
|
|
1136
|
-
} else {
|
|
1137
|
-
this.log("\nEnter profile information:");
|
|
1138
|
-
profile = await getAppProfileInteractive("", true);
|
|
1139
|
-
if (!profile) {
|
|
1140
|
-
this.log(`
|
|
1141
|
-
${chalk.gray("Profile setup cancelled")}`);
|
|
1142
|
-
return;
|
|
1143
|
-
}
|
|
1029
|
+
let profile;
|
|
1030
|
+
if (flags.name) {
|
|
1031
|
+
profile = {
|
|
1032
|
+
name: flags.name,
|
|
1033
|
+
website: flags.website,
|
|
1034
|
+
description: flags.description,
|
|
1035
|
+
xURL: flags["x-url"],
|
|
1036
|
+
imagePath: flags.image
|
|
1037
|
+
};
|
|
1038
|
+
const validationError = validateAppProfile(profile);
|
|
1039
|
+
if (validationError) {
|
|
1040
|
+
this.error(validationError);
|
|
1144
1041
|
}
|
|
1145
|
-
this.log("\
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
);
|
|
1156
|
-
resolver.updateCacheEntry(appId, response.name);
|
|
1157
|
-
invalidateProfileCache(environment);
|
|
1042
|
+
this.log("\n\u{1F4CB} Profile Summary:");
|
|
1043
|
+
this.log(` Name: ${profile.name}`);
|
|
1044
|
+
if (profile.website) this.log(` Website: ${profile.website}`);
|
|
1045
|
+
if (profile.description) this.log(` Description: ${profile.description}`);
|
|
1046
|
+
if (profile.xURL) this.log(` X URL: ${profile.xURL}`);
|
|
1047
|
+
if (profile.imagePath) this.log(` Image: ${profile.imagePath}`);
|
|
1048
|
+
} else {
|
|
1049
|
+
this.log("\nEnter profile information:");
|
|
1050
|
+
profile = await getAppProfileInteractive("", true);
|
|
1051
|
+
if (!profile) {
|
|
1158
1052
|
this.log(`
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
this.log(` Name: ${response.name}`);
|
|
1162
|
-
if (response.website) this.log(` Website: ${response.website}`);
|
|
1163
|
-
if (response.description) this.log(` Description: ${response.description}`);
|
|
1164
|
-
if (response.xURL) this.log(` X URL: ${response.xURL}`);
|
|
1165
|
-
if (response.imageURL) this.log(` Image URL: ${response.imageURL}`);
|
|
1166
|
-
} catch (error) {
|
|
1167
|
-
this.error(`Failed to upload profile: ${error.message}`);
|
|
1053
|
+
${chalk.gray("Profile setup cancelled")}`);
|
|
1054
|
+
return;
|
|
1168
1055
|
}
|
|
1169
|
-
}
|
|
1056
|
+
}
|
|
1057
|
+
this.log("\nUploading app profile...");
|
|
1058
|
+
const userApiClient = new UserApiClient3(environmentConfig, privateKey, rpcUrl, getClientId());
|
|
1059
|
+
try {
|
|
1060
|
+
const response = await userApiClient.uploadAppProfile(
|
|
1061
|
+
appId,
|
|
1062
|
+
profile.name,
|
|
1063
|
+
profile.website,
|
|
1064
|
+
profile.description,
|
|
1065
|
+
profile.xURL,
|
|
1066
|
+
profile.imagePath
|
|
1067
|
+
);
|
|
1068
|
+
resolver.updateCacheEntry(appId, response.name);
|
|
1069
|
+
invalidateProfileCache(environment);
|
|
1070
|
+
this.log(`
|
|
1071
|
+
\u2705 ${chalk.green(`Profile updated successfully for app '${response.name}'`)}`);
|
|
1072
|
+
this.log("\nUploaded Profile:");
|
|
1073
|
+
this.log(` Name: ${response.name}`);
|
|
1074
|
+
if (response.website) this.log(` Website: ${response.website}`);
|
|
1075
|
+
if (response.description) this.log(` Description: ${response.description}`);
|
|
1076
|
+
if (response.xURL) this.log(` X URL: ${response.xURL}`);
|
|
1077
|
+
if (response.imageURL) this.log(` Image URL: ${response.imageURL}`);
|
|
1078
|
+
} catch (error) {
|
|
1079
|
+
this.error(`Failed to upload profile: ${error.message}`);
|
|
1080
|
+
}
|
|
1170
1081
|
}
|
|
1171
1082
|
};
|
|
1172
1083
|
export {
|