@dokploy/cli 0.2.8 → 0.3.1

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.
Files changed (88) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/client.d.ts +10 -0
  3. package/dist/client.js +72 -0
  4. package/dist/commands/auth.d.ts +2 -0
  5. package/dist/commands/auth.js +28 -0
  6. package/dist/generated/commands.d.ts +2 -0
  7. package/dist/generated/commands.js +9059 -0
  8. package/dist/index.d.ts +2 -1
  9. package/dist/index.js +24 -1
  10. package/package.json +25 -58
  11. package/readme.md +101 -83
  12. package/bin/dev.cmd +0 -3
  13. package/bin/dev.js +0 -6
  14. package/bin/run.cmd +0 -3
  15. package/bin/run.js +0 -5
  16. package/dist/commands/app/create.d.ts +0 -17
  17. package/dist/commands/app/create.js +0 -127
  18. package/dist/commands/app/delete.d.ts +0 -11
  19. package/dist/commands/app/delete.js +0 -106
  20. package/dist/commands/app/deploy.d.ts +0 -11
  21. package/dist/commands/app/deploy.js +0 -107
  22. package/dist/commands/app/stop.d.ts +0 -11
  23. package/dist/commands/app/stop.js +0 -102
  24. package/dist/commands/authenticate.d.ts +0 -10
  25. package/dist/commands/authenticate.js +0 -83
  26. package/dist/commands/database/mariadb/create.d.ts +0 -18
  27. package/dist/commands/database/mariadb/create.js +0 -188
  28. package/dist/commands/database/mariadb/delete.d.ts +0 -11
  29. package/dist/commands/database/mariadb/delete.js +0 -104
  30. package/dist/commands/database/mariadb/deploy.d.ts +0 -11
  31. package/dist/commands/database/mariadb/deploy.js +0 -103
  32. package/dist/commands/database/mariadb/stop.d.ts +0 -11
  33. package/dist/commands/database/mariadb/stop.js +0 -103
  34. package/dist/commands/database/mongo/create.d.ts +0 -17
  35. package/dist/commands/database/mongo/create.js +0 -176
  36. package/dist/commands/database/mongo/delete.d.ts +0 -11
  37. package/dist/commands/database/mongo/delete.js +0 -106
  38. package/dist/commands/database/mongo/deploy.d.ts +0 -11
  39. package/dist/commands/database/mongo/deploy.js +0 -103
  40. package/dist/commands/database/mongo/stop.d.ts +0 -11
  41. package/dist/commands/database/mongo/stop.js +0 -103
  42. package/dist/commands/database/mysql/create.d.ts +0 -18
  43. package/dist/commands/database/mysql/create.js +0 -188
  44. package/dist/commands/database/mysql/delete.d.ts +0 -11
  45. package/dist/commands/database/mysql/delete.js +0 -106
  46. package/dist/commands/database/mysql/deploy.d.ts +0 -6
  47. package/dist/commands/database/mysql/deploy.js +0 -86
  48. package/dist/commands/database/mysql/stop.d.ts +0 -6
  49. package/dist/commands/database/mysql/stop.js +0 -86
  50. package/dist/commands/database/postgres/create.d.ts +0 -17
  51. package/dist/commands/database/postgres/create.js +0 -176
  52. package/dist/commands/database/postgres/delete.d.ts +0 -11
  53. package/dist/commands/database/postgres/delete.js +0 -106
  54. package/dist/commands/database/postgres/deploy.d.ts +0 -11
  55. package/dist/commands/database/postgres/deploy.js +0 -103
  56. package/dist/commands/database/postgres/stop.d.ts +0 -11
  57. package/dist/commands/database/postgres/stop.js +0 -103
  58. package/dist/commands/database/redis/create.d.ts +0 -15
  59. package/dist/commands/database/redis/create.js +0 -151
  60. package/dist/commands/database/redis/delete.d.ts +0 -11
  61. package/dist/commands/database/redis/delete.js +0 -106
  62. package/dist/commands/database/redis/deploy.d.ts +0 -11
  63. package/dist/commands/database/redis/deploy.js +0 -103
  64. package/dist/commands/database/redis/stop.d.ts +0 -11
  65. package/dist/commands/database/redis/stop.js +0 -103
  66. package/dist/commands/env/pull.d.ts +0 -10
  67. package/dist/commands/env/pull.js +0 -68
  68. package/dist/commands/env/push.d.ts +0 -10
  69. package/dist/commands/env/push.js +0 -106
  70. package/dist/commands/project/create.d.ts +0 -11
  71. package/dist/commands/project/create.js +0 -89
  72. package/dist/commands/project/info.d.ts +0 -10
  73. package/dist/commands/project/info.js +0 -122
  74. package/dist/commands/project/list.d.ts +0 -6
  75. package/dist/commands/project/list.js +0 -43
  76. package/dist/commands/verify.d.ts +0 -6
  77. package/dist/commands/verify.js +0 -62
  78. package/dist/utils/http.d.ts +0 -4
  79. package/dist/utils/http.js +0 -4
  80. package/dist/utils/shared.d.ts +0 -10
  81. package/dist/utils/shared.js +0 -55
  82. package/dist/utils/slug.d.ts +0 -1
  83. package/dist/utils/slug.js +0 -12
  84. package/dist/utils/slugify.d.ts +0 -3
  85. package/dist/utils/slugify.js +0 -2
  86. package/dist/utils/utils.d.ts +0 -6
  87. package/dist/utils/utils.js +0 -26
  88. package/oclif.manifest.json +0 -1680
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 Mauricio Siu
3
+ Copyright (c) 2026 Dokploy Technologies, Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -0,0 +1,10 @@
1
+ import { type AxiosInstance } from "axios";
2
+ export interface AuthConfig {
3
+ token: string;
4
+ url: string;
5
+ }
6
+ export declare function readAuthConfig(): AuthConfig;
7
+ export declare function saveAuthConfig(url: string, token: string): void;
8
+ export declare function createClient(): AxiosInstance;
9
+ export declare function apiPost(endpoint: string, data?: Record<string, unknown>): Promise<any>;
10
+ export declare function apiGet(endpoint: string, params?: Record<string, unknown>): Promise<any>;
package/dist/client.js ADDED
@@ -0,0 +1,72 @@
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import axios from "axios";
5
+ import chalk from "chalk";
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = path.dirname(__filename);
8
+ const configPath = path.join(__dirname, "..", "config.json");
9
+ function loadEnvFile() {
10
+ const envPath = path.resolve(process.cwd(), ".env");
11
+ if (!fs.existsSync(envPath))
12
+ return;
13
+ const content = fs.readFileSync(envPath, "utf8");
14
+ for (const line of content.split("\n")) {
15
+ const trimmed = line.trim();
16
+ if (!trimmed || trimmed.startsWith("#"))
17
+ continue;
18
+ const eqIndex = trimmed.indexOf("=");
19
+ if (eqIndex === -1)
20
+ continue;
21
+ const key = trimmed.slice(0, eqIndex).trim();
22
+ const value = trimmed.slice(eqIndex + 1).trim().replace(/^["']|["']$/g, "");
23
+ if (!process.env[key]) {
24
+ process.env[key] = value;
25
+ }
26
+ }
27
+ }
28
+ export function readAuthConfig() {
29
+ loadEnvFile();
30
+ const envToken = process.env.DOKPLOY_API_KEY ?? process.env.DOKPLOY_AUTH_TOKEN;
31
+ const envUrl = process.env.DOKPLOY_URL;
32
+ if (envToken && envUrl) {
33
+ return { token: envToken, url: envUrl };
34
+ }
35
+ if (!fs.existsSync(configPath)) {
36
+ console.error(chalk.red("No configuration found. Please run 'dokploy auth' first or set DOKPLOY_URL and DOKPLOY_AUTH_TOKEN environment variables."));
37
+ process.exit(1);
38
+ }
39
+ const config = JSON.parse(fs.readFileSync(configPath, "utf8"));
40
+ const { token, url } = config;
41
+ if (!url || !token) {
42
+ console.error(chalk.red("Incomplete auth config. Run 'dokploy auth' or set environment variables."));
43
+ process.exit(1);
44
+ }
45
+ return { token, url };
46
+ }
47
+ export function saveAuthConfig(url, token) {
48
+ fs.writeFileSync(configPath, JSON.stringify({ url, token }, null, 2));
49
+ }
50
+ export function createClient() {
51
+ const auth = readAuthConfig();
52
+ return axios.create({
53
+ baseURL: `${auth.url}/api`,
54
+ headers: {
55
+ "x-api-key": auth.token,
56
+ "Content-Type": "application/json",
57
+ },
58
+ });
59
+ }
60
+ export async function apiPost(endpoint, data) {
61
+ const client = createClient();
62
+ const response = await client.post(`/trpc/${endpoint}`, data ? { json: data } : undefined);
63
+ return response.data?.result?.data?.json ?? response.data;
64
+ }
65
+ export async function apiGet(endpoint, params) {
66
+ const client = createClient();
67
+ const query = params
68
+ ? `?input=${encodeURIComponent(JSON.stringify(params))}`
69
+ : "";
70
+ const response = await client.get(`/trpc/${endpoint}${query}`);
71
+ return response.data?.result?.data?.json ?? response.data;
72
+ }
@@ -0,0 +1,2 @@
1
+ import type { Command } from "commander";
2
+ export declare function registerAuthCommand(program: Command): void;
@@ -0,0 +1,28 @@
1
+ import axios from "axios";
2
+ import chalk from "chalk";
3
+ import { saveAuthConfig } from "../client.js";
4
+ export function registerAuthCommand(program) {
5
+ program
6
+ .command("auth")
7
+ .description("Authenticate with your Dokploy server")
8
+ .requiredOption("-u, --url <url>", "Server URL (e.g., https://panel.dokploy.com)")
9
+ .requiredOption("-t, --token <token>", "API key from your Dokploy dashboard")
10
+ .action(async (opts) => {
11
+ const url = opts.url.replace(/\/+$/, "");
12
+ console.log(chalk.blue("Validating credentials..."));
13
+ try {
14
+ await axios.get(`${url}/api/trpc/user.get`, {
15
+ headers: {
16
+ "x-api-key": opts.token,
17
+ "Content-Type": "application/json",
18
+ },
19
+ });
20
+ saveAuthConfig(url, opts.token);
21
+ console.log(chalk.green("Authenticated successfully."));
22
+ }
23
+ catch (error) {
24
+ console.error(chalk.red(`Authentication failed: ${error.message}`));
25
+ process.exit(1);
26
+ }
27
+ });
28
+ }
@@ -0,0 +1,2 @@
1
+ import type { Command } from "commander";
2
+ export declare function registerGeneratedCommands(program: Command): void;