@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.
- package/LICENSE.md +21 -0
- package/dist/commands/app/create.d.ts +4 -0
- package/dist/commands/app/create.js +87 -37
- package/dist/commands/app/delete.d.ts +2 -0
- package/dist/commands/app/delete.js +50 -28
- package/dist/commands/app/deploy.d.ts +5 -0
- package/dist/commands/app/deploy.js +93 -55
- package/dist/commands/app/stop.d.ts +5 -0
- package/dist/commands/app/stop.js +87 -54
- package/dist/commands/database/mariadb/create.d.ts +9 -0
- package/dist/commands/database/mariadb/create.js +160 -66
- package/dist/commands/database/mariadb/delete.d.ts +2 -0
- package/dist/commands/database/mariadb/delete.js +56 -47
- package/dist/commands/database/mariadb/deploy.d.ts +5 -0
- package/dist/commands/database/mariadb/deploy.js +88 -54
- package/dist/commands/database/mariadb/stop.d.ts +5 -0
- package/dist/commands/database/mariadb/stop.js +88 -54
- package/dist/commands/database/mongo/create.d.ts +8 -0
- package/dist/commands/database/mongo/create.js +145 -76
- package/dist/commands/database/mongo/delete.d.ts +2 -0
- package/dist/commands/database/mongo/delete.js +56 -45
- package/dist/commands/database/mongo/deploy.d.ts +5 -0
- package/dist/commands/database/mongo/deploy.js +88 -54
- package/dist/commands/database/mongo/stop.d.ts +5 -0
- package/dist/commands/database/mongo/stop.js +88 -54
- package/dist/commands/database/mysql/create.d.ts +9 -0
- package/dist/commands/database/mysql/create.js +168 -81
- package/dist/commands/database/mysql/delete.d.ts +2 -0
- package/dist/commands/database/mysql/delete.js +56 -47
- package/dist/commands/database/mysql/deploy.js +70 -53
- package/dist/commands/database/mysql/stop.js +70 -53
- package/dist/commands/database/postgres/create.d.ts +8 -0
- package/dist/commands/database/postgres/create.js +155 -76
- package/dist/commands/database/postgres/delete.d.ts +2 -0
- package/dist/commands/database/postgres/delete.js +56 -44
- package/dist/commands/database/postgres/deploy.d.ts +5 -0
- package/dist/commands/database/postgres/deploy.js +90 -56
- package/dist/commands/database/postgres/stop.d.ts +5 -0
- package/dist/commands/database/postgres/stop.js +91 -57
- package/dist/commands/database/redis/create.d.ts +6 -0
- package/dist/commands/database/redis/create.js +129 -65
- package/dist/commands/database/redis/delete.d.ts +2 -0
- package/dist/commands/database/redis/delete.js +60 -50
- package/dist/commands/database/redis/deploy.d.ts +5 -0
- package/dist/commands/database/redis/deploy.js +90 -56
- package/dist/commands/database/redis/stop.d.ts +5 -0
- package/dist/commands/database/redis/stop.js +91 -57
- package/dist/commands/env/pull.d.ts +10 -0
- package/dist/commands/env/pull.js +68 -0
- package/dist/commands/env/push.d.ts +10 -0
- package/dist/commands/env/push.js +106 -0
- package/dist/commands/project/create.d.ts +2 -1
- package/dist/commands/project/create.js +53 -34
- package/dist/utils/utils.js +9 -2
- package/oclif.manifest.json +895 -110
- package/package.json +3 -2
- 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
|
|
7
|
+
static description = "Create a new project.";
|
|
8
8
|
static examples = [
|
|
9
|
-
"$ <%= config.bin %>
|
|
10
|
-
"$ <%= config.bin %>
|
|
11
|
-
"$ <%= config.bin %>
|
|
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
|
-
|
|
20
|
-
char: "
|
|
21
|
-
description: "
|
|
22
|
-
|
|
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
|
|
30
|
-
|
|
31
|
-
if (!
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
48
|
-
|
|
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
|
-
|
|
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
|
}
|
package/dist/utils/utils.js
CHANGED
|
@@ -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
|
};
|