Skip to content

Commit

Permalink
Merge pull request #41 from onderceylan/next
Browse files Browse the repository at this point in the history
1.2.0 release
  • Loading branch information
onderceylan authored Sep 12, 2019
2 parents c2dc925 + 23e4bbd commit 1751914
Show file tree
Hide file tree
Showing 16 changed files with 708 additions and 195 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
"ecmaVersion": 2018
},
"rules": {
"no-prototype-builtins": "off"
}
}
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ __snapshots__/*
.prettierrc
.travis.yml
.releaserc
.idea
.github
*.test.js
47 changes: 35 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,35 +66,58 @@ $ pwa-asset-generator --help
-b --background Page background to use when image source is provided: css value [default: transparent]
-o --opaque Making screenshots to be saved with a background color [default: true]
-p --padding Padding to use when image source provided: css value [default: "10%"]
-s --scrape Scraping Apple Human Interface Guidelines to fetch splash screen specs [default: true]
-m --manifest Web app manifest file path to automatically update manifest file with the generated images
-i --index Index html file path to automatically put splash screen meta tags in
-s --scrape Scraping Apple Human Interface guidelines to fetch splash screen specs [default: true]
-m --manifest Web app manifest file path to automatically update manifest file with the generated icons
-i --index Index html file path to automatically put splash screen and icon meta tags in
-a --path Path prefix to prepend for href links generated for meta tags
-t --type Image type: png|jpeg [default: png]
-q --quality Image quality: 0...100 (Only for JPEG) [default: 100]
-h --splash-only Only generate splash screens [default: false]
-c --icon-only Only generate icons [default: false]
-l --landscape-only Only generate landscape splash screens [default: false]
-r --portrait-only Only generate portrait splash screens [default: false]
-g --log Logs the steps of the library process [default: true]
Examples
$ pwa-asset-generator logo.html .
$ pwa-asset-generator https://your-cdn-server.com/assets/logo.png . -t jpeg -q 90 --splash-only --portrait-only
$ pwa-asset-generator logo.svg ./assets --scrape false --icon-only
$ pwa-asset-generator logo.svg ./assets --scrape false --icon-only --path "%PUBLIC_URL%"
$ pwa-asset-generator https://raw.githubusercontent.com/onderceylan/pwa-asset-generator/HEAD/static/logo.png -p "15%" -b "linear-gradient(to right, #fa709a 0%, #fee140 100%)"
Flag examples
--background="rgba(255, 255, 255, .5)"
--opaque=false
--padding="10px"
--scrape=false
--manifest=./src/manifest.json
--index=./src/index.html
--type=jpeg
--quality=80
--background "rgba(255, 255, 255, .5)"
--opaque false
--padding "10px"
--scrape false
--manifest ./src/manifest.json
--index ./src/index.html
--path "%PUBLIC_URL%"
--type jpeg
--quality 80
--splash-only
--icon-only
--landscape-only
--portrait-only
--log false
```

### Module

```javascript
const pwaAssetGenerator = require('pwa-asset-generator');

(async () => {
const { savedImages, htmlContent, manifestJsonContent } = await pwaAssetGenerator.generateImages(
'https://raw.githubusercontent.com/onderceylan/pwa-asset-generator/HEAD/static/logo.png',
'./temp',
{
scrape: false,
background: "linear-gradient(to right, #fa709a 0%, #fee140 100%)",
splashOnly: true,
portraitOnly: true,
log: false
});
})();
```

## Troubleshooting
Expand Down
94 changes: 94 additions & 0 deletions __snapshots__/cli.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ exports[`generates icons and splash screens when both only flags exist 1`] = `
]
<link rel=\\"apple-touch-icon\\" sizes=\\"180x180\\" href=\\"temp/apple-icon-180.png\\">
<link rel=\\"apple-touch-icon\\" sizes=\\"167x167\\" href=\\"temp/apple-icon-167.png\\">
<link rel=\\"apple-touch-icon\\" sizes=\\"152x152\\" href=\\"temp/apple-icon-152.png\\">
Expand Down Expand Up @@ -82,6 +83,94 @@ exports[`generates icons and splash screens when both only flags exist 1`] = `
<link rel=\\"apple-touch-startup-image\\"
href=\\"temp/apple-splash-1136-640.png\\"
media=\\"(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)\\">
"
`;
exports[`generates icons and splash screens with path prefix 1`] = `
"
[
{
\\"src\\": \\"temp/manifest-icon-192.png\\",
\\"sizes\\": \\"192x192\\",
\\"type\\": \\"image/png\\"
},
{
\\"src\\": \\"temp/manifest-icon-512.png\\",
\\"sizes\\": \\"512x512\\",
\\"type\\": \\"image/png\\"
}
]
<link rel=\\"apple-touch-icon\\" sizes=\\"180x180\\" href=\\"%PUBLIC_URL%/temp/apple-icon-180.png\\">
<link rel=\\"apple-touch-icon\\" sizes=\\"167x167\\" href=\\"%PUBLIC_URL%/temp/apple-icon-167.png\\">
<link rel=\\"apple-touch-icon\\" sizes=\\"152x152\\" href=\\"%PUBLIC_URL%/temp/apple-icon-152.png\\">
<link rel=\\"apple-touch-icon\\" sizes=\\"120x120\\" href=\\"%PUBLIC_URL%/temp/apple-icon-120.png\\">
<meta name=\\"apple-mobile-web-app-capable\\" content=\\"yes\\">
<link rel=\\"apple-touch-startup-image\\"
href=\\"%PUBLIC_URL%/temp/apple-splash-2048-2732.png\\"
media=\\"(device-width: 1024px) and (device-height: 1366px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)\\">
<link rel=\\"apple-touch-startup-image\\"
href=\\"%PUBLIC_URL%/temp/apple-splash-2732-2048.png\\"
media=\\"(device-width: 1024px) and (device-height: 1366px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)\\">
<link rel=\\"apple-touch-startup-image\\"
href=\\"%PUBLIC_URL%/temp/apple-splash-1668-2388.png\\"
media=\\"(device-width: 834px) and (device-height: 1194px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)\\">
<link rel=\\"apple-touch-startup-image\\"
href=\\"%PUBLIC_URL%/temp/apple-splash-2388-1668.png\\"
media=\\"(device-width: 834px) and (device-height: 1194px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)\\">
<link rel=\\"apple-touch-startup-image\\"
href=\\"%PUBLIC_URL%/temp/apple-splash-1668-2224.png\\"
media=\\"(device-width: 834px) and (device-height: 1112px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)\\">
<link rel=\\"apple-touch-startup-image\\"
href=\\"%PUBLIC_URL%/temp/apple-splash-2224-1668.png\\"
media=\\"(device-width: 834px) and (device-height: 1112px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)\\">
<link rel=\\"apple-touch-startup-image\\"
href=\\"%PUBLIC_URL%/temp/apple-splash-1536-2048.png\\"
media=\\"(device-width: 768px) and (device-height: 1024px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)\\">
<link rel=\\"apple-touch-startup-image\\"
href=\\"%PUBLIC_URL%/temp/apple-splash-2048-1536.png\\"
media=\\"(device-width: 768px) and (device-height: 1024px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)\\">
<link rel=\\"apple-touch-startup-image\\"
href=\\"%PUBLIC_URL%/temp/apple-splash-1242-2688.png\\"
media=\\"(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)\\">
<link rel=\\"apple-touch-startup-image\\"
href=\\"%PUBLIC_URL%/temp/apple-splash-2688-1242.png\\"
media=\\"(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)\\">
<link rel=\\"apple-touch-startup-image\\"
href=\\"%PUBLIC_URL%/temp/apple-splash-1125-2436.png\\"
media=\\"(device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)\\">
<link rel=\\"apple-touch-startup-image\\"
href=\\"%PUBLIC_URL%/temp/apple-splash-2436-1125.png\\"
media=\\"(device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)\\">
<link rel=\\"apple-touch-startup-image\\"
href=\\"%PUBLIC_URL%/temp/apple-splash-828-1792.png\\"
media=\\"(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)\\">
<link rel=\\"apple-touch-startup-image\\"
href=\\"%PUBLIC_URL%/temp/apple-splash-1792-828.png\\"
media=\\"(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)\\">
<link rel=\\"apple-touch-startup-image\\"
href=\\"%PUBLIC_URL%/temp/apple-splash-1242-2208.png\\"
media=\\"(device-width: 414px) and (device-height: 736px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)\\">
<link rel=\\"apple-touch-startup-image\\"
href=\\"%PUBLIC_URL%/temp/apple-splash-2208-1242.png\\"
media=\\"(device-width: 414px) and (device-height: 736px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)\\">
<link rel=\\"apple-touch-startup-image\\"
href=\\"%PUBLIC_URL%/temp/apple-splash-750-1334.png\\"
media=\\"(device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)\\">
<link rel=\\"apple-touch-startup-image\\"
href=\\"%PUBLIC_URL%/temp/apple-splash-1334-750.png\\"
media=\\"(device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)\\">
<link rel=\\"apple-touch-startup-image\\"
href=\\"%PUBLIC_URL%/temp/apple-splash-640-1136.png\\"
media=\\"(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)\\">
<link rel=\\"apple-touch-startup-image\\"
href=\\"%PUBLIC_URL%/temp/apple-splash-1136-640.png\\"
media=\\"(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)\\">
"
`;
Expand All @@ -101,12 +190,14 @@ exports[`generates icons only 1`] = `
]
<link rel=\\"apple-touch-icon\\" sizes=\\"180x180\\" href=\\"temp/apple-icon-180.png\\">
<link rel=\\"apple-touch-icon\\" sizes=\\"167x167\\" href=\\"temp/apple-icon-167.png\\">
<link rel=\\"apple-touch-icon\\" sizes=\\"152x152\\" href=\\"temp/apple-icon-152.png\\">
<link rel=\\"apple-touch-icon\\" sizes=\\"120x120\\" href=\\"temp/apple-icon-120.png\\">
<meta name=\\"apple-mobile-web-app-capable\\" content=\\"yes\\">
"
`;
Expand Down Expand Up @@ -144,6 +235,7 @@ exports[`generates landscape splash screens only 1`] = `
<link rel=\\"apple-touch-startup-image\\"
href=\\"temp/apple-splash-1136-640.png\\"
media=\\"(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)\\">
"
`;
Expand Down Expand Up @@ -181,6 +273,7 @@ exports[`generates portrait splash screens only 1`] = `
<link rel=\\"apple-touch-startup-image\\"
href=\\"temp/apple-splash-640-1136.png\\"
media=\\"(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)\\">
"
`;
Expand Down Expand Up @@ -248,5 +341,6 @@ exports[`generates splash screens only 1`] = `
<link rel=\\"apple-touch-startup-image\\"
href=\\"temp/apple-splash-1136-640.png\\"
media=\\"(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)\\">
"
`;
Loading

0 comments on commit 1751914

Please sign in to comment.