@aiyiran/myclaw 1.0.14 → 1.0.16
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/wsl2.js +41 -16
package/package.json
CHANGED
package/wsl2.js
CHANGED
|
@@ -41,10 +41,20 @@ const C = isWindows
|
|
|
41
41
|
// ============================================================================
|
|
42
42
|
|
|
43
43
|
function launchElevatedPS(script) {
|
|
44
|
-
const
|
|
44
|
+
const fs = require('fs');
|
|
45
|
+
const path = require('path');
|
|
46
|
+
|
|
47
|
+
// 把脚本写到临时文件(避免 Windows 命令行长度限制)
|
|
48
|
+
const tmpDir = process.env.LOCALAPPDATA
|
|
49
|
+
? path.join(process.env.LOCALAPPDATA, 'myclaw')
|
|
50
|
+
: path.join(os.tmpdir(), 'myclaw');
|
|
51
|
+
try { fs.mkdirSync(tmpDir, { recursive: true }); } catch {}
|
|
52
|
+
const scriptPath = path.join(tmpDir, 'wsl2_installer.ps1');
|
|
53
|
+
fs.writeFileSync(scriptPath, script, 'utf8');
|
|
54
|
+
|
|
45
55
|
try {
|
|
46
56
|
execSync(
|
|
47
|
-
`powershell -Command "Start-Process powershell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -
|
|
57
|
+
`powershell -Command "Start-Process powershell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File \\"${scriptPath}\\"' -Verb RunAs"`,
|
|
48
58
|
{ stdio: 'inherit' }
|
|
49
59
|
);
|
|
50
60
|
return true;
|
|
@@ -94,9 +104,7 @@ if (-Not $userInput) {
|
|
|
94
104
|
Write-Host ' 下载完成!'
|
|
95
105
|
} catch {
|
|
96
106
|
Write-Host ' [失败] 下载失败,请检查网络后重试 myclaw wsl2'
|
|
97
|
-
|
|
98
|
-
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
|
|
99
|
-
exit 1
|
|
107
|
+
throw '下载失败'
|
|
100
108
|
}
|
|
101
109
|
} else {
|
|
102
110
|
Write-Host ' 使用上次缓存的文件'
|
|
@@ -149,6 +157,7 @@ function runPhase1() {
|
|
|
149
157
|
const ps = `
|
|
150
158
|
$ErrorActionPreference = 'Continue'
|
|
151
159
|
$Host.UI.RawUI.WindowTitle = 'MyClaw WSL2 Installer - Phase 1'
|
|
160
|
+
try {
|
|
152
161
|
Write-Host ''
|
|
153
162
|
Write-Host '========================================'
|
|
154
163
|
Write-Host ' MyClaw WSL2 安装 - 阶段 1/2'
|
|
@@ -196,10 +205,7 @@ ${askMsi}
|
|
|
196
205
|
Start-Process msiexec.exe -ArgumentList "/i \`"$msi\`" /quiet /norestart" -Wait -NoNewWindow
|
|
197
206
|
Write-Host ' [OK]'
|
|
198
207
|
} catch {
|
|
199
|
-
Write-Host ' [失败]'
|
|
200
|
-
Write-Host ''; Write-Host '按任意键关闭...'
|
|
201
|
-
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
|
|
202
|
-
exit 1
|
|
208
|
+
Write-Host ' [失败] 安装出错'
|
|
203
209
|
}
|
|
204
210
|
}
|
|
205
211
|
|
|
@@ -211,9 +217,18 @@ Write-Host ' >>> 请立即 [重启电脑] <<<'
|
|
|
211
217
|
Write-Host ''
|
|
212
218
|
Write-Host ' 重启后运行: myclaw wsl2'
|
|
213
219
|
Write-Host '========================================'
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
220
|
+
|
|
221
|
+
} catch {
|
|
222
|
+
Write-Host ''
|
|
223
|
+
Write-Host '========================================'
|
|
224
|
+
Write-Host " [异常] 发生错误: $_"
|
|
225
|
+
Write-Host ' 请截图此窗口内容后联系老师'
|
|
226
|
+
Write-Host '========================================'
|
|
227
|
+
} finally {
|
|
228
|
+
Write-Host ''
|
|
229
|
+
Write-Host '按任意键关闭此窗口...'
|
|
230
|
+
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
|
|
231
|
+
}
|
|
217
232
|
`;
|
|
218
233
|
|
|
219
234
|
if (launchElevatedPS(ps)) {
|
|
@@ -248,11 +263,12 @@ function runPhase2() {
|
|
|
248
263
|
const ps = `
|
|
249
264
|
$ErrorActionPreference = 'Continue'
|
|
250
265
|
$Host.UI.RawUI.WindowTitle = 'MyClaw WSL2 Installer - Phase 2'
|
|
266
|
+
try {
|
|
251
267
|
Write-Host ''
|
|
252
268
|
Write-Host '========================================'
|
|
253
269
|
Write-Host ' MyClaw WSL2 安装 - 阶段 2/2'
|
|
254
270
|
Write-Host ' 导入预制 Linux 环境'
|
|
255
|
-
Write-Host '========================================'
|
|
271
|
+
Write-Host '========================================'
|
|
256
272
|
Write-Host ''
|
|
257
273
|
|
|
258
274
|
$dir = "$env:LOCALAPPDATA\\myclaw"
|
|
@@ -304,9 +320,18 @@ if ($installed) {
|
|
|
304
320
|
Write-Host ' [失败] 请检查后重试: myclaw wsl2'
|
|
305
321
|
}
|
|
306
322
|
Write-Host '========================================'
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
323
|
+
|
|
324
|
+
} catch {
|
|
325
|
+
Write-Host ''
|
|
326
|
+
Write-Host '========================================'
|
|
327
|
+
Write-Host " [异常] 发生错误: $_"
|
|
328
|
+
Write-Host ' 请截图此窗口内容后联系老师'
|
|
329
|
+
Write-Host '========================================'
|
|
330
|
+
} finally {
|
|
331
|
+
Write-Host ''
|
|
332
|
+
Write-Host '按任意键关闭此窗口...'
|
|
333
|
+
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
|
|
334
|
+
}
|
|
310
335
|
`;
|
|
311
336
|
|
|
312
337
|
if (launchElevatedPS(ps)) {
|