publish to mac app store

This commit is contained in:
Bruce Liu 2020-06-29 09:28:32 +08:00
parent b1f4b7c613
commit df7ddf5a00
8 changed files with 99 additions and 11 deletions

3
.gitignore vendored
View File

@ -4,4 +4,5 @@ dist/*.js.map
dist/*.html
bin/*
package-lock.json
.DS_Store
.DS_Store
*.provisionprofile

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key><true/>
<key>com.apple.security.inherit</key><true/>
<key>com.apple.security.cs.allow-jit</key><true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key><true/>
</dict>
</plist>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key><true/>
</dict>
</plist>

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key><true/>
<key>com.apple.security.application-groups</key>
<array>
<string>EM8VE646TZ.DevHYLiu.FluentReader</string>
</array>
<!-- Put any entitlements your app requires here. Below is a example -->
<key>com.apple.security.network.client</key><true/>
<key>com.apple.security.files.user-selected.read-write</key><true/>
<key>com.apple.security.files.user-selected.read-only</key><true/>
<key>com.apple.security.cs.allow-jit</key><true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key><true/>
<key>com.apple.security.cs.allow-dyld-environment-variables</key><true/>
</dict>
</plist>

31
build/resignAndPackage.sh Normal file
View File

@ -0,0 +1,31 @@
printf "......................\nresignAndPackage start\n\n"
# Name of your app.
APP="Fluent Reader"
# Your Certificate name.
CERT="Jieyu Yan (EM8VE646TZ)"
# The path of your app to sign.
APP_PATH="/Users/bruce/Documents/repos/fluent-reader/bin/darwin/x64/mas/$APP.app"
# The path to the location you want to put the signed package.
RESULT_PATH="/Users/bruce/Documents/repos/fluent-reader/bin/darwin/x64/mas/$APP-mac_store.pkg"
# The name of certificates you requested.
APP_KEY="3rd Party Mac Developer Application: $CERT"
INSTALLER_KEY="3rd Party Mac Developer Installer: $CERT"
# The path of your plist files.
PARENT_PLIST="build/entitlements.mas.plist"
CHILD_PLIST="build/entitlements.mas.inherit.plist"
LOGINHELPER_PLIST="build/entitlements.mas.loginhelper.plist"
FRAMEWORKS_PATH="$APP_PATH/Contents/Frameworks"
codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$FRAMEWORKS_PATH/Electron Framework.framework/Versions/A/Electron Framework"
codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$FRAMEWORKS_PATH/Electron Framework.framework/Versions/A/Libraries/libffmpeg.dylib"
codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$FRAMEWORKS_PATH/Electron Framework.framework/Libraries/libffmpeg.dylib"
codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$FRAMEWORKS_PATH/Electron Framework.framework"
codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$FRAMEWORKS_PATH/$APP Helper.app/Contents/MacOS/$APP Helper"
codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$FRAMEWORKS_PATH/$APP Helper.app/"
codesign -s "$APP_KEY" -f --entitlements "$LOGINHELPER_PLIST" "$APP_PATH/Contents/Library/LoginItems/$APP Login Helper.app/Contents/MacOS/$APP Login Helper"
codesign -s "$APP_KEY" -f --entitlements "$LOGINHELPER_PLIST" "$APP_PATH/Contents/Library/LoginItems/$APP Login Helper.app/"
codesign -s "$APP_KEY" -f --entitlements "$CHILD_PLIST" "$APP_PATH/Contents/MacOS/$APP"
codesign -s "$APP_KEY" -f --entitlements "$PARENT_PLIST" "$APP_PATH"
productbuild --component "$APP_PATH" /Applications --sign "$INSTALLER_KEY" "$RESULT_PATH"
printf "\nresignAndPackage end\n......................\n"

View File

@ -9,6 +9,7 @@
"start": "npm run build && npm run electron",
"package-win": "electron-builder -w --x64 && electron-builder -w --ia32 && electron-builder -w appx:arm64",
"package-mac": "sudo electron-builder --mac",
"package-mas": "sudo electron-builder --mac mas && sudo bash build/resignAndPackage.sh",
"package-linux": "electron-builder --linux"
},
"keywords": [],
@ -50,9 +51,20 @@
"deleteAppDataOnUninstall": true
},
"mac": {
"darkModeSupport": true,
"target": [
"dmg"
]
],
"category": "public.app-category.news"
},
"mas": {
"appId": "DevHYLiu.FluentReader",
"entitlements": "build/entitlements.mas.plist",
"entitlementsInherit": "build/entitlements.mas.inherit.plist",
"provisioningProfile": "build/embedded.provisionprofile",
"hardenedRuntime": false,
"gatekeeperAssess": false,
"asarUnpack": []
},
"linux": {
"target": [
@ -70,7 +82,7 @@
"@types/redux-thunk": "^2.1.0",
"@types/reselect": "^2.2.0",
"@yang991178/rss-parser": "^3.8.1",
"electron": "^9.0.4",
"electron": "^9.0.5",
"electron-builder": "^22.7.0",
"electron-react-devtools": "^0.5.3",
"electron-store": "^5.2.0",

View File

@ -3,20 +3,22 @@ import windowStateKeeper = require("electron-window-state")
import Store = require("electron-store")
import performUpdate from "./scripts/update-scripts"
const locked = app.requestSingleInstanceLock()
if (!locked) {
app.quit()
if (!process.mas) {
const locked = app.requestSingleInstanceLock()
if (!locked) {
app.quit()
}
}
let mainWindow: BrowserWindow
let store: Store
let restarting: boolean
function init() {
function init(setTheme = true) {
restarting = false
store = new Store()
performUpdate(store)
nativeTheme.themeSource = store.get("theme", "system")
if (setTheme) nativeTheme.themeSource = store.get("theme", "system")
}
init()
@ -96,7 +98,7 @@ app.on("window-all-closed", function () {
}
mainWindow = null
if (restarting) {
init()
init(false)
createWindow()
} else if (process.platform !== "darwin") {
app.quit()

View File

@ -161,10 +161,17 @@ export function importAll(path) {
Promise.all(promises).then(() => {
delete configs.nedb
store.clear()
let hasTheme = false
for (let [key, value] of Object.entries(configs)) {
// @ts-ignore
store.set(key, value)
if (key === THEME_STORE_KEY) {
setThemeSettings(value as ThemeSettings)
hasTheme = true
} else {
// @ts-ignore
store.set(key, value)
}
}
if (!hasTheme) setThemeSettings(ThemeSettings.Default)
ipcRenderer.send("restart")
})
}