@solidnative-dev/cli 0.0.0-stage → 0.1.0-alpha.0

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.
Files changed (184) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +841 -2
  3. package/dist/android-apk-signing.d.ts +36 -0
  4. package/dist/android-apk-signing.d.ts.map +1 -0
  5. package/dist/android-apk-signing.js +292 -0
  6. package/dist/android-apk-signing.js.map +1 -0
  7. package/dist/android-bundle-signing.d.ts +34 -0
  8. package/dist/android-bundle-signing.d.ts.map +1 -0
  9. package/dist/android-bundle-signing.js +167 -0
  10. package/dist/android-bundle-signing.js.map +1 -0
  11. package/dist/android-causal-debug.d.ts +38 -0
  12. package/dist/android-causal-debug.d.ts.map +1 -0
  13. package/dist/android-causal-debug.js +239 -0
  14. package/dist/android-causal-debug.js.map +1 -0
  15. package/dist/android-device-proof.d.ts +58 -0
  16. package/dist/android-device-proof.d.ts.map +1 -0
  17. package/dist/android-device-proof.js +554 -0
  18. package/dist/android-device-proof.js.map +1 -0
  19. package/dist/android-logs.d.ts +50 -0
  20. package/dist/android-logs.d.ts.map +1 -0
  21. package/dist/android-logs.js +253 -0
  22. package/dist/android-logs.js.map +1 -0
  23. package/dist/android-release-signing.d.ts +12 -0
  24. package/dist/android-release-signing.d.ts.map +1 -0
  25. package/dist/android-release-signing.js +165 -0
  26. package/dist/android-release-signing.js.map +1 -0
  27. package/dist/android-run-lease.d.ts +15 -0
  28. package/dist/android-run-lease.d.ts.map +1 -0
  29. package/dist/android-run-lease.js +333 -0
  30. package/dist/android-run-lease.js.map +1 -0
  31. package/dist/android-run-preflight.d.ts +45 -0
  32. package/dist/android-run-preflight.d.ts.map +1 -0
  33. package/dist/android-run-preflight.js +183 -0
  34. package/dist/android-run-preflight.js.map +1 -0
  35. package/dist/android-signing-shared.d.ts +38 -0
  36. package/dist/android-signing-shared.d.ts.map +1 -0
  37. package/dist/android-signing-shared.js +210 -0
  38. package/dist/android-signing-shared.js.map +1 -0
  39. package/dist/bin.d.ts +3 -0
  40. package/dist/bin.d.ts.map +1 -0
  41. package/dist/bin.js +4530 -0
  42. package/dist/bin.js.map +1 -0
  43. package/dist/bundle-artifacts.d.ts +48 -0
  44. package/dist/bundle-artifacts.d.ts.map +1 -0
  45. package/dist/bundle-artifacts.js +427 -0
  46. package/dist/bundle-artifacts.js.map +1 -0
  47. package/dist/causal-debug-compare.d.ts +81 -0
  48. package/dist/causal-debug-compare.d.ts.map +1 -0
  49. package/dist/causal-debug-compare.js +238 -0
  50. package/dist/causal-debug-compare.js.map +1 -0
  51. package/dist/causal-debug-report.d.ts +33 -0
  52. package/dist/causal-debug-report.d.ts.map +1 -0
  53. package/dist/causal-debug-report.js +979 -0
  54. package/dist/causal-debug-report.js.map +1 -0
  55. package/dist/causal-debug-watch.d.ts +33 -0
  56. package/dist/causal-debug-watch.d.ts.map +1 -0
  57. package/dist/causal-debug-watch.js +92 -0
  58. package/dist/causal-debug-watch.js.map +1 -0
  59. package/dist/causal-debug.d.ts +131 -0
  60. package/dist/causal-debug.d.ts.map +1 -0
  61. package/dist/causal-debug.js +503 -0
  62. package/dist/causal-debug.js.map +1 -0
  63. package/dist/compatibility-catalog.d.ts +88 -0
  64. package/dist/compatibility-catalog.d.ts.map +1 -0
  65. package/dist/compatibility-catalog.js +344 -0
  66. package/dist/compatibility-catalog.js.map +1 -0
  67. package/dist/deep-link.d.ts +90 -0
  68. package/dist/deep-link.d.ts.map +1 -0
  69. package/dist/deep-link.js +346 -0
  70. package/dist/deep-link.js.map +1 -0
  71. package/dist/device-proof-signatures.d.ts +307 -0
  72. package/dist/device-proof-signatures.d.ts.map +1 -0
  73. package/dist/device-proof-signatures.js +1024 -0
  74. package/dist/device-proof-signatures.js.map +1 -0
  75. package/dist/fingerprint.d.ts +35 -0
  76. package/dist/fingerprint.d.ts.map +1 -0
  77. package/dist/fingerprint.js +454 -0
  78. package/dist/fingerprint.js.map +1 -0
  79. package/dist/index.d.ts +388 -0
  80. package/dist/index.d.ts.map +1 -0
  81. package/dist/index.js +2996 -0
  82. package/dist/index.js.map +1 -0
  83. package/dist/ios-causal-debug.d.ts +39 -0
  84. package/dist/ios-causal-debug.d.ts.map +1 -0
  85. package/dist/ios-causal-debug.js +318 -0
  86. package/dist/ios-causal-debug.js.map +1 -0
  87. package/dist/ios-logs.d.ts +58 -0
  88. package/dist/ios-logs.d.ts.map +1 -0
  89. package/dist/ios-logs.js +269 -0
  90. package/dist/ios-logs.js.map +1 -0
  91. package/dist/ios-process.d.ts +69 -0
  92. package/dist/ios-process.d.ts.map +1 -0
  93. package/dist/ios-process.js +389 -0
  94. package/dist/ios-process.js.map +1 -0
  95. package/dist/ios-run-preflight.d.ts +35 -0
  96. package/dist/ios-run-preflight.d.ts.map +1 -0
  97. package/dist/ios-run-preflight.js +172 -0
  98. package/dist/ios-run-preflight.js.map +1 -0
  99. package/dist/live-causal-debug-report.d.ts +49 -0
  100. package/dist/live-causal-debug-report.d.ts.map +1 -0
  101. package/dist/live-causal-debug-report.js +123 -0
  102. package/dist/live-causal-debug-report.js.map +1 -0
  103. package/dist/local-symbolication.d.ts +35 -0
  104. package/dist/local-symbolication.d.ts.map +1 -0
  105. package/dist/local-symbolication.js +89 -0
  106. package/dist/local-symbolication.js.map +1 -0
  107. package/dist/native-archive.d.ts +15 -0
  108. package/dist/native-archive.d.ts.map +1 -0
  109. package/dist/native-archive.js +441 -0
  110. package/dist/native-archive.js.map +1 -0
  111. package/dist/native-test.d.ts +43 -0
  112. package/dist/native-test.d.ts.map +1 -0
  113. package/dist/native-test.js +209 -0
  114. package/dist/native-test.js.map +1 -0
  115. package/dist/package-add.d.ts +56 -0
  116. package/dist/package-add.d.ts.map +1 -0
  117. package/dist/package-add.js +764 -0
  118. package/dist/package-add.js.map +1 -0
  119. package/dist/react-native-upgrade.d.ts +96 -0
  120. package/dist/react-native-upgrade.d.ts.map +1 -0
  121. package/dist/react-native-upgrade.js +882 -0
  122. package/dist/react-native-upgrade.js.map +1 -0
  123. package/dist/release-device-correlation.d.ts +40 -0
  124. package/dist/release-device-correlation.d.ts.map +1 -0
  125. package/dist/release-device-correlation.js +113 -0
  126. package/dist/release-device-correlation.js.map +1 -0
  127. package/dist/release-signatures.d.ts +168 -0
  128. package/dist/release-signatures.d.ts.map +1 -0
  129. package/dist/release-signatures.js +677 -0
  130. package/dist/release-signatures.js.map +1 -0
  131. package/dist/release.d.ts +88 -0
  132. package/dist/release.d.ts.map +1 -0
  133. package/dist/release.js +771 -0
  134. package/dist/release.js.map +1 -0
  135. package/dist/signature-utilities.d.ts +16 -0
  136. package/dist/signature-utilities.d.ts.map +1 -0
  137. package/dist/signature-utilities.js +114 -0
  138. package/dist/signature-utilities.js.map +1 -0
  139. package/dist/solid-diagnostics-correlation.d.ts +11 -0
  140. package/dist/solid-diagnostics-correlation.d.ts.map +1 -0
  141. package/dist/solid-diagnostics-correlation.js +78 -0
  142. package/dist/solid-diagnostics-correlation.js.map +1 -0
  143. package/dist/solid-diagnostics-debug.d.ts +15 -0
  144. package/dist/solid-diagnostics-debug.d.ts.map +1 -0
  145. package/dist/solid-diagnostics-debug.js +93 -0
  146. package/dist/solid-diagnostics-debug.js.map +1 -0
  147. package/dist/solid-diagnostics-inspection.d.ts +41 -0
  148. package/dist/solid-diagnostics-inspection.d.ts.map +1 -0
  149. package/dist/solid-diagnostics-inspection.js +196 -0
  150. package/dist/solid-diagnostics-inspection.js.map +1 -0
  151. package/dist/source-map.d.ts +36 -0
  152. package/dist/source-map.d.ts.map +1 -0
  153. package/dist/source-map.js +488 -0
  154. package/dist/source-map.js.map +1 -0
  155. package/dist/stack-symbolication.d.ts +56 -0
  156. package/dist/stack-symbolication.d.ts.map +1 -0
  157. package/dist/stack-symbolication.js +310 -0
  158. package/dist/stack-symbolication.js.map +1 -0
  159. package/dist/symbolication.d.ts +27 -0
  160. package/dist/symbolication.d.ts.map +1 -0
  161. package/dist/symbolication.js +75 -0
  162. package/dist/symbolication.js.map +1 -0
  163. package/dist/tree-debug.d.ts +53 -0
  164. package/dist/tree-debug.d.ts.map +1 -0
  165. package/dist/tree-debug.js +283 -0
  166. package/dist/tree-debug.js.map +1 -0
  167. package/dist/versions.d.ts +13 -0
  168. package/dist/versions.d.ts.map +1 -0
  169. package/dist/versions.js +14 -0
  170. package/dist/versions.js.map +1 -0
  171. package/package.json +46 -3
  172. package/templates/react-native-0.88/README.md +328 -0
  173. package/templates/react-native-0.88/android/CMakeLists.txt +27 -0
  174. package/templates/react-native-0.88/android/MainActivity.kt +123 -0
  175. package/templates/react-native-0.88/android/MainApplication.kt +43 -0
  176. package/templates/react-native-0.88/android/OnLoad.cpp +60 -0
  177. package/templates/react-native-0.88/index.js +1 -0
  178. package/templates/react-native-0.88/ios/AppDelegate.swift +190 -0
  179. package/templates/react-native-0.88/metro.config.js +16 -0
  180. package/templates/react-native-0.88/specs/NativeSolidNativeDebug.ts +16 -0
  181. package/templates/react-native-0.88/specs/NativeSolidNativePlatformAndroid.ts +14 -0
  182. package/templates/react-native-0.88/src/App.tsx +161 -0
  183. package/templates/react-native-0.88/src/main.tsx +88 -0
  184. package/templates/react-native-0.88/test/App.test.tsx +152 -0
