mirror of
https://github.com/saltbo/zpan.git
synced 2026-08-29 00:01:42 +08:00
53ca110218
Flatten the instance `runtime` object into two fields: `runtime` (the JS engine,
node | workerd) and `platform` (the deployment host). The About page shows each
as its own row with friendly labels (e.g. "workerd" + "Cloudflare Workers",
"Node.js" + "Docker").
- Detect the platform from the entry file (entry === target): each serverless
entry declares it; entry-node sniffs Cloud Run (K_SERVICE) / Docker
(ZPAN_RUNTIME, set in the Dockerfile) / bare node. Cloudflare is detected from
the D1 binding.
- Decouple the cloud payload: zpan-cloud-sdk fixes runtime { provider, target },
so CloudInstanceInfo keeps that shape and buildCloudInstanceInfo maps to it;
buildInstanceInfo serves the richer flat shape to the About API.
- Migrate PostHog instance telemetry to the runtime/platform shape and merge the
duplicate runtimeInfo in licensing-admin into the shared one.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
19 lines
665 B
TypeScript
19 lines
665 B
TypeScript
import type { InstanceInfo } from '../shared/types/instance'
|
|
|
|
export type DeployPlatform = NonNullable<InstanceInfo['platform']>
|
|
|
|
declare global {
|
|
var __ZPAN_PLATFORM__: DeployPlatform | undefined
|
|
}
|
|
|
|
// A deployment entry declares its platform at startup — the entry file IS the
|
|
// target, the most reliable signal. entry-node additionally sniffs Cloud Run /
|
|
// Docker, which share the Node entry. Cloudflare is detected from the D1 binding.
|
|
export function setDeployPlatform(platform: DeployPlatform): void {
|
|
globalThis.__ZPAN_PLATFORM__ = platform
|
|
}
|
|
|
|
export function getDeployPlatform(): DeployPlatform | undefined {
|
|
return globalThis.__ZPAN_PLATFORM__
|
|
}
|