Skip to content

Commit

Permalink
Merge pull request #267 from GoogleChromeLabs/bump/0.4.0
Browse files Browse the repository at this point in the history
Bump version to 0.4.0
westonruter authored Mar 31, 2020
2 parents ffaa46f + 270b02b commit f5ecce4
Showing 10 changed files with 68 additions and 64 deletions.
51 changes: 24 additions & 27 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
/* jshint node:true */
/* eslint-disable camelcase, no-console, no-param-reassign */

module.exports = function(grunt) {
module.exports = function (grunt) {
"use strict";

grunt.initConfig({
@@ -11,33 +11,33 @@ module.exports = function(grunt) {
// Clean up the build.
clean: {
build: {
src: ["build"]
}
src: ["build"],
},
},

// Shell actions.
shell: {
options: {
stdout: true,
stderr: true
stderr: true,
},
readme: {
command: "npm run generate-readme" // Generate the readme.md.
command: "npm run generate-readme", // Generate the readme.md.
},
phpunit: {
command: "phpunit"
command: "phpunit",
},
verify_matching_versions: {
command: "php bin/verify-version-consistency.php"
command: "php bin/verify-version-consistency.php",
},
install_workbox: {
command:
"if [ -e wp-includes/js/workbox* ]; then rm -r wp-includes/js/workbox*; fi; npx workbox copyLibraries wp-includes/js/ && mv wp-includes/js/workbox-v* wp-includes/js/workbox"
"if [ -e wp-includes/js/workbox* ]; then rm -r wp-includes/js/workbox*; fi; npx workbox copyLibraries wp-includes/js/ && mv wp-includes/js/workbox-v* wp-includes/js/workbox",
},
create_build_zip: {
command:
'if [ ! -e build ]; then echo "Run grunt build first."; exit 1; fi; if [ -e pwa.zip ]; then rm pwa.zip; fi; cd build; zip -r ../pwa.zip .; cd ..; echo; echo "ZIP of build: $(pwd)/pwa.zip"'
}
'if [ ! -e build ]; then echo "Run grunt build first."; exit 1; fi; if [ -e pwa.zip ]; then rm pwa.zip; fi; cd build; zip -r ../pwa.zip .; cd ..; echo; echo "ZIP of build: $(pwd)/pwa.zip"',
},
},

// Deploys a git Repo to the WordPress SVN repo.
@@ -46,10 +46,10 @@ module.exports = function(grunt) {
options: {
plugin_slug: "pwa",
build_dir: "build",
assets_dir: "wp-assets"
}
}
}
assets_dir: "wp-assets",
},
},
},
});

