From 572e4844983b3e6ab44eab09e5d6a49c911c3987 Mon Sep 17 00:00:00 2001 From: PwLDev Date: Tue, 28 Apr 2026 21:07:06 -0700 Subject: [PATCH] switch to submodule --- .gitignore | 4 --- .gitmodules | 3 +++ bun.lock | 1 - deps/milsko | 1 + package.json | 8 +++--- scripts/download.js | 59 --------------------------------------------- scripts/install.js | 31 ------------------------ 7 files changed, 7 insertions(+), 100 deletions(-) create mode 100644 .gitmodules create mode 160000 deps/milsko delete mode 100644 scripts/download.js delete mode 100644 scripts/install.js diff --git a/.gitignore b/.gitignore index e7d2d4f..c8eb801 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,6 @@ # Node node_modules/ -# Milsko -deps/ -*.tar.gz - # Build build/ dist/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..5ce06bc --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "deps/milsko"] + path = deps/milsko + url = https://forgejo.nishi.boats/pyrite-dev/milsko.git diff --git a/bun.lock b/bun.lock index f5e0479..b08d78d 100644 --- a/bun.lock +++ b/bun.lock @@ -7,7 +7,6 @@ "dependencies": { "node-addon-api": "^8.7.0", "node-gyp-build": "^4.8.4", - "tar": "^7.5.13", }, "devDependencies": { "@types/node": "^25.6.0", diff --git a/deps/milsko b/deps/milsko new file mode 160000 index 0000000..572c170 --- /dev/null +++ b/deps/milsko @@ -0,0 +1 @@ +Subproject commit 572c170cd6772e7ff633b6406b3eebbb57965bce diff --git a/package.json b/package.json index ec83c8f..14f7554 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,13 @@ { "name": "milsko", "version": "1.0.1", + "upstream": "v1.0a", "description": "Lightweight and cross-platform native GUI toolkit", "main": "lib/index.js", "type": "module", - "upstream": "v1.0a", "scripts": { + "install": "node-gyp-build", "bindgen": "node scripts/bindgen.js && prettier --write lib/", - "download": "node scripts/download.js", - "install": "node scripts/install.js", "update": "rimraf deps/milsko.tar.gz deps/milsko/ && node scripts/download.js" }, "repository": { @@ -42,8 +41,7 @@ }, "dependencies": { "node-addon-api": "^8.7.0", - "node-gyp-build": "^4.8.4", - "tar": "^7.5.13" + "node-gyp-build": "^4.8.4" }, "files": [ "README.md", diff --git a/scripts/download.js b/scripts/download.js deleted file mode 100644 index 20eedc2..0000000 --- a/scripts/download.js +++ /dev/null @@ -1,59 +0,0 @@ -import { execSync } from "node:child_process"; -import { createWriteStream, mkdirSync } from "node:fs"; -import { createRequire } from "node:module"; -import { join, resolve } from "node:path"; -import { Readable } from "node:stream"; -import { pipeline } from "node:stream/promises"; -import { t, extract as tarExtract } from "tar"; - -const extractDir = resolve("deps"); -const fileName = "milsko.tar.gz"; -const source = - "https://forgejo.nishi.boats/api/v1/repos/pyrite-dev/milsko/tags"; - -const require = createRequire(import.meta.url); -const { upstream } = require("../package.json"); - -export async function download() { - console.log("[Mw] Fetching Milsko release tags from", source); - - const response = await fetch(source); - if (!response.ok) { - throw new Error( - "Failed to fetch the Milsko repository tags, try running npm run install or npm run update again (" + - response.status + - ")" - ); - } - - const tags = await response.json(); - const match = tags.find((k) => k.name == upstream); - - if (!match) { - throw new Error( - "Could not find a tag that matches the upstream version " + upstream - ); - } - - const tarUrl = match["tarball_url"]; - console.log("[Mw] Fetching tarball from " + tarUrl); - - const tarball = await fetch(tarUrl); - - const filePath = join(extractDir, fileName); - mkdirSync(extractDir, { recursive: true }); // mkdir -p - - const tarStream = Readable.fromWeb(tarball.body); - const fileStream = createWriteStream(filePath); - - await pipeline(tarStream, fileStream); - await tarExtract({ - file: filePath, - cwd: extractDir - }); - - console.log("[Mw] Milsko library successfully installed!"); -} - -if (import.meta.main) - download(); \ No newline at end of file diff --git a/scripts/install.js b/scripts/install.js deleted file mode 100644 index c85fd38..0000000 --- a/scripts/install.js +++ /dev/null @@ -1,31 +0,0 @@ -import { execSync } from "node:child_process" -import { createRequire } from "node:module"; -import { download } from "./download"; - -const require = createRequire(import.meta.url); -const forceBuild = process.env["npm_config_build_from_source"] == "true"; - -function hasPrebuilt() { - let prebuilt = false; - - try { - require("node-gyp-build")(".."); - prebuilt = true; - } catch (error) { - prebuilt = false; - } - - return prebuilt; -} - -async function install() { - console.log("[Mw] Downloading Milsko library..."); - await download(); - - console.log("[Mw] Building from source..."); - execSync("npx node-gyp rebuild", { stdio: "inherit" }); -} - -if (forceBuild || !hasPrebuilt()) { - install(); -} \ No newline at end of file