@xcanwin/manyoyo 4.2.4 → 4.2.5

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.
Files changed (2) hide show
  1. package/lib/image-build.js +22 -6
  2. package/package.json +1 -1
@@ -152,21 +152,32 @@ function cleanupGoTmpPath(ctx, tmpGoPath, warnOnError) {
152
152
  const { YELLOW, NC } = ctx.colors;
153
153
  if (!fs.existsSync(tmpGoPath)) return;
154
154
 
155
+ let cleanupFailed = false;
155
156
  try {
156
157
  ctx.runCmd('go', ['clean', '-modcache'], {
157
158
  stdio: 'inherit',
158
159
  ignoreError: true,
159
160
  env: { ...process.env, GOPATH: tmpGoPath }
160
161
  });
161
- ctx.runCmd('chmod', ['-R', 'u+w', tmpGoPath], { stdio: 'inherit', ignoreError: true });
162
- ctx.runCmd('rm', ['-rf', tmpGoPath], { stdio: 'inherit', ignoreError: true });
163
- } catch (e) {
164
- if (warnOnError) {
165
- ctx.log(`${YELLOW}提示: 临时目录清理失败,可手动删除 ${tmpGoPath}${NC}`);
166
- }
162
+ } catch (e) { cleanupFailed = true; }
163
+ try { ctx.runCmd('chmod', ['-R', 'u+w', tmpGoPath], { stdio: 'inherit', ignoreError: true }); } catch (e) { cleanupFailed = true; }
164
+ try { ctx.runCmd('rm', ['-rf', tmpGoPath], { stdio: 'inherit', ignoreError: true }); } catch (e) { cleanupFailed = true; }
165
+ if (cleanupFailed && warnOnError) {
166
+ ctx.log(`${YELLOW}提示: 临时目录清理失败,可手动删除 ${tmpGoPath}${NC}`);
167
167
  }
168
168
  }
169
169
 
170
+ function isGoCommandMissing(error) {
171
+ const message = error && error.message ? String(error.message) : '';
172
+ const stderr = error && error.stderr ? String(error.stderr) : '';
173
+ const stdout = error && error.stdout ? String(error.stdout) : '';
174
+ const combined = `${message}\n${stderr}\n${stdout}`.toLowerCase();
175
+ if (error && String(error.code || '').toUpperCase() === 'ENOENT') {
176
+ return /\bgo\b/.test(message.toLowerCase()) || /spawnsync go enoent|spawn go enoent/.test(combined);
177
+ }
178
+ return /spawnsync go enoent|spawn go enoent|go: not found|go: command not found|command not found: go/.test(combined);
179
+ }
180
+
170
181
  function resolveGoplsSource(tmpGoPath, arch) {
171
182
  const primary = path.join(tmpGoPath, 'bin', `linux_${arch}`, 'gopls');
172
183
  if (fs.existsSync(primary)) return primary;
@@ -209,6 +220,11 @@ function prepareGoplsBuildCache(ctx, cache, imageTool, arch) {
209
220
  ctx.log(`${GREEN}✓ gopls 下载完成${NC}`);
210
221
  cleanupGoTmpPath(ctx, tmpGoPath, true);
211
222
  } catch (e) {
223
+ if (isGoCommandMissing(e)) {
224
+ ctx.log(`${YELLOW}提示: 未检测到本机 go,跳过 gopls 本地缓存预下载,将在镜像构建阶段安装${NC}`);
225
+ cleanupGoTmpPath(ctx, tmpGoPath, false);
226
+ return;
227
+ }
212
228
  ctx.error(`${RED}错误: gopls 下载失败${NC}`);
213
229
  throw e;
214
230
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xcanwin/manyoyo",
3
- "version": "4.2.4",
3
+ "version": "4.2.5",
4
4
  "imageVersion": "1.8.0-common",
5
5
  "description": "AI Agent CLI Security Sandbox for Docker and Podman",
6
6
  "keywords": [