@dokploy/cli 0.2.5 → 0.2.7

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 (31) hide show
  1. package/dist/commands/app/create.js +1 -1
  2. package/dist/commands/app/delete.js +1 -1
  3. package/dist/commands/app/deploy.js +1 -1
  4. package/dist/commands/app/stop.js +1 -1
  5. package/dist/commands/authenticate.js +6 -2
  6. package/dist/commands/database/mariadb/create.js +1 -12
  7. package/dist/commands/database/mariadb/delete.js +1 -1
  8. package/dist/commands/database/mariadb/deploy.js +1 -1
  9. package/dist/commands/database/mariadb/stop.js +1 -1
  10. package/dist/commands/database/mongo/create.js +1 -1
  11. package/dist/commands/database/mongo/delete.js +1 -1
  12. package/dist/commands/database/mongo/deploy.js +1 -1
  13. package/dist/commands/database/mongo/stop.js +1 -1
  14. package/dist/commands/database/mysql/create.js +1 -12
  15. package/dist/commands/database/mysql/delete.js +1 -1
  16. package/dist/commands/database/mysql/deploy.js +1 -1
  17. package/dist/commands/database/mysql/stop.js +1 -1
  18. package/dist/commands/database/postgres/create.js +1 -11
  19. package/dist/commands/database/postgres/delete.js +1 -1
  20. package/dist/commands/database/postgres/deploy.js +1 -1
  21. package/dist/commands/database/postgres/stop.js +1 -1
  22. package/dist/commands/database/redis/create.js +1 -9
  23. package/dist/commands/database/redis/delete.js +1 -1
  24. package/dist/commands/database/redis/deploy.js +1 -1
  25. package/dist/commands/database/redis/stop.js +1 -1
  26. package/dist/commands/env/push.js +2 -2
  27. package/dist/commands/project/create.js +1 -5
  28. package/dist/commands/verify.js +31 -14
  29. package/dist/utils/shared.js +2 -2
  30. package/oclif.manifest.json +322 -322
  31. package/package.json +1 -1
@@ -111,7 +111,7 @@ export default class AppCreate extends Command {
111
111
  },
112
112
  }, {
113
113
  headers: {
114
- Authorization: `Bearer ${auth.token}`,
114
+ "x-api-key": auth.token,
115
115
  "Content-Type": "application/json",
116
116
  },
117
117
  });
@@ -90,7 +90,7 @@ export default class AppDelete extends Command {
90
90
  },
91
91
  }, {
92
92
  headers: {
93
- Authorization: `Bearer ${auth.token}`,
93
+ "x-api-key": auth.token,
94
94
  "Content-Type": "application/json",
95
95
  },
96
96
  });
@@ -91,7 +91,7 @@ export default class AppDeploy extends Command {
91
91
  },
92
92
  }, {
93
93
  headers: {
94
- Authorization: `Bearer ${auth.token}`,
94
+ "x-api-key": auth.token,
95
95
  "Content-Type": "application/json",
96
96
  },
97
97
  });
@@ -86,7 +86,7 @@ export default class AppStop extends Command {
86
86
  },
87
87
  }, {
88
88
  headers: {
89
- Authorization: `Bearer ${auth.token}`,
89
+ "x-api-key": auth.token,
90
90
  "Content-Type": "application/json",
91
91
  },
92
92
  });
@@ -61,9 +61,9 @@ export default class Authenticate extends Command {
61
61
  config.url = url;
62
62
  try {
63
63
  console.log(`\n${chalk.blue("Validating server...")}`);
64
- await axios.post(`${url}/api/trpc/auth.verifyToken`, {}, {
64
+ await axios.get(`${url}/api/trpc/user.get`, {
65
65
  headers: {
66
- Authorization: `Bearer ${token}`,
66
+ "x-api-key": token,
67
67
  "Content-Type": "application/json",
68
68
  },
69
69
  });
@@ -77,3 +77,7 @@ export default class Authenticate extends Command {
77
77
  }
78
78
  }
79
79
  }
80
+ // curl -X 'GET' \
81
+ // 'https://panel.jinza.app/api/project.all' \
82
+ // -H 'accept: application/json' \
83
+ // -H 'x-api-key: EawCkTREMhxoAqvCxJFZurgCGoDZPjYHHrLgUPghRjJTpXLaahFdhCOGfABZXTRP'
@@ -158,17 +158,6 @@ export default class DatabaseMariadbCreate extends Command {
158
158
  }
159
159
  }
160
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));
172
161
  const response = await axios.post(`${auth.url}/api/trpc/mariadb.create`, {
173
162
  json: {
174
163
  name,
@@ -183,7 +172,7 @@ export default class DatabaseMariadbCreate extends Command {
183
172
  },
184
173
  }, {
185
174
  headers: {
186
- Authorization: `Bearer ${auth.token}`,
175
+ "x-api-key": auth.token,
187
176
  "Content-Type": "application/json",
188
177
  },
189
178
  });
@@ -88,7 +88,7 @@ export default class DatabaseMariadbDelete extends Command {
88
88
  },
89
89
  }, {
90
90
  headers: {
91
- Authorization: `Bearer ${auth.token}`,
91
+ "x-api-key": auth.token,
92
92
  "Content-Type": "application/json",
93
93
  },
94
94
  });
