2
2
mirror of https://github.com/Llewellynvdm/nativefier.git synced 2024-11-11 15:51:06 +00:00
Commit Graph

872 Commits

Author SHA1 Message Date
Ronan Jouchet
35eb72edfd Fix travis build
We no longer have a postinstall so we need to explicitly
'npm run dev-up' for cli+app deps, like we did before.
2020-03-16 21:20:38 -04:00
Ronan Jouchet
cde5c1e13b Fix failing to global-sudo-install due to postinstall script (fix #923)
As documented in https://github.com/jiahaog/nativefier/issues/923#issuecomment-599300317 ,

- #923 is caused by installing placeholder app deps at nativefier
  *install* time, with yarn (8.0.2) or npm (8.0.3). This is new in
  Nativefier 8.x, for the motivations behind it, see
  https://github.com/jiahaog/nativefier/pull/898#issuecomment-583865045

- During testing, I did test global installs, but never to a
  system / non-user-writable path (my `$npm_config_prefix` is set to
  `"$HOME/.node_modules"`)

- But without such a config and when installing globally to a
  non-user-writable/system path with `sudo npm i -g nativefier`,

    - Installation of nativefier core works...

    - ... but then `postinstall` tries to do its job of installing
    app deps, and fails in various OS-dependent ways, but all about
    access rights.
    I suspect that, although main nativefier install runs as `su` with
    access rights to system paths, `postinstall` scripts are run *out*
    of `su`.
    That would make sense for security reasons: out of hook scripts,
    npm knows exactly what will be touched in your filesystem: it's the
    static contents of the published tarball; a postinstall script with
    sudo rights could do nasty dynamic stuff. So, although I don't see
    any mention of that in
    [npm-scripts docs / hooks](https://docs.npmjs.com/misc/scripts#hook-scripts)
    and I haven't dug npm/cli's code, I can understand it.

So, reverting back to `webpack`ing the placeholder app, as done pre-8.0.
2020-03-16 21:06:03 -04:00
Ronan Jouchet
0a380bd0f4 Update changelog for v8.0.3 2020-03-15 20:57:48 -04:00
Ronan Jouchet
f1f6dda4d1 Fix failing to install due to app yarn install
Actually not sure this will work, but let's try.
If that works, that means we're back to pre-
https://github.com/jiahaog/nativefier/pull/898#issuecomment-583865045 ,
with a 60s timeout due to npm bug https://github.com/npm/cli/issues/757

Looking at a real fix, potentially coming back to `webpack` the app.
2020-03-15 20:54:21 -04:00
Ronan Jouchet
dbf12e4f78 README: fix path to images 2020-03-15 17:57:22 -04:00
Ronan Jouchet
2c036cb8a2 Update changelog for v8.0.2 2020-03-15 17:41:20 -04:00
Ronan Jouchet
b16e893237 Travis: only attempt to deploy with linux/node12 build, take 2 2020-03-15 17:40:43 -04:00
Ronan Jouchet
f600047463 Update changelog for v8.0.1 2020-03-15 17:24:51 -04:00
Ronan Jouchet
fd37a6a4c8 Align full tests (linter+tests) with deployment platform 2020-03-15 17:23:48 -04:00
Ronan Jouchet
d6e7aa6f41 Fix inferTitle test broken on Node 8 2020-03-15 17:19:19 -04:00
Ronan Jouchet
20de73c559 Travis: only attempt to deploy with linux/node12 build 2020-03-15 17:09:56 -04:00
Ronan Jouchet
93c2d32c87 Update changelog for v8.0.0 2020-03-15 16:51:09 -04:00
Ronan Jouchet
c9ee6667d4
Revamp and move to TypeScript (#898)
## Breaking changes

- Require **Node >= 8.10.0 and npm 5.6.0**
- Move to **Electron 8.1.1**.
- That's it. Lots of care went into breaking CLI & programmatic behavior
  as little as possible. **Please report regressions**.
- Known issue: build may fail behind a proxy. Get in touch if you use one:
  https://github.com/jiahaog/nativefier/issues/907#issuecomment-596144768

## Changes summary

Nativefier didn't get much love recently, to the point that it's
becoming hard to run on recent Node, due to old dependencies.
Also, some past practices now seem weird, as better expressible
by modern JS/TS, discouraging contributions including mine.

Addressing this, and one thing leading to another, came a
bigger-than-expected revamp, aiming at making Nativefier more
**lean, stable, future-proof, user-friendly and dev-friendly**,
while **not changing the CLI/programmatic interfaces**. Highlights:

- **Require Node>=8**, as imposed by many of our dependencies. Node 8
  is twice LTS, and easily available even in conservative Linux distros.
  No reason not to demand it.
- **Default to Electron 8**.
- **Bump** all dependencies to latest version, including electron-packager.
- **Move to TS**. TS is great. As of today, I see no reason not to use it,
  and fight interface bugs at runtime rather than at compile time.
  With that, get rid of everything Babel/Webpack.
- **Move away from Gulp**. Gulp's selling point is perf via streaming,
  but for small builds like Nativefier, npm tasks are plenty good
  and less dependency bloat. Gulp was the driver for this PR: broken
  on Node 12, and I didn't feel like just upgrading and keeping it.
- Add tons of **verbose logs** everywhere it makes sense, to have a
  fine & clear trace of the program flow. This will be helpful to
  debug user-reported issues, and already helped me fix a few bugs.
    - With better simple logging, get rid of the quirky and buggy
      progress bar based on package `progress`. Nice logging (minimal
      by default, the verbose logging mentioned above is only used
      when passing `--verbose`) is better and one less dependency.
- **Dump `async` package**, a relic from old callback-hell early Node.
  Also dump a few other micro-packages unnecessary now.
- A first pass of code **cleanup** thanks to modern JS/TS features:
  fixes, simplifications, jsdoc type annotations to types, etc.
- **Remove GitHub integrations Hound & CodeClimate**, which are more
  exotic than good'ol'linters, and whose signal-to-noise ratio is too low.
- Quality: **Add tests** and add **Windows + macOS CI builds**.
  Also, add a **manual test script**, helping to quickly verify the
  hard-to-programatically-test stuff before releases, and limit regressions.
- **Fix a very small number of existing bugs**. The goal of this PR was
  *not* to fix bugs, but to get Nativefier in better shape to do so.
  Bugfixes will come later. Still, these got addressed:
  - Add common `Alt`+`Left`/`Right` for previous/next navigation.
  - Improve #379: fix zoom with `Ctrl` + numpad `+`/`-`
  - Fix pinch-to-zoom (see https://github.com/jiahaog/nativefier/issues/379#issuecomment-598612128 )
2020-03-15 16:50:01 -04:00
Ronan Jouchet
f115beed0d Issue templates: nits 2020-03-10 09:19:02 -04:00
Ronan Jouchet
9b50ebf3ca Issue templates / bugreport: nit 2020-03-10 09:17:05 -04:00
Ronan Jouchet
a4c373db80 Issue templates: comment header, enrich featurerequest 2020-03-10 09:15:53 -04:00
Ronan Jouchet
e57dc16cd3
Update bug_report.md 2020-03-10 09:12:46 -04:00
Ronan Jouchet
dc46b16247
Update feature_request.md 2020-03-10 09:11:18 -04:00
Ronan Jouchet
92ef0a4f08
Delete ISSUE_TEMPLATE.md 2020-03-10 09:07:39 -04:00
Jia Hao
ba37e5ccd0
Add modern github issue templates: bug, feature request (#901)
Co-authored-by: Ronan Jouchet <ronan@jouchet.fr>
2020-03-10 09:06:34 -04:00
Roberto Leinardi
261ee2913b
Fix #903: JS error when using Electron 7+ and --tray (PR #904)
The API `tray.setHighlightMode(mode)` has been be removed in electron v7.0
without replacement.

This causes the display of an error dialog every time an app is
shown/hidden if the parameter `--tray` is used when nativefying. This is
completely independent form the website you are nativefying and it
happens with all the version of electron after 6.x.

Source: https://www.electronjs.org/docs/api/breaking-changes#tray
2020-02-16 18:11:48 -05:00
Ronan Jouchet
b927b401b0 Update changelog for v7.7.1 2020-01-23 20:00:43 -05:00
Ronan Jouchet
97f092b77b Bump default Electron to 5.0.13 2020-01-23 19:57:18 -05:00
Siddharth Srinivasan
010f88aa1b Fix weirdly platform-dependent folder naming logic (PR #850, fix #708) 2020-01-15 09:09:37 -05:00
lockwiser
18813776ca Doc: Clarify background-color arguments (#891) 2020-01-14 13:52:49 -05:00
Darío Hereñú
2edbf799c1 Fixed duplicate word in doc for -bounce (#883) 2019-12-13 18:40:24 -05:00
Adrian DC
359f57c1f7 app: fix: nativefier application menu support on Electron 5.0 (#876) 2019-10-27 15:42:02 -04:00
otato.z
ef13ff1e1d feat: proxy rules with --proxy-rules flag (#854)
See https://electronjs.org/docs/api/session?q=proxy#sessetproxyconfig-callback
2019-10-22 19:38:39 -04:00
Adrian DC
84f06e3e79 app: handle nativefier.json readonly access with options.maximize (#856)
**Resolves #855**

**Example result upon Terminal launch:**

`WARNING: Ignored nativefier.json rewrital (Error: EACCES: permission denied, open '/usr/lib/jupyter-remote-client/resources/app/nativefier.json')`

**Behaviour:**

+ Instead of crashing, the application properly opens and is always maximized.

+ When permissions are R/W, the application is maximized on first launch and the closing states are remembered by the OS throughout launches.
2019-10-22 19:36:40 -04:00
shun
e00f08e5d6 Fix filter exception when injecting CSS (PR #837)
When injecting CSS, an `onBeforeRequest paramater 'filter' must have property 'urls'` error is thrown.

![image](https://user-images.githubusercontent.com/599164/63574823-a3dd6180-c5c3-11e9-89c0-a9debdd4f696.png)

This is caused by [Electron PR #19337: Throw on invalid webRequest filters](https://github.com/electron/electron/pull/19337).

So, pass filter argument properly, like Electron expects it strictly.
2019-08-28 07:28:18 -04:00
Ronan Jouchet
4f235c550a Update changelog for v7.7.0 2019-08-22 21:55:44 +02:00
Clement Fradet Normand
99b1808dde Improve doc for --internal-urls (PR #833) 2019-08-22 21:46:20 +02:00
Alex D'Andrea
b4d1ee0d39 Restore login functionality broken since Electron 5.x (PR #826)
nodeIntegration is required if eg. Javascript code makes use of the
`require` expression to import classes into the current scope. login.js
uses an electron import - without it, the callback mechanism does not
work, and thus the whole login functionality.

Electron seems to have changed the default value for a windows `nodeIntegration` to `false` since version 5 (see https://stackoverflow.com/questions/55093700/electron-5-0-0-uncaught-referenceerror-require-is-not-defined)

Without the integration, the login component's functionality is broken, though. This PR enables the nodeIntegration feature for the login window and makes it properly propagate the given credentials.

Tested with Electron 6.0.0 on Linux.
2019-08-22 21:41:37 +02:00
FabulousCupcake
d0a0614ba3 Add --browserwindow-options to completely expose Electron options (PR #835)
This adds a new flag `--browserwindow-options`, taking a stringified JSON object as input.  
It will be inserted directly into the options when BrowserConfig is initialized.

This allows total configurability of the electron BrowserWindow configuration via nativefier.

An example use case is added to the documentation, which modifies the default font family in the browser.

#### References

- https://github.com/electron/electron/blob/master/docs/api/browser-window.md#new-browserwindowoptions
  - See the following for electron v3.1.7
  - https://github.com/electron/electron/blob/v3.1.7/docs/api/browser-window.md#new-browserwindowoptions
2019-08-22 21:37:49 +02:00
Umair Ahmed
81c422d4e0 Support setting background color (fixes #795) (PR #819)
Adds a `--background-color` flag for the background of the window when the app isn't loaded.
2019-08-22 21:25:58 +02:00
Nate Woolls
5433569921 Support macOS 10.4+ Dark Mode, default to Electron 5.x (#796)
Introduces a `--darwin-dark-mode-support` flag. 
(I kept the same flag used by Electron Packager.)
This required bumping Electron and Electron Packager.

Addresses:

- https://github.com/jiahaog/nativefier/issues/733
- https://github.com/jiahaog/nativefier/issues/727
2019-08-22 21:05:39 +02:00
Adrian DC
b959956a38 Squirrel: resolve .quit() issue with missing ../screen (PR #784)
* As explained in: https://github.com/electron/electron/issues/8862#issuecomment-294303518
    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
2019-04-19 13:21:36 -04:00
Ronan Jouchet
070efe6fa9 Update changelog for v7.6.12 2019-03-25 19:14:25 -04:00
Ronan Jouchet
5cdfe96cbe Bump default electron to 3.1.7 2019-03-25 11:19:33 -04:00
Ying
479611ecc4 Fix crash when launching a second instance using option --single-instance (Fixes #664)
This refactors the deprecated call to `app.makeSingleInstance()`.
See [electron / app.requestSingleInstanceLock()](https://electronjs.org/docs/all?q=app.requestSingleInstanceLock).
2019-03-25 11:16:28 -04:00
Anas Emad
a27bb0fd35 Prevent menu from opening on Alt+Shift, by defining Alt+... menu shortcuts (#768)
On Linux if you try to change the keyboard layout with Alt + Shift,
the menu will pop up. Shortcuts are needed because Electron opens
the first menu on pressing `Alt` if no hotkey is assigned.

[Similar issue in RocketChat](https://github.com/RocketChat/Rocket.Chat.Electron/issues/50)
2019-03-17 11:29:15 -04:00
Ronan Jouchet
07faeb1881 Update changelog for v7.6.11 2019-02-10 22:20:40 -05:00
Ronan Jouchet
726f44d266 Bump default Electron to 3.1.3 2019-02-09 21:46:15 -05:00
Adrian DC
5b6cc89f22 Fix #316: Add --clear-cache flag to cleanup session on start/exit ("incognito" mode) (PR #747)
- Add a new `clearCache` option and `--clear-cache` parameter
  to trigger session cleanups upon window launch and close

- Covers the feature request from issue #316 

- Use case example: Forcing authentification / login between sessions without limiting cache size
2019-02-08 10:03:29 -05:00
Ronan Jouchet
85aacaaa52
Doc for squirrel installers 2019-02-08 09:59:20 -05:00
Adrian DC
310d63e397 Support packaging nativefier applications into Squirrel-based installers (#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}`));
});
```
2019-02-08 09:57:32 -05:00
Dword
3588f8a85f Icon conversion: don't crash if source/destination paths have spaces (PR #736) 2019-01-09 10:08:17 -05:00
Ronan Jouchet
c722f8a5ac Update changelog for v7.6.10 2019-01-01 23:44:57 -05:00
Ronan Jouchet
d6b4b23f0a Bump default Electron to 3.0.13 2019-01-01 23:42:50 -05:00
Dominic Hopton
e064f765cb Fix CSS & JavaScript injection (Fixes #703, Fixes #731, PR #732)
* Fix for CSS Injection not working (#703)

Issue:
When using `onHeadersReceived`, the code was passing `null` for the filters.
This appears to trigger behaviour that matches _no_ urls at all.
This results in it never being called to inject the CSS.

Fix:
Pass an empty array instead. Now it's called for all URLs.

Tests pass & linting is clean

* Fix JavaScript injection (#731)

Issue:
It appears that on low endd evices (Core m3 MacBook), the attachment to
`DOMContentLoaded` happens _after_ the event has been raised, so does
not have a chance to inject the script.

Fix:
Move the attachment to the top of the file -- before the imports. This
triggers a bunch of linting erros, so also added disablement inplace.

Additional:
Clarified when the injected JS gets loaded, and what it can assume about
the DOM.
2019-01-01 23:38:45 -05:00