Files
cindy/apps/desktop/scripts/dev-remote-env.mjs
Lizi bb3f71d084 chore: Cindy 首次开源提交 / initial open-source release
Cindy 是心动网络 (X.D. Network Inc.) 的跨端 AI Agent 客户端。
本次提交包含 Desktop(Electron)、Mobile(Expo)及全部共享 packages
的完整源码,以 Apache-2.0 协议开源。

This is the first public release of Cindy, X.D. Network's cross-platform
AI agent client: the Electron desktop app, the Expo mobile app, and all
shared workspace packages, licensed under Apache-2.0.

- 许可与合规:根 LICENSE(Apache-2.0)+ NOTICE;第三方组件归属声明与
  SPDX SBOM 收口在 docs/legal/notices/,由 pnpm licenses:generate 生成。
- 社区文件:README / CONTRIBUTING / CODE_OF_CONDUCT / SECURITY / SUPPORT
  中英双语;issue / PR 模板与 CI workflow 在 .github/。
- 协议层以公开 submodule 引入:github.com/makecindy/cindy-protocol。
- 提交前已通过仓库门禁:全量 pnpm test:unit 与涉及 package 的 typecheck。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-24 08:30:44 +08:00

53 lines
1.9 KiB
JavaScript

#!/usr/bin/env node
/**
* dev-remote-env.mjs — dev:remote / dev:inspect 的构建身份注入包装。
*
* 2026-07 端点清单重构后,运行期业务端点全部来自启动时解析的端点清单
* (restart 按 --region 读仓内 config/endpoint*.json,--endpoints-cdn 走对应区域
* 线上 CDN),本包装
* 不再注入任何端点 URL;剩余职责是「remote 模式不读 apps/desktop/.env」的
* 构建身份注入只剩 VITE_CINDY_AUTH_REGION(强制覆盖,不吃 .env 同名变量)。
*
* 用法:node scripts/dev-remote-env.mjs <command> [args...]
*/
import { spawn } from 'node:child_process';
import {
applyDesktopDevStartupConfig,
stripDesktopDevRegionArgs,
} from '../../../scripts/shared/desktop-dev-region.mjs';
const [command, ...rawArgs] = process.argv.slice(2);
if (!command) {
console.error('usage: node scripts/dev-remote-env.mjs <command> [args...]');
process.exit(2);
}
const startupConfig = applyDesktopDevStartupConfig({ argv: rawArgs, mode: 'remote' });
const args = stripDesktopDevRegionArgs(rawArgs);
const env = {
...process.env,
XDT_DESKTOP_DEV_MODE: 'remote',
VITE_CINDY_AUTH_REGION: startupConfig.region,
};
const isWindows = process.platform === 'win32';
// Windows 下 electron-forge 等 .cmd shim 需要经 shell 解析;shell 模式下 Node 不转义
// args 数组(DEP0190),这里自行做最小引号处理(实际参数均为简单 token,含空格时兜底)。
const quote = (a) => (/[\s"]/.test(a) ? `"${a.replace(/"/g, '""')}"` : a);
const child = isWindows
? spawn([command, ...args].map(quote).join(' '), { stdio: 'inherit', env, shell: true })
: spawn(command, args, { stdio: 'inherit', env });
child.on('exit', (code, signal) => {
if (signal) {
process.kill(process.pid, signal);
return;
}
process.exit(code ?? 1);
});
child.on('error', (err) => {
console.error(`[dev-remote-env] failed to launch ${command}: ${err.message}`);
process.exit(1);
});