mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-26 02:11:56 +00:00
fix the types
This commit is contained in:
@@ -42,12 +42,12 @@ export class Backups<M extends SDKManifest> {
|
|||||||
|
|
||||||
private constructor(
|
private constructor(
|
||||||
private options = DEFAULT_OPTIONS,
|
private options = DEFAULT_OPTIONS,
|
||||||
private backupSet = [] as BackupSet<keyof M["volumes"] & string>[],
|
private backupSet = [] as BackupSet<M["volumes"][0]>[],
|
||||||
) {}
|
) {}
|
||||||
static volumes<M extends SDKManifest = never>(
|
static volumes<M extends SDKManifest = never>(
|
||||||
...volumeNames: Array<keyof M["volumes"] & string>
|
...volumeNames: Array<M["volumes"][0]>
|
||||||
) {
|
): Backups<M> {
|
||||||
return new Backups().addSets(
|
return new Backups<M>().addSets(
|
||||||
...volumeNames.map((srcVolume) => ({
|
...volumeNames.map((srcVolume) => ({
|
||||||
srcVolume,
|
srcVolume,
|
||||||
srcPath: "./",
|
srcPath: "./",
|
||||||
@@ -57,7 +57,7 @@ export class Backups<M extends SDKManifest> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
static addSets<M extends SDKManifest = never>(
|
static addSets<M extends SDKManifest = never>(
|
||||||
...options: BackupSet<keyof M["volumes"] & string>[]
|
...options: BackupSet<M["volumes"][0]>[]
|
||||||
) {
|
) {
|
||||||
return new Backups().addSets(...options)
|
return new Backups().addSets(...options)
|
||||||
}
|
}
|
||||||
@@ -75,7 +75,7 @@ export class Backups<M extends SDKManifest> {
|
|||||||
}
|
}
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
volumes(...volumeNames: Array<keyof M["volumes"] & string>) {
|
volumes(...volumeNames: Array<M["volumes"][0]>) {
|
||||||
return this.addSets(
|
return this.addSets(
|
||||||
...volumeNames.map((srcVolume) => ({
|
...volumeNames.map((srcVolume) => ({
|
||||||
srcVolume,
|
srcVolume,
|
||||||
@@ -85,7 +85,7 @@ export class Backups<M extends SDKManifest> {
|
|||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
addSets(...options: BackupSet<keyof M["volumes"] & string>[]) {
|
addSets(...options: BackupSet<M["volumes"][0]>[]) {
|
||||||
options.forEach((x) =>
|
options.forEach((x) =>
|
||||||
this.backupSet.push({ ...x, options: { ...this.options, ...x.options } }),
|
this.backupSet.push({ ...x, options: { ...this.options, ...x.options } }),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ import { ExpectedExports } from "../types"
|
|||||||
import { _ } from "../util"
|
import { _ } from "../util"
|
||||||
|
|
||||||
export type SetupBackupsParams<M extends SDKManifest> = Array<
|
export type SetupBackupsParams<M extends SDKManifest> = Array<
|
||||||
(keyof M["volumes"] & string) | Backups<M>
|
M["volumes"][0] | Backups<M>
|
||||||
>
|
>
|
||||||
|
|
||||||
export function setupBackups<M extends SDKManifest>(
|
export function setupBackups<M extends SDKManifest>(
|
||||||
...args: _<SetupBackupsParams<M>>
|
...args: _<SetupBackupsParams<M>>
|
||||||
) {
|
) {
|
||||||
const backups = Array<Backups<M>>()
|
const backups = Array<Backups<M>>()
|
||||||
const volumes = new Set<keyof M["volumes"] & string>()
|
const volumes = new Set<M["volumes"][0]>()
|
||||||
for (const arg of args) {
|
for (const arg of args) {
|
||||||
if (arg instanceof Backups) {
|
if (arg instanceof Backups) {
|
||||||
backups.push(arg)
|
backups.push(arg)
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class SetupDependencyMounts<Building> {
|
|||||||
|
|
||||||
addPath<
|
addPath<
|
||||||
Name extends string,
|
Name extends string,
|
||||||
Volume extends keyof M["volumes"] & string,
|
Volume extends M["volumes"][0] & string,
|
||||||
Path extends string,
|
Path extends string,
|
||||||
ManifestId extends M["id"],
|
ManifestId extends M["id"],
|
||||||
M extends SDKManifest,
|
M extends SDKManifest,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { TriggerInput } from "../trigger/TriggerInput"
|
|||||||
import { defaultTrigger } from "../trigger/defaultTrigger"
|
import { defaultTrigger } from "../trigger/defaultTrigger"
|
||||||
import { DaemonReturned, Effects, ValidIfNoStupidEscape } from "../types"
|
import { DaemonReturned, Effects, ValidIfNoStupidEscape } from "../types"
|
||||||
import { createUtils } from "../util"
|
import { createUtils } from "../util"
|
||||||
|
import { Signals } from "../util/utils"
|
||||||
type Daemon<Ids extends string, Command extends string, Id extends string> = {
|
type Daemon<Ids extends string, Command extends string, Id extends string> = {
|
||||||
id: "" extends Id ? never : Id
|
id: "" extends Id ? never : Id
|
||||||
command: ValidIfNoStupidEscape<Command> | [string, ...string[]]
|
command: ValidIfNoStupidEscape<Command> | [string, ...string[]]
|
||||||
@@ -128,7 +129,7 @@ export class Daemons<Ids extends string> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
async term(options?: { signal?: string; timeout?: number }) {
|
async term(options?: { signal?: Signals; timeout?: number }) {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
Object.values<Promise<DaemonReturned>>(daemonsStarted).map((x) =>
|
Object.values<Promise<DaemonReturned>>(daemonsStarted).map((x) =>
|
||||||
x.then((x) => x.term(options)),
|
x.then((x) => x.term(options)),
|
||||||
|
|||||||
@@ -4,12 +4,16 @@ export function setupManifest<
|
|||||||
Id extends string,
|
Id extends string,
|
||||||
Version extends ManifestVersion,
|
Version extends ManifestVersion,
|
||||||
Dependencies extends Record<string, unknown>,
|
Dependencies extends Record<string, unknown>,
|
||||||
Volumes extends string[],
|
VolumesTypes extends string,
|
||||||
|
AssetTypes extends string,
|
||||||
|
ImagesTypes extends string,
|
||||||
Manifest extends SDKManifest & {
|
Manifest extends SDKManifest & {
|
||||||
dependencies: Dependencies
|
dependencies: Dependencies
|
||||||
id: Id
|
id: Id
|
||||||
version: Version
|
version: Version
|
||||||
volumes: Volumes
|
assets: AssetTypes[]
|
||||||
|
images: ImagesTypes[]
|
||||||
|
volumes: VolumesTypes[]
|
||||||
},
|
},
|
||||||
>(manifest: Manifest): Manifest {
|
>(manifest: Manifest): Manifest {
|
||||||
return manifest
|
return manifest
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ describe("mountDependencies", () => {
|
|||||||
},
|
},
|
||||||
dependencies: {},
|
dependencies: {},
|
||||||
})
|
})
|
||||||
|
const clnManifestVolumes = clnManifest.volumes
|
||||||
const lndManifest = setupManifest({
|
const lndManifest = setupManifest({
|
||||||
id: "lnd",
|
id: "lnd",
|
||||||
title: "",
|
title: "",
|
||||||
|
|||||||
39
lib/types.ts
39
lib/types.ts
@@ -3,7 +3,7 @@ import { InputSpec } from "./config/configTypes"
|
|||||||
import { DependenciesReceipt } from "./config/setupConfig"
|
import { DependenciesReceipt } from "./config/setupConfig"
|
||||||
import { PortOptions } from "./interfaces/Host"
|
import { PortOptions } from "./interfaces/Host"
|
||||||
import { UrlString } from "./util/getNetworkInterface"
|
import { UrlString } from "./util/getNetworkInterface"
|
||||||
import { NetworkInterfaceType } from "./util/utils"
|
import { NetworkInterfaceType, Signals } from "./util/utils"
|
||||||
|
|
||||||
export type ExportedAction = (options: {
|
export type ExportedAction = (options: {
|
||||||
effects: Effects
|
effects: Effects
|
||||||
@@ -148,7 +148,7 @@ export type CommandType<A extends string> =
|
|||||||
|
|
||||||
export type DaemonReturned = {
|
export type DaemonReturned = {
|
||||||
wait(): Promise<string>
|
wait(): Promise<string>
|
||||||
term(): Promise<void>
|
term(options?: { signal?: Signals; timeout?: number }): Promise<void>
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ActionMetadata = {
|
export type ActionMetadata = {
|
||||||
@@ -495,40 +495,7 @@ export type ActionResult = {
|
|||||||
}
|
}
|
||||||
export type SetResult = {
|
export type SetResult = {
|
||||||
/** These are the unix process signals */
|
/** These are the unix process signals */
|
||||||
signal:
|
signal: Signals
|
||||||
| "SIGTERM"
|
|
||||||
| "SIGHUP"
|
|
||||||
| "SIGINT"
|
|
||||||
| "SIGQUIT"
|
|
||||||
| "SIGILL"
|
|
||||||
| "SIGTRAP"
|
|
||||||
| "SIGABRT"
|
|
||||||
| "SIGBUS"
|
|
||||||
| "SIGFPE"
|
|
||||||
| "SIGKILL"
|
|
||||||
| "SIGUSR1"
|
|
||||||
| "SIGSEGV"
|
|
||||||
| "SIGUSR2"
|
|
||||||
| "SIGPIPE"
|
|
||||||
| "SIGALRM"
|
|
||||||
| "SIGSTKFLT"
|
|
||||||
| "SIGCHLD"
|
|
||||||
| "SIGCONT"
|
|
||||||
| "SIGSTOP"
|
|
||||||
| "SIGTSTP"
|
|
||||||
| "SIGTTIN"
|
|
||||||
| "SIGTTOU"
|
|
||||||
| "SIGURG"
|
|
||||||
| "SIGXCPU"
|
|
||||||
| "SIGXFSZ"
|
|
||||||
| "SIGVTALRM"
|
|
||||||
| "SIGPROF"
|
|
||||||
| "SIGWINCH"
|
|
||||||
| "SIGIO"
|
|
||||||
| "SIGPWR"
|
|
||||||
| "SIGSYS"
|
|
||||||
| "SIGEMT"
|
|
||||||
| "SIGINFO"
|
|
||||||
"depends-on": DependsOn
|
"depends-on": DependsOn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,8 @@ import {
|
|||||||
import * as CP from "node:child_process"
|
import * as CP from "node:child_process"
|
||||||
import { promisify } from "node:util"
|
import { promisify } from "node:util"
|
||||||
import { splitCommand } from "./splitCommand"
|
import { splitCommand } from "./splitCommand"
|
||||||
export type Signals = "SIGTERM" | "SIGKILL"
|
export type Signals = NodeJS.Signals
|
||||||
|
|
||||||
export const SIGTERM: Signals = "SIGTERM"
|
export const SIGTERM: Signals = "SIGTERM"
|
||||||
export const SIGKILL: Signals = "SIGTERM"
|
export const SIGKILL: Signals = "SIGTERM"
|
||||||
export const NO_TIMEOUT = -1
|
export const NO_TIMEOUT = -1
|
||||||
|
|||||||
Reference in New Issue
Block a user