@@ -87,7 +87,7 @@ export default class DatabaseMariadbDeploy extends Command {
87
87
  },
88
88
  }, {
89
89
  headers: {
90
- Authorization: `Bearer ${auth.token}`,
90
+ "x-api-key": auth.token,
91
91
  "Content-Type": "application/json",
92
92
  },
93
93
  });
@@ -87,7 +87,7 @@ export default class DatabaseMariadbStop extends Command {
87
87
  },
88
88
  }, {
89
89
  headers: {
90
- Authorization: `Bearer ${auth.token}`,
90
+ "x-api-key": auth.token,
91
91
  "Content-Type": "application/json",
92
92
  },
93
93
  });
@@ -160,7 +160,7 @@ export default class DatabaseMongoCreate extends Command {
160
160
  },
161
161
  }, {
162
162
  headers: {
163
- Authorization: `Bearer ${auth.token}`,
163
+ "x-api-key": auth.token,
164
164
  "Content-Type": "application/json",
165
165
  },
166
166
  });
@@ -90,7 +90,7 @@ export default class DatabaseMongoDelete extends Command {
90
90
  },
91
91
  }, {
92
92
  headers: {
93
- Authorization: `Bearer ${auth.token}`,
93
+ "x-api-key": auth.token,
94
94
  "Content-Type": "application/json",
95
95
  },
96
96
  });
@@ -87,7 +87,7 @@ export default class DatabaseMongoDeploy extends Command {
87
87
  },
88
88
  }, {
89
89
  headers: {
90
- Authorization: `Bearer ${auth.token}`,
90
+ "x-api-key": auth.token,
91
91
  "Content-Type": "application/json",
92
92
  },
93
93
  });
@@ -87,7 +87,7 @@ export default class DatabaseMongoStop extends Command {
87
87
  },
88
88
  }, {
89
89
  headers: {
90
- Authorization: `Bearer ${auth.token}`,
90
+ "x-api-key": auth.token,
91
91
  "Content-Type": "application/json",
92
92
  },
93
93
  });
@@ -158,17 +158,6 @@ export default class DatabaseMysqlCreate extends Command {
158
158
  }
159
159
  }
160
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));
172
161
  const response = await axios.post(`${auth.url}/api/trpc/mysql.create`, {
173
162
  json: {
174
163
  name,
@@ -183,7 +172,7 @@ export default class DatabaseMysqlCreate extends Command {
183
172
  },
184
173
  }, {
185
174
  headers: {
186
- Authorization: `Bearer ${auth.token}`,
175
+ "x-api-key": auth.token,
187
176
  "Content-Type": "application/json",
188
177
  },
189
178
  });
@@ -90,7 +90,7 @@ export default class DatabaseMysqlDelete extends Command {
90
90
  },
91
91
  }, {
92
92
  headers: {
93
- Authorization: `Bearer ${auth.token}`,
93
+ "x-api-key": auth.token,
94
94
  "Content-Type": "application/json",
95
95
  },
96
96
  });
@@ -70,7 +70,7 @@ export default class DatabaseMysqlDeploy extends Command {
70
70
  },
71
71
  }, {
72
72
  headers: {
73
- Authorization: `Bearer ${auth.token}`,
73
+ "x-api-key": auth.token,
74
74
  "Content-Type": "application/json",
75
75
  },
76
76
  });
@@ -70,7 +70,7 @@ export default class DatabaseMysqlStop extends Command {
70
70
  },
71
71
  }, {
72
72
  headers: {
73
- Authorization: `Bearer ${auth.token}`,
73
+ "x-api-key": auth.token,
74
74
  "Content-Type": "application/json",
75
75
  },
76
76
  });
