Skip to content
This repository has been archived by the owner on Sep 29, 2023. It is now read-only.

Support packaging nativefier applications into Squirrel-based installers #744

Merged
merged 2 commits into from
Feb 8, 2019
Merged

Conversation

AdrianDC
Copy link
Contributor

@AdrianDC AdrianDC commented Jan 20, 2019

Squirrel is "an installation and update framework for Windows desktop apps ".

This PR adds electron-squirrel-startup, allowing to package nativefier applications
into squirrel-based setup installers. Squirrel require this entrypoint to perform
desktop and startup menu creations, without showing the UI on setup launches.

  • References: https://github.com/mongodb-js/electron-squirrel-startup

  • Resolves electron-winstaller and electron-installer-windows support of desktop / startup menu shortcuts for nativefier packaged applications.

  • The electron-squirrel-startup entrypoint has no effect on both Linux and Darwin, only on Windows

  • Supporting it directly inside nativefier avoids having to "hack" around the existing main.js
    and including dependencies from electron-squirrel-startup in an intermediate package
    to be included in a third layer for the final installer executable

  • The following script based on both nativefier and electron-winstaller templates
    represents a portable proof of concept for this merge request :

var nativefier = require('nativefier').default;
var electronInstaller = require('electron-winstaller');

var options = {
  name: 'Web WhatsApp',
  targetUrl: 'http://web.whatsapp.com',
  platform: 'windows',
  arch: 'x64',
  version: '0.36.4',
  out: '.',
  overwrite: false,
  asar: false,
  counter: false,
  bounce: false,
  width: 1280,
  height: 800,
  showMenuBar: false,
  fastQuit: false,
  userAgent: 'Mozilla ...',
  ignoreCertificate: false,
  ignoreGpuBlacklist: false,
  enableEs3Apis: false,
  insecure: false,
  honest: false,
  zoom: 1.0,
  singleInstance: false,
  fileDownloadOptions: {
    saveAs: true
  },
  processEnvs: {
    GOOGLE_API_KEY: '<your-google-api-key>'
  }
};

nativefier(options, function(error, appPath) {
  if (error) {
    console.error(error);
    return;
  }
  console.log('App has been nativefied to', appPath);

  resultPromise = electronInstaller.createWindowsInstaller({
    appDirectory: 'Web WhatsApp-win32-x64',
    outputDirectory: './',
    authors: 'Web WhatsApp',
    exe: 'Web WhatsApp.exe'
  });

  resultPromise.then(() => console.log('It worked!'), e => console.log(`No dice: ${e.message}`));
});

@ronjouch
Copy link
Contributor

ronjouch commented Jan 20, 2019

@AdrianDC thanks for the PR! What is this? What does it have to do with Nativefier? A tiny bit of context, please 🙂.

@AdrianDC
Copy link
Contributor Author

@AdrianDC thanks for the PR! What is this? What does it have to do with Nativefier? A tiny bit of context, please 🙂.

I completed the merge request's presentation with the last 4 items,
including a proof-of-concept to present a simple use case and validate the additions

@ronjouch ronjouch changed the title app: Add support for electron-squirrel-startup entrypoint Support packagng nativefier applications into Squirrel-based installers Feb 8, 2019
@ronjouch ronjouch changed the title Support packagng nativefier applications into Squirrel-based installers Support packaging nativefier applications into Squirrel-based installers Feb 8, 2019
@ronjouch
Copy link
Contributor

ronjouch commented Feb 8, 2019

@AdrianDC okay, got it, thanks for the explanation! Merging and adding docs.

@ronjouch ronjouch merged commit 310d63e into nativefier:master Feb 8, 2019
@ronjouch
Copy link
Contributor

ronjouch commented Feb 8, 2019

@AdrianDC okay, got it, thanks for the explanation! Merging and adding docs.

That will do for now: https://github.com/jiahaog/nativefier/blob/master/docs/api.md#packaging-squirrel-based-installers . Thanks again @AdrianDC, and 🙏 for the delay. Merging a few other things over the weekend, then cutting a release.

ronjouch pushed a commit that referenced this pull request Apr 19, 2019
 * As explained in: electron/electron#8862 (comment)
    an issue with .quit() exists with a "Cannot find module '../screen'" issue,
    while using the .exit() alternative avoids the issue

* Validated on Windows with the same logic as #744 where the issue recently appeared
@steveacalabro
Copy link

steveacalabro commented Jul 25, 2019

missing ../screen is still an issue for me @AdrianDC (Edit: Just needs to be released to a new version)

Adam777Z pushed a commit to Adam777Z/nativefier that referenced this pull request Nov 9, 2022
…ers (nativefier#744)

[Squirrel](https://github.com/Squirrel/Squirrel.Windows) is *"an installation and update
framework for Windows desktop apps "*.

This PR adds `electron-squirrel-startup`, allowing to package nativefier applications 
into squirrel-based setup installers. Squirrel require this entrypoint to perform
desktop and startup menu creations, without showing the UI on setup launches.

- References: https://github.com/mongodb-js/electron-squirrel-startup

- Resolves `electron-winstaller` and `electron-installer-windows` support of desktop / startup menu shortcuts for nativefier packaged applications.

- The `electron-squirrel-startup` entrypoint has no effect on both Linux and Darwin, only on Windows

- Supporting it directly inside `nativefier` avoids having to "hack" around the existing `main.js`
  and including dependencies from `electron-squirrel-startup` in an intermediate package
  to be included in a third layer for the final installer executable

- The following script based on both `nativefier` and `electron-winstaller` templates
   represents a portable proof of concept for this merge request :

```js
var nativefier = require('nativefier').default;
var electronInstaller = require('electron-winstaller');

var options = {
  name: 'Web WhatsApp',
  targetUrl: 'http://web.whatsapp.com',
  platform: 'windows',
  arch: 'x64',
  version: '0.36.4',
  out: '.',
  overwrite: false,
  asar: false,
  counter: false,
  bounce: false,
  width: 1280,
  height: 800,
  showMenuBar: false,
  fastQuit: false,
  userAgent: 'Mozilla ...',
  ignoreCertificate: false,
  ignoreGpuBlacklist: false,
  enableEs3Apis: false,
  insecure: false,
  honest: false,
  zoom: 1.0,
  singleInstance: false,
  fileDownloadOptions: {
    saveAs: true
  },
  processEnvs: {
    GOOGLE_API_KEY: '<your-google-api-key>'
  }
};

nativefier(options, function(error, appPath) {
  if (error) {
    console.error(error);
    return;
  }
  console.log('App has been nativefied to', appPath);

  resultPromise = electronInstaller.createWindowsInstaller({
    appDirectory: 'Web WhatsApp-win32-x64',
    outputDirectory: './',
    authors: 'Web WhatsApp',
    exe: 'Web WhatsApp.exe'
  });

  resultPromise.then(() => console.log('It worked!'), e => console.log(`No dice: ${e.message}`));
});
```
Adam777Z pushed a commit to Adam777Z/nativefier that referenced this pull request Nov 9, 2022
…#784)

 * As explained in: electron/electron#8862 (comment)
    an issue with .quit() exists with a "Cannot find module '../screen'" issue,
    while using the .exit() alternative avoids the issue

* Validated on Windows with the same logic as nativefier#744 where the issue recently appeared
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants