@szc-ft/mcp-szcd-client 0.32.0 → 0.32.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
CHANGED
|
@@ -103,24 +103,33 @@ function installWindows(browser) {
|
|
|
103
103
|
const lnkPath = path.join(desktop, `${browser.name} DevSession.lnk`);
|
|
104
104
|
|
|
105
105
|
// PowerShell 创建 .lnk
|
|
106
|
-
// 注意:
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
`$s
|
|
111
|
-
`$s.
|
|
112
|
-
`$s.
|
|
113
|
-
`$s.
|
|
106
|
+
// 注意:Arguments 字符串里含 "C:/..." 这种裸双引号;为彻底避开 shell 引号嵌套,
|
|
107
|
+
// 用 PowerShell -EncodedCommand:脚本块以 UTF-16LE 序列化后 base64 传入,
|
|
108
|
+
// 不再依赖 cmd / bash 的引号转义规则。
|
|
109
|
+
const psScript = [
|
|
110
|
+
`$s = (New-Object -ComObject WScript.Shell).CreateShortcut([System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('${b64utf8(lnkPath)}')))`,
|
|
111
|
+
`$s.TargetPath = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('${b64utf8(browser.exe)}'))`,
|
|
112
|
+
`$s.Arguments = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('${b64utf8(args)}'))`,
|
|
113
|
+
`$s.WorkingDirectory = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('${b64utf8(path.dirname(browser.exe))}'))`,
|
|
114
|
+
`$s.IconLocation = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('${b64utf8(browser.exe + ",0")}'))`,
|
|
115
|
+
`$s.Description = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('${b64utf8(browser.name + " CDP dev mode (port " + CDP_PORT + ") — used by szcd local-browser-test")}'))`,
|
|
114
116
|
`$s.Save()`,
|
|
115
117
|
].join("; ");
|
|
118
|
+
// -EncodedCommand 要求脚本块本身是 UTF-16LE base64
|
|
119
|
+
const encoded = Buffer.from(psScript, "utf16le").toString("base64");
|
|
116
120
|
try {
|
|
117
|
-
execSync(`powershell -NoProfile -ExecutionPolicy Bypass -
|
|
121
|
+
execSync(`powershell -NoProfile -ExecutionPolicy Bypass -EncodedCommand ${encoded}`, { stdio: "ignore" });
|
|
118
122
|
return { ok: true, path: lnkPath };
|
|
119
123
|
} catch (e) {
|
|
120
124
|
return { ok: false, error: e.message };
|
|
121
125
|
}
|
|
122
126
|
}
|
|
123
127
|
|
|
128
|
+
// 字符串 → UTF-8 bytes → base64,给 PowerShell 内联反序列化用
|
|
129
|
+
function b64utf8(s) {
|
|
130
|
+
return Buffer.from(String(s), "utf8").toString("base64");
|
|
131
|
+
}
|
|
132
|
+
|
|
124
133
|
function installMac(browser) {
|
|
125
134
|
const dataDir = getUserDataDir(browser.id, "darwin");
|
|
126
135
|
const appDir = path.join(os.homedir(), "Applications");
|