@dokploy/cli 0.2.3

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 (77) hide show
  1. package/README.md +112 -0
  2. package/bin/dev.cmd +3 -0
  3. package/bin/dev.js +6 -0
  4. package/bin/run.cmd +3 -0
  5. package/bin/run.js +5 -0
  6. package/dist/commands/app/create.d.ts +13 -0
  7. package/dist/commands/app/create.js +77 -0
  8. package/dist/commands/app/delete.d.ts +9 -0
  9. package/dist/commands/app/delete.js +84 -0
  10. package/dist/commands/app/deploy.d.ts +6 -0
  11. package/dist/commands/app/deploy.js +69 -0
  12. package/dist/commands/app/stop.d.ts +6 -0
  13. package/dist/commands/app/stop.js +69 -0
  14. package/dist/commands/authenticate.d.ts +10 -0
  15. package/dist/commands/authenticate.js +79 -0
  16. package/dist/commands/database/mariadb/create.d.ts +9 -0
  17. package/dist/commands/database/mariadb/create.js +105 -0
  18. package/dist/commands/database/mariadb/delete.d.ts +9 -0
  19. package/dist/commands/database/mariadb/delete.js +95 -0
  20. package/dist/commands/database/mariadb/deploy.d.ts +6 -0
  21. package/dist/commands/database/mariadb/deploy.js +69 -0
  22. package/dist/commands/database/mariadb/stop.d.ts +6 -0
  23. package/dist/commands/database/mariadb/stop.js +69 -0
  24. package/dist/commands/database/mongo/create.d.ts +9 -0
  25. package/dist/commands/database/mongo/create.js +107 -0
  26. package/dist/commands/database/mongo/delete.d.ts +9 -0
  27. package/dist/commands/database/mongo/delete.js +95 -0
  28. package/dist/commands/database/mongo/deploy.d.ts +6 -0
  29. package/dist/commands/database/mongo/deploy.js +69 -0
  30. package/dist/commands/database/mongo/stop.d.ts +6 -0
  31. package/dist/commands/database/mongo/stop.js +69 -0
  32. package/dist/commands/database/mysql/create.d.ts +9 -0
  33. package/dist/commands/database/mysql/create.js +112 -0
  34. package/dist/commands/database/mysql/delete.d.ts +9 -0
  35. package/dist/commands/database/mysql/delete.js +97 -0
  36. package/dist/commands/database/mysql/deploy.d.ts +6 -0
  37. package/dist/commands/database/mysql/deploy.js +69 -0
  38. package/dist/commands/database/mysql/stop.d.ts +6 -0
  39. package/dist/commands/database/mysql/stop.js +69 -0
  40. package/dist/commands/database/postgres/create.d.ts +9 -0
  41. package/dist/commands/database/postgres/create.js +107 -0
  42. package/dist/commands/database/postgres/delete.d.ts +9 -0
  43. package/dist/commands/database/postgres/delete.js +94 -0
  44. package/dist/commands/database/postgres/deploy.d.ts +6 -0
  45. package/dist/commands/database/postgres/deploy.js +69 -0
  46. package/dist/commands/database/postgres/stop.d.ts +6 -0
  47. package/dist/commands/database/postgres/stop.js +69 -0
  48. package/dist/commands/database/redis/create.d.ts +9 -0
  49. package/dist/commands/database/redis/create.js +95 -0
  50. package/dist/commands/database/redis/delete.d.ts +9 -0
  51. package/dist/commands/database/redis/delete.js +96 -0
  52. package/dist/commands/database/redis/deploy.d.ts +6 -0
  53. package/dist/commands/database/redis/deploy.js +69 -0
  54. package/dist/commands/database/redis/stop.d.ts +6 -0
  55. package/dist/commands/database/redis/stop.js +69 -0
  56. package/dist/commands/project/create.d.ts +10 -0
  57. package/dist/commands/project/create.js +74 -0
  58. package/dist/commands/project/info.d.ts +10 -0
  59. package/dist/commands/project/info.js +122 -0
  60. package/dist/commands/project/list.d.ts +6 -0
  61. package/dist/commands/project/list.js +43 -0
  62. package/dist/commands/verify.d.ts +6 -0
  63. package/dist/commands/verify.js +45 -0
  64. package/dist/index.d.ts +1 -0
  65. package/dist/index.js +1 -0
  66. package/dist/utils/http.d.ts +4 -0
  67. package/dist/utils/http.js +4 -0
  68. package/dist/utils/shared.d.ts +10 -0
  69. package/dist/utils/shared.js +55 -0
  70. package/dist/utils/slug.d.ts +1 -0
  71. package/dist/utils/slug.js +12 -0
  72. package/dist/utils/slugify.d.ts +3 -0
  73. package/dist/utils/slugify.js +2 -0
  74. package/dist/utils/utils.d.ts +6 -0
  75. package/dist/utils/utils.js +19 -0
  76. package/oclif.manifest.json +895 -0
  77. package/package.json +87 -0