// Load tasks.
@@ -63,7 +63,7 @@ module.exports = function(grunt) {

grunt.registerTask("readme", ["shell:readme"]);

grunt.registerTask("build", function() {
grunt.registerTask("build", function () {
const done = this.async();
const spawnQueue = [];
const stdout = [];
@@ -73,11 +73,11 @@ module.exports = function(grunt) {
spawnQueue.push(
{
cmd: "git",
args: ["--no-pager", "log", "-1", "--format=%h", "--date=short"]
args: ["--no-pager", "log", "-1", "--format=%h", "--date=short"],
},
{
cmd: "git",
args: ["ls-files"]
args: ["ls-files"],
}
);

@@ -87,15 +87,12 @@ module.exports = function(grunt) {
const versionAppend =
commitHash +
"-" +
new Date()
.toISOString()
.replace(/\.\d+/, "")
.replace(/-|:/g, "");
new Date().toISOString().replace(/\.\d+/, "").replace(/-|:/g, "");

const paths = lsOutput
.trim()
.split(/\n/)
.filter(function(file) {
.filter(function (file) {
return !/^(\.|bin|([^/]+)+\.(json|xml)|Gruntfile\.js|tests|CONTRIBUTING\.md|wp-assets|composer\..*|webpack.*)/.test(
file
);
@@ -129,9 +126,9 @@ module.exports = function(grunt) {
}
}
return content;
}
}
}
},
},
},
});
grunt.task.run("copy");

@@ -143,7 +140,7 @@ module.exports = function(grunt) {
if (!nextSpawnArgs) {
finalize();
} else {
grunt.util.spawn(nextSpawnArgs, function(err, res) {
grunt.util.spawn(nextSpawnArgs, function (err, res) {
if (err) {
throw new Error(err.message);
}
@@ -162,6 +159,6 @@ module.exports = function(grunt) {
"shell:verify_matching_versions",
"shell:phpunit",
"build",
"wp_deploy"
"wp_deploy",
]);
};
12 changes: 9 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
"grunt-shell": "3.0.1",
"grunt-wp-deploy": "2.0.0",
"npm-run-all": "4.1.5",
"prettier": "2.0.2",
"workbox-cli": "5.1.2"
},
"scripts": {
4 changes: 2 additions & 2 deletions pwa.php
Original file line number Diff line number Diff line change
@@ -9,15 +9,15 @@
* Plugin Name: PWA
* Plugin URI: https://github.com/GoogleChromeLabs/pwa-wp
* Description: Feature plugin to bring Progressive Web App (PWA) capabilities to Core
* Version: 0.4.0-alpha
* Version: 0.4.0
* Author: PWA Plugin Contributors
* Author URI: https://github.com/GoogleChromeLabs/pwa-wp/graphs/contributors
* Text Domain: pwa
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
*/

define( 'PWA_VERSION', '0.4.0-alpha' );
define( 'PWA_VERSION', '0.4.0' );
define( 'PWA_PLUGIN_FILE', __FILE__ );
define( 'PWA_PLUGIN_DIR', dirname( __FILE__ ) );
define( 'PWA_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ WordPress feature plugin to bring Progressive Web App (PWA) capabilities to Core
**Tags:** [pwa](https://wordpress.org/plugins/tags/pwa), [progressive web apps](https://wordpress.org/plugins/tags/progressive-web-apps), [service workers](https://wordpress.org/plugins/tags/service-workers), [web app manifest](https://wordpress.org/plugins/tags/web-app-manifest), [https](https://wordpress.org/plugins/tags/https)
**Requires at least:** 5.3
**Tested up to:** 5.4
**Stable tag:** 0.3.0
**Stable tag:** 0.4.0
**License:** [GPLv2 or later](http://www.gnu.org/licenses/gpl-2.0.html)
**Requires PHP:** 5.6

2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ Contributors: google, xwp, westonruter
Tags: pwa, progressive web apps, service workers, web app manifest, https
Requires at least: 5.3
Tested up to: 5.4
Stable tag: 0.3.0
Stable tag: 0.4.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Requires PHP: 5.6
32 changes: 16 additions & 16 deletions wp-includes/js/service-worker-navigation-routing.js
Original file line number Diff line number Diff line change
@@ -36,30 +36,30 @@ ERROR_OFFLINE_URL, ERROR_500_URL, NAVIGATION_DENYLIST_PATTERNS, ERROR_MESSAGES *
* @return {Promise<Response>} Response.
*/
async function handleNavigationRequest({ event }) {
const handleResponse = response => {
const handleResponse = (response) => {
if (response.status < 500) {
return response;
}

const originalResponse = response.clone();
return response.text().then(function(responseBody) {
return response.text().then(function (responseBody) {
// Prevent serving custom error template if WordPress is already responding with a valid error page (e.g. via wp_die()).
if (-1 !== responseBody.indexOf("</html>")) {
return originalResponse;
}

return caches
.match(wp.serviceWorker.precaching.getCacheKeyForURL(ERROR_500_URL))
.then(function(errorResponse) {
.then(function (errorResponse) {
if (!errorResponse) {
return response;
}

return errorResponse.text().then(function(text) {
return errorResponse.text().then(function (text) {
const init = {
status: errorResponse.status,
statusText: errorResponse.statusText,
headers: errorResponse.headers
headers: errorResponse.headers,
};

let body = text.replace(
@@ -68,7 +68,7 @@ ERROR_OFFLINE_URL, ERROR_500_URL, NAVIGATION_DENYLIST_PATTERNS, ERROR_MESSAGES *
);
body = body.replace(
/([<]!--WP_SERVICE_WORKER_ERROR_TEMPLATE_BEGIN-->)((?:.|\n)+?)([<]!--WP_SERVICE_WORKER_ERROR_TEMPLATE_END-->)/,
details => {
(details) => {
if (!responseBody) {
return ""; // Remove the details from the document entirely.
}
@@ -109,12 +109,12 @@ ERROR_OFFLINE_URL, ERROR_500_URL, NAVIGATION_DENYLIST_PATTERNS, ERROR_MESSAGES *
const sendOfflineResponse = () => {
return caches
.match(wp.serviceWorker.precaching.getCacheKeyForURL(ERROR_OFFLINE_URL))
.then(function(response) {
return response.text().then(function(text) {
.then(function (response) {
return response.text().then(function (text) {
const init = {
status: response.status,
statusText: response.statusText,
headers: response.headers
headers: response.headers,
};

const body = text.replace(
@@ -136,11 +136,11 @@ ERROR_OFFLINE_URL, ERROR_500_URL, NAVIGATION_DENYLIST_PATTERNS, ERROR_MESSAGES *
}

const denylist = NAVIGATION_DENYLIST_PATTERNS.map(
pattern => new RegExp(pattern)
(pattern) => new RegExp(pattern)
);
if (navigationRouteEntry && navigationRouteEntry.url) {
wp.serviceWorker.routing.registerNavigationRoute(navigationRouteEntry.url, {
denylist
denylist,
});

class FetchNavigationRoute extends wp.serviceWorker.routing.Route {
@@ -154,7 +154,7 @@ ERROR_OFFLINE_URL, ERROR_500_URL, NAVIGATION_DENYLIST_PATTERNS, ERROR_MESSAGES *
handler,
{ allowlist: _allowlist = [/./], denylist: _denylist = [] } = {}
) {
super(options => this._match(options), handler);
super((options) => this._match(options), handler);
this._allowlist = _allowlist;
this._denylist = _denylist;
}
@@ -183,7 +183,7 @@ ERROR_OFFLINE_URL, ERROR_500_URL, NAVIGATION_DENYLIST_PATTERNS, ERROR_MESSAGES *
}
}

return this._allowlist.some(regExp => regExp.test(pathnameAndSearch));
return this._allowlist.some((regExp) => regExp.test(pathnameAndSearch));
}
}

@@ -193,7 +193,7 @@ ERROR_OFFLINE_URL, ERROR_500_URL, NAVIGATION_DENYLIST_PATTERNS, ERROR_MESSAGES *
} else {
wp.serviceWorker.routing.registerRoute(
new wp.serviceWorker.routing.NavigationRoute(handleNavigationRequest, {
denylist
denylist,
})
);
}
@@ -205,8 +205,8 @@ wp.serviceWorker.routing.registerRoute(
new wp.serviceWorker.strategies.NetworkOnly(),
{
allowlist: NAVIGATION_DENYLIST_PATTERNS.map(
pattern => new RegExp(pattern)
)
(pattern) => new RegExp(pattern)
),
}
)
);
24 changes: 12 additions & 12 deletions wp-includes/js/service-worker-offline-commenting.js
Original file line number Diff line number Diff line change
@@ -8,25 +8,25 @@
const commentHandler = ({ event }) => {
const clone = event.request.clone();
return fetch(event.request)
.then(response => {
.then((response) => {
if (response.status < 500) {
return response;
}

// @todo This is duplicated with code in service-worker-navigation-routing.js.
return response.text().then(function(errorText) {
return response.text().then(function (errorText) {
return caches
.match(wp.serviceWorker.precaching.getCacheKeyForURL(ERROR_500_URL))
.then(function(errorResponse) {
.then(function (errorResponse) {
if (!errorResponse) {
return response;
}

return errorResponse.text().then(function(text) {
return errorResponse.text().then(function (text) {
const init = {
status: errorResponse.status,
statusText: errorResponse.statusText,
headers: errorResponse.headers
headers: errorResponse.headers,
};

let body = text.replace(
@@ -35,7 +35,7 @@
);
body = body.replace(
/([<]!--WP_SERVICE_WORKER_ERROR_TEMPLATE_BEGIN-->)((?:.|\n)+?)([<]!--WP_SERVICE_WORKER_ERROR_TEMPLATE_END-->)/,
details => {
(details) => {
if (!errorText) {
return ""; // Remove the details from the document entirely.
}
@@ -75,7 +75,7 @@
})
.catch(() => {
const bodyPromise = clone.blob();
bodyPromise.then(function(body) {
bodyPromise.then(function (body) {
const request = event.request;
const req = new Request(request.url, {
method: request.method,
@@ -84,12 +84,12 @@
credentials: request.credentials,
referrer: request.referrer,
redirect: "manual",
body
body,
});

// Add request to queue.
queue.pushRequest({
request: req
request: req,
});
});

@@ -98,12 +98,12 @@
.match(
wp.serviceWorker.precaching.getCacheKeyForURL(ERROR_OFFLINE_URL)
)
.then(function(response) {
return response.text().then(function(text) {
.then(function (response) {
return response.text().then(function (text) {
const init = {
status: response.status,
statusText: response.statusText,
headers: response.headers
headers: response.headers,
};

const body = text.replace(
2 changes: 1 addition & 1 deletion wp-includes/js/service-worker-precaching.js
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
// @todo Should not the strategy be tied to each entry as well?
// @todo Use networkFirst instead of cacheFirst when WP_DEBUG.
wp.serviceWorker.precaching.addRoute({
ignoreUrlParametersMatching: [/^utm_/, /^wp-mce-/, /^ver$/]
ignoreUrlParametersMatching: [/^utm_/, /^wp-mce-/, /^ver$/],
// @todo Add urlManipulation which allows for the list of ignoreUrlParametersMatching to be supplied with each entry.
});
})();
2 changes: 1 addition & 1 deletion wp-includes/js/service-worker.js
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ if (!self.wp) {
wp.serviceWorker = workbox;

// Skip the waiting phase for the Service Worker.
self.addEventListener("message", function(event) {
self.addEventListener("message", function (event) {
if ("skipWaiting" === event.data.action) {
self.skipWaiting();
}

0 comments on commit f5ecce4

Please sign in to comment.