diff --git a/package-lock.json b/package-lock.json index 6a5955b..5717386 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@athenna/common", - "version": "4.45.0", + "version": "4.46.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@athenna/common", - "version": "4.45.0", + "version": "4.46.0", "license": "MIT", "dependencies": { "@fastify/formbody": "^7.4.0", @@ -38,7 +38,7 @@ }, "devDependencies": { "@athenna/test": "^4.29.0", - "@athenna/tsconfig": "^4.18.0", + "@athenna/tsconfig": "^4.19.0", "@types/bytes": "^3.1.4", "@types/callsite": "^1.0.34", "@types/debug": "^4.1.12", @@ -116,9 +116,9 @@ } }, "node_modules/@athenna/tsconfig": { - "version": "4.18.0", - "resolved": "https://registry.npmjs.org/@athenna/tsconfig/-/tsconfig-4.18.0.tgz", - "integrity": "sha512-daS2Mfwd68MfBKUp4mk8nSRzPIl2eUZKV6wRCkMnuQKjUaKgqp2bsv8pXt2UmobDY44hcI675LHeKWaAK4WT6w==", + "version": "4.19.0", + "resolved": "https://registry.npmjs.org/@athenna/tsconfig/-/tsconfig-4.19.0.tgz", + "integrity": "sha512-BpbbnXyMXDHS2DMCUDHWOjFYvzHOe3CJQM+OmQ7MFTS8UXIBaavDd0160aoLCrJLk5IPuCytO1VastQ+h2xRUg==", "dev": true, "license": "MIT", "dependencies": { @@ -9699,9 +9699,9 @@ } }, "node_modules/safe-stable-stringify": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.4.3.tgz", - "integrity": "sha512-e2bDA2WJT0wxseVd4lsDP4+3ONX6HpMXQa1ZhFQ7SU+GjvORCmShbCMltrtIDfkYhVHrOcPtj+KhmDBdPdZD1g==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.5.0.tgz", + "integrity": "sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA==", "license": "MIT", "engines": { "node": ">=10" diff --git a/package.json b/package.json index c7aff42..c794fcf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@athenna/common", - "version": "4.45.0", + "version": "4.46.0", "description": "The Athenna common helpers to use in any Node.js ESM project.", "license": "MIT", "author": "João Lenon ", @@ -83,7 +83,7 @@ }, "devDependencies": { "@athenna/test": "^4.29.0", - "@athenna/tsconfig": "^4.18.0", + "@athenna/tsconfig": "^4.19.0", "@types/bytes": "^3.1.4", "@types/callsite": "^1.0.34", "@types/debug": "^4.1.12", diff --git a/src/helpers/Path.ts b/src/helpers/Path.ts index 2017923..329cab1 100644 --- a/src/helpers/Path.ts +++ b/src/helpers/Path.ts @@ -34,6 +34,8 @@ export class Path { interceptors: 'app/http/interceptors', terminators: 'app/http/terminators', validators: 'app/validators', + cron: 'app/cron', + schedulers: 'app/cron/schedulers', bootstrap: 'bootstrap', config: 'config', database: 'database', @@ -739,6 +741,38 @@ export class Path { return this } + /** + * Return the cron' path of your project. + */ + public static cron(subPath: string = sep): string { + return this.pwd(this.dirs.cron + sep + normalize(subPath)) + } + + /** + * Set the directory of cron folder. + */ + public static setCron(directory: string): typeof Path { + this.dirs.cron = directory + + return this + } + + /** + * Return the schedulers' path of your project. + */ + public static schedulers(subPath: string = sep): string { + return this.pwd(this.dirs.schedulers + sep + normalize(subPath)) + } + + /** + * Set the directory of schedulers folder. + */ + public static setSchedulers(directory: string): typeof Path { + this.dirs.schedulers = directory + + return this + } + /** * Return the migrations' path of your project. */ diff --git a/src/types/PathDirs.ts b/src/types/PathDirs.ts index d3e40a2..f167e58 100644 --- a/src/types/PathDirs.ts +++ b/src/types/PathDirs.ts @@ -26,6 +26,8 @@ export interface PathDirs { interceptors?: string terminators?: string validators?: string + cron?: string + schedulers?: string bootstrap?: string config?: string database?: string diff --git a/tests/unit/ExecTest.ts b/tests/unit/ExecTest.ts index 23bc514..b71ea3a 100644 --- a/tests/unit/ExecTest.ts +++ b/tests/unit/ExecTest.ts @@ -196,8 +196,8 @@ export default class ExecTest { const { stdout, stderr, exitCode } = await Exec.node(Path.fixtures('node-script.ts')) assert.equal(exitCode, 0) - assert.equal(stdout, 'hello') - assert.equal(stderr, 'hello') + assert.isTrue(stdout.includes('hello')) + assert.isTrue(stderr.includes('hello')) } @Test() diff --git a/tests/unit/ParserTest.ts b/tests/unit/ParserTest.ts index de45a66..a5ed9a2 100644 --- a/tests/unit/ParserTest.ts +++ b/tests/unit/ParserTest.ts @@ -291,7 +291,7 @@ export default class ParserTest { public async shouldBeAbleToParseArrayWithKeysThatGotCommaToCsv({ assert }: Context) { const csv = Parser.arrayToCsv([{ id: 1, 'name, sur': 'lenon' }]) - assert.deepEqual(csv, 'id,"""name, sur"""\n1,lenon') + assert.deepEqual(csv, 'id,"name, sur"\n1,lenon') } @Test() diff --git a/tests/unit/PathTest.ts b/tests/unit/PathTest.ts index bd4736c..c09a9d7 100644 --- a/tests/unit/PathTest.ts +++ b/tests/unit/PathTest.ts @@ -74,6 +74,7 @@ export default class PathTest { const mainPath = process.cwd().concat(sep, 'app') assert.equal(Path.http(), mainPath.concat(sep, 'http')) + assert.equal(Path.cron(), mainPath.concat(sep, 'cron')) assert.equal(Path.console(), mainPath.concat(sep, 'console')) assert.equal(Path.models(), mainPath.concat(sep, 'models')) assert.equal(Path.services(), mainPath.concat(sep, 'services')) @@ -101,6 +102,13 @@ export default class PathTest { assert.equal(Path.commands(), mainPath.concat(sep, 'commands')) } + @Test() + public async shouldGetTheSubPathsOfCronMainPath({ assert }: Context) { + const mainPath = process.cwd().concat(sep, 'app', sep, 'cron') + + assert.equal(Path.schedulers(), mainPath.concat(sep, 'schedulers')) + } + @Test() public async shouldGetTheSubPathsOfDatabaseMainPath({ assert }: Context) { const mainPath = process.cwd().concat(sep, 'database') @@ -173,6 +181,8 @@ export default class PathTest { .setMiddlewares('build/app/http/middlewares') .setInterceptors('build/app/http/interceptors') .setTerminators('build/app/http/terminators') + .setCron('build/app/cron') + .setSchedulers('/build/app/cron/schedulers') .setBootstrap('build/bootstrap') .setConfig('build/config') .setDatabase('build/database') @@ -214,6 +224,8 @@ export default class PathTest { 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.bootstrap().endsWith(`build${sep}bootstrap`)) assert.isTrue(Path.config().endsWith(`build${sep}config`)) assert.isTrue(Path.database().endsWith(`build${sep}database`))