@justdanielndev/status-page 1.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/.prettierrc.cjs +1 -0
  2. package/.upptimerc.yml +42 -0
  3. package/CHANGELOG.md +791 -0
  4. package/LICENSE +21 -0
  5. package/README.md +46 -0
  6. package/cypress/fixtures/example.json +5 -0
  7. package/cypress/integration/incident.spec.js +9 -0
  8. package/cypress/integration/live-status.spec.js +12 -0
  9. package/cypress/plugins/index.js +17 -0
  10. package/cypress/support/commands.js +25 -0
  11. package/cypress/support/index.js +20 -0
  12. package/cypress.json +4 -0
  13. package/i18n.yml +61 -0
  14. package/init-tests.ts +12 -0
  15. package/jest.config.js +4 -0
  16. package/package.json +78 -0
  17. package/post-process.ts +61 -0
  18. package/pre-process.ts +32 -0
  19. package/release.config.js +1 -0
  20. package/rollup.config.js +116 -0
  21. package/src/client.js +18 -0
  22. package/src/components/ActiveIncidents.svelte +79 -0
  23. package/src/components/ActiveScheduled.svelte +96 -0
  24. package/src/components/Graph.svelte +76 -0
  25. package/src/components/History.svelte +84 -0
  26. package/src/components/Incident.svelte +161 -0
  27. package/src/components/Incidents.svelte +83 -0
  28. package/src/components/LiveStatus.svelte +190 -0
  29. package/src/components/Loading.svelte +37 -0
  30. package/src/components/Nav.svelte +88 -0
  31. package/src/components/Scheduled.svelte +72 -0
  32. package/src/components/Summary.svelte +54 -0
  33. package/src/routes/_error.svelte +41 -0
  34. package/src/routes/_layout.svelte +110 -0
  35. package/src/routes/error.svelte +27 -0
  36. package/src/routes/history/[number].svelte +17 -0
  37. package/src/routes/incident/[number].svelte +13 -0
  38. package/src/routes/index.svelte +48 -0
  39. package/src/routes/rate-limit-exceeded.svelte +88 -0
  40. package/src/server.js +25 -0
  41. package/src/service-worker.js +15 -0
  42. package/src/template.html +34 -0
  43. package/src/utils/createOctokit.js +67 -0
  44. package/static/global.css +203 -0
  45. package/static/logo-192.png +0 -0
  46. package/static/logo-512.png +0 -0
  47. package/static/manifest.json +20 -0
  48. package/static/themes/dark.css +26 -0
  49. package/static/themes/light.css +26 -0
  50. package/static/themes/night.css +26 -0
  51. package/static/themes/ocean.css +26 -0
  52. package/tsconfig.json +20 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Anand Chowdhary
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # ⬆️ Upptime Status Page
2
+
3
+ This repository contains the web app for Upptime's status page website. It's written in Svelte and a sample website is published at https://demo.upptime.js.org/.
4
+
5
+ [**To get started, visit upptime/upptime →**](https://github.com/upptime/upptime)
6
+
7
+ <!-- prettier-ignore-start -->
8
+ | | Status |
9
+ | - | - |
10
+ | Build | [![Node CI](https://github.com/upptime/status-page/workflows/Node%20CI/badge.svg)](https://github.com/upptime/status-page/actions?query=workflow%3A%22Node+CI%22) [![Dependencies](https://img.shields.io/librariesio/github/upptime/status-page)](https://libraries.io/github/upptime/status-page) [![GitHub release (latest by date)](https://img.shields.io/github/v/release/upptime/status-page)](https://github.com/upptime/status-page/releases) [![Snyk Vulnerabilities for GitHub Repo](https://img.shields.io/snyk/vulnerabilities/github/upptime/status-page)](https://snyk.io/test/github/upptime/status-page) |
11
+ | Health | [![License CI](https://github.com/upptime/status-page/workflows/License%20CI/badge.svg)](https://github.com/upptime/status-page/actions?query=workflow%3A%22License+CI%22) [![CLA Assistant](https://github.com/upptime/status-page/workflows/CLA%20Assistant/badge.svg)](https://github.com/upptime/status-page/actions?query=workflow%3A%22CLA+Assistant%22) [![Pull Request Labeler](https://github.com/upptime/status-page/workflows/Pull%20Request%20Labeler/badge.svg)](https://github.com/upptime/status-page/actions?query=workflow%3A%22Pull+Request+Labeler%22) |
12
+ | PRs | [![Feature Branch Pull Request](https://github.com/upptime/status-page/workflows/Feature%20Branch%20Pull%20Request/badge.svg)](https://github.com/upptime/status-page/actions?query=workflow%3A%22Feature+Branch+Pull+Request%22) [![Hotfix Branch Pull Request](https://github.com/upptime/status-page/workflows/Hotfix%20Branch%20Pull%20Request/badge.svg)](https://github.com/upptime/status-page/actions?query=workflow%3A%22Hotfix+Branch+Pull+Request%22) [![Merge PRs](https://github.com/upptime/status-page/workflows/Merge%20PRs/badge.svg)](https://github.com/upptime/status-page/actions?query=workflow%3A%22Merge+PRs%22) |
13
+ <!-- prettier-ignore-end -->
14
+
15
+ ## 🎁 Contributing
16
+
17
+ This repository is for Upptime's embeddable web app. We love contributions, so please read our [Contributing Guidelines](https://github.com/upptime-js/.github/blob/master/CONTRIBUTING.md) and [Code of Conduct](https://github.com/upptime-js/.github/blob/master/CODE_OF_CONDUCT.md) and open an issue or make a pull request!
18
+
19
+ ### Issues
20
+
21
+ We use the [upptime/upptime](https://github.com/upptime/upptime) repository for issues for all projects, including this one. If you found a bug or have a feature request, [open an issue](https://github.com/upptime/upptime/issues) in the Upptime repository and add the label "static-site".
22
+
23
+ ## 💻 Usage
24
+
25
+ When you use Upptime, we automatically generate a static status website and push it to the `gh-pages` branch. You don't have to manually manage any code from this repository.
26
+
27
+ When building locally, you can start a server:
28
+
29
+ ```bash
30
+ npm run dev
31
+ ```
32
+
33
+ Currently, the `.upptimerc.yml` configuration file is required one directly above the project root.
34
+
35
+ ## 📄 License
36
+
37
+ [MIT](./LICENSE) © [Koj](https://koj.co)
38
+
39
+ <p align="center">
40
+ <a href="https://koj.co">
41
+ <img width="44" alt="Koj" src="https://kojcdn.com/v1598284251/website-v2/koj-github-footer_m089ze.svg">
42
+ </a>
43
+ </p>
44
+ <p align="center">
45
+ <sub>An open source project by <a href="https://koj.co">Koj</a>. <br> <a href="https://koj.co">Furnish your home in style, for as low as CHF175/month →</a></sub>
46
+ </p>
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "Using fixtures to represent data",
3
+ "email": "hello@cypress.io",
4
+ "body": "Fixtures are a great way to mock data for responses to routes"
5
+ }
@@ -0,0 +1,9 @@
1
+ describe("Live status", () => {
2
+ beforeEach(() => {
3
+ cy.visit("/incident/8");
4
+ cy.wait(2000);
5
+ });
6
+ it("has multiple status messages", () => {
7
+ cy.get("article").should("have.lengthOf.above", 1);
8
+ });
9
+ });
@@ -0,0 +1,12 @@
1
+ describe("Live status", () => {
2
+ beforeEach(() => {
3
+ cy.visit("/");
4
+ cy.wait(2000);
5
+ });
6
+ it("has multiple status boxes", () => {
7
+ cy.get("article.link").should("have.lengthOf.above", 2);
8
+ });
9
+ it("has past issues", () => {
10
+ cy.get("article.down.link").should("have.lengthOf.above", 3);
11
+ });
12
+ });
@@ -0,0 +1,17 @@
1
+ // ***********************************************************
2
+ // This example plugins/index.js can be used to load plugins
3
+ //
4
+ // You can change the location of this file or turn off loading
5
+ // the plugins file with the 'pluginsFile' configuration option.
6
+ //
7
+ // You can read more here:
8
+ // https://on.cypress.io/plugins-guide
9
+ // ***********************************************************
10
+
11
+ // This function is called when a project is opened or re-opened (e.g. due to
12
+ // the project's config changing)
13
+
14
+ module.exports = (on, config) => {
15
+ // `on` is used to hook into various events Cypress emits
16
+ // `config` is the resolved Cypress config
17
+ };
@@ -0,0 +1,25 @@
1
+ // ***********************************************
2
+ // This example commands.js shows you how to
3
+ // create various custom commands and overwrite
4
+ // existing commands.
5
+ //
6
+ // For more comprehensive examples of custom
7
+ // commands please read more here:
8
+ // https://on.cypress.io/custom-commands
9
+ // ***********************************************
10
+ //
11
+ //
12
+ // -- This is a parent command --
13
+ // Cypress.Commands.add("login", (email, password) => { ... })
14
+ //
15
+ //
16
+ // -- This is a child command --
17
+ // Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
18
+ //
19
+ //
20
+ // -- This is a dual command --
21
+ // Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
22
+ //
23
+ //
24
+ // -- This is will overwrite an existing command --
25
+ // Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
@@ -0,0 +1,20 @@
1
+ // ***********************************************************
2
+ // This example support/index.js is processed and
3
+ // loaded automatically before your test files.
4
+ //
5
+ // This is a great place to put global configuration and
6
+ // behavior that modifies Cypress.
7
+ //
8
+ // You can change the location of this file or turn off
9
+ // automatically serving support files with the
10
+ // 'supportFile' configuration option.
11
+ //
12
+ // You can read more here:
13
+ // https://on.cypress.io/configuration
14
+ // ***********************************************************
15
+
16
+ // Import commands.js using ES2015 syntax:
17
+ import "./commands";
18
+
19
+ // Alternatively you can use CommonJS syntax:
20
+ // require('./commands')
package/cypress.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "baseUrl": "http://localhost:3000",
3
+ "video": false
4
+ }
package/i18n.yml ADDED
@@ -0,0 +1,61 @@
1
+ activeIncidents: Active Incidents
2
+ allSystemsOperational: All systems are operational
3
+ incidentReport: "Incident #$NUMBER report →"
4
+ activeIncidentSummary: Opened at $DATE with $POSTS posts
5
+ incidentTitle: Incident $NUMBER Details
6
+ incidentDetails: Incident Details
7
+ incidentFixed: Fixed
8
+ incidentOngoing: Ongoing
9
+ incidentOpenedAt: Opened at
10
+ incidentClosedAt: Closed at
11
+ incidentViewOnGitHub: View and Subscribe on GitHub
12
+ incidentCommentSummary: Posted at $DATE by $AUTHOR
13
+ incidentBack: ← Back to all incidents
14
+ pastIncidents: Past Incidents
15
+ pastIncidentsResolved: Resolved in $MINUTES minutes with $POSTS posts
16
+ liveStatus: Live Status
17
+ overallUptime: "Overall uptime: $UPTIME"
18
+ overallUptimeTitle: Overall uptime
19
+ averageResponseTime: "Average response time: $TIMEms"
20
+ averageResponseTimeTitle: Average response
21
+ sevelDayResponseTime: 7-day response time
22
+ responseTimeMs: Response time (ms)
23
+ up: Up
24
+ down: Down
25
+ degraded: Degraded
26
+ ms: ms
27
+ loading: Loading
28
+ navGitHub: GitHub
29
+ footer: This page is [open source]($REPO), powered by [Upptime](https://upptime.js.org)
30
+ rateLimitExceededTitle: Rate limit exceeded
31
+ rateLimitExceededIntro: You have exceeded the number of requests you can do in an hour, so you'll have to wait before accessing this website again. Alternately, you can add a GitHub Personal Access Token to continue to use this website.
32
+ rateLimitExceededWhatDoesErrorMean: What does this error mean?
33
+ rateLimitExceededErrorMeaning: This website uses the GitHub API to access real-time data about our websites' status. By default, GitHub allows each IP address 60 requests per hour, which you have consumed.
34
+ rateLimitExceededErrorHowCanFix: How can I fix it?
35
+ rateLimitExceededErrorFix: You can wait for another hour and your IP address' limit will be restored. Alternately, you can add your GitHub Personal Access Token, which gives you an additional 5,000 requests per hour.
36
+ rateLimitExceededGeneratePAT: Learn how to generate a Personal Access Token
37
+ rateLimitExceededHasSet: You have a personal access token set.
38
+ rateLimitExceededRemoveToken: Remove token
39
+ rateLimitExceededGitHubPAT: GitHub Personal Access Token
40
+ rateLimitExceededCopyPastePAT: Copy and paste your token
41
+ rateLimitExceededSaveToken: Save token
42
+ errorTitle: An error occurred
43
+ errorIntro: An error occurred in trying to get the latest status details.
44
+ errorText: You can try again in a few moments.
45
+ errorHome: Go to the homepage
46
+ pastScheduledMaintenance: Past Scheduled Maintenance
47
+ scheduledMaintenance: Scheduled Maintenance
48
+ scheduledMaintenanceSummaryStarted: Started at $DATE for $DURATION minutes
49
+ scheduledMaintenanceSummaryStarts: Starts at $DATE for $DURATION minutes
50
+ startedAt: Started at
51
+ startsAt: Starts at
52
+ duration: Duration
53
+ durationMin: $DURATION minutes
54
+ incidentCompleted: Completed
55
+ incidentScheduled: Scheduled
56
+ duration24H: 24h
57
+ duration7D: 7d
58
+ duration30D: 30d
59
+ duration1Y: 1y
60
+ durationAll: all
61
+ locale: en-US
package/init-tests.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { copyFile, readFile } from "fs-extra";
2
+ import { join } from "path";
3
+
4
+ const initTests = async () => {
5
+ let hasFile = false;
6
+ try {
7
+ await readFile(join("..", ".upptimerc.yml"));
8
+ hasFile = true;
9
+ } catch (error) {}
10
+ if (!hasFile) await copyFile(join(".", ".upptimerc.yml"), join("..", ".upptimerc.yml"));
11
+ };
12
+ initTests();
package/jest.config.js ADDED
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ preset: "ts-jest",
3
+ testEnvironment: "node",
4
+ };
package/package.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "name": "@justdanielndev/status-page",
3
+ "version": "1.17.0",
4
+ "description": "Upptime status page website",
5
+ "main": "dist/index.js",
6
+ "scripts": {
7
+ "pre-process": "ts-node pre-process.ts",
8
+ "post-process": "ts-node post-process.ts",
9
+ "init-tests": "ts-node init-tests.ts",
10
+ "dev": "npm run pre-process && sapper dev",
11
+ "build": "npm run init-tests && npm run pre-process && sapper build --legacy",
12
+ "export": "npm run pre-process && npm run post-process",
13
+ "start": "node __sapper__/build",
14
+ "cy:run": "cypress run",
15
+ "cy:open": "cypress open",
16
+ "test": "npm run init-tests && run-p --race dev cy:run",
17
+ "semantic-release": "semantic-release"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/justdanielndev/status-page.git"
22
+ },
23
+ "keywords": [
24
+ "koj",
25
+ "template",
26
+ "nodejs",
27
+ "typescript"
28
+ ],
29
+ "author": "Zoe <zoe@hackclub.email>",
30
+ "license": "MIT",
31
+ "bugs": {
32
+ "url": "https://github.com/justdanielndev/status-page/issues"
33
+ },
34
+ "homepage": "https://github.com/justdanielndev/status-page#readme",
35
+ "dependencies": {
36
+ "@octokit/rest": "^18.12.0",
37
+ "compression": "^1.7.4",
38
+ "fs-extra": "^10.1.0",
39
+ "js-yaml": "^4.1.0",
40
+ "polka": "next",
41
+ "sirv": "^1.0.5",
42
+ "snarkdown": "^2.0.0",
43
+ "svelte-chartjs": "^1.1.4"
44
+ },
45
+ "devDependencies": {
46
+ "@babel/core": "^7.18.2",
47
+ "@babel/plugin-syntax-dynamic-import": "^7.8.3",
48
+ "@babel/plugin-transform-runtime": "^7.18.2",
49
+ "@babel/preset-env": "^7.18.2",
50
+ "@babel/runtime": "^7.18.3",
51
+ "@koj/config": "^1.2.11",
52
+ "@rollup/plugin-babel": "^5.1.0",
53
+ "@rollup/plugin-commonjs": "^17.0.0",
54
+ "@rollup/plugin-json": "^4.1.0",
55
+ "@rollup/plugin-node-resolve": "^11.0.1",
56
+ "@rollup/plugin-replace": "^2.3.3",
57
+ "@semantic-release/changelog": "^6.0.1",
58
+ "@semantic-release/git": "^10.0.1",
59
+ "@semantic-release/github": "^8.0.4",
60
+ "@semantic-release/npm": "^9.0.1",
61
+ "@types/fs-extra": "^9.0.13",
62
+ "@types/jest": "^27.5.1",
63
+ "@types/js-yaml": "^4.0.5",
64
+ "cypress": "^9.7.0",
65
+ "jest": "^28.1.0",
66
+ "npm-run-all": "^4.1.5",
67
+ "rollup": "^2.74.1",
68
+ "rollup-plugin-svelte": "^6.0.1",
69
+ "rollup-plugin-terser": "^7.0.2",
70
+ "sapper": "^0.29.0",
71
+ "semantic-release": "^19.0.2",
72
+ "semantic-release-gitmoji": "^1.4.4",
73
+ "svelte": "^3.24.1",
74
+ "ts-jest": "^28.0.3",
75
+ "ts-node": "^10.8.0",
76
+ "typescript": "^4.7.2"
77
+ }
78
+ }
@@ -0,0 +1,61 @@
1
+ import { readFile, writeFile, copyFile, copy, remove, pathExists } from "fs-extra";
2
+ import { load } from "js-yaml";
3
+ import { join } from "path";
4
+ import { execSync } from "child_process";
5
+
6
+ export const postProcess = async () => {
7
+ let config: {
8
+ "status-website"?: {
9
+ cname?: string;
10
+ robotsText?: string;
11
+ baseUrl?: string;
12
+ };
13
+ } = load(await readFile(join("..", ".upptimerc.yml"), "utf8")) as any;
14
+ const baseUrl = (config["status-website"] || {}).baseUrl || "/";
15
+
16
+ execSync(`sapper export --legacy --basepath ${baseUrl}`, {
17
+ stdio: "inherit",
18
+ });
19
+
20
+ if (baseUrl !== "/") {
21
+ await copy(join(".", "__sapper__", "export", baseUrl), join(".", "__sapper__", "export"));
22
+ await remove(join(".", "__sapper__", "export", baseUrl));
23
+ }
24
+
25
+ try {
26
+ if (await pathExists(join(".", "assets")))
27
+ await copy(join(".", "assets"), join(".", "__sapper__", "export"), { recursive: true });
28
+ } catch (error) {
29
+ console.log("Got an error in copying assets", error);
30
+ }
31
+
32
+ const [owner, repo] = (process.env.GITHUB_REPOSITORY || "").split("/");
33
+
34
+ if (
35
+ config["status-website"] &&
36
+ config["status-website"].cname &&
37
+ config["status-website"].cname !== "demo.upptime.js.org"
38
+ )
39
+ await writeFile(join(".", "__sapper__", "export", "CNAME"), config["status-website"].cname);
40
+ else if (
41
+ config["status-website"] &&
42
+ config["status-website"].cname &&
43
+ config["status-website"].cname === "demo.upptime.js.org" &&
44
+ owner === "upptime" &&
45
+ repo === "upptime"
46
+ )
47
+ await writeFile(join(".", "__sapper__", "export", "CNAME"), "demo.upptime.js.org");
48
+
49
+ if (config["status-website"] && config["status-website"].robotsText)
50
+ await writeFile(
51
+ join(".", "__sapper__", "export", "robots.txt"),
52
+ config["status-website"].robotsText
53
+ );
54
+
55
+ await copyFile(
56
+ join(".", "__sapper__", "export", "service-worker-index.html"),
57
+ join(".", "__sapper__", "export", "404.html")
58
+ );
59
+ };
60
+
61
+ postProcess();
package/pre-process.ts ADDED
@@ -0,0 +1,32 @@
1
+ import { readFile, writeJson, ensureDir } from "fs-extra";
2
+ import { load } from "js-yaml";
3
+ import { join } from "path";
4
+
5
+ export const preProcess = async () => {
6
+ const i18n = load(await readFile(join(".", "i18n.yml"), "utf8")) as {
7
+ [index: string]: string;
8
+ };
9
+
10
+ let config: {
11
+ logoUrl?: string;
12
+ name?: string;
13
+ owner: string;
14
+ repo: string;
15
+ introTitle?: string;
16
+ introMessage?: string;
17
+ path: string;
18
+ i18n?: { [index: string]: string };
19
+ "status-website"?: {
20
+ cname?: string;
21
+ baseUrl?: string;
22
+ };
23
+ } = load(await readFile(join("..", ".upptimerc.yml"), "utf8")) as any;
24
+ if (!config.owner || !config.repo) throw new Error("Owner/repo not set");
25
+ config.path = `https://${config.owner}.github.io/${config.repo}`;
26
+ if (config["status-website"]?.cname) config.path = `https://${config["status-website"].cname}${config["status-website"]?.baseUrl ?? ""}`;
27
+ config.i18n = { ...i18n, ...config.i18n };
28
+ await ensureDir(join(".", "src", "data"));
29
+ await writeJson(join(".", "src", "data", "config.json"), config);
30
+ };
31
+
32
+ preProcess();
@@ -0,0 +1 @@
1
+ module.exports = require("@koj/config").releaseMaster;
@@ -0,0 +1,116 @@
1
+ import resolve from "@rollup/plugin-node-resolve";
2
+ import replace from "@rollup/plugin-replace";
3
+ import commonjs from "@rollup/plugin-commonjs";
4
+ import svelte from "rollup-plugin-svelte";
5
+ import babel from "@rollup/plugin-babel";
6
+ import json from "@rollup/plugin-json";
7
+ import { terser } from "rollup-plugin-terser";
8
+ import config from "sapper/config/rollup.js";
9
+ import pkg from "./package.json";
10
+
11
+ const mode = process.env.NODE_ENV;
12
+ const dev = mode === "development";
13
+ const legacy = !!process.env.SAPPER_LEGACY_BUILD;
14
+
15
+ const onwarn = (warning, onwarn) =>
16
+ (warning.code === "MISSING_EXPORT" && /'preload'/.test(warning.message)) ||
17
+ (warning.code === "CIRCULAR_DEPENDENCY" && /[/\\]@sapper[/\\]/.test(warning.message)) ||
18
+ onwarn(warning);
19
+
20
+ export default {
21
+ client: {
22
+ input: config.client.input(),
23
+ output: config.client.output(),
24
+ plugins: [
25
+ json(),
26
+ replace({
27
+ "process.browser": true,
28
+ "process.env.NODE_ENV": JSON.stringify(mode),
29
+ }),
30
+ svelte({
31
+ dev,
32
+ hydratable: true,
33
+ emitCss: true,
34
+ }),
35
+ resolve({
36
+ browser: true,
37
+ dedupe: ["svelte"],
38
+ }),
39
+ commonjs(),
40
+
41
+ legacy &&
42
+ babel({
43
+ extensions: [".js", ".mjs", ".html", ".svelte"],
44
+ babelHelpers: "runtime",
45
+ exclude: ["node_modules/@babel/**"],
46
+ presets: [
47
+ [
48
+ "@babel/preset-env",
49
+ {
50
+ targets: "> 0.25%, not dead",
51
+ },
52
+ ],
53
+ ],
54
+ plugins: [
55
+ "@babel/plugin-syntax-dynamic-import",
56
+ [
57
+ "@babel/plugin-transform-runtime",
58
+ {
59
+ useESModules: true,
60
+ },
61
+ ],
62
+ ],
63
+ }),
64
+
65
+ !dev &&
66
+ terser({
67
+ module: true,
68
+ }),
69
+ ],
70
+
71
+ preserveEntrySignatures: false,
72
+ onwarn,
73
+ },
74
+
75
+ server: {
76
+ input: config.server.input(),
77
+ output: config.server.output(),
78
+ plugins: [
79
+ json(),
80
+ replace({
81
+ "process.browser": false,
82
+ "process.env.NODE_ENV": JSON.stringify(mode),
83
+ }),
84
+ svelte({
85
+ generate: "ssr",
86
+ hydratable: true,
87
+ dev,
88
+ }),
89
+ resolve({
90
+ dedupe: ["svelte"],
91
+ }),
92
+ commonjs(),
93
+ ],
94
+ external: Object.keys(pkg.dependencies).concat(require("module").builtinModules),
95
+
96
+ preserveEntrySignatures: "strict",
97
+ onwarn,
98
+ },
99
+
100
+ serviceworker: {
101
+ input: config.serviceworker.input(),
102
+ output: config.serviceworker.output(),
103
+ plugins: [
104
+ resolve(),
105
+ replace({
106
+ "process.browser": true,
107
+ "process.env.NODE_ENV": JSON.stringify(mode),
108
+ }),
109
+ commonjs(),
110
+ !dev && terser(),
111
+ ],
112
+
113
+ preserveEntrySignatures: false,
114
+ onwarn,
115
+ },
116
+ };
package/src/client.js ADDED
@@ -0,0 +1,18 @@
1
+ import * as sapper from '@sapper/app';
2
+
3
+ //
4
+ // <https://github.com/upptime/upptime/issues/758>
5
+ // if we do not use this then we need to move sapper at end of <body>
6
+ // <https://caniuse.com/domcontentloaded>
7
+ //
8
+ if (document.readyState !== 'loading') {
9
+ sapper.start({
10
+ target: document.querySelector('#sapper')
11
+ });
12
+ } else {
13
+ document.addEventListener('DOMContentLoaded', function() {
14
+ sapper.start({
15
+ target: document.querySelector('#sapper')
16
+ });
17
+ });
18
+ }
@@ -0,0 +1,79 @@
1
+ <script>
2
+ import Loading from "../components/Loading.svelte";
3
+ import { onMount } from "svelte";
4
+ import config from "../data/config.json";
5
+ import { cachedResponse, createOctokit, handleError } from "../utils/createOctokit";
6
+
7
+ let loading = true;
8
+ const octokit = createOctokit();
9
+ const owner = config.owner;
10
+ const repo = config.repo;
11
+ let incidents = [];
12
+
13
+ onMount(async () => {
14
+ try {
15
+ incidents = (
16
+ await cachedResponse(`issues-${owner}-${repo}`, () =>
17
+ octokit.issues.listForRepo({
18
+ owner,
19
+ repo,
20
+ state: "open",
21
+ filter: "all",
22
+ sort: "created",
23
+ direction: "desc",
24
+ labels: "status",
25
+ })
26
+ )
27
+ ).data;
28
+ incidents = incidents.map((incident, index) => {
29
+ incident.showHeading =
30
+ index === 0 ||
31
+ new Date(incidents[index - 1].created_at).toLocaleDateString() !==
32
+ new Date(incident.created_at).toLocaleDateString();
33
+ return incident;
34
+ });
35
+ } catch (error) {
36
+ handleError(error);
37
+ }
38
+ loading = false;
39
+ });
40
+ </script>
41
+
42
+ {#if !incidents.length && !loading}
43
+ <article class="up">✅ &nbsp; {config.i18n.allSystemsOperational}</article>
44
+ {/if}
45
+
46
+ <section>
47
+ {#if loading}
48
+ <Loading />
49
+ {:else if incidents.length}
50
+ <h2>{config.i18n.activeIncidents}</h2>
51
+ {#each incidents as incident}
52
+ <article
53
+ class="down down-active link {incident.title.includes('degraded') ? 'degraded' : ''}"
54
+ >
55
+ <div class="f">
56
+ <div>
57
+ <h4>{incident.title.replace("🛑", "").replace("⚠️", "").trim()}</h4>
58
+ <div>
59
+ {config.i18n.activeIncidentSummary
60
+ .replace(/\$DATE/g, new Date(incident.created_at).toLocaleString(config.i18n.locale))
61
+ .replace(/\$POSTS/g, incident.comments)}
62
+ </div>
63
+ </div>
64
+ <div class="f r">
65
+ <a href={`${config.path}/incident/${incident.number}`}>
66
+ {config.i18n.incidentReport.replace(/\$NUMBER/g, incident.number)}
67
+ </a>
68
+ </div>
69
+ </div>
70
+ </article>
71
+ {/each}
72
+ {/if}
73
+ </section>
74
+
75
+ <style>
76
+ section {
77
+ margin-bottom: 2rem;
78
+ }
79
+ </style>