From 95f569b350bb9f890be9e9b7a76ed964fd559d44 Mon Sep 17 00:00:00 2001 From: Sylvain Mariel Date: Sat, 25 Aug 2018 20:46:33 +0200 Subject: [PATCH] electron-builder instead of packager Switched to electron-builder te prepare the File Association --- README.md | 37 +++++++++-------------- docs/README.md | 50 ------------------------------- electron-builder.json | 70 +++++++++++++++++++++++++++++++++++++++++++ package.json | 28 ++++++++--------- 4 files changed, 98 insertions(+), 87 deletions(-) delete mode 100644 docs/README.md create mode 100644 electron-builder.json diff --git a/README.md b/README.md index 10def33..bba0af8 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/docs/README.md b/docs/README.md deleted file mode 100644 index 9184cb4..0000000 --- a/docs/README.md +++ /dev/null @@ -1,50 +0,0 @@ -![icon](https://raw.githubusercontent.com/smariel/PTree/master/icons/png/128x128.png) - -PTree aims to help building power supplies on electronics design. -A first window is dedicated to build the tree itself by adding sources and loads. -The second window lists all components with their consumption on each power supplies. -The third window is a graphical summary of all consumption on the design. - -[Download PTree](https://github.com/smariel/PTree/releases) - -![screenshot](https://raw.githubusercontent.com/smariel/PTree/master/docs/screenshot.png) -![screenshot2](https://raw.githubusercontent.com/smariel/PTree/master/docs/screenshot2.png) - -## Basic commands -Simple installation using git and npm: - - $ git clone https://github.com/smariel/PTree - $ cd PTree - $ npm install - -Automatically build SASS on each save (in a dedicated shell): - - $ cd sass - $ ./watch.sh - -Run: - - $ npm start - -Build and deploy using electron-packager: - - $ npm run build: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 | -| all | = macos + windows + linux | - -Finally, a complete view of the objects imbrication can be found in /docs/synop.jpg -![synoptic](https://raw.githubusercontent.com/smariel/PTree/master/docs/synop.jpg) diff --git a/electron-builder.json b/electron-builder.json new file mode 100644 index 0000000..64a12f1 --- /dev/null +++ b/electron-builder.json @@ -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" + } + ] + } +} diff --git a/package.json b/package.json index 55797c9..7e47d47 100644 --- a/package.json +++ b/package.json @@ -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": { @@ -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", @@ -50,5 +49,6 @@ }, "devDependencies": { "electron": "^2.0.6" + "electron-builder": "^20.28.2" } }