@gfean/react-native-bundle-drop 0.3.5 → 0.3.6
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/ios/BundleDropLocator.h +11 -0
- package/ios/BundleDropLocator.swift +1 -1
- package/lib/CLI/cli.js +56 -6
- package/lib/CLI/scripts/aipowered/apply-plan.d.ts +10 -0
- package/lib/CLI/scripts/aipowered/apply-plan.js +50 -0
- package/lib/CLI/scripts/aipowered/backend-client.d.ts +6 -0
- package/lib/CLI/scripts/aipowered/backend-client.js +34 -0
- package/lib/CLI/scripts/aipowered/diff-preview.d.ts +7 -0
- package/lib/CLI/scripts/aipowered/diff-preview.js +33 -0
- package/lib/CLI/scripts/aipowered/init-native-config.d.ts +2 -0
- package/lib/CLI/scripts/aipowered/init-native-config.js +131 -0
- package/lib/CLI/scripts/aipowered/scanner.d.ts +5 -0
- package/lib/CLI/scripts/aipowered/scanner.js +349 -0
- package/lib/CLI/scripts/aipowered/types.d.ts +53 -0
- package/lib/CLI/scripts/aipowered/types.js +2 -0
- package/lib/CLI/scripts/aipowered/validate-plan.d.ts +8 -0
- package/lib/CLI/scripts/aipowered/validate-plan.js +164 -0
- package/lib/CLI/scripts/init-config.js +10 -5
- package/lib/CLI/scripts/init-native-config.js +1 -1
- package/lib/CLI/scripts/post-init.js +7 -18
- package/lib/CLI/scripts/upload-cli.d.ts +2 -0
- package/lib/CLI/scripts/upload-cli.js +53 -25
- package/lib/CLI/utils/ui.d.ts +3 -0
- package/lib/CLI/utils/ui.js +26 -0
- package/lib/api/clientApi.d.ts +2 -1
- package/lib/api/clientApi.js +9 -0
- package/lib/api/types.d.ts +17 -0
- package/lib/context.d.ts +4 -4
- package/lib/context.js +2 -2
- package/lib/fs/bundlePointer.d.ts +2 -0
- package/lib/fs/bundlePointer.js +14 -4
- package/lib/index.d.ts +6 -3
- package/lib/index.js +5 -1
- package/lib/injectImageResolver.js +6 -15
- package/lib/loadConfig.d.ts +4 -4
- package/lib/manager/downloadAndInstall.d.ts +3 -0
- package/lib/manager/downloadAndInstall.js +23 -3
- package/lib/manager/reporting.d.ts +2 -0
- package/lib/manager/reporting.js +25 -0
- package/lib/manager/rollbackState.d.ts +25 -8
- package/lib/manager/rollbackState.js +87 -22
- package/lib/manager/updateCheck.js +15 -1
- package/lib/manager/updateState.d.ts +5 -1
- package/lib/manager/updateState.js +20 -11
- package/lib/runtime/service.d.ts +28 -0
- package/lib/runtime/service.js +134 -10
- package/lib/scripts/bundle.d.ts +4 -1
- package/lib/scripts/bundle.js +41 -28
- package/lib/scripts/projectRoot.d.ts +1 -0
- package/lib/scripts/projectRoot.js +54 -0
- package/lib/scripts/upload-bundle.d.ts +2 -1
- package/lib/scripts/upload-bundle.js +46 -37
- package/lib/useBundleDrop.d.ts +2 -0
- package/lib/useBundleDrop.js +1 -0
- package/package.json +3 -2
package/lib/CLI/cli.js
CHANGED
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.buildProgram = void 0;
|
|
8
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
9
|
const chalk_1 = __importDefault(require("chalk"));
|
|
9
10
|
const commander_1 = require("commander");
|
|
10
11
|
const figures_1 = __importDefault(require("figures"));
|
|
@@ -50,6 +51,38 @@ const logInvalidAuthFile = () => {
|
|
|
50
51
|
`CLI docs: ${DOCS_CLI_URL}\n` +
|
|
51
52
|
`CI/CD docs: ${DOCS_CI_CD_URL}`);
|
|
52
53
|
};
|
|
54
|
+
const fetchFreshAuthContext = async (params) => {
|
|
55
|
+
try {
|
|
56
|
+
const response = await axios_1.default.get(`${params.serverUrl}/auth/cli/context`, {
|
|
57
|
+
headers: {
|
|
58
|
+
Accept: 'application/json',
|
|
59
|
+
Authorization: `Bearer ${params.token}`,
|
|
60
|
+
},
|
|
61
|
+
timeout: 15000,
|
|
62
|
+
});
|
|
63
|
+
const context = response.data || {};
|
|
64
|
+
return {
|
|
65
|
+
user: context.email || context.firstName || context.lastName
|
|
66
|
+
? {
|
|
67
|
+
email: context.email,
|
|
68
|
+
firstName: context.firstName,
|
|
69
|
+
lastName: context.lastName,
|
|
70
|
+
}
|
|
71
|
+
: undefined,
|
|
72
|
+
projects: Array.isArray(context.projects) ? context.projects : [],
|
|
73
|
+
organizations: Array.isArray(context.organizations) ? context.organizations : [],
|
|
74
|
+
memberships: Array.isArray(context.memberships) ? context.memberships : [],
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
console.log(chalk_1.default.yellow('⚠️ Could not refresh BundleDrop project list; using cached login context.'));
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const writeStoredAuthData = (tokenPath, data) => {
|
|
83
|
+
fs_1.default.mkdirSync(path_1.default.dirname(tokenPath), { recursive: true });
|
|
84
|
+
fs_1.default.writeFileSync(tokenPath, JSON.stringify(data, null, 2), 'utf8');
|
|
85
|
+
};
|
|
53
86
|
const buildProgram = () => {
|
|
54
87
|
const program = new commander_1.Command();
|
|
55
88
|
program
|
|
@@ -82,6 +115,8 @@ ${chalk_1.default.gray('CI/CD →')} ${chalk_1.default.underline.gray(DOCS_CI_CD
|
|
|
82
115
|
.option('--release-notes <text>', 'Release notes (max 2000 chars)')
|
|
83
116
|
.option('--token <token>', 'Personal Access Token (alternative to `bundle-drop login`)')
|
|
84
117
|
.option('--author <name>', 'Override the author name stored with the bundle')
|
|
118
|
+
.option('--sourcemap', 'Generate source maps alongside the bundle for error tracking')
|
|
119
|
+
.option('--artifact-dir <path>', 'Copy bundle, source map, and result JSON to this directory before cleanup')
|
|
85
120
|
.description(chalk_1.default.whiteBright('Bundle and upload an OTA zip to the server'))
|
|
86
121
|
.addHelpText('after', `
|
|
87
122
|
${chalk_1.default.bold('Examples:')}
|
|
@@ -90,6 +125,7 @@ ${chalk_1.default.bold('Examples:')}
|
|
|
90
125
|
${chalk_1.default.gray('bundle-drop upload android --buildgradle-path android/app/build.gradle --channel QA --release-notes "Bug fixes"')}
|
|
91
126
|
${chalk_1.default.gray('bundle-drop upload android --version 1.2.3 --channel General --runtimeVersion 3.0.0')}
|
|
92
127
|
${chalk_1.default.gray('bundle-drop upload android --version 1.2.3 --channel General --token bdp_pat_xxx')}
|
|
128
|
+
${chalk_1.default.gray('bundle-drop upload android --version 1.2.3 --channel General --sourcemap --artifact-dir ./build/bundledrop')}
|
|
93
129
|
|
|
94
130
|
${chalk_1.default.gray('Uploading docs →')} ${chalk_1.default.underline.gray(DOCS_UPLOADING_URL)}
|
|
95
131
|
${chalk_1.default.gray('CI/CD docs →')} ${chalk_1.default.underline.gray(DOCS_CI_CD_URL)}
|
|
@@ -146,10 +182,19 @@ ${chalk_1.default.gray('CI/CD docs →')} ${chalk_1.default.underline.gray(DOCS_
|
|
|
146
182
|
logInvalidAuthFile();
|
|
147
183
|
return;
|
|
148
184
|
}
|
|
185
|
+
const serverUrl = normalizeServerUrl(data.serverUrl || data.baseUrl || process.env.BUNDLE_DROP_SERVER_URL);
|
|
186
|
+
const freshContext = await fetchFreshAuthContext({
|
|
187
|
+
serverUrl,
|
|
188
|
+
token: data.token,
|
|
189
|
+
});
|
|
190
|
+
const initData = freshContext ? { ...data, ...freshContext } : data;
|
|
191
|
+
if (freshContext) {
|
|
192
|
+
writeStoredAuthData(authState.tokenPath, initData);
|
|
193
|
+
}
|
|
149
194
|
await require('../CLI/scripts/init-config').initConfig({
|
|
150
|
-
serverUrl
|
|
151
|
-
projects:
|
|
152
|
-
organizations:
|
|
195
|
+
serverUrl,
|
|
196
|
+
projects: initData.projects || [],
|
|
197
|
+
organizations: initData.organizations || [],
|
|
153
198
|
downloadApiKey: data.downloadApiKey || '',
|
|
154
199
|
authToken: data.token,
|
|
155
200
|
});
|
|
@@ -157,9 +202,14 @@ ${chalk_1.default.gray('CI/CD docs →')} ${chalk_1.default.underline.gray(DOCS_
|
|
|
157
202
|
});
|
|
158
203
|
program
|
|
159
204
|
.command('init-native')
|
|
160
|
-
.
|
|
161
|
-
.
|
|
162
|
-
|
|
205
|
+
.option('--legacy', 'Use deterministic regex-based patching (no network)')
|
|
206
|
+
.description('Apply native changes (AppDelegate / MainApplication) automatically')
|
|
207
|
+
.action(async (options) => {
|
|
208
|
+
if (options.legacy) {
|
|
209
|
+
require('../CLI/scripts/init-native-config').initNativeConfig();
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
await require('../CLI/scripts/aipowered/init-native-config').initNativeConfigAi();
|
|
163
213
|
});
|
|
164
214
|
program
|
|
165
215
|
.command('init-metro')
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AiPatchPlan } from './types';
|
|
2
|
+
export type ApplyResult = {
|
|
3
|
+
backupDir: string;
|
|
4
|
+
changedFiles: string[];
|
|
5
|
+
};
|
|
6
|
+
export declare function restoreBackups(result: ApplyResult): void;
|
|
7
|
+
export declare function applyPatchPlans(params: {
|
|
8
|
+
projectRoot: string;
|
|
9
|
+
changes: AiPatchPlan[];
|
|
10
|
+
}): ApplyResult;
|
|
@@ -0,0 +1,50 @@
|
|
|
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.restoreBackups = restoreBackups;
|
|
7
|
+
exports.applyPatchPlans = applyPatchPlans;
|
|
8
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
9
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const validate_plan_1 = require("./validate-plan");
|
|
12
|
+
const sha256 = (content) => crypto_1.default.createHash('sha256').update(content).digest('hex');
|
|
13
|
+
const timestamp = () => new Date().toISOString().replace(/[:.]/g, '-');
|
|
14
|
+
function restoreBackups(result) {
|
|
15
|
+
for (const relative of result.changedFiles) {
|
|
16
|
+
const backupPath = path_1.default.join(result.backupDir, relative);
|
|
17
|
+
if (fs_extra_1.default.existsSync(backupPath)) {
|
|
18
|
+
fs_extra_1.default.copyFileSync(backupPath, path_1.default.resolve(result.backupDir, '..', '..', relative));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function applyPatchPlans(params) {
|
|
23
|
+
const backupDir = path_1.default.join(params.projectRoot, '.bundledrop-backup', timestamp());
|
|
24
|
+
const changedFiles = [];
|
|
25
|
+
const result = { backupDir, changedFiles };
|
|
26
|
+
try {
|
|
27
|
+
for (const change of params.changes) {
|
|
28
|
+
if (!(0, validate_plan_1.isSafeRelativePath)(change.file) || !(0, validate_plan_1.isPatchableNativeEntrypoint)(change.file)) {
|
|
29
|
+
throw new Error(`Refusing to write AI plan outside native entrypoints: ${change.file}`);
|
|
30
|
+
}
|
|
31
|
+
const targetPath = path_1.default.join(params.projectRoot, change.file);
|
|
32
|
+
const original = fs_extra_1.default.readFileSync(targetPath, 'utf8');
|
|
33
|
+
if (sha256(original) !== change.originalSha256) {
|
|
34
|
+
throw new Error(`File changed since AI scan: ${change.file}`);
|
|
35
|
+
}
|
|
36
|
+
const backupPath = path_1.default.join(backupDir, change.file);
|
|
37
|
+
fs_extra_1.default.ensureDirSync(path_1.default.dirname(backupPath));
|
|
38
|
+
fs_extra_1.default.copyFileSync(targetPath, backupPath);
|
|
39
|
+
changedFiles.push(change.file);
|
|
40
|
+
const tmpPath = `${targetPath}.bundledrop-tmp`;
|
|
41
|
+
fs_extra_1.default.writeFileSync(tmpPath, change.updated, 'utf8');
|
|
42
|
+
fs_extra_1.default.renameSync(tmpPath, targetPath);
|
|
43
|
+
}
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
restoreBackups(result);
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
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.requestAiInitPlan = requestAiInitPlan;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const DEFAULT_AI_INIT_TIMEOUT_MS = 180000;
|
|
9
|
+
const resolveTimeoutMs = () => {
|
|
10
|
+
const value = Number(process.env.BUNDLE_DROP_AI_INIT_TIMEOUT_MS || process.env.AI_INIT_TIMEOUT_MS || '');
|
|
11
|
+
return Number.isFinite(value) && value > 0 ? value : DEFAULT_AI_INIT_TIMEOUT_MS;
|
|
12
|
+
};
|
|
13
|
+
async function requestAiInitPlan(params) {
|
|
14
|
+
try {
|
|
15
|
+
const response = await axios_1.default.post(`${params.serverUrl}/ai/init-plan`, params.request, {
|
|
16
|
+
headers: {
|
|
17
|
+
Accept: 'application/json',
|
|
18
|
+
Authorization: `Bearer ${params.authToken}`,
|
|
19
|
+
},
|
|
20
|
+
timeout: resolveTimeoutMs(),
|
|
21
|
+
});
|
|
22
|
+
return response.data;
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
const raw = error?.response?.data;
|
|
26
|
+
if (error?.code === 'ECONNABORTED' || /timeout/i.test(String(error?.message || ''))) {
|
|
27
|
+
throw new Error('AI planning request timed out. The backend may still be waiting on OpenAI; try again, or set BUNDLE_DROP_AI_INIT_TIMEOUT_MS to a larger value.');
|
|
28
|
+
}
|
|
29
|
+
const message = raw && typeof raw === 'object'
|
|
30
|
+
? raw.error || JSON.stringify(raw)
|
|
31
|
+
: raw || error?.message || 'AI planning request failed';
|
|
32
|
+
throw new Error(`AI planning request failed: ${message}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
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.buildUnifiedDiff = buildUnifiedDiff;
|
|
7
|
+
exports.colorizeUnifiedDiff = colorizeUnifiedDiff;
|
|
8
|
+
const diff_1 = require("diff");
|
|
9
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
+
function buildUnifiedDiff(params) {
|
|
11
|
+
return params.changes
|
|
12
|
+
.map(change => {
|
|
13
|
+
const original = params.originals.get(change.file) ?? '';
|
|
14
|
+
return (0, diff_1.createTwoFilesPatch)(`a/${change.file}`, `b/${change.file}`, original, change.updated, '', '', { context: 3 });
|
|
15
|
+
})
|
|
16
|
+
.join('\n');
|
|
17
|
+
}
|
|
18
|
+
function colorizeUnifiedDiff(diff) {
|
|
19
|
+
return diff
|
|
20
|
+
.split('\n')
|
|
21
|
+
.map(line => {
|
|
22
|
+
if (line.startsWith('+++') || line.startsWith('---'))
|
|
23
|
+
return chalk_1.default.bold(line);
|
|
24
|
+
if (line.startsWith('+'))
|
|
25
|
+
return chalk_1.default.green(line);
|
|
26
|
+
if (line.startsWith('-'))
|
|
27
|
+
return chalk_1.default.red(line);
|
|
28
|
+
if (line.startsWith('@@'))
|
|
29
|
+
return chalk_1.default.cyan(line);
|
|
30
|
+
return line;
|
|
31
|
+
})
|
|
32
|
+
.join('\n');
|
|
33
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
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;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { AiScannerResult } from './types';
|
|
2
|
+
export declare const isSummaryOnlyAiContextFile: (relativePath: string) => boolean;
|
|
3
|
+
export declare const isTrustedAiPlanningServer: (serverUrl: string) => boolean;
|
|
4
|
+
export declare function findProjectRoot(startDir?: string): string;
|
|
5
|
+
export declare function scanProjectForAiNativeInit(startDir?: string): AiScannerResult;
|