From 5ffc64e64bea4062df94746eee9e6deb59e92fe4 Mon Sep 17 00:00:00 2001 From: jlenon7 Date: Sun, 10 Dec 2023 11:53:11 +0000 Subject: [PATCH] feat(path): add models method --- package.json | 2 +- src/helpers/Path.ts | 17 +++++++++++++++++ src/types/PathDirs.ts | 1 + tests/unit/PathTest.ts | 3 +++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 60289fb..1a60aa9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@athenna/common", - "version": "4.21.0", + "version": "4.22.0", "description": "The Athenna common helpers to use in any Node.js ESM project.", "license": "MIT", "author": "João Lenon ", diff --git a/src/helpers/Path.ts b/src/helpers/Path.ts index fe329da..746ae2d 100644 --- a/src/helpers/Path.ts +++ b/src/helpers/Path.ts @@ -19,6 +19,7 @@ export class Path { bin: 'bin', src: 'src', app: 'app', + models: 'app/models', services: 'app/services', exceptions: 'app/exceptions', repositories: 'app/repositories', @@ -526,6 +527,22 @@ export class Path { return this } + /** + * Return the models' path of your project. + */ + public static models(subPath: string = sep): string { + return this.pwd(this.dirs.models + sep + normalize(subPath)) + } + + /** + * Set the directory of models folder. + */ + public static setModels(directory: string): typeof Path { + this.dirs.models = directory + + return this + } + /** * Return the services' path of your project. */ diff --git a/src/types/PathDirs.ts b/src/types/PathDirs.ts index ad0a739..df4a94d 100644 --- a/src/types/PathDirs.ts +++ b/src/types/PathDirs.ts @@ -11,6 +11,7 @@ export interface PathDirs { bin?: string src?: string app?: string + models?: string services?: string exceptions?: string repositories?: string diff --git a/tests/unit/PathTest.ts b/tests/unit/PathTest.ts index 2e8d86f..334ccf0 100644 --- a/tests/unit/PathTest.ts +++ b/tests/unit/PathTest.ts @@ -75,6 +75,7 @@ export default class PathTest { assert.equal(Path.http(), mainPath.concat(sep, 'http')) assert.equal(Path.console(), mainPath.concat(sep, 'console')) + assert.equal(Path.models(), mainPath.concat(sep, 'models')) assert.equal(Path.services(), mainPath.concat(sep, 'services')) assert.equal(Path.exceptions(), mainPath.concat(sep, 'exceptions')) assert.equal(Path.repositories(), mainPath.concat(sep, 'repositories')) @@ -154,6 +155,7 @@ export default class PathTest { Path.setBin('build/bin') .setSrc('build/src') .setApp('build/app') + .setModels('build/app/models') .setServices('build/app/services') .setExceptions('build/app/exceptions') .setRepositories('build/app/repositories') @@ -190,6 +192,7 @@ export default class PathTest { assert.isTrue(Path.bin().endsWith(`build${sep}bin`)) assert.isTrue(Path.src().endsWith(`build${sep}src`)) assert.isTrue(Path.app().endsWith(`build${sep}app`)) + assert.isTrue(Path.models().endsWith(`build${sep}app${sep}models`)) assert.isTrue(Path.services().endsWith(`build${sep}app${sep}services`)) assert.isTrue(Path.exceptions().endsWith(`build${sep}app${sep}exceptions`)) assert.isTrue(Path.repositories().endsWith(`build${sep}app${sep}repositories`))