跳到主要内容

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

浏览文件

collect-app-licenses.mjs

56 行 · 3.3 KB历史下载
1#!/usr/bin/env node
2import { cpSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
3import { execFileSync } from "node:child_process";
4import { resolve, join } from "node:path";
5
6// Collect the licenses of the packages actually shipped in the workbench.
7const target = process.argv[2];
8if (!target) throw new Error("Usage: node scripts/collect-app-licenses.mjs <output-directory>");
9const root = resolve(import.meta.dirname, "..");
10mkdirSync(target, { recursive: true });
11for (const file of ["LICENSE", "NOTICE", "THIRD_PARTY_LICENSES"]) {
12 cpSync(join(root, file), join(target, file));
13}
14cpSync(join(root, "internal/exitpolicy/data"), join(target, "exit-country-data"), { recursive: true });
15const lock = JSON.parse(readFileSync(join(root, "ui/package-lock.json"), "utf8"));
16const notices = [];
17for (const [path, entry] of Object.entries(lock.packages)) {
18 if (!path || entry.dev) continue;
19 const source = join(root, "ui", path);
20 const name = JSON.parse(readFileSync(join(source, "package.json"), "utf8")).name;
21 const dest = join(target, "npm", name);
22 const files = readdirSync(source).filter((file) => /^(licen[sc]e|copying|notice)(\.|$)/i.test(file) && statSync(join(source, file)).isFile());
23 if (!files.length) throw new Error(`Missing license for ${name}@${entry.version}`);
24 mkdirSync(dest, { recursive: true });
25 for (const file of files) cpSync(join(source, file), join(dest, file));
26 notices.push(`${name}@${entry.version}: ${entry.license || "see license files"}`);
27}
28writeFileSync(join(target, "npm", "NOTICE.txt"), `${notices.join("\n")}\n`);
29const novnc = join(root, "ui/vendor/novnc");
30for (const file of ["LICENSE.txt", "AUTHORS", "NOTICE.cage", "docs", "vendor/pako/LICENSE"]) {
31 mkdirSync(join(target, "novnc", file.includes("/") ? file.slice(0, file.lastIndexOf("/")) : ""), { recursive: true });
32 cpSync(join(novnc, file), join(target, "novnc", file), { recursive: true });
33}
34// MPL-covered source and local modifications travel with the executable.
35cpSync(join(root, "ui/.generated/novnc"), join(target, "novnc-source"), { recursive: true });
36
37// The embedded Tailscale node is a separate guest executable and module.
38const tailnetModules = new Set();
39for (const [os, arch] of [["linux", "amd64"], ["darwin", "arm64"], ["windows", "amd64"]]) {
40 const dirs = execFileSync("go", ["list", "-deps", "-f", "{{if .Module}}{{.Module.Dir}}{{end}}", "."], {
41 cwd: join(root, "tools/tailnet"), env: { ...process.env, GOOS: os, GOARCH: arch, CGO_ENABLED: "0", GOFLAGS: "" }, encoding: "utf8",
42 });
43 for (const dir of dirs.split("\n").filter(Boolean)) if (resolve(dir) !== join(root, "tools/tailnet")) tailnetModules.add(dir);
44}
45const tailnetNotices = [];
46for (const dir of tailnetModules) {
47 const normalized = dir.replaceAll("\\", "/");
48 const name = normalized.slice(normalized.lastIndexOf("/pkg/mod/") + 9);
49 const dest = join(target, "tailnet-go", name);
50 const licenses = readdirSync(dir).filter(file => /^(licen[sc]e|copying|notice|patents|authors)(\.|$)/i.test(file) && statSync(join(dir, file)).isFile());
51 if (!licenses.length) throw Error(`Missing guest dependency license: ${name}`);
52 mkdirSync(dest, { recursive: true });
53 for (const file of licenses) cpSync(join(dir, file), join(dest, file));
54 tailnetNotices.push(name);
55}
56writeFileSync(join(target, "tailnet-go", "NOTICE.txt"), tailnetNotices.sort().join("\n") + "\n");