Skip to content

Commit 15cd0f1

Browse files
committed
✨ Auto updater
1 parent a6526eb commit 15cd0f1

26 files changed

+878
-671
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ npm-debug.log*
2222
yarn-debug.log*
2323
yarn-error.log*
2424
dist
25+
26+
electron-builder.yaml

.prettierrc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"tabWidth": 4,
3-
"useTabs": true,
4-
"bracketSpacing": true,
5-
"singleQuote": false,
6-
"endOfLine": "crlf",
7-
"trailingComma": "all",
8-
"semi": true
2+
"tabWidth": 4,
3+
"useTabs": false,
4+
"bracketSpacing": true,
5+
"singleQuote": false,
6+
"endOfLine": "crlf",
7+
"trailingComma": "all",
8+
"semi": true
99
}

electron-builder.yaml.example

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
appId: com.example.ElectronTailwindReactTemplate
2+
3+
publish:
4+
provider: github
5+
token: YOUR_GITHUB_TOKEN
6+
7+
files:
8+
[
9+
"dist/**/*",
10+
"build/**/*",
11+
"node_modules/**/*",
12+
"package.json",
13+
"build/icon.*",
14+
]
15+
16+
directories:
17+
buildResources: assets
18+
19+
icon: ./build/icon.ico

package.json

