@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
|
@@ -5,7 +5,7 @@ import { Command, Args, Flags as Flags2 } from "@oclif/core";
|
|
|
5
5
|
|
|
6
6
|
// src/client.ts
|
|
7
7
|
import {
|
|
8
|
-
|
|
8
|
+
createAppModule,
|
|
9
9
|
createBillingModule,
|
|
10
10
|
getEnvironmentConfig as getEnvironmentConfig2,
|
|
11
11
|
requirePrivateKey,
|
|
@@ -52,7 +52,6 @@ import * as path from "path";
|
|
|
52
52
|
import * as os from "os";
|
|
53
53
|
import { load as loadYaml, dump as dumpYaml } from "js-yaml";
|
|
54
54
|
import { getBuildType } from "@layr-labs/ecloud-sdk";
|
|
55
|
-
import * as crypto from "crypto";
|
|
56
55
|
var GLOBAL_CONFIG_FILE = "config.yaml";
|
|
57
56
|
var PROFILE_CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
58
57
|
function getGlobalConfigDir() {
|
|
@@ -99,10 +98,6 @@ function getDefaultEnvironment() {
|
|
|
99
98
|
const config = loadGlobalConfig();
|
|
100
99
|
return config.default_environment;
|
|
101
100
|
}
|
|
102
|
-
function getGlobalTelemetryPreference() {
|
|
103
|
-
const config = loadGlobalConfig();
|
|
104
|
-
return config.telemetry_enabled;
|
|
105
|
-
}
|
|
106
101
|
function getProfileCache(environment) {
|
|
107
102
|
const config = loadGlobalConfig();
|
|
108
103
|
const cacheEntry = config.profile_cache?.[environment];
|
|
@@ -126,24 +121,6 @@ function setProfileCache(environment, profiles) {
|
|
|
126
121
|
};
|
|
127
122
|
saveGlobalConfig(config);
|
|
128
123
|
}
|
|
129
|
-
function getOrCreateUserUUID() {
|
|
130
|
-
const config = loadGlobalConfig();
|
|
131
|
-
if (config.user_uuid) {
|
|
132
|
-
return config.user_uuid;
|
|
133
|
-
}
|
|
134
|
-
const uuid = generateUUID();
|
|
135
|
-
config.user_uuid = uuid;
|
|
136
|
-
config.first_run = false;
|
|
137
|
-
saveGlobalConfig(config);
|
|
138
|
-
return uuid;
|
|
139
|
-
}
|
|
140
|
-
function generateUUID() {
|
|
141
|
-
const bytes = crypto.randomBytes(16);
|
|
142
|
-
bytes[6] = bytes[6] & 15 | 64;
|
|
143
|
-
bytes[8] = bytes[8] & 63 | 128;
|
|
144
|
-
const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0"));
|
|
145
|
-
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("");
|
|
146
|
-
}
|
|
147
124
|
|
|
148
125
|
// src/utils/appNames.ts
|
|
149
126
|
import * as fs2 from "fs";
|
|
@@ -191,7 +168,7 @@ function listApps(environment) {
|
|
|
191
168
|
|
|
192
169
|
// src/utils/version.ts
|
|
193
170
|
function getCliVersion() {
|
|
194
|
-
return true ? "0.1.0-
|
|
171
|
+
return true ? "0.1.0-rc.2" : "0.0.0";
|
|
195
172
|
}
|
|
196
173
|
function getClientId() {
|
|
197
174
|
return `ecloud-cli/v${getCliVersion()}`;
|
|
@@ -608,7 +585,7 @@ async function validateCommonFlags(flags) {
|
|
|
608
585
|
}
|
|
609
586
|
|
|
610
587
|
// src/client.ts
|
|
611
|
-
async function
|
|
588
|
+
async function createAppClient(flags) {
|
|
612
589
|
flags = await validateCommonFlags(flags);
|
|
613
590
|
const environment = flags.environment;
|
|
614
591
|
const environmentConfig = getEnvironmentConfig2(environment);
|
|
@@ -619,14 +596,12 @@ async function createComputeClient(flags) {
|
|
|
619
596
|
if (flags.verbose) {
|
|
620
597
|
console.log(`Using private key from: ${source}`);
|
|
621
598
|
}
|
|
622
|
-
return
|
|
599
|
+
return createAppModule({
|
|
623
600
|
verbose: flags.verbose,
|
|
624
601
|
privateKey,
|
|
625
602
|
rpcUrl,
|
|
626
603
|
environment,
|
|
627
|
-
clientId: getClientId()
|
|
628
|
-
skipTelemetry: true
|
|
629
|
-
// CLI already has telemetry, skip SDK telemetry
|
|
604
|
+
clientId: getClientId()
|
|
630
605
|
});
|
|
631
606
|
}
|
|
632
607
|
|
|
@@ -638,66 +613,6 @@ import {
|
|
|
638
613
|
isMainnet
|
|
639
614
|
} from "@layr-labs/ecloud-sdk";
|
|
640
615
|
import chalk from "chalk";
|
|
641
|
-
|
|
642
|
-
// src/telemetry.ts
|
|
643
|
-
import {
|
|
644
|
-
createTelemetryClient,
|
|
645
|
-
createAppEnvironment,
|
|
646
|
-
createMetricsContext,
|
|
647
|
-
addMetric,
|
|
648
|
-
addMetricWithDimensions,
|
|
649
|
-
emitMetrics,
|
|
650
|
-
getBuildType as getBuildType2
|
|
651
|
-
} from "@layr-labs/ecloud-sdk";
|
|
652
|
-
function createCLITelemetryClient() {
|
|
653
|
-
const userUUID = getOrCreateUserUUID();
|
|
654
|
-
const environment = createAppEnvironment(userUUID);
|
|
655
|
-
const telemetryEnabled = getGlobalTelemetryPreference();
|
|
656
|
-
return createTelemetryClient(environment, "ecloud-cli", {
|
|
657
|
-
telemetryEnabled: telemetryEnabled === true
|
|
658
|
-
// Only enabled if explicitly set to true
|
|
659
|
-
});
|
|
660
|
-
}
|
|
661
|
-
async function withTelemetry(command, action) {
|
|
662
|
-
const client = createCLITelemetryClient();
|
|
663
|
-
const metrics = createMetricsContext();
|
|
664
|
-
metrics.properties["source"] = "ecloud-cli";
|
|
665
|
-
metrics.properties["command"] = command.id || command.constructor.name;
|
|
666
|
-
const environment = getDefaultEnvironment() || "sepolia";
|
|
667
|
-
metrics.properties["environment"] = environment;
|
|
668
|
-
const buildType = getBuildType2() || "prod";
|
|
669
|
-
metrics.properties["build_type"] = buildType;
|
|
670
|
-
const cliVersion = command.config.version;
|
|
671
|
-
if (cliVersion) {
|
|
672
|
-
metrics.properties["cli_version"] = cliVersion;
|
|
673
|
-
}
|
|
674
|
-
addMetric(metrics, "Count", 1);
|
|
675
|
-
let actionError;
|
|
676
|
-
let result;
|
|
677
|
-
try {
|
|
678
|
-
result = await action();
|
|
679
|
-
return result;
|
|
680
|
-
} catch (err) {
|
|
681
|
-
actionError = err instanceof Error ? err : new Error(String(err));
|
|
682
|
-
throw err;
|
|
683
|
-
} finally {
|
|
684
|
-
const resultValue = actionError ? "Failure" : "Success";
|
|
685
|
-
const dimensions = {};
|
|
686
|
-
if (actionError) {
|
|
687
|
-
dimensions["error"] = actionError.message;
|
|
688
|
-
}
|
|
689
|
-
addMetricWithDimensions(metrics, resultValue, 1, dimensions);
|
|
690
|
-
const duration = Date.now() - metrics.startTime.getTime();
|
|
691
|
-
addMetric(metrics, "DurationMilliseconds", duration);
|
|
692
|
-
try {
|
|
693
|
-
await emitMetrics(client, metrics);
|
|
694
|
-
await client.close();
|
|
695
|
-
} catch {
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
// src/commands/compute/app/terminate.ts
|
|
701
616
|
var AppLifecycleTerminate = class _AppLifecycleTerminate extends Command {
|
|
702
617
|
static description = "Terminate app (terminate GCP instance) permanently";
|
|
703
618
|
static args = {
|
|
@@ -715,51 +630,49 @@ var AppLifecycleTerminate = class _AppLifecycleTerminate extends Command {
|
|
|
715
630
|
})
|
|
716
631
|
};
|
|
717
632
|
async run() {
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
this.log(`
|
|
633
|
+
const { args, flags } = await this.parse(_AppLifecycleTerminate);
|
|
634
|
+
const app = await createAppClient(flags);
|
|
635
|
+
const environment = flags.environment || "sepolia";
|
|
636
|
+
const environmentConfig = getEnvironmentConfig3(environment);
|
|
637
|
+
const rpcUrl = flags.rpcUrl || environmentConfig.defaultRPCURL;
|
|
638
|
+
const privateKey = flags["private-key"] || await getPrivateKeyInteractive(environment);
|
|
639
|
+
const appId = await getOrPromptAppID({
|
|
640
|
+
appID: args["app-id"],
|
|
641
|
+
environment: flags["environment"],
|
|
642
|
+
privateKey,
|
|
643
|
+
rpcUrl,
|
|
644
|
+
action: "terminate"
|
|
645
|
+
});
|
|
646
|
+
const callData = encodeTerminateAppData(appId);
|
|
647
|
+
const estimate = await estimateTransactionGas({
|
|
648
|
+
privateKey,
|
|
649
|
+
rpcUrl,
|
|
650
|
+
environmentConfig,
|
|
651
|
+
to: environmentConfig.appControllerAddress,
|
|
652
|
+
data: callData
|
|
653
|
+
});
|
|
654
|
+
if (!flags.force) {
|
|
655
|
+
const costInfo = isMainnet(environmentConfig) ? ` (cost: up to ${estimate.maxCostEth} ETH)` : "";
|
|
656
|
+
const confirmed = await confirm(`\u26A0\uFE0F Permanently destroy app ${appId}${costInfo}?`);
|
|
657
|
+
if (!confirmed) {
|
|
658
|
+
this.log(`
|
|
745
659
|
${chalk.gray(`Termination aborted`)}`);
|
|
746
|
-
|
|
747
|
-
}
|
|
660
|
+
return;
|
|
748
661
|
}
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
});
|
|
755
|
-
if (!res.tx) {
|
|
756
|
-
this.log(`
|
|
757
|
-
${chalk.gray(`Termination failed`)}`);
|
|
758
|
-
} else {
|
|
759
|
-
this.log(`
|
|
760
|
-
\u2705 ${chalk.green(`App terminated successfully`)}`);
|
|
662
|
+
}
|
|
663
|
+
const res = await app.terminate(appId, {
|
|
664
|
+
gas: {
|
|
665
|
+
maxFeePerGas: estimate.maxFeePerGas,
|
|
666
|
+
maxPriorityFeePerGas: estimate.maxPriorityFeePerGas
|
|
761
667
|
}
|
|
762
668
|
});
|
|
669
|
+
if (!res.tx) {
|
|
670
|
+
this.log(`
|
|
671
|
+
${chalk.gray(`Termination failed`)}`);
|
|
672
|
+
} else {
|
|
673
|
+
this.log(`
|
|
674
|
+
\u2705 ${chalk.green(`App terminated successfully`)}`);
|
|
675
|
+
}
|
|
763
676
|
}
|
|
764
677
|
};
|
|
765
678
|
export {
|