@unerr-ai/unerr 0.1.1 → 0.1.3
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 +14 -1
- package/dist/cli.js +1656 -1203
- package/package.json +1 -1
- package/scripts/postinstall.mjs +29 -16
package/package.json
CHANGED
package/scripts/postinstall.mjs
CHANGED
|
@@ -30,8 +30,6 @@ const ci =
|
|
|
30
30
|
process.env.GITHUB_ACTIONS;
|
|
31
31
|
if (ci) process.exit(0);
|
|
32
32
|
|
|
33
|
-
if (!process.stderr.isTTY) process.exit(0);
|
|
34
|
-
|
|
35
33
|
const npmGlobal = process.env.npm_config_global;
|
|
36
34
|
if (npmGlobal !== undefined && npmGlobal !== "true") process.exit(0);
|
|
37
35
|
|
|
@@ -55,6 +53,19 @@ try {
|
|
|
55
53
|
}
|
|
56
54
|
if (!globalBin) process.exit(0);
|
|
57
55
|
|
|
56
|
+
// ANSI codes (use plain text if stderr is not a TTY)
|
|
57
|
+
const hasTTY = !!process.stderr.isTTY;
|
|
58
|
+
const W = hasTTY ? "\x1b[33m" : "";
|
|
59
|
+
const G = hasTTY ? "\x1b[32m" : "";
|
|
60
|
+
const B = hasTTY ? "\x1b[1m" : "";
|
|
61
|
+
const D = hasTTY ? "\x1b[2m" : "";
|
|
62
|
+
const R = hasTTY ? "\x1b[0m" : "";
|
|
63
|
+
const C = hasTTY ? "\x1b[36m" : "";
|
|
64
|
+
|
|
65
|
+
const stderr = (msg) => process.stderr.write(msg);
|
|
66
|
+
|
|
67
|
+
// ── Check PATH ───────────────────────────────────────────────
|
|
68
|
+
|
|
58
69
|
const pathSep = process.platform === "win32" ? ";" : ":";
|
|
59
70
|
const pathDirs = (process.env.PATH || "").split(pathSep);
|
|
60
71
|
const normalizedGlobalBin = globalBin.replace(/\/+$/, "");
|
|
@@ -62,7 +73,16 @@ const isOnPath = pathDirs.some(
|
|
|
62
73
|
(d) => d.replace(/\/+$/, "") === normalizedGlobalBin
|
|
63
74
|
);
|
|
64
75
|
|
|
65
|
-
if (isOnPath)
|
|
76
|
+
if (isOnPath) {
|
|
77
|
+
stderr(
|
|
78
|
+
`\n ${G}✓${R} ${B}unerr${R} is installed and ready to use.\n` +
|
|
79
|
+
` ${D}Run ${C}unerr${D} in any project to start.${R}\n\n`
|
|
80
|
+
);
|
|
81
|
+
process.exit(0);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// For the interactive warning/prompt, we need a TTY
|
|
85
|
+
if (!hasTTY) process.exit(0);
|
|
66
86
|
|
|
67
87
|
// ── Detect shell & version manager ──────────────────────────
|
|
68
88
|
|
|
@@ -72,16 +92,6 @@ const hasFnm = !!process.env.FNM_MULTISHELL_PATH;
|
|
|
72
92
|
const hasVolta = !!process.env.VOLTA_HOME;
|
|
73
93
|
const home = homedir();
|
|
74
94
|
|
|
75
|
-
// ANSI codes
|
|
76
|
-
const W = "\x1b[33m";
|
|
77
|
-
const G = "\x1b[32m";
|
|
78
|
-
const B = "\x1b[1m";
|
|
79
|
-
const D = "\x1b[2m";
|
|
80
|
-
const R = "\x1b[0m";
|
|
81
|
-
const C = "\x1b[36m";
|
|
82
|
-
|
|
83
|
-
const stderr = (msg) => process.stderr.write(msg);
|
|
84
|
-
|
|
85
95
|
// ── Shell RC helpers ─────────────────────────────────────────
|
|
86
96
|
|
|
87
97
|
function getRcPath() {
|
|
@@ -148,11 +158,14 @@ function getFixPayload() {
|
|
|
148
158
|
};
|
|
149
159
|
}
|
|
150
160
|
|
|
151
|
-
// Generic: direct PATH export
|
|
161
|
+
// Generic: direct PATH export — use $HOME instead of absolute home path for portability
|
|
162
|
+
const portableBin = normalizedGlobalBin.startsWith(home)
|
|
163
|
+
? normalizedGlobalBin.replace(home, "$HOME")
|
|
164
|
+
: normalizedGlobalBin;
|
|
152
165
|
const exportLine =
|
|
153
166
|
shell === "fish"
|
|
154
|
-
? `set -gx PATH ${
|
|
155
|
-
: `export PATH="${
|
|
167
|
+
? `set -gx PATH ${portableBin} $PATH`
|
|
168
|
+
: `export PATH="${portableBin}:$PATH"`;
|
|
156
169
|
|
|
157
170
|
return {
|
|
158
171
|
lines: ["", "# npm global bin (added by unerr postinstall)", exportLine],
|