(core) Endpoint to report on the latest version of stable grist-core image

Summary:
New endpoint `/api/version` that returns latest version of stable docker image in format:
```
{"latestVersion":"1.1.12","
  updatedAt":"2024-03-06T06:28:25.752337Z","
  isCritical":false,
 "updateURL":"https://hub.docker.com/r/gristlabs/grist"
}
```

It connects to docker hub API and reads the version from the tag lists endpoint.
Stores telemetry passed from the client such us: current version, deployment type, installationId and others.

Test Plan: Added new test

Reviewers: georgegevoian

Reviewed By: georgegevoian

Differential Revision: https://phab.getgrist.com/D4220
This commit is contained in:
Jarosław Sadziński
2024-04-05 10:54:53 +02:00
parent ddc28e327b
commit bddbcddbef
7 changed files with 665 additions and 3 deletions

View File

@@ -302,11 +302,26 @@ export async function readFixtureDoc(docName: string) {
// a class to store a snapshot of environment variables, can be reverted to by
// calling .restore()
export class EnvironmentSnapshot {
public static push() {
this._stack.push(new EnvironmentSnapshot());
}
public static pop() {
const snapshot = this._stack.pop();
if (!snapshot) {
throw new Error("EnvironmentSnapshot stack is empty");
}
snapshot.restore();
}
private static _stack: EnvironmentSnapshot[] = [];
private _oldEnv: NodeJS.ProcessEnv;
public constructor() {
this._oldEnv = clone(process.env);
}
// Reset environment variables.
public restore() {
Object.assign(process.env, this._oldEnv);