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。

test(desktop): 验证 macOS Swift target 输出

guyong6b621cbe1508
diff --git a/apps/desktop/forge.config.ts b/apps/desktop/forge.config.ts
index 05551bf708..2546b89d64 100644
--- a/apps/desktop/forge.config.ts
+++ b/apps/desktop/forge.config.ts
@@ -21,6 +21,7 @@ import {
} from '@cindy/maker-shared/brand-identity';
import { stageMacIOSSimulatorHelper } from './forge-ios-simulator-helper';
import { stagePackagedThirdPartyNotices } from './forge-third-party-notices';
+import { swiftTargetTriple, swiftTargetTriplesForForgeArch } from './src/main/remote-desktop/swiftTarget';
import { READ_SHEET_RUNTIME_PACKAGES } from '../../packages/lizi-mcps/src/cindy-docs/readSheetRuntimeDeps';
import { reviewPdfRuntimePackages } from './src/main/reviewer/reviewPdfRuntimeDeps';
import {
@@ -913,26 +914,6 @@ const MACOS_SESSION_DRAG_RELEASE_HELPER_DEPLOYMENT_TARGET = 'macos10.15';
const MACOS_XBOX_GAMEPAD_HELPER_DEPLOYMENT_TARGET = 'macos11.0';
const MACOS_REMOTE_DESKTOP_INPUT_DEPLOYMENT_TARGET = 'macos10.15';
-function swiftTargetTriple(cpuArch: 'arm64' | 'x86_64', deploymentTarget: string): string {
- return `${cpuArch}-apple-${deploymentTarget}`;
-}
-
-function swiftTargetTriplesForForgeArch(arch: ForgeArch, deploymentTarget: string): string[] {
- switch (arch) {
- case 'x64':
- return [swiftTargetTriple('x86_64', deploymentTarget)];
- case 'arm64':
- return [swiftTargetTriple('arm64', deploymentTarget)];
- case 'universal':
- return [
- swiftTargetTriple('x86_64', deploymentTarget),
- swiftTargetTriple('arm64', deploymentTarget),
- ];
- default:
- throw new Error(`[forge] unsupported macOS Swift helper arch: ${arch}`);
- }
-}
-
function swiftArchLabel(arch: ForgeArch, deploymentTarget: string): string {
return swiftTargetTriplesForForgeArch(arch, deploymentTarget)
.map((target) => target.split('-')[0])
diff --git a/apps/desktop/src/main/__tests__/sessionDragReleaseNativeHost.test.ts b/apps/desktop/src/main/__tests__/sessionDragReleaseNativeHost.test.ts
index 90905da692..a3d77e8103 100644
--- a/apps/desktop/src/main/__tests__/sessionDragReleaseNativeHost.test.ts
+++ b/apps/desktop/src/main/__tests__/sessionDragReleaseNativeHost.test.ts
@@ -5,6 +5,7 @@ import { PassThrough } from 'node:stream';
import type { ChildProcessByStdio } from 'node:child_process';
import type { Readable, Writable } from 'node:stream';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import { swiftTargetTriple, swiftTargetTriplesForForgeArch } from '../remote-desktop/swiftTarget.js';
const h = vi.hoisted(() => ({
spawn: vi.fn(),
@@ -148,6 +149,12 @@ describe('SessionDragReleaseNativeHost', () => {
"MACOS_REMOTE_DESKTOP_INPUT_DEPLOYMENT_TARGET,\n [],\n 'remote desktop input'",
);
expect(forgeSource).not.toContain("dest, arch, '10.15', [], 'remote desktop input'");
+ expect(swiftTargetTriple('arm64', 'macos10.15')).toBe('arm64-apple-macos10.15');
+ expect(swiftTargetTriple('x86_64', 'macos10.15')).toBe('x86_64-apple-macos10.15');
+ expect(swiftTargetTriplesForForgeArch('universal', 'macos10.15')).toEqual([
+ 'x86_64-apple-macos10.15',
+ 'arm64-apple-macos10.15',
+ ]);
});
});
diff --git a/apps/desktop/src/main/remote-desktop/swiftTarget.ts b/apps/desktop/src/main/remote-desktop/swiftTarget.ts
new file mode 100644
index 0000000000..f1b0b6479a
--- /dev/null
+++ b/apps/desktop/src/main/remote-desktop/swiftTarget.ts
@@ -0,0 +1,27 @@
+import type { ForgeArch } from '@electron-forge/shared-types';
+
+export function swiftTargetTriple(
+ cpuArch: 'arm64' | 'x86_64',
+ deploymentTarget: string,
+): string {
+ return `${cpuArch}-apple-${deploymentTarget}`;
+}
+
+export function swiftTargetTriplesForForgeArch(
+ arch: ForgeArch,
+ deploymentTarget: string,
+): string[] {
+ switch (arch) {
+ case 'x64':
+ return [swiftTargetTriple('x86_64', deploymentTarget)];
+ case 'arm64':
+ return [swiftTargetTriple('arm64', deploymentTarget)];
+ case 'universal':
+ return [
+ swiftTargetTriple('x86_64', deploymentTarget),
+ swiftTargetTriple('arm64', deploymentTarget),
+ ];
+ default:
+ throw new Error(`[forge] unsupported macOS Swift helper arch: ${arch}`);
+ }
+}