peachsim 0.1.1667 → 0.1.1674
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/README.md +1 -1
- package/cli/bridge-flow-runner.ts +4 -1
- package/cli/commands/coverage-swift.ts +291 -0
- package/cli/commands/coverage.ts +168 -24
- package/cli/commands/diagnose.ts +1 -19
- package/cli/commands/inspect/settling.ts +37 -4
- package/cli/commands/react.ts +3 -18
- package/cli/commands/screenshot.ts +1 -1
- package/cli/commands/screenshots-capture.ts +1 -1
- package/cli/drivers/playwright-provisioning.ts +1 -4
- package/cli/drivers/playwright.ts +15 -1
- package/cli/scene-video.ts +1 -1
- package/cli/ui.ts +20 -0
- package/cli/ws-bridge.ts +7 -36
- package/detox/frame-identity.cjs +21 -0
- package/detox/frame-identity.d.cts +6 -0
- package/detox/index.ts +39 -33
- package/detox/jest-environment.cjs +4 -1
- package/detox/jest-setup-after-env.cjs +0 -4
- package/detox/navigation-lifecycle.ts +2 -2
- package/detox/proof-observer.ts +126 -0
- package/dist-lib/agent-daemon-client.cjs +29 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +10 -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/bundle-channel.cjs +557 -158
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +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/config.mjs +1 -1
- package/dist-lib/detox/index.cjs +5098 -7344
- package/dist-lib/detox/jest-environment.cjs +4 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +602 -152
- package/dist-lib/expo-swift-metadata.cjs +1 -1
- package/dist-lib/expo-swift-metadata.mjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +688 -194
- package/dist-lib/host/fetch-proxy-handler.cjs +6 -3
- 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 +247 -11
- 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 +10 -1
- package/dist-lib/metro-production-bundle.mjs +12 -1
- package/dist-lib/metro.cjs +155 -5
- package/dist-lib/native-app-identity-project.cjs +43 -5
- package/dist-lib/native-app-identity-project.mjs +43 -5
- 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 +21 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +73 -27
- package/dist-lib/public-origins-lib-static.json +1 -1
- package/dist-lib/public-origins-lib.json +563 -183
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/reap-browser.cjs +964 -0
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +38 -5
- package/dist-lib/sdk.mjs +38 -5
- package/dist-lib/skills.cjs +1031 -530
- package/dist-lib/swift-compile.cjs +298 -86
- package/dist-lib/swift-compile.mjs +298 -86
- package/dist-lib/swift-package.cjs +53 -4
- package/dist-lib/swift-package.mjs +52 -4
- package/dist-lib/swift-submit.cjs +2 -2
- package/dist-lib/swift-submit.mjs +2 -2
- package/dist-lib/swift-toolchain.cjs +25 -44
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +603 -114
- package/dist-lib/vite.cjs +65 -3
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-engine/src/engine/clipboardContract.d.ts +7 -0
- package/dist-types/packages/peach-engine/src/engine/glass-material.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +2 -0
- package/dist-types/packages/peach-engine/src/engine/inspect-outline.d.ts +2 -1
- package/dist-types/packages/peach-engine/src/engine/liquid-glass.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/engine/paint-boundary.d.ts +4 -1
- package/dist-types/packages/peach-engine/src/render-worker/host-service-protocol.d.ts +7 -0
- package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime-kind.d.ts +24 -0
- package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime.d.ts +4 -2
- package/dist-types/packages/peach-engine/src/rolldown-bundle-inventory.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/settings/devices.d.ts +1 -0
- package/dist-types/packages/peach-globals/src/clipboardBridgeContract.d.ts +18 -0
- package/dist-types/packages/peach-globals/src/compositorBridgeContract.d.ts +10 -1
- package/dist-types/packages/peach-globals/src/index.d.ts +2 -2
- package/dist-types/packages/peach-globals/src/nodeContract.d.ts +1 -0
- package/dist-types/packages/peach-kit/src/capabilities.d.ts +1 -0
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFString.h +2 -0
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h +54 -0
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h +23 -4
- package/sdk/ios/System/Library/Frameworks/SystemConfiguration.framework/Headers/SCDynamicStore.h +439 -0
- package/sdk/ios/System/Library/Frameworks/SystemConfiguration.framework/Headers/SCDynamicStoreCopySpecific.h +216 -0
- package/sdk/ios/System/Library/Frameworks/SystemConfiguration.framework/Headers/SCDynamicStoreKey.h +267 -0
- package/sdk/ios/System/Library/Frameworks/SystemConfiguration.framework/Headers/SCNetwork.h +204 -0
- package/sdk/ios/System/Library/Frameworks/SystemConfiguration.framework/Headers/SCNetworkConfiguration.h +1393 -0
- package/sdk/ios/System/Library/Frameworks/SystemConfiguration.framework/Headers/SCNetworkConnection.h +568 -0
- package/sdk/ios/System/Library/Frameworks/SystemConfiguration.framework/Headers/SCNetworkReachability.h +369 -0
- package/sdk/ios/System/Library/Frameworks/SystemConfiguration.framework/Headers/SCPreferences.h +473 -0
- package/sdk/ios/System/Library/Frameworks/SystemConfiguration.framework/Headers/SCPreferencesPath.h +179 -0
- package/sdk/ios/System/Library/Frameworks/SystemConfiguration.framework/Headers/SCPreferencesSetSpecific.h +95 -0
- package/sdk/ios/System/Library/Frameworks/SystemConfiguration.framework/Headers/SCSchemaDefinitions.h +2395 -0
- package/sdk/ios/System/Library/Frameworks/SystemConfiguration.framework/Headers/SystemConfiguration.h +184 -0
- package/sdk/ios/usr/include/_ctype.h +388 -0
- package/sdk/ios/usr/include/_inttypes.h +296 -0
- package/sdk/ios/usr/include/_locale.h +83 -0
- package/sdk/ios/usr/include/_locale_posix2008.h +65 -0
- package/sdk/ios/usr/include/_time.h +207 -0
- package/sdk/ios/usr/include/ctype.h +70 -0
- package/sdk/ios/usr/include/dispatch/dispatch.h +69 -6
- package/sdk/ios/usr/include/inttypes.h +35 -0
- package/sdk/ios/usr/include/libkern/OSByteOrder.h +315 -0
- package/sdk/ios/usr/include/libkern/machine/OSByteOrder.h +147 -0
- package/sdk/ios/usr/include/locale.h +59 -0
- package/sdk/ios/usr/include/runetype.h +118 -0
- package/sdk/ios/usr/include/setjmp.h +99 -0
- package/sdk/ios/usr/include/sys/_types/_clock_t.h +32 -0
- package/sdk/ios/usr/include/sys/_types/_ct_rune_t.h +33 -0
- package/sdk/ios/usr/include/sys/_types/_rune_t.h +32 -0
- package/sdk/ios/usr/include/sys/_types/_time_t.h +32 -0
- package/sdk/ios/usr/include/sys/_types/_wint_t.h +33 -0
- package/sdk/ios/usr/include/sys/cdefs.h +2 -0
- package/sdk/ios/usr/include/time.h +67 -2
- package/src/bridge-contract.ts +42 -0
- package/src/chromium-admission.ts +196 -0
- package/src/host/bridge-host.ts +6 -43
- package/src/host/rolldown-bundle-forward.ts +4 -1
- package/src/launch-deadline.ts +74 -0
- package/src/nitro-adapter.lock.json +3 -3
- package/src/profiles.ts +21 -0
- package/src/react-native-coverage/capability-reference-resolution.ts +402 -0
- package/src/react-native-coverage/capability-source-references.ts +1296 -0
- package/src/react-native-coverage/native-typescript-parser.ts +74 -0
- package/src/react-native-coverage/project-aliases.ts +207 -0
- package/src/react-native-coverage/verified-reach.ts +47 -0
- package/src/reap-browser.ts +1019 -0
- package/src/skills/builtin/a11y-review.ts +1 -1
- package/src/skills/builtin/perf-profile.ts +1 -1
- package/src/skills/builtin/screenshot-all.ts +1 -1
- package/src/skills/builtin/visual-diff.ts +1 -1
- package/src/swift-compile.ts +109 -57
- package/src/swift-coverage/indexdump.ts +80 -0
- package/src/swift-coverage/indexing.ts +147 -0
- package/src/swift-coverage/package.ts +230 -0
- package/src/swift-coverage/provenance.ts +47 -0
- package/src/swift-coverage/reader.ts +81 -0
- package/src/swift-coverage/source.ts +252 -0
- package/src/swift-coverage/types.ts +58 -0
- package/src/swift-coverage/xcode-assets.ts +175 -0
- package/src/swift-coverage/xcode-bridging.ts +160 -0
- package/src/swift-coverage/xcode-packages.ts +251 -0
- package/src/swift-coverage/xcode-strings.ts +78 -0
- package/src/swift-coverage/xcode.ts +656 -0
- package/src/swift-distribution.lock.json +8 -8
- package/src/swift-host.ts +21 -1
- package/src/swift-objc-compile.ts +7 -3
- package/src/swift-objc-import.ts +191 -27
- package/src/swift-objc-metadata.ts +2 -2
- package/src/swift-objc-standin.ts +9 -2
- package/src/swift-package-manifest.ts +134 -13
- package/src/swift-package.ts +69 -4
- package/src/swift-standins.ts +4 -1
- package/src/swift-submit.ts +2 -1
- package/src/swift-toolchain.ts +36 -61
- package/src/worker-system-chunks.ts +3 -10
- package/src/xcode-project.ts +5 -5
- package/detox/attempt-events.cjs +0 -914
- package/detox/attempt-events.d.cts +0 -113
- package/detox/motion-change.cjs +0 -524
- package/detox/motion-change.d.cts +0 -140
- package/detox/motion-leg-starts.cjs +0 -20
- package/detox/motion-leg-starts.d.cts +0 -8
- package/detox/proof-frame.cjs +0 -190
- package/detox/record-block-execution.cjs +0 -78
package/README.md
CHANGED
|
@@ -283,7 +283,7 @@ the later trace URL notifies viewers without extending that duration.
|
|
|
283
283
|
Maestro YAML header `onFlowStart` and `onFlowComplete` hooks reach the same
|
|
284
284
|
runner as body hooks, including nested `runFlow` files. A header reset flow
|
|
285
285
|
therefore runs before assertions in each flow.
|
|
286
|
-
| sim drivers | Launch or attach the actual sim page. Playwright owns isolated browser profiles; the native host owns Mac and Linux desktop windows; Electron owns Windows windows. The current sim is reused unless `--new`, `--profile`, or `--ephemeral` requests a separate one. | `cli/drivers/index.ts`, `cli/drivers/registry.ts`, `cli/drivers/electron.ts`, `cli/drivers/playwright.ts` |
|
|
286
|
+
| sim drivers | Launch or attach the actual sim page. Playwright owns isolated browser profiles; the native host owns Mac and Linux desktop windows; Electron owns Windows windows. The current sim is reused unless `--new`, `--profile`, or `--ephemeral` requests a separate one. A profile holds one browser: `--profile <id>` refuses before launching while that profile's browser is alive. An external Playwright `connectOverCDP` observer that calls `exposeBinding` replaces the page's existing host bindings, so observe with raw CDP. | `cli/drivers/index.ts`, `cli/drivers/registry.ts`, `cli/drivers/electron.ts`, `cli/drivers/playwright.ts` |
|
|
287
287
|
| SootSimBridgeHost (serve/daemon) | The bridge process (`peach serve`, or autostarted as the daemon via launchd/systemd). HTTP+WS hub on `:7668`: relays commands between CLI clients and registered sims; also serves runtime HTTP, `/__server-scan`, and fetch/WS proxies. | `src/host/bridge-host.ts`, `cli/commands/serve.ts`, `cli/commands/daemon.ts`, `src/home-paths.ts` |
|
|
288
288
|
| AgentHost + sessions | Agent-routing extension of the host: owns the single FIFO reader per agent session and fans `agent:event`/`session-status` pushes to every WS subscriber. Backed by agent-sessions + attached-projects stores. | `src/host/agent-host.ts`, `src/agent-sessions.ts`, `src/attached-projects.ts`, `src/agent-daemon-client.ts` |
|
|
289
289
|
| host proxies + dev-server scan | Host-side helpers so a cross-origin tenant worker can reach local dev servers and same-origin APIs: `/__server-scan` discovers running metro/expo/vxrn/one servers; fetch + websocket proxies relay guest-app network through the daemon. | `src/host/fetch-proxy-handler.ts`, `src/host/websocket-proxy.ts`, `scripts/dev-server-scanner.ts`, `src/dev-bundle-resolution.ts` |
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import * as fs from 'fs'
|
|
2
2
|
import * as path from 'path'
|
|
3
3
|
import { isTextInputEditCommand, type TextInputEditCommand } from '@peach/globals'
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
REQUIRED_IDENTICAL_FLOW_FRAMES,
|
|
6
|
+
framesIdentical,
|
|
7
|
+
} from '../detox/frame-identity.cjs'
|
|
5
8
|
import { devices, type DeviceModel } from '../src/device-catalog.ts'
|
|
6
9
|
import { flowTimeoutScale } from '../src/flow-timeout-scale'
|
|
7
10
|
import { composeFramedScreenshot } from '../src/screenshots/frame-compose'
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process'
|
|
2
|
+
import { existsSync, mkdtempSync, readdirSync, realpathSync, rmSync } from 'node:fs'
|
|
3
|
+
import { tmpdir } from 'node:os'
|
|
4
|
+
import { dirname, join, relative, resolve, sep } from 'node:path'
|
|
5
|
+
import { indexSwiftPackage } from '../../src/swift-coverage/package'
|
|
6
|
+
import { buildSwiftIndexReader } from '../../src/swift-coverage/reader'
|
|
7
|
+
import { indexSwiftXcodeApp, xcodeMetadataFiles } from '../../src/swift-coverage/xcode'
|
|
8
|
+
import { localPackageModules } from '../../src/swift-coverage/xcode-packages'
|
|
9
|
+
import lock from '../../src/swift-distribution.lock.json' with { type: 'json' }
|
|
10
|
+
import {
|
|
11
|
+
swiftPackageDescription,
|
|
12
|
+
swiftPackageManifest,
|
|
13
|
+
} from '../../src/swift-package-manifest'
|
|
14
|
+
import { readPackageFile } from '../../src/swift-source-file'
|
|
15
|
+
import { swiftCompilerInstallSteps, swiftToolchainBin } from '../../src/swift-toolchain'
|
|
16
|
+
import { findXcodeProject, readXcodeAppTarget } from '../../src/xcode-project'
|
|
17
|
+
import type { CoverageGraphRequest } from './coverage'
|
|
18
|
+
|
|
19
|
+
// the existing build owners supply membership; requested roots select primaries,
|
|
20
|
+
// while every original target source remains available to the compiler.
|
|
21
|
+
export async function createSwiftCoverageReport(
|
|
22
|
+
appDirectory: string,
|
|
23
|
+
requestedSources: readonly string[],
|
|
24
|
+
graphRequest?: CoverageGraphRequest,
|
|
25
|
+
targetName?: string,
|
|
26
|
+
) {
|
|
27
|
+
const app = realpathSync(appDirectory)
|
|
28
|
+
const unknown = (reason: string) => ({
|
|
29
|
+
schemaVersion: 1,
|
|
30
|
+
input: { kind: 'swift-source-index', app },
|
|
31
|
+
status: 'unknown' as const,
|
|
32
|
+
reasons: [reason],
|
|
33
|
+
summary: {
|
|
34
|
+
symbolicReferences: null,
|
|
35
|
+
possibleFeatures: null,
|
|
36
|
+
mapped: null,
|
|
37
|
+
verified: null,
|
|
38
|
+
},
|
|
39
|
+
})
|
|
40
|
+
if (graphRequest)
|
|
41
|
+
return unknown(
|
|
42
|
+
'Final build graph options apply to React Native input; Swift dependency closure remains unknown.',
|
|
43
|
+
)
|
|
44
|
+
if (process.platform !== 'darwin')
|
|
45
|
+
return unknown(
|
|
46
|
+
'Swift iOS source indexing needs an installed Xcode toolchain and simulator SDK.',
|
|
47
|
+
)
|
|
48
|
+
const work = mkdtempSync(join(tmpdir(), 'peach-swift-coverage-'))
|
|
49
|
+
try {
|
|
50
|
+
if (!existsSync(join(app, 'Package.swift'))) {
|
|
51
|
+
const project = findXcodeProject(app)
|
|
52
|
+
if (!project)
|
|
53
|
+
return unknown(
|
|
54
|
+
'Swift source membership needs an unambiguous SwiftPM package or Xcode application target. Loose sources remain unknown.',
|
|
55
|
+
)
|
|
56
|
+
const target = readXcodeAppTarget(project, targetName, undefined, {
|
|
57
|
+
prepareGeneratedSources: false,
|
|
58
|
+
})
|
|
59
|
+
const root = realpathSync(target.rootDir)
|
|
60
|
+
const files: Record<string, string> = {}
|
|
61
|
+
const metadata = xcodeMetadataFiles(target, project)
|
|
62
|
+
if (!target.sources.length || target.sources.length > 2_000)
|
|
63
|
+
return unknown('Swift target needs 1 to 2000 original source files.')
|
|
64
|
+
let bytes = 0
|
|
65
|
+
// a bridging header exposes every project header its search maps reach
|
|
66
|
+
const headers = target.objc?.bridgingHeader
|
|
67
|
+
? [target.objc.bridgingHeader, ...target.objc.headers]
|
|
68
|
+
: []
|
|
69
|
+
// local package products the app links compile as modules from their sources
|
|
70
|
+
const packages = localPackageModules(target, root)
|
|
71
|
+
const packageSources =
|
|
72
|
+
packages.status === 'modules'
|
|
73
|
+
? packages.modules.flatMap((module) =>
|
|
74
|
+
module.files.map((file) => join(root, file)),
|
|
75
|
+
)
|
|
76
|
+
: []
|
|
77
|
+
for (const file of new Set([
|
|
78
|
+
...metadata,
|
|
79
|
+
...target.sources,
|
|
80
|
+
...headers,
|
|
81
|
+
...packageSources,
|
|
82
|
+
])) {
|
|
83
|
+
const content = readPackageFile(root, file, 4 * 1024 * 1024)
|
|
84
|
+
bytes += content.length
|
|
85
|
+
if (bytes > 32 * 1024 * 1024)
|
|
86
|
+
return unknown('Xcode input exceeds the 32 MiB snapshot limit.')
|
|
87
|
+
files[relative(root, file)] = content.toString('utf8')
|
|
88
|
+
}
|
|
89
|
+
const sourceBase = /\.(?:xcodeproj|xcworkspace)$/.test(app) ? dirname(project) : app
|
|
90
|
+
const roots = requestedSources.map((source) => {
|
|
91
|
+
const path = relative(root, resolve(sourceBase, source))
|
|
92
|
+
if (path === '..' || path.startsWith(`..${sep}`))
|
|
93
|
+
throw new Error('--source must stay inside the app root')
|
|
94
|
+
return path
|
|
95
|
+
})
|
|
96
|
+
const sources = target.sources.map((file) => relative(root, file))
|
|
97
|
+
const primaries = sources.filter(
|
|
98
|
+
(source) =>
|
|
99
|
+
!roots.length ||
|
|
100
|
+
roots.some(
|
|
101
|
+
(root) => !root || source === root || source.startsWith(`${root}${sep}`),
|
|
102
|
+
),
|
|
103
|
+
)
|
|
104
|
+
if (!primaries.length)
|
|
105
|
+
return unknown('Requested source roots contain no Xcode target sources.')
|
|
106
|
+
const tools = swiftCoverageTools(work)
|
|
107
|
+
const result = await indexSwiftXcodeApp({
|
|
108
|
+
root,
|
|
109
|
+
project,
|
|
110
|
+
target: target.name,
|
|
111
|
+
configuration: target.configuration,
|
|
112
|
+
compile: { files, entry: primaries[0]! },
|
|
113
|
+
primaries,
|
|
114
|
+
indexdump: tools.indexdump,
|
|
115
|
+
native: {
|
|
116
|
+
swiftc: tools.swiftc,
|
|
117
|
+
flags: [
|
|
118
|
+
'-target',
|
|
119
|
+
`arm64-apple-ios${target.iosDeploymentTarget || tools.version}-simulator`,
|
|
120
|
+
'-sdk',
|
|
121
|
+
tools.sdk,
|
|
122
|
+
],
|
|
123
|
+
},
|
|
124
|
+
})
|
|
125
|
+
if (result.status === 'unknown') return unknown(result.reasons.join('\n'))
|
|
126
|
+
return {
|
|
127
|
+
schemaVersion: 1,
|
|
128
|
+
input: {
|
|
129
|
+
...result.index.input,
|
|
130
|
+
app,
|
|
131
|
+
requestedSources: requestedSources.length ? requestedSources : ['.'],
|
|
132
|
+
},
|
|
133
|
+
status: 'indexed' as const,
|
|
134
|
+
summary: {
|
|
135
|
+
symbolicReferences: result.index.sites.length,
|
|
136
|
+
possibleFeatures: null,
|
|
137
|
+
mapped: null,
|
|
138
|
+
verified: null,
|
|
139
|
+
},
|
|
140
|
+
project: result.project,
|
|
141
|
+
reader: tools.reader,
|
|
142
|
+
index: result.index,
|
|
143
|
+
unknowns: result.unknowns,
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
const manifest = swiftPackageManifest(app)
|
|
147
|
+
const targets = [...manifest.targets.values()].filter(
|
|
148
|
+
(target) =>
|
|
149
|
+
target.type === 'executable' && (!targetName || target.name === targetName),
|
|
150
|
+
)
|
|
151
|
+
if (targets.length !== 1)
|
|
152
|
+
return unknown(
|
|
153
|
+
'Swift coverage needs one unambiguous executable SwiftPM target; pass --target to choose one.',
|
|
154
|
+
)
|
|
155
|
+
const target = targets[0]!
|
|
156
|
+
const described = swiftPackageDescription(manifest).targets.find(
|
|
157
|
+
(item) => item.name === target.name,
|
|
158
|
+
)
|
|
159
|
+
if (!described)
|
|
160
|
+
return unknown('SwiftPM did not describe the selected executable target.')
|
|
161
|
+
const files: Record<string, string> = {}
|
|
162
|
+
for (const name of readdirSync(app).filter((name) =>
|
|
163
|
+
/^Package(?:@swift-[\d.]+)?\.swift$/.test(name),
|
|
164
|
+
))
|
|
165
|
+
files[name] = readPackageFile(app, join(app, name), 4 * 1024 * 1024).toString(
|
|
166
|
+
'utf8',
|
|
167
|
+
)
|
|
168
|
+
let bytes = 0
|
|
169
|
+
const sources = described.sources.map((file) =>
|
|
170
|
+
relative(app, resolve(app, described.path, file)),
|
|
171
|
+
)
|
|
172
|
+
if (!sources.length || sources.length > 2_000)
|
|
173
|
+
return unknown('Swift target needs 1 to 2000 original source files.')
|
|
174
|
+
for (const source of sources) {
|
|
175
|
+
const content = readPackageFile(app, join(app, source), 4 * 1024 * 1024)
|
|
176
|
+
bytes += content.length
|
|
177
|
+
if (bytes > 32 * 1024 * 1024)
|
|
178
|
+
return unknown('Swift target exceeds the 32 MiB source limit.')
|
|
179
|
+
files[source] = content.toString('utf8')
|
|
180
|
+
}
|
|
181
|
+
const roots = requestedSources.map((source) => {
|
|
182
|
+
const path = relative(app, resolve(app, source))
|
|
183
|
+
if (path === '..' || path.startsWith(`..${sep}`))
|
|
184
|
+
throw new Error('--source must stay inside the app directory')
|
|
185
|
+
return path
|
|
186
|
+
})
|
|
187
|
+
const primaries = sources.filter(
|
|
188
|
+
(source) =>
|
|
189
|
+
!roots.length ||
|
|
190
|
+
roots.some(
|
|
191
|
+
(root) => !root || source === root || source.startsWith(`${root}${sep}`),
|
|
192
|
+
),
|
|
193
|
+
)
|
|
194
|
+
if (!primaries.length)
|
|
195
|
+
return unknown('Requested source roots contain no SwiftPM target sources.')
|
|
196
|
+
const { swiftc, sdk, version, indexdump, reader } = swiftCoverageTools(work)
|
|
197
|
+
const result = await indexSwiftPackage({
|
|
198
|
+
root: app,
|
|
199
|
+
target: target.name,
|
|
200
|
+
compile: { files, entry: primaries[0]! },
|
|
201
|
+
configuration: 'debug',
|
|
202
|
+
indexdump,
|
|
203
|
+
native: {
|
|
204
|
+
swiftc,
|
|
205
|
+
flags: [
|
|
206
|
+
'-target',
|
|
207
|
+
`${process.arch === 'arm64' ? 'arm64' : 'x86_64'}-apple-ios${version}-simulator`,
|
|
208
|
+
'-sdk',
|
|
209
|
+
sdk,
|
|
210
|
+
],
|
|
211
|
+
},
|
|
212
|
+
primaries,
|
|
213
|
+
})
|
|
214
|
+
if (result.status === 'unknown') return unknown(result.reasons.join('\n'))
|
|
215
|
+
return {
|
|
216
|
+
schemaVersion: 1,
|
|
217
|
+
input: {
|
|
218
|
+
...result.index.input,
|
|
219
|
+
app,
|
|
220
|
+
requestedSources: requestedSources.length ? requestedSources : ['.'],
|
|
221
|
+
},
|
|
222
|
+
status: 'indexed' as const,
|
|
223
|
+
summary: {
|
|
224
|
+
symbolicReferences: result.index.sites.length,
|
|
225
|
+
possibleFeatures: null,
|
|
226
|
+
mapped: null,
|
|
227
|
+
verified: null,
|
|
228
|
+
},
|
|
229
|
+
package: result.package,
|
|
230
|
+
reader,
|
|
231
|
+
index: result.index,
|
|
232
|
+
unknowns: result.unknowns,
|
|
233
|
+
}
|
|
234
|
+
} catch (error) {
|
|
235
|
+
return unknown(error instanceof Error ? error.message : String(error))
|
|
236
|
+
} finally {
|
|
237
|
+
rmSync(work, { recursive: true, force: true })
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function swiftCoverageTools(work: string) {
|
|
242
|
+
const swiftc = execFileSync('xcrun', ['--find', 'swiftc'], { encoding: 'utf8' }).trim()
|
|
243
|
+
const sdk = execFileSync('xcrun', ['--sdk', 'iphonesimulator', '--show-sdk-path'], {
|
|
244
|
+
encoding: 'utf8',
|
|
245
|
+
}).trim()
|
|
246
|
+
const version = execFileSync(
|
|
247
|
+
'xcrun',
|
|
248
|
+
['--sdk', 'iphonesimulator', '--show-sdk-version'],
|
|
249
|
+
{ encoding: 'utf8' },
|
|
250
|
+
).trim()
|
|
251
|
+
const indexdump = join(work, 'indexdump')
|
|
252
|
+
const reader = buildSwiftIndexReader(
|
|
253
|
+
join(swiftToolchainBin(lock.release), 'swiftc'),
|
|
254
|
+
indexdump,
|
|
255
|
+
() => swiftCompilerInstallSteps(lock.release),
|
|
256
|
+
)
|
|
257
|
+
return { swiftc, sdk, version, indexdump, reader }
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export async function runSwiftCoverage(
|
|
261
|
+
app: string,
|
|
262
|
+
sources: string[],
|
|
263
|
+
json: boolean,
|
|
264
|
+
graphRequest?: CoverageGraphRequest,
|
|
265
|
+
target?: string,
|
|
266
|
+
): Promise<number> {
|
|
267
|
+
const report = await createSwiftCoverageReport(app, sources, graphRequest, target)
|
|
268
|
+
if (json) console.log(JSON.stringify(report, null, 2))
|
|
269
|
+
else if (report.status === 'unknown') {
|
|
270
|
+
console.log('Swift source reach is unknown.')
|
|
271
|
+
for (const reason of report.reasons) console.log(` ${reason}`)
|
|
272
|
+
} else {
|
|
273
|
+
console.log(
|
|
274
|
+
`Indexed ${report.index.input.sources.length} Swift module files: ${report.index.sites.length} explicit symbolic references.`,
|
|
275
|
+
)
|
|
276
|
+
console.log('Feature reach, mapped share and verified share: unknown.')
|
|
277
|
+
for (const command of report.index.native.commands.filter(
|
|
278
|
+
(command) => command.code !== 0,
|
|
279
|
+
))
|
|
280
|
+
console.log(
|
|
281
|
+
` ${command.file}: indexing failed (exit ${command.code}); references may be incomplete.`,
|
|
282
|
+
)
|
|
283
|
+
for (const site of report.index.sites)
|
|
284
|
+
console.log(
|
|
285
|
+
` ${site.file}:${site.line}:${site.col} ${site.name} (${site.usr}): mapping unknown; native proof unknown`,
|
|
286
|
+
)
|
|
287
|
+
for (const limitation of [...report.unknowns, ...report.index.unknowns])
|
|
288
|
+
console.log(` ${limitation}`)
|
|
289
|
+
}
|
|
290
|
+
return report.status === 'unknown' || !report.index.native.succeeded ? 1 : 0
|
|
291
|
+
}
|
package/cli/commands/coverage.ts
CHANGED
|
@@ -10,14 +10,20 @@ import {
|
|
|
10
10
|
} from '@peach/compat/verified-map-types'
|
|
11
11
|
import { resolveCompatVersionRange } from '@peach/compat/version-range'
|
|
12
12
|
import { z } from 'zod'
|
|
13
|
-
import
|
|
13
|
+
import inventoryData from '../../../peach-compat/src/generated/capability-inventory.json'
|
|
14
|
+
import { resolveCapabilityReferences } from '../../src/react-native-coverage/capability-reference-resolution'
|
|
14
15
|
import {
|
|
15
16
|
capabilitySourceExclusion,
|
|
16
17
|
collectCapabilityReferences,
|
|
17
18
|
type CapabilityReferenceCandidate,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
import
|
|
19
|
+
type StaticValue,
|
|
20
|
+
} from '../../src/react-native-coverage/capability-source-references'
|
|
21
|
+
import { withTypeScriptSourceParser } from '../../src/react-native-coverage/native-typescript-parser'
|
|
22
|
+
import { createProjectModuleResolver } from '../../src/react-native-coverage/project-aliases'
|
|
23
|
+
import {
|
|
24
|
+
fileReachesFeature,
|
|
25
|
+
referenceFeatures,
|
|
26
|
+
} from '../../src/react-native-coverage/verified-reach'
|
|
21
27
|
import { coverageParserPath } from './coverage-parser'
|
|
22
28
|
import { readProjectManifest, resolveManifestVersions } from './detect'
|
|
23
29
|
import type { ProjectManifest } from './projectReportContract'
|
|
@@ -32,14 +38,17 @@ const SOURCE_EXTENSIONS = new Set([
|
|
|
32
38
|
'.mts',
|
|
33
39
|
'.cts',
|
|
34
40
|
])
|
|
41
|
+
const MAX_SOURCE_FILES = 10_000
|
|
35
42
|
// validate the snapshot fields this consumer reads, without changing proof schemas.
|
|
36
43
|
const inventorySchema = z.object({
|
|
37
|
-
generatedAt: z.string(),
|
|
38
44
|
sourceApiSnapshots: z.array(
|
|
39
45
|
z.object({
|
|
40
46
|
exportName: z.string(),
|
|
41
47
|
module: z.string(),
|
|
42
48
|
sourceApiVersion: z.string(),
|
|
49
|
+
sourceIdentity: z
|
|
50
|
+
.object({ entry: z.string(), sha256: z.string().regex(/^[a-f0-9]{64}$/) })
|
|
51
|
+
.optional(),
|
|
43
52
|
}),
|
|
44
53
|
),
|
|
45
54
|
rows: z.array(
|
|
@@ -199,7 +208,11 @@ export async function createCoverageReport(
|
|
|
199
208
|
const full = resolve(app, path)
|
|
200
209
|
const stat = lstatSync(full)
|
|
201
210
|
if (stat.isSymbolicLink()) {
|
|
202
|
-
|
|
211
|
+
// a link to a document or asset hides no source; only a link that could
|
|
212
|
+
// name source or a directory leaves the scan incomplete.
|
|
213
|
+
const extension = extname(path)
|
|
214
|
+
if (!extension || SOURCE_EXTENSIONS.has(extension))
|
|
215
|
+
unknowns.push({ path, reason: 'symbolic link was not followed' })
|
|
203
216
|
continue
|
|
204
217
|
}
|
|
205
218
|
if (stat.isDirectory()) {
|
|
@@ -225,7 +238,7 @@ export async function createCoverageReport(
|
|
|
225
238
|
)
|
|
226
239
|
continue
|
|
227
240
|
if (
|
|
228
|
-
files.size >=
|
|
241
|
+
files.size >= MAX_SOURCE_FILES ||
|
|
229
242
|
stat.size > 4 * 1024 * 1024 ||
|
|
230
243
|
bytes + stat.size > 32 * 1024 * 1024
|
|
231
244
|
) {
|
|
@@ -274,7 +287,7 @@ export async function createCoverageReport(
|
|
|
274
287
|
})
|
|
275
288
|
const graph = final && 'graph' in final ? final : undefined
|
|
276
289
|
const parserPath = files.size ? await coverageParserPath() : undefined
|
|
277
|
-
const
|
|
290
|
+
const scanned: CapabilityReferenceCandidate[] = files.size
|
|
278
291
|
? await withTypeScriptSourceParser(async (parse) => {
|
|
279
292
|
// one snapshot holds the repository. each file keeps its own lexical bindings.
|
|
280
293
|
return parse(files, async (sources, projects) => {
|
|
@@ -295,6 +308,22 @@ export async function createCoverageReport(
|
|
|
295
308
|
})
|
|
296
309
|
}, parserPath)
|
|
297
310
|
: []
|
|
311
|
+
// a tsconfig path, baseUrl or package.json import names the app's own source,
|
|
312
|
+
// never an installed package. an alias to a directory with native code stays
|
|
313
|
+
// a reference, reported as app-owned native code.
|
|
314
|
+
const projectModule = createProjectModuleResolver(app)
|
|
315
|
+
const localNativeModules = new Map<string, string>()
|
|
316
|
+
let projectModuleReferences = 0
|
|
317
|
+
const candidates = scanned.filter((candidate) => {
|
|
318
|
+
const resolved = projectModule(candidate.path, candidate.module)
|
|
319
|
+
if (!resolved) return true
|
|
320
|
+
if (resolved.kind === 'native') {
|
|
321
|
+
localNativeModules.set(`${candidate.path}\0${candidate.module}`, resolved.path)
|
|
322
|
+
return true
|
|
323
|
+
}
|
|
324
|
+
projectModuleReferences++
|
|
325
|
+
return false
|
|
326
|
+
})
|
|
298
327
|
const referencedPackages = new Map<string, Set<string>>()
|
|
299
328
|
for (const reference of candidates) {
|
|
300
329
|
const owner = sourceOwners.get(reference.path)
|
|
@@ -315,7 +344,8 @@ export async function createCoverageReport(
|
|
|
315
344
|
versionOwners.set(owner, resolveManifestVersions(owner, { dependencies }, lockfiles))
|
|
316
345
|
}
|
|
317
346
|
const definitions = new Map(inventory.rows.map((row) => [row.id, row]))
|
|
318
|
-
const
|
|
347
|
+
const allFeatures = surfaces.flatMap((surface) => surface.features)
|
|
348
|
+
const doorReferences = resolveCapabilityReferences(
|
|
319
349
|
inventory.rows,
|
|
320
350
|
candidates,
|
|
321
351
|
verifiedSourceApiDoors(
|
|
@@ -337,7 +367,8 @@ export async function createCoverageReport(
|
|
|
337
367
|
? inventory.sourceApiSnapshots.find(
|
|
338
368
|
(snapshot) =>
|
|
339
369
|
snapshot.module === reference.module &&
|
|
340
|
-
snapshot.exportName === reference.exportName
|
|
370
|
+
snapshot.exportName === reference.exportName &&
|
|
371
|
+
(reference.memberName !== null || snapshot.sourceIdentity !== undefined),
|
|
341
372
|
)
|
|
342
373
|
: undefined
|
|
343
374
|
const versionStatus =
|
|
@@ -355,12 +386,7 @@ export async function createCoverageReport(
|
|
|
355
386
|
: 'unknown'
|
|
356
387
|
const features =
|
|
357
388
|
reference.state === 'attributed'
|
|
358
|
-
?
|
|
359
|
-
.flatMap((surface) => surface.features)
|
|
360
|
-
.filter((feature) =>
|
|
361
|
-
feature.frontDoors.some((door) => door === reference.capabilityId),
|
|
362
|
-
)
|
|
363
|
-
.map((feature) => feature.id)
|
|
389
|
+
? referenceFeatures(allFeatures, reference.capabilityId, reference.value ?? null)
|
|
364
390
|
: []
|
|
365
391
|
return {
|
|
366
392
|
...reference,
|
|
@@ -373,12 +399,15 @@ export async function createCoverageReport(
|
|
|
373
399
|
: 'not-in-final-graph'
|
|
374
400
|
: null,
|
|
375
401
|
artifactVersion: graph?.graph.artifactVersions[reference.packageName] ?? null,
|
|
402
|
+
localNativeModule:
|
|
403
|
+
localNativeModules.get(`${reference.path}\0${reference.module}`) ?? null,
|
|
376
404
|
packageOwner: owner ? relative(app, owner).split(sep).join('/') || '.' : null,
|
|
377
405
|
packageVersion: dependency ?? null,
|
|
378
406
|
versionStatus,
|
|
379
407
|
supportedVersionRange: row?.supportedVersionRange ?? null,
|
|
380
408
|
exactTestedVersion: row?.exactTestedVersion ?? null,
|
|
381
409
|
sourceApiVersion: sourceApi?.sourceApiVersion ?? null,
|
|
410
|
+
sourceApiIdentity: sourceApi?.sourceIdentity ?? null,
|
|
382
411
|
platformApplicable: sourceApi ? true : (row?.platforms.includes('ios') ?? null),
|
|
383
412
|
features,
|
|
384
413
|
mapping:
|
|
@@ -395,6 +424,31 @@ export async function createCoverageReport(
|
|
|
395
424
|
: 'unmapped-feature',
|
|
396
425
|
}
|
|
397
426
|
})
|
|
427
|
+
// a feature with declared reach needs every condition met inside one file
|
|
428
|
+
const mappedByPath = new Map<
|
|
429
|
+
string,
|
|
430
|
+
{ capabilityId: string; value: StaticValue | null }[]
|
|
431
|
+
>()
|
|
432
|
+
for (const reference of doorReferences)
|
|
433
|
+
if (reference.mapping === 'mapped' && 'capabilityId' in reference)
|
|
434
|
+
mappedByPath.set(reference.path, [
|
|
435
|
+
...(mappedByPath.get(reference.path) ?? []),
|
|
436
|
+
{ capabilityId: reference.capabilityId, value: reference.value ?? null },
|
|
437
|
+
])
|
|
438
|
+
const featureReach = new Map(allFeatures.map((feature) => [feature.id, feature]))
|
|
439
|
+
const references = doorReferences.map((reference) => {
|
|
440
|
+
if (reference.mapping !== 'mapped') return reference
|
|
441
|
+
const peers = mappedByPath.get(reference.path) ?? []
|
|
442
|
+
const features = reference.features.filter((id) => {
|
|
443
|
+
const feature = featureReach.get(id)
|
|
444
|
+
return feature !== undefined && fileReachesFeature(feature, peers)
|
|
445
|
+
})
|
|
446
|
+
return {
|
|
447
|
+
...reference,
|
|
448
|
+
features,
|
|
449
|
+
mapping: features.length ? 'mapped' : 'unmapped-feature',
|
|
450
|
+
}
|
|
451
|
+
})
|
|
398
452
|
const reached = new Set(
|
|
399
453
|
references
|
|
400
454
|
.filter((reference) => reference.mapping === 'mapped')
|
|
@@ -426,6 +480,37 @@ export async function createCoverageReport(
|
|
|
426
480
|
reason: 'source references do not select device, OS, settings or interaction cells',
|
|
427
481
|
proofUrl: 'https://peachsim.com/conformance',
|
|
428
482
|
}))
|
|
483
|
+
const packages = new Map<
|
|
484
|
+
string,
|
|
485
|
+
{
|
|
486
|
+
name: string
|
|
487
|
+
versions: Set<string>
|
|
488
|
+
unversionedReferences: number
|
|
489
|
+
verifiedRanges: Set<string>
|
|
490
|
+
references: number
|
|
491
|
+
byMapping: Record<string, number>
|
|
492
|
+
}
|
|
493
|
+
>()
|
|
494
|
+
for (const reference of references) {
|
|
495
|
+
const entry = packages.get(reference.packageName) ?? {
|
|
496
|
+
name: reference.packageName,
|
|
497
|
+
versions: new Set<string>(),
|
|
498
|
+
unversionedReferences: 0,
|
|
499
|
+
verifiedRanges: new Set<string>(),
|
|
500
|
+
references: 0,
|
|
501
|
+
byMapping: {},
|
|
502
|
+
}
|
|
503
|
+
entry.references++
|
|
504
|
+
if (reference.packageVersion)
|
|
505
|
+
entry.versions.add(
|
|
506
|
+
`${reference.packageVersion.version} (${reference.packageVersion.source})`,
|
|
507
|
+
)
|
|
508
|
+
else entry.unversionedReferences++
|
|
509
|
+
entry.byMapping[reference.mapping] = (entry.byMapping[reference.mapping] ?? 0) + 1
|
|
510
|
+
if (reference.supportedVersionRange)
|
|
511
|
+
entry.verifiedRanges.add(reference.supportedVersionRange)
|
|
512
|
+
packages.set(reference.packageName, entry)
|
|
513
|
+
}
|
|
429
514
|
return {
|
|
430
515
|
schemaVersion: 1,
|
|
431
516
|
input: {
|
|
@@ -441,7 +526,6 @@ export async function createCoverageReport(
|
|
|
441
526
|
},
|
|
442
527
|
registry: {
|
|
443
528
|
source: 'cli-capability-snapshot',
|
|
444
|
-
generatedAt: inventory.generatedAt,
|
|
445
529
|
fingerprint: createHash('sha256')
|
|
446
530
|
.update(JSON.stringify(inventoryData))
|
|
447
531
|
.digest('hex'),
|
|
@@ -457,11 +541,33 @@ export async function createCoverageReport(
|
|
|
457
541
|
reference.mapping === 'unknown-version' ||
|
|
458
542
|
reference.mapping === 'unmapped-feature',
|
|
459
543
|
).length,
|
|
544
|
+
versionMismatchReferences: references.filter(
|
|
545
|
+
(reference) =>
|
|
546
|
+
reference.state === 'attributed' && reference.versionStatus === 'unmatched',
|
|
547
|
+
).length,
|
|
548
|
+
projectModuleReferences,
|
|
460
549
|
possibleFeatures: features.length,
|
|
461
550
|
mapped: null,
|
|
462
551
|
verified: null,
|
|
463
552
|
},
|
|
464
553
|
graph: graph?.graph ?? null,
|
|
554
|
+
packages: [...packages.values()]
|
|
555
|
+
.map((entry) => ({
|
|
556
|
+
...entry,
|
|
557
|
+
versions: [...entry.versions].sort(),
|
|
558
|
+
verifiedRanges: [...entry.verifiedRanges].sort(),
|
|
559
|
+
}))
|
|
560
|
+
.sort((a, b) => b.references - a.references || a.name.localeCompare(b.name)),
|
|
561
|
+
localNativeModules: [
|
|
562
|
+
...Map.groupBy(
|
|
563
|
+
references.filter((reference) => reference.localNativeModule),
|
|
564
|
+
(reference) => `${reference.module}\0${reference.localNativeModule}`,
|
|
565
|
+
).values(),
|
|
566
|
+
].map((group) => ({
|
|
567
|
+
module: group[0]?.module ?? '',
|
|
568
|
+
path: group[0]?.localNativeModule ?? '',
|
|
569
|
+
references: group.length,
|
|
570
|
+
})),
|
|
465
571
|
references,
|
|
466
572
|
features,
|
|
467
573
|
unknowns,
|
|
@@ -476,6 +582,7 @@ export async function createCoverageReport(
|
|
|
476
582
|
'Transitive library source, computed loading, cross-file aliases and runtime values are not resolved. Their feature and scenario reach remains unknown.',
|
|
477
583
|
'Declared dependency ranges alone are not exact package versions. The installed or unambiguous lockfile version must match the inventory range.',
|
|
478
584
|
'This CLI inventory snapshot is not pinned to a selected runtime. Native fidelity and scenario verification remain unknown; no aggregate percentage is established.',
|
|
585
|
+
"Imports through the app's own tsconfig or jsconfig paths, baseUrl or package.json imports are application source, not packages, and are not counted as references. App-owned native modules behind such an alias are listed and stay unknown.",
|
|
479
586
|
'Swift source indexing is not included in this React Native source scan.',
|
|
480
587
|
],
|
|
481
588
|
}
|
|
@@ -488,6 +595,7 @@ export async function runCoverage(args: string[]): Promise<number> {
|
|
|
488
595
|
let graph = false
|
|
489
596
|
let entry: string | undefined
|
|
490
597
|
let platform: 'ios' | 'android' = 'ios'
|
|
598
|
+
let target: string | undefined
|
|
491
599
|
for (let index = 0; index < args.length; index++) {
|
|
492
600
|
const arg = args[index]
|
|
493
601
|
if (arg === '--json') {
|
|
@@ -498,6 +606,11 @@ export async function runCoverage(args: string[]): Promise<number> {
|
|
|
498
606
|
graph = true
|
|
499
607
|
continue
|
|
500
608
|
}
|
|
609
|
+
if (arg === '--target') {
|
|
610
|
+
target = args[++index]
|
|
611
|
+
if (!target || target.startsWith('-')) throw new Error('--target needs a name')
|
|
612
|
+
continue
|
|
613
|
+
}
|
|
501
614
|
if (arg === '--entry' || arg === '--platform') {
|
|
502
615
|
const value = args[++index]
|
|
503
616
|
if (!value || value.startsWith('-')) throw new Error(`${arg} needs a value`)
|
|
@@ -515,6 +628,23 @@ export async function runCoverage(args: string[]): Promise<number> {
|
|
|
515
628
|
}
|
|
516
629
|
if (!graph && (entry || platform !== 'ios'))
|
|
517
630
|
throw new Error('--entry and --platform need --graph')
|
|
631
|
+
if (
|
|
632
|
+
existsSync(join(app, 'Package.swift')) ||
|
|
633
|
+
sources.some((source) => extname(source) === '.swift') ||
|
|
634
|
+
/\.(?:xcodeproj|xcworkspace)$/.test(app) ||
|
|
635
|
+
(!existsSync(join(app, 'package.json')) &&
|
|
636
|
+
readdirSync(app).some((name) => /\.(?:xcodeproj|xcworkspace)$/.test(name)))
|
|
637
|
+
) {
|
|
638
|
+
const { runSwiftCoverage } = await import('./coverage-swift')
|
|
639
|
+
return runSwiftCoverage(
|
|
640
|
+
app,
|
|
641
|
+
sources,
|
|
642
|
+
json,
|
|
643
|
+
graph ? { entry, platform } : undefined,
|
|
644
|
+
target,
|
|
645
|
+
)
|
|
646
|
+
}
|
|
647
|
+
if (target) throw new Error('--target selects an Xcode application target')
|
|
518
648
|
const report = await createCoverageReport(
|
|
519
649
|
app,
|
|
520
650
|
sources,
|
|
@@ -522,11 +652,15 @@ export async function runCoverage(args: string[]): Promise<number> {
|
|
|
522
652
|
)
|
|
523
653
|
if (json) console.log(JSON.stringify(report, null, 2))
|
|
524
654
|
else {
|
|
655
|
+
const { summary } = report
|
|
656
|
+
console.log(
|
|
657
|
+
`Scanned ${report.input.files} source files: ${summary.references} package references (${summary.projectModuleReferences} imports of the app's own modules not counted).`,
|
|
658
|
+
)
|
|
525
659
|
console.log(
|
|
526
|
-
`
|
|
660
|
+
` mapped to a feature: ${summary.mappedReferences}; installed version outside the verified range: ${summary.versionMismatchReferences}; other unknown or unmapped: ${summary.unknownReferences - summary.versionMismatchReferences}`,
|
|
527
661
|
)
|
|
528
662
|
console.log(
|
|
529
|
-
`Possible features: ${
|
|
663
|
+
`Possible features: ${summary.possibleFeatures}. Mapped share: unknown. Verified share: unknown.`,
|
|
530
664
|
)
|
|
531
665
|
if (report.graph)
|
|
532
666
|
console.log(
|
|
@@ -536,13 +670,23 @@ export async function runCoverage(args: string[]): Promise<number> {
|
|
|
536
670
|
console.log(
|
|
537
671
|
` ${feature.id}${feature.graphReach ? ` (${feature.graphReach})` : ''}: verification unknown; unknown axes: ${feature.unknownAxes.join(', ') || 'none'}`,
|
|
538
672
|
)
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
673
|
+
const PACKAGE_LINES = 15
|
|
674
|
+
console.log('Packages by references:')
|
|
675
|
+
for (const entry of report.packages.slice(0, PACKAGE_LINES))
|
|
676
|
+
console.log(
|
|
677
|
+
` ${entry.name} ${entry.versions.join(' | ') || 'version unknown'}${entry.versions.length && entry.unversionedReferences ? ` (${entry.unversionedReferences} references without a version)` : ''}${entry.verifiedRanges.length ? `, verified ${entry.verifiedRanges.join(' | ')}` : ''}: ${entry.references} references; ${Object.entries(
|
|
678
|
+
entry.byMapping,
|
|
679
|
+
)
|
|
680
|
+
.map(([mapping, count]) => `${count} ${mapping}`)
|
|
681
|
+
.join(', ')}`,
|
|
682
|
+
)
|
|
683
|
+
if (report.packages.length > PACKAGE_LINES)
|
|
684
|
+
console.log(` ${report.packages.length - PACKAGE_LINES} more packages; use --json`)
|
|
685
|
+
for (const module of report.localNativeModules)
|
|
543
686
|
console.log(
|
|
544
|
-
`
|
|
687
|
+
` app-owned native module ${module.module} (${module.path}): ${module.references} references, unknown`,
|
|
545
688
|
)
|
|
689
|
+
console.log('Every reference with its file and position is in --json.')
|
|
546
690
|
for (const issue of report.unknowns) console.log(` ${issue.path}: ${issue.reason}`)
|
|
547
691
|
for (const limitation of report.limitations) console.log(` ${limitation}`)
|
|
548
692
|
}
|