Skip to content

Commit

Permalink
Merge pull request #16 from AthennaIO/develop
Browse files Browse the repository at this point in the history
chore(npm): update dependencies
  • Loading branch information
jlenon7 authored Sep 7, 2023
2 parents e9f2f59 + 3b6320f commit b6f724d
Show file tree
Hide file tree
Showing 15 changed files with 181 additions and 181 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ build
*.js
*.d.ts
*.js.map
!tests/stubs/**/*.js
!tests/stubs/**/*.d.ts
!tests/stubs/**/*.js.map
!tests/fixtures/**/*.js
!tests/fixtures/**/*.d.ts
!tests/fixtures/**/*.js.map

# IDE
.idea
Expand Down
268 changes: 134 additions & 134 deletions package-lock.json

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@athenna/view",
"version": "4.1.0",
"version": "4.2.0",
"description": "The Athenna template engine. Built on top of Edge.",
"license": "MIT",
"author": "João Lenon <[email protected]>",
Expand Down Expand Up @@ -50,10 +50,10 @@
"edge.js": "^5.5.1"
},
"devDependencies": {
"@athenna/common": "^4.4.0",
"@athenna/config": "^4.3.0",
"@athenna/ioc": "^4.1.0",
"@athenna/test": "^4.3.0",
"@athenna/common": "^4.10.1",
"@athenna/config": "^4.4.0",
"@athenna/ioc": "^4.2.0",
"@athenna/test": "^4.5.0",
"@typescript-eslint/eslint-plugin": "^5.56.0",
"@typescript-eslint/parser": "^5.56.0",
"c8": "^7.12.0",
Expand Down Expand Up @@ -109,7 +109,7 @@
},
"prettier": {
"singleQuote": true,
"trailingComma": "all",
"trailingComma": "none",
"arrowParens": "avoid",
"endOfLine": "lf",
"semi": false,
Expand Down Expand Up @@ -166,4 +166,4 @@
]
}
}
}
}
2 changes: 1 addition & 1 deletion src/exceptions/AlreadyExistComponentException.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class AlreadyExistComponentException extends Exception {
status: 500,
code: 'E_EXIST_COMPONENT',
message: `The component ${name} already exists.`,
help: `This exception is thrown when trying to create a component with a name that is already is use, in this case "${name}". Try to create your component with a different name or remove the other component first using the "View.removeComponent('${name}')" method. Also, "View.createTemplate('${name}', 'your-component-value')" will automatically remove the other component for you.`,
help: `This exception is thrown when trying to create a component with a name that is already is use, in this case "${name}". Try to create your component with a different name or remove the other component first using the "View.removeComponent('${name}')" method. Also, "View.createTemplate('${name}', 'your-component-value')" will automatically remove the other component for you.`
})
}
}
2 changes: 1 addition & 1 deletion src/exceptions/EmptyComponentException.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class EmptyComponentException extends Exception {
status: 500,
code: 'E_EMPTY_COMPONENT',
message: `The component ${name} cannot be registered with "null" or "undefined" value.`,
help: `This exception is thrown when trying to create a component with a "null" or "undefined" value. Try to set at least an empty string when using the "View.createComponent('${name}', '')" method.`,
help: `This exception is thrown when trying to create a component with a "null" or "undefined" value. Try to set at least an empty string when using the "View.createComponent('${name}', '')" method.`
})
}
}
2 changes: 1 addition & 1 deletion src/exceptions/NotFoundTemplateException.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class NotFoundTemplateException extends Exception {
status: 500,
code: 'E_NOT_FOUND',
message: `The view or component ${name} cannot be found.`,
help: `This exception is thrown when trying to render a view or a component that has not been registered. Try to create your template or your disk it using the "View.createTemplate('${name}', 'your-template-content')", or "View.createViewDisk('${name}', 'your-view-disk-path')" methods.`,
help: `This exception is thrown when trying to render a view or a component that has not been registered. Try to create your template or your disk using the "View.createTemplate('${name}', 'your-template-content')", or "View.createViewDisk('${name}', 'your-view-disk-path')" methods.`
})
}
}
4 changes: 2 additions & 2 deletions src/views/ViewImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export class ViewImpl {
'Path %s for view disk %s is not absolute and is going to be resolved using cwd %s.',
path,
name,
Path.pwd(),
Path.pwd()
)

