moondust 0.0.2 → 0.1.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.
package/README.md CHANGED
@@ -1,27 +1 @@
1
- <p>
2
- <img width="100%" src="https://assets.solidjs.com/banner?type=Moondust&background=tiles&project=%20" alt="Moondust">
3
- </p>
4
-
5
- # Moondust
6
-
7
- [![pnpm](https://img.shields.io/badge/maintained%20with-pnpm-cc00ff.svg?style=for-the-badge&logo=pnpm)](https://pnpm.io/)
8
-
9
- Moondust is a component library designed with many themes in mind and customizable props.
10
-
11
- ## Quick start
12
-
13
- Install it:
14
-
15
- ```bash
16
- npm i moondust
17
- # or
18
- yarn add moondust
19
- # or
20
- pnpm add moondust
21
- ```
22
-
23
- Use it:
24
-
25
- ```tsx
26
- import moondust from "moondust";
27
- ```
1
+ Moondust is a local, open-source app for managing multiple repositories and the coding agents you use across them.
@@ -0,0 +1,118 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Moondust npm entry: ensure cached release binary exists, then exec with argv forwarded.
4
+ *
5
+ * Expects GitHub Releases with assets named:
6
+ * moondust_<semver>_linux_amd64.tar.gz
7
+ * moondust_<semver>_darwin_arm64.tar.gz
8
+ * moondust_<semver>_windows_amd64.zip
9
+ * (see RELEASE_ASSETS.md in repo root)
10
+ */
11
+ import { spawn } from "node:child_process";
12
+ import { readFileSync, existsSync, mkdirSync, copyFileSync, unlinkSync, rmSync } from "node:fs";
13
+ import path from "node:path";
14
+ import { fileURLToPath } from "node:url";
15
+ import os from "node:os";
16
+
17
+ import { getTargetTriple, assetBasename } from "../lib/platform.js";
18
+ import { getReleaseAssetUrl } from "../lib/github.js";
19
+ import {
20
+ downloadToFile,
21
+ extractArchive,
22
+ findBinaryInDir,
23
+ tempDownloadPath,
24
+ ensureExecutable,
25
+ } from "../lib/download.js";
26
+
27
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
28
+ const pkg = JSON.parse(readFileSync(path.join(__dirname, "..", "package.json"), "utf8"));
29
+
30
+ function githubRepoFromPackage(p) {
31
+ const url = p.repository?.url;
32
+ if (!url) return null;
33
+ const m = String(url)
34
+ .replace(/\.git$/, "")
35
+ .match(/github\.com\/([^/]+)\/([^/]+)/i);
36
+ return m ? `${m[1]}/${m[2]}` : null;
37
+ }
38
+
39
+ const REPO = process.env.MOONDUST_GITHUB_REPO ?? githubRepoFromPackage(pkg);
40
+
41
+ const GITHUB_TOKEN = process.env.GITHUB_TOKEN ?? process.env.GH_TOKEN;
42
+
43
+ function cacheDir(version) {
44
+ const base =
45
+ process.env.MOONDUST_CACHE_DIR ??
46
+ path.join(os.homedir(), ".cache", "moondust", version);
47
+ return base;
48
+ }
49
+
50
+ function binaryName(ext) {
51
+ return `moondust${ext}`;
52
+ }
53
+
54
+ async function ensureBinary(version, triple) {
55
+ const base = assetBasename(version, triple);
56
+ const isZip = triple.os === "windows";
57
+ const archiveName = isZip ? `${base}.zip` : `${base}.tar.gz`;
58
+ const tag = version.startsWith("v") ? version : `v${version}`;
59
+ const destDir = cacheDir(version);
60
+ const cached = path.join(destDir, binaryName(triple.ext));
61
+
62
+ if (existsSync(cached)) {
63
+ return cached;
64
+ }
65
+
66
+ if (!REPO || !REPO.includes("/")) {
67
+ throw new Error(
68
+ "Set MOONDUST_GITHUB_REPO to owner/repo (e.g. myorg/moondust) or add repository.url to packages/cli/package.json",
69
+ );
70
+ }
71
+
72
+ const url = await getReleaseAssetUrl(REPO, tag, archiveName, GITHUB_TOKEN);
73
+ const tmpArchive = tempDownloadPath("moondust") + (isZip ? ".zip" : ".tar.gz");
74
+ const extractRoot = tempDownloadPath("moondust-extract");
75
+
76
+ try {
77
+ await downloadToFile(url, tmpArchive, GITHUB_TOKEN);
78
+ await extractArchive(tmpArchive, extractRoot, isZip);
79
+ const found = await findBinaryInDir(extractRoot, "moondust", triple.ext);
80
+ mkdirSync(destDir, { recursive: true });
81
+ copyFileSync(found, cached);
82
+ await ensureExecutable(cached);
83
+ } finally {
84
+ try {
85
+ unlinkSync(tmpArchive);
86
+ } catch {
87
+ /* ignore */
88
+ }
89
+ try {
90
+ rmSync(extractRoot, { recursive: true, force: true });
91
+ } catch {
92
+ /* ignore */
93
+ }
94
+ }
95
+
96
+ return cached;
97
+ }
98
+
99
+ async function main() {
100
+ const version = pkg.version;
101
+ const triple = getTargetTriple();
102
+ const binPath = await ensureBinary(version, triple);
103
+
104
+ const child = spawn(binPath, process.argv.slice(2), {
105
+ stdio: "inherit",
106
+ env: process.env,
107
+ windowsHide: false,
108
+ });
109
+ child.on("exit", (code, signal) => {
110
+ if (signal) process.kill(process.pid, signal);
111
+ else process.exit(code ?? 1);
112
+ });
113
+ }
114
+
115
+ main().catch((err) => {
116
+ console.error(err.message || err);
117
+ process.exit(1);
118
+ });
@@ -0,0 +1,67 @@
1
+ import { createWriteStream } from "node:fs";
2
+ import { mkdir, chmod, stat } from "node:fs/promises";
3
+ import { pipeline } from "node:stream/promises";
4
+ import { tmpdir } from "node:os";
5
+ import path from "node:path";
6
+ import { randomBytes } from "node:crypto";
7
+ import extractZip from "extract-zip";
8
+ import { x as extractTar } from "tar";
9
+
10
+ export async function downloadToFile(url, destPath, token) {
11
+ const headers = { "User-Agent": "moondust-npm-cli" };
12
+ if (token) headers.Authorization = `Bearer ${token}`;
13
+ const res = await fetch(url, { headers });
14
+ if (!res.ok) {
15
+ const text = await res.text();
16
+ throw new Error(`Download failed ${res.status}: ${text.slice(0, 300)}`);
17
+ }
18
+ await mkdir(path.dirname(destPath), { recursive: true });
19
+ const tmp = `${destPath}.${randomBytes(8).toString("hex")}.part`;
20
+ await pipeline(res.body, createWriteStream(tmp));
21
+ const { rename } = await import("node:fs/promises");
22
+ await rename(tmp, destPath);
23
+ }
24
+
25
+ export async function extractArchive(archivePath, outDir, isZip) {
26
+ await mkdir(outDir, { recursive: true });
27
+ if (isZip) {
28
+ await extractZip(archivePath, { dir: outDir });
29
+ } else {
30
+ await extractTar({ file: archivePath, cwd: outDir });
31
+ }
32
+ }
33
+
34
+ export async function findBinaryInDir(dir, baseName, ext) {
35
+ const expected = `${baseName}${ext}`;
36
+ const direct = path.join(dir, expected);
37
+ try {
38
+ await stat(direct);
39
+ return direct;
40
+ } catch {
41
+ // walk one level
42
+ }
43
+ const { readdir } = await import("node:fs/promises");
44
+ const entries = await readdir(dir, { withFileTypes: true });
45
+ for (const e of entries) {
46
+ if (e.isDirectory()) {
47
+ const p = path.join(dir, e.name, expected);
48
+ try {
49
+ await stat(p);
50
+ return p;
51
+ } catch {
52
+ /* continue */
53
+ }
54
+ }
55
+ }
56
+ throw new Error(`Could not find ${expected} inside extracted archive (looked in ${dir})`);
57
+ }
58
+
59
+ export function tempDownloadPath(prefix) {
60
+ return path.join(tmpdir(), `${prefix}-${randomBytes(8).toString("hex")}`);
61
+ }
62
+
63
+ export async function ensureExecutable(filePath) {
64
+ if (process.platform === "win32") return;
65
+ const s = await stat(filePath);
66
+ await chmod(filePath, s.mode | 0o111);
67
+ }
package/lib/github.js ADDED
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Resolve download URL for a release asset from GitHub's API.
3
+ */
4
+ export async function getReleaseAssetUrl(repo, tag, assetName, token) {
5
+ const url = `https://api.github.com/repos/${repo}/releases/tags/${encodeURIComponent(tag)}`;
6
+ const headers = {
7
+ Accept: "application/vnd.github+json",
8
+ "X-GitHub-Api-Version": "2022-11-28",
9
+ "User-Agent": "moondust-npm-cli",
10
+ };
11
+ if (token) headers.Authorization = `Bearer ${token}`;
12
+
13
+ const res = await fetch(url, { headers });
14
+ if (res.status === 404) {
15
+ throw new Error(
16
+ `Release ${tag} not found for ${repo}. Publish a GitHub Release with that tag and matching assets.`,
17
+ );
18
+ }
19
+ if (!res.ok) {
20
+ const text = await res.text();
21
+ throw new Error(`GitHub API ${res.status}: ${text.slice(0, 500)}`);
22
+ }
23
+
24
+ const data = await res.json();
25
+ const assets = data.assets ?? [];
26
+ const match = assets.find((a) => a.name === assetName);
27
+ if (!match) {
28
+ const names = assets.map((a) => a.name).join(", ");
29
+ throw new Error(
30
+ `No asset named "${assetName}" on ${tag}. Available: ${names || "(none)"}`,
31
+ );
32
+ }
33
+ return match.browser_download_url;
34
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Maps Node's platform/arch to release asset names (see docs in repo root RELEASE_ASSETS.md).
3
+ */
4
+ export function getTargetTriple() {
5
+ const platform = process.platform;
6
+ const arch = process.arch;
7
+
8
+ if (platform === "win32") {
9
+ if (arch === "x64" || arch === "ia32") return { os: "windows", arch: "amd64", ext: ".exe" };
10
+ if (arch === "arm64") return { os: "windows", arch: "arm64", ext: ".exe" };
11
+ }
12
+ if (platform === "darwin") {
13
+ if (arch === "arm64") return { os: "darwin", arch: "arm64", ext: "" };
14
+ if (arch === "x64") return { os: "darwin", arch: "amd64", ext: "" };
15
+ }
16
+ if (platform === "linux") {
17
+ if (arch === "x64") return { os: "linux", arch: "amd64", ext: "" };
18
+ if (arch === "arm64") return { os: "linux", arch: "arm64", ext: "" };
19
+ }
20
+
21
+ throw new Error(
22
+ `Unsupported platform: ${platform} ${arch}. Build or download a binary for this OS manually.`,
23
+ );
24
+ }
25
+
26
+ export function assetBasename(version, triple) {
27
+ const v = version.replace(/^v/, "");
28
+ return `moondust_${v}_${triple.os}_${triple.arch}`;
29
+ }
package/package.json CHANGED
@@ -1,91 +1,30 @@
1
1
  {
2
- "name": "moondust",
3
- "version": "0.0.2",
4
- "description": "Moondust is a component library designed with many themes in mind and customizable props.",
5
- "license": "MIT",
6
- "author": "Zackary Santana",
7
- "contributors": [],
8
- "repository": {
9
- "type": "git",
10
- "url": "git+https://github.com/zackarysantana/moondust.git"
11
- },
12
- "homepage": "https://github.com/zackarysantana/moondust#readme",
13
- "bugs": {
14
- "url": "https://github.com/zackarysantana/moondust/issues"
15
- },
16
- "files": [
17
- "dist"
18
- ],
19
- "private": false,
20
- "sideEffects": false,
21
- "type": "module",
22
- "main": "./dist/index.js",
23
- "module": "./dist/index.js",
24
- "types": "./dist/index.d.ts",
25
- "browser": {},
26
- "exports": {
27
- "solid": {
28
- "development": "./dist/dev.jsx",
29
- "import": "./dist/index.jsx"
30
- },
31
- "development": {
32
- "import": {
33
- "types": "./dist/index.d.ts",
34
- "default": "./dist/dev.js"
35
- }
36
- },
37
- "import": {
38
- "types": "./dist/index.d.ts",
39
- "default": "./dist/index.js"
40
- }
41
- },
42
- "typesVersions": {},
43
- "scripts": {
44
- "dev": "vite serve dev",
45
- "build": "tsup",
46
- "test": "concurrently pnpm:test:*",
47
- "test:client": "vitest",
48
- "test:ssr": "pnpm run test:client --mode ssr",
49
- "prepublishOnly": "pnpm build",
50
- "format": "prettier --ignore-path .gitignore -w \"src/**/*.{js,ts,json,css,tsx,jsx}\" \"dev/**/*.{js,ts,json,css,tsx,jsx}\"",
51
- "lint": "concurrently pnpm:lint:*",
52
- "lint:code": "eslint --ignore-path .gitignore --max-warnings 0 src/**/*.{js,ts,tsx,jsx}",
53
- "lint:types": "tsc --noEmit",
54
- "update-deps": "pnpm up -Li"
55
- },
56
- "peerDependencies": {
57
- "solid-js": "^1.6.0"
58
- },
59
- "devDependencies": {
60
- "@types/node": "^20.12.12",
61
- "@typescript-eslint/eslint-plugin": "^7.9.0",
62
- "@typescript-eslint/parser": "^7.9.0",
63
- "class-variance-authority": "^0.7.0",
64
- "clsx": "^2.1.1",
65
- "concurrently": "^8.2.2",
66
- "esbuild": "^0.23.0",
67
- "esbuild-plugin-solid": "^0.6.0",
68
- "eslint": "^8.56.0",
69
- "eslint-plugin-eslint-comments": "^3.2.0",
70
- "eslint-plugin-no-only-tests": "^3.1.0",
71
- "jsdom": "^24.0.0",
72
- "prettier": "^3.3.3",
73
- "prettier-plugin-tailwindcss": "^0.6.5",
74
- "solid-js": "^1.8.17",
75
- "tailwind-merge": "^2.4.0",
76
- "tsup": "^8.0.2",
77
- "tsup-preset-solid": "^2.2.0",
78
- "typescript": "^5.4.5",
79
- "vite": "^5.2.11",
80
- "vite-plugin-solid": "^2.10.2",
81
- "vitest": "^2.0.2"
82
- },
83
- "keywords": [
84
- "solid"
85
- ],
86
- "packageManager": "pnpm@9.1.1",
87
- "engines": {
88
- "node": ">=18",
89
- "pnpm": ">=9.0.0"
90
- }
91
- }
2
+ "name": "moondust",
3
+ "version": "0.1.0",
4
+ "description": "Download and run the Moondust desktop app from GitHub Releases",
5
+ "type": "module",
6
+ "bin": {
7
+ "moondust": "bin/moondust.js"
8
+ },
9
+ "files": [
10
+ "bin",
11
+ "lib"
12
+ ],
13
+ "engines": {
14
+ "node": ">=18"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "https://github.com/zackarysantana/moondust.git"
19
+ },
20
+ "keywords": [
21
+ "moondust",
22
+ "desktop",
23
+ "launcher"
24
+ ],
25
+ "license": "MIT",
26
+ "dependencies": {
27
+ "extract-zip": "^2.0.1",
28
+ "tar": "^7.4.3"
29
+ }
30
+ }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2022 {{me}}
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.