diff --git a/package.json b/package.json index b49cab2..6451eed 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "chalk": "^5.3.0", "cli-table3": "^0.6.5", "inquirer": "^9.2.23", + "slugify": "^1.6.6", "superjson": "^2.2.1" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1e509c1..b48de68 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -26,6 +26,9 @@ dependencies: inquirer: specifier: ^9.2.23 version: 9.2.23 + slugify: + specifier: ^1.6.6 + version: 1.6.6 superjson: specifier: ^2.2.1 version: 2.2.1 @@ -4784,6 +4787,11 @@ packages: astral-regex: 2.0.0 is-fullwidth-code-point: 3.0.0 + /slugify@1.6.6: + resolution: {integrity: sha512-h+z7HKHYXj6wJU+AnS/+IH8Uh9fdcX1Lrhg1/VMdf9PwoBQXFcXiAdsy2tSK0P6gKwJLXp02r90ahUCqHk9rrw==} + engines: {node: '>=8.0.0'} + dev: false + /snake-case@3.0.4: resolution: {integrity: sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg==} dependencies: diff --git a/src/commands/app/create.ts b/src/commands/app/create.ts index 66fe787..339d859 100644 --- a/src/commands/app/create.ts +++ b/src/commands/app/create.ts @@ -55,7 +55,7 @@ export default class AppCreate extends Command { name: project.name, value: project.projectId, })), - message: "Select a project to create the application in:", + message: "Select a project to create the database in:", name: "selectedProject", type: "list", }, @@ -68,16 +68,32 @@ export default class AppCreate extends Command { } } + const databases = ["postgres", "mysql", "redis", "mariadb", "mongo"]; + + const databaseSelect = await inquirer.prompt([ + { + choices: databases.map((database: any) => ({ + name: database, + value: database, + })), + message: "Select a database to create the application in:", + name: "selectedDatabase", + type: "list", + }, + ]); + + const urlSelected = `${auth.url}/api/trpc/${databaseSelect.selectedDatabase}.create`; + // Solicitar detalles de la nueva aplicación const appDetails = await inquirer.prompt([ { - message: "Enter the application name:", + message: "Enter the database name:", name: "appName", type: "input", - validate: (input) => (input ? true : "Application name is required"), + validate: (input) => (input ? true : "Database name is required"), }, { - message: "Enter the application description (optional):", + message: "Enter the database description (optional):", name: "appDescription", type: "input", }, @@ -87,32 +103,30 @@ export default class AppCreate extends Command { // Crear la aplicación en el proyecto seleccionado try { - const response = await axios.post( - `${auth.url}/api/trpc/application.create`, - { - json: { - description: appDescription, - name: appName, - projectId, - }, - }, - { - headers: { - Authorization: `Bearer ${auth.token}`, - "Content-Type": "application/json", - }, - }, - ); - - if (!response.data.result.data.json) { - this.error(chalk.red("Error creating application")); - } - - this.log( - chalk.green( - `Application '${appName}' created successfully in project ID '${projectId}'.`, - ), - ); + // const response = await axios.post( + // `${auth.url}/api/trpc/application.create`, + // { + // json: { + // description: appDescription, + // name: appName, + // projectId, + // }, + // }, + // { + // headers: { + // Authorization: `Bearer ${auth.token}`, + // "Content-Type": "application/json", + // }, + // }, + // ); + // if (!response.data.result.data.json) { + // this.error(chalk.red("Error creating application")); + // } + // this.log( + // chalk.green( + // `Application '${appName}' created successfully in project ID '${projectId}'.`, + // ), + // ); } catch (error) { // @ts-expect-error TODO: Fix this this.error(chalk.red(`Failed to create application: ${error.message}`)); diff --git a/src/commands/database/create.ts b/src/commands/database/create.ts new file mode 100644 index 0000000..b9559d4 --- /dev/null +++ b/src/commands/database/create.ts @@ -0,0 +1,121 @@ +import { Command, Flags } from "@oclif/core"; +import axios from "axios"; +import chalk from "chalk"; +import inquirer from "inquirer"; + +import { readAuthConfig } from "../../utils/utils.js"; + +export default class DatabaseCreate extends Command { + static description = "Create a new database within a project."; + + static examples = ["$ <%= config.bin %> app create"]; + + static flags = { + projectId: Flags.string({ + char: "p", + description: "ID of the project", + required: false, + }), + }; + + public async run(): Promise { + const auth = await readAuthConfig(this); + + const { flags } = await this.parse(DatabaseCreate); + + let { projectId } = flags; + + if (!projectId) { + // Obtener la lista de proyectos y permitir la selección + console.log(chalk.blue.bold("\n Listing all Projects \n")); + + try { + const response = await axios.get(`${auth.url}/api/trpc/project.all`, { + headers: { + Authorization: `Bearer ${auth.token}`, + "Content-Type": "application/json", + }, + }); + + if (!response.data.result.data.json) { + this.error(chalk.red("Error fetching projects")); + } + + const projects = response.data.result.data.json; + + if (projects.length === 0) { + this.log(chalk.yellow("No projects found.")); + return; + } + + // Permitir al usuario seleccionar un proyecto + const answers = await inquirer.prompt([ + { + choices: projects.map((project: any) => ({ + name: project.name, + value: project.projectId, + })), + message: "Select a project to create the application in:", + name: "selectedProject", + type: "list", + }, + ]); + + projectId = answers.selectedProject; + } catch (error) { + // @ts-expect-error TODO: Fix this + this.error(chalk.red(`Failed to fetch project list: ${error.message}`)); + } + } + + // Solicitar detalles de la nueva aplicación + const appDetails = await inquirer.prompt([ + { + message: "Enter the database name:", + name: "appName", + type: "input", + validate: (input) => (input ? true : "Application name is required"), + }, + { + message: "Enter the application description (optional):", + name: "appDescription", + type: "input", + }, + ]); + + const { appDescription, appName } = appDetails; + + // Crear la aplicación en el proyecto seleccionado + try { + const response = await axios.post( + `${auth.url}/api/trpc/database.create`, + { + json: { + description: appDescription, + name: appName, + projectId, + }, + }, + { + headers: { + Authorization: `Bearer ${auth.token}`, + "Content-Type": "application/json", + }, + }, + ); + + if (!response.data.result.data.json) { + this.error(chalk.red("Error creating application")); + } + + this.log( + chalk.green( + `Application '${appName}' created successfully in project ID '${projectId}'.`, + ), + ); + } catch (error) { + // @ts-expect-error TODO: Fix this + this.error(chalk.red(`Failed to create application: ${error.message}`)); + } + } +} diff --git a/src/commands/database/mariadb/create.ts b/src/commands/database/mariadb/create.ts new file mode 100644 index 0000000..38b3f2a --- /dev/null +++ b/src/commands/database/mariadb/create.ts @@ -0,0 +1,144 @@ +import { Command, Flags } from "@oclif/core"; +import axios from "axios"; +import chalk from "chalk"; +import inquirer from "inquirer"; + +import { slugify } from "../../../utils/slug.js"; +import { readAuthConfig } from "../../../utils/utils.js"; + +export default class DatabaseMariadbCreate extends Command { + static description = "Create a new database within a project."; + + static examples = ["$ <%= config.bin %> mariadb create"]; + + static flags = { + projectId: Flags.string({ + char: "p", + description: "ID of the project", + required: false, + }), + }; + + public async run(): Promise { + const auth = await readAuthConfig(this); + + const { flags } = await this.parse(DatabaseMariadbCreate); + + const { projectId } = flags; + if (!projectId) { + console.log(chalk.blue.bold("\n Listing all Projects \n")); + + try { + const response = await axios.get(`${auth.url}/api/trpc/project.all`, { + headers: { + Authorization: `Bearer ${auth.token}`, + "Content-Type": "application/json", + }, + }); + + if (!response.data.result.data.json) { + this.error(chalk.red("Error fetching projects")); + } + + const projects = response.data.result.data.json; + + if (projects.length === 0) { + this.log(chalk.yellow("No projects found.")); + return; + } + + const { project } = await inquirer.prompt([ + { + choices: projects.map((project: any) => ({ + name: project.name, + value: project, + })), + message: "Select a project to create the database in:", + name: "project", + type: "list", + }, + ]); + + const appDetails = await inquirer.prompt([ + { + message: "Enter the name:", + name: "name", + type: "input", + validate: (input) => (input ? true : "Database name is required"), + }, + { + message: "Database name:", + name: "databaseName", + type: "input", + validate: (input) => (input ? true : "Database name is required"), + }, + { + message: "Enter the database description (optional):", + name: "description", + type: "input", + }, + { + message: "Database Root Password (optional):", + name: "databaseRootPassword", + type: "input", + }, + { + message: "Database password (optional):", + name: "databasePassword", + type: "input", + }, + { + default: "mariadb:4", + message: "Docker Image (default: mariadb:4):", + name: "dockerImage", + type: "input", + }, + { + default: "mariadb", + message: "Database User: (default: mariadb):", + name: "databaseUser", + type: "input", + }, + ]); + + const appName = await inquirer.prompt([ + { + default: `${slugify(project.name)}-${appDetails.name}`, + message: "Enter the App name: (optional):", + name: "appName", + type: "input", + validate: (input) => (input ? true : "Database name is required"), + }, + ]); + + const responseDatabase = await axios.post( + `${auth.url}/api/trpc/mariadb.create`, + { + json: { + ...appDetails, + appName: appName.appName, + projectId: project.projectId, + }, + }, + { + headers: { + Authorization: `Bearer ${auth.token}`, + "Content-Type": "application/json", + }, + }, + ); + + if (!responseDatabase.data.result.data.json) { + this.error(chalk.red("Error creating database")); + } + + this.log( + chalk.green(`Database '${appDetails.name}' created successfully.`), + ); + } catch (error) { + // @ts-expect-error TODO: Fix this + this.error(chalk.red(`Failed to fetch project list: ${error.message}`)); + } + } + } +} diff --git a/src/commands/database/mongo/create.ts b/src/commands/database/mongo/create.ts new file mode 100644 index 0000000..df1c007 --- /dev/null +++ b/src/commands/database/mongo/create.ts @@ -0,0 +1,138 @@ +import { Command, Flags } from "@oclif/core"; +import axios from "axios"; +import chalk from "chalk"; +import inquirer from "inquirer"; + +import { slugify } from "../../../utils/slug.js"; +import { readAuthConfig } from "../../../utils/utils.js"; + +export default class DatabaseMongoCreate extends Command { + static description = "Create a new database within a project."; + + static examples = ["$ <%= config.bin %> mongo create"]; + + static flags = { + projectId: Flags.string({ + char: "p", + description: "ID of the project", + required: false, + }), + }; + + public async run(): Promise { + const auth = await readAuthConfig(this); + const { flags } = await this.parse(DatabaseMongoCreate); + + const { projectId } = flags; + if (!projectId) { + console.log(chalk.blue.bold("\n Listing all Projects \n")); + + try { + const response = await axios.get(`${auth.url}/api/trpc/project.all`, { + headers: { + Authorization: `Bearer ${auth.token}`, + "Content-Type": "application/json", + }, + }); + + if (!response.data.result.data.json) { + this.error(chalk.red("Error fetching projects")); + } + + const projects = response.data.result.data.json; + + if (projects.length === 0) { + this.log(chalk.yellow("No projects found.")); + return; + } + + const { project } = await inquirer.prompt([ + { + choices: projects.map((project: any) => ({ + name: project.name, + value: project, + })), + message: "Select a project to create the database in:", + name: "project", + type: "list", + }, + ]); + + const appDetails = await inquirer.prompt([ + { + message: "Enter the name:", + name: "name", + type: "input", + validate: (input) => (input ? true : "Database name is required"), + }, + { + message: "Database name:", + name: "databaseName", + type: "input", + validate: (input) => (input ? true : "Database name is required"), + }, + { + message: "Enter the database description (optional):", + name: "description", + type: "input", + }, + { + message: "Database password (optional):", + name: "databasePassword", + type: "input", + }, + { + default: "mongo:6", + message: "Docker Image (default: mongo:6):", + name: "dockerImage", + type: "input", + }, + { + default: "mongo", + message: "Database User: (default: mongo):", + name: "databaseUser", + type: "input", + }, + ]); + + const appName = await inquirer.prompt([ + { + default: `${slugify(project.name)}-${appDetails.name}`, + message: "Enter the App name: (optional):", + name: "appName", + type: "input", + validate: (input) => (input ? true : "App name is required"), + }, + ]); + + const responseDatabase = await axios.post( + `${auth.url}/api/trpc/mongo.create`, + { + json: { + ...appDetails, + appName: appName.appName, + projectId: project.projectId, + }, + }, + { + headers: { + Authorization: `Bearer ${auth.token}`, + "Content-Type": "application/json", + }, + }, + ); + + if (!responseDatabase.data.result.data.json) { + this.error(chalk.red("Error creating database")); + } + + this.log( + chalk.green(`Database '${appDetails.name}' created successfully.`), + ); + } catch (error) { + // @ts-expect-error TODO: Fix this + this.error(chalk.red(`Failed to fetch project list: ${error.message}`)); + } + } + } +} diff --git a/src/commands/database/mysql/create.ts b/src/commands/database/mysql/create.ts new file mode 100644 index 0000000..eb286b7 --- /dev/null +++ b/src/commands/database/mysql/create.ts @@ -0,0 +1,143 @@ +import { Command, Flags } from "@oclif/core"; +import axios from "axios"; +import chalk from "chalk"; +import inquirer from "inquirer"; + +import { slugify } from "../../../utils/slug.js"; +import { readAuthConfig } from "../../../utils/utils.js"; + +export default class DatabaseMysqlCreate extends Command { + static description = "Create a new database within a project."; + + static examples = ["$ <%= config.bin %> mysql create"]; + + static flags = { + projectId: Flags.string({ + char: "p", + description: "ID of the project", + required: false, + }), + }; + + public async run(): Promise { + const auth = await readAuthConfig(this); + const { flags } = await this.parse(DatabaseMysqlCreate); + + const { projectId } = flags; + if (!projectId) { + console.log(chalk.blue.bold("\n Listing all Projects \n")); + + try { + const response = await axios.get(`${auth.url}/api/trpc/project.all`, { + headers: { + Authorization: `Bearer ${auth.token}`, + "Content-Type": "application/json", + }, + }); + + if (!response.data.result.data.json) { + this.error(chalk.red("Error fetching projects")); + } + + const projects = response.data.result.data.json; + + if (projects.length === 0) { + this.log(chalk.yellow("No projects found.")); + return; + } + + const { project } = await inquirer.prompt([ + { + choices: projects.map((project: any) => ({ + name: project.name, + value: project, + })), + message: "Select a project to create the database in:", + name: "project", + type: "list", + }, + ]); + + const appDetails = await inquirer.prompt([ + { + message: "Enter the name:", + name: "name", + type: "input", + validate: (input) => (input ? true : "Database name is required"), + }, + { + message: "Database name:", + name: "databaseName", + type: "input", + validate: (input) => (input ? true : "Database name is required"), + }, + { + message: "Enter the database description (optional):", + name: "description", + type: "input", + }, + { + message: "Database Root Password (optional):", + name: "databaseRootPassword", + type: "input", + }, + { + message: "Database password (optional):", + name: "databasePassword", + type: "input", + }, + { + default: "mysql:8", + message: "Docker Image (default: mysql:8):", + name: "dockerImage", + type: "input", + }, + { + default: "mysql", + message: "Database User: (default: mysql):", + name: "databaseUser", + type: "input", + }, + ]); + + const appName = await inquirer.prompt([ + { + default: `${slugify(project.name)}-${appDetails.name}`, + message: "Enter the App name: (optional):", + name: "appName", + type: "input", + validate: (input) => (input ? true : "Database name is required"), + }, + ]); + + const responseDatabase = await axios.post( + `${auth.url}/api/trpc/mysql.create`, + { + json: { + ...appDetails, + appName: appName.appName, + projectId: project.projectId, + }, + }, + { + headers: { + Authorization: `Bearer ${auth.token}`, + "Content-Type": "application/json", + }, + }, + ); + + if (!responseDatabase.data.result.data.json) { + this.error(chalk.red("Error creating database")); + } + + this.log( + chalk.green(`Database '${appDetails.name}' created successfully.`), + ); + } catch (error) { + // @ts-expect-error TODO: Fix this + this.error(chalk.red(`Failed to fetch project list: ${error.message}`)); + } + } + } +} diff --git a/src/commands/database/postgres/create.ts b/src/commands/database/postgres/create.ts new file mode 100644 index 0000000..94451db --- /dev/null +++ b/src/commands/database/postgres/create.ts @@ -0,0 +1,140 @@ +import { Command, Flags } from "@oclif/core"; +import axios from "axios"; +import chalk from "chalk"; +import inquirer from "inquirer"; + +import { slugify } from "../../../utils/slug.js"; +import { readAuthConfig } from "../../../utils/utils.js"; + +export default class DatabasePostgresCreate extends Command { + static description = "Create a new database within a project."; + + static examples = ["$ <%= config.bin %> postgres create"]; + + static flags = { + projectId: Flags.string({ + char: "p", + description: "ID of the project", + required: false, + }), + }; + + public async run(): Promise { + const auth = await readAuthConfig(this); + + const { flags } = await this.parse(DatabasePostgresCreate); + + const { projectId } = flags; + if (!projectId) { + console.log(chalk.blue.bold("\n Listing all Projects \n")); + + try { + const response = await axios.get(`${auth.url}/api/trpc/project.all`, { + headers: { + Authorization: `Bearer ${auth.token}`, + "Content-Type": "application/json", + }, + }); + + if (!response.data.result.data.json) { + this.error(chalk.red("Error fetching projects")); + } + + const projects = response.data.result.data.json; + + if (projects.length === 0) { + this.log(chalk.yellow("No projects found.")); + return; + } + + const { project } = await inquirer.prompt([ + { + choices: projects.map((project: any) => ({ + name: project.name, + value: project, + })), + message: "Select a project to create the database in:", + name: "project", + type: "list", + }, + ]); + + const appDetails = await inquirer.prompt([ + { + message: "Enter the name:", + name: "name", + type: "input", + validate: (input) => (input ? true : "Database name is required"), + }, + { + message: "Database name:", + name: "databaseName", + type: "input", + validate: (input) => (input ? true : "Database name is required"), + }, + { + message: "Enter the database description (optional):", + name: "description", + type: "input", + }, + { + message: "Database password (optional):", + name: "databasePassword", + type: "input", + }, + { + default: "postgres:15", + message: "Docker Image (default: postgres:15):", + name: "dockerImage", + type: "input", + }, + + { + default: "postgres", + message: "Database User: (default: postgres):", + name: "databaseUser", + type: "input", + }, + ]); + + const appName = await inquirer.prompt([ + { + default: `${slugify(project.name)}-${appDetails.name}`, + message: "Enter the App name: (optional):", + name: "appName", + type: "input", + validate: (input) => (input ? true : "Database name is required"), + }, + ]); + + const responseDatabase = await axios.post( + `${auth.url}/api/trpc/postgres.create`, + { + json: { + ...appDetails, + appName: appName.appName, + projectId: project.projectId, + }, + }, + { + headers: { + Authorization: `Bearer ${auth.token}`, + "Content-Type": "application/json", + }, + }, + ); + + if (!responseDatabase.data.result.data.json) { + this.error(chalk.red("Error creating database")); + } + + this.log( + chalk.green(`Database '${appDetails.name}' created successfully.`), + ); + } catch (error) { + // @ts-expect-error TODO: Fix this + this.error(chalk.red(`Failed to fetch project list: ${error.message}`)); + } + } + } +} diff --git a/src/commands/database/redis/create.ts b/src/commands/database/redis/create.ts new file mode 100644 index 0000000..a68f00a --- /dev/null +++ b/src/commands/database/redis/create.ts @@ -0,0 +1,125 @@ +import { Command, Flags } from "@oclif/core"; +import axios from "axios"; +import chalk from "chalk"; +import inquirer from "inquirer"; + +import { slugify } from "../../../utils/slug.js"; +import { readAuthConfig } from "../../../utils/utils.js"; + +export default class DatabaseRedisCreate extends Command { + static description = "Create a new database within a project."; + + static examples = ["$ <%= config.bin %> redis create"]; + + static flags = { + projectId: Flags.string({ + char: "p", + description: "ID of the project", + required: false, + }), + }; + + public async run(): Promise { + const auth = await readAuthConfig(this); + const { flags } = await this.parse(DatabaseRedisCreate); + const { projectId } = flags; + if (!projectId) { + console.log(chalk.blue.bold("\n Listing all Projects \n")); + + try { + const response = await axios.get(`${auth.url}/api/trpc/project.all`, { + headers: { + Authorization: `Bearer ${auth.token}`, + "Content-Type": "application/json", + }, + }); + + if (!response.data.result.data.json) { + this.error(chalk.red("Error fetching projects")); + } + + const projects = response.data.result.data.json; + + if (projects.length === 0) { + this.log(chalk.yellow("No projects found.")); + return; + } + + const { project } = await inquirer.prompt([ + { + choices: projects.map((project: any) => ({ + name: project.name, + value: project, + })), + message: "Select a project to create the database in:", + name: "project", + type: "list", + }, + ]); + + const appDetails = await inquirer.prompt([ + { + message: "Enter the name:", + name: "name", + type: "input", + validate: (input) => (input ? true : "Database name is required"), + }, + { + message: "Enter the database description (optional):", + name: "description", + type: "input", + }, + { + message: "Database password (optional):", + name: "databasePassword", + type: "input", + }, + { + default: "redis:7", + message: "Docker Image (default: redis:7):", + name: "dockerImage", + type: "input", + }, + ]); + + const appName = await inquirer.prompt([ + { + default: `${slugify(project.name)}-${appDetails.name}`, + message: "Enter the App name: (optional):", + name: "appName", + type: "input", + validate: (input) => (input ? true : "Database name is required"), + }, + ]); + + const responseDatabase = await axios.post( + `${auth.url}/api/trpc/redis.create`, + { + json: { + ...appDetails, + appName: appName.appName, + projectId: project.projectId, + }, + }, + { + headers: { + Authorization: `Bearer ${auth.token}`, + "Content-Type": "application/json", + }, + }, + ); + + if (!responseDatabase.data.result.data.json) { + this.error(chalk.red("Error creating database")); + } + + this.log( + chalk.green(`Database '${appDetails.name}' created successfully.`), + ); + } catch (error) { + // @ts-expect-error TODO: Fix this + this.error(chalk.red(`Failed to fetch project list: ${error.message}`)); + } + } + } +} diff --git a/src/utils/slug.ts b/src/utils/slug.ts new file mode 100644 index 0000000..1c79a8c --- /dev/null +++ b/src/utils/slug.ts @@ -0,0 +1,14 @@ +import slug from "./slugify.js"; + +export const slugify = (text: string | undefined) => { + if (!text) { + return ""; + } + + const cleanedText = text.trim().replaceAll(/[^\d\sA-Za-z]/g, ""); + return slug(cleanedText, { + lower: true, + strict: true, + trim: true, + }); +}; diff --git a/src/utils/slugify.ts b/src/utils/slugify.ts new file mode 100644 index 0000000..c68e030 --- /dev/null +++ b/src/utils/slugify.ts @@ -0,0 +1,3 @@ +import slugify from "slugify"; + +export default slugify as unknown as typeof slugify.default; diff --git a/test/commands/database/create.test.ts b/test/commands/database/create.test.ts new file mode 100644 index 0000000..0e9c882 --- /dev/null +++ b/test/commands/database/create.test.ts @@ -0,0 +1,14 @@ +import {runCommand} from '@oclif/test' +import {expect} from 'chai' + +describe('database:create', () => { + it('runs database:create cmd', async () => { + const {stdout} = await runCommand('database:create') + expect(stdout).to.contain('hello world') + }) + + it('runs database:create --name oclif', async () => { + const {stdout} = await runCommand('database:create --name oclif') + expect(stdout).to.contain('hello oclif') + }) +}) diff --git a/test/commands/database/mariadb/create.test.ts b/test/commands/database/mariadb/create.test.ts new file mode 100644 index 0000000..5891adf --- /dev/null +++ b/test/commands/database/mariadb/create.test.ts @@ -0,0 +1,14 @@ +import {runCommand} from '@oclif/test' +import {expect} from 'chai' + +describe('database:mariadb:create', () => { + it('runs database:mariadb:create cmd', async () => { + const {stdout} = await runCommand('database:mariadb:create') + expect(stdout).to.contain('hello world') + }) + + it('runs database:mariadb:create --name oclif', async () => { + const {stdout} = await runCommand('database:mariadb:create --name oclif') + expect(stdout).to.contain('hello oclif') + }) +}) diff --git a/test/commands/database/mongo/create.test.ts b/test/commands/database/mongo/create.test.ts new file mode 100644 index 0000000..b04cc22 --- /dev/null +++ b/test/commands/database/mongo/create.test.ts @@ -0,0 +1,14 @@ +import {runCommand} from '@oclif/test' +import {expect} from 'chai' + +describe('database:mongo:create', () => { + it('runs database:mongo:create cmd', async () => { + const {stdout} = await runCommand('database:mongo:create') + expect(stdout).to.contain('hello world') + }) + + it('runs database:mongo:create --name oclif', async () => { + const {stdout} = await runCommand('database:mongo:create --name oclif') + expect(stdout).to.contain('hello oclif') + }) +}) diff --git a/test/commands/database/mysql/create.test.ts b/test/commands/database/mysql/create.test.ts new file mode 100644 index 0000000..0812e46 --- /dev/null +++ b/test/commands/database/mysql/create.test.ts @@ -0,0 +1,14 @@ +import {runCommand} from '@oclif/test' +import {expect} from 'chai' + +describe('database:mysql:create', () => { + it('runs database:mysql:create cmd', async () => { + const {stdout} = await runCommand('database:mysql:create') + expect(stdout).to.contain('hello world') + }) + + it('runs database:mysql:create --name oclif', async () => { + const {stdout} = await runCommand('database:mysql:create --name oclif') + expect(stdout).to.contain('hello oclif') + }) +}) diff --git a/test/commands/database/postgres/create.test.ts b/test/commands/database/postgres/create.test.ts new file mode 100644 index 0000000..a032ffd --- /dev/null +++ b/test/commands/database/postgres/create.test.ts @@ -0,0 +1,14 @@ +import {runCommand} from '@oclif/test' +import {expect} from 'chai' + +describe('database:postgres:create', () => { + it('runs database:postgres:create cmd', async () => { + const {stdout} = await runCommand('database:postgres:create') + expect(stdout).to.contain('hello world') + }) + + it('runs database:postgres:create --name oclif', async () => { + const {stdout} = await runCommand('database:postgres:create --name oclif') + expect(stdout).to.contain('hello oclif') + }) +}) diff --git a/test/commands/database/redis/create.test.ts b/test/commands/database/redis/create.test.ts new file mode 100644 index 0000000..9e910e6 --- /dev/null +++ b/test/commands/database/redis/create.test.ts @@ -0,0 +1,14 @@ +import {runCommand} from '@oclif/test' +import {expect} from 'chai' + +describe('database:redis:create', () => { + it('runs database:redis:create cmd', async () => { + const {stdout} = await runCommand('database:redis:create') + expect(stdout).to.contain('hello world') + }) + + it('runs database:redis:create --name oclif', async () => { + const {stdout} = await runCommand('database:redis:create --name oclif') + expect(stdout).to.contain('hello oclif') + }) +})