45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
TypeScript
export interface Platform {
|
|
/**
|
|
* The architecture
|
|
*/
|
|
arch: 'x86_64' | 'aarch64' | string;
|
|
};
|
|
|
|
type PackagePhase = (task: PackageTask) => Promise<void>;
|
|
|
|
/**
|
|
* Sufficient information for representing current packaging platform.
|
|
*/
|
|
export interface PackagePlatform {
|
|
hostPlatform: Platform;
|
|
buildPlatform: Platform;
|
|
}
|
|
|
|
export interface PackageTask {
|
|
name: string;
|
|
patchPhase?: PackagePhase;
|
|
configurePhase?: PackagePhase;
|
|
buildPhase?: PackagePhase;
|
|
installPhase?: PackagePhase;
|
|
[key: string]: any;
|
|
}
|
|
|
|
export async function buildPackage(task: PackageTask) {
|
|
if (task.patchPhase) {
|
|
console.log(`${task.name}/patchPhase`);
|
|
await task.patchPhase(task);
|
|
}
|
|
if (task.configurePhase) {
|
|
console.log(`${task.name}/configurePhase`);
|
|
await task.configurePhase(task);
|
|
}
|
|
if (task.buildPhase) {
|
|
console.log(`${task.name}/buildPhase`);
|
|
await task.buildPhase(task);
|
|
}
|
|
if (task.installPhase) {
|
|
console.log(`${task.name}/installPhase`);
|
|
await task.installPhase(task);
|
|
}
|
|
}
|