-
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
209eadc
commit e48c58c
Showing
8 changed files
with
625 additions
and
2 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 { readAuthConfig } from "../../utils/utils.js"; | ||
import chalk from "chalk"; | ||
import { getProject, getProjects } from "../../utils/shared.js"; | ||
import inquirer from "inquirer"; | ||
import type { Answers } from "./create.js"; | ||
import axios from "axios"; | ||
|
||
export default class AppDeploy extends Command { | ||
static description = "Deploy an application to a project."; | ||
|
||
static examples = ["$ <%= config.bin %> app deploy"]; | ||
|
||
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 deploy the application in:", | ||
name: "project", | ||
type: "list", | ||
}, | ||
]); | ||
|
||
const projectId = project.projectId; | ||
|
||
const projectSelected = await getProject(projectId, auth, this); | ||
|
||
if (projectSelected.applications.length === 0) { | ||
this.error(chalk.yellow("No applications found in this project.")); | ||
} | ||
|
||
const appAnswers = await inquirer.prompt([ | ||
{ | ||
// @ts-ignore | ||
choices: projectSelected.applications.map((app) => ({ | ||
name: app.name, | ||
value: app.applicationId, | ||
})), | ||
message: "Select the application to deploy:", | ||
name: "selectedApp", | ||
type: "list", | ||
}, | ||
]); | ||
|
||
const applicationId = appAnswers.selectedApp; | ||
|
||
const confirmAnswers = await inquirer.prompt([ | ||
{ | ||
default: false, | ||
message: "Are you sure you want to deploy this application?", | ||
name: "confirmDelete", | ||
type: "confirm", | ||
}, | ||
]); | ||
|
||
if (!confirmAnswers.confirmDelete) { | ||
this.error(chalk.yellow("Application deployment cancelled.")); | ||
} | ||
|
||
const response = await axios.post( | ||
`${auth.url}/api/trpc/application.deploy`, | ||
{ | ||
json: { | ||
applicationId, | ||
}, | ||
}, | ||
{ | ||
headers: { | ||
Authorization: `Bearer ${auth.token}`, | ||
"Content-Type": "application/json", | ||
}, | ||
}, | ||
); | ||
|
||
if (response.status !== 200) { | ||
this.error(chalk.red("Error deploying application")); | ||
} | ||
this.log(chalk.green("Application deploy 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 { readAuthConfig } from "../../utils/utils.js"; | ||
import chalk from "chalk"; | ||
import inquirer from "inquirer"; | ||
import { getProject, getProjects } from "../../utils/shared.js"; | ||
import type { Answers } from "./create.js"; | ||
import axios from "axios"; | ||
|
||
export default class AppStop extends Command { | ||
static description = "Stop an application from a project."; | ||
|
||
static examples = ["$ <%= config.bin %> app 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 application in:", | ||
name: "project", | ||
type: "list", | ||
}, | ||
]); | ||
|
||
const projectId = project.projectId; | ||
|
||
const projectSelected = await getProject(projectId, auth, this); | ||
|
||
if (projectSelected.applications.length === 0) { | ||
this.error(chalk.yellow("No applications found in this project.")); | ||
} | ||
|
||
const appAnswers = await inquirer.prompt([ | ||
{ | ||
// @ts-ignore | ||
choices: projectSelected.applications.map((app) => ({ | ||
name: app.name, | ||
value: app.applicationId, | ||
})), | ||
message: "Select the application to stop:", | ||
name: "selectedApp", | ||
type: "list", | ||
}, | ||
]); | ||
|
||
const applicationId = appAnswers.selectedApp; | ||
|
||
const confirmAnswers = await inquirer.prompt([ | ||
{ | ||
default: false, | ||
message: "Are you sure you want to stop this application?", | ||
name: "confirmDelete", | ||
type: "confirm", | ||
}, | ||
]); | ||
|
||
if (!confirmAnswers.confirmDelete) { | ||
this.error(chalk.yellow("Application stop cancelled.")); | ||
} | ||
|
||
const response = await axios.post( | ||
`${auth.url}/api/trpc/application.stop`, | ||
{ | ||
json: { | ||
applicationId, | ||
}, | ||
}, | ||
{ | ||
headers: { | ||
Authorization: `Bearer ${auth.token}`, | ||
"Content-Type": "application/json", | ||
}, | ||
}, | ||
); | ||
|
||
if (response.status !== 200) { | ||
this.error(chalk.red("Error stopping application")); | ||
} | ||
this.log(chalk.green("Application 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
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 { readAuthConfig } from "../../../utils/utils.js"; | ||
import chalk from "chalk"; | ||
import { getProject, getProjects } from "../../../utils/shared.js"; | ||
import inquirer from "inquirer"; | ||
import type { Answers } from "../../app/create.js"; | ||
import axios from "axios"; | ||
|
||
export default class DatabaseMariadbDeploy extends Command { | ||
static description = "Deploy an mariadb to a project."; | ||
|
||
static examples = ["$ <%= config.bin %> app deploy"]; | ||
|
||
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 deploy 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 deploy:", | ||
name: "selectedApp", | ||
type: "list", | ||
}, | ||
]); | ||
|
||
const mariadbId = appAnswers.selectedApp; | ||
|
||
const confirmAnswers = await inquirer.prompt([ | ||
{ | ||
default: false, | ||
message: "Are you sure you want to deploy this mariadb?", | ||
name: "confirmDelete", | ||
type: "confirm", | ||
}, | ||
]); | ||
|
||
if (!confirmAnswers.confirmDelete) { | ||
this.error(chalk.yellow("mariadb deployment cancelled.")); | ||
} | ||
|
||
const response = await axios.post( | ||
`${auth.url}/api/trpc/mariadb.deploy`, | ||
{ | ||
json: { | ||
mariadbId, | ||
}, | ||
}, | ||
{ | ||
headers: { | ||
Authorization: `Bearer ${auth.token}`, | ||
"Content-Type": "application/json", | ||
}, | ||
}, | ||
); | ||
|
||
if (response.status !== 200) { | ||
this.error(chalk.red("Error deploying mariadb")); | ||
} | ||
this.log(chalk.green("Mariadb deploy 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 { readAuthConfig } from "../../../utils/utils.js"; | ||
import chalk from "chalk"; | ||
import { getProject, getProjects } from "../../../utils/shared.js"; | ||
import inquirer from "inquirer"; | ||
import type { Answers } from "../../app/create.js"; | ||
import axios from "axios"; | ||
|
||
export default class DatabaseMongoDeploy extends Command { | ||
static description = "Deploy an mongo to a project."; | ||
|
||
static examples = ["$ <%= config.bin %> app deploy"]; | ||
|
||
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 deploy 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 deploy:", | ||
name: "selectedApp", | ||
type: "list", | ||
}, | ||
]); | ||
|
||
const mongoId = appAnswers.selectedApp; | ||
|
||
const confirmAnswers = await inquirer.prompt([ | ||
{ | ||
default: false, | ||
message: "Are you sure you want to deploy this mongo?", | ||
name: "confirmDelete", | ||
type: "confirm", | ||
}, | ||
]); | ||
|
||
if (!confirmAnswers.confirmDelete) { | ||
this.error(chalk.yellow("mongo deployment cancelled.")); | ||
} | ||
|
||
const response = await axios.post( | ||
`${auth.url}/api/trpc/mongo.deploy`, | ||
{ | ||
json: { | ||
mongoId, | ||
}, | ||
}, | ||
{ | ||
headers: { | ||
Authorization: `Bearer ${auth.token}`, | ||
"Content-Type": "application/json", | ||
}, | ||
}, | ||
); | ||
|
||
if (response.status !== 200) { | ||
this.error(chalk.red("Error deploying mongo")); | ||
} | ||
this.log(chalk.green("Mongo deploy successful.")); | ||
} | ||
} |
Oops, something went wrong.