@aigtc/cli 0.1.1

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