From 7f3c189ec1f70ebdc75057da79ea456584752c3f Mon Sep 17 00:00:00 2001 From: J H <2364004+Blu-J@users.noreply.github.com> Date: Fri, 2 Feb 2024 08:41:32 -0700 Subject: [PATCH] beta4 --- lib/StartSdk.ts | 2 +- lib/config/configTypes.ts | 52 ++++++++++++++++----------------- lib/interfaces/Origin.ts | 5 +++- lib/mainFn/Daemons.ts | 2 +- lib/mainFn/index.ts | 4 +-- lib/types.ts | 2 +- lib/util/Overlay.ts | 5 +++- lib/util/getNetworkInterface.ts | 6 +++- 8 files changed, 44 insertions(+), 34 deletions(-) diff --git a/lib/StartSdk.ts b/lib/StartSdk.ts index d2413b3..85f157a 100644 --- a/lib/StartSdk.ts +++ b/lib/StartSdk.ts @@ -196,7 +196,7 @@ export class StartSdk { setupMain: ( fn: (o: { effects: Effects - started(onTerm: () => void): null + started(onTerm: () => PromiseLike): PromiseLike utils: Utils }) => Promise>, ) => setupMain(fn), diff --git a/lib/config/configTypes.ts b/lib/config/configTypes.ts index 2c8d374..55e5041 100644 --- a/lib/config/configTypes.ts +++ b/lib/config/configTypes.ts @@ -17,28 +17,28 @@ export type ValueSpec = ValueSpecOf export type ValueSpecOf = T extends "text" ? ValueSpecText : T extends "textarea" - ? ValueSpecTextarea - : T extends "number" - ? ValueSpecNumber - : T extends "color" - ? ValueSpecColor - : T extends "datetime" - ? ValueSpecDatetime - : T extends "toggle" - ? ValueSpecToggle - : T extends "select" - ? ValueSpecSelect - : T extends "multiselect" - ? ValueSpecMultiselect - : T extends "list" - ? ValueSpecList - : T extends "object" - ? ValueSpecObject - : T extends "file" - ? ValueSpecFile - : T extends "union" - ? ValueSpecUnion - : never + ? ValueSpecTextarea + : T extends "number" + ? ValueSpecNumber + : T extends "color" + ? ValueSpecColor + : T extends "datetime" + ? ValueSpecDatetime + : T extends "toggle" + ? ValueSpecToggle + : T extends "select" + ? ValueSpecSelect + : T extends "multiselect" + ? ValueSpecMultiselect + : T extends "list" + ? ValueSpecList + : T extends "object" + ? ValueSpecObject + : T extends "file" + ? ValueSpecFile + : T extends "union" + ? ValueSpecUnion + : never export interface ValueSpecText extends ListValueSpecText, WithStandalone { required: boolean @@ -164,10 +164,10 @@ export type ListValueSpecType = "text" | "number" | "object" export type ListValueSpecOf = T extends "text" ? ListValueSpecText : T extends "number" - ? ListValueSpecNumber - : T extends "object" - ? ListValueSpecObject - : never + ? ListValueSpecNumber + : T extends "object" + ? ListValueSpecObject + : never /** represents a spec for a list */ export type ValueSpecList = ValueSpecListOf export interface ValueSpecListOf diff --git a/lib/interfaces/Origin.ts b/lib/interfaces/Origin.ts index 08ad3f8..1bab628 100644 --- a/lib/interfaces/Origin.ts +++ b/lib/interfaces/Origin.ts @@ -2,7 +2,10 @@ import { Address } from "../types" import { Host, PortOptions } from "./Host" export class Origin { - constructor(readonly host: T, readonly options: PortOptions) {} + constructor( + readonly host: T, + readonly options: PortOptions, + ) {} build({ username, path, search }: BuildOptions): Address { const qpEntries = Object.entries(search) diff --git a/lib/mainFn/Daemons.ts b/lib/mainFn/Daemons.ts index 6db8f0b..9fd94dd 100644 --- a/lib/mainFn/Daemons.ts +++ b/lib/mainFn/Daemons.ts @@ -123,7 +123,7 @@ export class Daemons { ({ status: "failing", message: "message" in err ? err.message : String(err), - } as CheckResult), + }) as CheckResult, ) currentInput.lastResult = response.status || null if (!currentInput.hadSuccess && response.status === "passing") { diff --git a/lib/mainFn/index.ts b/lib/mainFn/index.ts index 1ad041e..ba79880 100644 --- a/lib/mainFn/index.ts +++ b/lib/mainFn/index.ts @@ -21,7 +21,7 @@ import { SDKManifest } from "../manifest/ManifestTypes" export const setupMain = ( fn: (o: { effects: Effects - started(onTerm: () => void): null + started(onTerm: () => PromiseLike): PromiseLike utils: Utils }) => Promise>, ): ExpectedExports.main => { @@ -30,6 +30,6 @@ export const setupMain = ( ...options, utils: createMainUtils(options.effects), }) - await result.build().then((x) => x.wait()) + return result } } diff --git a/lib/types.ts b/lib/types.ts index f45765e..338e7a7 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -60,7 +60,7 @@ export namespace ExpectedExports { */ export type main = (options: { effects: Effects - started(onTerm: () => Promise): Promise + started(onTerm: () => PromiseLike): PromiseLike }) => Promise> /** diff --git a/lib/util/Overlay.ts b/lib/util/Overlay.ts index 2b82f4d..3a8984b 100644 --- a/lib/util/Overlay.ts +++ b/lib/util/Overlay.ts @@ -6,7 +6,10 @@ import { Buffer } from "node:buffer" export const execFile = promisify(cp.execFile) export class Overlay { - private constructor(readonly effects: T.Effects, readonly rootfs: string) {} + private constructor( + readonly effects: T.Effects, + readonly rootfs: string, + ) {} static async of(effects: T.Effects, imageId: string) { const rootfs = await effects.createOverlayedImage({ imageId }) diff --git a/lib/util/getNetworkInterface.ts b/lib/util/getNetworkInterface.ts index 7dcb8c5..91c4014 100644 --- a/lib/util/getNetworkInterface.ts +++ b/lib/util/getNetworkInterface.ts @@ -66,7 +66,11 @@ const addressHostToUrl = ( { options, username, suffix }: Address, host: HostName, ): UrlString => { - const scheme = host.endsWith('.onion') ? options.scheme : (options.addSsl ? options.addSsl.scheme : options.scheme) // TODO: encode whether hostname transport is "secure"? + const scheme = host.endsWith(".onion") + ? options.scheme + : options.addSsl + ? options.addSsl.scheme + : options.scheme // TODO: encode whether hostname transport is "secure"? return `${scheme ? `${scheme}//` : ""}${ username ? `${username}@` : "" }${host}${suffix}`