de670b3834
* Do Not Rely on Module State * Update storage.ts
27 lines
700 B
TypeScript
27 lines
700 B
TypeScript
const EVENT_VERSION = 'NEXT_CLI_SESSION_STARTED'
|
|
|
|
type EventCliSessionStarted = {
|
|
nextVersion: string
|
|
nodeVersion: string
|
|
cliCommand: string
|
|
}
|
|
|
|
export function eventVersion(
|
|
event: Omit<EventCliSessionStarted, 'nextVersion' | 'nodeVersion'>
|
|
): { eventName: string; payload: EventCliSessionStarted }[] {
|
|
// This should be an invariant, if it fails our build tooling is broken.
|
|
if (typeof process.env.__NEXT_VERSION !== 'string') {
|
|
return []
|
|
}
|
|
|
|
return [
|
|
{
|
|
eventName: EVENT_VERSION,
|
|
payload: {
|
|
nextVersion: process.env.__NEXT_VERSION,
|
|
nodeVersion: process.version,
|
|
cliCommand: event.cliCommand,
|
|
} as EventCliSessionStarted,
|
|
},
|
|
]
|
|
}
|