跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

build-macos-guest-core.test.mjs

38 行 · 1.7 KB历史下载
1import test from 'node:test';
2import assert from 'node:assert/strict';
3import { mkdtempSync, mkdirSync, writeFileSync, rmSync } from 'node:fs';
4import { tmpdir } from 'node:os';
5import { join, resolve } from 'node:path';
6import { spawnSync } from 'node:child_process';
7
8test('fresh-cache Mac core build downloads VZ source before copying and builds its patched binding', () => {
9 const root = mkdtempSync(join(tmpdir(), 'cage-vz-fresh-cache-'));
10 try {
11 const bin = join(root, 'bin'), module = join(root, 'module');
12 mkdirSync(bin); mkdirSync(module);
13 writeFileSync(join(module, 'go.mod'), 'module github.com/Code-Hex/vz/v3\n');
14 writeFileSync(join(bin, 'go'), `#!/bin/sh
15set -eu
16if test "$1 $2" = 'mod download'; then touch "$CAGE_VZ_FIXTURE/downloaded"; exit; fi
17if test "$1 $2" = 'mod edit'; then exit; fi
18case "$*" in
19 *Version*) printf v3.7.1 ;;
20 *Dir*) if test -f "$CAGE_VZ_FIXTURE/downloaded"; then printf '%s/module' "$CAGE_VZ_FIXTURE"; fi ;;
21 *) exit 2 ;;
22esac
23`, { mode: 0o755 });
24 writeFileSync(join(bin, 'make'), `#!/bin/sh
25set -eu
26trial=$(printf '%s' "$GOFLAGS" | sed 's/.*-modfile=//')
27test -f "$(dirname "$trial")/vz/cage_view_object_darwin.go"
28grep -q CageViewObject "$(dirname "$trial")/vz/cage_view_object_darwin.go"
29test "$1" = cage
30printf patched-binding-built
31`, { mode: 0o755 });
32 const result = spawnSync('/bin/bash', [resolve('scripts/guest-os/build-macos-guest-core.sh'), '0.1.7-rc.1'], {
33 encoding: 'utf8', env: { ...process.env, PATH: `${bin}:${process.env.PATH}`, CAGE_VZ_FIXTURE: root },
34 });
35 assert.equal(result.status, 0, result.stderr);
36 assert.match(result.stdout, /patched-binding-built/);
37 } finally { rmSync(root, { recursive: true, force: true }); }
38});