├── public ├── favicon.ico ├── favicon.png ├── history.csv ├── manifest.json └── index.html ├── stats-log ├── README.md ├── 2019-06-25.json ├── 2019-10-03.json ├── 2019-10-23.json ├── 2019-10-25.json └── 2019-11-19.json ├── src ├── App.css ├── App.test.js ├── Stats.js ├── index.css ├── index.js ├── Cutestrap-customizations.css ├── logo.svg ├── App.js └── serviceWorker.js ├── bin ├── deploy.sh ├── insert_version.js └── update_version.js ├── .gitignore ├── README.md ├── package.json └── inject-stats.js /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peterbe/arewestumptownedyet/master/public/favicon.ico -------------------------------------------------------------------------------- /public/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peterbe/arewestumptownedyet/master/public/favicon.png -------------------------------------------------------------------------------- /stats-log/README.md: -------------------------------------------------------------------------------- 1 | The files in this directory are automatically 2 | generated by the inject-stats.js script. 3 | -------------------------------------------------------------------------------- /public/history.csv: -------------------------------------------------------------------------------- 1 | DATE,COUNT 2 | 1561487223266,50 3 | 1570121694561,53 4 | 1571859217322,78 5 | 1572011071446,78 6 | 1574190626872,166 7 | -------------------------------------------------------------------------------- /stats-log/2019-06-25.json: -------------------------------------------------------------------------------- 1 | { 2 | "date": 1561487223266, 3 | "kuma": { 4 | "en-US": 18256, 5 | "all": 64262 6 | }, 7 | "stumptown": { 8 | "en-US": 50, 9 | "all": null 10 | } 11 | } -------------------------------------------------------------------------------- /stats-log/2019-10-03.json: -------------------------------------------------------------------------------- 1 | { 2 | "date": 1570121694561, 3 | "kuma": { 4 | "en-US": 18256, 5 | "all": 64262 6 | }, 7 | "stumptown": { 8 | "en-US": 53, 9 | "all": null 10 | } 11 | } -------------------------------------------------------------------------------- /stats-log/2019-10-23.json: -------------------------------------------------------------------------------- 1 | { 2 | "date": 1571859217322, 3 | "kuma": { 4 | "en-US": 18256, 5 | "all": 64262 6 | }, 7 | "stumptown": { 8 | "en-US": 78, 9 | "all": null 10 | } 11 | } -------------------------------------------------------------------------------- /stats-log/2019-10-25.json: -------------------------------------------------------------------------------- 1 | { 2 | "date": 1572011071446, 3 | "kuma": { 4 | "en-US": 18256, 5 | "all": 64262 6 | }, 7 | "stumptown": { 8 | "en-US": 78, 9 | "all": null 10 | } 11 | } -------------------------------------------------------------------------------- /stats-log/2019-11-19.json: -------------------------------------------------------------------------------- 1 | { 2 | "date": 1574190626872, 3 | "kuma": { 4 | "en-US": 18256, 5 | "all": 64262 6 | }, 7 | "stumptown": { 8 | "en-US": 166, 9 | "all": null 10 | } 11 | } -------------------------------------------------------------------------------- /src/App.css: -------------------------------------------------------------------------------- 1 | h1, 2 | h2 { 3 | text-align: center; 4 | } 5 | h2 { 6 | font-size: 1000%; 7 | margin: 200px; 8 | } 9 | h3 { 10 | margin-top: 100px; 11 | } 12 | p.number { 13 | font-size: 500%; 14 | margin: 70px; 15 | } 16 | 17 | footer { 18 | margin-top: 200px; 19 | } 20 | -------------------------------------------------------------------------------- /bin/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eo pipefail 3 | 4 | 5 | INLINE_RUNTIME_CHUNK=false \ 6 | yarn run build 7 | 8 | ./bin/update_version.js > build/version.json 9 | 10 | ./bin/insert_version.js build/version.json build/index.html 11 | 12 | gh-pages --add --dist build/ 13 | -------------------------------------------------------------------------------- /src/App.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from './App'; 4 | 5 | it('renders without crashing', () => { 6 | const div = document.createElement('div'); 7 | ReactDOM.render(, div); 8 | ReactDOM.unmountComponentAtNode(div); 9 | }); 10 | -------------------------------------------------------------------------------- /src/Stats.js: -------------------------------------------------------------------------------- 1 | /** This page is auto-generated from inject-stats.js 2 | * Date: Tue Nov 19 2019 14:10:26 GMT-0500 (Eastern Standard Time) 3 | */ 4 | 5 | export const Stats = { 6 | "date": 1574190626872, 7 | "kuma": { 8 | "en-US": 18256, 9 | "all": 64262 10 | }, 11 | "stumptown": { 12 | "en-US": 166, 13 | "all": null 14 | } 15 | }; 16 | -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "arewestumptownedyet", 3 | "name": "Are We Stumptowned Yet?", 4 | "icons": [ 5 | { 6 | "src": "favicon.png", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", 4 | "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { hydrate, render } from "react-dom"; 3 | // import ReactDOM from "react-dom"; 4 | import "./index.css"; 5 | import App from "./App"; 6 | 7 | const rootElement = document.getElementById("root"); 8 | if (rootElement.hasChildNodes()) { 9 | hydrate(, rootElement); 10 | } else { 11 | render(, rootElement); 12 | } 13 | 14 | // ReactDOM.render(, document.getElementById("root")); 15 | -------------------------------------------------------------------------------- /src/Cutestrap-customizations.css: -------------------------------------------------------------------------------- 1 | * { 2 | /* Sets our Baseline Grid */ 3 | --rhythm: 1.5rem; 4 | 5 | /* Sets font-size relative to rhythm */ 6 | --line-height-ratio: 1.4; 7 | } 8 | 9 | /* Layout Specific Styles */ 10 | 11 | body{ 12 | padding: var(--rhythm) var(--rhythm-half); 13 | margin: 0 auto; 14 | max-width: 65rem; 15 | } 16 | .header { 17 | text-align: center; 18 | } 19 | 20 | .navigation { 21 | text-align: center; 22 | } 23 | 24 | .navigation ul { 25 | display: flex; 26 | list-style-type: none; 27 | margin-left: 0; 28 | justify-content: center; 29 | } 30 | 31 | .navigation li { 32 | padding: 0 var(--rhythm-half); 33 | } 34 | -------------------------------------------------------------------------------- /bin/insert_version.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | const fs = require("fs"); 3 | 4 | const versionFile = process.argv[2]; 5 | if (!versionFile) throw new Error("missing file argument"); 6 | const versionString = fs.readFileSync(versionFile, "utf8"); 7 | const data = JSON.parse(versionString); 8 | 9 | const htmlFile = process.argv[3]; 10 | if (!htmlFile) throw new Error("missing file argument"); 11 | let html = fs.readFileSync(htmlFile, "utf8"); 12 | 13 | let tag = '
{ 16 | if (keeps.includes(key)) { 17 | tag += `data-${key}="${value}" `; 18 | } 19 | }); 20 | tag = tag.trim() + ">"; 21 | 22 | html = html.replace(/
]+>/, tag); 23 | fs.writeFileSync(htmlFile, html, "utf8"); 24 | -------------------------------------------------------------------------------- /bin/update_version.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | const fs = require("fs"); 3 | const spawn = require("child_process").spawnSync; 4 | 5 | const package = require("../package.json"); 6 | const name = package.name; 7 | 8 | const spawnStr = (cmd, ...args) => { 9 | const spawned = spawn(cmd, ...args); 10 | return spawned.stdout.toString().trim(); 11 | }; 12 | const version = spawnStr("git", ["describe", "--always", "--tag"]); 13 | 14 | const logRaw = spawnStr("git", ["log", "--pretty=format:'%H--%cI'", "-n", "1"]); 15 | 16 | const log = logRaw.slice(1, logRaw.length - 1); 17 | const commit = log.split("--")[0]; 18 | const date = log.split("--")[1]; 19 | 20 | console.log( 21 | JSON.stringify( 22 | { 23 | name, 24 | version, 25 | commit, 26 | date 27 | }, 28 | undefined, 29 | 2 30 | ) 31 | ); 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Are We Stumptowned Yet? 2 | 3 | ## About 4 | 5 | A semi-whimsical web page for displaying an executive summary of the 6 | progress of turning MDN Web Docs into structured content that 7 | can be rendered. 8 | 9 | ## How To Hack On 10 | 11 | Install stuff and run: 12 | 13 | yarn 14 | yarn run start 15 | open http://localhost:3000 16 | 17 | To generate the stats you need to have a `stumptown-renderer` clone in 18 | which you have, at some recent point, run `make deployment-build`. Then run: 19 | 20 | node inject-stats.js ../stumptown-renderer/stumptown/packaged/ src/Stats.js 21 | 22 | That will update `src/Stats.js` and possible files in `./stats-log/` which 23 | you need to git add. 24 | 25 | ## Deployment 26 | 27 | Just run: 28 | 29 | yarn run deploy 30 | 31 | You need to have write access to push to `github.com/peterbe/arewestumptownedyet`. 32 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Are We Stumptowned Yet? 10 | 11 | 12 | 13 |
14 | 15 | 21 |
22 | 23 | 24 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "arewestumptownedyet", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "cutestrap": "2.0.0-4", 7 | "react": "^16.12.0", 8 | "react-dom": "^16.12.0", 9 | "react-roughviz": "0.1.7", 10 | "react-scripts": "3.3.0" 11 | }, 12 | "devDependencies": { 13 | "csv-writer": "1.5.0", 14 | "gh-pages": "2.1.1", 15 | "react-snap": "1.23.0" 16 | }, 17 | "resolutions": { 18 | "eslint-utils": ">=1.4.2", 19 | "lodash": ">=4.17.12", 20 | "handlebars": ">=4.5.3", 21 | "https-proxy-agent": ">=3.0.0" 22 | }, 23 | "scripts": { 24 | "start": "react-scripts start", 25 | "build": "react-scripts build", 26 | "test": "react-scripts test", 27 | "eject": "react-scripts eject", 28 | "deploy": "./bin/deploy.sh", 29 | "postbuild": "react-snap" 30 | }, 31 | "eslintConfig": { 32 | "extends": "react-app" 33 | }, 34 | "browserslist": { 35 | "production": [ 36 | ">0.2%", 37 | "not dead", 38 | "not op_mini all" 39 | ], 40 | "development": [ 41 | "last 1 chrome version", 42 | "last 1 firefox version", 43 | "last 1 safari version" 44 | ] 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /inject-stats.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Script to generate JavaScript code that contains all the necessary stats. 3 | * 4 | * Usage: 5 | * 6 | * node inject-stats.js node inject-stats.js ../stumptown-renderer/stumptown/packaged/ [src/Stats.js] 7 | */ 8 | const fs = require("fs"); 9 | const path = require("path"); 10 | 11 | const createCsvWriter = require("csv-writer").createObjectCsvWriter; 12 | 13 | const args = process.argv.slice(2); 14 | 15 | if (!args.length) { 16 | throw new Error( 17 | "Usage: node inject-stats.js path/to/stumptown/packaged/dir [src/Stats.js] [stats-log]" 18 | ); 19 | } 20 | 21 | let sourceDir = args[0]; 22 | let destination = "src/Stats.js"; 23 | if (args.length > 1) { 24 | destination = args[1]; 25 | } 26 | let logsDir = "./stats-log"; 27 | if (args.length > 2) { 28 | logsDir = args[2]; 29 | } 30 | 31 | let countJsonFiles = 0; 32 | let sumJsonFilesBytes = 0; 33 | function walk(directory) { 34 | const files = fs.readdirSync(directory); 35 | for (let filename of files) { 36 | // console.log(filename); 37 | const filepath = path.join(directory, filename); 38 | if (filename.endsWith(".json")) { 39 | sumJsonFilesBytes += fs.statSync(filepath).size; 40 | countJsonFiles++; 41 | } 42 | 43 | if (fs.statSync(filepath).isDirectory()) { 44 | walk(filepath); 45 | } 46 | } 47 | } 48 | 49 | walk(sourceDir); 50 | console.log({ countJsonFiles, sumJsonFilesBytes }); 51 | 52 | /** 53 | * Note to self; here's how I found out how many documents Kuma has in prod. 54 | 55 | Start a `./manage.py shell_plus` in kubectl on prod. 56 | Paste in this code: 57 | 58 | from django.db.models import Q 59 | from kuma.wiki.constants import EXPERIMENT_TITLE_PREFIX, LEGACY_MINDTOUCH_NAMESPACES 60 | q = Q(slug__startswith=EXPERIMENT_TITLE_PREFIX) 61 | for legacy_mindtouch_namespace in LEGACY_MINDTOUCH_NAMESPACES: 62 | q |= Q(slug__startswith='{}:'.format(legacy_mindtouch_namespace)) 63 | docs = Document.objects.filter(is_redirect=False).exclude(html='', current_revision__isnull=True).exclude(q) 64 | docs.count() 65 | docs.filter(locale='en-US').count() 66 | 67 | * As of June 24 2019, I ran that and the number was 64,262 (all) 68 | * and 18,256 (en-US) 69 | * */ 70 | 71 | const kumaDocuments = { 72 | "en-US": 18256, 73 | all: 64262 74 | }; 75 | 76 | const stats = { 77 | date: new Date().getTime(), 78 | kuma: kumaDocuments, 79 | stumptown: { 80 | "en-US": countJsonFiles, 81 | all: null 82 | } 83 | }; 84 | 85 | fs.mkdirSync(logsDir, { recursive: true }); 86 | const statsLogToday = new Date().toISOString().split("T")[0] + ".json"; 87 | fs.writeFileSync( 88 | path.join(logsDir, statsLogToday), 89 | JSON.stringify(stats, null, 2) 90 | ); 91 | 92 | const history = fs 93 | .readdirSync(logsDir) 94 | .filter(item => /\d\d\d\d-\d\d-\d\d\.json/.test(item)) 95 | .sort((a, b) => b - a) 96 | .map(file => JSON.parse(fs.readFileSync(path.join(logsDir, file), "utf-8"))); 97 | 98 | const csvOutfile = "public/history.csv"; 99 | const csvWriter = createCsvWriter({ 100 | path: csvOutfile, 101 | header: [{ id: "date", title: "DATE" }, { id: "count", title: "COUNT" }] 102 | }); 103 | csvWriter 104 | .writeRecords( 105 | history.map(row => { 106 | return { date: row.date, count: row.stumptown["en-US"] }; 107 | }) 108 | ) 109 | .then(() => { 110 | console.log(`Wrote ${history.length} rows to ${csvOutfile}`); 111 | }); 112 | console.log(history); 113 | 114 | const code = `/** This page is auto-generated from inject-stats.js 115 | * Date: ${new Date()} 116 | */ 117 | 118 | export const Stats = ${JSON.stringify(stats, null, 2)}; 119 | `; 120 | 121 | fs.writeFileSync(destination, code); 122 | console.log(`Wrote ${destination} 🎉`); 123 | -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { Bar, Line } from "react-roughviz"; 3 | // import "./light.css"; 4 | import "cutestrap/dist/css/cutestrap.min.css"; 5 | import "./Cutestrap-customizations.css"; 6 | import "./App.css"; 7 | 8 | import { Stats } from "./Stats"; 9 | 10 | export const isServer = 11 | typeof document === "undefined" || navigator.userAgent === "ReactSnap"; 12 | 13 | function App() { 14 | return ( 15 |
16 |
17 |

Are We Stumptowned Yet?

18 |
19 | 20 |
21 |

22 | No{" "} 23 | 24 | ☹️ 25 | 26 |

27 | 28 |

What's this?

29 |

30 | Stumptown is a Mozilla MDN project to rewrite existing documentation 31 | about web development, from a{" "} 32 | Wiki, stored in a central 33 | relational database, to{" "} 34 | strutured content (e.g. Markdown files) in a Git repo. 35 |

36 |

Stumptown consists of two parts:

37 | 51 |

52 | This site is about attempting to measure how many ready pages there 53 | are in github.com/mdn/stumptown-content and contrast that with 54 | the number of pages in developer.mozilla.org. 55 |

56 | 57 |

Current Status

58 |
59 |
60 | Kuma (en-US): 61 |
62 |

{Stats.kuma["en-US"].toLocaleString()}

63 | 64 |
65 | Stumptown (en-US): 66 |
67 |

{Stats.stumptown["en-US"].toLocaleString()}

68 |

69 | Approximately{" "} 70 | {( 71 | (100 * Stats.stumptown["en-US"]) / 72 | (Stats.stumptown["en-US"] + Stats.kuma["en-US"]) 73 | ).toFixed(1)} 74 | % of Kuma 75 |

76 |
77 |

78 | As of {prettyTimestamp(Stats.date)} 79 |

80 |
81 | 82 | 83 |
84 |
85 | 94 |
95 | ); 96 | } 97 | 98 | function prettyTimestamp(ts) { 99 | const d = new Date(ts); 100 | return d.toLocaleDateString(); 101 | } 102 | 103 | export default App; 104 | 105 | function StatsChart() { 106 | if (isServer) { 107 | return No SVG charts in server mode; 108 | } 109 | const data = { 110 | labels: ["Kuma (en-US)", "Stumptown"], 111 | values: [Stats.kuma["en-US"], Stats.stumptown["en-US"]] 112 | }; 113 | 114 | return ; 115 | } 116 | 117 | function HistoryChart() { 118 | if (isServer) { 119 | return No SVG charts in server mode; 120 | } 121 | const data = process.env.PUBLIC_URL + "history.csv"; 122 | // Still a bit broken since it doesn't display the dates on the 123 | // x-axis. 124 | return ( 125 | 139 | ); 140 | } 141 | -------------------------------------------------------------------------------- /src/serviceWorker.js: -------------------------------------------------------------------------------- 1 | // This optional code is used to register a service worker. 2 | // register() is not called by default. 3 | 4 | // This lets the app load faster on subsequent visits in production, and gives 5 | // it offline capabilities. However, it also means that developers (and users) 6 | // will only see deployed updates on subsequent visits to a page, after all the 7 | // existing tabs open on the page have been closed, since previously cached 8 | // resources are updated in the background. 9 | 10 | // To learn more about the benefits of this model and instructions on how to 11 | // opt-in, read https://bit.ly/CRA-PWA 12 | 13 | const isLocalhost = Boolean( 14 | window.location.hostname === 'localhost' || 15 | // [::1] is the IPv6 localhost address. 16 | window.location.hostname === '[::1]' || 17 | // 127.0.0.1/8 is considered localhost for IPv4. 18 | window.location.hostname.match( 19 | /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ 20 | ) 21 | ); 22 | 23 | export function register(config) { 24 | if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { 25 | // The URL constructor is available in all browsers that support SW. 26 | const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href); 27 | if (publicUrl.origin !== window.location.origin) { 28 | // Our service worker won't work if PUBLIC_URL is on a different origin 29 | // from what our page is served on. This might happen if a CDN is used to 30 | // serve assets; see https://github.com/facebook/create-react-app/issues/2374 31 | return; 32 | } 33 | 34 | window.addEventListener('load', () => { 35 | const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; 36 | 37 | if (isLocalhost) { 38 | // This is running on localhost. Let's check if a service worker still exists or not. 39 | checkValidServiceWorker(swUrl, config); 40 | 41 | // Add some additional logging to localhost, pointing developers to the 42 | // service worker/PWA documentation. 43 | navigator.serviceWorker.ready.then(() => { 44 | console.log( 45 | 'This web app is being served cache-first by a service ' + 46 | 'worker. To learn more, visit https://bit.ly/CRA-PWA' 47 | ); 48 | }); 49 | } else { 50 | // Is not localhost. Just register service worker 51 | registerValidSW(swUrl, config); 52 | } 53 | }); 54 | } 55 | } 56 | 57 | function registerValidSW(swUrl, config) { 58 | navigator.serviceWorker 59 | .register(swUrl) 60 | .then(registration => { 61 | registration.onupdatefound = () => { 62 | const installingWorker = registration.installing; 63 | if (installingWorker == null) { 64 | return; 65 | } 66 | installingWorker.onstatechange = () => { 67 | if (installingWorker.state === 'installed') { 68 | if (navigator.serviceWorker.controller) { 69 | // At this point, the updated precached content has been fetched, 70 | // but the previous service worker will still serve the older 71 | // content until all client tabs are closed. 72 | console.log( 73 | 'New content is available and will be used when all ' + 74 | 'tabs for this page are closed. See https://bit.ly/CRA-PWA.' 75 | ); 76 | 77 | // Execute callback 78 | if (config && config.onUpdate) { 79 | config.onUpdate(registration); 80 | } 81 | } else { 82 | // At this point, everything has been precached. 83 | // It's the perfect time to display a 84 | // "Content is cached for offline use." message. 85 | console.log('Content is cached for offline use.'); 86 | 87 | // Execute callback 88 | if (config && config.onSuccess) { 89 | config.onSuccess(registration); 90 | } 91 | } 92 | } 93 | }; 94 | }; 95 | }) 96 | .catch(error => { 97 | console.error('Error during service worker registration:', error); 98 | }); 99 | } 100 | 101 | function checkValidServiceWorker(swUrl, config) { 102 | // Check if the service worker can be found. If it can't reload the page. 103 | fetch(swUrl) 104 | .then(response => { 105 | // Ensure service worker exists, and that we really are getting a JS file. 106 | const contentType = response.headers.get('content-type'); 107 | if ( 108 | response.status === 404 || 109 | (contentType != null && contentType.indexOf('javascript') === -1) 110 | ) { 111 | // No service worker found. Probably a different app. Reload the page. 112 | navigator.serviceWorker.ready.then(registration => { 113 | registration.unregister().then(() => { 114 | window.location.reload(); 115 | }); 116 | }); 117 | } else { 118 | // Service worker found. Proceed as normal. 119 | registerValidSW(swUrl, config); 120 | } 121 | }) 122 | .catch(() => { 123 | console.log( 124 | 'No internet connection found. App is running in offline mode.' 125 | ); 126 | }); 127 | } 128 | 129 | export function unregister() { 130 | if ('serviceWorker' in navigator) { 131 | navigator.serviceWorker.ready.then(registration => { 132 | registration.unregister(); 133 | }); 134 | } 135 | } 136 | --------------------------------------------------------------------------------