@abhraneeldhar7/xommit 2.0.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/config.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "xommit",
3
+ "version": "1.2",
4
+ "github": "https://github.com/abhraneeldhar7/xommit",
5
+ "website": "https://xommit.antk.in",
6
+ "assets": {
7
+ "win32": "xommit.exe",
8
+ "linux": "xommit",
9
+ "darwin": "xommit-macos"
10
+ },
11
+ "binaries": {
12
+ "win32": "xommit.exe",
13
+ "linux": "xommit",
14
+ "darwin": "xommit-macos"
15
+ }
16
+ }
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@abhraneeldhar7/xommit",
3
+ "version": "2.0.0",
4
+ "description": "Vague messages into Conventional Commits using AI",
5
+ "main": "scripts/index.js",
6
+ "publishConfig": { "access": "public" },
7
+ "bin": {
8
+ "xommit": "scripts/index.js"
9
+ },
10
+ "files": ["scripts/index.js", "config.json"],
11
+ "scripts": {
12
+ "build": "node scripts/build.js"
13
+ },
14
+ "keywords": [
15
+ "git",
16
+ "commit",
17
+ "conventional-commits",
18
+ "cli",
19
+ "ai"
20
+ ],
21
+ "author": "abhraneeldhar@gmail.com",
22
+ "license": "MIT"
23
+ }
@@ -0,0 +1,80 @@
1
+ #!/usr/bin/env node
2
+
3
+ // scripts/index.js - npm shim
4
+ //
5
+ // Finds the C++ binary, downloads it from GitHub Releases if missing,
6
+ // then forwards all args to it.
7
+
8
+ const { execFileSync } = require("child_process");
9
+ const path = require("path");
10
+ const fs = require("fs");
11
+ const https = require("https");
12
+
13
+ const config = require("../config.json");
14
+
15
+ const REPO = config.github + "/releases/latest/download";
16
+
17
+ // Find binary for platform
18
+ const platform = process.platform;
19
+ let binary, asset;
20
+
21
+ if (config.assets[platform]) {
22
+ binary = path.join(__dirname, "..", "bin", config.binaries[platform]);
23
+ asset = config.assets[platform];
24
+ } else {
25
+ console.error("Unsupported platform: " + platform);
26
+ process.exit(1);
27
+ }
28
+
29
+ // Download binary from GitHub Releases if missing
30
+ function download() {
31
+ const url = REPO + "/" + asset;
32
+ const binDir = path.dirname(binary);
33
+
34
+ if (!fs.existsSync(binDir)) {
35
+ fs.mkdirSync(binDir, { recursive: true });
36
+ }
37
+
38
+ console.error("Downloading " + asset + " from GitHub Releases...");
39
+
40
+ return new Promise((resolve, reject) => {
41
+ https.get(url, { headers: { "User-Agent": "xommit" } }, (res) => {
42
+ if (res.statusCode === 302 || res.statusCode === 301) {
43
+ https.get(res.headers.location, (res2) => {
44
+ const file = fs.createWriteStream(binary);
45
+ res2.pipe(file);
46
+ file.on("finish", () => { file.close(); resolve(); });
47
+ }).on("error", reject);
48
+ } else if (res.statusCode === 200) {
49
+ const file = fs.createWriteStream(binary);
50
+ res.pipe(file);
51
+ file.on("finish", () => { file.close(); resolve(); });
52
+ } else {
53
+ reject(new Error("Download failed: HTTP " + res.statusCode));
54
+ }
55
+ }).on("error", reject);
56
+ });
57
+ }
58
+
59
+ async function main() {
60
+ if (!fs.existsSync(binary)) {
61
+ try {
62
+ await download();
63
+ if (platform !== "win32") {
64
+ fs.chmodSync(binary, 0o755);
65
+ }
66
+ } catch (err) {
67
+ console.error("Failed to download binary: " + err.message);
68
+ console.error("Download manually from: " + REPO);
69
+ process.exit(1);
70
+ }
71
+ }
72
+
73
+ try {
74
+ execFileSync(binary, process.argv.slice(2), { stdio: "inherit" });
75
+ } catch (err) {
76
+ process.exit(err.status !== undefined ? err.status : 1);
77
+ }
78
+ }
79
+
80
+ main();