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:
Aiden McClelland
2025-05-23 11:23:29 -06:00
committed by GitHub
parent b1f9f90fec
commit 90e61989a4
19 changed files with 120 additions and 85 deletions

View File

@@ -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)
}
},
}
}

View File

@@ -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)
},
}
}