Skip to content

Commit

Permalink
Merge pull request #30 from AthennaIO/develop
Browse files Browse the repository at this point in the history
feat(cmd): add `make:test` and configurer
  • Loading branch information
jlenon7 authored Feb 25, 2024
2 parents d9dddd6 + 899f812 commit db321fb
Show file tree
Hide file tree
Showing 21 changed files with 916 additions and 264 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# View 📄

> The Athenna template engine. Built on top of Edge.
> The Athenna template engine. Built on top of Edge.js.
[![GitHub followers](https://img.shields.io/github/followers/athennaio.svg?style=social&label=Follow&maxAge=2592000)](https://github.com/athennaio?tab=followers)
[![GitHub stars](https://img.shields.io/github/stars/AthennaIO/View.svg?style=social&label=Star&maxAge=2592000)](https://github.com/AthennaIO/View/stargazers/)
Expand Down
58 changes: 58 additions & 0 deletions configurer/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* @athenna/view
*
* (c) João Lenon <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck

import { File, Path } from '@athenna/common'
import { BaseConfigurer } from '@athenna/artisan'

export default class ViewConfigurer extends BaseConfigurer {
public async configure() {
const ext = Path.ext()
const task = this.logger.task()

task.addPromise(`Create view.${ext} configuration file`, () => {
return new File(`./view`).copy(Path.config(`view.${ext}`))
})

task.addPromise('Update commands of .athennarc.json', () => {
return this.rc
.setTo(
'commands',
'make:view',
'@athenna/view/commands/MakeViewCommand'
)
.save()
})

task.addPromise('Update templates of .athennarc.json', () => {
return this.rc
.setTo(
'templates',
'view',
'node_modules/@athenna/view/templates/model.edge'
)
.save()
})

task.addPromise('Update providers of .athennarc.json', () => {
return this.rc
.pushTo('providers', '@athenna/view/providers/ViewProvider')
.save()
})

await task.run()

console.log()
this.logger.success(
'Successfully configured ({dim,yellow} @athenna/view) library'
)
}
}
94 changes: 94 additions & 0 deletions configurer/view
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/**
* @athenna/view
*
* (c) João Lenon <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck

import { Env } from '@athenna/config'
import { Path } from '@athenna/common'

export default {
/*
|--------------------------------------------------------------------------
| Default view disk
|--------------------------------------------------------------------------
|
| Here you may define the default view disk of your application.
|
| ```typescript
| // Render the Path.views('home.edge') file
| View.render('home')
| // Render the Path.views('pages/posts/post.edge') file
| View.render('pages/posts/post')
| ```
|
*/

disk: Path.views(),

/*
|--------------------------------------------------------------------------
| Named view disks
|--------------------------------------------------------------------------
|
| Here you may define the named view disks of your application. Different
| from the `disk`, named disks are rendered with the alias in front:
|
| ```typescript
| View.render('mydisk::myview', { name: 'Athenna' })
| ```
|
*/

namedDisks: {},

/*
|--------------------------------------------------------------------------
| View components
|--------------------------------------------------------------------------
|
| Here you may define your in-memory components. Components works exactly
| like the `disk` to be rendered, the only difference is that they are
| saved in-memory.
|
| ```typescript
| View.render('button', { content: 'Login' })
| ```
|
*/

components: {},

/*
|--------------------------------------------------------------------------
| Edge options
|--------------------------------------------------------------------------
|
| Define any option accepted by `Edge.create()` method. By default `cache`
| option will be set if in production environment.
|
*/

edge: {
/*
|--------------------------------------------------------------------------
| Cache
|--------------------------------------------------------------------------
|
| The templates are re-compiled whenever you call the `View.render()` method.
| Meaning that if you change your template while your application is running,
| the next time `View.render()` is called it will have the new changes.
| You must enable the cache mode in production to avoid re-compiling the
| templates. The compiled output will be saved within the memory.
|
*/

cache: Env('APP_ENV') === 'production'
}
}
120 changes: 93 additions & 27 deletions package-lock.json

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

Loading

0 comments on commit db321fb

Please sign in to comment.