import { Effects, ExpectedExports } from "../types"; import { Utils, utils } from "../util"; export type InstallFn = (opts: { effects: Effects; utils: Utils; }) => Promise; export class Install { private constructor(readonly fn: InstallFn) {} static of(fn: InstallFn) { return new Install(fn); } async init({ effects, previousVersion, }: Parameters[0]) { if (!previousVersion) await this.fn({ effects, utils: utils(effects) }); } } export function setupInstall(fn: InstallFn) { return Install.of(fn); }