package/dist/bin.js ADDED
@@ -0,0 +1,4530 @@
1
+ #!/usr/bin/env node
2
+ import path from "node:path";
3
+ import { SOLID_NATIVE_CLI_VERSION, VERIFIED_REACT_NATIVE_VERSION, NATIVE_CAUSAL_DEBUG_WATCH_DEFAULT_MAX_CONSECUTIVE_FAILURES, assembleNativeDeviceProofSignature, assembleNativeReleaseSignature, auditNativeReactNativeUpgrade, checkNativeBundleSources, checkNativeCompatibilityCatalog, checkNativeSolidBindingGeneration, compareNativeCausalDebugFiles, correlateNativeSolidDiagnosticsFiles, captureNativeAndroidCausalDebugReport, captureNativeAndroidCausalDebugSnapshot, captureNativeAndroidSolidDiagnostics, captureNativeAndroidTreeDebugSnapshot, captureNativeIosCausalDebugReport, captureNativeIosCausalDebugSnapshot, captureNativeIosSolidDiagnostics, captureNativeIosTreeDebugSnapshot, createNativeAdapterScaffoldPlan, createNativePackageAddPlan, createNativeAndroidLogsPlan, createNativeAndroidDeviceProof, createNativeCompatibilityEvidenceReport, createNativeDeviceProofIngestion, createNativeDeviceProofSignature, createNativeDeviceProofSigningRequest, createNativeSolidBindingAudit, createNativeBuildPlan, createNativeBundlePlan, createNativeCausalTraceFile, createNativeCausalTraceStream, createNativeCausalDebugReportFile, createNativeCausalDebugReportStream, createNativeCreatePlan, createNativeFingerprint, createNativeGeneratePlan, createNativeIosLogsPlan, createNativeDeepLinkPlan, createNativeReleaseManifest, createNativeReleaseDeviceCorrelation, createNativeReleaseSignature, createNativeReleaseSigningRequest, createNativeSymbolicationHandoff, createNativeRunPlan, createNativeStartPlan, createNativeTestPlan, executeNativeBuildPlan, executeNativeAdapterScaffoldPlan, executeNativePackageAddPlan, executeNativeBundlePlan, executeNativeCreatePlan, executeNativeGeneratePlan, executeNativeIosLogsPlan, executeNativeDeepLinkPlan, executeNativeAndroidLogsPlan, executeNativeRunPlan, executeNativeStartPlan, executeNativeTestPlan, formatDoctorReport, formatNativeAndroidApkSigningReport, formatNativeAndroidBundleSigningReport, formatNativeCausalDebugComparison, formatNativeAndroidLogsPlan, formatNativeCausalDebugInspection, formatNativeBuildPlan, formatNativeBundleVerification, formatNativeBundlePlan, formatNativeCompatibilityCatalogReport, formatNativeCreatePlan, formatNativeCreateSuccess, formatNativePackageAddPlan, formatNativeDeviceProofIngestion, formatNativeDeviceProofSignatureVerification, formatNativeFingerprint, formatNativeGeneratePlan, formatNativeIosApplicationProcessStatus, formatNativeIosApplicationProcessStop, formatNativeIosLogsPlan, formatNativeDeepLinkPlan, formatNativeReleaseVerification, formatNativeReleaseDeviceCorrelation, formatNativeReleaseSignatureVerification, formatNativeReactNativeUpgradeReport, formatNativeSourceLocationSymbolication, formatNativeStackTraceSymbolication, formatNativeSolidDiagnosticsInspection, formatNativeSolidDiagnosticsCorrelation, formatNativeTreeDebugInspection, formatNativeSymbolicationHandoff, formatNativeRunPlan, formatNativeSourceMapPolicyReport, formatNativeStartPlan, formatNativeTestPlan, inspectNativeCausalDebugFile, inspectNativeCausalDebugSnapshot, inspectNativeCausalDebugStream, inspectNativeSolidDiagnosticsFile, inspectNativeSolidDiagnosticsStream, inspectNativeTreeDebugFile, inspectNativeTreeDebugStream, inspectNativeDeviceProofProfile, readNativeSolidDiagnosticsDebugFile, readNativeTreeDebugSnapshotFile, readNativeDeviceProofReceipt, readNativeIosApplicationProcessStatus, runDoctor, stopNativeIosApplicationProcesses, symbolicateNativeSourceLocations, symbolicateNativeStackTraceFile, symbolicateNativeStackTraceStream, verifyNativeBundleManifest, verifyNativeAndroidApkSigning, verifyNativeAndroidBundleSigning, verifyNativeDeviceProofSignature, verifyNativeReleaseManifest, verifyNativeReleaseSignature, watchNativeCausalDebugSnapshots, writeNativeCausalDebugReportFile, } from "./index.js";
4
+ const HELP = `Solid Native CLI ${SOLID_NATIVE_CLI_VERSION} (command: sn | solid-native)
5
+
6
+ Usage (use \`sn\` or \`solid-native\`):
7
+ solid-native add navigation [--cwd PATH] [--dry-run] [--json]
8
+ solid-native adapter create MODULE --library PACKAGE [--output FILE] [--bindings FILE] [--dry-run]
9
+ solid-native create NAME [--directory PATH] [--package-name ID] [--title TITLE]
10
+ solid-native build ios|android [--cwd PATH] [--dry-run] [--] [native options]
11
+ solid-native debug capture-android PACKAGE --serial ID [--timeout MS]
12
+ solid-native debug diagnostics-android PACKAGE --serial ID [--duration MS] [--timeout MS]
13
+ solid-native debug report-android PACKAGE --serial ID [--duration MS] [--timeout MS] [--show-attributes] [--output FILE]
14
+ solid-native debug tree-android PACKAGE --serial ID [--timeout MS]
15
+ solid-native debug capture-ios BUNDLE --device ID [--timeout MS]
16
+ solid-native debug diagnostics-ios BUNDLE --device ID [--duration MS] [--timeout MS]
17
+ solid-native debug report-ios BUNDLE --device ID [--duration MS] [--timeout MS] [--show-attributes] [--output FILE]
18
+ solid-native debug tree-ios BUNDLE --device ID [--timeout MS]
19
+ solid-native debug diagnostics-inspect ARTIFACT|- [--json]
20
+ solid-native debug tree-inspect SNAPSHOT|- [--json]
21
+ solid-native debug correlate DIAGNOSTICS SNAPSHOT [--json]
22
+ solid-native debug watch-android PACKAGE --serial ID [--interval MS] [--count N] [--max-failures N] [--timeout MS] [--json]
23
+ solid-native debug watch-ios BUNDLE --device ID [--interval MS] [--count N] [--max-failures N] [--timeout MS] [--json]
24
+ solid-native debug compare BASELINE CANDIDATE [--max-p95-regression PERCENT] [--json]
25
+ solid-native debug inspect SNAPSHOT|- [--operation ID] [--show-attributes] [--json]
26
+ solid-native debug report SNAPSHOT|- [--diagnostics ARTIFACT] [--tree SNAPSHOT] [--operation ID] [--show-attributes] [--output FILE]
27
+ solid-native debug trace SNAPSHOT|- [--show-attributes]
28
+ solid-native debug symbolicate MAP (--at LINE:COLUMN... | --stack STACK|-) [--json]
29
+ solid-native bundle ios|android [--cwd PATH] [--output PATH] [--dry-run]
30
+ solid-native bundle sources MAP [--require SOURCE] [--forbid-containing TEXT] [--json]
31
+ solid-native bundle verify MANIFEST [--json]
32
+ solid-native compatibility check [--cwd PATH] [--catalog FILE] [--platform all|ios|android] [--json]
33
+ solid-native compatibility evidence FILE... [--cwd PATH] [--json]
34
+ solid-native device status-ios BUNDLE --device ID [--json]
35
+ solid-native device stop-ios BUNDLE --device ID [--json]
36
+ solid-native device-proof create-android --serial ID --not-before UTC --bundle FILE --source-map FILE --apk FILE --instrumentation-apk FILE --bindings FILE --instrumentation-results DIR --instrumentation-class CLASS --instrumentation-test TEST --require SOURCE --output FILE
37
+ solid-native device-proof sign RECEIPT --key PRIVATE_KEY --key-id ID --project NAME
38
+ solid-native device-proof signing-request RECEIPT --key-id ID --project NAME
39
+ solid-native device-proof assemble-signature REQUEST --signature FILE --public-key FILE
40
+ solid-native device-proof profile RECEIPT [--json]
41
+ solid-native device-proof ingestion SIGNATURE --proof RECEIPT --trust-policy FILE
42
+ solid-native device-proof verify-signature SIGNATURE --proof RECEIPT --public-key FILE --key-id ID --project NAME
43
+ solid-native device-proof verify-signature SIGNATURE --proof RECEIPT --trust-policy FILE
44
+ solid-native doctor [--platform all|ios|android] [--cwd PATH] [--strict] [--json]
45
+ solid-native fingerprint [--platform all|ios|android] [--cwd PATH] [--json]
46
+ solid-native generate [--platform all|ios|android] [--cwd PATH] [--output PATH]
47
+ solid-native logs android PACKAGE [--serial ID] [--since VALUE] [--dry-run]
48
+ solid-native logs ios BUNDLE --device ID --restart [--dry-run]
49
+ solid-native open android PACKAGE URL [--serial ID] [--cold] [--dry-run]
50
+ solid-native open ios BUNDLE URL --device ID [--cold] [--dry-run]
51
+ solid-native run ios|android [--cwd PATH] [--dry-run] [--] [native options]
52
+ solid-native release create --bundle FILE --artifact FILE --release ID --channel NAME --revision SHA [--android-upload-certificate-sha256 HEX | --android-signing-certificate-sha256 HEX...]
53
+ solid-native release verify-android-signing AAB|APK [--expected-certificate-sha256 HEX...] [--json]
54
+ solid-native release sign MANIFEST --key PRIVATE_KEY --key-id ID [--bundle FILE --artifact FILE]
55
+ solid-native release signing-request MANIFEST --key-id ID [--bundle FILE --artifact FILE]
56
+ solid-native release assemble-signature REQUEST --signature FILE --public-key FILE
57
+ solid-native release correlate-device-proof SIGNATURE --manifest MANIFEST --bundle FILE --artifact FILE --trust-policy FILE --device-signature FILE --proof RECEIPT --device-trust-policy FILE
58
+ solid-native release verify MANIFEST --bundle FILE --artifact FILE [--json]
59
+ solid-native release verify-signature SIGNATURE --manifest MANIFEST --public-key FILE --key-id ID --project NAME --platform ios|android --channel NAME (--bundle FILE --artifact FILE | --envelope-only)
60
+ solid-native release verify-signature SIGNATURE --manifest MANIFEST --trust-policy FILE (--bundle FILE --artifact FILE | --envelope-only)
61
+ solid-native release symbolication SIGNATURE --manifest MANIFEST --trust-policy FILE --bundle FILE --artifact FILE [--json]
62
+ solid-native start [--cwd PATH] [--dry-run] [--] [Metro options]
63
+ solid-native test [FILE|DIRECTORY...] [--watch] [--test-name-pattern REGEXP] [--production] [--cwd PATH] [--dry-run] [--json]
64
+ solid-native upgrade react-native --candidate PATH [--cwd PATH] [--json]
65
+ solid-native --help
66
+ solid-native --version
67
+
68
+ The doctor command is read-only. It checks the pinned React Native backend,
69
+ Fabric/Hermes project settings, and the local Xcode or Android toolchain.
70
+ --strict exits nonzero for warnings as well as failures, without changing the
71
+ machine-readable report schema.`;
72
+ const UPGRADE_HELP = `Usage:
73
+ solid-native upgrade react-native --candidate PATH [--cwd PATH] [--json]
74
+
75
+ Audits an already-installed candidate project against the current application
76
+ without changing either tree or using the network. It verifies exact package,
77
+ normalized runtime, Hermes compiler/bytecode, React, Codegen, Gradle plugin,
78
+ lockfile, and Fabric-boundary identities; fingerprints the imported upstream
79
+ header surface; and prints the native and physical-device gates still required.
80
+ A passing audit never promotes an unverified React Native backend.`;
81
+ const FINGERPRINT_HELP = `Usage:
82
+ solid-native fingerprint [--platform all|ios|android] [--cwd PATH] [--json]
83
+
84
+ Hashes the reviewed runtime identity, lockfile, compiler/bootstrap, and native
85
+ project inputs into deterministic per-platform compatibility fingerprints.
86
+ The result is unsigned local metadata; a delivery system must sign it before a
87
+ running application trusts it.`;
88
+ const CAUSAL_DEBUG_HELP = `Usage:
89
+ solid-native debug capture-android PACKAGE --serial ID [--timeout MS]
90
+ solid-native debug diagnostics-android PACKAGE --serial ID
91
+ [--duration MS] [--timeout MS]
92
+ solid-native debug report-android PACKAGE --serial ID [--duration MS]
93
+ [--timeout MS] [--show-attributes]
94
+ [--output FILE]
95
+ solid-native debug tree-android PACKAGE --serial ID [--timeout MS]
96
+ solid-native debug capture-ios BUNDLE --device ID [--timeout MS]
97
+ solid-native debug diagnostics-ios BUNDLE --device ID
98
+ [--duration MS] [--timeout MS]
99
+ solid-native debug report-ios BUNDLE --device ID [--duration MS]
100
+ [--timeout MS] [--show-attributes]
101
+ [--output FILE]
102
+ solid-native debug tree-ios BUNDLE --device ID [--timeout MS]
103
+ solid-native debug diagnostics-inspect ARTIFACT|- [--cwd PATH] [--json]
104
+ solid-native debug tree-inspect SNAPSHOT|- [--cwd PATH] [--json]
105
+ solid-native debug correlate DIAGNOSTICS SNAPSHOT [--cwd PATH] [--json]
106
+ solid-native debug watch-android PACKAGE --serial ID [--interval MS]
107
+ [--count N] [--max-failures N]
108
+ [--timeout MS] [--json]
109
+ solid-native debug watch-ios BUNDLE --device ID [--interval MS]
110
+ [--count N] [--max-failures N]
111
+ [--timeout MS] [--json]
112
+ solid-native debug compare BASELINE CANDIDATE
113
+ [--max-p95-regression PERCENT]
114
+ [--cwd PATH] [--json]
115
+ solid-native debug inspect SNAPSHOT|- [--operation ID] [--show-attributes]
116
+ [--cwd PATH] [--json]
117
+ solid-native debug report SNAPSHOT|- [--diagnostics ARTIFACT] [--tree SNAPSHOT]
118
+ [--operation ID] [--show-attributes]
119
+ [--output FILE] [--cwd PATH]
120
+ solid-native debug trace SNAPSHOT|- [--show-attributes] [--cwd PATH]
121
+ solid-native debug symbolicate MAP (--at LINE:COLUMN... | --stack STACK|-)
122
+ [--cwd PATH] [--json]
123
+
124
+ Validates one bounded causal-debug snapshot from a device or test process and
125
+ prints a path-free structural summary. Selecting an operation reconstructs its
126
+ retained causal ancestors and descendants. Attributes remain excluded unless
127
+ --show-attributes is explicit; the snapshot parser validates structure but
128
+ cannot determine whether custom application attributes contain private data.
129
+
130
+ Capture Android asks one running debuggable application for an app-private,
131
+ nonce-bound snapshot, validates it, removes the response, and writes only the
132
+ snapshot JSON to stdout. Store builds do not expose the transport.
133
+
134
+ Diagnostics Android opens one exclusive, timed Solid diagnostics and attribution
135
+ window in a development bundle. It writes a strict, bounded artifact containing
136
+ only diagnostic codes, static computation names, dependency changes, rerun
137
+ causes, and aggregate costs. Values, messages, stacks, owner IDs, props, text,
138
+ and rendered content never cross the device boundary.
139
+
140
+ Capture iOS delivers a nonce URL to one explicit device and bundle, consumes
141
+ only the matching app-container response through CoreDevice, acknowledges its
142
+ deletion, and writes the validated snapshot JSON. Store builds ignore requests.
143
+
144
+ Diagnostics iOS applies the same exclusive, timed, value-free Solid diagnostics
145
+ protocol through nonce-bound CoreDevice URLs and app-container responses.
146
+
147
+ Report Android and report iOS perform the complete live workflow in one
148
+ command: capture diagnostics first, capture the containing causal timeline
149
+ second, validate and correlate both, and emit the self-contained HTML debugger
150
+ to stdout or a private atomic file selected with --output. Existing output
151
+ files are never overwritten. Application-authored causal attributes stay
152
+ excluded unless --show-attributes is explicit. Device response files are
153
+ consumed by the same nonce-bound transports and no intermediate local artifact
154
+ is required.
155
+
156
+ Correlate validates a diagnostics artifact and a later causal snapshot, then
157
+ joins named Solid effect reruns to native computation → commit → mount → frame
158
+ chains in the same bounded capture window. The result explicitly remains a
159
+ static-name/window correlation, not an exact per-rerun token join.
160
+
161
+ Diagnostics inspect validates one captured artifact and prints bounded counts,
162
+ rerun outcomes, retained causes, aggregate costs, and the hottest static scope
163
+ and write names. It never adds raw runtime values or application content.
164
+
165
+ Tree Android and tree iOS request one app-private, nonce-bound structural
166
+ snapshot of the mounted logical UI tree, validate it within a 1 MiB budget,
167
+ remove the device response, and write the snapshot JSON to stdout. Only
168
+ component names, process-local handles, sorted prop/event key names, closed-enum
169
+ accessibility roles, static causal annotations, and text character counts cross
170
+ the boundary; rendered text, prop values, labels, and user input are excluded.
171
+
172
+ Tree inspect validates one captured UI tree snapshot from a file or stdin (-)
173
+ and renders a deterministic ASCII view hierarchy with component, event, and
174
+ causal summaries, or structured JSON with --json.
175
+
176
+ Watch repeats the matching one-shot capture sequentially and prints a safe
177
+ inspection after each response. It retains no snapshots, never overlaps
178
+ requests, and stops after three consecutive failures by default. --json emits
179
+ newline-delimited inspections. Without --count it runs until interrupted.
180
+ Watching iOS uses CoreDevice URL delivery for every capture and can foreground
181
+ the selected application.
182
+
183
+ Compare reads two bounded snapshots and reports aggregate operation, status,
184
+ graph-quality, and per-kind successful p95 duration deltas without exposing attributes.
185
+ Increased errors, evictions, discarded records, or unresolved causes fail the
186
+ comparison. Duration is informational unless --max-p95-regression supplies an
187
+ explicit percentage threshold; a failed comparison exits with status 1.
188
+
189
+ Report emits one self-contained offline HTML debugger to stdout. It includes a
190
+ searchable timeline and navigable causal links, makes no network requests, and
191
+ excludes application-authored attributes unless --show-attributes is explicit.
192
+ --output writes a private atomic file and refuses to replace an existing path.
193
+
194
+ Trace emits a deterministic Chrome JSON event array to stdout. Perfetto can
195
+ open it directly and renders retained cause relationships as flow arrows.
196
+ Attributes remain excluded unless --show-attributes is explicit.
197
+
198
+ Symbolication resolves either explicit one-based JavaScript locations or one
199
+ bounded Hermes/JSC/JavaScript stack file through a previously canonicalized
200
+ portable Solid Native source map. Use --stack - for strict bounded UTF-8 stdin.
201
+ Raw messages and generated bundle URLs are not retained in its result.`;
202
+ const ADAPTER_HELP = `Usage:
203
+ solid-native adapter create MODULE --library PACKAGE [--cwd PATH]
204
+ [--platform all|ios|android]
205
+ [--bindings FILE] [--output FILE]
206
+ [--dry-run] [--json]
207
+
208
+ Scaffolds an application-owned TurboModule adapter from one exact installed
209
+ Codegen dependency. Methods remain behind explicit policy hooks with unknown
210
+ outputs until application validation is written. Codegen event emitters become
211
+ decoded Solid-owned accessors. Existing files are never overwritten, and the
212
+ selected generated binding must be current before creation.`;
213
+ const ADD_HELP = `Usage:
214
+ solid-native add navigation [--cwd PATH] [--dry-run] [--json]
215
+
216
+ Installs one reviewed Solid Native capability recipe. The navigation recipe
217
+ pins the supported react-native-screens backend, copies its content-addressed
218
+ patch into the application without overwriting a different file, merges the
219
+ pnpm-workspace.yaml patch mapping, and reinstalls so the native dependency is actually
220
+ patched. Use --dry-run to inspect every package and filesystem action.`;
221
+ const CREATE_HELP = `Usage:
222
+ solid-native create NAME [--directory PATH] [--package-name ID] [--title TITLE]
223
+ [--skip-install] [--dry-run] [--json]
224
+
225
+ Creates an application-owned React Native 0.88 shell, replaces its React root
226
+ with Solid Native's OXC/Metro and JSI/Fabric bootstrap, and installs with the
227
+ validated pnpm 12 toolchain. Use --dry-run to inspect the upstream init command.`;
228
+ const GENERATE_HELP = `Usage:
229
+ solid-native generate [--platform all|ios|android] [--cwd PATH]
230
+ [--source app|library] [--output PATH] [--verbose]
231
+ [--solid-library PACKAGE]...
232
+ [--solid-output FILE | --no-solid]
233
+ [--audit | --check | --dry-run] [--json]
234
+
235
+ Solid Native resolves the application-local React Native 0.88 Codegen command.
236
+ Generated native artifacts stay in the application-owned platform tree unless
237
+ an explicit output path is supplied. Component and TurboModule application
238
+ schemas also emit React-free typed Solid bindings under generated/ by default.
239
+ Repeat --solid-library to include installed, direct dependency Codegen specs in
240
+ the same binding module. --check compares that module without running native
241
+ Codegen or writing files. --audit inventories reusable and excluded surfaces
242
+ without evaluating package wrappers. Use --dry-run to inspect both outputs.`;
243
+ const COMPATIBILITY_HELP = `Usage:
244
+ solid-native compatibility check [--cwd PATH] [--catalog FILE]
245
+ [--platform all|ios|android] [--json]
246
+ solid-native compatibility evidence FILE... [--cwd PATH] [--json]
247
+
248
+ Re-audits exact installed dependency Codegen schemas against an
249
+ application-owned compatibility catalog. Claims distinguish schema discovery,
250
+ generated bindings, native integration, and physical-device verification.
251
+ Evidence references must remain inside the application and match their pinned
252
+ SHA-256. The evidence operation prints ready-to-paste content-addressed entries;
253
+ it does not approve changes or replace running the referenced physical proof.`;
254
+ const DEVICE_PROOF_HELP = `Usage:
255
+ solid-native device-proof create-android --serial ID --not-before UTC
256
+ --bundle FILE --source-map FILE --apk FILE
257
+ --instrumentation-apk FILE --bindings FILE
258
+ --instrumentation-results DIR
259
+ --instrumentation-class CLASS
260
+ --instrumentation-test TEST --require SOURCE
261
+ [--require SOURCE]...
262
+ [--forbid-containing TEXT]...
263
+ --output FILE [--cwd PATH] [--json]
264
+ solid-native device-proof sign RECEIPT --key PRIVATE_KEY --key-id ID
265
+ --project NAME [--cwd PATH] [--output PATH]
266
+ [--json]
267
+ solid-native device-proof signing-request RECEIPT --key-id ID
268
+ --project NAME [--cwd PATH] [--output PATH]
269
+ [--json]
270
+ solid-native device-proof assemble-signature REQUEST --signature FILE
271
+ --public-key FILE [--cwd PATH] [--output PATH]
272
+ [--json]
273
+ solid-native device-proof profile RECEIPT [--cwd PATH] [--json]
274
+ solid-native device-proof ingestion SIGNATURE --proof RECEIPT
275
+ --public-key FILE --key-id ID --project NAME
276
+ [--cwd PATH] [--json]
277
+ solid-native device-proof ingestion SIGNATURE --proof RECEIPT
278
+ --trust-policy FILE
279
+ [--minimum-policy-sequence INTEGER]
280
+ [--cwd PATH] [--json]
281
+ solid-native device-proof verify-signature SIGNATURE --proof RECEIPT
282
+ --public-key FILE --key-id ID --project NAME
283
+ [--cwd PATH] [--json]
284
+ solid-native device-proof verify-signature SIGNATURE --proof RECEIPT
285
+ --trust-policy FILE
286
+ [--minimum-policy-sequence INTEGER]
287
+ [--cwd PATH] [--json]
288
+ Verification and ingestion optionally accept:
289
+ [--proof-sha256 SHA256] [--revision SHA]
290
+ [--native-fingerprint SHA256]
291
+ [--artifact-sha256 HEX]
292
+ [--profile-fingerprint SHA256]
293
+ [--minimum-measured-at UTC]
294
+ [--maximum-measured-at UTC]
295
+
296
+ The create-android operation emits an immutable portable schema-1 receipt only
297
+ after one fresh passing physical-device test, a clean stable Git revision,
298
+ live non-emulator device inspection, exact source-map policy, and stable bundle,
299
+ map, binding, and APK digests. It never overwrites existing evidence.
300
+
301
+ Signing strictly validates a clean physical-device receipt before signing its
302
+ exact bytes with a caller-managed Ed25519 key. Device-proof statements use a distinct
303
+ cryptographic context from release signatures and carry a separately governed
304
+ project identity. Verification requires either a pinned public key, key ID, and
305
+ project name or a versioned trust policy with active/revoked keys, and exposes
306
+ authenticated proof lineage only when every check passes. The ingestion
307
+ operation returns a path-free, uploader-neutral environment and execution
308
+ descriptor under that same authenticated lineage. Optional exact receipt,
309
+ revision, native-compatibility, application-artifact, and measurement-window
310
+ constraints prevent a valid but stale or unrelated lab result from satisfying
311
+ one rollout. Portable schema-1 receipts require a profile fingerprint over the
312
+ instrumentation and source policy; the profile operation prints the exact
313
+ reviewable identity. The signed measurement time is not an independent trusted
314
+ timestamp. The
315
+ signing-request operation emits the exact contextual payload for an offline,
316
+ HSM, or KMS signer; assemble-signature verifies returned raw or canonical
317
+ base64url Ed25519 bytes without reading private-key material. The CLI does not
318
+ generate keys, infer trust from a key file, or turn execution evidence into
319
+ release authorization.`;
320
+ const RUN_HELP = `Usage:
321
+ solid-native run ios [--cwd PATH] [--dry-run] [--json] [--] [run-ios options]
322
+ solid-native run android [--cwd PATH] [--dry-run] [--json] [--] [run-android options]
323
+
324
+ Solid Native resolves the application-local React Native 0.88 CLI and streams
325
+ its native build output directly. Arguments after the platform are forwarded;
326
+ use --dry-run to inspect the exact command without building or installing.
327
+ An explicit Android --device or --deviceId value is verified through adb before
328
+ Gradle starts. Physical targets must be unlocked and receive a reversible wired
329
+ stay-awake lease until run-android exits; emulators are not modified. Without a
330
+ selector, exactly one authorized target must be connected. Use --list-devices
331
+ for React Native's interactive multi-device selection. An automatically
332
+ resolved target is pinned into the run-android invocation after validation.
333
+ An explicit iOS --device value is treated as physical. An explicit --udid is
334
+ resolved against CoreSimulator first; physical destinations must be currently
335
+ unlocked before Metro, CocoaPods, or Xcode can start.`;
336
+ const LOGS_HELP = `Usage:
337
+ solid-native logs android PACKAGE [--serial ID] [--since VALUE]
338
+ [--dry-run] [--json]
339
+ solid-native logs ios BUNDLE --device ID --restart [--dry-run] [--json]
340
+
341
+ Selects exactly one authorized Android device (or the explicit serial), resolves
342
+ the installed application's exact UID, and streams only that UID's JavaScript
343
+ and native logcat records across process restarts. History defaults to logcat
344
+ -T 1; --since accepts another bounded logcat time or count. Dry runs perform
345
+ read-only device/package discovery and print the exact streaming command.
346
+
347
+ iOS requires an explicit CoreDevice identifier and --restart acknowledgement.
348
+ It verifies one developer-installed bundle, replaces that application process,
349
+ and attaches its standard streams through Xcode's supported launch console.
350
+ It does not include historical logs or survive an application restart. Ctrl-C
351
+ ends the console and launched app instead of leaving background processes.`;
352
+ const DEVICE_HELP = `Usage:
353
+ solid-native device status-ios BUNDLE --device ID [--json]
354
+ solid-native device stop-ios BUNDLE --device ID [--json]
355
+
356
+ Inspects or stops one exact developer-installed iOS application on an explicit
357
+ CoreDevice target. status-ios is read-only. stop-ios terminates every observed
358
+ process generation for that bundle and requires a full one-second clean window
359
+ before succeeding, so an immediate scene relaunch cannot be mistaken for
360
+ cleanup. Neither operation uninstalls the application or targets another
361
+ bundle.`;
362
+ const OPEN_HELP = `Usage:
363
+ solid-native open android PACKAGE URL [--serial ID] [--cold]
364
+ [--dry-run] [--json]
365
+ solid-native open ios BUNDLE URL --device ID [--cold]
366
+ [--dry-run] [--json]
367
+
368
+ Delivers one validated absolute URL to an explicitly targeted installed
369
+ application on a physical device. Android constrains intent resolution to the
370
+ selected package and verifies the resolved Activity. iOS verifies one
371
+ developer-installed bundle and consumes CoreDevice's structured launch result.
372
+
373
+ The default preserve mode does not terminate an existing application process;
374
+ it launches the app when absent. --cold explicitly stops any existing process
375
+ before delivery. Dry runs perform only device/application discovery and print
376
+ the exact inspected command. URL query values are visible in plan JSON and the
377
+ platform-tool command, so do not use production credentials as test links.`;
378
+ const BUILD_HELP = `Usage:
379
+ solid-native build ios [--cwd PATH] [--dry-run] [--json] [--] [build-ios options]
380
+ solid-native build android [--cwd PATH] [--dry-run] [--json] [--] [build-android options]
381
+
382
+ Creates a non-launching Release build through the application-local React
383
+ Native 0.88 CLI. Native options can select another mode, scheme, destination,
384
+ or Gradle task. Android Release mode produces bundle/release/app-release.aab;
385
+ pass --tasks assembleRelease explicitly when an APK is required. Use --dry-run
386
+ to inspect the exact command without building.`;
387
+ const BUNDLE_HELP = `Usage:
388
+ solid-native bundle ios|android [--cwd PATH] [--output PATH]
389
+ [--entry-file FILE] [--hermes-source]
390
+ [--dry-run] [--json]
391
+ [--] [Metro options]
392
+ solid-native bundle verify MANIFEST [--json]
393
+ solid-native bundle sources MAP [--cwd PATH] [--require SOURCE]...
394
+ [--forbid-containing TEXT]... [--json]
395
+
396
+ Creates a production OXC/Metro bundle, copied assets, and a composed source map
397
+ whose machine paths are canonicalized to portable app:/// identities.
398
+ --hermes-source emits the exact non-minified input expected by native iOS and
399
+ Android Release Hermes packaging. Use --dry-run to inspect without writing
400
+ artifacts. The sources operation validates a raw or canonical map through the
401
+ same bounded parser, requires each exact normalized source once, and rejects
402
+ every source containing a forbidden fragment.`;
403
+ const START_HELP = `Usage:
404
+ solid-native start [--cwd PATH] [--dry-run] [--json] [--] [Metro options]
405
+
406
+ Validates the installed Solid runtime, OXC/Metro compiler, and application
407
+ bootstrap before starting the application-local React Native 0.88 Metro server.
408
+ Use --dry-run to inspect the exact command without opening a listening port.`;
409
+ const TEST_HELP = `Usage:
410
+ solid-native test [FILE|DIRECTORY...] [--watch]
411
+ [--test-name-pattern REGEXP]
412
+ [--production]
413
+ [--cwd PATH] [--dry-run] [--json]
414
+
415
+ Discovers *.test and *.spec JavaScript/TypeScript files beneath test/ by
416
+ default, compiles TS and TSX with the same Solid universal OXC pipeline used by
417
+ Metro, and runs them with Node's built-in test runner. Explicit inputs must stay
418
+ inside the application. --watch reruns affected tests when their imported
419
+ dependencies change. --test-name-pattern filters test names with a JavaScript
420
+ regular expression. No simulator, device, Babel, Jest, or React renderer is
421
+ started. Tests use Solid's development runtime by default so diagnostics and
422
+ attribution are available. --production selects the optimized runtime for an
423
+ explicit production-semantics pass. Use --dry-run to inspect the exact files
424
+ and command.`;
425
+ const RELEASE_HELP = `Usage:
426
+ solid-native release verify-android-signing AAB|APK
427
+ [--expected-certificate-sha256 HEX...]
428
+ [--cwd PATH] [--json]
429
+ solid-native release create --bundle MANIFEST --artifact FILE --release ID
430
+ --channel NAME --revision SHA [--cwd PATH]
431
+ [--inspect-embedded-bundle] [--output PATH]
432
+ [--android-upload-certificate-sha256 HEX]
433
+ [--android-signing-certificate-sha256 HEX...]
434
+ [--json]
435
+ solid-native release verify MANIFEST --bundle MANIFEST --artifact FILE
436
+ [--cwd PATH] [--json]
437
+ solid-native release sign MANIFEST --key PRIVATE_KEY --key-id ID
438
+ [--bundle MANIFEST --artifact FILE]
439
+ [--cwd PATH] [--output PATH] [--json]
440
+ solid-native release signing-request MANIFEST --key-id ID
441
+ [--bundle MANIFEST --artifact FILE]
442
+ [--cwd PATH] [--output PATH] [--json]
443
+ solid-native release assemble-signature REQUEST --signature FILE
444
+ --public-key FILE [--cwd PATH]
445
+ [--output PATH] [--json]
446
+ solid-native release correlate-device-proof SIGNATURE --manifest MANIFEST
447
+ --bundle MANIFEST --artifact FILE
448
+ --trust-policy FILE
449
+ [--minimum-policy-sequence INTEGER]
450
+ --device-signature FILE --proof RECEIPT
451
+ --device-trust-policy FILE
452
+ [--device-minimum-policy-sequence INTEGER]
453
+ [--device-profile-fingerprint SHA256]
454
+ [--proof-sha256 SHA256]
455
+ [--minimum-measured-at UTC]
456
+ [--maximum-measured-at UTC]
457
+ [--cwd PATH] [--json]
458
+ solid-native release verify-signature SIGNATURE --manifest MANIFEST
459
+ --public-key FILE --key-id ID --project NAME
460
+ --platform ios|android --channel NAME
461
+ [--release ID] [--revision SHA]
462
+ [--release-fingerprint SHA256]
463
+ [--bundle-fingerprint SHA256]
464
+ [--native-fingerprint SHA256]
465
+ [--artifact-sha256 HEX]
466
+ (--bundle MANIFEST --artifact FILE |
467
+ --envelope-only) [--cwd PATH]
468
+ [--json]
469
+ solid-native release verify-signature SIGNATURE --manifest MANIFEST
470
+ --trust-policy FILE
471
+ [--minimum-policy-sequence INTEGER]
472
+ (--bundle MANIFEST --artifact FILE |
473
+ --envelope-only) [--cwd PATH] [--json]
474
+ solid-native release symbolication SIGNATURE --manifest MANIFEST
475
+ (--trust-policy FILE |
476
+ --public-key FILE --key-id ID --project NAME
477
+ --platform ios|android --channel NAME)
478
+ --bundle MANIFEST --artifact FILE
479
+ [--minimum-policy-sequence INTEGER]
480
+ [--cwd PATH] [--json]
481
+
482
+ Creates or verifies an unsigned deterministic envelope binding the portable
483
+ bundle, native compatibility inputs, source revision, channel, and final native
484
+ artifact. Detached Ed25519 signatures require either separately pinned key and
485
+ scope options or a bounded trust-policy file carrying active/revoked Ed25519
486
+ keys plus project/platform/channel scope. Supplying
487
+ --bundle and --artifact makes signing and signature verification check every
488
+ release input. A signing request exposes the same canonical contextual payload
489
+ for an offline or HSM/KMS signer; assembly requires the matching Ed25519 public
490
+ key and never reads a private key. Envelope-only verification must be explicit.
491
+ The release symbolication operation requires complete input verification and emits the
492
+ exact bundle/source-map pair under the same authorized release identity used by
493
+ runtime telemetry; it performs no upload. The CLI does not generate keys or
494
+ manage credentials. Android signing verification uses JDK jarsigner/keytool,
495
+ rejects unsigned or Android-Debug-signed AABs, and can pin the expected upload
496
+ certificate SHA-256. Passing that fingerprint to release create also binds the
497
+ verified public identity into the envelope. It does not claim Play acceptance
498
+ or Play App Signing.`;
499
+ function argumentValue(args, index, flag) {
500
+ const value = args[index + 1];
501
+ if (value === undefined || value.startsWith("-")) {
502
+ throw new TypeError(`${flag} requires a value.`);
503
+ }
504
+ return value;
505
+ }
506
+ function parseCreateArguments(args) {
507
+ const projectName = args[0];
508
+ if (projectName === "--help" || projectName === "-h") {
509
+ process.stdout.write(`${CREATE_HELP}\n`);
510
+ return undefined;
511
+ }
512
+ if (projectName === undefined || projectName.startsWith("-")) {
513
+ throw new TypeError("create requires a project name.");
514
+ }
515
+ let directory;
516
+ let dryRun = false;
517
+ let json = false;
518
+ let packageName;
519
+ let skipInstall = false;
520
+ let title;
521
+ for (let index = 1; index < args.length; index += 1) {
522
+ const argument = args[index];
523
+ if (argument === "--directory") {
524
+ directory = argumentValue(args, index, argument);
525
+ index += 1;
526
+ continue;
527
+ }
528
+ if (argument === "--package-name") {
529
+ packageName = argumentValue(args, index, argument);
530
+ index += 1;
531
+ continue;
532
+ }
533
+ if (argument === "--title") {
534
+ title = argumentValue(args, index, argument);
535
+ index += 1;
536
+ continue;
537
+ }
538
+ if (argument === "--skip-install") {
539
+ skipInstall = true;
540
+ continue;
541
+ }
542
+ if (argument === "--dry-run") {
543
+ dryRun = true;
544
+ continue;
545
+ }
546
+ if (argument === "--json") {
547
+ json = true;
548
+ continue;
549
+ }
550
+ if (argument === "--help" || argument === "-h") {
551
+ process.stdout.write(`${CREATE_HELP}\n`);
552
+ return undefined;
553
+ }
554
+ throw new TypeError(`Unknown create option ${String(argument)}.`);
555
+ }
556
+ if (json && !dryRun) {
557
+ throw new TypeError("create --json requires --dry-run so scaffold logs cannot corrupt JSON output.");
558
+ }
559
+ return {
560
+ dryRun,
561
+ json,
562
+ projectName,
563
+ skipInstall,
564
+ ...(directory === undefined ? {} : { directory }),
565
+ ...(packageName === undefined ? {} : { packageName }),
566
+ ...(title === undefined ? {} : { title }),
567
+ };
568
+ }
569
+ function parseDoctorArguments(args) {
570
+ let cwd;
571
+ let json = false;
572
+ let platform = "all";
573
+ let strict = false;
574
+ for (let index = 0; index < args.length; index += 1) {
575
+ const argument = args[index];
576
+ if (argument === "--json") {
577
+ json = true;
578
+ continue;
579
+ }
580
+ if (argument === "--strict") {
581
+ strict = true;
582
+ continue;
583
+ }
584
+ if (argument === "--cwd") {
585
+ cwd = argumentValue(args, index, argument);
586
+ index += 1;
587
+ continue;
588
+ }
589
+ if (argument === "--platform") {
590
+ const value = argumentValue(args, index, argument);
591
+ if (value !== "all" && value !== "ios" && value !== "android") {
592
+ throw new TypeError(`Unsupported platform ${value}.`);
593
+ }
594
+ platform = value;
595
+ index += 1;
596
+ continue;
597
+ }
598
+ if (argument === "--help" || argument === "-h") {
599
+ process.stdout.write(`${HELP}\n`);
600
+ process.exitCode = 0;
601
+ return {
602
+ json,
603
+ platform,
604
+ strict,
605
+ ...(cwd === undefined ? {} : { cwd }),
606
+ };
607
+ }
608
+ throw new TypeError(`Unknown doctor option ${String(argument)}.`);
609
+ }
610
+ return { json, platform, strict, ...(cwd === undefined ? {} : { cwd }) };
611
+ }
612
+ function parseUpgradeArguments(args) {
613
+ const target = args[0];
614
+ if (target === "--help" || target === "-h") {
615
+ process.stdout.write(`${UPGRADE_HELP}\n`);
616
+ return undefined;
617
+ }
618
+ if (target !== "react-native") {
619
+ throw new TypeError(target === undefined
620
+ ? "upgrade requires the react-native target."
621
+ : `Unsupported upgrade target ${target}.`);
622
+ }
623
+ let candidate;
624
+ let cwd;
625
+ let json = false;
626
+ for (let index = 1; index < args.length; index += 1) {
627
+ const argument = args[index];
628
+ if (argument === "--candidate") {
629
+ candidate = argumentValue(args, index, argument);
630
+ index += 1;
631
+ continue;
632
+ }
633
+ if (argument === "--cwd") {
634
+ cwd = argumentValue(args, index, argument);
635
+ index += 1;
636
+ continue;
637
+ }
638
+ if (argument === "--json") {
639
+ json = true;
640
+ continue;
641
+ }
642
+ if (argument === "--help" || argument === "-h") {
643
+ process.stdout.write(`${UPGRADE_HELP}\n`);
644
+ return undefined;
645
+ }
646
+ throw new TypeError(`Unknown upgrade option ${String(argument)}.`);
647
+ }
648
+ if (candidate === undefined) {
649
+ throw new TypeError("upgrade react-native requires --candidate PATH.");
650
+ }
651
+ return {
652
+ candidate,
653
+ json,
654
+ ...(cwd === undefined ? {} : { cwd }),
655
+ };
656
+ }
657
+ function parseFingerprintArguments(args) {
658
+ let cwd;
659
+ let json = false;
660
+ let platform = "all";
661
+ for (let index = 0; index < args.length; index += 1) {
662
+ const argument = args[index];
663
+ if (argument === "--json") {
664
+ json = true;
665
+ continue;
666
+ }
667
+ if (argument === "--cwd") {
668
+ cwd = argumentValue(args, index, argument);
669
+ index += 1;
670
+ continue;
671
+ }
672
+ if (argument === "--platform") {
673
+ const value = argumentValue(args, index, argument);
674
+ if (value !== "all" && value !== "ios" && value !== "android") {
675
+ throw new TypeError(`Unsupported platform ${value}.`);
676
+ }
677
+ platform = value;
678
+ index += 1;
679
+ continue;
680
+ }
681
+ if (argument === "--help" || argument === "-h") {
682
+ process.stdout.write(`${FINGERPRINT_HELP}\n`);
683
+ return undefined;
684
+ }
685
+ throw new TypeError(`Unknown fingerprint option ${String(argument)}.`);
686
+ }
687
+ return { json, platform, ...(cwd === undefined ? {} : { cwd }) };
688
+ }
689
+ function parseCausalDebugArguments(args) {
690
+ const operation = args[0];
691
+ if (operation === "--help" || operation === "-h") {
692
+ process.stdout.write(`${CAUSAL_DEBUG_HELP}\n`);
693
+ return undefined;
694
+ }
695
+ if (operation !== "capture-android" &&
696
+ operation !== "diagnostics-android" &&
697
+ operation !== "report-android" &&
698
+ operation !== "tree-android" &&
699
+ operation !== "capture-ios" &&
700
+ operation !== "diagnostics-ios" &&
701
+ operation !== "report-ios" &&
702
+ operation !== "tree-ios" &&
703
+ operation !== "diagnostics-inspect" &&
704
+ operation !== "tree-inspect" &&
705
+ operation !== "correlate" &&
706
+ operation !== "watch-android" &&
707
+ operation !== "watch-ios" &&
708
+ operation !== "compare" &&
709
+ operation !== "inspect" &&
710
+ operation !== "report" &&
711
+ operation !== "trace" &&
712
+ operation !== "symbolicate") {
713
+ throw new TypeError("debug requires capture-android, diagnostics-android, report-android, tree-android, capture-ios, diagnostics-ios, report-ios, tree-ios, diagnostics-inspect, tree-inspect, correlate, watch-android, watch-ios, compare, inspect, report, trace, or symbolicate.");
714
+ }
715
+ if (operation === "correlate") {
716
+ const diagnosticsPath = args[1];
717
+ const snapshotPath = args[2];
718
+ if (diagnosticsPath === "--help" ||
719
+ diagnosticsPath === "-h" ||
720
+ snapshotPath === "--help" ||
721
+ snapshotPath === "-h") {
722
+ process.stdout.write(`${CAUSAL_DEBUG_HELP}\n`);
723
+ return undefined;
724
+ }
725
+ if (diagnosticsPath === undefined ||
726
+ snapshotPath === undefined ||
727
+ diagnosticsPath.startsWith("-") ||
728
+ snapshotPath.startsWith("-")) {
729
+ throw new TypeError("debug correlate requires diagnostics and causal snapshot paths.");
730
+ }
731
+ let cwd;
732
+ let json = false;
733
+ for (let index = 3; index < args.length; index += 1) {
734
+ const argument = args[index];
735
+ if (argument === "--cwd") {
736
+ cwd = argumentValue(args, index, argument);
737
+ index += 1;
738
+ continue;
739
+ }
740
+ if (argument === "--json") {
741
+ json = true;
742
+ continue;
743
+ }
744
+ if (argument === "--help" || argument === "-h") {
745
+ process.stdout.write(`${CAUSAL_DEBUG_HELP}\n`);
746
+ return undefined;
747
+ }
748
+ throw new TypeError(`Unknown debug correlate option ${String(argument)}.`);
749
+ }
750
+ return {
751
+ operation,
752
+ diagnosticsPath,
753
+ snapshotPath,
754
+ json,
755
+ ...(cwd === undefined ? {} : { cwd }),
756
+ };
757
+ }
758
+ if (operation === "compare") {
759
+ const baselinePath = args[1];
760
+ const candidatePath = args[2];
761
+ if (baselinePath === "--help" ||
762
+ baselinePath === "-h" ||
763
+ candidatePath === "--help" ||
764
+ candidatePath === "-h") {
765
+ process.stdout.write(`${CAUSAL_DEBUG_HELP}\n`);
766
+ return undefined;
767
+ }
768
+ if (baselinePath === undefined ||
769
+ candidatePath === undefined ||
770
+ baselinePath.startsWith("-") ||
771
+ candidatePath.startsWith("-")) {
772
+ throw new TypeError("debug compare requires baseline and candidate snapshot paths.");
773
+ }
774
+ let cwd;
775
+ let json = false;
776
+ let maxP95RegressionPercent;
777
+ for (let index = 3; index < args.length; index += 1) {
778
+ const argument = args[index];
779
+ if (argument === "--cwd") {
780
+ cwd = argumentValue(args, index, argument);
781
+ index += 1;
782
+ continue;
783
+ }
784
+ if (argument === "--json") {
785
+ json = true;
786
+ continue;
787
+ }
788
+ if (argument === "--max-p95-regression") {
789
+ const value = Number(argumentValue(args, index, argument));
790
+ if (!Number.isFinite(value) || value < 0 || value > 10_000) {
791
+ throw new TypeError("--max-p95-regression requires a finite percentage from 0 through 10000.");
792
+ }
793
+ maxP95RegressionPercent = value;
794
+ index += 1;
795
+ continue;
796
+ }
797
+ if (argument === "--help" || argument === "-h") {
798
+ process.stdout.write(`${CAUSAL_DEBUG_HELP}\n`);
799
+ return undefined;
800
+ }
801
+ throw new TypeError(`Unknown debug compare option ${String(argument)}.`);
802
+ }
803
+ return {
804
+ operation,
805
+ baselinePath,
806
+ candidatePath,
807
+ json,
808
+ ...(cwd === undefined ? {} : { cwd }),
809
+ ...(maxP95RegressionPercent === undefined
810
+ ? {}
811
+ : { maxP95RegressionPercent }),
812
+ };
813
+ }
814
+ const androidDeviceOperation = operation === "capture-android" ||
815
+ operation === "diagnostics-android" ||
816
+ operation === "report-android" ||
817
+ operation === "tree-android" ||
818
+ operation === "watch-android";
819
+ const iosDeviceOperation = operation === "capture-ios" ||
820
+ operation === "diagnostics-ios" ||
821
+ operation === "report-ios" ||
822
+ operation === "tree-ios" ||
823
+ operation === "watch-ios";
824
+ const deviceOperation = androidDeviceOperation || iosDeviceOperation;
825
+ const liveReportOperation = operation === "report-android" || operation === "report-ios";
826
+ const watchOperation = operation === "watch-android" || operation === "watch-ios";
827
+ const inputPath = args[1];
828
+ if (inputPath === "--help" || inputPath === "-h") {
829
+ process.stdout.write(`${CAUSAL_DEBUG_HELP}\n`);
830
+ return undefined;
831
+ }
832
+ if (inputPath === undefined ||
833
+ (inputPath.startsWith("-") &&
834
+ !(operation !== "symbolicate" && !deviceOperation && inputPath === "-"))) {
835
+ throw new TypeError(deviceOperation
836
+ ? `debug ${operation} requires ${androidDeviceOperation ? "an Android application ID" : "an iOS bundle identifier"}.`
837
+ : `debug ${operation} requires an input path.`);
838
+ }
839
+ let count;
840
+ let cwd;
841
+ let includeAttributes = false;
842
+ let json = false;
843
+ let device;
844
+ let diagnosticsPath;
845
+ let treePath;
846
+ let durationMs;
847
+ let intervalMs;
848
+ let maxConsecutiveFailures;
849
+ let operationId;
850
+ let outputPath;
851
+ let serial;
852
+ let stackPath;
853
+ let timeoutMs;
854
+ const locations = [];
855
+ for (let index = 2; index < args.length; index += 1) {
856
+ const argument = args[index];
857
+ if (argument === "--cwd") {
858
+ if (deviceOperation) {
859
+ throw new TypeError(`debug ${operation} does not support --cwd.`);
860
+ }
861
+ cwd = argumentValue(args, index, argument);
862
+ index += 1;
863
+ continue;
864
+ }
865
+ if (argument === "--json") {
866
+ if (operation === "report" ||
867
+ liveReportOperation ||
868
+ operation === "trace" ||
869
+ operation === "capture-android" ||
870
+ operation === "diagnostics-android" ||
871
+ operation === "tree-android" ||
872
+ operation === "capture-ios" ||
873
+ operation === "diagnostics-ios" ||
874
+ operation === "tree-ios") {
875
+ throw new TypeError(operation === "trace" || operation === "report" || liveReportOperation
876
+ ? `debug ${operation} always emits ${operation === "trace" ? "Chrome JSON" : "HTML"} and does not support --json.`
877
+ : `debug ${operation} always emits snapshot JSON and does not support --json.`);
878
+ }
879
+ json = true;
880
+ continue;
881
+ }
882
+ if (argument === "--operation") {
883
+ if (operation !== "inspect" && operation !== "report") {
884
+ throw new TypeError(`debug ${operation} does not support --operation.`);
885
+ }
886
+ operationId = argumentValue(args, index, argument);
887
+ index += 1;
888
+ continue;
889
+ }
890
+ if (argument === "--diagnostics") {
891
+ if (operation !== "report") {
892
+ throw new TypeError(`debug ${operation} does not support --diagnostics.`);
893
+ }
894
+ const value = argumentValue(args, index, argument);
895
+ if (value === "-") {
896
+ throw new TypeError("debug report --diagnostics requires a file path, not stdin.");
897
+ }
898
+ if (diagnosticsPath !== undefined) {
899
+ throw new TypeError("debug report accepts --diagnostics only once.");
900
+ }
901
+ diagnosticsPath = value;
902
+ index += 1;
903
+ continue;
904
+ }
905
+ if (argument === "--tree") {
906
+ if (operation !== "report") {
907
+ throw new TypeError(`debug ${operation} does not support --tree.`);
908
+ }
909
+ if (args[index + 1] === "-") {
910
+ throw new TypeError("debug report --tree requires a file path, not stdin.");
911
+ }
912
+ const value = argumentValue(args, index, argument);
913
+ if (treePath !== undefined) {
914
+ throw new TypeError("debug report accepts --tree only once.");
915
+ }
916
+ treePath = value;
917
+ index += 1;
918
+ continue;
919
+ }
920
+ if (argument === "--show-attributes") {
921
+ if (operation === "symbolicate" ||
922
+ operation === "diagnostics-inspect" ||
923
+ operation === "tree-inspect" ||
924
+ (deviceOperation && !liveReportOperation)) {
925
+ throw new TypeError(`debug ${operation} does not support --show-attributes.`);
926
+ }
927
+ includeAttributes = true;
928
+ continue;
929
+ }
930
+ if (argument === "--output") {
931
+ if (operation !== "report" && !liveReportOperation) {
932
+ throw new TypeError(`debug ${operation} does not support --output.`);
933
+ }
934
+ if (outputPath !== undefined) {
935
+ throw new TypeError(`debug ${operation} accepts --output only once.`);
936
+ }
937
+ const value = argumentValue(args, index, argument);
938
+ if (value === "-") {
939
+ throw new TypeError(`debug ${operation} --output requires a file path; omit it for stdout.`);
940
+ }
941
+ outputPath = value;
942
+ index += 1;
943
+ continue;
944
+ }
945
+ if (argument === "--serial") {
946
+ if (!androidDeviceOperation) {
947
+ throw new TypeError(`debug ${operation} does not support --serial.`);
948
+ }
949
+ serial = argumentValue(args, index, argument);
950
+ index += 1;
951
+ continue;
952
+ }
953
+ if (argument === "--device") {
954
+ if (!iosDeviceOperation) {
955
+ throw new TypeError(`debug ${operation} does not support --device.`);
956
+ }
957
+ device = argumentValue(args, index, argument);
958
+ index += 1;
959
+ continue;
960
+ }
961
+ if (argument === "--timeout") {
962
+ if (!deviceOperation) {
963
+ throw new TypeError(`debug ${operation} does not support --timeout.`);
964
+ }
965
+ const value = argumentValue(args, index, argument);
966
+ timeoutMs = Number(value);
967
+ if (!Number.isSafeInteger(timeoutMs)) {
968
+ throw new TypeError("--timeout requires a safe integer.");
969
+ }
970
+ index += 1;
971
+ continue;
972
+ }
973
+ if (argument === "--duration") {
974
+ if (operation !== "diagnostics-android" &&
975
+ operation !== "diagnostics-ios" &&
976
+ operation !== "report-android" &&
977
+ operation !== "report-ios") {
978
+ throw new TypeError(`debug ${operation} does not support --duration.`);
979
+ }
980
+ durationMs = Number(argumentValue(args, index, argument));
981
+ if (!Number.isSafeInteger(durationMs)) {
982
+ throw new TypeError("--duration requires a safe integer.");
983
+ }
984
+ index += 1;
985
+ continue;
986
+ }
987
+ if (argument === "--interval" ||
988
+ argument === "--count" ||
989
+ argument === "--max-failures") {
990
+ if (!watchOperation) {
991
+ throw new TypeError(`debug ${operation} does not support ${argument}.`);
992
+ }
993
+ const value = Number(argumentValue(args, index, argument));
994
+ if (!Number.isSafeInteger(value) || value < 1) {
995
+ throw new TypeError(`${argument} requires a positive safe integer.`);
996
+ }
997
+ if (argument === "--interval")
998
+ intervalMs = value;
999
+ if (argument === "--count")
1000
+ count = value;
1001
+ if (argument === "--max-failures") {
1002
+ maxConsecutiveFailures = value;
1003
+ }
1004
+ index += 1;
1005
+ continue;
1006
+ }
1007
+ if (argument === "--at") {
1008
+ if (operation !== "symbolicate") {
1009
+ throw new TypeError(`debug ${operation} does not support --at.`);
1010
+ }
1011
+ const value = argumentValue(args, index, argument);
1012
+ const match = /^([1-9]\d*):([1-9]\d*)$/u.exec(value);
1013
+ if (match === null) {
1014
+ throw new TypeError(`Symbolication location ${JSON.stringify(value)} must use positive one-based LINE:COLUMN.`);
1015
+ }
1016
+ const line = Number(match[1]);
1017
+ const column = Number(match[2]);
1018
+ if (!Number.isSafeInteger(line) || !Number.isSafeInteger(column)) {
1019
+ throw new TypeError(`Symbolication location ${JSON.stringify(value)} must use safe integers.`);
1020
+ }
1021
+ locations.push({ line, column });
1022
+ index += 1;
1023
+ continue;
1024
+ }
1025
+ if (argument === "--stack") {
1026
+ if (operation !== "symbolicate") {
1027
+ throw new TypeError(`debug ${operation} does not support --stack.`);
1028
+ }
1029
+ if (stackPath !== undefined) {
1030
+ throw new TypeError("debug symbolicate accepts --stack only once.");
1031
+ }
1032
+ const value = args[index + 1];
1033
+ if (value === undefined ||
1034
+ value.length === 0 ||
1035
+ (value.startsWith("-") && value !== "-")) {
1036
+ throw new TypeError("--stack requires a file path or - for stdin.");
1037
+ }
1038
+ stackPath = value;
1039
+ index += 1;
1040
+ continue;
1041
+ }
1042
+ if (argument === "--help" || argument === "-h") {
1043
+ process.stdout.write(`${CAUSAL_DEBUG_HELP}\n`);
1044
+ return undefined;
1045
+ }
1046
+ throw new TypeError(`Unknown debug ${operation} option ${String(argument)}.`);
1047
+ }
1048
+ if (operation === "capture-android") {
1049
+ if (serial === undefined) {
1050
+ throw new TypeError("debug capture-android requires --serial.");
1051
+ }
1052
+ return {
1053
+ operation,
1054
+ packageName: inputPath,
1055
+ serial,
1056
+ ...(timeoutMs === undefined ? {} : { timeoutMs }),
1057
+ };
1058
+ }
1059
+ if (operation === "diagnostics-android") {
1060
+ if (serial === undefined) {
1061
+ throw new TypeError("debug diagnostics-android requires --serial.");
1062
+ }
1063
+ return {
1064
+ operation,
1065
+ packageName: inputPath,
1066
+ serial,
1067
+ ...(durationMs === undefined ? {} : { durationMs }),
1068
+ ...(timeoutMs === undefined ? {} : { timeoutMs }),
1069
+ };
1070
+ }
1071
+ if (operation === "report-android") {
1072
+ if (serial === undefined) {
1073
+ throw new TypeError("debug report-android requires --serial.");
1074
+ }
1075
+ return {
1076
+ operation,
1077
+ packageName: inputPath,
1078
+ serial,
1079
+ includeAttributes,
1080
+ ...(outputPath === undefined ? {} : { outputPath }),
1081
+ ...(durationMs === undefined ? {} : { durationMs }),
1082
+ ...(timeoutMs === undefined ? {} : { timeoutMs }),
1083
+ };
1084
+ }
1085
+ if (operation === "tree-android") {
1086
+ if (serial === undefined) {
1087
+ throw new TypeError("debug tree-android requires --serial.");
1088
+ }
1089
+ return {
1090
+ operation,
1091
+ packageName: inputPath,
1092
+ serial,
1093
+ ...(timeoutMs === undefined ? {} : { timeoutMs }),
1094
+ };
1095
+ }
1096
+ if (operation === "capture-ios") {
1097
+ if (device === undefined) {
1098
+ throw new TypeError("debug capture-ios requires --device.");
1099
+ }
1100
+ return {
1101
+ operation,
1102
+ bundleIdentifier: inputPath,
1103
+ device,
1104
+ ...(timeoutMs === undefined ? {} : { timeoutMs }),
1105
+ };
1106
+ }
1107
+ if (operation === "tree-ios") {
1108
+ if (device === undefined) {
1109
+ throw new TypeError("debug tree-ios requires --device.");
1110
+ }
1111
+ return {
1112
+ operation,
1113
+ bundleIdentifier: inputPath,
1114
+ device,
1115
+ ...(timeoutMs === undefined ? {} : { timeoutMs }),
1116
+ };
1117
+ }
1118
+ if (operation === "diagnostics-ios") {
1119
+ if (device === undefined) {
1120
+ throw new TypeError("debug diagnostics-ios requires --device.");
1121
+ }
1122
+ return {
1123
+ operation,
1124
+ bundleIdentifier: inputPath,
1125
+ device,
1126
+ ...(durationMs === undefined ? {} : { durationMs }),
1127
+ ...(timeoutMs === undefined ? {} : { timeoutMs }),
1128
+ };
1129
+ }
1130
+ if (operation === "report-ios") {
1131
+ if (device === undefined) {
1132
+ throw new TypeError("debug report-ios requires --device.");
1133
+ }
1134
+ return {
1135
+ operation,
1136
+ bundleIdentifier: inputPath,
1137
+ device,
1138
+ includeAttributes,
1139
+ ...(outputPath === undefined ? {} : { outputPath }),
1140
+ ...(durationMs === undefined ? {} : { durationMs }),
1141
+ ...(timeoutMs === undefined ? {} : { timeoutMs }),
1142
+ };
1143
+ }
1144
+ if (operation === "watch-android") {
1145
+ if (serial === undefined) {
1146
+ throw new TypeError("debug watch-android requires --serial.");
1147
+ }
1148
+ return {
1149
+ operation,
1150
+ packageName: inputPath,
1151
+ serial,
1152
+ json,
1153
+ ...(count === undefined ? {} : { count }),
1154
+ ...(intervalMs === undefined ? {} : { intervalMs }),
1155
+ ...(maxConsecutiveFailures === undefined
1156
+ ? {}
1157
+ : { maxConsecutiveFailures }),
1158
+ ...(timeoutMs === undefined ? {} : { timeoutMs }),
1159
+ };
1160
+ }
1161
+ if (operation === "diagnostics-inspect") {
1162
+ return {
1163
+ operation,
1164
+ artifactPath: inputPath,
1165
+ json,
1166
+ ...(cwd === undefined ? {} : { cwd }),
1167
+ };
1168
+ }
1169
+ if (operation === "tree-inspect") {
1170
+ return {
1171
+ operation,
1172
+ snapshotPath: inputPath,
1173
+ json,
1174
+ ...(cwd === undefined ? {} : { cwd }),
1175
+ };
1176
+ }
1177
+ if (operation === "watch-ios") {
1178
+ if (device === undefined) {
1179
+ throw new TypeError("debug watch-ios requires --device.");
1180
+ }
1181
+ return {
1182
+ operation,
1183
+ bundleIdentifier: inputPath,
1184
+ device,
1185
+ json,
1186
+ ...(count === undefined ? {} : { count }),
1187
+ ...(intervalMs === undefined ? {} : { intervalMs }),
1188
+ ...(maxConsecutiveFailures === undefined
1189
+ ? {}
1190
+ : { maxConsecutiveFailures }),
1191
+ ...(timeoutMs === undefined ? {} : { timeoutMs }),
1192
+ };
1193
+ }
1194
+ if (operation === "symbolicate") {
1195
+ if (locations.length > 0 && stackPath !== undefined) {
1196
+ throw new TypeError("debug symbolicate --at and --stack are mutually exclusive.");
1197
+ }
1198
+ if (locations.length === 0 && stackPath === undefined) {
1199
+ throw new TypeError("debug symbolicate requires --at or --stack.");
1200
+ }
1201
+ const common = {
1202
+ operation,
1203
+ json,
1204
+ sourceMapPath: inputPath,
1205
+ ...(cwd === undefined ? {} : { cwd }),
1206
+ };
1207
+ return stackPath === undefined
1208
+ ? { ...common, input: "locations", locations }
1209
+ : { ...common, input: "stack", stackPath };
1210
+ }
1211
+ if (operation === "trace") {
1212
+ return {
1213
+ operation,
1214
+ includeAttributes,
1215
+ snapshotPath: inputPath,
1216
+ ...(cwd === undefined ? {} : { cwd }),
1217
+ };
1218
+ }
1219
+ if (operation === "report") {
1220
+ return {
1221
+ operation,
1222
+ includeAttributes,
1223
+ snapshotPath: inputPath,
1224
+ ...(outputPath === undefined ? {} : { outputPath }),
1225
+ ...(cwd === undefined ? {} : { cwd }),
1226
+ ...(diagnosticsPath === undefined ? {} : { diagnosticsPath }),
1227
+ ...(treePath === undefined ? {} : { treePath }),
1228
+ ...(operationId === undefined ? {} : { operationId }),
1229
+ };
1230
+ }
1231
+ return {
1232
+ operation,
1233
+ includeAttributes,
1234
+ json,
1235
+ snapshotPath: inputPath,
1236
+ ...(cwd === undefined ? {} : { cwd }),
1237
+ ...(operationId === undefined ? {} : { operationId }),
1238
+ };
1239
+ }
1240
+ function parseCompatibilityArguments(args) {
1241
+ const operation = args[0];
1242
+ if (operation === "--help" || operation === "-h") {
1243
+ process.stdout.write(`${COMPATIBILITY_HELP}\n`);
1244
+ return undefined;
1245
+ }
1246
+ if (operation === "evidence") {
1247
+ let cwd;
1248
+ let json = false;
1249
+ const paths = [];
1250
+ for (let index = 1; index < args.length; index += 1) {
1251
+ const argument = args[index];
1252
+ if (argument === "--help" || argument === "-h") {
1253
+ process.stdout.write(`${COMPATIBILITY_HELP}\n`);
1254
+ return undefined;
1255
+ }
1256
+ if (argument === "--json") {
1257
+ json = true;
1258
+ continue;
1259
+ }
1260
+ if (argument === "--cwd") {
1261
+ cwd = argumentValue(args, index, argument);
1262
+ index += 1;
1263
+ continue;
1264
+ }
1265
+ if (argument.startsWith("-")) {
1266
+ throw new TypeError(`Unknown compatibility evidence option ${String(argument)}.`);
1267
+ }
1268
+ paths.push(argument);
1269
+ }
1270
+ if (paths.length === 0) {
1271
+ throw new TypeError("compatibility evidence requires at least one file.");
1272
+ }
1273
+ return {
1274
+ operation,
1275
+ json,
1276
+ paths: Object.freeze(paths),
1277
+ ...(cwd === undefined ? {} : { cwd }),
1278
+ };
1279
+ }
1280
+ if (operation !== "check") {
1281
+ throw new TypeError("compatibility requires the check or evidence operation.");
1282
+ }
1283
+ let catalogPath;
1284
+ let cwd;
1285
+ let json = false;
1286
+ let platform = "all";
1287
+ for (let index = 1; index < args.length; index += 1) {
1288
+ const argument = args[index];
1289
+ if (argument === "--help" || argument === "-h") {
1290
+ process.stdout.write(`${COMPATIBILITY_HELP}\n`);
1291
+ return undefined;
1292
+ }
1293
+ if (argument === "--json") {
1294
+ json = true;
1295
+ continue;
1296
+ }
1297
+ if (argument === "--catalog") {
1298
+ catalogPath = argumentValue(args, index, argument);
1299
+ index += 1;
1300
+ continue;
1301
+ }
1302
+ if (argument === "--cwd") {
1303
+ cwd = argumentValue(args, index, argument);
1304
+ index += 1;
1305
+ continue;
1306
+ }
1307
+ if (argument === "--platform") {
1308
+ const value = argumentValue(args, index, argument);
1309
+ if (value !== "all" && value !== "ios" && value !== "android") {
1310
+ throw new TypeError(`Unsupported platform ${value}.`);
1311
+ }
1312
+ platform = value;
1313
+ index += 1;
1314
+ continue;
1315
+ }
1316
+ throw new TypeError(`Unknown compatibility option ${String(argument)}.`);
1317
+ }
1318
+ return {
1319
+ operation,
1320
+ json,
1321
+ platform,
1322
+ ...(catalogPath === undefined ? {} : { catalogPath }),
1323
+ ...(cwd === undefined ? {} : { cwd }),
1324
+ };
1325
+ }
1326
+ function parseDeviceProofArguments(args) {
1327
+ const operation = args[0];
1328
+ if (operation === "--help" || operation === "-h") {
1329
+ process.stdout.write(`${DEVICE_PROOF_HELP}\n`);
1330
+ return undefined;
1331
+ }
1332
+ if (operation === "create-android") {
1333
+ let applicationApkPath;
1334
+ let applicationBundlePath;
1335
+ let cwd;
1336
+ const forbiddenSourceFragments = [];
1337
+ let generatedBindingsPath;
1338
+ let instrumentationApkPath;
1339
+ let instrumentationClass;
1340
+ let instrumentationResultsDirectory;
1341
+ let instrumentationTest;
1342
+ let json = false;
1343
+ let notBefore;
1344
+ let outputPath;
1345
+ const requiredSources = [];
1346
+ let serial;
1347
+ let sourceMapPath;
1348
+ const singles = new Set();
1349
+ for (let index = 1; index < args.length; index += 1) {
1350
+ const argument = args[index];
1351
+ if (argument === "--help" || argument === "-h") {
1352
+ process.stdout.write(`${DEVICE_PROOF_HELP}\n`);
1353
+ return undefined;
1354
+ }
1355
+ if (argument === "--json") {
1356
+ json = true;
1357
+ continue;
1358
+ }
1359
+ if (argument === "--require" || argument === "--forbid-containing") {
1360
+ const value = argumentValue(args, index, argument);
1361
+ if (argument === "--require")
1362
+ requiredSources.push(value);
1363
+ else
1364
+ forbiddenSourceFragments.push(value);
1365
+ index += 1;
1366
+ continue;
1367
+ }
1368
+ if (argument === "--apk" ||
1369
+ argument === "--bindings" ||
1370
+ argument === "--bundle" ||
1371
+ argument === "--cwd" ||
1372
+ argument === "--instrumentation-apk" ||
1373
+ argument === "--instrumentation-class" ||
1374
+ argument === "--instrumentation-results" ||
1375
+ argument === "--instrumentation-test" ||
1376
+ argument === "--not-before" ||
1377
+ argument === "--output" ||
1378
+ argument === "--serial" ||
1379
+ argument === "--source-map") {
1380
+ if (singles.has(argument)) {
1381
+ throw new TypeError(`device-proof create-android option ${argument} is duplicated.`);
1382
+ }
1383
+ singles.add(argument);
1384
+ const value = argumentValue(args, index, argument);
1385
+ if (argument === "--apk")
1386
+ applicationApkPath = value;
1387
+ if (argument === "--bindings")
1388
+ generatedBindingsPath = value;
1389
+ if (argument === "--bundle")
1390
+ applicationBundlePath = value;
1391
+ if (argument === "--cwd")
1392
+ cwd = value;
1393
+ if (argument === "--instrumentation-apk") {
1394
+ instrumentationApkPath = value;
1395
+ }
1396
+ if (argument === "--instrumentation-class") {
1397
+ instrumentationClass = value;
1398
+ }
1399
+ if (argument === "--instrumentation-results") {
1400
+ instrumentationResultsDirectory = value;
1401
+ }
1402
+ if (argument === "--instrumentation-test") {
1403
+ instrumentationTest = value;
1404
+ }
1405
+ if (argument === "--not-before")
1406
+ notBefore = value;
1407
+ if (argument === "--output")
1408
+ outputPath = value;
1409
+ if (argument === "--serial")
1410
+ serial = value;
1411
+ if (argument === "--source-map")
1412
+ sourceMapPath = value;
1413
+ index += 1;
1414
+ continue;
1415
+ }
1416
+ throw new TypeError(`Unknown device-proof create-android option ${String(argument)}.`);
1417
+ }
1418
+ const missing = [
1419
+ ...(serial === undefined ? ["--serial"] : []),
1420
+ ...(notBefore === undefined ? ["--not-before"] : []),
1421
+ ...(applicationBundlePath === undefined ? ["--bundle"] : []),
1422
+ ...(sourceMapPath === undefined ? ["--source-map"] : []),
1423
+ ...(applicationApkPath === undefined ? ["--apk"] : []),
1424
+ ...(instrumentationApkPath === undefined
1425
+ ? ["--instrumentation-apk"]
1426
+ : []),
1427
+ ...(generatedBindingsPath === undefined ? ["--bindings"] : []),
1428
+ ...(instrumentationResultsDirectory === undefined
1429
+ ? ["--instrumentation-results"]
1430
+ : []),
1431
+ ...(instrumentationClass === undefined
1432
+ ? ["--instrumentation-class"]
1433
+ : []),
1434
+ ...(instrumentationTest === undefined ? ["--instrumentation-test"] : []),
1435
+ ...(requiredSources.length === 0 ? ["--require"] : []),
1436
+ ...(outputPath === undefined ? ["--output"] : []),
1437
+ ];
1438
+ if (missing.length > 0) {
1439
+ throw new TypeError(`device-proof create-android requires ${missing.join(", ")}.`);
1440
+ }
1441
+ return {
1442
+ operation,
1443
+ applicationApkPath: applicationApkPath,
1444
+ applicationBundlePath: applicationBundlePath,
1445
+ forbiddenSourceFragments: Object.freeze(forbiddenSourceFragments),
1446
+ generatedBindingsPath: generatedBindingsPath,
1447
+ instrumentationApkPath: instrumentationApkPath,
1448
+ instrumentationClass: instrumentationClass,
1449
+ instrumentationResultsDirectory: instrumentationResultsDirectory,
1450
+ instrumentationTest: instrumentationTest,
1451
+ json,
1452
+ notBefore: notBefore,
1453
+ outputPath: outputPath,
1454
+ requiredSources: Object.freeze(requiredSources),
1455
+ serial: serial,
1456
+ sourceMapPath: sourceMapPath,
1457
+ ...(cwd === undefined ? {} : { cwd }),
1458
+ };
1459
+ }
1460
+ if (operation === "profile") {
1461
+ const proofPath = args[1];
1462
+ if (proofPath === undefined ||
1463
+ proofPath.startsWith("-") ||
1464
+ proofPath.length === 0) {
1465
+ throw new TypeError("device-proof profile requires a receipt path.");
1466
+ }
1467
+ let cwd;
1468
+ let json = false;
1469
+ for (let index = 2; index < args.length; index += 1) {
1470
+ const argument = args[index];
1471
+ if (argument === "--help" || argument === "-h") {
1472
+ process.stdout.write(`${DEVICE_PROOF_HELP}\n`);
1473
+ return undefined;
1474
+ }
1475
+ if (argument === "--json") {
1476
+ json = true;
1477
+ continue;
1478
+ }
1479
+ if (argument === "--cwd") {
1480
+ cwd = argumentValue(args, index, argument);
1481
+ index += 1;
1482
+ continue;
1483
+ }
1484
+ throw new TypeError(`Unknown device-proof profile option ${String(argument)}.`);
1485
+ }
1486
+ return {
1487
+ operation,
1488
+ proofPath,
1489
+ json,
1490
+ ...(cwd === undefined ? {} : { cwd }),
1491
+ };
1492
+ }
1493
+ if (operation === "sign") {
1494
+ const proofPath = args[1];
1495
+ if (proofPath === undefined ||
1496
+ proofPath.startsWith("-") ||
1497
+ proofPath.length === 0) {
1498
+ throw new TypeError("device-proof sign requires a receipt path.");
1499
+ }
1500
+ let cwd;
1501
+ let json = false;
1502
+ let keyId;
1503
+ let outputPath;
1504
+ let privateKeyPath;
1505
+ let projectName;
1506
+ for (let index = 2; index < args.length; index += 1) {
1507
+ const argument = args[index];
1508
+ if (argument === "--help" || argument === "-h") {
1509
+ process.stdout.write(`${DEVICE_PROOF_HELP}\n`);
1510
+ return undefined;
1511
+ }
1512
+ if (argument === "--json") {
1513
+ json = true;
1514
+ continue;
1515
+ }
1516
+ if (argument === "--cwd" ||
1517
+ argument === "--key" ||
1518
+ argument === "--key-id" ||
1519
+ argument === "--output" ||
1520
+ argument === "--project") {
1521
+ const value = argumentValue(args, index, argument);
1522
+ if (argument === "--cwd")
1523
+ cwd = value;
1524
+ if (argument === "--key")
1525
+ privateKeyPath = value;
1526
+ if (argument === "--key-id")
1527
+ keyId = value;
1528
+ if (argument === "--output")
1529
+ outputPath = value;
1530
+ if (argument === "--project")
1531
+ projectName = value;
1532
+ index += 1;
1533
+ continue;
1534
+ }
1535
+ throw new TypeError(`Unknown device-proof sign option ${String(argument)}.`);
1536
+ }
1537
+ const missing = [
1538
+ ...(privateKeyPath === undefined ? ["--key"] : []),
1539
+ ...(keyId === undefined ? ["--key-id"] : []),
1540
+ ...(projectName === undefined ? ["--project"] : []),
1541
+ ];
1542
+ if (missing.length > 0) {
1543
+ throw new TypeError(`device-proof sign requires ${missing.join(", ")}.`);
1544
+ }
1545
+ return {
1546
+ operation,
1547
+ proofPath,
1548
+ privateKeyPath: privateKeyPath,
1549
+ keyId: keyId,
1550
+ projectName: projectName,
1551
+ json,
1552
+ ...(cwd === undefined ? {} : { cwd }),
1553
+ ...(outputPath === undefined ? {} : { outputPath }),
1554
+ };
1555
+ }
1556
+ if (operation === "signing-request") {
1557
+ const proofPath = args[1];
1558
+ if (proofPath === undefined ||
1559
+ proofPath.startsWith("-") ||
1560
+ proofPath.length === 0) {
1561
+ throw new TypeError("device-proof signing-request requires a receipt path.");
1562
+ }
1563
+ let cwd;
1564
+ let json = false;
1565
+ let keyId;
1566
+ let outputPath;
1567
+ let projectName;
1568
+ for (let index = 2; index < args.length; index += 1) {
1569
+ const argument = args[index];
1570
+ if (argument === "--help" || argument === "-h") {
1571
+ process.stdout.write(`${DEVICE_PROOF_HELP}\n`);
1572
+ return undefined;
1573
+ }
1574
+ if (argument === "--json") {
1575
+ json = true;
1576
+ continue;
1577
+ }
1578
+ if (argument === "--cwd" ||
1579
+ argument === "--key-id" ||
1580
+ argument === "--output" ||
1581
+ argument === "--project") {
1582
+ const value = argumentValue(args, index, argument);
1583
+ if (argument === "--cwd")
1584
+ cwd = value;
1585
+ if (argument === "--key-id")
1586
+ keyId = value;
1587
+ if (argument === "--output")
1588
+ outputPath = value;
1589
+ if (argument === "--project")
1590
+ projectName = value;
1591
+ index += 1;
1592
+ continue;
1593
+ }
1594
+ throw new TypeError(`Unknown device-proof signing-request option ${String(argument)}.`);
1595
+ }
1596
+ const missing = [
1597
+ ...(keyId === undefined ? ["--key-id"] : []),
1598
+ ...(projectName === undefined ? ["--project"] : []),
1599
+ ];
1600
+ if (missing.length > 0) {
1601
+ throw new TypeError(`device-proof signing-request requires ${missing.join(", ")}.`);
1602
+ }
1603
+ return {
1604
+ operation,
1605
+ proofPath,
1606
+ keyId: keyId,
1607
+ projectName: projectName,
1608
+ json,
1609
+ ...(cwd === undefined ? {} : { cwd }),
1610
+ ...(outputPath === undefined ? {} : { outputPath }),
1611
+ };
1612
+ }
1613
+ if (operation === "assemble-signature") {
1614
+ const requestPath = args[1];
1615
+ if (requestPath === undefined ||
1616
+ requestPath.startsWith("-") ||
1617
+ requestPath.length === 0) {
1618
+ throw new TypeError("device-proof assemble-signature requires a signing request path.");
1619
+ }
1620
+ let cwd;
1621
+ let detachedSignaturePath;
1622
+ let json = false;
1623
+ let outputPath;
1624
+ let publicKeyPath;
1625
+ for (let index = 2; index < args.length; index += 1) {
1626
+ const argument = args[index];
1627
+ if (argument === "--help" || argument === "-h") {
1628
+ process.stdout.write(`${DEVICE_PROOF_HELP}\n`);
1629
+ return undefined;
1630
+ }
1631
+ if (argument === "--json") {
1632
+ json = true;
1633
+ continue;
1634
+ }
1635
+ if (argument === "--cwd" ||
1636
+ argument === "--output" ||
1637
+ argument === "--public-key" ||
1638
+ argument === "--signature") {
1639
+ const value = argumentValue(args, index, argument);
1640
+ if (argument === "--cwd")
1641
+ cwd = value;
1642
+ if (argument === "--output")
1643
+ outputPath = value;
1644
+ if (argument === "--public-key")
1645
+ publicKeyPath = value;
1646
+ if (argument === "--signature")
1647
+ detachedSignaturePath = value;
1648
+ index += 1;
1649
+ continue;
1650
+ }
1651
+ throw new TypeError(`Unknown device-proof assemble-signature option ${String(argument)}.`);
1652
+ }
1653
+ const missing = [
1654
+ ...(detachedSignaturePath === undefined ? ["--signature"] : []),
1655
+ ...(publicKeyPath === undefined ? ["--public-key"] : []),
1656
+ ];
1657
+ if (missing.length > 0) {
1658
+ throw new TypeError(`device-proof assemble-signature requires ${missing.join(", ")}.`);
1659
+ }
1660
+ return {
1661
+ operation,
1662
+ requestPath,
1663
+ detachedSignaturePath: detachedSignaturePath,
1664
+ publicKeyPath: publicKeyPath,
1665
+ json,
1666
+ ...(cwd === undefined ? {} : { cwd }),
1667
+ ...(outputPath === undefined ? {} : { outputPath }),
1668
+ };
1669
+ }
1670
+ if (operation !== "ingestion" && operation !== "verify-signature") {
1671
+ throw new TypeError("device-proof requires create-android, profile, sign, signing-request, assemble-signature, ingestion, or verify-signature.");
1672
+ }
1673
+ const signaturePath = args[1];
1674
+ if (signaturePath === undefined ||
1675
+ signaturePath.startsWith("-") ||
1676
+ signaturePath.length === 0) {
1677
+ throw new TypeError(`device-proof ${operation} requires a signature path.`);
1678
+ }
1679
+ let cwd;
1680
+ let expectedApplicationArtifactSha256;
1681
+ let expectedKeyId;
1682
+ let expectedNativeCompatibilityFingerprint;
1683
+ let expectedProofSha256;
1684
+ let expectedProfileFingerprint;
1685
+ let expectedSourceRevision;
1686
+ let json = false;
1687
+ let maximumMeasuredAt;
1688
+ let minimumTrustPolicySequence;
1689
+ let minimumMeasuredAt;
1690
+ let proofPath;
1691
+ let projectName;
1692
+ let publicKeyPath;
1693
+ let trustPolicyPath;
1694
+ for (let index = 2; index < args.length; index += 1) {
1695
+ const argument = args[index];
1696
+ if (argument === "--help" || argument === "-h") {
1697
+ process.stdout.write(`${DEVICE_PROOF_HELP}\n`);
1698
+ return undefined;
1699
+ }
1700
+ if (argument === "--json") {
1701
+ json = true;
1702
+ continue;
1703
+ }
1704
+ if (argument === "--artifact-sha256" ||
1705
+ argument === "--cwd" ||
1706
+ argument === "--key-id" ||
1707
+ argument === "--maximum-measured-at" ||
1708
+ argument === "--minimum-measured-at" ||
1709
+ argument === "--minimum-policy-sequence" ||
1710
+ argument === "--native-fingerprint" ||
1711
+ argument === "--proof" ||
1712
+ argument === "--proof-sha256" ||
1713
+ argument === "--profile-fingerprint" ||
1714
+ argument === "--project" ||
1715
+ argument === "--public-key" ||
1716
+ argument === "--revision" ||
1717
+ argument === "--trust-policy") {
1718
+ const value = argumentValue(args, index, argument);
1719
+ if (argument === "--artifact-sha256") {
1720
+ expectedApplicationArtifactSha256 = value;
1721
+ }
1722
+ if (argument === "--cwd")
1723
+ cwd = value;
1724
+ if (argument === "--key-id")
1725
+ expectedKeyId = value;
1726
+ if (argument === "--maximum-measured-at")
1727
+ maximumMeasuredAt = value;
1728
+ if (argument === "--minimum-measured-at")
1729
+ minimumMeasuredAt = value;
1730
+ if (argument === "--minimum-policy-sequence") {
1731
+ const parsed = Number(value);
1732
+ if (!Number.isSafeInteger(parsed) || parsed <= 0) {
1733
+ throw new TypeError(`device-proof ${operation} --minimum-policy-sequence must be a positive safe integer.`);
1734
+ }
1735
+ minimumTrustPolicySequence = parsed;
1736
+ }
1737
+ if (argument === "--native-fingerprint") {
1738
+ expectedNativeCompatibilityFingerprint = value;
1739
+ }
1740
+ if (argument === "--proof")
1741
+ proofPath = value;
1742
+ if (argument === "--proof-sha256")
1743
+ expectedProofSha256 = value;
1744
+ if (argument === "--profile-fingerprint") {
1745
+ expectedProfileFingerprint = value;
1746
+ }
1747
+ if (argument === "--project")
1748
+ projectName = value;
1749
+ if (argument === "--public-key")
1750
+ publicKeyPath = value;
1751
+ if (argument === "--revision")
1752
+ expectedSourceRevision = value;
1753
+ if (argument === "--trust-policy")
1754
+ trustPolicyPath = value;
1755
+ index += 1;
1756
+ continue;
1757
+ }
1758
+ throw new TypeError(`Unknown device-proof ${operation} option ${String(argument)}.`);
1759
+ }
1760
+ const pinnedTrustSupplied = publicKeyPath !== undefined ||
1761
+ expectedKeyId !== undefined ||
1762
+ projectName !== undefined;
1763
+ if (trustPolicyPath !== undefined && pinnedTrustSupplied) {
1764
+ throw new TypeError(`device-proof ${operation} --trust-policy cannot be combined with pinned-key options.`);
1765
+ }
1766
+ if (trustPolicyPath === undefined &&
1767
+ minimumTrustPolicySequence !== undefined) {
1768
+ throw new TypeError(`device-proof ${operation} --minimum-policy-sequence requires --trust-policy.`);
1769
+ }
1770
+ const missing = [...(proofPath === undefined ? ["--proof"] : [])];
1771
+ if (trustPolicyPath === undefined) {
1772
+ missing.push(...(publicKeyPath === undefined ? ["--public-key"] : []), ...(expectedKeyId === undefined ? ["--key-id"] : []), ...(projectName === undefined ? ["--project"] : []));
1773
+ }
1774
+ if (missing.length > 0) {
1775
+ throw new TypeError(`device-proof ${operation} requires ${missing.join(", ")}.`);
1776
+ }
1777
+ const base = {
1778
+ operation,
1779
+ signaturePath,
1780
+ proofPath: proofPath,
1781
+ json,
1782
+ ...(cwd === undefined ? {} : { cwd }),
1783
+ ...(expectedProofSha256 === undefined ? {} : { expectedProofSha256 }),
1784
+ ...(expectedProfileFingerprint === undefined
1785
+ ? {}
1786
+ : { expectedProfileFingerprint }),
1787
+ ...(expectedSourceRevision === undefined ? {} : { expectedSourceRevision }),
1788
+ ...(expectedNativeCompatibilityFingerprint === undefined
1789
+ ? {}
1790
+ : { expectedNativeCompatibilityFingerprint }),
1791
+ ...(expectedApplicationArtifactSha256 === undefined
1792
+ ? {}
1793
+ : { expectedApplicationArtifactSha256 }),
1794
+ ...(minimumMeasuredAt === undefined ? {} : { minimumMeasuredAt }),
1795
+ ...(maximumMeasuredAt === undefined ? {} : { maximumMeasuredAt }),
1796
+ };
1797
+ return trustPolicyPath === undefined
1798
+ ? {
1799
+ ...base,
1800
+ publicKeyPath: publicKeyPath,
1801
+ expectedKeyId: expectedKeyId,
1802
+ projectName: projectName,
1803
+ }
1804
+ : {
1805
+ ...base,
1806
+ trustPolicyPath,
1807
+ ...(minimumTrustPolicySequence === undefined
1808
+ ? {}
1809
+ : { minimumTrustPolicySequence }),
1810
+ };
1811
+ }
1812
+ function parseAdapterArguments(args) {
1813
+ const operation = args[0];
1814
+ if (operation === "--help" || operation === "-h") {
1815
+ process.stdout.write(`${ADAPTER_HELP}\n`);
1816
+ return undefined;
1817
+ }
1818
+ if (operation !== "create") {
1819
+ throw new TypeError("adapter requires the create operation.");
1820
+ }
1821
+ const moduleName = args[1];
1822
+ if (moduleName === undefined ||
1823
+ moduleName.startsWith("-") ||
1824
+ moduleName.length === 0) {
1825
+ throw new TypeError("adapter create requires a TurboModule name.");
1826
+ }
1827
+ let bindingsPath;
1828
+ let cwd;
1829
+ let dryRun = false;
1830
+ let json = false;
1831
+ let outputPath;
1832
+ let packageName;
1833
+ let platform = "all";
1834
+ for (let index = 2; index < args.length; index += 1) {
1835
+ const argument = args[index];
1836
+ if (argument === "--help" || argument === "-h") {
1837
+ process.stdout.write(`${ADAPTER_HELP}\n`);
1838
+ return undefined;
1839
+ }
1840
+ if (argument === "--dry-run") {
1841
+ dryRun = true;
1842
+ continue;
1843
+ }
1844
+ if (argument === "--json") {
1845
+ json = true;
1846
+ continue;
1847
+ }
1848
+ if (argument === "--bindings" ||
1849
+ argument === "--cwd" ||
1850
+ argument === "--library" ||
1851
+ argument === "--output" ||
1852
+ argument === "--platform") {
1853
+ const value = argumentValue(args, index, argument);
1854
+ index += 1;
1855
+ if (argument === "--bindings")
1856
+ bindingsPath = value;
1857
+ if (argument === "--cwd")
1858
+ cwd = value;
1859
+ if (argument === "--library")
1860
+ packageName = value;
1861
+ if (argument === "--output")
1862
+ outputPath = value;
1863
+ if (argument === "--platform") {
1864
+ if (value !== "all" && value !== "ios" && value !== "android") {
1865
+ throw new TypeError(`Unsupported platform ${value}.`);
1866
+ }
1867
+ platform = value;
1868
+ }
1869
+ continue;
1870
+ }
1871
+ throw new TypeError(`Unknown adapter option ${String(argument)}.`);
1872
+ }
1873
+ if (packageName === undefined) {
1874
+ throw new TypeError("adapter create requires --library PACKAGE.");
1875
+ }
1876
+ if (json && !dryRun) {
1877
+ throw new TypeError("adapter create --json requires --dry-run.");
1878
+ }
1879
+ return {
1880
+ dryRun,
1881
+ json,
1882
+ moduleName,
1883
+ packageName,
1884
+ platform,
1885
+ ...(bindingsPath === undefined ? {} : { bindingsPath }),
1886
+ ...(cwd === undefined ? {} : { cwd }),
1887
+ ...(outputPath === undefined ? {} : { outputPath }),
1888
+ };
1889
+ }
1890
+ function parseAddArguments(args) {
1891
+ const capability = args[0];
1892
+ if (capability === "--help" || capability === "-h") {
1893
+ process.stdout.write(`${ADD_HELP}\n`);
1894
+ return undefined;
1895
+ }
1896
+ if (capability !== "navigation") {
1897
+ throw new TypeError("add requires a supported capability; currently: navigation.");
1898
+ }
1899
+ let cwd;
1900
+ let dryRun = false;
1901
+ let json = false;
1902
+ for (let index = 1; index < args.length; index += 1) {
1903
+ const argument = args[index];
1904
+ if (argument === "--help" || argument === "-h") {
1905
+ process.stdout.write(`${ADD_HELP}\n`);
1906
+ return undefined;
1907
+ }
1908
+ if (argument === "--cwd") {
1909
+ cwd = argumentValue(args, index, argument);
1910
+ index += 1;
1911
+ continue;
1912
+ }
1913
+ if (argument === "--dry-run") {
1914
+ dryRun = true;
1915
+ continue;
1916
+ }
1917
+ if (argument === "--json") {
1918
+ json = true;
1919
+ continue;
1920
+ }
1921
+ throw new TypeError(`Unknown add option ${String(argument)}.`);
1922
+ }
1923
+ if (json && !dryRun) {
1924
+ throw new TypeError("add --json requires --dry-run.");
1925
+ }
1926
+ return {
1927
+ capability,
1928
+ dryRun,
1929
+ json,
1930
+ ...(cwd === undefined ? {} : { cwd }),
1931
+ };
1932
+ }
1933
+ function parseRunArguments(args) {
1934
+ const platform = args[0];
1935
+ if (platform === "--help" || platform === "-h") {
1936
+ process.stdout.write(`${RUN_HELP}\n`);
1937
+ return undefined;
1938
+ }
1939
+ if (platform !== "ios" && platform !== "android") {
1940
+ throw new TypeError("run requires an ios or android platform.");
1941
+ }
1942
+ let cwd;
1943
+ let dryRun = false;
1944
+ let json = false;
1945
+ const forwardedArgs = [];
1946
+ for (let index = 1; index < args.length; index += 1) {
1947
+ const argument = args[index];
1948
+ if (argument === "--") {
1949
+ forwardedArgs.push(...args.slice(index + 1));
1950
+ break;
1951
+ }
1952
+ if (argument === "--cwd") {
1953
+ cwd = argumentValue(args, index, argument);
1954
+ index += 1;
1955
+ continue;
1956
+ }
1957
+ if (argument === "--dry-run") {
1958
+ dryRun = true;
1959
+ continue;
1960
+ }
1961
+ if (argument === "--json") {
1962
+ json = true;
1963
+ continue;
1964
+ }
1965
+ if (argument === "--help" || argument === "-h") {
1966
+ process.stdout.write(`${RUN_HELP}\n`);
1967
+ return undefined;
1968
+ }
1969
+ if (argument !== undefined)
1970
+ forwardedArgs.push(argument);
1971
+ }
1972
+ if (json && !dryRun) {
1973
+ throw new TypeError("run --json requires --dry-run so build logs cannot corrupt JSON output.");
1974
+ }
1975
+ return {
1976
+ dryRun,
1977
+ forwardedArgs,
1978
+ json,
1979
+ platform,
1980
+ ...(cwd === undefined ? {} : { cwd }),
1981
+ };
1982
+ }
1983
+ function parseLogsArguments(args) {
1984
+ const platform = args[0];
1985
+ if (platform === "--help" || platform === "-h") {
1986
+ process.stdout.write(`${LOGS_HELP}\n`);
1987
+ return undefined;
1988
+ }
1989
+ if (platform !== "android" && platform !== "ios") {
1990
+ throw new TypeError("logs requires an ios or android platform.");
1991
+ }
1992
+ const applicationIdentifier = args[1];
1993
+ if (applicationIdentifier === "--help" || applicationIdentifier === "-h") {
1994
+ process.stdout.write(`${LOGS_HELP}\n`);
1995
+ return undefined;
1996
+ }
1997
+ if (applicationIdentifier === undefined ||
1998
+ applicationIdentifier.startsWith("-")) {
1999
+ throw new TypeError(platform === "android"
2000
+ ? "logs android requires an application package."
2001
+ : "logs ios requires an application bundle identifier.");
2002
+ }
2003
+ if (platform === "ios") {
2004
+ let device;
2005
+ let dryRun = false;
2006
+ let json = false;
2007
+ let restart = false;
2008
+ for (let index = 2; index < args.length; index += 1) {
2009
+ const argument = args[index];
2010
+ if (argument === "--device") {
2011
+ device = argumentValue(args, index, argument);
2012
+ index += 1;
2013
+ continue;
2014
+ }
2015
+ if (argument === "--restart") {
2016
+ restart = true;
2017
+ continue;
2018
+ }
2019
+ if (argument === "--dry-run") {
2020
+ dryRun = true;
2021
+ continue;
2022
+ }
2023
+ if (argument === "--json") {
2024
+ json = true;
2025
+ continue;
2026
+ }
2027
+ if (argument === "--help" || argument === "-h") {
2028
+ process.stdout.write(`${LOGS_HELP}\n`);
2029
+ return undefined;
2030
+ }
2031
+ throw new TypeError(`Unknown logs option ${String(argument)}.`);
2032
+ }
2033
+ if (device === undefined) {
2034
+ throw new TypeError("logs ios requires --device ID.");
2035
+ }
2036
+ if (!restart) {
2037
+ throw new TypeError("logs ios requires --restart to acknowledge replacement and termination of the application process.");
2038
+ }
2039
+ if (json && !dryRun) {
2040
+ throw new TypeError("logs --json requires --dry-run so live device output cannot corrupt JSON.");
2041
+ }
2042
+ return {
2043
+ platform,
2044
+ bundleIdentifier: applicationIdentifier,
2045
+ device,
2046
+ dryRun,
2047
+ json,
2048
+ restart: true,
2049
+ };
2050
+ }
2051
+ const packageName = applicationIdentifier;
2052
+ let dryRun = false;
2053
+ let json = false;
2054
+ let serial;
2055
+ let since;
2056
+ for (let index = 2; index < args.length; index += 1) {
2057
+ const argument = args[index];
2058
+ if (argument === "--dry-run") {
2059
+ dryRun = true;
2060
+ continue;
2061
+ }
2062
+ if (argument === "--json") {
2063
+ json = true;
2064
+ continue;
2065
+ }
2066
+ if (argument === "--help" || argument === "-h") {
2067
+ process.stdout.write(`${LOGS_HELP}\n`);
2068
+ return undefined;
2069
+ }
2070
+ if (argument === "--serial" || argument === "--since") {
2071
+ const value = argumentValue(args, index, argument);
2072
+ index += 1;
2073
+ if (argument === "--serial")
2074
+ serial = value;
2075
+ else
2076
+ since = value;
2077
+ continue;
2078
+ }
2079
+ throw new TypeError(`Unknown logs option ${String(argument)}.`);
2080
+ }
2081
+ if (json && !dryRun) {
2082
+ throw new TypeError("logs --json requires --dry-run so live device output cannot corrupt JSON.");
2083
+ }
2084
+ return {
2085
+ platform,
2086
+ dryRun,
2087
+ json,
2088
+ packageName,
2089
+ ...(serial === undefined ? {} : { serial }),
2090
+ ...(since === undefined ? {} : { since }),
2091
+ };
2092
+ }
2093
+ function parseDeviceArguments(args) {
2094
+ const operation = args[0];
2095
+ if (operation === "--help" || operation === "-h") {
2096
+ process.stdout.write(`${DEVICE_HELP}\n`);
2097
+ return undefined;
2098
+ }
2099
+ if (operation !== "status-ios" && operation !== "stop-ios") {
2100
+ throw new TypeError("device requires status-ios or stop-ios.");
2101
+ }
2102
+ const bundleIdentifier = args[1];
2103
+ if (bundleIdentifier === "--help" || bundleIdentifier === "-h") {
2104
+ process.stdout.write(`${DEVICE_HELP}\n`);
2105
+ return undefined;
2106
+ }
2107
+ if (bundleIdentifier === undefined || bundleIdentifier.startsWith("-")) {
2108
+ throw new TypeError(`device ${operation} requires an iOS bundle identifier.`);
2109
+ }
2110
+ let device;
2111
+ let json = false;
2112
+ for (let index = 2; index < args.length; index += 1) {
2113
+ const argument = args[index];
2114
+ if (argument === "--device") {
2115
+ if (device !== undefined) {
2116
+ throw new TypeError(`device ${operation} option --device is duplicated.`);
2117
+ }
2118
+ device = argumentValue(args, index, argument);
2119
+ index += 1;
2120
+ continue;
2121
+ }
2122
+ if (argument === "--json") {
2123
+ if (json) {
2124
+ throw new TypeError(`device ${operation} option --json is duplicated.`);
2125
+ }
2126
+ json = true;
2127
+ continue;
2128
+ }
2129
+ if (argument === "--help" || argument === "-h") {
2130
+ process.stdout.write(`${DEVICE_HELP}\n`);
2131
+ return undefined;
2132
+ }
2133
+ throw new TypeError(`Unknown device ${operation} option ${String(argument)}.`);
2134
+ }
2135
+ if (device === undefined) {
2136
+ throw new TypeError(`device ${operation} requires --device ID.`);
2137
+ }
2138
+ return { operation, bundleIdentifier, device, json };
2139
+ }
2140
+ function parseOpenArguments(args) {
2141
+ const platform = args[0];
2142
+ if (platform === "--help" || platform === "-h") {
2143
+ process.stdout.write(`${OPEN_HELP}\n`);
2144
+ return undefined;
2145
+ }
2146
+ if (platform !== "android" && platform !== "ios") {
2147
+ throw new TypeError("open requires an ios or android platform.");
2148
+ }
2149
+ const applicationIdentifier = args[1];
2150
+ const url = args[2];
2151
+ if (applicationIdentifier === "--help" ||
2152
+ applicationIdentifier === "-h" ||
2153
+ url === "--help" ||
2154
+ url === "-h") {
2155
+ process.stdout.write(`${OPEN_HELP}\n`);
2156
+ return undefined;
2157
+ }
2158
+ if (applicationIdentifier === undefined ||
2159
+ applicationIdentifier.startsWith("-")) {
2160
+ throw new TypeError(platform === "android"
2161
+ ? "open android requires an application package."
2162
+ : "open ios requires an application bundle identifier.");
2163
+ }
2164
+ if (url === undefined || url.startsWith("-")) {
2165
+ throw new TypeError("open requires an absolute deep-link URL.");
2166
+ }
2167
+ let cold = false;
2168
+ let device;
2169
+ let dryRun = false;
2170
+ let json = false;
2171
+ let serial;
2172
+ for (let index = 3; index < args.length; index += 1) {
2173
+ const argument = args[index];
2174
+ if (argument === "--cold") {
2175
+ cold = true;
2176
+ continue;
2177
+ }
2178
+ if (argument === "--dry-run") {
2179
+ dryRun = true;
2180
+ continue;
2181
+ }
2182
+ if (argument === "--json") {
2183
+ json = true;
2184
+ continue;
2185
+ }
2186
+ if (argument === "--help" || argument === "-h") {
2187
+ process.stdout.write(`${OPEN_HELP}\n`);
2188
+ return undefined;
2189
+ }
2190
+ if (argument === "--serial" && platform === "android") {
2191
+ serial = argumentValue(args, index, argument);
2192
+ index += 1;
2193
+ continue;
2194
+ }
2195
+ if (argument === "--device" && platform === "ios") {
2196
+ device = argumentValue(args, index, argument);
2197
+ index += 1;
2198
+ continue;
2199
+ }
2200
+ throw new TypeError(`Unknown open option ${String(argument)}.`);
2201
+ }
2202
+ if (platform === "ios") {
2203
+ if (device === undefined) {
2204
+ throw new TypeError("open ios requires --device ID.");
2205
+ }
2206
+ return {
2207
+ platform,
2208
+ bundleIdentifier: applicationIdentifier,
2209
+ cold,
2210
+ device,
2211
+ dryRun,
2212
+ json,
2213
+ url,
2214
+ };
2215
+ }
2216
+ return {
2217
+ platform,
2218
+ cold,
2219
+ dryRun,
2220
+ json,
2221
+ packageName: applicationIdentifier,
2222
+ url,
2223
+ ...(serial === undefined ? {} : { serial }),
2224
+ };
2225
+ }
2226
+ function parseBuildArguments(args) {
2227
+ const platform = args[0];
2228
+ if (platform === "--help" || platform === "-h") {
2229
+ process.stdout.write(`${BUILD_HELP}\n`);
2230
+ return undefined;
2231
+ }
2232
+ if (platform !== "ios" && platform !== "android") {
2233
+ throw new TypeError("build requires an ios or android platform.");
2234
+ }
2235
+ let cwd;
2236
+ let dryRun = false;
2237
+ let json = false;
2238
+ const forwardedArgs = [];
2239
+ for (let index = 1; index < args.length; index += 1) {
2240
+ const argument = args[index];
2241
+ if (argument === "--") {
2242
+ forwardedArgs.push(...args.slice(index + 1));
2243
+ break;
2244
+ }
2245
+ if (argument === "--cwd") {
2246
+ cwd = argumentValue(args, index, argument);
2247
+ index += 1;
2248
+ continue;
2249
+ }
2250
+ if (argument === "--dry-run") {
2251
+ dryRun = true;
2252
+ continue;
2253
+ }
2254
+ if (argument === "--json") {
2255
+ json = true;
2256
+ continue;
2257
+ }
2258
+ if (argument === "--help" || argument === "-h") {
2259
+ process.stdout.write(`${BUILD_HELP}\n`);
2260
+ return undefined;
2261
+ }
2262
+ if (argument !== undefined)
2263
+ forwardedArgs.push(argument);
2264
+ }
2265
+ if (json && !dryRun) {
2266
+ throw new TypeError("build --json requires --dry-run so build logs cannot corrupt JSON output.");
2267
+ }
2268
+ return {
2269
+ dryRun,
2270
+ forwardedArgs,
2271
+ json,
2272
+ platform,
2273
+ ...(cwd === undefined ? {} : { cwd }),
2274
+ };
2275
+ }
2276
+ function parseBundleArguments(args) {
2277
+ const platform = args[0];
2278
+ if (platform === "--help" || platform === "-h") {
2279
+ process.stdout.write(`${BUNDLE_HELP}\n`);
2280
+ return undefined;
2281
+ }
2282
+ if (platform !== "ios" && platform !== "android") {
2283
+ throw new TypeError("bundle requires an ios or android platform.");
2284
+ }
2285
+ let cwd;
2286
+ let dryRun = false;
2287
+ let entryFile;
2288
+ let hermesSource = false;
2289
+ let json = false;
2290
+ let outputDirectory;
2291
+ const forwardedArgs = [];
2292
+ for (let index = 1; index < args.length; index += 1) {
2293
+ const argument = args[index];
2294
+ if (argument === "--") {
2295
+ forwardedArgs.push(...args.slice(index + 1));
2296
+ break;
2297
+ }
2298
+ if (argument === "--cwd") {
2299
+ cwd = argumentValue(args, index, argument);
2300
+ index += 1;
2301
+ continue;
2302
+ }
2303
+ if (argument === "--output") {
2304
+ outputDirectory = argumentValue(args, index, argument);
2305
+ index += 1;
2306
+ continue;
2307
+ }
2308
+ if (argument === "--entry-file") {
2309
+ entryFile = argumentValue(args, index, argument);
2310
+ index += 1;
2311
+ continue;
2312
+ }
2313
+ if (argument === "--dry-run") {
2314
+ dryRun = true;
2315
+ continue;
2316
+ }
2317
+ if (argument === "--json") {
2318
+ json = true;
2319
+ continue;
2320
+ }
2321
+ if (argument === "--hermes-source") {
2322
+ hermesSource = true;
2323
+ continue;
2324
+ }
2325
+ if (argument === "--help" || argument === "-h") {
2326
+ process.stdout.write(`${BUNDLE_HELP}\n`);
2327
+ return undefined;
2328
+ }
2329
+ if (argument !== undefined)
2330
+ forwardedArgs.push(argument);
2331
+ }
2332
+ if (json && !dryRun) {
2333
+ throw new TypeError("bundle --json requires --dry-run so Metro logs cannot corrupt JSON output.");
2334
+ }
2335
+ return {
2336
+ dryRun,
2337
+ forwardedArgs,
2338
+ hermesSource,
2339
+ json,
2340
+ platform,
2341
+ ...(cwd === undefined ? {} : { cwd }),
2342
+ ...(entryFile === undefined ? {} : { entryFile }),
2343
+ ...(outputDirectory === undefined ? {} : { outputDirectory }),
2344
+ };
2345
+ }
2346
+ function parseBundleVerifyArguments(args) {
2347
+ const manifestPath = args[0];
2348
+ if (manifestPath === "--help" || manifestPath === "-h") {
2349
+ process.stdout.write(`${BUNDLE_HELP}\n`);
2350
+ return undefined;
2351
+ }
2352
+ if (manifestPath === undefined || manifestPath.startsWith("-")) {
2353
+ throw new TypeError("bundle verify requires a manifest path.");
2354
+ }
2355
+ let json = false;
2356
+ for (const argument of args.slice(1)) {
2357
+ if (argument === "--json") {
2358
+ json = true;
2359
+ continue;
2360
+ }
2361
+ if (argument === "--help" || argument === "-h") {
2362
+ process.stdout.write(`${BUNDLE_HELP}\n`);
2363
+ return undefined;
2364
+ }
2365
+ throw new TypeError(`Unknown bundle verify option ${argument}.`);
2366
+ }
2367
+ return { json, manifestPath };
2368
+ }
2369
+ function parseBundleSourcesArguments(args) {
2370
+ const sourceMapPath = args[0];
2371
+ if (sourceMapPath === "--help" || sourceMapPath === "-h") {
2372
+ process.stdout.write(`${BUNDLE_HELP}\n`);
2373
+ return undefined;
2374
+ }
2375
+ if (sourceMapPath === undefined || sourceMapPath.startsWith("-")) {
2376
+ throw new TypeError("bundle sources requires a source-map path.");
2377
+ }
2378
+ let cwd;
2379
+ let json = false;
2380
+ const requiredSources = [];
2381
+ const forbiddenSourceFragments = [];
2382
+ for (let index = 1; index < args.length; index += 1) {
2383
+ const argument = args[index];
2384
+ if (argument === "--cwd" ||
2385
+ argument === "--require" ||
2386
+ argument === "--forbid-containing") {
2387
+ const value = argumentValue(args, index, argument);
2388
+ index += 1;
2389
+ if (argument === "--cwd")
2390
+ cwd = value;
2391
+ else if (argument === "--require")
2392
+ requiredSources.push(value);
2393
+ else
2394
+ forbiddenSourceFragments.push(value);
2395
+ continue;
2396
+ }
2397
+ if (argument === "--json") {
2398
+ json = true;
2399
+ continue;
2400
+ }
2401
+ if (argument === "--help" || argument === "-h") {
2402
+ process.stdout.write(`${BUNDLE_HELP}\n`);
2403
+ return undefined;
2404
+ }
2405
+ throw new TypeError(`Unknown bundle sources option ${String(argument)}.`);
2406
+ }
2407
+ return {
2408
+ forbiddenSourceFragments,
2409
+ json,
2410
+ requiredSources,
2411
+ sourceMapPath,
2412
+ ...(cwd === undefined ? {} : { cwd }),
2413
+ };
2414
+ }
2415
+ function parseStartArguments(args) {
2416
+ let cwd;
2417
+ let dryRun = false;
2418
+ let json = false;
2419
+ const forwardedArgs = [];
2420
+ for (let index = 0; index < args.length; index += 1) {
2421
+ const argument = args[index];
2422
+ if (argument === "--") {
2423
+ forwardedArgs.push(...args.slice(index + 1));
2424
+ break;
2425
+ }
2426
+ if (argument === "--cwd") {
2427
+ cwd = argumentValue(args, index, argument);
2428
+ index += 1;
2429
+ continue;
2430
+ }
2431
+ if (argument === "--dry-run") {
2432
+ dryRun = true;
2433
+ continue;
2434
+ }
2435
+ if (argument === "--json") {
2436
+ json = true;
2437
+ continue;
2438
+ }
2439
+ if (argument === "--help" || argument === "-h") {
2440
+ process.stdout.write(`${START_HELP}\n`);
2441
+ return undefined;
2442
+ }
2443
+ if (argument !== undefined)
2444
+ forwardedArgs.push(argument);
2445
+ }
2446
+ if (json && !dryRun) {
2447
+ throw new TypeError("start --json requires --dry-run so Metro logs cannot corrupt JSON output.");
2448
+ }
2449
+ return {
2450
+ dryRun,
2451
+ forwardedArgs,
2452
+ json,
2453
+ ...(cwd === undefined ? {} : { cwd }),
2454
+ };
2455
+ }
2456
+ function parseTestArguments(args) {
2457
+ let cwd;
2458
+ let dryRun = false;
2459
+ let json = false;
2460
+ let runtime = "development";
2461
+ let testNamePattern;
2462
+ let watch = false;
2463
+ const paths = [];
2464
+ for (let index = 0; index < args.length; index += 1) {
2465
+ const argument = args[index];
2466
+ if (argument === "--cwd") {
2467
+ cwd = argumentValue(args, index, argument);
2468
+ index += 1;
2469
+ continue;
2470
+ }
2471
+ if (argument === "--dry-run") {
2472
+ dryRun = true;
2473
+ continue;
2474
+ }
2475
+ if (argument === "--json") {
2476
+ json = true;
2477
+ continue;
2478
+ }
2479
+ if (argument === "--production") {
2480
+ runtime = "production";
2481
+ continue;
2482
+ }
2483
+ if (argument === "--watch") {
2484
+ watch = true;
2485
+ continue;
2486
+ }
2487
+ if (argument === "--test-name-pattern") {
2488
+ testNamePattern = argumentValue(args, index, argument);
2489
+ index += 1;
2490
+ continue;
2491
+ }
2492
+ if (argument === "--help" || argument === "-h") {
2493
+ process.stdout.write(`${TEST_HELP}\n`);
2494
+ return undefined;
2495
+ }
2496
+ if (argument?.startsWith("-") === true) {
2497
+ throw new TypeError(`Unknown test option ${argument}.`);
2498
+ }
2499
+ if (argument !== undefined)
2500
+ paths.push(argument);
2501
+ }
2502
+ if (json && !dryRun) {
2503
+ throw new TypeError("test --json requires --dry-run so test output cannot corrupt JSON output.");
2504
+ }
2505
+ return {
2506
+ dryRun,
2507
+ json,
2508
+ paths,
2509
+ runtime,
2510
+ watch,
2511
+ ...(cwd === undefined ? {} : { cwd }),
2512
+ ...(testNamePattern === undefined ? {} : { testNamePattern }),
2513
+ };
2514
+ }
2515
+ function parseReleaseCreateArguments(args) {
2516
+ let artifactPath;
2517
+ const androidSigningCertificateSha256s = [];
2518
+ let androidUploadCertificateSha256;
2519
+ let bundleManifestPath;
2520
+ let channel;
2521
+ let cwd;
2522
+ let inspectEmbeddedBundle = false;
2523
+ let json = false;
2524
+ let outputPath;
2525
+ let release;
2526
+ let sourceRevision;
2527
+ for (let index = 0; index < args.length; index += 1) {
2528
+ const argument = args[index];
2529
+ if (argument === "--help" || argument === "-h") {
2530
+ process.stdout.write(`${RELEASE_HELP}\n`);
2531
+ return undefined;
2532
+ }
2533
+ if (argument === "--json") {
2534
+ json = true;
2535
+ continue;
2536
+ }
2537
+ if (argument === "--inspect-embedded-bundle") {
2538
+ inspectEmbeddedBundle = true;
2539
+ continue;
2540
+ }
2541
+ if (argument === "--artifact" ||
2542
+ argument === "--android-signing-certificate-sha256" ||
2543
+ argument === "--android-upload-certificate-sha256" ||
2544
+ argument === "--bundle" ||
2545
+ argument === "--channel" ||
2546
+ argument === "--cwd" ||
2547
+ argument === "--output" ||
2548
+ argument === "--release" ||
2549
+ argument === "--revision") {
2550
+ const value = argumentValue(args, index, argument);
2551
+ index += 1;
2552
+ if (argument === "--artifact")
2553
+ artifactPath = value;
2554
+ if (argument === "--android-signing-certificate-sha256") {
2555
+ androidSigningCertificateSha256s.push(value);
2556
+ }
2557
+ if (argument === "--android-upload-certificate-sha256") {
2558
+ androidUploadCertificateSha256 = value;
2559
+ }
2560
+ if (argument === "--bundle")
2561
+ bundleManifestPath = value;
2562
+ if (argument === "--channel")
2563
+ channel = value;
2564
+ if (argument === "--cwd")
2565
+ cwd = value;
2566
+ if (argument === "--output")
2567
+ outputPath = value;
2568
+ if (argument === "--release")
2569
+ release = value;
2570
+ if (argument === "--revision")
2571
+ sourceRevision = value;
2572
+ continue;
2573
+ }
2574
+ throw new TypeError(`Unknown release create option ${String(argument)}.`);
2575
+ }
2576
+ const missing = [
2577
+ ...(artifactPath === undefined ? ["--artifact"] : []),
2578
+ ...(bundleManifestPath === undefined ? ["--bundle"] : []),
2579
+ ...(release === undefined ? ["--release"] : []),
2580
+ ...(channel === undefined ? ["--channel"] : []),
2581
+ ...(sourceRevision === undefined ? ["--revision"] : []),
2582
+ ];
2583
+ if (missing.length > 0) {
2584
+ throw new TypeError(`release create requires ${missing.join(", ")}.`);
2585
+ }
2586
+ if (androidSigningCertificateSha256s.length > 0 &&
2587
+ androidUploadCertificateSha256 !== undefined) {
2588
+ throw new TypeError("release create accepts either APK signing certificates or an AAB upload certificate, not both.");
2589
+ }
2590
+ return {
2591
+ androidSigningCertificateSha256s,
2592
+ artifactPath: artifactPath,
2593
+ bundleManifestPath: bundleManifestPath,
2594
+ channel: channel,
2595
+ inspectEmbeddedBundle,
2596
+ json,
2597
+ release: release,
2598
+ sourceRevision: sourceRevision,
2599
+ ...(androidUploadCertificateSha256 === undefined
2600
+ ? {}
2601
+ : { androidUploadCertificateSha256 }),
2602
+ ...(cwd === undefined ? {} : { cwd }),
2603
+ ...(outputPath === undefined ? {} : { outputPath }),
2604
+ };
2605
+ }
2606
+ function parseReleaseVerifyAndroidSigningArguments(args) {
2607
+ const artifactPath = args[0];
2608
+ if (artifactPath === "--help" || artifactPath === "-h") {
2609
+ process.stdout.write(`${RELEASE_HELP}\n`);
2610
+ return undefined;
2611
+ }
2612
+ if (artifactPath === undefined || artifactPath.startsWith("-")) {
2613
+ throw new TypeError("release verify-android-signing requires an AAB or APK path.");
2614
+ }
2615
+ let cwd;
2616
+ const expectedCertificateSha256s = [];
2617
+ let json = false;
2618
+ for (let index = 1; index < args.length; index += 1) {
2619
+ const argument = args[index];
2620
+ if (argument === "--help" || argument === "-h") {
2621
+ process.stdout.write(`${RELEASE_HELP}\n`);
2622
+ return undefined;
2623
+ }
2624
+ if (argument === "--json") {
2625
+ json = true;
2626
+ continue;
2627
+ }
2628
+ if (argument === "--cwd" || argument === "--expected-certificate-sha256") {
2629
+ const value = argumentValue(args, index, argument);
2630
+ index += 1;
2631
+ if (argument === "--cwd")
2632
+ cwd = value;
2633
+ if (argument === "--expected-certificate-sha256") {
2634
+ expectedCertificateSha256s.push(value);
2635
+ }
2636
+ continue;
2637
+ }
2638
+ throw new TypeError(`Unknown release verify-android-signing option ${String(argument)}.`);
2639
+ }
2640
+ return {
2641
+ artifactPath,
2642
+ expectedCertificateSha256s,
2643
+ json,
2644
+ ...(cwd === undefined ? {} : { cwd }),
2645
+ };
2646
+ }
2647
+ function parseReleaseVerifyArguments(args) {
2648
+ const manifestPath = args[0];
2649
+ if (manifestPath === "--help" || manifestPath === "-h") {
2650
+ process.stdout.write(`${RELEASE_HELP}\n`);
2651
+ return undefined;
2652
+ }
2653
+ if (manifestPath === undefined || manifestPath.startsWith("-")) {
2654
+ throw new TypeError("release verify requires a manifest path.");
2655
+ }
2656
+ let artifactPath;
2657
+ let bundleManifestPath;
2658
+ let cwd;
2659
+ let json = false;
2660
+ for (let index = 1; index < args.length; index += 1) {
2661
+ const argument = args[index];
2662
+ if (argument === "--help" || argument === "-h") {
2663
+ process.stdout.write(`${RELEASE_HELP}\n`);
2664
+ return undefined;
2665
+ }
2666
+ if (argument === "--json") {
2667
+ json = true;
2668
+ continue;
2669
+ }
2670
+ if (argument === "--artifact" ||
2671
+ argument === "--bundle" ||
2672
+ argument === "--cwd") {
2673
+ const value = argumentValue(args, index, argument);
2674
+ index += 1;
2675
+ if (argument === "--artifact")
2676
+ artifactPath = value;
2677
+ if (argument === "--bundle")
2678
+ bundleManifestPath = value;
2679
+ if (argument === "--cwd")
2680
+ cwd = value;
2681
+ continue;
2682
+ }
2683
+ throw new TypeError(`Unknown release verify option ${String(argument)}.`);
2684
+ }
2685
+ const missing = [
2686
+ ...(artifactPath === undefined ? ["--artifact"] : []),
2687
+ ...(bundleManifestPath === undefined ? ["--bundle"] : []),
2688
+ ];
2689
+ if (missing.length > 0) {
2690
+ throw new TypeError(`release verify requires ${missing.join(", ")}.`);
2691
+ }
2692
+ return {
2693
+ artifactPath: artifactPath,
2694
+ bundleManifestPath: bundleManifestPath,
2695
+ json,
2696
+ manifestPath,
2697
+ ...(cwd === undefined ? {} : { cwd }),
2698
+ };
2699
+ }
2700
+ function parseReleaseSignArguments(args) {
2701
+ const manifestPath = args[0];
2702
+ if (manifestPath === "--help" || manifestPath === "-h") {
2703
+ process.stdout.write(`${RELEASE_HELP}\n`);
2704
+ return undefined;
2705
+ }
2706
+ if (manifestPath === undefined || manifestPath.startsWith("-")) {
2707
+ throw new TypeError("release sign requires a manifest path.");
2708
+ }
2709
+ let artifactPath;
2710
+ let bundleManifestPath;
2711
+ let cwd;
2712
+ let json = false;
2713
+ let keyId;
2714
+ let outputPath;
2715
+ let privateKeyPath;
2716
+ for (let index = 1; index < args.length; index += 1) {
2717
+ const argument = args[index];
2718
+ if (argument === "--help" || argument === "-h") {
2719
+ process.stdout.write(`${RELEASE_HELP}\n`);
2720
+ return undefined;
2721
+ }
2722
+ if (argument === "--json") {
2723
+ json = true;
2724
+ continue;
2725
+ }
2726
+ if (argument === "--artifact" ||
2727
+ argument === "--bundle" ||
2728
+ argument === "--cwd" ||
2729
+ argument === "--key" ||
2730
+ argument === "--key-id" ||
2731
+ argument === "--output") {
2732
+ const value = argumentValue(args, index, argument);
2733
+ index += 1;
2734
+ if (argument === "--artifact")
2735
+ artifactPath = value;
2736
+ if (argument === "--bundle")
2737
+ bundleManifestPath = value;
2738
+ if (argument === "--cwd")
2739
+ cwd = value;
2740
+ if (argument === "--key")
2741
+ privateKeyPath = value;
2742
+ if (argument === "--key-id")
2743
+ keyId = value;
2744
+ if (argument === "--output")
2745
+ outputPath = value;
2746
+ continue;
2747
+ }
2748
+ throw new TypeError(`Unknown release sign option ${String(argument)}.`);
2749
+ }
2750
+ const missing = [
2751
+ ...(privateKeyPath === undefined ? ["--key"] : []),
2752
+ ...(keyId === undefined ? ["--key-id"] : []),
2753
+ ];
2754
+ if (missing.length > 0) {
2755
+ throw new TypeError(`release sign requires ${missing.join(", ")}.`);
2756
+ }
2757
+ if ((artifactPath === undefined) !== (bundleManifestPath === undefined)) {
2758
+ throw new TypeError("release sign requires --artifact and --bundle together.");
2759
+ }
2760
+ return {
2761
+ json,
2762
+ keyId: keyId,
2763
+ manifestPath,
2764
+ privateKeyPath: privateKeyPath,
2765
+ ...(artifactPath === undefined ? {} : { artifactPath }),
2766
+ ...(bundleManifestPath === undefined ? {} : { bundleManifestPath }),
2767
+ ...(cwd === undefined ? {} : { cwd }),
2768
+ ...(outputPath === undefined ? {} : { outputPath }),
2769
+ };
2770
+ }
2771
+ function parseReleaseSigningRequestArguments(args) {
2772
+ const manifestPath = args[0];
2773
+ if (manifestPath === "--help" || manifestPath === "-h") {
2774
+ process.stdout.write(`${RELEASE_HELP}\n`);
2775
+ return undefined;
2776
+ }
2777
+ if (manifestPath === undefined || manifestPath.startsWith("-")) {
2778
+ throw new TypeError("release signing-request requires a manifest path.");
2779
+ }
2780
+ let artifactPath;
2781
+ let bundleManifestPath;
2782
+ let cwd;
2783
+ let json = false;
2784
+ let keyId;
2785
+ let outputPath;
2786
+ for (let index = 1; index < args.length; index += 1) {
2787
+ const argument = args[index];
2788
+ if (argument === "--help" || argument === "-h") {
2789
+ process.stdout.write(`${RELEASE_HELP}\n`);
2790
+ return undefined;
2791
+ }
2792
+ if (argument === "--json") {
2793
+ json = true;
2794
+ continue;
2795
+ }
2796
+ if (argument === "--artifact" ||
2797
+ argument === "--bundle" ||
2798
+ argument === "--cwd" ||
2799
+ argument === "--key-id" ||
2800
+ argument === "--output") {
2801
+ const value = argumentValue(args, index, argument);
2802
+ index += 1;
2803
+ if (argument === "--artifact")
2804
+ artifactPath = value;
2805
+ if (argument === "--bundle")
2806
+ bundleManifestPath = value;
2807
+ if (argument === "--cwd")
2808
+ cwd = value;
2809
+ if (argument === "--key-id")
2810
+ keyId = value;
2811
+ if (argument === "--output")
2812
+ outputPath = value;
2813
+ continue;
2814
+ }
2815
+ throw new TypeError(`Unknown release signing-request option ${String(argument)}.`);
2816
+ }
2817
+ if (keyId === undefined) {
2818
+ throw new TypeError("release signing-request requires --key-id.");
2819
+ }
2820
+ if ((artifactPath === undefined) !== (bundleManifestPath === undefined)) {
2821
+ throw new TypeError("release signing-request requires --artifact and --bundle together.");
2822
+ }
2823
+ return {
2824
+ json,
2825
+ keyId,
2826
+ manifestPath,
2827
+ ...(artifactPath === undefined ? {} : { artifactPath }),
2828
+ ...(bundleManifestPath === undefined ? {} : { bundleManifestPath }),
2829
+ ...(cwd === undefined ? {} : { cwd }),
2830
+ ...(outputPath === undefined ? {} : { outputPath }),
2831
+ };
2832
+ }
2833
+ function parseReleaseAssembleSignatureArguments(args) {
2834
+ const requestPath = args[0];
2835
+ if (requestPath === "--help" || requestPath === "-h") {
2836
+ process.stdout.write(`${RELEASE_HELP}\n`);
2837
+ return undefined;
2838
+ }
2839
+ if (requestPath === undefined || requestPath.startsWith("-")) {
2840
+ throw new TypeError("release assemble-signature requires a signing request path.");
2841
+ }
2842
+ let cwd;
2843
+ let detachedSignaturePath;
2844
+ let json = false;
2845
+ let outputPath;
2846
+ let publicKeyPath;
2847
+ for (let index = 1; index < args.length; index += 1) {
2848
+ const argument = args[index];
2849
+ if (argument === "--help" || argument === "-h") {
2850
+ process.stdout.write(`${RELEASE_HELP}\n`);
2851
+ return undefined;
2852
+ }
2853
+ if (argument === "--json") {
2854
+ json = true;
2855
+ continue;
2856
+ }
2857
+ if (argument === "--cwd" ||
2858
+ argument === "--output" ||
2859
+ argument === "--public-key" ||
2860
+ argument === "--signature") {
2861
+ const value = argumentValue(args, index, argument);
2862
+ index += 1;
2863
+ if (argument === "--cwd")
2864
+ cwd = value;
2865
+ if (argument === "--output")
2866
+ outputPath = value;
2867
+ if (argument === "--public-key")
2868
+ publicKeyPath = value;
2869
+ if (argument === "--signature")
2870
+ detachedSignaturePath = value;
2871
+ continue;
2872
+ }
2873
+ throw new TypeError(`Unknown release assemble-signature option ${String(argument)}.`);
2874
+ }
2875
+ const missing = [
2876
+ ...(detachedSignaturePath === undefined ? ["--signature"] : []),
2877
+ ...(publicKeyPath === undefined ? ["--public-key"] : []),
2878
+ ];
2879
+ if (missing.length > 0) {
2880
+ throw new TypeError(`release assemble-signature requires ${missing.join(", ")}.`);
2881
+ }
2882
+ return {
2883
+ detachedSignaturePath: detachedSignaturePath,
2884
+ json,
2885
+ publicKeyPath: publicKeyPath,
2886
+ requestPath,
2887
+ ...(cwd === undefined ? {} : { cwd }),
2888
+ ...(outputPath === undefined ? {} : { outputPath }),
2889
+ };
2890
+ }
2891
+ function parseReleaseDeviceCorrelationArguments(args) {
2892
+ const signaturePath = args[0];
2893
+ if (signaturePath === "--help" || signaturePath === "-h") {
2894
+ process.stdout.write(`${RELEASE_HELP}\n`);
2895
+ return undefined;
2896
+ }
2897
+ if (signaturePath === undefined || signaturePath.startsWith("-")) {
2898
+ throw new TypeError("release correlate-device-proof requires a release signature path.");
2899
+ }
2900
+ let artifactPath;
2901
+ let bundleManifestPath;
2902
+ let cwd;
2903
+ let deviceMinimumTrustPolicySequence;
2904
+ let deviceProofPath;
2905
+ let deviceProfileFingerprint;
2906
+ let deviceSignaturePath;
2907
+ let deviceTrustPolicyPath;
2908
+ let expectedProofSha256;
2909
+ let json = false;
2910
+ let manifestPath;
2911
+ let maximumMeasuredAt;
2912
+ let minimumMeasuredAt;
2913
+ let minimumTrustPolicySequence;
2914
+ let trustPolicyPath;
2915
+ for (let index = 1; index < args.length; index += 1) {
2916
+ const argument = args[index];
2917
+ if (argument === "--help" || argument === "-h") {
2918
+ process.stdout.write(`${RELEASE_HELP}\n`);
2919
+ return undefined;
2920
+ }
2921
+ if (argument === "--json") {
2922
+ json = true;
2923
+ continue;
2924
+ }
2925
+ if (argument === "--artifact" ||
2926
+ argument === "--bundle" ||
2927
+ argument === "--cwd" ||
2928
+ argument === "--device-minimum-policy-sequence" ||
2929
+ argument === "--device-profile-fingerprint" ||
2930
+ argument === "--device-signature" ||
2931
+ argument === "--device-trust-policy" ||
2932
+ argument === "--manifest" ||
2933
+ argument === "--maximum-measured-at" ||
2934
+ argument === "--minimum-measured-at" ||
2935
+ argument === "--minimum-policy-sequence" ||
2936
+ argument === "--proof" ||
2937
+ argument === "--proof-sha256" ||
2938
+ argument === "--trust-policy") {
2939
+ const value = argumentValue(args, index, argument);
2940
+ index += 1;
2941
+ if (argument === "--artifact")
2942
+ artifactPath = value;
2943
+ if (argument === "--bundle")
2944
+ bundleManifestPath = value;
2945
+ if (argument === "--cwd")
2946
+ cwd = value;
2947
+ if (argument === "--device-signature")
2948
+ deviceSignaturePath = value;
2949
+ if (argument === "--device-profile-fingerprint") {
2950
+ deviceProfileFingerprint = value;
2951
+ }
2952
+ if (argument === "--device-trust-policy") {
2953
+ deviceTrustPolicyPath = value;
2954
+ }
2955
+ if (argument === "--manifest")
2956
+ manifestPath = value;
2957
+ if (argument === "--maximum-measured-at")
2958
+ maximumMeasuredAt = value;
2959
+ if (argument === "--minimum-measured-at")
2960
+ minimumMeasuredAt = value;
2961
+ if (argument === "--proof")
2962
+ deviceProofPath = value;
2963
+ if (argument === "--proof-sha256")
2964
+ expectedProofSha256 = value;
2965
+ if (argument === "--trust-policy")
2966
+ trustPolicyPath = value;
2967
+ if (argument === "--minimum-policy-sequence" ||
2968
+ argument === "--device-minimum-policy-sequence") {
2969
+ const parsed = Number(value);
2970
+ if (!Number.isSafeInteger(parsed) || parsed <= 0) {
2971
+ throw new TypeError(`release correlate-device-proof ${argument} must be a positive safe integer.`);
2972
+ }
2973
+ if (argument === "--minimum-policy-sequence") {
2974
+ minimumTrustPolicySequence = parsed;
2975
+ }
2976
+ else {
2977
+ deviceMinimumTrustPolicySequence = parsed;
2978
+ }
2979
+ }
2980
+ continue;
2981
+ }
2982
+ throw new TypeError(`Unknown release correlate-device-proof option ${String(argument)}.`);
2983
+ }
2984
+ const missing = [
2985
+ ...(manifestPath === undefined ? ["--manifest"] : []),
2986
+ ...(bundleManifestPath === undefined ? ["--bundle"] : []),
2987
+ ...(artifactPath === undefined ? ["--artifact"] : []),
2988
+ ...(trustPolicyPath === undefined ? ["--trust-policy"] : []),
2989
+ ...(deviceSignaturePath === undefined ? ["--device-signature"] : []),
2990
+ ...(deviceProofPath === undefined ? ["--proof"] : []),
2991
+ ...(deviceTrustPolicyPath === undefined ? ["--device-trust-policy"] : []),
2992
+ ];
2993
+ if (missing.length > 0) {
2994
+ throw new TypeError(`release correlate-device-proof requires ${missing.join(", ")}.`);
2995
+ }
2996
+ return {
2997
+ artifactPath: artifactPath,
2998
+ bundleManifestPath: bundleManifestPath,
2999
+ deviceProofPath: deviceProofPath,
3000
+ deviceSignaturePath: deviceSignaturePath,
3001
+ deviceTrustPolicyPath: deviceTrustPolicyPath,
3002
+ json,
3003
+ manifestPath: manifestPath,
3004
+ signaturePath,
3005
+ trustPolicyPath: trustPolicyPath,
3006
+ ...(cwd === undefined ? {} : { cwd }),
3007
+ ...(deviceMinimumTrustPolicySequence === undefined
3008
+ ? {}
3009
+ : { deviceMinimumTrustPolicySequence }),
3010
+ ...(deviceProfileFingerprint === undefined
3011
+ ? {}
3012
+ : { deviceProfileFingerprint }),
3013
+ ...(expectedProofSha256 === undefined ? {} : { expectedProofSha256 }),
3014
+ ...(maximumMeasuredAt === undefined ? {} : { maximumMeasuredAt }),
3015
+ ...(minimumMeasuredAt === undefined ? {} : { minimumMeasuredAt }),
3016
+ ...(minimumTrustPolicySequence === undefined
3017
+ ? {}
3018
+ : { minimumTrustPolicySequence }),
3019
+ };
3020
+ }
3021
+ function parseReleaseVerifySignatureArguments(args, operation = "verify-signature", requireInputs = false) {
3022
+ const command = `release ${operation}`;
3023
+ const signaturePath = args[0];
3024
+ if (signaturePath === "--help" || signaturePath === "-h") {
3025
+ process.stdout.write(`${RELEASE_HELP}\n`);
3026
+ return undefined;
3027
+ }
3028
+ if (signaturePath === undefined || signaturePath.startsWith("-")) {
3029
+ throw new TypeError(`${command} requires a signature path.`);
3030
+ }
3031
+ let cwd;
3032
+ let expectedKeyId;
3033
+ let artifactPath;
3034
+ let bundleManifestPath;
3035
+ let envelopeOnly = false;
3036
+ let json = false;
3037
+ let manifestPath;
3038
+ let minimumTrustPolicySequence;
3039
+ let publicKeyPath;
3040
+ let trustPolicyPath;
3041
+ let projectName;
3042
+ let platform;
3043
+ let channel;
3044
+ let release;
3045
+ let sourceRevision;
3046
+ let releaseFingerprint;
3047
+ let bundleFingerprint;
3048
+ let nativeCompatibilityFingerprint;
3049
+ let artifactSha256;
3050
+ for (let index = 1; index < args.length; index += 1) {
3051
+ const argument = args[index];
3052
+ if (argument === "--help" || argument === "-h") {
3053
+ process.stdout.write(`${RELEASE_HELP}\n`);
3054
+ return undefined;
3055
+ }
3056
+ if (argument === "--json") {
3057
+ json = true;
3058
+ continue;
3059
+ }
3060
+ if (argument === "--envelope-only") {
3061
+ if (requireInputs) {
3062
+ throw new TypeError(`${command} does not support --envelope-only.`);
3063
+ }
3064
+ envelopeOnly = true;
3065
+ continue;
3066
+ }
3067
+ if (argument === "--cwd" ||
3068
+ argument === "--artifact" ||
3069
+ argument === "--artifact-sha256" ||
3070
+ argument === "--bundle" ||
3071
+ argument === "--bundle-fingerprint" ||
3072
+ argument === "--channel" ||
3073
+ argument === "--key-id" ||
3074
+ argument === "--manifest" ||
3075
+ argument === "--minimum-policy-sequence" ||
3076
+ argument === "--native-fingerprint" ||
3077
+ argument === "--platform" ||
3078
+ argument === "--project" ||
3079
+ argument === "--public-key" ||
3080
+ argument === "--release" ||
3081
+ argument === "--release-fingerprint" ||
3082
+ argument === "--revision" ||
3083
+ argument === "--trust-policy") {
3084
+ const value = argumentValue(args, index, argument);
3085
+ index += 1;
3086
+ if (argument === "--cwd")
3087
+ cwd = value;
3088
+ if (argument === "--artifact")
3089
+ artifactPath = value;
3090
+ if (argument === "--artifact-sha256")
3091
+ artifactSha256 = value;
3092
+ if (argument === "--bundle")
3093
+ bundleManifestPath = value;
3094
+ if (argument === "--bundle-fingerprint")
3095
+ bundleFingerprint = value;
3096
+ if (argument === "--channel")
3097
+ channel = value;
3098
+ if (argument === "--key-id")
3099
+ expectedKeyId = value;
3100
+ if (argument === "--manifest")
3101
+ manifestPath = value;
3102
+ if (argument === "--minimum-policy-sequence") {
3103
+ const parsed = Number(value);
3104
+ if (!Number.isSafeInteger(parsed) || parsed <= 0) {
3105
+ throw new TypeError(`${command} --minimum-policy-sequence must be a positive safe integer.`);
3106
+ }
3107
+ minimumTrustPolicySequence = parsed;
3108
+ }
3109
+ if (argument === "--native-fingerprint")
3110
+ nativeCompatibilityFingerprint = value;
3111
+ if (argument === "--platform") {
3112
+ if (value !== "android" && value !== "ios") {
3113
+ throw new TypeError(`${command} --platform must be ios or android.`);
3114
+ }
3115
+ platform = value;
3116
+ }
3117
+ if (argument === "--project")
3118
+ projectName = value;
3119
+ if (argument === "--public-key")
3120
+ publicKeyPath = value;
3121
+ if (argument === "--trust-policy")
3122
+ trustPolicyPath = value;
3123
+ if (argument === "--release")
3124
+ release = value;
3125
+ if (argument === "--release-fingerprint")
3126
+ releaseFingerprint = value;
3127
+ if (argument === "--revision")
3128
+ sourceRevision = value;
3129
+ continue;
3130
+ }
3131
+ throw new TypeError(`Unknown ${command} option ${String(argument)}.`);
3132
+ }
3133
+ const missing = [...(manifestPath === undefined ? ["--manifest"] : [])];
3134
+ const pinnedPolicySupplied = publicKeyPath !== undefined ||
3135
+ expectedKeyId !== undefined ||
3136
+ projectName !== undefined ||
3137
+ platform !== undefined ||
3138
+ channel !== undefined ||
3139
+ release !== undefined ||
3140
+ sourceRevision !== undefined ||
3141
+ releaseFingerprint !== undefined ||
3142
+ bundleFingerprint !== undefined ||
3143
+ nativeCompatibilityFingerprint !== undefined ||
3144
+ artifactSha256 !== undefined;
3145
+ if (trustPolicyPath !== undefined && pinnedPolicySupplied) {
3146
+ throw new TypeError(`${command} --trust-policy cannot be combined with pinned key or scope options.`);
3147
+ }
3148
+ if (trustPolicyPath === undefined &&
3149
+ minimumTrustPolicySequence !== undefined) {
3150
+ throw new TypeError(`${command} --minimum-policy-sequence requires --trust-policy.`);
3151
+ }
3152
+ if (trustPolicyPath === undefined) {
3153
+ missing.push(...(publicKeyPath === undefined ? ["--public-key"] : []), ...(expectedKeyId === undefined ? ["--key-id"] : []), ...(projectName === undefined ? ["--project"] : []), ...(platform === undefined ? ["--platform"] : []), ...(channel === undefined ? ["--channel"] : []));
3154
+ }
3155
+ if (missing.length > 0) {
3156
+ throw new TypeError(`${command} requires ${missing.join(", ")}.`);
3157
+ }
3158
+ if ((artifactPath === undefined) !== (bundleManifestPath === undefined)) {
3159
+ throw new TypeError(`${command} requires --artifact and --bundle together.`);
3160
+ }
3161
+ if (envelopeOnly &&
3162
+ (artifactPath !== undefined || bundleManifestPath !== undefined)) {
3163
+ throw new TypeError(`${command} --envelope-only cannot be combined with --artifact or --bundle.`);
3164
+ }
3165
+ if (!envelopeOnly && artifactPath === undefined) {
3166
+ throw new TypeError(requireInputs
3167
+ ? `${command} requires --artifact and --bundle.`
3168
+ : `${command} requires --artifact and --bundle or --envelope-only.`);
3169
+ }
3170
+ return {
3171
+ ...(artifactPath === undefined ? {} : { artifactPath }),
3172
+ ...(bundleManifestPath === undefined ? {} : { bundleManifestPath }),
3173
+ envelopeOnly,
3174
+ json,
3175
+ manifestPath: manifestPath,
3176
+ signaturePath,
3177
+ ...(trustPolicyPath === undefined
3178
+ ? {
3179
+ expectedKeyId: expectedKeyId,
3180
+ policy: {
3181
+ projectName: projectName,
3182
+ platform: platform,
3183
+ channel: channel,
3184
+ ...(release === undefined ? {} : { release }),
3185
+ ...(sourceRevision === undefined ? {} : { sourceRevision }),
3186
+ ...(releaseFingerprint === undefined ? {} : { releaseFingerprint }),
3187
+ ...(bundleFingerprint === undefined ? {} : { bundleFingerprint }),
3188
+ ...(nativeCompatibilityFingerprint === undefined
3189
+ ? {}
3190
+ : { nativeCompatibilityFingerprint }),
3191
+ ...(artifactSha256 === undefined ? {} : { artifactSha256 }),
3192
+ },
3193
+ publicKeyPath: publicKeyPath,
3194
+ }
3195
+ : {
3196
+ trustPolicyPath,
3197
+ ...(minimumTrustPolicySequence === undefined
3198
+ ? {}
3199
+ : { minimumTrustPolicySequence }),
3200
+ }),
3201
+ ...(cwd === undefined ? {} : { cwd }),
3202
+ };
3203
+ }
3204
+ function parseGenerateArguments(args) {
3205
+ let audit = false;
3206
+ let check = false;
3207
+ let cwd;
3208
+ let dryRun = false;
3209
+ let json = false;
3210
+ let outputPath;
3211
+ let platform = "all";
3212
+ let source = "app";
3213
+ let generateSolidBindings = true;
3214
+ const solidLibraries = [];
3215
+ let solidOutputPath;
3216
+ let verbose = false;
3217
+ for (let index = 0; index < args.length; index += 1) {
3218
+ const argument = args[index];
3219
+ if (argument === "--help" || argument === "-h") {
3220
+ process.stdout.write(`${GENERATE_HELP}\n`);
3221
+ return undefined;
3222
+ }
3223
+ if (argument === "--cwd") {
3224
+ cwd = argumentValue(args, index, argument);
3225
+ index += 1;
3226
+ continue;
3227
+ }
3228
+ if (argument === "--platform") {
3229
+ const value = argumentValue(args, index, argument);
3230
+ if (value !== "all" && value !== "ios" && value !== "android") {
3231
+ throw new TypeError(`Unsupported platform ${value}.`);
3232
+ }
3233
+ platform = value;
3234
+ index += 1;
3235
+ continue;
3236
+ }
3237
+ if (argument === "--source") {
3238
+ const value = argumentValue(args, index, argument);
3239
+ if (value !== "app" && value !== "library") {
3240
+ throw new TypeError(`Unsupported Codegen source ${value}.`);
3241
+ }
3242
+ source = value;
3243
+ index += 1;
3244
+ continue;
3245
+ }
3246
+ if (argument === "--output") {
3247
+ outputPath = argumentValue(args, index, argument);
3248
+ index += 1;
3249
+ continue;
3250
+ }
3251
+ if (argument === "--solid-output") {
3252
+ solidOutputPath = argumentValue(args, index, argument);
3253
+ index += 1;
3254
+ continue;
3255
+ }
3256
+ if (argument === "--solid-library") {
3257
+ solidLibraries.push(argumentValue(args, index, argument));
3258
+ index += 1;
3259
+ continue;
3260
+ }
3261
+ if (argument === "--no-solid") {
3262
+ generateSolidBindings = false;
3263
+ continue;
3264
+ }
3265
+ if (argument === "--verbose") {
3266
+ verbose = true;
3267
+ continue;
3268
+ }
3269
+ if (argument === "--dry-run") {
3270
+ dryRun = true;
3271
+ continue;
3272
+ }
3273
+ if (argument === "--check") {
3274
+ check = true;
3275
+ continue;
3276
+ }
3277
+ if (argument === "--audit") {
3278
+ audit = true;
3279
+ continue;
3280
+ }
3281
+ if (argument === "--json") {
3282
+ json = true;
3283
+ continue;
3284
+ }
3285
+ throw new TypeError(`Unknown generate option ${String(argument)}.`);
3286
+ }
3287
+ if (Number(audit) + Number(check) + Number(dryRun) > 1) {
3288
+ throw new TypeError("generate --audit, --check, and --dry-run are mutually exclusive.");
3289
+ }
3290
+ if (json && !audit && !dryRun && !check) {
3291
+ throw new TypeError("generate --json requires --audit, --dry-run, or --check so Codegen logs cannot corrupt JSON output.");
3292
+ }
3293
+ if (!generateSolidBindings &&
3294
+ (solidOutputPath !== undefined || solidLibraries.length > 0)) {
3295
+ throw new TypeError("--solid-output and --solid-library cannot be combined with --no-solid.");
3296
+ }
3297
+ if ((audit || check) && !generateSolidBindings) {
3298
+ throw new TypeError("generate --audit and --check cannot be combined with --no-solid.");
3299
+ }
3300
+ if ((audit || check) && outputPath !== undefined) {
3301
+ throw new TypeError("generate --audit and --check cannot be combined with the native --output path.");
3302
+ }
3303
+ return {
3304
+ audit,
3305
+ check,
3306
+ dryRun,
3307
+ json,
3308
+ platform,
3309
+ source,
3310
+ generateSolidBindings,
3311
+ solidLibraries,
3312
+ verbose,
3313
+ ...(cwd === undefined ? {} : { cwd }),
3314
+ ...(outputPath === undefined ? {} : { outputPath }),
3315
+ ...(solidOutputPath === undefined ? {} : { solidOutputPath }),
3316
+ };
3317
+ }
3318
+ function terminalSafeErrorMessage(error) {
3319
+ let message = "Unknown error";
3320
+ try {
3321
+ message = error instanceof Error ? error.message : String(error);
3322
+ }
3323
+ catch {
3324
+ // Hostile error values must not interfere with CLI shutdown.
3325
+ }
3326
+ return message.slice(0, 2_048).replace(/\p{Cc}/gu, (character) => {
3327
+ const codePoint = character.codePointAt(0);
3328
+ return `\\u${(codePoint ?? 0).toString(16).padStart(4, "0")}`;
3329
+ });
3330
+ }
3331
+ async function main(args) {
3332
+ const command = args[0];
3333
+ if (command === undefined || command === "--help" || command === "-h") {
3334
+ process.stdout.write(`${HELP}\n`);
3335
+ return;
3336
+ }
3337
+ if (command === "--version" || command === "-v") {
3338
+ process.stdout.write(`${SOLID_NATIVE_CLI_VERSION}\n`);
3339
+ return;
3340
+ }
3341
+ if (command === "debug") {
3342
+ const options = parseCausalDebugArguments(args.slice(1));
3343
+ if (options === undefined)
3344
+ return;
3345
+ if (options.operation === "capture-android") {
3346
+ const snapshot = await captureNativeAndroidCausalDebugSnapshot({
3347
+ packageName: options.packageName,
3348
+ serial: options.serial,
3349
+ ...(options.timeoutMs === undefined
3350
+ ? {}
3351
+ : { timeoutMs: options.timeoutMs }),
3352
+ });
3353
+ process.stdout.write(`${JSON.stringify(snapshot, null, 2)}\n`);
3354
+ return;
3355
+ }
3356
+ if (options.operation === "diagnostics-android") {
3357
+ const diagnostics = await captureNativeAndroidSolidDiagnostics({
3358
+ packageName: options.packageName,
3359
+ serial: options.serial,
3360
+ ...(options.durationMs === undefined
3361
+ ? {}
3362
+ : { durationMs: options.durationMs }),
3363
+ ...(options.timeoutMs === undefined
3364
+ ? {}
3365
+ : { timeoutMs: options.timeoutMs }),
3366
+ });
3367
+ process.stdout.write(`${JSON.stringify(diagnostics, null, 2)}\n`);
3368
+ return;
3369
+ }
3370
+ if (options.operation === "report-android") {
3371
+ const report = await captureNativeAndroidCausalDebugReport({
3372
+ packageName: options.packageName,
3373
+ serial: options.serial,
3374
+ includeAttributes: options.includeAttributes,
3375
+ ...(options.durationMs === undefined
3376
+ ? {}
3377
+ : { durationMs: options.durationMs }),
3378
+ ...(options.timeoutMs === undefined
3379
+ ? {}
3380
+ : { timeoutMs: options.timeoutMs }),
3381
+ });
3382
+ if (options.outputPath === undefined) {
3383
+ process.stdout.write(report);
3384
+ }
3385
+ else {
3386
+ const outputPath = await writeNativeCausalDebugReportFile({
3387
+ report,
3388
+ outputPath: options.outputPath,
3389
+ });
3390
+ process.stdout.write(`Wrote causal report: ${outputPath}\n`);
3391
+ }
3392
+ return;
3393
+ }
3394
+ if (options.operation === "tree-android") {
3395
+ const snapshot = await captureNativeAndroidTreeDebugSnapshot({
3396
+ packageName: options.packageName,
3397
+ serial: options.serial,
3398
+ ...(options.timeoutMs === undefined
3399
+ ? {}
3400
+ : { timeoutMs: options.timeoutMs }),
3401
+ });
3402
+ process.stdout.write(`${JSON.stringify(snapshot, null, 2)}\n`);
3403
+ return;
3404
+ }
3405
+ if (options.operation === "capture-ios") {
3406
+ const snapshot = await captureNativeIosCausalDebugSnapshot({
3407
+ bundleIdentifier: options.bundleIdentifier,
3408
+ device: options.device,
3409
+ ...(options.timeoutMs === undefined
3410
+ ? {}
3411
+ : { timeoutMs: options.timeoutMs }),
3412
+ });
3413
+ process.stdout.write(`${JSON.stringify(snapshot, null, 2)}\n`);
3414
+ return;
3415
+ }
3416
+ if (options.operation === "tree-ios") {
3417
+ const snapshot = await captureNativeIosTreeDebugSnapshot({
3418
+ bundleIdentifier: options.bundleIdentifier,
3419
+ device: options.device,
3420
+ ...(options.timeoutMs === undefined
3421
+ ? {}
3422
+ : { timeoutMs: options.timeoutMs }),
3423
+ });
3424
+ process.stdout.write(`${JSON.stringify(snapshot, null, 2)}\n`);
3425
+ return;
3426
+ }
3427
+ if (options.operation === "diagnostics-ios") {
3428
+ const diagnostics = await captureNativeIosSolidDiagnostics({
3429
+ bundleIdentifier: options.bundleIdentifier,
3430
+ device: options.device,
3431
+ ...(options.durationMs === undefined
3432
+ ? {}
3433
+ : { durationMs: options.durationMs }),
3434
+ ...(options.timeoutMs === undefined
3435
+ ? {}
3436
+ : { timeoutMs: options.timeoutMs }),
3437
+ });
3438
+ process.stdout.write(`${JSON.stringify(diagnostics, null, 2)}\n`);
3439
+ return;
3440
+ }
3441
+ if (options.operation === "report-ios") {
3442
+ const report = await captureNativeIosCausalDebugReport({
3443
+ bundleIdentifier: options.bundleIdentifier,
3444
+ device: options.device,
3445
+ includeAttributes: options.includeAttributes,
3446
+ ...(options.durationMs === undefined
3447
+ ? {}
3448
+ : { durationMs: options.durationMs }),
3449
+ ...(options.timeoutMs === undefined
3450
+ ? {}
3451
+ : { timeoutMs: options.timeoutMs }),
3452
+ });
3453
+ if (options.outputPath === undefined) {
3454
+ process.stdout.write(report);
3455
+ }
3456
+ else {
3457
+ const outputPath = await writeNativeCausalDebugReportFile({
3458
+ report,
3459
+ outputPath: options.outputPath,
3460
+ });
3461
+ process.stdout.write(`Wrote causal report: ${outputPath}\n`);
3462
+ }
3463
+ return;
3464
+ }
3465
+ if (options.operation === "correlate") {
3466
+ const correlation = await correlateNativeSolidDiagnosticsFiles({
3467
+ diagnosticsPath: options.diagnosticsPath,
3468
+ snapshotPath: options.snapshotPath,
3469
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
3470
+ });
3471
+ process.stdout.write(options.json
3472
+ ? `${JSON.stringify(correlation, null, 2)}\n`
3473
+ : `${formatNativeSolidDiagnosticsCorrelation(correlation)}\n`);
3474
+ return;
3475
+ }
3476
+ if (options.operation === "watch-android" ||
3477
+ options.operation === "watch-ios") {
3478
+ let interrupted = false;
3479
+ let interruptWait;
3480
+ const interrupt = () => {
3481
+ interrupted = true;
3482
+ interruptWait?.();
3483
+ };
3484
+ const waitForInterval = (milliseconds) => new Promise((resolve) => {
3485
+ let settled = false;
3486
+ const finish = () => {
3487
+ if (settled)
3488
+ return;
3489
+ settled = true;
3490
+ clearTimeout(timer);
3491
+ interruptWait = undefined;
3492
+ resolve();
3493
+ };
3494
+ const timer = setTimeout(finish, milliseconds);
3495
+ interruptWait = finish;
3496
+ });
3497
+ process.once("SIGINT", interrupt);
3498
+ process.once("SIGTERM", interrupt);
3499
+ try {
3500
+ await watchNativeCausalDebugSnapshots({
3501
+ capture: () => options.operation === "watch-android"
3502
+ ? captureNativeAndroidCausalDebugSnapshot({
3503
+ packageName: options.packageName,
3504
+ serial: options.serial,
3505
+ ...(options.timeoutMs === undefined
3506
+ ? {}
3507
+ : { timeoutMs: options.timeoutMs }),
3508
+ })
3509
+ : captureNativeIosCausalDebugSnapshot({
3510
+ bundleIdentifier: options.bundleIdentifier,
3511
+ device: options.device,
3512
+ ...(options.timeoutMs === undefined
3513
+ ? {}
3514
+ : { timeoutMs: options.timeoutMs }),
3515
+ }),
3516
+ onSnapshot: (snapshot, index) => {
3517
+ const inspection = inspectNativeCausalDebugSnapshot(snapshot);
3518
+ process.stdout.write(options.json
3519
+ ? `${JSON.stringify(inspection)}\n`
3520
+ : `${index === 0 ? "" : "\n"}Snapshot ${String(index + 1)}\n${formatNativeCausalDebugInspection(inspection)}\n`);
3521
+ },
3522
+ onCaptureError: (error, consecutiveFailureCount) => {
3523
+ const maximum = options.maxConsecutiveFailures ??
3524
+ NATIVE_CAUSAL_DEBUG_WATCH_DEFAULT_MAX_CONSECUTIVE_FAILURES;
3525
+ process.stderr.write(`solid-native: device snapshot failed (${String(consecutiveFailureCount)}/${String(maximum)}): ${terminalSafeErrorMessage(error)}\n`);
3526
+ },
3527
+ shouldContinue: () => !interrupted,
3528
+ ...(options.count === undefined ? {} : { count: options.count }),
3529
+ ...(options.intervalMs === undefined
3530
+ ? {}
3531
+ : { intervalMs: options.intervalMs }),
3532
+ ...(options.maxConsecutiveFailures === undefined
3533
+ ? {}
3534
+ : {
3535
+ maxConsecutiveFailures: options.maxConsecutiveFailures,
3536
+ }),
3537
+ dependencies: { wait: waitForInterval },
3538
+ });
3539
+ }
3540
+ finally {
3541
+ interruptWait?.();
3542
+ process.off("SIGINT", interrupt);
3543
+ process.off("SIGTERM", interrupt);
3544
+ }
3545
+ return;
3546
+ }
3547
+ if (options.operation === "compare") {
3548
+ const comparison = await compareNativeCausalDebugFiles({
3549
+ baselinePath: options.baselinePath,
3550
+ candidatePath: options.candidatePath,
3551
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
3552
+ ...(options.maxP95RegressionPercent === undefined
3553
+ ? {}
3554
+ : {
3555
+ maxP95RegressionPercent: options.maxP95RegressionPercent,
3556
+ }),
3557
+ });
3558
+ process.stdout.write(options.json
3559
+ ? `${JSON.stringify(comparison, null, 2)}\n`
3560
+ : `${formatNativeCausalDebugComparison(comparison)}\n`);
3561
+ if (!comparison.ok)
3562
+ process.exitCode = 1;
3563
+ return;
3564
+ }
3565
+ if (options.operation === "diagnostics-inspect") {
3566
+ const inspection = options.artifactPath === "-"
3567
+ ? await inspectNativeSolidDiagnosticsStream(process.stdin)
3568
+ : await inspectNativeSolidDiagnosticsFile({
3569
+ artifactPath: options.artifactPath,
3570
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
3571
+ });
3572
+ process.stdout.write(options.json
3573
+ ? `${JSON.stringify(inspection, null, 2)}\n`
3574
+ : `${formatNativeSolidDiagnosticsInspection(inspection)}\n`);
3575
+ return;
3576
+ }
3577
+ if (options.operation === "tree-inspect") {
3578
+ const inspection = options.snapshotPath === "-"
3579
+ ? await inspectNativeTreeDebugStream(process.stdin)
3580
+ : await inspectNativeTreeDebugFile({
3581
+ snapshotPath: options.snapshotPath,
3582
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
3583
+ });
3584
+ process.stdout.write(options.json
3585
+ ? `${JSON.stringify(inspection, null, 2)}\n`
3586
+ : `${formatNativeTreeDebugInspection(inspection)}\n`);
3587
+ return;
3588
+ }
3589
+ if (options.operation === "symbolicate") {
3590
+ if (options.input === "stack") {
3591
+ const result = options.stackPath === "-"
3592
+ ? await symbolicateNativeStackTraceStream({
3593
+ sourceMapPath: options.sourceMapPath,
3594
+ stream: process.stdin,
3595
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
3596
+ })
3597
+ : await symbolicateNativeStackTraceFile({
3598
+ sourceMapPath: options.sourceMapPath,
3599
+ stackPath: options.stackPath,
3600
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
3601
+ });
3602
+ process.stdout.write(options.json
3603
+ ? `${JSON.stringify(result, null, 2)}\n`
3604
+ : `${formatNativeStackTraceSymbolication(result)}\n`);
3605
+ return;
3606
+ }
3607
+ const result = await symbolicateNativeSourceLocations({
3608
+ sourceMapPath: options.sourceMapPath,
3609
+ locations: options.locations,
3610
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
3611
+ });
3612
+ process.stdout.write(options.json
3613
+ ? `${JSON.stringify(result, null, 2)}\n`
3614
+ : `${formatNativeSourceLocationSymbolication(result)}\n`);
3615
+ return;
3616
+ }
3617
+ if (options.operation === "trace") {
3618
+ const traceOptions = {
3619
+ includeAttributes: options.includeAttributes,
3620
+ };
3621
+ const trace = options.snapshotPath === "-"
3622
+ ? await createNativeCausalTraceStream(process.stdin, traceOptions)
3623
+ : await createNativeCausalTraceFile({
3624
+ ...traceOptions,
3625
+ snapshotPath: options.snapshotPath,
3626
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
3627
+ });
3628
+ process.stdout.write(`${JSON.stringify(trace, null, 2)}\n`);
3629
+ return;
3630
+ }
3631
+ if (options.operation === "report") {
3632
+ const diagnostics = options.diagnosticsPath === undefined
3633
+ ? undefined
3634
+ : await readNativeSolidDiagnosticsDebugFile(options.diagnosticsPath, options.cwd);
3635
+ const tree = options.treePath === undefined
3636
+ ? undefined
3637
+ : await readNativeTreeDebugSnapshotFile(options.treePath, options.cwd);
3638
+ const reportOptions = {
3639
+ includeAttributes: options.includeAttributes,
3640
+ ...(diagnostics === undefined ? {} : { diagnostics }),
3641
+ ...(tree === undefined ? {} : { tree }),
3642
+ ...(options.operationId === undefined
3643
+ ? {}
3644
+ : { operationId: options.operationId }),
3645
+ };
3646
+ const report = options.snapshotPath === "-"
3647
+ ? await createNativeCausalDebugReportStream(process.stdin, reportOptions)
3648
+ : await createNativeCausalDebugReportFile({
3649
+ ...reportOptions,
3650
+ snapshotPath: options.snapshotPath,
3651
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
3652
+ });
3653
+ if (options.outputPath === undefined) {
3654
+ process.stdout.write(report);
3655
+ }
3656
+ else {
3657
+ const outputPath = await writeNativeCausalDebugReportFile({
3658
+ report,
3659
+ outputPath: options.outputPath,
3660
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
3661
+ });
3662
+ process.stdout.write(`Wrote causal report: ${outputPath}\n`);
3663
+ }
3664
+ return;
3665
+ }
3666
+ const inspectionOptions = {
3667
+ includeAttributes: options.includeAttributes,
3668
+ ...(options.operationId === undefined
3669
+ ? {}
3670
+ : { operationId: options.operationId }),
3671
+ };
3672
+ const inspection = options.snapshotPath === "-"
3673
+ ? await inspectNativeCausalDebugStream(process.stdin, inspectionOptions)
3674
+ : await inspectNativeCausalDebugFile({
3675
+ ...inspectionOptions,
3676
+ snapshotPath: options.snapshotPath,
3677
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
3678
+ });
3679
+ process.stdout.write(options.json
3680
+ ? `${JSON.stringify(inspection, null, 2)}\n`
3681
+ : `${formatNativeCausalDebugInspection(inspection)}\n`);
3682
+ return;
3683
+ }
3684
+ if (command === "create") {
3685
+ const options = parseCreateArguments(args.slice(1));
3686
+ if (options === undefined)
3687
+ return;
3688
+ const plan = await createNativeCreatePlan({
3689
+ projectName: options.projectName,
3690
+ skipInstall: options.skipInstall,
3691
+ ...(options.directory === undefined
3692
+ ? {}
3693
+ : { directory: options.directory }),
3694
+ ...(options.packageName === undefined
3695
+ ? {}
3696
+ : { packageName: options.packageName }),
3697
+ ...(options.title === undefined ? {} : { title: options.title }),
3698
+ });
3699
+ if (options.dryRun) {
3700
+ process.stdout.write(options.json
3701
+ ? `${JSON.stringify(plan, null, 2)}\n`
3702
+ : `Target: ${plan.targetDirectory}\nCommand: ${formatNativeCreatePlan(plan)}\n`);
3703
+ return;
3704
+ }
3705
+ process.stdout.write(`Creating ${plan.projectName} with Solid Native's verified React Native ${VERIFIED_REACT_NATIVE_VERSION} backend...\n`);
3706
+ const exitCode = await executeNativeCreatePlan(plan);
3707
+ process.exitCode = exitCode;
3708
+ if (exitCode === 0) {
3709
+ process.stdout.write(`${formatNativeCreateSuccess(plan)}\n`);
3710
+ }
3711
+ return;
3712
+ }
3713
+ if (command === "add") {
3714
+ const options = parseAddArguments(args.slice(1));
3715
+ if (options === undefined)
3716
+ return;
3717
+ const plan = await createNativePackageAddPlan({
3718
+ capability: options.capability,
3719
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
3720
+ });
3721
+ if (options.dryRun) {
3722
+ process.stdout.write(options.json
3723
+ ? `${JSON.stringify(plan, null, 2)}\n`
3724
+ : `Project: ${plan.projectRoot}\n${formatNativePackageAddPlan(plan)}\n`);
3725
+ return;
3726
+ }
3727
+ const exitCode = await executeNativePackageAddPlan(plan);
3728
+ process.exitCode = exitCode;
3729
+ if (exitCode === 0) {
3730
+ process.stdout.write(`Added Solid Native ${plan.capability} to ${plan.projectRoot}.\n`);
3731
+ }
3732
+ return;
3733
+ }
3734
+ if (command === "adapter") {
3735
+ const options = parseAdapterArguments(args.slice(1));
3736
+ if (options === undefined)
3737
+ return;
3738
+ const plan = await createNativeAdapterScaffoldPlan({
3739
+ moduleName: options.moduleName,
3740
+ packageName: options.packageName,
3741
+ platform: options.platform,
3742
+ ...(options.bindingsPath === undefined
3743
+ ? {}
3744
+ : { bindingsPath: options.bindingsPath }),
3745
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
3746
+ ...(options.outputPath === undefined
3747
+ ? {}
3748
+ : { outputPath: options.outputPath }),
3749
+ });
3750
+ if (options.dryRun) {
3751
+ process.stdout.write(options.json
3752
+ ? `${JSON.stringify(plan, null, 2)}\n`
3753
+ : `Adapter: ${plan.outputPath}\nBindings: ${plan.bindingGeneration.outputPath}\nModule: ${plan.moduleName} from ${plan.packageName}${plan.packageVersion === undefined ? "" : `@${plan.packageVersion}`}\n`);
3754
+ return;
3755
+ }
3756
+ await executeNativeAdapterScaffoldPlan(plan);
3757
+ process.stdout.write(`Created native adapter scaffold: ${plan.outputPath}\n`);
3758
+ return;
3759
+ }
3760
+ if (command === "build") {
3761
+ const options = parseBuildArguments(args.slice(1));
3762
+ if (options === undefined)
3763
+ return;
3764
+ const plan = await createNativeBuildPlan({
3765
+ platform: options.platform,
3766
+ forwardedArgs: options.forwardedArgs,
3767
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
3768
+ });
3769
+ if (options.dryRun) {
3770
+ process.stdout.write(options.json
3771
+ ? `${JSON.stringify(plan, null, 2)}\n`
3772
+ : `Project: ${plan.projectRoot}\nCommand: ${formatNativeBuildPlan(plan)}\n`);
3773
+ return;
3774
+ }
3775
+ process.exitCode = await executeNativeBuildPlan(plan);
3776
+ return;
3777
+ }
3778
+ if (command === "bundle") {
3779
+ if (args[1] === "sources") {
3780
+ const options = parseBundleSourcesArguments(args.slice(2));
3781
+ if (options === undefined)
3782
+ return;
3783
+ const report = await checkNativeBundleSources(options);
3784
+ process.stdout.write(options.json
3785
+ ? `${JSON.stringify(report, null, 2)}\n`
3786
+ : `${formatNativeSourceMapPolicyReport(report)}\n`);
3787
+ if (!report.ok)
3788
+ process.exitCode = 1;
3789
+ return;
3790
+ }
3791
+ if (args[1] === "verify") {
3792
+ const options = parseBundleVerifyArguments(args.slice(2));
3793
+ if (options === undefined)
3794
+ return;
3795
+ const report = await verifyNativeBundleManifest(options.manifestPath);
3796
+ process.stdout.write(options.json
3797
+ ? `${JSON.stringify(report, null, 2)}\n`
3798
+ : `${formatNativeBundleVerification(report)}\n`);
3799
+ if (!report.ok)
3800
+ process.exitCode = 1;
3801
+ return;
3802
+ }
3803
+ const options = parseBundleArguments(args.slice(1));
3804
+ if (options === undefined)
3805
+ return;
3806
+ const plan = await createNativeBundlePlan({
3807
+ platform: options.platform,
3808
+ forwardedArgs: options.forwardedArgs,
3809
+ hermesSource: options.hermesSource,
3810
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
3811
+ ...(options.entryFile === undefined
3812
+ ? {}
3813
+ : { entryFile: options.entryFile }),
3814
+ ...(options.outputDirectory === undefined
3815
+ ? {}
3816
+ : { outputDirectory: options.outputDirectory }),
3817
+ });
3818
+ if (options.dryRun) {
3819
+ process.stdout.write(options.json
3820
+ ? `${JSON.stringify(plan, null, 2)}\n`
3821
+ : `Project: ${plan.projectRoot}\nCommand: ${formatNativeBundlePlan(plan)}\n`);
3822
+ return;
3823
+ }
3824
+ const exitCode = await executeNativeBundlePlan(plan);
3825
+ process.exitCode = exitCode;
3826
+ if (exitCode === 0) {
3827
+ process.stdout.write(`Bundle: ${plan.bundlePath}\nSource map: ${plan.sourceMapPath}\nAssets: ${plan.assetsDirectory}\nManifest: ${plan.manifestPath}\n`);
3828
+ }
3829
+ return;
3830
+ }
3831
+ if (command === "fingerprint") {
3832
+ const options = parseFingerprintArguments(args.slice(1));
3833
+ if (options === undefined)
3834
+ return;
3835
+ const report = await createNativeFingerprint({
3836
+ platform: options.platform,
3837
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
3838
+ });
3839
+ process.stdout.write(options.json
3840
+ ? `${JSON.stringify(report, null, 2)}\n`
3841
+ : `${formatNativeFingerprint(report)}\n`);
3842
+ return;
3843
+ }
3844
+ if (command === "compatibility") {
3845
+ const options = parseCompatibilityArguments(args.slice(1));
3846
+ if (options === undefined)
3847
+ return;
3848
+ if (options.operation === "evidence") {
3849
+ const report = await createNativeCompatibilityEvidenceReport({
3850
+ paths: options.paths,
3851
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
3852
+ });
3853
+ process.stdout.write(options.json
3854
+ ? `${JSON.stringify(report, null, 2)}\n`
3855
+ : `${report.evidence.map((entry) => `${entry.sha256} ${entry.path}`).join("\n")}\n`);
3856
+ return;
3857
+ }
3858
+ const report = await checkNativeCompatibilityCatalog({
3859
+ platform: options.platform,
3860
+ ...(options.catalogPath === undefined
3861
+ ? {}
3862
+ : { catalogPath: options.catalogPath }),
3863
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
3864
+ });
3865
+ process.stdout.write(options.json
3866
+ ? `${JSON.stringify(report, null, 2)}\n`
3867
+ : `${formatNativeCompatibilityCatalogReport(report)}\n`);
3868
+ if (!report.ok)
3869
+ process.exitCode = 1;
3870
+ return;
3871
+ }
3872
+ if (command === "device") {
3873
+ const options = parseDeviceArguments(args.slice(1));
3874
+ if (options === undefined)
3875
+ return;
3876
+ if (options.operation === "status-ios") {
3877
+ const status = await readNativeIosApplicationProcessStatus({
3878
+ bundleIdentifier: options.bundleIdentifier,
3879
+ device: options.device,
3880
+ });
3881
+ process.stdout.write(options.json
3882
+ ? `${JSON.stringify(status, null, 2)}\n`
3883
+ : `${formatNativeIosApplicationProcessStatus(status)}\n`);
3884
+ return;
3885
+ }
3886
+ const result = await stopNativeIosApplicationProcesses({
3887
+ bundleIdentifier: options.bundleIdentifier,
3888
+ device: options.device,
3889
+ });
3890
+ process.stdout.write(options.json
3891
+ ? `${JSON.stringify(result, null, 2)}\n`
3892
+ : `${formatNativeIosApplicationProcessStop(result)}\n`);
3893
+ return;
3894
+ }
3895
+ if (command === "device-proof") {
3896
+ const options = parseDeviceProofArguments(args.slice(1));
3897
+ if (options === undefined)
3898
+ return;
3899
+ if (options.operation === "create-android") {
3900
+ const result = await createNativeAndroidDeviceProof({
3901
+ applicationApkPath: options.applicationApkPath,
3902
+ applicationBundlePath: options.applicationBundlePath,
3903
+ forbiddenSourceFragments: options.forbiddenSourceFragments,
3904
+ generatedBindingsPath: options.generatedBindingsPath,
3905
+ instrumentationApkPath: options.instrumentationApkPath,
3906
+ instrumentationClass: options.instrumentationClass,
3907
+ instrumentationResultsDirectory: options.instrumentationResultsDirectory,
3908
+ instrumentationTest: options.instrumentationTest,
3909
+ notBefore: options.notBefore,
3910
+ outputPath: options.outputPath,
3911
+ requiredSources: options.requiredSources,
3912
+ serial: options.serial,
3913
+ sourceMapPath: options.sourceMapPath,
3914
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
3915
+ });
3916
+ process.stdout.write(options.json
3917
+ ? `${JSON.stringify(result, null, 2)}\n`
3918
+ : `Android device proof: ${result.receiptSha256}\nReceipt: ${result.receiptPath}\nProfile: ${result.profile.profileFingerprint}\n`);
3919
+ return;
3920
+ }
3921
+ if (options.operation === "profile") {
3922
+ const receipt = await readNativeDeviceProofReceipt(path.resolve(options.cwd ?? process.cwd(), options.proofPath));
3923
+ const profile = inspectNativeDeviceProofProfile(receipt);
3924
+ process.stdout.write(options.json
3925
+ ? `${JSON.stringify(profile, null, 2)}\n`
3926
+ : `Device-proof profile: ${profile.profileFingerprint}\nReceipt schema: ${String(profile.receiptSchemaVersion)}\nInstrumentation: ${profile.instrumentation.className}#${profile.instrumentation.testName}\nSource-policy checks: ${String(profile.sourcePolicy.length)}\n`);
3927
+ return;
3928
+ }
3929
+ if (options.operation === "sign") {
3930
+ const result = await createNativeDeviceProofSignature({
3931
+ proofPath: options.proofPath,
3932
+ privateKeyPath: options.privateKeyPath,
3933
+ keyId: options.keyId,
3934
+ projectName: options.projectName,
3935
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
3936
+ ...(options.outputPath === undefined
3937
+ ? {}
3938
+ : { outputPath: options.outputPath }),
3939
+ });
3940
+ process.stdout.write(options.json
3941
+ ? `${JSON.stringify(result, null, 2)}\n`
3942
+ : `Device proof: ${result.signature.proofSha256}\nProject: ${result.signature.projectName}\nKey: ${result.signature.keyId}\nSignature: ${result.signaturePath}\n`);
3943
+ return;
3944
+ }
3945
+ if (options.operation === "signing-request") {
3946
+ const result = await createNativeDeviceProofSigningRequest({
3947
+ proofPath: options.proofPath,
3948
+ keyId: options.keyId,
3949
+ projectName: options.projectName,
3950
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
3951
+ ...(options.outputPath === undefined
3952
+ ? {}
3953
+ : { outputPath: options.outputPath }),
3954
+ });
3955
+ process.stdout.write(options.json
3956
+ ? `${JSON.stringify(result, null, 2)}\n`
3957
+ : `Device proof: ${result.request.proofSha256}\nProject: ${result.request.projectName}\nKey: ${result.request.keyId}\nPayload SHA-256: ${result.request.payloadSha256}\nSigning request: ${result.requestPath}\n`);
3958
+ return;
3959
+ }
3960
+ if (options.operation === "assemble-signature") {
3961
+ const result = await assembleNativeDeviceProofSignature({
3962
+ requestPath: options.requestPath,
3963
+ detachedSignaturePath: options.detachedSignaturePath,
3964
+ publicKeyPath: options.publicKeyPath,
3965
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
3966
+ ...(options.outputPath === undefined
3967
+ ? {}
3968
+ : { outputPath: options.outputPath }),
3969
+ });
3970
+ process.stdout.write(options.json
3971
+ ? `${JSON.stringify(result, null, 2)}\n`
3972
+ : `Device proof: ${result.signature.proofSha256}\nProject: ${result.signature.projectName}\nKey: ${result.signature.keyId}\nSigning request: ${result.requestPath}\nSignature: ${result.signaturePath}\n`);
3973
+ return;
3974
+ }
3975
+ const deviceProofPolicyOptions = {
3976
+ ...(options.expectedProofSha256 === undefined
3977
+ ? {}
3978
+ : { expectedProofSha256: options.expectedProofSha256 }),
3979
+ ...(options.expectedProfileFingerprint === undefined
3980
+ ? {}
3981
+ : { expectedProfileFingerprint: options.expectedProfileFingerprint }),
3982
+ ...(options.expectedSourceRevision === undefined
3983
+ ? {}
3984
+ : { expectedSourceRevision: options.expectedSourceRevision }),
3985
+ ...(options.expectedNativeCompatibilityFingerprint === undefined
3986
+ ? {}
3987
+ : {
3988
+ expectedNativeCompatibilityFingerprint: options.expectedNativeCompatibilityFingerprint,
3989
+ }),
3990
+ ...(options.expectedApplicationArtifactSha256 === undefined
3991
+ ? {}
3992
+ : {
3993
+ expectedApplicationArtifactSha256: options.expectedApplicationArtifactSha256,
3994
+ }),
3995
+ ...(options.minimumMeasuredAt === undefined
3996
+ ? {}
3997
+ : { minimumMeasuredAt: options.minimumMeasuredAt }),
3998
+ ...(options.maximumMeasuredAt === undefined
3999
+ ? {}
4000
+ : { maximumMeasuredAt: options.maximumMeasuredAt }),
4001
+ };
4002
+ const verificationOptions = options.trustPolicyPath === undefined
4003
+ ? {
4004
+ proofPath: options.proofPath,
4005
+ signaturePath: options.signaturePath,
4006
+ ...deviceProofPolicyOptions,
4007
+ publicKeyPath: options.publicKeyPath,
4008
+ expectedKeyId: options.expectedKeyId,
4009
+ projectName: options.projectName,
4010
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
4011
+ }
4012
+ : {
4013
+ proofPath: options.proofPath,
4014
+ signaturePath: options.signaturePath,
4015
+ ...deviceProofPolicyOptions,
4016
+ trustPolicyPath: options.trustPolicyPath,
4017
+ ...(options.minimumTrustPolicySequence === undefined
4018
+ ? {}
4019
+ : {
4020
+ minimumTrustPolicySequence: options.minimumTrustPolicySequence,
4021
+ }),
4022
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
4023
+ };
4024
+ if (options.operation === "ingestion") {
4025
+ const ingestion = await createNativeDeviceProofIngestion(verificationOptions);
4026
+ process.stdout.write(options.json
4027
+ ? `${JSON.stringify(ingestion, null, 2)}\n`
4028
+ : `${formatNativeDeviceProofIngestion(ingestion)}\n`);
4029
+ return;
4030
+ }
4031
+ const report = await verifyNativeDeviceProofSignature(verificationOptions);
4032
+ process.stdout.write(options.json
4033
+ ? `${JSON.stringify(report, null, 2)}\n`
4034
+ : `${formatNativeDeviceProofSignatureVerification(report)}\n`);
4035
+ if (!report.ok)
4036
+ process.exitCode = 1;
4037
+ return;
4038
+ }
4039
+ if (command === "generate") {
4040
+ const options = parseGenerateArguments(args.slice(1));
4041
+ if (options === undefined)
4042
+ return;
4043
+ const plan = await createNativeGeneratePlan({
4044
+ platform: options.platform,
4045
+ source: options.source,
4046
+ generateSolidBindings: options.generateSolidBindings,
4047
+ solidLibraries: options.solidLibraries,
4048
+ verbose: options.verbose,
4049
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
4050
+ ...(options.outputPath === undefined
4051
+ ? {}
4052
+ : { outputPath: options.outputPath }),
4053
+ ...(options.solidOutputPath === undefined
4054
+ ? {}
4055
+ : { solidOutputPath: options.solidOutputPath }),
4056
+ });
4057
+ if (options.audit) {
4058
+ if (plan.solidBindings === undefined) {
4059
+ throw new TypeError("generate --audit requires an application or selected dependency Codegen config.");
4060
+ }
4061
+ const report = createNativeSolidBindingAudit(plan.solidBindings, {
4062
+ platform: options.platform,
4063
+ });
4064
+ process.stdout.write(options.json
4065
+ ? `${JSON.stringify(report, null, 2)}\n`
4066
+ : `Solid binding audit: ${report.components.length} reusable components, ${report.interfaceOnlyComponents.length} interface-only components, ${report.modules.length} TurboModules.\nInputs: ${report.inputs.map((input) => `${input.packageName}${input.packageVersion === undefined ? "" : `@${input.packageVersion}`}`).join(", ")}\n`);
4067
+ return;
4068
+ }
4069
+ if (options.check) {
4070
+ if (plan.solidBindings === undefined) {
4071
+ throw new TypeError("generate --check requires an application or selected dependency Codegen config.");
4072
+ }
4073
+ const report = await checkNativeSolidBindingGeneration(plan.solidBindings);
4074
+ process.stdout.write(options.json
4075
+ ? `${JSON.stringify(report, null, 2)}\n`
4076
+ : `Solid bindings ${report.status}: ${report.outputPath}\n`);
4077
+ if (!report.ok)
4078
+ process.exitCode = 1;
4079
+ return;
4080
+ }
4081
+ if (options.dryRun) {
4082
+ process.stdout.write(options.json
4083
+ ? `${JSON.stringify(plan, null, 2)}\n`
4084
+ : `Project: ${plan.projectRoot}\nCommand: ${formatNativeGeneratePlan(plan)}${plan.solidBindings === undefined ? "" : `\nSolid bindings: ${plan.solidBindings.outputPath}`}\n`);
4085
+ return;
4086
+ }
4087
+ process.exitCode = await executeNativeGeneratePlan(plan);
4088
+ return;
4089
+ }
4090
+ if (command === "release") {
4091
+ const operation = args[1];
4092
+ if (operation === "--help" || operation === "-h") {
4093
+ process.stdout.write(`${RELEASE_HELP}\n`);
4094
+ return;
4095
+ }
4096
+ if (operation === "verify-android-signing") {
4097
+ const options = parseReleaseVerifyAndroidSigningArguments(args.slice(2));
4098
+ if (options === undefined)
4099
+ return;
4100
+ const extension = path.extname(options.artifactPath).toLowerCase();
4101
+ if (extension !== ".aab" && extension !== ".apk") {
4102
+ throw new TypeError("release verify-android-signing requires an .aab or .apk artifact.");
4103
+ }
4104
+ if (extension === ".aab" &&
4105
+ options.expectedCertificateSha256s.length > 1) {
4106
+ throw new TypeError("An Android App Bundle accepts exactly one expected upload certificate.");
4107
+ }
4108
+ const report = extension === ".aab"
4109
+ ? await verifyNativeAndroidBundleSigning({
4110
+ artifactPath: options.artifactPath,
4111
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
4112
+ ...(options.expectedCertificateSha256s[0] === undefined
4113
+ ? {}
4114
+ : {
4115
+ expectedCertificateSha256: options.expectedCertificateSha256s[0],
4116
+ }),
4117
+ })
4118
+ : await verifyNativeAndroidApkSigning({
4119
+ artifactPath: options.artifactPath,
4120
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
4121
+ ...(options.expectedCertificateSha256s.length === 0
4122
+ ? {}
4123
+ : {
4124
+ expectedCertificateSha256s: options.expectedCertificateSha256s,
4125
+ }),
4126
+ });
4127
+ process.stdout.write(options.json
4128
+ ? `${JSON.stringify(report, null, 2)}\n`
4129
+ : `${extension === ".aab" ? formatNativeAndroidBundleSigningReport(report) : formatNativeAndroidApkSigningReport(report)}\n`);
4130
+ if (!report.ok)
4131
+ process.exitCode = 1;
4132
+ return;
4133
+ }
4134
+ if (operation === "create") {
4135
+ const options = parseReleaseCreateArguments(args.slice(2));
4136
+ if (options === undefined)
4137
+ return;
4138
+ const releaseOptions = {
4139
+ artifactPath: options.artifactPath,
4140
+ bundleManifestPath: options.bundleManifestPath,
4141
+ channel: options.channel,
4142
+ inspectEmbeddedBundle: options.inspectEmbeddedBundle,
4143
+ release: options.release,
4144
+ sourceRevision: options.sourceRevision,
4145
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
4146
+ ...(options.outputPath === undefined
4147
+ ? {}
4148
+ : { outputPath: options.outputPath }),
4149
+ };
4150
+ const result = options.androidSigningCertificateSha256s.length > 0
4151
+ ? await createNativeReleaseManifest({
4152
+ ...releaseOptions,
4153
+ androidSigningCertificateSha256s: options.androidSigningCertificateSha256s,
4154
+ })
4155
+ : options.androidUploadCertificateSha256 !== undefined
4156
+ ? await createNativeReleaseManifest({
4157
+ ...releaseOptions,
4158
+ androidUploadCertificateSha256: options.androidUploadCertificateSha256,
4159
+ })
4160
+ : await createNativeReleaseManifest(releaseOptions);
4161
+ process.stdout.write(options.json
4162
+ ? `${JSON.stringify(result, null, 2)}\n`
4163
+ : `Release: ${result.manifest.releaseFingerprint}\nManifest: ${result.manifestPath}\nUnsigned: verify a trusted signature before delivery.\n`);
4164
+ return;
4165
+ }
4166
+ if (operation === "sign") {
4167
+ const options = parseReleaseSignArguments(args.slice(2));
4168
+ if (options === undefined)
4169
+ return;
4170
+ const result = await createNativeReleaseSignature({
4171
+ keyId: options.keyId,
4172
+ manifestPath: options.manifestPath,
4173
+ privateKeyPath: options.privateKeyPath,
4174
+ ...(options.artifactPath === undefined
4175
+ ? {}
4176
+ : { artifactPath: options.artifactPath }),
4177
+ ...(options.bundleManifestPath === undefined
4178
+ ? {}
4179
+ : { bundleManifestPath: options.bundleManifestPath }),
4180
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
4181
+ ...(options.outputPath === undefined
4182
+ ? {}
4183
+ : { outputPath: options.outputPath }),
4184
+ });
4185
+ process.stdout.write(options.json
4186
+ ? `${JSON.stringify(result, null, 2)}\n`
4187
+ : `Release: ${result.signature.releaseFingerprint}\nKey: ${result.signature.keyId}\nInputs: ${result.verification === undefined ? "envelope only" : "verified artifact, bundle, and native compatibility"}\nSignature: ${result.signaturePath}\n`);
4188
+ return;
4189
+ }
4190
+ if (operation === "signing-request") {
4191
+ const options = parseReleaseSigningRequestArguments(args.slice(2));
4192
+ if (options === undefined)
4193
+ return;
4194
+ const result = await createNativeReleaseSigningRequest({
4195
+ keyId: options.keyId,
4196
+ manifestPath: options.manifestPath,
4197
+ ...(options.artifactPath === undefined
4198
+ ? {}
4199
+ : { artifactPath: options.artifactPath }),
4200
+ ...(options.bundleManifestPath === undefined
4201
+ ? {}
4202
+ : { bundleManifestPath: options.bundleManifestPath }),
4203
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
4204
+ ...(options.outputPath === undefined
4205
+ ? {}
4206
+ : { outputPath: options.outputPath }),
4207
+ });
4208
+ process.stdout.write(options.json
4209
+ ? `${JSON.stringify(result, null, 2)}\n`
4210
+ : `Release: ${result.request.releaseFingerprint}\nKey: ${result.request.keyId}\nInputs: ${result.verification === undefined ? "envelope only" : "verified artifact, bundle, and native compatibility"}\nPayload SHA-256: ${result.request.payloadSha256}\nSigning request: ${result.requestPath}\n`);
4211
+ return;
4212
+ }
4213
+ if (operation === "assemble-signature") {
4214
+ const options = parseReleaseAssembleSignatureArguments(args.slice(2));
4215
+ if (options === undefined)
4216
+ return;
4217
+ const result = await assembleNativeReleaseSignature({
4218
+ detachedSignaturePath: options.detachedSignaturePath,
4219
+ publicKeyPath: options.publicKeyPath,
4220
+ requestPath: options.requestPath,
4221
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
4222
+ ...(options.outputPath === undefined
4223
+ ? {}
4224
+ : { outputPath: options.outputPath }),
4225
+ });
4226
+ process.stdout.write(options.json
4227
+ ? `${JSON.stringify(result, null, 2)}\n`
4228
+ : `Release: ${result.signature.releaseFingerprint}\nKey: ${result.signature.keyId}\nSigning request: ${result.requestPath}\nSignature: ${result.signaturePath}\n`);
4229
+ return;
4230
+ }
4231
+ if (operation === "correlate-device-proof") {
4232
+ const options = parseReleaseDeviceCorrelationArguments(args.slice(2));
4233
+ if (options === undefined)
4234
+ return;
4235
+ const correlation = await createNativeReleaseDeviceCorrelation({
4236
+ release: {
4237
+ manifestPath: options.manifestPath,
4238
+ signaturePath: options.signaturePath,
4239
+ bundleManifestPath: options.bundleManifestPath,
4240
+ artifactPath: options.artifactPath,
4241
+ trustPolicyPath: options.trustPolicyPath,
4242
+ ...(options.minimumTrustPolicySequence === undefined
4243
+ ? {}
4244
+ : {
4245
+ minimumTrustPolicySequence: options.minimumTrustPolicySequence,
4246
+ }),
4247
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
4248
+ },
4249
+ deviceProof: {
4250
+ proofPath: options.deviceProofPath,
4251
+ signaturePath: options.deviceSignaturePath,
4252
+ trustPolicyPath: options.deviceTrustPolicyPath,
4253
+ ...(options.deviceMinimumTrustPolicySequence === undefined
4254
+ ? {}
4255
+ : {
4256
+ minimumTrustPolicySequence: options.deviceMinimumTrustPolicySequence,
4257
+ }),
4258
+ ...(options.deviceProfileFingerprint === undefined
4259
+ ? {}
4260
+ : {
4261
+ expectedProfileFingerprint: options.deviceProfileFingerprint,
4262
+ }),
4263
+ ...(options.expectedProofSha256 === undefined
4264
+ ? {}
4265
+ : { expectedProofSha256: options.expectedProofSha256 }),
4266
+ ...(options.minimumMeasuredAt === undefined
4267
+ ? {}
4268
+ : { minimumMeasuredAt: options.minimumMeasuredAt }),
4269
+ ...(options.maximumMeasuredAt === undefined
4270
+ ? {}
4271
+ : { maximumMeasuredAt: options.maximumMeasuredAt }),
4272
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
4273
+ },
4274
+ });
4275
+ process.stdout.write(options.json
4276
+ ? `${JSON.stringify(correlation, null, 2)}\n`
4277
+ : `${formatNativeReleaseDeviceCorrelation(correlation)}\n`);
4278
+ return;
4279
+ }
4280
+ if (operation === "verify") {
4281
+ const options = parseReleaseVerifyArguments(args.slice(2));
4282
+ if (options === undefined)
4283
+ return;
4284
+ const report = await verifyNativeReleaseManifest({
4285
+ artifactPath: options.artifactPath,
4286
+ bundleManifestPath: options.bundleManifestPath,
4287
+ manifestPath: options.manifestPath,
4288
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
4289
+ });
4290
+ process.stdout.write(options.json
4291
+ ? `${JSON.stringify(report, null, 2)}\n`
4292
+ : `${formatNativeReleaseVerification(report)}\n`);
4293
+ if (!report.ok)
4294
+ process.exitCode = 1;
4295
+ return;
4296
+ }
4297
+ if (operation === "symbolication") {
4298
+ const options = parseReleaseVerifySignatureArguments(args.slice(2), "symbolication", true);
4299
+ if (options === undefined)
4300
+ return;
4301
+ const commonOptions = {
4302
+ manifestPath: options.manifestPath,
4303
+ signaturePath: options.signaturePath,
4304
+ ...(options.trustPolicyPath === undefined
4305
+ ? {
4306
+ expectedKeyId: options.expectedKeyId,
4307
+ policy: options.policy,
4308
+ publicKeyPath: options.publicKeyPath,
4309
+ }
4310
+ : {
4311
+ trustPolicyPath: options.trustPolicyPath,
4312
+ ...(options.minimumTrustPolicySequence === undefined
4313
+ ? {}
4314
+ : {
4315
+ minimumTrustPolicySequence: options.minimumTrustPolicySequence,
4316
+ }),
4317
+ }),
4318
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
4319
+ };
4320
+ const handoff = await createNativeSymbolicationHandoff({
4321
+ ...commonOptions,
4322
+ artifactPath: options.artifactPath,
4323
+ bundleManifestPath: options.bundleManifestPath,
4324
+ });
4325
+ process.stdout.write(options.json
4326
+ ? `${JSON.stringify(handoff, null, 2)}\n`
4327
+ : `${formatNativeSymbolicationHandoff(handoff)}\n`);
4328
+ return;
4329
+ }
4330
+ if (operation === "verify-signature") {
4331
+ const options = parseReleaseVerifySignatureArguments(args.slice(2));
4332
+ if (options === undefined)
4333
+ return;
4334
+ const commonOptions = {
4335
+ manifestPath: options.manifestPath,
4336
+ signaturePath: options.signaturePath,
4337
+ ...(options.trustPolicyPath === undefined
4338
+ ? {
4339
+ expectedKeyId: options.expectedKeyId,
4340
+ policy: options.policy,
4341
+ publicKeyPath: options.publicKeyPath,
4342
+ }
4343
+ : {
4344
+ trustPolicyPath: options.trustPolicyPath,
4345
+ ...(options.minimumTrustPolicySequence === undefined
4346
+ ? {}
4347
+ : {
4348
+ minimumTrustPolicySequence: options.minimumTrustPolicySequence,
4349
+ }),
4350
+ }),
4351
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
4352
+ };
4353
+ const report = await verifyNativeReleaseSignature(options.envelopeOnly
4354
+ ? { ...commonOptions, envelopeOnly: true }
4355
+ : {
4356
+ ...commonOptions,
4357
+ artifactPath: options.artifactPath,
4358
+ bundleManifestPath: options.bundleManifestPath,
4359
+ });
4360
+ process.stdout.write(options.json
4361
+ ? `${JSON.stringify(report, null, 2)}\n`
4362
+ : `${formatNativeReleaseSignatureVerification(report)}\n`);
4363
+ if (!report.ok)
4364
+ process.exitCode = 1;
4365
+ return;
4366
+ }
4367
+ throw new TypeError("release requires verify-android-signing, create, sign, signing-request, assemble-signature, correlate-device-proof, verify, verify-signature, or symbolication.");
4368
+ }
4369
+ if (command === "run") {
4370
+ const options = parseRunArguments(args.slice(1));
4371
+ if (options === undefined)
4372
+ return;
4373
+ const plan = await createNativeRunPlan({
4374
+ platform: options.platform,
4375
+ forwardedArgs: options.forwardedArgs,
4376
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
4377
+ });
4378
+ if (options.dryRun) {
4379
+ process.stdout.write(options.json
4380
+ ? `${JSON.stringify(plan, null, 2)}\n`
4381
+ : `Project: ${plan.projectRoot}\nCommand: ${formatNativeRunPlan(plan)}\n`);
4382
+ return;
4383
+ }
4384
+ process.exitCode = await executeNativeRunPlan(plan);
4385
+ return;
4386
+ }
4387
+ if (command === "logs") {
4388
+ const options = parseLogsArguments(args.slice(1));
4389
+ if (options === undefined)
4390
+ return;
4391
+ if (options.platform === "ios") {
4392
+ const plan = await createNativeIosLogsPlan({
4393
+ bundleIdentifier: options.bundleIdentifier,
4394
+ device: options.device,
4395
+ restart: options.restart,
4396
+ });
4397
+ if (options.dryRun) {
4398
+ process.stdout.write(options.json
4399
+ ? `${JSON.stringify(plan, null, 2)}\n`
4400
+ : `Device: ${plan.device}\nApplication: ${plan.application.name} ${plan.application.version} (${plan.bundleIdentifier})\nRestarts application: yes\nHistorical logs: no\nCommand: ${formatNativeIosLogsPlan(plan)}\n`);
4401
+ return;
4402
+ }
4403
+ process.stderr.write(`Restarting ${plan.bundleIdentifier} on ${plan.device} and streaming its launch console; Ctrl-C stops the app and stream.\n`);
4404
+ process.exitCode = await executeNativeIosLogsPlan(plan);
4405
+ return;
4406
+ }
4407
+ const plan = await createNativeAndroidLogsPlan({
4408
+ packageName: options.packageName,
4409
+ ...(options.serial === undefined ? {} : { serial: options.serial }),
4410
+ ...(options.since === undefined ? {} : { since: options.since }),
4411
+ });
4412
+ if (options.dryRun) {
4413
+ process.stdout.write(options.json
4414
+ ? `${JSON.stringify(plan, null, 2)}\n`
4415
+ : `Device: ${plan.serial}\nPackage: ${plan.packageName} (UID ${String(plan.uid)})\nCommand: ${formatNativeAndroidLogsPlan(plan)}\n`);
4416
+ return;
4417
+ }
4418
+ process.stderr.write(`Streaming ${plan.packageName} on ${plan.serial} (UID ${String(plan.uid)}); press Ctrl-C to stop.\n`);
4419
+ process.exitCode = await executeNativeAndroidLogsPlan(plan);
4420
+ return;
4421
+ }
4422
+ if (command === "open") {
4423
+ const options = parseOpenArguments(args.slice(1));
4424
+ if (options === undefined)
4425
+ return;
4426
+ const plan = options.platform === "android"
4427
+ ? await createNativeDeepLinkPlan({
4428
+ platform: "android",
4429
+ packageName: options.packageName,
4430
+ url: options.url,
4431
+ cold: options.cold,
4432
+ ...(options.serial === undefined ? {} : { serial: options.serial }),
4433
+ })
4434
+ : await createNativeDeepLinkPlan({
4435
+ platform: "ios",
4436
+ bundleIdentifier: options.bundleIdentifier,
4437
+ device: options.device,
4438
+ url: options.url,
4439
+ cold: options.cold,
4440
+ });
4441
+ if (options.dryRun) {
4442
+ process.stdout.write(options.json
4443
+ ? `${JSON.stringify(plan, null, 2)}\n`
4444
+ : `Device: ${plan.platform === "android" ? plan.serial : plan.device}\nApplication: ${plan.platform === "android" ? plan.packageName : `${plan.application.name} ${plan.application.version} (${plan.bundleIdentifier})`}\nMode: ${plan.mode}\nCommand: ${formatNativeDeepLinkPlan(plan)}\n`);
4445
+ return;
4446
+ }
4447
+ const result = await executeNativeDeepLinkPlan(plan);
4448
+ process.stdout.write(options.json
4449
+ ? `${JSON.stringify(result, null, 2)}\n`
4450
+ : result.platform === "android"
4451
+ ? `Opened ${result.url} in ${result.activity} on ${result.serial} (${result.launchState}, ${result.mode}).\n`
4452
+ : `Opened ${result.url} in ${result.bundleIdentifier} on ${result.device} (PID ${String(result.processIdentifier)}, ${result.mode}).\n`);
4453
+ return;
4454
+ }
4455
+ if (command === "start") {
4456
+ const options = parseStartArguments(args.slice(1));
4457
+ if (options === undefined)
4458
+ return;
4459
+ const plan = await createNativeStartPlan({
4460
+ forwardedArgs: options.forwardedArgs,
4461
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
4462
+ });
4463
+ if (options.dryRun) {
4464
+ process.stdout.write(options.json
4465
+ ? `${JSON.stringify(plan, null, 2)}\n`
4466
+ : `Project: ${plan.projectRoot}\nCommand: ${formatNativeStartPlan(plan)}\n`);
4467
+ return;
4468
+ }
4469
+ process.exitCode = await executeNativeStartPlan(plan);
4470
+ return;
4471
+ }
4472
+ if (command === "test") {
4473
+ const options = parseTestArguments(args.slice(1));
4474
+ if (options === undefined)
4475
+ return;
4476
+ const plan = await createNativeTestPlan({
4477
+ paths: options.paths,
4478
+ runtime: options.runtime,
4479
+ watch: options.watch,
4480
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
4481
+ ...(options.testNamePattern === undefined
4482
+ ? {}
4483
+ : { testNamePattern: options.testNamePattern }),
4484
+ });
4485
+ if (options.dryRun) {
4486
+ process.stdout.write(options.json
4487
+ ? `${JSON.stringify(plan, null, 2)}\n`
4488
+ : `Project: ${plan.projectRoot}\nRuntime: ${plan.runtime}\nTests: ${plan.testFiles.map((file) => path.relative(plan.projectRoot, file)).join(", ")}\nCommand: ${formatNativeTestPlan(plan)}\n`);
4489
+ return;
4490
+ }
4491
+ process.exitCode = await executeNativeTestPlan(plan);
4492
+ return;
4493
+ }
4494
+ if (command === "upgrade") {
4495
+ const options = parseUpgradeArguments(args.slice(1));
4496
+ if (options === undefined)
4497
+ return;
4498
+ const report = await auditNativeReactNativeUpgrade({
4499
+ candidate: options.candidate,
4500
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
4501
+ });
4502
+ process.stdout.write(options.json
4503
+ ? `${JSON.stringify(report, null, 2)}\n`
4504
+ : `${formatNativeReactNativeUpgradeReport(report)}\n`);
4505
+ if (!report.ok)
4506
+ process.exitCode = 1;
4507
+ return;
4508
+ }
4509
+ if (command !== "doctor") {
4510
+ throw new TypeError(`Unknown command ${command}. Run solid-native --help.`);
4511
+ }
4512
+ const options = parseDoctorArguments(args.slice(1));
4513
+ if (args.includes("--help") || args.includes("-h"))
4514
+ return;
4515
+ const report = await runDoctor({
4516
+ platform: options.platform,
4517
+ ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
4518
+ });
4519
+ process.stdout.write(options.json
4520
+ ? `${JSON.stringify(report, null, 2)}\n`
4521
+ : `${formatDoctorReport(report)}\n`);
4522
+ if (!report.ok || (options.strict && report.summary.warn > 0)) {
4523
+ process.exitCode = 1;
4524
+ }
4525
+ }
4526
+ main(process.argv.slice(2)).catch((error) => {
4527
+ process.stderr.write(`solid-native: ${terminalSafeErrorMessage(error)}\n`);
4528
+ process.exitCode = 2;
4529
+ });
4530
+ //# sourceMappingURL=bin.js.map