peachsim 0.1.713 → 0.1.715
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/commands/install-desktop.ts +74 -20
- package/cli/commands/maestro.ts +7 -337
- package/cli/commands/test.ts +1 -1
- package/cli/desktop-companion.ts +11 -6
- package/cli/maestro-workspace.ts +347 -0
- 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 +1 -1
- 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 +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- 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 +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +9 -5
- 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 +1 -1
- 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 +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +19 -11
- package/dist-lib/swift-compile.cjs +1 -1
- package/dist-lib/swift-compile.mjs +1 -1
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +1 -1
- package/dist-lib/vite.cjs +1 -1
- package/package.json +1 -1
|
@@ -24,8 +24,12 @@ import {
|
|
|
24
24
|
unlinkSync,
|
|
25
25
|
} from 'fs'
|
|
26
26
|
import { tmpdir } from 'os'
|
|
27
|
-
import { dirname, join, resolve } from 'path'
|
|
28
|
-
import {
|
|
27
|
+
import { basename, dirname, join, resolve } from 'path'
|
|
28
|
+
import {
|
|
29
|
+
findDesktopCompanion,
|
|
30
|
+
findInstalledDesktopCompanion,
|
|
31
|
+
getNativeDesktopAppPath,
|
|
32
|
+
} from '../desktop-companion'
|
|
29
33
|
import { confirm } from '../prompt'
|
|
30
34
|
import { rnxExit } from '../run-rnx'
|
|
31
35
|
import { accent, bold, failure, muted, success, withSpinner } from '../ui'
|
|
@@ -43,6 +47,18 @@ interface Target {
|
|
|
43
47
|
|
|
44
48
|
function detectTarget(): Target | null {
|
|
45
49
|
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
|
+
}
|
|
46
62
|
if (process.platform === 'darwin') {
|
|
47
63
|
const platform: TargetPlatform = arch === 'arm64' ? 'mac-arm64' : 'mac-x64'
|
|
48
64
|
const filename = `peach-latest-${platform}.dmg`
|
|
@@ -128,7 +144,7 @@ function renderProgress(received: number, total: number | null): string {
|
|
|
128
144
|
return ` ${bar} ${pct}% ${mb} / ${totalMb} MB`
|
|
129
145
|
}
|
|
130
146
|
|
|
131
|
-
async function installMacDmg(dmgPath: string): Promise<string> {
|
|
147
|
+
async function installMacDmg(dmgPath: string, nativeApp?: string): Promise<string> {
|
|
132
148
|
const mountOutput = spawnSync(
|
|
133
149
|
'hdiutil',
|
|
134
150
|
['attach', '-nobrowse', '-readonly', dmgPath],
|
|
@@ -148,36 +164,61 @@ async function installMacDmg(dmgPath: string): Promise<string> {
|
|
|
148
164
|
throw new Error(`could not determine dmg mount point (output: ${mountOutput.stdout})`)
|
|
149
165
|
}
|
|
150
166
|
|
|
151
|
-
const
|
|
167
|
+
const appName = nativeApp ? 'PeachDesktop.app' : 'peach.app'
|
|
168
|
+
const appSource = join(mountPoint, appName)
|
|
152
169
|
if (!existsSync(appSource)) {
|
|
153
170
|
spawnSync('hdiutil', ['detach', '-force', mountPoint])
|
|
154
|
-
throw new Error(
|
|
171
|
+
throw new Error(`${appName} not found inside ${mountPoint}`)
|
|
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
|
+
}
|
|
155
192
|
}
|
|
156
193
|
|
|
157
194
|
// prefer /Applications if writable, otherwise ~/Applications (same paths
|
|
158
195
|
// findInstalledDesktopCompanion checks, so no extra config needed post-install).
|
|
159
196
|
const systemApps = '/Applications'
|
|
160
197
|
const userApps = resolve(process.env.HOME || '', 'Applications')
|
|
161
|
-
let destRoot = systemApps
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
198
|
+
let destRoot = nativeApp ? dirname(nativeApp) : systemApps
|
|
199
|
+
if (!nativeApp)
|
|
200
|
+
try {
|
|
201
|
+
const probe = join(systemApps, `.peach-write-probe-${process.pid}`)
|
|
202
|
+
spawnSync('touch', [probe])
|
|
203
|
+
if (existsSync(probe)) rmSync(probe, { force: true })
|
|
204
|
+
else destRoot = userApps
|
|
205
|
+
} catch {
|
|
206
|
+
destRoot = userApps
|
|
207
|
+
}
|
|
208
|
+
if (nativeApp || destRoot === userApps) {
|
|
171
209
|
mkdirSync(destRoot, { recursive: true })
|
|
172
210
|
}
|
|
173
211
|
|
|
174
|
-
const appDest = join(destRoot, 'peach.app')
|
|
212
|
+
const appDest = nativeApp || join(destRoot, 'peach.app')
|
|
175
213
|
|
|
176
214
|
// copy alongside the destination and swap, rather than deleting the installed
|
|
177
215
|
// app first. removing it up front means a failed copy leaves the user with no
|
|
178
216
|
// app at all, having destroyed a working install to do it. the staging path is
|
|
179
217
|
// in the same directory so the swap is a rename on one volume.
|
|
180
|
-
const staging = join(
|
|
218
|
+
const staging = join(
|
|
219
|
+
destRoot,
|
|
220
|
+
`.${basename(appDest, '.app')}-incoming-${process.pid}.app`,
|
|
221
|
+
)
|
|
181
222
|
rmSync(staging, { recursive: true, force: true })
|
|
182
223
|
|
|
183
224
|
const copy = spawnSync('cp', ['-R', appSource, staging])
|
|
@@ -188,7 +229,10 @@ async function installMacDmg(dmgPath: string): Promise<string> {
|
|
|
188
229
|
}
|
|
189
230
|
const detach = spawnSync('hdiutil', ['detach', '-force', mountPoint])
|
|
190
231
|
|
|
191
|
-
const previous = join(
|
|
232
|
+
const previous = join(
|
|
233
|
+
destRoot,
|
|
234
|
+
`.${basename(appDest, '.app')}-previous-${process.pid}.app`,
|
|
235
|
+
)
|
|
192
236
|
if (existsSync(appDest)) {
|
|
193
237
|
const park = spawnSync('mv', [appDest, previous])
|
|
194
238
|
if (park.status !== 0) {
|
|
@@ -271,6 +315,9 @@ options:
|
|
|
271
315
|
-y, --yes skip confirmation and install immediately
|
|
272
316
|
--force reinstall even if the companion is already present
|
|
273
317
|
|
|
318
|
+
Set PEACH_DESKTOP_APP=/absolute/PeachDesktop.app to install native staging there.
|
|
319
|
+
The same variable selects that app when launching. Without it, install uses Electron.
|
|
320
|
+
|
|
274
321
|
examples:
|
|
275
322
|
peach desktop install
|
|
276
323
|
peach desktop install --yes
|
|
@@ -286,7 +333,12 @@ examples:
|
|
|
286
333
|
!process.stdin.isTTY
|
|
287
334
|
const force = args.includes('--force')
|
|
288
335
|
|
|
289
|
-
const
|
|
336
|
+
const nativeApp = getNativeDesktopAppPath()
|
|
337
|
+
const existing = nativeApp
|
|
338
|
+
? existsSync(nativeApp)
|
|
339
|
+
? findDesktopCompanion()
|
|
340
|
+
: null
|
|
341
|
+
: findInstalledDesktopCompanion()
|
|
290
342
|
if (existing && !force) {
|
|
291
343
|
console.log(` ${success('✓')} Desktop app is already installed at ${existing.path}`)
|
|
292
344
|
console.log(` ${muted('Pass --force to reinstall.')}`)
|
|
@@ -371,7 +423,9 @@ examples:
|
|
|
371
423
|
// the download is good, only placing the app failed. on macOS the disk
|
|
372
424
|
// image installs itself perfectly well by hand, so open it and let the user
|
|
373
425
|
// drag rather than leaving them at a dead end. keep workDir for that.
|
|
374
|
-
if (
|
|
426
|
+
if (nativeApp) {
|
|
427
|
+
rmSync(workDir, { recursive: true, force: true })
|
|
428
|
+
} else if (process.platform === 'darwin') {
|
|
375
429
|
spawnSync('open', [downloadPath])
|
|
376
430
|
console.error(` Opened ${target.filename} — drag peach to Applications to finish.`)
|
|
377
431
|
} else {
|
package/cli/commands/maestro.ts
CHANGED
|
@@ -21,6 +21,13 @@ import {
|
|
|
21
21
|
type JUnitCaseInput,
|
|
22
22
|
type SessionLogFlow,
|
|
23
23
|
} from '../maestro-report'
|
|
24
|
+
import {
|
|
25
|
+
collectFlowFiles,
|
|
26
|
+
extractMaestroCompatFlags,
|
|
27
|
+
loadMaestroWorkspaceConfig,
|
|
28
|
+
type MaestroCompatOptions,
|
|
29
|
+
type MaestroWorkspaceConfig,
|
|
30
|
+
} from '../maestro-workspace'
|
|
24
31
|
import { registerRun, shouldRegisterRun, stepSummaryFromTrace } from '../run-registry'
|
|
25
32
|
import { RnxExit } from '../run-rnx'
|
|
26
33
|
import {
|
|
@@ -204,219 +211,6 @@ export function applyEnvFlags(args: string[]): string[] {
|
|
|
204
211
|
return out
|
|
205
212
|
}
|
|
206
213
|
|
|
207
|
-
// maestro-cli flags this command consumes itself, accepted so an existing
|
|
208
|
-
// script can swap `maestro test` for `peach maestro test` unedited. each one
|
|
209
|
-
// either takes effect below or says out loud that it does not: an option
|
|
210
|
-
// that is quietly dropped is how a run reports success while doing something
|
|
211
|
-
// other than what was asked. `--origin` is consumed here because only this
|
|
212
|
-
// command reads it; everything this function leaves alone rides on to the
|
|
213
|
-
// flow runner, which rejects what it does not know.
|
|
214
|
-
//
|
|
215
|
-
// both `--flag value` and `--flag=value` spellings work: maestro's own docs
|
|
216
|
-
// use the `=` form for tags and output dirs, so rejecting it would break the
|
|
217
|
-
// exact command lines users paste from there.
|
|
218
|
-
export interface MaestroCompatOptions {
|
|
219
|
-
// null = flag absent. CLI lists take precedence over config.yaml (maestro
|
|
220
|
-
// documents CLI-always-wins), so absent must stay distinguishable from [].
|
|
221
|
-
includeTags: string[] | null
|
|
222
|
-
excludeTags: string[] | null
|
|
223
|
-
configPath: string | null
|
|
224
|
-
format: string | null
|
|
225
|
-
output: string | null
|
|
226
|
-
testOutputDir: string | null
|
|
227
|
-
debugOutput: string | null
|
|
228
|
-
platform: string | null
|
|
229
|
-
testSuiteName: string | null
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
const MAESTRO_COMPAT_VALUE_FLAGS = new Set([
|
|
233
|
-
'--include-tags',
|
|
234
|
-
'--exclude-tags',
|
|
235
|
-
'--config',
|
|
236
|
-
'--format',
|
|
237
|
-
'--output',
|
|
238
|
-
'--test-output-dir',
|
|
239
|
-
'--debug-output',
|
|
240
|
-
'--platform',
|
|
241
|
-
'--udid',
|
|
242
|
-
'--test-suite-name',
|
|
243
|
-
'--shards',
|
|
244
|
-
'--shard-all',
|
|
245
|
-
'--shard-split',
|
|
246
|
-
'--api-key',
|
|
247
|
-
'--api-url',
|
|
248
|
-
'--screen-size',
|
|
249
|
-
])
|
|
250
|
-
|
|
251
|
-
// shared with the cloud submitter, which resolves tag selection before any
|
|
252
|
-
// hosted job exists the same way a local workspace run does.
|
|
253
|
-
export function splitTagList(value: string): string[] {
|
|
254
|
-
return value
|
|
255
|
-
.split(',')
|
|
256
|
-
.map((tag) => tag.trim())
|
|
257
|
-
.filter((tag) => tag.length > 0)
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
export function extractMaestroCompatFlags(args: string[]): {
|
|
261
|
-
rest: string[]
|
|
262
|
-
compat: MaestroCompatOptions
|
|
263
|
-
} {
|
|
264
|
-
const compat: MaestroCompatOptions = {
|
|
265
|
-
includeTags: null,
|
|
266
|
-
excludeTags: null,
|
|
267
|
-
configPath: null,
|
|
268
|
-
format: null,
|
|
269
|
-
output: null,
|
|
270
|
-
testOutputDir: null,
|
|
271
|
-
debugOutput: null,
|
|
272
|
-
platform: null,
|
|
273
|
-
testSuiteName: null,
|
|
274
|
-
}
|
|
275
|
-
const rest: string[] = []
|
|
276
|
-
for (let i = 0; i < args.length; i++) {
|
|
277
|
-
const a = args[i]
|
|
278
|
-
const eq = a.indexOf('=')
|
|
279
|
-
const head = eq > 0 ? a.slice(0, eq) : a
|
|
280
|
-
if (MAESTRO_COMPAT_VALUE_FLAGS.has(head)) {
|
|
281
|
-
const inline = eq > 0 ? a.slice(eq + 1) : null
|
|
282
|
-
const next = args[i + 1]
|
|
283
|
-
const value =
|
|
284
|
-
inline !== null && inline.length > 0
|
|
285
|
-
? inline
|
|
286
|
-
: next !== undefined && !next.startsWith('-')
|
|
287
|
-
? next
|
|
288
|
-
: null
|
|
289
|
-
if (inline === null || inline.length === 0) i += 1
|
|
290
|
-
if (value === null || value.length === 0) {
|
|
291
|
-
throw new Error(`${head} expects a value`)
|
|
292
|
-
}
|
|
293
|
-
switch (head) {
|
|
294
|
-
case '--include-tags':
|
|
295
|
-
compat.includeTags = [...(compat.includeTags ?? []), ...splitTagList(value)]
|
|
296
|
-
break
|
|
297
|
-
case '--exclude-tags':
|
|
298
|
-
compat.excludeTags = [...(compat.excludeTags ?? []), ...splitTagList(value)]
|
|
299
|
-
break
|
|
300
|
-
case '--config':
|
|
301
|
-
compat.configPath = value
|
|
302
|
-
break
|
|
303
|
-
case '--format':
|
|
304
|
-
// maestro spells it JUNIT; normalize so either case works.
|
|
305
|
-
compat.format = value.toLowerCase()
|
|
306
|
-
break
|
|
307
|
-
case '--output':
|
|
308
|
-
compat.output = value
|
|
309
|
-
break
|
|
310
|
-
case '--test-output-dir':
|
|
311
|
-
compat.testOutputDir = value
|
|
312
|
-
break
|
|
313
|
-
case '--debug-output':
|
|
314
|
-
compat.debugOutput = value
|
|
315
|
-
break
|
|
316
|
-
case '--platform':
|
|
317
|
-
if (value.toLowerCase() !== 'ios') {
|
|
318
|
-
throw new Error(
|
|
319
|
-
`peach emulates iOS only; --platform ${value} is not supported`,
|
|
320
|
-
)
|
|
321
|
-
}
|
|
322
|
-
compat.platform = value
|
|
323
|
-
break
|
|
324
|
-
case '--udid':
|
|
325
|
-
console.warn(
|
|
326
|
-
' warn: --udid selects a Maestro simulator; peach manages its own sim — pin one with --sim instead',
|
|
327
|
-
)
|
|
328
|
-
break
|
|
329
|
-
case '--test-suite-name':
|
|
330
|
-
compat.testSuiteName = value
|
|
331
|
-
break
|
|
332
|
-
case '--shards':
|
|
333
|
-
case '--shard-all':
|
|
334
|
-
case '--shard-split':
|
|
335
|
-
console.warn(
|
|
336
|
-
` warn: ${head} shards across Maestro devices; peach runs the full selection on one sim`,
|
|
337
|
-
)
|
|
338
|
-
break
|
|
339
|
-
case '--api-key':
|
|
340
|
-
case '--api-url':
|
|
341
|
-
console.warn(` warn: ${head} is Maestro beta AI analysis; peach ignores it`)
|
|
342
|
-
break
|
|
343
|
-
case '--screen-size':
|
|
344
|
-
console.warn(' warn: --screen-size is web-only; peach ignores it')
|
|
345
|
-
break
|
|
346
|
-
}
|
|
347
|
-
continue
|
|
348
|
-
}
|
|
349
|
-
if (a === '--origin') {
|
|
350
|
-
// read above for the run-registration origin. the flow runner has no
|
|
351
|
-
// --origin, so it must not ride into playbackArgs.
|
|
352
|
-
i += 1
|
|
353
|
-
continue
|
|
354
|
-
}
|
|
355
|
-
if (a === '-d') {
|
|
356
|
-
// maestro's short form for --device. peach's device flag names a device
|
|
357
|
-
// model, and the flow runner reads it under the long spelling only.
|
|
358
|
-
rest.push('--device')
|
|
359
|
-
continue
|
|
360
|
-
}
|
|
361
|
-
if (a === '--no-ansi' || a === '--no-color') {
|
|
362
|
-
// trivially satisfied: peach prints no ANSI escapes anywhere on this path.
|
|
363
|
-
continue
|
|
364
|
-
}
|
|
365
|
-
if (a === '--ansi' || a === '--color') {
|
|
366
|
-
console.warn(' warn: peach prints no ANSI escapes; colored output is unavailable')
|
|
367
|
-
continue
|
|
368
|
-
}
|
|
369
|
-
if (a === '--continuous' || a === '-c') {
|
|
370
|
-
console.warn(' warn: --continuous is not implemented in peach — running once')
|
|
371
|
-
continue
|
|
372
|
-
}
|
|
373
|
-
if (a === '--flatten-debug-output') {
|
|
374
|
-
// peach writes one <dir>/maestro.log with no per-run subfolders or
|
|
375
|
-
// timestamps, so the maestro layout flag is already satisfied.
|
|
376
|
-
continue
|
|
377
|
-
}
|
|
378
|
-
if (a === '--analyze') {
|
|
379
|
-
console.warn(' warn: --analyze is Maestro beta AI analysis; peach ignores it')
|
|
380
|
-
continue
|
|
381
|
-
}
|
|
382
|
-
if (a === '-s') {
|
|
383
|
-
const count = args[i + 1]
|
|
384
|
-
if (!count || count.startsWith('-')) throw new Error('-s expects a value')
|
|
385
|
-
i += 1
|
|
386
|
-
console.warn(
|
|
387
|
-
' warn: -s shards across Maestro devices; peach runs the full selection on one sim',
|
|
388
|
-
)
|
|
389
|
-
continue
|
|
390
|
-
}
|
|
391
|
-
if (head === '-p') {
|
|
392
|
-
// -p is the peach bridge-port short, not maestro's --platform short. a
|
|
393
|
-
// non-numeric value is a pasted maestro command line; fail loud with
|
|
394
|
-
// the mapping instead of pinning the bridge to a NaN port.
|
|
395
|
-
const value = eq > 0 ? a.slice(eq + 1) : args[i + 1]
|
|
396
|
-
if (value !== undefined && !value.startsWith('-') && !/^\d+$/.test(value)) {
|
|
397
|
-
throw new Error(
|
|
398
|
-
`-p is the peach bridge-port short; use --platform for the Maestro platform (got ${JSON.stringify(value)})`,
|
|
399
|
-
)
|
|
400
|
-
}
|
|
401
|
-
rest.push(a)
|
|
402
|
-
continue
|
|
403
|
-
}
|
|
404
|
-
rest.push(a)
|
|
405
|
-
}
|
|
406
|
-
if (
|
|
407
|
-
compat.format !== null &&
|
|
408
|
-
!['junit', 'html', 'html-detailed', 'noop'].includes(compat.format)
|
|
409
|
-
) {
|
|
410
|
-
throw new Error(`unsupported --format: ${compat.format} (peach writes junit reports)`)
|
|
411
|
-
}
|
|
412
|
-
if (compat.format === 'html' || compat.format === 'html-detailed') {
|
|
413
|
-
console.warn(
|
|
414
|
-
' warn: --format html is not implemented in peach — running without a report',
|
|
415
|
-
)
|
|
416
|
-
}
|
|
417
|
-
return { rest, compat }
|
|
418
|
-
}
|
|
419
|
-
|
|
420
214
|
function findDefaultMaestroTarget(cwd: string): string | null {
|
|
421
215
|
for (const dir of MAESTRO_DIRS) {
|
|
422
216
|
const abs = path.join(cwd, dir)
|
|
@@ -425,130 +219,6 @@ function findDefaultMaestroTarget(cwd: string): string | null {
|
|
|
425
219
|
return null
|
|
426
220
|
}
|
|
427
221
|
|
|
428
|
-
interface MaestroWorkspaceConfig {
|
|
429
|
-
flows?: string[]
|
|
430
|
-
includeTags?: string[]
|
|
431
|
-
excludeTags?: string[]
|
|
432
|
-
testOutputDir?: string
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
export interface CollectFlowFilesOptions {
|
|
436
|
-
// explicit `--config <path>`; globs still resolve under the target dir.
|
|
437
|
-
configPath?: string
|
|
438
|
-
// CLI tag lists; null/undefined falls back to the workspace config (maestro
|
|
439
|
-
// documents CLI-always-wins, never a union).
|
|
440
|
-
includeTags?: string[] | null
|
|
441
|
-
excludeTags?: string[] | null
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
// read the workspace config for a directory target: an explicit --config
|
|
445
|
-
// path, else config.yaml/config.yml beside the flows, else empty policy.
|
|
446
|
-
export function loadMaestroWorkspaceConfig(
|
|
447
|
-
dir: string,
|
|
448
|
-
configPath?: string,
|
|
449
|
-
): { path: string | null; config: MaestroWorkspaceConfig } {
|
|
450
|
-
const found =
|
|
451
|
-
configPath ??
|
|
452
|
-
['config.yaml', 'config.yml']
|
|
453
|
-
.map((name) => path.join(dir, name))
|
|
454
|
-
.find((p) => fs.existsSync(p))
|
|
455
|
-
if (!found) return { path: null, config: {} }
|
|
456
|
-
if (!fs.existsSync(found)) {
|
|
457
|
-
throw new Error(`maestro config not found: ${configPath}`)
|
|
458
|
-
}
|
|
459
|
-
// yaml.parse returns any; shape-check the fields we use below instead
|
|
460
|
-
// of trusting the file
|
|
461
|
-
const parsed: unknown = yaml.parse(fs.readFileSync(found, 'utf8'))
|
|
462
|
-
if (!parsed || typeof parsed !== 'object') return { path: found, config: {} }
|
|
463
|
-
const raw = parsed as Record<string, unknown>
|
|
464
|
-
const config: MaestroWorkspaceConfig = {}
|
|
465
|
-
if (Array.isArray(raw.flows)) {
|
|
466
|
-
config.flows = raw.flows.filter((g): g is string => typeof g === 'string')
|
|
467
|
-
}
|
|
468
|
-
if (Array.isArray(raw.includeTags)) {
|
|
469
|
-
config.includeTags = raw.includeTags.filter((t): t is string => typeof t === 'string')
|
|
470
|
-
}
|
|
471
|
-
if (Array.isArray(raw.excludeTags)) {
|
|
472
|
-
config.excludeTags = raw.excludeTags.filter((t): t is string => typeof t === 'string')
|
|
473
|
-
}
|
|
474
|
-
if (typeof raw.testOutputDir === 'string' && raw.testOutputDir.length > 0) {
|
|
475
|
-
config.testOutputDir = raw.testOutputDir
|
|
476
|
-
}
|
|
477
|
-
return { path: found, config }
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
// workspace planning for directory targets — mirrors maestro's
|
|
481
|
-
// WorkspaceExecutionPlanner: discover config.yaml/config.yml in the
|
|
482
|
-
// directory, walk it recursively for *.yaml/*.yml flow files (config files
|
|
483
|
-
// excluded), keep the ones matching the config's `flows:` globs (default
|
|
484
|
-
// `*` = top level only; `!`-prefixed globs subtract from the positive
|
|
485
|
-
// matches), then filter by includeTags/excludeTags against each flow's
|
|
486
|
-
// frontmatter `tags:` (OR within a flag, include-then-exclude between them).
|
|
487
|
-
//
|
|
488
|
-
// an explicit file target always runs: maestro runs a named flow even when
|
|
489
|
-
// its tags would exclude it from a directory run.
|
|
490
|
-
export function collectFlowFiles(
|
|
491
|
-
target: string,
|
|
492
|
-
opts: CollectFlowFilesOptions = {},
|
|
493
|
-
): string[] {
|
|
494
|
-
const stat = fs.statSync(target)
|
|
495
|
-
if (stat.isFile()) return [target]
|
|
496
|
-
if (!stat.isDirectory()) {
|
|
497
|
-
throw new Error(`not a file or directory: ${target}`)
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
const { path: configPath, config } = loadMaestroWorkspaceConfig(target, opts.configPath)
|
|
501
|
-
|
|
502
|
-
const globs =
|
|
503
|
-
Array.isArray(config.flows) && config.flows.length > 0 ? config.flows : ['*']
|
|
504
|
-
const positive = globs.filter((glob) => !glob.startsWith('!'))
|
|
505
|
-
const negative = globs
|
|
506
|
-
.filter((glob) => glob.startsWith('!'))
|
|
507
|
-
.map((glob) => glob.slice(1))
|
|
508
|
-
.filter((glob) => glob.length > 0)
|
|
509
|
-
if (positive.length === 0) {
|
|
510
|
-
throw new Error(
|
|
511
|
-
`flows: needs at least one positive pattern in ${configPath ?? target} (got only exclusions)`,
|
|
512
|
-
)
|
|
513
|
-
}
|
|
514
|
-
const isFlowFile = (rel: string) => {
|
|
515
|
-
const base = path.basename(rel)
|
|
516
|
-
if (base.startsWith('.')) return false
|
|
517
|
-
if (!base.endsWith('.yaml') && !base.endsWith('.yml')) return false
|
|
518
|
-
if (base === 'config.yaml' || base === 'config.yml') return false
|
|
519
|
-
return true
|
|
520
|
-
}
|
|
521
|
-
const matched = new Set<string>()
|
|
522
|
-
for (const glob of positive) {
|
|
523
|
-
for (const rel of fs.globSync(glob, { cwd: target })) {
|
|
524
|
-
if (!isFlowFile(rel)) continue
|
|
525
|
-
const abs = path.join(target, rel)
|
|
526
|
-
if (fs.existsSync(abs) && fs.statSync(abs).isFile()) matched.add(abs)
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
for (const glob of negative) {
|
|
530
|
-
for (const rel of fs.globSync(glob, { cwd: target })) {
|
|
531
|
-
matched.delete(path.join(target, rel))
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
let files = [...matched].sort()
|
|
535
|
-
|
|
536
|
-
const includeTags = opts.includeTags ?? config.includeTags ?? []
|
|
537
|
-
const excludeTags = opts.excludeTags ?? config.excludeTags ?? []
|
|
538
|
-
if (includeTags.length > 0 || excludeTags.length > 0) {
|
|
539
|
-
files = files.filter((file) => {
|
|
540
|
-
const { frontmatter } = parseFlowFile(fs.readFileSync(file, 'utf8'))
|
|
541
|
-
const tags: string[] = Array.isArray(frontmatter.tags) ? frontmatter.tags : []
|
|
542
|
-
if (includeTags.length > 0 && !tags.some((t) => includeTags.includes(t))) {
|
|
543
|
-
return false
|
|
544
|
-
}
|
|
545
|
-
if (tags.some((t) => excludeTags.includes(t))) return false
|
|
546
|
-
return true
|
|
547
|
-
})
|
|
548
|
-
}
|
|
549
|
-
return files
|
|
550
|
-
}
|
|
551
|
-
|
|
552
222
|
function flowFileStem(file: string): string {
|
|
553
223
|
return path.basename(file).replace(/\.(ya?ml)$/i, '')
|
|
554
224
|
}
|
package/cli/commands/test.ts
CHANGED
|
@@ -884,7 +884,7 @@ export async function runCloudTest(
|
|
|
884
884
|
}
|
|
885
885
|
}
|
|
886
886
|
if (maestroTarget && statSync(targetPath).isDirectory()) {
|
|
887
|
-
const { collectFlowFiles, splitTagList } = await import('
|
|
887
|
+
const { collectFlowFiles, splitTagList } = await import('../maestro-workspace')
|
|
888
888
|
const tagFlag = (name: string): string[] | null => {
|
|
889
889
|
let values: string[] | null = null
|
|
890
890
|
for (let i = 0; i < forwarded.length; i++) {
|
package/cli/desktop-companion.ts
CHANGED
|
@@ -229,13 +229,18 @@ function findWindowsInstall(): DesktopCompanionInstall | null {
|
|
|
229
229
|
return null
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
-
export function
|
|
232
|
+
export function getNativeDesktopAppPath(): string | null {
|
|
233
233
|
const explicitApp = process.env.PEACH_DESKTOP_APP
|
|
234
|
-
if (explicitApp)
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
234
|
+
if (!explicitApp) return null
|
|
235
|
+
if (process.platform !== 'darwin' || !explicitApp.endsWith('.app')) {
|
|
236
|
+
throw new Error('PEACH_DESKTOP_APP must name a Mac .app bundle')
|
|
237
|
+
}
|
|
238
|
+
return resolve(explicitApp)
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export function findDesktopCompanion(): DesktopCompanionInstall | null {
|
|
242
|
+
const appPath = getNativeDesktopAppPath()
|
|
243
|
+
if (appPath) {
|
|
239
244
|
if (!existsSync(join(appPath, 'Contents/MacOS/PeachDesktop'))) {
|
|
240
245
|
throw new Error(`native desktop executable missing in ${appPath}`)
|
|
241
246
|
}
|