@@ -147,16 +147,6 @@ export default class DatabasePostgresCreate extends Command {
147
147
  }
148
148
  }
149
149
  try {
150
- console.log(JSON.stringify({
151
- name,
152
- databaseName,
153
- description,
154
- databasePassword,
155
- databaseUser,
156
- dockerImage,
157
- appName,
158
- projectId,
159
- }, null, 2));
160
150
  const response = await axios.post(`${auth.url}/api/trpc/postgres.create`, {
161
151
  json: {
162
152
  name,
@@ -170,7 +160,7 @@ export default class DatabasePostgresCreate extends Command {
170
160
  },
171
161
  }, {
172
162
  headers: {
173
- Authorization: `Bearer ${auth.token}`,
163
+ "x-api-key": auth.token,
174
164
  "Content-Type": "application/json",
175
165
  },
176
166
  });
@@ -90,7 +90,7 @@ export default class DatabasePostgresDelete extends Command {
90
90
  },
91
91
  }, {
92
92
  headers: {
93
- Authorization: `Bearer ${auth.token}`,
93
+ "x-api-key": auth.token,
94
94
  "Content-Type": "application/json",
95
95
  },
96
96
  });
@@ -87,7 +87,7 @@ export default class DatabasePostgresDeploy extends Command {
87
87
  },
88
88
  }, {
89
89
  headers: {
90
- Authorization: `Bearer ${auth.token}`,
90
+ "x-api-key": auth.token,
91
91
  "Content-Type": "application/json",
92
92
  },
93
93
  });
@@ -87,7 +87,7 @@ export default class DatabasePostgresStop extends Command {
87
87
  },
88
88
  }, {
89
89
  headers: {
90
- Authorization: `Bearer ${auth.token}`,
90
+ "x-api-key": auth.token,
91
91
  "Content-Type": "application/json",
92
92
  },
93
93
  });
@@ -124,14 +124,6 @@ export default class DatabaseRedisCreate extends Command {
124
124
  }
125
125
  }
126
126
  try {
127
- console.log(JSON.stringify({
128
- name,
129
- description,
130
- databasePassword,
131
- dockerImage,
132
- appName,
133
- projectId,
134
- }, null, 2));
135
127
  const response = await axios.post(`${auth.url}/api/trpc/redis.create`, {
136
128
  json: {
137
129
  name,
@@ -143,7 +135,7 @@ export default class DatabaseRedisCreate extends Command {
143
135
  },
144
136
  }, {
145
137
  headers: {
146
- Authorization: `Bearer ${auth.token}`,
138
+ "x-api-key": auth.token,
147
139
  "Content-Type": "application/json",
148
140
  },
149
141
  });
@@ -90,7 +90,7 @@ export default class DatabaseRedisDelete extends Command {
90
90
  },
91
91
  }, {
92
92
  headers: {
93
- Authorization: `Bearer ${auth.token}`,
93
+ "x-api-key": auth.token,
94
94
  "Content-Type": "application/json",
95
95
  },
96
96
  });
@@ -87,7 +87,7 @@ export default class DatabaseRedisDeploy extends Command {
87
87
  },
88
88
  }, {
89
89
  headers: {
90
- Authorization: `Bearer ${auth.token}`,
90
+ "x-api-key": auth.token,
91
91
  "Content-Type": "application/json",
92
92
  },
93
93
  });
@@ -87,7 +87,7 @@ export default class DatabaseRedisStop extends Command {
87
87
  },
88
88
  }, {
89
89
  headers: {
90
- Authorization: `Bearer ${auth.token}`,
90
+ "x-api-key": auth.token,
91
91
  "Content-Type": "application/json",
92
92
  },
93
93
  });
@@ -75,7 +75,7 @@ export default class EnvPush extends Command {
75
75
  }
76
76
  }, {
77
77
  headers: {
78
- Authorization: `Bearer ${auth.token}`,
78
+ "x-api-key": auth.token,
79
79
  "Content-Type": "application/json",
80
80
  },
81
81
  });
@@ -93,7 +93,7 @@ export default class EnvPush extends Command {
93
93
  }
94
94
  }, {
95
95
  headers: {
96
- Authorization: `Bearer ${auth.token}`,
96
+ "x-api-key": auth.token,
97
97
  "Content-Type": "application/json",
98
98
  },
99
99
  });
@@ -66,10 +66,6 @@ export default class ProjectCreate extends Command {
66
66
  }
67
67
  }
