Skip to content

Commit

Permalink
electron-builder instead of packager
Browse files Browse the repository at this point in the history
Switched to electron-builder te prepare the File Association
  • Loading branch information
smariel committed Aug 25, 2018
1 parent 25214bf commit 95f569b
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 87 deletions.
37 changes: 14 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,36 +39,27 @@ Open a dedicated terminal and let the following command running while you are de

# Build and deploy

electron-packager is used to create binaries for all platforms. Install it *globally*:
electron-builder is used to create binaries for all platforms. Install it as a dev dependency:

$ npm install -g electron-packager
$ npm install electron-builder --save-dev

package.json contains multiple scripts to easily build PTree. Just run:

$ npm run build:xxx
$ npm run xxx

Where "xxx" must be replaced by:

| xxx | Platform |
| ------- | ------------------------- |
| mac | macOS |
| mas | macOS [Mac App Store](https://electron.atom.io/docs/tutorial/mac-app-store-submission-guide/) |
| lin32 | Linux x86 32 bits |
| lin64 | Linux x86 64 bits |
| linArm7 | Linux ARMv7 |
| win32 | Windows 32 bits |
| win64 | Windows 64 bits |
| macos | = mac + mas |
| windows | = win32 + win64 |
| linux | = lin32 + lin64 + linArm7 |
| 64 | = mac + win64 + lin64 |
| all | = macos + windows + linux |

What the script do:
- Package the app for the specifed platform into a folder
- Set the icon to the binary
- Copy the license, equations.pdf and a project example to the folder
- Zip the folder
| xxx | Platform |
| --------- | --------------------------------------------------- |
| build:mac | folder with macOS .app |
| build:win | folder with windows .exe + windows stuff |
| build:lin | folder with linux binary + linux stuff |
| dist:mac | macOS .app in .dmg disk image + extras files |
| dist:win | windows portable .exe in a .zip file + extras files |
| dist:lin | linux AppImage in a .zip file + extras files |
| build:all | = build:mac + build:win + build:lin |
| dist:all | = dist:mac + dist:win + dist:lin |


# Verifications
You can verify multiple items before deploying.
Expand Down
50 changes: 0 additions & 50 deletions docs/README.md

This file was deleted.

70 changes: 70 additions & 0 deletions electron-builder.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"appId" : "fr.sylvain-mariel.PTree",
"artifactName" : "${productName}.${ext}",
"directories" : {"output" : "bin"},
"asar" : false,
"files": [
"!bin/*",
"!icons/*",
"!docs/*",
"!sass/*",
"!test/*"
],
"extraResources": {
"from" : "docs/equations.pdf",
"to" : "app/docs/equations.pdf"
},
"win": {
"icon" : "icons/win/icon.ico",
"target" : "portable"
},
"linux": {
"icon" : "icons/png/",
"target" : {"target":"AppImage", "arch": "ia32"}
},
"mac": {
"category" : "public.app-category.developer-tools",
"icon" : "icons/mac/icon.icns",
"target" : "dmg"
},
"dmg": {
"iconSize": 80,
"window" : {
"x" : 400,
"y" : 100,
"width" : 540,
"height" : 380
},
"contents": [
{
"x" : 130,
"y" : 170,
"type" : "file"
},
{
"x" : 410,
"y" : 170,
"type" : "link",
"path" : "/Applications"
},
{
"x" : 130,
"y" : 0,
"type" : "file",
"path" : "docs/example.ptree"
},
{
"x" : 270,
"y" : 0,
"type" : "file",
"path" : "docs/equations.pdf"
},
{
"x" : 410,
"y" : 0,
"type" : "file",
"path" : "LICENSE.md"
}
]
}
}
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
"name": "PTree",
"version": "1.4.2",
"description": "Design power trees and estimate consumptions",
"author": "Sylvain Mariel",
"author": {
"name" : "Sylvain Mariel",
"email" : "sylvain.mariel@otmax.fr",
"url" : "https://github.com/smariel"
},
"license": "GPL-3.0",
"main": "main.js",
"jshintConfig": {
Expand All @@ -11,19 +15,14 @@
"scripts": {
"postinstall": "",
"start": "electron . --debug",
"build:mac": " electron-packager . --out=bin --platform=darwin --arch=x64 --overwrite --icon=icons/mac/icon.icns ; cp LICENSE.md bin/PTree-darwin-x64/LICENSE ; cp docs/equations.pdf bin/PTree-darwin-x64/equations.pdf ; cp docs/example.ptree bin/PTree-darwin-x64/example.ptree ; rm -f bin/PTree-macos.zip ; zip -r -X -y -q bin/PTree-macos.zip bin/PTree-darwin-x64/",
"build:mas": " electron-packager . --out=bin --platform=mas --arch=x64 --overwrite --icon=icons/mac/icon.icns ; cp LICENSE.md bin/PTree-mas-x64/LICENSE ; cp docs/equations.pdf bin/PTree-mas-x64/equations.pdf ; cp docs/example.ptree bin/PTree-mas-x64/example.ptree ; rm -f bin/PTree-mas.zip ; zip -r -X -y -q bin/PTree-mas.zip bin/PTree-mas-x64/",
"build:win32": " electron-packager . --out=bin --platform=win32 --arch=ia32 --overwrite --icon=icons/win/icon.ico ; cp LICENSE.md bin/PTree-win32-ia32/LICENSE ; cp docs/equations.pdf bin/PTree-win32-ia32/equations.pdf ; cp docs/example.ptree bin/PTree-win32-ia32/example.ptree ; rm -f bin/PTree-windows_32.zip ; zip -r -X -y -q bin/PTree-windows_32.zip bin/PTree-win32-ia32/",
"build:win64": " electron-packager . --out=bin --platform=win32 --arch=x64 --overwrite --icon=icons/win/icon.ico ; cp LICENSE.md bin/PTree-win32-x64/LICENSE ; cp docs/equations.pdf bin/PTree-win32-x64/equations.pdf ; cp docs/example.ptree bin/PTree-win32-x64/example.ptree ; rm -f bin/PTree-windows.zip ; zip -r -X -y -q bin/PTree-windows.zip bin/PTree-win32-x64/",
"build:lin32": " electron-packager . --out=bin --platform=linux --arch=ia32 --overwrite --icon=icons/png/1024x1024.png ; cp LICENSE.md bin/PTree-linux-ia32/LICENSE ; cp docs/equations.pdf bin/PTree-linux-ia32/equations.pdf ; cp docs/example.ptree bin/PTree-linux-ia32/example.ptree ; rm -f bin/PTree-linux_32.zip ; zip -r -X -y -q bin/PTree-linux_32.zip bin/PTree-linux-ia32/",
"build:lin64": " electron-packager . --out=bin --platform=linux --arch=x64 --overwrite --icon=icons/png/1024x1024.png ; cp LICENSE.md bin/PTree-linux-x64/LICENSE ; cp docs/equations.pdf bin/PTree-linux-x64/equations.pdf ; cp docs/example.ptree bin/PTree-linux-x64/example.ptree ; rm -f bin/PTree-linux.zip ; zip -r -X -y -q bin/PTree-linux.zip bin/PTree-linux-x64/",
"build:linArm7": "electron-packager . --out=bin --platform=linux --arch=armv7l --overwrite --icon=icons/png/1024x1024.png ; cp LICENSE.md bin/PTree-linux-armv7l/LICENSE ; cp docs/equations.pdf bin/PTree-linux-armv7l/equations.pdf ; cp docs/example.ptree bin/PTree-linux-armv7l/example.ptree ; rm -f bin/PTree-linux_arm.zip ; zip -r -X -y -q bin/PTree-linux_arm.zip bin/PTree-linux-armv7l/",
"build:macos": " npm run build:mac && npm run build:mas",
"build:windows": "npm run build:win32 && npm run build:win64",
"build:linux": " npm run build:lin32 && npm run build:lin64 && npm run build:linArm7",
"build:64": " npm run build:mac && npm run build:win64 && npm run build:lin64",
"build:all": " npm run build:macos && npm run build:windows && npm run build:linux",
"build": " npm run build:all"
"build:mac": "electron-builder --config electron-builder.json --mac --dir",
"build:win": "electron-builder --config electron-builder.json --win --dir",
"build:lin": "electron-builder --config electron-builder.json --linux --dir",
"dist:mac": " electron-builder --config electron-builder.json --mac ; cd bin ; mv PTree.dmg PTree-macos.dmg",
"dist:win": " electron-builder --config electron-builder.json --win ; cd bin ; mkdir PTree ; mv PTree.exe PTree/ ; cp ../LICENSE.md PTree/LICENSE.txt ; cp ../docs/equations.pdf PTree/ ; cp ../docs/example.ptree PTree/ ; rm -f PTree-windows.zip ; zip -r -X -y -q PTree-windows.zip PTree/ ; rm -rf PTree",
"dist:lin": " electron-builder --config electron-builder.json --linux ; cd bin ; mkdir PTree ; mv PTree.AppImage PTree/ ; cp ../LICENSE.md PTree/LICENSE.txt ; cp ../docs/equations.pdf PTree/ ; cp ../docs/example.ptree PTree/ ; rm -f PTree-linux.zip ; zip -r -X -y -q PTree-linux.zip PTree/ ; rm -rf PTree",
"build:all": "npm run build:mac && npm run build:win && npm run build:lin",
"dist:all": " npm run dist:mac && npm run dist:win && npm run dist:lin"
},
"repository": {
"type": "git",
Expand All @@ -50,5 +49,6 @@
},
"devDependencies": {
"electron": "^2.0.6"
"electron-builder": "^20.28.2"
}
}

0 comments on commit 95f569b

Please sign in to comment.