Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(path): add jobs and workers path #124

Merged
merged 2 commits into from
May 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@athenna/common",
"version": "4.39.0",
"version": "4.40.0",
"description": "The Athenna common helpers to use in any Node.js ESM project.",
"license": "MIT",
"author": "João Lenon <lenon@athenna.io>",
34 changes: 34 additions & 0 deletions src/helpers/Path.ts
Original file line number Diff line number Diff line change
@@ -21,6 +21,8 @@ export class Path {
app: 'app',
models: 'app/models',
services: 'app/services',
jobs: 'app/jobs',
workers: 'app/workers',
exceptions: 'app/exceptions',
repositories: 'app/repositories',
console: 'app/console',
@@ -560,6 +562,38 @@ export class Path {
return this
}

/**
* Return the jobs' path of your project.
*/
public static jobs(subPath: string = sep): string {
return this.pwd(this.dirs.jobs + sep + normalize(subPath))
}

/**
* Set the directory of jobs folder.
*/
public static setJobs(directory: string): typeof Path {
this.dirs.jobs = directory

return this
}

/**
* Return the workers' path of your project.
*/
public static workers(subPath: string = sep): string {
return this.pwd(this.dirs.workers + sep + normalize(subPath))
}

/**
* Set the directory of workers folder.
*/
public static setWorkers(directory: string): typeof Path {
this.dirs.workers = directory

return this
}

/**
* Return the repositories' path of your project.
*/
2 changes: 2 additions & 0 deletions src/types/PathDirs.ts
Original file line number Diff line number Diff line change
@@ -13,6 +13,8 @@ export interface PathDirs {
app?: string
models?: string
services?: string
jobs?: string
workers?: string
exceptions?: string
repositories?: string
console?: string
10 changes: 9 additions & 1 deletion tests/unit/PathTest.ts
Original file line number Diff line number Diff line change
@@ -77,6 +77,9 @@ export default class PathTest {
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.jobs(), mainPath.concat(sep, 'jobs'))
assert.equal(Path.workers(), mainPath.concat(sep, 'workers'))
assert.equal(Path.validators(), mainPath.concat(sep, 'validators'))
assert.equal(Path.exceptions(), mainPath.concat(sep, 'exceptions'))
assert.equal(Path.repositories(), mainPath.concat(sep, 'repositories'))
}
@@ -157,6 +160,9 @@ export default class PathTest {
.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')
@@ -194,6 +200,9 @@ export default class PathTest {
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`))
@@ -203,7 +212,6 @@ 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.validators().endsWith(`build${sep}app${sep}validators`))
assert.isTrue(Path.bootstrap().endsWith(`build${sep}bootstrap`))
assert.isTrue(Path.config().endsWith(`build${sep}config`))
assert.isTrue(Path.database().endsWith(`build${sep}database`))

Unchanged files with check annotations Beta

/**

Check failure on line 1 in src/helpers/Folder.ts

GitHub Actions / linux (21.x)

Property 'base' is missing in type '{ dir: string; name: string; path: string; files: FileJson[]; folders: FolderJson[]; createdAt: Date; accessedAt: Date; modifiedAt: Date; folderSize: string; ... 5 more ...; originalFolderExists: boolean; }' but required in type 'FolderJson'.

Check failure on line 1 in src/helpers/Folder.ts

GitHub Actions / windows (21.x)

Property 'base' is missing in type '{ dir: string; name: string; path: string; files: FileJson[]; folders: FolderJson[]; createdAt: Date; accessedAt: Date; modifiedAt: Date; folderSize: string; ... 5 more ...; originalFolderExists: boolean; }' but required in type 'FolderJson'.
* @athenna/common
*
* (c) João Lenon <lenon@athenna.io>