@remcp/remcp 0.2.229 → 0.2.230
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 +1 -1
- package/src/cli/windows-cli-shim.mjs +36 -2
package/package.json
CHANGED
|
@@ -5,6 +5,41 @@
|
|
|
5
5
|
import fs from 'node:fs';
|
|
6
6
|
import path from 'node:path';
|
|
7
7
|
|
|
8
|
+
// Exact npm cmd-shim template; partial markers cannot establish ownership.
|
|
9
|
+
export const WINDOWS_NPM_POWERSHELL_SHIM = String.raw`#!/usr/bin/env pwsh
|
|
10
|
+
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
|
11
|
+
|
|
12
|
+
$exe=""
|
|
13
|
+
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
|
14
|
+
# Fix case when both the Windows and Linux builds of Node
|
|
15
|
+
# are installed in the same directory
|
|
16
|
+
$exe=".exe"
|
|
17
|
+
}
|
|
18
|
+
$ret=0
|
|
19
|
+
if (Test-Path "$basedir/node$exe") {
|
|
20
|
+
# Support pipeline input
|
|
21
|
+
if ($MyInvocation.ExpectingInput) {
|
|
22
|
+
$input | & "$basedir/node$exe" "$basedir/node_modules/@remcp/remcp/bin/remcp.mjs" $args
|
|
23
|
+
} else {
|
|
24
|
+
& "$basedir/node$exe" "$basedir/node_modules/@remcp/remcp/bin/remcp.mjs" $args
|
|
25
|
+
}
|
|
26
|
+
$ret=$LASTEXITCODE
|
|
27
|
+
} else {
|
|
28
|
+
# Support pipeline input
|
|
29
|
+
if ($MyInvocation.ExpectingInput) {
|
|
30
|
+
$input | & "node$exe" "$basedir/node_modules/@remcp/remcp/bin/remcp.mjs" $args
|
|
31
|
+
} else {
|
|
32
|
+
& "node$exe" "$basedir/node_modules/@remcp/remcp/bin/remcp.mjs" $args
|
|
33
|
+
}
|
|
34
|
+
$ret=$LASTEXITCODE
|
|
35
|
+
}
|
|
36
|
+
exit $ret
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
function normalizedShim(text) {
|
|
40
|
+
return text.replace(/^\uFEFF/, '').replace(/\r\n/g, '\n').replace(/\n+$/, '');
|
|
41
|
+
}
|
|
42
|
+
|
|
8
43
|
export function assertWindowsNpmPowerShellShimOwned(prefix) {
|
|
9
44
|
const powershell = path.join(prefix, 'remcp.ps1');
|
|
10
45
|
let metadata;
|
|
@@ -14,8 +49,7 @@ export function assertWindowsNpmPowerShellShimOwned(prefix) {
|
|
|
14
49
|
throw new Error('Refusing to replace an unknown ReMCP PowerShell launcher');
|
|
15
50
|
}
|
|
16
51
|
const contents = fs.readFileSync(powershell, 'utf8');
|
|
17
|
-
if (contents.length > 16000 ||
|
|
18
|
-
|| !contents.includes('$basedir/node_modules/@remcp/remcp/bin/remcp.mjs')) {
|
|
52
|
+
if (contents.length > 16000 || normalizedShim(contents) !== normalizedShim(WINDOWS_NPM_POWERSHELL_SHIM)) {
|
|
19
53
|
throw new Error('Refusing to remove a non-npm ReMCP PowerShell launcher');
|
|
20
54
|
}
|
|
21
55
|
return true;
|