Skip to content

Commit

Permalink
feat: pull in os-version maps from Slab to reduce chance of stale data
Browse files Browse the repository at this point in the history
  • Loading branch information
calebjclark committed Dec 29, 2020
1 parent f57f3b5 commit 201b3c9
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 39 deletions.
30 changes: 30 additions & 0 deletions emulate-browsers/base/data/darwinToMacOsVersionMap.json
@@ -0,0 +1,30 @@
{
"7.0": "10.3.0",
"7.9": "10.3.9",
"8.0": "10.4.0",
"8.11": "10.4.11",
"9.0": "10.5.0",
"9.8": "10.5.8",
"10.0": "10.6.0",
"10.8": "10.6.8",
"11.0.0": "10.7.0",
"11.4.2": "10.7.5",
"12.0.0": "10.8.0",
"12.6.0": "10.8.5",
"13.0.0": "10.9.0",
"13.4.0": "10.9.5",
"14.0.0": "10.10.0",
"14.5.0": "10.10.5",
"15.0.0": "10.11.0",
"15.6.0": "10.11.6",
"16.0.0": "10.12.0",
"16.5.0": "10.12.4",
"16.6.0": "10.12.6",
"17.5.0": "10.13.4",
"17.6.0": "10.13.5",
"17.7.0": "10.13.6",
"18.2.0": "10.14.1",
"19.2.0": "10.15.2",
"19.3.0": "10.15.3",
"19.5.0": "10.15.5"
}
6 changes: 6 additions & 0 deletions emulate-browsers/base/data/windowsToWindowsVersionMap.json
@@ -0,0 +1,6 @@
{
"6.1": "10",
"6.2": "8",
"6.3": "8.1",
"10.0": "10"
}
41 changes: 2 additions & 39 deletions emulate-browsers/base/lib/getLocalOperatingSystemMeta.ts
@@ -1,5 +1,7 @@
import Os from 'os';
import { convertVersionsToTree, getClosestNumberMatch } from "./VersionUtils";
import darwinToMacOsVersionMap from '../data/darwinToMacOsVersionMap.json';
import windowsToWindowsVersionMap from '../data/windowsToWindowsVersionMap.json';

export default function getLocalOperatingSystemMeta() {
const platform = Os.platform();
Expand Down Expand Up @@ -69,45 +71,6 @@ const platformToOsName = {
sunos: 'linux',
}

// pulled the following from https://en.wikipedia.org/wiki/Darwin_%28operating_system%29#Release_history
const darwinToMacOsVersionMap = {
'7.0': '10.3.0',
'7.9': '10.3.9',
'8.0': '10.4.0',
'8.11': '10.4.11',
'9.0': '10.5.0',
'9.8': '10.5.8',
'10.0': '10.6.0',
'10.8': '10.6.8',
'11.0.0': '10.7.0',
'11.4.2': '10.7.5',
'12.0.0': '10.8.0',
'12.6.0': '10.8.5',
'13.0.0': '10.9.0',
'13.4.0': '10.9.5',
'14.0.0': '10.10.0',
'14.5.0': '10.10.5',
'15.0.0': '10.11.0',
'15.6.0': '10.11.6',
'16.0.0': '10.12.0',
'16.5.0': '10.12.4',
'16.6.0': '10.12.6',
'17.5.0': '10.13.4',
'17.6.0': '10.13.5',
'17.7.0': '10.13.6',
'18.2.0': '10.14.1',
'19.2.0': '10.15.2',
'19.3.0': '10.15.3',
'19.5.0': '10.15.5',
};

const darwinVersionTree = convertVersionsToTree(Object.keys(darwinToMacOsVersionMap));

const windowsToWindowsVersionMap = {
'6.1': '10',
'6.2': '8',
'6.3': '8.1',
'10.0': '10',
}
const windowsVersionTree = convertVersionsToTree(Object.keys(windowsToWindowsVersionMap));

12 changes: 12 additions & 0 deletions emulate-browsers/base/scripts/updateData.ts
@@ -0,0 +1,12 @@
import * as Fs from 'fs';
import * as Path from 'path';

const slabDataDir = process.env.SLAB_DATA_DIR || Path.resolve(__dirname, '../../../../slab/.data');
const slabBasicsDir = Path.join(slabDataDir, 'basics');
const dataDir = Path.resolve(__dirname, '../data');

const darwinToMacOsVersionMap = Fs.readFileSync(`${slabBasicsDir}/darwinToMacOsVersionMap.json`, 'utf8');
const windowsToWindowsVersionMap = Fs.readFileSync(`${slabBasicsDir}/windowsToWindowsVersionMap.json`, 'utf8');

Fs.writeFileSync(`${dataDir}/darwinToMacOsVersionMap.json`, darwinToMacOsVersionMap);
Fs.writeFileSync(`${dataDir}/windowsToWindowsVersionMap.json`, windowsToWindowsVersionMap);

0 comments on commit 201b3c9

Please sign in to comment.