diff --git a/package-lock.json b/package-lock.json index 5717386..6274702 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@athenna/common", - "version": "4.46.0", + "version": "5.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@athenna/common", - "version": "4.46.0", + "version": "5.0.0", "license": "MIT", "dependencies": { "@fastify/formbody": "^7.4.0", @@ -37,8 +37,8 @@ "youch-terminal": "^2.2.3" }, "devDependencies": { - "@athenna/test": "^4.29.0", - "@athenna/tsconfig": "^4.19.0", + "@athenna/test": "^4.30.0", + "@athenna/tsconfig": "^5.0.0", "@types/bytes": "^3.1.4", "@types/callsite": "^1.0.34", "@types/debug": "^4.1.12", @@ -99,9 +99,9 @@ "license": "MIT" }, "node_modules/@athenna/test": { - "version": "4.29.0", - "resolved": "https://registry.npmjs.org/@athenna/test/-/test-4.29.0.tgz", - "integrity": "sha512-dO9/9/OazVGKSeX8zEQOVfFSSNAukReDCiqeWlHseoWDhSicEuZKKSRS7vXky1VneQ6EaTubECzXOsulufZD3g==", + "version": "4.30.0", + "resolved": "https://registry.npmjs.org/@athenna/test/-/test-4.30.0.tgz", + "integrity": "sha512-PyvvDXUf3ZsHpBxhwqA5OBUv8JCTOFtAIxmBJZwYPJEMnf4RndlhkjdKfJ/1anE9yoazqm5iJ4G4IvAp4dZF3g==", "dev": true, "license": "MIT", "dependencies": { @@ -116,9 +116,9 @@ } }, "node_modules/@athenna/tsconfig": { - "version": "4.19.0", - "resolved": "https://registry.npmjs.org/@athenna/tsconfig/-/tsconfig-4.19.0.tgz", - "integrity": "sha512-BpbbnXyMXDHS2DMCUDHWOjFYvzHOe3CJQM+OmQ7MFTS8UXIBaavDd0160aoLCrJLk5IPuCytO1VastQ+h2xRUg==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@athenna/tsconfig/-/tsconfig-5.0.0.tgz", + "integrity": "sha512-GolYan7ILYA5/GDVriEAbz6E100epGh68Gy1ZbPven4VrfrBsf3Zqfl3qsjcqJvks5shEFko8N/xL4sGO2qMjA==", "dev": true, "license": "MIT", "dependencies": { @@ -1144,9 +1144,9 @@ "license": "MIT" }, "node_modules/@types/chai": { - "version": "4.3.17", - "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.17.tgz", - "integrity": "sha512-zmZ21EWzR71B4Sscphjief5djsLre50M6lI622OSySTmn9DB3j+C3kWroHfBQWXbOBwbgg/M8CG/hUxDLIloow==", + "version": "4.3.18", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.18.tgz", + "integrity": "sha512-2UfJzigyNa8kYTKn7o4hNMPphkxtu4WTJyobK3m4FBpyj7EK5xgtPcOtxLm7Dznk/Qxr0QXn+gQbkg7mCZKdfg==", "dev": true, "license": "MIT" }, diff --git a/package.json b/package.json index c794fcf..076f65a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@athenna/common", - "version": "4.46.0", + "version": "5.0.0", "description": "The Athenna common helpers to use in any Node.js ESM project.", "license": "MIT", "author": "João Lenon ", @@ -82,8 +82,8 @@ "youch-terminal": "^2.2.3" }, "devDependencies": { - "@athenna/test": "^4.29.0", - "@athenna/tsconfig": "^4.19.0", + "@athenna/test": "^4.30.0", + "@athenna/tsconfig": "^5.0.0", "@types/bytes": "^3.1.4", "@types/callsite": "^1.0.34", "@types/debug": "^4.1.12", diff --git a/src/helpers/Color.ts b/src/helpers/Color.ts index 4b88852..6b3785a 100644 --- a/src/helpers/Color.ts +++ b/src/helpers/Color.ts @@ -273,13 +273,13 @@ export class Color { * * @example * ```ts - * const message = Color.apply('The file ({yellow, bold} "app/services/Service") has been created.') + * const message = Color.apply('The file ({yellow, bold} "src/services/Service") has been created.') * * console.log(message) * ``` * Output: * ```bash - * The file "app/services/Service" has been created. + * The file "src/services/Service" has been created. * ``` */ public static apply(...args: string[]): string { diff --git a/src/helpers/Path.ts b/src/helpers/Path.ts index 329cab1..dd83d4e 100644 --- a/src/helpers/Path.ts +++ b/src/helpers/Path.ts @@ -19,42 +19,42 @@ export class Path { bin: 'bin', src: 'src', app: 'app', - models: 'app/models', - services: 'app/services', - jobs: 'app/jobs', - workers: 'app/workers', - exceptions: 'app/exceptions', - repositories: 'app/repositories', - console: 'app/console', - commands: 'app/console/commands', - http: 'app/http', - guards: 'app/http/guards', - controllers: 'app/http/controllers', - middlewares: 'app/http/middlewares', - interceptors: 'app/http/interceptors', - terminators: 'app/http/terminators', - validators: 'app/validators', - cron: 'app/cron', - schedulers: 'app/cron/schedulers', + models: 'src/models', + services: 'src/services', + jobs: 'src/jobs', + workers: 'src/workers', + exceptions: 'src/exceptions', + repositories: 'src/repositories', + console: 'src/console', + commands: 'src/console/commands', + http: 'src/http', + guards: 'src/http/guards', + controllers: 'src/http/controllers', + middlewares: 'src/http/middlewares', + interceptors: 'src/http/interceptors', + terminators: 'src/http/terminators', + validators: 'src/validators', + cron: 'src/cron', + schedulers: 'src/cron/schedulers', bootstrap: 'bootstrap', - config: 'config', - database: 'database', - seeders: 'database/seeders', - migrations: 'database/migrations', - lang: 'lang', - resources: 'resources', - views: 'resources/views', - locales: 'resources/locales', + config: 'src/config', + database: 'src/database', + seeders: 'src/database/seeders', + migrations: 'src/database/migrations', + lang: 'src/lang', + resources: 'src/resources', + views: 'src/resources/views', + locales: 'src/resources/locales', nodeModules: 'node_modules', nodeModulesBin: 'node_modules/.bin', - providers: 'providers', - facades: 'providers/facades', + providers: 'src/providers', + facades: 'src/facades', public: 'public', static: 'public/static', assets: 'public/assets', - routes: 'routes', - storage: 'storage', - logs: 'storage/logs', + routes: 'src/routes', + storage: 'src/storage', + logs: 'src/storage/logs', tests: 'tests', stubs: 'tests/stubs', fixtures: 'tests/fixtures' diff --git a/tests/unit/PathTest.ts b/tests/unit/PathTest.ts index c09a9d7..8f8642d 100644 --- a/tests/unit/PathTest.ts +++ b/tests/unit/PathTest.ts @@ -49,18 +49,12 @@ export default class PathTest { public async shouldGetTheMainApplicationPaths({ assert }: Context) { const mainPath = process.cwd() - assert.equal(Path.app(), mainPath.concat(sep, 'app')) + assert.equal(Path.bin(), mainPath.concat(sep, 'bin')) assert.equal(Path.src(), mainPath.concat(sep, 'src')) + assert.equal(Path.app(), mainPath.concat(sep, 'app')) assert.equal(Path.bootstrap(), mainPath.concat(sep, 'bootstrap')) - assert.equal(Path.config(), mainPath.concat(sep, 'config')) - assert.equal(Path.database(), mainPath.concat(sep, 'database')) - assert.equal(Path.lang(), mainPath.concat(sep, 'lang')) assert.equal(Path.nodeModules(), mainPath.concat(sep, 'node_modules')) - assert.equal(Path.providers(), mainPath.concat(sep, 'providers')) assert.equal(Path.public(), mainPath.concat(sep, 'public')) - assert.equal(Path.resources(), mainPath.concat(sep, 'resources')) - assert.equal(Path.routes(), mainPath.concat(sep, 'routes')) - assert.equal(Path.storage(), mainPath.concat(sep, 'storage')) assert.equal(Path.tests(), mainPath.concat(sep, 'tests')) assert.isDefined(Path.vmTmp()) assert.isDefined(Path.vmHome()) @@ -70,8 +64,8 @@ export default class PathTest { } @Test() - public async shouldGetTheSubPathsOfAppMainPath({ assert }: Context) { - const mainPath = process.cwd().concat(sep, 'app') + public async shouldGetTheSubPathsOfSrcMainPath({ assert }: Context) { + const mainPath = process.cwd().concat(sep, 'src') assert.equal(Path.http(), mainPath.concat(sep, 'http')) assert.equal(Path.cron(), mainPath.concat(sep, 'cron')) @@ -87,7 +81,7 @@ export default class PathTest { @Test() public async shouldGetTheSubPathsOfHttpMainPath({ assert }: Context) { - const mainPath = process.cwd().concat(sep, 'app', sep, 'http') + const mainPath = process.cwd().concat(sep, 'src', sep, 'http') assert.equal(Path.controllers(), mainPath.concat(sep, 'controllers')) assert.equal(Path.middlewares(), mainPath.concat(sep, 'middlewares')) @@ -97,21 +91,21 @@ export default class PathTest { @Test() public async shouldGetTheSubPathsOfConsoleMainPath({ assert }: Context) { - const mainPath = process.cwd().concat(sep, 'app', sep, 'console') + const mainPath = process.cwd().concat(sep, 'src', sep, 'console') assert.equal(Path.commands(), mainPath.concat(sep, 'commands')) } @Test() public async shouldGetTheSubPathsOfCronMainPath({ assert }: Context) { - const mainPath = process.cwd().concat(sep, 'app', sep, 'cron') + const mainPath = process.cwd().concat(sep, 'src', sep, 'cron') assert.equal(Path.schedulers(), mainPath.concat(sep, 'schedulers')) } @Test() public async shouldGetTheSubPathsOfDatabaseMainPath({ assert }: Context) { - const mainPath = process.cwd().concat(sep, 'database') + const mainPath = process.cwd().concat(sep, 'src', sep, 'database') assert.equal(Path.seeders(), mainPath.concat(sep, 'seeders')) assert.equal(Path.migrations(), mainPath.concat(sep, 'migrations')) @@ -141,67 +135,60 @@ export default class PathTest { @Test() public async shouldGetTheSubPathsOfStorageMainPath({ assert }: Context) { - const mainPath = process.cwd().concat(sep, 'storage') + const mainPath = process.cwd().concat(sep, 'src', sep, 'storage') assert.equal(Path.logs(), mainPath.concat(sep, 'logs')) } @Test() public async shouldGetTheSubPathsOfResourcesMainPath({ assert }: Context) { - const mainPath = process.cwd().concat(sep, 'resources') + const mainPath = process.cwd().concat(sep, 'src', sep, 'resources') assert.equal(Path.views(), mainPath.concat(sep, 'views')) assert.equal(Path.locales(), mainPath.concat(sep, 'locales')) } - @Test() - public async shouldGetTheSubPathsOfProvidersMainPath({ assert }: Context) { - const mainPath = process.cwd().concat(sep, 'providers') - - assert.equal(Path.facades(), mainPath.concat(sep, 'facades')) - } - @Test() public async shouldBeAbleToSetupDifferentPathsForAllMethodsOfPathClass({ assert }: Context) { Path.setBin('build/bin') .setSrc('build/src') .setApp('build/app') - .setModels('build/app/models') - .setServices('build/app/services') - .setJobs('build/app/jobs') - .setWorkers('build/app/workers') - .setValidators('build/app/validators') - .setExceptions('build/app/exceptions') - .setRepositories('build/app/repositories') - .setConsole('build/app/console') - .setCommands('build/app/console/commands') - .setHttp('build/app/http') - .setGuards('build/app/http/guards') - .setControllers('build/app/http/controllers') - .setMiddlewares('build/app/http/middlewares') - .setInterceptors('build/app/http/interceptors') - .setTerminators('build/app/http/terminators') - .setCron('build/app/cron') - .setSchedulers('/build/app/cron/schedulers') + .setModels('build/src/models') + .setServices('build/src/services') + .setJobs('build/src/jobs') + .setWorkers('build/src/workers') + .setValidators('build/src/validators') + .setExceptions('build/src/exceptions') + .setRepositories('build/src/repositories') + .setConsole('build/src/console') + .setCommands('build/src/console/commands') + .setHttp('build/src/http') + .setGuards('build/src/http/guards') + .setControllers('build/src/http/controllers') + .setMiddlewares('build/src/http/middlewares') + .setInterceptors('build/src/http/interceptors') + .setTerminators('build/src/http/terminators') + .setCron('build/src/cron') + .setSchedulers('/build/src/cron/schedulers') .setBootstrap('build/bootstrap') - .setConfig('build/config') - .setDatabase('build/database') - .setSeeders('build/database/seeders') - .setMigrations('build/database/migrations') - .setLang('build/lang') - .setResources('build/resources') - .setViews('build/resources/views') - .setLocales('build/resources/locales') + .setConfig('build/src/config') + .setDatabase('build/src/database') + .setSeeders('build/src/database/seeders') + .setMigrations('build/src/database/migrations') + .setLang('build/src/lang') + .setResources('build/src/resources') + .setViews('build/src/resources/views') + .setLocales('build/src/resources/locales') .setNodeModules('build/node_modules') .setNodeModulesBin('build/node_modules/.bin') - .setProviders('build/providers') - .setFacades('build/providers/facades') + .setProviders('build/src/providers') + .setFacades('build/src/facades') .setPublic('build/public') .setStatic('build/public/static') .setAssets('build/public/assets') - .setRoutes('build/routes') - .setStorage('build/storage') - .setLogs('build/storage/logs') + .setRoutes('build/src/routes') + .setStorage('build/src/storage') + .setLogs('build/src/storage/logs') .setTests('build/tests') .setStubs('build/tests/stubs') .setFixtures('build/tests/fixtures') @@ -209,41 +196,41 @@ 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.jobs().endsWith(`build${sep}app${sep}jobs`)) - assert.isTrue(Path.workers().endsWith(`build${sep}app${sep}workers`)) - assert.isTrue(Path.validators().endsWith(`build${sep}app${sep}validators`)) - assert.isTrue(Path.exceptions().endsWith(`build${sep}app${sep}exceptions`)) - assert.isTrue(Path.repositories().endsWith(`build${sep}app${sep}repositories`)) - assert.isTrue(Path.console().endsWith(`build${sep}app${sep}console`)) - assert.isTrue(Path.commands().endsWith(`build${sep}app${sep}console${sep}commands`)) - assert.isTrue(Path.http().endsWith(`build${sep}app${sep}http`)) - assert.isTrue(Path.guards().endsWith(`build${sep}app${sep}http${sep}guards`)) - assert.isTrue(Path.controllers().endsWith(`build${sep}app${sep}http${sep}controllers`)) - assert.isTrue(Path.middlewares().endsWith(`build${sep}app${sep}http${sep}middlewares`)) - assert.isTrue(Path.interceptors().endsWith(`build${sep}app${sep}http${sep}interceptors`)) - assert.isTrue(Path.terminators().endsWith(`build${sep}app${sep}http${sep}terminators`)) - assert.isTrue(Path.cron().endsWith(`build${sep}app${sep}cron`)) - assert.isTrue(Path.schedulers().endsWith(`build${sep}app${sep}cron${sep}schedulers`)) + assert.isTrue(Path.models().endsWith(`build${sep}src${sep}models`)) + assert.isTrue(Path.services().endsWith(`build${sep}src${sep}services`)) + assert.isTrue(Path.jobs().endsWith(`build${sep}src${sep}jobs`)) + assert.isTrue(Path.workers().endsWith(`build${sep}src${sep}workers`)) + assert.isTrue(Path.validators().endsWith(`build${sep}src${sep}validators`)) + assert.isTrue(Path.exceptions().endsWith(`build${sep}src${sep}exceptions`)) + assert.isTrue(Path.repositories().endsWith(`build${sep}src${sep}repositories`)) + assert.isTrue(Path.console().endsWith(`build${sep}src${sep}console`)) + assert.isTrue(Path.commands().endsWith(`build${sep}src${sep}console${sep}commands`)) + assert.isTrue(Path.http().endsWith(`build${sep}src${sep}http`)) + assert.isTrue(Path.guards().endsWith(`build${sep}src${sep}http${sep}guards`)) + assert.isTrue(Path.controllers().endsWith(`build${sep}src${sep}http${sep}controllers`)) + assert.isTrue(Path.middlewares().endsWith(`build${sep}src${sep}http${sep}middlewares`)) + assert.isTrue(Path.interceptors().endsWith(`build${sep}src${sep}http${sep}interceptors`)) + assert.isTrue(Path.terminators().endsWith(`build${sep}src${sep}http${sep}terminators`)) + assert.isTrue(Path.cron().endsWith(`build${sep}src${sep}cron`)) + assert.isTrue(Path.schedulers().endsWith(`build${sep}src${sep}cron${sep}schedulers`)) assert.isTrue(Path.bootstrap().endsWith(`build${sep}bootstrap`)) - assert.isTrue(Path.config().endsWith(`build${sep}config`)) - assert.isTrue(Path.database().endsWith(`build${sep}database`)) - assert.isTrue(Path.seeders().endsWith(`build${sep}database${sep}seeders`)) - assert.isTrue(Path.migrations().endsWith(`build${sep}database${sep}migrations`)) - assert.isTrue(Path.resources().endsWith(`build${sep}resources`)) - assert.isTrue(Path.views().endsWith(`build${sep}resources${sep}views`)) - assert.isTrue(Path.locales().endsWith(`build${sep}resources${sep}locales`)) + assert.isTrue(Path.config().endsWith(`build${sep}src${sep}config`)) + assert.isTrue(Path.database().endsWith(`build${sep}src${sep}database`)) + assert.isTrue(Path.seeders().endsWith(`build${sep}src${sep}database${sep}seeders`)) + assert.isTrue(Path.migrations().endsWith(`build${sep}src${sep}database${sep}migrations`)) + assert.isTrue(Path.resources().endsWith(`build${sep}src${sep}resources`)) + assert.isTrue(Path.views().endsWith(`build${sep}src${sep}resources${sep}views`)) + assert.isTrue(Path.locales().endsWith(`build${sep}src${sep}resources${sep}locales`)) assert.isTrue(Path.nodeModules().endsWith(`build${sep}node_modules`)) assert.isTrue(Path.nodeModulesBin().endsWith(`build${sep}node_modules${sep}.bin`)) - assert.isTrue(Path.providers().endsWith(`build${sep}providers`)) - assert.isTrue(Path.facades().endsWith(`build${sep}providers${sep}facades`)) + assert.isTrue(Path.providers().endsWith(`build${sep}src${sep}providers`)) + assert.isTrue(Path.facades().endsWith(`build${sep}src${sep}facades`)) assert.isTrue(Path.public().endsWith(`build${sep}public`)) assert.isTrue(Path.static().endsWith(`build${sep}public${sep}static`)) assert.isTrue(Path.assets().endsWith(`build${sep}public${sep}assets`)) - assert.isTrue(Path.routes().endsWith(`build${sep}routes`)) - assert.isTrue(Path.storage().endsWith(`build${sep}storage`)) - assert.isTrue(Path.logs().endsWith(`build${sep}storage${sep}logs`)) + assert.isTrue(Path.routes().endsWith(`build${sep}src${sep}routes`)) + assert.isTrue(Path.storage().endsWith(`build${sep}src${sep}storage`)) + assert.isTrue(Path.logs().endsWith(`build${sep}src${sep}storage${sep}logs`)) assert.isTrue(Path.tests().endsWith(`build${sep}tests`)) assert.isTrue(Path.stubs().endsWith(`build${sep}tests${sep}stubs`)) assert.isTrue(Path.fixtures().endsWith(`build${sep}tests${sep}fixtures`))