Initial vmc CLI

This commit is contained in:
Vault Sovereign
2025-12-26 19:35:03 +00:00
commit a075fcf95f
37 changed files with 3967 additions and 0 deletions

23
src/lib/env.ts Normal file
View File

@@ -0,0 +1,23 @@
import fs from "node:fs";
import path from "node:path";
import os from "node:os";
import dotenv from "dotenv";
export function loadEnv() {
const homeEnv = path.join(os.homedir(), ".env");
const localEnv = path.join(process.cwd(), ".env");
if (fs.existsSync(homeEnv)) dotenv.config({ path: homeEnv });
if (fs.existsSync(localEnv)) dotenv.config({ path: localEnv });
}
export function requireHcloudToken(): string {
loadEnv();
const token = process.env.HCLOUD_TOKEN?.trim();
if (!token) {
throw new Error(
"HCLOUD_TOKEN missing. Put it in ~/.env or ./vm-cloud/.env as: HCLOUD_TOKEN=xxxxx"
);
}
return token;
}