From 6700d0694723423382d962f223bdf15d757a1af1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Lenon?= Date: Mon, 4 Apr 2022 22:41:52 -0300 Subject: [PATCH 01/19] feat: add controller template --- templates/.gitkeep | 0 templates/__name__Controller.ts.ejs | 62 +++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) delete mode 100644 templates/.gitkeep create mode 100644 templates/__name__Controller.ts.ejs diff --git a/templates/.gitkeep b/templates/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/templates/__name__Controller.ts.ejs b/templates/__name__Controller.ts.ejs new file mode 100644 index 0000000..e1ae357 --- /dev/null +++ b/templates/__name__Controller.ts.ejs @@ -0,0 +1,62 @@ +import { ContextContract } from '@athenna/http' +import { Container } from 'providers/Container' + +export class <%= namePascal %>Controller { + /** + * Use the constructor to resolve any dependency of the Ioc container + * + * @param container + * @return <%= namePascal %>Controller + */ + constructor(_container: Container) {} + + /** + * Index method + * + * @param ctx: ContextContract + * @return any[] + */ + async index({ response }: ContextContract) { + return response.status(200).send([{}]) + } + + /** + * Store method + * + * @param ctx: ContextContract + * @return any + */ + async store({ response }: ContextContract) { + return response.status(201).send({}) + } + + /** + * Show method + * + * @param ctx: ContextContract + * @return any + */ + async show({ response }: ContextContract) { + return response.status(200).send({}) + } + + /** + * Update method + * + * @param ctx: ContextContract + * @return any + */ + async update({ response, params }: ContextContract) { + return response.status(200).send({ id: params.id }) + } + + /** + * Delete method + * + * @param ctx: ContextContract + * @return void + */ + async delete({ response }: ContextContract) { + return response.status(204) + } +} From 965a0604c010aae3aa34434fef79a375abcc6710 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Lenon?= Date: Tue, 5 Apr 2022 10:36:11 -0300 Subject: [PATCH 02/19] feat: add make:controller command --- package-lock.json | 94 ++++++++++++++++++++++++++++- package.json | 2 + src/Cli.ts | 28 ++++++++- src/Commands/Make.ts | 89 +++++++++++++++++++++++++++ src/Commands/New.ts | 13 ++-- templates/__name__Controller.js.ejs | 62 +++++++++++++++++++ 6 files changed, 276 insertions(+), 12 deletions(-) create mode 100644 src/Commands/Make.ts create mode 100644 templates/__name__Controller.js.ejs diff --git a/package-lock.json b/package-lock.json index 050c5b8..af3ab03 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@athenna/cli", - "version": "1.0.0", + "version": "1.0.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@athenna/cli", - "version": "1.0.0", + "version": "1.0.1", "license": "MIT", "dependencies": { "@secjs/utils": "1.8.0", @@ -14,6 +14,7 @@ "chalk-rainbow": "1.0.0", "cli-table": "0.3.11", "commander": "9.1.0", + "ejs": "^3.1.6", "figlet": "1.5.2", "inquirer": "8.2.2", "ora": "5.4.1", @@ -27,6 +28,7 @@ "@types/chalk": "2.2.0", "@types/cli-table": "0.3.0", "@types/commander": "2.12.2", + "@types/ejs": "^3.1.0", "@types/jest": "27.0.1", "@types/node": "14.17.0", "@types/ora": "3.2.0", @@ -1973,6 +1975,12 @@ "commander": "*" } }, + "node_modules/@types/ejs": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@types/ejs/-/ejs-3.1.0.tgz", + "integrity": "sha512-DCg+Ka+uDQ31lJ/UtEXVlaeV3d6t81gifaVWKJy4MYVVgvJttyX/viREy+If7fz+tK/gVxTGMtyrFPnm4gjrVA==", + "dev": true + }, "node_modules/@types/eslint": { "version": "8.4.1", "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.4.1.tgz", @@ -2740,6 +2748,11 @@ "node": ">=8" } }, + "node_modules/async": { + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/async/-/async-0.9.2.tgz", + "integrity": "sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=" + }, "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -4425,6 +4438,20 @@ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz", "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==" }, + "node_modules/ejs": { + "version": "3.1.6", + "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.6.tgz", + "integrity": "sha512-9lt9Zse4hPucPkoP7FHDF0LQAlGyF9JVpnClFLFH3aSSbxmyoqINRpp/9wePWJTUl4KOQwRL72Iw3InHPDkoGw==", + "dependencies": { + "jake": "^10.6.1" + }, + "bin": { + "ejs": "bin/cli.js" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/electron-to-chromium": { "version": "1.4.89", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.89.tgz", @@ -5757,6 +5784,14 @@ "node": "^10.12.0 || >=12.0.0" } }, + "node_modules/filelist": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.2.tgz", + "integrity": "sha512-z7O0IS8Plc39rTCq6i6iHxk43duYOn8uFJiWSewIq0Bww1RNybVHSCjahmcC87ZqAm4OTvFzlzeGu3XAzG1ctQ==", + "dependencies": { + "minimatch": "^3.0.4" + } + }, "node_modules/fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", @@ -7304,6 +7339,23 @@ "node": ">=8" } }, + "node_modules/jake": { + "version": "10.8.4", + "resolved": "https://registry.npmjs.org/jake/-/jake-10.8.4.tgz", + "integrity": "sha512-MtWeTkl1qGsWUtbl/Jsca/8xSoK3x0UmS82sNbjqxxG/de/M/3b1DntdjHgPMC50enlTNwXOCRqPXLLt5cCfZA==", + "dependencies": { + "async": "0.9.x", + "chalk": "^4.0.2", + "filelist": "^1.0.1", + "minimatch": "^3.0.4" + }, + "bin": { + "jake": "bin/cli.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/jest": { "version": "27.1.0", "resolved": "https://registry.npmjs.org/jest/-/jest-27.1.0.tgz", @@ -15098,6 +15150,12 @@ "commander": "*" } }, + "@types/ejs": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@types/ejs/-/ejs-3.1.0.tgz", + "integrity": "sha512-DCg+Ka+uDQ31lJ/UtEXVlaeV3d6t81gifaVWKJy4MYVVgvJttyX/viREy+If7fz+tK/gVxTGMtyrFPnm4gjrVA==", + "dev": true + }, "@types/eslint": { "version": "8.4.1", "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.4.1.tgz", @@ -15712,6 +15770,11 @@ "integrity": "sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==", "dev": true }, + "async": { + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/async/-/async-0.9.2.tgz", + "integrity": "sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=" + }, "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -17000,6 +17063,14 @@ } } }, + "ejs": { + "version": "3.1.6", + "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.6.tgz", + "integrity": "sha512-9lt9Zse4hPucPkoP7FHDF0LQAlGyF9JVpnClFLFH3aSSbxmyoqINRpp/9wePWJTUl4KOQwRL72Iw3InHPDkoGw==", + "requires": { + "jake": "^10.6.1" + } + }, "electron-to-chromium": { "version": "1.4.89", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.89.tgz", @@ -17991,6 +18062,14 @@ "flat-cache": "^3.0.4" } }, + "filelist": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.2.tgz", + "integrity": "sha512-z7O0IS8Plc39rTCq6i6iHxk43duYOn8uFJiWSewIq0Bww1RNybVHSCjahmcC87ZqAm4OTvFzlzeGu3XAzG1ctQ==", + "requires": { + "minimatch": "^3.0.4" + } + }, "fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", @@ -19129,6 +19208,17 @@ "istanbul-lib-report": "^3.0.0" } }, + "jake": { + "version": "10.8.4", + "resolved": "https://registry.npmjs.org/jake/-/jake-10.8.4.tgz", + "integrity": "sha512-MtWeTkl1qGsWUtbl/Jsca/8xSoK3x0UmS82sNbjqxxG/de/M/3b1DntdjHgPMC50enlTNwXOCRqPXLLt5cCfZA==", + "requires": { + "async": "0.9.x", + "chalk": "^4.0.2", + "filelist": "^1.0.1", + "minimatch": "^3.0.4" + } + }, "jest": { "version": "27.1.0", "resolved": "https://registry.npmjs.org/jest/-/jest-27.1.0.tgz", diff --git a/package.json b/package.json index a40a7dd..1885cc2 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "@types/chalk": "2.2.0", "@types/cli-table": "0.3.0", "@types/commander": "2.12.2", + "@types/ejs": "3.1.0", "@types/jest": "27.0.1", "@types/node": "14.17.0", "@types/ora": "3.2.0", @@ -171,6 +172,7 @@ "chalk-rainbow": "1.0.0", "cli-table": "0.3.11", "commander": "9.1.0", + "ejs": "3.1.6", "figlet": "1.5.2", "inquirer": "8.2.2", "ora": "5.4.1", diff --git a/src/Cli.ts b/src/Cli.ts index 4b897fd..33e7f3f 100644 --- a/src/Cli.ts +++ b/src/Cli.ts @@ -12,20 +12,32 @@ import { Command } from 'commander' import { New } from './Commands/New' import { version } from '../package.json' import chalkRainbow from 'chalk-rainbow' +import { Make } from './Commands/Make' +import { resolve } from 'path' export class Cli { + private clientFolder: string private program: Command public constructor() { + this.clientFolder = process.cwd() + this.program = new Command() + /** + * Change all process.cwd commands to return the + * root path where @athenna/cli is stored + */ + process.chdir(resolve(__dirname, '..')) + console.log(chalkRainbow(figlet.textSync('Athenna'))) this.program.version(`v${version}`, '-v, --version') } async main() { - const newCommand = new New() + const newCommand = new New(this.clientFolder) + const makeCommand = new Make(this.clientFolder) this.program .command('new') @@ -35,6 +47,20 @@ export class Cli { .action(newCommand.project.bind(newCommand)) .createHelp() + this.program + .command('make:controller') + .argument('', 'Your controller name') + .option( + '-e, --extension ', + 'Current extension available: ts, js', + 'ts', + ) + .description( + 'Make a new controller file inside app/Http/Controllers directory', + ) + .action(makeCommand.controller.bind(makeCommand)) + .createHelp() + await this.program.parseAsync(process.argv) } } diff --git a/src/Commands/Make.ts b/src/Commands/Make.ts new file mode 100644 index 0000000..17da147 --- /dev/null +++ b/src/Commands/Make.ts @@ -0,0 +1,89 @@ +/** + * @athenna/cli + * + * (c) Victor Tesoura Júnior + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +import ejs from 'ejs' +import chalk from 'chalk' +import { Logger } from '../Utils/Logger' +import { File, Folder, Path, String } from '@secjs/utils' + +export class Make { + private readonly logger: Logger + private readonly clientFolder: string + private readonly templatesFolder: Folder + + public constructor(clientFolder: string) { + this.clientFolder = clientFolder + + this.logger = new Logger() + + this.templatesFolder = new Folder(Path.pwd('templates')).loadSync() + } + + async controller(name: string, options: any): Promise { + this.logger.success.bold.log('[ MAKING CONTROLLER ]\n') + + if (name.includes('Controller') || name.includes('Controllers')) { + name = name.split('Controller')[0] + } + + const template = this.getTemplate('__name__Controller', options) + + if (!template) { + // TODO Log error instead of throw + throw new Error('File not found') + } + + // TODO Resolve the path always looking to his project root + // TODO Maybe find for the package.json file in getConcretePath + const path = this.getConcretePath(name, template.base) + const content = this.normalizeTemplate(name, template.getContentSync()) + + const concreteController = await new File(path, content).create() + + console.log( + `\n${chalk.bold.green('[ success ]')} Controller ${ + concreteController.name + } successfully created inside app/Http/Controllers`, + ) + } + + private getTemplate(templateName: string, options: any): File { + templateName = `${templateName}.${options.extension}.ejs` + + return this.templatesFolder.files.find(f => f.base === templateName) as File + } + + private getConcretePath(name: string, baseTemplateName: string) { + const normalizedName = this.normalizeName(name, baseTemplateName) + + return `${this.clientFolder}/app/Http/Controllers/${normalizedName}` + } + + private normalizeName(name: string, baseTemplateName: string): string { + return baseTemplateName + .replace('.ejs', '') + .replace('__name__', name) + .replace('__name_low__', name.toLowerCase()) + .replace('__name_plural__', String.pluralize(name)) + .replace('__name_plural_low__', String.pluralize(name).toLowerCase()) + } + + private normalizeTemplate(name: string, templateContent: Buffer): Buffer { + const templateString = ejs.render(templateContent.toString(), { + nameUp: name.toUpperCase(), + nameCamel: String.toCamelCase(name), + namePlural: String.pluralize(name), + namePascal: String.toPascalCase(name), + namePluralCamel: String.toCamelCase(String.pluralize(name)), + namePluralPascal: String.toPascalCase(String.pluralize(name)), + }) + + return Buffer.from(templateString) + } +} diff --git a/src/Commands/New.ts b/src/Commands/New.ts index 40f0dde..16b2bb7 100644 --- a/src/Commands/New.ts +++ b/src/Commands/New.ts @@ -12,7 +12,7 @@ import chalk from 'chalk' import Table from 'cli-table' import { existsSync } from 'fs' import { promisify } from 'util' -import { resolve, sep } from 'path' +import { sep } from 'path' import { Logger } from '../Utils/Logger' import { Folder, Path } from '@secjs/utils' import { NodeExecException } from '../Exceptions/NodeExecException' @@ -24,15 +24,10 @@ export class New { private readonly clientFolder: string private readonly repositoryUrl: string - public constructor() { - this.clientFolder = process.cwd() - this.logger = new Logger() + public constructor(clientFolder: string) { + this.clientFolder = clientFolder - /** - * Change all process.cwd commands to return the - * root path where @athenna/cli is stored - */ - process.chdir(resolve(__dirname, '..', '..')) + this.logger = new Logger() this.repositoryUrl = 'https://github.com/AthennaIO/Scaffold.git' } diff --git a/templates/__name__Controller.js.ejs b/templates/__name__Controller.js.ejs new file mode 100644 index 0000000..f1e72f8 --- /dev/null +++ b/templates/__name__Controller.js.ejs @@ -0,0 +1,62 @@ +import { ContextContract } from '@athenna/http' +import { Container } from 'providers/Container' + +export class <%= namePascal %>Controller { + /** + * Use the constructor to resolve any dependency of the Ioc container + * + * @param container + * @return <%= namePascal %>Controller + */ + constructor(_container) {} + + /** + * Index method + * + * @param ctx: ContextContract + * @return any[] + */ + async index({ response }) { + return response.status(200).send([{}]) + } + + /** + * Store method + * + * @param ctx: ContextContract + * @return any + */ + async store({ response }) { + return response.status(201).send({}) + } + + /** + * Show method + * + * @param ctx: ContextContract + * @return any + */ + async show({ response }) { + return response.status(200).send({}) + } + + /** + * Update method + * + * @param ctx: ContextContract + * @return any + */ + async update({ response, params }) { + return response.status(200).send({ id: params.id }) + } + + /** + * Delete method + * + * @param ctx: ContextContract + * @return void + */ + async delete({ response }) { + return response.status(204) + } +} From 85afae54064d9a5fafae20f4e36ae6031ca3d591 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Lenon?= Date: Tue, 5 Apr 2022 11:56:37 -0300 Subject: [PATCH 03/19] feat: create engine to add colors in logs string --- src/Cli.ts | 6 +++--- src/Commands/Make.ts | 34 ++++++++++++++++++++------------ src/Commands/New.ts | 26 ++++++++----------------- src/Utils/CtxLogger.ts | 44 ++++++++++++++++++++++++++++++++++++++++++ src/Utils/Logger.ts | 30 ++++++++++++++++++++++++++++ 5 files changed, 107 insertions(+), 33 deletions(-) create mode 100644 src/Utils/CtxLogger.ts diff --git a/src/Cli.ts b/src/Cli.ts index 33e7f3f..6188901 100644 --- a/src/Cli.ts +++ b/src/Cli.ts @@ -8,12 +8,12 @@ */ import figlet from 'figlet' +import { resolve } from 'path' import { Command } from 'commander' import { New } from './Commands/New' -import { version } from '../package.json' -import chalkRainbow from 'chalk-rainbow' import { Make } from './Commands/Make' -import { resolve } from 'path' +import chalkRainbow from 'chalk-rainbow' +import { version } from '../package.json' export class Cli { private clientFolder: string diff --git a/src/Commands/Make.ts b/src/Commands/Make.ts index 17da147..b3480f5 100644 --- a/src/Commands/Make.ts +++ b/src/Commands/Make.ts @@ -8,25 +8,24 @@ */ import ejs from 'ejs' -import chalk from 'chalk' import { Logger } from '../Utils/Logger' import { File, Folder, Path, String } from '@secjs/utils' +import { CtxLogger } from '../Utils/CtxLogger' +import { existsSync } from 'fs' +import { parse } from 'path' export class Make { - private readonly logger: Logger private readonly clientFolder: string private readonly templatesFolder: Folder public constructor(clientFolder: string) { this.clientFolder = clientFolder - this.logger = new Logger() - this.templatesFolder = new Folder(Path.pwd('templates')).loadSync() } async controller(name: string, options: any): Promise { - this.logger.success.bold.log('[ MAKING CONTROLLER ]\n') + new Logger().success.bold.log('[ MAKING CONTROLLER ]\n') if (name.includes('Controller') || name.includes('Controllers')) { name = name.split('Controller')[0] @@ -35,8 +34,11 @@ export class Make { const template = this.getTemplate('__name__Controller', options) if (!template) { - // TODO Log error instead of throw - throw new Error('File not found') + CtxLogger.error( + `Template for extension ({yellow} "${options.extension}") has not been found`, + ) + + return } // TODO Resolve the path always looking to his project root @@ -44,12 +46,20 @@ export class Make { const path = this.getConcretePath(name, template.base) const content = this.normalizeTemplate(name, template.getContentSync()) - const concreteController = await new File(path, content).create() + if (existsSync(path)) { + CtxLogger.error( + `The controller ({yellow} "${ + parse(path).name + }") already exists. Try using another name`, + ) + + return + } + + const controller = await new File(path, content).create() - console.log( - `\n${chalk.bold.green('[ success ]')} Controller ${ - concreteController.name - } successfully created inside app/Http/Controllers`, + CtxLogger.success( + `Controller ({yellow} "${controller.name}") successfully created.`, ) } diff --git a/src/Commands/New.ts b/src/Commands/New.ts index 16b2bb7..5af5268 100644 --- a/src/Commands/New.ts +++ b/src/Commands/New.ts @@ -9,26 +9,24 @@ import ora from 'ora' import chalk from 'chalk' +import { sep } from 'path' import Table from 'cli-table' import { existsSync } from 'fs' import { promisify } from 'util' -import { sep } from 'path' import { Logger } from '../Utils/Logger' import { Folder, Path } from '@secjs/utils' +import { CtxLogger } from '../Utils/CtxLogger' import { NodeExecException } from '../Exceptions/NodeExecException' const exec = promisify(require('child_process').exec) export class New { - private readonly logger: Logger private readonly clientFolder: string private readonly repositoryUrl: string public constructor(clientFolder: string) { this.clientFolder = clientFolder - this.logger = new Logger() - this.repositoryUrl = 'https://github.com/AthennaIO/Scaffold.git' } @@ -37,10 +35,8 @@ export class New { await new Folder(Path.storage()).create() if (!this[options.type]) { - console.log( - `${chalk.bold.red('[ error ]')} The project type "${ - options.type - }" doesnt exist. Try running "athenna new:project --help" to se the available project types`, + CtxLogger.error( + `The project type ({yellow} "${options.type}") doesnt exist. Try running ({yellow} "athenna new:project --help") to se the available project types`, ) return @@ -50,16 +46,14 @@ export class New { } async http(projectName: string) { - this.logger.success.bold.log('[ GENERATING HTTP SERVER ]\n') + new Logger().success.bold.log('[ GENERATING HTTP SERVER ]\n') const projectPath = Path.storage(`project/${projectName}`) const concretePath = `${this.clientFolder}${sep}${projectName}` if (existsSync(concretePath)) { - console.log( - `${chalk.bold.red( - '[ error ]', - )} The folder ${projectName} already exists. Try another project name`, + CtxLogger.error( + `The directory ({yellow} "${projectName}") already exists. Try another project name`, ) return @@ -84,11 +78,7 @@ export class New { await this.runCommand(runNpmInstallCommand, 'Installing dependencies') await this.runCommand(moveProjectCommand, 'Moving project to your path') - console.log( - `\n${chalk.bold.green( - '[ success ]', - )} Project created at ${projectName} folder`, - ) + CtxLogger.success(`Project created at ({yellow} "${projectName}") folder`) const table = new Table() diff --git a/src/Utils/CtxLogger.ts b/src/Utils/CtxLogger.ts new file mode 100644 index 0000000..6674c2d --- /dev/null +++ b/src/Utils/CtxLogger.ts @@ -0,0 +1,44 @@ +/** + * @athenna/cli + * + * (c) João Lenon + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +import chalk from 'chalk' +import { Logger } from './Logger' + +export class CtxLogger { + private static logger = new Logger() + + static info(message: string): void { + const ctx = chalk.bold.cyan('[ info ]') + + this.logger.log(`${ctx} ${message}`) + } + + static warn(message: string): void { + const ctx = chalk.bold.yellow('[ warn ]') + + this.logger.log(`${ctx} ${message}`) + } + + static error(message: string): void { + const ctx = chalk.bold.red('[ error ]') + + this.logger.log(`${ctx} ${message}`) + } + + static debug(message: string): void { + const ctx = chalk.bold.magenta('[ debug ]') + + this.logger.log(`${ctx} ${message}`) + } + + static success(message: string): void { + const ctx = chalk.bold.green('\n[ success ]') + + this.logger.log(`${ctx} ${message}`) + } +} diff --git a/src/Utils/Logger.ts b/src/Utils/Logger.ts index ec26623..25103f1 100644 --- a/src/Utils/Logger.ts +++ b/src/Utils/Logger.ts @@ -8,6 +8,7 @@ */ import chalk from 'chalk' +import { Is } from '@secjs/utils' export class Logger { private chalk: any @@ -53,6 +54,35 @@ export class Logger { } log(content: any) { + if (Is.String(content)) { + const matches = content.match(/\({(.*?)} (.*?)\)/g) + + if (matches) { + matches.forEach(match => { + const color = match + .split(' ')[0] + .replace('(', '') + .replace('{', '') + .replace('}', '') + + if (!this.chalk[color]) { + throw new Error(`Color ${color} does not exist`) + } + + const message = match + .replace(`({${color}} `, '') + .replace(')', '') + .replace('}', '') + + const replacedMatch = match + .replace(`({${color}} `, '') + .replace(`${message})`, this.chalk[color](message)) + + content = content.replace(match, replacedMatch) + }) + } + } + console.log(this.chalk(content)) this.chalk = chalk } From 4293d377f7e3f58b8db6c529bd03fe7b7d12dab9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Lenon?= Date: Tue, 5 Apr 2022 12:01:55 -0300 Subject: [PATCH 04/19] feat: add dots to commands --- src/Commands/Make.ts | 4 ++-- src/Commands/New.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Commands/Make.ts b/src/Commands/Make.ts index b3480f5..7616085 100644 --- a/src/Commands/Make.ts +++ b/src/Commands/Make.ts @@ -35,7 +35,7 @@ export class Make { if (!template) { CtxLogger.error( - `Template for extension ({yellow} "${options.extension}") has not been found`, + `Template for extension ({yellow} "${options.extension}") has not been found.`, ) return @@ -50,7 +50,7 @@ export class Make { CtxLogger.error( `The controller ({yellow} "${ parse(path).name - }") already exists. Try using another name`, + }") already exists. Try using another name.`, ) return diff --git a/src/Commands/New.ts b/src/Commands/New.ts index 5af5268..bdd8265 100644 --- a/src/Commands/New.ts +++ b/src/Commands/New.ts @@ -36,7 +36,7 @@ export class New { if (!this[options.type]) { CtxLogger.error( - `The project type ({yellow} "${options.type}") doesnt exist. Try running ({yellow} "athenna new:project --help") to se the available project types`, + `The project type ({yellow} "${options.type}") doesnt exist. Try running ({yellow} "athenna new:project --help") to se the available project types.`, ) return @@ -53,7 +53,7 @@ export class New { if (existsSync(concretePath)) { CtxLogger.error( - `The directory ({yellow} "${projectName}") already exists. Try another project name`, + `The directory ({yellow} "${projectName}") already exists. Try another project name.`, ) return @@ -78,7 +78,7 @@ export class New { await this.runCommand(runNpmInstallCommand, 'Installing dependencies') await this.runCommand(moveProjectCommand, 'Moving project to your path') - CtxLogger.success(`Project created at ({yellow} "${projectName}") folder`) + CtxLogger.success(`Project created at ({yellow} "${projectName}") folder.`) const table = new Table() From f99a5389b96c8e532e3601577943696d38f207b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Lenon?= Date: Tue, 5 Apr 2022 16:15:07 -0300 Subject: [PATCH 05/19] feat: add support for multiple chalk commands on log engine --- src/Commands/Make.ts | 2 +- src/Utils/Logger.ts | 38 ++++++++++++++++---------------------- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/src/Commands/Make.ts b/src/Commands/Make.ts index 7616085..933eb21 100644 --- a/src/Commands/Make.ts +++ b/src/Commands/Make.ts @@ -59,7 +59,7 @@ export class Make { const controller = await new File(path, content).create() CtxLogger.success( - `Controller ({yellow} "${controller.name}") successfully created.`, + `Controller ({yellow,italic} "${controller.name}") successfully created.`, ) } diff --git a/src/Utils/Logger.ts b/src/Utils/Logger.ts index 25103f1..d244e45 100644 --- a/src/Utils/Logger.ts +++ b/src/Utils/Logger.ts @@ -55,31 +55,25 @@ export class Logger { log(content: any) { if (Is.String(content)) { - const matches = content.match(/\({(.*?)} (.*?)\)/g) + const matches = content.match(/\({(.*?)} (.*?)\)/) if (matches) { - matches.forEach(match => { - const color = match - .split(' ')[0] - .replace('(', '') - .replace('{', '') - .replace('}', '') - - if (!this.chalk[color]) { - throw new Error(`Color ${color} does not exist`) - } - - const message = match - .replace(`({${color}} `, '') - .replace(')', '') - .replace('}', '') - - const replacedMatch = match - .replace(`({${color}} `, '') - .replace(`${message})`, this.chalk[color](message)) - - content = content.replace(match, replacedMatch) + const chalkMethodsString = matches[1].replace(/\s/g, '') + const chalkMethodsArray = chalkMethodsString.split(',') + const message = matches[2] + + let chalk = this.chalk + + chalkMethodsArray.forEach(chalkMethod => { + if (!chalk[chalkMethod]) return + + chalk = chalk[chalkMethod] }) + + content = content + .replace(`({${matches[1]}} `, '') + .replace(`({${matches[1]}}`, '') + .replace(`${matches[2]})`, chalk(message)) } } From 4e5c04e05f7813acc1e16e38da5c55643e3f063b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Lenon?= Date: Tue, 5 Apr 2022 16:42:21 -0300 Subject: [PATCH 06/19] fix: remove italic from log --- src/Commands/Make.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/Make.ts b/src/Commands/Make.ts index 933eb21..7616085 100644 --- a/src/Commands/Make.ts +++ b/src/Commands/Make.ts @@ -59,7 +59,7 @@ export class Make { const controller = await new File(path, content).create() CtxLogger.success( - `Controller ({yellow,italic} "${controller.name}") successfully created.`, + `Controller ({yellow} "${controller.name}") successfully created.`, ) } From b3f22fe1b2f24ba7c15287573cb0d1957e6e8897 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Lenon?= Date: Tue, 5 Apr 2022 17:50:25 -0300 Subject: [PATCH 07/19] feat: show help when error occurs --- config/logging.ts | 37 +++++ package-lock.json | 303 +++++++++++++++++++++++++++++++++++------ package.json | 7 +- src/Cli.ts | 2 + src/Commands/Make.ts | 20 +-- src/Commands/New.ts | 20 ++- src/Utils/CtxLogger.ts | 44 ------ src/Utils/Logger.ts | 83 ----------- 8 files changed, 334 insertions(+), 182 deletions(-) create mode 100644 config/logging.ts delete mode 100644 src/Utils/CtxLogger.ts delete mode 100644 src/Utils/Logger.ts diff --git a/config/logging.ts b/config/logging.ts new file mode 100644 index 0000000..a3b3e51 --- /dev/null +++ b/config/logging.ts @@ -0,0 +1,37 @@ +export default { + /* + |-------------------------------------------------------------------------- + | Default Log Channel + |-------------------------------------------------------------------------- + | + | This option defines the default log channel that gets used when writing + | messages to the logs. The name specified in this option should match + | one of the channels defined in the "channels" configuration object. + | + */ + + default: 'cli', + + /* + |-------------------------------------------------------------------------- + | Log Channels + |-------------------------------------------------------------------------- + | + | Here you may configure the log channels for your application. + | + | Available Drivers: "console", "debug", "file". + | Available Formatters: "cli", "simple", "nest", "json". + | + */ + + channels: { + cli: { + driver: 'console', + formatter: 'cli', + streamType: 'stdout', + formatterConfig: { + level: 'INFO', + }, + }, + }, +} diff --git a/package-lock.json b/package-lock.json index af3ab03..4934e2c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,20 +1,21 @@ { "name": "@athenna/cli", - "version": "1.0.1", + "version": "1.0.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@athenna/cli", - "version": "1.0.1", + "version": "1.0.2", "license": "MIT", "dependencies": { + "@athenna/logger": "1.0.9", "@secjs/utils": "1.8.0", "chalk": "4.1.1", "chalk-rainbow": "1.0.0", "cli-table": "0.3.11", "commander": "9.1.0", - "ejs": "^3.1.6", + "ejs": "3.1.6", "figlet": "1.5.2", "inquirer": "8.2.2", "ora": "5.4.1", @@ -28,7 +29,7 @@ "@types/chalk": "2.2.0", "@types/cli-table": "0.3.0", "@types/commander": "2.12.2", - "@types/ejs": "^3.1.0", + "@types/ejs": "3.1.0", "@types/jest": "27.0.1", "@types/node": "14.17.0", "@types/ora": "3.2.0", @@ -69,6 +70,135 @@ "node": ">=6.0.0" } }, + "node_modules/@athenna/ioc": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@athenna/ioc/-/ioc-1.0.9.tgz", + "integrity": "sha512-IqU04R7oZFGeHQRjI6d1hK1P0VYF6FYaKLQP0BAQL407q+Wh5AkDEqIxQDyInIOoqIyWjpRet0WpRWjUyrQ1tw==", + "dependencies": { + "@secjs/utils": "1.7.8", + "awilix": "7.0.0", + "reflect-metadata": "0.1.13", + "tscpaths": "0.0.9" + } + }, + "node_modules/@athenna/ioc/node_modules/@secjs/utils": { + "version": "1.7.8", + "resolved": "https://registry.npmjs.org/@secjs/utils/-/utils-1.7.8.tgz", + "integrity": "sha512-DrcuJhcF2kdUJWoilniCFxbNWVbJJiTI/1NP779kvOSBD8g402tBzqgIjZdrL+tItjcEXMEUFURvmmZeI1l9VQ==", + "dependencies": { + "bytes": "3.1.2", + "chalk": "4.1.2", + "change-case": "4.1.2", + "http-status-codes": "2.2.0", + "kind-of": "6.0.3", + "lodash": "4.17.21", + "mime-types": "2.1.34", + "ms": "2.1.3", + "pluralize": "8.0.0", + "uuid": "8.3.2", + "validator-brazil": "1.2.2" + } + }, + "node_modules/@athenna/ioc/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/@athenna/ioc/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/@athenna/ioc/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/@athenna/ioc/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "node_modules/@athenna/ioc/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/@athenna/ioc/node_modules/mime-db": { + "version": "1.51.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz", + "integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/@athenna/ioc/node_modules/mime-types": { + "version": "2.1.34", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.34.tgz", + "integrity": "sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==", + "dependencies": { + "mime-db": "1.51.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/@athenna/ioc/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "node_modules/@athenna/ioc/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@athenna/logger": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@athenna/logger/-/logger-1.0.9.tgz", + "integrity": "sha512-qJa0VSeKWjLrZ9i0roa3MC2abem8whYA0i2XPHbUZ0WP7mvwCRT2EJZZex1Jv4nB+wLZy4M6f5bFmwOwztksXQ==", + "dependencies": { + "@athenna/ioc": "1.0.9", + "@secjs/utils": "1.8.0", + "chalk": "4.1.1", + "reflect-metadata": "0.1.13", + "tscpaths": "0.0.9" + } + }, "node_modules/@babel/code-frame": { "version": "7.12.11", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.11.tgz", @@ -1700,7 +1830,6 @@ "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", - "dev": true, "dependencies": { "@nodelib/fs.stat": "2.0.5", "run-parallel": "^1.1.9" @@ -1713,7 +1842,6 @@ "version": "2.0.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", - "dev": true, "engines": { "node": ">= 8" } @@ -1722,7 +1850,6 @@ "version": "1.2.8", "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", - "dev": true, "dependencies": { "@nodelib/fs.scandir": "2.1.5", "fastq": "^1.6.0" @@ -2770,6 +2897,18 @@ "node": ">= 4.5.0" } }, + "node_modules/awilix": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/awilix/-/awilix-7.0.0.tgz", + "integrity": "sha512-Ye4SLwqVfrsHSRRT6OmxvJjmnKryWzvEUdKEgnq/wODkYsV1Yo+L2k0aHEj5WhPyDym17hCRBxJn5whXWhU2Tw==", + "dependencies": { + "camel-case": "^4.1.2", + "fast-glob": "^3.2.11" + }, + "engines": { + "node": ">=12.0.0" + } + }, "node_modules/babel-jest": { "version": "27.5.1", "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-27.5.1.tgz", @@ -3007,7 +3146,6 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", - "dev": true, "dependencies": { "fill-range": "^7.0.1" }, @@ -5710,7 +5848,6 @@ "version": "3.2.11", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.11.tgz", "integrity": "sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew==", - "dev": true, "dependencies": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", @@ -5738,7 +5875,6 @@ "version": "1.13.0", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz", "integrity": "sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw==", - "dev": true, "dependencies": { "reusify": "^1.0.4" } @@ -5796,7 +5932,6 @@ "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", - "dev": true, "dependencies": { "to-regex-range": "^5.0.1" }, @@ -6056,7 +6191,6 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dev": true, "dependencies": { "is-glob": "^4.0.1" }, @@ -7026,7 +7160,6 @@ "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true, "engines": { "node": ">=0.12.0" } @@ -10031,7 +10164,6 @@ "version": "4.0.4", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz", "integrity": "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==", - "dev": true, "dependencies": { "braces": "^3.0.1", "picomatch": "^2.2.3" @@ -10745,7 +10877,6 @@ "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", - "dev": true, "engines": { "node": ">=8.6" }, @@ -11000,7 +11131,6 @@ "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", - "dev": true, "funding": [ { "type": "github", @@ -11275,7 +11405,6 @@ "version": "1.0.4", "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", - "dev": true, "engines": { "iojs": ">=1.0.0", "node": ">=0.10.0" @@ -11320,7 +11449,6 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", - "dev": true, "funding": [ { "type": "github", @@ -12521,7 +12649,6 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "dev": true, "dependencies": { "is-number": "^7.0.0" }, @@ -13685,6 +13812,110 @@ "@jridgewell/trace-mapping": "^0.3.0" } }, + "@athenna/ioc": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@athenna/ioc/-/ioc-1.0.9.tgz", + "integrity": "sha512-IqU04R7oZFGeHQRjI6d1hK1P0VYF6FYaKLQP0BAQL407q+Wh5AkDEqIxQDyInIOoqIyWjpRet0WpRWjUyrQ1tw==", + "requires": { + "@secjs/utils": "1.7.8", + "awilix": "7.0.0", + "reflect-metadata": "0.1.13", + "tscpaths": "0.0.9" + }, + "dependencies": { + "@secjs/utils": { + "version": "1.7.8", + "resolved": "https://registry.npmjs.org/@secjs/utils/-/utils-1.7.8.tgz", + "integrity": "sha512-DrcuJhcF2kdUJWoilniCFxbNWVbJJiTI/1NP779kvOSBD8g402tBzqgIjZdrL+tItjcEXMEUFURvmmZeI1l9VQ==", + "requires": { + "bytes": "3.1.2", + "chalk": "4.1.2", + "change-case": "4.1.2", + "http-status-codes": "2.2.0", + "kind-of": "6.0.3", + "lodash": "4.17.21", + "mime-types": "2.1.34", + "ms": "2.1.3", + "pluralize": "8.0.0", + "uuid": "8.3.2", + "validator-brazil": "1.2.2" + } + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "requires": { + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" + }, + "mime-db": { + "version": "1.51.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz", + "integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==" + }, + "mime-types": { + "version": "2.1.34", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.34.tgz", + "integrity": "sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==", + "requires": { + "mime-db": "1.51.0" + } + }, + "ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "@athenna/logger": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@athenna/logger/-/logger-1.0.9.tgz", + "integrity": "sha512-qJa0VSeKWjLrZ9i0roa3MC2abem8whYA0i2XPHbUZ0WP7mvwCRT2EJZZex1Jv4nB+wLZy4M6f5bFmwOwztksXQ==", + "requires": { + "@athenna/ioc": "1.0.9", + "@secjs/utils": "1.8.0", + "chalk": "4.1.1", + "reflect-metadata": "0.1.13", + "tscpaths": "0.0.9" + } + }, "@babel/code-frame": { "version": "7.12.11", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.11.tgz", @@ -14925,7 +15156,6 @@ "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", - "dev": true, "requires": { "@nodelib/fs.stat": "2.0.5", "run-parallel": "^1.1.9" @@ -14934,14 +15164,12 @@ "@nodelib/fs.stat": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", - "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", - "dev": true + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==" }, "@nodelib/fs.walk": { "version": "1.2.8", "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", - "dev": true, "requires": { "@nodelib/fs.scandir": "2.1.5", "fastq": "^1.6.0" @@ -15786,6 +16014,15 @@ "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==" }, + "awilix": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/awilix/-/awilix-7.0.0.tgz", + "integrity": "sha512-Ye4SLwqVfrsHSRRT6OmxvJjmnKryWzvEUdKEgnq/wODkYsV1Yo+L2k0aHEj5WhPyDym17hCRBxJn5whXWhU2Tw==", + "requires": { + "camel-case": "^4.1.2", + "fast-glob": "^3.2.11" + } + }, "babel-jest": { "version": "27.5.1", "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-27.5.1.tgz", @@ -15965,7 +16202,6 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", - "dev": true, "requires": { "fill-range": "^7.0.1" } @@ -18000,7 +18236,6 @@ "version": "3.2.11", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.11.tgz", "integrity": "sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew==", - "dev": true, "requires": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", @@ -18025,7 +18260,6 @@ "version": "1.13.0", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz", "integrity": "sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw==", - "dev": true, "requires": { "reusify": "^1.0.4" } @@ -18074,7 +18308,6 @@ "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", - "dev": true, "requires": { "to-regex-range": "^5.0.1" } @@ -18273,7 +18506,6 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dev": true, "requires": { "is-glob": "^4.0.1" } @@ -18980,8 +19212,7 @@ "is-number": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==" }, "is-number-object": { "version": "1.0.6", @@ -21227,7 +21458,6 @@ "version": "4.0.4", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz", "integrity": "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==", - "dev": true, "requires": { "braces": "^3.0.1", "picomatch": "^2.2.3" @@ -21793,8 +22023,7 @@ "picomatch": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", - "dev": true + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==" }, "pify": { "version": "3.0.0", @@ -21977,8 +22206,7 @@ "queue-microtask": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", - "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", - "dev": true + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==" }, "randombytes": { "version": "2.1.0", @@ -22175,8 +22403,7 @@ "reusify": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", - "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", - "dev": true + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==" }, "rimraf": { "version": "3.0.2", @@ -22202,7 +22429,6 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", - "dev": true, "requires": { "queue-microtask": "^1.2.2" } @@ -23124,7 +23350,6 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "dev": true, "requires": { "is-number": "^7.0.0" } diff --git a/package.json b/package.json index 1885cc2..cebc6a5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@athenna/cli", - "version": "1.0.1", + "version": "1.0.2", "description": "", "license": "MIT", "author": "Victor Tesoura Júnior ", @@ -150,6 +150,10 @@ } }, "files": [ + "config/*.js", + "config/*.d.ts", + "config/**/*.js", + "config/**/*.d.ts", "templates/*.js", "templates/*.d.ts", "templates/**/*.js", @@ -167,6 +171,7 @@ } }, "dependencies": { + "@athenna/logger": "1.0.9", "@secjs/utils": "1.8.0", "chalk": "4.1.1", "chalk-rainbow": "1.0.0", diff --git a/src/Cli.ts b/src/Cli.ts index 6188901..e2b5d9f 100644 --- a/src/Cli.ts +++ b/src/Cli.ts @@ -45,6 +45,7 @@ export class Cli { .option('-t, --type ', 'Current types available: http', 'http') .description('Scaffold a new Athenna project') .action(newCommand.project.bind(newCommand)) + .showHelpAfterError() .createHelp() this.program @@ -59,6 +60,7 @@ export class Cli { 'Make a new controller file inside app/Http/Controllers directory', ) .action(makeCommand.controller.bind(makeCommand)) + .showHelpAfterError() .createHelp() await this.program.parseAsync(process.argv) diff --git a/src/Commands/Make.ts b/src/Commands/Make.ts index 7616085..2f5cc69 100644 --- a/src/Commands/Make.ts +++ b/src/Commands/Make.ts @@ -8,24 +8,28 @@ */ import ejs from 'ejs' -import { Logger } from '../Utils/Logger' -import { File, Folder, Path, String } from '@secjs/utils' -import { CtxLogger } from '../Utils/CtxLogger' -import { existsSync } from 'fs' +import chalk from 'chalk' + import { parse } from 'path' +import { existsSync } from 'fs' +import { Logger } from '@athenna/logger' +import { File, Folder, Path, String } from '@secjs/utils' export class Make { + private readonly logger: Logger private readonly clientFolder: string private readonly templatesFolder: Folder public constructor(clientFolder: string) { this.clientFolder = clientFolder + this.logger = new Logger() + this.templatesFolder = new Folder(Path.pwd('templates')).loadSync() } async controller(name: string, options: any): Promise { - new Logger().success.bold.log('[ MAKING CONTROLLER ]\n') + console.log(chalk.bold.green('[ MAKING CONTROLLER ]\n')) if (name.includes('Controller') || name.includes('Controllers')) { name = name.split('Controller')[0] @@ -34,7 +38,7 @@ export class Make { const template = this.getTemplate('__name__Controller', options) if (!template) { - CtxLogger.error( + this.logger.error( `Template for extension ({yellow} "${options.extension}") has not been found.`, ) @@ -47,7 +51,7 @@ export class Make { const content = this.normalizeTemplate(name, template.getContentSync()) if (existsSync(path)) { - CtxLogger.error( + this.logger.error( `The controller ({yellow} "${ parse(path).name }") already exists. Try using another name.`, @@ -58,7 +62,7 @@ export class Make { const controller = await new File(path, content).create() - CtxLogger.success( + this.logger.success( `Controller ({yellow} "${controller.name}") successfully created.`, ) } diff --git a/src/Commands/New.ts b/src/Commands/New.ts index bdd8265..d43104a 100644 --- a/src/Commands/New.ts +++ b/src/Commands/New.ts @@ -9,24 +9,27 @@ import ora from 'ora' import chalk from 'chalk' -import { sep } from 'path' import Table from 'cli-table' + +import { sep } from 'path' import { existsSync } from 'fs' import { promisify } from 'util' -import { Logger } from '../Utils/Logger' +import { Logger } from '@athenna/logger' import { Folder, Path } from '@secjs/utils' -import { CtxLogger } from '../Utils/CtxLogger' import { NodeExecException } from '../Exceptions/NodeExecException' const exec = promisify(require('child_process').exec) export class New { + private readonly logger: Logger private readonly clientFolder: string private readonly repositoryUrl: string public constructor(clientFolder: string) { this.clientFolder = clientFolder + this.logger = new Logger() + this.repositoryUrl = 'https://github.com/AthennaIO/Scaffold.git' } @@ -35,7 +38,7 @@ export class New { await new Folder(Path.storage()).create() if (!this[options.type]) { - CtxLogger.error( + this.logger.error( `The project type ({yellow} "${options.type}") doesnt exist. Try running ({yellow} "athenna new:project --help") to se the available project types.`, ) @@ -46,13 +49,13 @@ export class New { } async http(projectName: string) { - new Logger().success.bold.log('[ GENERATING HTTP SERVER ]\n') + console.log(chalk.bold.green('[ GENERATING HTTP SERVER ]\n')) const projectPath = Path.storage(`project/${projectName}`) const concretePath = `${this.clientFolder}${sep}${projectName}` if (existsSync(concretePath)) { - CtxLogger.error( + this.logger.error( `The directory ({yellow} "${projectName}") already exists. Try another project name.`, ) @@ -78,7 +81,10 @@ export class New { await this.runCommand(runNpmInstallCommand, 'Installing dependencies') await this.runCommand(moveProjectCommand, 'Moving project to your path') - CtxLogger.success(`Project created at ({yellow} "${projectName}") folder.`) + console.log('\n') + this.logger.success( + `Project created at ({yellow} "${projectName}") folder.`, + ) const table = new Table() diff --git a/src/Utils/CtxLogger.ts b/src/Utils/CtxLogger.ts deleted file mode 100644 index 6674c2d..0000000 --- a/src/Utils/CtxLogger.ts +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @athenna/cli - * - * (c) João Lenon - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -import chalk from 'chalk' -import { Logger } from './Logger' - -export class CtxLogger { - private static logger = new Logger() - - static info(message: string): void { - const ctx = chalk.bold.cyan('[ info ]') - - this.logger.log(`${ctx} ${message}`) - } - - static warn(message: string): void { - const ctx = chalk.bold.yellow('[ warn ]') - - this.logger.log(`${ctx} ${message}`) - } - - static error(message: string): void { - const ctx = chalk.bold.red('[ error ]') - - this.logger.log(`${ctx} ${message}`) - } - - static debug(message: string): void { - const ctx = chalk.bold.magenta('[ debug ]') - - this.logger.log(`${ctx} ${message}`) - } - - static success(message: string): void { - const ctx = chalk.bold.green('\n[ success ]') - - this.logger.log(`${ctx} ${message}`) - } -} diff --git a/src/Utils/Logger.ts b/src/Utils/Logger.ts deleted file mode 100644 index d244e45..0000000 --- a/src/Utils/Logger.ts +++ /dev/null @@ -1,83 +0,0 @@ -/** - * @secjs/cli - * - * (c) João Lenon - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -import chalk from 'chalk' -import { Is } from '@secjs/utils' - -export class Logger { - private chalk: any - - public constructor() { - this.chalk = chalk - } - - get bold(): this { - this.chalk = this.chalk.bold - - return this - } - - get info(): this { - this.chalk = this.chalk.cyan - - return this - } - - get debug(): this { - this.chalk = this.chalk.magenta - - return this - } - - get warn(): this { - this.chalk = this.chalk.yellow - - return this - } - - get error(): this { - this.chalk = this.chalk.red - - return this - } - - get success(): this { - this.chalk = this.chalk.green - - return this - } - - log(content: any) { - if (Is.String(content)) { - const matches = content.match(/\({(.*?)} (.*?)\)/) - - if (matches) { - const chalkMethodsString = matches[1].replace(/\s/g, '') - const chalkMethodsArray = chalkMethodsString.split(',') - const message = matches[2] - - let chalk = this.chalk - - chalkMethodsArray.forEach(chalkMethod => { - if (!chalk[chalkMethod]) return - - chalk = chalk[chalkMethod] - }) - - content = content - .replace(`({${matches[1]}} `, '') - .replace(`({${matches[1]}}`, '') - .replace(`${matches[2]})`, chalk(message)) - } - } - - console.log(this.chalk(content)) - this.chalk = chalk - } -} From ce2fd6cdba52cdddee5232f5f47e5840aef02b25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Lenon?= Date: Wed, 6 Apr 2022 10:30:07 -0300 Subject: [PATCH 08/19] feat: update @athenna/logger and tests --- config/logging.ts | 3 +++ package-lock.json | 14 +++++++------- package.json | 2 +- tests/Unit/Commands/MakeTest.ts | 24 ++++++++++++++++++++++++ tests/Unit/Commands/NewTest.ts | 2 +- 5 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 tests/Unit/Commands/MakeTest.ts diff --git a/config/logging.ts b/config/logging.ts index a3b3e51..f912f9a 100644 --- a/config/logging.ts +++ b/config/logging.ts @@ -1,3 +1,5 @@ +import { Color } from '@athenna/logger' + export default { /* |-------------------------------------------------------------------------- @@ -31,6 +33,7 @@ export default { streamType: 'stdout', formatterConfig: { level: 'INFO', + chalk: Color.cyan, }, }, }, diff --git a/package-lock.json b/package-lock.json index 4934e2c..24cbcde 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.2", "license": "MIT", "dependencies": { - "@athenna/logger": "1.0.9", + "@athenna/logger": "1.1.1", "@secjs/utils": "1.8.0", "chalk": "4.1.1", "chalk-rainbow": "1.0.0", @@ -188,9 +188,9 @@ } }, "node_modules/@athenna/logger": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/@athenna/logger/-/logger-1.0.9.tgz", - "integrity": "sha512-qJa0VSeKWjLrZ9i0roa3MC2abem8whYA0i2XPHbUZ0WP7mvwCRT2EJZZex1Jv4nB+wLZy4M6f5bFmwOwztksXQ==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@athenna/logger/-/logger-1.1.1.tgz", + "integrity": "sha512-cHv846NbsYVPeIhEXUsiGch48sfVLtMNXbK2eFVl7JV32TYP56jGexJgFzOmMVnl/dAeuV/HBGSgP7Ta3z5YFA==", "dependencies": { "@athenna/ioc": "1.0.9", "@secjs/utils": "1.8.0", @@ -13905,9 +13905,9 @@ } }, "@athenna/logger": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/@athenna/logger/-/logger-1.0.9.tgz", - "integrity": "sha512-qJa0VSeKWjLrZ9i0roa3MC2abem8whYA0i2XPHbUZ0WP7mvwCRT2EJZZex1Jv4nB+wLZy4M6f5bFmwOwztksXQ==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@athenna/logger/-/logger-1.1.1.tgz", + "integrity": "sha512-cHv846NbsYVPeIhEXUsiGch48sfVLtMNXbK2eFVl7JV32TYP56jGexJgFzOmMVnl/dAeuV/HBGSgP7Ta3z5YFA==", "requires": { "@athenna/ioc": "1.0.9", "@secjs/utils": "1.8.0", diff --git a/package.json b/package.json index cebc6a5..fffa5dc 100644 --- a/package.json +++ b/package.json @@ -171,7 +171,7 @@ } }, "dependencies": { - "@athenna/logger": "1.0.9", + "@athenna/logger": "1.1.1", "@secjs/utils": "1.8.0", "chalk": "4.1.1", "chalk-rainbow": "1.0.0", diff --git a/tests/Unit/Commands/MakeTest.ts b/tests/Unit/Commands/MakeTest.ts new file mode 100644 index 0000000..9bb3194 --- /dev/null +++ b/tests/Unit/Commands/MakeTest.ts @@ -0,0 +1,24 @@ +/** + * @athenna/cli + * + * (c) Victor Tesoura Júnior + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +import { existsSync } from 'fs' +import { Folder, Path } from '@secjs/utils' +import { Make } from '../../../src/Commands/Make' + +describe('\n MakeTest', () => { + it('should be able to create a new http project', async () => { + await new Make(Path.storage()).controller('TestControllers', { extension: 'ts' }) + + expect(existsSync(Path.storage('app/Http/Controllers/TestController.ts'))).toBeTruthy() + }, 60000) + + afterEach(async () => { + await Folder.safeRemove('storage/app') + }) +}) diff --git a/tests/Unit/Commands/NewTest.ts b/tests/Unit/Commands/NewTest.ts index 6bb0d03..4d6a800 100644 --- a/tests/Unit/Commands/NewTest.ts +++ b/tests/Unit/Commands/NewTest.ts @@ -13,7 +13,7 @@ import { New } from '../../../src/Commands/New' describe('\n NewTest', () => { it('should be able to create a new http project', async () => { - await new New().project('test', { type: 'http' }) + await new New(Path.pwd()).project('test', { type: 'http' }) expect(existsSync(Path.pwd('test/.env'))).toBeTruthy() expect(existsSync(Path.pwd('test/app'))).toBeTruthy() From a3e54f02e383178f4a02ba519187cc1b647017de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Lenon?= Date: Wed, 6 Apr 2022 12:41:26 -0300 Subject: [PATCH 09/19] feat: add middleware command and lint option --- package.json | 4 +- src/Cli.ts | 17 +++++++ src/Commands/Make.ts | 73 +++++++++++++++++++++++++++-- src/Commands/New.ts | 34 ++------------ src/Utils/runCommand.ts | 35 ++++++++++++++ templates/__name__Middleware.js.ejs | 43 +++++++++++++++++ templates/__name__Middleware.ts.ejs | 50 ++++++++++++++++++++ tests/Unit/Commands/MakeTest.ts | 8 +++- 8 files changed, 228 insertions(+), 36 deletions(-) create mode 100644 src/Utils/runCommand.ts create mode 100644 templates/__name__Middleware.js.ejs create mode 100644 templates/__name__Middleware.ts.ejs diff --git a/package.json b/package.json index fffa5dc..6ce9639 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ "build": "tsc --project tsconfig.json && tscpaths -p tsconfig.json -s . -o .", "test": "npm run lint:fix && cross-env NODE_TS=true cross-env NODE_ENV=testing jest --verbose", "test:debug": "npm run lint:fix && cross-env NODE_TS=true cross-env NODE_ENV=testing cross-env DEBUG=api:* jest --verbose", - "lint:fix": "eslint \"{src,tests}/**/*.ts\" --fix" + "eslint": "eslint", + "lint:fix": "npm run eslint \"{src,tests}/**/!(*.d)*.ts\" --fix" }, "keywords": [ "nodejs", @@ -133,6 +134,7 @@ "dot-notation": "off", "camelcase": "off", "no-undef": "off", + "@typescript-eslint/no-empty-function": "off", "@typescript-eslint/no-var-requires": "off", "no-useless-constructor": "off", "@typescript-eslint/no-useless-constructor": "off", diff --git a/src/Cli.ts b/src/Cli.ts index e2b5d9f..b6e6984 100644 --- a/src/Cli.ts +++ b/src/Cli.ts @@ -56,6 +56,7 @@ export class Cli { 'Current extension available: ts, js', 'ts', ) + .option('--no-lint', 'Do not run eslint in the controller') .description( 'Make a new controller file inside app/Http/Controllers directory', ) @@ -63,6 +64,22 @@ export class Cli { .showHelpAfterError() .createHelp() + this.program + .command('make:middleware') + .argument('', 'Your middleware name') + .option( + '-e, --extension ', + 'Current extension available: ts, js', + 'ts', + ) + .option('--no-lint', 'Do not run eslint in the middleware', false) + .description( + 'Make a new middleware file inside app/Http/Middlewares directory', + ) + .action(makeCommand.middleware.bind(makeCommand)) + .showHelpAfterError() + .createHelp() + await this.program.parseAsync(process.argv) } } diff --git a/src/Commands/Make.ts b/src/Commands/Make.ts index 2f5cc69..da7928d 100644 --- a/src/Commands/Make.ts +++ b/src/Commands/Make.ts @@ -13,6 +13,7 @@ import chalk from 'chalk' import { parse } from 'path' import { existsSync } from 'fs' import { Logger } from '@athenna/logger' +import { runCommand } from '../Utils/runCommand' import { File, Folder, Path, String } from '@secjs/utils' export class Make { @@ -47,7 +48,8 @@ export class Make { // TODO Resolve the path always looking to his project root // TODO Maybe find for the package.json file in getConcretePath - const path = this.getConcretePath(name, template.base) + const normalizedName = this.normalizeName(name, template.base) + const path = this.getConcretePath(`app/Http/Controllers/${normalizedName}`) const content = this.normalizeTemplate(name, template.getContentSync()) if (existsSync(path)) { @@ -65,6 +67,69 @@ export class Make { this.logger.success( `Controller ({yellow} "${controller.name}") successfully created.`, ) + + if (options.lint) { + await this.runEslintOnFile('Controller', controller.path) + } + } + + async middleware(name: string, options: any): Promise { + console.log(chalk.bold.green('[ MAKING MIDDLEWARE ]\n')) + + if (name.includes('Middleware') || name.includes('Middlewares')) { + name = name.split('Middleware')[0] + } + + const template = this.getTemplate('__name__Middleware', options) + + if (!template) { + this.logger.error( + `Template for extension ({yellow} "${options.extension}") has not been found.`, + ) + + return + } + + // TODO Resolve the path always looking to his project root + // TODO Maybe find for the package.json file in getConcretePath + const normalizedName = this.normalizeName(name, template.base) + const path = this.getConcretePath(`app/Http/Middlewares/${normalizedName}`) + const content = this.normalizeTemplate(name, template.getContentSync()) + + if (existsSync(path)) { + this.logger.error( + `The middleware ({yellow} "${ + parse(path).name + }") already exists. Try using another name.`, + ) + + return + } + + const middleware = await new File(path, content).create() + + this.logger.success( + `Middleware ({yellow} "${middleware.name}") successfully created.`, + ) + + if (options.lint) { + await this.runEslintOnFile('Middleware', middleware.path) + } + } + + private async runEslintOnFile(resource: string, filePath: string) { + const { name } = parse(filePath) + + try { + await runCommand(`npm run eslint ${filePath} -- --fix --quiet`) + this.logger.success( + `${resource} ({yellow} "${name}") successfully linted.`, + ) + } catch (error) { + this.logger.error( + `Failed to lint ${resource} ({yellow} "${name}"). Please check your eslint configurations.`, + ) + } } private getTemplate(templateName: string, options: any): File { @@ -73,10 +138,8 @@ export class Make { return this.templatesFolder.files.find(f => f.base === templateName) as File } - private getConcretePath(name: string, baseTemplateName: string) { - const normalizedName = this.normalizeName(name, baseTemplateName) - - return `${this.clientFolder}/app/Http/Controllers/${normalizedName}` + private getConcretePath(normalizedPath: string) { + return `${this.clientFolder}/${normalizedPath}` } private normalizeName(name: string, baseTemplateName: string): string { diff --git a/src/Commands/New.ts b/src/Commands/New.ts index d43104a..4f2460e 100644 --- a/src/Commands/New.ts +++ b/src/Commands/New.ts @@ -7,18 +7,14 @@ * file that was distributed with this source code. */ -import ora from 'ora' import chalk from 'chalk' import Table from 'cli-table' import { sep } from 'path' import { existsSync } from 'fs' -import { promisify } from 'util' import { Logger } from '@athenna/logger' import { Folder, Path } from '@secjs/utils' -import { NodeExecException } from '../Exceptions/NodeExecException' - -const exec = promisify(require('child_process').exec) +import { runCommand } from '../Utils/runCommand' export class New { private readonly logger: Logger @@ -68,18 +64,18 @@ export class New { const rmGitAndCopyEnv = `${cdCommand} && rm -rf .git && rm -rf .github && cp .env.example .env` const moveProjectCommand = `mv ${projectPath} ${concretePath}` - await this.runCommand( + await runCommand( cloneCommand, `Cloning scaffold project from ${this.repositoryUrl}`, ) - await this.runCommand( + await runCommand( rmGitAndCopyEnv, 'Removing defaults and creating .env file from .env.example', ) - await this.runCommand(runNpmInstallCommand, 'Installing dependencies') - await this.runCommand(moveProjectCommand, 'Moving project to your path') + await runCommand(runNpmInstallCommand, 'Installing dependencies') + await runCommand(moveProjectCommand, 'Moving project to your path') console.log('\n') this.logger.success( @@ -99,24 +95,4 @@ export class New { console.log(`\n${table.toString()}`) } - - private async runCommand(command: string, log?: string) { - const spinner = ora(log) - - if (log) { - spinner.color = 'yellow' - - spinner.start() - } - - try { - await exec(command) - - spinner.succeed(log) - } catch (err) { - spinner.fail(log) - - throw new NodeExecException(command) - } - } } diff --git a/src/Utils/runCommand.ts b/src/Utils/runCommand.ts new file mode 100644 index 0000000..ed3a0f3 --- /dev/null +++ b/src/Utils/runCommand.ts @@ -0,0 +1,35 @@ +/** + * @athenna/cli + * + * (c) Victor Tesoura Júnior + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +import ora from 'ora' +import { promisify } from 'util' +import { NodeExecException } from '../Exceptions/NodeExecException' + +const exec = promisify(require('child_process').exec) + +export async function runCommand(command: string, log?: string) { + const spinner = ora(log) + + if (log) { + spinner.color = 'yellow' + + spinner.start() + } + + try { + await exec(command) + + if (log) spinner.succeed(log) + } catch (err) { + // console.log(err) + if (log) spinner.fail(log) + + throw new NodeExecException(command) + } +} diff --git a/templates/__name__Middleware.js.ejs b/templates/__name__Middleware.js.ejs new file mode 100644 index 0000000..6561bff --- /dev/null +++ b/templates/__name__Middleware.js.ejs @@ -0,0 +1,43 @@ +import { MiddlewareContract } from '@athenna/http' + +export class <%= namePascal %>Middleware implements MiddlewareContract { + /** + * Use the constructor to resolve any dependency of the Ioc container + * + * @param container + * @return <%= namePascal %>Middleware + */ + constructor(_container) {} + + /** + * Handle method is executed before the request gets in your controller. + * + * @param ctx + * @return any + */ + async handle({ next }) { + next() + } + + /** + * Intercept method is executed before the response has been sent. + * + * @param ctx + * @return any + */ + async intercept({ body }) { + body.intercepted = true + + return body + } + + /** + * Terminate method is executed after the response has been sent. + * + * @param ctx + * @return any + */ + async terminate({ next }) { + next() + } +} diff --git a/templates/__name__Middleware.ts.ejs b/templates/__name__Middleware.ts.ejs new file mode 100644 index 0000000..3c0fea5 --- /dev/null +++ b/templates/__name__Middleware.ts.ejs @@ -0,0 +1,50 @@ +import { + HandleContextContract, + InterceptContextContract, + TerminateContextContract, + MiddlewareContract, +} from '@athenna/http' + +import { Container } from 'providers/Container' + +export class <%= namePascal %>Middleware implements MiddlewareContract { + /** + * Use the constructor to resolve any dependency of the Ioc container + * + * @param container + * @return <%= namePascal %>Middleware + */ + constructor(_container: Container) {} + + /** + * Handle method is executed before the request gets in your controller. + * + * @param ctx + * @return any + */ + async handle({ next }: HandleContextContract) { + next() + } + + /** + * Intercept method is executed before the response has been sent. + * + * @param ctx + * @return any + */ + async intercept({ body }: InterceptContextContract) { + body.intercepted = true + + return body + } + + /** + * Terminate method is executed after the response has been sent. + * + * @param ctx + * @return any + */ + async terminate({ next }: TerminateContextContract) { + next() + } +} diff --git a/tests/Unit/Commands/MakeTest.ts b/tests/Unit/Commands/MakeTest.ts index 9bb3194..864d39e 100644 --- a/tests/Unit/Commands/MakeTest.ts +++ b/tests/Unit/Commands/MakeTest.ts @@ -12,12 +12,18 @@ import { Folder, Path } from '@secjs/utils' import { Make } from '../../../src/Commands/Make' describe('\n MakeTest', () => { - it('should be able to create a new http project', async () => { + it('should be able to create a controller file', async () => { await new Make(Path.storage()).controller('TestControllers', { extension: 'ts' }) expect(existsSync(Path.storage('app/Http/Controllers/TestController.ts'))).toBeTruthy() }, 60000) + it('should be able to create a middleware file', async () => { + await new Make(Path.storage()).middleware('TestMiddlewares', { extension: 'ts' }) + + expect(existsSync(Path.storage('app/Http/Middlewares/TestMiddleware.ts'))).toBeTruthy() + }, 60000) + afterEach(async () => { await Folder.safeRemove('storage/app') }) From 36af839838fbf938c99d9d6850dba11a077e5cca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Lenon?= Date: Wed, 6 Apr 2022 13:22:08 -0300 Subject: [PATCH 10/19] feat: add service and provider ejs templates --- src/Cli.ts | 3 ++- src/Commands/Make.ts | 1 + templates/__name__Controller.ts.ejs | 2 +- templates/__name__Middleware.ts.ejs | 2 +- templates/__name__Provider.js.ejs | 32 +++++++++++++++++++++++++++++ templates/__name__Provider.ts.ejs | 32 +++++++++++++++++++++++++++++ templates/__name__Service.js.ejs | 9 ++++++++ templates/__name__Service.ts.ejs | 11 ++++++++++ 8 files changed, 89 insertions(+), 3 deletions(-) create mode 100644 templates/__name__Provider.js.ejs create mode 100644 templates/__name__Provider.ts.ejs create mode 100644 templates/__name__Service.js.ejs create mode 100644 templates/__name__Service.ts.ejs diff --git a/src/Cli.ts b/src/Cli.ts index b6e6984..4cf7427 100644 --- a/src/Cli.ts +++ b/src/Cli.ts @@ -8,11 +8,12 @@ */ import figlet from 'figlet' +import chalkRainbow from 'chalk-rainbow' + import { resolve } from 'path' import { Command } from 'commander' import { New } from './Commands/New' import { Make } from './Commands/Make' -import chalkRainbow from 'chalk-rainbow' import { version } from '../package.json' export class Cli { diff --git a/src/Commands/Make.ts b/src/Commands/Make.ts index da7928d..be285bd 100644 --- a/src/Commands/Make.ts +++ b/src/Commands/Make.ts @@ -73,6 +73,7 @@ export class Make { } } + // TODO Add middleware to namedMiddlewares object of HttpKernel async middleware(name: string, options: any): Promise { console.log(chalk.bold.green('[ MAKING MIDDLEWARE ]\n')) diff --git a/templates/__name__Controller.ts.ejs b/templates/__name__Controller.ts.ejs index e1ae357..d13ddb6 100644 --- a/templates/__name__Controller.ts.ejs +++ b/templates/__name__Controller.ts.ejs @@ -8,7 +8,7 @@ export class <%= namePascal %>Controller { * @param container * @return <%= namePascal %>Controller */ - constructor(_container: Container) {} + public constructor(_container: Container) {} /** * Index method diff --git a/templates/__name__Middleware.ts.ejs b/templates/__name__Middleware.ts.ejs index 3c0fea5..e1952ae 100644 --- a/templates/__name__Middleware.ts.ejs +++ b/templates/__name__Middleware.ts.ejs @@ -14,7 +14,7 @@ export class <%= namePascal %>Middleware implements MiddlewareContract { * @param container * @return <%= namePascal %>Middleware */ - constructor(_container: Container) {} + public constructor(_container: Container) {} /** * Handle method is executed before the request gets in your controller. diff --git a/templates/__name__Provider.js.ejs b/templates/__name__Provider.js.ejs new file mode 100644 index 0000000..05f29aa --- /dev/null +++ b/templates/__name__Provider.js.ejs @@ -0,0 +1,32 @@ +import { ServiceProvider } from '@athenna/ioc' + +export class <%= namePascal %>Provider extends ServiceProvider { + /** + * All the container bindings that should be registered. + */ + bindings = {} + + /** + * All the container instances that should be registered. + */ + instances = {} + + /** + * All the container singletons that should be registered. + */ + singletons = {} + + /** + * Register any application services. + * + * @return void + */ + register() {} + + /** + * Bootstrap any application services. + * + * @return void + */ + boot() {} +} diff --git a/templates/__name__Provider.ts.ejs b/templates/__name__Provider.ts.ejs new file mode 100644 index 0000000..039068a --- /dev/null +++ b/templates/__name__Provider.ts.ejs @@ -0,0 +1,32 @@ +import { ServiceProvider } from '@athenna/ioc' + +export class <%= namePascal %>Provider extends ServiceProvider { + /** + * All the container bindings that should be registered. + */ + public bindings = {} + + /** + * All the container instances that should be registered. + */ + public instances = {} + + /** + * All the container singletons that should be registered. + */ + public singletons = {} + + /** + * Register any application services. + * + * @return void + */ + public register() {} + + /** + * Bootstrap any application services. + * + * @return void + */ + public boot() {} +} diff --git a/templates/__name__Service.js.ejs b/templates/__name__Service.js.ejs new file mode 100644 index 0000000..b01f3ed --- /dev/null +++ b/templates/__name__Service.js.ejs @@ -0,0 +1,9 @@ +export class <%= namePascal %>Service { + /** + * Use the constructor to resolve any dependency of the Ioc container + * + * @param _container + * @return <%= namePascal %>Service + */ + constructor(_container) {} +} diff --git a/templates/__name__Service.ts.ejs b/templates/__name__Service.ts.ejs new file mode 100644 index 0000000..e3db122 --- /dev/null +++ b/templates/__name__Service.ts.ejs @@ -0,0 +1,11 @@ +import { Container } from 'providers/Container' + +export class <%= namePascal %>Service { + /** + * Use the constructor to resolve any dependency of the Ioc container + * + * @param _container + * @return <%= namePascal %>Service + */ + public constructor(_container: Container) {} +} From 54f267e2746861bb5d7d9a46681d8af14e4b304a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Lenon?= Date: Wed, 6 Apr 2022 16:29:56 -0300 Subject: [PATCH 11/19] fix: remove implements from js middleware template --- templates/__name__Middleware.js.ejs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/templates/__name__Middleware.js.ejs b/templates/__name__Middleware.js.ejs index 6561bff..581a1e7 100644 --- a/templates/__name__Middleware.js.ejs +++ b/templates/__name__Middleware.js.ejs @@ -1,6 +1,4 @@ -import { MiddlewareContract } from '@athenna/http' - -export class <%= namePascal %>Middleware implements MiddlewareContract { +export class <%= namePascal %>Middleware { /** * Use the constructor to resolve any dependency of the Ioc container * From fc309bf4a5423d7f588fcd93c00d17dd1cb9c662 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Lenon?= Date: Thu, 7 Apr 2022 08:56:07 -0300 Subject: [PATCH 12/19] feat: clone scaffold from http branch --- src/Cli.ts | 4 +- src/Commands/New.ts | 4 +- templates/__name__Controller.js.ejs | 62 ----------------------------- templates/__name__Middleware.js.ejs | 41 ------------------- templates/__name__Provider.js.ejs | 32 --------------- templates/__name__Service.js.ejs | 9 ----- 6 files changed, 4 insertions(+), 148 deletions(-) delete mode 100644 templates/__name__Controller.js.ejs delete mode 100644 templates/__name__Middleware.js.ejs delete mode 100644 templates/__name__Provider.js.ejs delete mode 100644 templates/__name__Service.js.ejs diff --git a/src/Cli.ts b/src/Cli.ts index 4cf7427..4c4c2b7 100644 --- a/src/Cli.ts +++ b/src/Cli.ts @@ -54,7 +54,7 @@ export class Cli { .argument('', 'Your controller name') .option( '-e, --extension ', - 'Current extension available: ts, js', + 'Current extension available: ts', 'ts', ) .option('--no-lint', 'Do not run eslint in the controller') @@ -70,7 +70,7 @@ export class Cli { .argument('', 'Your middleware name') .option( '-e, --extension ', - 'Current extension available: ts, js', + 'Current extension available: ts', 'ts', ) .option('--no-lint', 'Do not run eslint in the middleware', false) diff --git a/src/Commands/New.ts b/src/Commands/New.ts index 4f2460e..e79a59b 100644 --- a/src/Commands/New.ts +++ b/src/Commands/New.ts @@ -59,14 +59,14 @@ export class New { } const cdCommand = `cd ${projectPath}` - const cloneCommand = `git clone ${this.repositoryUrl} ${projectPath}` + const cloneCommand = `git clone --branch http ${this.repositoryUrl} ${projectPath}` const runNpmInstallCommand = `${cdCommand} && npm install --silent` const rmGitAndCopyEnv = `${cdCommand} && rm -rf .git && rm -rf .github && cp .env.example .env` const moveProjectCommand = `mv ${projectPath} ${concretePath}` await runCommand( cloneCommand, - `Cloning scaffold project from ${this.repositoryUrl}`, + `Cloning scaffold project from ${this.repositoryUrl} in branch http`, ) await runCommand( diff --git a/templates/__name__Controller.js.ejs b/templates/__name__Controller.js.ejs deleted file mode 100644 index f1e72f8..0000000 --- a/templates/__name__Controller.js.ejs +++ /dev/null @@ -1,62 +0,0 @@ -import { ContextContract } from '@athenna/http' -import { Container } from 'providers/Container' - -export class <%= namePascal %>Controller { - /** - * Use the constructor to resolve any dependency of the Ioc container - * - * @param container - * @return <%= namePascal %>Controller - */ - constructor(_container) {} - - /** - * Index method - * - * @param ctx: ContextContract - * @return any[] - */ - async index({ response }) { - return response.status(200).send([{}]) - } - - /** - * Store method - * - * @param ctx: ContextContract - * @return any - */ - async store({ response }) { - return response.status(201).send({}) - } - - /** - * Show method - * - * @param ctx: ContextContract - * @return any - */ - async show({ response }) { - return response.status(200).send({}) - } - - /** - * Update method - * - * @param ctx: ContextContract - * @return any - */ - async update({ response, params }) { - return response.status(200).send({ id: params.id }) - } - - /** - * Delete method - * - * @param ctx: ContextContract - * @return void - */ - async delete({ response }) { - return response.status(204) - } -} diff --git a/templates/__name__Middleware.js.ejs b/templates/__name__Middleware.js.ejs deleted file mode 100644 index 581a1e7..0000000 --- a/templates/__name__Middleware.js.ejs +++ /dev/null @@ -1,41 +0,0 @@ -export class <%= namePascal %>Middleware { - /** - * Use the constructor to resolve any dependency of the Ioc container - * - * @param container - * @return <%= namePascal %>Middleware - */ - constructor(_container) {} - - /** - * Handle method is executed before the request gets in your controller. - * - * @param ctx - * @return any - */ - async handle({ next }) { - next() - } - - /** - * Intercept method is executed before the response has been sent. - * - * @param ctx - * @return any - */ - async intercept({ body }) { - body.intercepted = true - - return body - } - - /** - * Terminate method is executed after the response has been sent. - * - * @param ctx - * @return any - */ - async terminate({ next }) { - next() - } -} diff --git a/templates/__name__Provider.js.ejs b/templates/__name__Provider.js.ejs deleted file mode 100644 index 05f29aa..0000000 --- a/templates/__name__Provider.js.ejs +++ /dev/null @@ -1,32 +0,0 @@ -import { ServiceProvider } from '@athenna/ioc' - -export class <%= namePascal %>Provider extends ServiceProvider { - /** - * All the container bindings that should be registered. - */ - bindings = {} - - /** - * All the container instances that should be registered. - */ - instances = {} - - /** - * All the container singletons that should be registered. - */ - singletons = {} - - /** - * Register any application services. - * - * @return void - */ - register() {} - - /** - * Bootstrap any application services. - * - * @return void - */ - boot() {} -} diff --git a/templates/__name__Service.js.ejs b/templates/__name__Service.js.ejs deleted file mode 100644 index b01f3ed..0000000 --- a/templates/__name__Service.js.ejs +++ /dev/null @@ -1,9 +0,0 @@ -export class <%= namePascal %>Service { - /** - * Use the constructor to resolve any dependency of the Ioc container - * - * @param _container - * @return <%= namePascal %>Service - */ - constructor(_container) {} -} From 380c9e5096e5d1ad04ad0ffbf048bba37b5f32f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Lenon?= Date: Thu, 7 Apr 2022 09:00:23 -0300 Subject: [PATCH 13/19] feat: update logger and utils --- package-lock.json | 239 ++++---------------------------- package.json | 4 +- src/Cli.ts | 3 + src/Utils/runCommand.ts | 3 +- tests/Unit/Commands/MakeTest.ts | 6 +- tests/Unit/Commands/NewTest.ts | 6 +- 6 files changed, 43 insertions(+), 218 deletions(-) diff --git a/package-lock.json b/package-lock.json index 24cbcde..62bfbad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,8 +9,8 @@ "version": "1.0.2", "license": "MIT", "dependencies": { - "@athenna/logger": "1.1.1", - "@secjs/utils": "1.8.0", + "@athenna/logger": "1.1.2", + "@secjs/utils": "1.8.2", "chalk": "4.1.1", "chalk-rainbow": "1.0.0", "cli-table": "0.3.11", @@ -71,129 +71,23 @@ } }, "node_modules/@athenna/ioc": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/@athenna/ioc/-/ioc-1.0.9.tgz", - "integrity": "sha512-IqU04R7oZFGeHQRjI6d1hK1P0VYF6FYaKLQP0BAQL407q+Wh5AkDEqIxQDyInIOoqIyWjpRet0WpRWjUyrQ1tw==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@athenna/ioc/-/ioc-1.1.1.tgz", + "integrity": "sha512-XtpAH/K73FsuixNSvI8B4+zxI9xfuGJmM2uq1/Px6PimEBNxzL3ScXG+L4JRhbSdWKM+Eq/AlNxu3EU1F1wgAA==", "dependencies": { - "@secjs/utils": "1.7.8", + "@secjs/utils": "1.8.2", "awilix": "7.0.0", "reflect-metadata": "0.1.13", "tscpaths": "0.0.9" } }, - "node_modules/@athenna/ioc/node_modules/@secjs/utils": { - "version": "1.7.8", - "resolved": "https://registry.npmjs.org/@secjs/utils/-/utils-1.7.8.tgz", - "integrity": "sha512-DrcuJhcF2kdUJWoilniCFxbNWVbJJiTI/1NP779kvOSBD8g402tBzqgIjZdrL+tItjcEXMEUFURvmmZeI1l9VQ==", - "dependencies": { - "bytes": "3.1.2", - "chalk": "4.1.2", - "change-case": "4.1.2", - "http-status-codes": "2.2.0", - "kind-of": "6.0.3", - "lodash": "4.17.21", - "mime-types": "2.1.34", - "ms": "2.1.3", - "pluralize": "8.0.0", - "uuid": "8.3.2", - "validator-brazil": "1.2.2" - } - }, - "node_modules/@athenna/ioc/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/@athenna/ioc/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/@athenna/ioc/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/@athenna/ioc/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/@athenna/ioc/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/@athenna/ioc/node_modules/mime-db": { - "version": "1.51.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz", - "integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/@athenna/ioc/node_modules/mime-types": { - "version": "2.1.34", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.34.tgz", - "integrity": "sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==", - "dependencies": { - "mime-db": "1.51.0" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/@athenna/ioc/node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" - }, - "node_modules/@athenna/ioc/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/@athenna/logger": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@athenna/logger/-/logger-1.1.1.tgz", - "integrity": "sha512-cHv846NbsYVPeIhEXUsiGch48sfVLtMNXbK2eFVl7JV32TYP56jGexJgFzOmMVnl/dAeuV/HBGSgP7Ta3z5YFA==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@athenna/logger/-/logger-1.1.2.tgz", + "integrity": "sha512-VPPXh8TTXOO0kySSVE5pNYnbCvgSUzhfqDEGkFsNhtlES9kAdTGu09dVtP9VRc+zVGT9NCmnLOmc6MXkToVRgQ==", "dependencies": { - "@athenna/ioc": "1.0.9", - "@secjs/utils": "1.8.0", + "@athenna/ioc": "1.1.1", + "@secjs/utils": "1.8.2", "chalk": "4.1.1", "reflect-metadata": "0.1.13", "tscpaths": "0.0.9" @@ -1879,9 +1773,9 @@ } }, "node_modules/@secjs/utils": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/@secjs/utils/-/utils-1.8.0.tgz", - "integrity": "sha512-HfffBCtuTK6pRxa6SEhGAinZTj+dRySd8DzlGXR5gpB86Ces48wBEV4wpM39H1sGN60Ct7YL3b9335cBRNq0tg==", + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/@secjs/utils/-/utils-1.8.2.tgz", + "integrity": "sha512-6o1Ws3Sazbn3qsz0sFJzS7WmCOpX7T2RnRJVtTH90Er5XMci5WK9FxcWKsFtklUpVAfh7gieAF0M/y6LKKTP0w==", "dependencies": { "bytes": "3.1.2", "chalk": "4.1.2", @@ -13813,104 +13707,23 @@ } }, "@athenna/ioc": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/@athenna/ioc/-/ioc-1.0.9.tgz", - "integrity": "sha512-IqU04R7oZFGeHQRjI6d1hK1P0VYF6FYaKLQP0BAQL407q+Wh5AkDEqIxQDyInIOoqIyWjpRet0WpRWjUyrQ1tw==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@athenna/ioc/-/ioc-1.1.1.tgz", + "integrity": "sha512-XtpAH/K73FsuixNSvI8B4+zxI9xfuGJmM2uq1/Px6PimEBNxzL3ScXG+L4JRhbSdWKM+Eq/AlNxu3EU1F1wgAA==", "requires": { - "@secjs/utils": "1.7.8", + "@secjs/utils": "1.8.2", "awilix": "7.0.0", "reflect-metadata": "0.1.13", "tscpaths": "0.0.9" - }, - "dependencies": { - "@secjs/utils": { - "version": "1.7.8", - "resolved": "https://registry.npmjs.org/@secjs/utils/-/utils-1.7.8.tgz", - "integrity": "sha512-DrcuJhcF2kdUJWoilniCFxbNWVbJJiTI/1NP779kvOSBD8g402tBzqgIjZdrL+tItjcEXMEUFURvmmZeI1l9VQ==", - "requires": { - "bytes": "3.1.2", - "chalk": "4.1.2", - "change-case": "4.1.2", - "http-status-codes": "2.2.0", - "kind-of": "6.0.3", - "lodash": "4.17.21", - "mime-types": "2.1.34", - "ms": "2.1.3", - "pluralize": "8.0.0", - "uuid": "8.3.2", - "validator-brazil": "1.2.2" - } - }, - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" - }, - "mime-db": { - "version": "1.51.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz", - "integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==" - }, - "mime-types": { - "version": "2.1.34", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.34.tgz", - "integrity": "sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==", - "requires": { - "mime-db": "1.51.0" - } - }, - "ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "requires": { - "has-flag": "^4.0.0" - } - } } }, "@athenna/logger": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@athenna/logger/-/logger-1.1.1.tgz", - "integrity": "sha512-cHv846NbsYVPeIhEXUsiGch48sfVLtMNXbK2eFVl7JV32TYP56jGexJgFzOmMVnl/dAeuV/HBGSgP7Ta3z5YFA==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@athenna/logger/-/logger-1.1.2.tgz", + "integrity": "sha512-VPPXh8TTXOO0kySSVE5pNYnbCvgSUzhfqDEGkFsNhtlES9kAdTGu09dVtP9VRc+zVGT9NCmnLOmc6MXkToVRgQ==", "requires": { - "@athenna/ioc": "1.0.9", - "@secjs/utils": "1.8.0", + "@athenna/ioc": "1.1.1", + "@secjs/utils": "1.8.2", "chalk": "4.1.1", "reflect-metadata": "0.1.13", "tscpaths": "0.0.9" @@ -15185,9 +14998,9 @@ } }, "@secjs/utils": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/@secjs/utils/-/utils-1.8.0.tgz", - "integrity": "sha512-HfffBCtuTK6pRxa6SEhGAinZTj+dRySd8DzlGXR5gpB86Ces48wBEV4wpM39H1sGN60Ct7YL3b9335cBRNq0tg==", + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/@secjs/utils/-/utils-1.8.2.tgz", + "integrity": "sha512-6o1Ws3Sazbn3qsz0sFJzS7WmCOpX7T2RnRJVtTH90Er5XMci5WK9FxcWKsFtklUpVAfh7gieAF0M/y6LKKTP0w==", "requires": { "bytes": "3.1.2", "chalk": "4.1.2", diff --git a/package.json b/package.json index 6ce9639..b6c5d23 100644 --- a/package.json +++ b/package.json @@ -173,8 +173,8 @@ } }, "dependencies": { - "@athenna/logger": "1.1.1", - "@secjs/utils": "1.8.0", + "@athenna/logger": "1.1.2", + "@secjs/utils": "1.8.2", "chalk": "4.1.1", "chalk-rainbow": "1.0.0", "cli-table": "0.3.11", diff --git a/src/Cli.ts b/src/Cli.ts index 4c4c2b7..e6cc785 100644 --- a/src/Cli.ts +++ b/src/Cli.ts @@ -15,6 +15,7 @@ import { Command } from 'commander' import { New } from './Commands/New' import { Make } from './Commands/Make' import { version } from '../package.json' +import { Config, Path } from '@secjs/utils' export class Cli { private clientFolder: string @@ -37,6 +38,8 @@ export class Cli { } async main() { + await new Config().safeLoad(Path.config()) + const newCommand = new New(this.clientFolder) const makeCommand = new Make(this.clientFolder) diff --git a/src/Utils/runCommand.ts b/src/Utils/runCommand.ts index ed3a0f3..8a40de7 100644 --- a/src/Utils/runCommand.ts +++ b/src/Utils/runCommand.ts @@ -9,9 +9,10 @@ import ora from 'ora' import { promisify } from 'util' +import { exec as ChildProcessExec } from 'child_process' import { NodeExecException } from '../Exceptions/NodeExecException' -const exec = promisify(require('child_process').exec) +const exec = promisify(ChildProcessExec) export async function runCommand(command: string, log?: string) { const spinner = ora(log) diff --git a/tests/Unit/Commands/MakeTest.ts b/tests/Unit/Commands/MakeTest.ts index 864d39e..b9b0129 100644 --- a/tests/Unit/Commands/MakeTest.ts +++ b/tests/Unit/Commands/MakeTest.ts @@ -8,10 +8,14 @@ */ import { existsSync } from 'fs' -import { Folder, Path } from '@secjs/utils' +import { Config, Folder, Path } from '@secjs/utils' import { Make } from '../../../src/Commands/Make' describe('\n MakeTest', () => { + beforeAll(async () => { + await new Config().safeLoad(Path.config('logging')) + }) + it('should be able to create a controller file', async () => { await new Make(Path.storage()).controller('TestControllers', { extension: 'ts' }) diff --git a/tests/Unit/Commands/NewTest.ts b/tests/Unit/Commands/NewTest.ts index 4d6a800..700040e 100644 --- a/tests/Unit/Commands/NewTest.ts +++ b/tests/Unit/Commands/NewTest.ts @@ -8,10 +8,14 @@ */ import { existsSync } from 'fs' -import { Folder, Path } from '@secjs/utils' +import { Config, Folder, Path } from '@secjs/utils' import { New } from '../../../src/Commands/New' describe('\n NewTest', () => { + beforeAll(async () => { + await new Config().safeLoad(Path.config('logging')) + }) + it('should be able to create a new http project', async () => { await new New(Path.pwd()).project('test', { type: 'http' }) From a21c4b93659f9fe1bc1b22871bc794b1cb31e98c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Lenon?= Date: Thu, 7 Apr 2022 16:34:30 -0300 Subject: [PATCH 14/19] feat: update logger and utils --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index b6c5d23..58610c9 100644 --- a/package.json +++ b/package.json @@ -173,8 +173,8 @@ } }, "dependencies": { - "@athenna/logger": "1.1.2", - "@secjs/utils": "1.8.2", + "@athenna/logger": "1.1.4", + "@secjs/utils": "1.8.3", "chalk": "4.1.1", "chalk-rainbow": "1.0.0", "cli-table": "0.3.11", From 203c439e75a1cb2647dea258eefd9a434c2e67ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Lenon?= Date: Thu, 7 Apr 2022 16:34:59 -0300 Subject: [PATCH 15/19] feat: update logger and utils --- package-lock.json | 52 +++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/package-lock.json b/package-lock.json index 62bfbad..5f403f0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,8 +9,8 @@ "version": "1.0.2", "license": "MIT", "dependencies": { - "@athenna/logger": "1.1.2", - "@secjs/utils": "1.8.2", + "@athenna/logger": "1.1.4", + "@secjs/utils": "1.8.3", "chalk": "4.1.1", "chalk-rainbow": "1.0.0", "cli-table": "0.3.11", @@ -71,23 +71,23 @@ } }, "node_modules/@athenna/ioc": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@athenna/ioc/-/ioc-1.1.1.tgz", - "integrity": "sha512-XtpAH/K73FsuixNSvI8B4+zxI9xfuGJmM2uq1/Px6PimEBNxzL3ScXG+L4JRhbSdWKM+Eq/AlNxu3EU1F1wgAA==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@athenna/ioc/-/ioc-1.1.2.tgz", + "integrity": "sha512-yJV8+T9lKXEBeS73YhQGCosKjT7q4qSQxtShSU0t1tu2tfJc7qiFAVZNXCP9w6TfkRxUWwWDnh8r14Gdd1chFw==", "dependencies": { - "@secjs/utils": "1.8.2", + "@secjs/utils": "1.8.3", "awilix": "7.0.0", "reflect-metadata": "0.1.13", "tscpaths": "0.0.9" } }, "node_modules/@athenna/logger": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@athenna/logger/-/logger-1.1.2.tgz", - "integrity": "sha512-VPPXh8TTXOO0kySSVE5pNYnbCvgSUzhfqDEGkFsNhtlES9kAdTGu09dVtP9VRc+zVGT9NCmnLOmc6MXkToVRgQ==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@athenna/logger/-/logger-1.1.4.tgz", + "integrity": "sha512-BHYpkAXl3ICar2Sv94OpPEPwmtMMcKYIcGzDrzPGTFY2E6zgocYAMLVzdb4+1ijq1fxqQrY3ZyAaGTxzzmyYUQ==", "dependencies": { - "@athenna/ioc": "1.1.1", - "@secjs/utils": "1.8.2", + "@athenna/ioc": "1.1.2", + "@secjs/utils": "1.8.3", "chalk": "4.1.1", "reflect-metadata": "0.1.13", "tscpaths": "0.0.9" @@ -1773,9 +1773,9 @@ } }, "node_modules/@secjs/utils": { - "version": "1.8.2", - "resolved": "https://registry.npmjs.org/@secjs/utils/-/utils-1.8.2.tgz", - "integrity": "sha512-6o1Ws3Sazbn3qsz0sFJzS7WmCOpX7T2RnRJVtTH90Er5XMci5WK9FxcWKsFtklUpVAfh7gieAF0M/y6LKKTP0w==", + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/@secjs/utils/-/utils-1.8.3.tgz", + "integrity": "sha512-iXnJCJw3P8MP7VUlcQHcaKQPBxZhTQ4By2P4HDRbGLF7ATk7HBBUjXV8LRNnzCl7kGgBLLLjcNMuIEr+knsm1A==", "dependencies": { "bytes": "3.1.2", "chalk": "4.1.2", @@ -13707,23 +13707,23 @@ } }, "@athenna/ioc": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@athenna/ioc/-/ioc-1.1.1.tgz", - "integrity": "sha512-XtpAH/K73FsuixNSvI8B4+zxI9xfuGJmM2uq1/Px6PimEBNxzL3ScXG+L4JRhbSdWKM+Eq/AlNxu3EU1F1wgAA==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@athenna/ioc/-/ioc-1.1.2.tgz", + "integrity": "sha512-yJV8+T9lKXEBeS73YhQGCosKjT7q4qSQxtShSU0t1tu2tfJc7qiFAVZNXCP9w6TfkRxUWwWDnh8r14Gdd1chFw==", "requires": { - "@secjs/utils": "1.8.2", + "@secjs/utils": "1.8.3", "awilix": "7.0.0", "reflect-metadata": "0.1.13", "tscpaths": "0.0.9" } }, "@athenna/logger": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@athenna/logger/-/logger-1.1.2.tgz", - "integrity": "sha512-VPPXh8TTXOO0kySSVE5pNYnbCvgSUzhfqDEGkFsNhtlES9kAdTGu09dVtP9VRc+zVGT9NCmnLOmc6MXkToVRgQ==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@athenna/logger/-/logger-1.1.4.tgz", + "integrity": "sha512-BHYpkAXl3ICar2Sv94OpPEPwmtMMcKYIcGzDrzPGTFY2E6zgocYAMLVzdb4+1ijq1fxqQrY3ZyAaGTxzzmyYUQ==", "requires": { - "@athenna/ioc": "1.1.1", - "@secjs/utils": "1.8.2", + "@athenna/ioc": "1.1.2", + "@secjs/utils": "1.8.3", "chalk": "4.1.1", "reflect-metadata": "0.1.13", "tscpaths": "0.0.9" @@ -14998,9 +14998,9 @@ } }, "@secjs/utils": { - "version": "1.8.2", - "resolved": "https://registry.npmjs.org/@secjs/utils/-/utils-1.8.2.tgz", - "integrity": "sha512-6o1Ws3Sazbn3qsz0sFJzS7WmCOpX7T2RnRJVtTH90Er5XMci5WK9FxcWKsFtklUpVAfh7gieAF0M/y6LKKTP0w==", + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/@secjs/utils/-/utils-1.8.3.tgz", + "integrity": "sha512-iXnJCJw3P8MP7VUlcQHcaKQPBxZhTQ4By2P4HDRbGLF7ATk7HBBUjXV8LRNnzCl7kGgBLLLjcNMuIEr+knsm1A==", "requires": { "bytes": "3.1.2", "chalk": "4.1.2", From ebe598aa6aaecbab91d89c6640a4692bb28ee2e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Lenon?= Date: Fri, 8 Apr 2022 11:56:56 -0300 Subject: [PATCH 16/19] feat: generate .env.test file with .env --- package-lock.json | 14 +++++++------- package.json | 2 +- src/Commands/New.ts | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5f403f0..c767501 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.2", "license": "MIT", "dependencies": { - "@athenna/logger": "1.1.4", + "@athenna/logger": "1.1.6", "@secjs/utils": "1.8.3", "chalk": "4.1.1", "chalk-rainbow": "1.0.0", @@ -82,9 +82,9 @@ } }, "node_modules/@athenna/logger": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/@athenna/logger/-/logger-1.1.4.tgz", - "integrity": "sha512-BHYpkAXl3ICar2Sv94OpPEPwmtMMcKYIcGzDrzPGTFY2E6zgocYAMLVzdb4+1ijq1fxqQrY3ZyAaGTxzzmyYUQ==", + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/@athenna/logger/-/logger-1.1.6.tgz", + "integrity": "sha512-4eI4DiPyqMpVQBQCbfnJjHByRwOyn4oEJF+3drevam9/7R9YirmyGJHy0gjJILuE50Is28ailI3oJscRvKhJOw==", "dependencies": { "@athenna/ioc": "1.1.2", "@secjs/utils": "1.8.3", @@ -13718,9 +13718,9 @@ } }, "@athenna/logger": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/@athenna/logger/-/logger-1.1.4.tgz", - "integrity": "sha512-BHYpkAXl3ICar2Sv94OpPEPwmtMMcKYIcGzDrzPGTFY2E6zgocYAMLVzdb4+1ijq1fxqQrY3ZyAaGTxzzmyYUQ==", + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/@athenna/logger/-/logger-1.1.6.tgz", + "integrity": "sha512-4eI4DiPyqMpVQBQCbfnJjHByRwOyn4oEJF+3drevam9/7R9YirmyGJHy0gjJILuE50Is28ailI3oJscRvKhJOw==", "requires": { "@athenna/ioc": "1.1.2", "@secjs/utils": "1.8.3", diff --git a/package.json b/package.json index 58610c9..4910091 100644 --- a/package.json +++ b/package.json @@ -173,7 +173,7 @@ } }, "dependencies": { - "@athenna/logger": "1.1.4", + "@athenna/logger": "1.1.6", "@secjs/utils": "1.8.3", "chalk": "4.1.1", "chalk-rainbow": "1.0.0", diff --git a/src/Commands/New.ts b/src/Commands/New.ts index e79a59b..a1a63f7 100644 --- a/src/Commands/New.ts +++ b/src/Commands/New.ts @@ -61,7 +61,7 @@ export class New { const cdCommand = `cd ${projectPath}` const cloneCommand = `git clone --branch http ${this.repositoryUrl} ${projectPath}` const runNpmInstallCommand = `${cdCommand} && npm install --silent` - const rmGitAndCopyEnv = `${cdCommand} && rm -rf .git && rm -rf .github && cp .env.example .env` + const rmGitAndCopyEnv = `${cdCommand} && rm -rf .git && rm -rf .github && cp .env.example .env && cp .env.example .env.test` const moveProjectCommand = `mv ${projectPath} ${concretePath}` await runCommand( @@ -71,7 +71,7 @@ export class New { await runCommand( rmGitAndCopyEnv, - 'Removing defaults and creating .env file from .env.example', + 'Removing defaults and creating .env/.env.test files from .env.example', ) await runCommand(runNpmInstallCommand, 'Installing dependencies') From b3b862545394358663207fa10cd8d1523e9c1f77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Lenon?= Date: Mon, 11 Apr 2022 01:20:44 -0300 Subject: [PATCH 17/19] feat: update dependencies --- package-lock.json | 30 +++++++++++++++--------------- package.json | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/package-lock.json b/package-lock.json index c767501..343e1f6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.2", "license": "MIT", "dependencies": { - "@athenna/logger": "1.1.6", + "@athenna/logger": "1.1.7", "@secjs/utils": "1.8.3", "chalk": "4.1.1", "chalk-rainbow": "1.0.0", @@ -71,9 +71,9 @@ } }, "node_modules/@athenna/ioc": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@athenna/ioc/-/ioc-1.1.2.tgz", - "integrity": "sha512-yJV8+T9lKXEBeS73YhQGCosKjT7q4qSQxtShSU0t1tu2tfJc7qiFAVZNXCP9w6TfkRxUWwWDnh8r14Gdd1chFw==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@athenna/ioc/-/ioc-1.1.3.tgz", + "integrity": "sha512-owhtIGKqUp3Wr/PpOfBPLTyShqtRbbJTgkYBATHdeE+7TydT4FU6F5lXYzmAMUNvXjO6Wb+F4mBHTchZikDMxQ==", "dependencies": { "@secjs/utils": "1.8.3", "awilix": "7.0.0", @@ -82,11 +82,11 @@ } }, "node_modules/@athenna/logger": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/@athenna/logger/-/logger-1.1.6.tgz", - "integrity": "sha512-4eI4DiPyqMpVQBQCbfnJjHByRwOyn4oEJF+3drevam9/7R9YirmyGJHy0gjJILuE50Is28ailI3oJscRvKhJOw==", + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/@athenna/logger/-/logger-1.1.7.tgz", + "integrity": "sha512-l6htUx0WI4Z2PbH2n+09ACFT1UJ54djtKMWZsLDo1zcWo2LqWsz6pCvSuqbvFQLeSGhxFDZ/u5pMAmWiJKG0DQ==", "dependencies": { - "@athenna/ioc": "1.1.2", + "@athenna/ioc": "1.1.3", "@secjs/utils": "1.8.3", "chalk": "4.1.1", "reflect-metadata": "0.1.13", @@ -13707,9 +13707,9 @@ } }, "@athenna/ioc": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@athenna/ioc/-/ioc-1.1.2.tgz", - "integrity": "sha512-yJV8+T9lKXEBeS73YhQGCosKjT7q4qSQxtShSU0t1tu2tfJc7qiFAVZNXCP9w6TfkRxUWwWDnh8r14Gdd1chFw==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@athenna/ioc/-/ioc-1.1.3.tgz", + "integrity": "sha512-owhtIGKqUp3Wr/PpOfBPLTyShqtRbbJTgkYBATHdeE+7TydT4FU6F5lXYzmAMUNvXjO6Wb+F4mBHTchZikDMxQ==", "requires": { "@secjs/utils": "1.8.3", "awilix": "7.0.0", @@ -13718,11 +13718,11 @@ } }, "@athenna/logger": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/@athenna/logger/-/logger-1.1.6.tgz", - "integrity": "sha512-4eI4DiPyqMpVQBQCbfnJjHByRwOyn4oEJF+3drevam9/7R9YirmyGJHy0gjJILuE50Is28ailI3oJscRvKhJOw==", + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/@athenna/logger/-/logger-1.1.7.tgz", + "integrity": "sha512-l6htUx0WI4Z2PbH2n+09ACFT1UJ54djtKMWZsLDo1zcWo2LqWsz6pCvSuqbvFQLeSGhxFDZ/u5pMAmWiJKG0DQ==", "requires": { - "@athenna/ioc": "1.1.2", + "@athenna/ioc": "1.1.3", "@secjs/utils": "1.8.3", "chalk": "4.1.1", "reflect-metadata": "0.1.13", diff --git a/package.json b/package.json index 4910091..09031cc 100644 --- a/package.json +++ b/package.json @@ -173,7 +173,7 @@ } }, "dependencies": { - "@athenna/logger": "1.1.6", + "@athenna/logger": "1.1.7", "@secjs/utils": "1.8.3", "chalk": "4.1.1", "chalk-rainbow": "1.0.0", From 206e26d7b822979efda74a7998b910f44c91ec75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Lenon?= Date: Tue, 19 Apr 2022 19:07:52 -0300 Subject: [PATCH 18/19] refactor: remove make commands from cli and move to artisan --- README.md | 2 +- config/logging.ts | 6 +- package-lock.json | 775 ++++++++++++++++++++++++++-- package.json | 8 +- src/Cli.ts | 36 +- src/Commands/Make.ts | 167 ------ templates/__name__Controller.ts.ejs | 62 --- templates/__name__Middleware.ts.ejs | 50 -- templates/__name__Provider.ts.ejs | 32 -- templates/__name__Service.ts.ejs | 11 - tests/Unit/Commands/MakeTest.ts | 34 -- tests/Unit/Commands/NewTest.ts | 2 +- 12 files changed, 750 insertions(+), 435 deletions(-) delete mode 100644 src/Commands/Make.ts delete mode 100644 templates/__name__Controller.ts.ejs delete mode 100644 templates/__name__Middleware.ts.ejs delete mode 100644 templates/__name__Provider.ts.ejs delete mode 100644 templates/__name__Service.ts.ejs delete mode 100644 tests/Unit/Commands/MakeTest.ts diff --git a/README.md b/README.md index 8882ea5..a9b2b6d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Cli ⌨️ -> Template for new projects +> Athenna CLI to create new projects and install components. [![Git Hubfollowers](https://img.shields.io/github/followers/athennaio.svg?style=social&label=Follow&maxAge=2592000)](https://github.com/athennaio?tab=followers) [![GitHub stars](https://img.shields.io/github/stars/athennaio/cli.svg?style=social&label=Star&maxAge=2592000)](https://github.com/athennaio/cli/stargazers/) diff --git a/config/logging.ts b/config/logging.ts index f912f9a..6ff5ff7 100644 --- a/config/logging.ts +++ b/config/logging.ts @@ -21,8 +21,10 @@ export default { | | Here you may configure the log channels for your application. | - | Available Drivers: "console", "debug", "file". - | Available Formatters: "cli", "simple", "nest", "json". + | Available Drivers: + | "console", "debug", "discord", "file", "null", "pino", "slack", "telegram". + | Available Formatters: + | "cli", "simple", "nest", "json", "request", "message", "pino-pretty(only for pino driver)". | */ diff --git a/package-lock.json b/package-lock.json index 343e1f6..cbe533a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.2", "license": "MIT", "dependencies": { - "@athenna/logger": "1.1.7", + "@athenna/logger": "1.1.8", "@secjs/utils": "1.8.3", "chalk": "4.1.1", "chalk-rainbow": "1.0.0", @@ -82,14 +82,18 @@ } }, "node_modules/@athenna/logger": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/@athenna/logger/-/logger-1.1.7.tgz", - "integrity": "sha512-l6htUx0WI4Z2PbH2n+09ACFT1UJ54djtKMWZsLDo1zcWo2LqWsz6pCvSuqbvFQLeSGhxFDZ/u5pMAmWiJKG0DQ==", + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/@athenna/logger/-/logger-1.1.8.tgz", + "integrity": "sha512-k6Cy8tGuTxXxhwghUoM43/d/C887WTecBpAYsKt3c7rNbdCLKbVtXqKBpldBSlGyKBrkLhZeA5ZV6NRbwXmZew==", "dependencies": { "@athenna/ioc": "1.1.3", "@secjs/utils": "1.8.3", + "axios": "0.26.1", "chalk": "4.1.1", + "pino": "7.10.0", + "pino-pretty": "7.6.1", "reflect-metadata": "0.1.13", + "telegraf": "4.7.0", "tscpaths": "0.0.9" } }, @@ -2492,6 +2496,17 @@ "integrity": "sha512-9IK9EadsbHo6jLWIpxpR6pL0sazTXV6+SQv25ZB+F7Bj9mJNaOc4nCRabwd5M/JwmUa8idz6Eci6eKfJryPs6Q==", "dev": true }, + "node_modules/abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "dependencies": { + "event-target-shim": "^5.0.0" + }, + "engines": { + "node": ">=6.5" + } + }, "node_modules/acorn": { "version": "7.4.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", @@ -2622,7 +2637,6 @@ "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, "dependencies": { "color-convert": "^1.9.0" }, @@ -2667,6 +2681,49 @@ "sprintf-js": "~1.0.2" } }, + "node_modules/args": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/args/-/args-5.0.1.tgz", + "integrity": "sha512-1kqmFCFsPffavQFGt8OxJdIcETti99kySRUPMpOhaGjL6mRJn8HFU1OxKY5bMqfZKUwTQc1mZkAjmGYaVOHFtQ==", + "dependencies": { + "camelcase": "5.0.0", + "chalk": "2.4.2", + "leven": "2.1.0", + "mri": "1.1.4" + }, + "engines": { + "node": ">= 6.0.0" + } + }, + "node_modules/args/node_modules/camelcase": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.0.0.tgz", + "integrity": "sha512-faqwZqnWxbxn+F1d399ygeamQNy3lPp/H9H6rNrqYh4FSVCtcY+3cub1MxA8o9mDd55mM8Aghuu/kuyYA6VTsA==", + "engines": { + "node": ">=6" + } + }, + "node_modules/args/node_modules/chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dependencies": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/args/node_modules/leven": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/leven/-/leven-2.1.0.tgz", + "integrity": "sha1-wuep93IJTe6dNCAq6KzORoeHVYA=", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/arr-diff": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", @@ -2791,6 +2848,14 @@ "node": ">= 4.5.0" } }, + "node_modules/atomic-sleep": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/atomic-sleep/-/atomic-sleep-1.0.0.tgz", + "integrity": "sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==", + "engines": { + "node": ">=8.0.0" + } + }, "node_modules/awilix": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/awilix/-/awilix-7.0.0.tgz", @@ -2803,6 +2868,14 @@ "node": ">=12.0.0" } }, + "node_modules/axios": { + "version": "0.26.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz", + "integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==", + "dependencies": { + "follow-redirects": "^1.14.8" + } + }, "node_modules/babel-jest": { "version": "27.5.1", "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-27.5.1.tgz", @@ -3126,6 +3199,25 @@ "ieee754": "^1.1.13" } }, + "node_modules/buffer-alloc": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/buffer-alloc/-/buffer-alloc-1.2.0.tgz", + "integrity": "sha512-CFsHQgjtW1UChdXgbyJGtnm+O/uLQeZdtbDo8mfUgYXCHSM1wgrVxXm6bSyrUuErEb+4sYVGCzASBRot7zyrow==", + "dependencies": { + "buffer-alloc-unsafe": "^1.1.0", + "buffer-fill": "^1.0.0" + } + }, + "node_modules/buffer-alloc-unsafe": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz", + "integrity": "sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg==" + }, + "node_modules/buffer-fill": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/buffer-fill/-/buffer-fill-1.0.0.tgz", + "integrity": "sha1-+PeLdniYiO858gXNY39o5wISKyw=" + }, "node_modules/buffer-from": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", @@ -3798,7 +3890,6 @@ "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, "dependencies": { "color-name": "1.1.3" } @@ -3806,8 +3897,12 @@ "node_modules/color-name": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", - "dev": true + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, + "node_modules/colorette": { + "version": "2.0.16", + "resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.16.tgz", + "integrity": "sha512-hUewv7oMjCp+wkBv5Rm0v87eJhq4woh5rSR+42YSQJKecCqgIqNkZ6lAlQms/BwHPJA5NKMRlpxPRv0n8HQW6g==" }, "node_modules/colors": { "version": "1.0.3", @@ -4226,11 +4321,18 @@ "integrity": "sha512-hBSVCvSmWC+QypYObzwGOd9wqdDpOt+0wl0KbU+R+uuZBS1jN8VsD1ss3irQDknRj5NvxiTF6oj/nDRnN/UQNw==", "dev": true }, + "node_modules/dateformat": { + "version": "4.6.3", + "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-4.6.3.tgz", + "integrity": "sha512-2P0p0pFGzHS5EMnhdxQi7aJN+iMheud0UhG4dlE1DLAlvL8JHjJJTX/CSm4JXwV0Ka5nGk3zC5mcb5bUQUxxMA==", + "engines": { + "node": "*" + } + }, "node_modules/debug": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "dev": true, "dependencies": { "ms": "2.1.2" }, @@ -4470,6 +4572,17 @@ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz", "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==" }, + "node_modules/duplexify": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-4.1.2.tgz", + "integrity": "sha512-fz3OjcNCHmRP12MJoZMPglx8m4rrFP8rovnk4vT8Fs+aonZoCwGg10dSsQsfP/E62eZcPTMSMP6686fu9Qlqtw==", + "dependencies": { + "end-of-stream": "^1.4.1", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1", + "stream-shift": "^1.0.0" + } + }, "node_modules/ejs": { "version": "3.1.6", "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.6.tgz", @@ -4520,7 +4633,6 @@ "version": "1.4.4", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", - "dev": true, "dependencies": { "once": "^1.4.0" } @@ -5397,6 +5509,14 @@ "node": ">=0.10.0" } }, + "node_modules/event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", + "engines": { + "node": ">=6" + } + }, "node_modules/events": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", @@ -5765,6 +5885,19 @@ "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", "dev": true }, + "node_modules/fast-redact": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/fast-redact/-/fast-redact-3.1.1.tgz", + "integrity": "sha512-odVmjC8x8jNeMZ3C+rPMESzXVSEU8tSWSHv9HFxP2mm89G/1WwqhrerJDQm9Zus8X6aoRgQDThKqptdNA6bt+A==", + "engines": { + "node": ">=6" + } + }, + "node_modules/fast-safe-stringify": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz", + "integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==" + }, "node_modules/fastq": { "version": "1.13.0", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz", @@ -5895,6 +6028,25 @@ "integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==", "dev": true }, + "node_modules/follow-redirects": { + "version": "1.14.9", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz", + "integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, "node_modules/for-in": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", @@ -6248,7 +6400,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true, "engines": { "node": ">=4" } @@ -9284,6 +9435,14 @@ "url": "https://github.com/chalk/supports-color?sponsor=1" } }, + "node_modules/joycon": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/joycon/-/joycon-3.1.1.tgz", + "integrity": "sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==", + "engines": { + "node": ">=10" + } + }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -10110,8 +10269,7 @@ "node_modules/minimist": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", - "dev": true + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" }, "node_modules/mixin-deep": { "version": "1.3.2", @@ -10125,11 +10283,23 @@ "node": ">=0.10.0" } }, + "node_modules/module-alias": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/module-alias/-/module-alias-2.2.2.tgz", + "integrity": "sha512-A/78XjoX2EmNvppVWEhM2oGk3x4lLxnkEA4jTbaK97QKSDjkIoOsKQlfylt/d3kKKi596Qy3NP5XrXJ6fZIC9Q==" + }, + "node_modules/mri": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/mri/-/mri-1.1.4.tgz", + "integrity": "sha512-6y7IjGPm8AzlvoUrwAaw1tLnUBudaS3752vcd8JtrpGGQn+rXIe63LFVHm/YMwtqAuh+LJPCFdlLYPWM1nYn6w==", + "engines": { + "node": ">=4" + } + }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "node_modules/mute-stream": { "version": "0.0.8", @@ -10190,6 +10360,44 @@ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz", "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==" }, + "node_modules/node-fetch": { + "version": "2.6.7", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", + "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/node-fetch/node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=" + }, + "node_modules/node-fetch/node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=" + }, + "node_modules/node-fetch/node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, "node_modules/node-int64": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", @@ -10430,6 +10638,11 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/on-exit-leak-free": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/on-exit-leak-free/-/on-exit-leak-free-0.2.0.tgz", + "integrity": "sha512-dqaz3u44QbRXQooZLTUKU41ZrzYrcvLISVgbrzbyCMxpmSLJvZ3ZamIJIZ29P6OhZIkNIQKosdeM6t1LYbA9hg==" + }, "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -10611,6 +10824,14 @@ "node": ">=8" } }, + "node_modules/p-timeout": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-timeout/-/p-timeout-4.1.0.tgz", + "integrity": "sha512-+/wmHtzJuWii1sXn3HCuH/FTwGhrp4tmJTxSKJbfS+vkipci6osxXM5mY0jUiRzWKMTgUT8l7HFbeSwZAynqHw==", + "engines": { + "node": ">=10" + } + }, "node_modules/p-try": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", @@ -10787,6 +11008,75 @@ "node": ">=4" } }, + "node_modules/pino": { + "version": "7.10.0", + "resolved": "https://registry.npmjs.org/pino/-/pino-7.10.0.tgz", + "integrity": "sha512-T6R92jy/APDElEuOk0gqa4nds3ZgqFbHde2X0g8XorlyPlVGlr9T5KQphtp72a3ByKOdZMg/gM/0IprpGQfTWg==", + "dependencies": { + "atomic-sleep": "^1.0.0", + "fast-redact": "^3.0.0", + "on-exit-leak-free": "^0.2.0", + "pino-abstract-transport": "v0.5.0", + "pino-std-serializers": "^4.0.0", + "process-warning": "^1.0.0", + "quick-format-unescaped": "^4.0.3", + "real-require": "^0.1.0", + "safe-stable-stringify": "^2.1.0", + "sonic-boom": "^2.2.1", + "thread-stream": "^0.15.1" + }, + "bin": { + "pino": "bin.js" + } + }, + "node_modules/pino-abstract-transport": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/pino-abstract-transport/-/pino-abstract-transport-0.5.0.tgz", + "integrity": "sha512-+KAgmVeqXYbTtU2FScx1XS3kNyfZ5TrXY07V96QnUSFqo2gAqlvmaxH67Lj7SWazqsMabf+58ctdTcBgnOLUOQ==", + "dependencies": { + "duplexify": "^4.1.2", + "split2": "^4.0.0" + } + }, + "node_modules/pino-pretty": { + "version": "7.6.1", + "resolved": "https://registry.npmjs.org/pino-pretty/-/pino-pretty-7.6.1.tgz", + "integrity": "sha512-H7N6ZYkiyrfwBGW9CSjx0uyO9Q2Lyt73881+OTYk8v3TiTdgN92QHrWlEq/LeWw5XtDP64jeSk3mnc6T+xX9/w==", + "dependencies": { + "args": "^5.0.1", + "colorette": "^2.0.7", + "dateformat": "^4.6.3", + "fast-safe-stringify": "^2.0.7", + "joycon": "^3.1.1", + "on-exit-leak-free": "^0.2.0", + "pino-abstract-transport": "^0.5.0", + "pump": "^3.0.0", + "readable-stream": "^3.6.0", + "rfdc": "^1.3.0", + "secure-json-parse": "^2.4.0", + "sonic-boom": "^2.2.0", + "strip-json-comments": "^3.1.1" + }, + "bin": { + "pino-pretty": "bin.js" + } + }, + "node_modules/pino-pretty/node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/pino-std-serializers": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/pino-std-serializers/-/pino-std-serializers-4.0.0.tgz", + "integrity": "sha512-cK0pekc1Kjy5w9V2/n+8MkZwusa6EyyxfeQCB799CQRhRt/CqYKiWs5adeu8Shve2ZNffvfC/7J64A2PJo1W/Q==" + }, "node_modules/pirates": { "version": "4.0.5", "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.5.tgz", @@ -10974,6 +11264,11 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/process-warning": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/process-warning/-/process-warning-1.0.0.tgz", + "integrity": "sha512-du4wfLyj4yCZq1VupnVSZmRsPJsNuxoDQFdCFHLaYiEbFBD7QE0a+I4D7hOxrVnh78QE/YipFAj9lXHiXocV+Q==" + }, "node_modules/progress": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", @@ -11006,7 +11301,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", - "dev": true, "dependencies": { "end-of-stream": "^1.1.0", "once": "^1.3.1" @@ -11040,6 +11334,11 @@ } ] }, + "node_modules/quick-format-unescaped": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/quick-format-unescaped/-/quick-format-unescaped-4.0.4.tgz", + "integrity": "sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg==" + }, "node_modules/randombytes": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", @@ -11132,6 +11431,14 @@ "node": ">= 6" } }, + "node_modules/real-require": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/real-require/-/real-require-0.1.0.tgz", + "integrity": "sha512-r/H9MzAWtrv8aSVjPCMFpDMl5q66GqtmmRkRjpHTsp4zBAa+snZyiQNlMONiUmEJcsnaw0wCauJ2GWODr/aFkg==", + "engines": { + "node": ">= 12.13.0" + } + }, "node_modules/reflect-metadata": { "version": "0.1.13", "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.13.tgz", @@ -11304,6 +11611,11 @@ "node": ">=0.10.0" } }, + "node_modules/rfdc": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.3.0.tgz", + "integrity": "sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA==" + }, "node_modules/rimraf": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", @@ -11379,6 +11691,14 @@ "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", "dev": true }, + "node_modules/safe-compare": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/safe-compare/-/safe-compare-1.1.4.tgz", + "integrity": "sha512-b9wZ986HHCo/HbKrRpBJb2kqXMK9CEWIE1egeEvZsYn69ay3kdfl9nG3RyOcR+jInTDf7a86WQ1d4VJX7goSSQ==", + "dependencies": { + "buffer-alloc": "^1.2.0" + } + }, "node_modules/safe-regex": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", @@ -11387,11 +11707,27 @@ "ret": "~0.1.10" } }, + "node_modules/safe-stable-stringify": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.3.1.tgz", + "integrity": "sha512-kYBSfT+troD9cDA85VDnHZ1rpHC50O0g1e6WlGHVCz/g+JS+9WKLj+XwFYyR8UbrZN8ll9HUpDAAddY58MGisg==", + "engines": { + "node": ">=10" + } + }, "node_modules/safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, + "node_modules/sandwich-stream": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/sandwich-stream/-/sandwich-stream-2.0.2.tgz", + "integrity": "sha512-jLYV0DORrzY3xaz/S9ydJL6Iz7essZeAfnAavsJ+zsJGZ1MOnsS52yRjU3uF3pJa/lla7+wisp//fxOwOH8SKQ==", + "engines": { + "node": ">= 0.10" + } + }, "node_modules/saxes": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/saxes/-/saxes-5.0.1.tgz", @@ -11423,6 +11759,11 @@ "url": "https://opencollective.com/webpack" } }, + "node_modules/secure-json-parse": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/secure-json-parse/-/secure-json-parse-2.4.0.tgz", + "integrity": "sha512-Q5Z/97nbON5t/L/sH6mY2EacfjVGwrCcSi5D3btRO2GZ8pf1K1UN7Z9H5J57hjVU2Qzxr1xO+FmBhOvEkzCMmg==" + }, "node_modules/semver": { "version": "7.3.5", "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", @@ -11760,6 +12101,14 @@ "node": ">=0.10.0" } }, + "node_modules/sonic-boom": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-2.7.0.tgz", + "integrity": "sha512-Ynxp0OGQG91wvDjCbFlRMHbSUmDq7dE/EgDeUJ/j+Q9x1FVkFry20cjLykxRSmlm3QS0B4JYAKE8239XKN4SHQ==", + "dependencies": { + "atomic-sleep": "^1.0.0" + } + }, "node_modules/source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -11841,6 +12190,14 @@ "node": ">=0.10.0" } }, + "node_modules/split2": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/split2/-/split2-4.1.0.tgz", + "integrity": "sha512-VBiJxFkxiXRlUIeyMQi8s4hgvKCSjtknJv/LVYbrgALPwf5zSKmEwV9Lst25AkvMDnvxODugjdl6KZgwKM1WYQ==", + "engines": { + "node": ">= 10.x" + } + }, "node_modules/sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", @@ -11956,6 +12313,11 @@ "node": ">=0.10.0" } }, + "node_modules/stream-shift": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.1.tgz", + "integrity": "sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ==" + }, "node_modules/string_decoder": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", @@ -12130,7 +12492,6 @@ "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, "dependencies": { "has-flag": "^3.0.0" }, @@ -12319,6 +12680,28 @@ "node": ">=6" } }, + "node_modules/telegraf": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/telegraf/-/telegraf-4.7.0.tgz", + "integrity": "sha512-rspH4kiVHE1zpnyQvlGFj+Tzu7zN02gSOcdLUayvnkaTwww2E6xBkwne+DKkDPdaRhvQ61J+dcVhLQv9fL+FsQ==", + "dependencies": { + "abort-controller": "^3.0.0", + "debug": "^4.3.3", + "minimist": "^1.2.5", + "module-alias": "^2.2.2", + "node-fetch": "^2.6.7", + "p-timeout": "^4.1.0", + "safe-compare": "^1.1.4", + "sandwich-stream": "^2.0.2", + "typegram": "^3.8.0" + }, + "bin": { + "telegraf": "bin/telegraf" + }, + "engines": { + "node": "^12.20.0 || >=14.13.1" + } + }, "node_modules/terminal-link": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/terminal-link/-/terminal-link-2.1.1.tgz", @@ -12466,6 +12849,14 @@ "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", "dev": true }, + "node_modules/thread-stream": { + "version": "0.15.2", + "resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-0.15.2.tgz", + "integrity": "sha512-UkEhKIg2pD+fjkHQKyJO3yoIvAP3N6RlNFt2dUhcS1FGvCD1cQa1M/PGknCLFIyZdtJOWQjejp7bdNqmN7zwdA==", + "dependencies": { + "real-require": "^0.1.0" + } + }, "node_modules/throat": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/throat/-/throat-6.0.1.tgz", @@ -13100,6 +13491,11 @@ "is-typedarray": "^1.0.0" } }, + "node_modules/typegram": { + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/typegram/-/typegram-3.8.0.tgz", + "integrity": "sha512-MdlbWu0HfmgFJf4+xj6eqGYuanV2LJxBYTzLrD0kTV+woQ5dxDD2k8UVVjYnbBGkAagAyxzQevPiFZRWLFHSBw==" + }, "node_modules/typescript": { "version": "4.3.5", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.5.tgz", @@ -13718,14 +14114,18 @@ } }, "@athenna/logger": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/@athenna/logger/-/logger-1.1.7.tgz", - "integrity": "sha512-l6htUx0WI4Z2PbH2n+09ACFT1UJ54djtKMWZsLDo1zcWo2LqWsz6pCvSuqbvFQLeSGhxFDZ/u5pMAmWiJKG0DQ==", + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/@athenna/logger/-/logger-1.1.8.tgz", + "integrity": "sha512-k6Cy8tGuTxXxhwghUoM43/d/C887WTecBpAYsKt3c7rNbdCLKbVtXqKBpldBSlGyKBrkLhZeA5ZV6NRbwXmZew==", "requires": { "@athenna/ioc": "1.1.3", "@secjs/utils": "1.8.3", + "axios": "0.26.1", "chalk": "4.1.1", + "pino": "7.10.0", + "pino-pretty": "7.6.1", "reflect-metadata": "0.1.13", + "telegraf": "4.7.0", "tscpaths": "0.0.9" } }, @@ -15612,6 +16012,14 @@ "integrity": "sha512-9IK9EadsbHo6jLWIpxpR6pL0sazTXV6+SQv25ZB+F7Bj9mJNaOc4nCRabwd5M/JwmUa8idz6Eci6eKfJryPs6Q==", "dev": true }, + "abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "requires": { + "event-target-shim": "^5.0.0" + } + }, "acorn": { "version": "7.4.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", @@ -15709,7 +16117,6 @@ "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, "requires": { "color-convert": "^1.9.0" } @@ -15745,6 +16152,39 @@ "sprintf-js": "~1.0.2" } }, + "args": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/args/-/args-5.0.1.tgz", + "integrity": "sha512-1kqmFCFsPffavQFGt8OxJdIcETti99kySRUPMpOhaGjL6mRJn8HFU1OxKY5bMqfZKUwTQc1mZkAjmGYaVOHFtQ==", + "requires": { + "camelcase": "5.0.0", + "chalk": "2.4.2", + "leven": "2.1.0", + "mri": "1.1.4" + }, + "dependencies": { + "camelcase": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.0.0.tgz", + "integrity": "sha512-faqwZqnWxbxn+F1d399ygeamQNy3lPp/H9H6rNrqYh4FSVCtcY+3cub1MxA8o9mDd55mM8Aghuu/kuyYA6VTsA==" + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "leven": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/leven/-/leven-2.1.0.tgz", + "integrity": "sha1-wuep93IJTe6dNCAq6KzORoeHVYA=" + } + } + }, "arr-diff": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", @@ -15827,6 +16267,11 @@ "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==" }, + "atomic-sleep": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/atomic-sleep/-/atomic-sleep-1.0.0.tgz", + "integrity": "sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==" + }, "awilix": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/awilix/-/awilix-7.0.0.tgz", @@ -15836,6 +16281,14 @@ "fast-glob": "^3.2.11" } }, + "axios": { + "version": "0.26.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz", + "integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==", + "requires": { + "follow-redirects": "^1.14.8" + } + }, "babel-jest": { "version": "27.5.1", "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-27.5.1.tgz", @@ -16065,6 +16518,25 @@ "ieee754": "^1.1.13" } }, + "buffer-alloc": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/buffer-alloc/-/buffer-alloc-1.2.0.tgz", + "integrity": "sha512-CFsHQgjtW1UChdXgbyJGtnm+O/uLQeZdtbDo8mfUgYXCHSM1wgrVxXm6bSyrUuErEb+4sYVGCzASBRot7zyrow==", + "requires": { + "buffer-alloc-unsafe": "^1.1.0", + "buffer-fill": "^1.0.0" + } + }, + "buffer-alloc-unsafe": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz", + "integrity": "sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg==" + }, + "buffer-fill": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/buffer-fill/-/buffer-fill-1.0.0.tgz", + "integrity": "sha1-+PeLdniYiO858gXNY39o5wISKyw=" + }, "buffer-from": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", @@ -16589,7 +17061,6 @@ "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, "requires": { "color-name": "1.1.3" } @@ -16597,8 +17068,12 @@ "color-name": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", - "dev": true + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, + "colorette": { + "version": "2.0.16", + "resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.16.tgz", + "integrity": "sha512-hUewv7oMjCp+wkBv5Rm0v87eJhq4woh5rSR+42YSQJKecCqgIqNkZ6lAlQms/BwHPJA5NKMRlpxPRv0n8HQW6g==" }, "colors": { "version": "1.0.3", @@ -16921,11 +17396,15 @@ "integrity": "sha512-hBSVCvSmWC+QypYObzwGOd9wqdDpOt+0wl0KbU+R+uuZBS1jN8VsD1ss3irQDknRj5NvxiTF6oj/nDRnN/UQNw==", "dev": true }, + "dateformat": { + "version": "4.6.3", + "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-4.6.3.tgz", + "integrity": "sha512-2P0p0pFGzHS5EMnhdxQi7aJN+iMheud0UhG4dlE1DLAlvL8JHjJJTX/CSm4JXwV0Ka5nGk3zC5mcb5bUQUxxMA==" + }, "debug": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "dev": true, "requires": { "ms": "2.1.2" } @@ -17112,6 +17591,17 @@ } } }, + "duplexify": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-4.1.2.tgz", + "integrity": "sha512-fz3OjcNCHmRP12MJoZMPglx8m4rrFP8rovnk4vT8Fs+aonZoCwGg10dSsQsfP/E62eZcPTMSMP6686fu9Qlqtw==", + "requires": { + "end-of-stream": "^1.4.1", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1", + "stream-shift": "^1.0.0" + } + }, "ejs": { "version": "3.1.6", "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.6.tgz", @@ -17147,7 +17637,6 @@ "version": "1.4.4", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", - "dev": true, "requires": { "once": "^1.4.0" } @@ -17775,6 +18264,11 @@ "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", "dev": true }, + "event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==" + }, "events": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", @@ -18069,6 +18563,16 @@ "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", "dev": true }, + "fast-redact": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/fast-redact/-/fast-redact-3.1.1.tgz", + "integrity": "sha512-odVmjC8x8jNeMZ3C+rPMESzXVSEU8tSWSHv9HFxP2mm89G/1WwqhrerJDQm9Zus8X6aoRgQDThKqptdNA6bt+A==" + }, + "fast-safe-stringify": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz", + "integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==" + }, "fastq": { "version": "1.13.0", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz", @@ -18178,6 +18682,11 @@ "integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==", "dev": true }, + "follow-redirects": { + "version": "1.14.9", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz", + "integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==" + }, "for-in": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", @@ -18445,8 +18954,7 @@ "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" }, "has-symbols": { "version": "1.0.3", @@ -20661,6 +21169,11 @@ } } }, + "joycon": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/joycon/-/joycon-3.1.1.tgz", + "integrity": "sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==" + }, "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -21308,8 +21821,7 @@ "minimist": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", - "dev": true + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" }, "mixin-deep": { "version": "1.3.2", @@ -21320,11 +21832,20 @@ "is-extendable": "^1.0.1" } }, + "module-alias": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/module-alias/-/module-alias-2.2.2.tgz", + "integrity": "sha512-A/78XjoX2EmNvppVWEhM2oGk3x4lLxnkEA4jTbaK97QKSDjkIoOsKQlfylt/d3kKKi596Qy3NP5XrXJ6fZIC9Q==" + }, + "mri": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/mri/-/mri-1.1.4.tgz", + "integrity": "sha512-6y7IjGPm8AzlvoUrwAaw1tLnUBudaS3752vcd8JtrpGGQn+rXIe63LFVHm/YMwtqAuh+LJPCFdlLYPWM1nYn6w==" + }, "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "mute-stream": { "version": "0.0.8", @@ -21384,6 +21905,35 @@ } } }, + "node-fetch": { + "version": "2.6.7", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", + "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", + "requires": { + "whatwg-url": "^5.0.0" + }, + "dependencies": { + "tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=" + }, + "webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=" + }, + "whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=", + "requires": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + } + } + }, "node-int64": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", @@ -21569,6 +22119,11 @@ "es-abstract": "^1.19.1" } }, + "on-exit-leak-free": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/on-exit-leak-free/-/on-exit-leak-free-0.2.0.tgz", + "integrity": "sha512-dqaz3u44QbRXQooZLTUKU41ZrzYrcvLISVgbrzbyCMxpmSLJvZ3ZamIJIZ29P6OhZIkNIQKosdeM6t1LYbA9hg==" + }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -21701,6 +22256,11 @@ "aggregate-error": "^3.0.0" } }, + "p-timeout": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-timeout/-/p-timeout-4.1.0.tgz", + "integrity": "sha512-+/wmHtzJuWii1sXn3HCuH/FTwGhrp4tmJTxSKJbfS+vkipci6osxXM5mY0jUiRzWKMTgUT8l7HFbeSwZAynqHw==" + }, "p-try": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", @@ -21844,6 +22404,65 @@ "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", "dev": true }, + "pino": { + "version": "7.10.0", + "resolved": "https://registry.npmjs.org/pino/-/pino-7.10.0.tgz", + "integrity": "sha512-T6R92jy/APDElEuOk0gqa4nds3ZgqFbHde2X0g8XorlyPlVGlr9T5KQphtp72a3ByKOdZMg/gM/0IprpGQfTWg==", + "requires": { + "atomic-sleep": "^1.0.0", + "fast-redact": "^3.0.0", + "on-exit-leak-free": "^0.2.0", + "pino-abstract-transport": "v0.5.0", + "pino-std-serializers": "^4.0.0", + "process-warning": "^1.0.0", + "quick-format-unescaped": "^4.0.3", + "real-require": "^0.1.0", + "safe-stable-stringify": "^2.1.0", + "sonic-boom": "^2.2.1", + "thread-stream": "^0.15.1" + } + }, + "pino-abstract-transport": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/pino-abstract-transport/-/pino-abstract-transport-0.5.0.tgz", + "integrity": "sha512-+KAgmVeqXYbTtU2FScx1XS3kNyfZ5TrXY07V96QnUSFqo2gAqlvmaxH67Lj7SWazqsMabf+58ctdTcBgnOLUOQ==", + "requires": { + "duplexify": "^4.1.2", + "split2": "^4.0.0" + } + }, + "pino-pretty": { + "version": "7.6.1", + "resolved": "https://registry.npmjs.org/pino-pretty/-/pino-pretty-7.6.1.tgz", + "integrity": "sha512-H7N6ZYkiyrfwBGW9CSjx0uyO9Q2Lyt73881+OTYk8v3TiTdgN92QHrWlEq/LeWw5XtDP64jeSk3mnc6T+xX9/w==", + "requires": { + "args": "^5.0.1", + "colorette": "^2.0.7", + "dateformat": "^4.6.3", + "fast-safe-stringify": "^2.0.7", + "joycon": "^3.1.1", + "on-exit-leak-free": "^0.2.0", + "pino-abstract-transport": "^0.5.0", + "pump": "^3.0.0", + "readable-stream": "^3.6.0", + "rfdc": "^1.3.0", + "secure-json-parse": "^2.4.0", + "sonic-boom": "^2.2.0", + "strip-json-comments": "^3.1.1" + }, + "dependencies": { + "strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==" + } + } + }, + "pino-std-serializers": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/pino-std-serializers/-/pino-std-serializers-4.0.0.tgz", + "integrity": "sha512-cK0pekc1Kjy5w9V2/n+8MkZwusa6EyyxfeQCB799CQRhRt/CqYKiWs5adeu8Shve2ZNffvfC/7J64A2PJo1W/Q==" + }, "pirates": { "version": "4.0.5", "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.5.tgz", @@ -21978,6 +22597,11 @@ } } }, + "process-warning": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/process-warning/-/process-warning-1.0.0.tgz", + "integrity": "sha512-du4wfLyj4yCZq1VupnVSZmRsPJsNuxoDQFdCFHLaYiEbFBD7QE0a+I4D7hOxrVnh78QE/YipFAj9lXHiXocV+Q==" + }, "progress": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", @@ -22004,7 +22628,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", - "dev": true, "requires": { "end-of-stream": "^1.1.0", "once": "^1.3.1" @@ -22021,6 +22644,11 @@ "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==" }, + "quick-format-unescaped": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/quick-format-unescaped/-/quick-format-unescaped-4.0.4.tgz", + "integrity": "sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg==" + }, "randombytes": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", @@ -22099,6 +22727,11 @@ "util-deprecate": "^1.0.1" } }, + "real-require": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/real-require/-/real-require-0.1.0.tgz", + "integrity": "sha512-r/H9MzAWtrv8aSVjPCMFpDMl5q66GqtmmRkRjpHTsp4zBAa+snZyiQNlMONiUmEJcsnaw0wCauJ2GWODr/aFkg==" + }, "reflect-metadata": { "version": "0.1.13", "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.13.tgz", @@ -22218,6 +22851,11 @@ "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==" }, + "rfdc": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.3.0.tgz", + "integrity": "sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA==" + }, "rimraf": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", @@ -22261,6 +22899,14 @@ "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", "dev": true }, + "safe-compare": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/safe-compare/-/safe-compare-1.1.4.tgz", + "integrity": "sha512-b9wZ986HHCo/HbKrRpBJb2kqXMK9CEWIE1egeEvZsYn69ay3kdfl9nG3RyOcR+jInTDf7a86WQ1d4VJX7goSSQ==", + "requires": { + "buffer-alloc": "^1.2.0" + } + }, "safe-regex": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", @@ -22269,11 +22915,21 @@ "ret": "~0.1.10" } }, + "safe-stable-stringify": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.3.1.tgz", + "integrity": "sha512-kYBSfT+troD9cDA85VDnHZ1rpHC50O0g1e6WlGHVCz/g+JS+9WKLj+XwFYyR8UbrZN8ll9HUpDAAddY58MGisg==" + }, "safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, + "sandwich-stream": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/sandwich-stream/-/sandwich-stream-2.0.2.tgz", + "integrity": "sha512-jLYV0DORrzY3xaz/S9ydJL6Iz7essZeAfnAavsJ+zsJGZ1MOnsS52yRjU3uF3pJa/lla7+wisp//fxOwOH8SKQ==" + }, "saxes": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/saxes/-/saxes-5.0.1.tgz", @@ -22295,6 +22951,11 @@ "ajv-keywords": "^3.5.2" } }, + "secure-json-parse": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/secure-json-parse/-/secure-json-parse-2.4.0.tgz", + "integrity": "sha512-Q5Z/97nbON5t/L/sH6mY2EacfjVGwrCcSi5D3btRO2GZ8pf1K1UN7Z9H5J57hjVU2Qzxr1xO+FmBhOvEkzCMmg==" + }, "semver": { "version": "7.3.5", "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", @@ -22573,6 +23234,14 @@ } } }, + "sonic-boom": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-2.7.0.tgz", + "integrity": "sha512-Ynxp0OGQG91wvDjCbFlRMHbSUmDq7dE/EgDeUJ/j+Q9x1FVkFry20cjLykxRSmlm3QS0B4JYAKE8239XKN4SHQ==", + "requires": { + "atomic-sleep": "^1.0.0" + } + }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -22646,6 +23315,11 @@ "extend-shallow": "^3.0.0" } }, + "split2": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/split2/-/split2-4.1.0.tgz", + "integrity": "sha512-VBiJxFkxiXRlUIeyMQi8s4hgvKCSjtknJv/LVYbrgALPwf5zSKmEwV9Lst25AkvMDnvxODugjdl6KZgwKM1WYQ==" + }, "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", @@ -22739,6 +23413,11 @@ } } }, + "stream-shift": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.1.tgz", + "integrity": "sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ==" + }, "string_decoder": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", @@ -22864,7 +23543,6 @@ "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, "requires": { "has-flag": "^3.0.0" } @@ -23005,6 +23683,22 @@ "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==", "dev": true }, + "telegraf": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/telegraf/-/telegraf-4.7.0.tgz", + "integrity": "sha512-rspH4kiVHE1zpnyQvlGFj+Tzu7zN02gSOcdLUayvnkaTwww2E6xBkwne+DKkDPdaRhvQ61J+dcVhLQv9fL+FsQ==", + "requires": { + "abort-controller": "^3.0.0", + "debug": "^4.3.3", + "minimist": "^1.2.5", + "module-alias": "^2.2.2", + "node-fetch": "^2.6.7", + "p-timeout": "^4.1.0", + "safe-compare": "^1.1.4", + "sandwich-stream": "^2.0.2", + "typegram": "^3.8.0" + } + }, "terminal-link": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/terminal-link/-/terminal-link-2.1.1.tgz", @@ -23099,6 +23793,14 @@ "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", "dev": true }, + "thread-stream": { + "version": "0.15.2", + "resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-0.15.2.tgz", + "integrity": "sha512-UkEhKIg2pD+fjkHQKyJO3yoIvAP3N6RlNFt2dUhcS1FGvCD1cQa1M/PGknCLFIyZdtJOWQjejp7bdNqmN7zwdA==", + "requires": { + "real-require": "^0.1.0" + } + }, "throat": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/throat/-/throat-6.0.1.tgz", @@ -23567,6 +24269,11 @@ "is-typedarray": "^1.0.0" } }, + "typegram": { + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/typegram/-/typegram-3.8.0.tgz", + "integrity": "sha512-MdlbWu0HfmgFJf4+xj6eqGYuanV2LJxBYTzLrD0kTV+woQ5dxDD2k8UVVjYnbBGkAagAyxzQevPiFZRWLFHSBw==" + }, "typescript": { "version": "4.3.5", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.5.tgz", diff --git a/package.json b/package.json index 09031cc..3952e5d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@athenna/cli", "version": "1.0.2", - "description": "", + "description": "Athenna CLI to create new projects and install components.", "license": "MIT", "author": "Victor Tesoura Júnior ", "repository": "https://github.com/AthennaIO/Cli.git", @@ -156,10 +156,6 @@ "config/*.d.ts", "config/**/*.js", "config/**/*.d.ts", - "templates/*.js", - "templates/*.d.ts", - "templates/**/*.js", - "templates/**/*.d.ts", "src/*.js", "src/*.d.ts", "src/**/*.js", @@ -173,7 +169,7 @@ } }, "dependencies": { - "@athenna/logger": "1.1.7", + "@athenna/logger": "1.1.8", "@secjs/utils": "1.8.3", "chalk": "4.1.1", "chalk-rainbow": "1.0.0", diff --git a/src/Cli.ts b/src/Cli.ts index e6cc785..bd0804d 100644 --- a/src/Cli.ts +++ b/src/Cli.ts @@ -13,7 +13,6 @@ import chalkRainbow from 'chalk-rainbow' import { resolve } from 'path' import { Command } from 'commander' import { New } from './Commands/New' -import { Make } from './Commands/Make' import { version } from '../package.json' import { Config, Path } from '@secjs/utils' @@ -38,10 +37,9 @@ export class Cli { } async main() { - await new Config().safeLoad(Path.config()) + await new Config().safeLoad(Path.config('logging')) const newCommand = new New(this.clientFolder) - const makeCommand = new Make(this.clientFolder) this.program .command('new') @@ -52,38 +50,6 @@ export class Cli { .showHelpAfterError() .createHelp() - this.program - .command('make:controller') - .argument('', 'Your controller name') - .option( - '-e, --extension ', - 'Current extension available: ts', - 'ts', - ) - .option('--no-lint', 'Do not run eslint in the controller') - .description( - 'Make a new controller file inside app/Http/Controllers directory', - ) - .action(makeCommand.controller.bind(makeCommand)) - .showHelpAfterError() - .createHelp() - - this.program - .command('make:middleware') - .argument('', 'Your middleware name') - .option( - '-e, --extension ', - 'Current extension available: ts', - 'ts', - ) - .option('--no-lint', 'Do not run eslint in the middleware', false) - .description( - 'Make a new middleware file inside app/Http/Middlewares directory', - ) - .action(makeCommand.middleware.bind(makeCommand)) - .showHelpAfterError() - .createHelp() - await this.program.parseAsync(process.argv) } } diff --git a/src/Commands/Make.ts b/src/Commands/Make.ts deleted file mode 100644 index be285bd..0000000 --- a/src/Commands/Make.ts +++ /dev/null @@ -1,167 +0,0 @@ -/** - * @athenna/cli - * - * (c) Victor Tesoura Júnior - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -import ejs from 'ejs' -import chalk from 'chalk' - -import { parse } from 'path' -import { existsSync } from 'fs' -import { Logger } from '@athenna/logger' -import { runCommand } from '../Utils/runCommand' -import { File, Folder, Path, String } from '@secjs/utils' - -export class Make { - private readonly logger: Logger - private readonly clientFolder: string - private readonly templatesFolder: Folder - - public constructor(clientFolder: string) { - this.clientFolder = clientFolder - - this.logger = new Logger() - - this.templatesFolder = new Folder(Path.pwd('templates')).loadSync() - } - - async controller(name: string, options: any): Promise { - console.log(chalk.bold.green('[ MAKING CONTROLLER ]\n')) - - if (name.includes('Controller') || name.includes('Controllers')) { - name = name.split('Controller')[0] - } - - const template = this.getTemplate('__name__Controller', options) - - if (!template) { - this.logger.error( - `Template for extension ({yellow} "${options.extension}") has not been found.`, - ) - - return - } - - // TODO Resolve the path always looking to his project root - // TODO Maybe find for the package.json file in getConcretePath - const normalizedName = this.normalizeName(name, template.base) - const path = this.getConcretePath(`app/Http/Controllers/${normalizedName}`) - const content = this.normalizeTemplate(name, template.getContentSync()) - - if (existsSync(path)) { - this.logger.error( - `The controller ({yellow} "${ - parse(path).name - }") already exists. Try using another name.`, - ) - - return - } - - const controller = await new File(path, content).create() - - this.logger.success( - `Controller ({yellow} "${controller.name}") successfully created.`, - ) - - if (options.lint) { - await this.runEslintOnFile('Controller', controller.path) - } - } - - // TODO Add middleware to namedMiddlewares object of HttpKernel - async middleware(name: string, options: any): Promise { - console.log(chalk.bold.green('[ MAKING MIDDLEWARE ]\n')) - - if (name.includes('Middleware') || name.includes('Middlewares')) { - name = name.split('Middleware')[0] - } - - const template = this.getTemplate('__name__Middleware', options) - - if (!template) { - this.logger.error( - `Template for extension ({yellow} "${options.extension}") has not been found.`, - ) - - return - } - - // TODO Resolve the path always looking to his project root - // TODO Maybe find for the package.json file in getConcretePath - const normalizedName = this.normalizeName(name, template.base) - const path = this.getConcretePath(`app/Http/Middlewares/${normalizedName}`) - const content = this.normalizeTemplate(name, template.getContentSync()) - - if (existsSync(path)) { - this.logger.error( - `The middleware ({yellow} "${ - parse(path).name - }") already exists. Try using another name.`, - ) - - return - } - - const middleware = await new File(path, content).create() - - this.logger.success( - `Middleware ({yellow} "${middleware.name}") successfully created.`, - ) - - if (options.lint) { - await this.runEslintOnFile('Middleware', middleware.path) - } - } - - private async runEslintOnFile(resource: string, filePath: string) { - const { name } = parse(filePath) - - try { - await runCommand(`npm run eslint ${filePath} -- --fix --quiet`) - this.logger.success( - `${resource} ({yellow} "${name}") successfully linted.`, - ) - } catch (error) { - this.logger.error( - `Failed to lint ${resource} ({yellow} "${name}"). Please check your eslint configurations.`, - ) - } - } - - private getTemplate(templateName: string, options: any): File { - templateName = `${templateName}.${options.extension}.ejs` - - return this.templatesFolder.files.find(f => f.base === templateName) as File - } - - private getConcretePath(normalizedPath: string) { - return `${this.clientFolder}/${normalizedPath}` - } - - private normalizeName(name: string, baseTemplateName: string): string { - return baseTemplateName - .replace('.ejs', '') - .replace('__name__', name) - .replace('__name_low__', name.toLowerCase()) - .replace('__name_plural__', String.pluralize(name)) - .replace('__name_plural_low__', String.pluralize(name).toLowerCase()) - } - - private normalizeTemplate(name: string, templateContent: Buffer): Buffer { - const templateString = ejs.render(templateContent.toString(), { - nameUp: name.toUpperCase(), - nameCamel: String.toCamelCase(name), - namePlural: String.pluralize(name), - namePascal: String.toPascalCase(name), - namePluralCamel: String.toCamelCase(String.pluralize(name)), - namePluralPascal: String.toPascalCase(String.pluralize(name)), - }) - - return Buffer.from(templateString) - } -} diff --git a/templates/__name__Controller.ts.ejs b/templates/__name__Controller.ts.ejs deleted file mode 100644 index d13ddb6..0000000 --- a/templates/__name__Controller.ts.ejs +++ /dev/null @@ -1,62 +0,0 @@ -import { ContextContract } from '@athenna/http' -import { Container } from 'providers/Container' - -export class <%= namePascal %>Controller { - /** - * Use the constructor to resolve any dependency of the Ioc container - * - * @param container - * @return <%= namePascal %>Controller - */ - public constructor(_container: Container) {} - - /** - * Index method - * - * @param ctx: ContextContract - * @return any[] - */ - async index({ response }: ContextContract) { - return response.status(200).send([{}]) - } - - /** - * Store method - * - * @param ctx: ContextContract - * @return any - */ - async store({ response }: ContextContract) { - return response.status(201).send({}) - } - - /** - * Show method - * - * @param ctx: ContextContract - * @return any - */ - async show({ response }: ContextContract) { - return response.status(200).send({}) - } - - /** - * Update method - * - * @param ctx: ContextContract - * @return any - */ - async update({ response, params }: ContextContract) { - return response.status(200).send({ id: params.id }) - } - - /** - * Delete method - * - * @param ctx: ContextContract - * @return void - */ - async delete({ response }: ContextContract) { - return response.status(204) - } -} diff --git a/templates/__name__Middleware.ts.ejs b/templates/__name__Middleware.ts.ejs deleted file mode 100644 index e1952ae..0000000 --- a/templates/__name__Middleware.ts.ejs +++ /dev/null @@ -1,50 +0,0 @@ -import { - HandleContextContract, - InterceptContextContract, - TerminateContextContract, - MiddlewareContract, -} from '@athenna/http' - -import { Container } from 'providers/Container' - -export class <%= namePascal %>Middleware implements MiddlewareContract { - /** - * Use the constructor to resolve any dependency of the Ioc container - * - * @param container - * @return <%= namePascal %>Middleware - */ - public constructor(_container: Container) {} - - /** - * Handle method is executed before the request gets in your controller. - * - * @param ctx - * @return any - */ - async handle({ next }: HandleContextContract) { - next() - } - - /** - * Intercept method is executed before the response has been sent. - * - * @param ctx - * @return any - */ - async intercept({ body }: InterceptContextContract) { - body.intercepted = true - - return body - } - - /** - * Terminate method is executed after the response has been sent. - * - * @param ctx - * @return any - */ - async terminate({ next }: TerminateContextContract) { - next() - } -} diff --git a/templates/__name__Provider.ts.ejs b/templates/__name__Provider.ts.ejs deleted file mode 100644 index 039068a..0000000 --- a/templates/__name__Provider.ts.ejs +++ /dev/null @@ -1,32 +0,0 @@ -import { ServiceProvider } from '@athenna/ioc' - -export class <%= namePascal %>Provider extends ServiceProvider { - /** - * All the container bindings that should be registered. - */ - public bindings = {} - - /** - * All the container instances that should be registered. - */ - public instances = {} - - /** - * All the container singletons that should be registered. - */ - public singletons = {} - - /** - * Register any application services. - * - * @return void - */ - public register() {} - - /** - * Bootstrap any application services. - * - * @return void - */ - public boot() {} -} diff --git a/templates/__name__Service.ts.ejs b/templates/__name__Service.ts.ejs deleted file mode 100644 index e3db122..0000000 --- a/templates/__name__Service.ts.ejs +++ /dev/null @@ -1,11 +0,0 @@ -import { Container } from 'providers/Container' - -export class <%= namePascal %>Service { - /** - * Use the constructor to resolve any dependency of the Ioc container - * - * @param _container - * @return <%= namePascal %>Service - */ - public constructor(_container: Container) {} -} diff --git a/tests/Unit/Commands/MakeTest.ts b/tests/Unit/Commands/MakeTest.ts deleted file mode 100644 index b9b0129..0000000 --- a/tests/Unit/Commands/MakeTest.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @athenna/cli - * - * (c) Victor Tesoura Júnior - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -import { existsSync } from 'fs' -import { Config, Folder, Path } from '@secjs/utils' -import { Make } from '../../../src/Commands/Make' - -describe('\n MakeTest', () => { - beforeAll(async () => { - await new Config().safeLoad(Path.config('logging')) - }) - - it('should be able to create a controller file', async () => { - await new Make(Path.storage()).controller('TestControllers', { extension: 'ts' }) - - expect(existsSync(Path.storage('app/Http/Controllers/TestController.ts'))).toBeTruthy() - }, 60000) - - it('should be able to create a middleware file', async () => { - await new Make(Path.storage()).middleware('TestMiddlewares', { extension: 'ts' }) - - expect(existsSync(Path.storage('app/Http/Middlewares/TestMiddleware.ts'))).toBeTruthy() - }, 60000) - - afterEach(async () => { - await Folder.safeRemove('storage/app') - }) -}) diff --git a/tests/Unit/Commands/NewTest.ts b/tests/Unit/Commands/NewTest.ts index 700040e..f3408ac 100644 --- a/tests/Unit/Commands/NewTest.ts +++ b/tests/Unit/Commands/NewTest.ts @@ -8,8 +8,8 @@ */ import { existsSync } from 'fs' +import { New } from 'src/Commands/New' import { Config, Folder, Path } from '@secjs/utils' -import { New } from '../../../src/Commands/New' describe('\n NewTest', () => { beforeAll(async () => { From a45ed40a8a542753e950cf904552ae6103fe476a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Lenon?= Date: Tue, 19 Apr 2022 20:34:46 -0300 Subject: [PATCH 19/19] chore: remove eslint script --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 3952e5d..ec74bff 100644 --- a/package.json +++ b/package.json @@ -12,8 +12,7 @@ "build": "tsc --project tsconfig.json && tscpaths -p tsconfig.json -s . -o .", "test": "npm run lint:fix && cross-env NODE_TS=true cross-env NODE_ENV=testing jest --verbose", "test:debug": "npm run lint:fix && cross-env NODE_TS=true cross-env NODE_ENV=testing cross-env DEBUG=api:* jest --verbose", - "eslint": "eslint", - "lint:fix": "npm run eslint \"{src,tests}/**/!(*.d)*.ts\" --fix" + "lint:fix": "eslint \"{src,tests}/**/!(*.d)*.ts\" --fix" }, "keywords": [ "nodejs",