From dde26fe01bf459b2b5bddb08ae01881eca5e9d23 Mon Sep 17 00:00:00 2001 From: Tangb Date: Sat, 5 Feb 2022 18:28:34 +0100 Subject: [PATCH] Properly handle errors in linux and windows. Disable publish during packaging --- package-lock.json | 4 ++-- package.json | 2 +- scripts/build-linux64.sh | 24 +++++++++++++++++++++++- scripts/build-mac64.sh | 4 ++-- scripts/build-windows64.bat | 13 +++++++++++-- 5 files changed, 39 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index bbdb7d2..3ed7da5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "cleep-desktop", - "version": "0.1.5", + "version": "0.1.6", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "cleep-desktop", - "version": "0.1.5", + "version": "0.1.6", "license": "MIT", "dependencies": { "@electron/remote": "^1.2.2", diff --git a/package.json b/package.json index 41c54fa..28b68aa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cleep-desktop", - "version": "0.1.5", + "version": "0.1.6", "description": "Desktop application to manage your Cleep devices", "main": "main.js", "scripts": { diff --git a/scripts/build-linux64.sh b/scripts/build-linux64.sh index f406651..593d801 100755 --- a/scripts/build-linux64.sh +++ b/scripts/build-linux64.sh @@ -1,5 +1,21 @@ #!/bin/bash +# Check command result +# $1: command result (usually $?) +# $2: awaited command result +# $3: error message +checkResult() { + if [ $1 -ne $2 ] + then + msg=$3 + if [[ -z "$1" ]]; then + msg="see output log" + fi + echo -e "${RED}Error occured: $msg.${NOCOLOR}" + exit 1 + fi +} + # env CLEEPDESKTOPPATH=packaging/cleepdesktop_tree @@ -16,8 +32,10 @@ echo echo "Packaging cleepdesktopcore..." echo "-----------------------------" python3 -m pip install -r requirements.txt +checkResult $? 0 "Failed to install python dependencies" cp config/cleepdesktopcore-linux64.spec cleepdesktopcore-linux64.spec python3 -m PyInstaller --workpath packaging --clean --noconfirm --noupx --debug all --log-level INFO cleepdesktopcore-linux64.spec +checkResult $? 0 "Failed to build core application" rm cleepdesktopcore-linux64.spec echo "Generated files:" ls -l dist/cleepdesktopcore @@ -29,7 +47,9 @@ echo echo "Building electron app..." echo "------------------------" npm ci +checkResult $? 0 "Failed to run npm" node_modules/.bin/tsc --outDir "$CLEEPDESKTOPPATH" +checkResult $? 0 "Failed to build electron application" echo "Done" # copy files and dirs @@ -52,10 +72,12 @@ then echo "Publishing cleepdesktop..." echo "--------------------------" GH_TOKEN=$GH_TOKEN_CLEEPDESKTOP node_modules/.bin/electron-builder --linux --x64 --projectDir "$CLEEPDESKTOPPATH" --publish always + checkResult $? 0 "Failed to publish cleepdesktop" else echo "Packaging cleepdesktop..." echo "-------------------------" - node_modules/.bin/electron-builder --linux --x64 --projectDir "$CLEEPDESKTOPPATH" + node_modules/.bin/electron-builder --linux --x64 --projectDir "$CLEEPDESKTOPPATH" --publish never + checkResult $? 0 "Failed to package cleepdesktop" fi # cleaning diff --git a/scripts/build-mac64.sh b/scripts/build-mac64.sh index 22a57dd..a7823a9 100755 --- a/scripts/build-mac64.sh +++ b/scripts/build-mac64.sh @@ -64,7 +64,7 @@ echo "Done" # electron-builder echo -echo "DEBUG cmd param \"$1\"" +echo if [ "$1" == "publish" ] then echo "Publishing cleepdesktop..." @@ -74,7 +74,7 @@ then else echo "Packaging cleepdesktop..." echo "-------------------------" - node_modules/.bin/electron-builder --mac --x64 --projectDir "$CLEEPDESKTOPPATH" + node_modules/.bin/electron-builder --mac --x64 --projectDir "$CLEEPDESKTOPPATH" --publish never checkResult $? 0 "Failed to package cleepdesktop" fi diff --git a/scripts/build-windows64.bat b/scripts/build-windows64.bat index 11fb910..1973bf8 100644 --- a/scripts/build-windows64.bat +++ b/scripts/build-windows64.bat @@ -15,9 +15,11 @@ echo. echo Packaging cleepdesktopcore... echo ----------------------------- py -3 -m pip install -r ./requirements.txt +if %ERRORLEVEL% NEQ 0 goto :error py -3 -m pip freeze xcopy /q /y config\cleepdesktopcore-windows64.spec . py -3 -m PyInstaller --workpath packaging --clean --noconfirm --noupx --windowed --debug all --log-level INFO cleepdesktopcore-windows64.spec +if %ERRORLEVEL% NEQ 0 goto :error del /q cleepdesktopcore-windows64.spec echo Generated files: dir dist\cleepdesktopcore @@ -40,7 +42,9 @@ echo. echo Building electron app... echo ------------------------ call npm ci +if %ERRORLEVEL% NEQ 0 goto :error cmd /C "node_modules\.bin\tsc --outDir %CLEEPDESKTOPPATH%" +if %ERRORLEVEL% NEQ 0 goto :error echo Done :: copy files and dirs @@ -68,10 +72,12 @@ if "%1" == "publish" ( echo -------------------------- set "GH_TOKEN=%GH_TOKEN_CLEEPDESKTOP%" cmd /C "node_modules\.bin\electron-builder --windows --x64 --projectDir %CLEEPDESKTOPPATH% --publish always" + if %ERRORLEVEL% NEQ 0 goto :error ) else ( echo Packaging cleepdesktop... echo ------------------------- - cmd /C "node_modules\.bin\electron-builder --windows --x64 --projectDir %CLEEPDESKTOPPATH%" + cmd /C "node_modules\.bin\electron-builder --windows --x64 --projectDir %CLEEPDESKTOPPATH% --publish never" + if %ERRORLEVEL% NEQ 0 goto :error ) :: finalizing moving generated stuff to dist directory and removing temp stuff @@ -92,4 +98,7 @@ rmdir /Q /S core\modules\__pycache__ echo Done echo. -echo Build result in dist/ folder \ No newline at end of file +echo Build result in dist/ folder + +:error +echo ===== Error occured see above ===== \ No newline at end of file