@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.
Files changed (51) hide show
  1. package/dist/commands/app/create.d.ts +4 -0
  2. package/dist/commands/app/create.js +87 -37
  3. package/dist/commands/app/delete.d.ts +2 -0
  4. package/dist/commands/app/delete.js +50 -28
  5. package/dist/commands/app/deploy.d.ts +5 -0
  6. package/dist/commands/app/deploy.js +93 -55
  7. package/dist/commands/app/stop.d.ts +5 -0
  8. package/dist/commands/app/stop.js +87 -54
  9. package/dist/commands/database/mariadb/create.d.ts +9 -0
  10. package/dist/commands/database/mariadb/create.js +160 -66
  11. package/dist/commands/database/mariadb/delete.d.ts +2 -0
  12. package/dist/commands/database/mariadb/delete.js +56 -47
  13. package/dist/commands/database/mariadb/deploy.d.ts +5 -0
  14. package/dist/commands/database/mariadb/deploy.js +88 -54
  15. package/dist/commands/database/mariadb/stop.d.ts +5 -0
  16. package/dist/commands/database/mariadb/stop.js +88 -54
  17. package/dist/commands/database/mongo/create.d.ts +8 -0
  18. package/dist/commands/database/mongo/create.js +145 -76
  19. package/dist/commands/database/mongo/delete.d.ts +2 -0
  20. package/dist/commands/database/mongo/delete.js +56 -45
  21. package/dist/commands/database/mongo/deploy.d.ts +5 -0
  22. package/dist/commands/database/mongo/deploy.js +88 -54
  23. package/dist/commands/database/mongo/stop.d.ts +5 -0
  24. package/dist/commands/database/mongo/stop.js +88 -54
  25. package/dist/commands/database/mysql/create.d.ts +9 -0
  26. package/dist/commands/database/mysql/create.js +168 -81
  27. package/dist/commands/database/mysql/delete.d.ts +2 -0
  28. package/dist/commands/database/mysql/delete.js +56 -47
  29. package/dist/commands/database/mysql/deploy.js +70 -53
  30. package/dist/commands/database/mysql/stop.js +70 -53
  31. package/dist/commands/database/postgres/create.d.ts +8 -0
  32. package/dist/commands/database/postgres/create.js +155 -76
  33. package/dist/commands/database/postgres/delete.d.ts +2 -0
  34. package/dist/commands/database/postgres/delete.js +56 -44
  35. package/dist/commands/database/postgres/deploy.d.ts +5 -0
  36. package/dist/commands/database/postgres/deploy.js +90 -56
  37. package/dist/commands/database/postgres/stop.d.ts +5 -0
  38. package/dist/commands/database/postgres/stop.js +91 -57
  39. package/dist/commands/database/redis/create.d.ts +6 -0
  40. package/dist/commands/database/redis/create.js +129 -65
  41. package/dist/commands/database/redis/delete.d.ts +2 -0
  42. package/dist/commands/database/redis/delete.js +60 -50
  43. package/dist/commands/database/redis/deploy.d.ts +5 -0
  44. package/dist/commands/database/redis/deploy.js +90 -56
  45. package/dist/commands/database/redis/stop.d.ts +5 -0
  46. package/dist/commands/database/redis/stop.js +91 -57
  47. package/dist/commands/project/create.d.ts +2 -1
  48. package/dist/commands/project/create.js +53 -34
  49. package/dist/utils/utils.js +9 -2
  50. package/oclif.manifest.json +876 -151
  51. package/package.json +1 -1
@@ -16,65 +16,75 @@ export default class DatabaseMysqlDelete extends Command {
16
16
  description: "ID of the project",
17
17
  required: false,
18
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
+ }),
19
29
  };
