How to guard against missing dependencies in production electron app? - electron

I am using electron-builder to package an application and I'm looking for a way to guard against the following mistake:
My electron app has a main process dependency required in production, but I mistakenly listed it in devDependencies. I don't notice this during development because the module is installed in my development environment.
After building the production version and launching it, an alert dialog will pop-up with an Error: cannot find module stacktrace.
I'm looking for an automated way to catch/prevent this mistake.
What I tried so far:
After building with electron-builder, I have an automated test that launches the production app as a node child_process.spawn and then connects to it using puppeteer. And I have a process.on('uncaughtException') listener in the main process.
Since this error is raised from the require stack, it appears to not get handled by this listener. Also, the error creates an alert dialog box that blocks execution of the spawned process until the box is closed (something I don't know how to do in a CI environment) which means the test hangs and times-out without providing useful feedback.
I'm using electron-builder to package the main process dependencies and vite to bundle the renderer dependencies.

Related

Electron builder works on development but not on install

I'm trying to follow other people who had a similar issue like this one
Electron-Builder include external folder I wish i could be more specific on what my problem is, the reason is that i dont know whats wrong.
I am making a react app which has a server with an sqlite db and im trying to use electron.js to make it into an installable/executable
here is my dummy repo https://github.com/Juan321654/electron_react_with_build_installer_sqlite_db the master branch was just how to make electron work with react, the server branch is the one that i need help with
you can clone and just do npm i, npm run start to launch executable. npm run build to build
the code works fine in development mode and even after i make the build project with electron i can launch the executable and it works fine and it reads the data from the database, but as soon as i take the dist folder out of the project to send to someone or install the software, it stops working and it loads the app, but it does not read the data from the server/db, I am not sure if its missing node modules or the server folder, or maybe if im missing some kind of command in my scripts in the package.json?

cdk watch command never returns

I'm following the workshop provided by aws, https://cdkworkshop.com/20-typescript/30-hello-cdk/300-cdk-watch.html.
When I issue
$ cdk watch
After the command is succeeded, it never returns. I can see that the new function is deployed correctly on the aws console. But it seems like it didn't finish normally.
When I issue
$ cdk deploy --hotswap
I get no error. It deploys and returns cleanly.
Anyone knows or experiences the same?
This is the expected behaviour. "watch mode (cdk deploy --watch, or cdk watch for short) continuously monitors your CDK app's source files and assets for changes and immediately performs a deployment of the specified stacks when a change is detected".
Watch mode is a common CLI idiom. Typescript's tsc --watch, works similarly, for instance, continuously compiling to js as you make changes.

How to run an MSIX installed application from the command line

I have an application packaged and signed as an MSIX, it installs and runs from the start menu. I'd like to be able to run the application from the command line too, for automated testing, but I can't see a way to do it. From powershell the docs suggest Invoke-CommandInsideDesktopPackage, but that requires developer mode which I'd rather not enable on test machines, and also is not the same as just running the app. What I'd love is a simple command line command that starts the app in the same way that the start menu does it.
By design, the binaries from an installation folder of an MSIX folder are not directly accessible through their direct path.
The correct way to run an app from the command line from an MSIX package is with the use of an execution alias. The following article contains more details about how an execution alias works and how you can define it in your package, no matter the tool you use to build the MSIX package.
- App Execution Alias
Also, here is a related question on SO.

Electron Squirrel.Windows: How can I remove local app data on uninstall?

Currently I have an installer built with Squirrel.Windows. On uninstall, the application directory under:
C:\Users\Me\AppData\Local\MyApplicationDirectory
remains. I have tried using rimraf under the the --squirrel-uninstall hook to remove the directory, but it fails because the files are in use.
Here is what I have that is not working:
case '--squirrel-uninstall':
var myLocalAppData = "C:\\Users\\Me\\AppData\\Local\\MyApplication";
rimraf(myLocalAppData);
app.quit();
I have tried the following to no avail:
Using a setTimeout() to delay the rimraf(myLocalAppData) call
Using the maxBusyTries param in the rimraf options to continue retrying for 10 seconds if a EBUSY, ENOTEMPTY, or EPERM error code is encountered when trying to clean up the directory
Running app.exit() before the rimraf(myLocalAppData)
I know the NSIS installer provided by electron-builder properly cleans up the app data directory, but I cannot use it as I need a MSI to support machine wide installations via Group Policy Management.
Any help is appreciated!

AIR3 Native Process will not start in release build

Currently I am building an application that launches crtmpd (a rtmp server written in C++).
Whenever I launch the application from within Flash Builder it works great, if I install a release build from an air file the process.start() returns a generic "could not start process" error.
The crtmpserver.exe is stored in applicationDirectory and the config file is kept in applicationStorageDirectoy.
So I've moved it to the native storage directory. But the problem persists. I've found the following though:
startupInfo = new NativeProcessStartupInfo();
startupInfo.executable = binFile;
processArgs = new Vector.<String>();
processArgs.push(luaFile.nativePath);
startupInfo.arguments = processArgs;
In the IDE after this startupInfo is setup correctly. On client machines all properties of startupInfo are still null.
You might want to try putting it in the application storage directory. I've seen permissions issues were the user wasn't Admin and could't run a native process once it was installed.
The problem was I was packaging with an Air installer rather than a native installer.
Once I packaged with the appropriate installer the problem has resolved itself.

Resources