GameVersionUtils
Utility functions to automatically detect the version a game is running at.
Beyond the place version, this reads the deploy metadata baked in by the nevermore CLI (see NevermoreCLIManifestUtils) so diagnostics can report which environment and commit a build came from:
print(GameVersionUtils.getVersionString())
--> 1.0.0 · integration · a4a79e8 · v312 (deployed from main)
--> 1.0.0 · integration · users/quenty/thing · a4a79e8 · v312 (deployed from a branch)
--> studio (never deployed)
--> undeployed · v312 (published outside the CLI)
Types
ServerType
type ServerType = "standard" | "vip" | "reserved"The server type to return
GameVersionStringConfig
interface GameVersionStringConfig {separator: string?--
between fields, defaults to " · "
placeVersionPrefix: string?--
before a numeric place version, defaults to "v"
undeployedLabel: string?--
for a live place with no manifest, defaults to "undeployed"
unknownTargetLabel: string?--
for a deploy that did not record its target, defaults to "unknown"
defaultBranches: {[string]: boolean}?--
branches not worth reporting, defaults to main and master
}How GameVersionUtils.formatVersionString renders a build. Every field is optional and falls back to the default below, so a caller that only wants a different separator passes only that.
defaultBranches are the branches every build is expected to come from --
the branch is only worth reporting when a build came from somewhere else.
Functions
getBuild
GameVersionUtils.getBuild() → stringGets the game build
getBuildWithServerType
GameVersionUtils.getBuildWithServerType() → stringGets the game build with a server type specified for debugging
getServerType
Gets a string label for the current server type
isVIPServer
GameVersionUtils.isVIPServer() → booleanReturns true if we're a VIP server
getEnvironmentName
GameVersionUtils.getEnvironmentName() → string?
Gets the deploy target the running place was deployed to, for example
"integration" or "production-demo". This is the target name from the
deploying package's deploy.nevermore.json.
Returns nil in Studio and in any place that was not deployed through the nevermore CLI, so callers can degrade to whatever they showed before rather than inventing an environment name.
observeEnvironmentName
Observes the deploy target, firing immediately and again if the metadata changes. On the client the metadata arrives with replication, so the first value may be nil before it lands.
formatVersionString
Formats a human readable version string out of deploy metadata and a build.
Fields are emitted from most to least stable -- package version, environment, branch, commit, then the place version -- and any field that is not known is dropped rather than printed as a placeholder.
The branch is only included when the build came from something other than
main or master, which is exactly the case where the environment alone
does not tell you what is running.
getVersionString
Gets the version string for the running place. See GameVersionUtils.formatVersionString for the format.
Safe on both the client and the server, but on the client the deploy metadata replicates with the package, so prefer GameVersionUtils.observeVersionString for anything shown at boot.
observeVersionString
Observes the version string, firing immediately and again whenever the deploy metadata or the place version changes.