@gfean/react-native-bundle-drop 0.4.6 → 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 +166 -79
- 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 +228 -43
- 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 +246 -32
- package/lib/CLI/scripts/login-cli.js +35 -10
- 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/CLI/scripts/sight-artifacts.d.ts +17 -0
- package/lib/CLI/scripts/sight-artifacts.js +204 -0
- package/lib/CLI/scripts/sight-cli.d.ts +10 -0
- package/lib/CLI/scripts/sight-cli.js +127 -0
- package/lib/CLI/scripts/sight-session.d.ts +14 -0
- package/lib/CLI/scripts/sight-session.js +192 -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
|
@@ -2,6 +2,7 @@ import type { ProjectType } from '../../../expo';
|
|
|
2
2
|
export type InitProjectOptions = {
|
|
3
3
|
projectType?: ProjectType;
|
|
4
4
|
dryRun?: boolean;
|
|
5
|
+
migrateCodePush?: boolean;
|
|
5
6
|
migrateExpoUpdates?: boolean;
|
|
6
7
|
prebuild?: boolean;
|
|
7
8
|
yes?: boolean;
|
|
@@ -12,6 +13,9 @@ export type InitProjectOptions = {
|
|
|
12
13
|
projectSlug: string;
|
|
13
14
|
authToken: string;
|
|
14
15
|
};
|
|
16
|
+
runtimeDeliveryBootstrap?: {
|
|
17
|
+
content: string;
|
|
18
|
+
};
|
|
15
19
|
};
|
|
16
20
|
export declare function initProjectConfigAi(options?: InitProjectOptions): Promise<void>;
|
|
17
21
|
export default initProjectConfigAi;
|
|
@@ -17,15 +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';
|
|
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';
|
|
25
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
|
+
};
|
|
26
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
|
+
};
|
|
27
72
|
const shouldApplyAiChange = (change) => change.confidence !== 'low' &&
|
|
28
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
|
+
}
|
|
29
107
|
const hasCleanGitStatus = (projectRoot, command) => {
|
|
30
108
|
try {
|
|
31
109
|
const status = (0, child_process_1.execSync)(command, {
|
|
@@ -40,30 +118,37 @@ const hasCleanGitStatus = (projectRoot, command) => {
|
|
|
40
118
|
}
|
|
41
119
|
};
|
|
42
120
|
const usesStrictExpoRuntimeAuthority = (projectRoot, virtualConfig) => {
|
|
43
|
-
const
|
|
44
|
-
const configContent =
|
|
45
|
-
?
|
|
121
|
+
const configFile = inspectPlanningFile(projectRoot, 'bundle.drop.config.js');
|
|
122
|
+
const configContent = configFile.exists
|
|
123
|
+
? configFile.content
|
|
46
124
|
: virtualConfig?.content;
|
|
47
125
|
return Boolean(configContent && EXPO_RUNTIME_AUTHORITY_PATTERN.test(configContent));
|
|
48
126
|
};
|
|
49
127
|
const hasCleanGitWorktree = (projectRoot) => hasCleanGitStatus(projectRoot, 'git status --porcelain');
|
|
50
128
|
const restoreNativePrebuild = (backup, reason) => {
|
|
129
|
+
const failedRoot = path_1.default.join(backup.backupDir, reason);
|
|
130
|
+
fs_extra_1.default.mkdirSync(failedRoot);
|
|
51
131
|
for (const directory of ['ios', 'android']) {
|
|
52
132
|
const current = path_1.default.join(backup.projectRoot, directory);
|
|
53
|
-
const failed = path_1.default.join(
|
|
54
|
-
|
|
55
|
-
fs_extra_1.default.
|
|
56
|
-
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;
|
|
57
141
|
}
|
|
58
142
|
if (backup.existingDirectories.includes(directory)) {
|
|
143
|
+
(0, safe_file_transaction_1.inspectProjectDirectory)(backup.backupDir, directory);
|
|
59
144
|
fs_extra_1.default.copySync(path_1.default.join(backup.backupDir, directory), current, { preserveTimestamps: true });
|
|
60
145
|
}
|
|
61
146
|
}
|
|
62
147
|
};
|
|
63
148
|
const runLayeredPrebuild = (projectRoot) => {
|
|
64
149
|
const expoCli = require.resolve('expo/bin/cli', { paths: [projectRoot] });
|
|
65
|
-
const backupDir =
|
|
66
|
-
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));
|
|
67
152
|
const backup = { projectRoot, backupDir, existingDirectories };
|
|
68
153
|
for (const directory of existingDirectories) {
|
|
69
154
|
fs_extra_1.default.copySync(path_1.default.join(projectRoot, directory), path_1.default.join(backupDir, directory), {
|
|
@@ -94,20 +179,10 @@ const assertBundleDropPluginPresent = (projectRoot) => {
|
|
|
94
179
|
'For dynamic config, keep the AI-proposed app.config patch and try again.');
|
|
95
180
|
}
|
|
96
181
|
};
|
|
97
|
-
const isSummarizedSetupContext = (
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
const absolutePath = path_1.default.isAbsolute(candidate) ? candidate : path_1.default.resolve(projectRoot, candidate);
|
|
103
|
-
const relativePath = path_1.default.relative(projectRoot, absolutePath).split(path_1.default.sep).join('/');
|
|
104
|
-
if (relativePath.startsWith('../') ||
|
|
105
|
-
path_1.default.isAbsolute(relativePath) ||
|
|
106
|
-
!/^app\.config\.(js|ts|cjs|mjs)$/.test(relativePath)) {
|
|
107
|
-
throw new Error(`Expo reported an unsafe dynamic app config path: ${candidate}. No files changed.`);
|
|
108
|
-
}
|
|
109
|
-
return relativePath;
|
|
110
|
-
};
|
|
182
|
+
const isSummarizedSetupContext = (file) => file.kind === 'package_manifest' ||
|
|
183
|
+
file.kind === 'bundle_drop_config' ||
|
|
184
|
+
file.kind === 'metro_config' ||
|
|
185
|
+
file.path === 'app.json';
|
|
111
186
|
const describeAiDestination = (serverUrl) => {
|
|
112
187
|
const parsed = new URL(serverUrl);
|
|
113
188
|
const isLocal = ['localhost', '127.0.0.1', '::1', '[::1]', '10.0.2.2'].includes(parsed.hostname);
|
|
@@ -120,9 +195,11 @@ const describeAiDestination = (serverUrl) => {
|
|
|
120
195
|
};
|
|
121
196
|
async function requestContextConsent(files, serverUrl, yes) {
|
|
122
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.`));
|
|
123
200
|
console.log(chalk_1.default.gray('Files proposed for AI setup planning:'));
|
|
124
201
|
files.forEach(file => {
|
|
125
|
-
const disclosure = isSummarizedSetupContext(file
|
|
202
|
+
const disclosure = isSummarizedSetupContext(file) ? 'summary only' : 'full content';
|
|
126
203
|
console.log(chalk_1.default.gray(` - ${file.path} (${file.kind}, ${disclosure})`));
|
|
127
204
|
});
|
|
128
205
|
if (yes)
|
|
@@ -155,14 +232,32 @@ const existingSetupPassesDoctor = async (projectRoot, projectType, detected) =>
|
|
|
155
232
|
return false;
|
|
156
233
|
}
|
|
157
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
|
+
};
|
|
158
248
|
async function initProjectConfigAi(options = {}) {
|
|
159
249
|
const projectRoot = (0, scanner_1.findProjectRoot)(process.cwd());
|
|
160
250
|
const projectType = (0, expo_1.detectProjectType)({ projectRoot, explicitType: options.projectType });
|
|
161
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);
|
|
162
254
|
assertSetupOwnershipCompatible(projectType, scan.request.detected.expoUpdatesStatus);
|
|
163
|
-
if (
|
|
255
|
+
if (!bootstrapChange &&
|
|
256
|
+
!bootstrapGitignoreChange &&
|
|
257
|
+
await existingSetupPassesDoctor(projectRoot, projectType, scan.request.detected)) {
|
|
164
258
|
console.log(chalk_1.default.green('✅ Bundle Drop setup is already complete. No AI planning is required.'));
|
|
165
259
|
await (0, doctor_1.runDoctor)({ projectType, cwd: projectRoot });
|
|
260
|
+
logRuntimeInitializationNextStep();
|
|
166
261
|
return;
|
|
167
262
|
}
|
|
168
263
|
console.log(chalk_1.default.cyan(`🧠 Bundle Drop AI setup (${projectType})`));
|
|
@@ -182,15 +277,26 @@ async function initProjectConfigAi(options = {}) {
|
|
|
182
277
|
finally {
|
|
183
278
|
loading.stop();
|
|
184
279
|
}
|
|
280
|
+
(0, terminal_safety_1.assertSafeProviderPlan)(plan);
|
|
185
281
|
console.log(chalk_1.default.cyan('\nSetup summary:'));
|
|
186
|
-
console.log(plan.summary);
|
|
187
|
-
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)}`)));
|
|
188
284
|
plan.actions.forEach(action => {
|
|
189
285
|
const confirmation = action.requiresConfirmation ? ' (confirmation required)' : '';
|
|
190
|
-
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)));
|
|
191
288
|
});
|
|
192
289
|
if (plan.confidence === 'low') {
|
|
193
|
-
|
|
290
|
+
if (options.virtualConfig && !options.dryRun) {
|
|
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');
|
|
295
|
+
console.log(chalk_1.default.green(`Project config retained at ${configPath}`));
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
console.log(chalk_1.default.yellow('AI confidence is low. Native and Expo setup files were not changed.'));
|
|
299
|
+
console.log(chalk_1.default.gray(`Manual setup: ${DOCS_MANUAL_SETUP_URL}`));
|
|
194
300
|
return;
|
|
195
301
|
}
|
|
196
302
|
if (projectType === 'expo' && scan.request.detected.expoUpdatesStatus === 'active') {
|
|
@@ -208,13 +314,36 @@ async function initProjectConfigAi(options = {}) {
|
|
|
208
314
|
'after reviewing the plan; a new native binary will be required.');
|
|
209
315
|
}
|
|
210
316
|
}
|
|
211
|
-
|
|
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')) {
|
|
212
340
|
if (options.yes)
|
|
213
341
|
continue;
|
|
214
342
|
const actionAnswer = await (0, prompts_1.default)({
|
|
215
343
|
type: 'confirm',
|
|
216
344
|
name: 'proceed',
|
|
217
|
-
message: `Proceed with ${action.type}?
|
|
345
|
+
message: `Proceed with ${(0, terminal_safety_1.escapeTerminalControls)(action.type)}? ` +
|
|
346
|
+
(0, terminal_safety_1.escapeTerminalControls)(action.reason),
|
|
218
347
|
initial: false,
|
|
219
348
|
});
|
|
220
349
|
if (!actionAnswer.proceed) {
|
|
@@ -222,15 +351,29 @@ async function initProjectConfigAi(options = {}) {
|
|
|
222
351
|
return;
|
|
223
352
|
}
|
|
224
353
|
}
|
|
225
|
-
const aiChanges = plan.changes.filter(shouldApplyAiChange);
|
|
226
354
|
const originals = new Map(scan.request.files.map(file => [file.path, file.content]));
|
|
227
|
-
(
|
|
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
|
+
});
|
|
228
371
|
if (projectType === 'bare') {
|
|
229
372
|
const metroChange = (0, bare_metro_config_1.planBareMetroConfig)(projectRoot);
|
|
230
|
-
const
|
|
231
|
-
const bundleConfigExists =
|
|
373
|
+
const bundleConfigFile = inspectPlanningFile(projectRoot, 'bundle.drop.config.js');
|
|
374
|
+
const bundleConfigExists = bundleConfigFile.exists;
|
|
232
375
|
const bundleConfig = bundleConfigExists
|
|
233
|
-
?
|
|
376
|
+
? bundleConfigFile.content
|
|
234
377
|
: options.virtualConfig?.content;
|
|
235
378
|
const updatedBundleConfig = bundleConfig
|
|
236
379
|
? (0, configure_expo_1.setBundleDropProjectType)(bundleConfig, 'bare')
|
|
@@ -244,11 +387,18 @@ async function initProjectConfigAi(options = {}) {
|
|
|
244
387
|
reason: 'Persist the reviewed bare React Native project type.',
|
|
245
388
|
}
|
|
246
389
|
: null;
|
|
247
|
-
const localChanges = [
|
|
248
|
-
|
|
390
|
+
const localChanges = [
|
|
391
|
+
metroChange,
|
|
392
|
+
bundleConfigChange,
|
|
393
|
+
bootstrapChange,
|
|
394
|
+
bootstrapGitignoreChange,
|
|
395
|
+
].filter((change) => Boolean(change));
|
|
396
|
+
if (!aiChanges.length && !localChanges.length && !shouldMigrateCodePush) {
|
|
249
397
|
console.log(chalk_1.default.gray('No bare native changes are required.'));
|
|
250
|
-
if (!options.dryRun)
|
|
398
|
+
if (!options.dryRun) {
|
|
251
399
|
await (0, doctor_1.runDoctor)({ projectType: 'bare', cwd: projectRoot });
|
|
400
|
+
logRuntimeInitializationNextStep();
|
|
401
|
+
}
|
|
252
402
|
return;
|
|
253
403
|
}
|
|
254
404
|
const bareOriginals = new Map(originals);
|
|
@@ -270,6 +420,10 @@ async function initProjectConfigAi(options = {}) {
|
|
|
270
420
|
originals: bareOriginals,
|
|
271
421
|
changes: previewChanges,
|
|
272
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
|
+
}
|
|
273
427
|
if (options.dryRun) {
|
|
274
428
|
console.log(chalk_1.default.gray('Dry run complete. No files changed.'));
|
|
275
429
|
return;
|
|
@@ -281,10 +435,21 @@ async function initProjectConfigAi(options = {}) {
|
|
|
281
435
|
console.log(chalk_1.default.gray('No files changed.'));
|
|
282
436
|
return;
|
|
283
437
|
}
|
|
284
|
-
|
|
438
|
+
let dependencyBackup;
|
|
439
|
+
let result;
|
|
285
440
|
let metroResult;
|
|
286
441
|
try {
|
|
287
|
-
(
|
|
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
|
+
});
|
|
288
453
|
if (localChanges.length) {
|
|
289
454
|
metroResult = (0, configure_expo_1.applyExpoConfigurationChanges)({
|
|
290
455
|
projectRoot,
|
|
@@ -296,10 +461,18 @@ async function initProjectConfigAi(options = {}) {
|
|
|
296
461
|
catch (error) {
|
|
297
462
|
if (metroResult)
|
|
298
463
|
(0, configure_expo_1.restoreExpoConfiguration)(metroResult);
|
|
299
|
-
|
|
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
|
+
}
|
|
300
470
|
throw error;
|
|
301
471
|
}
|
|
472
|
+
if (!result)
|
|
473
|
+
throw new Error('Bare setup transaction completed without a backup result.');
|
|
302
474
|
console.log(chalk_1.default.green(`✅ Bare React Native setup complete. Backups: ${result.backupDir}`));
|
|
475
|
+
logRuntimeInitializationNextStep();
|
|
303
476
|
return;
|
|
304
477
|
}
|
|
305
478
|
const hasNativeDirectories = scan.request.detected.hasNativeDirectories;
|
|
@@ -316,7 +489,10 @@ async function initProjectConfigAi(options = {}) {
|
|
|
316
489
|
const unusualAiChanges = aiChanges.filter(change => !deterministicPaths.has(change.file));
|
|
317
490
|
if ((0, configure_expo_1.hasDynamicExpoConfig)(projectRoot)) {
|
|
318
491
|
const evaluatedConfig = (0, expo_1.evaluateExpoConfig)(projectRoot);
|
|
319
|
-
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
|
+
}
|
|
320
496
|
if (!hasBundleDropPlugin(evaluatedConfig.exp) &&
|
|
321
497
|
!unusualAiChanges.some(change => change.file === dynamicConfigFile)) {
|
|
322
498
|
throw new Error(`Dynamic Expo config requires an allowlisted AI patch for its evaluated root config ` +
|
|
@@ -325,6 +501,7 @@ async function initProjectConfigAi(options = {}) {
|
|
|
325
501
|
}
|
|
326
502
|
const combinedChanges = [
|
|
327
503
|
...deterministic,
|
|
504
|
+
...(bootstrapChange ? [bootstrapChange] : []),
|
|
328
505
|
...unusualAiChanges.map(change => ({
|
|
329
506
|
file: change.file,
|
|
330
507
|
original: originals.get(change.file) ?? null,
|
|
@@ -392,6 +569,13 @@ async function initProjectConfigAi(options = {}) {
|
|
|
392
569
|
projectRoot,
|
|
393
570
|
changes: combinedChanges.filter(change => change.file !== 'package.json'),
|
|
394
571
|
});
|
|
572
|
+
(0, validate_plan_1.validateAppliedSetupChanges)({
|
|
573
|
+
projectRoot,
|
|
574
|
+
projectType: 'expo',
|
|
575
|
+
changes: unusualAiChanges,
|
|
576
|
+
migrateExpoUpdates: Boolean(options.migrateExpoUpdates),
|
|
577
|
+
originals,
|
|
578
|
+
});
|
|
395
579
|
assertBundleDropPluginPresent(projectRoot);
|
|
396
580
|
if (hasNativeDirectories && options.prebuild) {
|
|
397
581
|
prebuildBackup = runLayeredPrebuild(projectRoot);
|
|
@@ -411,6 +595,7 @@ async function initProjectConfigAi(options = {}) {
|
|
|
411
595
|
throw error;
|
|
412
596
|
}
|
|
413
597
|
console.log(chalk_1.default.green(`✅ Expo setup complete. Backups: ${applyResult.backupDir}`));
|
|
598
|
+
logRuntimeInitializationNextStep();
|
|
414
599
|
if (!hasNativeDirectories) {
|
|
415
600
|
console.log(chalk_1.default.gray('Run expo run:*, explicit prebuild/manual build, or EAS Build to generate native integration.'));
|
|
416
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;
|