peachsim 0.1.729 → 0.1.745
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/bridge-flow-runner.ts +15 -2
- package/cli/commands/control.ts +13 -3
- package/cli/commands/desktop.ts +1 -0
- package/cli/commands/electron.ts +12 -8
- package/cli/commands/flow.ts +1 -3
- package/cli/commands/install-desktop.ts +105 -66
- package/cli/commands/logout.ts +5 -1
- package/cli/commands/no-bridge-hint.ts +2 -2
- package/cli/commands/swift.ts +26 -9
- package/cli/desktop-companion.ts +36 -9
- package/cli/drivers/desktop.ts +65 -0
- package/cli/drivers/electron.ts +4 -66
- package/cli/drivers/index.ts +1 -0
- package/cli/drivers/playwright.ts +3 -3
- package/cli/drivers/registry.ts +7 -2
- package/cli/drivers/types.ts +4 -3
- package/cli/maestro-js.ts +10 -0
- package/cli/outbound-endpoints.ts +2 -2
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-identity.cjs +1 -1
- package/dist-lib/agent-sessions.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +39 -9
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/capture-contract.cjs +13 -19
- package/dist-lib/capture-contract.mjs +13 -19
- package/dist-lib/cli-constants.cjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/detox/index.cjs +20 -2
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +32 -1
- package/dist-lib/host/bridge-host.cjs +1617 -533
- package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +14 -19
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +1 -1
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +1 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/render-mode.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +2 -1
- package/dist-lib/sdk.mjs +2 -1
- package/dist-lib/skills.cjs +2307 -1068
- package/dist-lib/swift-compile.cjs +318 -61
- package/dist-lib/swift-compile.mjs +314 -62
- package/dist-lib/swift-package.cjs +146 -9
- package/dist-lib/swift-package.mjs +144 -9
- package/dist-lib/swift-submit.cjs +2 -2
- package/dist-lib/swift-submit.mjs +2 -2
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +1311 -227
- package/dist-lib/vite.cjs +1 -1
- package/package.json +1 -1
- package/skills/contrast/SKILL.md +1 -1
- package/src/auth/shared-session.ts +45 -9
- package/src/bridge-constants.ts +7 -7
- package/src/capture-contract.ts +18 -33
- package/src/desktop-host-delivery.ts +81 -0
- package/src/home-paths.ts +30 -0
- package/src/host/bridge-host.ts +11 -6
- package/src/native-seam-manifest.ts +0 -11
- package/src/sim-client.ts +1 -0
- package/src/swift-compile.ts +404 -69
- package/src/swift-distribution.lock.json +11 -11
- package/src/swift-host.ts +316 -43
- package/src/swift-package.ts +204 -19
- package/src/swift-remote-packages.ts +255 -0
- package/src/swift-submit.ts +4 -1
- package/src/vite-plugin.ts +19 -8
- package/src/xcode-project.ts +527 -0
|
@@ -15,6 +15,7 @@ import { waitForSootsimIdle } from './commands/inspect/settling'
|
|
|
15
15
|
import { callShellCommandWhenReady, getShellState } from './commands/inspect/shared'
|
|
16
16
|
import { PERMISSION_KINDS } from './commands/permissions'
|
|
17
17
|
import { saveCurrentSimId } from './current-sim'
|
|
18
|
+
import { parseFlowFile } from './flow-file'
|
|
18
19
|
import { FlowLiveStatusReporter } from './flow-live-status'
|
|
19
20
|
import { MaestroJsContext, scriptConditionIsTruthy } from './maestro-js'
|
|
20
21
|
import { ensureCliRecordingEntitlement } from './recording-access'
|
|
@@ -2804,9 +2805,10 @@ export class SootSimBridgeFlowRunner {
|
|
|
2804
2805
|
// next command resolves its target. an app can take a few hundred ms to
|
|
2805
2806
|
// react to a press, so stillness must hold about half a second, and it
|
|
2806
2807
|
// counts painted frames because a spinner repaints without moving layout.
|
|
2807
|
-
// a screen that never stops proceeds when the budget runs out, as there
|
|
2808
|
+
// a screen that never stops proceeds when the budget runs out, as there,
|
|
2809
|
+
// and names what kept it moving: every such step pays the whole budget.
|
|
2808
2810
|
private async waitForAppToSettle() {
|
|
2809
|
-
await waitForSootsimIdle({
|
|
2811
|
+
const result = await waitForSootsimIdle({
|
|
2810
2812
|
bridge: this.bridge,
|
|
2811
2813
|
simId: this.opts.simId,
|
|
2812
2814
|
maxMs: 3000,
|
|
@@ -2815,6 +2817,11 @@ export class SootSimBridgeFlowRunner {
|
|
|
2815
2817
|
strict: true,
|
|
2816
2818
|
paintStill: true,
|
|
2817
2819
|
})
|
|
2820
|
+
if (!result.settled) {
|
|
2821
|
+
console.warn(
|
|
2822
|
+
` [flow] still moving after ${result.elapsed}ms: ${result.blockedBy}`,
|
|
2823
|
+
)
|
|
2824
|
+
}
|
|
2818
2825
|
}
|
|
2819
2826
|
|
|
2820
2827
|
private async settleAfterInput() {
|
|
@@ -3442,6 +3449,12 @@ export class SootSimBridgeFlowRunner {
|
|
|
3442
3449
|
if (file) {
|
|
3443
3450
|
const flowPath = path.resolve(this.opts.flowDir, file)
|
|
3444
3451
|
const flowContent = fs.readFileSync(flowPath, 'utf8')
|
|
3452
|
+
// the sub-flow's own config env defines after runFlow's env, as
|
|
3453
|
+
// upstream prepends runFlow env to the parsed sub-flow commands.
|
|
3454
|
+
const { frontmatter } = parseFlowFile(flowContent)
|
|
3455
|
+
if (frontmatter.env && typeof frontmatter.env === 'object') {
|
|
3456
|
+
this.js.defineVariables(frontmatter.env)
|
|
3457
|
+
}
|
|
3445
3458
|
const previousDir = this.opts.flowDir
|
|
3446
3459
|
;(this.opts as { flowDir: string }).flowDir = path.dirname(flowPath)
|
|
3447
3460
|
try {
|
package/cli/commands/control.ts
CHANGED
|
@@ -159,13 +159,18 @@ export function resolveDriverConnectWaitOptions(): DriverConnectWaitOptions {
|
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
function isDriverId(value: string): value is DriverId {
|
|
162
|
-
return value === 'electron' || value === 'playwright'
|
|
162
|
+
return value === 'desktop' || value === 'electron' || value === 'playwright'
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
function simUsesDriver(sim: BridgeSimInfo, driverId: DriverId): boolean {
|
|
166
166
|
if (driverId === 'playwright') {
|
|
167
167
|
return sim.meta?.sootsimHostDriver === 'playwright'
|
|
168
168
|
}
|
|
169
|
+
if (driverId === 'desktop') {
|
|
170
|
+
return Boolean(
|
|
171
|
+
sim.url && new URL(sim.url).searchParams.get('peachHostDriver') === 'desktop',
|
|
172
|
+
)
|
|
173
|
+
}
|
|
169
174
|
return sim.userAgent?.includes('Electron/') === true
|
|
170
175
|
}
|
|
171
176
|
|
|
@@ -855,6 +860,8 @@ async function splashImageReachable(imageUrl: string): Promise<boolean> {
|
|
|
855
860
|
}
|
|
856
861
|
|
|
857
862
|
export interface BuildShellUrlOptions {
|
|
863
|
+
// marks native host windows so the bridge can reuse a CLI-opened desktop sim.
|
|
864
|
+
hostDriver?: 'desktop'
|
|
858
865
|
// when set, forces the metro `hot` query on the resolved bundle URL. true
|
|
859
866
|
// for interactive opens (HMR runtime in bundle, edits hot-apply), false
|
|
860
867
|
// for `--driver playwright`/agent runs (no in-bundle HMR wiring, no ws
|
|
@@ -936,6 +943,7 @@ export async function buildShellUrl(
|
|
|
936
943
|
project,
|
|
937
944
|
)
|
|
938
945
|
const expoStamped = new URL(stamped)
|
|
946
|
+
if (opts.hostDriver) expoStamped.searchParams.set('peachHostDriver', opts.hostDriver)
|
|
939
947
|
if (expoRoot) {
|
|
940
948
|
const world = resolveBridgeWorld()
|
|
941
949
|
const port = resolveBridgePortForPin({
|
|
@@ -991,6 +999,7 @@ function deriveCurrentSimBaseUrl(
|
|
|
991
999
|
// and `stampAppFonts` doesn't get the chance to re-derive against the
|
|
992
1000
|
// current bundle. drop it so the rebuild starts clean.
|
|
993
1001
|
url.searchParams.delete('appFonts')
|
|
1002
|
+
url.searchParams.delete('appManifest')
|
|
994
1003
|
// appSplash and appCatalog are target-specific in the same way: drop them
|
|
995
1004
|
// so the configured splash and catalog re-derive against the current
|
|
996
1005
|
// bundle.
|
|
@@ -1688,8 +1697,8 @@ export async function runOpenCommand(
|
|
|
1688
1697
|
opts.signal?.throwIfAborted()
|
|
1689
1698
|
|
|
1690
1699
|
// playwright is the browser-sim launcher. it owns an isolated profile and
|
|
1691
|
-
// can reap exactly its own browser tree.
|
|
1692
|
-
//
|
|
1700
|
+
// can reap exactly its own browser tree. desktop opens the native host and
|
|
1701
|
+
// electron the Electron companion. none opens the user's browser profile.
|
|
1693
1702
|
const requestedDriverId = args.find((_, i) => args[i - 1] === '--driver') || ''
|
|
1694
1703
|
if (requestedDriverId && !isDriverId(requestedDriverId)) {
|
|
1695
1704
|
console.error(
|
|
@@ -1840,6 +1849,7 @@ export async function runOpenCommand(
|
|
|
1840
1849
|
|
|
1841
1850
|
const buildShellUrlOpts: BuildShellUrlOptions = {
|
|
1842
1851
|
hot: hotMode,
|
|
1852
|
+
hostDriver: driverId === 'desktop' ? 'desktop' : undefined,
|
|
1843
1853
|
device: deviceArg,
|
|
1844
1854
|
posture: postureArg,
|
|
1845
1855
|
orientation: orientationArg,
|
package/cli/commands/desktop.ts
CHANGED
|
@@ -18,6 +18,7 @@ options:
|
|
|
18
18
|
--port <number> connect to a running dev server on this port
|
|
19
19
|
--profile <id> launch with an isolated persistent storage profile
|
|
20
20
|
--ephemeral launch with a temporary isolated storage profile
|
|
21
|
+
--native launch or install the native desktop host (macOS arm64)
|
|
21
22
|
-y, --yes install without prompting
|
|
22
23
|
`)
|
|
23
24
|
}
|
package/cli/commands/electron.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
// peach desktop — launch the installed desktop companion via the
|
|
2
|
-
// electron driver
|
|
2
|
+
// electron driver, or the native host via the desktop driver with --native
|
|
3
|
+
// (or PEACH_DESKTOP_APP). the drivers wrap findDesktopCompanion +
|
|
3
4
|
// launchDesktopCompanion, so this command is a thin CLI surface that
|
|
4
5
|
// parses options, prompts for install, and delegates everything else.
|
|
5
6
|
|
|
6
7
|
import { ensureProfile } from '../../src/profiles'
|
|
7
|
-
import { findDesktopCompanion } from '../desktop-companion'
|
|
8
|
-
import { electronDriver } from '../drivers'
|
|
8
|
+
import { findDesktopCompanion, wantsNativeDesktop } from '../desktop-companion'
|
|
9
|
+
import { desktopDriver, electronDriver } from '../drivers'
|
|
9
10
|
import { confirm } from '../prompt'
|
|
10
11
|
import { rnxExit } from '../run-rnx'
|
|
11
12
|
import { buildShellUrl } from './control'
|
|
@@ -48,11 +49,13 @@ options:
|
|
|
48
49
|
--port <number> connect to running dev server on this port
|
|
49
50
|
--profile <id> launch with an isolated persistent storage profile
|
|
50
51
|
--ephemeral launch with a temporary isolated storage profile
|
|
52
|
+
--native launch the native desktop host (peach desktop install --native)
|
|
51
53
|
|
|
52
54
|
examples:
|
|
53
55
|
peach desktop
|
|
54
56
|
peach desktop --port 5173
|
|
55
57
|
peach desktop --profile qa
|
|
58
|
+
peach desktop --native
|
|
56
59
|
`)
|
|
57
60
|
rnxExit(0)
|
|
58
61
|
}
|
|
@@ -64,23 +67,24 @@ examples:
|
|
|
64
67
|
rnxExit(1)
|
|
65
68
|
}
|
|
66
69
|
const profileId = profileArg ? ensureProfile(profileArg).id : undefined
|
|
67
|
-
|
|
70
|
+
const native = wantsNativeDesktop({ native: args.includes('--native') })
|
|
71
|
+
let install = findDesktopCompanion({ native })
|
|
68
72
|
if (!install) {
|
|
69
|
-
printMissingCompanionHint()
|
|
73
|
+
printMissingCompanionHint(native)
|
|
70
74
|
const canPrompt =
|
|
71
75
|
process.stdin.isTTY && process.env.CI !== '1' && process.env.PEACH_NO_PROMPT !== '1'
|
|
72
76
|
if (canPrompt && (await confirm('run peach desktop install now?', true))) {
|
|
73
77
|
console.log()
|
|
74
78
|
const { runInstallDesktop } = await import('./install-desktop')
|
|
75
|
-
await runInstallDesktop(['--yes'])
|
|
76
|
-
install = findDesktopCompanion()
|
|
79
|
+
await runInstallDesktop(native ? ['--yes', '--native'] : ['--yes'])
|
|
80
|
+
install = findDesktopCompanion({ native })
|
|
77
81
|
}
|
|
78
82
|
if (!install) rnxExit(1)
|
|
79
83
|
}
|
|
80
84
|
console.log(` launching ${install.path}`)
|
|
81
85
|
|
|
82
86
|
const url = await resolveElectronLaunchUrl(args, opts)
|
|
83
|
-
const result = await electronDriver.launch({
|
|
87
|
+
const result = await (native ? desktopDriver : electronDriver).launch({
|
|
84
88
|
url,
|
|
85
89
|
device: opts.device,
|
|
86
90
|
profileId,
|
package/cli/commands/flow.ts
CHANGED
|
@@ -676,9 +676,7 @@ flow extension:
|
|
|
676
676
|
// DefineVariablesCommand).
|
|
677
677
|
driver.js.putEnv('MAESTRO_FILENAME', path.basename(flowPath, path.extname(flowPath)))
|
|
678
678
|
if (frontmatter.env && typeof frontmatter.env === 'object') {
|
|
679
|
-
|
|
680
|
-
driver.js.putEnv(key, value)
|
|
681
|
-
}
|
|
679
|
+
driver.js.defineVariables(frontmatter.env)
|
|
682
680
|
}
|
|
683
681
|
|
|
684
682
|
let profileResult: SootSimFlowProfileResult | null = null
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
// peach desktop install — download and install the optional desktop GUI
|
|
2
2
|
//
|
|
3
3
|
// the CLI + daemon are the canonical peach surface; this command is only
|
|
4
|
-
// for users who want
|
|
4
|
+
// for users who want a GUI companion on top of that.
|
|
5
5
|
//
|
|
6
|
+
// --native installs the native desktop host by version under
|
|
7
|
+
// ~/.peach/desktop/<version>/ through the same verified, versioned delivery
|
|
8
|
+
// `peach runtime install` uses (src/desktop-host-delivery.ts).
|
|
9
|
+
//
|
|
10
|
+
// otherwise it installs the Electron companion: it
|
|
6
11
|
// fetches the right platform artifact from https://contrast.dev/api/electron-release/
|
|
7
12
|
// and installs it into the OS-native location that findInstalledDesktopCompanion() looks for:
|
|
8
13
|
// macos: ~/Applications/peach.app (or /Applications if writable)
|
|
@@ -26,10 +31,10 @@ import {
|
|
|
26
31
|
import { tmpdir } from 'os'
|
|
27
32
|
import { basename, dirname, join, resolve } from 'path'
|
|
28
33
|
import {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
} from '../desktop-companion'
|
|
34
|
+
DESKTOP_HOST_CHANNELS,
|
|
35
|
+
desktopHostDelivery,
|
|
36
|
+
} from '../../src/desktop-host-delivery'
|
|
37
|
+
import { findInstalledDesktopCompanion } from '../desktop-companion'
|
|
33
38
|
import { confirm } from '../prompt'
|
|
34
39
|
import { rnxExit } from '../run-rnx'
|
|
35
40
|
import { accent, bold, failure, muted, success, withSpinner } from '../ui'
|
|
@@ -47,18 +52,6 @@ interface Target {
|
|
|
47
52
|
|
|
48
53
|
function detectTarget(): Target | null {
|
|
49
54
|
const arch = process.arch
|
|
50
|
-
const nativeApp = getNativeDesktopAppPath()
|
|
51
|
-
if (nativeApp) {
|
|
52
|
-
if (arch !== 'arm64')
|
|
53
|
-
throw new Error('native staging is available only on macOS arm64')
|
|
54
|
-
const filename = 'PeachDesktop-latest-mac-arm64.dmg'
|
|
55
|
-
return {
|
|
56
|
-
platform: 'mac-arm64',
|
|
57
|
-
filename,
|
|
58
|
-
url: 'https://r2.rnxsim.com/releases/native/staging/' + filename,
|
|
59
|
-
install: (downloaded) => installMacDmg(downloaded, nativeApp),
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
55
|
if (process.platform === 'darwin') {
|
|
63
56
|
const platform: TargetPlatform = arch === 'arm64' ? 'mac-arm64' : 'mac-x64'
|
|
64
57
|
const filename = `peach-latest-${platform}.dmg`
|
|
@@ -144,7 +137,7 @@ function renderProgress(received: number, total: number | null): string {
|
|
|
144
137
|
return ` ${bar} ${pct}% ${mb} / ${totalMb} MB`
|
|
145
138
|
}
|
|
146
139
|
|
|
147
|
-
async function installMacDmg(dmgPath: string
|
|
140
|
+
async function installMacDmg(dmgPath: string): Promise<string> {
|
|
148
141
|
const mountOutput = spawnSync(
|
|
149
142
|
'hdiutil',
|
|
150
143
|
['attach', '-nobrowse', '-readonly', dmgPath],
|
|
@@ -164,52 +157,30 @@ async function installMacDmg(dmgPath: string, nativeApp?: string): Promise<strin
|
|
|
164
157
|
throw new Error(`could not determine dmg mount point (output: ${mountOutput.stdout})`)
|
|
165
158
|
}
|
|
166
159
|
|
|
167
|
-
const
|
|
168
|
-
const appSource = join(mountPoint, appName)
|
|
160
|
+
const appSource = join(mountPoint, 'peach.app')
|
|
169
161
|
if (!existsSync(appSource)) {
|
|
170
162
|
spawnSync('hdiutil', ['detach', '-force', mountPoint])
|
|
171
|
-
throw new Error(
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (nativeApp) {
|
|
175
|
-
const requirement =
|
|
176
|
-
'=anchor apple generic and identifier "dev.contrast.peach-desktop" and certificate leaf[subject.OU] = "399WY8X9HY" and certificate leaf[field.1.2.840.113635.100.6.1.13] exists'
|
|
177
|
-
const signature = spawnSync('codesign', [
|
|
178
|
-
'--verify',
|
|
179
|
-
'--deep',
|
|
180
|
-
'--strict',
|
|
181
|
-
'-R',
|
|
182
|
-
requirement,
|
|
183
|
-
appSource,
|
|
184
|
-
])
|
|
185
|
-
const notarization = spawnSync('spctl', ['--assess', '--type', 'execute', appSource])
|
|
186
|
-
if (signature.status !== 0 || notarization.status !== 0) {
|
|
187
|
-
spawnSync('hdiutil', ['detach', '-force', mountPoint])
|
|
188
|
-
throw new Error(
|
|
189
|
-
'native staging app failed Developer ID or notarization verification',
|
|
190
|
-
)
|
|
191
|
-
}
|
|
163
|
+
throw new Error(`peach.app not found inside ${mountPoint}`)
|
|
192
164
|
}
|
|
193
165
|
|
|
194
166
|
// prefer /Applications if writable, otherwise ~/Applications (same paths
|
|
195
167
|
// findInstalledDesktopCompanion checks, so no extra config needed post-install).
|
|
196
168
|
const systemApps = '/Applications'
|
|
197
169
|
const userApps = resolve(process.env.HOME || '', 'Applications')
|
|
198
|
-
let destRoot =
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
if (nativeApp || destRoot === userApps) {
|
|
170
|
+
let destRoot = systemApps
|
|
171
|
+
try {
|
|
172
|
+
const probe = join(systemApps, `.peach-write-probe-${process.pid}`)
|
|
173
|
+
spawnSync('touch', [probe])
|
|
174
|
+
if (existsSync(probe)) rmSync(probe, { force: true })
|
|
175
|
+
else destRoot = userApps
|
|
176
|
+
} catch {
|
|
177
|
+
destRoot = userApps
|
|
178
|
+
}
|
|
179
|
+
if (destRoot === userApps) {
|
|
209
180
|
mkdirSync(destRoot, { recursive: true })
|
|
210
181
|
}
|
|
211
182
|
|
|
212
|
-
const appDest =
|
|
183
|
+
const appDest = join(destRoot, 'peach.app')
|
|
213
184
|
|
|
214
185
|
// copy alongside the destination and swap, rather than deleting the installed
|
|
215
186
|
// app first. removing it up front means a failed copy leaves the user with no
|
|
@@ -310,17 +281,24 @@ The CLI works without it. Choose Desktop when you want a dedicated native window
|
|
|
310
281
|
|
|
311
282
|
usage:
|
|
312
283
|
peach desktop install [options]
|
|
284
|
+
peach desktop install --native [version] [options]
|
|
313
285
|
|
|
314
286
|
options:
|
|
315
|
-
-y, --yes
|
|
316
|
-
--force
|
|
287
|
+
-y, --yes skip confirmation and install immediately
|
|
288
|
+
--force reinstall even if the companion is already present
|
|
289
|
+
--native install the native desktop host (macOS arm64) under
|
|
290
|
+
~/.peach/desktop/<version> and make it active
|
|
291
|
+
--channel <name> with --native: production (default) or staging
|
|
317
292
|
|
|
318
|
-
|
|
319
|
-
|
|
293
|
+
environment:
|
|
294
|
+
PEACH_DESKTOP_VERSION with --native: pin this host version
|
|
295
|
+
PEACH_DESKTOP_APP launch this PeachDesktop.app instead of the active version
|
|
320
296
|
|
|
321
297
|
examples:
|
|
322
298
|
peach desktop install
|
|
323
299
|
peach desktop install --yes
|
|
300
|
+
peach desktop install --native
|
|
301
|
+
peach desktop install --native --channel staging
|
|
324
302
|
`)
|
|
325
303
|
rnxExit(0)
|
|
326
304
|
}
|
|
@@ -332,13 +310,12 @@ examples:
|
|
|
332
310
|
process.env.CI === '1' ||
|
|
333
311
|
!process.stdin.isTTY
|
|
334
312
|
const force = args.includes('--force')
|
|
313
|
+
if (args.includes('--native')) {
|
|
314
|
+
await installNativeHost(args, force)
|
|
315
|
+
return
|
|
316
|
+
}
|
|
335
317
|
|
|
336
|
-
const
|
|
337
|
-
const existing = nativeApp
|
|
338
|
-
? existsSync(nativeApp)
|
|
339
|
-
? findDesktopCompanion()
|
|
340
|
-
: null
|
|
341
|
-
: findInstalledDesktopCompanion()
|
|
318
|
+
const existing = findInstalledDesktopCompanion()
|
|
342
319
|
if (existing && !force) {
|
|
343
320
|
console.log(` ${success('✓')} Desktop app is already installed at ${existing.path}`)
|
|
344
321
|
console.log(` ${muted('Pass --force to reinstall.')}`)
|
|
@@ -423,9 +400,7 @@ examples:
|
|
|
423
400
|
// the download is good, only placing the app failed. on macOS the disk
|
|
424
401
|
// image installs itself perfectly well by hand, so open it and let the user
|
|
425
402
|
// drag rather than leaving them at a dead end. keep workDir for that.
|
|
426
|
-
if (
|
|
427
|
-
rmSync(workDir, { recursive: true, force: true })
|
|
428
|
-
} else if (process.platform === 'darwin') {
|
|
403
|
+
if (process.platform === 'darwin') {
|
|
429
404
|
spawnSync('open', [downloadPath])
|
|
430
405
|
console.error(` Opened ${target.filename} — drag peach to Applications to finish.`)
|
|
431
406
|
} else {
|
|
@@ -439,3 +414,67 @@ examples:
|
|
|
439
414
|
console.log(' peach desktop Launch the desktop app')
|
|
440
415
|
console.log(' peach open <target> Open a demo or bundle in it')
|
|
441
416
|
}
|
|
417
|
+
|
|
418
|
+
// the native host's identity, checked on the installed copy: the manifest
|
|
419
|
+
// checksum proves the bytes are the published ones, this proves who signed them.
|
|
420
|
+
const NATIVE_HOST_REQUIREMENT =
|
|
421
|
+
'=anchor apple generic and identifier "dev.contrast.peach-desktop" and certificate leaf[subject.OU] = "399WY8X9HY" and certificate leaf[field.1.2.840.113635.100.6.1.13] exists'
|
|
422
|
+
|
|
423
|
+
async function installNativeHost(args: string[], force: boolean): Promise<void> {
|
|
424
|
+
const channelIndex = args.indexOf('--channel')
|
|
425
|
+
const channel = channelIndex >= 0 ? args[channelIndex + 1] : undefined
|
|
426
|
+
if (channelIndex >= 0 && !channel) {
|
|
427
|
+
console.error(` --channel needs ${DESKTOP_HOST_CHANNELS.join(' or ')}`)
|
|
428
|
+
rnxExit(1)
|
|
429
|
+
}
|
|
430
|
+
const version = args.find(
|
|
431
|
+
(arg, i) => !arg.startsWith('-') && args[i - 1] !== '--channel' && arg !== 'install',
|
|
432
|
+
)
|
|
433
|
+
try {
|
|
434
|
+
const delivery = desktopHostDelivery(channel)
|
|
435
|
+
const resolvedChannel = delivery.resolveChannel(channel)
|
|
436
|
+
const result = await withSpinner(
|
|
437
|
+
`Installing the native desktop host (${resolvedChannel})`,
|
|
438
|
+
() =>
|
|
439
|
+
delivery.install({
|
|
440
|
+
version,
|
|
441
|
+
channel: resolvedChannel,
|
|
442
|
+
force,
|
|
443
|
+
// the installed copy becomes active only once its signature checks out
|
|
444
|
+
setActive: false,
|
|
445
|
+
quiet: true,
|
|
446
|
+
}),
|
|
447
|
+
)
|
|
448
|
+
const app = join(result.runtimeDir, 'PeachDesktop.app')
|
|
449
|
+
if (result.installed) {
|
|
450
|
+
const signature = spawnSync('codesign', [
|
|
451
|
+
'--verify',
|
|
452
|
+
'--deep',
|
|
453
|
+
'--strict',
|
|
454
|
+
'-R',
|
|
455
|
+
NATIVE_HOST_REQUIREMENT,
|
|
456
|
+
app,
|
|
457
|
+
])
|
|
458
|
+
const notarization = spawnSync('spctl', ['--assess', '--type', 'execute', app])
|
|
459
|
+
if (signature.status !== 0 || notarization.status !== 0) {
|
|
460
|
+
rmSync(result.runtimeDir, { recursive: true, force: true })
|
|
461
|
+
throw new Error(
|
|
462
|
+
`version ${result.version} failed Developer ID or notarization verification`,
|
|
463
|
+
)
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
delivery.product.writeActiveRuntime(result.version)
|
|
467
|
+
console.log(
|
|
468
|
+
` ${success('✓')} Native desktop host ${result.version} ${result.installed ? 'installed' : 'already installed'} at ${app}`,
|
|
469
|
+
)
|
|
470
|
+
} catch (err) {
|
|
471
|
+
console.error(
|
|
472
|
+
` ${failure('×')} Native desktop install failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
473
|
+
)
|
|
474
|
+
rnxExit(1)
|
|
475
|
+
}
|
|
476
|
+
console.log()
|
|
477
|
+
console.log(` ${bold('Ready')}`)
|
|
478
|
+
console.log(' peach desktop --native Launch the native desktop host')
|
|
479
|
+
console.log(' peach open <target> --driver desktop Open a demo or bundle in it')
|
|
480
|
+
}
|
package/cli/commands/logout.ts
CHANGED
|
@@ -13,7 +13,11 @@ export async function runLogout() {
|
|
|
13
13
|
try {
|
|
14
14
|
await fetch(`${current.origin.replace(/\/$/, '')}/api/auth/sign-out`, {
|
|
15
15
|
method: 'POST',
|
|
16
|
-
headers: {
|
|
16
|
+
headers: {
|
|
17
|
+
authorization: `Bearer ${current.token}`,
|
|
18
|
+
'content-type': 'application/json',
|
|
19
|
+
},
|
|
20
|
+
body: '{}',
|
|
17
21
|
})
|
|
18
22
|
} catch {
|
|
19
23
|
// best-effort only
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
import type { BridgeSimInfo } from '../ws-bridge'
|
|
4
4
|
|
|
5
|
-
export function printMissingCompanionHint() {
|
|
5
|
+
export function printMissingCompanionHint(native = false) {
|
|
6
6
|
console.error(' no peach desktop companion found.')
|
|
7
7
|
console.error('')
|
|
8
8
|
console.error(' install the desktop app:')
|
|
9
|
-
console.error(
|
|
9
|
+
console.error(` peach desktop install${native ? ' --native' : ''}`)
|
|
10
10
|
console.error('')
|
|
11
11
|
console.error(' or install the recommended background service:')
|
|
12
12
|
console.error(' peach daemon install')
|
package/cli/commands/swift.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
type SwiftModule,
|
|
11
11
|
} from '../../src/swift-distribution'
|
|
12
12
|
import { SWIFT_HMR_PATH, SWIFT_PACKAGE_PATH } from '../../src/swift-submit'
|
|
13
|
+
import { findXcodeProject } from '../../src/xcode-project'
|
|
13
14
|
import { authHeaderValue, resolveCliAuth } from '../auth'
|
|
14
15
|
import { PeachExit } from '../run-rnx'
|
|
15
16
|
import { runOpenCommand, type OpenCommandResources } from './control'
|
|
@@ -24,6 +25,7 @@ export async function runSwift(
|
|
|
24
25
|
const openArgs: string[] = []
|
|
25
26
|
let hostPort = 0
|
|
26
27
|
let uploadSource = false
|
|
28
|
+
let target: string | undefined
|
|
27
29
|
const valueFlags = new Set([
|
|
28
30
|
'--device',
|
|
29
31
|
'--driver',
|
|
@@ -43,7 +45,10 @@ export async function runSwift(
|
|
|
43
45
|
for (let index = 0; index < input.length; index++) {
|
|
44
46
|
const arg = input[index]
|
|
45
47
|
if (arg === '--upload-source') uploadSource = true
|
|
46
|
-
else if (arg === '--
|
|
48
|
+
else if (arg === '--target') {
|
|
49
|
+
target = input[++index]
|
|
50
|
+
if (!target || target.startsWith('-')) throw new Error('--target requires a value')
|
|
51
|
+
} else if (arg === '--host-port' || valueFlags.has(arg)) {
|
|
47
52
|
const value = input[++index]
|
|
48
53
|
if (!value || value.startsWith('-')) throw new Error(`${arg} requires a value`)
|
|
49
54
|
if (arg === '--host-port') {
|
|
@@ -54,10 +59,14 @@ export async function runSwift(
|
|
|
54
59
|
} else openArgs.push(arg, value)
|
|
55
60
|
} else if (booleanFlags.has(arg)) openArgs.push(arg)
|
|
56
61
|
else if (arg.startsWith('-')) throw new Error(`unknown peach swift flag: ${arg}`)
|
|
57
|
-
else if (packagePath) throw new Error('peach swift expects one
|
|
62
|
+
else if (packagePath) throw new Error('peach swift expects one project')
|
|
58
63
|
else packagePath = path.resolve(arg)
|
|
59
64
|
}
|
|
60
|
-
if (!packagePath)
|
|
65
|
+
if (!packagePath) {
|
|
66
|
+
throw new Error(
|
|
67
|
+
'usage: peach swift <SwiftPM directory | Xcode project or workspace> [--target <app target>]',
|
|
68
|
+
)
|
|
69
|
+
}
|
|
61
70
|
// local by default: this machine's swift.org toolchain compiles against the
|
|
62
71
|
// checkout's module or the distribution PEACH_SWIFT_ENDPOINT names, and no
|
|
63
72
|
// source leaves it. --upload-source compiles on Contrast instead.
|
|
@@ -91,14 +100,22 @@ export async function runSwift(
|
|
|
91
100
|
return 1
|
|
92
101
|
}
|
|
93
102
|
}
|
|
103
|
+
const host = await import('../../src/swift-host')
|
|
94
104
|
packagePath = fs.realpathSync(packagePath)
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
105
|
+
// a SwiftPM package compiles as itself; an xcode project compiles its
|
|
106
|
+
// application target, with the project directory as the package path.
|
|
107
|
+
const swiftPackage =
|
|
108
|
+
fs.statSync(packagePath).isDirectory() &&
|
|
109
|
+
fs.existsSync(path.join(packagePath, 'Package.swift'))
|
|
110
|
+
const xcodeproj = swiftPackage ? null : findXcodeProject(packagePath)
|
|
111
|
+
if (!swiftPackage && !xcodeproj) {
|
|
112
|
+
throw new Error(
|
|
113
|
+
'peach swift needs a directory containing Package.swift, or an Xcode project or workspace',
|
|
114
|
+
)
|
|
100
115
|
}
|
|
101
|
-
|
|
116
|
+
if (target && !xcodeproj)
|
|
117
|
+
throw new Error('--target selects an Xcode application target')
|
|
118
|
+
if (xcodeproj) packagePath = host.openXcodeProject(xcodeproj, target, module?.root)
|
|
102
119
|
// collection preflights every input path before any source bytes are read.
|
|
103
120
|
host.swiftPackageWatchFiles(packagePath, undefined)
|
|
104
121
|
const packageName = path.basename(packagePath)
|
package/cli/desktop-companion.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { execFileSync, spawn } from 'child_process'
|
|
|
2
2
|
import { existsSync, readdirSync } from 'fs'
|
|
3
3
|
import { dirname, join, resolve } from 'path'
|
|
4
4
|
import { fileURLToPath } from 'url'
|
|
5
|
+
import { activeDesktopHostApp } from '../src/desktop-host-delivery'
|
|
5
6
|
|
|
6
7
|
// resolved lazily — sootsim-engine is a workspace package in dev, but absent
|
|
7
8
|
// from the published npm tarball. don't crash module load just because the
|
|
@@ -26,6 +27,7 @@ export interface DesktopCompanionInstall {
|
|
|
26
27
|
platform: NodeJS.Platform
|
|
27
28
|
kind:
|
|
28
29
|
| 'native-mac-app'
|
|
30
|
+
| 'native-linux-app'
|
|
29
31
|
| 'mac-app'
|
|
30
32
|
| 'linux-appimage'
|
|
31
33
|
| 'linux-binary'
|
|
@@ -40,6 +42,7 @@ export interface DesktopCompanionLaunchResult {
|
|
|
40
42
|
launched: boolean
|
|
41
43
|
via?:
|
|
42
44
|
| 'native-mac-app'
|
|
45
|
+
| 'native-linux-app'
|
|
43
46
|
| 'mac-app'
|
|
44
47
|
| 'linux-appimage'
|
|
45
48
|
| 'linux-binary'
|
|
@@ -229,23 +232,47 @@ function findWindowsInstall(): DesktopCompanionInstall | null {
|
|
|
229
232
|
return null
|
|
230
233
|
}
|
|
231
234
|
|
|
235
|
+
export interface DesktopCompanionOptions {
|
|
236
|
+
// the native host: PEACH_DESKTOP_APP, else the active version
|
|
237
|
+
// `peach desktop install --native` installed under ~/.peach/desktop.
|
|
238
|
+
native?: boolean
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// an explicit PEACH_DESKTOP_APP selects the native host for every launch.
|
|
242
|
+
export function wantsNativeDesktop(opts: DesktopCompanionOptions = {}): boolean {
|
|
243
|
+
return opts.native === true || !!process.env.PEACH_DESKTOP_APP
|
|
244
|
+
}
|
|
245
|
+
|
|
232
246
|
export function getNativeDesktopAppPath(): string | null {
|
|
233
247
|
const explicitApp = process.env.PEACH_DESKTOP_APP
|
|
234
|
-
if (!explicitApp) return
|
|
235
|
-
if (process.platform
|
|
248
|
+
if (!explicitApp) return activeDesktopHostApp()
|
|
249
|
+
if (process.platform === 'darwin' && !explicitApp.endsWith('.app'))
|
|
236
250
|
throw new Error('PEACH_DESKTOP_APP must name a Mac .app bundle')
|
|
237
|
-
|
|
251
|
+
if (process.platform !== 'darwin' && process.platform !== 'linux')
|
|
252
|
+
throw new Error('native desktop requires macOS or Linux')
|
|
238
253
|
return resolve(explicitApp)
|
|
239
254
|
}
|
|
240
255
|
|
|
241
|
-
|
|
256
|
+
function findNativeDesktopCompanion(): DesktopCompanionInstall | null {
|
|
242
257
|
const appPath = getNativeDesktopAppPath()
|
|
243
|
-
if (appPath)
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
258
|
+
if (!appPath) return null
|
|
259
|
+
const mac = process.platform === 'darwin'
|
|
260
|
+
if (!existsSync(mac ? join(appPath, 'Contents/MacOS/PeachDesktop') : appPath)) {
|
|
261
|
+
throw new Error(
|
|
262
|
+
`native desktop executable missing in ${appPath}${mac ? ' (run `peach desktop install --native --force`)' : ''}`,
|
|
263
|
+
)
|
|
264
|
+
}
|
|
265
|
+
return {
|
|
266
|
+
path: appPath,
|
|
267
|
+
platform: process.platform,
|
|
268
|
+
kind: mac ? 'native-mac-app' : 'native-linux-app',
|
|
248
269
|
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export function findDesktopCompanion(
|
|
273
|
+
opts: DesktopCompanionOptions = {},
|
|
274
|
+
): DesktopCompanionInstall | null {
|
|
275
|
+
if (wantsNativeDesktop(opts)) return findNativeDesktopCompanion()
|
|
249
276
|
const dev = findDevElectron()
|
|
250
277
|
if (dev) return dev
|
|
251
278
|
if (isInRepoCheckout()) {
|