@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.
- package/LICENSE.md +1 -1
- package/dist/client.d.ts +10 -0
- package/dist/client.js +72 -0
- package/dist/commands/auth.d.ts +2 -0
- package/dist/commands/auth.js +28 -0
- package/dist/generated/commands.d.ts +2 -0
- package/dist/generated/commands.js +9059 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +24 -1
- package/package.json +25 -58
- package/readme.md +101 -83
- package/bin/dev.cmd +0 -3
- package/bin/dev.js +0 -6
- package/bin/run.cmd +0 -3
- package/bin/run.js +0 -5
- package/dist/commands/app/create.d.ts +0 -17
- package/dist/commands/app/create.js +0 -127
- package/dist/commands/app/delete.d.ts +0 -11
- package/dist/commands/app/delete.js +0 -106
- package/dist/commands/app/deploy.d.ts +0 -11
- package/dist/commands/app/deploy.js +0 -107
- package/dist/commands/app/stop.d.ts +0 -11
- package/dist/commands/app/stop.js +0 -102
- package/dist/commands/authenticate.d.ts +0 -10
- package/dist/commands/authenticate.js +0 -83
- package/dist/commands/database/mariadb/create.d.ts +0 -18
- package/dist/commands/database/mariadb/create.js +0 -188
- package/dist/commands/database/mariadb/delete.d.ts +0 -11
- package/dist/commands/database/mariadb/delete.js +0 -104
- package/dist/commands/database/mariadb/deploy.d.ts +0 -11
- package/dist/commands/database/mariadb/deploy.js +0 -103
- package/dist/commands/database/mariadb/stop.d.ts +0 -11
- package/dist/commands/database/mariadb/stop.js +0 -103
- package/dist/commands/database/mongo/create.d.ts +0 -17
- package/dist/commands/database/mongo/create.js +0 -176
- package/dist/commands/database/mongo/delete.d.ts +0 -11
- package/dist/commands/database/mongo/delete.js +0 -106
- package/dist/commands/database/mongo/deploy.d.ts +0 -11
- package/dist/commands/database/mongo/deploy.js +0 -103
- package/dist/commands/database/mongo/stop.d.ts +0 -11
- package/dist/commands/database/mongo/stop.js +0 -103
- package/dist/commands/database/mysql/create.d.ts +0 -18
- package/dist/commands/database/mysql/create.js +0 -188
- package/dist/commands/database/mysql/delete.d.ts +0 -11
- package/dist/commands/database/mysql/delete.js +0 -106
- package/dist/commands/database/mysql/deploy.d.ts +0 -6
- package/dist/commands/database/mysql/deploy.js +0 -86
- package/dist/commands/database/mysql/stop.d.ts +0 -6
- package/dist/commands/database/mysql/stop.js +0 -86
- package/dist/commands/database/postgres/create.d.ts +0 -17
- package/dist/commands/database/postgres/create.js +0 -176
- package/dist/commands/database/postgres/delete.d.ts +0 -11
- package/dist/commands/database/postgres/delete.js +0 -106
- package/dist/commands/database/postgres/deploy.d.ts +0 -11
- package/dist/commands/database/postgres/deploy.js +0 -103
- package/dist/commands/database/postgres/stop.d.ts +0 -11
- package/dist/commands/database/postgres/stop.js +0 -103
- package/dist/commands/database/redis/create.d.ts +0 -15
- package/dist/commands/database/redis/create.js +0 -151
- package/dist/commands/database/redis/delete.d.ts +0 -11
- package/dist/commands/database/redis/delete.js +0 -106
- package/dist/commands/database/redis/deploy.d.ts +0 -11
- package/dist/commands/database/redis/deploy.js +0 -103
- package/dist/commands/database/redis/stop.d.ts +0 -11
- package/dist/commands/database/redis/stop.js +0 -103
- package/dist/commands/env/pull.d.ts +0 -10
- package/dist/commands/env/pull.js +0 -68
- package/dist/commands/env/push.d.ts +0 -10
- package/dist/commands/env/push.js +0 -106
- package/dist/commands/project/create.d.ts +0 -11
- package/dist/commands/project/create.js +0 -89
- package/dist/commands/project/info.d.ts +0 -10
- package/dist/commands/project/info.js +0 -122
- package/dist/commands/project/list.d.ts +0 -6
- package/dist/commands/project/list.js +0 -43
- package/dist/commands/verify.d.ts +0 -6
- package/dist/commands/verify.js +0 -62
- package/dist/utils/http.d.ts +0 -4
- package/dist/utils/http.js +0 -4
- package/dist/utils/shared.d.ts +0 -10
- package/dist/utils/shared.js +0 -55
- package/dist/utils/slug.d.ts +0 -1
- package/dist/utils/slug.js +0 -12
- package/dist/utils/slugify.d.ts +0 -3
- package/dist/utils/slugify.js +0 -2
- package/dist/utils/utils.d.ts +0 -6
- package/dist/utils/utils.js +0 -26
- package/oclif.manifest.json +0 -1680
package/LICENSE.md
CHANGED
package/dist/client.d.ts
ADDED
|
@@ -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,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
|
+
}
|