How to release the electron app with only modified modules/files? - javascript

I am using electron builder to package the app and releasing on github private repository and also implemented electron-updater to update the app automatically in background, everything is working fine.
but the problem is each time i am releasing the app on github using below script
"scripts": {
"deploy": "electron-builder --config=electron-builder.yml build --win --x64 --ia32 --publish always"
},
Electron-builder config file
directories:
output: dist
buildResources: build
nsis:
allowToChangeInstallationDirectory: true
oneClick: false
perMachine: false
deleteAppDataOnUninstall: true
license: ./license.txt
win:
target:
- target: nsis
icon: ./icons/logo.png
mac:
icon: ./icons/icon.icns
target:
- target: dmg
- target: zip
hardenedRuntime: true
gatekeeperAssess: false
entitlements: build/macos/entitlements.mac.plist
entitlementsInherit: build/macos/entitlements.mac.plist
dmg:
sign: false
linux:
target:
- target: deb
- target: tar.gz
- target: snap
asar: true
buildDependenciesFromSource: true
compression: store
publish:
provider: github
token: xxxxxxxxxxxxxxxxxxxxxxxxxxx
releaseType: release
Pakcage.json
{
"name": "testapp",
"productName": "testapp",
"version": "0.0.1",
"description": "My Electron application description",
"main": "src/main.js",
"scripts": {
"start": "electron-forge start",
"package": "electron-forge package",
"make": "electron-forge make",
"publish": "electron-forge publish",
"lint": "echo \"No linting configured\"",
"clean": "npm cache clean --force",
"build": "electron-builder --config=electron-builder.yml build --win --x64 --ia32 --publish never",
"deploy": "electron-builder --config=electron-builder.yml build --win --x64 --ia32 --publish always",
"postinstall": "electron-builder install-app-deps"
},
"repository": {
"type": "git",
"url": "repourl"
},
"keywords": [],
"author": {
"name": "name",
"email": "emailid"
},
"license": "MIT",
"build": {
"appId": "appid",
"category": "Business",
"publish": [
{
"provider": "github",
"private": true,
"owner": "user",
"repo": "reponmae"
}
]
},
"config": {
"forge": {
"packagerConfig": {},
"makers": [
{
"name": "#electron-forge/maker-squirrel",
"config": {
"name": "DesktopDMS"
}
},
{
"name": "#electron-forge/maker-zip",
"platforms": [
"darwin"
]
},
{
"name": "#electron-forge/maker-deb",
"config": {}
},
{
"name": "#electron-forge/maker-rpm",
"config": {}
}
]
}
},
"dependencies": {
"#progress/kendo-ui": "^2020.2.617", //i know kendo and synfusion UI packages increasing app size
"#syncfusion/ej2": "^18.1.59",
"axios": "^0.19.2",
"electron-json-storage": "^4.2.0",
"electron-updater": "^4.3.5",
"jquery": "^3.5.1",
"jsrender": "^1.0.6",
"material-datetime-picker": "^2.4.0",
"materialize-css": "^1.0.0-rc.2"
},
"devDependencies": {
"#electron-forge/cli": "^6.0.0-beta.52",
"#electron-forge/maker-deb": "^6.0.0-beta.51",
"#electron-forge/maker-rpm": "^6.0.0-beta.51",
"#electron-forge/maker-squirrel": "^6.0.0-beta.51",
"#electron-forge/maker-zip": "^6.0.0-beta.51",
"electron": "9.0.4",
"electron-builder": "^22.8.0",
}
}
electron builder always creating new package/installer/app with same size[in between 250-300MB] and electron updater is downloading the updated version of app.
So how can i reduce the size of progressive releases[or release only modified module/files] because its very frustrating to download complete app each time.
I have tried compression[not getting much difference] and removed some unused packages as well.
As i know VS Code/ Zoom/ Slack are managing this scenario but i don't know how.
I need some help/direction to achieve it. Thanks in advance.

Mate that's not possible at the moment. I request you to follow the common approach of bundling new application and make release.

Related

Electron app becomes blank whenever I reload

I'm making an electron app however it my page turns blanks whenever I reload it - with Ctrl + R. The developer tools becomes blank as well and it shows the following error -
Devtools was disconnected from the page
Once page is reloaded DevTools will automatically reconnect
This is my package.json
{
"name": "pla",
"version": "1.0.0",
"description": "T",
"main": "main.js",
"scripts": {
"start": "electron .",
"rebuild": "electron-rebuild -f -w sqlite3"
},
"author": "R",
"license": "MIT",
"dependencies": {
"custom-electron-titlebar": "^3.2.4",
"electron": "^10.1.3",
"jquery": "^3.5.1",
"knex": "^0.21.6",
"sqlite3": "^5.0.0"
},
"devDependencies": {
"electron-rebuild": "^2.2.0"
}
}
Initialise devtools
// Add developer tools item if not in production
if (process.env.NODE_ENV != "production") {
mainMenuTemplate.push({
label: "Developer Tools",
submenu: [
{
label: "Toggle Devtools",
accelerator: process.platform == "darwin" ? "command+I" : "Ctrl+I",
click(item, focusedWindow) {
focusedWindow.toggleDevTools();
},
},
{
role: "reload",
},
],
});
}

