@solidnative-dev/cli 0.0.0-stage → 0.1.0-beta.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.
- package/LICENSE +21 -0
- package/README.md +841 -2
- package/dist/android-apk-signing.d.ts +36 -0
- package/dist/android-apk-signing.d.ts.map +1 -0
- package/dist/android-apk-signing.js +292 -0
- package/dist/android-apk-signing.js.map +1 -0
- package/dist/android-bundle-signing.d.ts +34 -0
- package/dist/android-bundle-signing.d.ts.map +1 -0
- package/dist/android-bundle-signing.js +167 -0
- package/dist/android-bundle-signing.js.map +1 -0
- package/dist/android-causal-debug.d.ts +38 -0
- package/dist/android-causal-debug.d.ts.map +1 -0
- package/dist/android-causal-debug.js +239 -0
- package/dist/android-causal-debug.js.map +1 -0
- package/dist/android-device-proof.d.ts +58 -0
- package/dist/android-device-proof.d.ts.map +1 -0
- package/dist/android-device-proof.js +554 -0
- package/dist/android-device-proof.js.map +1 -0
- package/dist/android-logs.d.ts +50 -0
- package/dist/android-logs.d.ts.map +1 -0
- package/dist/android-logs.js +253 -0
- package/dist/android-logs.js.map +1 -0
- package/dist/android-release-signing.d.ts +12 -0
- package/dist/android-release-signing.d.ts.map +1 -0
- package/dist/android-release-signing.js +165 -0
- package/dist/android-release-signing.js.map +1 -0
- package/dist/android-run-lease.d.ts +15 -0
- package/dist/android-run-lease.d.ts.map +1 -0
- package/dist/android-run-lease.js +333 -0
- package/dist/android-run-lease.js.map +1 -0
- package/dist/android-run-preflight.d.ts +45 -0
- package/dist/android-run-preflight.d.ts.map +1 -0
- package/dist/android-run-preflight.js +183 -0
- package/dist/android-run-preflight.js.map +1 -0
- package/dist/android-signing-shared.d.ts +38 -0
- package/dist/android-signing-shared.d.ts.map +1 -0
- package/dist/android-signing-shared.js +210 -0
- package/dist/android-signing-shared.js.map +1 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +4530 -0
- package/dist/bin.js.map +1 -0
- package/dist/bundle-artifacts.d.ts +48 -0
- package/dist/bundle-artifacts.d.ts.map +1 -0
- package/dist/bundle-artifacts.js +427 -0
- package/dist/bundle-artifacts.js.map +1 -0
- package/dist/causal-debug-compare.d.ts +81 -0
- package/dist/causal-debug-compare.d.ts.map +1 -0
- package/dist/causal-debug-compare.js +238 -0
- package/dist/causal-debug-compare.js.map +1 -0
- package/dist/causal-debug-report.d.ts +33 -0
- package/dist/causal-debug-report.d.ts.map +1 -0
- package/dist/causal-debug-report.js +979 -0
- package/dist/causal-debug-report.js.map +1 -0
- package/dist/causal-debug-watch.d.ts +33 -0
- package/dist/causal-debug-watch.d.ts.map +1 -0
- package/dist/causal-debug-watch.js +92 -0
- package/dist/causal-debug-watch.js.map +1 -0
- package/dist/causal-debug.d.ts +131 -0
- package/dist/causal-debug.d.ts.map +1 -0
- package/dist/causal-debug.js +503 -0
- package/dist/causal-debug.js.map +1 -0
- package/dist/compatibility-catalog.d.ts +88 -0
- package/dist/compatibility-catalog.d.ts.map +1 -0
- package/dist/compatibility-catalog.js +344 -0
- package/dist/compatibility-catalog.js.map +1 -0
- package/dist/deep-link.d.ts +90 -0
- package/dist/deep-link.d.ts.map +1 -0
- package/dist/deep-link.js +346 -0
- package/dist/deep-link.js.map +1 -0
- package/dist/device-proof-signatures.d.ts +307 -0
- package/dist/device-proof-signatures.d.ts.map +1 -0
- package/dist/device-proof-signatures.js +1024 -0
- package/dist/device-proof-signatures.js.map +1 -0
- package/dist/fingerprint.d.ts +35 -0
- package/dist/fingerprint.d.ts.map +1 -0
- package/dist/fingerprint.js +454 -0
- package/dist/fingerprint.js.map +1 -0
- package/dist/index.d.ts +388 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2996 -0
- package/dist/index.js.map +1 -0
- package/dist/ios-causal-debug.d.ts +39 -0
- package/dist/ios-causal-debug.d.ts.map +1 -0
- package/dist/ios-causal-debug.js +318 -0
- package/dist/ios-causal-debug.js.map +1 -0
- package/dist/ios-logs.d.ts +58 -0
- package/dist/ios-logs.d.ts.map +1 -0
- package/dist/ios-logs.js +269 -0
- package/dist/ios-logs.js.map +1 -0
- package/dist/ios-process.d.ts +69 -0
- package/dist/ios-process.d.ts.map +1 -0
- package/dist/ios-process.js +389 -0
- package/dist/ios-process.js.map +1 -0
- package/dist/ios-run-preflight.d.ts +35 -0
- package/dist/ios-run-preflight.d.ts.map +1 -0
- package/dist/ios-run-preflight.js +172 -0
- package/dist/ios-run-preflight.js.map +1 -0
- package/dist/live-causal-debug-report.d.ts +49 -0
- package/dist/live-causal-debug-report.d.ts.map +1 -0
- package/dist/live-causal-debug-report.js +123 -0
- package/dist/live-causal-debug-report.js.map +1 -0
- package/dist/local-symbolication.d.ts +35 -0
- package/dist/local-symbolication.d.ts.map +1 -0
- package/dist/local-symbolication.js +89 -0
- package/dist/local-symbolication.js.map +1 -0
- package/dist/native-archive.d.ts +15 -0
- package/dist/native-archive.d.ts.map +1 -0
- package/dist/native-archive.js +441 -0
- package/dist/native-archive.js.map +1 -0
- package/dist/native-test.d.ts +43 -0
- package/dist/native-test.d.ts.map +1 -0
- package/dist/native-test.js +209 -0
- package/dist/native-test.js.map +1 -0
- package/dist/package-add.d.ts +56 -0
- package/dist/package-add.d.ts.map +1 -0
- package/dist/package-add.js +764 -0
- package/dist/package-add.js.map +1 -0
- package/dist/react-native-upgrade.d.ts +96 -0
- package/dist/react-native-upgrade.d.ts.map +1 -0
- package/dist/react-native-upgrade.js +882 -0
- package/dist/react-native-upgrade.js.map +1 -0
- package/dist/release-device-correlation.d.ts +40 -0
- package/dist/release-device-correlation.d.ts.map +1 -0
- package/dist/release-device-correlation.js +113 -0
- package/dist/release-device-correlation.js.map +1 -0
- package/dist/release-signatures.d.ts +168 -0
- package/dist/release-signatures.d.ts.map +1 -0
- package/dist/release-signatures.js +677 -0
- package/dist/release-signatures.js.map +1 -0
- package/dist/release.d.ts +88 -0
- package/dist/release.d.ts.map +1 -0
- package/dist/release.js +771 -0
- package/dist/release.js.map +1 -0
- package/dist/signature-utilities.d.ts +16 -0
- package/dist/signature-utilities.d.ts.map +1 -0
- package/dist/signature-utilities.js +114 -0
- package/dist/signature-utilities.js.map +1 -0
- package/dist/solid-diagnostics-correlation.d.ts +11 -0
- package/dist/solid-diagnostics-correlation.d.ts.map +1 -0
- package/dist/solid-diagnostics-correlation.js +78 -0
- package/dist/solid-diagnostics-correlation.js.map +1 -0
- package/dist/solid-diagnostics-debug.d.ts +15 -0
- package/dist/solid-diagnostics-debug.d.ts.map +1 -0
- package/dist/solid-diagnostics-debug.js +93 -0
- package/dist/solid-diagnostics-debug.js.map +1 -0
- package/dist/solid-diagnostics-inspection.d.ts +41 -0
- package/dist/solid-diagnostics-inspection.d.ts.map +1 -0
- package/dist/solid-diagnostics-inspection.js +196 -0
- package/dist/solid-diagnostics-inspection.js.map +1 -0
- package/dist/source-map.d.ts +36 -0
- package/dist/source-map.d.ts.map +1 -0
- package/dist/source-map.js +488 -0
- package/dist/source-map.js.map +1 -0
- package/dist/stack-symbolication.d.ts +56 -0
- package/dist/stack-symbolication.d.ts.map +1 -0
- package/dist/stack-symbolication.js +310 -0
- package/dist/stack-symbolication.js.map +1 -0
- package/dist/symbolication.d.ts +27 -0
- package/dist/symbolication.d.ts.map +1 -0
- package/dist/symbolication.js +75 -0
- package/dist/symbolication.js.map +1 -0
- package/dist/tree-debug.d.ts +53 -0
- package/dist/tree-debug.d.ts.map +1 -0
- package/dist/tree-debug.js +283 -0
- package/dist/tree-debug.js.map +1 -0
- package/dist/versions.d.ts +13 -0
- package/dist/versions.d.ts.map +1 -0
- package/dist/versions.js +14 -0
- package/dist/versions.js.map +1 -0
- package/package.json +46 -3
- package/templates/react-native-0.88/README.md +328 -0
- package/templates/react-native-0.88/android/CMakeLists.txt +27 -0
- package/templates/react-native-0.88/android/MainActivity.kt +123 -0
- package/templates/react-native-0.88/android/MainApplication.kt +43 -0
- package/templates/react-native-0.88/android/OnLoad.cpp +60 -0
- package/templates/react-native-0.88/index.js +1 -0
- package/templates/react-native-0.88/ios/AppDelegate.swift +190 -0
- package/templates/react-native-0.88/metro.config.js +16 -0
- package/templates/react-native-0.88/specs/NativeSolidNativeDebug.ts +16 -0
- package/templates/react-native-0.88/specs/NativeSolidNativePlatformAndroid.ts +14 -0
- package/templates/react-native-0.88/src/App.tsx +161 -0
- package/templates/react-native-0.88/src/main.tsx +88 -0
- package/templates/react-native-0.88/test/App.test.tsx +152 -0
|
@@ -0,0 +1,882 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { access, readFile, readdir } from "node:fs/promises";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { REACT_NATIVE_0_88_RELEASE } from "@solidnative-dev/react-native-compat";
|
|
6
|
+
const EXACT_VERSION = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/u;
|
|
7
|
+
const MAX_COMPILER_OUTPUT = 64 * 1024;
|
|
8
|
+
const COMPILER_TIMEOUT_MS = 8_000;
|
|
9
|
+
const EXTERNAL_NATIVE_HEADER_PREFIXES = Object.freeze(["fbjni/", "folly/"]);
|
|
10
|
+
const QUALIFICATION_GATES = Object.freeze([
|
|
11
|
+
{
|
|
12
|
+
id: "repository",
|
|
13
|
+
scope: "repository",
|
|
14
|
+
description: "Rebuild the complete workspace, package artifacts, type checks, tests, and architecture/boundary verifiers from the candidate lockfile.",
|
|
15
|
+
commands: ["pnpm ci:verify"],
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
id: "android-release",
|
|
19
|
+
scope: "android",
|
|
20
|
+
description: "Compile and link a clean Android Release, then inspect the packaged Hermes bundle before launch.",
|
|
21
|
+
commands: [
|
|
22
|
+
"pnpm --filter @solidnative-dev/native-e2e android:assemble",
|
|
23
|
+
"pnpm --filter @solidnative-dev/native-e2e bundle:verify:android",
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: "ios-release",
|
|
28
|
+
scope: "ios",
|
|
29
|
+
description: "Regenerate CocoaPods and complete a signed, non-simulator iOS Release build.",
|
|
30
|
+
commands: [
|
|
31
|
+
"pnpm --filter @solidnative-dev/native-e2e ios:pods",
|
|
32
|
+
"pnpm --filter @solidnative-dev/native-e2e ios:release",
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: "ordinary-device-launches",
|
|
37
|
+
scope: "cross-platform",
|
|
38
|
+
description: "Cold-launch ordinary Release applications on physical Android and iOS devices and prove mount, measure, event delivery, quiescence, and teardown.",
|
|
39
|
+
commands: [
|
|
40
|
+
"pnpm --filter @solidnative-dev/native-e2e android:launch:test",
|
|
41
|
+
"pnpm --filter @solidnative-dev/native-e2e ios:test",
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: "navigation-restoration",
|
|
46
|
+
scope: "cross-platform",
|
|
47
|
+
description: "Rerun native stack, modal/sheet, tab, cold-link, and process-restoration proofs on both platforms.",
|
|
48
|
+
commands: [
|
|
49
|
+
"pnpm --filter @solidnative-dev/native-e2e android:navigation:restoration:test",
|
|
50
|
+
"pnpm --filter @solidnative-dev/native-e2e android:navigation:modal-stack:test",
|
|
51
|
+
"pnpm --filter @solidnative-dev/native-e2e android:tabs:test",
|
|
52
|
+
"pnpm --filter @solidnative-dev/native-e2e ios:navigation:restoration:test",
|
|
53
|
+
"pnpm --filter @solidnative-dev/native-e2e ios:navigation:modal:test",
|
|
54
|
+
"pnpm --filter @solidnative-dev/native-e2e ios:navigation:sheet:test",
|
|
55
|
+
"pnpm --filter @solidnative-dev/native-e2e ios:tabs:test",
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
id: "native-capabilities",
|
|
60
|
+
scope: "cross-platform",
|
|
61
|
+
description: "Exercise representative TurboModules, generated components, native resources, lifecycle, reload, cancellation, and memory-pressure behavior.",
|
|
62
|
+
commands: [],
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: "performance-and-memory",
|
|
66
|
+
scope: "cross-platform",
|
|
67
|
+
description: "Collect new matched performance, sustained telemetry, thermal, and memory evidence; do not inherit measurements from the prior backend.",
|
|
68
|
+
commands: ["pnpm benchmark"],
|
|
69
|
+
},
|
|
70
|
+
]);
|
|
71
|
+
function isRecord(value) {
|
|
72
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
73
|
+
}
|
|
74
|
+
function stringRecord(value) {
|
|
75
|
+
if (!isRecord(value))
|
|
76
|
+
return undefined;
|
|
77
|
+
const result = {};
|
|
78
|
+
for (const [name, entry] of Object.entries(value)) {
|
|
79
|
+
if (typeof entry === "string")
|
|
80
|
+
result[name] = entry;
|
|
81
|
+
}
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
function parseManifest(source, label) {
|
|
85
|
+
const value = JSON.parse(source);
|
|
86
|
+
if (!isRecord(value))
|
|
87
|
+
throw new TypeError(`${label} must contain an object.`);
|
|
88
|
+
const dependencies = stringRecord(value.dependencies);
|
|
89
|
+
const devDependencies = stringRecord(value.devDependencies);
|
|
90
|
+
const peerDependencies = stringRecord(value.peerDependencies);
|
|
91
|
+
return {
|
|
92
|
+
...(typeof value.name === "string" ? { name: value.name } : {}),
|
|
93
|
+
...(typeof value.version === "string" ? { version: value.version } : {}),
|
|
94
|
+
...(dependencies === undefined ? {} : { dependencies }),
|
|
95
|
+
...(devDependencies === undefined ? {} : { devDependencies }),
|
|
96
|
+
...(peerDependencies === undefined ? {} : { peerDependencies }),
|
|
97
|
+
...(isRecord(value.exports) ? { exports: value.exports } : {}),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function declaredVersion(manifest, packageName) {
|
|
101
|
+
return (manifest.dependencies?.[packageName] ??
|
|
102
|
+
manifest.devDependencies?.[packageName] ??
|
|
103
|
+
manifest.peerDependencies?.[packageName]);
|
|
104
|
+
}
|
|
105
|
+
async function defaultPathExists(target) {
|
|
106
|
+
try {
|
|
107
|
+
await access(target);
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function defaultRunCompiler(compilerPath, cwd) {
|
|
115
|
+
return new Promise((resolve) => {
|
|
116
|
+
let stdout = "";
|
|
117
|
+
let stderr = "";
|
|
118
|
+
let settled = false;
|
|
119
|
+
const child = spawn(compilerPath, ["-version"], {
|
|
120
|
+
cwd,
|
|
121
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
122
|
+
});
|
|
123
|
+
const append = (current, chunk) => `${current}${chunk.toString("utf8")}`.slice(-MAX_COMPILER_OUTPUT);
|
|
124
|
+
child.stdout.on("data", (chunk) => {
|
|
125
|
+
stdout = append(stdout, chunk);
|
|
126
|
+
});
|
|
127
|
+
child.stderr.on("data", (chunk) => {
|
|
128
|
+
stderr = append(stderr, chunk);
|
|
129
|
+
});
|
|
130
|
+
const finish = (result) => {
|
|
131
|
+
if (settled)
|
|
132
|
+
return;
|
|
133
|
+
settled = true;
|
|
134
|
+
clearTimeout(timer);
|
|
135
|
+
resolve(result);
|
|
136
|
+
};
|
|
137
|
+
const timer = setTimeout(() => {
|
|
138
|
+
child.kill("SIGTERM");
|
|
139
|
+
finish({ exitCode: null, stdout, stderr: `${stderr}\nTimed out.` });
|
|
140
|
+
}, COMPILER_TIMEOUT_MS);
|
|
141
|
+
child.on("error", (error) => {
|
|
142
|
+
finish({
|
|
143
|
+
exitCode: null,
|
|
144
|
+
stdout,
|
|
145
|
+
stderr: `${stderr}\n${error.message}`,
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
child.on("close", (exitCode) => finish({ exitCode, stdout, stderr }));
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
function dependencies(overrides) {
|
|
152
|
+
return {
|
|
153
|
+
hostPlatform: overrides?.hostPlatform ?? process.platform,
|
|
154
|
+
pathExists: overrides?.pathExists ?? defaultPathExists,
|
|
155
|
+
readTextFile: overrides?.readTextFile ?? ((target) => readFile(target, "utf8")),
|
|
156
|
+
runCompiler: overrides?.runCompiler ?? defaultRunCompiler,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
async function findProjectRoot(start, pathExists) {
|
|
160
|
+
let current = path.resolve(start);
|
|
161
|
+
while (true) {
|
|
162
|
+
if (await pathExists(path.join(current, "package.json")))
|
|
163
|
+
return current;
|
|
164
|
+
const parent = path.dirname(current);
|
|
165
|
+
if (parent === current) {
|
|
166
|
+
throw new TypeError(`No package.json was found at or above ${start}.`);
|
|
167
|
+
}
|
|
168
|
+
current = parent;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
async function findAncestorFile(start, name, pathExists) {
|
|
172
|
+
let current = path.resolve(start);
|
|
173
|
+
while (true) {
|
|
174
|
+
const candidate = path.join(current, name);
|
|
175
|
+
if (await pathExists(candidate))
|
|
176
|
+
return candidate;
|
|
177
|
+
const parent = path.dirname(current);
|
|
178
|
+
if (parent === current)
|
|
179
|
+
return undefined;
|
|
180
|
+
current = parent;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
async function findInstalledManifest(projectRoot, packageName, deps) {
|
|
184
|
+
let current = projectRoot;
|
|
185
|
+
while (true) {
|
|
186
|
+
const manifestPath = path.join(current, "node_modules", packageName, "package.json");
|
|
187
|
+
if (await deps.pathExists(manifestPath)) {
|
|
188
|
+
return {
|
|
189
|
+
manifestPath,
|
|
190
|
+
packageRoot: path.dirname(manifestPath),
|
|
191
|
+
manifest: parseManifest(await deps.readTextFile(manifestPath), `${packageName}/package.json`),
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
const parent = path.dirname(current);
|
|
195
|
+
if (parent === current)
|
|
196
|
+
return undefined;
|
|
197
|
+
current = parent;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
function exactVersion(value, packageName, projectLabel, checks) {
|
|
201
|
+
if (value !== undefined && EXACT_VERSION.test(value))
|
|
202
|
+
return true;
|
|
203
|
+
checks.push({
|
|
204
|
+
id: `${projectLabel}.${packageName}.declaration`,
|
|
205
|
+
label: `${projectLabel} ${packageName}`,
|
|
206
|
+
status: "fail",
|
|
207
|
+
message: value === undefined
|
|
208
|
+
? `${packageName} is not declared.`
|
|
209
|
+
: `${packageName} is declared as ${value}, not an exact release.`,
|
|
210
|
+
remediation: `Pin ${packageName} to one exact installed release for a reproducible backend audit.`,
|
|
211
|
+
});
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
function normalizedPackageVersion(value) {
|
|
215
|
+
return /^(\d+)\.(\d+)\.(\d+)/u.exec(value)?.slice(1, 4).join(".");
|
|
216
|
+
}
|
|
217
|
+
function parseRuntimeVersion(source) {
|
|
218
|
+
const major = /#define\s+REACT_NATIVE_VERSION_MAJOR\s+(\d+)/u.exec(source)?.[1];
|
|
219
|
+
const minor = /#define\s+REACT_NATIVE_VERSION_MINOR\s+(\d+)/u.exec(source)?.[1];
|
|
220
|
+
const patch = /#define\s+REACT_NATIVE_VERSION_PATCH\s+(\d+)/u.exec(source)?.[1];
|
|
221
|
+
return major === undefined || minor === undefined || patch === undefined
|
|
222
|
+
? undefined
|
|
223
|
+
: `${major}.${minor}.${patch}`;
|
|
224
|
+
}
|
|
225
|
+
function hermesCompilerPath(compilerRoot, hostPlatform) {
|
|
226
|
+
const relative = hostPlatform === "darwin"
|
|
227
|
+
? ["hermesc", "osx-bin", "hermesc"]
|
|
228
|
+
: hostPlatform === "linux"
|
|
229
|
+
? ["hermesc", "linux64-bin", "hermesc"]
|
|
230
|
+
: hostPlatform === "win32"
|
|
231
|
+
? ["hermesc", "win64-bin", "hermesc.exe"]
|
|
232
|
+
: undefined;
|
|
233
|
+
return relative === undefined
|
|
234
|
+
? undefined
|
|
235
|
+
: path.join(compilerRoot, ...relative);
|
|
236
|
+
}
|
|
237
|
+
function simpleSemverParts(value) {
|
|
238
|
+
const match = /^(\d+)\.(\d+)\.(\d+)/u.exec(value);
|
|
239
|
+
if (match === null)
|
|
240
|
+
return undefined;
|
|
241
|
+
return [Number(match[1]), Number(match[2]), Number(match[3])];
|
|
242
|
+
}
|
|
243
|
+
function compareParts(left, right) {
|
|
244
|
+
for (let index = 0; index < 3; index += 1) {
|
|
245
|
+
const difference = (left[index] ?? 0) - (right[index] ?? 0);
|
|
246
|
+
if (difference !== 0)
|
|
247
|
+
return difference;
|
|
248
|
+
}
|
|
249
|
+
return 0;
|
|
250
|
+
}
|
|
251
|
+
function satisfiesSimplePeer(version, range) {
|
|
252
|
+
const observed = simpleSemverParts(version);
|
|
253
|
+
if (observed === undefined)
|
|
254
|
+
return undefined;
|
|
255
|
+
if (EXACT_VERSION.test(range)) {
|
|
256
|
+
const required = simpleSemverParts(range);
|
|
257
|
+
return required === undefined
|
|
258
|
+
? undefined
|
|
259
|
+
: compareParts(observed, required) === 0;
|
|
260
|
+
}
|
|
261
|
+
const caret = /^\^(\d+)\.(\d+)\.(\d+)$/u.exec(range);
|
|
262
|
+
if (caret === null)
|
|
263
|
+
return undefined;
|
|
264
|
+
const required = [Number(caret[1]), Number(caret[2]), Number(caret[3])];
|
|
265
|
+
if (compareParts(observed, required) < 0)
|
|
266
|
+
return false;
|
|
267
|
+
if ((required[0] ?? 0) > 0)
|
|
268
|
+
return observed[0] === required[0];
|
|
269
|
+
if ((required[1] ?? 0) > 0) {
|
|
270
|
+
return observed[0] === 0 && observed[1] === required[1];
|
|
271
|
+
}
|
|
272
|
+
return observed[0] === 0 && observed[1] === 0 && observed[2] === required[2];
|
|
273
|
+
}
|
|
274
|
+
async function inspectProject(start, projectLabel, deps, checks) {
|
|
275
|
+
const root = await findProjectRoot(start, deps.pathExists);
|
|
276
|
+
const manifest = parseManifest(await deps.readTextFile(path.join(root, "package.json")), `${projectLabel} package.json`);
|
|
277
|
+
const declaredReactNative = declaredVersion(manifest, "react-native");
|
|
278
|
+
const hasExactReactNative = exactVersion(declaredReactNative, "react-native", projectLabel, checks);
|
|
279
|
+
const reactNative = await findInstalledManifest(root, "react-native", deps);
|
|
280
|
+
if (reactNative === undefined) {
|
|
281
|
+
checks.push({
|
|
282
|
+
id: `${projectLabel}.react-native.installation`,
|
|
283
|
+
label: `${projectLabel} React Native installation`,
|
|
284
|
+
status: "fail",
|
|
285
|
+
message: "react-native is not installed for this project.",
|
|
286
|
+
remediation: "Install the candidate lockfile before running the upgrade audit.",
|
|
287
|
+
});
|
|
288
|
+
return undefined;
|
|
289
|
+
}
|
|
290
|
+
const packageVersion = reactNative.manifest.version;
|
|
291
|
+
if (!hasExactReactNative ||
|
|
292
|
+
packageVersion === undefined ||
|
|
293
|
+
packageVersion !== declaredReactNative) {
|
|
294
|
+
checks.push({
|
|
295
|
+
id: `${projectLabel}.react-native.identity`,
|
|
296
|
+
label: `${projectLabel} React Native identity`,
|
|
297
|
+
status: "fail",
|
|
298
|
+
message: `The application declares ${String(declaredReactNative)} and resolves ${String(packageVersion)}.`,
|
|
299
|
+
remediation: "Reinstall from the candidate lockfile and require an exact declaration/install match.",
|
|
300
|
+
});
|
|
301
|
+
return { root, manifest, reactNative };
|
|
302
|
+
}
|
|
303
|
+
checks.push({
|
|
304
|
+
id: `${projectLabel}.react-native.identity`,
|
|
305
|
+
label: `${projectLabel} React Native identity`,
|
|
306
|
+
status: "pass",
|
|
307
|
+
message: `The exact ${packageVersion} package is declared and installed.`,
|
|
308
|
+
});
|
|
309
|
+
const runtimeHeader = path.join(reactNative.packageRoot, "ReactCommon", "cxxreact", "ReactNativeVersion.h");
|
|
310
|
+
let runtimeVersion;
|
|
311
|
+
try {
|
|
312
|
+
runtimeVersion = parseRuntimeVersion(await deps.readTextFile(runtimeHeader));
|
|
313
|
+
}
|
|
314
|
+
catch {
|
|
315
|
+
runtimeVersion = undefined;
|
|
316
|
+
}
|
|
317
|
+
const normalized = normalizedPackageVersion(packageVersion);
|
|
318
|
+
if (runtimeVersion === undefined || normalized !== runtimeVersion) {
|
|
319
|
+
checks.push({
|
|
320
|
+
id: `${projectLabel}.react-native.runtime`,
|
|
321
|
+
label: `${projectLabel} native runtime identity`,
|
|
322
|
+
status: "fail",
|
|
323
|
+
message: runtimeVersion === undefined
|
|
324
|
+
? "ReactNativeVersion.h is missing or unreadable."
|
|
325
|
+
: `Package ${packageVersion} normalizes to ${String(normalized)}, but native headers expose ${runtimeVersion}.`,
|
|
326
|
+
remediation: "Keep npm release and normalized native runtime identities separate and verify their intended pairing.",
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
330
|
+
checks.push({
|
|
331
|
+
id: `${projectLabel}.react-native.runtime`,
|
|
332
|
+
label: `${projectLabel} native runtime identity`,
|
|
333
|
+
status: "pass",
|
|
334
|
+
message: `Package ${packageVersion} maps explicitly to native runtime ${runtimeVersion}.`,
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
const requiredHermes = reactNative.manifest.dependencies?.["hermes-compiler"];
|
|
338
|
+
const declaredHermes = declaredVersion(manifest, "hermes-compiler");
|
|
339
|
+
const compiler = await findInstalledManifest(root, "hermes-compiler", deps);
|
|
340
|
+
const installedHermes = compiler?.manifest.version;
|
|
341
|
+
let bytecodeVersion;
|
|
342
|
+
if (requiredHermes === undefined ||
|
|
343
|
+
!EXACT_VERSION.test(requiredHermes) ||
|
|
344
|
+
declaredHermes !== requiredHermes ||
|
|
345
|
+
installedHermes !== requiredHermes ||
|
|
346
|
+
compiler === undefined) {
|
|
347
|
+
checks.push({
|
|
348
|
+
id: `${projectLabel}.hermes.pair`,
|
|
349
|
+
label: `${projectLabel} Hermes pair`,
|
|
350
|
+
status: "fail",
|
|
351
|
+
message: `React Native requires ${String(requiredHermes)}, the app declares ${String(declaredHermes)}, and ${String(installedHermes)} is installed.`,
|
|
352
|
+
remediation: "Directly pin the exact hermes-compiler dependency declared by the installed react-native package.",
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
const compilerPath = hermesCompilerPath(compiler.packageRoot, deps.hostPlatform);
|
|
357
|
+
if (compilerPath === undefined || !(await deps.pathExists(compilerPath))) {
|
|
358
|
+
checks.push({
|
|
359
|
+
id: `${projectLabel}.hermes.pair`,
|
|
360
|
+
label: `${projectLabel} Hermes pair`,
|
|
361
|
+
status: "fail",
|
|
362
|
+
message: `hermes-compiler ${installedHermes} does not provide a compiler for ${deps.hostPlatform}.`,
|
|
363
|
+
remediation: "Install the complete compiler artifact on a supported host.",
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
else {
|
|
367
|
+
const result = await deps.runCompiler(compilerPath, root);
|
|
368
|
+
const output = `${result.stdout}\n${result.stderr}`;
|
|
369
|
+
const release = /Hermes release version:\s*([^\s]+)/u.exec(output)?.[1];
|
|
370
|
+
const bytecode = /HBC bytecode version:\s*(\d+)/u.exec(output)?.[1];
|
|
371
|
+
bytecodeVersion = bytecode === undefined ? undefined : Number(bytecode);
|
|
372
|
+
if (result.exitCode !== 0 ||
|
|
373
|
+
release !== installedHermes ||
|
|
374
|
+
!Number.isSafeInteger(bytecodeVersion)) {
|
|
375
|
+
checks.push({
|
|
376
|
+
id: `${projectLabel}.hermes.pair`,
|
|
377
|
+
label: `${projectLabel} Hermes pair`,
|
|
378
|
+
status: "fail",
|
|
379
|
+
message: `hermesc reports release ${String(release)} and HBC ${String(bytecodeVersion)} for package ${installedHermes}.`,
|
|
380
|
+
remediation: "Repair the compiler installation before any native build; successful compilation cannot prove bundle/runtime compatibility.",
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
checks.push({
|
|
385
|
+
id: `${projectLabel}.hermes.pair`,
|
|
386
|
+
label: `${projectLabel} Hermes pair`,
|
|
387
|
+
status: "pass",
|
|
388
|
+
message: `React Native, hermes-compiler ${installedHermes}, and hermesc HBC ${String(bytecodeVersion)} form one exact pair.`,
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
const declaredReact = declaredVersion(manifest, "react");
|
|
394
|
+
const installedReactManifest = await findInstalledManifest(root, "react", deps);
|
|
395
|
+
const installedReact = installedReactManifest?.manifest.version;
|
|
396
|
+
const reactPeerRange = reactNative.manifest.peerDependencies?.react;
|
|
397
|
+
const peerSatisfied = installedReact === undefined || reactPeerRange === undefined
|
|
398
|
+
? false
|
|
399
|
+
: satisfiesSimplePeer(installedReact, reactPeerRange);
|
|
400
|
+
if (declaredReact === undefined ||
|
|
401
|
+
!EXACT_VERSION.test(declaredReact) ||
|
|
402
|
+
installedReact !== declaredReact ||
|
|
403
|
+
reactPeerRange === undefined ||
|
|
404
|
+
peerSatisfied === false) {
|
|
405
|
+
checks.push({
|
|
406
|
+
id: `${projectLabel}.react.pair`,
|
|
407
|
+
label: `${projectLabel} React peer`,
|
|
408
|
+
status: "fail",
|
|
409
|
+
message: `React Native requests ${String(reactPeerRange)}; the app declares ${String(declaredReact)} and resolves ${String(installedReact)}.`,
|
|
410
|
+
remediation: "Pin one exact React release that satisfies the installed React Native peer range.",
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
else {
|
|
414
|
+
checks.push({
|
|
415
|
+
id: `${projectLabel}.react.pair`,
|
|
416
|
+
label: `${projectLabel} React peer`,
|
|
417
|
+
status: peerSatisfied === undefined ? "warn" : "pass",
|
|
418
|
+
message: peerSatisfied === undefined
|
|
419
|
+
? `React ${installedReact} is exact, but the audit cannot interpret peer range ${reactPeerRange}; review it explicitly.`
|
|
420
|
+
: `React ${installedReact} satisfies the React Native ${reactPeerRange} peer contract.`,
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
const companionVersions = {};
|
|
424
|
+
for (const packageName of [
|
|
425
|
+
"@react-native/codegen",
|
|
426
|
+
"@react-native/gradle-plugin",
|
|
427
|
+
]) {
|
|
428
|
+
const required = reactNative.manifest.dependencies?.[packageName];
|
|
429
|
+
const declared = declaredVersion(manifest, packageName);
|
|
430
|
+
const installed = await findInstalledManifest(root, packageName, deps);
|
|
431
|
+
const installedVersion = installed?.manifest.version;
|
|
432
|
+
if (required === undefined ||
|
|
433
|
+
!EXACT_VERSION.test(required) ||
|
|
434
|
+
declared !== required ||
|
|
435
|
+
installedVersion !== required) {
|
|
436
|
+
checks.push({
|
|
437
|
+
id: `${projectLabel}.${packageName}.pair`,
|
|
438
|
+
label: `${projectLabel} ${packageName} pair`,
|
|
439
|
+
status: "fail",
|
|
440
|
+
message: `React Native requires ${String(required)}, the app declares ${String(declared)}, and ${String(installedVersion)} is installed.`,
|
|
441
|
+
remediation: `Pin the exact ${packageName} release declared by the installed react-native package.`,
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
else {
|
|
445
|
+
companionVersions[packageName] = installedVersion;
|
|
446
|
+
checks.push({
|
|
447
|
+
id: `${projectLabel}.${packageName}.pair`,
|
|
448
|
+
label: `${projectLabel} ${packageName} pair`,
|
|
449
|
+
status: "pass",
|
|
450
|
+
message: `${packageName} is exactly paired at ${installedVersion}.`,
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
const lockfilePath = await findAncestorFile(root, "pnpm-lock.yaml", deps.pathExists);
|
|
455
|
+
if (lockfilePath === undefined) {
|
|
456
|
+
checks.push({
|
|
457
|
+
id: `${projectLabel}.lockfile`,
|
|
458
|
+
label: `${projectLabel} lockfile`,
|
|
459
|
+
status: "fail",
|
|
460
|
+
message: "No pnpm-lock.yaml exists at or above the project.",
|
|
461
|
+
remediation: "Install and commit one candidate lockfile before comparing native compatibility.",
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
const metro = await findInstalledManifest(root, "metro-transform-worker", deps);
|
|
465
|
+
if (runtimeVersion === undefined ||
|
|
466
|
+
requiredHermes === undefined ||
|
|
467
|
+
bytecodeVersion === undefined ||
|
|
468
|
+
installedReact === undefined ||
|
|
469
|
+
reactPeerRange === undefined ||
|
|
470
|
+
companionVersions["@react-native/codegen"] === undefined ||
|
|
471
|
+
companionVersions["@react-native/gradle-plugin"] === undefined ||
|
|
472
|
+
lockfilePath === undefined) {
|
|
473
|
+
return { root, manifest, reactNative };
|
|
474
|
+
}
|
|
475
|
+
const lockfileSource = await deps.readTextFile(lockfilePath);
|
|
476
|
+
return {
|
|
477
|
+
root,
|
|
478
|
+
manifest,
|
|
479
|
+
reactNative,
|
|
480
|
+
identity: {
|
|
481
|
+
projectRoot: root,
|
|
482
|
+
packageVersion,
|
|
483
|
+
runtimeVersion,
|
|
484
|
+
hermesCompilerVersion: requiredHermes,
|
|
485
|
+
hermesBytecodeVersion: bytecodeVersion,
|
|
486
|
+
reactVersion: installedReact,
|
|
487
|
+
reactPeerRange,
|
|
488
|
+
codegenVersion: companionVersions["@react-native/codegen"],
|
|
489
|
+
gradlePluginVersion: companionVersions["@react-native/gradle-plugin"],
|
|
490
|
+
...(metro?.manifest.version === undefined
|
|
491
|
+
? {}
|
|
492
|
+
: { metroTransformWorkerVersion: metro.manifest.version }),
|
|
493
|
+
lockfilePath,
|
|
494
|
+
lockfileSha256: createHash("sha256").update(lockfileSource).digest("hex"),
|
|
495
|
+
},
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
function parseStringArray(value, field, allowEmpty) {
|
|
499
|
+
if (!Array.isArray(value) ||
|
|
500
|
+
(!allowEmpty && value.length === 0) ||
|
|
501
|
+
value.some((entry) => typeof entry !== "string" || entry.length === 0)) {
|
|
502
|
+
throw new TypeError(`${field} must be ${allowEmpty ? "an" : "a non-empty"} array of strings.`);
|
|
503
|
+
}
|
|
504
|
+
return value;
|
|
505
|
+
}
|
|
506
|
+
function parseBoundaryManifest(source) {
|
|
507
|
+
const value = JSON.parse(source);
|
|
508
|
+
if (!isRecord(value) || value.schemaVersion !== 1) {
|
|
509
|
+
throw new TypeError("The React Native boundary must use schemaVersion 1.");
|
|
510
|
+
}
|
|
511
|
+
if (typeof value.reactNativeVersion !== "string") {
|
|
512
|
+
throw new TypeError("reactNativeVersion must be a string.");
|
|
513
|
+
}
|
|
514
|
+
if (!Array.isArray(value.cocoapods) ||
|
|
515
|
+
value.cocoapods.some((entry) => !isRecord(entry) ||
|
|
516
|
+
typeof entry.name !== "string" ||
|
|
517
|
+
(entry.version !== null && typeof entry.version !== "string")) ||
|
|
518
|
+
!isRecord(value.androidCmake)) {
|
|
519
|
+
throw new TypeError("cocoapods entries and androidCmake must describe the native build boundary.");
|
|
520
|
+
}
|
|
521
|
+
return {
|
|
522
|
+
schemaVersion: 1,
|
|
523
|
+
reactNativeVersion: value.reactNativeVersion,
|
|
524
|
+
nativeHeaders: parseStringArray(value.nativeHeaders, "nativeHeaders", false),
|
|
525
|
+
generatedCodegenHeaders: parseStringArray(value.generatedCodegenHeaders, "generatedCodegenHeaders", true),
|
|
526
|
+
androidImports: parseStringArray(value.androidImports, "androidImports", true),
|
|
527
|
+
cocoapods: value.cocoapods,
|
|
528
|
+
androidCmake: {
|
|
529
|
+
reactNativeIncludeDirectories: parseStringArray(value.androidCmake.reactNativeIncludeDirectories, "androidCmake.reactNativeIncludeDirectories", false),
|
|
530
|
+
inheritedCompileOptions: parseStringArray(value.androidCmake.inheritedCompileOptions, "androidCmake.inheritedCompileOptions", true),
|
|
531
|
+
},
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
async function readBoundary(project, deps) {
|
|
535
|
+
const fabricHost = await findInstalledManifest(project.root, "@solidnative-dev/fabric-host", deps);
|
|
536
|
+
if (fabricHost === undefined) {
|
|
537
|
+
throw new TypeError("@solidnative-dev/fabric-host is not installed.");
|
|
538
|
+
}
|
|
539
|
+
const target = fabricHost.manifest.exports?.["./react-native-boundary"];
|
|
540
|
+
if (typeof target !== "string" || !target.startsWith("./")) {
|
|
541
|
+
throw new TypeError("@solidnative-dev/fabric-host does not expose ./react-native-boundary.");
|
|
542
|
+
}
|
|
543
|
+
const manifestPath = path.resolve(fabricHost.packageRoot, target);
|
|
544
|
+
const relative = path.relative(fabricHost.packageRoot, manifestPath);
|
|
545
|
+
if (relative === "" ||
|
|
546
|
+
relative === ".." ||
|
|
547
|
+
relative.startsWith(`..${path.sep}`)) {
|
|
548
|
+
throw new TypeError("The React Native boundary export leaves its package.");
|
|
549
|
+
}
|
|
550
|
+
return {
|
|
551
|
+
path: manifestPath,
|
|
552
|
+
manifest: parseBoundaryManifest(await deps.readTextFile(manifestPath)),
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
async function indexHeaderFiles(root, basenames) {
|
|
556
|
+
const found = new Map();
|
|
557
|
+
const visit = async (directory, depth) => {
|
|
558
|
+
if (depth > 24)
|
|
559
|
+
return;
|
|
560
|
+
const entries = await readdir(directory, { withFileTypes: true });
|
|
561
|
+
entries.sort((left, right) => left.name < right.name ? -1 : left.name > right.name ? 1 : 0);
|
|
562
|
+
for (const entry of entries) {
|
|
563
|
+
const target = path.join(directory, entry.name);
|
|
564
|
+
if (entry.isDirectory()) {
|
|
565
|
+
if (entry.name !== "node_modules")
|
|
566
|
+
await visit(target, depth + 1);
|
|
567
|
+
}
|
|
568
|
+
else if (entry.isFile() && basenames.has(entry.name)) {
|
|
569
|
+
const relative = path.relative(root, target).split(path.sep).join("/");
|
|
570
|
+
const list = found.get(entry.name) ?? [];
|
|
571
|
+
list.push(relative);
|
|
572
|
+
found.set(entry.name, list);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
};
|
|
576
|
+
await visit(root, 0);
|
|
577
|
+
return found;
|
|
578
|
+
}
|
|
579
|
+
function bestHeaderMatches(header, index) {
|
|
580
|
+
const basename = path.posix.basename(header);
|
|
581
|
+
const candidates = index.get(basename) ?? [];
|
|
582
|
+
const exactSuffix = candidates.filter((candidate) => candidate === header || candidate.endsWith(`/${header}`));
|
|
583
|
+
return exactSuffix.length > 0 ? exactSuffix : candidates;
|
|
584
|
+
}
|
|
585
|
+
async function headerDigest(root, relativePath, deps) {
|
|
586
|
+
return createHash("sha256")
|
|
587
|
+
.update(await deps.readTextFile(path.join(root, relativePath)))
|
|
588
|
+
.digest("hex");
|
|
589
|
+
}
|
|
590
|
+
async function auditBoundary(source, candidate, boundaryPath, sourceBoundary, candidateBoundary, deps) {
|
|
591
|
+
const addedHeaders = candidateBoundary.nativeHeaders.filter((header) => !sourceBoundary.nativeHeaders.includes(header));
|
|
592
|
+
const removedHeaders = sourceBoundary.nativeHeaders.filter((header) => !candidateBoundary.nativeHeaders.includes(header));
|
|
593
|
+
const basenames = new Set(candidateBoundary.nativeHeaders.map((header) => path.posix.basename(header)));
|
|
594
|
+
const [sourceIndex, candidateIndex] = await Promise.all([
|
|
595
|
+
indexHeaderFiles(source.reactNative.packageRoot, basenames),
|
|
596
|
+
indexHeaderFiles(candidate.reactNative.packageRoot, basenames),
|
|
597
|
+
]);
|
|
598
|
+
const deltas = [];
|
|
599
|
+
for (const header of candidateBoundary.nativeHeaders) {
|
|
600
|
+
const sourcePaths = bestHeaderMatches(header, sourceIndex);
|
|
601
|
+
const candidatePaths = bestHeaderMatches(header, candidateIndex);
|
|
602
|
+
let status;
|
|
603
|
+
if (addedHeaders.includes(header) && candidatePaths.length > 0) {
|
|
604
|
+
status = "added";
|
|
605
|
+
}
|
|
606
|
+
else if (sourcePaths.length === 0 &&
|
|
607
|
+
candidatePaths.length === 0 &&
|
|
608
|
+
EXTERNAL_NATIVE_HEADER_PREFIXES.some((prefix) => header.startsWith(prefix))) {
|
|
609
|
+
status = "external";
|
|
610
|
+
}
|
|
611
|
+
else if (sourcePaths.length === 0 || candidatePaths.length === 0) {
|
|
612
|
+
status = "missing";
|
|
613
|
+
}
|
|
614
|
+
else if (sourcePaths.length !== 1 || candidatePaths.length !== 1) {
|
|
615
|
+
status = "ambiguous";
|
|
616
|
+
}
|
|
617
|
+
else {
|
|
618
|
+
const [sourceDigest, candidateDigest] = await Promise.all([
|
|
619
|
+
headerDigest(source.reactNative.packageRoot, sourcePaths[0], deps),
|
|
620
|
+
headerDigest(candidate.reactNative.packageRoot, candidatePaths[0], deps),
|
|
621
|
+
]);
|
|
622
|
+
status =
|
|
623
|
+
sourceDigest !== candidateDigest
|
|
624
|
+
? "changed"
|
|
625
|
+
: sourcePaths[0] !== candidatePaths[0]
|
|
626
|
+
? "moved"
|
|
627
|
+
: "unchanged";
|
|
628
|
+
}
|
|
629
|
+
deltas.push({ header, status, sourcePaths, candidatePaths });
|
|
630
|
+
}
|
|
631
|
+
const headers = (status) => deltas
|
|
632
|
+
.filter((entry) => entry.status === status)
|
|
633
|
+
.map((entry) => entry.header);
|
|
634
|
+
return {
|
|
635
|
+
manifestPath: boundaryPath,
|
|
636
|
+
reactNativeVersion: candidateBoundary.reactNativeVersion,
|
|
637
|
+
nativeHeaderCount: candidateBoundary.nativeHeaders.length,
|
|
638
|
+
generatedCodegenHeaderCount: candidateBoundary.generatedCodegenHeaders.length,
|
|
639
|
+
androidImportCount: candidateBoundary.androidImports.length,
|
|
640
|
+
cocoapodCount: candidateBoundary.cocoapods.length,
|
|
641
|
+
headerDeltas: deltas,
|
|
642
|
+
addedHeaders,
|
|
643
|
+
removedHeaders,
|
|
644
|
+
changedHeaders: headers("changed"),
|
|
645
|
+
unchangedHeaders: headers("unchanged"),
|
|
646
|
+
movedHeaders: headers("moved"),
|
|
647
|
+
externalHeaders: headers("external"),
|
|
648
|
+
missingHeaders: headers("missing"),
|
|
649
|
+
ambiguousHeaders: headers("ambiguous"),
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
function compareIdentity(source, candidate, checks) {
|
|
653
|
+
checks.push(candidate.packageVersion === source.packageVersion
|
|
654
|
+
? {
|
|
655
|
+
id: "upgrade.release-change",
|
|
656
|
+
label: "Backend release change",
|
|
657
|
+
status: "warn",
|
|
658
|
+
message: `Source and candidate both use React Native ${candidate.packageVersion}; this is a consistency audit, not an upgrade.`,
|
|
659
|
+
}
|
|
660
|
+
: {
|
|
661
|
+
id: "upgrade.release-change",
|
|
662
|
+
label: "Backend release change",
|
|
663
|
+
status: "pass",
|
|
664
|
+
message: `The candidate changes React Native ${source.packageVersion} to ${candidate.packageVersion} and records runtime ${candidate.runtimeVersion} separately.`,
|
|
665
|
+
});
|
|
666
|
+
if (source.hermesCompilerVersion === candidate.hermesCompilerVersion &&
|
|
667
|
+
source.hermesBytecodeVersion === candidate.hermesBytecodeVersion) {
|
|
668
|
+
checks.push({
|
|
669
|
+
id: "upgrade.hermes-change",
|
|
670
|
+
label: "Hermes upgrade delta",
|
|
671
|
+
status: "pass",
|
|
672
|
+
message: `The candidate retains compiler ${candidate.hermesCompilerVersion} and HBC ${String(candidate.hermesBytecodeVersion)}.`,
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
else {
|
|
676
|
+
checks.push({
|
|
677
|
+
id: "upgrade.hermes-change",
|
|
678
|
+
label: "Hermes upgrade delta",
|
|
679
|
+
status: "warn",
|
|
680
|
+
message: `Hermes changes from ${source.hermesCompilerVersion}/HBC ${String(source.hermesBytecodeVersion)} to ${candidate.hermesCompilerVersion}/HBC ${String(candidate.hermesBytecodeVersion)}; native compilation alone cannot validate this pair.`,
|
|
681
|
+
remediation: "Inspect the packaged bytecode and prove cold launch on both physical runtimes.",
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
function isVerifiedBackendIdentity(identity) {
|
|
686
|
+
return (identity?.packageVersion === REACT_NATIVE_0_88_RELEASE.packageVersion &&
|
|
687
|
+
identity.runtimeVersion === REACT_NATIVE_0_88_RELEASE.runtimeVersion &&
|
|
688
|
+
identity.hermesCompilerVersion ===
|
|
689
|
+
REACT_NATIVE_0_88_RELEASE.hermesCompilerVersion &&
|
|
690
|
+
identity.hermesBytecodeVersion ===
|
|
691
|
+
REACT_NATIVE_0_88_RELEASE.hermesBytecodeVersion);
|
|
692
|
+
}
|
|
693
|
+
/**
|
|
694
|
+
* Audits one already-installed React Native candidate without changing either
|
|
695
|
+
* project. Passing means that the candidate is coherent enough to start the
|
|
696
|
+
* listed qualification work; it never promotes a backend release.
|
|
697
|
+
*/
|
|
698
|
+
export async function auditNativeReactNativeUpgrade(options) {
|
|
699
|
+
const deps = dependencies(options.dependencies);
|
|
700
|
+
const checks = [];
|
|
701
|
+
const sourceChecks = [];
|
|
702
|
+
const candidateChecks = [];
|
|
703
|
+
const [source, candidate] = await Promise.all([
|
|
704
|
+
inspectProject(options.cwd ?? process.cwd(), "source", deps, sourceChecks),
|
|
705
|
+
inspectProject(options.candidate, "candidate", deps, candidateChecks),
|
|
706
|
+
]);
|
|
707
|
+
checks.push(...sourceChecks, ...candidateChecks);
|
|
708
|
+
let boundary;
|
|
709
|
+
if (source?.identity !== undefined && candidate?.identity !== undefined) {
|
|
710
|
+
checks.push(isVerifiedBackendIdentity(source.identity)
|
|
711
|
+
? {
|
|
712
|
+
id: "source.supported-matrix",
|
|
713
|
+
label: "Verified upgrade baseline",
|
|
714
|
+
status: "pass",
|
|
715
|
+
message: `The source is the device-verified React Native ${REACT_NATIVE_0_88_RELEASE.packageVersion} backend.`,
|
|
716
|
+
}
|
|
717
|
+
: {
|
|
718
|
+
id: "source.supported-matrix",
|
|
719
|
+
label: "Verified upgrade baseline",
|
|
720
|
+
status: "fail",
|
|
721
|
+
message: `The source is React Native ${source.identity.packageVersion} / runtime ${source.identity.runtimeVersion} / Hermes ${source.identity.hermesCompilerVersion} HBC ${String(source.identity.hermesBytecodeVersion)}, not the device-verified baseline.`,
|
|
722
|
+
remediation: `Run the comparison from the verified React Native ${REACT_NATIVE_0_88_RELEASE.packageVersion} backend so the delta has a trusted anchor.`,
|
|
723
|
+
});
|
|
724
|
+
compareIdentity(source.identity, candidate.identity, checks);
|
|
725
|
+
try {
|
|
726
|
+
const [sourceBoundary, candidateBoundary] = await Promise.all([
|
|
727
|
+
readBoundary(source, deps),
|
|
728
|
+
readBoundary(candidate, deps),
|
|
729
|
+
]);
|
|
730
|
+
if (sourceBoundary.manifest.reactNativeVersion !==
|
|
731
|
+
source.identity.packageVersion) {
|
|
732
|
+
checks.push({
|
|
733
|
+
id: "source.fabric-boundary.version",
|
|
734
|
+
label: "Source Fabric boundary version",
|
|
735
|
+
status: "fail",
|
|
736
|
+
message: `The source boundary declares React Native ${sourceBoundary.manifest.reactNativeVersion}, but the source installs ${source.identity.packageVersion}.`,
|
|
737
|
+
remediation: "Repair the supported baseline boundary before comparing a candidate.",
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
else {
|
|
741
|
+
checks.push({
|
|
742
|
+
id: "source.fabric-boundary.version",
|
|
743
|
+
label: "Source Fabric boundary version",
|
|
744
|
+
status: "pass",
|
|
745
|
+
message: `The source Fabric boundary is assigned to React Native ${source.identity.packageVersion}.`,
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
if (candidateBoundary.manifest.reactNativeVersion !==
|
|
749
|
+
candidate.identity.packageVersion) {
|
|
750
|
+
checks.push({
|
|
751
|
+
id: "candidate.fabric-boundary.version",
|
|
752
|
+
label: "Candidate Fabric boundary version",
|
|
753
|
+
status: "fail",
|
|
754
|
+
message: `The boundary declares React Native ${candidateBoundary.manifest.reactNativeVersion}, but the candidate installs ${candidate.identity.packageVersion}.`,
|
|
755
|
+
remediation: "Select or draft a version-specific Fabric adapter and regenerate its boundary manifest before compiling the candidate.",
|
|
756
|
+
});
|
|
757
|
+
}
|
|
758
|
+
else {
|
|
759
|
+
checks.push({
|
|
760
|
+
id: "candidate.fabric-boundary.version",
|
|
761
|
+
label: "Candidate Fabric boundary version",
|
|
762
|
+
status: "pass",
|
|
763
|
+
message: `The Fabric boundary is explicitly assigned to React Native ${candidate.identity.packageVersion}.`,
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
boundary = await auditBoundary(source, candidate, candidateBoundary.path, sourceBoundary.manifest, candidateBoundary.manifest, deps);
|
|
767
|
+
if (boundary.missingHeaders.length > 0) {
|
|
768
|
+
checks.push({
|
|
769
|
+
id: "candidate.fabric-boundary.headers",
|
|
770
|
+
label: "Candidate upstream header surface",
|
|
771
|
+
status: "fail",
|
|
772
|
+
message: `${String(boundary.missingHeaders.length)} of ${String(boundary.nativeHeaderCount)} imported upstream headers cannot be found in both release trees: ${boundary.missingHeaders.join(", ")}.`,
|
|
773
|
+
remediation: "Update the adapter imports deliberately and regenerate the boundary inventory.",
|
|
774
|
+
});
|
|
775
|
+
}
|
|
776
|
+
else {
|
|
777
|
+
const changed = boundary.changedHeaders.length;
|
|
778
|
+
const moved = boundary.movedHeaders.length;
|
|
779
|
+
const added = boundary.addedHeaders.length;
|
|
780
|
+
const removed = boundary.removedHeaders.length;
|
|
781
|
+
const external = boundary.externalHeaders.length;
|
|
782
|
+
const ambiguous = boundary.ambiguousHeaders.length;
|
|
783
|
+
checks.push({
|
|
784
|
+
id: "candidate.fabric-boundary.headers",
|
|
785
|
+
label: "Candidate upstream header surface",
|
|
786
|
+
status: ambiguous > 0 ? "warn" : "pass",
|
|
787
|
+
message: `Found all React Native-owned imported headers; the adapter adds ${String(added)} and removes ${String(removed)}, ${String(changed)} retained headers changed upstream, ${String(moved)} moved, ${String(external)} come from external native dependencies, and ${String(ambiguous)} require disambiguation.`,
|
|
788
|
+
...(ambiguous === 0
|
|
789
|
+
? {}
|
|
790
|
+
: {
|
|
791
|
+
remediation: "Inspect every ambiguous basename and use native compilation to resolve the actual include target.",
|
|
792
|
+
}),
|
|
793
|
+
});
|
|
794
|
+
}
|
|
795
|
+
checks.push({
|
|
796
|
+
id: "candidate.fabric-boundary.review",
|
|
797
|
+
label: "Fabric API review",
|
|
798
|
+
status: "warn",
|
|
799
|
+
message: `The manifest bounds ${String(boundary.nativeHeaderCount)} native headers, ${String(boundary.androidImportCount)} Android imports, ${String(boundary.cocoapodCount)} pods, and ${String(boundary.generatedCodegenHeaderCount)} generated headers; source presence is not an ABI or behavioral proof.`,
|
|
800
|
+
remediation: "Review changed upstream implementations and complete every native and physical-device qualification gate below.",
|
|
801
|
+
});
|
|
802
|
+
}
|
|
803
|
+
catch (error) {
|
|
804
|
+
checks.push({
|
|
805
|
+
id: "candidate.fabric-boundary",
|
|
806
|
+
label: "Candidate Fabric boundary",
|
|
807
|
+
status: "fail",
|
|
808
|
+
message: error instanceof Error ? error.message : String(error),
|
|
809
|
+
remediation: "Install a complete Fabric Host candidate with a valid exported React Native boundary manifest.",
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
const candidateSupported = isVerifiedBackendIdentity(candidate?.identity);
|
|
814
|
+
checks.push(candidateSupported
|
|
815
|
+
? {
|
|
816
|
+
id: "candidate.supported-matrix",
|
|
817
|
+
label: "Supported backend matrix",
|
|
818
|
+
status: "pass",
|
|
819
|
+
message: `React Native ${REACT_NATIVE_0_88_RELEASE.packageVersion} is already in the device-verified backend matrix.`,
|
|
820
|
+
}
|
|
821
|
+
: {
|
|
822
|
+
id: "candidate.supported-matrix",
|
|
823
|
+
label: "Supported backend matrix",
|
|
824
|
+
status: "warn",
|
|
825
|
+
message: `The candidate is not the device-verified React Native ${REACT_NATIVE_0_88_RELEASE.packageVersion} backend. This audit does not add support.`,
|
|
826
|
+
remediation: "Keep the candidate isolated until every qualification gate is complete and reviewed evidence is recorded.",
|
|
827
|
+
});
|
|
828
|
+
const summary = {
|
|
829
|
+
pass: checks.filter((entry) => entry.status === "pass").length,
|
|
830
|
+
warn: checks.filter((entry) => entry.status === "warn").length,
|
|
831
|
+
fail: checks.filter((entry) => entry.status === "fail").length,
|
|
832
|
+
};
|
|
833
|
+
return {
|
|
834
|
+
schemaVersion: 0,
|
|
835
|
+
operation: "upgrade-react-native",
|
|
836
|
+
ok: summary.fail === 0,
|
|
837
|
+
candidateSupported,
|
|
838
|
+
promotionReady: false,
|
|
839
|
+
...(source?.identity === undefined ? {} : { source: source.identity }),
|
|
840
|
+
...(candidate?.identity === undefined
|
|
841
|
+
? {}
|
|
842
|
+
: { candidate: candidate.identity }),
|
|
843
|
+
...(boundary === undefined ? {} : { boundary }),
|
|
844
|
+
checks,
|
|
845
|
+
summary,
|
|
846
|
+
qualificationGates: QUALIFICATION_GATES,
|
|
847
|
+
};
|
|
848
|
+
}
|
|
849
|
+
export function formatNativeReactNativeUpgradeReport(report) {
|
|
850
|
+
const symbols = {
|
|
851
|
+
pass: "✓",
|
|
852
|
+
warn: "!",
|
|
853
|
+
fail: "✗",
|
|
854
|
+
};
|
|
855
|
+
const lines = [
|
|
856
|
+
"Solid Native React Native upgrade audit",
|
|
857
|
+
...(report.source === undefined
|
|
858
|
+
? []
|
|
859
|
+
: [
|
|
860
|
+
`Source: ${report.source.packageVersion} (${report.source.projectRoot})`,
|
|
861
|
+
]),
|
|
862
|
+
...(report.candidate === undefined
|
|
863
|
+
? []
|
|
864
|
+
: [
|
|
865
|
+
`Candidate: ${report.candidate.packageVersion} / runtime ${report.candidate.runtimeVersion} (${report.candidate.projectRoot})`,
|
|
866
|
+
]),
|
|
867
|
+
"",
|
|
868
|
+
...report.checks.flatMap((entry) => [
|
|
869
|
+
`${symbols[entry.status]} ${entry.label}: ${entry.message}`,
|
|
870
|
+
...(entry.remediation === undefined
|
|
871
|
+
? []
|
|
872
|
+
: [` Next: ${entry.remediation}`]),
|
|
873
|
+
]),
|
|
874
|
+
"",
|
|
875
|
+
"Qualification gates (not executed by this audit):",
|
|
876
|
+
...report.qualificationGates.map((gate) => `- ${gate.id} [${gate.scope}]: ${gate.description}${gate.commands.length === 0 ? "" : `\n ${gate.commands.join("\n ")}`}`),
|
|
877
|
+
"",
|
|
878
|
+
`${report.ok ? "Audit ready" : "Audit blocked"}: ${String(report.summary.pass)} passed, ${String(report.summary.warn)} warnings, ${String(report.summary.fail)} failed. Backend promotion remains false.`,
|
|
879
|
+
];
|
|
880
|
+
return lines.join("\n");
|
|
881
|
+
}
|
|
882
|
+
//# sourceMappingURL=react-native-upgrade.js.map
|