@ai-git/cli 0.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/bin/ai-git +39 -0
- package/package.json +35 -0
- package/scripts/postinstall.js +67 -0
package/bin/ai-git
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { execFileSync } = require("child_process");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const os = require("os");
|
|
6
|
+
|
|
7
|
+
const PLATFORMS = {
|
|
8
|
+
darwin: { arm64: "@ai-git/darwin-arm64", x64: "@ai-git/darwin-x64" },
|
|
9
|
+
linux: { arm64: "@ai-git/linux-arm64", x64: "@ai-git/linux-x64" },
|
|
10
|
+
win32: { x64: "@ai-git/win32-x64" },
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const platformPkgs = PLATFORMS[os.platform()];
|
|
14
|
+
if (!platformPkgs) {
|
|
15
|
+
console.error(`Unsupported platform: ${os.platform()}-${os.arch()}`);
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const pkg = platformPkgs[os.arch()];
|
|
20
|
+
if (!pkg) {
|
|
21
|
+
console.error(`Unsupported architecture: ${os.platform()}-${os.arch()}`);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const ext = os.platform() === "win32" ? ".exe" : "";
|
|
26
|
+
const bin = path.join(
|
|
27
|
+
path.dirname(require.resolve(`${pkg}/package.json`)),
|
|
28
|
+
"bin",
|
|
29
|
+
`ai-git${ext}`,
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
execFileSync(bin, process.argv.slice(2), { stdio: "inherit" });
|
|
34
|
+
} catch (e) {
|
|
35
|
+
if (e && typeof e === "object" && "status" in e) {
|
|
36
|
+
process.exit(e.status);
|
|
37
|
+
}
|
|
38
|
+
throw e;
|
|
39
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ai-git/cli",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "AI-powered git commit message generator",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/sadiksaifi/ai-git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://ai-git.xyz",
|
|
11
|
+
"bin": {
|
|
12
|
+
"ai-git": "bin/ai-git"
|
|
13
|
+
},
|
|
14
|
+
"optionalDependencies": {
|
|
15
|
+
"@ai-git/darwin-arm64": "0.0.0",
|
|
16
|
+
"@ai-git/darwin-x64": "0.0.0",
|
|
17
|
+
"@ai-git/linux-arm64": "0.0.0",
|
|
18
|
+
"@ai-git/linux-x64": "0.0.0",
|
|
19
|
+
"@ai-git/win32-x64": "0.0.0"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"postinstall": "node scripts/postinstall.js"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"bin/",
|
|
26
|
+
"scripts/"
|
|
27
|
+
],
|
|
28
|
+
"keywords": [
|
|
29
|
+
"git",
|
|
30
|
+
"ai",
|
|
31
|
+
"commit",
|
|
32
|
+
"conventional-commits",
|
|
33
|
+
"cli"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
const os = require("os");
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
|
|
5
|
+
const PLATFORMS = {
|
|
6
|
+
darwin: { arm64: "@ai-git/darwin-arm64", x64: "@ai-git/darwin-x64" },
|
|
7
|
+
linux: { arm64: "@ai-git/linux-arm64", x64: "@ai-git/linux-x64" },
|
|
8
|
+
win32: { x64: "@ai-git/win32-x64" },
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// Write install method marker
|
|
12
|
+
function writeMarker() {
|
|
13
|
+
try {
|
|
14
|
+
const isWindows = os.platform() === "win32";
|
|
15
|
+
let stateDir;
|
|
16
|
+
if (isWindows) {
|
|
17
|
+
const base = process.env.LOCALAPPDATA || path.join(os.homedir(), "AppData", "Local");
|
|
18
|
+
stateDir = path.join(base, "ai-git", "state");
|
|
19
|
+
} else {
|
|
20
|
+
const base = process.env.XDG_STATE_HOME || path.join(os.homedir(), ".local", "state");
|
|
21
|
+
stateDir = path.join(base, "ai-git");
|
|
22
|
+
}
|
|
23
|
+
fs.mkdirSync(stateDir, { recursive: true });
|
|
24
|
+
fs.writeFileSync(path.join(stateDir, "install-method"), "npm");
|
|
25
|
+
} catch {
|
|
26
|
+
// Non-critical — silent fail
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Check if platform binary is available
|
|
31
|
+
function checkBinary() {
|
|
32
|
+
const platformPkgs = PLATFORMS[os.platform()];
|
|
33
|
+
if (!platformPkgs) return false;
|
|
34
|
+
|
|
35
|
+
const pkg = platformPkgs[os.arch()];
|
|
36
|
+
if (!pkg) return false;
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
require.resolve(`${pkg}/package.json`);
|
|
40
|
+
return true;
|
|
41
|
+
} catch {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function main() {
|
|
47
|
+
if (checkBinary()) {
|
|
48
|
+
writeMarker();
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Platform binary not found (e.g., --ignore-optional was used)
|
|
53
|
+
// Provide guidance rather than silently failing
|
|
54
|
+
console.warn(
|
|
55
|
+
`\nai-git: Platform binary not found for ${os.platform()}-${os.arch()}.`,
|
|
56
|
+
);
|
|
57
|
+
console.warn(
|
|
58
|
+
"If you used --ignore-optional, the platform package was skipped.",
|
|
59
|
+
);
|
|
60
|
+
console.warn(
|
|
61
|
+
"You can install the binary manually: curl -fsSL https://ai-git.xyz/install | bash\n",
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
writeMarker();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
main();
|