Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public async handle (argv: string[]) {
this.setupApplication()
await this.importAssembler(argv[0])
const manifest = new this.ace.Manifest(dirname(resolveFrom(this.appRoot, '@adonisjs/assembler')))
const kernel = new this.ace.Kernel(this.application)
/**
* Showing commands help
*/
kernel.flag('help', async (value, _, command) => {
if (!value) {
return
}
kernel.printHelp(command)
process.exit(0)
}, { alias: 'h' })
kernel.useManifest(manifest)
await kernel.handle(argv)
import slash from 'slash'
import picomatch from 'picomatch'
import { join, relative } from 'path'
import { Ioc } from '@adonisjs/fold'
import importFresh from 'import-fresh'
import { resolveFrom } from '@poppinss/utils'
import { Application } from '@adonisjs/application/build/standalone'
import { RCFILE_NAME, ACE_FILE_NAME } from '../../config/paths'
/**
* Exposes the API to pull meta files from the `.adonisrc.json` file and
* also match relative file paths against the defined globs.
*/
export class RcFile {
public rcFilePath = resolveFrom(this.appRoot, `./${RCFILE_NAME}`)
/**
* Raw rcfile contents
*/
public raw = this.getDiskContents()
/**
* Reference to application
*/
public application = new Application(this.appRoot, new Ioc(), this.raw, {})
/**
* A matcher to know if a file is part of the meta files globs
*/
public isMetaFile: (filePath: string) => boolean = picomatch(this.getMetaFilesGlob())
private loadProvider (providerPath: string) {
providerPath = this.basePath ? resolveFrom(this.basePath, providerPath) : providerPath
const provider = esmRequire(providerPath)
if (typeof (provider) !== 'function') {
throw new Error(`Make sure export default the provider from ${providerPath}`)
}
return new provider(this.ioc)
}
export function optionalResolveAndRequire (
filePath: string,
fromPath: string,
optional = false,
): any | null {
try {
return optionalRequire(resolveFrom(fromPath, filePath))
} catch (error) {
if (isMissingModuleError(error) && optional) {
return null
}
throw error
}
}
SERVER_ENTRY_FILE,
DEFAULT_BUILD_DIR,
} from '../../config/paths'
/**
* Exposes the API to build the AdonisJs project for development or
* production. The production build has it's own set of node_modules
*/
export class Compiler {
/**
* Reference to typescript compiler
*/
public tsCompiler = new TypescriptCompiler(
this.appRoot,
TSCONFIG_FILE_NAME,
require(resolveFrom(this.appRoot, 'typescript/lib/typescript')),
)
/**
* Reference to HTTP server
*/
public httpServer: HttpServer | DummyHttpServer
/**
* Reference to rc File
*/
public rcFile = new RcFile(this.appRoot)
/**
* Manifest instance to generate ace manifest file
*/
public manifest = new Manifest(this.appRoot, this.logger)