diff --git a/lib/config/builder/value.ts b/lib/config/builder/value.ts index 7092a06..01673a6 100644 --- a/lib/config/builder/value.ts +++ b/lib/config/builder/value.ts @@ -2,6 +2,7 @@ import { Config, LazyBuild, LazyBuildOptions } from "./config" import { List } from "./list" import { Variants } from "./variants" import { + FilePath, Pattern, RandomString, ValueSpec, @@ -623,7 +624,7 @@ export class Value { } }, spec.validator) } - static file(a: { + static file, Store>(a: { name: string description?: string | null warning?: string | null @@ -636,12 +637,13 @@ export class Value { warning: null, ...a, } - if (a.required) { - return new Value(() => buildValue, string) - } - return new Value( - () => buildValue, - string.optional(), + return new Value, Store>( + () => ({ + ...buildValue, + + ...requiredLikeToAbove(a.required), + }), + asRequiredParser(object({ filePath: string }), a), ) } static dynamicFile( diff --git a/lib/config/configTypes.ts b/lib/config/configTypes.ts index 560afa9..2c8d374 100644 --- a/lib/config/configTypes.ts +++ b/lib/config/configTypes.ts @@ -58,6 +58,10 @@ export interface ValueSpecTextarea extends WithStandalone { /** Immutable means it can only be configed at the first config then never again */ immutable: boolean } + +export type FilePath = { + filePath: string +} export interface ValueSpecNumber extends ListValueSpecNumber, WithStandalone { required: boolean default: number | null diff --git a/lib/inits/setupExports.ts b/lib/inits/setupExports.ts index 647a1c8..70ba15a 100644 --- a/lib/inits/setupExports.ts +++ b/lib/inits/setupExports.ts @@ -4,10 +4,15 @@ import { Utils } from "../util/utils" export type SetupExports = (opts: { effects: Effects utils: Utils -}) => { - ui: ExposeUiPaths - services: ExposeServicePaths -} +}) => + | { + ui: ExposeUiPaths + services: ExposeServicePaths + } + | Promise<{ + ui: ExposeUiPaths + services: ExposeServicePaths + }> export const setupExports = (fn: (opts: SetupExports) => void) => fn