abstract class Package {
abstract environment(): string[];
abstract source(): string;
abstract builder(): string;
path(): string {
return "bla";
}
}
abstract class UnixPackage extends Package {
abstract buildInputs(): Package[];
environment(): string[] {
let path = "";
for (let buildInput of this.buildInputs()) {
path += ":" + buildInput.path() + "/bin";
}
return ["path=" + path];
}
configure(): string {
return "./configure";
}
build(): string {
return "make";
}
install(): string {
return "make install";
}
builder(): string {
return this.configure() + "\n" +
this.build() + "\n" +
this.install();
}
}
class FooPackage extends Package {
environment(): string[] {
return [];
}
source(): string {
return "foo";
}
builder(): string {
return "bla";
}
}
class HelloPackage extends UnixPackage {
buildInputs(): Package[] {
return [
new FooPackage(),
];
}
build(): string {
return "foobar";
}
source(): string {
return "bla";
}
}
const package = new HelloPackage();
console.log(package.source());
console.log(package.environment());
console.log(package.builder());