@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.
- package/dist/commands/app/create.js +1 -1
- package/dist/commands/app/delete.js +1 -1
- package/dist/commands/app/deploy.js +1 -1
- package/dist/commands/app/stop.js +1 -1
- package/dist/commands/authenticate.js +6 -2
- package/dist/commands/database/mariadb/create.js +1 -12
- package/dist/commands/database/mariadb/delete.js +1 -1
- package/dist/commands/database/mariadb/deploy.js +1 -1
- package/dist/commands/database/mariadb/stop.js +1 -1
- package/dist/commands/database/mongo/create.js +1 -1
- package/dist/commands/database/mongo/delete.js +1 -1
- package/dist/commands/database/mongo/deploy.js +1 -1
- package/dist/commands/database/mongo/stop.js +1 -1
- package/dist/commands/database/mysql/create.js +1 -12
- package/dist/commands/database/mysql/delete.js +1 -1
- package/dist/commands/database/mysql/deploy.js +1 -1
- package/dist/commands/database/mysql/stop.js +1 -1
- package/dist/commands/database/postgres/create.js +1 -11
- package/dist/commands/database/postgres/delete.js +1 -1
- package/dist/commands/database/postgres/deploy.js +1 -1
- package/dist/commands/database/postgres/stop.js +1 -1
- package/dist/commands/database/redis/create.js +1 -9
- package/dist/commands/database/redis/delete.js +1 -1
- package/dist/commands/database/redis/deploy.js +1 -1
- package/dist/commands/database/redis/stop.js +1 -1
- package/dist/commands/env/push.js +2 -2
- package/dist/commands/project/create.js +1 -5
- package/dist/commands/verify.js +31 -14
- package/dist/utils/shared.js +2 -2
- package/oclif.manifest.json +322 -322
- package/package.json +1 -1
|
@@ -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.
|
|
64
|
+
await axios.get(`${url}/api/trpc/user.get`, {
|
|
65
65
|
headers: {
|
|
66
|
-
|
|
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
|
-
|
|
175
|
+
"x-api-key": auth.token,
|
|
187
176
|
"Content-Type": "application/json",
|
|
188
177
|
},
|
|
189
178
|
});
|
|
@@ -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
|
-
|
|
175
|
+
"x-api-key": auth.token,
|
|
187
176
|
"Content-Type": "application/json",
|
|
188
177
|
},
|
|
189
178
|
});
|
|
@@ -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
|
-
|
|
163
|
+
"x-api-key": auth.token,
|
|
174
164
|
"Content-Type": "application/json",
|
|
175
165
|
},
|
|
176
166
|
});
|
|
@@ -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
|
-
|
|
138
|
+
"x-api-key": auth.token,
|
|
147
139
|
"Content-Type": "application/json",
|
|
148
140
|
},
|
|
149
141
|
});
|
|
@@ -75,7 +75,7 @@ export default class EnvPush extends Command {
|
|
|
75
75
|
}
|
|
76
76
|
}, {
|
|
77
77
|
headers: {
|
|
78
|
-
|
|
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
|
-
|
|
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
|
-
|
|
76
|
+
"x-api-key": auth.token,
|
|
81
77
|
"Content-Type": "application/json",
|
|
82
78
|
},
|
|
83
79
|
});
|
package/dist/commands/verify.js
CHANGED
|
@@ -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
|
-
|
|
16
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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(
|
|
26
|
-
const response = await axios.
|
|
44
|
+
console.log(chalk.blue("Validating token with server..."));
|
|
45
|
+
const response = await axios.get(`${url}/api/trpc/user.get`, {
|
|
27
46
|
headers: {
|
|
28
|
-
|
|
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
|
}
|
package/dist/utils/shared.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
33
|
+
"x-api-key": auth.token,
|
|
34
34
|
"Content-Type": "application/json",
|
|
35
35
|
},
|
|
36
36
|
params: {
|