Skip to content
This repository has been archived by the owner on Jun 13, 2022. It is now read-only.

Commit

Permalink
feat(core, website): upgrade workbox to v4.x
Browse files Browse the repository at this point in the history
  • Loading branch information
giovagnoli committed Jun 13, 2019
1 parent 2011bc6 commit 6952de3
Show file tree
Hide file tree
Showing 18 changed files with 342 additions and 180 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ import './minus-circle-solid'
import './question-circle-regular'
import './times-circle-solid'
import './times-solid'
import './unlink-solid'

This file was deleted.

5 changes: 0 additions & 5 deletions packages/@statusfy/core/client/locales/br-default.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@
"description": "Desculpe, não podemos concluir sua requisição"
}
},
"offline": {
"title": "Estamos Offline!",
"subtitle": "Desculpe!",
"description": "Não foi possível carregar a página requisitada. Por gentileza verifique sua conexão e tente novamente."
},
"systems": {
"items": {
"cdn": {
Expand Down
5 changes: 0 additions & 5 deletions packages/@statusfy/core/client/locales/de-default.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@
"description": "Wir konnten deine Anfrage nicht bearbeiten. Wir bedauern eventuelle Unannehmlichkeiten."
}
},
"offline": {
"title": "Keine Internetverbindung",
"subtitle": "Hoppla!",
"description": "Wir konnten die von dir angeforderte Seite nicht laden. Bitte überprüfe deine Netzwerkverbindung und versuche es erneut."
},
"systems": {
"items": {
"cdn": {
Expand Down
5 changes: 0 additions & 5 deletions packages/@statusfy/core/client/locales/en-default.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@
"description": "We're sorry, but we cannot fulfill your request"
}
},
"offline": {
"title": "You're Offline",
"subtitle": "Sorry!",
"description": "We were unable to load the page you requested. Please check your network connection and try again."
},
"systems": {
"items": {
"cdn": {
Expand Down
5 changes: 0 additions & 5 deletions packages/@statusfy/core/client/locales/es-default.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@
"description": "Lo sentimos, pero no podemos cumplir con tu solicitud"
}
},
"offline": {
"title": "Estás Fuera de Línea",
"subtitle": "¡Lo sentimos!",
"description": "No pudimos cargar la página solicitada. Verifica tu conexión de red y vuelve a intentarlo."
},
"systems": {
"items": {
"cdn": {
Expand Down
5 changes: 0 additions & 5 deletions packages/@statusfy/core/client/locales/hu-default.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@
"description": "Sajnáljuk, de a kérést nem lehet teljesíteni"
}
},
"offline": {
"title": "Ön offline",
"subtitle": "Sajnáljuk!",
"description": "Nem sikerült betölteni a kért oldalt. Kérjük, ellenőrizze a hálózati kapcsolatot és próbálja újra."
},
"systems": {
"items": {
"cdn": {
Expand Down
5 changes: 0 additions & 5 deletions packages/@statusfy/core/client/locales/it-default.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@
"description": "Spiacenti, la richiesta non può essere elaborata"
}
},
"offline": {
"title": "Sei Offline",
"subtitle": "Spiacenti!",
"description": "Non è stato possibile caricare la pagina richiesta. Controlla la tua connessione di rete e riprova."
},
"systems": {
"items": {
"cdn": {
Expand Down
64 changes: 0 additions & 64 deletions packages/@statusfy/core/client/pages/offline.vue

This file was deleted.

4 changes: 4 additions & 0 deletions packages/@statusfy/core/lib/config/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ module.exports = function generateConfig(sourceDir, cliOptions) {
runtime.strategyOptions.cacheName = `${siteConfig.name}_${runtime.strategyOptions.cacheName}`;
}
});

if (siteConfig.analytics && siteConfig.analytics.ga) {
nuxtConfig.workbox.offlineAnalytics = true;
}
} else {
const nuxtiPwaModuleConfig = nuxtConfig.modules.find(
item => item[0] === "@nuxtjs/pwa"
Expand Down
10 changes: 2 additions & 8 deletions packages/@statusfy/core/nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,8 @@ module.exports = {
},
workbox: {
publicPath: "/static/",
offlinePage: "/offline",
_runtimeCaching: [
{
urlPattern: "/static/(?!content).*$",
handler: "cacheFirst",
method: "GET"
}
],
cleanupOutdatedCaches: true,
assetsURLPattern: "/static/(?!content).*$",
runtimeCaching: [
{
urlPattern: "(/static/content)?/api/v0/.*",
Expand Down
2 changes: 1 addition & 1 deletion packages/@statusfy/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.19",
"@nuxtjs/axios": "^5.5.4",
"@nuxtjs/pwa": "^2.5.0",
"@nuxtjs/pwa": "^3.0.0-beta.16",
"@statusfy/common": "0.3.2-beta.3",
"@statusfy/markdown": "0.3.2-beta.3",
"body-parser": "^1.18.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,16 +283,11 @@ Object {
"version": "0.3.2-beta.3",
},
"workbox": Object {
"_runtimeCaching": Array [
Object {
"handler": "cacheFirst",
"method": "GET",
"urlPattern": "/static/(?!content).*$",
},
],
"assetsURLPattern": "/static/(?!content).*$",
"cacheId": "app_name",
"cleanupOutdatedCaches": true,
"globDirectory": "../.tmp/advanced/.statusfy/dist/client",
"offlinePage": "/offline",
"offlineAnalytics": true,
"publicPath": "/static/",
"runtimeCaching": Array [
Object {
Expand Down Expand Up @@ -531,16 +526,10 @@ Object {
"version": "0.3.2-beta.3",
},
"workbox": Object {
"_runtimeCaching": Array [
Object {
"handler": "cacheFirst",
"method": "GET",
"urlPattern": "/static/(?!content).*$",
},
],
"assetsURLPattern": "/static/(?!content).*$",
"cacheId": "title",
"cleanupOutdatedCaches": true,
"globDirectory": "../.tmp/cli/.statusfy/dist/client",
"offlinePage": "/offline",
"publicPath": "/static/",
"runtimeCaching": Array [
Object {
Expand Down Expand Up @@ -1010,16 +999,11 @@ Object {
"version": "0.3.2-beta.3",
},
"workbox": Object {
"_runtimeCaching": Array [
Object {
"handler": "cacheFirst",
"method": "GET",
"urlPattern": "/static/(?!content).*$",
},
],
"assetsURLPattern": "/static/(?!content).*$",
"cacheId": "Nombre Aplicación",
"cleanupOutdatedCaches": true,
"globDirectory": "../.tmp/spanish/.statusfy/dist/client",
"offlinePage": "/offline",
"offlineAnalytics": true,
"publicPath": "/static/",
"runtimeCaching": Array [
Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ Object {
],
"lang": "en",
"name": "Demo System Status",
"publicPath": "/static/",
"short_name": "System Status",
"start_url": "/?standalone=true&utm_source=web_app&utm_medium=pwa",
"theme_color": "#1b1f23",
Expand Down
8 changes: 3 additions & 5 deletions packages/demo/test/build-generate.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ describe('build-generate', () => {
test('sw.js', async () => {
const swContent = await fse.readFile(path.resolve(sourceDir, 'dist', 'sw.js'), 'utf-8')

expect(swContent).toContain("workbox.precaching.precacheAndRoute(['/offline'])")
expect(swContent).toContain("workbox.routing.registerRoute(new RegExp('/static/(?!content).*$'), workbox.strategies.cacheFirst({}), 'GET')")
expect(swContent).toContain("workbox.routing.registerRoute(new RegExp('(/static/content)?/api/v0/.*'), workbox.strategies.networkFirst({\"cacheName\":\"demo_system_status_api\",\"cacheExpiration\":{\"maxEntries\":10,\"maxAgeSeconds\":300}}), 'GET')")
expect(swContent).toContain("caches.match('/offline')")
expect(swContent).toContain("\"cacheId\": \"demo_system_status\"")
expect(swContent).toContain("workbox.precaching.cleanupOutdatedCaches()")
expect(swContent).toContain("workbox.routing.registerRoute(new RegExp('/static/(?!content).*$'), new workbox.strategies.CacheFirst ({}), 'GET')")
expect(swContent).toContain("workbox.routing.registerRoute(new RegExp('(/static/content)?/api/v0/.*'), new workbox.strategies.NetworkFirst ({\"cacheName\":\"demo_system_status_api\",\"cacheExpiration\":{\"maxEntries\":10,\"maxAgeSeconds\":300}}), 'GET')")
})
})
3 changes: 0 additions & 3 deletions packages/website/nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,6 @@ module.exports = {
theme_color: mainColor,
version: pkg.version
},
workbox: {
offlinePage: '/offline'
},
/*
** Google Analytics configuration
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@fortawesome/fontawesome-svg-core": "^1.2.19",
"@nuxtjs/axios": "^5.5.4",
"@nuxtjs/google-analytics": "^2.2.0",
"@nuxtjs/pwa": "^2.6.0",
"@nuxtjs/pwa": "^3.0.0-beta.16",
"@nuxtjs/sitemap": "^1.2.0",
"@statusfy/common": "0.3.2-beta.3",
"animate.css": "^3.7.2",
Expand Down
Loading

0 comments on commit 6952de3

Please sign in to comment.