mirror of
https://github.com/Dokploy/cli.git
synced 2026-06-19 14:15:20 +02:00
feat: add list and create project
This commit is contained in:
4
src/utils/http.ts
Normal file
4
src/utils/http.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export const headers = {
|
||||
"Content-Type": "application/json",
|
||||
"User-Agent": "Dokploy CLI",
|
||||
};
|
||||
36
src/utils/utils.ts
Normal file
36
src/utils/utils.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import type { Command } from "@oclif/core";
|
||||
|
||||
import chalk from "chalk";
|
||||
import * as fs from "node:fs";
|
||||
import * as path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
const configPath = path.join(__dirname, "..", "..", "config.json");
|
||||
|
||||
export const readAuthConfig = async (
|
||||
command: Command,
|
||||
): Promise<{ token: string; url: string }> => {
|
||||
if (!fs.existsSync(configPath)) {
|
||||
command.error(
|
||||
chalk.red(
|
||||
"No configuration file found. Please authenticate first using the 'authenticate' command.",
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
const configFileContent = fs.readFileSync(configPath, "utf8");
|
||||
const config = JSON.parse(configFileContent);
|
||||
const { token, url } = config;
|
||||
|
||||
if (!url || !token) {
|
||||
command.error(
|
||||
chalk.red(
|
||||
"Incomplete authentication details. Please authenticate again using the 'authenticate' command.",
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return { token, url };
|
||||
};
|
||||
Reference in New Issue
Block a user