Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lighthouse top scores #84

Merged
merged 10 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .lighthouserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
"categories.best-practices" : [
"error",
{
"minScore": 0.96
"minScore": 1
}
],
"categories.seo" : [
"error",
{
"minScore": 0.9
"minScore": 1
}
]
}
Expand Down
24 changes: 15 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ MAKE_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
install:
deno install

dev: install
open http://localhost:8000 && sh scripts/dev.sh
dev: clean-build-output install prepare-static-files
open http://localhost:8000 && deno -A ./scripts/dev.js

format:
deno fmt
Expand All @@ -31,25 +31,31 @@ checks: install compile build verify-formatting lint
lighthouse-audit: install build
lhci autorun

# you will need to `make serve` first (in a separate terminal)
# & with this: it will update the lighthouse score badges
# in the docs folder where ReadMe refers to (you will need to commit the changes)
lighthouse-badges:
npx lighthouse-badges -o docs/lighthouse/badges -u https://teomrd.github.io/miropad/
npx lighthouse-badges -o docs/lighthouse/badges -u http://localhost:3000/

update-lighthouse-badges: lighthouse-badges
$(MAKE_DIR)/scripts/update-badges.sh

clean:
clean-build-output:
rm -rf ./dist

clean: clean-build-output
deno clean
rm -rf ./node_modules
rm -rf ./out
rm -rf ./dist
rm -rf ./dev
rm -rf ./*lock*

serve: build
serve $(MAKE_DIR)/dist

build: install
$(MAKE_DIR)/scripts/build.sh
prepare-static-files:
$(MAKE_DIR)/scripts/prepare-static-files.sh

build: clean-build-output install prepare-static-files
deno -A ./scripts/build.js

deploy: version build
$(MAKE_DIR)/scripts/deploy.sh
2 changes: 1 addition & 1 deletion docs/lighthouse/badges/lighthouse_accessibility.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/lighthouse/badges/lighthouse_seo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as esbuild from "npm:esbuild";

const VERSION = Deno.env.get("NEW_VERSION") || `v0.0.0`;

const result = await esbuild.build({
await esbuild.build({
entryPoints: ["./src/index.ts"],
bundle: true,
platform: "browser",
Expand Down
23 changes: 0 additions & 23 deletions scripts/build.sh

This file was deleted.

7 changes: 4 additions & 3 deletions scripts/dev.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import * as esbuild from "esbuild";
import miropad from "../package.json" with { type: "json" };

const VERSION = `v0.0.0`;
const context = await esbuild.context({
entryPoints: ["src/index.ts"],
bundle: true,
outfile: "dev/index.js",
outfile: "dist/index.js",
target: ["es2020", "chrome100", "firefox100"],
minify: true,
sourcemap: true,
Expand All @@ -17,15 +18,15 @@ const context = await esbuild.context({
define: {
"process.env.NODE_ENV": '"development"',
TITLE_NAME: JSON.stringify("✍️ MiroPad"),
VERSION: JSON.stringify(miropad.version),
VERSION: JSON.stringify(VERSION),
global: "globalThis",
},
});

await context.watch();

const { host, port } = await context.serve({
servedir: "dev",
servedir: "dist",
});

console.log(`Running v${miropad.version} on ${host}:${port} 🚀`);
10 changes: 0 additions & 10 deletions scripts/dev.sh

This file was deleted.

14 changes: 14 additions & 0 deletions scripts/prepare-static-files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

## copy over static files from src
rsync -r ./src/assets/images ./dist
rsync ./src/assets/favicon.ico ./dist
rsync ./src/index.html ./dist
rsync ./src/manifest.json ./dist
rsync ./src/service-worker.js ./dist
./node_modules/.bin/workbox injectManifest ./workbox-config.js

## versioning static file generation
version="${NEW_VERSION:-"v0.0.0"}"
echo -e "🛠️ Building ${COLOR_GREEN}MiroPad${NO_COLOR} ${COLOR_RED}${version}${NO_COLOR} \n"
echo "$version" >./dist/version
20 changes: 11 additions & 9 deletions src/index.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="application-name" content="✍️ MiroPad" />
<meta charset="UTF-8">
<meta name="application-name" content="✍️ MiroPad">
<meta
name="description"
content="Temporary note keeping app for the browser"
/>
<meta name="author" content="teomrd" />
<link rel="icon" href="./favicon.ico" />
>
<meta name="author" content="teomrd">
<link rel="icon" href="./favicon.ico">
<meta name="theme-color" content="#000000" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="manifest" href="./manifest.json" crossorigin="use-credentials" />
<link rel="apple-touch-icon" href="./images/icons/icon-192x192.png" />
<link rel="apple-touch-icon" href="./images/icons/icon-192x192.png">
<link rel="stylesheet" href="index.css">
<title>
MiroPad
</title>
Expand Down Expand Up @@ -57,8 +58,8 @@ <h3>✍️ MiroPad</h3>
<button
id="note-info-button"
class="icon-button"
title="info"
aria-label="show note information"
title="information"
aria-label="information"
>
<svg
xmlns="http://www.w3.org/2000/svg"
Expand Down Expand Up @@ -145,5 +146,6 @@ <h3>INFO</h3>
<footer>
<div class="console hidden"></div>
</footer>
<script type="module" src="./index.js"></script>
</body>
</html>
6 changes: 5 additions & 1 deletion src/js/registerServiceWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ export const requestNotificationPermission = async () => {
export const registerServiceWorker = () => {
if ("serviceWorker" in navigator) {
navigator.serviceWorker.register(
`${globalThis.location.pathname}service-worker.js?v=${VERSION}`,
`${
globalThis.location.pathname.slice(-1) === "/"
? globalThis.location.pathname
: `${globalThis.location.origin}/`
}service-worker.js?v=${VERSION}`,
);
}
};
4 changes: 3 additions & 1 deletion src/js/utils/fileSystem/fileSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ export const saveFileAs = async (contents: string, title?: string) => {

export const saveDataToFile = (() => {
const a = document.createElement("a");
document.body.appendChild(a);
a.setAttribute("style", "display: none");
a.setAttribute("id", "download-to-file");
a.setAttribute("href", "#");
document.body.appendChild(a);
return (
data: unknown,
fileName = `MiroPad-${new Date().toISOString()}.json`,
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
}
],
"orientation": "portrait",
"Scope": "https://teomrd.github.io/miropad/",
"scope": "https://teomrd.github.io/miropad/",
"start_url": "https://teomrd.github.io/miropad",
"icons": [
{
Expand Down
Binary file removed static/favicon.ico
Binary file not shown.
Binary file removed static/images/icons/icon-128x128.png
Binary file not shown.
Binary file removed static/images/icons/icon-144x144.png
Binary file not shown.
Binary file removed static/images/icons/icon-152x152.png
Binary file not shown.
Binary file removed static/images/icons/icon-192x192.png
Binary file not shown.
Binary file removed static/images/icons/icon-384x384.png
Binary file not shown.
Binary file removed static/images/icons/icon-512x512.png
Binary file not shown.
Binary file removed static/images/icons/icon-72x72.png
Binary file not shown.
Binary file removed static/images/icons/icon-96x96.png
Binary file not shown.
Binary file removed static/images/icons/maskable_icon.png
Binary file not shown.
93 changes: 0 additions & 93 deletions static/index.html

This file was deleted.

Loading