electron-updater not detecting any updates - electron

i am making an app using electron
i already did everything regarding auto-updating the app
but its not detecting the new release (1.0.1) when opened, although i released it using electron-builder.
i did commit and checked everything
here is my code:
main.js:
function createWindow () {
// Create the browser mainWindow.
mainWindow = new BrowserWindow({
useContentSize: true,
show: false,
title: "My app",
webPreferences: {
preload: path.join(__dirname, './preload.js'),
plugins: true,
nodeIntegration: false,
webSecurity: false
}
})
registerKeys()
Menu.setApplicationMenu(createMenu());
mainWindow.loadFile(path.join(__dirname, 'index.html'));
mainWindow.once('ready-to-show', () => {
autoUpdater.checkForUpdatesAndNotify();
});
};
autoUpdater.on('update-available', (updateInfo) => {
dialog.showMessageBox({
type: "info",
buttons: ["Ok"],
title: "Update Available",
message: "There is a new version available (v" + updateInfo.version + "). It will be installed when the app closes."
});
}
);
ipcMain.on('restart_app', () => {
autoUpdater.quitAndInstall();
});
package.json:
"name": "my-app",
"version": "1.0.0",
"description": "my app",
"productName": "My app",
"main": "main.js",
"scripts": {
"start": "electron .",
"dist": "electron-builder",
"build": "electron-builder build --win --publish never",
"deploy": "electron-builder build --win --publish always"
},
"repository": "https://github.com/mygithub/myrepo",
"build": {
"publish": [
{
"provider": "github",
"owner": "mygithub",
"repo": "myrepo"
}

Related

gitlab-runner "FATAL: invalid argument" error

I developed an electron app. I want to send the latest version to Gitlaba and perform automatic update.
my package.json
{
"name": "kantar-tekillestirme",
"productName": "kantar",
"version": "2.0.0",
"description": "A minimal Electron application",
"main": "main.js",
"scripts": {
"start": "electron .",
"pack": "electron-builder --dir",
"build": "electron-builder --win",
"build-all": "electon-builder --win",
"build-dev": "electron-builder build --win --publish never",
"deploy": "electron-builder build --win --publish always",
"release": "electron-builder --win --publish always",
"dist:win": "electron-builder -w",
"dist": "electron-builder",
"postinstall": "",
"install": "node-gyp install"
},
"repository": {
"type": "git",
"url": "git+https://my.special.domain/kantar/kantar-tekillestirme",
"release": "latest"
},
"build": {
"appId": "com.kantar.updateexample",
"artifactName": "${productName}-${version}.${ext}",
"extraFiles": [
"files"
],
"publish": [
{
"provider": "generic",
"url": "https://my.special.domain"
}
],
"win": {
"target": "nsis",
"icon": "./files/icon/kantar.png",
"verifyUpdateCodeSignature": false
},
"nsis": {
"allowElevation": false,
"allowToChangeInstallationDirectory": true,
"oneClick": false,
"perMachine": true
}
},
"author": "GitHub",
"license": "CC0-1.0",
}
I removed some of the fields and he wouldn't let me publish them all
I'm sharing my "gitlab-ci" file.
copied the gitlab-ci file from here
Here's the mistake I made
Why am I encountering this error. How do I release a new version? Can you help me?

Whatsapp web js not working with electronjs

I make a project in electronJS with whatsapp-web.js. When i debug with npm start it works properly.
but when I build with electron and install the (.exe) file the project don't works. It seems the Puppeteer not running. How can I solve the problem?
NB: I am using electron-builder for build the application for Windows.
{
"name": "testapp",
"version": "1.0.0",
"description": "testapp",
"main": "main.js",
"scripts": {
"start": "electron .",
"build": "electron-builder"
},
"build": {
"appId": "com.testapp.test",
"productName": "testapp",
"target": "NSIS",
"nsis" : {
"oneClick" : true,
"allowToChangeInstallationDirectory" : false
}
},
"author": "Udayan Basak",
"license": "ISC",
"devDependencies": {
"electron": "^15.3.1",
"electron-builder": "^22.14.5"
},
"dependencies": {
"whatsapp-web.js": "^1.15.2"
}
}
This is my package.json data.
[Again: full project working fine in development mode. It causes error in production lavel.]
const { Client } = require('whatsapp-web.js');
const {app, BrowserWindow, ipcMain, ipcRenderer } = require('electron')
const client = new Client();
client.on('qr', (qr) => {
win.webContents.send("qrcode", qr)
});
client.on('ready', () => {
win.webContents.send("ready", "ready")
})

Uncaught TypeError: app.whenReady() / app.on("ready"). Electron 15.1.0

When the application is launched, the following problems occur.
Screenshot of app.whenReady function error.
app.whenReady().then(createWindow)
Screenshot of app.on('ready') function error.
app.on('ready', createWindow)
// index.js
const { app, BrowserWindow } = require('electron');
const path = require('path');
if (require('electron-squirrel-startup')) { // eslint-disable-line global-require
app.quit();
}
let mainWindow
function createWindow() {
mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
enableRemoteModule: true
}
});
mainWindow.loadFile(path.join(__dirname, 'index.html'));
mainWindow.webContents.openDevTools();
}
app.whenReady().then(createWindow)
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
// package.json
{
"name": "demo-app",
"productName": "demo-app",
"version": "1.0.0",
"description": "My Electron application description",
"main": "src/index.js",
"scripts": {
"start": "electron-forge start",
"package": "electron-forge package",
"make": "electron-forge make",
"publish": "electron-forge publish",
"lint": "echo \"No linting configured\""
},
"keywords": [],
"author": {
"name": "test",
"email": "test#test.com"
},
"license": "MIT",
"config": {
"forge": {
"packagerConfig": {},
"makers": [
{
"name": "#electron-forge/maker-squirrel",
"config": {
"name": "tutorial_app_remote"
}
},
{
"name": "#electron-forge/maker-zip",
"platforms": [
"darwin"
]
},
{
"name": "#electron-forge/maker-deb",
"config": {}
},
{
"name": "#electron-forge/maker-rpm",
"config": {}
}
]
}
},
"dependencies": {
"electron-squirrel-startup": "^1.0.0"
},
"devDependencies": {
"#electron-forge/cli": "^6.0.0-beta.61",
"#electron-forge/maker-deb": "^6.0.0-beta.61",
"#electron-forge/maker-rpm": "^6.0.0-beta.61",
"#electron-forge/maker-squirrel": "^6.0.0-beta.61",
"#electron-forge/maker-zip": "^6.0.0-beta.61",
"electron": "^15.1.0",
"nodemon": "^2.0.13"
}
}
// index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline'">
<title>Hello World!</title>
<link rel="stylesheet" href="index.css">
</head>
<body>
<h1>Hello World!</h1>
<p>Welcome to your Electron application.</p>
<script type="module" src="index.js">
</script>
</body>
</html>
Description
Application was built, using yarn create command and has all default functions and properties to run demo app. Two methods described above were checked that return the same error results.
I've also faced the problem with require is not defined, that was solved by adding false flag to the contextIsolation property of application window's webPreferences (IMHO can be useful for someone).
You should read a little bit more the Electron doc...
What I've checked was your main.js (**index.js** in your case).
BUT the problem is your **index.html** which is indicating also index.js as a ressource script.
Rename your index.js as main.js and do it also in your package.json : that your main process.
And obviuosly there will be no more error
After you will be able to put what you need in the renderer of index.html --> index.js.

