Begin work on new structure resolvers.

This commit is contained in:
Daniel Scalzi
2019-08-21 22:25:11 -04:00
parent b942f4df59
commit 2bbf732d8e
12 changed files with 413 additions and 87 deletions

View File

@@ -1,25 +1,32 @@
import { mkdirs } from 'fs-extra'
import { Distribution } from '../spec/distribution'
import { ModelStructure } from './model.struct'
import { ServerStructure } from './server.struct'
export class DistributionStructure implements ModelStructure<Distribution> {
private servers: ServerStructure[] | undefined
private serverStruct: ServerStructure
constructor(
private root: string
) {}
public getServers() {
return new ServerStructure(this.root).getSpecModel()
private absoluteRoot: string,
private baseUrl: string
) {
this.serverStruct = new ServerStructure(this.absoluteRoot, this.baseUrl)
}
public getSpecModel(): Distribution {
return {
version: '1.0.0',
rss: 'TODO',
servers: this.getServers()
}
public async init() {
await mkdirs(this.absoluteRoot)
await this.serverStruct.init()
}
public async getSpecModel() {
return new Promise(async (resolve) => {
resolve({
version: '1.0.0',
rss: '<FILL IN MANUALLY>',
servers: await this.serverStruct.getSpecModel()
})
}) as Promise<Distribution>
}
}