Skip to content

Commit

Permalink
Added support for CLI option --manifest (#12)
Browse files Browse the repository at this point in the history
* Update pwaify

Add --manifest option.

* Update manifest.js

Added support for CLI --manifest option

* Update index.js

Added support for CLI --manifest option.

* Update README.md

Add --manifest option usage example.
  • Loading branch information
getive authored May 22, 2020
1 parent 3002755 commit 85e9e9f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ npm install -g pwaify
```
pwaify https://airhorner.com
pwaify https://voice-memos.appspot.com/ --platforms=darwin --icon chrome-touch-icon-384x384.icns
pwaify https://m.weibo.cn --platforms=darwin --manifest=https://m.weibo.cn/static/pwa/manifest.json
```

(Might require `sudo` at the moment if you get `pref.json` error).
Expand Down
4 changes: 3 additions & 1 deletion bin/pwaify
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const cli = meow(`
Options
--platforms Platforms to build the app.
--icon App Icon.
--manifest Manifest.json url.
Examples
$ pwaify https://airhorner.com --platforms=darwin
Expand All @@ -17,5 +18,6 @@ require('../index')({
appUrl: cli.input[0],
platforms: cli.flags.platforms || 'all',
path: cli.flags.path || '.',
icon: cli.flags.icon
icon: cli.flags.icon,
manifestUrl: cli.flags.manifest
});
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ module.exports = function (options) {
debug('options', options);
const appUrl = options.appUrl;
const appPath = options.path;

return manifest.fetchManifestDetails(appUrl)
const manifestUrl = options.manifestUrl;
return manifest.fetchManifestDetails(appUrl, manifestUrl)
.then(function(manifestJson) {
debug('manifestJson', manifestJson);
var name = manifestJson.name || manifestJson.short_name;
Expand Down
7 changes: 6 additions & 1 deletion lib/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ const debug = require('debug')('manifest');
const Xray = require('x-ray');

module.exports = {
fetchManifestDetails: function fetchManifestDetails (appUrl) {
fetchManifestDetails: function fetchManifestDetails (appUrl, manifestUrl) {
return new Promise(function (resolve, reject) {
if (manifestUrl) {
return resolve({
manifestTarget: manifestUrl
});
}
var xray = Xray();
xray(appUrl, 'link[rel=manifest]@href')(function(err, manifestTarget) {
debug(err, manifestTarget);
Expand Down

0 comments on commit 85e9e9f

Please sign in to comment.