mirror of
https://github.com/stablyai/orca.git
synced 2026-11-15 18:37:24 +00:00
fix(cloud): N-01 lint: no as-casts in phase guards, return await in failAfterStart
This commit is contained in:
@@ -24,7 +24,10 @@ export function noteCloudCreatePhase(
|
||||
if (phase === 'provision-start' || !startedAt.has(creationId)) {
|
||||
startedAt.set(creationId, now)
|
||||
if (startedAt.size > MAX_TRACKED_CREATES) {
|
||||
startedAt.delete(startedAt.keys().next().value as string)
|
||||
const oldest = startedAt.keys().next()
|
||||
if (!oldest.done) {
|
||||
startedAt.delete(oldest.value)
|
||||
}
|
||||
}
|
||||
}
|
||||
const since = now - (startedAt.get(creationId) ?? now)
|
||||
|
||||
@@ -260,7 +260,7 @@ export function registerEphemeralVmHandlers(store: Store, pluginService?: Plugin
|
||||
warnings: getEphemeralVmRecipeResultWarnings(result.start.result)
|
||||
}
|
||||
} catch (error) {
|
||||
return failAfterStart(error)
|
||||
return await failAfterStart(error)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ export function registerEphemeralVmHandlers(store: Store, pluginService?: Plugin
|
||||
source: 'ephemeral-vm'
|
||||
})
|
||||
} catch (error) {
|
||||
return failAfterStart(error)
|
||||
return await failAfterStart(error)
|
||||
}
|
||||
const runtime = requireEphemeralVmRecipeResult(
|
||||
updateEphemeralVmRuntimeStatus(app.getPath('userData'), result.runtime.id, {
|
||||
|
||||
@@ -30,21 +30,24 @@ export type CloudCreateMainPhase = (typeof CLOUD_CREATE_MAIN_PHASES)[number]
|
||||
export type CloudCreateRendererPhase = (typeof CLOUD_CREATE_RENDERER_PHASES)[number]
|
||||
export type CloudCreatePhase = CloudCreateMainPhase | CloudCreateRendererPhase
|
||||
|
||||
const RENDERER_PHASES: ReadonlySet<string> = new Set(CLOUD_CREATE_RENDERER_PHASES)
|
||||
|
||||
export function isCloudCreateRendererPhase(value: unknown): value is CloudCreateRendererPhase {
|
||||
return (CLOUD_CREATE_RENDERER_PHASES as readonly unknown[]).includes(value)
|
||||
return typeof value === 'string' && RENDERER_PHASES.has(value)
|
||||
}
|
||||
|
||||
const PROVISION_LINE_PHASES = new Set<string>([
|
||||
const PROVISION_LINE_PHASES = [
|
||||
'provisioning',
|
||||
'plan-clone',
|
||||
'plan-update',
|
||||
'cloning',
|
||||
'updating',
|
||||
'connecting'
|
||||
])
|
||||
] as const satisfies readonly CloudCreateMainPhase[]
|
||||
|
||||
/** The phase a driver progress line names (`[orca-cloud] <phase>…`), or null for any other line. */
|
||||
export function cloudCreatePhaseFromProvisionLine(line: string): CloudCreateMainPhase | null {
|
||||
const match = /^\[orca-cloud\] ([a-z-]+)/.exec(line.trim())
|
||||
return match && PROVISION_LINE_PHASES.has(match[1]) ? (match[1] as CloudCreateMainPhase) : null
|
||||
const named = match?.[1]
|
||||
return PROVISION_LINE_PHASES.find((phase) => phase === named) ?? null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user