Skip to content

Commit

Permalink
Merge pull request #134 from AthennaIO/develop
Browse files Browse the repository at this point in the history
chore(npm): update dependencies
  • Loading branch information
jlenon7 authored Aug 25, 2024
2 parents 3b0b67e + 6eee675 commit 0f19fb7
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 14 deletions.
18 changes: 9 additions & 9 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/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 <[email protected]>",
Expand Down Expand Up @@ -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",
Expand Down
34 changes: 34 additions & 0 deletions src/helpers/Path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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.
*/
Expand Down
2 changes: 2 additions & 0 deletions src/types/PathDirs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export interface PathDirs {
interceptors?: string
terminators?: string
validators?: string
cron?: string
schedulers?: string
bootstrap?: string
config?: string
database?: string
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/ExecTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/ParserTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
12 changes: 12 additions & 0 deletions tests/unit/PathTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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`))
Expand Down

0 comments on commit 0f19fb7

Please sign in to comment.