@zeronium/zeronium-cli-lin-arm64 0.2.4 → 0.2.6

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/bun-linux-arm64 CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeronium/zeronium-cli-lin-arm64",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "A CLI tool for managing all your development projects",
5
5
  "license": "MIT",
6
6
  "os": [
@@ -14,5 +14,8 @@
14
14
  "zero": "./bun-linux-arm64"
15
15
  },
16
16
  "preferGlobal": true,
17
- "private": false
17
+ "private": false,
18
+ "scripts": {
19
+ "postinstall": "echo 'Runnin postinstall script' && node scripts/jump-function-setup.js"
20
+ }
18
21
  }
@@ -0,0 +1,90 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import os from "node:os";
4
+ import { execSync } from "node:child_process";
5
+ import readline from "node:readline/promises"; // Use the promise-based API
6
+ import { stdin as input, stdout as output } from "node:process";
7
+
8
+ const BASH_CODE = `
9
+ # Zero CLI Jump Function
10
+ zero() {
11
+ if [ "$1" = "jump" ]; then
12
+ DEST=$(command zero jump "$2")
13
+ if [ $? -eq 0 ] && [ -n "$DEST" ]; then
14
+ cd "$DEST"
15
+ fi
16
+ else
17
+ command zero "$@"
18
+ fi
19
+ }
20
+ `;
21
+
22
+ const PWSH_CODE = `
23
+ # Zero CLI Jump Function
24
+ function zero {
25
+ $zeroExe = (Get-Command zero -CommandType Application -ErrorAction SilentlyContinue).Source
26
+ if (!$zeroExe) { return }
27
+ if ($args[0] -eq "jump") {
28
+ $dest = & $zeroExe jump $args[1]
29
+ if ($LASTEXITCODE -eq 0 -and ![string]::IsNullOrWhiteSpace($dest)) {
30
+ Set-Location $dest
31
+ }
32
+ } else {
33
+ & $zeroExe @args
34
+ }
35
+ }
36
+ `;
37
+
38
+ async function setup() {
39
+ console.log("\n--- Zero CLI Setup ---");
40
+
41
+ if (!process.stdout.isTTY) {
42
+ console.log("Non-interactive terminal. Skipping setup.");
43
+ return;
44
+ }
45
+
46
+ const rl = readline.createInterface({ input, output });
47
+ const answer = await rl.question(
48
+ "Add 'zero jump' to your shell profile? (y/n): ",
49
+ );
50
+ rl.close();
51
+
52
+ if (answer.toLowerCase() !== "y") {
53
+ console.log("Setup skipped.\n");
54
+ return;
55
+ }
56
+
57
+ const isWindows = process.platform === "win32";
58
+
59
+ if (isWindows) {
60
+ try {
61
+ const profilePath = execSync(
62
+ 'powershell -NoProfile -Command "echo $PROFILE"',
63
+ )
64
+ .toString()
65
+ .trim();
66
+ appendToFile(profilePath, PWSH_CODE);
67
+ } catch (e) {
68
+ console.error("Could not locate PowerShell profile.");
69
+ }
70
+ } else {
71
+ const home = os.homedir();
72
+ [path.join(home, ".zshrc"), path.join(home, ".bashrc")].forEach(
73
+ (file) => {
74
+ if (fs.existsSync(file)) appendToFile(file, BASH_CODE);
75
+ },
76
+ );
77
+ }
78
+ }
79
+
80
+ function appendToFile(filePath, code) {
81
+ const content = fs.existsSync(filePath)
82
+ ? fs.readFileSync(filePath, "utf8")
83
+ : "";
84
+ if (!content.includes("Zero CLI Jump Function")) {
85
+ fs.appendFileSync(filePath, `\n${code}\n`);
86
+ console.log(`✅ Updated: ${filePath}`);
87
+ }
88
+ }
89
+
90
+ setup();