Electron application fails to update all of a sudden - electron-builder

My electron application was working just fine and all of a sudden new updates fail to download with the following error
Checking for update
[2023-01-13 16:42:04.897] [error] Error: Error: Cannot parse update info from latest.yml in the latest release artifacts (https://net2qa.netapp.com/client/win/latest.yml?noCache=1gmld8n1b): YAMLException: end of the stream or a document separator is expected (2:11)
1 | <!DOCTYPE html>
2 | <!-- Build: 1.0.2817.0 -->
---------------^
3 | <!-- StateVersion: 2.1.1 -->
4 | <!-- DeploymentMode: Development -->
at generateError (C:\Users\test\AppData\Local\Programs\net2offlineclient-qa\resources\app\node_modules\js-yaml\lib\loader.js:183:10)
at throwError (C:\Users\test\AppData\Local\Programs\net2offlineclient-qa\resources\app\node_modules\js-yaml\lib\loader.js:187:9)
at readDocument (C:\Users\test\AppData\Local\Programs\net2offlineclient-qa\resources\app\node_modules\js-yaml\lib\loader.js:1645:5)
at loadDocuments (C:\Users\test\AppData\Local\Programs\net2offlineclient-qa\resources\app\node_modules\js-yaml\lib\loader.js:1688:5)
at Object.load (C:\Users\test\AppData\Local\Programs\net2offlineclient-qa\resources\app\node_modules\js-yaml\lib\loader.js:1714:19)
at Object.parseUpdateInfo (C:\Users\test\AppData\Local\Programs\net2offlineclient-qa\resources\app\node_modules\electron-updater\out\providers\Provider.js:82:28)
at GenericProvider.getLatestVersion (C:\Users\test\AppData\Local\Programs\net2offlineclient-qa\resources\app\node_modules\electron-updater\out\providers\GenericProvider.js:23:35)
at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
at async NsisUpdater.getUpdateInfoAndProvider (C:\Users\test\AppData\Local\Programs\net2offlineclient-qa\resources\app\node_modules\electron-updater\out\AppUpdater.js:319:19)
at async NsisUpdater.doCheckForUpdates (C:\Users\test\AppData\Local\Programs\net2offlineclient-qa\resources\app\node_modules\electron-updater\out\AppUpdater.js:333:24), rawData: <!DOCTYPE html>
<!-- Build: 1.0.2817.0 -->
<!-- StateVersion: 2.1.1 -->
<!-- DeploymentMode: Development -->
<!-- CorrelationId: a3e10eac-45cb-4dc2-ac07-0d80c9e5ba8d -->
<!-- DataCenter: PNQ -->
<!-- Slice: 001-000 -->
<html lang="en"><head><link rel="icon" href="data:;base64,iVBORw0KGgo="><script data-container="true" nonce="91dduewxjK+C2hhaclwx1w==">var CP = {
"list": []
};
var SA_FIELDS = {
"AttributeFields": [
{
"UX_INPUT_TYPE": "TextBox",
"USER_INPUT_TYPE": "TextBox",
"IS_TEXT": true,
"IS_EMAIL": false,
"IS_PASSWORD": false,
"IS_DATE": false,
"IS_RADIO": false,
"IS_DROP": false,
"IS_TEXT_IN_PARAGRAPH": false,
"IS_CHECK_MULTI": false,
"IS_LINK": false,
"VERIFY": false,
"DN": "Email Address",
"ID": "signInName",
"U_HELP": "",
"DAY_PRE": "0",
"MONTH_PRE": "0",
"YEAR_PRE": "0",
"IS_REQ": true,
"IS_RDO": false,
"OPTIONS": []
}
]
};
I've deleted my node_modules folder and also updated NodeJS, electronJS, Electron Builder and also Updated Electron updater.
There hasn't been any changes in the application from the previous version to the new one in terms of adding new lib or or any major file changes, just some JavaScript fixes.
Any help here or pointing me in the right direction will be much appreciated!
Electron-Builder Version: 23.3.3
Electron-Updater Version: 5.2.1
Node Version: 18.9.0
Electron Version: 20.1.4

Okay, I was able to figure it out but the error message being shown is very misleading. So the issue was when the updater tried to download the file from the provided URL, it was being redirected to the login page (even though it had a bearer token) and it was failing because it was expecting a file to download but got a HTML page as the data.

Related

ExcelJS - Strict-mode does not allow assignment to undefined variables: regeneratorRuntime

I'm using DevExtreme dxDataGrid and I want to export data to an xlsx-file. They have implemented it using ExcelJs:
https://js.devexpress.com/Documentation/ApiReference/Common/Utils/excelExporter/#exportDataGridoptions
As explained I just need to reference the following libs:
<head>
<!-- ... -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.4.0/polyfill.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/exceljs/4.1.1/exceljs.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.2/FileSaver.min.js"></script>
<!-- reference the DevExtreme sources here -->
</head>
I'm using ASP.NET Core 6 with VS 2022. For this I'm using the Bundler & Minifier to bundle libs like jQuery, DevExtreme and ExcelJs.
I have downloaded ExcelJs (like I have done for jQuery etc.) with libman.json:
{
"version": "1.0",
"defaultProvider": "cdnjs",
"libraries": [
{
"library": "jquery#3.6.0",
"destination": "wwwroot/js/lib/jquery/"
},
{
"provider": "cdnjs",
"library": "exceljs#4.3.0",
"destination": "wwwroot/js/lib/exceljs/",
"files": [
"exceljs.min.js",
"exceljs.js"
]
},
{
"provider": "cdnjs",
"library": "FileSaver.js#2.0.5",
"destination": "wwwroot/js/lib/FileSaver.js/"
},
{
"provider": "cdnjs",
"library": "babel-polyfill#6.26.0",
"destination": "wwwroot/js/lib/babel-polyfill/"
}
]
}
Then I have added ExcelJs to my bundleconfig.json:
[
{
"outputFileName": "wwwroot/bundle/LibraryBundle.js",
"inputFiles": [
"wwwroot/js/lib/jquery/jquery.js",
"wwwroot/js/lib/babel-polyfill/polyfill.js",
"wwwroot/js/lib/exceljs/exceljs.js",
"wwwroot/js/lib/FileSaver.js/FileSaver.js"
]
}
]
Then I'm getting following error in Visual Studio:
Strict-mode does not allow assignment to undefined variables: regeneratorRuntime
strict-mode is defined in ExcelJS and also many other lib's I don't understand why I'm getting this error and how can I fix it. I was not able to find any similar issue at Github-ExcelJs and it doesn't look like that they are not really supporting their open issues. Because of that I'm tried to ask here.
I am still on ExcelJS 4.2.1, but I was running into a similar issue.
Based on this comment on an ExcelJS issue, in the exceljs.js file, this is the offending block of code:
try {
regeneratorRuntime = runtime;
} catch (accidentalStrictMode) {
// This module should not be running in strict mode, so the above
// assignment should always work unless something is misconfigured. Just
// in case runtime.js accidentally runs in strict mode, we can escape
// strict mode using a global Function call. This could conceivably fail
// if a Content Security Policy forbids using Function, but in that case
// the proper solution is to fix the accidental strict mode problem. If
// you've misconfigured your bundler to force strict mode and applied a
// CSP to forbid Function, and you're not willing to fix either of those
// problems, please detail your unique predicament in a GitHub issue.
Function("r", "regeneratorRuntime = r")(runtime);
}
NEW workaround from Phoniex is to create a file with simply
var regeneratorRuntime;
in it, and include it before the exceljs.js file.
OLD workaround is to replace the assignment in the try block with:
window.regeneratorRuntime = runtime;

jhipster Project won't build for prod profile : gradlew -Pprod bootWar fails on taks webpack

ISSUE SOLVED see below for infos
after searching for a solutions for 2 days now i give up. I coudn't find a similar issue on the web and i don't know what to do.
Hope somebody can help there...
Issue
The application is building and running fine with gradlew -Pdev bootWar jibDockerBuild
However, the build won't work when selecting the prod profile:
gradlew -Pprod bootWar jibDockerBuild
Reference Exception
ERROR in Illegal State: referring to a type without a variable
{"filePath":"D:/dev/myApp/node_modules/#angular/forms/forms.d.ts",
"name":"FormGroupDirective","members":[]}
FULL EXCEPTION
The following is printed on execution:
D:\dev\myApp>gradlew -Pprod bootWar jibDockerBuild
> Task :yarn_install
yarn install v1.9.4
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
info fsevents#1.2.4: The platform "win32" is incompatible with this module.
info "fsevents#1.2.4" is an optional dependency and failed compatibility check. Excluding it from installation.
[4/5] Linking dependencies...
warning " > bootstrap#4.1.3" has unmet peer dependency "jquery#1.9.1 - 3".
warning " > bootstrap#4.1.3" has unmet peer dependency "popper.js#^1.14.3".
warning " > ngx-webstorage#2.0.1" has incorrect peer dependency "#angular/core#^5.0.0".
[5/5] Building fresh packages...
Done in 97.47s.
> Task :webpack
yarn run v1.9.4
$ yarn run cleanup && yarn run webpack:prod:main && yarn run clean-www
$ rimraf build/{aot,www}
$ yarn run webpack --config webpack/webpack.prod.js --profile
$ node --max_old_space_size=4096 node_modules/webpack/bin/webpack.js --config webpack/webpack.prod.js --profile
(node:28256) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
Hash: 6aab3d14e434ee333c51
Version: webpack 4.8.0
Time: 8812ms
Built at: 2018-10-07 18:52:03
6 assets
Entrypoint polyfills = app/polyfills.6aab3d14e434ee333c51.bundle.js
Entrypoint global = global.1e92ecdbfdaf2bb32590.css app/global.6aab3d14e434ee333c51.bundle.js
Entrypoint main = app/main.6aab3d14e434ee333c51.bundle.js
[0] ./src/main/webapp/app/app.main.ts 0 bytes {0} [built]
factory:4638ms building:3545ms = 8183ms
[2] ./src/main/webapp/content/css/global.css 39 bytes {1} [built]
factory:4639ms building:2778ms = 7417ms
[3] ./src/main/webapp/app/polyfills.ts 0 bytes {2} [built]
factory:4638ms building:3540ms = 8178ms
+ 1 hidden module
ERROR in Illegal State: referring to a type without a variable {"filePath":"D:/dev/myApp/node_modules/#angular/forms/forms.d.ts","name":"FormGroupDirective","members":[]}
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
> Task :webpack FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':webpack'.
> Process 'command 'yarn.cmd'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.9/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 1m 58s
5 actionable tasks: 3 executed, 2 up-to-date
ENVIRONMENT
Windows 10
Using JHipster version installed locally in current project's node_modules
Executing jhipster:info
Options: from-cli: true
Welcome to the JHipster Information Sub-Generator
JHipster Version(s)
myApp#0.0.0 D:\dev\myApp
`-- generator-jhipster#5.4.1
JHipster configuration, a .yo-rc.json file generated in the root folder
<details>
<summary>.yo-rc.json file</summary>
<pre>
{
"generator-jhipster": {
"promptValues": {
"packageName": "de.myApp.myApp",
"nativeLanguage": "de"
},
"jhipsterVersion": "5.4.1",
"applicationType": "monolith",
"baseName": "myApp",
"packageName": "de.myApp.myApp",
"packageFolder": "de/myApp/myApp",
"serverPort": "8080",
"authenticationType": "session",
"cacheProvider": "ehcache",
"enableHibernateCache": true,
"websocket": false,
"databaseType": "sql",
"devDatabaseType": "mysql",
"prodDatabaseType": "mysql",
"searchEngine": false,
"messageBroker": false,
"serviceDiscoveryType": false,
"buildTool": "gradle",
"enableSwaggerCodegen": false,
"rememberMeKey": "YourJWTSecretKeyWasReplacedByThisMeaninglessTextByTheJHipsterInfoCommandForObviousSecurityReasons",
"clientFramework": "angularX",
"useSass": false,
"clientPackageManager": "yarn",
"testFrameworks": [],
"jhiPrefix": "jhi",
"enableTranslation": true,
"nativeLanguage": "de",
"languages": [
"de",
"en",
"fr"
],
"appsFolders": [
"myApp"
],
"directoryPath": "../",
"monitoring": "elk",
"consoleOptions": [
"curator"
],
"jwtSecretKey": "YourJWTSecretKeyWasReplacedByThisMeaninglessTextByTheJHipsterInfoCommandForObviousSecurityReasons"
}
}
</pre>
</details>
JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
SKIPPED
Environment and Tools
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)
git version 1.8.4.msysgit.0
node: v8.11.3
npm: 5.6.0
yarn: 1.9.4
Docker version 18.06.1-ce, build e68fc7a
docker-compose version 1.22.0, build f46880fe
I found the cause of the issue:
I obviously placed the ReactiveFormModul imports at the wrong place. I had it in a module "upwards", but actually, I had to place it into the module where I actually have the components defining the form. To be honest ... I don't understand exactly why this is an issue, maybe someone can clarify.
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '#angular/core';
import { RouterModule } from '#angular/router';
import { ReactiveFormsModule } from '#angular/forms';
*** other imports
#NgModule({
imports: [***, ReactiveFormsModule, *** ROUTER stuff,
declarations: [MyReactiveFormComponent],
schemas: [***]
})
export class MyReactiveFormModule {}
After this, I found also other issues that was working fine in the dev-build (again ... don't understand the reason. I guess that has to do with a stricter "compile" configuration):
The variable referencing the formGroup was declared "private". Therefore I got a compile Error on the prod profile. I had to change it so that it can be accessed by the html template.
Variables accessed in html must be public (or accessible by means of a getter method)
Accessing Form Controls in subsequent html elements must be "public"
Code-Example:
MyReactiveComponent.ts:
this.myForm = this.fb.group({
id: [this.myObject.id],
date: [this.myObject.date, Validators.required],
number: [this.myObject.number, [Validators.required, Validators.min(2), Validators.max(100)]],
dynamicOptions: this.fb.array([]),
prefilledOptions: [this.prefilledOptions, Validators.required]
});
MyReactiveComponent.html:
<div class="row justify-content-center">
<div class="col-8">
<form [formGroup]="myForm" id="myFormId" novalidate (ngSubmit)="save()" #editForm="ngForm">
<h2>Create or edit a Play</h2>
<div>
<jhi-alert-error></jhi-alert-error>
<div class="form-group">
<input type="number" class="form-control" formControlName="number" (blur)="updateNumber()" id="field_number" required min="2" jhiMin="2" max="100" jhiMax="100"/>
<div [hidden]="!(number?.dirty && number?.invalid)">
<small class="form-text text-danger"
[hidden]="!number?.errors?.required">
This field is required.
</small>
...
Accessing number in "number?.dirty" for example requires to have a getter-method to be able to access it:
get number() {
return this.myForm.get('number') as FormControl;
}
Hope that helps other when struggling...

WebStorm does not recognize `browser`, `element` etc in Protractor test spec

Following Protractor guide I wanted to create my first test. While the test works unfortunately JetBrains WebStorm does not recognize all of my variables in given test
I have enabled in Libraries/JavaScript:
jasmine
karma
karma-jasmine
HTML
Node.js Core
selenium-webdriver
As seen above Node.js Core library is enabled.
I have also visited this question but unfortunately the angular-protractor is no longer available.
What am I missing?
Your editor will understand it if its imported. Elese it will know where to find browser ot by
Add import statement at top of your file.
import {by, element} from 'protractor';
Use JS Hint RC. It will work like magic.
You can find this by going to
Settings -> Languages and Frameworks -> Javascript(select ECMA Script 6) ->Code Quality Tools- >JS Hint - Enable, use config file.
As for config file, save the bellow file, with following name: '.jshintrc'.
Rate the answer as positive if this worked for you!
{
"jasmine": true,
"mocha": true,
"esversion":6,
"loopfunc": true,
"node": true,
"globals": {
"esversion": 6,
"angular": false,
"browser": false,
"inject": false,
"_": false,
"driver": false,
"protractor": false,
"$": false,
"$$": false,
"element": false,
"by": false,
"list": false
}
}

Play framework app heroku configuration error: Key 'application.conf' may not be followed by token: 'application.prod.conf'

I built an app based on template play-silhouette-seed-slick. template link
I got a configuration error caused by com.typesafe.config.ConfigException$Parse after deploying the app to heroku.
"Configuration error: Configuration error[ # file:/app/target/universal/stage/conf/: 2: Key 'application.conf' may not be followed by token: 'application.prod.conf' (if you intended 'application.prod.conf' to be part of a key or string value, try enclosing the key or value in double quotes)]"
The Procfile
web: target/universal/stage/bin/panobike-plus-server -Dhttp.port=${PORT} -Dconfig.resource=${PLAY_CONF_FILE}
And app.json
{
"name": "play-silhouette-slick-seed",
"description": "Seed project to show how Silhouette can be implemented into a Play Framework application with database access using Slick 3.",
"keywords": [
"Play",
"Silhouette",
"Slick"
],
"website": "https://github.com/sbrunk/play-silhouette-slick-seed",
"repository": "https://github.com/sbrunk/play-silhouette-slick-seed",
"success_url": "/",
"env": {
"BUILDPACK_URL": "https://github.com/heroku/heroku-buildpack-scala.git",
"PLAY_CONF_FILE": "application.prod.conf",
"PLAY_APP_SECRET": "changeme",
"FACEBOOK_CLIENT_ID": "",
"FACEBOOK_CLIENT_SECRET": "",
"GOOGLE_CLIENT_ID": "",
"GOOGLE_CLIENT_SECRET": "",
"TWITTER_CONSUMER_KEY": "",
"TWITTER_CONSUMER_SECRET": ""
}
}
In my production config "application.prod.conf", there is no such key "application.conf".
What does this error message mean?
Thank you
It was a stupid question.
I did not call the https://api.heroku.com/app-setups endpoint to setup the app.json enabled application on Heroku.
I had the same error. That was due to lack of PLAY_CONF_FILE env variable. To fix this error you need to open Heroku web page -> Settings -> click on Config Vars button and set new PLAY_CONF_FILE variable. For example application.staging.conf

Remove menubar from Finder in Electron on OSX

I purchased a new macbook and I am now working on getting my apps to run on a 64bit mac.
However I haven't been able to remove the default menubar.
Is there anyway to change my app name from Electron to something else within Electron via app.js so I don't see Electron in Finder (revert to screenshot for better understanding)? Is there any way to remove the edit, view window, and help menus?
package.json:
{
"name": "hello",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"start": "electron ."
},
"author": "",
"license": "ISC",
"devDependencies": {
"electron-prebuilt": "^0.33.0"
}
}
app.js:
var app = require("app"),
BrowserWindow = require("browser-window");
app.on("ready", function() {
var mainWindow = new BrowserWindow({
toolbar: false,
"skip-taskbar": true,
"auto-hide-menu-bar": true,
width: 800,
height: 600
});
mainWindow.loadUrl("file://" + __dirname + "/index.html");
mainWindow.setMenuBarVisibility(false);
mainWindow.setAutoHideMenuBar(true);
mainWindow.openDevTools();
});
index.html:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello</title>
</head>
<body>
Hello world!
</body>
</html>
After you create your browser window do the following:
mainWindow.setMenu(null);
Only works for Windows and Linux! - http://electron.atom.io/docs/api/browser-window/#winsetmenumenu-linux-windows
Otherwise you can create a custom menu of your own by checking out Electron's documentation on the Menu: http://electron.atom.io/docs/api/menu/.
I got same problem here with my electron app
I tried mainWindow.setMenu(null); but it didn't work
but I noticed that when app is running, there was an electron icon show in the dock which is your app
I think maybe this is the point to cause the problem here
just give it a try
app.dock.hide();
Notice: it's an os x only method (documentation)
there you go
after hide dock icon, you app no longer have default functions of ApplicationMenu or dockMenu, such as Quit, About, Hide etc...
so you can consider about give your app a Tray
The name Electron is in the Info.plist file inside Electron.app, change it to what you want.

Resources