mirror of
https://github.com/Dokploy/cli.git
synced 2026-06-18 21:55:23 +02:00
feat: enhance CLI commands with improved flags and error handling
This commit introduces several improvements across multiple CLI commands: - Added new flags for more flexible command usage - Implemented interactive mode for commands when flags are not provided - Improved error handling and messaging - Added support for environment variable authentication - Standardized confirmation prompts and error messages - Enhanced type safety with TypeScript improvements
This commit is contained in:
@@ -15,10 +15,19 @@ export type AuthConfig = {
|
||||
};
|
||||
|
||||
export const readAuthConfig = async (command: Command): Promise<AuthConfig> => {
|
||||
// Primero intentar leer desde variables de entorno
|
||||
const envToken = process.env.DOKPLOY_AUTH_TOKEN;
|
||||
const envUrl = process.env.DOKPLOY_URL;
|
||||
|
||||
if (envToken && envUrl) {
|
||||
return { token: envToken, url: envUrl };
|
||||
}
|
||||
|
||||
// Si no hay variables de entorno, usar el archivo de configuración
|
||||
if (!fs.existsSync(configPath)) {
|
||||
command.error(
|
||||
chalk.red(
|
||||
"No configuration file found. Please authenticate first using the 'authenticate' command.",
|
||||
"No configuration file found and no environment variables set. Please authenticate first using the 'authenticate' command or set DOKPLOY_URL and DOKPLOY_AUTH_TOKEN environment variables.",
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -30,7 +39,7 @@ export const readAuthConfig = async (command: Command): Promise<AuthConfig> => {
|
||||
if (!url || !token) {
|
||||
command.error(
|
||||
chalk.red(
|
||||
"Incomplete authentication details. Please authenticate again using the 'authenticate' command.",
|
||||
"Incomplete authentication details. Please authenticate again using the 'authenticate' command or set environment variables.",
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user