20
30
  async run() {
21
31
  const auth = await readAuthConfig(this);
22
32
  const { flags } = await this.parse(DatabaseMysqlDelete);
23
- let { projectId } = flags;
24
- if (!projectId) {
33
+ let { projectId, mysqlId } = flags;
34
+ // Modo interactivo si no se proporcionan los flags necesarios
35
+ if (!projectId || !mysqlId) {
25
36
  console.log(chalk.blue.bold("\n Listing all Projects \n"));
26
37
  const projects = await getProjects(auth, this);
27
- if (projects.length === 0) {
28
- this.log(chalk.yellow("No projects found."));
29
- return;
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;
30
51
  }
31
- const answers = await inquirer.prompt([
32
- {
33
- choices: projects.map((project) => ({
34
- name: project.name,
35
- value: project.projectId,
36
- })),
37
- message: "Select a project to delete the MySQL database from:",
38
- name: "selectedProject",
39
- type: "list",
40
- },
41
- ]);
42
- projectId = answers.selectedProject;
43
- }
44
- try {
45
- const project = await getProject(projectId, auth, this);
46
- if (!project.mysql || project.mysql.length === 0) {
47
- this.log(chalk.yellow("No MySQL databases found in this project."));
48
- return;
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."));
49
55
  }
50
- // Permitir al usuario seleccionar una aplicación
51
- const appAnswers = await inquirer.prompt([
52
- {
53
- choices: project.mysql.map((app) => ({
54
- name: app.name,
55
- value: app.mysqlId,
56
- })),
57
- message: "Select the MySQL database to delete:",
58
- name: "selectedApp",
59
- type: "list",
60
- },
61
- ]);
62
- const mysqlId = appAnswers.selectedApp;
63
- // Confirmar eliminación
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) {
64
74
  const confirmAnswers = await inquirer.prompt([
65
75
  {
66
76
  default: false,
67
- message: "Are you sure you want to delete this mysql database?",
77
+ message: "Are you sure you want to delete this MySQL instance?",
68
78
  name: "confirmDelete",
69
79
  type: "confirm",
70
80
  },
71
81
  ]);
72
82
  if (!confirmAnswers.confirmDelete) {
73
- this.log(chalk.yellow("Application deletion cancelled."));
74
- return;
83
+ this.error(chalk.yellow("MySQL deletion cancelled."));
75
84
  }
76
- // Eliminar la aplicación seleccionada
77
- const deleteResponse = await axios.post(`${auth.url}/api/trpc/mysql.remove`, {
85
+ }
86
+ try {
87
+ const response = await axios.post(`${auth.url}/api/trpc/mysql.remove`, {
78
88
  json: {
79
89
  mysqlId,
80
90
  },
@@ -84,14 +94,13 @@ export default class DatabaseMysqlDelete extends Command {
84
94
  "Content-Type": "application/json",
85
95
  },
86
96
  });
87
- if (!deleteResponse.data.result.data.json) {
88
- this.error(chalk.red("Error deleting application"));
97
+ if (!response.data.result.data.json) {
98
+ this.error(chalk.red("Error deleting MySQL instance"));
89
99
  }
90
- this.log(chalk.green("Application deleted successfully."));
100
+ this.log(chalk.green("MySQL instance deleted successfully."));
91
101
  }
92
102
  catch (error) {
93
- // @ts-expect-error - TS2339: Property 'data' does not exist on type 'AxiosError<any>'.
94
- this.error(chalk.red(`Failed to delete application: ${error.message}`));
103
+ this.error(chalk.red(`Error deleting MySQL instance: ${error.message}`));
95
104
  }
96
105
  }
97
106
  }
@@ -9,61 +9,78 @@ export default class DatabaseMysqlDeploy extends Command {
9
9
  static examples = ["$ <%= config.bin %> app deploy"];
10
10
  async run() {
11
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 mysql 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.mysql.length === 0) {
28
- this.error(chalk.yellow("No mysql found in this project."));
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
+ }
29
51
  }
30
- const appAnswers = await inquirer.prompt([
31
- {
32
- // @ts-ignore
33
- choices: projectSelected.mysql.map((app) => ({
34
- name: app.name,
35
- value: app.mysqlId,
36
- })),
37
- message: "Select the mysql to deploy:",
38
- name: "selectedApp",
39
- type: "list",
40
- },
41
- ]);
42
- const mysqlId = appAnswers.selectedApp;
43
- const confirmAnswers = await inquirer.prompt([
44
- {
45
- default: false,
46
- message: "Are you sure you want to deploy this mysql?",
47
- name: "confirmDelete",
48
- type: "confirm",
49
- },
50
- ]);
51
- if (!confirmAnswers.confirmDelete) {
52
- this.error(chalk.yellow("mysql deployment cancelled."));
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
+ }
53
65
  }
54
- const response = await axios.post(`${auth.url}/api/trpc/mysql.deploy`, {
55
- json: {
56
- mysqlId,
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 mysql"));
66
+ try {
67
+ const response = await axios.post(`${auth.url}/api/trpc/mysql.deploy`, {
68
+ json: {
69
+ mysqlId,
70
+ },
71
+ }, {
72
+ headers: {
73
+ Authorization: `Bearer ${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}`));
66
84
  }
67
- this.log(chalk.green("Mysql deployed successful."));
68
85
  }
69
86
  }
@@ -9,61 +9,78 @@ export default class DatabaseMysqlStop extends Command {
9
9
  static examples = ["$ <%= config.bin %> mysql stop"];
10
10
  async run() {
11
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 mysql 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.mysql.length === 0) {
28
- this.error(chalk.yellow("No mysql found in this project."));
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
+ }
29
51
  }
30
- const appAnswers = await inquirer.prompt([
31
- {
32
- // @ts-ignore
33
- choices: projectSelected.mysql.map((app) => ({
34
- name: app.name,
35
- value: app.mysqlId,
36
- })),
37
- message: "Select the mysql to stop:",
38
- name: "selectedApp",
39
- type: "list",
40
- },
41
- ]);
42
- const mysqlId = appAnswers.selectedApp;
43
- const confirmAnswers = await inquirer.prompt([
44
- {
45
- default: false,
46
- message: "Are you sure you want to stop this mysql?",
47
- name: "confirmDelete",
48
- type: "confirm",
49
- },
50
- ]);
51
- if (!confirmAnswers.confirmDelete) {
52
- this.error(chalk.yellow("mysql stop cancelled."));
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
+ }
53
65
  }
54
- const response = await axios.post(`${auth.url}/api/trpc/mysql.stop`, {
55
- json: {
56
- mysqlId,
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 mysql"));
66
+ try {
67
+ const response = await axios.post(`${auth.url}/api/trpc/mysql.stop`, {
68
+ json: {
69
+ mysqlId,
70
+ },
71
+ }, {
72
+ headers: {
73
+ Authorization: `Bearer ${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}`));
66
84
  }
67
- this.log(chalk.green("Mysql stop successful."));
68
85
  }
69
86
  }
@@ -4,6 +4,14 @@ export default class DatabasePostgresCreate 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
+ 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>;
7
15
  };
8
16
  run(): Promise<void>;
9
17
  }