mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 20:14:49 +00:00
misc bugfixes for alpha.4 (#2953)
* fix lockup when stop during init * Fix incorrect description for registry package remove command * alpha.5 * beta.25 --------- Co-authored-by: Mariusz Kogen <k0gen@pm.me>
This commit is contained in:
@@ -51,41 +51,3 @@ export function setupOnInit(onInit: InitScriptOrFn): InitScript {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export function setupOnInstall(
|
||||
onInstall: InitScriptOrFn<"install">,
|
||||
): InitScript {
|
||||
return {
|
||||
init: async (effects, kind) => {
|
||||
if (kind === "install") {
|
||||
if ("init" in onInstall) await onInstall.init(effects, kind)
|
||||
else await onInstall(effects, kind)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export function setupOnUpdate(onUpdate: InitScriptOrFn<"update">): InitScript {
|
||||
return {
|
||||
init: async (effects, kind) => {
|
||||
if (kind === "update") {
|
||||
if ("init" in onUpdate) await onUpdate.init(effects, kind)
|
||||
else await onUpdate(effects, kind)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export function setupOnInstallOrUpdate(
|
||||
onInstallOrUpdate: InitScriptOrFn<"install" | "update">,
|
||||
): InitScript {
|
||||
return {
|
||||
init: async (effects, kind) => {
|
||||
if (kind === "install" || kind === "update") {
|
||||
if ("init" in onInstallOrUpdate)
|
||||
await onInstallOrUpdate.init(effects, kind)
|
||||
else await onInstallOrUpdate(effects, kind)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,18 +3,34 @@ import * as T from "../../../base/lib/types"
|
||||
|
||||
export type UninitFn = (
|
||||
effects: T.Effects,
|
||||
/**
|
||||
* @description the target version to prepare for
|
||||
*
|
||||
* on update: the canMigrateFrom of the new package
|
||||
* on uninstall: null
|
||||
* on shutdown: the current version
|
||||
*/
|
||||
target: VersionRange | ExtendedVersion | null,
|
||||
) => Promise<void | null | undefined>
|
||||
|
||||
export interface UninitScript {
|
||||
uninit(
|
||||
effects: T.Effects,
|
||||
/**
|
||||
* @description the target version to prepare for
|
||||
*
|
||||
* on update: the canMigrateFrom of the new package
|
||||
* on uninstall: null
|
||||
* on shutdown: the current version
|
||||
*/
|
||||
target: VersionRange | ExtendedVersion | null,
|
||||
): Promise<void>
|
||||
}
|
||||
|
||||
export type UninitScriptOrFn = UninitScript | UninitFn
|
||||
|
||||
export function setupUninit(
|
||||
...uninits: (UninitScript | UninitFn)[]
|
||||
...uninits: UninitScriptOrFn[]
|
||||
): T.ExpectedExports.uninit {
|
||||
return async (opts) => {
|
||||
for (const uninit of uninits) {
|
||||
@@ -23,3 +39,13 @@ export function setupUninit(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function setupOnUninit(onUninit: UninitScriptOrFn): UninitScript {
|
||||
return "uninit" in onUninit
|
||||
? onUninit
|
||||
: {
|
||||
uninit: async (effects, target) => {
|
||||
await onUninit(effects, target)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,13 +64,11 @@ import * as fs from "node:fs/promises"
|
||||
import {
|
||||
setupInit,
|
||||
setupUninit,
|
||||
setupOnInstall,
|
||||
setupOnUpdate,
|
||||
setupOnInstallOrUpdate,
|
||||
setupOnInit,
|
||||
setupOnUninit,
|
||||
} from "../../base/lib/inits"
|
||||
|
||||
export const OSVersion = testTypeVersion("0.4.0-alpha.4")
|
||||
export const OSVersion = testTypeVersion("0.4.0-alpha.5")
|
||||
|
||||
// prettier-ignore
|
||||
type AnyNeverCond<T extends any[], Then, Else> =
|
||||
@@ -506,21 +504,13 @@ export class StartSdk<Manifest extends T.SDKManifest> {
|
||||
*/
|
||||
setupDependencies: setupDependencies<Manifest>,
|
||||
/**
|
||||
* @description Use this function to create an InitScript that runs every time the service initializes
|
||||
* @description Use this function to create an InitScript that runs every time the service initializes (install, update, restore, rebuild, and server bootup)
|
||||
*/
|
||||
setupOnInit,
|
||||
/**
|
||||
* @description Use this function to create an InitScript that runs only when the service is freshly installed
|
||||
* @description Use this function to create an UninitScript that runs every time the service uninitializes (update, uninstall, and server shutdown)
|
||||
*/
|
||||
setupOnInstall,
|
||||
/**
|
||||
* @description Use this function to create an InitScript that runs only when the service is updated
|
||||
*/
|
||||
setupOnUpdate,
|
||||
/**
|
||||
* @description Use this function to create an InitScript that runs only when the service is installed or updated
|
||||
*/
|
||||
setupOnInstallOrUpdate,
|
||||
setupOnUninit,
|
||||
/**
|
||||
* @description Use this function to setup what happens when the service initializes.
|
||||
*
|
||||
|
||||
4
sdk/package/package-lock.json
generated
4
sdk/package/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@start9labs/start-sdk",
|
||||
"version": "0.4.0-beta.24",
|
||||
"version": "0.4.0-beta.25",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@start9labs/start-sdk",
|
||||
"version": "0.4.0-beta.24",
|
||||
"version": "0.4.0-beta.25",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@iarna/toml": "^3.0.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@start9labs/start-sdk",
|
||||
"version": "0.4.0-beta.24",
|
||||
"version": "0.4.0-beta.25",
|
||||
"description": "Software development kit to facilitate packaging services for StartOS",
|
||||
"main": "./package/lib/index.js",
|
||||
"types": "./package/lib/index.d.ts",
|
||||
|
||||
Reference in New Issue
Block a user