When I wants to run my code in local server i always get this kinds of error "SyntaxError: Cannot use import statement outside a module"

I've got a web development project based on e-commerce but when I try to run my project on the local server I always getting this type of error. Don't find any solution yet.
For better understanding, I added my server.js and package.json file in the post
Here it is sever.js
import express from 'express';
import data from './data';
const app = express();
app.get("/api/products", (req, res) => {
res.send(data.products);
});
app.listen (5000, () => {console.log("Server started at http://localhost:5000")})
In package.json
{
"name": "web-development",
"version": "1.0.0",
"description": "nothing",
"main": "nothing",
"scripts": {
"start": "nodemon --watch backend --exec babel-node backend/server.js"
},
"repository": {
"type": "git",
"url": ""
},
"author": "",
"license": "ISC",
"bugs": {
"url": ""
},
"homepage": "",
"dependencies": {
"express": "^4.17.1"
},
"devDependencies": {
"#babel/cli": "^7.10.5",
"#babel/core": "^7.11.1",
"#babel/node": "^7.10.5",
"#babel/preset-env": "^7.11.0",
"nodemon": "^2.0.4"
}
}
Update:
As far console, I added "type": "module", package.json now I get another error
Cannot GET /
Showing in my browser
Node.js does not support ES6 modules import/export syntax out of the box. Although you can enable it via --experimental-modules flag.
The project already uses Babel which transpile ES6 syntax to ES2015, but you need to add a few more scripts to package.json
start: Starts watching the file for changes. Then rebuilds the code and pipes it to babel-node
build: When you are ready to deploy the code for production, you build the ES2015 version of the code and you can run that.
package.json:
"scripts": {
"start": "nodemon --watch backend --exec babel-node backend/server.js"
"build": "babel backend/server.js -o lib/server.js",
},
To build the production code, run npm run build. Once the code is built, you can then run node lib/server.js
lib/server.js will look like:
Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
I suggest you just editing your package.json like the following.
{
"name": "web-development",
"version": "1.0.0",
"description": "nothing",
"main": "nothing",
"scripts": {
"start": "nodemon --watch backend --exec babel-node backend/server.js"
},
"repository": {
"type": "git",
"url": ""
},
"author": "",
"type": "module",
"license": "ISC",
"bugs": {
"url": ""
},
"homepage": "",
"dependencies": {
"express": "^4.17.1"
},
"devDependencies": {
"#babel/cli": "^7.10.5",
"#babel/core": "^7.11.1",
"#babel/node": "^7.10.5",
"#babel/preset-env": "^7.11.0",
"nodemon": "^2.0.4"
}
}

Elasticsearch Javascript Client Update not working

