Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(release): prepare WDA in Forge packages

JiangJiahao1f1348b8b709
diff --git a/apps/desktop/forge.config.ts b/apps/desktop/forge.config.ts
index 2c294109df..b170e5fbbd 100644
--- a/apps/desktop/forge.config.ts
+++ b/apps/desktop/forge.config.ts
@@ -907,6 +907,31 @@ function isMacForgePlatform(platform: ForgePlatform): boolean {
return platform === 'darwin' || platform === 'mas';
}
+function ensureMacIOSSimulatorWdaArchive(platform: ForgePlatform): void {
+ if (process.platform !== 'darwin' || !isMacForgePlatform(platform)) return;
+ const script = path.join(__dirname, 'scripts', 'ensure-wda-source-archive.mjs');
+ console.log(`[forge:prePackage] preparing pinned iOS Simulator WDA archive via ${script}...`);
+ const result = spawnSync(process.execPath, [script], {
+ cwd: __dirname,
+ stdio: 'inherit',
+ });
+ if (result.error) {
+ throw new Error(
+ `[forge] iOS Simulator WDA archive preparation failed: ${result.error.message}`,
+ );
+ }
+ if (result.signal) {
+ throw new Error(
+ `[forge] iOS Simulator WDA archive preparation terminated by signal ${result.signal}`,
+ );
+ }
+ if (result.status !== 0) {
+ throw new Error(
+ `[forge] iOS Simulator WDA archive preparation failed with exit code ${result.status}`,
+ );
+ }
+}
+
const MACOS_VOICE_HELPER_DEPLOYMENT_TARGET = 'macos10.15';
const MACOS_AGENT_ISLAND_HELPER_DEPLOYMENT_TARGET = 'macos14.0';
const MACOS_COMPUTER_PERMISSION_GUIDE_HELPER_DEPLOYMENT_TARGET = 'macos13.0';
@@ -1397,6 +1422,7 @@ const config: ForgeConfig = {
prePackage: async (_forgeConfig, platform, arch) => {
const targetPlatform = requestedTargetPlatform();
const targetArch = requestedTargetArch();
+ ensureMacIOSSimulatorWdaArchive(platform);
if (targetPlatform === 'win32') {
buildCindyUpdater();
}
diff --git a/apps/desktop/src/main/mcp-integrations/__tests__/ios-simulator-artifact.test.ts b/apps/desktop/src/main/mcp-integrations/__tests__/ios-simulator-artifact.test.ts
index ca4ea22c46..05fa2db0d6 100644
--- a/apps/desktop/src/main/mcp-integrations/__tests__/ios-simulator-artifact.test.ts
+++ b/apps/desktop/src/main/mcp-integrations/__tests__/ios-simulator-artifact.test.ts
@@ -160,6 +160,8 @@ describe('packaged iOS Simulator sidecar artifact verification', () => {
const source = await readFile(sourcePath, 'utf8');
const resourcesStart = source.indexOf('function extraResourcesForTarget');
const resourcesEnd = source.indexOf('function assertRealAndroidPlatformTool');
+ const ensureWdaStart = source.indexOf('function ensureMacIOSSimulatorWdaArchive');
+ const ensureWdaEnd = source.indexOf('const MACOS_VOICE_HELPER_DEPLOYMENT_TARGET');
const buildStart = source.indexOf('function buildMacIOSSimulatorHelper');
const buildEnd = source.indexOf('function runSwiftcForTarget');
const stageStart = source.indexOf('function stageMacIOSSimulatorHelper');
@@ -171,6 +173,8 @@ describe('packaged iOS Simulator sidecar artifact verification', () => {
for (const marker of [
resourcesStart,
resourcesEnd,
+ ensureWdaStart,
+ ensureWdaEnd,
buildStart,
buildEnd,
stageStart,
@@ -183,6 +187,7 @@ describe('packaged iOS Simulator sidecar artifact verification', () => {
}
const resourcesBody = source.slice(resourcesStart, resourcesEnd);
+ const ensureWdaBody = source.slice(ensureWdaStart, ensureWdaEnd);
const buildBody = source.slice(buildStart, buildEnd);
const stageBody = source.slice(stageStart, stageEnd);
const prePackageBody = source.slice(prePackageStart, postPackageStart);
@@ -190,6 +195,13 @@ describe('packaged iOS Simulator sidecar artifact verification', () => {
expect(resourcesBody).toContain("base.push('resources/ios-simulator')");
expect(resourcesBody).toContain("base.push('resources/cli')");
+ expect(ensureWdaBody).toContain("process.platform !== 'darwin'");
+ expect(ensureWdaBody).toContain('!isMacForgePlatform(platform)');
+ expect(ensureWdaBody).toContain("'ensure-wda-source-archive.mjs'");
+ expect(ensureWdaBody).toContain('spawnSync(process.execPath');
+ expect(ensureWdaBody).toContain('result.error');
+ expect(ensureWdaBody).toContain('result.signal');
+ expect(ensureWdaBody).toContain('result.status !== 0');
expect(buildBody).toContain("CINDY_IOS_SIDECAR_OUTPUT_MODE: 'helper'");
expect(buildBody).toContain('CINDY_IOS_SIDECAR_ARCH: helperArch');
expect(buildBody).toContain('`${CINDY_APP_ID}.ios-simulator-helper`');
@@ -197,7 +209,10 @@ describe('packaged iOS Simulator sidecar artifact verification', () => {
expect(stageBody).toContain("path.join(appContents, 'Helpers', IOS_SIMULATOR_HELPER_BUNDLE)");
expect(stageBody).toContain("fs.rmSync(path.join(resourceRoot, 'helper')");
expect(stageBody).toContain("fs.rmSync(path.join(resourceRoot, 'native')");
- expect(prePackageBody).toContain('buildMacIOSSimulatorHelper(platform, arch);');
+ const ensureWdaIndex = prePackageBody.indexOf('ensureMacIOSSimulatorWdaArchive(platform);');
+ const buildHelperIndex = prePackageBody.indexOf('buildMacIOSSimulatorHelper(platform, arch);');
+ expect(ensureWdaIndex).toBeGreaterThan(-1);
+ expect(buildHelperIndex).toBeGreaterThan(ensureWdaIndex);
expect(postPackageBody).toContain('stageMacIOSSimulatorHelper(buildPath, opts.platform);');
});