From 3772d677267374c14a86631a229e420c6f904440 Mon Sep 17 00:00:00 2001 From: "Rph :3" <11350302+rphsoftware@users.noreply.github.com> Date: Thu, 27 Mar 2025 17:25:19 +0100 Subject: [PATCH 1/3] Add flake with Bun --- dev-server/.envrc | 1 + dev-server/.gitignore | 1 + dev-server/flake.nix | 17 +++++++++++++++++ 3 files changed, 19 insertions(+) create mode 100644 dev-server/.envrc create mode 100644 dev-server/.gitignore create mode 100644 dev-server/flake.nix diff --git a/dev-server/.envrc b/dev-server/.envrc new file mode 100644 index 0000000..8392d15 --- /dev/null +++ b/dev-server/.envrc @@ -0,0 +1 @@ +use flake \ No newline at end of file diff --git a/dev-server/.gitignore b/dev-server/.gitignore new file mode 100644 index 0000000..ff51edf --- /dev/null +++ b/dev-server/.gitignore @@ -0,0 +1 @@ +.direnv \ No newline at end of file diff --git a/dev-server/flake.nix b/dev-server/flake.nix new file mode 100644 index 0000000..623e335 --- /dev/null +++ b/dev-server/flake.nix @@ -0,0 +1,17 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, utils }: + utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + in { + devShell = with pkgs; mkShell { + buildInputs = with pkgs; [ bun ]; + }; + } + ); +} -- 2.47.2 From 6edfa118b1de6b8bd964b4347d787644400a362a Mon Sep 17 00:00:00 2001 From: "Rph :3" <11350302+rphsoftware@users.noreply.github.com> Date: Thu, 27 Mar 2025 17:42:45 +0100 Subject: [PATCH 2/3] Implement dev server --- dev-server/.gitignore | 3 +- dev-server/bun.lock | 47 +++++++++++++++++++++++++++++++ dev-server/flake.lock | 61 ++++++++++++++++++++++++++++++++++++++++ dev-server/index.ts | 35 +++++++++++++++++++++++ dev-server/package.json | 16 +++++++++++ dev-server/tsconfig.json | 28 ++++++++++++++++++ 6 files changed, 189 insertions(+), 1 deletion(-) create mode 100644 dev-server/bun.lock create mode 100644 dev-server/flake.lock create mode 100644 dev-server/index.ts create mode 100644 dev-server/package.json create mode 100644 dev-server/tsconfig.json diff --git a/dev-server/.gitignore b/dev-server/.gitignore index ff51edf..4876a60 100644 --- a/dev-server/.gitignore +++ b/dev-server/.gitignore @@ -1 +1,2 @@ -.direnv \ No newline at end of file +.direnv +node_modules \ No newline at end of file diff --git a/dev-server/bun.lock b/dev-server/bun.lock new file mode 100644 index 0000000..251de84 --- /dev/null +++ b/dev-server/bun.lock @@ -0,0 +1,47 @@ +{ + "lockfileVersion": 1, + "workspaces": { + "": { + "name": "dev-server", + "dependencies": { + "@elysiajs/static": "^1.2.0", + "elysia": "^1.2.25", + }, + "devDependencies": { + "@types/bun": "latest", + }, + "peerDependencies": { + "typescript": "^5", + }, + }, + }, + "packages": { + "@elysiajs/static": ["@elysiajs/static@1.2.0", "", { "dependencies": { "node-cache": "^5.1.2" }, "peerDependencies": { "elysia": ">= 1.2.0" } }, "sha512-oLpAi8c+maPpA0XhhK3BELaIjIG+nXg/K9p8cFfW4q5ayRD59a3MOMOOGgpiXZkHJzLPWcouhhyyLAYtaANW4g=="], + + "@sinclair/typebox": ["@sinclair/typebox@0.34.31", "", {}, "sha512-qQ71T9DsITbX3dVCrcBERbs11YuSMg3wZPnT472JhqhWGPdiLgyvihJXU8m+ADJtJvRdjATIiACJD22dEknBrQ=="], + + "@types/bun": ["@types/bun@1.2.8", "", { "dependencies": { "bun-types": "1.2.7" } }, "sha512-t8L1RvJVUghW5V+M/fL3Thbxcs0HwNsXsnTEBEfEVqGteiJToOlZ/fyOEaR1kZsNqnu+3XA4RI/qmnX4w6+S+w=="], + + "@types/node": ["@types/node@22.13.14", "", { "dependencies": { "undici-types": "~6.20.0" } }, "sha512-Zs/Ollc1SJ8nKUAgc7ivOEdIBM8JAKgrqqUYi2J997JuKO7/tpQC+WCetQ1sypiKCQWHdvdg9wBNpUPEWZae7w=="], + + "@types/ws": ["@types/ws@8.18.0", "", { "dependencies": { "@types/node": "*" } }, "sha512-8svvI3hMyvN0kKCJMvTJP/x6Y/EoQbepff882wL+Sn5QsXb3etnamgrJq4isrBxSJj5L2AuXcI0+bgkoAXGUJw=="], + + "bun-types": ["bun-types@1.2.7", "", { "dependencies": { "@types/node": "*", "@types/ws": "*" } }, "sha512-P4hHhk7kjF99acXqKvltyuMQ2kf/rzIw3ylEDpCxDS9Xa0X0Yp/gJu/vDCucmWpiur5qJ0lwB2bWzOXa2GlHqA=="], + + "clone": ["clone@2.1.2", "", {}, "sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w=="], + + "cookie": ["cookie@1.0.2", "", {}, "sha512-9Kr/j4O16ISv8zBBhJoi4bXOYNTkFLOqSL3UDB0njXxCXNezjeyVrJyGOWtgfs/q2km1gwBcfH8q1yEGoMYunA=="], + + "elysia": ["elysia@1.2.25", "", { "dependencies": { "@sinclair/typebox": "^0.34.27", "cookie": "^1.0.2", "memoirist": "^0.3.0", "openapi-types": "^12.1.3" }, "peerDependencies": { "typescript": ">= 5.0.0" }, "optionalPeers": ["typescript"] }, "sha512-WsdQpORJvb4uszzeqYT0lg97knw1iBW1NTzJ1Jm57tiHg+DfAotlWXYbjmvQ039ssV0fYELDHinLLoUazZkEHg=="], + + "memoirist": ["memoirist@0.3.0", "", {}, "sha512-wR+4chMgVPq+T6OOsk40u9Wlpw1Pjx66NMNiYxCQQ4EUJ7jDs3D9kTCeKdBOkvAiqXlHLVJlvYL01PvIJ1MPNg=="], + + "node-cache": ["node-cache@5.1.2", "", { "dependencies": { "clone": "2.x" } }, "sha512-t1QzWwnk4sjLWaQAS8CHgOJ+RAfmHpxFWmc36IWTiWHQfs0w5JDMBS1b1ZxQteo0vVVuWJvIUKHDkkeK7vIGCg=="], + + "openapi-types": ["openapi-types@12.1.3", "", {}, "sha512-N4YtSYJqghVu4iek2ZUvcN/0aqH1kRDuNqzcycDxhOUpg7GdvLa2F3DgS6yBNhInhv2r/6I0Flkn7CqL8+nIcw=="], + + "typescript": ["typescript@5.8.2", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ=="], + + "undici-types": ["undici-types@6.20.0", "", {}, "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg=="], + } +} diff --git a/dev-server/flake.lock b/dev-server/flake.lock new file mode 100644 index 0000000..5ed05e2 --- /dev/null +++ b/dev-server/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1742923925, + "narHash": "sha256-biPjLws6FiBVUUDHEMFq5pUQL84Wf7PntPYdo3oKkFw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "25d1b84f5c90632a623c48d83a2faf156451e6b1", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "utils": "utils" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/dev-server/index.ts b/dev-server/index.ts new file mode 100644 index 0000000..fe4a5ad --- /dev/null +++ b/dev-server/index.ts @@ -0,0 +1,35 @@ +import { Elysia } from 'elysia' +import { staticPlugin } from "@elysiajs/static" +import { stat, readdir, readFile } from "node:fs/promises" +import { createHash } from "node:crypto"; + +type IndexEntry = { src: string, dest: string, hash: string }; + +async function scanDir(scanIn: string, base: string, outputBase: string): Promise { + let files = await readdir(scanIn + "/" + base); + let results: IndexEntry[] = []; + + for (let file of files) { + if (await stat(scanIn + "/" + base + "/" + file).then(r => r.isDirectory())) { + results = [...results, ...(await scanDir(scanIn, base + "/" + file, outputBase + file + "/"))] + } else { + results.push({ + src: base + "/" + file, + dest: outputBase + file, + hash: createHash('sha256').update(await readFile(scanIn + "/" + base + "/" + file)).digest('hex') + }); + } + } + + return results; +} + +new Elysia() + .get("/index.json", async () => scanDir("..", "src", "/")) + .get("/sha256.lua", async () => Bun.file("../sha256.lua")) + .use(staticPlugin({ + assets: "../src", + prefix: "/src" + })) + .get("/install.lua", async () => Bun.file("../install.lua")) + .listen(parseInt(process.env.PORT || "3000")) \ No newline at end of file diff --git a/dev-server/package.json b/dev-server/package.json new file mode 100644 index 0000000..7b6c663 --- /dev/null +++ b/dev-server/package.json @@ -0,0 +1,16 @@ +{ + "name": "dev-server", + "module": "index.ts", + "type": "module", + "private": true, + "devDependencies": { + "@types/bun": "latest" + }, + "peerDependencies": { + "typescript": "^5" + }, + "dependencies": { + "@elysiajs/static": "^1.2.0", + "elysia": "^1.2.25" + } +} \ No newline at end of file diff --git a/dev-server/tsconfig.json b/dev-server/tsconfig.json new file mode 100644 index 0000000..ab0f0b0 --- /dev/null +++ b/dev-server/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + // Environment setup & latest features + "lib": ["esnext"], + "target": "ESNext", + "module": "ESNext", + "moduleDetection": "force", + "jsx": "react-jsx", + "allowJs": true, + + // Bundler mode + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "noEmit": true, + + // Best practices + "strict": true, + "skipLibCheck": true, + "noFallthroughCasesInSwitch": true, + "noUncheckedIndexedAccess": true, + + // Some stricter flags (disabled by default) + "noUnusedLocals": false, + "noUnusedParameters": false, + "noPropertyAccessFromIndexSignature": false + } +} -- 2.47.2 From 4ff7e3216ca311b3d124ebfaa4e4e8fc6b62fbd5 Mon Sep 17 00:00:00 2001 From: "Rph :3" <11350302+rphsoftware@users.noreply.github.com> Date: Thu, 27 Mar 2025 17:42:56 +0100 Subject: [PATCH 3/3] Implement setting alternative repo bases with the snowier.repo_base setting --- install.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/install.lua b/install.lua index 797c7a1..4e60e5f 100644 --- a/install.lua +++ b/install.lua @@ -1,4 +1,5 @@ -local repoRoot = "https://git.colon-three.com/kodi/snowier/raw/branch/main/" +local defaultRoot = "https://git.colon-three.com/kodi/snowier/raw/branch/main/" +local repoRoot = settings.get("snowier.repo_base") or defaultRoot local URLs = { fileIndex = repoRoot .. "index.json", -- 2.47.2