@gfean/react-native-bundle-drop 0.5.1 → 0.6.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/README.md +168 -4
- package/android/build.gradle +1 -0
- package/android/src/main/java/com/bundledrop/BundleDropBoundedDownloader.kt +86 -0
- package/android/src/main/java/com/bundledrop/BundleDropModule.kt +69 -0
- package/android/src/main/java/com/bundledrop/BundleDropRuntimeCrypto.kt +81 -0
- package/ios/BundleDropBridge.m +18 -0
- package/ios/BundleDropLocator.swift +48 -2
- package/ios/BundleDropModule.swift +75 -0
- package/ios/BundleDropRuntimeCrypto.swift +45 -0
- package/lib/CLI/cli.d.ts +1 -0
- package/lib/CLI/cli.js +54 -2
- package/lib/CLI/scripts/aipowered/apply-setup-plan.js +7 -17
- package/lib/CLI/scripts/aipowered/backend-client.js +29 -4
- package/lib/CLI/scripts/aipowered/code-push-residue.d.ts +5 -0
- package/lib/CLI/scripts/aipowered/code-push-residue.js +126 -0
- package/lib/CLI/scripts/aipowered/credential-safety.d.ts +1 -0
- package/lib/CLI/scripts/aipowered/credential-safety.js +14 -0
- package/lib/CLI/scripts/aipowered/diff-preview.js +12 -4
- package/lib/CLI/scripts/aipowered/init-project-config.d.ts +4 -0
- package/lib/CLI/scripts/aipowered/init-project-config.js +221 -45
- package/lib/CLI/scripts/aipowered/scanner.d.ts +1 -0
- package/lib/CLI/scripts/aipowered/scanner.js +164 -32
- package/lib/CLI/scripts/aipowered/terminal-safety.d.ts +4 -0
- package/lib/CLI/scripts/aipowered/terminal-safety.js +124 -0
- package/lib/CLI/scripts/aipowered/validate-plan.d.ts +3 -0
- package/lib/CLI/scripts/aipowered/validate-plan.js +1080 -19
- package/lib/CLI/scripts/bare-metro-config.d.ts +1 -1
- package/lib/CLI/scripts/bare-metro-config.js +24 -32
- package/lib/CLI/scripts/doctor.js +143 -22
- package/lib/CLI/scripts/expo/configure-expo.js +51 -60
- package/lib/CLI/scripts/expo/package-manager.d.ts +2 -0
- package/lib/CLI/scripts/expo/package-manager.js +63 -25
- package/lib/CLI/scripts/init-config.d.ts +7 -7
- package/lib/CLI/scripts/init-config.js +185 -10
- package/lib/CLI/scripts/login-cli.js +29 -4
- package/lib/CLI/scripts/metro-config-authority.d.ts +8 -0
- package/lib/CLI/scripts/metro-config-authority.js +303 -0
- package/lib/CLI/scripts/native-entrypoint-authority.d.ts +2 -0
- package/lib/CLI/scripts/native-entrypoint-authority.js +378 -0
- package/lib/CLI/scripts/native-setup-contract.d.ts +2 -2
- package/lib/CLI/scripts/native-setup-contract.js +63 -33
- package/lib/CLI/scripts/native-startup-validator.d.ts +3 -0
- package/lib/CLI/scripts/native-startup-validator.js +964 -0
- package/lib/CLI/scripts/safe-file-transaction.d.ts +12 -0
- package/lib/CLI/scripts/safe-file-transaction.js +159 -0
- package/lib/api/clientApi.d.ts +3 -1
- package/lib/api/clientApi.js +14 -0
- package/lib/api/types.d.ts +39 -0
- package/lib/context.d.ts +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +3 -1
- package/lib/install/installFromZip.d.ts +3 -0
- package/lib/install/installFromZip.js +10 -1
- package/lib/loadConfig.d.ts +17 -1
- package/lib/loadConfig.js +16 -0
- package/lib/manager/downloadAndInstall.d.ts +3 -2
- package/lib/manager/downloadAndInstall.js +111 -46
- package/lib/manager/rollbackState.d.ts +3 -1
- package/lib/manager/rollbackState.js +2 -2
- package/lib/manager/updateCheck.d.ts +1 -0
- package/lib/manager/updateCheck.js +218 -78
- package/lib/metro.d.ts +8 -1
- package/lib/metro.js +68 -19
- package/lib/native/bundleDropNative.js +2 -1
- package/lib/native/fs.d.ts +6 -0
- package/lib/native/fs.js +24 -0
- package/lib/patch-engine/installFromPatchSet.d.ts +2 -0
- package/lib/patch-engine/installFromPatchSet.js +14 -3
- package/lib/patch-engine/patchTransport.d.ts +2 -0
- package/lib/patch-engine/patchTransport.js +9 -0
- package/lib/runtime/initState.d.ts +5 -0
- package/lib/runtime/initState.js +4 -0
- package/lib/runtime/service.js +60 -3
- package/lib/runtime-delivery/artifactCapability.d.ts +1 -0
- package/lib/runtime-delivery/artifactCapability.js +32 -0
- package/lib/runtime-delivery/authorityLeaseVerifier.d.ts +3 -0
- package/lib/runtime-delivery/authorityLeaseVerifier.js +106 -0
- package/lib/runtime-delivery/bootstrapConfig.d.ts +50 -0
- package/lib/runtime-delivery/bootstrapConfig.js +217 -0
- package/lib/runtime-delivery/diagnostics.d.ts +17 -0
- package/lib/runtime-delivery/diagnostics.js +58 -0
- package/lib/runtime-delivery/encoding.d.ts +5 -0
- package/lib/runtime-delivery/encoding.js +132 -0
- package/lib/runtime-delivery/heartbeat.d.ts +3 -0
- package/lib/runtime-delivery/heartbeat.js +88 -0
- package/lib/runtime-delivery/localResolver.d.ts +23 -0
- package/lib/runtime-delivery/localResolver.js +81 -0
- package/lib/runtime-delivery/manifestState.d.ts +9 -0
- package/lib/runtime-delivery/manifestState.js +102 -0
- package/lib/runtime-delivery/manifestVerifier.d.ts +13 -0
- package/lib/runtime-delivery/manifestVerifier.js +329 -0
- package/lib/runtime-delivery/runtimeDelivery.d.ts +19 -0
- package/lib/runtime-delivery/runtimeDelivery.js +375 -0
- package/lib/runtime-delivery/types.d.ts +87 -0
- package/lib/runtime-delivery/types.js +6 -0
- package/package.json +2 -2
|
@@ -17,16 +17,93 @@ const configure_expo_1 = require("../expo/configure-expo");
|
|
|
17
17
|
const package_manager_1 = require("../expo/package-manager");
|
|
18
18
|
const apply_setup_plan_1 = require("./apply-setup-plan");
|
|
19
19
|
const backend_client_1 = require("./backend-client");
|
|
20
|
+
const code_push_residue_1 = require("./code-push-residue");
|
|
20
21
|
const diff_preview_1 = require("./diff-preview");
|
|
22
|
+
const terminal_safety_1 = require("./terminal-safety");
|
|
21
23
|
const scanner_1 = require("./scanner");
|
|
22
24
|
const validate_plan_1 = require("./validate-plan");
|
|
23
25
|
const ui_1 = require("../../utils/ui");
|
|
26
|
+
const safe_file_transaction_1 = require("../safe-file-transaction");
|
|
27
|
+
const bootstrapConfig_1 = require("../../../runtime-delivery/bootstrapConfig");
|
|
24
28
|
const PACKAGE_NAME = '@gfean/react-native-bundle-drop';
|
|
25
29
|
const DOCS_MANUAL_SETUP_URL = 'https://bundledrop.app/docs/manual-setup';
|
|
30
|
+
const DOCS_RUNTIME_INITIALIZATION_URL = 'https://bundledrop.app/docs/installation#initialize-bundle-drop-in-javascript';
|
|
26
31
|
const EXPO_RUNTIME_AUTHORITY_PATTERN = /runtimeVersion\s*:\s*\{\s*source\s*:\s*['"]expo['"]\s*\}/;
|
|
32
|
+
const logRuntimeInitializationNextStep = () => {
|
|
33
|
+
console.log(chalk_1.default.cyan('JavaScript entry point: call BundleDrop.init once before rendering your app. ' +
|
|
34
|
+
DOCS_RUNTIME_INITIALIZATION_URL));
|
|
35
|
+
};
|
|
27
36
|
const sha256 = (content) => crypto_1.default.createHash('sha256').update(content).digest('hex');
|
|
37
|
+
const inspectPlanningFile = (projectRoot, relativePath) => {
|
|
38
|
+
if (!fs_extra_1.default.existsSync(projectRoot))
|
|
39
|
+
return { exists: false, content: '', mode: 0o666 };
|
|
40
|
+
return (0, safe_file_transaction_1.inspectProjectFile)(projectRoot, relativePath);
|
|
41
|
+
};
|
|
42
|
+
const planRuntimeDeliveryBootstrap = (projectRoot, bootstrap) => {
|
|
43
|
+
if (!bootstrap)
|
|
44
|
+
return null;
|
|
45
|
+
const bootstrapFile = inspectPlanningFile(projectRoot, bootstrapConfig_1.RUNTIME_DELIVERY_BOOTSTRAP_PATH);
|
|
46
|
+
const original = bootstrapFile.exists ? bootstrapFile.content : null;
|
|
47
|
+
if (original === bootstrap.content)
|
|
48
|
+
return null;
|
|
49
|
+
return {
|
|
50
|
+
file: bootstrapConfig_1.RUNTIME_DELIVERY_BOOTSTRAP_PATH,
|
|
51
|
+
original,
|
|
52
|
+
updated: bootstrap.content,
|
|
53
|
+
reason: 'Pin the authenticated runtime delivery bootstrap for this project.',
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
const planRuntimeDeliveryGitignore = (projectRoot, bootstrap) => {
|
|
57
|
+
if (!bootstrap)
|
|
58
|
+
return null;
|
|
59
|
+
const file = '.gitignore';
|
|
60
|
+
const gitignoreFile = inspectPlanningFile(projectRoot, file);
|
|
61
|
+
const original = gitignoreFile.exists ? gitignoreFile.content : null;
|
|
62
|
+
const updated = (0, bootstrapConfig_1.addRuntimeDeliveryBootstrapGitignoreRules)(original || '');
|
|
63
|
+
if (updated === original)
|
|
64
|
+
return null;
|
|
65
|
+
return {
|
|
66
|
+
file,
|
|
67
|
+
original,
|
|
68
|
+
updated,
|
|
69
|
+
reason: 'Keep the pinned runtime delivery bootstrap reproducible in clean builds.',
|
|
70
|
+
};
|
|
71
|
+
};
|
|
28
72
|
const shouldApplyAiChange = (change) => change.confidence !== 'low' &&
|
|
29
73
|
(change.decisionType === 'safe_auto_patch' || change.decisionType === 'review_only_patch');
|
|
74
|
+
const isDynamicExpoConfigChange = (change) => /^app\.config\.(?:js|ts|cjs|mjs)$/.test(change.file);
|
|
75
|
+
const reviewOnlyChanges = (changes) => changes.filter(change => change.confidence !== 'low' &&
|
|
76
|
+
(change.decisionType === 'review_only_patch' || isDynamicExpoConfigChange(change)));
|
|
77
|
+
async function confirmReviewOnlyChanges(params) {
|
|
78
|
+
const changesRequiringReview = reviewOnlyChanges(params.changes);
|
|
79
|
+
if (params.dryRun || !changesRequiringReview.length)
|
|
80
|
+
return true;
|
|
81
|
+
if (params.yes) {
|
|
82
|
+
console.log(chalk_1.default.yellow('Review-only AI changes require explicit interactive approval. ' +
|
|
83
|
+
'--yes cannot approve them. No files changed.'));
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
for (const change of changesRequiringReview) {
|
|
87
|
+
console.log(chalk_1.default.yellow(`\nReview-only proposed change: ${change.file}`));
|
|
88
|
+
console.log((0, diff_preview_1.colorizeUnifiedDiff)((0, diff_preview_1.buildUnifiedDiff)({
|
|
89
|
+
projectRoot: params.projectRoot,
|
|
90
|
+
originals: params.originals,
|
|
91
|
+
changes: [change],
|
|
92
|
+
})));
|
|
93
|
+
const answer = await (0, prompts_1.default)({
|
|
94
|
+
type: 'confirm',
|
|
95
|
+
name: 'approve',
|
|
96
|
+
message: `Apply this review-only AI change to ${(0, terminal_safety_1.escapeTerminalControls)(change.file)}? ` +
|
|
97
|
+
(0, terminal_safety_1.escapeTerminalControls)(change.reason),
|
|
98
|
+
initial: false,
|
|
99
|
+
});
|
|
100
|
+
if (!answer.approve) {
|
|
101
|
+
console.log(chalk_1.default.gray('Review-only AI change declined. No files changed.'));
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
30
107
|
const hasCleanGitStatus = (projectRoot, command) => {
|
|
31
108
|
try {
|
|
32
109
|
const status = (0, child_process_1.execSync)(command, {
|
|
@@ -41,30 +118,37 @@ const hasCleanGitStatus = (projectRoot, command) => {
|
|
|
41
118
|
}
|
|
42
119
|
};
|
|
43
120
|
const usesStrictExpoRuntimeAuthority = (projectRoot, virtualConfig) => {
|
|
44
|
-
const
|
|
45
|
-
const configContent =
|
|
46
|
-
?
|
|
121
|
+
const configFile = inspectPlanningFile(projectRoot, 'bundle.drop.config.js');
|
|
122
|
+
const configContent = configFile.exists
|
|
123
|
+
? configFile.content
|
|
47
124
|
: virtualConfig?.content;
|
|
48
125
|
return Boolean(configContent && EXPO_RUNTIME_AUTHORITY_PATTERN.test(configContent));
|
|
49
126
|
};
|
|
50
127
|
const hasCleanGitWorktree = (projectRoot) => hasCleanGitStatus(projectRoot, 'git status --porcelain');
|
|
51
128
|
const restoreNativePrebuild = (backup, reason) => {
|
|
129
|
+
const failedRoot = path_1.default.join(backup.backupDir, reason);
|
|
130
|
+
fs_extra_1.default.mkdirSync(failedRoot);
|
|
52
131
|
for (const directory of ['ios', 'android']) {
|
|
53
132
|
const current = path_1.default.join(backup.projectRoot, directory);
|
|
54
|
-
const failed = path_1.default.join(
|
|
55
|
-
|
|
56
|
-
fs_extra_1.default.
|
|
57
|
-
fs_extra_1.default.
|
|
133
|
+
const failed = path_1.default.join(failedRoot, directory);
|
|
134
|
+
try {
|
|
135
|
+
fs_extra_1.default.lstatSync(current);
|
|
136
|
+
fs_extra_1.default.renameSync(current, failed);
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
if (error.code !== 'ENOENT')
|
|
140
|
+
throw error;
|
|
58
141
|
}
|
|
59
142
|
if (backup.existingDirectories.includes(directory)) {
|
|
143
|
+
(0, safe_file_transaction_1.inspectProjectDirectory)(backup.backupDir, directory);
|
|
60
144
|
fs_extra_1.default.copySync(path_1.default.join(backup.backupDir, directory), current, { preserveTimestamps: true });
|
|
61
145
|
}
|
|
62
146
|
}
|
|
63
147
|
};
|
|
64
148
|
const runLayeredPrebuild = (projectRoot) => {
|
|
65
149
|
const expoCli = require.resolve('expo/bin/cli', { paths: [projectRoot] });
|
|
66
|
-
const backupDir =
|
|
67
|
-
const existingDirectories = ['ios', 'android'].filter(directory =>
|
|
150
|
+
const backupDir = (0, safe_file_transaction_1.createSafeBackupDirectory)(projectRoot, 'prebuild');
|
|
151
|
+
const existingDirectories = ['ios', 'android'].filter(directory => (0, safe_file_transaction_1.inspectProjectDirectory)(projectRoot, directory));
|
|
68
152
|
const backup = { projectRoot, backupDir, existingDirectories };
|
|
69
153
|
for (const directory of existingDirectories) {
|
|
70
154
|
fs_extra_1.default.copySync(path_1.default.join(projectRoot, directory), path_1.default.join(backupDir, directory), {
|
|
@@ -95,20 +179,10 @@ const assertBundleDropPluginPresent = (projectRoot) => {
|
|
|
95
179
|
'For dynamic config, keep the AI-proposed app.config patch and try again.');
|
|
96
180
|
}
|
|
97
181
|
};
|
|
98
|
-
const isSummarizedSetupContext = (
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
const absolutePath = path_1.default.isAbsolute(candidate) ? candidate : path_1.default.resolve(projectRoot, candidate);
|
|
104
|
-
const relativePath = path_1.default.relative(projectRoot, absolutePath).split(path_1.default.sep).join('/');
|
|
105
|
-
if (relativePath.startsWith('../') ||
|
|
106
|
-
path_1.default.isAbsolute(relativePath) ||
|
|
107
|
-
!/^app\.config\.(js|ts|cjs|mjs)$/.test(relativePath)) {
|
|
108
|
-
throw new Error(`Expo reported an unsafe dynamic app config path: ${candidate}. No files changed.`);
|
|
109
|
-
}
|
|
110
|
-
return relativePath;
|
|
111
|
-
};
|
|
182
|
+
const isSummarizedSetupContext = (file) => file.kind === 'package_manifest' ||
|
|
183
|
+
file.kind === 'bundle_drop_config' ||
|
|
184
|
+
file.kind === 'metro_config' ||
|
|
185
|
+
file.path === 'app.json';
|
|
112
186
|
const describeAiDestination = (serverUrl) => {
|
|
113
187
|
const parsed = new URL(serverUrl);
|
|
114
188
|
const isLocal = ['localhost', '127.0.0.1', '::1', '[::1]', '10.0.2.2'].includes(parsed.hostname);
|
|
@@ -121,9 +195,11 @@ const describeAiDestination = (serverUrl) => {
|
|
|
121
195
|
};
|
|
122
196
|
async function requestContextConsent(files, serverUrl, yes) {
|
|
123
197
|
console.log(chalk_1.default.gray(`AI setup destination: ${describeAiDestination(serverUrl)}`));
|
|
198
|
+
const contextSize = files.reduce((total, file) => total + Buffer.byteLength(file.content, 'utf8'), 0);
|
|
199
|
+
console.log(chalk_1.default.gray(`Provider context size: ${contextSize} bytes.`));
|
|
124
200
|
console.log(chalk_1.default.gray('Files proposed for AI setup planning:'));
|
|
125
201
|
files.forEach(file => {
|
|
126
|
-
const disclosure = isSummarizedSetupContext(file
|
|
202
|
+
const disclosure = isSummarizedSetupContext(file) ? 'summary only' : 'full content';
|
|
127
203
|
console.log(chalk_1.default.gray(` - ${file.path} (${file.kind}, ${disclosure})`));
|
|
128
204
|
});
|
|
129
205
|
if (yes)
|
|
@@ -156,14 +232,32 @@ const existingSetupPassesDoctor = async (projectRoot, projectType, detected) =>
|
|
|
156
232
|
return false;
|
|
157
233
|
}
|
|
158
234
|
};
|
|
235
|
+
const assertNoCodePushMigrationResidue = (projectRoot) => {
|
|
236
|
+
const residuePaths = (0, code_push_residue_1.findCodePushResiduePaths)(projectRoot);
|
|
237
|
+
if (!residuePaths.length)
|
|
238
|
+
return;
|
|
239
|
+
const displayedPaths = residuePaths.slice(0, 20).map(filePath => ` - ${filePath}`);
|
|
240
|
+
if (residuePaths.length > displayedPaths.length) {
|
|
241
|
+
displayedPaths.push(` - and ${residuePaths.length - displayedPaths.length} more path(s)`);
|
|
242
|
+
}
|
|
243
|
+
throw new Error('CodePush migration cannot continue while local CodePush references remain outside the ' +
|
|
244
|
+
`provider-patched native entrypoints:\n${displayedPaths.join('\n')}\n` +
|
|
245
|
+
'Remove the listed JS wrappers/imports, custom native references, build hooks, and ' +
|
|
246
|
+
'deployment-key configuration manually, then rerun Bundle Drop setup. No files changed.');
|
|
247
|
+
};
|
|
159
248
|
async function initProjectConfigAi(options = {}) {
|
|
160
249
|
const projectRoot = (0, scanner_1.findProjectRoot)(process.cwd());
|
|
161
250
|
const projectType = (0, expo_1.detectProjectType)({ projectRoot, explicitType: options.projectType });
|
|
162
251
|
const scan = (0, scanner_1.scanProjectForAiSetup)(projectType, projectRoot, options.virtualConfig);
|
|
252
|
+
const bootstrapChange = planRuntimeDeliveryBootstrap(projectRoot, options.runtimeDeliveryBootstrap);
|
|
253
|
+
const bootstrapGitignoreChange = planRuntimeDeliveryGitignore(projectRoot, options.runtimeDeliveryBootstrap);
|
|
163
254
|
assertSetupOwnershipCompatible(projectType, scan.request.detected.expoUpdatesStatus);
|
|
164
|
-
if (
|
|
255
|
+
if (!bootstrapChange &&
|
|
256
|
+
!bootstrapGitignoreChange &&
|
|
257
|
+
await existingSetupPassesDoctor(projectRoot, projectType, scan.request.detected)) {
|
|
165
258
|
console.log(chalk_1.default.green('✅ Bundle Drop setup is already complete. No AI planning is required.'));
|
|
166
259
|
await (0, doctor_1.runDoctor)({ projectType, cwd: projectRoot });
|
|
260
|
+
logRuntimeInitializationNextStep();
|
|
167
261
|
return;
|
|
168
262
|
}
|
|
169
263
|
console.log(chalk_1.default.cyan(`🧠 Bundle Drop AI setup (${projectType})`));
|
|
@@ -183,18 +277,21 @@ async function initProjectConfigAi(options = {}) {
|
|
|
183
277
|
finally {
|
|
184
278
|
loading.stop();
|
|
185
279
|
}
|
|
280
|
+
(0, terminal_safety_1.assertSafeProviderPlan)(plan);
|
|
186
281
|
console.log(chalk_1.default.cyan('\nSetup summary:'));
|
|
187
|
-
console.log(plan.summary);
|
|
188
|
-
plan.warnings.forEach(warning => console.log(chalk_1.default.yellow(`⚠️ ${warning}`)));
|
|
282
|
+
console.log((0, terminal_safety_1.escapeTerminalControls)(plan.summary));
|
|
283
|
+
plan.warnings.forEach(warning => console.log(chalk_1.default.yellow(`⚠️ ${(0, terminal_safety_1.escapeTerminalControls)(warning)}`)));
|
|
189
284
|
plan.actions.forEach(action => {
|
|
190
285
|
const confirmation = action.requiresConfirmation ? ' (confirmation required)' : '';
|
|
191
|
-
console.log(chalk_1.default.gray(` - ${action.type}${confirmation}:
|
|
286
|
+
console.log(chalk_1.default.gray(` - ${(0, terminal_safety_1.escapeTerminalControls)(action.type)}${confirmation}: ` +
|
|
287
|
+
(0, terminal_safety_1.escapeTerminalControls)(action.reason)));
|
|
192
288
|
});
|
|
193
289
|
if (plan.confidence === 'low') {
|
|
194
290
|
if (options.virtualConfig && !options.dryRun) {
|
|
195
|
-
const
|
|
196
|
-
if (!
|
|
197
|
-
|
|
291
|
+
const configFile = (0, safe_file_transaction_1.inspectProjectFile)(projectRoot, 'bundle.drop.config.js');
|
|
292
|
+
if (!configFile.exists) {
|
|
293
|
+
(0, safe_file_transaction_1.writeProjectFileAtomically)(projectRoot, 'bundle.drop.config.js', options.virtualConfig.content);
|
|
294
|
+
const configPath = path_1.default.join(projectRoot, 'bundle.drop.config.js');
|
|
198
295
|
console.log(chalk_1.default.green(`Project config retained at ${configPath}`));
|
|
199
296
|
}
|
|
200
297
|
}
|
|
@@ -217,13 +314,36 @@ async function initProjectConfigAi(options = {}) {
|
|
|
217
314
|
'after reviewing the plan; a new native binary will be required.');
|
|
218
315
|
}
|
|
219
316
|
}
|
|
220
|
-
|
|
317
|
+
if (projectType === 'bare' && scan.request.detected.codePushDetected) {
|
|
318
|
+
if (!options.migrateCodePush && !options.yes) {
|
|
319
|
+
const migrationAnswer = await (0, prompts_1.default)({
|
|
320
|
+
type: 'confirm',
|
|
321
|
+
name: 'migrate',
|
|
322
|
+
message: 'Remove react-native-code-push and migrate native startup ownership to Bundle Drop?',
|
|
323
|
+
initial: false,
|
|
324
|
+
});
|
|
325
|
+
options.migrateCodePush = Boolean(migrationAnswer.migrate);
|
|
326
|
+
}
|
|
327
|
+
if (!options.migrateCodePush) {
|
|
328
|
+
throw new Error('CodePush blocks Bundle Drop setup. Re-run with --migrate-code-push after reviewing ' +
|
|
329
|
+
'the plan; a new native binary will be required.');
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
const shouldMigrateCodePush = projectType === 'bare' &&
|
|
333
|
+
scan.request.detected.codePushDetected &&
|
|
334
|
+
Boolean(options.migrateCodePush);
|
|
335
|
+
if (shouldMigrateCodePush)
|
|
336
|
+
assertNoCodePushMigrationResidue(projectRoot);
|
|
337
|
+
for (const action of plan.actions.filter(action => action.requiresConfirmation &&
|
|
338
|
+
action.type !== 'migrate_expo_updates' &&
|
|
339
|
+
action.type !== 'migrate_codepush')) {
|
|
221
340
|
if (options.yes)
|
|
222
341
|
continue;
|
|
223
342
|
const actionAnswer = await (0, prompts_1.default)({
|
|
224
343
|
type: 'confirm',
|
|
225
344
|
name: 'proceed',
|
|
226
|
-
message: `Proceed with ${action.type}?
|
|
345
|
+
message: `Proceed with ${(0, terminal_safety_1.escapeTerminalControls)(action.type)}? ` +
|
|
346
|
+
(0, terminal_safety_1.escapeTerminalControls)(action.reason),
|
|
227
347
|
initial: false,
|
|
228
348
|
});
|
|
229
349
|
if (!actionAnswer.proceed) {
|
|
@@ -231,15 +351,29 @@ async function initProjectConfigAi(options = {}) {
|
|
|
231
351
|
return;
|
|
232
352
|
}
|
|
233
353
|
}
|
|
234
|
-
const aiChanges = plan.changes.filter(shouldApplyAiChange);
|
|
235
354
|
const originals = new Map(scan.request.files.map(file => [file.path, file.content]));
|
|
236
|
-
(
|
|
355
|
+
if (!await confirmReviewOnlyChanges({
|
|
356
|
+
projectRoot,
|
|
357
|
+
originals,
|
|
358
|
+
changes: plan.changes,
|
|
359
|
+
yes: options.yes,
|
|
360
|
+
dryRun: options.dryRun,
|
|
361
|
+
})) {
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
const aiChanges = plan.changes.filter(shouldApplyAiChange);
|
|
365
|
+
(0, validate_plan_1.validateSetupChangesBeforeApply)({
|
|
366
|
+
projectType,
|
|
367
|
+
originals,
|
|
368
|
+
changes: aiChanges,
|
|
369
|
+
migrateExpoUpdates: Boolean(options.migrateExpoUpdates),
|
|
370
|
+
});
|
|
237
371
|
if (projectType === 'bare') {
|
|
238
372
|
const metroChange = (0, bare_metro_config_1.planBareMetroConfig)(projectRoot);
|
|
239
|
-
const
|
|
240
|
-
const bundleConfigExists =
|
|
373
|
+
const bundleConfigFile = inspectPlanningFile(projectRoot, 'bundle.drop.config.js');
|
|
374
|
+
const bundleConfigExists = bundleConfigFile.exists;
|
|
241
375
|
const bundleConfig = bundleConfigExists
|
|
242
|
-
?
|
|
376
|
+
? bundleConfigFile.content
|
|
243
377
|
: options.virtualConfig?.content;
|
|
244
378
|
const updatedBundleConfig = bundleConfig
|
|
245
379
|
? (0, configure_expo_1.setBundleDropProjectType)(bundleConfig, 'bare')
|
|
@@ -253,11 +387,18 @@ async function initProjectConfigAi(options = {}) {
|
|
|
253
387
|
reason: 'Persist the reviewed bare React Native project type.',
|
|
254
388
|
}
|
|
255
389
|
: null;
|
|
256
|
-
const localChanges = [
|
|
257
|
-
|
|
390
|
+
const localChanges = [
|
|
391
|
+
metroChange,
|
|
392
|
+
bundleConfigChange,
|
|
393
|
+
bootstrapChange,
|
|
394
|
+
bootstrapGitignoreChange,
|
|
395
|
+
].filter((change) => Boolean(change));
|
|
396
|
+
if (!aiChanges.length && !localChanges.length && !shouldMigrateCodePush) {
|
|
258
397
|
console.log(chalk_1.default.gray('No bare native changes are required.'));
|
|
259
|
-
if (!options.dryRun)
|
|
398
|
+
if (!options.dryRun) {
|
|
260
399
|
await (0, doctor_1.runDoctor)({ projectType: 'bare', cwd: projectRoot });
|
|
400
|
+
logRuntimeInitializationNextStep();
|
|
401
|
+
}
|
|
261
402
|
return;
|
|
262
403
|
}
|
|
263
404
|
const bareOriginals = new Map(originals);
|
|
@@ -279,6 +420,10 @@ async function initProjectConfigAi(options = {}) {
|
|
|
279
420
|
originals: bareOriginals,
|
|
280
421
|
changes: previewChanges,
|
|
281
422
|
})));
|
|
423
|
+
if (shouldMigrateCodePush) {
|
|
424
|
+
const command = (0, package_manager_1.codePushRemovalCommand)((0, package_manager_1.detectPackageManager)(projectRoot));
|
|
425
|
+
console.log(chalk_1.default.yellow(`Dependency migration command: ${command.join(' ')}`));
|
|
426
|
+
}
|
|
282
427
|
if (options.dryRun) {
|
|
283
428
|
console.log(chalk_1.default.gray('Dry run complete. No files changed.'));
|
|
284
429
|
return;
|
|
@@ -290,10 +435,21 @@ async function initProjectConfigAi(options = {}) {
|
|
|
290
435
|
console.log(chalk_1.default.gray('No files changed.'));
|
|
291
436
|
return;
|
|
292
437
|
}
|
|
293
|
-
|
|
438
|
+
let dependencyBackup;
|
|
439
|
+
let result;
|
|
294
440
|
let metroResult;
|
|
295
441
|
try {
|
|
296
|
-
(
|
|
442
|
+
if (shouldMigrateCodePush) {
|
|
443
|
+
dependencyBackup = (0, package_manager_1.removeCodePushWithPackageManager)(projectRoot);
|
|
444
|
+
}
|
|
445
|
+
result = (0, apply_setup_plan_1.applySetupPatchPlans)({ projectRoot, projectType, changes: aiChanges });
|
|
446
|
+
(0, validate_plan_1.validateAppliedSetupChanges)({
|
|
447
|
+
projectRoot,
|
|
448
|
+
projectType,
|
|
449
|
+
changes: aiChanges,
|
|
450
|
+
migrateExpoUpdates: false,
|
|
451
|
+
originals,
|
|
452
|
+
});
|
|
297
453
|
if (localChanges.length) {
|
|
298
454
|
metroResult = (0, configure_expo_1.applyExpoConfigurationChanges)({
|
|
299
455
|
projectRoot,
|
|
@@ -305,10 +461,18 @@ async function initProjectConfigAi(options = {}) {
|
|
|
305
461
|
catch (error) {
|
|
306
462
|
if (metroResult)
|
|
307
463
|
(0, configure_expo_1.restoreExpoConfiguration)(metroResult);
|
|
308
|
-
|
|
464
|
+
if (result)
|
|
465
|
+
(0, apply_setup_plan_1.restoreSetupBackups)(result);
|
|
466
|
+
if (dependencyBackup) {
|
|
467
|
+
(0, package_manager_1.restoreDependencyMigration)(dependencyBackup);
|
|
468
|
+
console.log(chalk_1.default.yellow('Package files were restored; reinstall dependencies to repair node_modules.'));
|
|
469
|
+
}
|
|
309
470
|
throw error;
|
|
310
471
|
}
|
|
472
|
+
if (!result)
|
|
473
|
+
throw new Error('Bare setup transaction completed without a backup result.');
|
|
311
474
|
console.log(chalk_1.default.green(`✅ Bare React Native setup complete. Backups: ${result.backupDir}`));
|
|
475
|
+
logRuntimeInitializationNextStep();
|
|
312
476
|
return;
|
|
313
477
|
}
|
|
314
478
|
const hasNativeDirectories = scan.request.detected.hasNativeDirectories;
|
|
@@ -325,7 +489,10 @@ async function initProjectConfigAi(options = {}) {
|
|
|
325
489
|
const unusualAiChanges = aiChanges.filter(change => !deterministicPaths.has(change.file));
|
|
326
490
|
if ((0, configure_expo_1.hasDynamicExpoConfig)(projectRoot)) {
|
|
327
491
|
const evaluatedConfig = (0, expo_1.evaluateExpoConfig)(projectRoot);
|
|
328
|
-
const dynamicConfigFile = authoritativeDynamicExpoConfigFile(projectRoot, evaluatedConfig.dynamicConfigPath);
|
|
492
|
+
const dynamicConfigFile = (0, scanner_1.authoritativeDynamicExpoConfigFile)(projectRoot, evaluatedConfig.dynamicConfigPath);
|
|
493
|
+
if (!dynamicConfigFile) {
|
|
494
|
+
throw new Error('Expo did not identify the authoritative dynamic app config path. No files changed.');
|
|
495
|
+
}
|
|
329
496
|
if (!hasBundleDropPlugin(evaluatedConfig.exp) &&
|
|
330
497
|
!unusualAiChanges.some(change => change.file === dynamicConfigFile)) {
|
|
331
498
|
throw new Error(`Dynamic Expo config requires an allowlisted AI patch for its evaluated root config ` +
|
|
@@ -334,6 +501,7 @@ async function initProjectConfigAi(options = {}) {
|
|
|
334
501
|
}
|
|
335
502
|
const combinedChanges = [
|
|
336
503
|
...deterministic,
|
|
504
|
+
...(bootstrapChange ? [bootstrapChange] : []),
|
|
337
505
|
...unusualAiChanges.map(change => ({
|
|
338
506
|
file: change.file,
|
|
339
507
|
original: originals.get(change.file) ?? null,
|
|
@@ -401,6 +569,13 @@ async function initProjectConfigAi(options = {}) {
|
|
|
401
569
|
projectRoot,
|
|
402
570
|
changes: combinedChanges.filter(change => change.file !== 'package.json'),
|
|
403
571
|
});
|
|
572
|
+
(0, validate_plan_1.validateAppliedSetupChanges)({
|
|
573
|
+
projectRoot,
|
|
574
|
+
projectType: 'expo',
|
|
575
|
+
changes: unusualAiChanges,
|
|
576
|
+
migrateExpoUpdates: Boolean(options.migrateExpoUpdates),
|
|
577
|
+
originals,
|
|
578
|
+
});
|
|
404
579
|
assertBundleDropPluginPresent(projectRoot);
|
|
405
580
|
if (hasNativeDirectories && options.prebuild) {
|
|
406
581
|
prebuildBackup = runLayeredPrebuild(projectRoot);
|
|
@@ -420,6 +595,7 @@ async function initProjectConfigAi(options = {}) {
|
|
|
420
595
|
throw error;
|
|
421
596
|
}
|
|
422
597
|
console.log(chalk_1.default.green(`✅ Expo setup complete. Backups: ${applyResult.backupDir}`));
|
|
598
|
+
logRuntimeInitializationNextStep();
|
|
423
599
|
if (!hasNativeDirectories) {
|
|
424
600
|
console.log(chalk_1.default.gray('Run expo run:*, explicit prebuild/manual build, or EAS Build to generate native integration.'));
|
|
425
601
|
}
|
|
@@ -3,6 +3,7 @@ export declare const findCredentialLikeLiteral: (content: string) => string | nu
|
|
|
3
3
|
export declare const isTrustedAiPlanningServer: (serverUrl: string) => boolean;
|
|
4
4
|
export declare const isBundleDropHostedAiPlanningServer: (serverUrl: string) => boolean;
|
|
5
5
|
export declare function findProjectRoot(startDir?: string): string;
|
|
6
|
+
export declare const authoritativeDynamicExpoConfigFile: (projectRoot: string, candidate: unknown) => string | null;
|
|
6
7
|
export declare function scanProjectForAiSetup(projectType: AiSetupProjectType, startDir?: string, virtualConfig?: {
|
|
7
8
|
content: string;
|
|
8
9
|
serverUrl: string;
|