I am using elasticsearch JavaScript client with nodejs (Typescript). The update query is not working as expected can any one help me on this
My code is
const EsResponse = await esClient.update({
index: "myindex",
type: "mytype",
id: "1",
body: {
// put the partial document under the `doc` key
doc: {
title: "Updated"
}
}
});
And the response is
{
"msg": "[invalid_type_name_exception] Document mapping type name can't start with '_', found: [_update]",
"path": "/myindex/_update/1",
"query": {
"type": "mytype"
},
"body": "{\"doc\":{\"title\":\"Updated\"}}",
"statusCode": 400,
"response": "{\"error\":{\"root_cause\":[{\"type\":\"invalid_type_name_exception\",\"reason\":\"Document mapping type name can't start with '_', found: [_update]\"}],\"type\":\"invalid_type_name_exception\",\"reason\":\"Document mapping type name can't start with '_', found: [_update]\"},\"status\":400}"
}
My package.json file is
{
"name": "backend",
"version": "1.0.0",
"description": "The backend system",
"main": "dist/index.js",
"scripts": {
"prebuild": "tslint -c tslint.json -p tsconfig.json --fix",
"build": "tsc",
"prestart": "npm run build",
"start": "nodemon .",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Jagadeesh Kumar CK",
"license": "ISC",
"dependencies": {
"#types/body-parser": "^1.17.1",
"#types/cors": "^2.8.6",
"cors": "^2.8.5",
"elasticsearch": "^16.5.0",
"express": "^4.17.1",
"ts-node": "^8.5.2"
},
"devDependencies": {
"#types/elasticsearch": "^5.0.36",
"#types/express": "^4.17.2",
"#types/node": "^12.12.12",
"tslint": "^5.20.1",
"typescript": "^3.7.2"
}
}
My elastic search version is 6.3
The reason is because you're using a 7.x client against a 6.3 ES cluster.
You just need to configure the client to talk to 6.x clusters using the apiVersion configuration setting, like this:
var elasticsearch = require('elasticsearch');
var client = new elasticsearch.Client({
... other config options ...
"apiVersion": "6.8" <--- add this line
});

Electron desktop app Icon is not displaying?

I am creating an electron app in windows. Everything is working fine but when I run the setup, the desktop shortcut icon is electron's icon.
This is my package.json file:
{
"name": "happiness",
"version": "1.0.0",
"icon": "logomain.ico",
"iconUrl":"file:///E:/abc/abc1/logomain.ico",
"description": "Descriptions",
"main": "index.js",
"build": {
"appID": "happiness",
"productName": "happiness",
"icon": "logomain.ico"
},
"scripts": {
"start": "electron ."
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"electron-packager": "^13.0.1"
},
"dependencies": {
"electron-squirrel-startup": "^1.0.0",
"electron-winstaller": "^2.7.0"
}
}
I am using Electron windows installer to generate final exe and this is my build.js file:
var electronInstaller = require('electron-winstaller');
// In this case, we can use relative paths
var settings = {
appDirectory: './release-builds/app-happiness-win32-ia32',
outputDirectory: './myapp-source-built-installers',
authors: 'ABC',
exe: './app-happiness.exe',
setupIcon: 'logomain.ico'
};
resultPromise = electronInstaller.createWindowsInstaller(settings);
resultPromise.then(() => {
console.log("The installers of your application were succesfully created !");
}, (e) => {
console.log(`Well, sometimes you are not so lucky: ${e.message}`)
});
However the icon is displaying in control panel and in the startup menu. But in shortcut of the app electron's icon is displaying.
This is the command I'm using:
electron-packager . app-happiness --overwrite --asar=true --platform=win32 --arch=ia32 --out=release-builds --version-string.CompanyName=CE --version-string.FileDescription=CE --version-string.ProductName="Happiness" --electron-version=4.0.0 --icon=logomain.ico
and then
node build.js

Android NativeScript Path must be a string. Received undefined

I am a newbie in NativeScript, I am trying to import/open an existing NatriveScript project on Visual Studio code, I have installed, Node, NativeScript 3.0.3, when I try to build or run the project I get this from debug console
[NativeScriptCli] execute: tns --analyticsClient VSCode --version
[NSDebugAdapter] Using tns CLI v3.0.3 on path 'tns'
[NSDebugAdapter] Running tns command...
[NativeScriptCli] execute: tns --analyticsClient VSCode debug android --no-client --watch
[NSDebugAdapter] Watching the tns CLI output to receive a connection token
Searching for devices...
Executing before-prepare hook from c:\Dev\QAP\Mobile app\hooks\before-prepare\nativescript-dev-android-snapshot.js
[31;1mPath must be a string. Received undefined
[NSDebugAdapter] The tns command finished its execution with code 127.
Error: Unknown signal: SIGQUIT
Here is my package.json
{
"name": "tns-template-hello-world-ts",
"main": "app.js",
"version": "2.4.0",
"author": "Telerik <support#telerik.com>",
"description": "Nativescript hello-world-ts project template",
"license": "Apache-2.0",
"keywords": [
"telerik",
"mobile",
"nativescript",
"{N}",
"tns",
"appbuilder",
"template"
],
"repository": {
"type": "git",
"url": "git#github.com:NativeScript/template-hello-world-ts.git"
},
"bugs": {
"url": "https://github.com/NativeScript/template-hello-world-ts/issues"
},
"homepage": "https://github.com/NativeScript/template-hello-world-ts",
"android": {
"v8Flags": "--expose_gc"
},
"dependencies": {
"moment": "^2.11.2",
"nativescript-background-http": "^2.5.1",
"nativescript-camera": "0.0.8",
"nativescript-checkbox": "^1.2.2",
"nativescript-drop-down": "^1.4.0",
"nativescript-floatingactionbutton": "^2.1.3",
"nativescript-fresco": "^1.0.13",
"nativescript-imagepicker": "^2.4.1",
"nativescript-permissions": "^1.2.1",
"nativescript-pulltorefresh": "^1.1.9",
"nativescript-social-share": "^1.3.1",
"nativescript-telerik-ui": "^0.2.4",
"nativescript-theme-core": "^0.2.1",
"nativescript-toast": "^1.4.5",
"nativescript-videoplayer": "^1.1.4",
"nativescript-videorecorder": "^1.3.4",
"tns-core-modules": "^2.5.2"
},
"devDependencies": {
"nativescript-dev-typescript": "^0.3.2",
"nativescript-dev-android-snapshot": "^0.*.*"
}
}
and my launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch on Android",
"type": "nativescript",
"request": "launch",
"platform": "android",
"appRoot": "${workspaceRoot}",
"sourceMaps": true,
"watch": true
},
{
"name": "Attach on Android",
"type": "nativescript",
"request": "attach",
"platform": "android",
"appRoot": "${workspaceRoot}",
"sourceMaps": true,
"watch": false
}
]
}

Categories

Resources