codeplay-common 4.11.38 → 4.11.39

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 (40) hide show
  1. package/README.md +1 -1
  2. package/RELEASE_NOTES.md +13 -13
  3. package/files/buildCodeplay/add-splash-screen.js +1 -1
  4. package/files/buildCodeplay/codeplayBeforeBuild.js +2 -2
  5. package/files/buildCodeplay/ensure-current-build.cjs +32 -4
  6. package/files/buildCodeplay/fix-optimize-builld/android-r8-rules.cjs +31 -31
  7. package/files/buildCodeplay/fix-optimize-builld/ffmpeg-jni-rules.cjs +28 -28
  8. package/files/buildCodeplay/fix-optimize-builld/fix-optimize-build.gradle +9 -9
  9. package/files/buildCodeplay/fix-optimize-builld/restore-android-r8-rules.cjs +30 -30
  10. package/files/buildCodeplay/huawei-privacy-entry.js +135 -135
  11. package/files/buildCodeplay/huawei-privacy.css +22 -22
  12. package/files/buildCodeplay/ios-ad-consent.cjs +56 -56
  13. package/files/buildCodeplay/ios-emi-admob-modification.js +25 -25
  14. package/files/buildCodeplay/newly added.txt +89 -89
  15. package/files/buildCodeplay/non-google-billing.pro +3 -3
  16. package/files/buildCodeplay/release-sync.config.json +4 -4
  17. package/files/buildCodeplay/remove-force-kotlin-disable.js +43 -43
  18. package/files/buildCodeplay/ruads.cjs +220 -220
  19. package/files/buildCodeplay/saf-mediastore-dependency.cjs +21 -21
  20. package/files/buildCodeplay/setSplashAnimation.js +2 -2
  21. package/files/buildCodeplay/setup-ruads.cjs +62 -62
  22. package/files/buildCodeplay/splash-setup.cjs +88 -88
  23. package/files/buildCodeplay/store-billing.cjs +43 -43
  24. package/files/buildCodeplay/tests/huawei-live-reload.test.cjs +60 -60
  25. package/files/buildCodeplay/tests/huawei-privacy.test.cjs +49 -49
  26. package/files/scripts-common/collect-startup-profile.js +134 -134
  27. package/files/scripts-common/generate-baseline-profile.js +218 -218
  28. package/files/take-screen-image.js +4453 -4414
  29. package/package.json +1 -1
  30. package/runtime/splash-ready.mjs +52 -52
  31. package/runtime/vk-ads/vk-ad-configuration.json +39 -39
  32. package/scripts/baseline-profile.test.cjs +189 -189
  33. package/scripts/ensure-current-build.test.cjs +128 -28
  34. package/scripts/ios-ad-consent.test.cjs +99 -99
  35. package/scripts/ruads-install.test.cjs +197 -197
  36. package/scripts/ruads-policy.test.cjs +174 -174
  37. package/scripts/saf-mediastore-dependency.test.cjs +44 -44
  38. package/scripts/splash-setup.test.cjs +142 -142
  39. package/scripts/sync-files.js +1 -1
  40. package/scripts/vite-build-settings.test.cjs +93 -93
