@dokploy/cli 0.2.3 → 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 (57) hide show
  1. package/LICENSE.md +21 -0
  2. package/dist/commands/app/create.d.ts +4 -0
  3. package/dist/commands/app/create.js +87 -37
  4. package/dist/commands/app/delete.d.ts +2 -0
  5. package/dist/commands/app/delete.js +50 -28
  6. package/dist/commands/app/deploy.d.ts +5 -0
  7. package/dist/commands/app/deploy.js +93 -55
  8. package/dist/commands/app/stop.d.ts +5 -0
  9. package/dist/commands/app/stop.js +87 -54
  10. package/dist/commands/database/mariadb/create.d.ts +9 -0
  11. package/dist/commands/database/mariadb/create.js +160 -66
  12. package/dist/commands/database/mariadb/delete.d.ts +2 -0
  13. package/dist/commands/database/mariadb/delete.js +56 -47
  14. package/dist/commands/database/mariadb/deploy.d.ts +5 -0
  15. package/dist/commands/database/mariadb/deploy.js +88 -54
  16. package/dist/commands/database/mariadb/stop.d.ts +5 -0
  17. package/dist/commands/database/mariadb/stop.js +88 -54
  18. package/dist/commands/database/mongo/create.d.ts +8 -0
  19. package/dist/commands/database/mongo/create.js +145 -76
  20. package/dist/commands/database/mongo/delete.d.ts +2 -0
  21. package/dist/commands/database/mongo/delete.js +56 -45
  22. package/dist/commands/database/mongo/deploy.d.ts +5 -0
  23. package/dist/commands/database/mongo/deploy.js +88 -54
  24. package/dist/commands/database/mongo/stop.d.ts +5 -0
  25. package/dist/commands/database/mongo/stop.js +88 -54
  26. package/dist/commands/database/mysql/create.d.ts +9 -0
  27. package/dist/commands/database/mysql/create.js +168 -81
  28. package/dist/commands/database/mysql/delete.d.ts +2 -0
  29. package/dist/commands/database/mysql/delete.js +56 -47
  30. package/dist/commands/database/mysql/deploy.js +70 -53
  31. package/dist/commands/database/mysql/stop.js +70 -53
  32. package/dist/commands/database/postgres/create.d.ts +8 -0
  33. package/dist/commands/database/postgres/create.js +155 -76
  34. package/dist/commands/database/postgres/delete.d.ts +2 -0
  35. package/dist/commands/database/postgres/delete.js +56 -44
  36. package/dist/commands/database/postgres/deploy.d.ts +5 -0
  37. package/dist/commands/database/postgres/deploy.js +90 -56
  38. package/dist/commands/database/postgres/stop.d.ts +5 -0
  39. package/dist/commands/database/postgres/stop.js +91 -57
  40. package/dist/commands/database/redis/create.d.ts +6 -0
  41. package/dist/commands/database/redis/create.js +129 -65
  42. package/dist/commands/database/redis/delete.d.ts +2 -0
  43. package/dist/commands/database/redis/delete.js +60 -50
  44. package/dist/commands/database/redis/deploy.d.ts +5 -0
  45. package/dist/commands/database/redis/deploy.js +90 -56
  46. package/dist/commands/database/redis/stop.d.ts +5 -0
  47. package/dist/commands/database/redis/stop.js +91 -57
  48. package/dist/commands/env/pull.d.ts +10 -0
  49. package/dist/commands/env/pull.js +68 -0
  50. package/dist/commands/env/push.d.ts +10 -0
  51. package/dist/commands/env/push.js +106 -0
  52. package/dist/commands/project/create.d.ts +2 -1
  53. package/dist/commands/project/create.js +53 -34
  54. package/dist/utils/utils.js +9 -2
  55. package/oclif.manifest.json +895 -110
  56. package/package.json +3 -2
  57. package/{README.md → readme.md} +16 -1
@@ -4,56 +4,76 @@ import chalk from "chalk";
4
4
  import inquirer from "inquirer";
5
5
  import { readAuthConfig } from "../../utils/utils.js";