Lines changed: 74 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,76 @@
11
{
2-
"name": "electron-react-tailwind-template",
3-
"author": {
4-
"email": "demirci.baris38@gmail.com",
5-
"name": "Barış DEMİRCİ",
6-
"url": "https://338.rocks"
7-
},
8-
"description": "Electron app template with React and Tailwind CSS",
9-
"repository": {
10-
"type": "git",
11-
"url": "https://github.com/barbarbar338/electron-react-tailwind-template"
12-
},
13-
"license": "GPL-3.0",
14-
"version": "1.0.0",
15-
"private": true,
16-
"devDependencies": {
17-
"@types/node": "^17.0.21",
18-
"@types/react": "^17.0.39",
19-
"@types/react-dom": "^17.0.11",
20-
"@types/react-router-dom": "^5.3.3",
21-
"autoprefixer": "^10.4.2",
22-
"concurrently": "^7.0.0",
23-
"cross-env": "^7.0.3",
24-
"electron": "^17.1.0",
25-
"electron-builder": "^22.14.13",
26-
"postcss": "^8.4.7",
27-
"prettier": "^2.5.1",
28-
"react-scripts": "^5.0.0",
29-
"rimraf": "^3.0.2",
30-
"tailwindcss": "3.0.23",
31-
"typescript": "^4.5.5",
32-
"wait-on": "^6.0.1"
33-
},
34-
"dependencies": {
35-
"@electron/remote": "^2.0.5",
36-
"auto-launch": "^5.0.5",
37-
"electron-is-dev": "^2.0.0",
38-
"electron-reloader": "^1.2.3",
39-
"electron-squirrel-startup": "^1.0.0",
40-
"react": "^17.0.2",
41-
"react-dom": "^17.0.2",
42-
"react-icons": "^4.3.1",
43-
"react-router-dom": "^6.2.1",
44-
"react-toastify": "^8.2.0",
45-
"react-use": "^17.3.2"
46-
},
47-
"main": "public/main.js",
48-
"homepage": "./",
49-
"scripts": {
50-
"prebuild": "rimraf build && rimraf dist",
51-
"react:build": "react-scripts build",
52-
"react:dev": "react-scripts start",
53-
"electron:build": "electron-builder -c.extraMetadata.main=build/main.js",
54-
"electron:dev": "electron .",
55-
"build": "npm run react:build && npm run electron:build",
56-
"dev": "concurrently -k \"cross-env BROWSER=none npm run react:dev\" \"npm run electron:dev\"",
57-
"format": "prettier --write ."
58-
},
59-
"eslintConfig": {
60-
"extends": [
61-
"react-app"
62-
]
63-
},
64-
"browserslist": {
65-
"production": [
66-
">0.2%",
67-
"not dead",
68-
"not op_mini all"
69-
],
70-
"development": [
71-
"last 1 chrome version",
72-
"last 1 firefox version",
73-
"last 1 safari version"
74-
]
75-
},
76-
"build": {
77-
"extends": null,
78-
"appId": "com.example.app",
79-
"files": [
80-
"dist/**/*",
81-
"build/**/*",
82-
"node_modules/**/*",
83-
"package.json",
84-
"build/icon.*"
85-
],
86-
"directories": {
87-
"buildResources": "assets"
88-
},
89-
"icon": "./build/icon.ico"
90-
}
2+
"name": "electron-react-tailwind-template",
3+
"author": {
4+
"email": "demirci.baris38@gmail.com",
5+
"name": "Barış DEMİRCİ",
6+
"url": "https://338.rocks"
7+
},
8+
"description": "Electron app template with React and Tailwind CSS",
9+
"repository": {
10+
"type": "git",
11+
"url": "https://github.com/barbarbar338/electron-react-tailwind-template"
12+
},
13+
"license": "GPL-3.0",
14+
"version": "1.0.1",
15+
"private": true,
16+
"devDependencies": {
17+
"@types/node": "^17.0.44",
18+
"@types/react": "^18.0.12",
19+
"@types/react-dom": "^18.0.5",
20+
"@types/react-router-dom": "^5.3.3",
21+
"autoprefixer": "^10.4.7",
22+
"cross-env": "^7.0.3",
23+
"electron": "^19.0.4",
24+
"electron-builder": "^23.0.3",
25+
"postcss": "^8.4.14",
26+
"prettier": "^2.7.0",
27+
"react-scripts": "^5.0.1",
28+
"rimraf": "^3.0.2",
29+
"tailwindcss": "3.1.3",
30+
"typescript": "^4.7.3",
31+
"wait-on": "^6.0.1"
32+
},
33+
"dependencies": {
34+
"@electron/remote": "^2.0.8",
35+
"auto-launch": "^5.0.5",
36+
"electron-is-dev": "^2.0.0",
37+
"electron-reloader": "^1.2.3",
38+
"electron-squirrel-startup": "^1.0.0",
39+
"electron-updater": "^5.0.1",
40+
"react": "^18.2.0",
41+
"react-dom": "^18.2.0",
42+
"react-icons": "^4.4.0",
43+
"react-router-dom": "^6.3.0",
44+
"react-toastify": "^9.0.4",
45+
"react-use": "^17.4.0"
46+
},
47+
"homepage": "./",
48+
"scripts": {
49+
"prebuild": "rimraf build && rimraf dist",
50+
"react:build": "react-scripts build",
51+
"react:dev": "cross-env BROWSER=none react-scripts start",
52+
"electron:build": "electron-builder build --win --publish never",
53+
"electron:deploy": "electron-builder build --win --publish always",
54+
"electron:dev": "electron .",
55+
"build": "npm run react:build && npm run electron:build",
56+
"deploy": "npm run react:build && npm run electron:deploy",
57+
"format": "prettier --write ."
58+
},
59+
"eslintConfig": {
60+
"extends": [
61+
"react-app"
62+
]
63+
},
64+
"browserslist": {
65+
"production": [
66+
">0.2%",
67+
"not dead",
68+
"not op_mini all"
69+
],
70+
"development": [
71+
"last 1 chrome version",
72+
"last 1 firefox version",
73+
"last 1 safari version"
74+
]
75+
}
9176
}

postcss.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
2-
plugins: {
3-
tailwindcss: {},
4-
autoprefixer: {},
5-
},
2+
plugins: {
3+
tailwindcss: {},
4+
autoprefixer: {},
5+
},
66
};

