@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
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { Command, Flags } 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 = [
|
|
10
|
-
"$ <%= config.bin %> app deploy",
|
|
11
|
-
"$ <%= config.bin %> app deploy --applicationId myAppId",
|
|
12
|
-
"$ DOKPLOY_URL=xxx DOKPLOY_AUTH_TOKEN=xxx <%= config.bin %> app deploy --applicationId myAppId"
|
|
13
|
-
];
|
|
14
|
-
static flags = {
|
|
15
|
-
applicationId: Flags.string({
|
|
16
|
-
char: 'a',
|
|
17
|
-
description: 'ID of the application to deploy',
|
|
18
|
-
required: false,
|
|
19
|
-
}),
|
|
20
|
-
projectId: Flags.string({
|
|
21
|
-
char: 'p',
|
|
22
|
-
description: 'ID of the project',
|
|
23
|
-
required: false,
|
|
24
|
-
}),
|
|
25
|
-
skipConfirm: Flags.boolean({
|
|
26
|
-
char: 'y',
|
|
27
|
-
description: 'Skip confirmation prompt',
|
|
28
|
-
default: false,
|
|
29
|
-
})
|
|
30
|
-
};
|
|
31
|
-
async run() {
|
|
32
|
-
const auth = await readAuthConfig(this);
|
|
33
|
-
const { flags } = await this.parse(AppDeploy);
|
|
34
|
-
let { projectId, applicationId } = flags;
|
|
35
|
-
// Modo interactivo si no se proporcionan los flags necesarios
|
|
36
|
-
if (!projectId || !applicationId) {
|
|
37
|
-
console.log(chalk.blue.bold("\n Listing all Projects \n"));
|
|
38
|
-
const projects = await getProjects(auth, this);
|
|
39
|
-
if (!projectId) {
|
|
40
|
-
const { project } = await inquirer.prompt([
|
|
41
|
-
{
|
|
42
|
-
choices: projects.map((project) => ({
|
|
43
|
-
name: project.name,
|
|
44
|
-
value: project,
|
|
45
|
-
})),
|
|
46
|
-
message: "Select a project to deploy the application from:",
|
|
47
|
-
name: "project",
|
|
48
|
-
type: "list",
|
|
49
|
-
},
|
|
50
|
-
]);
|
|
51
|
-
projectId = project.projectId;
|
|
52
|
-
}
|
|
53
|
-
const projectSelected = await getProject(projectId, auth, this);
|
|
54
|
-
if (projectSelected.applications.length === 0) {
|
|
55
|
-
this.error(chalk.yellow("No applications found in this project."));
|
|
56
|
-
}
|
|
57
|
-
if (!applicationId) {
|
|
58
|
-
const appAnswers = await inquirer.prompt([
|
|
59
|
-
{
|
|
60
|
-
// @ts-ignore
|
|
61
|
-
choices: projectSelected.applications.map((app) => ({
|
|
62
|
-
name: app.name,
|
|
63
|
-
value: app.applicationId,
|
|
64
|
-
})),
|
|
65
|
-
message: "Select the application to deploy:",
|
|
66
|
-
name: "selectedApp",
|
|
67
|
-
type: "list",
|
|
68
|
-
},
|
|
69
|
-
]);
|
|
70
|
-
applicationId = appAnswers.selectedApp;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
// Confirmar si no se especifica --skipConfirm
|
|
74
|
-
if (!flags.skipConfirm) {
|
|
75
|
-
const confirmAnswers = await inquirer.prompt([
|
|
76
|
-
{
|
|
77
|
-
default: false,
|
|
78
|
-
message: "Are you sure you want to deploy this application?",
|
|
79
|
-
name: "confirmDelete",
|
|
80
|
-
type: "confirm",
|
|
81
|
-
},
|
|
82
|
-
]);
|
|
83
|
-
if (!confirmAnswers.confirmDelete) {
|
|
84
|
-
this.error(chalk.yellow("Application deployment cancelled."));
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
try {
|
|
88
|
-
const response = await axios.post(`${auth.url}/api/trpc/application.deploy`, {
|
|
89
|
-
json: {
|
|
90
|
-
applicationId,
|
|
91
|
-
},
|
|
92
|
-
}, {
|
|
93
|
-
headers: {
|
|
94
|
-
"x-api-key": auth.token,
|
|
95
|
-
"Content-Type": "application/json",
|
|
96
|
-
},
|
|
97
|
-
});
|
|
98
|
-
if (response.status !== 200) {
|
|
99
|
-
this.error(chalk.red("Error deploying application"));
|
|
100
|
-
}
|
|
101
|
-
this.log(chalk.green("Application deploy successful."));
|
|
102
|
-
}
|
|
103
|
-
catch (error) {
|
|
104
|
-
this.error(chalk.red(`Error deploying application: ${error.message}`));
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Command } from "@oclif/core";
|
|
2
|
-
export default class AppStop 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
|
-
applicationId: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
8
|
-
skipConfirm: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
9
|
-
};
|
|
10
|
-
run(): Promise<void>;
|
|
11
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { Command, Flags } 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
|
-
static flags = {
|
|
11
|
-
projectId: Flags.string({
|
|
12
|
-
char: 'p',
|
|
13
|
-
description: 'ID of the project',
|
|
14
|
-
required: false,
|
|
15
|
-
}),
|
|
16
|
-
applicationId: Flags.string({
|
|
17
|
-
char: 'a',
|
|
18
|
-
description: 'ID of the application to stop',
|
|
19
|
-
required: false,
|
|
20
|
-
}),
|
|
21
|
-
skipConfirm: Flags.boolean({
|
|
22
|
-
char: 'y',
|
|
23
|
-
description: 'Skip confirmation prompt',
|
|
24
|
-
default: false,
|
|
25
|
-
})
|
|
26
|
-
};
|
|
27
|
-
async run() {
|
|
28
|
-
const auth = await readAuthConfig(this);
|
|
29
|
-
const { flags } = await this.parse(AppStop);
|
|
30
|
-
let { projectId, applicationId } = flags;
|
|
31
|
-
// Modo interactivo si no se proporcionan los flags necesarios
|
|
32
|
-
if (!projectId || !applicationId) {
|
|
33
|
-
console.log(chalk.blue.bold("\n Listing all Projects \n"));
|
|
34
|
-
const projects = await getProjects(auth, this);
|
|
35
|
-
if (!projectId) {
|
|
36
|
-
const { project } = await inquirer.prompt([
|
|
37
|
-
{
|
|
38
|
-
choices: projects.map((project) => ({
|
|
39
|
-
name: project.name,
|
|
40
|
-
value: project,
|
|
41
|
-
})),
|
|
42
|
-
message: "Select a project to stop the application from:",
|
|
43
|
-
name: "project",
|
|
44
|
-
type: "list",
|
|
45
|
-
},
|
|
46
|
-
]);
|
|
47
|
-
projectId = project.projectId;
|
|
48
|
-
}
|
|
49
|
-
const projectSelected = await getProject(projectId, auth, this);
|
|
50
|
-
if (projectSelected.applications.length === 0) {
|
|
51
|
-
this.error(chalk.yellow("No applications found in this project."));
|
|
52
|
-
}
|
|
53
|
-
if (!applicationId) {
|
|
54
|
-
const appAnswers = await inquirer.prompt([
|
|
55
|
-
{
|
|
56
|
-
choices: projectSelected.applications.map((app) => ({
|
|
57
|
-
name: app.name,
|
|
58
|
-
value: app.applicationId,
|
|
59
|
-
})),
|
|
60
|
-
message: "Select the application to stop:",
|
|
61
|
-
name: "selectedApp",
|
|
62
|
-
type: "list",
|
|
63
|
-
},
|
|
64
|
-
]);
|
|
65
|
-
applicationId = appAnswers.selectedApp;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
// Confirmar si no se especifica --skipConfirm
|
|
69
|
-
if (!flags.skipConfirm) {
|
|
70
|
-
const confirmAnswers = await inquirer.prompt([
|
|
71
|
-
{
|
|
72
|
-
default: false,
|
|
73
|
-
message: "Are you sure you want to stop this application?",
|
|
74
|
-
name: "confirmDelete",
|
|
75
|
-
type: "confirm",
|
|
76
|
-
},
|
|
77
|
-
]);
|
|
78
|
-
if (!confirmAnswers.confirmDelete) {
|
|
79
|
-
this.error(chalk.yellow("Application stop cancelled."));
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
try {
|
|
83
|
-
const response = await axios.post(`${auth.url}/api/trpc/application.stop`, {
|
|
84
|
-
json: {
|
|
85
|
-
applicationId,
|
|
86
|
-
},
|
|
87
|
-
}, {
|
|
88
|
-
headers: {
|
|
89
|
-
"x-api-key": auth.token,
|
|
90
|
-
"Content-Type": "application/json",
|
|
91
|
-
},
|
|
92
|
-
});
|
|
93
|
-
if (response.status !== 200) {
|
|
94
|
-
this.error(chalk.red("Error stopping application"));
|
|
95
|
-
}
|
|
96
|
-
this.log(chalk.green("Application stop successful."));
|
|
97
|
-
}
|
|
98
|
-
catch (error) {
|
|
99
|
-
this.error(chalk.red(`Error stopping application: ${error.message}`));
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
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.get(`${url}/api/trpc/user.get`, {
|
|
65
|
-
headers: {
|
|
66
|
-
"x-api-key": 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
|
-
}
|
|
80
|
-
// curl -X 'GET' \
|
|
81
|
-
// 'https://panel.jinza.app/api/project.all' \
|
|
82
|
-
// -H 'accept: application/json' \
|
|
83
|
-
// -H 'x-api-key: EawCkTREMhxoAqvCxJFZurgCGoDZPjYHHrLgUPghRjJTpXLaahFdhCOGfABZXTRP'
|
|
@@ -1,18 +0,0 @@
|
|
|
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
|
-
name: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
8
|
-
databaseName: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
9
|
-
description: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
10
|
-
databaseRootPassword: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
11
|
-
databasePassword: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
12
|
-
databaseUser: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
13
|
-
dockerImage: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
14
|
-
skipConfirm: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
15
|
-
appName: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
16
|
-
};
|
|
17
|
-
run(): Promise<void>;
|
|
18
|
-
}
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import { Command, Flags } from "@oclif/core";
|
|
2
|
-
import axios from "axios";
|
|
3
|
-
import chalk from "chalk";
|
|
4
|
-
import inquirer from "inquirer";
|
|
5
|
-
import { readAuthConfig } from "../../../utils/utils.js";
|
|
6
|
-
import { getProjects } from "../../../utils/shared.js";
|
|
7
|
-
import { slugify } from "../../../utils/slug.js";
|
|
8
|
-
export default class DatabaseMariadbCreate extends Command {
|
|
9
|
-
static description = "Create a new MariaDB database within a project.";
|
|
10
|
-
static examples = ["$ <%= config.bin %> mariadb create"];
|
|
11
|
-
static flags = {
|
|
12
|
-
projectId: Flags.string({
|
|
13
|
-
char: "p",
|
|
14
|
-
description: "ID of the project",
|
|
15
|
-
required: false,
|
|
16
|
-
}),
|
|
17
|
-
name: Flags.string({
|
|
18
|
-
char: "n",
|
|
19
|
-
description: "Database name",
|
|
20
|
-
required: false,
|
|
21
|
-
}),
|
|
22
|
-
databaseName: Flags.string({
|
|
23
|
-
description: "MariaDB database name",
|
|
24
|
-
required: false,
|
|
25
|
-
}),
|
|
26
|
-
description: Flags.string({
|
|
27
|
-
char: "d",
|
|
28
|
-
description: "Database description",
|
|
29
|
-
required: false,
|
|
30
|
-
}),
|
|
31
|
-
databaseRootPassword: Flags.string({
|
|
32
|
-
description: "Database root password",
|
|
33
|
-
required: false,
|
|
34
|
-
}),
|
|
35
|
-
databasePassword: Flags.string({
|
|
36
|
-
description: "Database password",
|
|
37
|
-
required: false,
|
|
38
|
-
}),
|
|
39
|
-
databaseUser: Flags.string({
|
|
40
|
-
description: "Database user",
|
|
41
|
-
default: "mariadb",
|
|
42
|
-
}),
|
|
43
|
-
dockerImage: Flags.string({
|
|
44
|
-
description: "Docker image",
|
|
45
|
-
default: "mariadb:11",
|
|
46
|
-
}),
|
|
47
|
-
skipConfirm: Flags.boolean({
|
|
48
|
-
char: "y",
|
|
49
|
-
description: "Skip confirmation prompt",
|
|
50
|
-
default: false,
|
|
51
|
-
}),
|
|
52
|
-
appName: Flags.string({
|
|
53
|
-
description: "App name",
|
|
54
|
-
required: false,
|
|
55
|
-
}),
|
|
56
|
-
};
|
|
57
|
-
async run() {
|
|
58
|
-
const auth = await readAuthConfig(this);
|
|
59
|
-
const { flags } = await this.parse(DatabaseMariadbCreate);
|
|
60
|
-
let { projectId, name, databaseName, description, databaseRootPassword, databasePassword, databaseUser, dockerImage, appName } = flags;
|
|
61
|
-
// Modo interactivo si no se proporcionan los flags necesarios
|
|
62
|
-
if (!projectId || !name || !databaseName || !appName) {
|
|
63
|
-
console.log(chalk.blue.bold("\n Listing all Projects \n"));
|
|
64
|
-
const projects = await getProjects(auth, this);
|
|
65
|
-
if (!projectId) {
|
|
66
|
-
const { project } = await inquirer.prompt([
|
|
67
|
-
{
|
|
68
|
-
choices: projects.map((project) => ({
|
|
69
|
-
name: project.name,
|
|
70
|
-
value: project,
|
|
71
|
-
})),
|
|
72
|
-
message: "Select a project to create the MariaDB instance in:",
|
|
73
|
-
name: "project",
|
|
74
|
-
type: "list",
|
|
75
|
-
},
|
|
76
|
-
]);
|
|
77
|
-
projectId = project.projectId;
|
|
78
|
-
}
|
|
79
|
-
if (!name || !databaseName || !appName) {
|
|
80
|
-
const dbDetails = await inquirer.prompt([
|
|
81
|
-
{
|
|
82
|
-
message: "Enter the name:",
|
|
83
|
-
name: "name",
|
|
84
|
-
type: "input",
|
|
85
|
-
validate: (input) => (input ? true : "Database name is required"),
|
|
86
|
-
default: name,
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
message: "Database name:",
|
|
90
|
-
name: "databaseName",
|
|
91
|
-
type: "input",
|
|
92
|
-
validate: (input) => (input ? true : "Database name is required"),
|
|
93
|
-
default: databaseName,
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
message: "Enter the database description (optional):",
|
|
97
|
-
name: "description",
|
|
98
|
-
type: "input",
|
|
99
|
-
default: description,
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
message: "Database Root Password (optional):",
|
|
103
|
-
name: "databaseRootPassword",
|
|
104
|
-
type: "password",
|
|
105
|
-
default: databaseRootPassword,
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
message: "Database password (optional):",
|
|
109
|
-
name: "databasePassword",
|
|
110
|
-
type: "password",
|
|
111
|
-
default: databasePassword,
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
default: dockerImage || "mariadb:11",
|
|
115
|
-
message: "Docker Image (default: mariadb:11):",
|
|
116
|
-
name: "dockerImage",
|
|
117
|
-
type: "input",
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
default: databaseUser || "mariadb",
|
|
121
|
-
message: "Database User: (default: mariadb):",
|
|
122
|
-
name: "databaseUser",
|
|
123
|
-
type: "input",
|
|
124
|
-
},
|
|
125
|
-
]);
|
|
126
|
-
name = dbDetails.name;
|
|
127
|
-
databaseName = dbDetails.databaseName;
|
|
128
|
-
description = dbDetails.description;
|
|
129
|
-
databaseRootPassword = dbDetails.databaseRootPassword;
|
|
130
|
-
databasePassword = dbDetails.databasePassword;
|
|
131
|
-
dockerImage = dbDetails.dockerImage;
|
|
132
|
-
databaseUser = dbDetails.databaseUser;
|
|
133
|
-
const appNamePrompt = await inquirer.prompt([
|
|
134
|
-
{
|
|
135
|
-
default: appName || `${slugify(name)}`,
|
|
136
|
-
message: "Enter the App name:",
|
|
137
|
-
name: "appName",
|
|
138
|
-
type: "input",
|
|
139
|
-
validate: (input) => (input ? true : "App name is required"),
|
|
140
|
-
},
|
|
141
|
-
]);
|
|
142
|
-
appName = appNamePrompt.appName;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
// Confirmar si no se especifica --skipConfirm
|
|
146
|
-
if (!flags.skipConfirm) {
|
|
147
|
-
const confirm = await inquirer.prompt([
|
|
148
|
-
{
|
|
149
|
-
type: 'confirm',
|
|
150
|
-
name: 'proceed',
|
|
151
|
-
message: 'Do you want to create this MariaDB instance?',
|
|
152
|
-
default: false,
|
|
153
|
-
},
|
|
154
|
-
]);
|
|
155
|
-
if (!confirm.proceed) {
|
|
156
|
-
this.error(chalk.yellow("MariaDB creation cancelled."));
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
try {
|
|
161
|
-
const response = await axios.post(`${auth.url}/api/trpc/mariadb.create`, {
|
|
162
|
-
json: {
|
|
163
|
-
name,
|
|
164
|
-
databaseName,
|
|
165
|
-
description,
|
|
166
|
-
databaseRootPassword,
|
|
167
|
-
databasePassword,
|
|
168
|
-
databaseUser,
|
|
169
|
-
dockerImage,
|
|
170
|
-
appName,
|
|
171
|
-
projectId,
|
|
172
|
-
},
|
|
173
|
-
}, {
|
|
174
|
-
headers: {
|
|
175
|
-
"x-api-key": auth.token,
|
|
176
|
-
"Content-Type": "application/json",
|
|
177
|
-
},
|
|
178
|
-
});
|
|
179
|
-
if (!response.data.result.data.json) {
|
|
180
|
-
this.error(chalk.red("Error creating MariaDB instance", response.data.result.data.json));
|
|
181
|
-
}
|
|
182
|
-
this.log(chalk.green(`MariaDB instance '${name}' created successfully.`));
|
|
183
|
-
}
|
|
184
|
-
catch (error) {
|
|
185
|
-
this.error(chalk.red(`Error creating MariaDB instance: ${error.message}`));
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Command } from "@oclif/core";
|
|
2
|
-
export default class DatabaseMariadbDelete 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
|
-
mariadbId: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
8
|
-
skipConfirm: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
9
|
-
};
|
|
10
|
-
run(): Promise<void>;
|
|
11
|
-
}
|
|
@@ -1,104 +0,0 @@
|
|
|
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 DatabaseMariadbDelete extends Command {
|
|
8
|
-
static description = "Delete a MariaDB database from a project.";
|
|
9
|
-
static examples = [
|
|
10
|
-
"$ <%= config.bin %> mariadb delete",
|
|
11
|
-
"$ <%= config.bin %> mariadb 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
|
-
mariadbId: Flags.string({
|
|
20
|
-
char: "m",
|
|
21
|
-
description: "ID of the MariaDB instance to delete",
|
|
22
|
-
required: false,
|
|
23
|
-
}),
|
|
24
|
-
skipConfirm: Flags.boolean({
|
|
25
|
-
char: "y",
|
|
26
|
-
description: "Skip confirmation prompt",
|
|
27
|
-
default: false,
|
|
28
|
-
}),
|
|
29
|
-
};
|
|
30
|
-
async run() {
|
|
31
|
-
const auth = await readAuthConfig(this);
|
|
32
|
-
const { flags } = await this.parse(DatabaseMariadbDelete);
|
|
33
|
-
let { projectId, mariadbId } = flags;
|
|
34
|
-
if (!projectId || !mariadbId) {
|
|
35
|
-
console.log(chalk.blue.bold("\n Listing all Projects \n"));
|
|
36
|
-
const projects = await getProjects(auth, this);
|
|
37
|
-
if (!projectId) {
|
|
38
|
-
const answers = await inquirer.prompt([
|
|
39
|
-
{
|
|
40
|
-
choices: projects.map((project) => ({
|
|
41
|
-
name: project.name,
|
|
42
|
-
value: project.projectId,
|
|
43
|
-
})),
|
|
44
|
-
message: "Select a project to delete the MariaDB instance from:",
|
|
45
|
-
name: "selectedProject",
|
|
46
|
-
type: "list",
|
|
47
|
-
},
|
|
48
|
-
]);
|
|
49
|
-
projectId = answers.selectedProject;
|
|
50
|
-
}
|
|
51
|
-
const projectSelected = await getProject(projectId, auth, this);
|
|
52
|
-
if (!projectSelected.mariadb || projectSelected.mariadb.length === 0) {
|
|
53
|
-
this.error(chalk.yellow("No MariaDB instances found in this project."));
|
|
54
|
-
}
|
|
55
|
-
if (!mariadbId) {
|
|
56
|
-
const dbAnswers = await inquirer.prompt([
|
|
57
|
-
{
|
|
58
|
-
// @ts-ignore
|
|
59
|
-
choices: projectSelected.mariadb.map((db) => ({
|
|
60
|
-
name: db.name,
|
|
61
|
-
value: db.mariadbId,
|
|
62
|
-
})),
|
|
63
|
-
message: "Select the MariaDB instance to delete:",
|
|
64
|
-
name: "selectedDb",
|
|
65
|
-
type: "list",
|
|
66
|
-
},
|
|
67
|
-
]);
|
|
68
|
-
mariadbId = dbAnswers.selectedDb;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
if (!flags.skipConfirm) {
|
|
72
|
-
const confirmAnswers = await inquirer.prompt([
|
|
73
|
-
{
|
|
74
|
-
default: false,
|
|
75
|
-
message: "Are you sure you want to delete this MariaDB instance?",
|
|
76
|
-
name: "confirmDelete",
|
|
77
|
-
type: "confirm",
|
|
78
|
-
},
|
|
79
|
-
]);
|
|
80
|
-
if (!confirmAnswers.confirmDelete) {
|
|
81
|
-
this.error(chalk.yellow("MariaDB deletion cancelled."));
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
try {
|
|
85
|
-
const response = await axios.post(`${auth.url}/api/trpc/mariadb.remove`, {
|
|
86
|
-
json: {
|
|
87
|
-
mariadbId,
|
|
88
|
-
},
|
|
89
|
-
}, {
|
|
90
|
-
headers: {
|
|
91
|
-
"x-api-key": auth.token,
|
|
92
|
-
"Content-Type": "application/json",
|
|
93
|
-
},
|
|
94
|
-
});
|
|
95
|
-
if (!response.data.result.data.json) {
|
|
96
|
-
this.error(chalk.red("Error deleting MariaDB instance"));
|
|
97
|
-
}
|
|
98
|
-
this.log(chalk.green("MariaDB instance deleted successfully."));
|
|
99
|
-
}
|
|
100
|
-
catch (error) {
|
|
101
|
-
this.error(chalk.red(`Error deleting MariaDB instance: ${error.message}`));
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Command } from "@oclif/core";
|
|
2
|
-
export default class DatabaseMariadbDeploy 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
|
-
mariadbId: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
8
|
-
skipConfirm: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
9
|
-
};
|
|
10
|
-
run(): Promise<void>;
|
|
11
|
-
}
|