From e1909bf5c899c9d08abb69942adeb5f13826c6b9 Mon Sep 17 00:00:00 2001 From: David Ollerhead Date: Fri, 2 Feb 2018 13:06:29 +0000 Subject: [PATCH] Support Mac App Store (--mas) builds (PR #532) --- docs/api.md | 2 +- src/build/buildMain.js | 2 +- src/cli.js | 2 +- src/infer/inferOs.js | 2 +- src/infer/inferUserAgent.js | 1 + test/module/inferUserAgentSpec.js | 1 + 6 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/api.md b/docs/api.md index 5ccc0d4..cc187ec 100644 --- a/docs/api.md +++ b/docs/api.md @@ -93,7 +93,7 @@ The name of the application, which will affect strings in titles and the icon. ``` -p, --platform ``` -Automatically determined based on the current OS. Can be overwritten by specifying either `linux`, `windows`, or `osx`. +Automatically determined based on the current OS. Can be overwritten by specifying either `linux`, `windows`, `osx` or `mas` for a Mac App Store specific build. The alternative values `win32` (for Windows) or `darwin`, `mac` (for OSX) can also be used. diff --git a/src/build/buildMain.js b/src/build/buildMain.js index 10318b8..e847b16 100644 --- a/src/build/buildMain.js +++ b/src/build/buildMain.js @@ -63,7 +63,7 @@ function maybeCopyIcons(options, appPath, callback) { return; } - if (options.platform === 'darwin') { + if (options.platform === 'darwin' || options.platform === 'mas') { callback(); return; } diff --git a/src/cli.js b/src/cli.js index 743e07f..2872541 100755 --- a/src/cli.js +++ b/src/cli.js @@ -43,7 +43,7 @@ if (require.main === module) { program.out = appDir; }) .option('-n, --name ', 'app name') - .option('-p, --platform ', '\'osx\', \'linux\' or \'windows\'') + .option('-p, --platform ', '\'osx\', \'mas\', \'linux\' or \'windows\'') .option('-a, --arch ', '\'ia32\' or \'x64\' or \'armv7l\'') .option('--app-version ', 'The release version of the application. Maps to the `ProductVersion` metadata property on Windows, and `CFBundleShortVersionString` on OS X.') .option('--build-version ', 'The build version of the application. Maps to the `FileVersion` metadata property on Windows, and `CFBundleVersion` on OS X.') diff --git a/src/infer/inferOs.js b/src/infer/inferOs.js index 30b4540..0bbf66b 100644 --- a/src/infer/inferOs.js +++ b/src/infer/inferOs.js @@ -2,7 +2,7 @@ import os from 'os'; function inferPlatform() { const platform = os.platform(); - if (platform === 'darwin' || platform === 'win32' || platform === 'linux') { + if ((platform === 'darwin' || platform === 'mas') || platform === 'win32' || platform === 'linux') { return platform; } diff --git a/src/infer/inferUserAgent.js b/src/infer/inferUserAgent.js index d643c41..09be621 100644 --- a/src/infer/inferUserAgent.js +++ b/src/infer/inferUserAgent.js @@ -30,6 +30,7 @@ export function getUserAgentString(chromeVersion, platform) { let userAgent; switch (platform) { case 'darwin': + case 'mas': userAgent = `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${chromeVersion} Safari/537.36`; break; case 'win32': diff --git a/test/module/inferUserAgentSpec.js b/test/module/inferUserAgentSpec.js index f5be960..3b7d4a0 100644 --- a/test/module/inferUserAgentSpec.js +++ b/test/module/inferUserAgentSpec.js @@ -6,6 +6,7 @@ const { assert } = chai; const TEST_RESULT = { darwin: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.75 Safari/537.36', + mas: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.75 Safari/537.36', win32: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.75 Safari/537.36', linux: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.75 Safari/537.36', };