Start app on mac os directly after installation - node.js

I'd like to know if it is possible to create a dmg file which can be installed by Drag&Drop - and which starts directly after this installation without having to be called manually again.
And if this is possible, I'd like to know whether I can pass arguments to the (nodejs) process which will be started directly after the installation.
I managed to pass parameters to the process when I call it manually after the installation, but I want to run it directly.
Any help will be appreciated!
Thanks!

I solved it: Instead of creating an app and wrapping it into a dmg, I created an app and wrapped it into a pkg. For pkgs it is possible to use postinstall scripts, so I started the application through this script.

Related

How to update the PATH variable in a platform agnostic way using node js

i am making a CLI to automate the installation process of a software. I install it in a directory like $HOME/.software-name/. Now i would like to know about a platfrom agnostic way to update the system PATH environment variable so that in the future the user can run the command easily.
I am not looking for a os specific way like setx on windows or writing to the ~/.bashrc. I would prefer a library to do the task or a builtin function.
i know that i can retrieve the env variable using process.env.variableName but setting it would not work outside the child process (ie, NodeJS). It does work inside the NodeJS process but that is obviously not what is wanted here.
Thanks :)

nodejs .exe app crashed immediately opened in UWP

First, sorry for my poor English. I want to call .exe app in order to run a javascript in UWP, and I'm using FullTrustProcessLauncher. The extension I set is as below.
<Extensions>
<desktop:Extension Category="windows.fullTrustProcess" Executable="nodejs/node.exe">
<desktop:FullTrustProcess>
<desktop:ParameterGroup GroupId="SyncGroup" Parameters="/new1.js"/>
<desktop:ParameterGroup GroupId="OtherGroup" Parameters="/Other"/>
</desktop:FullTrustProcess>
</desktop:Extension>
</Extensions>
However, when I run the UWP app, the node.exe just appear for a second and immediately crashed. However when I call other applications like notepad++.exe, it will be open successfully. I'm wondering why this happened. Should I use FullTrustProcessLauncher or some other way to call nodejs(node.exe)? Looking forward to your help. Thanks.
I have know the problem. With the FullTrustProcoessLauncher you can only launch an EXE that is in your package, not an arbitrary process on the system. I made another win32 process in my package and call nodejs in the win32 process. The problem is sovled now.
The EXE needs to be included in the appx package
Then you should declare in the appx.manifest.
Make sure you declear the 'runFullTrust' capability in the appxmanifest.
You should have look the FullTrustProcessLauncher ms docs.

How to run ElectronJs without a UI?

As well as a UI, I'd like users to have the option of passing in command line options to my tool and for it to output the response to the command line (eg manually or in cron).
Even without creating a window, the UI gets going (eg taskbar on the mac), and on a linux back-end server with no UI libraries it crashes completely.
Is there a way I can avoid having to ship two apps separately, and also more annoyingly using electron to package up one exe, and something like pkg for the other?
Thanks!
You can use a bundling tool like EncloseJS to wrap your Electron application. This would allow you to write a CLI interface. You would then need to move the code that does the actual work to a shared library that both Electron and your CLI can use. You could then introduce a --headless flag that would simply not start the Electron app, while omitting the flag would start the app as usual.

Running Protractor from Node-webkit

Is is possible to run Protractor in any other way except using CLI?
Is there an API call which will simulate the command: 'protractor config file.js'?
I would like to start a test through a node-webkit application, and even though I can connect directly to the ChromeDriver through the directConnect parameter, this is no use if I can't run protractor from inside the script.
Of course, this is in an environment where Node and Protractor aren't available from CLI... simulating a distribution environment where the user doesn't have to install additional apps apart from my node-webkit (hence the node-webkit usage).
Thank you in advance for any pointers!
The protractor command line script boils down to invoking lib/cli.js which mostly deals with parsing commmand-line arguments and then invokes lib/launcher.js to actually start protractor.
I don't think any special concessions have been made in these files to be directly invoked programmatically, but I don't see any particular hurdles either.

How to declare an "install script" in a Node.js application?

I'm new to Node.js and I'm building a little application that connects to a MySQL database.
I wrote a script that initialize the database (well, for now it only creates a table), I invoke it with the command node storage/init_storage.js and when the task is done, the script does a process.exit() to terminate itself.
It works but I'm pretty sure there is a cleaner way to do that? In the future I will have more tasks to do when I'm reinstalling the app (maybe create folders, run tests...), is there a right place to do those things? Maybe a way to do them when npm install is launched?
Thank you for your help.

Resources