path = resolve(Path.pwd(), path)
Expand Down Expand Up @@ -360,7 +360,7 @@ export class ViewImpl {
if (!this.hasTemplate(name)) {
debug(
'Template %s does not exist and removing operation will be skipped.',
name,
name
)

return this
Expand Down
12 changes: 12 additions & 0 deletions tests/fixtures/config/view.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Path } from '@athenna/common'

export default {
disks: {
admin: Path.fixtures('views/admin'),
component: Path.fixtures('views/components')
},

edge: {
cache: false
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 0 additions & 12 deletions tests/stubs/config/view.ts

This file was deleted.

40 changes: 20 additions & 20 deletions tests/unit/ViewTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class ViewTest {
public async beforeEach() {
Config.clear()
new Ioc().reconstruct()
await Config.loadAll(Path.stubs('config'))
await Config.loadAll(Path.fixtures('config'))
}

@AfterEach()
Expand All @@ -31,7 +31,7 @@ export default class ViewTest {

@Test()
public async shouldBeAbleToRenderHtmlViewsWithComponentsIncluded({ assert }: Context) {
await Config.load(Path.stubs('config/view.ts'))
await Config.load(Path.fixtures('config/view.ts'))
new ViewProvider().register()

const content = await View.render('admin::listUsers', { users: JSON.stringify({ name: 'Victor Tesoura' }) })
Expand All @@ -43,7 +43,7 @@ export default class ViewTest {

@Test()
public async shouldBeAbleToRenderRawEdgeContent({ assert }: Context) {
await Config.load(Path.stubs('config/view.ts'))
await Config.load(Path.fixtures('config/view.ts'))
new ViewProvider().register()

const content = '## Hello {{ value }}'
Expand All @@ -58,7 +58,7 @@ export default class ViewTest {

@Test()
public async shouldBeAbleToAddAndRemoveGlobalPropertiesInViews({ assert }: Context) {
await Config.load(Path.stubs('config/view.ts'))
await Config.load(Path.fixtures('config/view.ts'))
new ViewProvider().register()

const content = await View.addProperty('nodeVersion', '18').renderRaw('## Node.js version: {{ nodeVersion }}')
Expand All @@ -70,18 +70,18 @@ export default class ViewTest {

@Test()
public async shouldNotThrowsErrorsWhenTryingToRemoveAGlobalPropertyThatDoesNotExists({ assert }: Context) {
await Config.load(Path.stubs('config/view.ts'))
await Config.load(Path.fixtures('config/view.ts'))
new ViewProvider().register()

assert.doesNotThrows(() => View.removeProperty('notFound'))
}

@Test()
public async shouldBeAbleToAddAndRemoveViewDisks({ assert }: Context) {
await Config.load(Path.stubs('config/view.ts'))
await Config.load(Path.fixtures('config/view.ts'))
new ViewProvider().register()

View.createViewDisk('test', Path.stubs('views'))
View.createViewDisk('test', Path.fixtures('views'))

assert.isTrue(View.hasViewDisk('test'))

Expand All @@ -92,7 +92,7 @@ export default class ViewTest {

@Test()
public async shouldThrowAnExceptionWhenTryingToRenderViewsThatAreNotRegistered({ assert }: Context) {
await Config.load(Path.stubs('config/view.ts'))
await Config.load(Path.fixtures('config/view.ts'))
new ViewProvider().register()

assert.throws(() => View.renderSync('notFound'), NotFoundTemplateException)
Expand All @@ -101,12 +101,12 @@ export default class ViewTest {

@Test()
public async shouldBeAbleToUpdateAlreadyMountedViewDisks({ assert }: Context) {
await Config.load(Path.stubs('config/view.ts'))
await Config.load(Path.fixtures('config/view.ts'))
new ViewProvider().register()

assert.isTrue(View.hasViewDisk('admin::listUsers'))

View.createViewDisk('admin', Path.stubs('views/components'))
View.createViewDisk('admin', Path.fixtures('views/components'))

assert.isFalse(View.hasViewDisk('admin::listUsers'))
assert.isTrue(View.hasViewDisk('admin::header'))
Expand All @@ -115,15 +115,15 @@ export default class ViewTest {

@Test()
public async shouldNotThrowsAnyErrorsWhenTryingToRemoveAViewDiskThatDoesNotExists({ assert }: Context) {
await Config.load(Path.stubs('config/view.ts'))
await Config.load(Path.fixtures('config/view.ts'))
new ViewProvider().register()

assert.doesNotThrows(() => View.removeViewDisk('notFound'))
}

@Test()
public async shouldBeAbleToCreateAndRemoveComponents({ assert }: Context) {
await Config.load(Path.stubs('config/view.ts'))
await Config.load(Path.fixtures('config/view.ts'))
new ViewProvider().register()

View.createComponent('hello', 'Hello')
Expand All @@ -137,26 +137,26 @@ export default class ViewTest {

@Test()
public async shouldThrowAnExceptionWhenTryingToCreateAUndefinedComponent({ assert }: Context) {
await Config.load(Path.stubs('config/view.ts'))
await Config.load(Path.fixtures('config/view.ts'))
new ViewProvider().register()

assert.throws(() => View.createComponent('testing', undefined), EmptyComponentException)
}

@Test()
public async shouldThrowAnExceptionWhenTryingToCreateAComponentWithANameThatAlreadyExists({ assert }: Context) {
await Config.load(Path.stubs('config/view.ts'))
await Config.load(Path.fixtures('config/view.ts'))
new ViewProvider().register()

assert.throws(
() => View.createComponent('testing', '').createComponent('testing', ''),
AlreadyExistComponentException,
AlreadyExistComponentException
)
}

@Test()
public async shouldBeAbleToAutomaticallyRemoveTheComponentIfNameIsAlreadyIsUse({ assert }: Context) {
await Config.load(Path.stubs('config/view.ts'))
await Config.load(Path.fixtures('config/view.ts'))
new ViewProvider().register()

View.createTemplate('hello', 'Hello')
Expand All @@ -170,23 +170,23 @@ export default class ViewTest {

@Test()
public async shouldNotThrowErrorsIfTryingToRemoveAComponentThatDoesNotExists({ assert }: Context) {
await Config.load(Path.stubs('config/view.ts'))
await Config.load(Path.fixtures('config/view.ts'))
new ViewProvider().register()

assert.doesNotThrows(() => View.removeComponent('notFound'))
}

@Test()
public async shouldNotThrowErrorsIfTryingToRemoveATemplateThatDoesNotExists({ assert }: Context) {
await Config.load(Path.stubs('config/view.ts'))
await Config.load(Path.fixtures('config/view.ts'))
new ViewProvider().register()

assert.doesNotThrows(() => View.removeTemplate('notFound'))
}

@Test()
public async shouldNotRegisterTemplateIfViewTemplatesRegisterIsFalse({ assert }: Context) {
await Config.load(Path.stubs('config/view.ts'))
await Config.load(Path.fixtures('config/view.ts'))
Config.set('view.templates.register', false)

new ViewProvider().register()
Expand All @@ -197,7 +197,7 @@ export default class ViewTest {
@Test()
public async shouldBeAbleToRegisterCustomTemplate({ assert }: Context) {
const templatePath = Path.resources('templates/command.edge')
await Config.load(Path.stubs('config/view.ts'))
await Config.load(Path.fixtures('config/view.ts'))
await new File(templatePath, Buffer.from('Hello')).load()

new ViewProvider().register()
Expand Down

0 comments on commit b6f724d

Please sign in to comment.