@dokploy/cli 0.2.4 → 0.2.5
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/dist/commands/app/create.d.ts +4 -0
- package/dist/commands/app/create.js +87 -37
- package/dist/commands/app/delete.d.ts +2 -0
- package/dist/commands/app/delete.js +50 -28
- package/dist/commands/app/deploy.d.ts +5 -0
- package/dist/commands/app/deploy.js +93 -55
- package/dist/commands/app/stop.d.ts +5 -0
- package/dist/commands/app/stop.js +87 -54
- package/dist/commands/database/mariadb/create.d.ts +9 -0
- package/dist/commands/database/mariadb/create.js +160 -66
- package/dist/commands/database/mariadb/delete.d.ts +2 -0
- package/dist/commands/database/mariadb/delete.js +56 -47
- package/dist/commands/database/mariadb/deploy.d.ts +5 -0
- package/dist/commands/database/mariadb/deploy.js +88 -54
- package/dist/commands/database/mariadb/stop.d.ts +5 -0
- package/dist/commands/database/mariadb/stop.js +88 -54
- package/dist/commands/database/mongo/create.d.ts +8 -0
- package/dist/commands/database/mongo/create.js +145 -76
- package/dist/commands/database/mongo/delete.d.ts +2 -0
- package/dist/commands/database/mongo/delete.js +56 -45
- package/dist/commands/database/mongo/deploy.d.ts +5 -0
- package/dist/commands/database/mongo/deploy.js +88 -54
- package/dist/commands/database/mongo/stop.d.ts +5 -0
- package/dist/commands/database/mongo/stop.js +88 -54
- package/dist/commands/database/mysql/create.d.ts +9 -0
- package/dist/commands/database/mysql/create.js +168 -81
- package/dist/commands/database/mysql/delete.d.ts +2 -0
- package/dist/commands/database/mysql/delete.js +56 -47
- package/dist/commands/database/mysql/deploy.js +70 -53
- package/dist/commands/database/mysql/stop.js +70 -53
- package/dist/commands/database/postgres/create.d.ts +8 -0
- package/dist/commands/database/postgres/create.js +155 -76
- package/dist/commands/database/postgres/delete.d.ts +2 -0
- package/dist/commands/database/postgres/delete.js +56 -44
- package/dist/commands/database/postgres/deploy.d.ts +5 -0
- package/dist/commands/database/postgres/deploy.js +90 -56
- package/dist/commands/database/postgres/stop.d.ts +5 -0
- package/dist/commands/database/postgres/stop.js +91 -57
- package/dist/commands/database/redis/create.d.ts +6 -0
- package/dist/commands/database/redis/create.js +129 -65
- package/dist/commands/database/redis/delete.d.ts +2 -0
- package/dist/commands/database/redis/delete.js +60 -50
- package/dist/commands/database/redis/deploy.d.ts +5 -0
- package/dist/commands/database/redis/deploy.js +90 -56
- package/dist/commands/database/redis/stop.d.ts +5 -0
- package/dist/commands/database/redis/stop.js +91 -57
- package/dist/commands/project/create.d.ts +2 -1
- package/dist/commands/project/create.js +53 -34
- package/dist/utils/utils.js +9 -2
- package/oclif.manifest.json +876 -151
- package/package.json +1 -1
|
@@ -14,81 +14,172 @@ export default class DatabaseMariadbCreate extends Command {
|
|
|
14
14
|
description: "ID of the project",
|
|
15
15
|
required: false,
|
|
16
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
|
+
}),
|
|
17
56
|
};
|
|
18
57
|
async run() {
|
|
19
58
|
const auth = await readAuthConfig(this);
|
|
20
59
|
const { flags } = await this.parse(DatabaseMariadbCreate);
|
|
21
|
-
let { projectId } = flags;
|
|
22
|
-
|
|
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) {
|
|
23
63
|
console.log(chalk.blue.bold("\n Listing all Projects \n"));
|
|
24
64
|
const projects = await getProjects(auth, this);
|
|
25
|
-
|
|
26
|
-
{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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([
|
|
79
148
|
{
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
validate: (input) => (input ? true : "App name is required"),
|
|
149
|
+
type: 'confirm',
|
|
150
|
+
name: 'proceed',
|
|
151
|
+
message: 'Do you want to create this MariaDB instance?',
|
|
152
|
+
default: false,
|
|
85
153
|
},
|
|
86
154
|
]);
|
|
155
|
+
if (!confirm.proceed) {
|
|
156
|
+
this.error(chalk.yellow("MariaDB creation cancelled."));
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
try {
|
|
161
|
+
console.log(JSON.stringify({
|
|
162
|
+
name,
|
|
163
|
+
databaseName,
|
|
164
|
+
description,
|
|
165
|
+
databaseRootPassword,
|
|
166
|
+
databasePassword,
|
|
167
|
+
databaseUser,
|
|
168
|
+
dockerImage,
|
|
169
|
+
appName,
|
|
170
|
+
projectId,
|
|
171
|
+
}, null, 2));
|
|
87
172
|
const response = await axios.post(`${auth.url}/api/trpc/mariadb.create`, {
|
|
88
173
|
json: {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
174
|
+
name,
|
|
175
|
+
databaseName,
|
|
176
|
+
description,
|
|
177
|
+
databaseRootPassword,
|
|
178
|
+
databasePassword,
|
|
179
|
+
databaseUser,
|
|
180
|
+
dockerImage,
|
|
181
|
+
appName,
|
|
182
|
+
projectId,
|
|
92
183
|
},
|
|
93
184
|
}, {
|
|
94
185
|
headers: {
|
|
@@ -97,9 +188,12 @@ export default class DatabaseMariadbCreate extends Command {
|
|
|
97
188
|
},
|
|
98
189
|
});
|
|
99
190
|
if (!response.data.result.data.json) {
|
|
100
|
-
this.error(chalk.red("Error creating MariaDB
|
|
191
|
+
this.error(chalk.red("Error creating MariaDB instance", response.data.result.data.json));
|
|
101
192
|
}
|
|
102
|
-
this.log(chalk.green(`MariaDB
|
|
193
|
+
this.log(chalk.green(`MariaDB instance '${name}' created successfully.`));
|
|
194
|
+
}
|
|
195
|
+
catch (error) {
|
|
196
|
+
this.error(chalk.red(`Error creating MariaDB instance: ${error.message}`));
|
|
103
197
|
}
|
|
104
198
|
}
|
|
105
199
|
}
|
|
@@ -4,6 +4,8 @@ export default class DatabaseMariadbDelete extends Command {
|
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
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>;
|
|
7
9
|
};
|
|
8
10
|
run(): Promise<void>;
|
|
9
11
|
}
|
|
@@ -16,62 +16,73 @@ export default class DatabaseMariadbDelete extends Command {
|
|
|
16
16
|
description: "ID of the project",
|
|
17
17
|
required: false,
|
|
18
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
|
+
}),
|
|
19
29
|
};
|
|
20
30
|
async run() {
|
|
21
31
|
const auth = await readAuthConfig(this);
|
|
22
32
|
const { flags } = await this.parse(DatabaseMariadbDelete);
|
|
23
|
-
let { projectId } = flags;
|
|
24
|
-
if (!projectId) {
|
|
33
|
+
let { projectId, mariadbId } = flags;
|
|
34
|
+
if (!projectId || !mariadbId) {
|
|
25
35
|
console.log(chalk.blue.bold("\n Listing all Projects \n"));
|
|
26
36
|
const projects = await getProjects(auth, this);
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
|
|
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;
|
|
30
50
|
}
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
name: "selectedProject",
|
|
35
|
-
message: "Select a project to delete the MariaDB database from:",
|
|
36
|
-
choices: projects.map((project) => ({
|
|
37
|
-
name: project.name,
|
|
38
|
-
value: project.projectId,
|
|
39
|
-
})),
|
|
40
|
-
},
|
|
41
|
-
]);
|
|
42
|
-
projectId = answers.selectedProject;
|
|
43
|
-
}
|
|
44
|
-
try {
|
|
45
|
-
const project = await getProject(projectId, auth, this);
|
|
46
|
-
if (!project.mariadb || project.mariadb.length === 0) {
|
|
47
|
-
this.log(chalk.yellow("No MariaDB databases found in this project."));
|
|
48
|
-
return;
|
|
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."));
|
|
49
54
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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) {
|
|
62
72
|
const confirmAnswers = await inquirer.prompt([
|
|
63
73
|
{
|
|
64
|
-
type: "confirm",
|
|
65
|
-
name: "confirmDelete",
|
|
66
|
-
message: "Are you sure you want to delete this MariaDB database?",
|
|
67
74
|
default: false,
|
|
75
|
+
message: "Are you sure you want to delete this MariaDB instance?",
|
|
76
|
+
name: "confirmDelete",
|
|
77
|
+
type: "confirm",
|
|
68
78
|
},
|
|
69
79
|
]);
|
|
70
80
|
if (!confirmAnswers.confirmDelete) {
|
|
71
|
-
this.
|
|
72
|
-
return;
|
|
81
|
+
this.error(chalk.yellow("MariaDB deletion cancelled."));
|
|
73
82
|
}
|
|
74
|
-
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
const response = await axios.post(`${auth.url}/api/trpc/mariadb.remove`, {
|
|
75
86
|
json: {
|
|
76
87
|
mariadbId,
|
|
77
88
|
},
|
|
@@ -81,15 +92,13 @@ export default class DatabaseMariadbDelete extends Command {
|
|
|
81
92
|
"Content-Type": "application/json",
|
|
82
93
|
},
|
|
83
94
|
});
|
|
84
|
-
if (!
|
|
85
|
-
this.error(chalk.red("Error deleting
|
|
95
|
+
if (!response.data.result.data.json) {
|
|
96
|
+
this.error(chalk.red("Error deleting MariaDB instance"));
|
|
86
97
|
}
|
|
87
|
-
this.log(chalk.green("MariaDB
|
|
98
|
+
this.log(chalk.green("MariaDB instance deleted successfully."));
|
|
88
99
|
}
|
|
89
100
|
catch (error) {
|
|
90
|
-
this.error(
|
|
91
|
-
// @ts-ignore
|
|
92
|
-
chalk.red(`Failed to delete MariaDB database: ${error.message}`));
|
|
101
|
+
this.error(chalk.red(`Error deleting MariaDB instance: ${error.message}`));
|
|
93
102
|
}
|
|
94
103
|
}
|
|
95
104
|
}
|
|
@@ -2,5 +2,10 @@ import { Command } from "@oclif/core";
|
|
|
2
2
|
export default class DatabaseMariadbDeploy extends Command {
|
|
3
3
|
static description: string;
|
|
4
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
|
+
};
|
|
5
10
|
run(): Promise<void>;
|
|
6
11
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Command } from "@oclif/core";
|
|
1
|
+
import { Command, Flags } from "@oclif/core";
|
|
2
2
|
import { readAuthConfig } from "../../../utils/utils.js";
|
|
3
3
|
import chalk from "chalk";
|
|
4
4
|
import { getProject, getProjects } from "../../../utils/shared.js";
|
|
@@ -7,63 +7,97 @@ import axios from "axios";
|
|
|
7
7
|
export default class DatabaseMariadbDeploy extends Command {
|
|
8
8
|
static description = "Deploy an mariadb to a project.";
|
|
9
9
|
static examples = ["$ <%= config.bin %> app deploy"];
|
|
10
|
+
static flags = {
|
|
11
|
+
projectId: Flags.string({
|
|
12
|
+
char: "p",
|
|
13
|
+
description: "ID of the project",
|
|
14
|
+
required: false,
|
|
15
|
+
}),
|
|
16
|
+
mariadbId: Flags.string({
|
|
17
|
+
char: "m",
|
|
18
|
+
description: "ID of the MariaDB instance to deploy",
|
|
19
|
+
required: false,
|
|
20
|
+
}),
|
|
21
|
+
skipConfirm: Flags.boolean({
|
|
22
|
+
char: "y",
|
|
23
|
+
description: "Skip confirmation prompt",
|
|
24
|
+
default: false,
|
|
25
|
+
}),
|
|
26
|
+
};
|
|
10
27
|
async run() {
|
|
11
28
|
const auth = await readAuthConfig(this);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
const { flags } = await this.parse(DatabaseMariadbDeploy);
|
|
30
|
+
let { projectId, mariadbId } = flags;
|
|
31
|
+
// Modo interactivo si no se proporcionan los flags necesarios
|
|
32
|
+
if (!projectId || !mariadbId) {
|
|
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 deploy the MariaDB in:",
|
|
43
|
+
name: "project",
|
|
44
|
+
type: "list",
|
|
45
|
+
},
|
|
46
|
+
]);
|
|
47
|
+
projectId = project.projectId;
|
|
48
|
+
}
|
|
49
|
+
const projectSelected = await getProject(projectId, auth, this);
|
|
50
|
+
if (projectSelected.mariadb.length === 0) {
|
|
51
|
+
this.error(chalk.yellow("No MariaDB instances found in this project."));
|
|
52
|
+
}
|
|
53
|
+
if (!mariadbId) {
|
|
54
|
+
const dbAnswers = await inquirer.prompt([
|
|
55
|
+
{
|
|
56
|
+
// @ts-ignore
|
|
57
|
+
choices: projectSelected.mariadb.map((db) => ({
|
|
58
|
+
name: db.name,
|
|
59
|
+
value: db.mariadbId,
|
|
60
|
+
})),
|
|
61
|
+
message: "Select the MariaDB instance to deploy:",
|
|
62
|
+
name: "selectedDb",
|
|
63
|
+
type: "list",
|
|
64
|
+
},
|
|
65
|
+
]);
|
|
66
|
+
mariadbId = dbAnswers.selectedDb;
|
|
67
|
+
}
|
|
29
68
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const confirmAnswers = await inquirer.prompt([
|
|
44
|
-
{
|
|
45
|
-
default: false,
|
|
46
|
-
message: "Are you sure you want to deploy this mariadb?",
|
|
47
|
-
name: "confirmDelete",
|
|
48
|
-
type: "confirm",
|
|
49
|
-
},
|
|
50
|
-
]);
|
|
51
|
-
if (!confirmAnswers.confirmDelete) {
|
|
52
|
-
this.error(chalk.yellow("mariadb deployment cancelled."));
|
|
69
|
+
// Confirmar si no se especifica --skipConfirm
|
|
70
|
+
if (!flags.skipConfirm) {
|
|
71
|
+
const confirmAnswers = await inquirer.prompt([
|
|
72
|
+
{
|
|
73
|
+
default: false,
|
|
74
|
+
message: "Are you sure you want to deploy this MariaDB instance?",
|
|
75
|
+
name: "confirmDeploy",
|
|
76
|
+
type: "confirm",
|
|
77
|
+
},
|
|
78
|
+
]);
|
|
79
|
+
if (!confirmAnswers.confirmDeploy) {
|
|
80
|
+
this.error(chalk.yellow("MariaDB deployment cancelled."));
|
|
81
|
+
}
|
|
53
82
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
83
|
+
try {
|
|
84
|
+
const response = await axios.post(`${auth.url}/api/trpc/mariadb.deploy`, {
|
|
85
|
+
json: {
|
|
86
|
+
mariadbId,
|
|
87
|
+
},
|
|
88
|
+
}, {
|
|
89
|
+
headers: {
|
|
90
|
+
Authorization: `Bearer ${auth.token}`,
|
|
91
|
+
"Content-Type": "application/json",
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
if (response.status !== 200) {
|
|
95
|
+
this.error(chalk.red("Error deploying MariaDB instance"));
|
|
96
|
+
}
|
|
97
|
+
this.log(chalk.green("MariaDB instance deployed successfully."));
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
this.error(chalk.red(`Error deploying MariaDB instance: ${error.message}`));
|
|
66
101
|
}
|
|
67
|
-
this.log(chalk.green("Mariadb deploy successful."));
|
|
68
102
|
}
|
|
69
103
|
}
|
|
@@ -2,5 +2,10 @@ import { Command } from "@oclif/core";
|
|
|
2
2
|
export default class DatabaseMariadbStop extends Command {
|
|
3
3
|
static description: string;
|
|
4
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
|
+
};
|
|
5
10
|
run(): Promise<void>;
|
|
6
11
|
}
|