-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e48c58c
commit 3b12f55
Showing
5 changed files
with
445 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { Command } from "@oclif/core"; | ||
import chalk from "chalk"; | ||
import inquirer from "inquirer"; | ||
import axios from "axios"; | ||
import { getProject, getProjects } from "../../../utils/shared.js"; | ||
import { readAuthConfig } from "../../../utils/utils.js"; | ||
import type { Answers } from "../../app/create.js"; | ||
|
||
export default class DatabaseMariadbStop extends Command { | ||
static description = "Stop an mariadb from a project."; | ||
|
||
static examples = ["$ <%= config.bin %> mariadb stop"]; | ||
|
||
public async run(): Promise<void> { | ||
const auth = await readAuthConfig(this); | ||
|
||
console.log(chalk.blue.bold("\n Listing all Projects \n")); | ||
|
||
const projects = await getProjects(auth, this); | ||
|
||
const { project } = await inquirer.prompt<Answers>([ | ||
{ | ||
choices: projects.map((project) => ({ | ||
name: project.name, | ||
value: project, | ||
})), | ||
message: "Select a project to stop the mariadb in:", | ||
name: "project", | ||
type: "list", | ||
}, | ||
]); | ||
|
||
const projectId = project.projectId; | ||
|
||
const projectSelected = await getProject(projectId, auth, this); | ||
|
||
if (projectSelected.mariadb.length === 0) { | ||
this.error(chalk.yellow("No mariadb found in this project.")); | ||
} | ||
|
||
const appAnswers = await inquirer.prompt([ | ||
{ | ||
// @ts-ignore | ||
choices: projectSelected.mariadb.map((app) => ({ | ||
name: app.name, | ||
value: app.mariadbId, | ||
})), | ||
message: "Select the mariadb to stop:", | ||
name: "selectedApp", | ||
type: "list", | ||
}, | ||
]); | ||
|
||
const mariadbId = appAnswers.selectedApp; | ||
|
||
const confirmAnswers = await inquirer.prompt([ | ||
{ | ||
default: false, | ||
message: "Are you sure you want to stop this mariadb?", | ||
name: "confirmDelete", | ||
type: "confirm", | ||
}, | ||
]); | ||
|
||
if (!confirmAnswers.confirmDelete) { | ||
this.error(chalk.yellow("Mariadb stop cancelled.")); | ||
} | ||
|
||
const response = await axios.post( | ||
`${auth.url}/api/trpc/mariadb.stop`, | ||
{ | ||
json: { | ||
mariadbId, | ||
}, | ||
}, | ||
{ | ||
headers: { | ||
Authorization: `Bearer ${auth.token}`, | ||
"Content-Type": "application/json", | ||
}, | ||
}, | ||
); | ||
|
||
if (response.status !== 200) { | ||
this.error(chalk.red("Error stopping mariadb")); | ||
} | ||
this.log(chalk.green("Mariadb stop successful.")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { Command } from "@oclif/core"; | ||
import chalk from "chalk"; | ||
import inquirer from "inquirer"; | ||
import axios from "axios"; | ||
import { getProject, getProjects } from "../../../utils/shared.js"; | ||
import { readAuthConfig } from "../../../utils/utils.js"; | ||
import type { Answers } from "../../app/create.js"; | ||
|
||
export default class DatabaseMongoStop extends Command { | ||
static description = "Stop an mongo from a project."; | ||
|
||
static examples = ["$ <%= config.bin %> mongo stop"]; | ||
|
||
public async run(): Promise<void> { | ||
const auth = await readAuthConfig(this); | ||
|
||
console.log(chalk.blue.bold("\n Listing all Projects \n")); | ||
|
||
const projects = await getProjects(auth, this); | ||
|
||
const { project } = await inquirer.prompt<Answers>([ | ||
{ | ||
choices: projects.map((project) => ({ | ||
name: project.name, | ||
value: project, | ||
})), | ||
message: "Select a project to stop the mongo in:", | ||
name: "project", | ||
type: "list", | ||
}, | ||
]); | ||
|
||
const projectId = project.projectId; | ||
|
||
const projectSelected = await getProject(projectId, auth, this); | ||
|
||
if (projectSelected.mongo.length === 0) { | ||
this.error(chalk.yellow("No mongo found in this project.")); | ||
} | ||
|
||
const appAnswers = await inquirer.prompt([ | ||
{ | ||
// @ts-ignore | ||
choices: projectSelected.mongo.map((app) => ({ | ||
name: app.name, | ||
value: app.mongoId, | ||
})), | ||
message: "Select the mongo to stop:", | ||
name: "selectedApp", | ||
type: "list", | ||
}, | ||
]); | ||
|
||
const mongoId = appAnswers.selectedApp; | ||
|
||
const confirmAnswers = await inquirer.prompt([ | ||
{ | ||
default: false, | ||
message: "Are you sure you want to stop this mongo?", | ||
name: "confirmDelete", | ||
type: "confirm", | ||
}, | ||
]); | ||
|
||
if (!confirmAnswers.confirmDelete) { | ||
this.error(chalk.yellow("mongo stop cancelled.")); | ||
} | ||
|
||
const response = await axios.post( | ||
`${auth.url}/api/trpc/mongo.stop`, | ||
{ | ||
json: { | ||
mongoId, | ||
}, | ||
}, | ||
{ | ||
headers: { | ||
Authorization: `Bearer ${auth.token}`, | ||
"Content-Type": "application/json", | ||
}, | ||
}, | ||
); | ||
|
||
if (response.status !== 200) { | ||
this.error(chalk.red("Error stopping mongo")); | ||
} | ||
this.log(chalk.green("Mongo stop successful.")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { Command } from "@oclif/core"; | ||
import chalk from "chalk"; | ||
import inquirer from "inquirer"; | ||
import axios from "axios"; | ||
import { getProject, getProjects } from "../../../utils/shared.js"; | ||
import { readAuthConfig } from "../../../utils/utils.js"; | ||
import type { Answers } from "../../app/create.js"; | ||
|
||
export default class DatabaseMysqlStop extends Command { | ||
static description = "Stop an mysql from a project."; | ||
|
||
static examples = ["$ <%= config.bin %> mysql stop"]; | ||
|
||
public async run(): Promise<void> { | ||
const auth = await readAuthConfig(this); | ||
|
||
console.log(chalk.blue.bold("\n Listing all Projects \n")); | ||
|
||
const projects = await getProjects(auth, this); | ||
|
||
const { project } = await inquirer.prompt<Answers>([ | ||
{ | ||
choices: projects.map((project) => ({ | ||
name: project.name, | ||
value: project, | ||
})), | ||
message: "Select a project to stop the mysql in:", | ||
name: "project", | ||
type: "list", | ||
}, | ||
]); | ||
|
||
const projectId = project.projectId; | ||
|
||
const projectSelected = await getProject(projectId, auth, this); | ||
|
||
if (projectSelected.mysql.length === 0) { | ||
this.error(chalk.yellow("No mysql found in this project.")); | ||
} | ||
|
||
const appAnswers = await inquirer.prompt([ | ||
{ | ||
// @ts-ignore | ||
choices: projectSelected.mysql.map((app) => ({ | ||
name: app.name, | ||
value: app.mysqlId, | ||
})), | ||
message: "Select the mysql to stop:", | ||
name: "selectedApp", | ||
type: "list", | ||
}, | ||
]); | ||
|
||
const mysqlId = appAnswers.selectedApp; | ||
|
||
const confirmAnswers = await inquirer.prompt([ | ||
{ | ||
default: false, | ||
message: "Are you sure you want to stop this mysql?", | ||
name: "confirmDelete", | ||
type: "confirm", | ||
}, | ||
]); | ||
|
||
if (!confirmAnswers.confirmDelete) { | ||
this.error(chalk.yellow("mysql stop cancelled.")); | ||
} | ||
|
||
const response = await axios.post( | ||
`${auth.url}/api/trpc/mysql.stop`, | ||
{ | ||
json: { | ||
mysqlId, | ||
}, | ||
}, | ||
{ | ||
headers: { | ||
Authorization: `Bearer ${auth.token}`, | ||
"Content-Type": "application/json", | ||
}, | ||
}, | ||
); | ||
|
||
if (response.status !== 200) { | ||
this.error(chalk.red("Error stopping mysql")); | ||
} | ||
this.log(chalk.green("Mysql stop successful.")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { Command } from "@oclif/core"; | ||
import chalk from "chalk"; | ||
import inquirer from "inquirer"; | ||
import axios from "axios"; | ||
import { getProject, getProjects } from "../../../utils/shared.js"; | ||
import { readAuthConfig } from "../../../utils/utils.js"; | ||
import type { Answers } from "../../app/create.js"; | ||
|
||
export default class DatabasePostgresStop extends Command { | ||
static description = "Stop an postgres from a project."; | ||
|
||
static examples = ["$ <%= config.bin %> postgres stop"]; | ||
|
||
public async run(): Promise<void> { | ||
const auth = await readAuthConfig(this); | ||
|
||
console.log(chalk.blue.bold("\n Listing all Projects \n")); | ||
|
||
const projects = await getProjects(auth, this); | ||
|
||
const { project } = await inquirer.prompt<Answers>([ | ||
{ | ||
choices: projects.map((project) => ({ | ||
name: project.name, | ||
value: project, | ||
})), | ||
message: "Select a project to stop the postgres in:", | ||
name: "project", | ||
type: "list", | ||
}, | ||
]); | ||
|
||
const projectId = project.projectId; | ||
|
||
const projectSelected = await getProject(projectId, auth, this); | ||
|
||
if (projectSelected.postgres.length === 0) { | ||
this.error(chalk.yellow("No postgres found in this project.")); | ||
} | ||
|
||
const appAnswers = await inquirer.prompt([ | ||
{ | ||
// @ts-ignore | ||
choices: projectSelected.postgres.map((app) => ({ | ||
name: app.name, | ||
value: app.postgresId, | ||
})), | ||
message: "Select the postgres to stop:", | ||
name: "selectedApp", | ||
type: "list", | ||
}, | ||
]); | ||
|
||
const postgresId = appAnswers.selectedApp; | ||
|
||
const confirmAnswers = await inquirer.prompt([ | ||
{ | ||
default: false, | ||
message: "Are you sure you want to stop this postgres?", | ||
name: "confirmDelete", | ||
type: "confirm", | ||
}, | ||
]); | ||
|
||
if (!confirmAnswers.confirmDelete) { | ||
this.error(chalk.yellow("postgres stop cancelled.")); | ||
} | ||
|
||
const response = await axios.post( | ||
`${auth.url}/api/trpc/postgres.stop`, | ||
{ | ||
json: { | ||
postgresId, | ||
}, | ||
}, | ||
{ | ||
headers: { | ||
Authorization: `Bearer ${auth.token}`, | ||
"Content-Type": "application/json", | ||
}, | ||
}, | ||
); | ||
|
||
if (response.status !== 200) { | ||
this.error(chalk.red("Error stopping postgres")); | ||
} | ||
this.log(chalk.green("Postgres stop successful.")); | ||
} | ||
} |
Oops, something went wrong.