@chathost/mcp-uat 1.1.0 → 1.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/package.json +5 -5
- package/postinstall.js +92 -0
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chathost/mcp-uat",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "chathost.io MCP server - deploy websites from your AI agent",
|
|
5
5
|
"bin": { "chathost-mcp": "index.js" },
|
|
6
6
|
"scripts": {
|
|
7
7
|
"postinstall": "node postinstall.js"
|
|
8
8
|
},
|
|
9
9
|
"optionalDependencies": {
|
|
10
|
-
"@chathost/mcp-uat-linux-x64": "1.1.
|
|
11
|
-
"@chathost/mcp-uat-darwin-arm64": "1.1.
|
|
12
|
-
"@chathost/mcp-uat-darwin-x64": "1.1.
|
|
13
|
-
"@chathost/mcp-uat-win-x64": "1.1.
|
|
10
|
+
"@chathost/mcp-uat-linux-x64": "1.1.1",
|
|
11
|
+
"@chathost/mcp-uat-darwin-arm64": "1.1.1",
|
|
12
|
+
"@chathost/mcp-uat-darwin-x64": "1.1.1",
|
|
13
|
+
"@chathost/mcp-uat-win-x64": "1.1.1"
|
|
14
14
|
},
|
|
15
15
|
"files": ["index.js", "postinstall.js", "env.json", "README.md", "server.json"],
|
|
16
16
|
"license": "MIT",
|
package/postinstall.js
CHANGED
|
@@ -9,11 +9,13 @@
|
|
|
9
9
|
* 1. Creates the ~/.chathost directory tree (bin, cache, logs, img-state)
|
|
10
10
|
* 2. Copies the platform binary to ~/.chathost/bin/chathost
|
|
11
11
|
* 3. Writes ~/.chathost/env (API + website URLs for the environment)
|
|
12
|
+
* 4. Adds ~/.chathost/bin to the shell PATH (bashrc/zshrc/profile or Windows user PATH)
|
|
12
13
|
*/
|
|
13
14
|
|
|
14
15
|
const fs = require("fs");
|
|
15
16
|
const path = require("path");
|
|
16
17
|
const os = require("os");
|
|
18
|
+
const { execSync } = require("child_process");
|
|
17
19
|
|
|
18
20
|
// --- Skip in CI environments (no need for local setup) ---
|
|
19
21
|
if (process.env.CI === "true" || process.env.CI === "1") {
|
|
@@ -105,5 +107,95 @@ if (fs.existsSync(envJsonPath)) {
|
|
|
105
107
|
} catch { /* skip on parse error */ }
|
|
106
108
|
}
|
|
107
109
|
|
|
110
|
+
// ──────────────────────────────────────────────
|
|
111
|
+
// 4. Add ~/.chathost/bin to shell PATH
|
|
112
|
+
// ──────────────────────────────────────────────
|
|
113
|
+
if (process.platform === "win32") {
|
|
114
|
+
ensurePathWindows(binDir);
|
|
115
|
+
} else {
|
|
116
|
+
ensurePathUnix();
|
|
117
|
+
}
|
|
118
|
+
|
|
108
119
|
// --- Done ---
|
|
109
120
|
console.log("chathost: setup complete!");
|
|
121
|
+
|
|
122
|
+
// ──────────────────────────────────────────────
|
|
123
|
+
// PATH helpers
|
|
124
|
+
// ──────────────────────────────────────────────
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* (Unix / macOS) Appends an `export PATH` line to the user's shell RC file.
|
|
128
|
+
* Chooses the file based on $SHELL:
|
|
129
|
+
* zsh -> ~/.zshrc
|
|
130
|
+
* bash -> ~/.bashrc
|
|
131
|
+
* * -> ~/.profile
|
|
132
|
+
* Idempotent — skips if ~/.chathost/bin is already referenced.
|
|
133
|
+
*/
|
|
134
|
+
function ensurePathUnix() {
|
|
135
|
+
const shell = (process.env.SHELL || "").split("/").pop();
|
|
136
|
+
|
|
137
|
+
let rcFile;
|
|
138
|
+
switch (shell) {
|
|
139
|
+
case "zsh":
|
|
140
|
+
rcFile = path.join(home, ".zshrc");
|
|
141
|
+
break;
|
|
142
|
+
case "bash":
|
|
143
|
+
rcFile = path.join(home, ".bashrc");
|
|
144
|
+
break;
|
|
145
|
+
default:
|
|
146
|
+
rcFile = path.join(home, ".profile");
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const marker = ".chathost/bin";
|
|
151
|
+
const block = [
|
|
152
|
+
"",
|
|
153
|
+
"# Added by chathost (https://chathost.io)",
|
|
154
|
+
'export PATH="$HOME/.chathost/bin:$PATH"',
|
|
155
|
+
"",
|
|
156
|
+
].join("\n");
|
|
157
|
+
|
|
158
|
+
let content = "";
|
|
159
|
+
try {
|
|
160
|
+
content = fs.readFileSync(rcFile, "utf-8");
|
|
161
|
+
} catch { /* file doesn't exist yet */ }
|
|
162
|
+
|
|
163
|
+
if (content.includes(marker)) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
fs.appendFileSync(rcFile, block);
|
|
168
|
+
console.log(`chathost: added ~/.chathost/bin to PATH in ${rcFile}`);
|
|
169
|
+
console.log(`chathost: restart your shell or run: source ${rcFile}`);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* (Windows) Adds binDir to the persistent user-level PATH via PowerShell.
|
|
174
|
+
* Idempotent — skips if the directory is already present (case-insensitive).
|
|
175
|
+
*/
|
|
176
|
+
function ensurePathWindows(dir) {
|
|
177
|
+
try {
|
|
178
|
+
const raw = execSync(
|
|
179
|
+
"powershell.exe -NoProfile -Command \"[Environment]::GetEnvironmentVariable('Path','User')\"",
|
|
180
|
+
{ encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] },
|
|
181
|
+
).trim();
|
|
182
|
+
|
|
183
|
+
const entries = raw.split(";").filter(Boolean);
|
|
184
|
+
if (entries.some((e) => e.toLowerCase() === dir.toLowerCase())) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const updated = raw ? `${dir};${raw}` : dir;
|
|
189
|
+
const escaped = updated.replace(/'/g, "''");
|
|
190
|
+
execSync(
|
|
191
|
+
`powershell.exe -NoProfile -Command "[Environment]::SetEnvironmentVariable('Path','${escaped}','User')"`,
|
|
192
|
+
{ encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] },
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
console.log(`chathost: added ${dir} to user PATH`);
|
|
196
|
+
console.log("chathost: restart your terminal for PATH changes to take effect");
|
|
197
|
+
} catch {
|
|
198
|
+
console.log("chathost: could not update PATH automatically — please add the following to your PATH manually:");
|
|
199
|
+
console.log(` ${dir}`);
|
|
200
|
+
}
|
|
201
|
+
}
|