2
2
mirror of https://github.com/Llewellynvdm/nativefier.git synced 2024-11-05 04:47:54 +00:00
nativefier/README.md

140 lines
7.1 KiB
Markdown
Raw Normal View History

2015-07-05 07:24:36 +00:00
# Nativefier
2016-03-13 07:27:32 +00:00
![Example of Nativefier app in the macOS dock](.github/dock-screenshot.png)
2015-07-06 05:44:49 +00:00
2016-03-10 18:27:49 +00:00
You want to make a native wrapper for WhatsApp Web (or any web page).
2016-01-19 14:02:01 +00:00
```bash
nativefier 'web.whatsapp.com'
2016-01-19 14:02:01 +00:00
```
![Walkthrough animation](.github/nativefier-walkthrough.gif)
2016-01-19 14:02:01 +00:00
You're done.
2015-07-05 07:24:36 +00:00
2016-01-19 14:02:01 +00:00
## Introduction
2015-07-05 07:24:36 +00:00
Nativefier is a command-line tool to easily create a desktop app for any web site
with minimal configuration. Apps are wrapped by [Electron](https://www.electronjs.org/)
(which uses Chromium under the hood) in an OS executable (`.app`, `.exe`, etc)
for use on Windows, macOS and Linux.
2015-07-05 08:43:44 +00:00
I did this because I was tired of having to `⌘-tab` or `alt-tab` to my browser and then search
through the numerous open tabs when I was using [Facebook Messenger](https://messenger.com) or
[Whatsapp Web](https://web.whatsapp.com) ([HN thread](https://news.ycombinator.com/item?id=10930718)). Nativefier features:
2016-01-29 17:57:30 +00:00
- Automatically retrieval of app icon / name.
- JavaScript and CSS injection.
- Many more, see the [API docs](API.md) or `nativefier --help`
2015-07-05 07:24:36 +00:00
## Installation
2017-04-09 02:35:46 +00:00
- macOS 10.9+ / Windows / Linux
- [Node.js](https://nodejs.org/) `>= 12.9` and npm `>= 6.9`
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 20:50:01 +00:00
- Optional dependencies:
- [ImageMagick](http://www.imagemagick.org/) or [GraphicsMagick](http://www.graphicsmagick.org/) to convert icons.
Make sure `convert` and `identify` or `gm` are in your system `$PATH`.
- [Wine](https://www.winehq.org/) to package Windows apps under non-Windows platforms.
2020-07-18 14:27:56 +00:00
Make sure `wine` is in your system `$PATH`.
2016-01-22 04:31:30 +00:00
Then, install Nativefier globally with `npm install -g nativefier`
2016-01-28 03:38:58 +00:00
## Usage
2016-01-28 03:38:58 +00:00
To create a native desktop app for [medium.com](https://medium.com),
simply `nativefier "medium.com"`
2016-01-28 03:38:58 +00:00
2020-07-18 14:27:56 +00:00
Nativefier will try to determine the app name, and well as lots of other options.
If desired, these options can be overwritten. For example, to override the name,
`nativefier --name 'My Medium App' 'medium.com'`
**Read the [API documentation](API.md) or run `nativefier --help`**
2020-07-18 14:27:56 +00:00
to learn about other command-line flags usable to configure the packaged app.
2016-01-18 17:17:27 +00:00
To have high-resolution icons used by default for an app/domain, please
2021-01-30 04:49:52 +00:00
contribute to the [icon repository](https://github.com/nativefier/nativefier-icons)!
2016-01-18 17:17:27 +00:00
### Build Commands Catalog
For a list of build commands contributed by the nativefier community take a look at the [CATALOG.md file](CATALOG.md)
## Usage with Docker
Nativefier is also usable from Docker.
2021-01-30 04:49:52 +00:00
- Pull the latest stable image from Docker Hub: `docker pull nativefier/nativefier`
- ... or build the image yourself: `docker build -t local/nativefier .`
2021-01-30 04:49:52 +00:00
(in this case, replace `nativefier/` in the below examples with `local/`)
By default, the command `nativefier --help` will be executed.
To build e.g. a Gmail nativefier app to a writable local `~/nativefier-apps`,
```bash
2021-01-30 04:49:52 +00:00
docker run --rm -v ~/nativefier-apps:/target/ nativefier/nativefier https://mail.google.com/ /target/
```
You can pass Nativefier flags, and mount volumes to provide local files. For example, to use an icon,
```bash
2021-01-30 04:49:52 +00:00
docker run --rm -v ~/my-icons-folder/:/src -v $TARGET-PATH:/target nativefier/nativefier --icon /src/icon.png --name whatsApp -p linux -a x64 https://web.whatsapp.com/ /target/
```
2016-03-13 07:27:32 +00:00
## Development
2016-03-10 18:27:49 +00:00
2021-01-30 04:49:52 +00:00
Help welcome on [bugs](https://github.com/nativefier/nativefier/issues?q=is%3Aopen+is%3Aissue+label%3Abug) and
[feature requests](https://github.com/nativefier/nativefier/issues?q=is%3Aopen+is%3Aissue+label%3Afeature-request).
[Developer / build docs](HACKING.md), [API documentation](API.md),
[Changelog](CHANGELOG.md).
2016-03-10 18:27:49 +00:00
## License
2015-07-06 05:44:49 +00:00
2016-03-13 07:27:32 +00:00
[MIT](LICENSE.md)
## Troubleshooting
Before submitting a question or bug report, please ensure you have read through these common issues and see if you can resolve the problem on your own. If you still encounter issues after trying these steps, or you don't see something similar to your issue listed, please submit a [bug report](https://github.com/nativefier/nativefier/issues/new?assignees=&labels=bug&template=bug_report.md).
Take a look a the [Build Command Catalog](CATALOG.md) as a working command for your application may already exist there.
### I am trying to use Nativefier to build an app for a site that tells me I have an old/unsupported browser.
This issue comes up for sites that do not wish to support an app made with Nativefier or similar technologies (such as [Google](https://github.com/nativefier/nativefier/issues/831) and [WhatsApp](https://github.com/nativefier/nativefier/issues/1112))
#### Troubleshooting Steps
1. First try setting the [`--user-agent`](https://github.com/nativefier/nativefier/blob/master/API.md#user-agent) to something different. Try using the value you would get at [https://www.whatismybrowser.com/detect/what-is-my-user-agent] and use your current browser's user agent.
2. If this doesn't work, the site (such as WhatsApp) may be using a service worker to analyze the app and detect. You can disable the service worker cache by doing the following, which is a known fix for WhatsApp:
1. Create a javascript file containing the following snippet:
```javascript
if ('serviceWorker' in navigator) {
caches.keys().then(function (cacheNames) {
cacheNames.forEach(function (cacheName) {
caches.delete(cacheName);
});
});
}
```
2. Inject the javascript file into your app when generating it with the [`--inject`](https://github.com/nativefier/nativefier/blob/master/API.md#inject) argument.
### I am trying to use Nativefier to build an app for a site with video, but the video won't play.
This issue comes up for certain sites like [HBO Max](https://github.com/nativefier/nativefier/issues/1153) and [Udemy](https://github.com/nativefier/nativefier/issues/1147).
#### Troubleshooting Steps
1. First try using the [`--widevine`](https://github.com/nativefier/nativefier/blob/master/API.md#widevine) argument when building the app. This uses the [Castlabs version of Electron](https://github.com/castlabs/electron-releases) which allows the playback of DRM enabled video.
2. If this doesn't work, the site may require your app to be signed for `--widevine` to work. See the [Castlabs documentation](https://github.com/castlabs/electron-releases/wiki/EVS) on using their application signing service to sign the application.
### I am trying different options to Nativefier to experiment with, but noticing that sometimes things cache between rebuilds of my app.
This issue can occur because the cache of the app and the app itself are kept separate by default. You can try clearing out the cache.
#### Troubleshooting Steps
1. Delete your app's cache, which can be found under the folder `<your_app_name_lower_case>-nativefier-<random_id>` in your OS's app data directory
- `<your_app_name_lower_case>` represents the lowercase version of your app's name. E.g., GitHub would be `github`.
- `<random_id>` represents a randomly generated id for your app. Open the containing folder to see what it may be.
2. For Linux, the app data directory is `$XDG_CONFIG_HOME` or `~/.config`
3. For MacOS, the app data directory is `~/Library/Application\ Support/`
4. For Windows, the app data directory is `%APPDATA%`