Skip to content

Commit

Permalink
✨ Install the correct Chromium binary for M1 Macs
Browse files Browse the repository at this point in the history
  • Loading branch information
wwilsman committed Aug 10, 2021
1 parent cd108c1 commit 8fdce06
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
11 changes: 8 additions & 3 deletions packages/core/src/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ function formatProgress(prefix, total, start, progress) {
// Returns an item from the map keyed by the current platform
function selectByPlatform(map) {
let { platform, arch } = process;
return map[platform === 'win32' && arch === 'x64' ? 'win64' : platform];
if (platform === 'win32' && arch === 'x64') platform = 'win64';
if (platform === 'darwin' && arch === 'arm64') platform = 'darwinArm';
return map[platform];
}

// Installs a revision of Chromium to a local directory
Expand All @@ -63,6 +65,7 @@ function installChromium({
selectByPlatform({
linux: `Linux_x64/${revision}/chrome-linux.zip`,
darwin: `Mac/${revision}/chrome-mac.zip`,
darwinArm: `Mac_Arm/${revision}/chrome-mac.zip`,
win64: `Win_x64/${revision}/chrome-win.zip`,
win32: `Win/${revision}/chrome-win.zip`
});
Expand All @@ -71,7 +74,8 @@ function installChromium({
linux: path.join('chrome-linux', 'chrome'),
win64: path.join('chrome-win', 'chrome.exe'),
win32: path.join('chrome-win', 'chrome.exe'),
darwin: path.join('chrome-mac', 'Chromium.app', 'Contents', 'MacOS', 'Chromium')
darwin: path.join('chrome-mac', 'Chromium.app', 'Contents', 'MacOS', 'Chromium'),
darwinArm: path.join('chrome-mac', 'Chromium.app', 'Contents', 'MacOS', 'Chromium')
});

return install({
Expand All @@ -89,7 +93,8 @@ installChromium.revisions = {
linux: '885264',
win64: '885282',
win32: '885263',
darwin: '885263'
darwin: '885263',
darwinArm: '885282'
};

// Installs an executable from a url to a local directory, returning the full path to the extracted
Expand Down
5 changes: 5 additions & 0 deletions packages/core/test/unit/install.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ describe('Unit / Install', () => {
url: jasmine.stringMatching(`Mac/${install.chromium.revisions.darwin}/chrome-mac.zip`),
return: path.join('chrome-mac', 'Chromium.app', 'Contents', 'MacOS', 'Chromium')
},
darwinArm: {
revision: install.chromium.revisions.darwinArm,
url: jasmine.stringMatching(`Mac/${install.chromium.revisions.darwinArm}/chrome-mac.zip`),
return: path.join('chrome-mac', 'Chromium.app', 'Contents', 'MacOS', 'Chromium')
},
win64: {
revision: install.chromium.revisions.win64,
url: jasmine.stringMatching(`Win_x64/${install.chromium.revisions.win64}/chrome-win.zip`),
Expand Down
6 changes: 4 additions & 2 deletions scripts/chromium-revision
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const GH_HEADERS = {
const G_STORAGE_API_URL = 'https://www.googleapis.com/storage/v1/b/chromium-browser-snapshots/o';
const G_STORAGE_PREFIXES = {
darwin: 'Mac',
darwinArm: 'Mac_Arm',
linux: 'Linux_x64',
win64: 'Win_x64',
win32: 'Win'
Expand Down Expand Up @@ -95,7 +96,7 @@ async function printVersionRevisions(version) {
// 50 revisions (not all platforms release at the same time)
let revisions = await task({
state: () => ({
platforms: ['linux', 'win64', 'win32', 'darwin'],
platforms: ['linux', 'win64', 'win32', 'darwin', 'darwinArm'],
range: [revision - 50, revision],
value: {}
}),
Expand All @@ -105,8 +106,9 @@ async function printVersionRevisions(version) {
async function(state) {
let platform = state.platforms[state.i - 1];
if (!platform) return state.value;
let rev = state.range[1];

for (let rev = state.range[1]; rev >= state.range[0]; rev--) {
for (; rev >= state.range[0]; rev--) {
// query google's storage api for the platform revision
let { items } = await request((
`${G_STORAGE_API_URL}?fields=items(name,metadata)&` +
Expand Down

0 comments on commit 8fdce06

Please sign in to comment.