@dokploy/cli 0.2.8 → 0.3.1
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 +1 -1
- package/dist/client.d.ts +10 -0
- package/dist/client.js +72 -0
- package/dist/commands/auth.d.ts +2 -0
- package/dist/commands/auth.js +28 -0
- package/dist/generated/commands.d.ts +2 -0
- package/dist/generated/commands.js +9059 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +24 -1
- package/package.json +25 -58
- package/readme.md +101 -83
- package/bin/dev.cmd +0 -3
- package/bin/dev.js +0 -6
- package/bin/run.cmd +0 -3
- package/bin/run.js +0 -5
- package/dist/commands/app/create.d.ts +0 -17
- package/dist/commands/app/create.js +0 -127
- package/dist/commands/app/delete.d.ts +0 -11
- package/dist/commands/app/delete.js +0 -106
- package/dist/commands/app/deploy.d.ts +0 -11
- package/dist/commands/app/deploy.js +0 -107
- package/dist/commands/app/stop.d.ts +0 -11
- package/dist/commands/app/stop.js +0 -102
- package/dist/commands/authenticate.d.ts +0 -10
- package/dist/commands/authenticate.js +0 -83
- package/dist/commands/database/mariadb/create.d.ts +0 -18
- package/dist/commands/database/mariadb/create.js +0 -188
- package/dist/commands/database/mariadb/delete.d.ts +0 -11
- package/dist/commands/database/mariadb/delete.js +0 -104
- package/dist/commands/database/mariadb/deploy.d.ts +0 -11
- package/dist/commands/database/mariadb/deploy.js +0 -103
- package/dist/commands/database/mariadb/stop.d.ts +0 -11
- package/dist/commands/database/mariadb/stop.js +0 -103
- package/dist/commands/database/mongo/create.d.ts +0 -17
- package/dist/commands/database/mongo/create.js +0 -176
- package/dist/commands/database/mongo/delete.d.ts +0 -11
- package/dist/commands/database/mongo/delete.js +0 -106
- package/dist/commands/database/mongo/deploy.d.ts +0 -11
- package/dist/commands/database/mongo/deploy.js +0 -103
- package/dist/commands/database/mongo/stop.d.ts +0 -11
- package/dist/commands/database/mongo/stop.js +0 -103
- package/dist/commands/database/mysql/create.d.ts +0 -18
- package/dist/commands/database/mysql/create.js +0 -188
- package/dist/commands/database/mysql/delete.d.ts +0 -11
- package/dist/commands/database/mysql/delete.js +0 -106
- package/dist/commands/database/mysql/deploy.d.ts +0 -6
- package/dist/commands/database/mysql/deploy.js +0 -86
- package/dist/commands/database/mysql/stop.d.ts +0 -6
- package/dist/commands/database/mysql/stop.js +0 -86
- package/dist/commands/database/postgres/create.d.ts +0 -17
- package/dist/commands/database/postgres/create.js +0 -176
- package/dist/commands/database/postgres/delete.d.ts +0 -11
- package/dist/commands/database/postgres/delete.js +0 -106
- package/dist/commands/database/postgres/deploy.d.ts +0 -11
- package/dist/commands/database/postgres/deploy.js +0 -103
- package/dist/commands/database/postgres/stop.d.ts +0 -11
- package/dist/commands/database/postgres/stop.js +0 -103
- package/dist/commands/database/redis/create.d.ts +0 -15
- package/dist/commands/database/redis/create.js +0 -151
- package/dist/commands/database/redis/delete.d.ts +0 -11
- package/dist/commands/database/redis/delete.js +0 -106
- package/dist/commands/database/redis/deploy.d.ts +0 -11
- package/dist/commands/database/redis/deploy.js +0 -103
- package/dist/commands/database/redis/stop.d.ts +0 -11
- package/dist/commands/database/redis/stop.js +0 -103
- package/dist/commands/env/pull.d.ts +0 -10
- package/dist/commands/env/pull.js +0 -68
- package/dist/commands/env/push.d.ts +0 -10
- package/dist/commands/env/push.js +0 -106
- package/dist/commands/project/create.d.ts +0 -11
- package/dist/commands/project/create.js +0 -89
- package/dist/commands/project/info.d.ts +0 -10
- package/dist/commands/project/info.js +0 -122
- package/dist/commands/project/list.d.ts +0 -6
- package/dist/commands/project/list.js +0 -43
- package/dist/commands/verify.d.ts +0 -6
- package/dist/commands/verify.js +0 -62
- package/dist/utils/http.d.ts +0 -4
- package/dist/utils/http.js +0 -4
- package/dist/utils/shared.d.ts +0 -10
- package/dist/utils/shared.js +0 -55
- package/dist/utils/slug.d.ts +0 -1
- package/dist/utils/slug.js +0 -12
- package/dist/utils/slugify.d.ts +0 -3
- package/dist/utils/slugify.js +0 -2
- package/dist/utils/utils.d.ts +0 -6
- package/dist/utils/utils.js +0 -26
- package/oclif.manifest.json +0 -1680
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { Command, Flags } from "@oclif/core";
|
|
2
|
-
import axios from "axios";
|
|
3
|
-
import chalk from "chalk";
|
|
4
|
-
import inquirer from "inquirer";
|
|
5
|
-
import { slugify } from "../../../utils/slug.js";
|
|
6
|
-
import { readAuthConfig } from "../../../utils/utils.js";
|
|
7
|
-
import { getProjects } from "../../../utils/shared.js";
|
|
8
|
-
export default class DatabaseRedisCreate extends Command {
|
|
9
|
-
static description = "Create a new Redis instance within a project.";
|
|
10
|
-
static examples = ["$ <%= config.bin %> redis create"];
|
|
11
|
-
static flags = {
|
|
12
|
-
projectId: Flags.string({
|
|
13
|
-
char: "p",
|
|
14
|
-
description: "ID of the project",
|
|
15
|
-
required: false,
|
|
16
|
-
}),
|
|
17
|
-
name: Flags.string({
|
|
18
|
-
char: "n",
|
|
19
|
-
description: "Instance name",
|
|
20
|
-
required: false,
|
|
21
|
-
}),
|
|
22
|
-
description: Flags.string({
|
|
23
|
-
char: "d",
|
|
24
|
-
description: "Instance description",
|
|
25
|
-
required: false,
|
|
26
|
-
}),
|
|
27
|
-
databasePassword: Flags.string({
|
|
28
|
-
description: "Redis password",
|
|
29
|
-
required: false,
|
|
30
|
-
}),
|
|
31
|
-
dockerImage: Flags.string({
|
|
32
|
-
description: "Docker image",
|
|
33
|
-
default: "redis:7",
|
|
34
|
-
}),
|
|
35
|
-
skipConfirm: Flags.boolean({
|
|
36
|
-
char: "y",
|
|
37
|
-
description: "Skip confirmation prompt",
|
|
38
|
-
default: false,
|
|
39
|
-
}),
|
|
40
|
-
appName: Flags.string({
|
|
41
|
-
description: "App name",
|
|
42
|
-
required: false,
|
|
43
|
-
}),
|
|
44
|
-
};
|
|
45
|
-
async run() {
|
|
46
|
-
const auth = await readAuthConfig(this);
|
|
47
|
-
const { flags } = await this.parse(DatabaseRedisCreate);
|
|
48
|
-
let { projectId, name, description, databasePassword, dockerImage, appName } = flags;
|
|
49
|
-
// Modo interactivo si no se proporcionan los flags necesarios
|
|
50
|
-
if (!projectId || !name || !appName || !databasePassword) {
|
|
51
|
-
console.log(chalk.blue.bold("\n Listing all Projects \n"));
|
|
52
|
-
const projects = await getProjects(auth, this);
|
|
53
|
-
if (!projectId) {
|
|
54
|
-
const { project } = await inquirer.prompt([
|
|
55
|
-
{
|
|
56
|
-
choices: projects.map((project) => ({
|
|
57
|
-
name: project.name,
|
|
58
|
-
value: project,
|
|
59
|
-
})),
|
|
60
|
-
message: "Select a project to create the Redis instance in:",
|
|
61
|
-
name: "project",
|
|
62
|
-
type: "list",
|
|
63
|
-
},
|
|
64
|
-
]);
|
|
65
|
-
projectId = project.projectId;
|
|
66
|
-
}
|
|
67
|
-
if (!name || !appName || !databasePassword) {
|
|
68
|
-
const redisDetails = await inquirer.prompt([
|
|
69
|
-
{
|
|
70
|
-
message: "Enter the name:",
|
|
71
|
-
name: "name",
|
|
72
|
-
type: "input",
|
|
73
|
-
validate: (input) => (input ? true : "Instance name is required"),
|
|
74
|
-
default: name,
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
message: "Enter the instance description (optional):",
|
|
78
|
-
name: "description",
|
|
79
|
-
type: "input",
|
|
80
|
-
default: description,
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
message: "Redis password:",
|
|
84
|
-
name: "databasePassword",
|
|
85
|
-
type: "password",
|
|
86
|
-
default: databasePassword,
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
default: dockerImage || "redis:7",
|
|
90
|
-
message: "Docker Image (default: redis:7):",
|
|
91
|
-
name: "dockerImage",
|
|
92
|
-
type: "input",
|
|
93
|
-
},
|
|
94
|
-
]);
|
|
95
|
-
name = redisDetails.name;
|
|
96
|
-
description = redisDetails.description;
|
|
97
|
-
databasePassword = redisDetails.databasePassword;
|
|
98
|
-
dockerImage = redisDetails.dockerImage;
|
|
99
|
-
const appNamePrompt = await inquirer.prompt([
|
|
100
|
-
{
|
|
101
|
-
default: appName || `${slugify(name)}`,
|
|
102
|
-
message: "Enter the App name:",
|
|
103
|
-
name: "appName",
|
|
104
|
-
type: "input",
|
|
105
|
-
validate: (input) => (input ? true : "App name is required"),
|
|
106
|
-
},
|
|
107
|
-
]);
|
|
108
|
-
appName = appNamePrompt.appName;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
// Confirmar si no se especifica --skipConfirm
|
|
112
|
-
if (!flags.skipConfirm) {
|
|
113
|
-
const confirm = await inquirer.prompt([
|
|
114
|
-
{
|
|
115
|
-
type: 'confirm',
|
|
116
|
-
name: 'proceed',
|
|
117
|
-
message: 'Do you want to create this Redis instance?',
|
|
118
|
-
default: false,
|
|
119
|
-
},
|
|
120
|
-
]);
|
|
121
|
-
if (!confirm.proceed) {
|
|
122
|
-
this.error(chalk.yellow("Redis creation cancelled."));
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
try {
|
|
127
|
-
const response = await axios.post(`${auth.url}/api/trpc/redis.create`, {
|
|
128
|
-
json: {
|
|
129
|
-
name,
|
|
130
|
-
description,
|
|
131
|
-
databasePassword,
|
|
132
|
-
dockerImage,
|
|
133
|
-
appName,
|
|
134
|
-
projectId,
|
|
135
|
-
},
|
|
136
|
-
}, {
|
|
137
|
-
headers: {
|
|
138
|
-
"x-api-key": auth.token,
|
|
139
|
-
"Content-Type": "application/json",
|
|
140
|
-
},
|
|
141
|
-
});
|
|
142
|
-
if (!response.data.result.data.json) {
|
|
143
|
-
this.error(chalk.red("Error creating Redis instance", response.data.result.data.json));
|
|
144
|
-
}
|
|
145
|
-
this.log(chalk.green(`Redis instance '${name}' created successfully.`));
|
|
146
|
-
}
|
|
147
|
-
catch (error) {
|
|
148
|
-
this.error(chalk.red(`Error creating Redis instance: ${error.message}`));
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Command } from "@oclif/core";
|
|
2
|
-
export default class DatabaseRedisDelete extends Command {
|
|
3
|
-
static description: string;
|
|
4
|
-
static examples: string[];
|
|
5
|
-
static flags: {
|
|
6
|
-
projectId: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
7
|
-
redisId: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
8
|
-
skipConfirm: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
9
|
-
};
|
|
10
|
-
run(): Promise<void>;
|
|
11
|
-
}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { Command, Flags } from "@oclif/core";
|
|
2
|
-
import { readAuthConfig } from "../../../utils/utils.js";
|
|
3
|
-
import chalk from "chalk";
|
|
4
|
-
import { getProject, getProjects } from "../../../utils/shared.js";
|
|
5
|
-
import inquirer from "inquirer";
|
|
6
|
-
import axios from "axios";
|
|
7
|
-
export default class DatabaseRedisDelete extends Command {
|
|
8
|
-
static description = "Delete a Redis instance from a project.";
|
|
9
|
-
static examples = [
|
|
10
|
-
"$ <%= config.bin %> redis delete",
|
|
11
|
-
"$ <%= config.bin %> redis delete -p <projectId>",
|
|
12
|
-
];
|
|
13
|
-
static flags = {
|
|
14
|
-
projectId: Flags.string({
|
|
15
|
-
char: "p",
|
|
16
|
-
description: "ID of the project",
|
|
17
|
-
required: false,
|
|
18
|
-
}),
|
|
19
|
-
redisId: Flags.string({
|
|
20
|
-
char: "r",
|
|
21
|
-
description: "ID of the Redis instance to delete",
|
|
22
|
-
required: false,
|
|
23
|
-
}),
|
|
24
|
-
skipConfirm: Flags.boolean({
|
|
25
|
-
char: "y",
|
|
26
|
-
description: "Skip confirmation prompt",
|
|
27
|
-
default: false,
|
|
28
|
-
}),
|
|
29
|
-
};
|
|
30
|
-
async run() {
|
|
31
|
-
const auth = await readAuthConfig(this);
|
|
32
|
-
const { flags } = await this.parse(DatabaseRedisDelete);
|
|
33
|
-
let { projectId, redisId } = flags;
|
|
34
|
-
// Modo interactivo si no se proporcionan los flags necesarios
|
|
35
|
-
if (!projectId || !redisId) {
|
|
36
|
-
console.log(chalk.blue.bold("\n Listing all Projects \n"));
|
|
37
|
-
const projects = await getProjects(auth, this);
|
|
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 Redis instance from:",
|
|
46
|
-
name: "selectedProject",
|
|
47
|
-
type: "list",
|
|
48
|
-
},
|
|
49
|
-
]);
|
|
50
|
-
projectId = answers.selectedProject;
|
|
51
|
-
}
|
|
52
|
-
const projectSelected = await getProject(projectId, auth, this);
|
|
53
|
-
if (!projectSelected.redis || projectSelected.redis.length === 0) {
|
|
54
|
-
this.error(chalk.yellow("No Redis instances found in this project."));
|
|
55
|
-
}
|
|
56
|
-
if (!redisId) {
|
|
57
|
-
const dbAnswers = await inquirer.prompt([
|
|
58
|
-
{
|
|
59
|
-
// @ts-ignore
|
|
60
|
-
choices: projectSelected.redis.map((db) => ({
|
|
61
|
-
name: db.name,
|
|
62
|
-
value: db.redisId,
|
|
63
|
-
})),
|
|
64
|
-
message: "Select the Redis instance to delete:",
|
|
65
|
-
name: "selectedDb",
|
|
66
|
-
type: "list",
|
|
67
|
-
},
|
|
68
|
-
]);
|
|
69
|
-
redisId = dbAnswers.selectedDb;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
// Confirmar si no se especifica --skipConfirm
|
|
73
|
-
if (!flags.skipConfirm) {
|
|
74
|
-
const confirmAnswers = await inquirer.prompt([
|
|
75
|
-
{
|
|
76
|
-
default: false,
|
|
77
|
-
message: "Are you sure you want to delete this Redis instance?",
|
|
78
|
-
name: "confirmDelete",
|
|
79
|
-
type: "confirm",
|
|
80
|
-
},
|
|
81
|
-
]);
|
|
82
|
-
if (!confirmAnswers.confirmDelete) {
|
|
83
|
-
this.error(chalk.yellow("Redis deletion cancelled."));
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
try {
|
|
87
|
-
const response = await axios.post(`${auth.url}/api/trpc/redis.remove`, {
|
|
88
|
-
json: {
|
|
89
|
-
redisId,
|
|
90
|
-
},
|
|
91
|
-
}, {
|
|
92
|
-
headers: {
|
|
93
|
-
"x-api-key": auth.token,
|
|
94
|
-
"Content-Type": "application/json",
|
|
95
|
-
},
|
|
96
|
-
});
|
|
97
|
-
if (!response.data.result.data.json) {
|
|
98
|
-
this.error(chalk.red("Error deleting Redis instance"));
|
|
99
|
-
}
|
|
100
|
-
this.log(chalk.green("Redis instance deleted successfully."));
|
|
101
|
-
}
|
|
102
|
-
catch (error) {
|
|
103
|
-
this.error(chalk.red(`Error deleting Redis instance: ${error.message}`));
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Command } from "@oclif/core";
|
|
2
|
-
export default class DatabaseRedisDeploy extends Command {
|
|
3
|
-
static description: string;
|
|
4
|
-
static examples: string[];
|
|
5
|
-
static flags: {
|
|
6
|
-
projectId: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
7
|
-
redisId: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
8
|
-
skipConfirm: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
9
|
-
};
|
|
10
|
-
run(): Promise<void>;
|
|
11
|
-
}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { Command, Flags } from "@oclif/core";
|
|
2
|
-
import { readAuthConfig } from "../../../utils/utils.js";
|
|
3
|
-
import chalk from "chalk";
|
|
4
|
-
import { getProject, getProjects } from "../../../utils/shared.js";
|
|
5
|
-
import inquirer from "inquirer";
|
|
6
|
-
import axios from "axios";
|
|
7
|
-
export default class DatabaseRedisDeploy extends Command {
|
|
8
|
-
static description = "Deploy a Redis instance to a project.";
|
|
9
|
-
static examples = ["$ <%= config.bin %> redis deploy"];
|
|
10
|
-
static flags = {
|
|
11
|
-
projectId: Flags.string({
|
|
12
|
-
char: "p",
|
|
13
|
-
description: "ID of the project",
|
|
14
|
-
required: false,
|
|
15
|
-
}),
|
|
16
|
-
redisId: Flags.string({
|
|
17
|
-
char: "r",
|
|
18
|
-
description: "ID of the Redis instance to deploy",
|
|
19
|
-
required: false,
|
|
20
|
-
}),
|
|
21
|
-
skipConfirm: Flags.boolean({
|
|
22
|
-
char: "y",
|
|
23
|
-
description: "Skip confirmation prompt",
|
|
24
|
-
default: false,
|
|
25
|
-
}),
|
|
26
|
-
};
|
|
27
|
-
async run() {
|
|
28
|
-
const auth = await readAuthConfig(this);
|
|
29
|
-
const { flags } = await this.parse(DatabaseRedisDeploy);
|
|
30
|
-
let { projectId, redisId } = flags;
|
|
31
|
-
// Modo interactivo si no se proporcionan los flags necesarios
|
|
32
|
-
if (!projectId || !redisId) {
|
|
33
|
-
console.log(chalk.blue.bold("\n Listing all Projects \n"));
|
|
34
|
-
const projects = await getProjects(auth, this);
|
|
35
|
-
if (!projectId) {
|
|
36
|
-
const { project } = await inquirer.prompt([
|
|
37
|
-
{
|
|
38
|
-
choices: projects.map((project) => ({
|
|
39
|
-
name: project.name,
|
|
40
|
-
value: project,
|
|
41
|
-
})),
|
|
42
|
-
message: "Select a project to deploy the Redis instance from:",
|
|
43
|
-
name: "project",
|
|
44
|
-
type: "list",
|
|
45
|
-
},
|
|
46
|
-
]);
|
|
47
|
-
projectId = project.projectId;
|
|
48
|
-
}
|
|
49
|
-
const projectSelected = await getProject(projectId, auth, this);
|
|
50
|
-
if (projectSelected.redis.length === 0) {
|
|
51
|
-
this.error(chalk.yellow("No Redis instances found in this project."));
|
|
52
|
-
}
|
|
53
|
-
if (!redisId) {
|
|
54
|
-
const dbAnswers = await inquirer.prompt([
|
|
55
|
-
{
|
|
56
|
-
// @ts-ignore
|
|
57
|
-
choices: projectSelected.redis.map((db) => ({
|
|
58
|
-
name: db.name,
|
|
59
|
-
value: db.redisId,
|
|
60
|
-
})),
|
|
61
|
-
message: "Select the Redis instance to deploy:",
|
|
62
|
-
name: "selectedDb",
|
|
63
|
-
type: "list",
|
|
64
|
-
},
|
|
65
|
-
]);
|
|
66
|
-
redisId = dbAnswers.selectedDb;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
// Confirmar si no se especifica --skipConfirm
|
|
70
|
-
if (!flags.skipConfirm) {
|
|
71
|
-
const confirmAnswers = await inquirer.prompt([
|
|
72
|
-
{
|
|
73
|
-
default: false,
|
|
74
|
-
message: "Are you sure you want to deploy this Redis instance?",
|
|
75
|
-
name: "confirmDeploy",
|
|
76
|
-
type: "confirm",
|
|
77
|
-
},
|
|
78
|
-
]);
|
|
79
|
-
if (!confirmAnswers.confirmDeploy) {
|
|
80
|
-
this.error(chalk.yellow("Redis deployment cancelled."));
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
try {
|
|
84
|
-
const response = await axios.post(`${auth.url}/api/trpc/redis.deploy`, {
|
|
85
|
-
json: {
|
|
86
|
-
redisId,
|
|
87
|
-
},
|
|
88
|
-
}, {
|
|
89
|
-
headers: {
|
|
90
|
-
"x-api-key": auth.token,
|
|
91
|
-
"Content-Type": "application/json",
|
|
92
|
-
},
|
|
93
|
-
});
|
|
94
|
-
if (response.status !== 200) {
|
|
95
|
-
this.error(chalk.red("Error deploying Redis instance"));
|
|
96
|
-
}
|
|
97
|
-
this.log(chalk.green("Redis instance deployed successfully."));
|
|
98
|
-
}
|
|
99
|
-
catch (error) {
|
|
100
|
-
this.error(chalk.red(`Error deploying Redis instance: ${error.message}`));
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Command } from "@oclif/core";
|
|
2
|
-
export default class DatabaseRedisStop extends Command {
|
|
3
|
-
static description: string;
|
|
4
|
-
static examples: string[];
|
|
5
|
-
static flags: {
|
|
6
|
-
projectId: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
7
|
-
redisId: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
8
|
-
skipConfirm: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
9
|
-
};
|
|
10
|
-
run(): Promise<void>;
|
|
11
|
-
}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { Command, Flags } from "@oclif/core";
|
|
2
|
-
import { readAuthConfig } from "../../../utils/utils.js";
|
|
3
|
-
import chalk from "chalk";
|
|
4
|
-
import { getProject, getProjects } from "../../../utils/shared.js";
|
|
5
|
-
import inquirer from "inquirer";
|
|
6
|
-
import axios from "axios";
|
|
7
|
-
export default class DatabaseRedisStop extends Command {
|
|
8
|
-
static description = "Stop a Redis instance in a project.";
|
|
9
|
-
static examples = ["$ <%= config.bin %> redis stop"];
|
|
10
|
-
static flags = {
|
|
11
|
-
projectId: Flags.string({
|
|
12
|
-
char: "p",
|
|
13
|
-
description: "ID of the project",
|
|
14
|
-
required: false,
|
|
15
|
-
}),
|
|
16
|
-
redisId: Flags.string({
|
|
17
|
-
char: "r",
|
|
18
|
-
description: "ID of the Redis instance to stop",
|
|
19
|
-
required: false,
|
|
20
|
-
}),
|
|
21
|
-
skipConfirm: Flags.boolean({
|
|
22
|
-
char: "y",
|
|
23
|
-
description: "Skip confirmation prompt",
|
|
24
|
-
default: false,
|
|
25
|
-
}),
|
|
26
|
-
};
|
|
27
|
-
async run() {
|
|
28
|
-
const auth = await readAuthConfig(this);
|
|
29
|
-
const { flags } = await this.parse(DatabaseRedisStop);
|
|
30
|
-
let { projectId, redisId } = flags;
|
|
31
|
-
// Modo interactivo si no se proporcionan los flags necesarios
|
|
32
|
-
if (!projectId || !redisId) {
|
|
33
|
-
console.log(chalk.blue.bold("\n Listing all Projects \n"));
|
|
34
|
-
const projects = await getProjects(auth, this);
|
|
35
|
-
if (!projectId) {
|
|
36
|
-
const { project } = await inquirer.prompt([
|
|
37
|
-
{
|
|
38
|
-
choices: projects.map((project) => ({
|
|
39
|
-
name: project.name,
|
|
40
|
-
value: project,
|
|
41
|
-
})),
|
|
42
|
-
message: "Select a project to stop the Redis instance from:",
|
|
43
|
-
name: "project",
|
|
44
|
-
type: "list",
|
|
45
|
-
},
|
|
46
|
-
]);
|
|
47
|
-
projectId = project.projectId;
|
|
48
|
-
}
|
|
49
|
-
const projectSelected = await getProject(projectId, auth, this);
|
|
50
|
-
if (projectSelected.redis.length === 0) {
|
|
51
|
-
this.error(chalk.yellow("No Redis instances found in this project."));
|
|
52
|
-
}
|
|
53
|
-
if (!redisId) {
|
|
54
|
-
const dbAnswers = await inquirer.prompt([
|
|
55
|
-
{
|
|
56
|
-
// @ts-ignore
|
|
57
|
-
choices: projectSelected.redis.map((db) => ({
|
|
58
|
-
name: db.name,
|
|
59
|
-
value: db.redisId,
|
|
60
|
-
})),
|
|
61
|
-
message: "Select the Redis instance to stop:",
|
|
62
|
-
name: "selectedDb",
|
|
63
|
-
type: "list",
|
|
64
|
-
},
|
|
65
|
-
]);
|
|
66
|
-
redisId = dbAnswers.selectedDb;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
// Confirmar si no se especifica --skipConfirm
|
|
70
|
-
if (!flags.skipConfirm) {
|
|
71
|
-
const confirmAnswers = await inquirer.prompt([
|
|
72
|
-
{
|
|
73
|
-
default: false,
|
|
74
|
-
message: "Are you sure you want to stop this Redis instance?",
|
|
75
|
-
name: "confirmStop",
|
|
76
|
-
type: "confirm",
|
|
77
|
-
},
|
|
78
|
-
]);
|
|
79
|
-
if (!confirmAnswers.confirmStop) {
|
|
80
|
-
this.error(chalk.yellow("Redis stop cancelled."));
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
try {
|
|
84
|
-
const response = await axios.post(`${auth.url}/api/trpc/redis.stop`, {
|
|
85
|
-
json: {
|
|
86
|
-
redisId,
|
|
87
|
-
},
|
|
88
|
-
}, {
|
|
89
|
-
headers: {
|
|
90
|
-
"x-api-key": auth.token,
|
|
91
|
-
"Content-Type": "application/json",
|
|
92
|
-
},
|
|
93
|
-
});
|
|
94
|
-
if (response.status !== 200) {
|
|
95
|
-
this.error(chalk.red("Error stopping Redis instance"));
|
|
96
|
-
}
|
|
97
|
-
this.log(chalk.green("Redis instance stopped successfully."));
|
|
98
|
-
}
|
|
99
|
-
catch (error) {
|
|
100
|
-
this.error(chalk.red(`Error stopping Redis instance: ${error.message}`));
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Command } from '@oclif/core';
|
|
2
|
-
export default class EnvPull extends Command {
|
|
3
|
-
static args: {
|
|
4
|
-
file: import("@oclif/core/lib/interfaces/parser.js").Arg<string, Record<string, unknown>>;
|
|
5
|
-
};
|
|
6
|
-
static description: string;
|
|
7
|
-
static examples: string[];
|
|
8
|
-
static flags: {};
|
|
9
|
-
run(): Promise<void>;
|
|
10
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { Args, Command } from '@oclif/core';
|
|
2
|
-
import { readAuthConfig } from "../../utils/utils.js";
|
|
3
|
-
import chalk from "chalk";
|
|
4
|
-
import { getProject, getProjects } from "../../utils/shared.js";
|
|
5
|
-
import inquirer from "inquirer";
|
|
6
|
-
import fs from 'fs';
|
|
7
|
-
export default class EnvPull extends Command {
|
|
8
|
-
static args = {
|
|
9
|
-
file: Args.string({ description: 'write to file', required: true }),
|
|
10
|
-
};
|
|
11
|
-
static description = 'Store remote environment variables in local';
|
|
12
|
-
static examples = [
|
|
13
|
-
'<%= config.bin %> <%= command.id %> .env.stage.local',
|
|
14
|
-
];
|
|
15
|
-
static flags = {};
|
|
16
|
-
async run() {
|
|
17
|
-
const { args } = await this.parse(EnvPull);
|
|
18
|
-
if (fs.existsSync(args.file)) {
|
|
19
|
-
const { override } = await inquirer.prompt([
|
|
20
|
-
{
|
|
21
|
-
message: `Do you want to override ${args.file} file?`,
|
|
22
|
-
name: "override",
|
|
23
|
-
default: false,
|
|
24
|
-
type: "confirm",
|
|
25
|
-
},
|
|
26
|
-
]);
|
|
27
|
-
if (!override) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
const auth = await readAuthConfig(this);
|
|
32
|
-
console.log(chalk.blue.bold("\n Listing all Projects \n"));
|
|
33
|
-
const projects = await getProjects(auth, this);
|
|
34
|
-
const { project } = await inquirer.prompt([
|
|
35
|
-
{
|
|
36
|
-
choices: projects.map((project) => ({
|
|
37
|
-
name: project.name,
|
|
38
|
-
value: project,
|
|
39
|
-
})),
|
|
40
|
-
message: "Select the project:",
|
|
41
|
-
name: "project",
|
|
42
|
-
type: "list",
|
|
43
|
-
},
|
|
44
|
-
]);
|
|
45
|
-
const projectId = project.projectId;
|
|
46
|
-
const projectSelected = await getProject(projectId, auth, this);
|
|
47
|
-
const choices = [
|
|
48
|
-
...projectSelected.applications.map((app) => ({
|
|
49
|
-
name: `${app.name} (Application)`,
|
|
50
|
-
value: app.env,
|
|
51
|
-
})),
|
|
52
|
-
...projectSelected.compose.map((compose) => ({
|
|
53
|
-
name: `${compose.name} (Compose)`,
|
|
54
|
-
value: compose.env,
|
|
55
|
-
})),
|
|
56
|
-
];
|
|
57
|
-
const { env } = await inquirer.prompt([
|
|
58
|
-
{
|
|
59
|
-
choices,
|
|
60
|
-
message: "Select a service to pull the environment variables:",
|
|
61
|
-
name: "env",
|
|
62
|
-
type: "list",
|
|
63
|
-
},
|
|
64
|
-
]);
|
|
65
|
-
fs.writeFileSync(args.file, env || "");
|
|
66
|
-
this.log(chalk.green("Environment variable write to file successful."));
|
|
67
|
-
}
|
|
68
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Command } from '@oclif/core';
|
|
2
|
-
export default class EnvPush extends Command {
|
|
3
|
-
static args: {
|
|
4
|
-
file: import("@oclif/core/lib/interfaces/parser.js").Arg<string, Record<string, unknown>>;
|
|
5
|
-
};
|
|
6
|
-
static description: string;
|
|
7
|
-
static examples: string[];
|
|
8
|
-
static flags: {};
|
|
9
|
-
run(): Promise<void>;
|
|
10
|
-
}
|