public/electron.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
const { app, BrowserWindow, ipcMain } = require("electron");
2+
const { autoUpdater } = require("electron-updater");
3+
const { createTray } = require("./utils/createTray");
4+
const { createMainWindow } = require("./utils/createMainWindow");
5+
const { createPopupWindow } = require("./utils/createPopupWindow");
6+
const { showNotification } = require("./utils/showNotification");
7+
const AutoLaunch = require("auto-launch");
8+
const remote = require("@electron/remote/main");
9+
const config = require("./utils/config");
10+
11+
if (config.isDev) require("electron-reloader")(module);
12+
if (require("electron-squirrel-startup")) app.quit();
13+
14+
remote.initialize();
15+
16+
const autoStart = new AutoLaunch({
17+
name: config.appName,
18+
});
19+
if (!config.isDev) autoStart.enable();
20+
21+
app.on("ready", async () => {
22+
config.mainWindow = await createMainWindow();
23+
config.tray = createTray();
24+
config.popupWindow = await createPopupWindow();
25+
showNotification(
26+
config.appName,
27+
"Application running on background! See application tray.",
28+
);
29+
});
30+
31+
app.on("window-all-closed", () => {
32+
if (process.platform !== "darwin") app.quit();
33+
});
34+
35+
app.on("activate", () => {
36+
if (BrowserWindow.getAllWindows().length === 0)
37+
config.mainWindow = createMainWindow();
38+
});
39+
40+
ipcMain.on("app_version", (event) => {
41+
event.sender.send("app_version", { version: app.getVersion() });
42+
});
43+
44+
autoUpdater.on("update-available", () => {
45+
config.mainWindow.webContents.send("update_available");
46+
});
47+
48+
autoUpdater.on("update-downloaded", () => {
49+
config.mainWindow.webContents.send("update_downloaded");
50+
});
51+
52+
ipcMain.on("restart_app", () => {
53+
autoUpdater.quitAndInstall();
54+
});

public/index.html

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
<!DOCTYPE html>
22
<html lang="en">
3-
<head>
4-
<meta charset="utf-8" />
5-
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6-
<meta name="viewport" content="width=device-width, initial-scale=1" />
7-
<meta name="theme-color" content="#000000" />
8-
<meta
9-
name="description"
10-
content="Web site created using create-react-app"
11-
/>
12-
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13-
<!--
3+
<head>
4+
<meta charset="utf-8" />
5+
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1" />
7+
<meta name="theme-color" content="#000000" />
8+
<meta
9+
name="description"
10+
content="Web site created using create-react-app"
11+
/>
12+
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13+
<!--
1414
manifest.json provides metadata used when your web app is installed on a
1515
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
1616
-->
17-
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
18-
<!--
17+
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
18+
<!--
1919
Notice the use of %PUBLIC_URL% in the tags above.
2020
It will be replaced with the URL of the `public` folder during the build.
2121
Only files inside the `public` folder can be referenced from the HTML.
@@ -24,12 +24,12 @@
2424
work correctly both with client-side routing and a non-root public URL.
2525
Learn how to configure a non-root public URL by running `npm run build`.
2626
-->
27-
<title>Electron React Tailwind Template</title>
28-
</head>
29-
<body>
30-
<noscript>You need to enable JavaScript to run this app.</noscript>
31-
<div id="root"></div>
32-
<!--
27+
<title>Electron React Tailwind Template</title>
28+
</head>
29+
<body>
30+
<noscript>You need to enable JavaScript to run this app.</noscript>
31+
<div id="root"></div>
32+
<!--
3333
This HTML file is a template.
3434
If you open it directly in the browser, you will see an empty page.
3535
@@ -39,5 +39,5 @@
3939
To begin the development, run `npm start` or `yarn start`.
4040
To create a production bundle, use `npm run build` or `yarn build`.
4141
-->
42-
</body>
42+
</body>
4343
</html>

public/main.js

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)