@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
@@ -1,103 +0,0 @@
1
- import { Command, Flags } from "@oclif/core";
2
- import chalk from "chalk";
3
- import inquirer from "inquirer";
4
- import axios from "axios";
5
- import { getProject, getProjects } from "../../../utils/shared.js";
6
- import { readAuthConfig } from "../../../utils/utils.js";
7
- export default class DatabaseMongoStop extends Command {
8
- static description = "Stop an mongo from a project.";
9
- static examples = ["$ <%= config.bin %> mongo stop"];
10
- static flags = {
11
- projectId: Flags.string({
12
- char: "p",
13
- description: "ID of the project",
14
- required: false,
15
- }),
16
- mongoId: Flags.string({
17
- char: "m",
18
- description: "ID of the MongoDB instance 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(DatabaseMongoStop);
30
- let { projectId, mongoId } = flags;
31
- // Modo interactivo si no se proporcionan los flags necesarios
32
- if (!projectId || !mongoId) {
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 MongoDB instance 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.mongo.length === 0) {
51
- this.error(chalk.yellow("No MongoDB instances found in this project."));
52
- }
53
- if (!mongoId) {
54
- const dbAnswers = await inquirer.prompt([
55
- {
56
- // @ts-ignore
57
- choices: projectSelected.mongo.map((db) => ({
58
- name: db.name,
59
- value: db.mongoId,
60
- })),
61
- message: "Select the MongoDB instance to stop:",
62
- name: "selectedDb",
63
- type: "list",
64
- },
65
- ]);
66
- mongoId = dbAnswers.selectedDb;
67
- }
68
- }
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 stop this MongoDB instance?",
75
- name: "confirmStop",
76
- type: "confirm",
77
- },
78
- ]);
79
- if (!confirmAnswers.confirmStop) {
80
- this.error(chalk.yellow("MongoDB stop cancelled."));
81
- }
82
- }
83
- try {
84
- const response = await axios.post(`${auth.url}/api/trpc/mongo.stop`, {
85
- json: {
86
- mongoId,
87
- },
88
- }, {
89
- headers: {
90
- "x-api-key": auth.token,
91
- "Content-Type": "application/json",
92
- },
93
- });
94
- if (response.status !== 200) {
95
- this.error(chalk.red("Error stopping MongoDB instance"));
96
- }
97
- this.log(chalk.green("MongoDB instance stopped successfully."));
98
- }
99
- catch (error) {
100
- this.error(chalk.red(`Error stopping MongoDB instance: ${error.message}`));
101
- }
102
- }
103
- }
@@ -1,18 +0,0 @@
1
- import { Command } from "@oclif/core";
2
- export default class DatabaseMysqlCreate 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 { slugify } from "../../../utils/slug.js";
6
- import { readAuthConfig } from "../../../utils/utils.js";
7
- import { getProjects } from "../../../utils/shared.js";
8
- export default class DatabaseMysqlCreate extends Command {
9
- static description = "Create a new MySQL database within a project.";
10
- static examples = ["$ <%= config.bin %> mysql 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: "MySQL 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: "mysql",
42
- }),
43
- dockerImage: Flags.string({
44
- description: "Docker image",
45
- default: "mysql:8",
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(DatabaseMysqlCreate);
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 || !databasePassword || !databaseRootPassword) {
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 MySQL instance in:",
73
- name: "project",
74
- type: "list",
75
- },
76
- ]);
77
- projectId = project.projectId;
78
- }
79
- if (!name || !databaseName || !appName || !databasePassword || !databaseRootPassword) {
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:",
103
- name: "databaseRootPassword",
104
- type: "password",
105
- default: databaseRootPassword,
106
- },
107
- {
108
- message: "Database password:",
109
- name: "databasePassword",
110
- type: "password",
111
- default: databasePassword,
112
- },
113
- {
114
- default: dockerImage || "mysql:8",
115
- message: "Docker Image (default: mysql:8):",
116
- name: "dockerImage",
117
- type: "input",
118
- },
119
- {
120
- default: databaseUser || "mysql",
121
- message: "Database User: (default: mysql):",
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 MySQL instance?',
152
- default: false,
153
- },
154
- ]);
155
- if (!confirm.proceed) {
156
- this.error(chalk.yellow("MySQL creation cancelled."));
157
- return;
158
- }
159
- }
160
- try {
161
- const response = await axios.post(`${auth.url}/api/trpc/mysql.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 MySQL instance", response.data.result.data.json));
181
- }
182
- this.log(chalk.green(`MySQL instance '${name}' created successfully.`));
183
- }
184
- catch (error) {
185
- this.error(chalk.red(`Error creating MySQL instance: ${error.message}`));
186
- }
187
- }
188
- }
@@ -1,11 +0,0 @@
1
- import { Command } from "@oclif/core";
2
- export default class DatabaseMysqlDelete 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
- mysqlId: 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,106 +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 { getProject, getProjects } from "../../../utils/shared.js";
7
- export default class DatabaseMysqlDelete extends Command {
8
- static description = "Delete a MySQL database from a project.";
9
- static examples = [
10
- "$ <%= config.bin %> mysql delete",
11
- "$ <%= config.bin %> mysql 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
- mysqlId: Flags.string({
20
- char: "i",
21
- description: "ID of the MySQL database",
22
- required: false,
23
- }),
24
- skipConfirm: Flags.boolean({
25
- char: "y",
26
- description: "Skip confirmation",
27
- required: false,
28
- }),
29
- };
30
- async run() {
31
- const auth = await readAuthConfig(this);
32
- const { flags } = await this.parse(DatabaseMysqlDelete);
33
- let { projectId, mysqlId } = flags;
34
- // Modo interactivo si no se proporcionan los flags necesarios
35
- if (!projectId || !mysqlId) {
36
- console.log(chalk.blue.bold("\n Listing all Projects \n"));
37
- const projects = await getProjects(auth, this);
38
- if (!projectId) {
39
- const answers = await inquirer.prompt([
40
- {
41
- choices: projects.map((project) => ({
42
- name: project.name,
43
- value: project.projectId,
44
- })),
45
- message: "Select a project to delete the MySQL instance from:",
46
- name: "selectedProject",
47
- type: "list",
48
- },
49
- ]);
50
- projectId = answers.selectedProject;
51
- }
52
- const projectSelected = await getProject(projectId, auth, this);
53
- if (!projectSelected.mysql || projectSelected.mysql.length === 0) {
54
- this.error(chalk.yellow("No MySQL instances found in this project."));
55
- }
56
- if (!mysqlId) {
57
- const dbAnswers = await inquirer.prompt([
58
- {
59
- // @ts-ignore
60
- choices: projectSelected.mysql.map((db) => ({
61
- name: db.name,
62
- value: db.mysqlId,
63
- })),
64
- message: "Select the MySQL instance to delete:",
65
- name: "selectedDb",
66
- type: "list",
67
- },
68
- ]);
69
- mysqlId = dbAnswers.selectedDb;
70
- }
71
- }
72
- // Confirmar si no se especifica --skipConfirm
73
- if (!flags.skipConfirm) {
74
- const confirmAnswers = await inquirer.prompt([
75
- {
76
- default: false,
77
- message: "Are you sure you want to delete this MySQL instance?",
78
- name: "confirmDelete",
79
- type: "confirm",
80
- },
81
- ]);
82
- if (!confirmAnswers.confirmDelete) {
83
- this.error(chalk.yellow("MySQL deletion cancelled."));
84
- }
85
- }
86
- try {
87
- const response = await axios.post(`${auth.url}/api/trpc/mysql.remove`, {
88
- json: {
89
- mysqlId,
90
- },
91
- }, {
92
- headers: {
93
- "x-api-key": auth.token,
94
- "Content-Type": "application/json",
95
- },
96
- });
97
- if (!response.data.result.data.json) {
98
- this.error(chalk.red("Error deleting MySQL instance"));
99
- }
100
- this.log(chalk.green("MySQL instance deleted successfully."));
101
- }
102
- catch (error) {
103
- this.error(chalk.red(`Error deleting MySQL instance: ${error.message}`));
104
- }
105
- }
106
- }
@@ -1,6 +0,0 @@
1
- import { Command } from "@oclif/core";
2
- export default class DatabaseMysqlDeploy extends Command {
3
- static description: string;
4
- static examples: string[];
5
- run(): Promise<void>;
6
- }
@@ -1,86 +0,0 @@
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 DatabaseMysqlDeploy extends Command {
8
- static description = "Deploy an mysql to a project.";
9
- static examples = ["$ <%= config.bin %> app deploy"];
10
- async run() {
11
- const auth = await readAuthConfig(this);
12
- const { flags } = await this.parse(DatabaseMysqlDeploy);
13
- let { projectId, mysqlId } = flags;
14
- // Modo interactivo si no se proporcionan los flags necesarios
15
- if (!projectId || !mysqlId) {
16
- console.log(chalk.blue.bold("\n Listing all Projects \n"));
17
- const projects = await getProjects(auth, this);
18
- if (!projectId) {
19
- const { project } = await inquirer.prompt([
20
- {
21
- choices: projects.map((project) => ({
22
- name: project.name,
23
- value: project,
24
- })),
25
- message: "Select a project to deploy the MySQL instance from:",
26
- name: "project",
27
- type: "list",
28
- },
29
- ]);
30
- projectId = project.projectId;
31
- }
32
- const projectSelected = await getProject(projectId, auth, this);
33
- if (projectSelected.mysql.length === 0) {
34
- this.error(chalk.yellow("No MySQL instances found in this project."));
35
- }
36
- if (!mysqlId) {
37
- const dbAnswers = await inquirer.prompt([
38
- {
39
- // @ts-ignore
40
- choices: projectSelected.mysql.map((db) => ({
41
- name: db.name,
42
- value: db.mysqlId,
43
- })),
44
- message: "Select the MySQL instance to deploy:",
45
- name: "selectedDb",
46
- type: "list",
47
- },
48
- ]);
49
- mysqlId = dbAnswers.selectedDb;
50
- }
51
- }
52
- // Confirmar si no se especifica --skipConfirm
53
- if (!flags.skipConfirm) {
54
- const confirmAnswers = await inquirer.prompt([
55
- {
56
- default: false,
57
- message: "Are you sure you want to deploy this MySQL instance?",
58
- name: "confirmDeploy",
59
- type: "confirm",
60
- },
61
- ]);
62
- if (!confirmAnswers.confirmDeploy) {
63
- this.error(chalk.yellow("MySQL deployment cancelled."));
64
- }
65
- }
66
- try {
67
- const response = await axios.post(`${auth.url}/api/trpc/mysql.deploy`, {
68
- json: {
69
- mysqlId,
70
- },
71
- }, {
72
- headers: {
73
- "x-api-key": auth.token,
74
- "Content-Type": "application/json",
75
- },
76
- });
77
- if (response.status !== 200) {
78
- this.error(chalk.red("Error deploying MySQL instance"));
79
- }
80
- this.log(chalk.green("MySQL instance deployed successfully."));
81
- }
82
- catch (error) {
83
- this.error(chalk.red(`Error deploying MySQL instance: ${error.message}`));
84
- }
85
- }
86
- }
@@ -1,6 +0,0 @@
1
- import { Command } from "@oclif/core";
2
- export default class DatabaseMysqlStop extends Command {
3
- static description: string;
4
- static examples: string[];
5
- run(): Promise<void>;
6
- }
@@ -1,86 +0,0 @@
1
- import { Command } from "@oclif/core";
2
- import chalk from "chalk";
3
- import inquirer from "inquirer";
4
- import axios from "axios";
5
- import { getProject, getProjects } from "../../../utils/shared.js";
6
- import { readAuthConfig } from "../../../utils/utils.js";
7
- export default class DatabaseMysqlStop extends Command {
8
- static description = "Stop an mysql from a project.";
9
- static examples = ["$ <%= config.bin %> mysql stop"];
10
- async run() {
11
- const auth = await readAuthConfig(this);
12
- const { flags } = await this.parse(DatabaseMysqlStop);
13
- let { projectId, mysqlId } = flags;
14
- // Modo interactivo si no se proporcionan los flags necesarios
15
- if (!projectId || !mysqlId) {
16
- console.log(chalk.blue.bold("\n Listing all Projects \n"));
17
- const projects = await getProjects(auth, this);
18
- if (!projectId) {
19
- const { project } = await inquirer.prompt([
20
- {
21
- choices: projects.map((project) => ({
22
- name: project.name,
23
- value: project,
24
- })),
25
- message: "Select a project to stop the MySQL instance from:",
26
- name: "project",
27
- type: "list",
28
- },
29
- ]);
30
- projectId = project.projectId;
31
- }
32
- const projectSelected = await getProject(projectId, auth, this);
33
- if (projectSelected.mysql.length === 0) {
34
- this.error(chalk.yellow("No MySQL instances found in this project."));
35
- }
36
- if (!mysqlId) {
37
- const dbAnswers = await inquirer.prompt([
38
- {
39
- // @ts-ignore
40
- choices: projectSelected.mysql.map((db) => ({
41
- name: db.name,
42
- value: db.mysqlId,
43
- })),
44
- message: "Select the MySQL instance to stop:",
45
- name: "selectedDb",
46
- type: "list",
47
- },
48
- ]);
49
- mysqlId = dbAnswers.selectedDb;
50
- }
51
- }
52
- // Confirmar si no se especifica --skipConfirm
53
- if (!flags.skipConfirm) {
54
- const confirmAnswers = await inquirer.prompt([
55
- {
56
- default: false,
57
- message: "Are you sure you want to stop this MySQL instance?",
58
- name: "confirmStop",
59
- type: "confirm",
60
- },
61
- ]);
62
- if (!confirmAnswers.confirmStop) {
63
- this.error(chalk.yellow("MySQL stop cancelled."));
64
- }
65
- }
66
- try {
67
- const response = await axios.post(`${auth.url}/api/trpc/mysql.stop`, {
68
- json: {
69
- mysqlId,
70
- },
71
- }, {
72
- headers: {
73
- "x-api-key": auth.token,
74
- "Content-Type": "application/json",
75
- },
76
- });
77
- if (response.status !== 200) {
78
- this.error(chalk.red("Error stopping MySQL instance"));
79
- }
80
- this.log(chalk.green("MySQL instance stopped successfully."));
81
- }
82
- catch (error) {
83
- this.error(chalk.red(`Error stopping MySQL instance: ${error.message}`));
84
- }
85
- }
86
- }
@@ -1,17 +0,0 @@
1
- import { Command } from "@oclif/core";
2
- export default class DatabasePostgresCreate 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
- databasePassword: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
11
- databaseUser: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
12
- dockerImage: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
13
- skipConfirm: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
14
- appName: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
15
- };
16
- run(): Promise<void>;
17
- }