Begin work on new structure resolvers.
This commit is contained in:
@@ -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>
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user