publish to github with electron-builder

when I test to publish on github I get this error write ECONNRESET at WriteWrap.onWriteComplete [as oncomplete] (internal/stream_base_commons.js:87:16)
Here is my code
{
"name": "app",
"version": "1.0.0",
"description": "A minimal Electron application",
"main": "main.js",
"scripts": {
"start": "electron .",
"dist": "electron-builder",
"publish": "electron-builder --publish always"
},
"author": "GitHub",
"license": "CC0-1.0",
"devDependencies": {
"electron": "^8.0.0",
"electron-builder": "^22.3.2"
},
"repository": {
"type" : "git",
"url" : "https://github.com/Fizo55/app.git"
},
"build": {
"appId": "com.fizo55.app",
"productName": "app",
"target": "NSIS",
"directories": {
"output": "build"
},
"publish": [
{
"provider": "github",
"private": true,
"owner": "Fizo55",
"repo": "app",
"token": "mytoken"
}
],
"nsis": {
"allowToChangeInstallationDirectory": true,
"oneClick": false
}
}
}
Thanks for your help
After some test, it was my connection the problem, I switched on my 4G and now it work perfectly.

how to build electron app for windows in ubuntu using electron builder

I have created an electron app .Using electron-builder I created appImage in linux.I want build app for windows in linux .But it is throwing wine required error .please help to resolve this issue.
this is package.json
"name": "Gamer",
"version": "1.0.0",
"main": "main.js",
"repository": "https://github.com/XYX/GAME",
"dependencies": {
"#agm/core": "^1.0.0-beta.5",
...
"electron-builder-squirrel-windows": "^22.1.0",
"electron-packager": "^14.1.0",
"electron-reload": "^1.5.0",
"electron-store": "^5.1.0",
},
"devDependencies": {
...
"electron": "^7.1.1",
"electron-builder": "^22.1.0",
"electron-prebuilt": "^1.4.13",
"electron-updater": "^4.2.0",
...
},
"scripts": {
"ng": "ng",
"start": "ng serve",
"start:electron": "ng build --base-href ./ && electron .",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"electron": "electron .",
"electron-build": "ng build --prod && electron .",
"pack": "electron-builder --dir",
"dist": "electron-builder",
"build:Win": "electron-builder --win",
"ship": "build",
"electron-packager": "electron-packager ./ --all."
},
"peerDependencies": {
"#angular/animations": "^7.2.15",
"#angular/cdk": "^7.3.7",
"#angular/material": "^7.3.7"
},
"author": "",
"license": "ISC",
"build": {
"appId": "com.electron.coxGamer",
"compression": "normal",
"extends": null,
"files": [
"*.js",
"build",
"dist"
],
"mac": {
"target": "zip"
},
"linux": {
"target": [
"AppImage",
"zip"
]
},
"win": {
"target": "NSIS"
},
"publish": {
"provider": "github",
"repo": "https://github.com/XYX/GAME",
"owner": "XYX"
}
}
}
Even the electron-updater throwing error for dev-update.yml not found.and also app-icon is not setting
const { app, BrowserWindow, Menu,ipcMain } = require('electron');
const path = require('path');
const url = require('url');
const { autoUpdater } = require("electron-updater");
Menu.setApplicationMenu(null);
let mainWindow;
const createWindow = () => {
mainWindow = new BrowserWindow({
width: 1200,
height: 900
});
mainWindow.setMenuBarVisibility(false);
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, 'dist', 'index.html'),
protocol: 'file:',
slashes: true
}));
mainWindow.on('closed', () => {
mainWindow = null;
});
};
autoUpdater.on('update-downloaded', (info) => {
win.webContents.send('updateReady')
});
app.on('ready', () => {
createWindow();
autoUpdater.checkForUpdates();
});
ipcMain.on("quitAndInstall", (event, arg) => {
autoUpdater.quitAndInstall();
});
app.on('window-all-closed', () => {
if (process.platform !== 'darwin')
app.quit();
});
app.on('activate', () => {
if (mainWindow === null) {
createWindow();
}
});
Here is how I managed to build windows app from mac/linux. Maybe this can help you #Krazy.
First off all, I'm using the docker version of electron-builder
And then, here are the steps
1- Install electron builder dev in your project
npm install electron-builder —save-dev
2- In package.json add this to script
"dist": "electron-builder"
3- Launch Docker
4- In terminal, run
docker run --rm -ti \
--env-file <(env | grep -iE 'DEBUG|NODE_|ELECTRON_|YARN_|NPM_|CI|CIRCLE|TRAVIS_TAG|TRAVIS|TRAVIS_REPO_|TRAVIS_BUILD_|TRAVIS_BRANCH|TRAVIS_PULL_REQUEST_|APPVEYOR_|CSC_|GH_|GITHUB_|BT_|AWS_|STRIP|BUILD_') \
--env ELECTRON_CACHE="/root/.cache/electron" \
--env ELECTRON_BUILDER_CACHE="/root/.cache/electron-builder" \
-v ${PWD}:/project \
-v ${PWD##*/}-node-modules:/project/node_modules \
-v ~/.cache/electron:/root/.cache/electron \
-v ~/.cache/electron-builder:/root/.cache/electron-builder \
electronuserland/builder:wine
5- cd into your project
6- type
yarn && yarn dist -w
This is how I build my first windows app in Linux.
1- Install electron builder dev in your project
npm install electron-builder
2- Create a builder.js file your should look like this.
const builder = require("electron-builder")
const Platform = builder.Platform
// Promise is returned
builder.build({
targets: Platform.WINDOWS.createTarget(),
config: {
'win': {
'files': [
// All your files you are using
'main.js',
],
'compression': 'store',
'asar': false
}
}
})
.then(() => {
// handle result
})
.catch((error) => {
// handle error
})
3- Launch your app.

Resources