mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-30 04:11:57 +00:00
chore: Getting in the action builder
This commit is contained in:
@@ -2,8 +2,12 @@ import { Parser } from "ts-matches";
|
||||
import * as T from "../types";
|
||||
import FileHelper from "./fileHelper";
|
||||
import nullIfEmpty from "./nullIfEmpty";
|
||||
import { getWrapperData } from "./getWrapperData";
|
||||
import { checkPortListening, checkWebUrl } from "../health/checkFns";
|
||||
import { WrapperData, getWrapperData } from "./getWrapperData";
|
||||
import {
|
||||
CheckResult,
|
||||
checkPortListening,
|
||||
checkWebUrl,
|
||||
} from "../health/checkFns";
|
||||
import { LocalPort, NetworkBuilder, TorHostname } from "../mainFn";
|
||||
import { ExtractWrapperData } from "../types";
|
||||
|
||||
@@ -35,7 +39,50 @@ function withAffine<B>() {
|
||||
return {} as { [affine]: B };
|
||||
}
|
||||
|
||||
export const utils = <WrapperData = never>(effects: T.Effects) => ({
|
||||
export type WrapperDataOptionals<WrapperData, Path extends string> = {
|
||||
validator?: Parser<unknown, ExtractWrapperData<WrapperData, Path>>;
|
||||
/** Defaults to what ever the package currently in */
|
||||
packageId?: string | undefined;
|
||||
};
|
||||
|
||||
export type Utils<WD> = {
|
||||
readFile: <A>(fileHelper: FileHelper<A>) => ReturnType<FileHelper<A>["read"]>;
|
||||
writeFile: <A>(
|
||||
fileHelper: FileHelper<A>,
|
||||
data: A,
|
||||
) => ReturnType<FileHelper<A>["write"]>;
|
||||
getWrapperData: <Path extends string>(
|
||||
path: T.EnsureWrapperDataPath<WD, Path>,
|
||||
options?: WrapperDataOptionals<WD, Path>,
|
||||
) => WrapperData<WD, Path>;
|
||||
setWrapperData: <Path extends string | never>(
|
||||
path: T.EnsureWrapperDataPath<WD, Path>,
|
||||
value: ExtractWrapperData<WD, Path>,
|
||||
) => Promise<void>;
|
||||
checkPortListening(
|
||||
port: number,
|
||||
options?: {
|
||||
error?: string;
|
||||
message?: string;
|
||||
},
|
||||
): Promise<CheckResult>;
|
||||
checkWebUrl(
|
||||
url: string,
|
||||
options?: {
|
||||
timeout?: number;
|
||||
successMessage?: string;
|
||||
errorMessage?: string;
|
||||
},
|
||||
): Promise<CheckResult>;
|
||||
localPort: (id: string) => LocalPort;
|
||||
networkBuilder: () => NetworkBuilder;
|
||||
torHostName: (id: string) => TorHostname;
|
||||
exists: (props: { path: string; volumeId: string }) => Promise<boolean>;
|
||||
nullIfEmpty: typeof nullIfEmpty;
|
||||
};
|
||||
export const utils = <WrapperData = never>(
|
||||
effects: T.Effects,
|
||||
): Utils<WrapperData> => ({
|
||||
readFile: <A>(fileHelper: FileHelper<A>) => fileHelper.read(effects),
|
||||
writeFile: <A>(fileHelper: FileHelper<A>, data: A) =>
|
||||
fileHelper.write(data, effects),
|
||||
@@ -55,9 +102,9 @@ export const utils = <WrapperData = never>(effects: T.Effects) => ({
|
||||
) => effects.setWrapperData<WrapperData, Path>({ value, path: path as any }),
|
||||
checkPortListening: checkPortListening.bind(null, effects),
|
||||
checkWebUrl: checkWebUrl.bind(null, effects),
|
||||
localPort: LocalPort.bind(null, effects),
|
||||
networkBuilder: NetworkBuilder.of.bind(null, effects),
|
||||
torHostName: TorHostname.of.bind(null, effects),
|
||||
localPort: (id: string) => new LocalPort(effects, id),
|
||||
networkBuilder: () => NetworkBuilder.of(effects),
|
||||
torHostName: (id: string) => TorHostname.of(effects, id),
|
||||
});
|
||||
|
||||
type NeverPossible = { [affine]: string };
|
||||
|
||||
Reference in New Issue
Block a user