@baitong-dev/mcp-helpers 0.0.1 → 0.0.2

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/dist/process.d.ts CHANGED
@@ -17,18 +17,11 @@ export declare function findGitBash(customPath?: string | null): string | null;
17
17
  * @param name Binary Name
18
18
  * @returns Whether the binary exists
19
19
  */
20
- export declare function isBinaryExists(name: string): boolean;
20
+ export declare function isBundledBinaryExists(name: string): boolean;
21
21
  /**
22
22
  * Get full path to a bundled binary
23
23
  * @param name Binary Name
24
24
  * @returns Full path to the binary
25
25
  */
26
26
  export declare function getBundledBinaryPath(name?: string): string;
27
- export declare function getBinaryEnvs(): {
28
- PATH: string;
29
- NODE: string;
30
- npm_config_globalconfig: string;
31
- npm_config_global_prefix: string;
32
- npm_config_prefix: string;
33
- npm_node_execpath: string;
34
- };
27
+ export declare function getBundledBinaryEnvs(): Record<string, string>;
package/dist/process.js CHANGED
@@ -7,9 +7,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.windowsToGitBashPath = windowsToGitBashPath;
8
8
  exports.gitBashToWindowsPath = gitBashToWindowsPath;
9
9
  exports.findGitBash = findGitBash;
10
- exports.isBinaryExists = isBinaryExists;
10
+ exports.isBundledBinaryExists = isBundledBinaryExists;
11
11
  exports.getBundledBinaryPath = getBundledBinaryPath;
12
- exports.getBinaryEnvs = getBinaryEnvs;
12
+ exports.getBundledBinaryEnvs = getBundledBinaryEnvs;
13
13
  const path_1 = __importDefault(require("path"));
14
14
  const config_1 = require("./config");
15
15
  const fs_1 = __importDefault(require("fs"));
@@ -127,7 +127,10 @@ function findGitBash(customPath) {
127
127
  * @param name Binary Name
128
128
  * @returns Binary Name with .exe extension on Windows
129
129
  */
130
- function getBinaryName(name) {
130
+ function getBundledBinaryName(name) {
131
+ if (name === 'ripgrep') {
132
+ name = 'rg';
133
+ }
131
134
  if (process.platform == 'win32') {
132
135
  if (['npm', 'npx'].includes(name)) {
133
136
  return name;
@@ -141,7 +144,7 @@ function getBinaryName(name) {
141
144
  * @param name Binary Name
142
145
  * @returns Whether the binary exists
143
146
  */
144
- function isBinaryExists(name) {
147
+ function isBundledBinaryExists(name) {
145
148
  const cmd = getBundledBinaryPath(name);
146
149
  return Bun.file(cmd).size > 0;
147
150
  }
@@ -155,7 +158,7 @@ function getBundledBinaryPath(name) {
155
158
  if (!name) {
156
159
  return binariesDir;
157
160
  }
158
- const binaryName = getBinaryName(name);
161
+ const binaryName = getBundledBinaryName(name);
159
162
  const binariesDirExists = fs_1.default.existsSync(binariesDir);
160
163
  if (binariesDirExists) {
161
164
  if (['git', 'bash', 'sh'].includes(name)) {
@@ -166,28 +169,32 @@ function getBundledBinaryPath(name) {
166
169
  // Node.js binaries are in a subdirectory
167
170
  return path_1.default.join(binariesDir, 'node', binaryName);
168
171
  }
169
- if (['python', 'python3'].includes(name)) {
172
+ if (['python'].includes(name)) {
170
173
  // Python binaries are in a subdirectory
171
174
  return path_1.default.join(binariesDir, 'python', binaryName);
172
175
  }
173
176
  if (['pip', 'pip3'].includes(name)) {
174
- // pip binaries are in a subdirectory
177
+ // Python binaries are in a subdirectory
175
178
  return path_1.default.join(binariesDir, 'python/Scripts', binaryName);
176
179
  }
180
+ if (['rg', 'ripgrep'].includes(name)) {
181
+ // ripgrep binaries are in a subdirectory
182
+ return path_1.default.join(binariesDir, 'ripgrep', binaryName);
183
+ }
177
184
  return path_1.default.join(binariesDir, binaryName);
178
185
  }
179
186
  return binaryName;
180
187
  }
181
- function getBinaryEnvs() {
188
+ function getBundledBinaryEnvs() {
182
189
  const binariesDir = getBundledBinaryPath();
183
- const envPaths = process.env?.path?.split(';') || [];
190
+ const envPaths = process.env?.PATH?.split(';') || [];
184
191
  envPaths.unshift(binariesDir); // bun uv uvx
185
192
  envPaths.unshift(path_1.default.join(binariesDir, 'node')); // node
186
193
  envPaths.unshift(path_1.default.join(binariesDir, 'python')); // python
187
194
  envPaths.unshift(path_1.default.join(binariesDir, 'python/Scripts')); // pip
188
195
  const nodePath = getBundledBinaryPath('node');
189
196
  const nodeDir = path_1.default.join(nodePath, '..');
190
- return {
197
+ const envs = {
191
198
  PATH: envPaths.join(';'),
192
199
  NODE: nodePath,
193
200
  npm_config_globalconfig: path_1.default.join(nodeDir, 'etc', 'npmrc'),
@@ -195,4 +202,20 @@ function getBinaryEnvs() {
195
202
  npm_config_prefix: nodeDir,
196
203
  npm_node_execpath: nodePath
197
204
  };
205
+ const MORE_ENV_VARS = [
206
+ 'BUN_TMPDIR',
207
+ 'BUN_INSTALL',
208
+ 'NPM_CONFIG_REGISTRY',
209
+ 'UV_PYTHON_INSTALL_MIRROR',
210
+ 'UV_DEFAULT_INDEX',
211
+ 'PIP_INDEX_URL'
212
+ ];
213
+ for (const key of MORE_ENV_VARS) {
214
+ const value = process.env[key];
215
+ if (value === undefined) {
216
+ continue;
217
+ }
218
+ envs[key] = value;
219
+ }
220
+ return envs;
198
221
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baitong-dev/mcp-helpers",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "main": "./dist/index.js",
5
5
  "files": [
6
6
  "dist",