@@ -1,218 +1,218 @@
1
- const { execFile, execFileSync, spawn } = require('child_process');
2
- const fs = require('fs');
3
- const path = require('path');
4
- const { promisify } = require('util');
5
- const { syncGeneratedProfileBackup } = require('./setup-baseline-profile.js');
6
- const { collectStartupProfile } = require('./collect-startup-profile.js');
7
-
8
- const rootDir = path.resolve(__dirname, '..');
9
- const androidDir = path.join(rootDir, 'android');
10
- const execFileAsync = promisify(execFile);
11
-
12
- async function getFrozenTestProcess(serial, testPackage) {
13
- const readDevice = async (args) => {
14
- const result = await execFileAsync('adb', ['-s', serial, 'shell', ...args], {
15
- encoding: 'utf8',
16
- timeout: 5000,
17
- });
18
- return result.stdout.trim();
19
- };
20
- try {
21
- const pid = await readDevice(['pidof', testPackage]);
22
- if (!/^\d+$/.test(pid)) return null;
23
- const groups = await readDevice(['cat', `/proc/${pid}/cgroup`]);
24
- const group = groups.match(/^0::(\/uid_\d+\/pid_\d+)$/m)?.[1];
25
- if (!group) return null;
26
- const frozen = await readDevice(['cat', `/sys/fs/cgroup${group}/cgroup.freeze`]);
27
- return frozen === '1' ? pid : null;
28
- } catch {
29
- // The runner may not be installed/running yet, or the device may restrict cgroup reads.
30
- return null;
31
- }
32
- }
33
-
34
- function runGradle(args, serial, timeoutMinutes, testPackage) {
35
- return new Promise((resolve, reject) => {
36
- const child = spawn(
37
- process.platform === 'win32' ? 'cmd.exe' : './gradlew',
38
- process.platform === 'win32' ? ['/d', '/s', '/c', `gradlew.bat ${args.join(' ')}`] : args,
39
- {
40
- cwd: androidDir,
41
- env: { ...process.env, ANDROID_SERIAL: serial },
42
- stdio: 'inherit',
43
- detached: process.platform !== 'win32',
44
- }
45
- );
46
- let stopReason;
47
- let finished = false;
48
- let checkingFreeze = false;
49
- let frozenPid = null;
50
- const stop = (reason, code) => {
51
- if (stopReason) return;
52
- stopReason = new Error(reason);
53
- stopReason.code = code;
54
- try {
55
- if (process.platform === 'win32') {
56
- execFileSync('taskkill', ['/pid', String(child.pid), '/t', '/f'], {
57
- stdio: 'ignore',
58
- timeout: 10000,
59
- });
60
- } else {
61
- process.kill(-child.pid, 'SIGKILL');
62
- }
63
- } catch (error) {
64
- // The child may already have exited before cancellation reached it.
65
- if (child.exitCode === null && error.code !== 'ESRCH') {
66
- console.error(`Unable to stop Gradle: ${error.message}`);
67
- }
68
- }
69
- try {
70
- execFileSync('adb', ['-s', serial, 'shell', 'am', 'force-stop', testPackage], {
71
- stdio: 'ignore',
72
- timeout: 10000,
73
- });
74
- } catch (error) {
75
- console.error(`Unable to stop device instrumentation: ${error.message}`);
76
- }
77
- };
78
- const onInterrupt = () => stop('Baseline Profile generation cancelled.');
79
- const startedAt = Date.now();
80
- const freezeMonitor = setInterval(async () => {
81
- if (finished || stopReason || checkingFreeze) return;
82
- checkingFreeze = true;
83
- try {
84
- const pid = await getFrozenTestProcess(serial, testPackage);
85
- if (finished || stopReason) return;
86
- if (pid && pid === frozenPid) {
87
- stop(`Android has frozen the Baseline Profile test runner (${testPackage}, PID ${pid}).`, 'BASELINE_TEST_FROZEN');
88
- } else if (pid) {
89
- console.log(`Test runner PID ${pid} is frozen by the device; checking again before stopping.`);
90
- }
91
- frozenPid = pid;
92
- } finally {
93
- checkingFreeze = false;
94
- }
95
- }, 10000);
96
- const progress = setInterval(() => {
97
- const minutes = Math.floor((Date.now() - startedAt) / 60000);
98
- console.log(`Baseline Profile run: ${minutes} minute(s) elapsed. The single test stays at 0/1 until collection finishes.`);
99
- }, 60000);
100
- const timeout = setTimeout(() => {
101
- stop(`Baseline Profile generation exceeded ${timeoutMinutes} minutes. Check the test log under android/baselineprofile/build/outputs/androidTest-results/connected/ for the last Benchmark step. Set BASELINE_PROFILE_TIMEOUT_MINUTES to allow a longer run.`);
102
- }, timeoutMinutes * 60000);
103
- process.on('SIGINT', onInterrupt);
104
- process.on('SIGTERM', onInterrupt);
105
- const cleanup = () => {
106
- finished = true;
107
- clearInterval(freezeMonitor);
108
- clearInterval(progress);
109
- clearTimeout(timeout);
110
- process.removeListener('SIGINT', onInterrupt);
111
- process.removeListener('SIGTERM', onInterrupt);
112
- };
113
- child.once('error', (error) => {
114
- cleanup();
115
- reject(error);
116
- });
117
- child.once('close', (status, signal) => {
118
- cleanup();
119
- if (stopReason) reject(stopReason);
120
- else if (signal) reject(new Error(`Baseline Profile generation stopped by ${signal}.`));
121
- else resolve(status ?? 1);
122
- });
123
- });
124
- }
125
-
126
- async function main() {
127
- const timeoutMinutes = Number(process.env.BASELINE_PROFILE_TIMEOUT_MINUTES || 20);
128
- if (!Number.isInteger(timeoutMinutes) || timeoutMinutes < 1 || timeoutMinutes > 1440) {
129
- throw new Error('BASELINE_PROFILE_TIMEOUT_MINUTES must be a whole number between 1 and 1440.');
130
- }
131
- const devices = execFileSync('adb', ['devices'], { encoding: 'utf8', timeout: 10000 })
132
- .split(/\r?\n/)
133
- .map(line => line.match(/^(.+?)\tdevice\s*$/))
134
- .filter(Boolean)
135
- .map(match => match[1]);
136
- const requestedSerial = process.env.ANDROID_SERIAL?.trim();
137
- if (requestedSerial?.includes(',')) {
138
- throw new Error('Set ANDROID_SERIAL to one device connection for Baseline Profile generation.');
139
- }
140
- const serial = requestedSerial || devices[0];
141
- if (!serial || !devices.includes(serial)) {
142
- throw new Error(requestedSerial
143
- ? `ADB device is not online: ${requestedSerial}`
144
- : 'No online ADB device. Connect an Android device before generating a Baseline Profile.');
145
- }
146
-
147
- const configPath = path.join(androidDir, 'app', 'src', 'main', 'assets', 'capacitor.config.json');
148
- const backupPath = path.join(rootDir, 'agent-temp', 'baseline-profile', 'capacitor.config.original.json');
149
- if (fs.existsSync(backupPath)) {
150
- throw new Error(`A previous run left a config backup at ${backupPath}. Confirm that run has stopped, restore it to ${configPath}, then remove the backup before retrying.`);
151
- }
152
- const originalConfig = fs.readFileSync(configPath);
153
- const config = JSON.parse(originalConfig.toString('utf8'));
154
- const sourceConfig = JSON.parse(fs.readFileSync(path.join(rootDir, 'capacitor.config.json'), 'utf8'));
155
- if (config.appId !== sourceConfig.appId) {
156
- throw new Error('Android assets belong to a different appId. Copy the correct production web assets before generating a Baseline Profile.');
157
- }
158
- const indexPath = path.join(path.dirname(configPath), 'public', 'index.html');
159
- if (!fs.existsSync(indexPath) || /\/@vite\/client|vite\/dist\/client/.test(fs.readFileSync(indexPath, 'utf8'))) {
160
- throw new Error('Bundled production web assets are missing or contain the Vite development client. Build and copy production web assets before generating a Baseline Profile.');
161
- }
162
-
163
- let offlineConfig;
164
- try {
165
- if (config.server?.url) {
166
- delete config.server.url;
167
- offlineConfig = Buffer.from(`${JSON.stringify(config, null, 2)}\n`);
168
- fs.mkdirSync(path.dirname(backupPath), { recursive: true });
169
- fs.writeFileSync(backupPath, originalConfig, { flag: 'wx' });
170
- fs.writeFileSync(configPath, offlineConfig);
171
- console.log('Temporarily disabled the Android live-reload URL. Profiling bundled web assets.');
172
- }
173
-
174
- const hostMode = process.argv.includes('--host');
175
- const deadline = Date.now() + timeoutMinutes * 60000;
176
- console.log(`Generating Baseline Profile using one ADB connection: ${serial}`);
177
- console.log(hostMode
178
- ? `Host-driven collection runs up to 15 startup iterations. Overall timeout: ${timeoutMinutes} minutes.`
179
- : `Collection runs up to 15 iterations inside one test; 0/1 is the test count. Overall timeout: ${timeoutMinutes} minutes.`);
180
- // Exit the Gradle JVM after each run so UTP log handles cannot persist in a reused daemon.
181
- const args = [hostMode ? ':app:assembleNonMinifiedRelease' : ':app:generateBaselineProfile', '--console=plain', '--no-daemon'];
182
- let needsHostCollection = hostMode;
183
- try {
184
- process.exitCode = await runGradle(args, serial, timeoutMinutes, `${config.appId}.baselineprofile`);
185
- if (process.exitCode !== 0) {
186
- throw new Error(`Gradle exited with code ${process.exitCode}. Check the test output above for the failing step.`);
187
- }
188
- } catch (error) {
189
- if (error.code !== 'BASELINE_TEST_FROZEN') throw error;
190
- console.log(`${error.message} Switching to host-driven collection.`);
191
- needsHostCollection = true;
192
- }
193
- if (needsHostCollection) {
194
- await collectStartupProfile({
195
- serial, appId: config.appId, rootDir, timeoutMinutes, deadline,
196
- apkPath: path.join(androidDir, 'app', 'build', 'outputs', 'apk', 'nonMinifiedRelease', 'app-nonMinifiedRelease.apk'),
197
- });
198
- syncGeneratedProfileBackup();
199
- process.exitCode = 0;
200
- } else {
201
- syncGeneratedProfileBackup({ backupOnly: true });
202
- }
203
- } finally {
204
- if (offlineConfig && fs.existsSync(backupPath)) {
205
- if (!fs.readFileSync(configPath).equals(offlineConfig)) {
206
- throw new Error(`Android config changed during profiling. Original config preserved at ${backupPath}; restore it after reviewing the changes.`);
207
- }
208
- fs.writeFileSync(configPath, originalConfig);
209
- fs.unlinkSync(backupPath);
210
- console.log('Restored the original Android live-reload configuration.');
211
- }
212
- }
213
- }
214
-
215
- main().catch((error) => {
216
- console.error(`Baseline Profile generation failed: ${error.message}`);
217
- process.exitCode = 1;
218
- });
1
+ const { execFile, execFileSync, spawn } = require('child_process');
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+ const { promisify } = require('util');
5
+ const { syncGeneratedProfileBackup } = require('./setup-baseline-profile.js');
6
+ const { collectStartupProfile } = require('./collect-startup-profile.js');
7
+
8
+ const rootDir = path.resolve(__dirname, '..');
9
+ const androidDir = path.join(rootDir, 'android');
10
+ const execFileAsync = promisify(execFile);
11
+
12
+ async function getFrozenTestProcess(serial, testPackage) {
13
+ const readDevice = async (args) => {
14
+ const result = await execFileAsync('adb', ['-s', serial, 'shell', ...args], {
15
+ encoding: 'utf8',
16
+ timeout: 5000,
17
+ });
18
+ return result.stdout.trim();
19
+ };
20
+ try {
21
+ const pid = await readDevice(['pidof', testPackage]);
22
+ if (!/^\d+$/.test(pid)) return null;
23
+ const groups = await readDevice(['cat', `/proc/${pid}/cgroup`]);
24
+ const group = groups.match(/^0::(\/uid_\d+\/pid_\d+)$/m)?.[1];
25
+ if (!group) return null;
26
+ const frozen = await readDevice(['cat', `/sys/fs/cgroup${group}/cgroup.freeze`]);
27
+ return frozen === '1' ? pid : null;
28
+ } catch {
29
+ // The runner may not be installed/running yet, or the device may restrict cgroup reads.
30
+ return null;
31
+ }
32
+ }
33
+
34
+ function runGradle(args, serial, timeoutMinutes, testPackage) {
35
+ return new Promise((resolve, reject) => {
36
+ const child = spawn(
37
+ process.platform === 'win32' ? 'cmd.exe' : './gradlew',
38
+ process.platform === 'win32' ? ['/d', '/s', '/c', `gradlew.bat ${args.join(' ')}`] : args,
39
+ {
40
+ cwd: androidDir,
41
+ env: { ...process.env, ANDROID_SERIAL: serial },
42
+ stdio: 'inherit',
43
+ detached: process.platform !== 'win32',
44
+ }
45
+ );
46
+ let stopReason;
47
+ let finished = false;
48
+ let checkingFreeze = false;
49
+ let frozenPid = null;
50
+ const stop = (reason, code) => {
51
+ if (stopReason) return;
52
+ stopReason = new Error(reason);
53
+ stopReason.code = code;
54
+ try {
55
+ if (process.platform === 'win32') {
56
+ execFileSync('taskkill', ['/pid', String(child.pid), '/t', '/f'], {
57
+ stdio: 'ignore',
58
+ timeout: 10000,
59
+ });
60
+ } else {
61
+ process.kill(-child.pid, 'SIGKILL');
62
+ }
63
+ } catch (error) {
64
+ // The child may already have exited before cancellation reached it.
65
+ if (child.exitCode === null && error.code !== 'ESRCH') {
66
+ console.error(`Unable to stop Gradle: ${error.message}`);
67
+ }
68
+ }
69
+ try {
70
+ execFileSync('adb', ['-s', serial, 'shell', 'am', 'force-stop', testPackage], {
71
+ stdio: 'ignore',
72
+ timeout: 10000,
73
+ });
74
+ } catch (error) {
75
+ console.error(`Unable to stop device instrumentation: ${error.message}`);
76
+ }
77
+ };
78
+ const onInterrupt = () => stop('Baseline Profile generation cancelled.');
79
+ const startedAt = Date.now();
80
+ const freezeMonitor = setInterval(async () => {
81
+ if (finished || stopReason || checkingFreeze) return;
82
+ checkingFreeze = true;
83
+ try {
84
+ const pid = await getFrozenTestProcess(serial, testPackage);
85
+ if (finished || stopReason) return;
86
+ if (pid && pid === frozenPid) {
87
+ stop(`Android has frozen the Baseline Profile test runner (${testPackage}, PID ${pid}).`, 'BASELINE_TEST_FROZEN');
88
+ } else if (pid) {
89
+ console.log(`Test runner PID ${pid} is frozen by the device; checking again before stopping.`);
90
+ }
91
+ frozenPid = pid;
92
+ } finally {
93
+ checkingFreeze = false;
94
+ }
95
+ }, 10000);
96
+ const progress = setInterval(() => {
97
+ const minutes = Math.floor((Date.now() - startedAt) / 60000);
98
+ console.log(`Baseline Profile run: ${minutes} minute(s) elapsed. The single test stays at 0/1 until collection finishes.`);
99
+ }, 60000);
100
+ const timeout = setTimeout(() => {
101
+ stop(`Baseline Profile generation exceeded ${timeoutMinutes} minutes. Check the test log under android/baselineprofile/build/outputs/androidTest-results/connected/ for the last Benchmark step. Set BASELINE_PROFILE_TIMEOUT_MINUTES to allow a longer run.`);
102
+ }, timeoutMinutes * 60000);
103
+ process.on('SIGINT', onInterrupt);
104
+ process.on('SIGTERM', onInterrupt);
105
+ const cleanup = () => {
106
+ finished = true;
107
+ clearInterval(freezeMonitor);
108
+ clearInterval(progress);
109
+ clearTimeout(timeout);
110
+ process.removeListener('SIGINT', onInterrupt);
111
+ process.removeListener('SIGTERM', onInterrupt);
112
+ };
113
+ child.once('error', (error) => {
114
+ cleanup();
115
+ reject(error);
116
+ });
117
+ child.once('close', (status, signal) => {
118
+ cleanup();
119
+ if (stopReason) reject(stopReason);
120
+ else if (signal) reject(new Error(`Baseline Profile generation stopped by ${signal}.`));
121
+ else resolve(status ?? 1);
122
+ });
123
+ });
124
+ }
125
+
126
+ async function main() {
127
+ const timeoutMinutes = Number(process.env.BASELINE_PROFILE_TIMEOUT_MINUTES || 20);
128
+ if (!Number.isInteger(timeoutMinutes) || timeoutMinutes < 1 || timeoutMinutes > 1440) {
129
+ throw new Error('BASELINE_PROFILE_TIMEOUT_MINUTES must be a whole number between 1 and 1440.');
130
+ }
131
+ const devices = execFileSync('adb', ['devices'], { encoding: 'utf8', timeout: 10000 })
132
+ .split(/\r?\n/)
133
+ .map(line => line.match(/^(.+?)\tdevice\s*$/))
134
+ .filter(Boolean)
135
+ .map(match => match[1]);
136
+ const requestedSerial = process.env.ANDROID_SERIAL?.trim();
137
+ if (requestedSerial?.includes(',')) {
138
+ throw new Error('Set ANDROID_SERIAL to one device connection for Baseline Profile generation.');
139
+ }
140
+ const serial = requestedSerial || devices[0];
141
+ if (!serial || !devices.includes(serial)) {
142
+ throw new Error(requestedSerial
143
+ ? `ADB device is not online: ${requestedSerial}`
144
+ : 'No online ADB device. Connect an Android device before generating a Baseline Profile.');
145
+ }
146
+
147
+ const configPath = path.join(androidDir, 'app', 'src', 'main', 'assets', 'capacitor.config.json');
148
+ const backupPath = path.join(rootDir, 'agent-temp', 'baseline-profile', 'capacitor.config.original.json');
149
+ if (fs.existsSync(backupPath)) {
150
+ throw new Error(`A previous run left a config backup at ${backupPath}. Confirm that run has stopped, restore it to ${configPath}, then remove the backup before retrying.`);
151
+ }
152
+ const originalConfig = fs.readFileSync(configPath);
153
+ const config = JSON.parse(originalConfig.toString('utf8'));
154
+ const sourceConfig = JSON.parse(fs.readFileSync(path.join(rootDir, 'capacitor.config.json'), 'utf8'));
155
+ if (config.appId !== sourceConfig.appId) {
156
+ throw new Error('Android assets belong to a different appId. Copy the correct production web assets before generating a Baseline Profile.');
157
+ }
158
+ const indexPath = path.join(path.dirname(configPath), 'public', 'index.html');
159
+ if (!fs.existsSync(indexPath) || /\/@vite\/client|vite\/dist\/client/.test(fs.readFileSync(indexPath, 'utf8'))) {
160
+ throw new Error('Bundled production web assets are missing or contain the Vite development client. Build and copy production web assets before generating a Baseline Profile.');
161
+ }
162
+
163
+ let offlineConfig;
164
+ try {
165
+ if (config.server?.url) {
166
+ delete config.server.url;
167
+ offlineConfig = Buffer.from(`${JSON.stringify(config, null, 2)}\n`);
168
+ fs.mkdirSync(path.dirname(backupPath), { recursive: true });
169
+ fs.writeFileSync(backupPath, originalConfig, { flag: 'wx' });
170
+ fs.writeFileSync(configPath, offlineConfig);
171
+ console.log('Temporarily disabled the Android live-reload URL. Profiling bundled web assets.');
172
+ }
173
+
174
+ const hostMode = process.argv.includes('--host');
175
+ const deadline = Date.now() + timeoutMinutes * 60000;
176
+ console.log(`Generating Baseline Profile using one ADB connection: ${serial}`);
177
+ console.log(hostMode
178
+ ? `Host-driven collection runs up to 15 startup iterations. Overall timeout: ${timeoutMinutes} minutes.`
179
+ : `Collection runs up to 15 iterations inside one test; 0/1 is the test count. Overall timeout: ${timeoutMinutes} minutes.`);
180
+ // Exit the Gradle JVM after each run so UTP log handles cannot persist in a reused daemon.
181
+ const args = [hostMode ? ':app:assembleNonMinifiedRelease' : ':app:generateBaselineProfile', '--console=plain', '--no-daemon'];
182
+ let needsHostCollection = hostMode;
183
+ try {
184
+ process.exitCode = await runGradle(args, serial, timeoutMinutes, `${config.appId}.baselineprofile`);
185
+ if (process.exitCode !== 0) {
186
+ throw new Error(`Gradle exited with code ${process.exitCode}. Check the test output above for the failing step.`);
187
+ }
188
+ } catch (error) {
189
+ if (error.code !== 'BASELINE_TEST_FROZEN') throw error;
190
+ console.log(`${error.message} Switching to host-driven collection.`);
191
+ needsHostCollection = true;
192
+ }
193
+ if (needsHostCollection) {
194
+ await collectStartupProfile({
195
+ serial, appId: config.appId, rootDir, timeoutMinutes, deadline,
196
+ apkPath: path.join(androidDir, 'app', 'build', 'outputs', 'apk', 'nonMinifiedRelease', 'app-nonMinifiedRelease.apk'),
197
+ });
198
+ syncGeneratedProfileBackup();
199
+ process.exitCode = 0;
200
+ } else {
201
+ syncGeneratedProfileBackup({ backupOnly: true });
202
+ }
203
+ } finally {
204
+ if (offlineConfig && fs.existsSync(backupPath)) {
205
+ if (!fs.readFileSync(configPath).equals(offlineConfig)) {
206
+ throw new Error(`Android config changed during profiling. Original config preserved at ${backupPath}; restore it after reviewing the changes.`);
207
+ }
208
+ fs.writeFileSync(configPath, originalConfig);
209
+ fs.unlinkSync(backupPath);
210
+ console.log('Restored the original Android live-reload configuration.');
211
+ }
212
+ }
213
+ }
214
+
215
+ main().catch((error) => {
216
+ console.error(`Baseline Profile generation failed: ${error.message}`);
217
+ process.exitCode = 1;
218
+ });