mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 02:11:53 +00:00
better ergonomics for versions (#2717)
This commit is contained in:
@@ -30,17 +30,11 @@ import { healthCheck, HealthCheckParams } from "./health/HealthCheck"
|
||||
import { checkPortListening } from "./health/checkFns/checkPortListening"
|
||||
import { checkWebUrl, runHealthScript } from "./health/checkFns"
|
||||
import { List } from "./config/builder/list"
|
||||
import { VersionInfo, VersionOptions } from "./versionInfo/VersionInfo"
|
||||
import { Install, InstallFn } from "./inits/setupInstall"
|
||||
import { setupActions } from "./actions/setupActions"
|
||||
import { setupDependencyConfig } from "./dependencies/setupDependencyConfig"
|
||||
import { SetupBackupsParams, setupBackups } from "./backup/setupBackups"
|
||||
import { setupInit } from "./inits/setupInit"
|
||||
import {
|
||||
EnsureUniqueId,
|
||||
VersionGraph,
|
||||
setupVersionGraph,
|
||||
} from "./versionInfo/setupVersionGraph"
|
||||
import { Uninstall, UninstallFn, setupUninstall } from "./inits/setupUninstall"
|
||||
import { setupMain } from "./mainFn"
|
||||
import { defaultTrigger } from "./trigger/defaultTrigger"
|
||||
@@ -81,6 +75,7 @@ import {
|
||||
} from "./dependencies/dependencies"
|
||||
import { health } from "."
|
||||
import { GetSslCertificate } from "./util/GetSslCertificate"
|
||||
import { VersionGraph } from "./version"
|
||||
|
||||
export const SDKVersion = testTypeVersion("0.3.6")
|
||||
|
||||
@@ -420,13 +415,6 @@ export class StartSdk<Manifest extends T.Manifest, Store> {
|
||||
started(onTerm: () => PromiseLike<void>): PromiseLike<void>
|
||||
}) => Promise<Daemons<Manifest, any>>,
|
||||
) => setupMain<Manifest, Store>(fn),
|
||||
setupVersionGraph: <
|
||||
CurrentVersion extends string,
|
||||
OtherVersions extends Array<VersionInfo<any>>,
|
||||
>(
|
||||
current: VersionInfo<CurrentVersion>,
|
||||
...other: EnsureUniqueId<OtherVersions, OtherVersions, CurrentVersion>
|
||||
) => setupVersionGraph<CurrentVersion, OtherVersions>(current, ...other),
|
||||
setupProperties:
|
||||
(
|
||||
fn: (options: { effects: Effects }) => Promise<T.SdkPropertiesReturn>,
|
||||
@@ -547,10 +535,6 @@ export class StartSdk<Manifest extends T.Manifest, Store> {
|
||||
>,
|
||||
) => List.dynamicText<Store>(getA),
|
||||
},
|
||||
VersionInfo: {
|
||||
of: <Version extends string>(options: VersionOptions<Version>) =>
|
||||
VersionInfo.of<Version>(options),
|
||||
},
|
||||
StorePath: pathBuilder<Store>(),
|
||||
Value: {
|
||||
toggle: Value.toggle,
|
||||
|
||||
@@ -29,3 +29,4 @@ export * as utils from "./util"
|
||||
export * as matches from "ts-matches"
|
||||
export * as YAML from "yaml"
|
||||
export * as TOML from "@iarna/toml"
|
||||
export * from "./version"
|
||||
|
||||
@@ -4,7 +4,7 @@ import { SetInterfaces } from "../interfaces/setupInterfaces"
|
||||
|
||||
import { ExposedStorePaths } from "../store/setupExposeStore"
|
||||
import * as T from "../types"
|
||||
import { VersionGraph } from "../versionInfo/setupVersionGraph"
|
||||
import { VersionGraph } from "../version/VersionGraph"
|
||||
import { Install } from "./setupInstall"
|
||||
import { Uninstall } from "./setupUninstall"
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import * as T from "../types"
|
||||
import { ImageConfig, ImageId, VolumeId } from "../osBindings"
|
||||
import { SDKManifest, SDKImageConfig } from "./ManifestTypes"
|
||||
import { SDKVersion } from "../StartSdk"
|
||||
import { VersionGraph } from "../versionInfo/setupVersionGraph"
|
||||
import { VersionGraph } from "../version/VersionGraph"
|
||||
|
||||
/**
|
||||
* This is an example of a function that takes a manifest and returns a new manifest with additional properties
|
||||
@@ -25,8 +25,8 @@ export function setupManifest<
|
||||
},
|
||||
Satisfies extends string[] = [],
|
||||
>(
|
||||
manifest: SDKManifest & Manifest,
|
||||
versions: VersionGraph<Version>,
|
||||
manifest: SDKManifest & Manifest,
|
||||
): Manifest & T.Manifest {
|
||||
const images = Object.entries(manifest.images).reduce(
|
||||
(images, [k, v]) => {
|
||||
|
||||
@@ -6,8 +6,8 @@ import { Variants } from "../config/builder/variants"
|
||||
import { ValueSpec } from "../config/configTypes"
|
||||
import { setupManifest } from "../manifest/setupManifest"
|
||||
import { StartSdk } from "../StartSdk"
|
||||
import { VersionGraph } from "../versionInfo/setupVersionGraph"
|
||||
import { VersionInfo } from "../versionInfo/VersionInfo"
|
||||
import { VersionGraph } from "../version/VersionGraph"
|
||||
import { VersionInfo } from "../version/VersionInfo"
|
||||
|
||||
describe("builder tests", () => {
|
||||
test("text", async () => {
|
||||
@@ -369,6 +369,13 @@ describe("values", () => {
|
||||
const sdk = StartSdk.of()
|
||||
.withManifest(
|
||||
setupManifest(
|
||||
VersionGraph.of(
|
||||
VersionInfo.of({
|
||||
version: "1.0.0:0",
|
||||
releaseNotes: "",
|
||||
migrations: {},
|
||||
}),
|
||||
),
|
||||
{
|
||||
id: "testOutput",
|
||||
title: "",
|
||||
@@ -402,13 +409,6 @@ describe("values", () => {
|
||||
},
|
||||
},
|
||||
},
|
||||
VersionGraph.of(
|
||||
VersionInfo.of({
|
||||
version: "1.0.0:0",
|
||||
releaseNotes: "",
|
||||
migrations: {},
|
||||
}),
|
||||
),
|
||||
),
|
||||
)
|
||||
.withStore<{ test: "a" }>()
|
||||
|
||||
@@ -1,12 +1,21 @@
|
||||
import { StartSdk } from "../StartSdk"
|
||||
import { setupManifest } from "../manifest/setupManifest"
|
||||
import { VersionInfo } from "../versionInfo/VersionInfo"
|
||||
import { VersionGraph } from "../versionInfo/setupVersionGraph"
|
||||
import { VersionInfo } from "../version/VersionInfo"
|
||||
import { VersionGraph } from "../version/VersionGraph"
|
||||
|
||||
export type Manifest = any
|
||||
export const sdk = StartSdk.of()
|
||||
.withManifest(
|
||||
setupManifest(
|
||||
VersionGraph.of(
|
||||
VersionInfo.of({
|
||||
version: "1.0.0:0",
|
||||
releaseNotes: "",
|
||||
migrations: {},
|
||||
})
|
||||
.satisfies("#other:1.0.0:0")
|
||||
.satisfies("#other:2.0.0:0"),
|
||||
),
|
||||
{
|
||||
id: "testOutput",
|
||||
title: "",
|
||||
@@ -41,15 +50,6 @@ export const sdk = StartSdk.of()
|
||||
},
|
||||
},
|
||||
},
|
||||
VersionGraph.of(
|
||||
VersionInfo.of({
|
||||
version: "1.0.0:0",
|
||||
releaseNotes: "",
|
||||
migrations: {},
|
||||
})
|
||||
.satisfies("#other:1.0.0:0")
|
||||
.satisfies("#other:2.0.0:0"),
|
||||
),
|
||||
),
|
||||
)
|
||||
.withStore<{ storeRoot: { storeLeaf: "value" } }>()
|
||||
|
||||
@@ -191,16 +191,6 @@ export class VersionGraph<CurrentVersion extends string> {
|
||||
)
|
||||
}
|
||||
|
||||
export function setupVersionGraph<
|
||||
CurrentVersion extends string,
|
||||
OtherVersions extends Array<VersionInfo<any>>,
|
||||
>(
|
||||
current: VersionInfo<CurrentVersion>,
|
||||
...other: EnsureUniqueId<OtherVersions, OtherVersions, CurrentVersion>
|
||||
) {
|
||||
return VersionGraph.of<CurrentVersion, OtherVersions>(current, ...other)
|
||||
}
|
||||
|
||||
// prettier-ignore
|
||||
export type EnsureUniqueId<A, B = A, OtherVersions = never> =
|
||||
B extends [] ? A :
|
||||
2
sdk/lib/version/index.ts
Normal file
2
sdk/lib/version/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./VersionGraph"
|
||||
export * from "./VersionInfo"
|
||||
@@ -22,7 +22,7 @@ const VERSION_2 = new Uint8Array([2])
|
||||
export class SideloadPage {
|
||||
isMobile = isPlatform(window, 'ios') || isPlatform(window, 'android')
|
||||
toUpload: {
|
||||
manifest: T.Manifest | null
|
||||
manifest: { title: string; version: string } | null
|
||||
icon: string | null
|
||||
file: File | null
|
||||
} = {
|
||||
|
||||
Reference in New Issue
Block a user