Prepare for first package

This commit is contained in:
garrettmills
2020-06-06 17:43:31 -05:00
parent 8319859828
commit 2c0b126546
9 changed files with 1027 additions and 715 deletions

View File

@@ -14,7 +14,7 @@ const SystemDManager = require('../logical/services/SystemDManager')
class Host extends Injectable {
static get services() {
return [...super.services, 'utility']
return [...super.services, 'utility', 'app']
}
_temp_path_command = 'mktemp -d'
@@ -39,11 +39,13 @@ class Host extends Injectable {
this.config = config
this.name = config.name
const injector = this.app.di()
if ( config.packages && config.packages.type ) {
if ( config.packages.type === 'dnf' ) {
this.packages = new DNFManager(this)
this.packages = injector.make(DNFManager, this)
} else if ( config.packages.type === 'apt' ) {
this.packages = new APTManager(this)
this.packages = injector.make(APTManager, this)
} else {
throw new Error(`Invalid or unknown package manager type: ${config.packages.type}`)
}
@@ -51,11 +53,13 @@ class Host extends Injectable {
if ( config.services && config.services.type ) {
if ( config.services.type === 'systemd' ) {
this.services = new SystemDManager(this)
this.services = injector.make(SystemDManager, this)
} else {
throw new Error(`Invalid or unknown service manager type: ${config.services.type}`)
}
}
this.injector = injector
}
async execute(command) {
@@ -82,16 +86,19 @@ class Host extends Injectable {
async get_temp_path() {
const path_string = await this.run_line_result(this._temp_path_command)
return new UniversalPath(this, path_string, UniversalPath.PATH_TYPE_DIRECTORY)
return this.injector.make(UniversalPath, this, path_string, UniversalPath.PATH_TYPE_DIRECTORY)
// return new UniversalPath(this, path_string, UniversalPath.PATH_TYPE_DIRECTORY)
}
async get_temp_file() {
const file_string = await this.run_line_result(this._temp_file_command)
return new UniversalPath(this, file_string, UniversalPath.PATH_TYPE_FILE)
return this.injector.make(UniversalPath, this, file_string, UniversalPath.PATH_TYPE_FILE)
// return new UniversalPath(this, file_string, UniversalPath.PATH_TYPE_FILE)
}
async get_path(local_path) {
const host_path = new UniversalPath(this, local_path)
const host_path = this.injector.make(UniversalPath, this, local_path)
// const host_path = new UniversalPath(this, local_path)
await host_path.classify()
return host_path
}