6
6
  export default class ProjectCreate extends Command {
7
- static description = "Create a new project with an optional description.";
7
+ static description = "Create a new project.";
8
8
  static examples = [
9
- "$ <%= config.bin %> <%= command.id %> -n MyProject -d 'This is my project description'",
10
- "$ <%= config.bin %> <%= command.id %> -n MyProject",
11
- "$ <%= config.bin %> <%= command.id %>",
9
+ "$ <%= config.bin %> project create",
10
+ "$ <%= config.bin %> project create -n MyProject -d 'Project description'",
11
+ "$ <%= config.bin %> project create --name MyProject --skipConfirm",
12
12
  ];
13
13
  static flags = {
14
+ name: Flags.string({
15
+ char: "n",
16
+ description: "Name of the project",
17
+ required: false,
18
+ }),
14
19
  description: Flags.string({
15
20
  char: "d",
16
21
  description: "Description of the project",
17
22
  required: false,
18
23
  }),
19
- name: Flags.string({
20
- char: "n",
21
- description: "Name of the project",
22
- required: false,
24
+ skipConfirm: Flags.boolean({
25
+ char: "y",
26
+ description: "Skip confirmation prompt",
27
+ default: false,
23
28
  }),
24
29
  };
25
30
  async run() {
26
31
  const auth = await readAuthConfig(this);
27
- console.log(chalk.blue.bold("\n Create a New Project \n"));
28
32
  const { flags } = await this.parse(ProjectCreate);
29
- let answers = {};
30
- const questions = [];
31
- if (!flags.name) {
32
- questions.push({
33
- message: chalk.green("Enter the project name:"),
34
- name: "name",
35
- type: "input",
36
- validate: (input) => (input ? true : "Project name is required"),
37
- });
38
- }
39
- if (!flags.description) {
40
- questions.push({
41
- default: "",
42
- message: chalk.green("Enter the project description (optional):"),
43
- name: "description",
44
- type: "input",
45
- });
33
+ let { name, description } = flags;
34
+ // Modo interactivo si no se proporcionan los flags necesarios
35
+ if (!name) {
36
+ const answers = await inquirer.prompt([
37
+ {
38
+ message: "Enter the project name:",
39
+ name: "name",
40
+ type: "input",
41
+ validate: (input) => (input ? true : "Project name is required"),
42
+ },
43
+ {
44
+ message: "Enter the project description (optional):",
45
+ name: "description",
46
+ type: "input",
47
+ default: description || "",
48
+ },
49
+ ]);
50
+ name = answers.name;
51
+ description = answers.description;
46
52
  }
47
- if (questions.length > 0) {
48
- answers = await inquirer.prompt(questions);
53
+ // Confirmar si no se especifica --skipConfirm
54
+ if (!flags.skipConfirm) {
55
+ const confirm = await inquirer.prompt([
56
+ {
57
+ type: 'confirm',
58
+ name: 'proceed',
59
+ message: 'Do you want to create this project?',
60
+ default: false,
61
+ },
62
+ ]);
63
+ if (!confirm.proceed) {
64
+ this.error(chalk.yellow("Project creation cancelled."));
65
+ return;
66
+ }
49
67
  }
50
- const name = flags.name || answers.name;
51
- const description = flags.description || answers.description;
52
68
  try {
69
+ console.log(JSON.stringify({
70
+ name,
71
+ description,
72
+ }, null, 2));
53
73
  const response = await axios.post(`${auth.url}/api/trpc/project.create`, {
54
74
  json: {
55
- description,
56
75
  name,
76
+ description,
57
77
  },
58
78
  }, {
59
79
  headers: {
@@ -62,13 +82,12 @@ export default class ProjectCreate extends Command {
62
82
  },
63
83
  });
64
84
  if (!response.data.result.data.json) {
65
- this.error(chalk.red("Error`"));
85
+ this.error(chalk.red("Error creating project", response.data.result.data.json));
66
86
  }
67
87
  this.log(chalk.green(`Project '${name}' created successfully.`));
68
88
  }
69
89
  catch (error) {
70
- // @ts-expect-error hola
71
- this.error(chalk.red(`Failed to create project: ${error.message}`));
90
+ this.error(chalk.red(`Error creating project: ${error.message}`));
72
91
  }
73
92
  }
74
93
  }
@@ -6,14 +6,21 @@ const __filename = fileURLToPath(import.meta.url);
6
6
  const __dirname = path.dirname(__filename);
7
7
  const configPath = path.join(__dirname, "..", "..", "config.json");
8
8
  export const readAuthConfig = async (command) => {
9
+ // Primero intentar leer desde variables de entorno
10
+ const envToken = process.env.DOKPLOY_AUTH_TOKEN;
11
+ const envUrl = process.env.DOKPLOY_URL;
12
+ if (envToken && envUrl) {
13
+ return { token: envToken, url: envUrl };
14
+ }
15
+ // Si no hay variables de entorno, usar el archivo de configuración
9
16
  if (!fs.existsSync(configPath)) {
10
- command.error(chalk.red("No configuration file found. Please authenticate first using the 'authenticate' command."));
17
+ command.error(chalk.red("No configuration file found and no environment variables set. Please authenticate first using the 'authenticate' command or set DOKPLOY_URL and DOKPLOY_AUTH_TOKEN environment variables."));
11
18
  }
12
19
  const configFileContent = fs.readFileSync(configPath, "utf8");
13
20
  const config = JSON.parse(configFileContent);
14
21
  const { token, url } = config;
15
22
  if (!url || !token) {
16
- command.error(chalk.red("Incomplete authentication details. Please authenticate again using the 'authenticate' command."));
23
+ command.error(chalk.red("Incomplete authentication details. Please authenticate again using the 'authenticate' command or set environment variables."));
17
24
  }
18
25
  return { token, url };
19
26
  };