Skip to content

Commit

Permalink
[web/keyserver] Separate web and keyserver versions
Browse files Browse the repository at this point in the history
Summary:
[ENG-4766](https://linear.app/comm/issue/ENG-4766)

We need to separate web and keyserver for the future multi keyserver world. One of the things we need to change is versioning - they both need to have a separate versions.

Test Plan: `yarn flow-all`, `cargo test` in rust node addon. Checked if after changing the version the version in generated rust code also changes.

Reviewers: inka, kamil, atul

Reviewed By: atul

Subscribers: ashoat, tomek, wyilio

Differential Revision: https://phab.comm.dev/D9503
  • Loading branch information
MichalGniadek committed Oct 31, 2023
1 parent 5c2682a commit 584f14b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 14 deletions.
10 changes: 5 additions & 5 deletions keyserver/addons/rust-node-addon/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ use std::path::Path;
fn main() {
napi_build::setup();

const VERSIONS_JS_PATH: &str = "../../../lib/facts/version.js";
const VERSIONS_JS_PATH: &str = "../../src/version.js";
println!("cargo:rerun-if-changed={}", VERSIONS_JS_PATH);
let js_path = Path::new(VERSIONS_JS_PATH);

let content = fs::read_to_string(js_path).expect("Failed to read version.js");

let version_line = content
.lines()
.find(|line| line.contains("webAndKeyserverCodeVersion"))
.expect("Failed to find webAndKeyserverCodeVersion line");
.find(|line| line.contains("keyserverCodeVersion"))
.expect("Failed to find keyserverCodeVersion line");

// Find a sequence in the input string that starts with
// 'webAndKeyserverCodeVersion', followed by any number of whitespace
// 'keyserverCodeVersion', followed by any number of whitespace
// characters, an equals sign, any number of additional whitespace characters,
// a series of one or more digits (and capture these digits), and finally a
// semicolon.
let re = Regex::new(r"webAndKeyserverCodeVersion\s*=\s*(\d+);").unwrap();
let re = Regex::new(r"keyserverCodeVersion\s*=\s*(\d+);").unwrap();
let version: u64 = re
.captures(version_line)
.and_then(|cap| cap.get(1))
Expand Down
5 changes: 3 additions & 2 deletions keyserver/src/responders/version-responders.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

import t, { type TInterface } from 'tcomb';

import { webAndKeyserverCodeVersion } from 'lib/facts/version.js';
import type { VersionResponse } from 'lib/types/device-types.js';
import { tShape } from 'lib/utils/validation-utils.js';

import { keyserverCodeVersion } from '../version.js';

export const versionResponseValidator: TInterface<VersionResponse> =
tShape<VersionResponse>({ codeVersion: t.Number });

const versionResponse = { codeVersion: webAndKeyserverCodeVersion };
const versionResponse = { codeVersion: keyserverCodeVersion };

async function versionResponder(): Promise<VersionResponse> {
return versionResponse;
Expand Down
3 changes: 3 additions & 0 deletions keyserver/src/version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// @flow

export const keyserverCodeVersion = 38;
5 changes: 0 additions & 5 deletions lib/facts/version.js

This file was deleted.

3 changes: 1 addition & 2 deletions web/app.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
ModalProvider,
useModalContext,
} from 'lib/components/modal-provider.react.js';
import { webAndKeyserverCodeVersion } from 'lib/facts/version.js';
import {
createLoadingStatusSelector,
combineLoadingStatuses,
Expand Down Expand Up @@ -89,7 +88,7 @@ registerConfig({
calendarRangeInactivityLimit: null,
platformDetails: {
platform: electron?.platform ?? 'web',
codeVersion: webAndKeyserverCodeVersion,
codeVersion: 38,
stateVersion: persistConfig.version,
},
});
Expand Down

0 comments on commit 584f14b

Please sign in to comment.