create-pwa
Advanced tools
Comparing version 0.3.0 to 0.4.0
{ | ||
"name": "create-pwa", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "Easily create a progressive web app", | ||
@@ -28,8 +28,8 @@ "scripts": { | ||
"dependencies": { | ||
"sharp": "^0.20.2", | ||
"yargs": "^11.0.0" | ||
"sharp": "^0.20.5", | ||
"yargs": "^12.0.1" | ||
}, | ||
"devDependencies": { | ||
"tape": "^4.9.0" | ||
"tape": "^4.9.1" | ||
} | ||
} |
@@ -1,3 +0,1 @@ | ||
[![GitHub stars](https://img.shields.io/github/stars/scriptex/create-pwa.svg?style=social&label=Stars)](https://github.com/scriptex/create-pwa) | ||
[![GitHub forks](https://img.shields.io/github/forks/scriptex/create-pwa.svg?style=social&label=Fork)](https://github.com/scriptex/create-pwa/network#fork-destination-box) | ||
[![GitHub release](https://img.shields.io/github/release/scriptex/create-pwa.svg)](https://github.com/scriptex/create-pwa/releases/latest) | ||
@@ -9,6 +7,6 @@ [![GitHub issues](https://img.shields.io/github/issues/scriptex/create-pwa.svg)](https://github.com/scriptex/create-pwa/issues) | ||
[![npm](https://img.shields.io/npm/v/create-pwa.svg)](https://www.npmjs.com/package/create-pwa) | ||
[![license](https://img.shields.io/github/license/scriptex/create-pwa.svg)](https://github.com/scriptex/create-pwa) | ||
[![Analytics](https://ga-beacon.appspot.com/UA-83446952-1/github.com/scriptex/create-pwa/README.md)](https://github.com/scriptex/create-pwa/) | ||
[![Open Source Love svg1](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://github.com/scriptex/create-pwa/) | ||
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/scriptex/create-pwa/graphs/commit-activity) | ||
[![Greenkeeper badge](https://badges.greenkeeper.io/scriptex/create-pwa.svg)](https://greenkeeper.io/) | ||
[![dependencies Status](https://david-dm.org/scriptex/create-pwa/status.svg)](https://david-dm.org/scriptex/create-pwa) | ||
[![devDependencies Status](https://david-dm.org/scriptex/create-pwa/dev-status.svg)](https://david-dm.org/scriptex/create-pwa?type=dev) | ||
@@ -33,3 +31,3 @@ # create-pwa | ||
```console | ||
```sh | ||
# Using NPM: | ||
@@ -55,3 +53,3 @@ npm i create-pwa --save-dev | ||
```console | ||
```sh | ||
cd your/app/folder | ||
@@ -64,7 +62,7 @@ | ||
``` | ||
```json | ||
{ | ||
"scripts": { | ||
"pwa": "create-pwa --icon=\"path/to/your/icon.png\"" | ||
} | ||
"scripts": { | ||
"pwa": "create-pwa --icon=\"path/to/your/icon.png\"" | ||
} | ||
} | ||
@@ -83,3 +81,3 @@ ``` | ||
1. Add the following to the `head` of your HTML file(s): | ||
1. Add the following to the `head` of your HTML file(s): | ||
@@ -92,20 +90,12 @@ ```html | ||
2. Add the following snippet to your application's JavaScript bundle or place it in a `script` tag just before the closing `</body>` tag in your HTML file(s): | ||
2. Add the following snippet to your application's JavaScript bundle or place it in a `script` tag just before the closing `</body>` tag in your HTML file(s): | ||
```js | ||
```javascript | ||
if ('serviceWorker' in navigator) { | ||
window.addEventListener('load', function() { | ||
navigator.serviceWorker.register('./service-worker.js').then( | ||
function(registration) { | ||
// Registration was successful | ||
console.log( | ||
'ServiceWorker registration successful with scope: ', | ||
registration.scope | ||
); | ||
}, | ||
function(err) { | ||
// registration failed :( | ||
console.log('ServiceWorker registration failed: ', err); | ||
} | ||
); | ||
window.addEventListener('load', () => { | ||
navigator.serviceWorker.register('./service-worker.js').then(registration => { | ||
console.log(`ServiceWorker registration successful with scope: ${registration.scope}`); | ||
}, error => { | ||
console.log(`ServiceWorker registration failed: ${error}`); | ||
}); | ||
}); | ||
@@ -112,0 +102,0 @@ } |
@@ -19,2 +19,3 @@ #!/usr/bin/env node | ||
const manifestTemplate = require('./manifest'); | ||
const appCacheTemplate = require('./appcache'); | ||
const serviceWorkerTemplate = require('./sw'); | ||
@@ -76,2 +77,12 @@ | ||
/** | ||
* Create app's cache manifest | ||
*/ | ||
const setAppCache = name => { | ||
writeFileSync( | ||
resolve(pwd, `${name}.appcache`), | ||
appCacheTemplate() | ||
); | ||
}; | ||
/** | ||
* Create all PWA required files | ||
@@ -83,3 +94,3 @@ */ | ||
setIcons(argv.icon || icon); | ||
setAppCache(name); | ||
setManifest(name); | ||
@@ -95,3 +106,4 @@ setServiceWorker(name); | ||
module.exports.setIcons = setIcons; | ||
module.exports.setAppCache = setAppCache; | ||
module.exports.setManifest = setManifest; | ||
module.exports.setServiceWorker = setServiceWorker; |
11
test.js
@@ -70,2 +70,13 @@ /** | ||
/** | ||
* Test if an appcache file is created | ||
*/ | ||
tape('Should create an appcache file', t => { | ||
const ac = resolve(__dirname, './create-pwa.appcache'); | ||
const appCacheFileExists = existsSync(ac); | ||
t.ok(appCacheFileExists, 'create-pwa.appcache exists'); | ||
t.end(); | ||
}); | ||
/** | ||
* Test if icons are being generated | ||
@@ -72,0 +83,0 @@ */ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
185589
21
431
113
1
+ Addedcamelcase@5.3.1(transitive)
+ Addedfind-up@3.0.0(transitive)
+ Addedlocate-path@3.0.0(transitive)
+ Addedp-limit@2.3.0(transitive)
+ Addedp-locate@3.0.0(transitive)
+ Addedp-try@2.2.0(transitive)
+ Addedy18n@4.0.3(transitive)
+ Addedyargs@12.0.5(transitive)
+ Addedyargs-parser@11.1.1(transitive)
- Removedcamelcase@4.1.0(transitive)
- Removedfind-up@2.1.0(transitive)
- Removedlocate-path@2.0.0(transitive)
- Removedp-limit@1.3.0(transitive)
- Removedp-locate@2.0.0(transitive)
- Removedp-try@1.0.0(transitive)
- Removedy18n@3.2.2(transitive)
- Removedyargs@11.1.1(transitive)
- Removedyargs-parser@9.0.2(transitive)
Updatedsharp@^0.20.5
Updatedyargs@^12.0.1