From 69d46f43c3a1aacf08ef9b94f8364399ba410b38 Mon Sep 17 00:00:00 2001 From: dubisdev Date: Fri, 12 Aug 2022 11:47:33 +0200 Subject: [PATCH 1/2] fix: disable autostart when running `yarn dev` --- app/main/createWindow/autoStart.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/main/createWindow/autoStart.js b/app/main/createWindow/autoStart.js index e28fa0fe..efb7f820 100644 --- a/app/main/createWindow/autoStart.js +++ b/app/main/createWindow/autoStart.js @@ -1,11 +1,12 @@ import { app } from 'electron' import AutoLaunch from 'auto-launch' -let appLauncher +const isLinux = !['win32', 'darwin'].includes(process.platform) +const isDevelopment = process.env.NODE_ENV === 'development' -const isLinux = ['win32', 'darwin'].indexOf(process.platform) === -1 - -if (isLinux) { appLauncher = new AutoLaunch({ name: 'Cerebro' }) } +const appLauncher = isLinux + ? new AutoLaunch({ name: 'Cerebro' }) + : null const isEnabled = async () => ( isLinux @@ -13,14 +14,15 @@ const isEnabled = async () => ( : app.getLoginItemSettings().openAtLogin ) -const set = (openAtLogin) => { +const set = async (openAtLogin) => { + const openAtStartUp = openAtLogin && !isDevelopment if (isLinux) { - return openAtLogin + return openAtStartUp ? appLauncher.enable() : appLauncher.disable() } - return app.setLoginItemSettings({ openAtLogin }) + return app.setLoginItemSettings({ openAtLogin: openAtStartUp }) } export default { isEnabled, set } From 4bd2a22c56c005fb6732f8c38d5ed563843e71c2 Mon Sep 17 00:00:00 2001 From: dubisdev Date: Fri, 12 Aug 2022 11:47:48 +0200 Subject: [PATCH 2/2] chore: add `package` command to build from source --- README.md | 18 +++++++++--------- package.json | 3 ++- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index dbc98ff9..4559eb47 100644 --- a/README.md +++ b/README.md @@ -59,14 +59,22 @@ And then install dependencies: yarn ``` -### Run +### Run in development mode ```bash $ yarn run dev ``` > Note: requires a node version >=16.x +### Build executable from source +If you would like to install one version but the package is not published you can use this command to build executable file from source: + +```bash +$ yarn package +``` + +> Note: in CI we use `yarn build` as there is an action to package and publish the executables ### Resolve common issues 1. `AssertionError: Current node version is not supported for development` on npm postinstall. After `yarn` postinstall script checks node version. If you see this error you have to check node and npm version in `package.json` `devEngines` section and install proper ones. @@ -89,14 +97,6 @@ Use shortcut `ctrl+space` to open app window and type `Cerebro Settings`. There *macOS*: `~/Library/Application Support/Cerebro/config.json` - -### Package -Use this command to build `.app` file: - -```bash -$ yarn build -``` - ## For developers ### Publish a release diff --git a/package.json b/package.json index 6382f9e5..299f60b2 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,8 @@ "start-hot": "yarn build-main-dev && cross-env HOT=1 NODE_ENV=development ./node_modules/.bin/electron -r @babel/register ./app", "release": "build -mwl --draft", "dev": "run-p hot-server start-hot", - "postinstall": "electron-builder install-app-deps" + "postinstall": "electron-builder install-app-deps", + "package": "yarn build && npx electron-builder" }, "build": { "productName": "Cerebro",