68
68
  try {
69
- console.log(JSON.stringify({
70
- name,
71
- description,
72
- }, null, 2));
73
69
  const response = await axios.post(`${auth.url}/api/trpc/project.create`, {
74
70
  json: {
75
71
  name,
@@ -77,7 +73,7 @@ export default class ProjectCreate extends Command {
77
73
  },
78
74
  }, {
79
75
  headers: {
80
- Authorization: `Bearer ${auth.token}`,
76
+ "x-api-key": auth.token,
81
77
  "Content-Type": "application/json",
82
78
  },
83
79
  });
@@ -12,34 +12,51 @@ export default class Verify extends Command {
12
12
  static examples = ["$ <%= config.bin %> <%= command.id %>"];
13
13
  async run() {
14
14
  console.log(chalk.blue.bold("\nVerifying Authentication Token"));
15
- if (!fs.existsSync(configPath)) {
16
- this.error(chalk.red("No configuration file found. Please authenticate first using `authenticate` command."));
15
+ let token;
16
+ let url;
17
+ // Verificar variables de entorno primero
18
+ const envToken = process.env.DOKPLOY_AUTH_TOKEN;
19
+ const envUrl = process.env.DOKPLOY_URL;
20
+ if (envToken && envUrl) {
21
+ token = envToken;
22
+ url = envUrl;
23
+ this.log(chalk.green("Using environment variables for authentication"));
17
24
  }
18
- const configFileContent = fs.readFileSync(configPath, "utf8");
19
- const config = JSON.parse(configFileContent);
20
- const { token, url } = config;
21
- if (!url || !token) {
22
- this.error(chalk.red("Incomplete authentication details. Please authenticate again using `authenticate` command."));
25
+ else {
26
+ // Si no hay variables de entorno, verificar archivo de configuración
27
+ if (!fs.existsSync(configPath)) {
28
+ this.error(chalk.red("No configuration found. Please either:\n" +
29
+ "1. Authenticate using `authenticate` command\n" +
30
+ "2. Set DOKPLOY_URL and DOKPLOY_AUTH_TOKEN environment variables"));
31
+ }
32
+ try {
33
+ const config = JSON.parse(fs.readFileSync(configPath, "utf8"));
34
+ token = config.token;
35
+ url = config.url;
36
+ this.log(chalk.green("Using configuration file for authentication"));
37
+ }
38
+ catch (error) {
39
+ this.error(chalk.red("Invalid configuration file. Please authenticate again using `authenticate` command."));
40
+ }
23
41
  }
42
+ // Validar el token contra el servidor
24
43
  try {
25
- console.log(`\n${chalk.blue("Validating token...")}`);
26
- const response = await axios.post(`${url}/api/trpc/auth.verifyToken`, {}, {
44
+ console.log(chalk.blue("Validating token with server..."));
45
+ const response = await axios.get(`${url}/api/trpc/user.get`, {
27
46
  headers: {
28
- Authorization: `Bearer ${token}`,
47
+ "x-api-key": token,
29
48
  "Content-Type": "application/json",
30
49
  },
31
50
  });
32
51
  if (response.data.result.data.json) {
33
- this.log(chalk.green("Token is valid."));
52
+ this.log(chalk.green("\n✓ Token is valid"));
34
53
  }
35
54
  else {
36
55
  this.error(chalk.red("Invalid token. Please authenticate again using `authenticate` command."));
37
56
  }
38
57
  }
39
58
  catch (error) {
40
- this.error(chalk.red(
41
- // @ts-ignore
42
- `Failed to verify token: ${error.message}. Please authenticate again using 'authenticate' command.`));
59
+ this.error(chalk.red(`Failed to verify token: ${error.message}. Please authenticate again using 'authenticate' command.`));
43
60
  }
44
61
  }
45
62
  }
@@ -4,7 +4,7 @@ export const getProjects = async (auth, command) => {
4
4
  try {
5
5
  const response = await axios.get(`${auth.url}/api/trpc/project.all`, {
6
6
  headers: {
7
- Authorization: `Bearer ${auth.token}`,
7
+ "x-api-key": auth.token,
8
8
  "Content-Type": "application/json",
9
9
  },
10
10
  });
@@ -30,7 +30,7 @@ export const getProject = async (projectId, auth, command) => {
30
30
  }
31
31
  const response = await axios.get(`${auth.url}/api/trpc/project.one`, {
32
32
  headers: {
33
- Authorization: `Bearer ${auth.token}`,
33
+ "x-api-key": auth.token,
34
34
  "Content-Type": "application/json",
35
35
  },
36
36
  params: {