@layr-labs/ecloud-cli 0.1.1-dev → 0.2.0-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.
- 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 +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 +2 -2
- package/dist/commands/auth/whoami.js.map +1 -1
- package/dist/commands/billing/cancel.js +5 -4
- package/dist/commands/billing/cancel.js.map +1 -1
- package/dist/commands/billing/status.js +3 -3
- package/dist/commands/billing/status.js.map +1 -1
- package/dist/commands/billing/subscribe.js +5 -4
- 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 +545 -17
- package/dist/commands/compute/app/deploy.js.map +1 -1
- package/dist/commands/compute/app/info.js +5 -3
- package/dist/commands/compute/app/info.js.map +1 -1
- package/dist/commands/compute/app/list.js +6 -4
- package/dist/commands/compute/app/list.js.map +1 -1
- package/dist/commands/compute/app/logs.js +8 -5
- package/dist/commands/compute/app/logs.js.map +1 -1
- package/dist/commands/compute/app/profile/set.js +3 -3
- package/dist/commands/compute/app/profile/set.js.map +1 -1
- package/dist/commands/compute/app/releases.js +1144 -0
- package/dist/commands/compute/app/releases.js.map +1 -0
- package/dist/commands/compute/app/start.js +8 -5
- package/dist/commands/compute/app/start.js.map +1 -1
- package/dist/commands/compute/app/stop.js +8 -5
- package/dist/commands/compute/app/stop.js.map +1 -1
- package/dist/commands/compute/app/terminate.js +8 -5
- package/dist/commands/compute/app/terminate.js.map +1 -1
- package/dist/commands/compute/app/upgrade.js +520 -11
- package/dist/commands/compute/app/upgrade.js.map +1 -1
- package/dist/commands/compute/build/info.js +501 -0
- package/dist/commands/compute/build/info.js.map +1 -0
- package/dist/commands/compute/build/list.js +575 -0
- package/dist/commands/compute/build/list.js.map +1 -0
- package/dist/commands/compute/build/logs.js +460 -0
- package/dist/commands/compute/build/logs.js.map +1 -0
- package/dist/commands/compute/build/status.js +482 -0
- package/dist/commands/compute/build/status.js.map +1 -0
- package/dist/commands/compute/build/submit.js +619 -0
- package/dist/commands/compute/build/submit.js.map +1 -0
- package/dist/commands/compute/build/verify.js +392 -0
- package/dist/commands/compute/build/verify.js.map +1 -0
- 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 -5
- package/dist/commands/compute/undelegate.js.map +1 -1
- package/dist/commands/{telemetry/disable.js → telemetry.js} +64 -15
- package/dist/commands/telemetry.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 +5 -2
- package/dist/commands/telemetry/disable.js.map +0 -1
- package/dist/commands/telemetry/enable.js +0 -164
- package/dist/commands/telemetry/enable.js.map +0 -1
- package/dist/commands/telemetry/status.js +0 -159
- package/dist/commands/telemetry/status.js.map +0 -1
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/commands/compute/build/logs.ts
|
|
4
|
+
import { Args, Command, Flags as Flags2 } from "@oclif/core";
|
|
5
|
+
|
|
6
|
+
// src/flags.ts
|
|
7
|
+
import { Flags } from "@oclif/core";
|
|
8
|
+
|
|
9
|
+
// src/utils/prompts.ts
|
|
10
|
+
import { input, select, password, confirm as inquirerConfirm } from "@inquirer/prompts";
|
|
11
|
+
import fs3 from "fs";
|
|
12
|
+
import path3 from "path";
|
|
13
|
+
import os3 from "os";
|
|
14
|
+
import { isAddress as isAddress2 } from "viem";
|
|
15
|
+
import { privateKeyToAccount as privateKeyToAccount2 } from "viem/accounts";
|
|
16
|
+
import {
|
|
17
|
+
getEnvironmentConfig,
|
|
18
|
+
getAvailableEnvironments,
|
|
19
|
+
isEnvironmentAvailable,
|
|
20
|
+
getAllAppsByDeveloper as getAllAppsByDeveloper2,
|
|
21
|
+
getCategoryDescriptions,
|
|
22
|
+
fetchTemplateCatalog,
|
|
23
|
+
PRIMARY_LANGUAGES,
|
|
24
|
+
validateAppName,
|
|
25
|
+
validateImageReference,
|
|
26
|
+
validateFilePath,
|
|
27
|
+
validatePrivateKeyFormat,
|
|
28
|
+
extractAppNameFromImage,
|
|
29
|
+
UserApiClient as UserApiClient2
|
|
30
|
+
} from "@layr-labs/ecloud-sdk";
|
|
31
|
+
|
|
32
|
+
// src/utils/appResolver.ts
|
|
33
|
+
import { isAddress } from "viem";
|
|
34
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
35
|
+
import {
|
|
36
|
+
UserApiClient,
|
|
37
|
+
getAllAppsByDeveloper
|
|
38
|
+
} from "@layr-labs/ecloud-sdk";
|
|
39
|
+
|
|
40
|
+
// src/utils/globalConfig.ts
|
|
41
|
+
import * as fs from "fs";
|
|
42
|
+
import * as path from "path";
|
|
43
|
+
import * as os from "os";
|
|
44
|
+
import { load as loadYaml, dump as dumpYaml } from "js-yaml";
|
|
45
|
+
import { getBuildType } from "@layr-labs/ecloud-sdk";
|
|
46
|
+
import * as crypto from "crypto";
|
|
47
|
+
var GLOBAL_CONFIG_FILE = "config.yaml";
|
|
48
|
+
var PROFILE_CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
49
|
+
function getGlobalConfigDir() {
|
|
50
|
+
const configHome = process.env.XDG_CONFIG_HOME;
|
|
51
|
+
let baseDir;
|
|
52
|
+
if (configHome && path.isAbsolute(configHome)) {
|
|
53
|
+
baseDir = configHome;
|
|
54
|
+
} else {
|
|
55
|
+
baseDir = path.join(os.homedir(), ".config");
|
|
56
|
+
}
|
|
57
|
+
const buildType = getBuildType();
|
|
58
|
+
const buildSuffix = buildType === "dev" ? "-dev" : "";
|
|
59
|
+
const configDirName = `ecloud${buildSuffix}`;
|
|
60
|
+
return path.join(baseDir, configDirName);
|
|
61
|
+
}
|
|
62
|
+
function getGlobalConfigPath() {
|
|
63
|
+
return path.join(getGlobalConfigDir(), GLOBAL_CONFIG_FILE);
|
|
64
|
+
}
|
|
65
|
+
function loadGlobalConfig() {
|
|
66
|
+
const configPath = getGlobalConfigPath();
|
|
67
|
+
if (!fs.existsSync(configPath)) {
|
|
68
|
+
return {
|
|
69
|
+
first_run: true
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
const content = fs.readFileSync(configPath, "utf-8");
|
|
74
|
+
const config = loadYaml(content);
|
|
75
|
+
return config || { first_run: true };
|
|
76
|
+
} catch {
|
|
77
|
+
return {
|
|
78
|
+
first_run: true
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function saveGlobalConfig(config) {
|
|
83
|
+
const configPath = getGlobalConfigPath();
|
|
84
|
+
const configDir = path.dirname(configPath);
|
|
85
|
+
fs.mkdirSync(configDir, { recursive: true, mode: 493 });
|
|
86
|
+
const content = dumpYaml(config, { lineWidth: -1 });
|
|
87
|
+
fs.writeFileSync(configPath, content, { mode: 420 });
|
|
88
|
+
}
|
|
89
|
+
function getDefaultEnvironment() {
|
|
90
|
+
const config = loadGlobalConfig();
|
|
91
|
+
return config.default_environment;
|
|
92
|
+
}
|
|
93
|
+
function getGlobalTelemetryPreference() {
|
|
94
|
+
const config = loadGlobalConfig();
|
|
95
|
+
return config.telemetry_enabled;
|
|
96
|
+
}
|
|
97
|
+
function getOrCreateUserUUID() {
|
|
98
|
+
const config = loadGlobalConfig();
|
|
99
|
+
if (config.user_uuid) {
|
|
100
|
+
return config.user_uuid;
|
|
101
|
+
}
|
|
102
|
+
const uuid = generateUUID();
|
|
103
|
+
config.user_uuid = uuid;
|
|
104
|
+
config.first_run = false;
|
|
105
|
+
saveGlobalConfig(config);
|
|
106
|
+
return uuid;
|
|
107
|
+
}
|
|
108
|
+
function generateUUID() {
|
|
109
|
+
const bytes = crypto.randomBytes(16);
|
|
110
|
+
bytes[6] = bytes[6] & 15 | 64;
|
|
111
|
+
bytes[8] = bytes[8] & 63 | 128;
|
|
112
|
+
const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0"));
|
|
113
|
+
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("");
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// src/utils/appNames.ts
|
|
117
|
+
import * as fs2 from "fs";
|
|
118
|
+
import * as path2 from "path";
|
|
119
|
+
import * as os2 from "os";
|
|
120
|
+
import { load as loadYaml2, dump as dumpYaml2 } from "js-yaml";
|
|
121
|
+
var CONFIG_DIR = path2.join(os2.homedir(), ".eigenx");
|
|
122
|
+
var APPS_DIR = path2.join(CONFIG_DIR, "apps");
|
|
123
|
+
|
|
124
|
+
// src/utils/version.ts
|
|
125
|
+
function getCliVersion() {
|
|
126
|
+
return true ? "0.2.0-dev" : "0.0.0";
|
|
127
|
+
}
|
|
128
|
+
function getClientId() {
|
|
129
|
+
return `ecloud-cli/v${getCliVersion()}`;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// src/utils/prompts.ts
|
|
133
|
+
function formatBuildChoice(build) {
|
|
134
|
+
const repoUrl = String(build.repoUrl || "").replace(/\.git$/i, "").replace(/\/+$/, "");
|
|
135
|
+
const repoName = (() => {
|
|
136
|
+
try {
|
|
137
|
+
const url = new URL(repoUrl);
|
|
138
|
+
const parts = url.pathname.split("/").filter(Boolean);
|
|
139
|
+
return parts.length ? parts[parts.length - 1] : repoUrl;
|
|
140
|
+
} catch {
|
|
141
|
+
const m = repoUrl.match(/[:/]+([^/:]+)$/);
|
|
142
|
+
return m?.[1] || repoUrl || "unknown";
|
|
143
|
+
}
|
|
144
|
+
})();
|
|
145
|
+
const shortSha = build.gitRef ? String(build.gitRef).slice(0, 10) : "unknown";
|
|
146
|
+
const shortId = build.buildId ? String(build.buildId).slice(0, 8) : "unknown";
|
|
147
|
+
const created = build.createdAt ? new Date(build.createdAt).toLocaleString() : "";
|
|
148
|
+
const status = String(build.status || "unknown");
|
|
149
|
+
return `${status} ${repoName}@${shortSha} ${shortId} ${created}`;
|
|
150
|
+
}
|
|
151
|
+
async function promptBuildIdFromRecentBuilds(options) {
|
|
152
|
+
const limit = Math.max(1, Math.min(100, options.limit ?? 20));
|
|
153
|
+
const builds = await options.client.list({
|
|
154
|
+
billingAddress: options.billingAddress,
|
|
155
|
+
limit,
|
|
156
|
+
offset: 0
|
|
157
|
+
});
|
|
158
|
+
if (!builds || builds.length === 0) {
|
|
159
|
+
throw new Error(`No builds found for billing address ${options.billingAddress}`);
|
|
160
|
+
}
|
|
161
|
+
const choice = await select({
|
|
162
|
+
message: "Select a build:",
|
|
163
|
+
choices: builds.map((b) => ({
|
|
164
|
+
name: formatBuildChoice(b),
|
|
165
|
+
value: b.buildId
|
|
166
|
+
}))
|
|
167
|
+
});
|
|
168
|
+
return choice;
|
|
169
|
+
}
|
|
170
|
+
async function getPrivateKeyInteractive(privateKey) {
|
|
171
|
+
if (privateKey) {
|
|
172
|
+
if (!validatePrivateKeyFormat(privateKey)) {
|
|
173
|
+
throw new Error("Invalid private key format");
|
|
174
|
+
}
|
|
175
|
+
return privateKey;
|
|
176
|
+
}
|
|
177
|
+
const { getPrivateKeyWithSource: getPrivateKeyWithSource2 } = await import("@layr-labs/ecloud-sdk");
|
|
178
|
+
const result = await getPrivateKeyWithSource2({ privateKey: void 0 });
|
|
179
|
+
if (result) {
|
|
180
|
+
return result.key;
|
|
181
|
+
}
|
|
182
|
+
const key = await password({
|
|
183
|
+
message: "Enter private key:",
|
|
184
|
+
mask: true,
|
|
185
|
+
validate: (value) => {
|
|
186
|
+
if (!value.trim()) {
|
|
187
|
+
return "Private key is required";
|
|
188
|
+
}
|
|
189
|
+
if (!validatePrivateKeyFormat(value)) {
|
|
190
|
+
return "Invalid private key format (must be 64 hex characters, optionally prefixed with 0x)";
|
|
191
|
+
}
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
return key.trim();
|
|
196
|
+
}
|
|
197
|
+
async function getEnvironmentInteractive(environment) {
|
|
198
|
+
if (environment) {
|
|
199
|
+
try {
|
|
200
|
+
getEnvironmentConfig(environment);
|
|
201
|
+
if (!isEnvironmentAvailable(environment)) {
|
|
202
|
+
throw new Error(`Environment ${environment} is not available in this build`);
|
|
203
|
+
}
|
|
204
|
+
return environment;
|
|
205
|
+
} catch {
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
const availableEnvs = getAvailableEnvironments();
|
|
209
|
+
let defaultEnv;
|
|
210
|
+
const configDefaultEnv = getDefaultEnvironment();
|
|
211
|
+
if (configDefaultEnv && availableEnvs.includes(configDefaultEnv)) {
|
|
212
|
+
try {
|
|
213
|
+
getEnvironmentConfig(configDefaultEnv);
|
|
214
|
+
defaultEnv = configDefaultEnv;
|
|
215
|
+
} catch {
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
const choices = [];
|
|
219
|
+
if (availableEnvs.includes("sepolia")) {
|
|
220
|
+
choices.push({ name: "sepolia - Ethereum Sepolia testnet", value: "sepolia" });
|
|
221
|
+
}
|
|
222
|
+
if (availableEnvs.includes("sepolia-dev")) {
|
|
223
|
+
choices.push({ name: "sepolia-dev - Ethereum Sepolia testnet (dev)", value: "sepolia-dev" });
|
|
224
|
+
}
|
|
225
|
+
if (availableEnvs.includes("mainnet-alpha")) {
|
|
226
|
+
choices.push({
|
|
227
|
+
name: "mainnet-alpha - Ethereum mainnet (\u26A0\uFE0F uses real funds)",
|
|
228
|
+
value: "mainnet-alpha"
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
if (choices.length === 0) {
|
|
232
|
+
throw new Error("No environments available in this build");
|
|
233
|
+
}
|
|
234
|
+
const env = await select({
|
|
235
|
+
message: "Select environment:",
|
|
236
|
+
choices,
|
|
237
|
+
default: defaultEnv
|
|
238
|
+
});
|
|
239
|
+
return env;
|
|
240
|
+
}
|
|
241
|
+
var MAX_IMAGE_SIZE = 4 * 1024 * 1024;
|
|
242
|
+
|
|
243
|
+
// src/flags.ts
|
|
244
|
+
var commonFlags = {
|
|
245
|
+
environment: Flags.string({
|
|
246
|
+
required: false,
|
|
247
|
+
description: "Deployment environment to use",
|
|
248
|
+
env: "ECLOUD_ENV"
|
|
249
|
+
}),
|
|
250
|
+
"private-key": Flags.string({
|
|
251
|
+
required: false,
|
|
252
|
+
description: "Private key for signing transactions",
|
|
253
|
+
env: "ECLOUD_PRIVATE_KEY"
|
|
254
|
+
}),
|
|
255
|
+
"rpc-url": Flags.string({
|
|
256
|
+
required: false,
|
|
257
|
+
description: "RPC URL to connect to blockchain",
|
|
258
|
+
env: "ECLOUD_RPC_URL"
|
|
259
|
+
}),
|
|
260
|
+
verbose: Flags.boolean({
|
|
261
|
+
required: false,
|
|
262
|
+
description: "Enable verbose logging (default: false)",
|
|
263
|
+
default: false
|
|
264
|
+
})
|
|
265
|
+
};
|
|
266
|
+
async function validateCommonFlags(flags, options) {
|
|
267
|
+
if (!flags["environment"]) {
|
|
268
|
+
flags["environment"] = getDefaultEnvironment();
|
|
269
|
+
}
|
|
270
|
+
flags["environment"] = await getEnvironmentInteractive(flags["environment"]);
|
|
271
|
+
if (options?.requirePrivateKey !== false) {
|
|
272
|
+
flags["private-key"] = await getPrivateKeyInteractive(flags["private-key"]);
|
|
273
|
+
}
|
|
274
|
+
return flags;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// src/client.ts
|
|
278
|
+
import {
|
|
279
|
+
createComputeModule,
|
|
280
|
+
createBillingModule,
|
|
281
|
+
createBuildModule,
|
|
282
|
+
getEnvironmentConfig as getEnvironmentConfig2,
|
|
283
|
+
requirePrivateKey,
|
|
284
|
+
getPrivateKeyWithSource
|
|
285
|
+
} from "@layr-labs/ecloud-sdk";
|
|
286
|
+
async function createBuildClient(flags) {
|
|
287
|
+
flags = await validateCommonFlags(flags, { requirePrivateKey: false });
|
|
288
|
+
return createBuildModule({
|
|
289
|
+
verbose: flags.verbose,
|
|
290
|
+
privateKey: flags["private-key"],
|
|
291
|
+
environment: flags.environment,
|
|
292
|
+
clientId: getClientId(),
|
|
293
|
+
skipTelemetry: true
|
|
294
|
+
// CLI already has telemetry, skip SDK telemetry
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// src/telemetry.ts
|
|
299
|
+
import {
|
|
300
|
+
createTelemetryClient,
|
|
301
|
+
createAppEnvironment,
|
|
302
|
+
createMetricsContext,
|
|
303
|
+
addMetric,
|
|
304
|
+
addMetricWithDimensions,
|
|
305
|
+
emitMetrics,
|
|
306
|
+
getBuildType as getBuildType2
|
|
307
|
+
} from "@layr-labs/ecloud-sdk";
|
|
308
|
+
function createCLITelemetryClient() {
|
|
309
|
+
const userUUID = getOrCreateUserUUID();
|
|
310
|
+
const environment = createAppEnvironment(userUUID);
|
|
311
|
+
const telemetryEnabled = getGlobalTelemetryPreference();
|
|
312
|
+
return createTelemetryClient(environment, "ecloud-cli", {
|
|
313
|
+
telemetryEnabled: telemetryEnabled === true
|
|
314
|
+
// Only enabled if explicitly set to true
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
async function withTelemetry(command, action) {
|
|
318
|
+
const client = createCLITelemetryClient();
|
|
319
|
+
const metrics = createMetricsContext();
|
|
320
|
+
metrics.properties["source"] = "ecloud-cli";
|
|
321
|
+
metrics.properties["command"] = command.id || command.constructor.name;
|
|
322
|
+
const environment = getDefaultEnvironment() || "sepolia";
|
|
323
|
+
metrics.properties["environment"] = environment;
|
|
324
|
+
const buildType = getBuildType2() || "prod";
|
|
325
|
+
metrics.properties["build_type"] = buildType;
|
|
326
|
+
const cliVersion = command.config.version;
|
|
327
|
+
if (cliVersion) {
|
|
328
|
+
metrics.properties["cli_version"] = cliVersion;
|
|
329
|
+
}
|
|
330
|
+
addMetric(metrics, "Count", 1);
|
|
331
|
+
let actionError;
|
|
332
|
+
let result;
|
|
333
|
+
try {
|
|
334
|
+
result = await action();
|
|
335
|
+
return result;
|
|
336
|
+
} catch (err) {
|
|
337
|
+
actionError = err instanceof Error ? err : new Error(String(err));
|
|
338
|
+
throw err;
|
|
339
|
+
} finally {
|
|
340
|
+
const resultValue = actionError ? "Failure" : "Success";
|
|
341
|
+
const dimensions = {};
|
|
342
|
+
if (actionError) {
|
|
343
|
+
dimensions["error"] = actionError.message;
|
|
344
|
+
}
|
|
345
|
+
addMetricWithDimensions(metrics, resultValue, 1, dimensions);
|
|
346
|
+
const duration = Date.now() - metrics.startTime.getTime();
|
|
347
|
+
addMetric(metrics, "DurationMilliseconds", duration);
|
|
348
|
+
try {
|
|
349
|
+
await emitMetrics(client, metrics);
|
|
350
|
+
await client.close();
|
|
351
|
+
} catch {
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// src/commands/compute/build/logs.ts
|
|
357
|
+
import chalk from "chalk";
|
|
358
|
+
import { BUILD_STATUS as BUILD_STATUS2 } from "@layr-labs/ecloud-sdk";
|
|
359
|
+
|
|
360
|
+
// src/utils/verifiableBuild.ts
|
|
361
|
+
import { BUILD_STATUS } from "@layr-labs/ecloud-sdk";
|
|
362
|
+
function assertBuildId(buildId) {
|
|
363
|
+
const trimmed = String(buildId ?? "").trim();
|
|
364
|
+
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
365
|
+
if (!UUID_RE.test(trimmed)) {
|
|
366
|
+
throw new Error(`Invalid build ID: '${buildId}' (expected a UUID)`);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// src/commands/compute/build/logs.ts
|
|
371
|
+
import { privateKeyToAccount as privateKeyToAccount3 } from "viem/accounts";
|
|
372
|
+
import { addHexPrefix } from "@layr-labs/ecloud-sdk";
|
|
373
|
+
var BuildLogs = class _BuildLogs extends Command {
|
|
374
|
+
static description = "Get or stream build logs";
|
|
375
|
+
static examples = [
|
|
376
|
+
`$ ecloud compute build logs abc123-def456-...`,
|
|
377
|
+
`$ ecloud compute build logs abc123-def456-... --follow`,
|
|
378
|
+
`$ ecloud compute build logs abc123-def456-... --tail 50`
|
|
379
|
+
];
|
|
380
|
+
static args = {
|
|
381
|
+
buildId: Args.string({
|
|
382
|
+
description: "Build ID",
|
|
383
|
+
required: false
|
|
384
|
+
})
|
|
385
|
+
};
|
|
386
|
+
static flags = {
|
|
387
|
+
...commonFlags,
|
|
388
|
+
follow: Flags2.boolean({
|
|
389
|
+
char: "f",
|
|
390
|
+
description: "Follow logs in real-time",
|
|
391
|
+
default: false
|
|
392
|
+
}),
|
|
393
|
+
tail: Flags2.integer({
|
|
394
|
+
description: "Show last N lines"
|
|
395
|
+
})
|
|
396
|
+
};
|
|
397
|
+
async run() {
|
|
398
|
+
return withTelemetry(this, async () => {
|
|
399
|
+
const { args, flags } = await this.parse(_BuildLogs);
|
|
400
|
+
const validatedFlags = await validateCommonFlags(flags);
|
|
401
|
+
const client = await createBuildClient(validatedFlags);
|
|
402
|
+
let buildId = args.buildId;
|
|
403
|
+
if (!buildId) {
|
|
404
|
+
const billingAddress = privateKeyToAccount3(
|
|
405
|
+
addHexPrefix(validatedFlags["private-key"])
|
|
406
|
+
).address;
|
|
407
|
+
buildId = await promptBuildIdFromRecentBuilds({ client, billingAddress, limit: 20 });
|
|
408
|
+
} else {
|
|
409
|
+
try {
|
|
410
|
+
assertBuildId(buildId);
|
|
411
|
+
} catch (e) {
|
|
412
|
+
this.error(e?.message || String(e));
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
if (flags.follow) {
|
|
416
|
+
const pollIntervalMs = 2e3;
|
|
417
|
+
let lastLogLength = 0;
|
|
418
|
+
while (true) {
|
|
419
|
+
const build = await client.get(buildId);
|
|
420
|
+
let logs2 = "";
|
|
421
|
+
try {
|
|
422
|
+
logs2 = await client.getLogs(buildId);
|
|
423
|
+
} catch {
|
|
424
|
+
}
|
|
425
|
+
if (logs2.length > lastLogLength) {
|
|
426
|
+
process.stdout.write(logs2.slice(lastLogLength));
|
|
427
|
+
lastLogLength = logs2.length;
|
|
428
|
+
}
|
|
429
|
+
if (build.status !== BUILD_STATUS2.BUILDING) {
|
|
430
|
+
process.stdout.write("\n");
|
|
431
|
+
break;
|
|
432
|
+
}
|
|
433
|
+
await showCountdown(Math.ceil(pollIntervalMs / 1e3));
|
|
434
|
+
}
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
const logs = await client.getLogs(buildId);
|
|
438
|
+
if (flags.tail !== void 0) {
|
|
439
|
+
const lines = logs.split("\n");
|
|
440
|
+
const tailedLines = lines.slice(-flags.tail);
|
|
441
|
+
this.log(tailedLines.join("\n"));
|
|
442
|
+
} else {
|
|
443
|
+
this.log(logs);
|
|
444
|
+
}
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
async function showCountdown(seconds) {
|
|
449
|
+
for (let i = seconds; i >= 0; i--) {
|
|
450
|
+
process.stdout.write(chalk.gray(`\rRefreshing in ${i}...`));
|
|
451
|
+
if (i > 0) {
|
|
452
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
process.stdout.write("\r");
|
|
456
|
+
}
|
|
457
|
+
export {
|
|
458
|
+
BuildLogs as default
|
|
459
|
+
};
|
|
460
|
+
//# sourceMappingURL=logs.js.map
|