Skip to content

Commit

Permalink
Merge pull request #160 from AthennaIO/develop
Browse files Browse the repository at this point in the history
chore(npm): update dependencies
  • Loading branch information
jlenon7 authored Jan 15, 2024
2 parents e7119f0 + 8f9f70e commit 34b3522
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 160 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@athenna/http",
"version": "4.17.0",
"version": "4.18.0",
"description": "The Athenna Http server. Built on top of fastify.",
"license": "MIT",
"author": "João Lenon <[email protected]>",
Expand Down Expand Up @@ -72,7 +72,7 @@
"#tests": "./tests/index.js"
},
"devDependencies": {
"@athenna/artisan": "^4.28.0",
"@athenna/artisan": "^4.30.0",
"@athenna/common": "^4.27.0",
"@athenna/config": "^4.12.0",
"@athenna/ioc": "^4.13.0",
Expand Down
46 changes: 8 additions & 38 deletions src/commands/MakeControllerCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
*/

import { Path } from '@athenna/common'
import { sep, resolve, isAbsolute } from 'node:path'
import { BaseCommand, Argument } from '@athenna/artisan'

export class MakeControllerCommand extends BaseCommand {
Expand All @@ -28,8 +27,14 @@ export class MakeControllerCommand extends BaseCommand {
public async handle(): Promise<void> {
this.logger.simple('({bold,green} [ MAKING CONTROLLER ])\n')

const destination = Config.get(
'rc.commands.make:controller.destination',
Path.controllers()
)

const file = await this.generator
.path(this.getFilePath())
.fileName(this.name)
.destination(destination)
.template('controller')
.setNameProperties(true)
.make()
Expand All @@ -38,47 +43,12 @@ export class MakeControllerCommand extends BaseCommand {
`Controller ({yellow} "${file.name}") successfully created.`
)

const importPath = this.getImportPath(file.name)
const importPath = this.generator.getImportPath()

await this.rc.pushTo('controllers', importPath).save()

this.logger.success(
`Athenna RC updated: ({dim,yellow} [ controllers += "${importPath}" ])`
)
}

/**
* Get the file path where it will be generated.
*/
private getFilePath(): string {
return this.getDestinationPath().concat(`${sep}${this.name}.${Path.ext()}`)
}

/**
* Get the destination path for the file that will be generated.
*/
private getDestinationPath(): string {
let destination = Config.get(
'rc.commands.make:controller.destination',
Path.controllers()
)

if (!isAbsolute(destination)) {
destination = resolve(Path.pwd(), destination)
}

return destination
}

/**
* Get the import path that should be registered in RC file.
*/
private getImportPath(fileName: string): string {
const destination = this.getDestinationPath()

return `${destination
.replace(Path.pwd(), '')
.replace(/\\/g, '/')
.replace('/', '#')}/${fileName}`
}
}
46 changes: 8 additions & 38 deletions src/commands/MakeInterceptorCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
*/

import { Path } from '@athenna/common'
import { sep, resolve, isAbsolute } from 'node:path'
import { BaseCommand, Argument } from '@athenna/artisan'

export class MakeInterceptorCommand extends BaseCommand {
Expand All @@ -28,8 +27,14 @@ export class MakeInterceptorCommand extends BaseCommand {
public async handle(): Promise<void> {
this.logger.simple('({bold,green} [ MAKING INTERCEPTOR ])\n')

const destination = Config.get(
'rc.commands.make:interceptor.destination',
Path.interceptors()
)

const file = await this.generator
.path(this.getFilePath())
.fileName(this.name)
.destination(destination)
.template('interceptor')
.setNameProperties(true)
.make()
Expand All @@ -38,47 +43,12 @@ export class MakeInterceptorCommand extends BaseCommand {
`Interceptor ({yellow} "${file.name}") successfully created.`
)

const importPath = this.getImportPath(file.name)
const importPath = this.generator.getImportPath()

await this.rc.pushTo('middlewares', importPath).save()

this.logger.success(
`Athenna RC updated: ({dim,yellow} [ middlewares += "${importPath}" ])`
)
}

/**
* Get the file path where it will be generated.
*/
private getFilePath(): string {
return this.getDestinationPath().concat(`${sep}${this.name}.${Path.ext()}`)
}

/**
* Get the destination path for the file that will be generated.
*/
private getDestinationPath(): string {
let destination = Config.get(
'rc.commands.make:interceptor.destination',
Path.interceptors()
)

if (!isAbsolute(destination)) {
destination = resolve(Path.pwd(), destination)
}

return destination
}

/**
* Get the import path that should be registered in RC file.
*/
private getImportPath(fileName: string): string {
const destination = this.getDestinationPath()

return `${destination
.replace(Path.pwd(), '')
.replace(/\\/g, '/')
.replace('/', '#')}/${fileName}`
}
}
46 changes: 8 additions & 38 deletions src/commands/MakeMiddlewareCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
*/

import { Path } from '@athenna/common'
import { sep, resolve, isAbsolute } from 'node:path'
import { BaseCommand, Argument } from '@athenna/artisan'

export class MakeMiddlewareCommand extends BaseCommand {
Expand All @@ -28,8 +27,14 @@ export class MakeMiddlewareCommand extends BaseCommand {
public async handle(): Promise<void> {
this.logger.simple('({bold,green} [ MAKING MIDDLEWARE ])\n')

const destination = Config.get(
'rc.commands.make:middleware.destination',
Path.middlewares()
)

const file = await this.generator
.path(this.getFilePath())
.fileName(this.name)
.destination(destination)
.template('middleware')
.setNameProperties(true)
.make()
Expand All @@ -38,47 +43,12 @@ export class MakeMiddlewareCommand extends BaseCommand {
`Middleware ({yellow} "${file.name}") successfully created.`
)

const importPath = this.getImportPath(file.name)
const importPath = this.generator.getImportPath()

await this.rc.pushTo('middlewares', importPath).save()

this.logger.success(
`Athenna RC updated: ({dim,yellow} [ middlewares += "${importPath}" ])`
)
}

/**
* Get the file path where it will be generated.
*/
private getFilePath(): string {
return this.getDestinationPath().concat(`${sep}${this.name}.${Path.ext()}`)
}

/**
* Get the destination path for the file that will be generated.
*/
private getDestinationPath(): string {
let destination = Config.get(
'rc.commands.make:middleware.destination',
Path.middlewares()
)

if (!isAbsolute(destination)) {
destination = resolve(Path.pwd(), destination)
}

return destination
}

/**
* Get the import path that should be registered in RC file.
*/
private getImportPath(fileName: string): string {
const destination = this.getDestinationPath()

return `${destination
.replace(Path.pwd(), '')
.replace(/\\/g, '/')
.replace('/', '#')}/${fileName}`
}
}
46 changes: 8 additions & 38 deletions src/commands/MakeTerminatorCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
*/

import { Path } from '@athenna/common'
import { sep, resolve, isAbsolute } from 'node:path'
import { BaseCommand, Argument } from '@athenna/artisan'

export class MakeTerminatorCommand extends BaseCommand {
Expand All @@ -28,8 +27,14 @@ export class MakeTerminatorCommand extends BaseCommand {
public async handle(): Promise<void> {
this.logger.simple('({bold,green} [ MAKING TERMINATOR ])\n')

const destination = Config.get(
'rc.commands.make:terminator.destination',
Path.terminators()
)

const file = await this.generator
.path(this.getFilePath())
.fileName(this.name)
.destination(destination)
.template('terminator')
.setNameProperties(true)
.make()
Expand All @@ -38,47 +43,12 @@ export class MakeTerminatorCommand extends BaseCommand {
`Terminator ({yellow} "${file.name}") successfully created.`
)

const importPath = this.getImportPath(file.name)
const importPath = this.generator.getImportPath()

await this.rc.pushTo('middlewares', importPath).save()

this.logger.success(
`Athenna RC updated: ({dim,yellow} [ middlewares += "${importPath}" ])`
)
}

/**
* Get the file path where it will be generated.
*/
private getFilePath(): string {
return this.getDestinationPath().concat(`${sep}${this.name}.${Path.ext()}`)
}

/**
* Get the destination path for the file that will be generated.
*/
private getDestinationPath(): string {
let destination = Config.get(
'rc.commands.make:terminator.destination',
Path.terminators()
)

if (!isAbsolute(destination)) {
destination = resolve(Path.pwd(), destination)
}

return destination
}

/**
* Get the import path that should be registered in RC file.
*/
private getImportPath(fileName: string): string {
const destination = this.getDestinationPath()

return `${destination
.replace(Path.pwd(), '')
.replace(/\\/g, '/')
.replace('/', '#')}/${fileName}`
}
}

0 comments on commit 34b3522

Please sign in to comment.