Skip to content

Commit

Permalink
✨ Auto updater
Browse files Browse the repository at this point in the history
  • Loading branch information
barbarbar338 committed Jun 15, 2022
1 parent a6526eb commit 15cd0f1
Show file tree
Hide file tree
Showing 26 changed files with 878 additions and 671 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
dist

electron-builder.yaml
14 changes: 7 additions & 7 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"tabWidth": 4,
"useTabs": true,
"bracketSpacing": true,
"singleQuote": false,
"endOfLine": "crlf",
"trailingComma": "all",
"semi": true
"tabWidth": 4,
"useTabs": false,
"bracketSpacing": true,
"singleQuote": false,
"endOfLine": "crlf",
"trailingComma": "all",
"semi": true
}
19 changes: 19 additions & 0 deletions electron-builder.yaml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
appId: com.example.ElectronTailwindReactTemplate

publish:
provider: github
token: YOUR_GITHUB_TOKEN

files:
[
"dist/**/*",
"build/**/*",
"node_modules/**/*",
"package.json",
"build/icon.*",
]

directories:
buildResources: assets

icon: ./build/icon.ico
163 changes: 74 additions & 89 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,91 +1,76 @@
{
"name": "electron-react-tailwind-template",
"author": {
"email": "demirci.baris38@gmail.com",
"name": "Barış DEMİRCİ",
"url": "https://338.rocks"
},
"description": "Electron app template with React and Tailwind CSS",
"repository": {
"type": "git",
"url": "https://github.com/barbarbar338/electron-react-tailwind-template"
},
"license": "GPL-3.0",
"version": "1.0.0",
"private": true,
"devDependencies": {
"@types/node": "^17.0.21",
"@types/react": "^17.0.39",
"@types/react-dom": "^17.0.11",
"@types/react-router-dom": "^5.3.3",
"autoprefixer": "^10.4.2",
"concurrently": "^7.0.0",
"cross-env": "^7.0.3",
"electron": "^17.1.0",
"electron-builder": "^22.14.13",
"postcss": "^8.4.7",
"prettier": "^2.5.1",
"react-scripts": "^5.0.0",
"rimraf": "^3.0.2",
"tailwindcss": "3.0.23",
"typescript": "^4.5.5",
"wait-on": "^6.0.1"
},
"dependencies": {
"@electron/remote": "^2.0.5",
"auto-launch": "^5.0.5",
"electron-is-dev": "^2.0.0",
"electron-reloader": "^1.2.3",
"electron-squirrel-startup": "^1.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-icons": "^4.3.1",
"react-router-dom": "^6.2.1",
"react-toastify": "^8.2.0",
"react-use": "^17.3.2"
},
"main": "public/main.js",
"homepage": "./",
"scripts": {
"prebuild": "rimraf build && rimraf dist",
"react:build": "react-scripts build",
"react:dev": "react-scripts start",
"electron:build": "electron-builder -c.extraMetadata.main=build/main.js",
"electron:dev": "electron .",
"build": "npm run react:build && npm run electron:build",
"dev": "concurrently -k \"cross-env BROWSER=none npm run react:dev\" \"npm run electron:dev\"",
"format": "prettier --write ."
},
"eslintConfig": {
"extends": [
"react-app"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"build": {
"extends": null,
"appId": "com.example.app",
"files": [
"dist/**/*",
"build/**/*",
"node_modules/**/*",
"package.json",
"build/icon.*"
],
"directories": {
"buildResources": "assets"
},
"icon": "./build/icon.ico"
}
"name": "electron-react-tailwind-template",
"author": {
"email": "demirci.baris38@gmail.com",
"name": "Barış DEMİRCİ",
"url": "https://338.rocks"
},
"description": "Electron app template with React and Tailwind CSS",
"repository": {
"type": "git",
"url": "https://github.com/barbarbar338/electron-react-tailwind-template"
},
"license": "GPL-3.0",
"version": "1.0.1",
"private": true,
"devDependencies": {
"@types/node": "^17.0.44",
"@types/react": "^18.0.12",
"@types/react-dom": "^18.0.5",
"@types/react-router-dom": "^5.3.3",
"autoprefixer": "^10.4.7",
"cross-env": "^7.0.3",
"electron": "^19.0.4",
"electron-builder": "^23.0.3",
"postcss": "^8.4.14",
"prettier": "^2.7.0",
"react-scripts": "^5.0.1",
"rimraf": "^3.0.2",
"tailwindcss": "3.1.3",
"typescript": "^4.7.3",
"wait-on": "^6.0.1"
},
"dependencies": {
"@electron/remote": "^2.0.8",
"auto-launch": "^5.0.5",
"electron-is-dev": "^2.0.0",
"electron-reloader": "^1.2.3",
"electron-squirrel-startup": "^1.0.0",
"electron-updater": "^5.0.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^4.4.0",
"react-router-dom": "^6.3.0",
"react-toastify": "^9.0.4",
"react-use": "^17.4.0"
},
"homepage": "./",
"scripts": {
"prebuild": "rimraf build && rimraf dist",
"react:build": "react-scripts build",
"react:dev": "cross-env BROWSER=none react-scripts start",
"electron:build": "electron-builder build --win --publish never",
"electron:deploy": "electron-builder build --win --publish always",
"electron:dev": "electron .",
"build": "npm run react:build && npm run electron:build",
"deploy": "npm run react:build && npm run electron:deploy",
"format": "prettier --write ."
},
"eslintConfig": {
"extends": [
"react-app"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
8 changes: 4 additions & 4 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};
54 changes: 54 additions & 0 deletions public/electron.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const { app, BrowserWindow, ipcMain } = require("electron");
const { autoUpdater } = require("electron-updater");
const { createTray } = require("./utils/createTray");
const { createMainWindow } = require("./utils/createMainWindow");
const { createPopupWindow } = require("./utils/createPopupWindow");
const { showNotification } = require("./utils/showNotification");
const AutoLaunch = require("auto-launch");
const remote = require("@electron/remote/main");
const config = require("./utils/config");

if (config.isDev) require("electron-reloader")(module);
if (require("electron-squirrel-startup")) app.quit();

remote.initialize();

const autoStart = new AutoLaunch({
name: config.appName,
});
if (!config.isDev) autoStart.enable();

app.on("ready", async () => {
config.mainWindow = await createMainWindow();
config.tray = createTray();
config.popupWindow = await createPopupWindow();
showNotification(
config.appName,
"Application running on background! See application tray.",
);
});

app.on("window-all-closed", () => {
if (process.platform !== "darwin") app.quit();
});

app.on("activate", () => {
if (BrowserWindow.getAllWindows().length === 0)
config.mainWindow = createMainWindow();
});

ipcMain.on("app_version", (event) => {
event.sender.send("app_version", { version: app.getVersion() });
});

autoUpdater.on("update-available", () => {
config.mainWindow.webContents.send("update_available");
});

autoUpdater.on("update-downloaded", () => {
config.mainWindow.webContents.send("update_downloaded");
});

ipcMain.on("restart_app", () => {
autoUpdater.quitAndInstall();
});
40 changes: 20 additions & 20 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Expand All @@ -24,12 +24,12 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Electron React Tailwind Template</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
<title>Electron React Tailwind Template</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
Expand All @@ -39,5 +39,5 @@
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</body>
</html>
37 changes: 0 additions & 37 deletions public/main.js

This file was deleted.

Loading

0 comments on commit 15cd0f1

Please sign in to comment.