parent
77fa6ad867
commit
564abb55c7
@ -0,0 +1,10 @@
|
||||
import {
|
||||
Unit,
|
||||
CommandLine,
|
||||
ValidationUnit,
|
||||
} from '@extollo/lib'
|
||||
|
||||
export const Units = [
|
||||
ValidationUnit,
|
||||
CommandLine,
|
||||
] as (typeof Unit)[]
|
@ -0,0 +1,43 @@
|
||||
import {Application, CommandLineApplication} from '@extollo/lib'
|
||||
import {Units} from './Units.extollo'
|
||||
|
||||
/*
|
||||
* Helper functions to bootstrap the Application instance for different uses.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get the base application with no final-target unit.
|
||||
*/
|
||||
export function base(): Application {
|
||||
const app = Application.getApplication()
|
||||
app.scaffold(__dirname, Units.slice(0, -1))
|
||||
return app
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the application with the final unit replaced with the CommandLineApplication
|
||||
* for use on the CLI.
|
||||
*/
|
||||
export function cli(): Application {
|
||||
const app = Application.getApplication()
|
||||
app.forceStartupMessage = false
|
||||
|
||||
const units = [...Units]
|
||||
|
||||
units.reverse()
|
||||
CommandLineApplication.setReplacement(units[0])
|
||||
units[0] = CommandLineApplication
|
||||
units.reverse()
|
||||
|
||||
app.scaffold(__dirname, units)
|
||||
return app
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the application as it should be run normally.
|
||||
*/
|
||||
export function app(): Application {
|
||||
const app = Application.getApplication()
|
||||
app.scaffold(__dirname, Units)
|
||||
return app
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env -S node --experimental-repl-await
|
||||
import {globalRegistry} from '@extollo/lib'
|
||||
import {cli} from './bootstrap'
|
||||
|
||||
globalRegistry.run(async () => {
|
||||
/*
|
||||
* The Application
|
||||
* -----------------------------------------------------
|
||||
* The application instance is a global inversion of control container that
|
||||
* ties your entire application together. The app container manages services
|
||||
* and lifecycle.
|
||||
*/
|
||||
const app = cli()
|
||||
await app.run()
|
||||
})
|
Loading…
Reference in new issue