package/README.md ADDED
@@ -0,0 +1,112 @@
1
+ # Dokploy CLI
2
+
3
+ <!-- ![Dokploy Logo](https://via.placeholder.com/150x150.png?text=Dokploy+CLI) -->
4
+
5
+ Dokploy CLI is a powerful and versatile command-line tool designed to remotely manage your Dokploy server. It simplifies the process of creating, deploying, and managing applications and databases.
6
+
7
+ <!-- [![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
8
+ [![Version](https://img.shields.io/npm/v/dokploy.svg)](https://npmjs.org/package/dokploy)
9
+ [![Downloads/week](https://img.shields.io/npm/dw/dokploy.svg)](https://npmjs.org/package/dokploy)
10
+ [![License](https://img.shields.io/npm/l/dokploy.svg)](https://github.com/yourusername/dokploy/blob/master/package.json) -->
11
+
12
+ ## Table of Contents
13
+
14
+ - [Installation](#installation)
15
+ - [Usage](#usage)
16
+ - [Commands](#commands)
17
+ - [Authentication](#authentication)
18
+ - [Project Management](#project-management)
19
+ - [Application Management](#application-management)
20
+ - [Database Management](#database-management)
21
+ - [Contributing](#contributing)
22
+ - [Support](#support)
23
+ - [License](#license)
24
+
25
+ ## Installation
26
+
27
+ ```sh-session
28
+ $ npm install -g dokploy
29
+ ```
30
+
31
+ ## Usage
32
+
33
+ ```sh-session
34
+ $ dokploy COMMAND
35
+ running command...
36
+
37
+ $ dokploy --version
38
+ dokploy/0.0.0 darwin-arm64 node-v18.18.0
39
+
40
+ $ dokploy --help [COMMAND]
41
+ USAGE
42
+ $ dokploy COMMAND
43
+ ...
44
+ ```
45
+
46
+ ## Commands
47
+
48
+ ### Authentication
49
+
50
+ - `dokploy authenticate`: Authenticate with the Dokploy server.
51
+ - `dokploy verify`: Verify current authentication.
52
+
53
+ ### Project Management
54
+
55
+ - `dokploy project:create`: Create a new project.
56
+ - `dokploy project:info`: Get information about an existing project.
57
+ - `dokploy project:list`: List all projects.
58
+
59
+ ### Application Management
60
+
61
+ - `dokploy app:create`: Create a new application.
62
+ - `dokploy app:delete`: Delete an existing application.
63
+ - `dokploy app:deploy`: Deploy an application.
64
+ - `dokploy app:stop`: Stop a running application.
65
+
66
+ ### Database Management
67
+
68
+ Dokploy supports various types of databases:
69
+
70
+ #### MariaDB
71
+ - `dokploy database:mariadb:create`
72
+ - `dokploy database:mariadb:delete`
73
+ - `dokploy database:mariadb:deploy`
74
+ - `dokploy database:mariadb:stop`
75
+
76
+ #### MongoDB
77
+ - `dokploy database:mongo:create`
78
+ - `dokploy database:mongo:delete`
79
+ - `dokploy database:mongo:deploy`
80
+ - `dokploy database:mongo:stop`
81
+
82
+ #### MySQL
83
+ - `dokploy database:mysql:create`
84
+ - `dokploy database:mysql:delete`
85
+ - `dokploy database:mysql:deploy`
86
+ - `dokploy database:mysql:stop`
87
+
88
+ #### PostgreSQL
89
+ - `dokploy database:postgres:create`
90
+ - `dokploy database:postgres:delete`
91
+ - `dokploy database:postgres:deploy`
92
+ - `dokploy database:postgres:stop`
93
+
94
+ #### Redis
95
+ - `dokploy database:redis:create`
96
+ - `dokploy database:redis:delete`
97
+ - `dokploy database:redis:deploy`
98
+ - `dokploy database:redis:stop`
99
+
100
+ For more information about a specific command, use:
101
+
102
+ ```sh-session
103
+ $ dokploy [COMMAND] --help
104
+ ```
105
+
106
+ ## Support
107
+
108
+ If you encounter any issues or have any questions, please [open an issue](https://github.com/yourusername/dokploy/issues) in our GitHub repository.
109
+
110
+ ## License
111
+
112
+ This project is licensed under the [MIT License](LICENSE).
package/bin/dev.cmd ADDED
@@ -0,0 +1,3 @@
1
+ @echo off
2
+
3
+ node --loader ts-node/esm --no-warnings=ExperimentalWarning "%~dp0\dev" %*
package/bin/dev.js ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env -S node --loader ts-node/esm --no-warnings=ExperimentalWarning
2
+
3
+ // eslint-disable-next-line n/shebang
4
+ import {execute} from '@oclif/core'
5
+
6
+ await execute({development: true, dir: import.meta.url})
package/bin/run.cmd ADDED
@@ -0,0 +1,3 @@
1
+ @echo off
2
+
3
+ node "%~dp0\run" %*
package/bin/run.js ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import {execute} from '@oclif/core'
4
+
5
+ await execute({dir: import.meta.url})
@@ -0,0 +1,13 @@
1
+ import { Command } from "@oclif/core";
2
+ import { type Project } from "../../utils/shared.js";
3
+ export interface Answers {
4
+ project: Project;
5
+ }
6
+ export default class AppCreate extends Command {
7
+ static description: string;
8
+ static examples: string[];
9
+ static flags: {
10
+ projectId: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
11
+ };
12
+ run(): Promise<void>;
13
+ }
@@ -0,0 +1,77 @@
1
+ import { Command, Flags } from "@oclif/core";
2
+ import axios from "axios";
3
+ import chalk from "chalk";
4
+ import inquirer from "inquirer";
5
+ import { getProjects } from "../../utils/shared.js";
6
+ import { slugify } from "../../utils/slug.js";
7
+ import { readAuthConfig } from "../../utils/utils.js";
8
+ export default class AppCreate extends Command {
9
+ static description = "Create a new application within a project.";
10
+ static examples = ["$ <%= config.bin %> app create"];
11
+ static flags = {
12
+ projectId: Flags.string({
13
+ char: "p",
14
+ description: "ID of the project",
15
+ required: false,
16
+ }),
17
+ };
18
+ async run() {
19
+ const auth = await readAuthConfig(this);
20
+ const { flags } = await this.parse(AppCreate);
21
+ let { projectId } = flags;
22
+ if (!projectId) {
23
+ console.log(chalk.blue.bold("\n Listing all Projects \n"));
24
+ const projects = await getProjects(auth, this);
25
+ const { project } = await inquirer.prompt([
26
+ {
27
+ choices: projects.map((project) => ({
28
+ name: project.name,
29
+ value: project,
30
+ })),
31
+ message: "Select a project to create the application in:",
32
+ name: "project",
33
+ type: "list",
34
+ },
35
+ ]);
36
+ projectId = project.projectId;
37
+ const appDetails = await inquirer.prompt([
38
+ {
39
+ message: "Enter the application name:",
40
+ name: "name",
41
+ type: "input",
42
+ validate: (input) => (input ? true : "Application name is required"),
43
+ },
44
+ {
45
+ message: "Enter the application description (optional):",
46
+ name: "appDescription",
47
+ type: "input",
48
+ },
49
+ ]);
50
+ const appName = await inquirer.prompt([
51
+ {
52
+ default: `${slugify(project.name)}-${appDetails.name}`,
53
+ message: "Enter the App name: (optional):",
54
+ name: "appName",
55
+ type: "input",
56
+ validate: (input) => (input ? true : "App name is required"),
57
+ },
58
+ ]);
59
+ const response = await axios.post(`${auth.url}/api/trpc/application.create`, {
60
+ json: {
61
+ ...appDetails,
62
+ appName: appName.appName,
63
+ projectId: project.projectId,
64
+ },
65
+ }, {
66
+ headers: {
67
+ Authorization: `Bearer ${auth.token}`,
68
+ "Content-Type": "application/json",
69
+ },
70
+ });
71
+ if (response.status !== 200) {
72
+ this.error(chalk.red("Error creating application"));
73
+ }
74
+ this.log(chalk.green(`Application '${appDetails.name}' created successfully.`));
75
+ }
76
+ }
77
+ }
@@ -0,0 +1,9 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class AppDelete extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ projectId: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
7
+ };
8
+ run(): Promise<void>;
9
+ }
@@ -0,0 +1,84 @@
1
+ import { Command, Flags } from "@oclif/core";
2
+ import axios from "axios";
3
+ import chalk from "chalk";
4
+ import inquirer from "inquirer";
5
+ import { getProject, getProjects } from "../../utils/shared.js";
6
+ import { readAuthConfig } from "../../utils/utils.js";
7
+ export default class AppDelete extends Command {
8
+ static description = "Delete an application from a project.";
9
+ static examples = [
10
+ "$ <%= config.bin %> app delete",
11
+ "$ <%= config.bin %> app delete -p <projectId>",
12
+ ];
13
+ static flags = {
14
+ projectId: Flags.string({
15
+ char: "p",
16
+ description: "ID of the project",
17
+ required: false,
18
+ }),
19
+ };
20
+ async run() {
21
+ const auth = await readAuthConfig(this);
22
+ const { flags } = await this.parse(AppDelete);
23
+ let { projectId } = flags;
24
+ if (!projectId) {
25
+ console.log(chalk.blue.bold("\n Listing all Projects \n"));
26
+ const projects = await getProjects(auth, this);
27
+ const { project } = await inquirer.prompt([
28
+ {
29
+ choices: projects.map((project) => ({
30
+ name: project.name,
31
+ value: project,
32
+ })),
33
+ message: "Select a project to create the application in:",
34
+ name: "project",
35
+ type: "list",
36
+ },
37
+ ]);
38
+ projectId = project.projectId;
39
+ const projectSelected = await getProject(projectId, auth, this);
40
+ if (projectSelected.applications.length === 0) {
41
+ this.error(chalk.yellow("No applications found in this project."));
42
+ }
43
+ const appAnswers = await inquirer.prompt([
44
+ {
45
+ // @ts-ignore
46
+ choices: projectSelected.applications.map((app) => ({
47
+ name: app.name,
48
+ value: app.applicationId,
49
+ })),
50
+ message: "Select the application to delete:",
51
+ name: "selectedApp",
52
+ type: "list",
53
+ },
54
+ ]);
55
+ const applicationId = appAnswers.selectedApp;
56
+ // // Confirmar eliminación
57
+ const confirmAnswers = await inquirer.prompt([
58
+ {
59
+ default: false,
60
+ message: "Are you sure you want to delete this application?",
61
+ name: "confirmDelete",
62
+ type: "confirm",
63
+ },
64
+ ]);
65
+ if (!confirmAnswers.confirmDelete) {
66
+ this.error(chalk.yellow("Application deletion cancelled."));
67
+ }
68
+ const deleteResponse = await axios.post(`${auth.url}/api/trpc/application.delete`, {
69
+ json: {
70
+ applicationId,
71
+ },
72
+ }, {
73
+ headers: {
74
+ Authorization: `Bearer ${auth.token}`,
75
+ "Content-Type": "application/json",
76
+ },
77
+ });
78
+ if (!deleteResponse.data.result.data.json) {
79
+ this.error(chalk.red("Error deleting application"));
80
+ }
81
+ this.log(chalk.green("Application deleted successfully."));
82
+ }
83
+ }
84
+ }
@@ -0,0 +1,6 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class AppDeploy extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ run(): Promise<void>;
6
+ }
@@ -0,0 +1,69 @@
1
+ import { Command } from "@oclif/core";
2
+ import { readAuthConfig } from "../../utils/utils.js";
3
+ import chalk from "chalk";
4
+ import { getProject, getProjects } from "../../utils/shared.js";
5
+ import inquirer from "inquirer";
6
+ import axios from "axios";
7
+ export default class AppDeploy extends Command {
8
+ static description = "Deploy an application to a project.";
9
+ static examples = ["$ <%= config.bin %> app deploy"];
10
+ async run() {
11
+ const auth = await readAuthConfig(this);
12
+ console.log(chalk.blue.bold("\n Listing all Projects \n"));
13
+ const projects = await getProjects(auth, this);
14
+ const { project } = await inquirer.prompt([
15
+ {
16
+ choices: projects.map((project) => ({
17
+ name: project.name,
18
+ value: project,
19
+ })),
20
+ message: "Select a project to deploy the application in:",
21
+ name: "project",
22
+ type: "list",
23
+ },
24
+ ]);
25
+ const projectId = project.projectId;
26
+ const projectSelected = await getProject(projectId, auth, this);
27
+ if (projectSelected.applications.length === 0) {
28
+ this.error(chalk.yellow("No applications found in this project."));
29
+ }
30
+ const appAnswers = await inquirer.prompt([
31
+ {
32
+ // @ts-ignore
33
+ choices: projectSelected.applications.map((app) => ({
34
+ name: app.name,
35
+ value: app.applicationId,
36
+ })),
37
+ message: "Select the application to deploy:",
38
+ name: "selectedApp",
39
+ type: "list",
40
+ },
41
+ ]);
42
+ const applicationId = appAnswers.selectedApp;
43
+ const confirmAnswers = await inquirer.prompt([
44
+ {
45
+ default: false,
46
+ message: "Are you sure you want to deploy this application?",
47
+ name: "confirmDelete",
48
+ type: "confirm",
49
+ },
50
+ ]);
51
+ if (!confirmAnswers.confirmDelete) {
52
+ this.error(chalk.yellow("Application deployment cancelled."));
53
+ }
54
+ const response = await axios.post(`${auth.url}/api/trpc/application.deploy`, {
55
+ json: {
56
+ applicationId,
57
+ },
58
+ }, {
59
+ headers: {
60
+ Authorization: `Bearer ${auth.token}`,
61
+ "Content-Type": "application/json",
62
+ },
63
+ });
64
+ if (response.status !== 200) {
65
+ this.error(chalk.red("Error deploying application"));
66
+ }
67
+ this.log(chalk.green("Application deploy successful."));
68
+ }
69
+ }
@@ -0,0 +1,6 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class AppStop extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ run(): Promise<void>;
6
+ }
@@ -0,0 +1,69 @@
1
+ import { Command } from "@oclif/core";
2
+ import { readAuthConfig } from "../../utils/utils.js";
3
+ import chalk from "chalk";
4
+ import inquirer from "inquirer";
5
+ import { getProject, getProjects } from "../../utils/shared.js";
6
+ import axios from "axios";
7
+ export default class AppStop extends Command {
8
+ static description = "Stop an application from a project.";
9
+ static examples = ["$ <%= config.bin %> app stop"];
10
+ async run() {
11
+ const auth = await readAuthConfig(this);
12
+ console.log(chalk.blue.bold("\n Listing all Projects \n"));
13
+ const projects = await getProjects(auth, this);
14
+ const { project } = await inquirer.prompt([
15
+ {
16
+ choices: projects.map((project) => ({
17
+ name: project.name,
18
+ value: project,
19
+ })),
20
+ message: "Select a project to stop the application in:",
21
+ name: "project",
22
+ type: "list",
23
+ },
24
+ ]);
25
+ const projectId = project.projectId;
26
+ const projectSelected = await getProject(projectId, auth, this);
27
+ if (projectSelected.applications.length === 0) {
28
+ this.error(chalk.yellow("No applications found in this project."));
29
+ }
30
+ const appAnswers = await inquirer.prompt([
31
+ {
32
+ // @ts-ignore
33
+ choices: projectSelected.applications.map((app) => ({
34
+ name: app.name,
35
+ value: app.applicationId,
36
+ })),
37
+ message: "Select the application to stop:",
38
+ name: "selectedApp",
39
+ type: "list",
40
+ },
41
+ ]);
42
+ const applicationId = appAnswers.selectedApp;
43
+ const confirmAnswers = await inquirer.prompt([
44
+ {
45
+ default: false,
46
+ message: "Are you sure you want to stop this application?",
47
+ name: "confirmDelete",
48
+ type: "confirm",
49
+ },
50
+ ]);
51
+ if (!confirmAnswers.confirmDelete) {
52
+ this.error(chalk.yellow("Application stop cancelled."));
53
+ }
54
+ const response = await axios.post(`${auth.url}/api/trpc/application.stop`, {
55
+ json: {
56
+ applicationId,
57
+ },
58
+ }, {
59
+ headers: {
60
+ Authorization: `Bearer ${auth.token}`,
61
+ "Content-Type": "application/json",
62
+ },
63
+ });
64
+ if (response.status !== 200) {
65
+ this.error(chalk.red("Error stopping application"));
66
+ }
67
+ this.log(chalk.green("Application stop successful."));
68
+ }
69
+ }
@@ -0,0 +1,10 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class Authenticate extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ token: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
7
+ url: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
8
+ };
9
+ run(): Promise<void>;
10
+ }
@@ -0,0 +1,79 @@
1
+ import { Command, Flags } from "@oclif/core";
2
+ import axios from "axios";
3
+ import chalk from "chalk";
4
+ import inquirer from "inquirer";
5
+ import * as fs from "node:fs";
6
+ import * as path from "node:path";
7
+ import { fileURLToPath } from "node:url";
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = path.dirname(__filename);
10
+ const configPath = path.join(__dirname, "..", "..", "config.json");
11
+ export default class Authenticate extends Command {
12
+ static description = "Authenticate the user by saving server URL and token";
13
+ static examples = [
14
+ "$ <%= config.bin %> <%= command.id %> --url=https://panel.dokploy.com --token=MRTHGZDGMRZWM43EMZSHGZTTMRTHGZDGONSGMZDTMY",
15
+ "$ <%= config.bin %> <%= command.id %> -u https://panel.dokploy.com -t MRTHGZDGMRZWM43EMZSHGZTTMRTHGZDGONSGMZDTMY",
16
+ ];
17
+ static flags = {
18
+ token: Flags.string({
19
+ char: "t",
20
+ description: "Authentication token",
21
+ }),
22
+ url: Flags.string({
23
+ char: "u",
24
+ description: "Server URL",
25
+ }),
26
+ };
27
+ async run() {
28
+ console.log(chalk.blue.bold("\n Welcome to Dokploy CLI Authentication \n"));
29
+ const { flags } = await this.parse(Authenticate);
30
+ let answers = {};
31
+ const questions = [];
32
+ let config = {};
33
+ if (fs.existsSync(configPath)) {
34
+ const configFileContent = fs.readFileSync(configPath, "utf8");
35
+ config = JSON.parse(configFileContent);
36
+ }
37
+ if (!flags.url) {
38
+ questions.push({
39
+ default: config.url,
40
+ message: chalk.green("Enter your server URL (e.g., https://panel.dokploy.com): "),
41
+ name: "url",
42
+ type: "input",
43
+ validate: (input) => (input ? true : "Server URL is required"),
44
+ });
45
+ }
46
+ if (!flags.token) {
47
+ questions.push({
48
+ default: config.token,
49
+ message: chalk.green("Enter your authentication token (e.g., MRTHGZDGMRZWM43EMZSHGZTTMRTHGZDGONSGMZDTMY=): "),
50
+ name: "token",
51
+ type: "input",
52
+ validate: (input) => input ? true : "Authentication token is required",
53
+ });
54
+ }
55
+ if (questions.length > 0) {
56
+ answers = await inquirer.prompt(questions);
57
+ }
58
+ const url = flags.url || answers.url;
59
+ const token = flags.token || answers.token;
60
+ config.token = token;
61
+ config.url = url;
62
+ try {
63
+ console.log(`\n${chalk.blue("Validating server...")}`);
64
+ await axios.post(`${url}/api/trpc/auth.verifyToken`, {}, {
65
+ headers: {
66
+ Authorization: `Bearer ${token}`,
67
+ "Content-Type": "application/json",
68
+ },
69
+ });
70
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
71
+ this.log(chalk.green("Authentication details saved successfully."));
72
+ }
73
+ catch (error) {
74
+ this.error(
75
+ // @ts-expect-error - Type
76
+ chalk.red(`Failed to save authentication details: ${error.message}`));
77
+ }
78
+ }
79
+ }
@@ -0,0 +1,9 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class DatabaseMariadbCreate extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ projectId: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
7
+ };
8
+ run(): Promise<void>;
9
+ }