@gfean/react-native-bundle-drop 0.4.4 → 0.4.5

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.
@@ -1,131 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.initNativeConfigAi = initNativeConfigAi;
7
- const chalk_1 = __importDefault(require("chalk"));
8
- const prompts_1 = __importDefault(require("prompts"));
9
- const apply_plan_1 = require("./apply-plan");
10
- const backend_client_1 = require("./backend-client");
11
- const diff_preview_1 = require("./diff-preview");
12
- const scanner_1 = require("./scanner");
13
- const validate_plan_1 = require("./validate-plan");
14
- const ui_1 = require("../../utils/ui");
15
- const DOCS_NATIVE_SETUP_URL = 'https://bundledrop.app/docs/installation#manual-native-setup';
16
- const shouldApply = (change) => (change.confidence === 'high' && change.decisionType === 'safe_auto_patch') ||
17
- ((change.confidence === 'high' || change.confidence === 'medium') &&
18
- change.decisionType === 'review_only_patch');
19
- const addOrReplaceChange = (changes, change) => {
20
- if (!change || !shouldApply(change))
21
- return;
22
- changes.set(change.file, change);
23
- };
24
- async function initNativeConfigAi() {
25
- console.log(chalk_1.default.cyan('🧠 BundleDrop AI native initialization'));
26
- const scan = (0, scanner_1.scanProjectForAiNativeInit)();
27
- console.log(chalk_1.default.gray('Files that will be sent for AI planning:'));
28
- scan.request.files.forEach(file => {
29
- const mode = (0, scanner_1.isSummaryOnlyAiContextFile)(file.path) ? ' (summary only)' : '';
30
- console.log(chalk_1.default.gray(` - ${file.path}${mode}`));
31
- });
32
- const host = scan.serverUrl.replace(/^https?:\/\//, '').replace(/\/.*$/, '');
33
- console.log(chalk_1.default.gray(`Destination: ${host}`));
34
- const sendAnswer = await (0, prompts_1.default)({
35
- type: 'confirm',
36
- name: 'send',
37
- message: [
38
- 'BundleDrop will analyze a limited native setup context of your app to generate a safe patch plan.',
39
- '',
40
- 'Included:',
41
- ' - native entrypoints are sent as-is',
42
- ' - project config/build files are summarized where possible',
43
- ' - prompts, patches, and project files are not stored by BundleDrop',
44
- '',
45
- 'Send this setup context for AI planning? (y/n)',
46
- ].join('\n'),
47
- initial: true,
48
- });
49
- if (!sendAnswer.send) {
50
- console.log(chalk_1.default.gray('No files sent. No files changed.'));
51
- return;
52
- }
53
- const loading = (0, ui_1.startLoadingStatus)('Requesting AI native setup plan');
54
- let plan;
55
- try {
56
- plan = await (0, backend_client_1.requestAiInitPlan)({
57
- serverUrl: scan.serverUrl,
58
- authToken: scan.authToken,
59
- request: scan.request,
60
- });
61
- }
62
- finally {
63
- loading.stop();
64
- }
65
- console.log(chalk_1.default.cyan('\nSummary:'));
66
- console.log(plan.summary);
67
- if (plan.confidence === 'low') {
68
- console.log(chalk_1.default.yellow(`AI confidence is low, so no native files will be changed.\n` +
69
- `Please use the manual setup guide: ${DOCS_NATIVE_SETUP_URL}`));
70
- return;
71
- }
72
- const selectedChanges = new Map();
73
- plan.changes.forEach(change => addOrReplaceChange(selectedChanges, change));
74
- for (const question of plan.questions) {
75
- console.log(chalk_1.default.yellow(`\n${question.message}`));
76
- const answer = await (0, prompts_1.default)({
77
- type: 'confirm',
78
- name: 'confirmed',
79
- message: question.prompt,
80
- initial: question.recommendedChoice === 'yes',
81
- });
82
- const confirmed = Boolean(answer.confirmed);
83
- if (confirmed) {
84
- addOrReplaceChange(selectedChanges, question.yesAction);
85
- }
86
- else if (question.noAction === 'manual_fallback') {
87
- if (question.file)
88
- selectedChanges.delete(question.file);
89
- console.log(chalk_1.default.yellow(`Manual setup required. See ${DOCS_NATIVE_SETUP_URL}`));
90
- }
91
- else if (question.noAction === 'skip') {
92
- if (question.file)
93
- selectedChanges.delete(question.file);
94
- }
95
- else {
96
- addOrReplaceChange(selectedChanges, question.noAction);
97
- }
98
- }
99
- const changes = [...selectedChanges.values()];
100
- if (!changes.length) {
101
- console.log(chalk_1.default.gray('No native changes to apply.'));
102
- console.log(chalk_1.default.gray(`If you expected changes, check that this React Native project has standard native entrypoints and no ambiguous custom bundle-loading setup. You can also continue with the manual setup guide: ${DOCS_NATIVE_SETUP_URL}`));
103
- return;
104
- }
105
- const originals = new Map(scan.request.files.map(file => [file.path, file.content]));
106
- (0, validate_plan_1.validateChangesBeforeApply)({ originals, changes });
107
- console.log(chalk_1.default.cyan('\nProposed diff:'));
108
- console.log((0, diff_preview_1.colorizeUnifiedDiff)((0, diff_preview_1.buildUnifiedDiff)({ projectRoot: scan.projectRoot, originals, changes })));
109
- const finalAnswer = await (0, prompts_1.default)({
110
- type: 'confirm',
111
- name: 'apply',
112
- message: 'Apply these AI-generated native changes?',
113
- initial: true,
114
- });
115
- if (!finalAnswer.apply) {
116
- console.log(chalk_1.default.gray('No files changed.'));
117
- return;
118
- }
119
- const applyResult = (0, apply_plan_1.applyPatchPlans)({ projectRoot: scan.projectRoot, changes });
120
- try {
121
- (0, validate_plan_1.validateAppliedChanges)(scan.projectRoot, changes);
122
- }
123
- catch (error) {
124
- (0, apply_plan_1.restoreBackups)(applyResult);
125
- throw error;
126
- }
127
- console.log(chalk_1.default.green('✅ AI native changes applied.'));
128
- console.log(chalk_1.default.gray(`Backups saved at ${applyResult.backupDir}`));
129
- console.log(chalk_1.default.gray('Recommended next check: review the native file changes and run your usual app build before shipping.'));
130
- }
131
- exports.default = initNativeConfigAi;